$Config

Allows users to configure scripts

目前為 2024-07-13 提交的版本,檢視 最新版本

此腳本不應該直接安裝,它是一個供其他腳本使用的函式庫。欲使用本函式庫,請在腳本 metadata 寫上: // @require https://update.gf.qytechs.cn/scripts/446506/1410402/%24Config.js

  1. var $Config;
  2. /******/ (() => { // webpackBootstrap
  3. /******/ "use strict";
  4. /******/ var __webpack_modules__ = ({
  5.  
  6. /***/ "./ts/consts.ts":
  7. /*!**********************!*\
  8. !*** ./ts/consts.ts ***!
  9. \**********************/
  10. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  11.  
  12. __webpack_require__.r(__webpack_exports__);
  13. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  14. /* harmony export */ SOCKET_ID: () => (/* binding */ SOCKET_ID)
  15. /* harmony export */ });
  16. const SOCKET_ID = 'tree-frame';
  17.  
  18.  
  19. /***/ }),
  20.  
  21. /***/ "./ts/library/index.ts":
  22. /*!*****************************!*\
  23. !*** ./ts/library/index.ts ***!
  24. \*****************************/
  25. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  26.  
  27. __webpack_require__.r(__webpack_exports__);
  28. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  29. /* harmony export */ edit: () => (/* binding */ edit),
  30. /* harmony export */ init: () => (/* binding */ init),
  31. /* harmony export */ reset: () => (/* reexport safe */ _modal_body__WEBPACK_IMPORTED_MODULE_3__.reset)
  32. /* harmony export */ });
  33. /* harmony import */ var _validation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./validation */ "./ts/library/validation/index.ts");
  34. /* harmony import */ var _modal__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../modal */ "./ts/modal/index.ts");
  35. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../modal/css */ "./ts/modal/css.ts");
  36. /* harmony import */ var _modal_body__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../modal/body */ "./ts/modal/body/index.ts");
  37. /* harmony import */ var _modal_header_actions_close__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/modal/header/actions/close */ "./ts/modal/header/actions/close/index.ts");
  38. var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
  39. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  40. return new (P || (P = Promise))(function (resolve, reject) {
  41. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  42. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  43. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  44. step((generator = generator.apply(thisArg, _arguments || [])).next());
  45. });
  46. };
  47.  
  48.  
  49.  
  50.  
  51.  
  52. function init(config, socket) {
  53. var _a;
  54. return __awaiter(this, void 0, void 0, function* () {
  55. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.setRootId)(socket.id);
  56. try {
  57. yield (0,_validation__WEBPACK_IMPORTED_MODULE_0__["default"])(config);
  58. (0,_modal__WEBPACK_IMPORTED_MODULE_1__["default"])(config, socket);
  59. // Config is valid
  60. return {
  61. requireReset: false,
  62. tree: (_a = config.userTree) !== null && _a !== void 0 ? _a : config.defaultTree,
  63. };
  64. }
  65. catch (error) {
  66. if (typeof config !== 'object' || !(0,_validation__WEBPACK_IMPORTED_MODULE_0__.hasOwnProperty)(config, 'userTree')) {
  67. throw error;
  68. }
  69. delete config.userTree;
  70. yield (0,_validation__WEBPACK_IMPORTED_MODULE_0__["default"])(config);
  71. (0,_modal__WEBPACK_IMPORTED_MODULE_1__["default"])(config, socket);
  72. // Config is valid with userTree removed
  73. return {
  74. requireReset: true,
  75. tree: config.defaultTree,
  76. error,
  77. };
  78. }
  79. });
  80. }
  81. function edit() {
  82. (0,_modal__WEBPACK_IMPORTED_MODULE_1__.getSocket)().focus();
  83. return new Promise((resolve) => {
  84. (0,_modal_header_actions_close__WEBPACK_IMPORTED_MODULE_4__.setCallback)(resolve);
  85. });
  86. }
  87.  
  88.  
  89.  
  90. /***/ }),
  91.  
  92. /***/ "./ts/library/validation/errors.ts":
  93. /*!*****************************************!*\
  94. !*** ./ts/library/validation/errors.ts ***!
  95. \*****************************************/
  96. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  97.  
  98. __webpack_require__.r(__webpack_exports__);
  99. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  100. /* harmony export */ DeactivatedError: () => (/* binding */ DeactivatedError),
  101. /* harmony export */ EmptyArrayError: () => (/* binding */ EmptyArrayError),
  102. /* harmony export */ EmptyStringError: () => (/* binding */ EmptyStringError),
  103. /* harmony export */ FunctionMatchError: () => (/* binding */ FunctionMatchError),
  104. /* harmony export */ HangingOptionsError: () => (/* binding */ HangingOptionsError),
  105. /* harmony export */ HangingPredicateError: () => (/* binding */ HangingPredicateError),
  106. /* harmony export */ JoinedError: () => (/* binding */ JoinedError),
  107. /* harmony export */ NoNodeColourError: () => (/* binding */ NoNodeColourError),
  108. /* harmony export */ NonIntegerError: () => (/* binding */ NonIntegerError),
  109. /* harmony export */ OptionMatchError: () => (/* binding */ OptionMatchError),
  110. /* harmony export */ PoolBranchError: () => (/* binding */ PoolBranchError),
  111. /* harmony export */ PoolSizeError: () => (/* binding */ PoolSizeError),
  112. /* harmony export */ PredicateError: () => (/* binding */ PredicateError),
  113. /* harmony export */ PropertyError: () => (/* binding */ PropertyError),
  114. /* harmony export */ SeedMatchError: () => (/* binding */ SeedMatchError),
  115. /* harmony export */ TypeError: () => (/* binding */ TypeError),
  116. /* harmony export */ UnexpectedStateError: () => (/* binding */ UnexpectedStateError),
  117. /* harmony export */ ValueError: () => (/* binding */ ValueError)
  118. /* harmony export */ });
  119. // Helpers
  120. function getOptionString(array) {
  121. if (array.length === 0) {
  122. throw new Error('No valid options.');
  123. }
  124. if (array.length === 1) {
  125. return `'${array[0]}'`;
  126. }
  127. return `'${array.slice(0, -1).join('\', \'')}' or '${array[array.length - 1]}'`;
  128. }
  129. function getPath(breadcrumbs) {
  130. return `/${breadcrumbs.join('/')}`;
  131. }
  132. // Errors
  133. class JoinedError extends Error {
  134. constructor(...errors) {
  135. super(errors.map(({ message }) => message).join(JoinedError.separator));
  136. }
  137. }
  138. JoinedError.separator = '\n\n';
  139. class UnexpectedStateError extends Error {
  140. constructor() {
  141. super('Unexpected state reached.');
  142. }
  143. }
  144. class TypeError extends Error {
  145. constructor(breadcrumbs, found, expected) {
  146. super(`Found a value of type '${found}' at ${getPath(breadcrumbs)}. Expected ${getOptionString(expected)}.`);
  147. }
  148. }
  149. class PropertyError extends Error {
  150. constructor(breadcrumbs, property, shouldExist) {
  151. super(`${shouldExist ? 'Missing' : 'Unexpected'} property '${property}' found at ${getPath(breadcrumbs)}.`);
  152. }
  153. }
  154. class ValueError extends Error {
  155. constructor(breadcrumbs, found, expected) {
  156. super(`Found a value of '${found}' at ${getPath(breadcrumbs)}. Expected ${getOptionString(expected)}.`);
  157. }
  158. }
  159. class NonIntegerError extends Error {
  160. constructor(breadcrumbs) {
  161. super(`Found illegal non-integer at ${getPath(breadcrumbs)}.`);
  162. }
  163. }
  164. class EmptyStringError extends Error {
  165. constructor(breadcrumbs) {
  166. super(`Found illegal empty string at ${getPath(breadcrumbs)}.`);
  167. }
  168. }
  169. class EmptyArrayError extends Error {
  170. constructor(breadcrumbs) {
  171. super(`Found illegal empty array at ${getPath(breadcrumbs)}.`);
  172. }
  173. }
  174. class PredicateError extends Error {
  175. constructor(breadcrumbs) {
  176. super(`Predicate failed at ${getPath(breadcrumbs)}. Predicates must succeed.`);
  177. }
  178. }
  179. class SeedMatchError extends Error {
  180. constructor() {
  181. super('All children must be structurally similar to their parent\'s seed.');
  182. }
  183. }
  184. class PoolBranchError extends Error {
  185. constructor(ancestorBreadcrumbs, descendantBreadcrumbs, poolId) {
  186. super('No node may share a poolId value with its ancestor.' + JoinedError.separator
  187. + `Found poolId value ${poolId} at ${getPath(ancestorBreadcrumbs)} and ${getPath(descendantBreadcrumbs)}.`);
  188. }
  189. }
  190. class PoolSizeError extends Error {
  191. constructor(poolId, found, expected) {
  192. super('Corresponding pools in the default & candidate trees must be the same size unless a pool parent or ancestor has a seed value.' + JoinedError.separator
  193. + `Found a size of ${found} at pool ${poolId}. Expected a size of ${expected}.`);
  194. }
  195. }
  196. class FunctionMatchError extends Error {
  197. constructor() {
  198. super('Corresponding function values in seed & non-seed branches must be the same pointer.');
  199. }
  200. }
  201. class OptionMatchError extends Error {
  202. constructor() {
  203. super('Options must have the same type as their node\'s value.');
  204. }
  205. }
  206. class HangingOptionsError extends Error {
  207. constructor() {
  208. super('Nodes without a value may not have options.');
  209. }
  210. }
  211. class HangingPredicateError extends Error {
  212. constructor() {
  213. super('Nodes without a value may not have a predicate.');
  214. }
  215. }
  216. class DeactivatedError extends Error {
  217. constructor() {
  218. super('Nodes can\'t be deactivated unless their parent has a seed.');
  219. }
  220. }
  221. class NoNodeColourError extends Error {
  222. constructor() {
  223. super('If the node color property is included, at least one value must be defined.');
  224. }
  225. }
  226.  
  227.  
  228. /***/ }),
  229.  
  230. /***/ "./ts/library/validation/index.ts":
  231. /*!****************************************!*\
  232. !*** ./ts/library/validation/index.ts ***!
  233. \****************************************/
  234. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  235.  
  236. __webpack_require__.r(__webpack_exports__);
  237. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  238. /* harmony export */ "default": () => (/* export default binding */ __WEBPACK_DEFAULT_EXPORT__),
  239. /* harmony export */ hasOwnProperty: () => (/* binding */ hasOwnProperty),
  240. /* harmony export */ validateUnexpectedKeys: () => (/* binding */ validateUnexpectedKeys)
  241. /* harmony export */ });
  242. /* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./types */ "./ts/library/validation/types.ts");
  243. /* harmony import */ var _errors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./errors */ "./ts/library/validation/errors.ts");
  244. /* harmony import */ var _styles__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./styles */ "./ts/library/validation/styles.ts");
  245. /* harmony import */ var _trees_pools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./trees/pools */ "./ts/library/validation/trees/pools.ts");
  246. /* harmony import */ var _trees_guards__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./trees/guards */ "./ts/library/validation/trees/guards.ts");
  247. /* harmony import */ var _trees_match__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./trees/match */ "./ts/library/validation/trees/match.ts");
  248. /* harmony import */ var _trees_predicates__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./trees/predicates */ "./ts/library/validation/trees/predicates.ts");
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256. // Helpers
  257. // Credit to https://fettblog.eu/typescript-hasownproperty/
  258. function hasOwnProperty(object, property) {
  259. return Object.hasOwnProperty.call(object, property);
  260. }
  261. function validateUnexpectedKeys(breadcrumbs, object, expected) {
  262. for (const key of Object.keys(object)) {
  263. if (!expected.includes(key))
  264. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.PropertyError(breadcrumbs, key, false);
  265. }
  266. }
  267. // Guard
  268. function isConfig(candidate) {
  269. if (typeof candidate !== 'object')
  270. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([], typeof candidate, ['object']);
  271. validateUnexpectedKeys([], candidate, _types__WEBPACK_IMPORTED_MODULE_0__.CONFIG_KEYS);
  272. // title
  273. if (!hasOwnProperty(candidate, 'title'))
  274. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.PropertyError([], 'title', true);
  275. if (typeof candidate.title !== 'string')
  276. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError(['title'], typeof candidate.title, ['string']);
  277. // defaultStyle
  278. if (hasOwnProperty(candidate, 'defaultStyle')) {
  279. if (!(0,_styles__WEBPACK_IMPORTED_MODULE_2__.isStyles)(['defaultStyle'], candidate.defaultStyle))
  280. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.UnexpectedStateError();
  281. if (hasOwnProperty(candidate.defaultStyle, 'name'))
  282. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.PropertyError(['defaultStyle'], 'name', false);
  283. if (hasOwnProperty(candidate.defaultStyle, 'isActive'))
  284. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.PropertyError(['defaultStyle'], 'isActive', false);
  285. }
  286. // userStyles
  287. if (!hasOwnProperty(candidate, 'userStyles'))
  288. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.PropertyError([], 'userStyles', true);
  289. if (!Array.isArray(candidate.userStyles))
  290. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError(['userStyles'], typeof candidate.userStyles, ['array']);
  291. for (const [i, style] of candidate.userStyles.entries()) {
  292. if (!(0,_styles__WEBPACK_IMPORTED_MODULE_2__.isStyles)(['userStyles', i.toString()], style))
  293. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.UnexpectedStateError();
  294. if (!hasOwnProperty(style, 'name'))
  295. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.PropertyError(['userStyles', i.toString()], 'name', true);
  296. if (typeof style.name !== 'string')
  297. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError(['userStyles', i.toString(), 'name'], typeof style.name, ['string']);
  298. if (!hasOwnProperty(style, 'isActive'))
  299. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.PropertyError(['userStyles', i.toString()], 'isActive', true);
  300. if (typeof style.isActive !== 'boolean')
  301. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError(['userStyles', i.toString(), 'isActive'], typeof style.isActive, ['boolean']);
  302. }
  303. // defaultTree
  304. if (!hasOwnProperty(candidate, 'defaultTree') || !(0,_trees_guards__WEBPACK_IMPORTED_MODULE_4__.isRoot)(['defaultTree'], candidate.defaultTree))
  305. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.PropertyError([], 'defaultTree', true);
  306. // userTree
  307. if (hasOwnProperty(candidate, 'userTree') && !(0,_trees_guards__WEBPACK_IMPORTED_MODULE_4__.isRoot)(['userTree'], candidate.userTree, true))
  308. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.UnexpectedStateError();
  309. return true;
  310. }
  311. // Validator
  312. function validateConfig({ title, defaultTree, userTree }) {
  313. // title
  314. if (title.length === 0)
  315. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.EmptyStringError(['title']);
  316. // trees
  317. (0,_trees_match__WEBPACK_IMPORTED_MODULE_5__.validateSeeds)(['defaultTree'], defaultTree);
  318. (0,_trees_pools__WEBPACK_IMPORTED_MODULE_3__.validatePools)(['defaultTree'], defaultTree);
  319. if (userTree) {
  320. (0,_trees_match__WEBPACK_IMPORTED_MODULE_5__.matchUserTreeParent)(['defaultTree'], defaultTree, ['userTree'], userTree);
  321. // Has to be done after mutations since new pools may be created
  322. (0,_trees_match__WEBPACK_IMPORTED_MODULE_5__.validatePoolSizeMatch)(defaultTree, userTree);
  323. }
  324. return Promise.all((0,_trees_predicates__WEBPACK_IMPORTED_MODULE_6__.validateParent)(['defaultTree'], defaultTree));
  325. }
  326. // API
  327. /* harmony default export */ function __WEBPACK_DEFAULT_EXPORT__(candidate) {
  328. if (!isConfig(candidate))
  329. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.UnexpectedStateError();
  330. return validateConfig(candidate);
  331. }
  332.  
  333.  
  334. /***/ }),
  335.  
  336. /***/ "./ts/library/validation/styles.ts":
  337. /*!*****************************************!*\
  338. !*** ./ts/library/validation/styles.ts ***!
  339. \*****************************************/
  340. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  341.  
  342. __webpack_require__.r(__webpack_exports__);
  343. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  344. /* harmony export */ isStyles: () => (/* binding */ isStyles)
  345. /* harmony export */ });
  346. /* harmony import */ var _errors__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./errors */ "./ts/library/validation/errors.ts");
  347. /* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./types */ "./ts/library/validation/types.ts");
  348.  
  349.  
  350. function isStyles(breadcrumbs, candidate) {
  351. if (typeof candidate !== 'object')
  352. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.TypeError(breadcrumbs, typeof candidate, ['object']);
  353. if (Array.isArray(candidate))
  354. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.TypeError(breadcrumbs, 'array', ['object']);
  355. for (const [key, value] of Object.entries(candidate)) {
  356. switch (key) {
  357. // Colours
  358. case 'modalOutline':
  359. case 'headBase':
  360. case 'headButtonExit':
  361. case 'headButtonLabel':
  362. case 'headButtonStyle':
  363. case 'nodeButtonRemove':
  364. case 'nodeButtonCreate':
  365. case 'nodeButtonMove':
  366. case 'nodeButtonDisable':
  367. case 'validBackground':
  368. case 'invalidBackground':
  369. case 'tooltipOutline':
  370. if (typeof value !== 'string')
  371. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.TypeError([...breadcrumbs, key], typeof value, ['string']);
  372. break;
  373. // Numbers
  374. case 'fontSize':
  375. if (typeof value !== 'number')
  376. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.TypeError([...breadcrumbs, key], typeof value, ['number']);
  377. break;
  378. // Contrast methods
  379. case 'headContrast':
  380. case 'nodeContrast':
  381. if (typeof value !== 'string')
  382. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.TypeError([...breadcrumbs, key], typeof value, ['string']);
  383. if (!_types__WEBPACK_IMPORTED_MODULE_1__.CONTRAST_METHODS.includes(value))
  384. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.ValueError([...breadcrumbs, key], value, _types__WEBPACK_IMPORTED_MODULE_1__.CONTRAST_METHODS);
  385. break;
  386. // Booleans
  387. case 'isActive':
  388. case 'borderLeaf':
  389. case 'borderNode':
  390. if (typeof value !== 'boolean')
  391. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.TypeError([...breadcrumbs, key], typeof value, ['boolean']);
  392. break;
  393. case 'nodeBase':
  394. if (!Array.isArray(value))
  395. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.TypeError([...breadcrumbs, key], typeof value, ['array']);
  396. if (value.length === 0)
  397. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.JoinedError(new _errors__WEBPACK_IMPORTED_MODULE_0__.NoNodeColourError(), new _errors__WEBPACK_IMPORTED_MODULE_0__.EmptyArrayError([...breadcrumbs, key]));
  398. for (const [i, subValue] of value.entries()) {
  399. if (typeof subValue !== 'string')
  400. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.TypeError([...breadcrumbs, key, i.toString()], typeof subValue, ['string']);
  401. }
  402. break;
  403. }
  404. }
  405. return true;
  406. }
  407.  
  408.  
  409. /***/ }),
  410.  
  411. /***/ "./ts/library/validation/trees/guards.ts":
  412. /*!***********************************************!*\
  413. !*** ./ts/library/validation/trees/guards.ts ***!
  414. \***********************************************/
  415. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  416.  
  417. __webpack_require__.r(__webpack_exports__);
  418. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  419. /* harmony export */ isParent: () => (/* binding */ isParent),
  420. /* harmony export */ isRoot: () => (/* binding */ isRoot)
  421. /* harmony export */ });
  422. /* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../types */ "./ts/library/validation/types.ts");
  423. /* harmony import */ var _errors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../errors */ "./ts/library/validation/errors.ts");
  424. /* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../index */ "./ts/library/validation/index.ts");
  425.  
  426.  
  427.  
  428. // Type predicates
  429. function isChild(breadcrumbs, candidate, isUserTree = false) {
  430. if (typeof candidate !== 'object')
  431. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs], typeof candidate, ['object']);
  432. if (isUserTree) {
  433. (0,_index__WEBPACK_IMPORTED_MODULE_2__.validateUnexpectedKeys)(breadcrumbs, candidate, _types__WEBPACK_IMPORTED_MODULE_0__.SAVED_KEYS);
  434. }
  435. else {
  436. (0,_index__WEBPACK_IMPORTED_MODULE_2__.validateUnexpectedKeys)(breadcrumbs, candidate, 'children' in candidate ? _types__WEBPACK_IMPORTED_MODULE_0__.MIDDLE_KEYS : _types__WEBPACK_IMPORTED_MODULE_0__.LEAF_KEYS);
  437. }
  438. if ((0,_index__WEBPACK_IMPORTED_MODULE_2__.hasOwnProperty)(candidate, 'label') && typeof candidate.label !== 'string')
  439. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'label'], typeof candidate.label, ['string']);
  440. if ((0,_index__WEBPACK_IMPORTED_MODULE_2__.hasOwnProperty)(candidate, 'value') && !_types__WEBPACK_IMPORTED_MODULE_0__.VALUE_TYPES.includes(typeof candidate.value))
  441. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'value'], typeof candidate.value, _types__WEBPACK_IMPORTED_MODULE_0__.VALUE_TYPES);
  442. if ((0,_index__WEBPACK_IMPORTED_MODULE_2__.hasOwnProperty)(candidate, 'options')) {
  443. if (!Array.isArray(candidate.options))
  444. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'options'], typeof candidate.options, ['array']);
  445. for (const [i, option] of candidate.options.entries()) {
  446. if (!_types__WEBPACK_IMPORTED_MODULE_0__.VALUE_TYPES.includes(typeof option))
  447. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'options', i.toString()], typeof option, _types__WEBPACK_IMPORTED_MODULE_0__.VALUE_TYPES);
  448. }
  449. }
  450. if ((0,_index__WEBPACK_IMPORTED_MODULE_2__.hasOwnProperty)(candidate, 'predicate') && typeof candidate.predicate !== 'function')
  451. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'predicate'], typeof candidate.predicate, ['function']);
  452. if ((0,_index__WEBPACK_IMPORTED_MODULE_2__.hasOwnProperty)(candidate, 'onUpdate') && typeof candidate.onUpdate !== 'function')
  453. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'onUpdate'], typeof candidate.onUpdate, ['function']);
  454. if ((0,_index__WEBPACK_IMPORTED_MODULE_2__.hasOwnProperty)(candidate, 'input')) {
  455. if (typeof candidate.input !== 'string')
  456. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'input'], typeof candidate.input, ['string']);
  457. if (!_types__WEBPACK_IMPORTED_MODULE_0__.INPUT_FORMATS.includes(candidate.input))
  458. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.ValueError([...breadcrumbs, 'input'], candidate.input, _types__WEBPACK_IMPORTED_MODULE_0__.INPUT_FORMATS);
  459. }
  460. if ((0,_index__WEBPACK_IMPORTED_MODULE_2__.hasOwnProperty)(candidate, 'isActive') && typeof candidate.isActive !== 'boolean')
  461. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'isActive'], typeof candidate.isActive, ['boolean']);
  462. if ((0,_index__WEBPACK_IMPORTED_MODULE_2__.hasOwnProperty)(candidate, 'children') && !isParent(breadcrumbs, candidate, isUserTree))
  463. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.UnexpectedStateError();
  464. return true;
  465. }
  466. function isParent(breadcrumbs, candidate, isUserTree = false) {
  467. if (!(0,_index__WEBPACK_IMPORTED_MODULE_2__.hasOwnProperty)(candidate, 'children'))
  468. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.PropertyError(breadcrumbs, 'children', true);
  469. if (!Array.isArray(candidate.children))
  470. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'children'], typeof candidate.children, ['array']);
  471. if ((0,_index__WEBPACK_IMPORTED_MODULE_2__.hasOwnProperty)(candidate, 'seed') && !isChild([...breadcrumbs, 'seed'], candidate.seed))
  472. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.UnexpectedStateError();
  473. if ((0,_index__WEBPACK_IMPORTED_MODULE_2__.hasOwnProperty)(candidate, 'poolId') && typeof candidate.poolId !== 'number')
  474. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'poolId'], typeof candidate.poolId, ['number']);
  475. if ((0,_index__WEBPACK_IMPORTED_MODULE_2__.hasOwnProperty)(candidate, 'childPredicate') && typeof candidate.childPredicate !== 'function')
  476. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'childPredicate'], typeof candidate.childPredicate, ['function']);
  477. if ((0,_index__WEBPACK_IMPORTED_MODULE_2__.hasOwnProperty)(candidate, 'descendantPredicate') && typeof candidate.descendantPredicate !== 'function')
  478. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'descendantPredicate'], typeof candidate.descendantPredicate, ['function']);
  479. if ((0,_index__WEBPACK_IMPORTED_MODULE_2__.hasOwnProperty)(candidate, 'onChildUpdate') && typeof candidate.onChildUpdate !== 'function')
  480. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'onChildUpdate'], typeof candidate.onChildUpdate, ['function']);
  481. if ((0,_index__WEBPACK_IMPORTED_MODULE_2__.hasOwnProperty)(candidate, 'onDescendantUpdate') && typeof candidate.onDescendantUpdate !== 'function')
  482. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'onDescendantUpdate'], typeof candidate.onDescendantUpdate, ['function']);
  483. for (const [i, child] of candidate.children.entries()) {
  484. if (!isChild([...breadcrumbs, 'children', i.toString()], child, isUserTree))
  485. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.UnexpectedStateError();
  486. }
  487. return true;
  488. }
  489. function isRoot(breadcrumbs, candidate, isUserTree = false) {
  490. if (typeof candidate !== 'object')
  491. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError(breadcrumbs, typeof candidate, ['object']);
  492. if (!isParent(breadcrumbs, candidate, isUserTree))
  493. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.UnexpectedStateError();
  494. (0,_index__WEBPACK_IMPORTED_MODULE_2__.validateUnexpectedKeys)(breadcrumbs, candidate, _types__WEBPACK_IMPORTED_MODULE_0__.ROOT_KEYS);
  495. return true;
  496. }
  497.  
  498.  
  499. /***/ }),
  500.  
  501. /***/ "./ts/library/validation/trees/match.ts":
  502. /*!**********************************************!*\
  503. !*** ./ts/library/validation/trees/match.ts ***!
  504. \**********************************************/
  505. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  506.  
  507. __webpack_require__.r(__webpack_exports__);
  508. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  509. /* harmony export */ matchUserTreeParent: () => (/* binding */ matchUserTreeParent),
  510. /* harmony export */ validatePoolSizeMatch: () => (/* binding */ validatePoolSizeMatch),
  511. /* harmony export */ validateSeeds: () => (/* binding */ validateSeeds)
  512. /* harmony export */ });
  513. /* harmony import */ var _errors__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../errors */ "./ts/library/validation/errors.ts");
  514.  
  515. // Helpers
  516. function validateOptionMatch(modelBreadcrumbs, model, candidateBreadcrumbs, candidate) {
  517. if ('options' in model !== 'options' in candidate)
  518. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.PropertyError(candidateBreadcrumbs, 'options', 'options' in model);
  519. if ('options' in model) {
  520. if (model.options.length !== candidate.options.length)
  521. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.ValueError([...candidateBreadcrumbs, 'options', 'length'], candidate.options.length, [model.options.length]);
  522. for (const [i, option] of model.options.entries()) {
  523. if (candidate.options[i] !== option)
  524. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.ValueError([...candidateBreadcrumbs, 'options', i.toString()], candidate.options[i], [option]);
  525. }
  526. }
  527. }
  528. function validateValueMatch(property, modelBreadcrumbs, model, candidateBreadcrumbs, candidate) {
  529. if (property in model !== property in candidate)
  530. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.PropertyError(candidateBreadcrumbs, property, property in model);
  531. if (model[property] !== candidate[property])
  532. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.ValueError([...candidateBreadcrumbs, property], candidate[property], [model[property]]);
  533. }
  534. function assignKeys(from, to) {
  535. for (const key of Object.keys(from)) {
  536. if (!(key in to)) {
  537. to[key] = from[key];
  538. }
  539. }
  540. }
  541. // Consistent userTree validators/enforcers
  542. function matchUserTreeChild(modelBreadcrumbs, model, candidateBreadcrumbs, candidate) {
  543. if ('value' in model !== 'value' in candidate) {
  544. if ('value' in candidate)
  545. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.PropertyError(candidateBreadcrumbs, 'value', false);
  546. candidate.value = model.value;
  547. }
  548. else if (typeof model.value !== typeof candidate.value) {
  549. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.TypeError([...candidateBreadcrumbs, 'value'], typeof candidate.value, [typeof model.value]);
  550. }
  551. if ('label' in model) {
  552. candidate.label = model.label;
  553. }
  554. else {
  555. delete candidate.label;
  556. }
  557. if ('children' in model !== 'children' in candidate)
  558. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.PropertyError(candidateBreadcrumbs, 'children', 'children' in model);
  559. if ('children' in model) {
  560. matchUserTreeParent(modelBreadcrumbs, model, candidateBreadcrumbs, candidate);
  561. }
  562. else {
  563. assignKeys(model, candidate);
  564. }
  565. }
  566. function matchUserTreeParent(modelBreadcrumbs, model, candidateBreadcrumbs, candidate) {
  567. assignKeys(model, candidate);
  568. if ('seed' in model) {
  569. for (const [i, child] of candidate.children.entries()) {
  570. matchUserTreeChild([...modelBreadcrumbs, 'seed'], model.seed, [...candidateBreadcrumbs, 'children', i.toString()], child);
  571. }
  572. return;
  573. }
  574. if ('poolId' in model) {
  575. return;
  576. }
  577. if (model.children.length !== candidate.children.length)
  578. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.ValueError([...candidateBreadcrumbs, 'children', 'length'], candidate.children.length, [model.children.length]);
  579. for (const [i, child] of candidate.children.entries()) {
  580. matchUserTreeChild([...modelBreadcrumbs, 'children', i.toString()], model.children[i], [...candidateBreadcrumbs, 'children', i.toString()], child);
  581. }
  582. // Done after validation to avoid validating certain matches
  583. if (model.children.length > candidate.children.length) {
  584. candidate.children.push(...model.children.slice(candidate.children.length));
  585. }
  586. }
  587. // defaultTree internal consistency validators
  588. function validateChildMatch(modelBreadcrumbs, model, candidateBreadcrumbs, candidate) {
  589. if ('value' in model !== 'value' in candidate)
  590. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.PropertyError(candidateBreadcrumbs, 'value', 'value' in model);
  591. if (typeof model.value !== typeof candidate.value)
  592. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.TypeError([...candidateBreadcrumbs, 'value'], typeof candidate.value, [typeof model.value]);
  593. validateValueMatch('label', modelBreadcrumbs, model, candidateBreadcrumbs, candidate);
  594. validateValueMatch('input', modelBreadcrumbs, model, candidateBreadcrumbs, candidate);
  595. validateOptionMatch(modelBreadcrumbs, model, candidateBreadcrumbs, candidate);
  596. try {
  597. validateValueMatch('predicate', modelBreadcrumbs, model, candidateBreadcrumbs, candidate);
  598. validateValueMatch('onUpdate', modelBreadcrumbs, model, candidateBreadcrumbs, candidate);
  599. }
  600. catch (error) {
  601. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.JoinedError(new _errors__WEBPACK_IMPORTED_MODULE_0__.FunctionMatchError(), error);
  602. }
  603. if ('children' in model !== 'children' in candidate)
  604. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.PropertyError(candidateBreadcrumbs, 'children', 'children' in model);
  605. if ('children' in model) {
  606. validateParentMatch(modelBreadcrumbs, model, candidateBreadcrumbs, candidate);
  607. }
  608. }
  609. function validateParentMatch(modelBreadcrumbs, model, candidateBreadcrumbs, candidate) {
  610. validateValueMatch('poolId', modelBreadcrumbs, model, candidateBreadcrumbs, candidate);
  611. try {
  612. validateValueMatch('childPredicate', modelBreadcrumbs, model, candidateBreadcrumbs, candidate);
  613. validateValueMatch('onChildUpdate', modelBreadcrumbs, model, candidateBreadcrumbs, candidate);
  614. validateValueMatch('descendantPredicate', modelBreadcrumbs, model, candidateBreadcrumbs, candidate);
  615. validateValueMatch('onDescendantUpdate', modelBreadcrumbs, model, candidateBreadcrumbs, candidate);
  616. }
  617. catch (error) {
  618. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.JoinedError(new _errors__WEBPACK_IMPORTED_MODULE_0__.FunctionMatchError(), error);
  619. }
  620. if ('seed' in model) {
  621. validateChildMatch([...modelBreadcrumbs, 'seed'], model.seed, [...candidateBreadcrumbs, 'seed'], candidate.seed);
  622. for (const [i, child] of candidate.children.entries()) {
  623. validateChildMatch([...modelBreadcrumbs, 'seed'], model.seed, [...candidateBreadcrumbs, 'children', i.toString()], child);
  624. }
  625. }
  626. else if (!('poolId' in model)) {
  627. if (model.children.length !== candidate.children.length)
  628. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.ValueError([...candidateBreadcrumbs, 'children', 'length'], candidate.children.length, [model.children.length]);
  629. for (const [i, child] of candidate.children.entries()) {
  630. validateChildMatch([...modelBreadcrumbs, 'children', i.toString()], model.children[i], [...candidateBreadcrumbs, 'children', i.toString()], child);
  631. }
  632. if (model.children.length > candidate.children.length) {
  633. candidate.children.push(...model.children.slice(candidate.children.length));
  634. }
  635. }
  636. }
  637. // Other validators
  638. function validateSeeds(breadcrumbs, node) {
  639. if ('children' in node) {
  640. if ('seed' in node) {
  641. try {
  642. for (const [i, child] of node.children.entries()) {
  643. validateChildMatch([...breadcrumbs, 'seed'], node.seed, [...breadcrumbs, 'children', i.toString()], child);
  644. }
  645. }
  646. catch (error) {
  647. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.JoinedError(new _errors__WEBPACK_IMPORTED_MODULE_0__.SeedMatchError(), error);
  648. }
  649. validateSeeds([...breadcrumbs, 'seed'], node.seed);
  650. }
  651. else {
  652. for (const [i, child] of node.children.entries()) {
  653. if ('isActive' in child && !child.isActive) {
  654. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.JoinedError(new _errors__WEBPACK_IMPORTED_MODULE_0__.DeactivatedError(), new _errors__WEBPACK_IMPORTED_MODULE_0__.ValueError([...breadcrumbs, 'children', i.toString(), 'isActive'], false, [true]));
  655. }
  656. }
  657. }
  658. for (const [i, child] of node.children.entries()) {
  659. validateSeeds([...breadcrumbs, 'children', i.toString()], child);
  660. }
  661. }
  662. }
  663. function getPoolSizes(node, uncapped = false) {
  664. const poolSizes = [];
  665. uncapped = uncapped || 'seed' in node;
  666. if ('poolId' in node) {
  667. poolSizes[node.poolId] = uncapped ? -1 : node.children.length;
  668. }
  669. if ('children' in node) {
  670. for (const child of node.children) {
  671. const subPoolSizes = getPoolSizes(child, uncapped);
  672. for (const id in subPoolSizes) {
  673. if (subPoolSizes[id] < 0) {
  674. poolSizes[id] = -1;
  675. }
  676. else if (id in poolSizes) {
  677. poolSizes[id] += subPoolSizes[id];
  678. }
  679. else {
  680. poolSizes[id] = subPoolSizes[id];
  681. }
  682. }
  683. }
  684. }
  685. return poolSizes;
  686. }
  687. function validatePoolSizeMatch(model, candidate) {
  688. const modelSizes = getPoolSizes(model);
  689. const candidateSizes = getPoolSizes(candidate);
  690. for (const id in modelSizes) {
  691. if (modelSizes[id] !== candidateSizes[id])
  692. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.PoolSizeError(Number.parseInt(id), candidateSizes[id], modelSizes[id]);
  693. }
  694. }
  695.  
  696.  
  697. /***/ }),
  698.  
  699. /***/ "./ts/library/validation/trees/pools.ts":
  700. /*!**********************************************!*\
  701. !*** ./ts/library/validation/trees/pools.ts ***!
  702. \**********************************************/
  703. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  704.  
  705. __webpack_require__.r(__webpack_exports__);
  706. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  707. /* harmony export */ validatePools: () => (/* binding */ validatePools)
  708. /* harmony export */ });
  709. /* harmony import */ var _errors__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../errors */ "./ts/library/validation/errors.ts");
  710.  
  711. function validatePools(breadcrumbs, node, ancestorPools = []) {
  712. if ('poolId' in node) {
  713. if (node.poolId in ancestorPools)
  714. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.PoolBranchError(ancestorPools[node.poolId], breadcrumbs, node.poolId);
  715. // Slice maintains empty entries, so the 'in' operator still works
  716. ancestorPools = ancestorPools.slice();
  717. ancestorPools[node.poolId] = breadcrumbs;
  718. }
  719. if ('children' in node) {
  720. // Recurse
  721. for (const [i, child] of node.children.entries()) {
  722. validatePools([...breadcrumbs, 'children', i.toString()], child, ancestorPools);
  723. }
  724. }
  725. }
  726.  
  727.  
  728. /***/ }),
  729.  
  730. /***/ "./ts/library/validation/trees/predicates.ts":
  731. /*!***************************************************!*\
  732. !*** ./ts/library/validation/trees/predicates.ts ***!
  733. \***************************************************/
  734. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  735.  
  736. __webpack_require__.r(__webpack_exports__);
  737. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  738. /* harmony export */ validateParent: () => (/* binding */ validateParent)
  739. /* harmony export */ });
  740. /* harmony import */ var _errors__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../errors */ "./ts/library/validation/errors.ts");
  741. /* harmony import */ var _predicate__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../predicate */ "./ts/predicate.ts");
  742.  
  743.  
  744. function getBoundPredicatePromise(response, error) {
  745. return (0,_predicate__WEBPACK_IMPORTED_MODULE_1__.getPredicatePromise)(response)
  746. .catch(() => Promise.reject(error));
  747. }
  748. function validateChild(breadcrumbs, child) {
  749. if (!('options' in child) && !('predicate' in child))
  750. return Promise.resolve();
  751. if (!('value' in child))
  752. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.JoinedError(new ('predicate' in child ? _errors__WEBPACK_IMPORTED_MODULE_0__.HangingPredicateError : _errors__WEBPACK_IMPORTED_MODULE_0__.HangingOptionsError)(), new _errors__WEBPACK_IMPORTED_MODULE_0__.PropertyError(breadcrumbs, 'value', true));
  753. if ('options' in child) {
  754. const type = typeof child.value;
  755. let valueFound = false;
  756. for (const [i, option] of child.options.entries()) {
  757. if (typeof option !== type) {
  758. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.JoinedError(new _errors__WEBPACK_IMPORTED_MODULE_0__.OptionMatchError(), new _errors__WEBPACK_IMPORTED_MODULE_0__.TypeError([...breadcrumbs, 'options', i.toString()], typeof option, [type]));
  759. }
  760. valueFound || (valueFound = child.value === option);
  761. }
  762. if (valueFound)
  763. return Promise.resolve();
  764. }
  765. if ('predicate' in child)
  766. return getBoundPredicatePromise(child.predicate(child.value), new _errors__WEBPACK_IMPORTED_MODULE_0__.PredicateError([...breadcrumbs, 'predicate']));
  767. return Promise.reject();
  768. }
  769. function validateParent(breadcrumbs, parent) {
  770. const promises = [];
  771. if ('seed' in parent) {
  772. const { seed } = parent;
  773. promises.push(validateChild([...breadcrumbs, 'seed'], seed));
  774. if ('children' in seed) {
  775. promises.push(...validateParent([...breadcrumbs, 'seed'], seed));
  776. }
  777. }
  778. const { children } = parent;
  779. if ('poolId' in parent && Math.floor(parent.poolId) !== parent.poolId)
  780. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.NonIntegerError([...breadcrumbs, 'poolId']);
  781. if ('childPredicate' in parent) {
  782. promises.push(getBoundPredicatePromise(parent.childPredicate(children), new _errors__WEBPACK_IMPORTED_MODULE_0__.PredicateError([...breadcrumbs, 'childPredicate'])));
  783. }
  784. if ('descendantPredicate' in parent) {
  785. promises.push(getBoundPredicatePromise(parent.descendantPredicate(children), new _errors__WEBPACK_IMPORTED_MODULE_0__.PredicateError([...breadcrumbs, 'descendantPredicate'])));
  786. }
  787. for (const [i, child] of children.entries()) {
  788. const childBreadcrumbs = [...breadcrumbs, 'children', i.toString()];
  789. promises.push(validateChild(childBreadcrumbs, child));
  790. if ('children' in child) {
  791. promises.push(...validateParent(childBreadcrumbs, child));
  792. }
  793. }
  794. return promises;
  795. }
  796.  
  797.  
  798. /***/ }),
  799.  
  800. /***/ "./ts/library/validation/types.ts":
  801. /*!****************************************!*\
  802. !*** ./ts/library/validation/types.ts ***!
  803. \****************************************/
  804. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  805.  
  806. __webpack_require__.r(__webpack_exports__);
  807. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  808. /* harmony export */ CONFIG_KEYS: () => (/* binding */ CONFIG_KEYS),
  809. /* harmony export */ CONTRAST_METHODS: () => (/* binding */ CONTRAST_METHODS),
  810. /* harmony export */ INPUT_FORMATS: () => (/* binding */ INPUT_FORMATS),
  811. /* harmony export */ LEAF_KEYS: () => (/* binding */ LEAF_KEYS),
  812. /* harmony export */ MIDDLE_KEYS: () => (/* binding */ MIDDLE_KEYS),
  813. /* harmony export */ ROOT_KEYS: () => (/* binding */ ROOT_KEYS),
  814. /* harmony export */ ROOT_OTHER_KEYS: () => (/* binding */ ROOT_OTHER_KEYS),
  815. /* harmony export */ ROOT_PREDICATE_KEYS: () => (/* binding */ ROOT_PREDICATE_KEYS),
  816. /* harmony export */ ROOT_UPDATE_KEYS: () => (/* binding */ ROOT_UPDATE_KEYS),
  817. /* harmony export */ SAVED_KEYS: () => (/* binding */ SAVED_KEYS),
  818. /* harmony export */ VALUE_TYPES: () => (/* binding */ VALUE_TYPES)
  819. /* harmony export */ });
  820. // Basic types
  821. const VALUE_TYPES = ['boolean', 'number', 'string'];
  822. const INPUT_FORMATS = ['color', 'date', 'datetime-local', 'email', 'month', 'password', 'search', 'tel', 'text', 'time', 'url', 'week'];
  823. const CONTRAST_METHODS = ['Black / White', 'Invert'];
  824. // Key categories
  825. const SAVED_KEYS = ['label', 'value', 'isActive', 'children'];
  826. const ROOT_PREDICATE_KEYS = ['childPredicate', 'descendantPredicate'];
  827. const ROOT_UPDATE_KEYS = ['onChildUpdate', 'onDescendantUpdate'];
  828. const ROOT_OTHER_KEYS = ['children', 'seed', 'poolId'];
  829. // Node types
  830. const LEAF_KEYS = ['label', 'value', 'predicate', 'options', 'input', 'isActive', 'onUpdate'];
  831. const ROOT_KEYS = [...ROOT_PREDICATE_KEYS, ...ROOT_UPDATE_KEYS, ...ROOT_OTHER_KEYS];
  832. const MIDDLE_KEYS = [...LEAF_KEYS, ...ROOT_KEYS];
  833. // Config type
  834. const CONFIG_KEYS = ['title', 'defaultTree', 'userTree', 'defaultStyle', 'userStyles'];
  835.  
  836.  
  837. /***/ }),
  838.  
  839. /***/ "./ts/modal/body/consts.ts":
  840. /*!*********************************!*\
  841. !*** ./ts/modal/body/consts.ts ***!
  842. \*********************************/
  843. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  844.  
  845. __webpack_require__.r(__webpack_exports__);
  846. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  847. /* harmony export */ MODAL_BODY_ID: () => (/* binding */ MODAL_BODY_ID)
  848. /* harmony export */ });
  849. const MODAL_BODY_ID = 'modal-body';
  850.  
  851.  
  852. /***/ }),
  853.  
  854. /***/ "./ts/modal/body/css.ts":
  855. /*!******************************!*\
  856. !*** ./ts/modal/body/css.ts ***!
  857. \******************************/
  858. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  859.  
  860. __webpack_require__.r(__webpack_exports__);
  861. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  862. /* harmony export */ "default": () => (/* binding */ generate)
  863. /* harmony export */ });
  864. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/consts.ts");
  865. /* harmony import */ var _nodes_css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./nodes/css */ "./ts/modal/body/nodes/css.ts");
  866. /* harmony import */ var _nodes_actions_css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./nodes/actions/css */ "./ts/modal/body/nodes/actions/css.ts");
  867. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../css */ "./ts/modal/css.ts");
  868.  
  869.  
  870.  
  871.  
  872. function generate() {
  873. (0,_nodes_css__WEBPACK_IMPORTED_MODULE_1__["default"])();
  874. (0,_nodes_actions_css__WEBPACK_IMPORTED_MODULE_2__["default"])();
  875. (0,_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`#${_consts__WEBPACK_IMPORTED_MODULE_0__.MODAL_BODY_ID}`, [
  876. ['overflow-y', 'auto'],
  877. ['overscroll-behavior', 'contain'],
  878. ['background-color', `var(--nodeBase0)`],
  879. ['flex-grow', '1'],
  880. ]);
  881. }
  882.  
  883.  
  884. /***/ }),
  885.  
  886. /***/ "./ts/modal/body/data/consts.ts":
  887. /*!**************************************!*\
  888. !*** ./ts/modal/body/data/consts.ts ***!
  889. \**************************************/
  890. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  891.  
  892. __webpack_require__.r(__webpack_exports__);
  893. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  894. /* harmony export */ ROOT_ID: () => (/* binding */ ROOT_ID)
  895. /* harmony export */ });
  896. const ROOT_ID = 'root-data';
  897.  
  898.  
  899. /***/ }),
  900.  
  901. /***/ "./ts/modal/body/data/index.ts":
  902. /*!*************************************!*\
  903. !*** ./ts/modal/body/data/index.ts ***!
  904. \*************************************/
  905. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  906.  
  907. __webpack_require__.r(__webpack_exports__);
  908. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  909. /* harmony export */ "default": () => (/* binding */ generate),
  910. /* harmony export */ getRoot: () => (/* binding */ getRoot),
  911. /* harmony export */ setTree: () => (/* binding */ setTree)
  912. /* harmony export */ });
  913. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/data/consts.ts");
  914. /* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../index */ "./ts/modal/body/index.ts");
  915.  
  916.  
  917. function getRoot() {
  918. return _index__WEBPACK_IMPORTED_MODULE_1__.ROOTS[_consts__WEBPACK_IMPORTED_MODULE_0__.ROOT_ID];
  919. }
  920. function setTree(data) {
  921. const root = getRoot();
  922. // Spread avoids looping on a shrinking array
  923. for (const child of [...root.children]) {
  924. child.disconnect();
  925. }
  926. root.addChildren(data.children);
  927. }
  928. function generate(data) {
  929. return (0,_index__WEBPACK_IMPORTED_MODULE_1__.generateTree)(data, _consts__WEBPACK_IMPORTED_MODULE_0__.ROOT_ID);
  930. }
  931.  
  932.  
  933. /***/ }),
  934.  
  935. /***/ "./ts/modal/body/index.ts":
  936. /*!********************************!*\
  937. !*** ./ts/modal/body/index.ts ***!
  938. \********************************/
  939. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  940.  
  941. __webpack_require__.r(__webpack_exports__);
  942. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  943. /* harmony export */ ROOTS: () => (/* binding */ ROOTS),
  944. /* harmony export */ "default": () => (/* binding */ generate),
  945. /* harmony export */ element: () => (/* binding */ element),
  946. /* harmony export */ generateTree: () => (/* binding */ generateTree),
  947. /* harmony export */ reset: () => (/* binding */ reset),
  948. /* harmony export */ setActive: () => (/* binding */ setActive)
  949. /* harmony export */ });
  950. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/consts.ts");
  951. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./css */ "./ts/modal/body/css.ts");
  952. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./style */ "./ts/modal/body/style/index.ts");
  953. /* harmony import */ var _data__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./data */ "./ts/modal/body/data/index.ts");
  954. /* harmony import */ var _style_update__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./style/update */ "./ts/modal/body/style/update/index.ts");
  955. /* harmony import */ var _nodes_root__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./nodes/root */ "./ts/modal/body/nodes/root.ts");
  956. /* harmony import */ var _nodes_actions_highlight__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @nodes/actions/highlight */ "./ts/modal/body/nodes/actions/highlight/index.ts");
  957. /* harmony import */ var _nodes_actions_active__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @nodes/actions/active */ "./ts/modal/body/nodes/actions/active.ts");
  958. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../consts */ "./ts/modal/consts.ts");
  959.  
  960.  
  961.  
  962.  
  963.  
  964.  
  965.  
  966.  
  967.  
  968. const ROOTS = {};
  969. const element = document.createElement('div');
  970. let resetTree;
  971. function setActive(button, actionId, doActivate = true) {
  972. if (doActivate) {
  973. button.classList.add(_consts__WEBPACK_IMPORTED_MODULE_8__.BUTTON_ACTIVE_CLASS);
  974. element.classList.add(actionId);
  975. }
  976. else {
  977. button.classList.remove(_consts__WEBPACK_IMPORTED_MODULE_8__.BUTTON_ACTIVE_CLASS);
  978. element.classList.remove(actionId);
  979. }
  980. }
  981. function generateTree(data, id) {
  982. if (ROOTS[id]) {
  983. throw new Error(`Attempted to instantiate second tree with id '${id}'.`);
  984. }
  985. const root = new _nodes_root__WEBPACK_IMPORTED_MODULE_5__["default"](data);
  986. root.element.elementContainer.id = id;
  987. ROOTS[id] = root;
  988. return root.element.elementContainer;
  989. }
  990. function generate({ userTree, defaultTree, userStyles, defaultStyle }) {
  991. resetTree = defaultTree;
  992. (0,_style_update__WEBPACK_IMPORTED_MODULE_4__["default"])((0,_style__WEBPACK_IMPORTED_MODULE_2__.getActiveStyle)(userStyles, defaultStyle));
  993. (0,_css__WEBPACK_IMPORTED_MODULE_1__["default"])();
  994. element.id = _consts__WEBPACK_IMPORTED_MODULE_0__.MODAL_BODY_ID;
  995. element.append((0,_style__WEBPACK_IMPORTED_MODULE_2__["default"])(userStyles, defaultStyle), (0,_data__WEBPACK_IMPORTED_MODULE_3__["default"])(userTree !== null && userTree !== void 0 ? userTree : defaultTree));
  996. (0,_nodes_actions_highlight__WEBPACK_IMPORTED_MODULE_6__.onMount)();
  997. (0,_nodes_actions_active__WEBPACK_IMPORTED_MODULE_7__.onMount)();
  998. return element;
  999. }
  1000. function reset() {
  1001. (0,_data__WEBPACK_IMPORTED_MODULE_3__.setTree)(resetTree);
  1002. }
  1003.  
  1004.  
  1005. /***/ }),
  1006.  
  1007. /***/ "./ts/modal/body/nodes/actions/active.ts":
  1008. /*!***********************************************!*\
  1009. !*** ./ts/modal/body/nodes/actions/active.ts ***!
  1010. \***********************************************/
  1011. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1012.  
  1013. __webpack_require__.r(__webpack_exports__);
  1014. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1015. /* harmony export */ onMount: () => (/* binding */ onMount),
  1016. /* harmony export */ register: () => (/* binding */ register),
  1017. /* harmony export */ reset: () => (/* binding */ reset)
  1018. /* harmony export */ });
  1019. /* harmony import */ var _edit__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./edit */ "./ts/modal/body/nodes/actions/edit/index.ts");
  1020. /* harmony import */ var _highlight__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./highlight */ "./ts/modal/body/nodes/actions/highlight/index.ts");
  1021. /* harmony import */ var _focus__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./focus */ "./ts/modal/body/nodes/actions/focus/index.ts");
  1022. /* harmony import */ var _buttons_position__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./buttons/position */ "./ts/modal/body/nodes/actions/buttons/position/index.ts");
  1023. /* harmony import */ var _modal__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/modal */ "./ts/modal/index.ts");
  1024.  
  1025.  
  1026.  
  1027.  
  1028.  
  1029. function register() {
  1030. _edit__WEBPACK_IMPORTED_MODULE_0__.reset();
  1031. }
  1032. function reset() {
  1033. for (const action of [_edit__WEBPACK_IMPORTED_MODULE_0__, _buttons_position__WEBPACK_IMPORTED_MODULE_3__, _focus__WEBPACK_IMPORTED_MODULE_2__, _highlight__WEBPACK_IMPORTED_MODULE_1__]) {
  1034. if (action.isActive()) {
  1035. action.reset();
  1036. return true;
  1037. }
  1038. }
  1039. return false;
  1040. }
  1041. function onMount() {
  1042. (0,_modal__WEBPACK_IMPORTED_MODULE_4__.getSocket)().addEventListener('keydown', (event) => {
  1043. if (event.key === 'Escape' && reset()) {
  1044. event.stopPropagation();
  1045. }
  1046. });
  1047. }
  1048.  
  1049.  
  1050. /***/ }),
  1051.  
  1052. /***/ "./ts/modal/body/nodes/actions/buttons/button.ts":
  1053. /*!*******************************************************!*\
  1054. !*** ./ts/modal/body/nodes/actions/buttons/button.ts ***!
  1055. \*******************************************************/
  1056. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1057.  
  1058. __webpack_require__.r(__webpack_exports__);
  1059. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1060. /* harmony export */ addActionButton: () => (/* binding */ addActionButton),
  1061. /* harmony export */ getNewButton: () => (/* binding */ getNewButton)
  1062. /* harmony export */ });
  1063. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/buttons/consts.ts");
  1064. /* harmony import */ var _active__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../active */ "./ts/modal/body/nodes/actions/active.ts");
  1065. /* harmony import */ var _tooltip__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../tooltip */ "./ts/modal/body/nodes/actions/tooltip/index.ts");
  1066. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  1067. /* harmony import */ var _modal_header_actions_alternate__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/modal/header/actions/alternate */ "./ts/modal/header/actions/alternate/index.ts");
  1068.  
  1069.  
  1070.  
  1071.  
  1072.  
  1073. // Creates an instantiation & adds it to the DOM
  1074. function addActionButton(template, onClick, node) {
  1075. const button = template.cloneNode(true);
  1076. button.addEventListener('click', (event) => {
  1077. event.stopPropagation();
  1078. _active__WEBPACK_IMPORTED_MODULE_1__.register();
  1079. (0,_tooltip__WEBPACK_IMPORTED_MODULE_2__.kill)();
  1080. onClick(node, button, (0,_modal_header_actions_alternate__WEBPACK_IMPORTED_MODULE_4__.isActive)());
  1081. });
  1082. button.addEventListener('keydown', (event) => {
  1083. // Prevent button presses via the Enter key from triggering actions
  1084. if (event.key === 'Enter') {
  1085. event.stopPropagation();
  1086. }
  1087. });
  1088. button.addEventListener('mouseleave', () => {
  1089. button.blur();
  1090. });
  1091. node.element.addButton(button);
  1092. return button;
  1093. }
  1094. // Creates a template
  1095. const getNewButton = (function () {
  1096. const buttonTemplate = document.createElement('button');
  1097. buttonTemplate.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS);
  1098. // Prevent tabbing to buttons until node is focused
  1099. buttonTemplate.setAttribute('tabIndex', '-1');
  1100. const svgTemplate = (() => {
  1101. const circle = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_3__.SVG_NAMESPACE, 'circle');
  1102. circle.setAttribute('r', '50');
  1103. circle.setAttribute('stroke-width', '10');
  1104. const svg = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_3__.SVG_NAMESPACE, 'svg');
  1105. svg.setAttribute('viewBox', '-70 -70 140 140');
  1106. svg.append(circle);
  1107. return svg;
  1108. })();
  1109. return function (group, actionId, description) {
  1110. const button = buttonTemplate.cloneNode(true);
  1111. const svg = svgTemplate.cloneNode(true);
  1112. button.classList.add(actionId);
  1113. button.title = description;
  1114. svg.append(group);
  1115. button.append(svg);
  1116. return button;
  1117. };
  1118. })();
  1119.  
  1120.  
  1121. /***/ }),
  1122.  
  1123. /***/ "./ts/modal/body/nodes/actions/buttons/consts.ts":
  1124. /*!*******************************************************!*\
  1125. !*** ./ts/modal/body/nodes/actions/buttons/consts.ts ***!
  1126. \*******************************************************/
  1127. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1128.  
  1129. __webpack_require__.r(__webpack_exports__);
  1130. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1131. /* harmony export */ ALT_CLASS: () => (/* binding */ ALT_CLASS),
  1132. /* harmony export */ BUTTON_CLASS: () => (/* binding */ BUTTON_CLASS),
  1133. /* harmony export */ PROSPECTIVE_CLASS: () => (/* binding */ PROSPECTIVE_CLASS)
  1134. /* harmony export */ });
  1135. const BUTTON_CLASS = 'node-button';
  1136. const ALT_CLASS = 'node-icon-alt';
  1137. const PROSPECTIVE_CLASS = 'node-prospective';
  1138.  
  1139.  
  1140. /***/ }),
  1141.  
  1142. /***/ "./ts/modal/body/nodes/actions/buttons/create/button.ts":
  1143. /*!**************************************************************!*\
  1144. !*** ./ts/modal/body/nodes/actions/buttons/create/button.ts ***!
  1145. \**************************************************************/
  1146. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1147.  
  1148. __webpack_require__.r(__webpack_exports__);
  1149. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1150. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  1151. /* harmony export */ });
  1152. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/buttons/create/consts.ts");
  1153. /* harmony import */ var _position_button_alt__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../position/button/alt */ "./ts/modal/body/nodes/actions/buttons/position/button/alt.ts");
  1154. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  1155.  
  1156.  
  1157.  
  1158. const lineHorizontal = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'line');
  1159. lineHorizontal.setAttribute('stroke-linecap', 'round');
  1160. lineHorizontal.setAttribute('stroke-width', '12');
  1161. lineHorizontal.setAttribute('x1', '-25');
  1162. lineHorizontal.setAttribute('x2', '25');
  1163. const lineVertical = lineHorizontal.cloneNode(true);
  1164. lineVertical.setAttribute('transform', 'rotate(90)');
  1165. const g = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'g');
  1166. g.append(lineHorizontal, lineVertical);
  1167. const BUTTON = (0,_position_button_alt__WEBPACK_IMPORTED_MODULE_1__.getPositionedButton)(g, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, 'Create', { scale: '1 1.15' });
  1168. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (BUTTON);
  1169.  
  1170.  
  1171. /***/ }),
  1172.  
  1173. /***/ "./ts/modal/body/nodes/actions/buttons/create/consts.ts":
  1174. /*!**************************************************************!*\
  1175. !*** ./ts/modal/body/nodes/actions/buttons/create/consts.ts ***!
  1176. \**************************************************************/
  1177. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1178.  
  1179. __webpack_require__.r(__webpack_exports__);
  1180. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1181. /* harmony export */ ACTION_ID: () => (/* binding */ ACTION_ID)
  1182. /* harmony export */ });
  1183. const ACTION_ID = 'node-create';
  1184.  
  1185.  
  1186. /***/ }),
  1187.  
  1188. /***/ "./ts/modal/body/nodes/actions/buttons/create/css.ts":
  1189. /*!***********************************************************!*\
  1190. !*** ./ts/modal/body/nodes/actions/buttons/create/css.ts ***!
  1191. \***********************************************************/
  1192. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1193.  
  1194. __webpack_require__.r(__webpack_exports__);
  1195. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1196. /* harmony export */ "default": () => (/* binding */ generate)
  1197. /* harmony export */ });
  1198. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/buttons/create/consts.ts");
  1199. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../css */ "./ts/modal/body/nodes/actions/buttons/css.ts");
  1200.  
  1201.  
  1202. function generate() {
  1203. (0,_css__WEBPACK_IMPORTED_MODULE_1__.addColourRule)(_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, '--nodeButtonCreate');
  1204. }
  1205.  
  1206.  
  1207. /***/ }),
  1208.  
  1209. /***/ "./ts/modal/body/nodes/actions/buttons/create/index.ts":
  1210. /*!*************************************************************!*\
  1211. !*** ./ts/modal/body/nodes/actions/buttons/create/index.ts ***!
  1212. \*************************************************************/
  1213. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1214.  
  1215. __webpack_require__.r(__webpack_exports__);
  1216. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1217. /* harmony export */ mount: () => (/* binding */ mount),
  1218. /* harmony export */ shouldMount: () => (/* binding */ shouldMount)
  1219. /* harmony export */ });
  1220. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/buttons/create/consts.ts");
  1221. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button */ "./ts/modal/body/nodes/actions/buttons/create/button.ts");
  1222. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../consts */ "./ts/modal/body/nodes/actions/buttons/consts.ts");
  1223. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../button */ "./ts/modal/body/nodes/actions/buttons/button.ts");
  1224. /* harmony import */ var _position__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../position */ "./ts/modal/body/nodes/actions/buttons/position/index.ts");
  1225. /* harmony import */ var _edit__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../edit */ "./ts/modal/body/nodes/actions/edit/index.ts");
  1226. /* harmony import */ var _tooltip__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../tooltip */ "./ts/modal/body/nodes/actions/tooltip/index.ts");
  1227. /* harmony import */ var _nodes_middle__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @nodes/middle */ "./ts/modal/body/nodes/middle.ts");
  1228. /* harmony import */ var _nodes_child__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @nodes/child */ "./ts/modal/body/nodes/child.ts");
  1229.  
  1230.  
  1231.  
  1232.  
  1233.  
  1234.  
  1235.  
  1236.  
  1237.  
  1238. let activeNode;
  1239. function reset() {
  1240. if (!activeNode) {
  1241. return;
  1242. }
  1243. _position__WEBPACK_IMPORTED_MODULE_4__.reset();
  1244. activeNode = undefined;
  1245. }
  1246. function getChild(node) {
  1247. const { seed } = node;
  1248. const child = 'children' in seed ? new _nodes_middle__WEBPACK_IMPORTED_MODULE_7__["default"](seed, node, 0) : new _nodes_child__WEBPACK_IMPORTED_MODULE_8__["default"](seed, node, 0);
  1249. child.element.addClass(_consts__WEBPACK_IMPORTED_MODULE_2__.PROSPECTIVE_CLASS);
  1250. return child;
  1251. }
  1252. function doAction(source, parent, index, button, doScroll = true) {
  1253. const child = getChild(source);
  1254. child.move(parent, index);
  1255. Promise.all((0,_edit__WEBPACK_IMPORTED_MODULE_5__.getSubPredicateResponses)(child.getAncestors()))
  1256. .then(() => {
  1257. child.element.removeClass(_consts__WEBPACK_IMPORTED_MODULE_2__.PROSPECTIVE_CLASS);
  1258. child.isActive = true;
  1259. reset();
  1260. if (doScroll) {
  1261. // Show the new node
  1262. child.element.scrollIntoView();
  1263. }
  1264. (0,_edit__WEBPACK_IMPORTED_MODULE_5__.triggerSubUpdateCallbacks)(child.getAncestors());
  1265. })
  1266. .catch((reason) => {
  1267. child.disconnect();
  1268. if (reason) {
  1269. (0,_tooltip__WEBPACK_IMPORTED_MODULE_6__.show)(reason, button);
  1270. }
  1271. });
  1272. }
  1273. function onClick(node, button, isAlt) {
  1274. const previousNode = activeNode;
  1275. reset();
  1276. if (!isAlt) {
  1277. doAction(node, node, 0, button, false);
  1278. }
  1279. else if (!previousNode || node !== previousNode) {
  1280. activeNode = node;
  1281. _position__WEBPACK_IMPORTED_MODULE_4__.mount(node, node.seed, node, node.children, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, button, doAction, false);
  1282. }
  1283. }
  1284. function mount(node) {
  1285. (0,_button__WEBPACK_IMPORTED_MODULE_3__.addActionButton)(_button__WEBPACK_IMPORTED_MODULE_1__["default"], onClick, node);
  1286. }
  1287. function shouldMount(node) {
  1288. return 'seed' in node;
  1289. }
  1290.  
  1291.  
  1292. /***/ }),
  1293.  
  1294. /***/ "./ts/modal/body/nodes/actions/buttons/css.ts":
  1295. /*!****************************************************!*\
  1296. !*** ./ts/modal/body/nodes/actions/buttons/css.ts ***!
  1297. \****************************************************/
  1298. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1299.  
  1300. __webpack_require__.r(__webpack_exports__);
  1301. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1302. /* harmony export */ addColourRule: () => (/* binding */ addColourRule),
  1303. /* harmony export */ "default": () => (/* binding */ generate)
  1304. /* harmony export */ });
  1305. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/buttons/consts.ts");
  1306. /* harmony import */ var _create_css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./create/css */ "./ts/modal/body/nodes/actions/buttons/create/css.ts");
  1307. /* harmony import */ var _move_css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./move/css */ "./ts/modal/body/nodes/actions/buttons/move/css.ts");
  1308. /* harmony import */ var _disable_css__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./disable/css */ "./ts/modal/body/nodes/actions/buttons/disable/css.ts");
  1309. /* harmony import */ var _duplicate_css__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./duplicate/css */ "./ts/modal/body/nodes/actions/buttons/duplicate/css.ts");
  1310. /* harmony import */ var _position_css__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./position/css */ "./ts/modal/body/nodes/actions/buttons/position/css.ts");
  1311. /* harmony import */ var _highlight_consts__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../highlight/consts */ "./ts/modal/body/nodes/actions/highlight/consts.ts");
  1312. /* harmony import */ var _nodes_consts__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @nodes/consts */ "./ts/modal/body/nodes/consts.ts");
  1313. /* harmony import */ var _modal_body_style_update_depth__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @/modal/body/style/update/depth */ "./ts/modal/body/style/update/depth.ts");
  1314. /* harmony import */ var _modal_header_actions_alternate_consts__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! @/modal/header/actions/alternate/consts */ "./ts/modal/header/actions/alternate/consts.ts");
  1315. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  1316. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  1317.  
  1318.  
  1319.  
  1320.  
  1321.  
  1322.  
  1323.  
  1324.  
  1325.  
  1326.  
  1327.  
  1328.  
  1329. function addColourRule(actionId, strokeVar) {
  1330. (0,_modal_css__WEBPACK_IMPORTED_MODULE_11__.addRule)([
  1331. `.${_nodes_consts__WEBPACK_IMPORTED_MODULE_7__.ELEMENT_CLASSES.ELEMENT_CONTAINER}:not(.${_highlight_consts__WEBPACK_IMPORTED_MODULE_6__.HIGHLIGHT_CLASS}) > `
  1332. + `.${_nodes_consts__WEBPACK_IMPORTED_MODULE_7__.ELEMENT_CLASSES.HEAD_CONTAINER} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_7__.ELEMENT_CLASSES.BUTTON_CONTAINER} > `
  1333. + `.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}.${actionId} > svg`,
  1334. ], ['fill', `var(${strokeVar})`]);
  1335. (0,_modal_css__WEBPACK_IMPORTED_MODULE_11__.addRule)(`.${_highlight_consts__WEBPACK_IMPORTED_MODULE_6__.HIGHLIGHT_CLASS} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_7__.ELEMENT_CLASSES.HEAD_CONTAINER} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_7__.ELEMENT_CLASSES.BUTTON_CONTAINER} > `
  1336. + `.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}.${actionId}.${_modal_consts__WEBPACK_IMPORTED_MODULE_10__.BUTTON_ACTIVE_CLASS} > svg > g`, ['stroke', `var(${strokeVar})`]);
  1337. (0,_modal_css__WEBPACK_IMPORTED_MODULE_11__.addRule)([
  1338. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}.${actionId}.${_modal_consts__WEBPACK_IMPORTED_MODULE_10__.BUTTON_ACTIVE_CLASS}:hover > svg > circle`,
  1339. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}.${actionId}.${_modal_consts__WEBPACK_IMPORTED_MODULE_10__.BUTTON_ACTIVE_CLASS}:focus > svg > circle`,
  1340. ], ['stroke', `var(${strokeVar})`]);
  1341. }
  1342. function generate() {
  1343. (0,_create_css__WEBPACK_IMPORTED_MODULE_1__["default"])();
  1344. (0,_move_css__WEBPACK_IMPORTED_MODULE_2__["default"])();
  1345. (0,_disable_css__WEBPACK_IMPORTED_MODULE_3__["default"])();
  1346. (0,_duplicate_css__WEBPACK_IMPORTED_MODULE_4__["default"])();
  1347. (0,_position_css__WEBPACK_IMPORTED_MODULE_5__["default"])();
  1348. (0,_modal_css__WEBPACK_IMPORTED_MODULE_11__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}`, [
  1349. ['height', '100%'],
  1350. ['position', 'relative'],
  1351. ]);
  1352. (0,_modal_css__WEBPACK_IMPORTED_MODULE_11__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS} > svg`, [
  1353. ['height', '100%'],
  1354. ['transform', 'scale(1.05)'],
  1355. ]);
  1356. (0,_modal_css__WEBPACK_IMPORTED_MODULE_11__.addRule)(`.${_nodes_consts__WEBPACK_IMPORTED_MODULE_7__.ELEMENT_CLASSES.BUTTON_CONTAINER}`, [
  1357. ['white-space', 'nowrap'],
  1358. ['z-index', '1'],
  1359. ]);
  1360. // Hide prospective nodes
  1361. (0,_modal_css__WEBPACK_IMPORTED_MODULE_11__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.PROSPECTIVE_CLASS}`, ['display', 'none']);
  1362. // Hide alt icon components
  1363. (0,_modal_css__WEBPACK_IMPORTED_MODULE_11__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ALT_CLASS}:not(.${_modal_header_actions_alternate_consts__WEBPACK_IMPORTED_MODULE_9__.ACTION_ID} *)`, ['display', 'none']);
  1364. (0,_modal_css__WEBPACK_IMPORTED_MODULE_11__.addRule)(`.${_modal_header_actions_alternate_consts__WEBPACK_IMPORTED_MODULE_9__.ACTION_ID} button.${_consts__WEBPACK_IMPORTED_MODULE_0__.ALT_CLASS} + *`, ['display', 'none']);
  1365. (0,_modal_body_style_update_depth__WEBPACK_IMPORTED_MODULE_8__.addDepthChangeListener)((depth, addRule) => {
  1366. const depthSelector = `.${_nodes_consts__WEBPACK_IMPORTED_MODULE_7__.DEPTH_CLASS_PREFIX}${depth} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_7__.ELEMENT_CLASSES.HEAD_CONTAINER} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_7__.ELEMENT_CLASSES.BUTTON_CONTAINER}`;
  1367. addRule(`.${_nodes_consts__WEBPACK_IMPORTED_MODULE_7__.ELEMENT_CLASSES.ELEMENT_CONTAINER}.${_highlight_consts__WEBPACK_IMPORTED_MODULE_6__.HIGHLIGHT_CLASS}${depthSelector} > `
  1368. + `.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}:not(.${_modal_consts__WEBPACK_IMPORTED_MODULE_10__.BUTTON_ACTIVE_CLASS}):not(:focus):not(:hover) > svg > g`, ['stroke', `var(--nodeBase${depth})`]);
  1369. addRule(`${depthSelector} > .${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}:not(.${_modal_consts__WEBPACK_IMPORTED_MODULE_10__.BUTTON_ACTIVE_CLASS}:hover):not(.${_modal_consts__WEBPACK_IMPORTED_MODULE_10__.BUTTON_ACTIVE_CLASS}:focus) > svg > circle`, ['stroke', `var(--nodeBase${depth})`]);
  1370. addRule([
  1371. // Not active, focused
  1372. `${depthSelector} > .${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}:focus > svg > g`,
  1373. `${depthSelector} > .${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}:hover > svg > g`,
  1374. ], [['stroke', `var(--nodeContrast${depth})`]]);
  1375. addRule([`${depthSelector} > .${_modal_consts__WEBPACK_IMPORTED_MODULE_10__.BUTTON_ACTIVE_CLASS} > svg`], [['stroke', `var(--nodeBase${depth})`]]);
  1376. addRule([
  1377. // Not active, focused
  1378. `${depthSelector} > .${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}:focus > svg`,
  1379. `${depthSelector} > .${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}:hover > svg`,
  1380. `.${_highlight_consts__WEBPACK_IMPORTED_MODULE_6__.HIGHLIGHT_CLASS}${depthSelector} > .${_modal_consts__WEBPACK_IMPORTED_MODULE_10__.BUTTON_ACTIVE_CLASS} > svg`,
  1381. ], [['fill', `var(--nodeBase${depth})`]]);
  1382. });
  1383. }
  1384.  
  1385.  
  1386. /***/ }),
  1387.  
  1388. /***/ "./ts/modal/body/nodes/actions/buttons/disable/button.ts":
  1389. /*!***************************************************************!*\
  1390. !*** ./ts/modal/body/nodes/actions/buttons/disable/button.ts ***!
  1391. \***************************************************************/
  1392. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1393.  
  1394. __webpack_require__.r(__webpack_exports__);
  1395. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1396. /* harmony export */ BUTTON_ALT: () => (/* binding */ BUTTON_ALT),
  1397. /* harmony export */ BUTTON_DEFAULT: () => (/* binding */ BUTTON_DEFAULT)
  1398. /* harmony export */ });
  1399. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/buttons/disable/consts.ts");
  1400. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../consts */ "./ts/modal/body/nodes/actions/buttons/consts.ts");
  1401. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../button */ "./ts/modal/body/nodes/actions/buttons/button.ts");
  1402. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  1403.  
  1404.  
  1405.  
  1406.  
  1407. const gDefault = (() => {
  1408. const circle = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_3__.SVG_NAMESPACE, 'circle');
  1409. circle.setAttribute('r', '30');
  1410. circle.setAttribute('stroke-width', '10');
  1411. const line = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_3__.SVG_NAMESPACE, 'line');
  1412. line.setAttribute('stroke-linecap', 'round');
  1413. line.setAttribute('stroke-width', '10');
  1414. line.setAttribute('x1', '-30');
  1415. line.setAttribute('x2', '30');
  1416. line.setAttribute('transform', 'rotate(45)');
  1417. const g = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_3__.SVG_NAMESPACE, 'g');
  1418. g.append(circle, line);
  1419. return g;
  1420. })();
  1421. const BUTTON_DEFAULT = (0,_button__WEBPACK_IMPORTED_MODULE_2__.getNewButton)(gDefault, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID_DEFAULT, 'Toggle Enabled');
  1422. const gAlt = (() => {
  1423. const line0 = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_3__.SVG_NAMESPACE, 'line');
  1424. line0.setAttribute('stroke-linecap', 'round');
  1425. line0.setAttribute('stroke-width', '12');
  1426. line0.setAttribute('x1', '-20');
  1427. line0.setAttribute('x2', '20');
  1428. line0.setAttribute('y1', '-20');
  1429. line0.setAttribute('y2', '20');
  1430. const line1 = line0.cloneNode(true);
  1431. line1.setAttribute('transform', 'rotate(90)');
  1432. const g = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_3__.SVG_NAMESPACE, 'g');
  1433. g.append(line0, line1);
  1434. return g;
  1435. })();
  1436. const BUTTON_ALT = (0,_button__WEBPACK_IMPORTED_MODULE_2__.getNewButton)(gAlt, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID_ALT, 'Delete');
  1437. BUTTON_ALT.classList.add(_consts__WEBPACK_IMPORTED_MODULE_1__.ALT_CLASS);
  1438.  
  1439.  
  1440. /***/ }),
  1441.  
  1442. /***/ "./ts/modal/body/nodes/actions/buttons/disable/consts.ts":
  1443. /*!***************************************************************!*\
  1444. !*** ./ts/modal/body/nodes/actions/buttons/disable/consts.ts ***!
  1445. \***************************************************************/
  1446. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1447.  
  1448. __webpack_require__.r(__webpack_exports__);
  1449. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1450. /* harmony export */ ACTION_ID_ALT: () => (/* binding */ ACTION_ID_ALT),
  1451. /* harmony export */ ACTION_ID_DEFAULT: () => (/* binding */ ACTION_ID_DEFAULT),
  1452. /* harmony export */ DISABLED_CLASS: () => (/* binding */ DISABLED_CLASS)
  1453. /* harmony export */ });
  1454. const ACTION_ID_DEFAULT = 'node-active';
  1455. const ACTION_ID_ALT = 'node-delete';
  1456. const DISABLED_CLASS = 'node-disable';
  1457.  
  1458.  
  1459. /***/ }),
  1460.  
  1461. /***/ "./ts/modal/body/nodes/actions/buttons/disable/css.ts":
  1462. /*!************************************************************!*\
  1463. !*** ./ts/modal/body/nodes/actions/buttons/disable/css.ts ***!
  1464. \************************************************************/
  1465. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1466.  
  1467. __webpack_require__.r(__webpack_exports__);
  1468. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1469. /* harmony export */ "default": () => (/* binding */ generate)
  1470. /* harmony export */ });
  1471. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/buttons/disable/consts.ts");
  1472. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../css */ "./ts/modal/body/nodes/actions/buttons/css.ts");
  1473. /* harmony import */ var _highlight_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../highlight/consts */ "./ts/modal/body/nodes/actions/highlight/consts.ts");
  1474. /* harmony import */ var _nodes_consts__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @nodes/consts */ "./ts/modal/body/nodes/consts.ts");
  1475. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  1476.  
  1477.  
  1478.  
  1479.  
  1480.  
  1481. function generate() {
  1482. (0,_css__WEBPACK_IMPORTED_MODULE_1__.addColourRule)(_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID_DEFAULT, '--nodeButtonDisable');
  1483. (0,_css__WEBPACK_IMPORTED_MODULE_1__.addColourRule)(_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID_ALT, '--nodeButtonDelete');
  1484. (0,_modal_css__WEBPACK_IMPORTED_MODULE_4__.addRule)([
  1485. // Self selectors
  1486. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.DISABLED_CLASS}:not(.${_highlight_consts__WEBPACK_IMPORTED_MODULE_2__.HIGHLIGHT_CLASS}) > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_3__.ELEMENT_CLASSES.HEAD_CONTAINER} .${_nodes_consts__WEBPACK_IMPORTED_MODULE_3__.ELEMENT_CLASSES.VALUE_CONTAINER}`,
  1487. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.DISABLED_CLASS}:not(.${_highlight_consts__WEBPACK_IMPORTED_MODULE_2__.HIGHLIGHT_CLASS}) > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_3__.ELEMENT_CLASSES.HEAD_CONTAINER} .${_nodes_consts__WEBPACK_IMPORTED_MODULE_3__.ELEMENT_CLASSES.LABEL_CONTAINER}`,
  1488. // Descendant selectors
  1489. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.DISABLED_CLASS} :not(.${_highlight_consts__WEBPACK_IMPORTED_MODULE_2__.HIGHLIGHT_CLASS}) > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_3__.ELEMENT_CLASSES.HEAD_CONTAINER} .${_nodes_consts__WEBPACK_IMPORTED_MODULE_3__.ELEMENT_CLASSES.VALUE_CONTAINER}`,
  1490. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.DISABLED_CLASS} :not(.${_highlight_consts__WEBPACK_IMPORTED_MODULE_2__.HIGHLIGHT_CLASS}) > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_3__.ELEMENT_CLASSES.HEAD_CONTAINER} .${_nodes_consts__WEBPACK_IMPORTED_MODULE_3__.ELEMENT_CLASSES.LABEL_CONTAINER}`,
  1491. ], ['opacity', '0.5']);
  1492. }
  1493.  
  1494.  
  1495. /***/ }),
  1496.  
  1497. /***/ "./ts/modal/body/nodes/actions/buttons/disable/index.ts":
  1498. /*!**************************************************************!*\
  1499. !*** ./ts/modal/body/nodes/actions/buttons/disable/index.ts ***!
  1500. \**************************************************************/
  1501. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1502.  
  1503. __webpack_require__.r(__webpack_exports__);
  1504. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1505. /* harmony export */ mount: () => (/* binding */ mount),
  1506. /* harmony export */ shouldMount: () => (/* binding */ shouldMount)
  1507. /* harmony export */ });
  1508. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/buttons/disable/consts.ts");
  1509. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button */ "./ts/modal/body/nodes/actions/buttons/disable/button.ts");
  1510. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../button */ "./ts/modal/body/nodes/actions/buttons/button.ts");
  1511. /* harmony import */ var _edit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../edit */ "./ts/modal/body/nodes/actions/edit/index.ts");
  1512. /* harmony import */ var _tooltip__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../tooltip */ "./ts/modal/body/nodes/actions/tooltip/index.ts");
  1513. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  1514.  
  1515.  
  1516.  
  1517.  
  1518.  
  1519.  
  1520. function updateButton(button, isActive) {
  1521. button.classList[isActive ? 'remove' : 'add'](_modal_consts__WEBPACK_IMPORTED_MODULE_5__.BUTTON_ACTIVE_CLASS);
  1522. }
  1523. function toggle(node) {
  1524. node.element[`${node.isActive ? 'add' : 'remove'}Class`](_consts__WEBPACK_IMPORTED_MODULE_0__.DISABLED_CLASS);
  1525. node.isActive = !node.isActive;
  1526. }
  1527. function onClick(node, button, isAlt) {
  1528. toggle(node);
  1529. Promise.all((0,_edit__WEBPACK_IMPORTED_MODULE_3__.getSubPredicateResponses)(node.getAncestors()))
  1530. .then(() => {
  1531. const ancestors = node.getAncestors();
  1532. if (isAlt) {
  1533. // TODO set up a way to confirm (tooltip + yes/no buttons? require extra button click?)
  1534. node.disconnect();
  1535. }
  1536. else {
  1537. updateButton(button, node.isActive);
  1538. }
  1539. (0,_edit__WEBPACK_IMPORTED_MODULE_3__.triggerSubUpdateCallbacks)(ancestors);
  1540. })
  1541. .catch((reason) => {
  1542. toggle(node);
  1543. if (typeof reason === 'string') {
  1544. _tooltip__WEBPACK_IMPORTED_MODULE_4__.show(reason, button);
  1545. }
  1546. });
  1547. }
  1548. function mount(node) {
  1549. (0,_button__WEBPACK_IMPORTED_MODULE_2__.addActionButton)(_button__WEBPACK_IMPORTED_MODULE_1__.BUTTON_ALT, onClick, node);
  1550. const defaultButton = (0,_button__WEBPACK_IMPORTED_MODULE_2__.addActionButton)(_button__WEBPACK_IMPORTED_MODULE_1__.BUTTON_DEFAULT, onClick, node);
  1551. if (!node.isActive) {
  1552. node.element.addClass(_consts__WEBPACK_IMPORTED_MODULE_0__.DISABLED_CLASS);
  1553. updateButton(defaultButton, false);
  1554. }
  1555. }
  1556. function shouldMount(node) {
  1557. return 'seed' in node.parent;
  1558. }
  1559.  
  1560.  
  1561. /***/ }),
  1562.  
  1563. /***/ "./ts/modal/body/nodes/actions/buttons/duplicate/button.ts":
  1564. /*!*****************************************************************!*\
  1565. !*** ./ts/modal/body/nodes/actions/buttons/duplicate/button.ts ***!
  1566. \*****************************************************************/
  1567. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1568.  
  1569. __webpack_require__.r(__webpack_exports__);
  1570. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1571. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  1572. /* harmony export */ });
  1573. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/buttons/duplicate/consts.ts");
  1574. /* harmony import */ var _position_button_alt__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../position/button/alt */ "./ts/modal/body/nodes/actions/buttons/position/button/alt.ts");
  1575. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  1576.  
  1577.  
  1578.  
  1579. const RADIUS = 15;
  1580. const HEIGHT = 25;
  1581. const WIDTH = 10;
  1582. const outline0 = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'path');
  1583. outline0.setAttribute('stroke-linecap', 'round');
  1584. outline0.setAttribute('stroke-width', '8');
  1585. outline0.setAttribute('fill', 'none');
  1586. outline0.setAttribute('d', `M ${WIDTH / 2 + RADIUS} ${-HEIGHT / 2}`
  1587. + `q 0,-${RADIUS} -${RADIUS},-${RADIUS}`
  1588. + `h -${WIDTH}`
  1589. + `q -${RADIUS},0 -${RADIUS},${RADIUS}`
  1590. + `v ${HEIGHT}`
  1591. + `q 0,${RADIUS} ${RADIUS},${RADIUS}`);
  1592. outline0.setAttribute('transform', `translate(-${RADIUS / 2}, -${RADIUS / 2})`);
  1593. const outline1 = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'path');
  1594. outline1.setAttribute('stroke-linecap', 'round');
  1595. outline1.setAttribute('stroke-width', '8');
  1596. outline1.setAttribute('fill', 'none');
  1597. outline1.setAttribute('d', `M ${WIDTH / 2 + RADIUS} ${-HEIGHT / 2}`
  1598. + `q 0,-${RADIUS} -${RADIUS},-${RADIUS}`
  1599. + `h -${WIDTH}`
  1600. + `q -${RADIUS},0 -${RADIUS},${RADIUS}`
  1601. + `v ${HEIGHT}`
  1602. + `q 0,${RADIUS} ${RADIUS},${RADIUS}`
  1603. + `h ${WIDTH}`
  1604. + `q ${RADIUS},0 ${RADIUS},-${RADIUS}`
  1605. + `v -${HEIGHT}`);
  1606. outline1.setAttribute('transform', `translate(${RADIUS / 2}, ${RADIUS / 2})`);
  1607. const g = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'g');
  1608. g.setAttribute('transform', `rotate(10)`);
  1609. g.append(outline0, outline1);
  1610. const BUTTON = (0,_position_button_alt__WEBPACK_IMPORTED_MODULE_1__.getPositionedButton)(g, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, 'Duplicate', { scale: 0.6, translate: '10 16', rotate: 10 });
  1611. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (BUTTON);
  1612.  
  1613.  
  1614. /***/ }),
  1615.  
  1616. /***/ "./ts/modal/body/nodes/actions/buttons/duplicate/consts.ts":
  1617. /*!*****************************************************************!*\
  1618. !*** ./ts/modal/body/nodes/actions/buttons/duplicate/consts.ts ***!
  1619. \*****************************************************************/
  1620. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1621.  
  1622. __webpack_require__.r(__webpack_exports__);
  1623. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1624. /* harmony export */ ACTION_ID: () => (/* binding */ ACTION_ID)
  1625. /* harmony export */ });
  1626. const ACTION_ID = 'node-copy';
  1627.  
  1628.  
  1629. /***/ }),
  1630.  
  1631. /***/ "./ts/modal/body/nodes/actions/buttons/duplicate/css.ts":
  1632. /*!**************************************************************!*\
  1633. !*** ./ts/modal/body/nodes/actions/buttons/duplicate/css.ts ***!
  1634. \**************************************************************/
  1635. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1636.  
  1637. __webpack_require__.r(__webpack_exports__);
  1638. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1639. /* harmony export */ "default": () => (/* binding */ generate)
  1640. /* harmony export */ });
  1641. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/buttons/duplicate/consts.ts");
  1642. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../css */ "./ts/modal/body/nodes/actions/buttons/css.ts");
  1643.  
  1644.  
  1645. function generate() {
  1646. (0,_css__WEBPACK_IMPORTED_MODULE_1__.addColourRule)(_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, '--nodeButtonDuplicate');
  1647. }
  1648.  
  1649.  
  1650. /***/ }),
  1651.  
  1652. /***/ "./ts/modal/body/nodes/actions/buttons/duplicate/index.ts":
  1653. /*!****************************************************************!*\
  1654. !*** ./ts/modal/body/nodes/actions/buttons/duplicate/index.ts ***!
  1655. \****************************************************************/
  1656. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1657.  
  1658. __webpack_require__.r(__webpack_exports__);
  1659. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1660. /* harmony export */ mount: () => (/* binding */ mount),
  1661. /* harmony export */ reset: () => (/* binding */ reset),
  1662. /* harmony export */ shouldMount: () => (/* binding */ shouldMount)
  1663. /* harmony export */ });
  1664. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/buttons/duplicate/consts.ts");
  1665. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button */ "./ts/modal/body/nodes/actions/buttons/duplicate/button.ts");
  1666. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../consts */ "./ts/modal/body/nodes/actions/buttons/consts.ts");
  1667. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../button */ "./ts/modal/body/nodes/actions/buttons/button.ts");
  1668. /* harmony import */ var _position__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../position */ "./ts/modal/body/nodes/actions/buttons/position/index.ts");
  1669. /* harmony import */ var _edit__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../edit */ "./ts/modal/body/nodes/actions/edit/index.ts");
  1670. /* harmony import */ var _tooltip__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../tooltip */ "./ts/modal/body/nodes/actions/tooltip/index.ts");
  1671.  
  1672.  
  1673.  
  1674.  
  1675.  
  1676.  
  1677.  
  1678. let activeNode;
  1679. function reset() {
  1680. if (!activeNode) {
  1681. return;
  1682. }
  1683. _position__WEBPACK_IMPORTED_MODULE_4__.reset();
  1684. activeNode = undefined;
  1685. }
  1686. function validate(copy, button, doScroll = true) {
  1687. Promise.all((0,_edit__WEBPACK_IMPORTED_MODULE_5__.getSubPredicateResponses)(copy.getAncestors()))
  1688. .then(() => {
  1689. copy.element.removeClass(_consts__WEBPACK_IMPORTED_MODULE_2__.PROSPECTIVE_CLASS);
  1690. reset();
  1691. if (doScroll) {
  1692. // Show the new node
  1693. copy.element.scrollIntoView();
  1694. }
  1695. (0,_edit__WEBPACK_IMPORTED_MODULE_5__.triggerSubUpdateCallbacks)(copy.getAncestors());
  1696. })
  1697. .catch((reason) => {
  1698. copy.disconnect();
  1699. if (reason) {
  1700. (0,_tooltip__WEBPACK_IMPORTED_MODULE_6__.show)(reason, button);
  1701. }
  1702. });
  1703. }
  1704. function getCopy(node) {
  1705. const copy = node.duplicate();
  1706. copy.element.addClass(_consts__WEBPACK_IMPORTED_MODULE_2__.PROSPECTIVE_CLASS);
  1707. return copy;
  1708. }
  1709. function doAction(node, parent, index, button) {
  1710. const copy = getCopy(node);
  1711. copy.move(parent, index);
  1712. validate(copy, button);
  1713. }
  1714. function onClick(node, button, isAlt) {
  1715. const previousNode = activeNode;
  1716. reset();
  1717. if (!isAlt) {
  1718. validate(getCopy(node), button, false);
  1719. }
  1720. else if (!previousNode || node !== previousNode) {
  1721. activeNode = node;
  1722. _position__WEBPACK_IMPORTED_MODULE_4__.mount(node, node, node.parent, node.getSiblings(), _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, button, doAction);
  1723. }
  1724. }
  1725. function mount(node) {
  1726. (0,_button__WEBPACK_IMPORTED_MODULE_3__.addActionButton)(_button__WEBPACK_IMPORTED_MODULE_1__["default"], onClick, node);
  1727. }
  1728. function shouldMount(node) {
  1729. return 'seed' in node.parent;
  1730. }
  1731.  
  1732.  
  1733. /***/ }),
  1734.  
  1735. /***/ "./ts/modal/body/nodes/actions/buttons/move/button.ts":
  1736. /*!************************************************************!*\
  1737. !*** ./ts/modal/body/nodes/actions/buttons/move/button.ts ***!
  1738. \************************************************************/
  1739. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1740.  
  1741. __webpack_require__.r(__webpack_exports__);
  1742. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1743. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  1744. /* harmony export */ });
  1745. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/buttons/move/consts.ts");
  1746. /* harmony import */ var _position_button_alt__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../position/button/alt */ "./ts/modal/body/nodes/actions/buttons/position/button/alt.ts");
  1747. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  1748.  
  1749.  
  1750.  
  1751. const arrowTrunk = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'line');
  1752. arrowTrunk.setAttribute('stroke-linecap', 'round');
  1753. arrowTrunk.setAttribute('stroke-width', '10');
  1754. arrowTrunk.setAttribute('y1', '-30');
  1755. arrowTrunk.setAttribute('y2', '30');
  1756. const arrowBottomLeft = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'line');
  1757. arrowBottomLeft.setAttribute('stroke-linecap', 'round');
  1758. arrowBottomLeft.setAttribute('stroke-width', '10');
  1759. arrowBottomLeft.setAttribute('x2', '-12');
  1760. arrowBottomLeft.setAttribute('y1', '27');
  1761. arrowBottomLeft.setAttribute('y2', '15');
  1762. const arrowBottomRight = arrowBottomLeft.cloneNode(true);
  1763. arrowBottomRight.setAttribute('x2', '12');
  1764. const g = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'g');
  1765. g.append(arrowTrunk, arrowBottomLeft, arrowBottomRight);
  1766. const BUTTON = (0,_position_button_alt__WEBPACK_IMPORTED_MODULE_1__.getPositionedButton)(g, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, 'Move');
  1767. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (BUTTON);
  1768.  
  1769.  
  1770. /***/ }),
  1771.  
  1772. /***/ "./ts/modal/body/nodes/actions/buttons/move/consts.ts":
  1773. /*!************************************************************!*\
  1774. !*** ./ts/modal/body/nodes/actions/buttons/move/consts.ts ***!
  1775. \************************************************************/
  1776. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1777.  
  1778. __webpack_require__.r(__webpack_exports__);
  1779. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1780. /* harmony export */ ACTION_ID: () => (/* binding */ ACTION_ID)
  1781. /* harmony export */ });
  1782. const ACTION_ID = 'node-move';
  1783.  
  1784.  
  1785. /***/ }),
  1786.  
  1787. /***/ "./ts/modal/body/nodes/actions/buttons/move/css.ts":
  1788. /*!*********************************************************!*\
  1789. !*** ./ts/modal/body/nodes/actions/buttons/move/css.ts ***!
  1790. \*********************************************************/
  1791. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1792.  
  1793. __webpack_require__.r(__webpack_exports__);
  1794. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1795. /* harmony export */ "default": () => (/* binding */ generate)
  1796. /* harmony export */ });
  1797. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/buttons/move/consts.ts");
  1798. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../css */ "./ts/modal/body/nodes/actions/buttons/css.ts");
  1799.  
  1800.  
  1801. function generate() {
  1802. (0,_css__WEBPACK_IMPORTED_MODULE_1__.addColourRule)(_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, '--nodeButtonMove');
  1803. }
  1804.  
  1805.  
  1806. /***/ }),
  1807.  
  1808. /***/ "./ts/modal/body/nodes/actions/buttons/move/index.ts":
  1809. /*!***********************************************************!*\
  1810. !*** ./ts/modal/body/nodes/actions/buttons/move/index.ts ***!
  1811. \***********************************************************/
  1812. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1813.  
  1814. __webpack_require__.r(__webpack_exports__);
  1815. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1816. /* harmony export */ mount: () => (/* binding */ mount),
  1817. /* harmony export */ reset: () => (/* binding */ reset),
  1818. /* harmony export */ shouldMount: () => (/* binding */ shouldMount),
  1819. /* harmony export */ unmount: () => (/* binding */ unmount)
  1820. /* harmony export */ });
  1821. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/buttons/move/consts.ts");
  1822. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button */ "./ts/modal/body/nodes/actions/buttons/move/button.ts");
  1823. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../consts */ "./ts/modal/body/nodes/actions/buttons/consts.ts");
  1824. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../button */ "./ts/modal/body/nodes/actions/buttons/button.ts");
  1825. /* harmony import */ var _position__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../position */ "./ts/modal/body/nodes/actions/buttons/position/index.ts");
  1826. /* harmony import */ var _edit__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../edit */ "./ts/modal/body/nodes/actions/edit/index.ts");
  1827. /* harmony import */ var _tooltip__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../tooltip */ "./ts/modal/body/nodes/actions/tooltip/index.ts");
  1828.  
  1829.  
  1830.  
  1831.  
  1832.  
  1833.  
  1834.  
  1835. let activeNode;
  1836. function reset() {
  1837. if (!activeNode) {
  1838. return;
  1839. }
  1840. _position__WEBPACK_IMPORTED_MODULE_4__.reset();
  1841. activeNode = undefined;
  1842. }
  1843. function getAncestorBranches(node, copy) {
  1844. if (node.parent === copy.parent) {
  1845. return [node.getAncestors()];
  1846. }
  1847. const oldAncestors = node.getAncestors();
  1848. const newAncestors = copy.getAncestors();
  1849. for (let i = Math.min(oldAncestors.length, newAncestors.length) - 1; i > 1; --i) {
  1850. if (oldAncestors[oldAncestors.length - i] === newAncestors[newAncestors.length - i]) {
  1851. return [oldAncestors.slice(0, -i), newAncestors];
  1852. }
  1853. }
  1854. // Branch is from the root
  1855. return [oldAncestors.slice(0, -1), newAncestors];
  1856. }
  1857. function doAction(node, newParent, index, button, doScroll = true) {
  1858. const copy = node.duplicate();
  1859. copy.element.addClass(_consts__WEBPACK_IMPORTED_MODULE_2__.PROSPECTIVE_CLASS);
  1860. copy.move(newParent, index);
  1861. node.isActive = false;
  1862. const ancestorBranches = getAncestorBranches(node, copy);
  1863. Promise.all(ancestorBranches.map((branch) => Promise.all((0,_edit__WEBPACK_IMPORTED_MODULE_5__.getSubPredicateResponses)(branch))))
  1864. .then(() => {
  1865. copy.element.removeClass(_consts__WEBPACK_IMPORTED_MODULE_2__.PROSPECTIVE_CLASS);
  1866. node.disconnect();
  1867. reset();
  1868. if (doScroll) {
  1869. // Show where the node's been moved to
  1870. copy.element.scrollIntoView();
  1871. }
  1872. for (const branch of ancestorBranches) {
  1873. (0,_edit__WEBPACK_IMPORTED_MODULE_5__.triggerSubUpdateCallbacks)(branch);
  1874. }
  1875. })
  1876. .catch((reason) => {
  1877. node.isActive = copy.isActive;
  1878. copy.disconnect();
  1879. if (reason) {
  1880. _tooltip__WEBPACK_IMPORTED_MODULE_6__.show(reason, button);
  1881. }
  1882. });
  1883. }
  1884. function onClick(node, button, isAlt) {
  1885. const previousNode = activeNode;
  1886. reset();
  1887. if (!isAlt) {
  1888. const newIndex = node.getIndex() + 2;
  1889. if (newIndex < node.parent.children.length + 1) {
  1890. doAction(node, node.parent, newIndex, button, false);
  1891. }
  1892. else {
  1893. _tooltip__WEBPACK_IMPORTED_MODULE_6__.show('Node can not be moved down.', button);
  1894. }
  1895. }
  1896. else if (!previousNode || node !== previousNode) {
  1897. // If the only valid target is the current parent
  1898. if (_position__WEBPACK_IMPORTED_MODULE_4__.hasDestinations(node)) {
  1899. activeNode = node;
  1900. _position__WEBPACK_IMPORTED_MODULE_4__.mount(node, node, node.parent, node.getSiblings(), _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, button, doAction, false);
  1901. }
  1902. else {
  1903. _tooltip__WEBPACK_IMPORTED_MODULE_6__.show('No other valid locations found.', button);
  1904. }
  1905. }
  1906. }
  1907. function unmount(node) {
  1908. if (activeNode && node === activeNode) {
  1909. reset();
  1910. }
  1911. }
  1912. function mount(node) {
  1913. (0,_button__WEBPACK_IMPORTED_MODULE_3__.addActionButton)(_button__WEBPACK_IMPORTED_MODULE_1__["default"], onClick, node);
  1914. }
  1915. function shouldMount(node) {
  1916. return Boolean(node.parent.seed) || ('poolId' in node.parent);
  1917. }
  1918.  
  1919.  
  1920. /***/ }),
  1921.  
  1922. /***/ "./ts/modal/body/nodes/actions/buttons/position/button/alt.ts":
  1923. /*!********************************************************************!*\
  1924. !*** ./ts/modal/body/nodes/actions/buttons/position/button/alt.ts ***!
  1925. \********************************************************************/
  1926. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1927.  
  1928. __webpack_require__.r(__webpack_exports__);
  1929. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1930. /* harmony export */ getPositionedButton: () => (/* binding */ getPositionedButton)
  1931. /* harmony export */ });
  1932. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../consts */ "./ts/modal/body/nodes/actions/buttons/consts.ts");
  1933. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../button */ "./ts/modal/body/nodes/actions/buttons/button.ts");
  1934. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  1935.  
  1936.  
  1937.  
  1938. const G_ALT = (() => {
  1939. const arrowTrunk = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'line');
  1940. arrowTrunk.setAttribute('stroke-linecap', 'round');
  1941. arrowTrunk.setAttribute('stroke-width', '10');
  1942. arrowTrunk.setAttribute('y1', '-30');
  1943. arrowTrunk.setAttribute('y2', '30');
  1944. const arrowBottomLeft = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'line');
  1945. arrowBottomLeft.setAttribute('stroke-linecap', 'round');
  1946. arrowBottomLeft.setAttribute('stroke-width', '10');
  1947. arrowBottomLeft.setAttribute('x2', '-12');
  1948. arrowBottomLeft.setAttribute('y1', '27');
  1949. arrowBottomLeft.setAttribute('y2', '15');
  1950. const arrowBottomRight = arrowBottomLeft.cloneNode(true);
  1951. arrowBottomRight.setAttribute('x2', '12');
  1952. const arrowTopRight = arrowBottomLeft.cloneNode(true);
  1953. arrowTopRight.setAttribute('transform', 'rotate(180)');
  1954. const arrowTopLeft = arrowBottomRight.cloneNode(true);
  1955. arrowTopLeft.setAttribute('transform', 'rotate(180)');
  1956. const g = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'g');
  1957. g.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.ALT_CLASS);
  1958. g.append(arrowTrunk, arrowBottomLeft, arrowBottomRight, arrowTopRight, arrowTopLeft);
  1959. return g;
  1960. })();
  1961. function getPositionedButton(gDefault, actionId, description, transform = {}) {
  1962. const g = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'g');
  1963. const gAlt = G_ALT.cloneNode(true);
  1964. gAlt.setAttribute('transform', Object.entries(transform).map(([key, value]) => `${key}(${value})`).join(' '));
  1965. g.append(gAlt, gDefault);
  1966. return (0,_button__WEBPACK_IMPORTED_MODULE_1__.getNewButton)(g, actionId, description);
  1967. }
  1968.  
  1969.  
  1970. /***/ }),
  1971.  
  1972. /***/ "./ts/modal/body/nodes/actions/buttons/position/button/index.ts":
  1973. /*!**********************************************************************!*\
  1974. !*** ./ts/modal/body/nodes/actions/buttons/position/button/index.ts ***!
  1975. \**********************************************************************/
  1976. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1977.  
  1978. __webpack_require__.r(__webpack_exports__);
  1979. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1980. /* harmony export */ BUTTON_PARENT: () => (/* binding */ BUTTON_PARENT),
  1981. /* harmony export */ BUTTON_SIBLING: () => (/* binding */ BUTTON_SIBLING)
  1982. /* harmony export */ });
  1983. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../consts */ "./ts/modal/body/nodes/actions/buttons/position/consts.ts");
  1984. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../button */ "./ts/modal/body/nodes/actions/buttons/button.ts");
  1985. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  1986.  
  1987.  
  1988.  
  1989. const arrowTrunk = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'line');
  1990. arrowTrunk.setAttribute('stroke-linecap', 'round');
  1991. arrowTrunk.setAttribute('stroke-width', '10');
  1992. arrowTrunk.setAttribute('y1', '-30');
  1993. arrowTrunk.setAttribute('y2', '30');
  1994. const arrowBottomLeft = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'line');
  1995. arrowBottomLeft.setAttribute('stroke-linecap', 'round');
  1996. arrowBottomLeft.setAttribute('stroke-width', '10');
  1997. arrowBottomLeft.setAttribute('x2', '-12');
  1998. arrowBottomLeft.setAttribute('y1', '27');
  1999. arrowBottomLeft.setAttribute('y2', '15');
  2000. const arrowBottomRight = arrowBottomLeft.cloneNode(true);
  2001. arrowBottomRight.setAttribute('x2', '12');
  2002. const gMain = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'g');
  2003. gMain.append(arrowTrunk, arrowBottomLeft, arrowBottomRight);
  2004. const gSibling = gMain.cloneNode(true);
  2005. const BUTTON_SIBLING = (0,_button__WEBPACK_IMPORTED_MODULE_1__.getNewButton)(gSibling, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, 'Select After');
  2006. const gParent = gMain.cloneNode(true);
  2007. gParent.setAttribute('transform', 'rotate(-45)');
  2008. const BUTTON_PARENT = (0,_button__WEBPACK_IMPORTED_MODULE_1__.getNewButton)(gParent, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, 'Select Into');
  2009.  
  2010.  
  2011. /***/ }),
  2012.  
  2013. /***/ "./ts/modal/body/nodes/actions/buttons/position/consts.ts":
  2014. /*!****************************************************************!*\
  2015. !*** ./ts/modal/body/nodes/actions/buttons/position/consts.ts ***!
  2016. \****************************************************************/
  2017. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2018.  
  2019. __webpack_require__.r(__webpack_exports__);
  2020. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2021. /* harmony export */ ACTION_ID: () => (/* binding */ ACTION_ID)
  2022. /* harmony export */ });
  2023. const ACTION_ID = 'node-position';
  2024.  
  2025.  
  2026. /***/ }),
  2027.  
  2028. /***/ "./ts/modal/body/nodes/actions/buttons/position/css.ts":
  2029. /*!*************************************************************!*\
  2030. !*** ./ts/modal/body/nodes/actions/buttons/position/css.ts ***!
  2031. \*************************************************************/
  2032. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2033.  
  2034. __webpack_require__.r(__webpack_exports__);
  2035. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2036. /* harmony export */ "default": () => (/* binding */ generate)
  2037. /* harmony export */ });
  2038. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/buttons/position/consts.ts");
  2039. /* harmony import */ var _focus_consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../focus/consts */ "./ts/modal/body/nodes/actions/focus/consts.ts");
  2040. /* harmony import */ var _nodes_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @nodes/consts */ "./ts/modal/body/nodes/consts.ts");
  2041. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  2042.  
  2043.  
  2044.  
  2045.  
  2046. function generate() {
  2047. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ROOT_CLASS}.${_focus_consts__WEBPACK_IMPORTED_MODULE_1__.FOCUS_CLASS} `
  2048. + `.${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.ELEMENT_CONTAINER}:not(.${_focus_consts__WEBPACK_IMPORTED_MODULE_1__.FOCUS_CLASS})`, ['display', 'none']);
  2049. }
  2050.  
  2051.  
  2052. /***/ }),
  2053.  
  2054. /***/ "./ts/modal/body/nodes/actions/buttons/position/index.ts":
  2055. /*!***************************************************************!*\
  2056. !*** ./ts/modal/body/nodes/actions/buttons/position/index.ts ***!
  2057. \***************************************************************/
  2058. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2059.  
  2060. __webpack_require__.r(__webpack_exports__);
  2061. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2062. /* harmony export */ getButton: () => (/* binding */ getButton),
  2063. /* harmony export */ hasDestinations: () => (/* binding */ hasDestinations),
  2064. /* harmony export */ isActive: () => (/* binding */ isActive),
  2065. /* harmony export */ mount: () => (/* binding */ mount),
  2066. /* harmony export */ reset: () => (/* binding */ reset)
  2067. /* harmony export */ });
  2068. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/buttons/position/consts.ts");
  2069. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button */ "./ts/modal/body/nodes/actions/buttons/position/button/index.ts");
  2070. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../button */ "./ts/modal/body/nodes/actions/buttons/button.ts");
  2071. /* harmony import */ var _focus__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../focus */ "./ts/modal/body/nodes/actions/focus/index.ts");
  2072. /* harmony import */ var _highlight__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../highlight */ "./ts/modal/body/nodes/actions/highlight/index.ts");
  2073. /* harmony import */ var _modal_body__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @/modal/body */ "./ts/modal/body/index.ts");
  2074. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  2075.  
  2076.  
  2077.  
  2078.  
  2079.  
  2080.  
  2081.  
  2082. const destinations = [];
  2083. let origin;
  2084. function isActive() {
  2085. return Boolean(origin);
  2086. }
  2087. function setActive(doActivate = true) {
  2088. (0,_modal_body__WEBPACK_IMPORTED_MODULE_5__.setActive)(origin.button, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, doActivate);
  2089. (0,_focus__WEBPACK_IMPORTED_MODULE_3__.reset)();
  2090. (0,_focus__WEBPACK_IMPORTED_MODULE_3__.focus)(doActivate, origin.source, false);
  2091. (0,_focus__WEBPACK_IMPORTED_MODULE_3__.focusBranch)(doActivate, origin.source, doActivate);
  2092. if (doActivate) {
  2093. (0,_focus__WEBPACK_IMPORTED_MODULE_3__.setTabIndexes)(false, origin.source);
  2094. origin.button.setAttribute('tabIndex', '1');
  2095. }
  2096. else {
  2097. origin.button.setAttribute('tabIndex', '-1');
  2098. }
  2099. origin.source.element.headContainer.focus();
  2100. }
  2101. function reset() {
  2102. if (!origin) {
  2103. return;
  2104. }
  2105. for (const { node, isParent, button } of destinations) {
  2106. (0,_focus__WEBPACK_IMPORTED_MODULE_3__.focusBranch)(false, node, isParent);
  2107. button.remove();
  2108. }
  2109. destinations.length = 0;
  2110. (0,_highlight__WEBPACK_IMPORTED_MODULE_4__.removeSustained)(origin.source);
  2111. setActive(false);
  2112. origin = undefined;
  2113. }
  2114. function getButton(node, actionId, onClick, isParent) {
  2115. const button = (0,_button__WEBPACK_IMPORTED_MODULE_2__.addActionButton)(isParent ? _button__WEBPACK_IMPORTED_MODULE_1__.BUTTON_PARENT : _button__WEBPACK_IMPORTED_MODULE_1__.BUTTON_SIBLING, onClick, node);
  2116. button.classList.add(actionId);
  2117. button.classList.add(_modal_consts__WEBPACK_IMPORTED_MODULE_6__.BUTTON_ACTIVE_CLASS);
  2118. button.setAttribute('tabIndex', '1');
  2119. return button;
  2120. }
  2121. function getBoundCallback(callback, parent, index) {
  2122. return (_, button) => callback(parent, index, button);
  2123. }
  2124. function addButtons(parent, actionId, callback, includeSelf) {
  2125. const isCurrentParent = parent === origin.parent;
  2126. if (isCurrentParent || (origin.isPooled && parent.poolId === origin.parent.poolId)) {
  2127. destinations.push({
  2128. node: parent,
  2129. isParent: true,
  2130. button: getButton(parent, actionId, getBoundCallback(callback, parent, 0), true),
  2131. });
  2132. (0,_focus__WEBPACK_IMPORTED_MODULE_3__.focusBranch)(true, parent);
  2133. for (const target of (!includeSelf && isCurrentParent) ? origin.siblings : parent.children) {
  2134. (0,_focus__WEBPACK_IMPORTED_MODULE_3__.focusBranch)(true, target, false);
  2135. destinations.push({
  2136. node: target,
  2137. isParent: false,
  2138. button: getButton(target, actionId, getBoundCallback(callback, target.parent, target.getIndex() + 1), false),
  2139. });
  2140. }
  2141. }
  2142. // Nodes can't be their own descendants
  2143. if (!isCurrentParent) {
  2144. for (const child of parent.children) {
  2145. if ('children' in child) {
  2146. addButtons(child, actionId, callback, includeSelf);
  2147. }
  2148. }
  2149. }
  2150. }
  2151. function hasDestinations(node) {
  2152. if (node.parent.children.length > 1) {
  2153. return true;
  2154. }
  2155. if (!('poolId' in node.parent)) {
  2156. return false;
  2157. }
  2158. const hasMatchingPool = (parent, poolId) => {
  2159. if (parent !== node.parent) {
  2160. if (parent.poolId === poolId) {
  2161. return true;
  2162. }
  2163. for (const child of parent.children) {
  2164. if ('children' in child && hasMatchingPool(child, poolId)) {
  2165. return true;
  2166. }
  2167. }
  2168. }
  2169. return false;
  2170. };
  2171. return hasMatchingPool(node.getRoot(), node.parent.poolId);
  2172. }
  2173. function mount(source, child, parent, siblings, actionId, button, callback, includeSelf = true) {
  2174. reset();
  2175. origin = {
  2176. source,
  2177. child,
  2178. siblings,
  2179. parent,
  2180. isPooled: 'poolId' in parent,
  2181. button,
  2182. actionId,
  2183. };
  2184. addButtons(parent.getRoot(), actionId, callback.bind(null, source), includeSelf);
  2185. (0,_highlight__WEBPACK_IMPORTED_MODULE_4__.addSustained)(source);
  2186. setActive();
  2187. return destinations.length;
  2188. }
  2189.  
  2190.  
  2191. /***/ }),
  2192.  
  2193. /***/ "./ts/modal/body/nodes/actions/css.ts":
  2194. /*!********************************************!*\
  2195. !*** ./ts/modal/body/nodes/actions/css.ts ***!
  2196. \********************************************/
  2197. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2198.  
  2199. __webpack_require__.r(__webpack_exports__);
  2200. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2201. /* harmony export */ "default": () => (/* binding */ generate)
  2202. /* harmony export */ });
  2203. /* harmony import */ var _edit_css__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./edit/css */ "./ts/modal/body/nodes/actions/edit/css.ts");
  2204. /* harmony import */ var _edit_option_css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./edit/option/css */ "./ts/modal/body/nodes/actions/edit/option/css.ts");
  2205. /* harmony import */ var _highlight_css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./highlight/css */ "./ts/modal/body/nodes/actions/highlight/css.ts");
  2206. /* harmony import */ var _focus_css__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./focus/css */ "./ts/modal/body/nodes/actions/focus/css.ts");
  2207. /* harmony import */ var _tooltip_css__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./tooltip/css */ "./ts/modal/body/nodes/actions/tooltip/css.ts");
  2208. /* harmony import */ var _buttons_css__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./buttons/css */ "./ts/modal/body/nodes/actions/buttons/css.ts");
  2209.  
  2210.  
  2211.  
  2212.  
  2213.  
  2214.  
  2215. function generate() {
  2216. (0,_edit_css__WEBPACK_IMPORTED_MODULE_0__["default"])();
  2217. (0,_edit_option_css__WEBPACK_IMPORTED_MODULE_1__["default"])();
  2218. (0,_highlight_css__WEBPACK_IMPORTED_MODULE_2__["default"])();
  2219. (0,_focus_css__WEBPACK_IMPORTED_MODULE_3__["default"])();
  2220. (0,_tooltip_css__WEBPACK_IMPORTED_MODULE_4__["default"])();
  2221. (0,_buttons_css__WEBPACK_IMPORTED_MODULE_5__["default"])();
  2222. }
  2223.  
  2224.  
  2225. /***/ }),
  2226.  
  2227. /***/ "./ts/modal/body/nodes/actions/edit/async.ts":
  2228. /*!***************************************************!*\
  2229. !*** ./ts/modal/body/nodes/actions/edit/async.ts ***!
  2230. \***************************************************/
  2231. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2232.  
  2233. __webpack_require__.r(__webpack_exports__);
  2234. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2235. /* harmony export */ isOngoing: () => (/* binding */ isOngoing),
  2236. /* harmony export */ reject: () => (/* binding */ reject),
  2237. /* harmony export */ resolve: () => (/* binding */ resolve),
  2238. /* harmony export */ start: () => (/* binding */ start)
  2239. /* harmony export */ });
  2240. let id = 0;
  2241. let count = 0;
  2242. let lastResolvedId = 0;
  2243. let lastRejectedId = 0;
  2244. function countDown() {
  2245. if (--count === 0) {
  2246. id = 0;
  2247. lastResolvedId = 0;
  2248. lastRejectedId = 0;
  2249. }
  2250. }
  2251. function start() {
  2252. count++;
  2253. return ++id;
  2254. }
  2255. function resolve(id) {
  2256. const isNew = lastResolvedId < id;
  2257. if (isNew) {
  2258. lastResolvedId = id;
  2259. }
  2260. countDown();
  2261. return isNew;
  2262. }
  2263. function reject(id) {
  2264. const isNew = lastRejectedId < id;
  2265. if (isNew) {
  2266. lastRejectedId = id;
  2267. }
  2268. countDown();
  2269. return isNew;
  2270. }
  2271. function isOngoing() {
  2272. return count > 0;
  2273. }
  2274.  
  2275.  
  2276. /***/ }),
  2277.  
  2278. /***/ "./ts/modal/body/nodes/actions/edit/consts.ts":
  2279. /*!****************************************************!*\
  2280. !*** ./ts/modal/body/nodes/actions/edit/consts.ts ***!
  2281. \****************************************************/
  2282. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2283.  
  2284. __webpack_require__.r(__webpack_exports__);
  2285. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2286. /* harmony export */ ACTIVE_CLASS: () => (/* binding */ ACTIVE_CLASS),
  2287. /* harmony export */ EDITABLE_CLASS: () => (/* binding */ EDITABLE_CLASS),
  2288. /* harmony export */ INVALID_BACKGROUND_CLASS: () => (/* binding */ INVALID_BACKGROUND_CLASS),
  2289. /* harmony export */ INVALID_CLASS: () => (/* binding */ INVALID_CLASS),
  2290. /* harmony export */ PENDING_CLASS: () => (/* binding */ PENDING_CLASS),
  2291. /* harmony export */ VALID_BACKGROUND_CLASS: () => (/* binding */ VALID_BACKGROUND_CLASS),
  2292. /* harmony export */ VALID_CLASS: () => (/* binding */ VALID_CLASS)
  2293. /* harmony export */ });
  2294. const EDITABLE_CLASS = 'editable';
  2295. const VALID_CLASS = 'valid';
  2296. const INVALID_CLASS = 'invalid';
  2297. const INVALID_BACKGROUND_CLASS = 'background-invalid';
  2298. const VALID_BACKGROUND_CLASS = 'background-valid';
  2299. const ACTIVE_CLASS = 'edit-active';
  2300. const PENDING_CLASS = 'edit-pending';
  2301.  
  2302.  
  2303. /***/ }),
  2304.  
  2305. /***/ "./ts/modal/body/nodes/actions/edit/css.ts":
  2306. /*!*************************************************!*\
  2307. !*** ./ts/modal/body/nodes/actions/edit/css.ts ***!
  2308. \*************************************************/
  2309. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2310.  
  2311. __webpack_require__.r(__webpack_exports__);
  2312. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2313. /* harmony export */ "default": () => (/* binding */ generate)
  2314. /* harmony export */ });
  2315. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/edit/consts.ts");
  2316. /* harmony import */ var _nodes_consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @nodes/consts */ "./ts/modal/body/nodes/consts.ts");
  2317. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  2318.  
  2319.  
  2320.  
  2321. function generate() {
  2322. // Use pointer when the node has a value and isn't being edited
  2323. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.EDITABLE_CLASS} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ELEMENT_CLASSES.HEAD_CONTAINER}`, ['cursor', 'pointer']);
  2324. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`:not(.${_consts__WEBPACK_IMPORTED_MODULE_0__.ACTIVE_CLASS}) > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ELEMENT_CLASSES.HEAD_CONTAINER} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ELEMENT_CLASSES.INFO_CONTAINER}`, ['pointer-events', 'none']);
  2325. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ELEMENT_CLASSES.VALUE}`, [
  2326. ['flex-grow', '1'],
  2327. ['outline', 'none'],
  2328. ['min-width', '0'],
  2329. ]);
  2330. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ELEMENT_CLASSES.VALUE}[type="checkbox"]`, [
  2331. ['min-height', '1em'],
  2332. ['min-width', '1em'],
  2333. ]);
  2334. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ELEMENT_CLASSES.VALUE}[type="color"]`, [
  2335. ['height', '1.3em'],
  2336. ['cursor', 'pointer'],
  2337. ]);
  2338. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.VALID_BACKGROUND_CLASS}`, ['background-color', 'var(--validBackground)']);
  2339. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.INVALID_BACKGROUND_CLASS}`, ['background-color', 'var(--invalidBackground)']);
  2340. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([`.${_consts__WEBPACK_IMPORTED_MODULE_0__.VALID_BACKGROUND_CLASS}`, `.${_consts__WEBPACK_IMPORTED_MODULE_0__.INVALID_BACKGROUND_CLASS}`], [
  2341. ['transition-property', 'width, padding-left'],
  2342. ['transition-duration', '500ms'],
  2343. ['right', '0'],
  2344. ['width', '0'],
  2345. ['padding-left', '0'],
  2346. ]);
  2347. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([
  2348. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.VALID_CLASS} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ELEMENT_CLASSES.HEAD_CONTAINER} .${_consts__WEBPACK_IMPORTED_MODULE_0__.VALID_BACKGROUND_CLASS}`,
  2349. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.INVALID_CLASS} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ELEMENT_CLASSES.HEAD_CONTAINER} .${_consts__WEBPACK_IMPORTED_MODULE_0__.INVALID_BACKGROUND_CLASS}`,
  2350. ], ['width', '100%']);
  2351. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([
  2352. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.VALID_CLASS} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ELEMENT_CLASSES.HEAD_CONTAINER} .${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ELEMENT_CLASSES.BUTTON_CONTAINER}:not(:empty) + * .${_consts__WEBPACK_IMPORTED_MODULE_0__.VALID_BACKGROUND_CLASS}`,
  2353. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.INVALID_CLASS} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ELEMENT_CLASSES.HEAD_CONTAINER} .${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ELEMENT_CLASSES.BUTTON_CONTAINER}:not(:empty) + * .${_consts__WEBPACK_IMPORTED_MODULE_0__.INVALID_BACKGROUND_CLASS}`,
  2354. ], ['padding-left', '0.8em']);
  2355. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.VALID_CLASS} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ELEMENT_CLASSES.HEAD_CONTAINER} .${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ELEMENT_CLASSES.VALUE_CONTAINER}`, ['color', 'var(--validFont) !important']);
  2356. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.INVALID_CLASS} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ELEMENT_CLASSES.HEAD_CONTAINER} .${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ELEMENT_CLASSES.VALUE_CONTAINER}`, ['color', 'var(--invalidFont) !important']);
  2357. }
  2358.  
  2359.  
  2360. /***/ }),
  2361.  
  2362. /***/ "./ts/modal/body/nodes/actions/edit/index.ts":
  2363. /*!***************************************************!*\
  2364. !*** ./ts/modal/body/nodes/actions/edit/index.ts ***!
  2365. \***************************************************/
  2366. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2367.  
  2368. __webpack_require__.r(__webpack_exports__);
  2369. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2370. /* harmony export */ doAction: () => (/* binding */ doAction),
  2371. /* harmony export */ getSubPredicateResponses: () => (/* binding */ getSubPredicateResponses),
  2372. /* harmony export */ isActive: () => (/* binding */ isActive),
  2373. /* harmony export */ mount: () => (/* binding */ mount),
  2374. /* harmony export */ reset: () => (/* binding */ reset),
  2375. /* harmony export */ shouldMount: () => (/* binding */ shouldMount),
  2376. /* harmony export */ triggerSubUpdateCallbacks: () => (/* binding */ triggerSubUpdateCallbacks),
  2377. /* harmony export */ unmount: () => (/* binding */ unmount),
  2378. /* harmony export */ update: () => (/* binding */ update)
  2379. /* harmony export */ });
  2380. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/edit/consts.ts");
  2381. /* harmony import */ var _async__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./async */ "./ts/modal/body/nodes/actions/edit/async.ts");
  2382. /* harmony import */ var _option__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./option */ "./ts/modal/body/nodes/actions/edit/option/index.ts");
  2383. /* harmony import */ var _tooltip__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../tooltip */ "./ts/modal/body/nodes/actions/tooltip/index.ts");
  2384. /* harmony import */ var _highlight__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../highlight */ "./ts/modal/body/nodes/actions/highlight/index.ts");
  2385. /* harmony import */ var _predicate__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @/predicate */ "./ts/predicate.ts");
  2386. var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
  2387. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  2388. return new (P || (P = Promise))(function (resolve, reject) {
  2389. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  2390. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  2391. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  2392. step((generator = generator.apply(thisArg, _arguments || [])).next());
  2393. });
  2394. };
  2395.  
  2396.  
  2397.  
  2398.  
  2399.  
  2400.  
  2401. let activeNode;
  2402. function isActive() {
  2403. return Boolean(activeNode);
  2404. }
  2405. function reset() {
  2406. if (!activeNode || _async__WEBPACK_IMPORTED_MODULE_1__.isOngoing()) {
  2407. return;
  2408. }
  2409. const { element } = activeNode;
  2410. activeNode.value = activeNode.lastAcceptedValue;
  2411. element.render(activeNode.value);
  2412. element.removeClass(_consts__WEBPACK_IMPORTED_MODULE_0__.VALID_CLASS);
  2413. element.removeClass(_consts__WEBPACK_IMPORTED_MODULE_0__.INVALID_CLASS);
  2414. element.removeClass(_consts__WEBPACK_IMPORTED_MODULE_0__.ACTIVE_CLASS);
  2415. _tooltip__WEBPACK_IMPORTED_MODULE_3__.reset();
  2416. _option__WEBPACK_IMPORTED_MODULE_2__.reset();
  2417. (0,_highlight__WEBPACK_IMPORTED_MODULE_4__.removeSustained)(activeNode);
  2418. activeNode = undefined;
  2419. }
  2420. function getValue(node) {
  2421. switch (typeof node.value) {
  2422. case 'boolean':
  2423. return Boolean(node.element.contrast.valueElement.checked);
  2424. case 'number':
  2425. return Number(node.element.contrast.valueElement.value);
  2426. default:
  2427. return node.element.contrast.valueElement.value;
  2428. }
  2429. }
  2430. function getSubPredicateResponses(ancestors = activeNode.getAncestors()) {
  2431. const responses = [];
  2432. if ('childPredicate' in ancestors[0]) {
  2433. responses.push((0,_predicate__WEBPACK_IMPORTED_MODULE_5__.getPredicatePromise)(ancestors[0].childPredicate()));
  2434. }
  2435. for (const ancestor of ancestors) {
  2436. if ('descendantPredicate' in ancestor) {
  2437. responses.push((0,_predicate__WEBPACK_IMPORTED_MODULE_5__.getPredicatePromise)(ancestor.descendantPredicate()));
  2438. }
  2439. }
  2440. return responses;
  2441. }
  2442. function getAllPredicateResponses() {
  2443. if (activeNode.forceValid || ('options' in activeNode && activeNode.options.includes(activeNode.value))) {
  2444. return getSubPredicateResponses();
  2445. }
  2446. if ('predicate' in activeNode) {
  2447. return [(0,_predicate__WEBPACK_IMPORTED_MODULE_5__.getPredicatePromise)(activeNode.predicate(activeNode.value)), ...getSubPredicateResponses()];
  2448. }
  2449. return [Promise.reject()];
  2450. }
  2451. function triggerSubUpdateCallbacks(ancestors = activeNode.getAncestors()) {
  2452. if ('onChildUpdate' in ancestors[0]) {
  2453. ancestors[0].onChildUpdate();
  2454. }
  2455. for (const ancestor of ancestors) {
  2456. if ('onDescendantUpdate' in ancestor) {
  2457. ancestor.onDescendantUpdate();
  2458. }
  2459. }
  2460. }
  2461. function triggerAllUpdateCallbacks() {
  2462. if ('onUpdate' in activeNode) {
  2463. activeNode.onUpdate(activeNode.value);
  2464. }
  2465. triggerSubUpdateCallbacks();
  2466. }
  2467. function update() {
  2468. return __awaiter(this, void 0, void 0, function* () {
  2469. const value = getValue(activeNode);
  2470. activeNode.value = value;
  2471. if ('options' in activeNode) {
  2472. _option__WEBPACK_IMPORTED_MODULE_2__.update(activeNode.value);
  2473. }
  2474. const id = _async__WEBPACK_IMPORTED_MODULE_1__.start();
  2475. activeNode.element.addClass(_consts__WEBPACK_IMPORTED_MODULE_0__.PENDING_CLASS);
  2476. try {
  2477. yield Promise.all(getAllPredicateResponses());
  2478. if (!_async__WEBPACK_IMPORTED_MODULE_1__.resolve(id)) {
  2479. return;
  2480. }
  2481. activeNode.lastAcceptedValue = value;
  2482. activeNode.element.removeClass(_consts__WEBPACK_IMPORTED_MODULE_0__.INVALID_CLASS);
  2483. activeNode.element.addClass(_consts__WEBPACK_IMPORTED_MODULE_0__.VALID_CLASS);
  2484. _tooltip__WEBPACK_IMPORTED_MODULE_3__.hide();
  2485. triggerAllUpdateCallbacks();
  2486. }
  2487. catch (reason) {
  2488. if (!_async__WEBPACK_IMPORTED_MODULE_1__.reject(id)) {
  2489. return;
  2490. }
  2491. activeNode.element.removeClass(_consts__WEBPACK_IMPORTED_MODULE_0__.VALID_CLASS);
  2492. activeNode.element.addClass(_consts__WEBPACK_IMPORTED_MODULE_0__.INVALID_CLASS);
  2493. if (reason) {
  2494. _tooltip__WEBPACK_IMPORTED_MODULE_3__.show(reason);
  2495. }
  2496. }
  2497. if (!_async__WEBPACK_IMPORTED_MODULE_1__.isOngoing()) {
  2498. activeNode.element.removeClass(_consts__WEBPACK_IMPORTED_MODULE_0__.PENDING_CLASS);
  2499. }
  2500. });
  2501. }
  2502. function unmount(node) {
  2503. if (node === activeNode) {
  2504. reset();
  2505. }
  2506. }
  2507. function doAction(node) {
  2508. if (activeNode === node || _async__WEBPACK_IMPORTED_MODULE_1__.isOngoing()) {
  2509. return;
  2510. }
  2511. reset();
  2512. _tooltip__WEBPACK_IMPORTED_MODULE_3__.kill();
  2513. activeNode = node;
  2514. activeNode.element.addClass(_consts__WEBPACK_IMPORTED_MODULE_0__.ACTIVE_CLASS);
  2515. activeNode.element.addClass(_consts__WEBPACK_IMPORTED_MODULE_0__.VALID_CLASS);
  2516. _tooltip__WEBPACK_IMPORTED_MODULE_3__.setNode(node);
  2517. if ('options' in node) {
  2518. _option__WEBPACK_IMPORTED_MODULE_2__.setNode(node);
  2519. }
  2520. if (node.input === 'color') {
  2521. node.element.contrast.valueElement.click();
  2522. }
  2523. else if (typeof node.value !== 'boolean') {
  2524. const input = node.element.contrast.valueElement;
  2525. input.select();
  2526. input.scrollLeft = input.scrollWidth;
  2527. }
  2528. (0,_highlight__WEBPACK_IMPORTED_MODULE_4__.addSustained)(node);
  2529. }
  2530. function mount(node) {
  2531. const { backgroundContainer, contrast: { valueElement, valueContainer }, headContainer } = node.element;
  2532. node.lastAcceptedValue = node.value;
  2533. node.element.addClass(_consts__WEBPACK_IMPORTED_MODULE_0__.EDITABLE_CLASS);
  2534. backgroundContainer.append(...(() => {
  2535. const valid = document.createElement('div');
  2536. const invalid = document.createElement('div');
  2537. valid.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.VALID_BACKGROUND_CLASS);
  2538. invalid.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.INVALID_BACKGROUND_CLASS);
  2539. return [valid, invalid];
  2540. })());
  2541. // Start
  2542. valueElement.addEventListener('focus', (event) => {
  2543. event.stopPropagation();
  2544. if (event.relatedTarget) {
  2545. doAction(node);
  2546. }
  2547. });
  2548. valueElement.addEventListener('blur', (event) => {
  2549. event.stopPropagation();
  2550. reset();
  2551. });
  2552. headContainer.addEventListener('click', (event) => {
  2553. event.stopPropagation();
  2554. valueElement.focus();
  2555. });
  2556. // Process new value
  2557. if (typeof node.value === 'boolean') {
  2558. headContainer.addEventListener('mousedown', (event) => {
  2559. event.stopPropagation();
  2560. event.preventDefault();
  2561. });
  2562. headContainer.addEventListener('click', () => {
  2563. valueElement.checked = !valueElement.checked;
  2564. update();
  2565. });
  2566. valueContainer.addEventListener('click', (event) => {
  2567. event.stopPropagation();
  2568. });
  2569. valueElement.addEventListener('click', (event) => {
  2570. event.stopPropagation();
  2571. update();
  2572. });
  2573. }
  2574. else {
  2575. valueElement.addEventListener('input', (event) => {
  2576. event.stopPropagation();
  2577. update();
  2578. });
  2579. }
  2580. if ('options' in node) {
  2581. _option__WEBPACK_IMPORTED_MODULE_2__.generate(node);
  2582. }
  2583. valueElement.addEventListener('keydown', (event) => {
  2584. switch (event.key) {
  2585. case 'Enter':
  2586. case 'Escape':
  2587. event.stopPropagation();
  2588. if (_async__WEBPACK_IMPORTED_MODULE_1__.isOngoing()) {
  2589. event.preventDefault();
  2590. }
  2591. else {
  2592. headContainer.focus();
  2593. }
  2594. }
  2595. });
  2596. }
  2597. function shouldMount(node) {
  2598. return 'value' in node;
  2599. }
  2600.  
  2601.  
  2602. /***/ }),
  2603.  
  2604. /***/ "./ts/modal/body/nodes/actions/edit/option/consts.ts":
  2605. /*!***********************************************************!*\
  2606. !*** ./ts/modal/body/nodes/actions/edit/option/consts.ts ***!
  2607. \***********************************************************/
  2608. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2609.  
  2610. __webpack_require__.r(__webpack_exports__);
  2611. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2612. /* harmony export */ OPTION_ACTIVE_CLASS: () => (/* binding */ OPTION_ACTIVE_CLASS),
  2613. /* harmony export */ OPTION_BACKGROUND_CLASS: () => (/* binding */ OPTION_BACKGROUND_CLASS),
  2614. /* harmony export */ OPTION_CLASS: () => (/* binding */ OPTION_CLASS),
  2615. /* harmony export */ OPTION_CONTAINER_CLASS: () => (/* binding */ OPTION_CONTAINER_CLASS),
  2616. /* harmony export */ OPTION_PARENT_CLASS: () => (/* binding */ OPTION_PARENT_CLASS),
  2617. /* harmony export */ OPTION_SHOW_CLASS: () => (/* binding */ OPTION_SHOW_CLASS),
  2618. /* harmony export */ OPTION_WRAPPER_CLASS: () => (/* binding */ OPTION_WRAPPER_CLASS)
  2619. /* harmony export */ });
  2620. const OPTION_CLASS = 'option';
  2621. const OPTION_CONTAINER_CLASS = 'option-container';
  2622. const OPTION_PARENT_CLASS = 'option-parent';
  2623. const OPTION_WRAPPER_CLASS = 'option-wrapper';
  2624. const OPTION_BACKGROUND_CLASS = 'option-background';
  2625. const OPTION_SHOW_CLASS = 'option-show';
  2626. const OPTION_ACTIVE_CLASS = 'option-active';
  2627.  
  2628.  
  2629. /***/ }),
  2630.  
  2631. /***/ "./ts/modal/body/nodes/actions/edit/option/css.ts":
  2632. /*!********************************************************!*\
  2633. !*** ./ts/modal/body/nodes/actions/edit/option/css.ts ***!
  2634. \********************************************************/
  2635. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2636.  
  2637. __webpack_require__.r(__webpack_exports__);
  2638. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2639. /* harmony export */ "default": () => (/* binding */ generate)
  2640. /* harmony export */ });
  2641. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/edit/option/consts.ts");
  2642. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../consts */ "./ts/modal/body/nodes/actions/edit/consts.ts");
  2643. /* harmony import */ var _nodes_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @nodes/consts */ "./ts/modal/body/nodes/consts.ts");
  2644. /* harmony import */ var _modal_body_style_update_depth__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/modal/body/style/update/depth */ "./ts/modal/body/style/update/depth.ts");
  2645. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  2646.  
  2647.  
  2648.  
  2649.  
  2650.  
  2651. function generate() {
  2652. (0,_modal_css__WEBPACK_IMPORTED_MODULE_4__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.OPTION_WRAPPER_CLASS}`, [
  2653. ['z-index', '2'],
  2654. ['position', 'absolute'],
  2655. ['bottom', '0'],
  2656. ['display', 'flex'],
  2657. ['width', '100%'],
  2658. ['pointer-events', 'initial'],
  2659. ]);
  2660. (0,_modal_css__WEBPACK_IMPORTED_MODULE_4__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.OPTION_PARENT_CLASS}`, [
  2661. ['position', 'absolute'],
  2662. ['display', 'flex'],
  2663. ['flex-direction', 'column'],
  2664. ['width', '100%'],
  2665. ['margin-left', '-1px'],
  2666. ['max-height', 'calc(4.2em + 5px)'],
  2667. ['overflow-y', 'auto'],
  2668. ['border-bottom-left-radius', '12px'],
  2669. ]);
  2670. (0,_modal_css__WEBPACK_IMPORTED_MODULE_4__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.OPTION_PARENT_CLASS}:not(.${_consts__WEBPACK_IMPORTED_MODULE_1__.ACTIVE_CLASS} *) `, [['display', 'none']]);
  2671. (0,_modal_css__WEBPACK_IMPORTED_MODULE_4__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.OPTION_CONTAINER_CLASS}`, [['position', 'relative']]);
  2672. (0,_modal_css__WEBPACK_IMPORTED_MODULE_4__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.OPTION_CONTAINER_CLASS} > *`, [['height', '1.4em']]);
  2673. (0,_modal_body_style_update_depth__WEBPACK_IMPORTED_MODULE_3__.addDepthChangeListener)((depth, addRule) => {
  2674. const headSelector = `.${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.DEPTH_CLASS_PREFIX}${depth} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.HEAD_CONTAINER}`;
  2675. addRule(`${headSelector} .${_consts__WEBPACK_IMPORTED_MODULE_0__.OPTION_PARENT_CLASS}`, [['border', `1px solid var(--nodeBase${depth})`]]);
  2676. addRule(`${headSelector} .${_consts__WEBPACK_IMPORTED_MODULE_0__.OPTION_CONTAINER_CLASS}`, [
  2677. ['background-color', `var(--nodeContrast${depth})`],
  2678. ['color', `var(--nodeBase${depth})`],
  2679. ['border', `1px solid var(--nodeBase${depth})`],
  2680. ]);
  2681. addRule(`${headSelector} .${_consts__WEBPACK_IMPORTED_MODULE_0__.OPTION_BACKGROUND_CLASS}`, [['background-color', `var(--nodeBase${depth})`]]);
  2682. addRule(`${headSelector} .${_consts__WEBPACK_IMPORTED_MODULE_0__.OPTION_ACTIVE_CLASS} .${_consts__WEBPACK_IMPORTED_MODULE_0__.OPTION_CLASS}`, [['color', `var(--nodeContrast${depth})`]]);
  2683. addRule(`${headSelector} .${_consts__WEBPACK_IMPORTED_MODULE_0__.OPTION_ACTIVE_CLASS} .${_consts__WEBPACK_IMPORTED_MODULE_0__.OPTION_BACKGROUND_CLASS}`, [['width', '100%']]);
  2684. });
  2685. (0,_modal_css__WEBPACK_IMPORTED_MODULE_4__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.OPTION_CLASS}`, [
  2686. ['position', 'relative'],
  2687. ['transition-property', 'all'],
  2688. ['transition-duration', '500ms'],
  2689. ['padding', '0 0.6rem'],
  2690. ]);
  2691. (0,_modal_css__WEBPACK_IMPORTED_MODULE_4__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.OPTION_BACKGROUND_CLASS}`, [
  2692. ['position', 'absolute'],
  2693. ['width', '0'],
  2694. ['transition', 'width 500ms ease 0s'],
  2695. ]);
  2696. (0,_modal_css__WEBPACK_IMPORTED_MODULE_4__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.OPTION_CONTAINER_CLASS}:not(.${_consts__WEBPACK_IMPORTED_MODULE_0__.OPTION_SHOW_CLASS})`, [['display', 'none']]);
  2697. }
  2698.  
  2699.  
  2700. /***/ }),
  2701.  
  2702. /***/ "./ts/modal/body/nodes/actions/edit/option/index.ts":
  2703. /*!**********************************************************!*\
  2704. !*** ./ts/modal/body/nodes/actions/edit/option/index.ts ***!
  2705. \**********************************************************/
  2706. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2707.  
  2708. __webpack_require__.r(__webpack_exports__);
  2709. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2710. /* harmony export */ generate: () => (/* binding */ generate),
  2711. /* harmony export */ isActive: () => (/* binding */ isActive),
  2712. /* harmony export */ reset: () => (/* binding */ reset),
  2713. /* harmony export */ setNode: () => (/* binding */ setNode),
  2714. /* harmony export */ update: () => (/* binding */ update)
  2715. /* harmony export */ });
  2716. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/edit/option/consts.ts");
  2717. /* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../index */ "./ts/modal/body/nodes/actions/edit/index.ts");
  2718. /* harmony import */ var _nodes_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @nodes/consts */ "./ts/modal/body/nodes/consts.ts");
  2719. /* harmony import */ var _modal_body__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/modal/body */ "./ts/modal/body/index.ts");
  2720.  
  2721.  
  2722.  
  2723.  
  2724. const activeOptions = [];
  2725. let activeIndex = -1;
  2726. function isActive() {
  2727. return activeOptions.some(({ parentElement }) => parentElement.classList.contains(_consts__WEBPACK_IMPORTED_MODULE_0__.OPTION_SHOW_CLASS));
  2728. }
  2729. function getTotalOffsetTop(from) {
  2730. let offsetTop = 2;
  2731. let node;
  2732. for (node = from; !node.classList.contains(_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ROOT_CLASS); node = node.offsetParent) {
  2733. offsetTop += node.offsetTop;
  2734. }
  2735. return offsetTop;
  2736. }
  2737. // source: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions#escaping
  2738. function escapeRegExp(string) {
  2739. return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
  2740. }
  2741. function setActive(option, isActive = true) {
  2742. option.classList[isActive ? 'add' : 'remove'](_consts__WEBPACK_IMPORTED_MODULE_0__.OPTION_ACTIVE_CLASS);
  2743. }
  2744. function deselect() {
  2745. if (activeIndex === -1) {
  2746. return;
  2747. }
  2748. setActive(activeOptions[activeIndex].parentElement, false);
  2749. activeIndex = -1;
  2750. }
  2751. function update(value) {
  2752. const stringValue = `${value}`;
  2753. const regExp = new RegExp(escapeRegExp(stringValue), 'i');
  2754. let hasVisibleChild = false;
  2755. for (const { parentElement, innerText } of activeOptions) {
  2756. if (stringValue.length < innerText.length && regExp.test(innerText)) {
  2757. parentElement.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.OPTION_SHOW_CLASS);
  2758. hasVisibleChild = true;
  2759. }
  2760. else {
  2761. parentElement.classList.remove(_consts__WEBPACK_IMPORTED_MODULE_0__.OPTION_SHOW_CLASS);
  2762. }
  2763. }
  2764. const wrapper = activeOptions[0].parentElement.parentElement;
  2765. if (!hasVisibleChild) {
  2766. wrapper.style.setProperty('display', 'none');
  2767. return;
  2768. }
  2769. wrapper.style.removeProperty('display');
  2770. const totalOffsetTop = getTotalOffsetTop(wrapper);
  2771. if (_modal_body__WEBPACK_IMPORTED_MODULE_3__.element.scrollTop + _modal_body__WEBPACK_IMPORTED_MODULE_3__.element.clientHeight < totalOffsetTop + wrapper.clientHeight) {
  2772. _modal_body__WEBPACK_IMPORTED_MODULE_3__.element.scrollTop = totalOffsetTop + wrapper.clientHeight - _modal_body__WEBPACK_IMPORTED_MODULE_3__.element.clientHeight;
  2773. }
  2774. deselect();
  2775. }
  2776. function setValue(node, value) {
  2777. node.element.contrast.valueElement.value = value;
  2778. (0,_index__WEBPACK_IMPORTED_MODULE_1__.update)();
  2779. deselect();
  2780. }
  2781. function reset() {
  2782. for (const { parentElement } of activeOptions) {
  2783. parentElement.classList.remove(_consts__WEBPACK_IMPORTED_MODULE_0__.OPTION_SHOW_CLASS);
  2784. }
  2785. deselect();
  2786. activeOptions.length = 0;
  2787. }
  2788. function setNode(node) {
  2789. // Using Array.from so typescript doesn't complain
  2790. activeOptions.push(...Array.from(node.element.contrast.valueContainer.querySelectorAll(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.OPTION_CLASS}`)));
  2791. update(node.value);
  2792. }
  2793. function generate(node) {
  2794. const wrapper = document.createElement('div');
  2795. const parent = document.createElement('div');
  2796. for (const value of node.options) {
  2797. const container = document.createElement('div');
  2798. const background = document.createElement('div');
  2799. const option = document.createElement('div');
  2800. option.innerText = value;
  2801. container.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.OPTION_CONTAINER_CLASS);
  2802. option.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.OPTION_CLASS);
  2803. background.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.OPTION_BACKGROUND_CLASS);
  2804. container.append(background, option);
  2805. parent.appendChild(container);
  2806. container.addEventListener('mousedown', (event) => {
  2807. event.stopPropagation();
  2808. event.preventDefault();
  2809. });
  2810. container.addEventListener('click', (event) => {
  2811. event.stopPropagation();
  2812. setValue(node, value);
  2813. });
  2814. container.addEventListener('mouseenter', (event) => {
  2815. event.stopPropagation();
  2816. setActive(container);
  2817. });
  2818. container.addEventListener('mouseleave', (event) => {
  2819. event.stopPropagation();
  2820. setActive(container, false);
  2821. });
  2822. }
  2823. node.element.contrast.valueElement.addEventListener('keydown', (event) => {
  2824. const priorIndex = activeIndex;
  2825. let hasChanged = false;
  2826. switch (event.key) {
  2827. case 'Tab':
  2828. case 'Enter':
  2829. if (activeIndex >= 0) {
  2830. event.stopImmediatePropagation();
  2831. event.preventDefault();
  2832. setValue(node, activeOptions[activeIndex].innerText);
  2833. }
  2834. return;
  2835. case 'ArrowDown':
  2836. for (let i = activeIndex + 1; i < activeOptions.length; ++i) {
  2837. const { parentElement } = activeOptions[i];
  2838. if (parentElement.classList.contains(_consts__WEBPACK_IMPORTED_MODULE_0__.OPTION_SHOW_CLASS)) {
  2839. activeIndex = i;
  2840. hasChanged = true;
  2841. const optionBottom = parentElement.offsetTop + parentElement.clientHeight;
  2842. if (parentElement.parentElement.scrollTop < optionBottom) {
  2843. parentElement.parentElement.scrollTop = optionBottom - parentElement.parentElement.clientHeight;
  2844. }
  2845. const totalOffsetTop = getTotalOffsetTop(parentElement);
  2846. if (_modal_body__WEBPACK_IMPORTED_MODULE_3__.element.scrollTop + _modal_body__WEBPACK_IMPORTED_MODULE_3__.element.clientHeight < totalOffsetTop + parentElement.clientHeight - parentElement.parentElement.scrollTop) {
  2847. _modal_body__WEBPACK_IMPORTED_MODULE_3__.element.scrollTop = totalOffsetTop + parentElement.clientHeight - _modal_body__WEBPACK_IMPORTED_MODULE_3__.element.clientHeight - parentElement.parentElement.scrollTop;
  2848. }
  2849. break;
  2850. }
  2851. }
  2852. break;
  2853. case 'ArrowUp':
  2854. for (let i = activeIndex - 1; i >= 0; --i) {
  2855. const { parentElement } = activeOptions[i];
  2856. if (parentElement.classList.contains(_consts__WEBPACK_IMPORTED_MODULE_0__.OPTION_SHOW_CLASS)) {
  2857. activeIndex = i;
  2858. hasChanged = true;
  2859. // Scroll option list if necessary
  2860. if (parentElement.parentElement.scrollTop > parentElement.offsetTop) {
  2861. parentElement.parentElement.scrollTop = parentElement.offsetTop;
  2862. }
  2863. const totalOffsetTop = getTotalOffsetTop(parentElement);
  2864. // Scroll modal body if necessary
  2865. if (_modal_body__WEBPACK_IMPORTED_MODULE_3__.element.scrollTop > totalOffsetTop - parentElement.parentElement.scrollTop) {
  2866. _modal_body__WEBPACK_IMPORTED_MODULE_3__.element.scrollTop = totalOffsetTop - parentElement.parentElement.scrollTop;
  2867. }
  2868. break;
  2869. }
  2870. }
  2871. if (hasChanged) {
  2872. break;
  2873. }
  2874. // eslint-disable-next-line no-fallthrough
  2875. default:
  2876. if (activeIndex >= 0) {
  2877. setActive(activeOptions[activeIndex].parentElement, false);
  2878. }
  2879. activeIndex = -1;
  2880. return;
  2881. }
  2882. if (!hasChanged) {
  2883. return;
  2884. }
  2885. if (priorIndex >= 0) {
  2886. setActive(activeOptions[priorIndex].parentElement, false);
  2887. }
  2888. const { parentElement } = activeOptions[activeIndex];
  2889. setActive(parentElement);
  2890. });
  2891. wrapper.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.OPTION_WRAPPER_CLASS);
  2892. parent.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.OPTION_PARENT_CLASS);
  2893. wrapper.appendChild(parent);
  2894. node.element.contrast.valueContainer.appendChild(wrapper);
  2895. }
  2896.  
  2897.  
  2898. /***/ }),
  2899.  
  2900. /***/ "./ts/modal/body/nodes/actions/focus/consts.ts":
  2901. /*!*****************************************************!*\
  2902. !*** ./ts/modal/body/nodes/actions/focus/consts.ts ***!
  2903. \*****************************************************/
  2904. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2905.  
  2906. __webpack_require__.r(__webpack_exports__);
  2907. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2908. /* harmony export */ FOCUS_CLASS: () => (/* binding */ FOCUS_CLASS),
  2909. /* harmony export */ FOCUS_SOURCE_CLASS: () => (/* binding */ FOCUS_SOURCE_CLASS)
  2910. /* harmony export */ });
  2911. const FOCUS_CLASS = 'node-focus';
  2912. const FOCUS_SOURCE_CLASS = 'node-focus-source';
  2913.  
  2914.  
  2915. /***/ }),
  2916.  
  2917. /***/ "./ts/modal/body/nodes/actions/focus/css.ts":
  2918. /*!**************************************************!*\
  2919. !*** ./ts/modal/body/nodes/actions/focus/css.ts ***!
  2920. \**************************************************/
  2921. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2922.  
  2923. __webpack_require__.r(__webpack_exports__);
  2924. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2925. /* harmony export */ "default": () => (/* binding */ generate)
  2926. /* harmony export */ });
  2927. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/focus/consts.ts");
  2928. /* harmony import */ var _nodes_consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @nodes/consts */ "./ts/modal/body/nodes/consts.ts");
  2929. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  2930.  
  2931.  
  2932.  
  2933. function generate() {
  2934. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ELEMENT_CLASSES.ELEMENT_CONTAINER}`, ['cursor', 'zoom-in']);
  2935. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ELEMENT_CLASSES.ELEMENT_CONTAINER}.${_consts__WEBPACK_IMPORTED_MODULE_0__.FOCUS_SOURCE_CLASS}`, ['cursor', 'zoom-out']);
  2936. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ROOT_CLASS}.${_consts__WEBPACK_IMPORTED_MODULE_0__.FOCUS_CLASS} .${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ELEMENT_CLASSES.ELEMENT_CONTAINER}:not(.${_consts__WEBPACK_IMPORTED_MODULE_0__.FOCUS_CLASS}):not(.${_consts__WEBPACK_IMPORTED_MODULE_0__.FOCUS_SOURCE_CLASS} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ELEMENT_CLASSES.CHILD_CONTAINER} > *)`, ['display', 'none']);
  2937. // Makes it easy to focus down the tree
  2938. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.FOCUS_SOURCE_CLASS} .${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.MIDDLE_CLASS} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ELEMENT_CLASSES.HEAD_CONTAINER}`, [['margin-left', '1.8em']]);
  2939. }
  2940.  
  2941.  
  2942. /***/ }),
  2943.  
  2944. /***/ "./ts/modal/body/nodes/actions/focus/index.ts":
  2945. /*!****************************************************!*\
  2946. !*** ./ts/modal/body/nodes/actions/focus/index.ts ***!
  2947. \****************************************************/
  2948. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2949.  
  2950. __webpack_require__.r(__webpack_exports__);
  2951. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2952. /* harmony export */ doAction: () => (/* binding */ doAction),
  2953. /* harmony export */ focus: () => (/* binding */ focus),
  2954. /* harmony export */ focusBranch: () => (/* binding */ focusBranch),
  2955. /* harmony export */ isActive: () => (/* binding */ isActive),
  2956. /* harmony export */ mount: () => (/* binding */ mount),
  2957. /* harmony export */ reset: () => (/* binding */ reset),
  2958. /* harmony export */ setTabIndexes: () => (/* binding */ setTabIndexes),
  2959. /* harmony export */ shouldMount: () => (/* binding */ shouldMount),
  2960. /* harmony export */ unmount: () => (/* binding */ unmount)
  2961. /* harmony export */ });
  2962. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/focus/consts.ts");
  2963. /* harmony import */ var _tooltip__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../tooltip */ "./ts/modal/body/nodes/actions/tooltip/index.ts");
  2964. /* harmony import */ var _buttons_position__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../buttons/position */ "./ts/modal/body/nodes/actions/buttons/position/index.ts");
  2965. /* harmony import */ var _highlight__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../highlight */ "./ts/modal/body/nodes/actions/highlight/index.ts");
  2966. /* harmony import */ var _active__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../active */ "./ts/modal/body/nodes/actions/active.ts");
  2967.  
  2968.  
  2969.  
  2970.  
  2971.  
  2972. let candidateNode;
  2973. let activeNode;
  2974. function isActive() {
  2975. return Boolean(activeNode);
  2976. }
  2977. function setTabIndexes(doAdd = true, node = activeNode) {
  2978. const { 'buttonContainer': { 'children': buttons }, contrast: { valueElement } } = node.element;
  2979. for (let i = buttons.length - 1; i >= 0; --i) {
  2980. // Must be set to -1 to prevent tabbing (removeAttribute sets it to 0)
  2981. buttons[i].setAttribute('tabIndex', doAdd ? '1' : '-1');
  2982. }
  2983. if (valueElement) {
  2984. valueElement.setAttribute('tabIndex', doAdd ? '1' : '-1');
  2985. }
  2986. }
  2987. function focus(doFocus = true, node = activeNode, doForce = true) {
  2988. // Avoid unfocusing the active node if not forced
  2989. if (doForce || node !== activeNode) {
  2990. node.element[`${doFocus ? 'add' : 'remove'}Class`](_consts__WEBPACK_IMPORTED_MODULE_0__.FOCUS_SOURCE_CLASS);
  2991. }
  2992. if (!('children' in node)) {
  2993. return;
  2994. }
  2995. }
  2996. function focusBranch(doFocus = true, node = activeNode, focusAncestors = true) {
  2997. node.element[`${doFocus ? 'add' : 'remove'}Class`](_consts__WEBPACK_IMPORTED_MODULE_0__.FOCUS_CLASS);
  2998. if (focusAncestors && 'parent' in node) {
  2999. focusBranch(doFocus, node.parent);
  3000. }
  3001. }
  3002. function reset() {
  3003. if (!activeNode) {
  3004. return;
  3005. }
  3006. focus(false);
  3007. focusBranch(false);
  3008. (0,_highlight__WEBPACK_IMPORTED_MODULE_3__.removeSustained)(activeNode);
  3009. setTabIndexes(false);
  3010. activeNode.element.scrollIntoView();
  3011. activeNode = undefined;
  3012. }
  3013. function doAction(node, doForce = false) {
  3014. const toggleOn = node !== activeNode;
  3015. (0,_tooltip__WEBPACK_IMPORTED_MODULE_1__.kill)();
  3016. // Avoid changing the view when it's already been focused
  3017. if ((0,_buttons_position__WEBPACK_IMPORTED_MODULE_2__.isActive)() || (doForce && !toggleOn)) {
  3018. return;
  3019. }
  3020. reset();
  3021. _active__WEBPACK_IMPORTED_MODULE_4__.register();
  3022. if (toggleOn) {
  3023. activeNode = node;
  3024. node.element.headContainer.focus();
  3025. focus();
  3026. focusBranch();
  3027. (0,_highlight__WEBPACK_IMPORTED_MODULE_3__.addSustained)(node);
  3028. setTabIndexes();
  3029. }
  3030. }
  3031. function unmount(node) {
  3032. if (node === activeNode) {
  3033. reset();
  3034. }
  3035. }
  3036. function mount(node) {
  3037. const { elementContainer, headContainer } = node.element;
  3038. // Handle keyboard input
  3039. elementContainer.addEventListener('keydown', (event) => {
  3040. if (event.key === 'Enter') {
  3041. event.stopPropagation();
  3042. doAction(node);
  3043. }
  3044. });
  3045. // Handle side click
  3046. elementContainer.addEventListener('mousedown', (event) => {
  3047. event.stopPropagation();
  3048. candidateNode = node;
  3049. });
  3050. elementContainer.addEventListener('mouseup', (event) => {
  3051. event.stopPropagation();
  3052. if (node === candidateNode) {
  3053. doAction(node);
  3054. }
  3055. candidateNode = undefined;
  3056. });
  3057. if ('value' in node) {
  3058. headContainer.addEventListener('mousedown', (event) => {
  3059. event.stopPropagation();
  3060. candidateNode = undefined;
  3061. });
  3062. headContainer.addEventListener('mouseup', (event) => {
  3063. event.stopPropagation();
  3064. candidateNode = undefined;
  3065. });
  3066. return;
  3067. }
  3068. // Handle head click
  3069. headContainer.addEventListener('mousedown', (event) => {
  3070. event.stopPropagation();
  3071. candidateNode = node;
  3072. });
  3073. headContainer.addEventListener('mouseup', (event) => {
  3074. event.stopPropagation();
  3075. if (node === candidateNode && headContainer.isSameNode(event.target)) {
  3076. doAction(node);
  3077. }
  3078. candidateNode = undefined;
  3079. });
  3080. }
  3081. function shouldMount() {
  3082. return true;
  3083. }
  3084.  
  3085.  
  3086. /***/ }),
  3087.  
  3088. /***/ "./ts/modal/body/nodes/actions/highlight/consts.ts":
  3089. /*!*********************************************************!*\
  3090. !*** ./ts/modal/body/nodes/actions/highlight/consts.ts ***!
  3091. \*********************************************************/
  3092. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  3093.  
  3094. __webpack_require__.r(__webpack_exports__);
  3095. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  3096. /* harmony export */ EAVE_ID: () => (/* binding */ EAVE_ID),
  3097. /* harmony export */ HIGHLIGHT_BACKGROUND_CLASS: () => (/* binding */ HIGHLIGHT_BACKGROUND_CLASS),
  3098. /* harmony export */ HIGHLIGHT_CLASS: () => (/* binding */ HIGHLIGHT_CLASS)
  3099. /* harmony export */ });
  3100. const HIGHLIGHT_CLASS = 'highlight';
  3101. const HIGHLIGHT_BACKGROUND_CLASS = 'background-highlight';
  3102. const EAVE_ID = 'tree-eave';
  3103.  
  3104.  
  3105. /***/ }),
  3106.  
  3107. /***/ "./ts/modal/body/nodes/actions/highlight/css.ts":
  3108. /*!******************************************************!*\
  3109. !*** ./ts/modal/body/nodes/actions/highlight/css.ts ***!
  3110. \******************************************************/
  3111. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  3112.  
  3113. __webpack_require__.r(__webpack_exports__);
  3114. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  3115. /* harmony export */ "default": () => (/* binding */ generate)
  3116. /* harmony export */ });
  3117. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/highlight/consts.ts");
  3118. /* harmony import */ var _buttons_consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../buttons/consts */ "./ts/modal/body/nodes/actions/buttons/consts.ts");
  3119. /* harmony import */ var _nodes_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @nodes/consts */ "./ts/modal/body/nodes/consts.ts");
  3120. /* harmony import */ var _modal_body_style_update_depth__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/modal/body/style/update/depth */ "./ts/modal/body/style/update/depth.ts");
  3121. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  3122.  
  3123.  
  3124.  
  3125.  
  3126.  
  3127. function generate() {
  3128. (0,_modal_css__WEBPACK_IMPORTED_MODULE_4__.addRule)(`.${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.LABEL_CONTAINER}`, [
  3129. ['padding-right', '0.4em'],
  3130. // Extend the background further into the value
  3131. ['padding-left', '4em'],
  3132. ]);
  3133. (0,_modal_css__WEBPACK_IMPORTED_MODULE_4__.addRule)(`.${_buttons_consts__WEBPACK_IMPORTED_MODULE_1__.BUTTON_CLASS}:last-child`, [
  3134. ['border-top-right-radius', '0.8em'],
  3135. ['border-bottom-right-radius', '0.8em'],
  3136. ]);
  3137. (0,_modal_css__WEBPACK_IMPORTED_MODULE_4__.addRule)([`.${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.BASE_CLASS}`], [
  3138. ['transition-property', 'width'],
  3139. ['transition-duration', '500ms'],
  3140. ['overflow', 'hidden'],
  3141. ['right', '0'],
  3142. ]);
  3143. (0,_modal_css__WEBPACK_IMPORTED_MODULE_4__.addRule)([`.${_consts__WEBPACK_IMPORTED_MODULE_0__.HIGHLIGHT_CLASS} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.HEAD_CONTAINER} .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.BASE_CLASS}`], [['width', '0']]);
  3144. (0,_modal_css__WEBPACK_IMPORTED_MODULE_4__.addRule)(`.${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.BUTTON_CONTAINER}:not(:empty) + * .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.BACKGROUND_CONTAINER} > *`, [['margin-left', '-0.8em']]);
  3145. (0,_modal_css__WEBPACK_IMPORTED_MODULE_4__.addRule)(`.${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.BUTTON_CONTAINER}:not(:empty) + * .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.BACKGROUND_CONTAINER} > .${_consts__WEBPACK_IMPORTED_MODULE_0__.HIGHLIGHT_BACKGROUND_CLASS}`, [
  3146. ['transition-property', 'width, padding-left'],
  3147. ['transition-duration', '500ms'],
  3148. ['width', '0'],
  3149. ]);
  3150. (0,_modal_css__WEBPACK_IMPORTED_MODULE_4__.addRule)([`.${_consts__WEBPACK_IMPORTED_MODULE_0__.HIGHLIGHT_CLASS} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.HEAD_CONTAINER} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.BUTTON_CONTAINER}:not(:empty) + * .${_consts__WEBPACK_IMPORTED_MODULE_0__.HIGHLIGHT_BACKGROUND_CLASS}`], [
  3151. ['width', '100%'],
  3152. ['padding-left', '0.8em'],
  3153. ]);
  3154. (0,_modal_css__WEBPACK_IMPORTED_MODULE_4__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.HIGHLIGHT_BACKGROUND_CLASS}`, [
  3155. ['height', '100%'],
  3156. ['width', '100%'],
  3157. ['padding-left', '0'],
  3158. ]);
  3159. (0,_modal_body_style_update_depth__WEBPACK_IMPORTED_MODULE_3__.addDepthChangeListener)((depth, addRule) => {
  3160. const rootSelector = `.${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.DEPTH_CLASS_PREFIX}${depth}`;
  3161. const headSelector = `${rootSelector} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.HEAD_CONTAINER}`;
  3162. addRule(`${headSelector} .${_consts__WEBPACK_IMPORTED_MODULE_0__.HIGHLIGHT_BACKGROUND_CLASS}`, ['background-color', `var(--nodeContrast${depth})`]);
  3163. addRule(`${headSelector} .${_buttons_consts__WEBPACK_IMPORTED_MODULE_1__.BUTTON_CLASS}`, ['background-color', `var(--nodeContrast${depth})`]);
  3164. addRule([`${headSelector} .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.BASE_CLASS}`], [
  3165. ['color', `var(--nodeContrast${depth})`],
  3166. ['background-color', `var(--nodeBase${depth})`],
  3167. ]);
  3168. addRule([`${headSelector} .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.CONTRAST_CLASS}`], [['color', `var(--nodeBase${depth})`]]);
  3169. addRule(`${headSelector} .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.BASE_CLASS} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.LABEL_CONTAINER}`, [['background-image', `linear-gradient(to right, transparent, 1.9em, var(--nodeBase${depth}) 3.8em)`]]);
  3170. addRule(`${headSelector} .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.CONTRAST_CLASS} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.LABEL_CONTAINER}`, [['background-image', `linear-gradient(to right, transparent, 1.9em, var(--nodeContrast${depth}) 3.8em)`]]);
  3171. });
  3172. (0,_modal_css__WEBPACK_IMPORTED_MODULE_4__.addRule)(`#${_consts__WEBPACK_IMPORTED_MODULE_0__.EAVE_ID}`, [
  3173. ['position', 'absolute'],
  3174. ['bottom', '0'],
  3175. ['width', '100%'],
  3176. ['height', '1px'],
  3177. ]);
  3178. }
  3179.  
  3180.  
  3181. /***/ }),
  3182.  
  3183. /***/ "./ts/modal/body/nodes/actions/highlight/index.ts":
  3184. /*!********************************************************!*\
  3185. !*** ./ts/modal/body/nodes/actions/highlight/index.ts ***!
  3186. \********************************************************/
  3187. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  3188.  
  3189. __webpack_require__.r(__webpack_exports__);
  3190. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  3191. /* harmony export */ addSustained: () => (/* binding */ addSustained),
  3192. /* harmony export */ focusHovered: () => (/* binding */ focusHovered),
  3193. /* harmony export */ generateEave: () => (/* binding */ generateEave),
  3194. /* harmony export */ isActive: () => (/* binding */ isActive),
  3195. /* harmony export */ mount: () => (/* binding */ mount),
  3196. /* harmony export */ onMount: () => (/* binding */ onMount),
  3197. /* harmony export */ removeSustained: () => (/* binding */ removeSustained),
  3198. /* harmony export */ reset: () => (/* binding */ reset),
  3199. /* harmony export */ shouldMount: () => (/* binding */ shouldMount)
  3200. /* harmony export */ });
  3201. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/highlight/consts.ts");
  3202. /* harmony import */ var _edit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../edit */ "./ts/modal/body/nodes/actions/edit/index.ts");
  3203. /* harmony import */ var _focus__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../focus */ "./ts/modal/body/nodes/actions/focus/index.ts");
  3204. /* harmony import */ var _buttons_position__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../buttons/position */ "./ts/modal/body/nodes/actions/buttons/position/index.ts");
  3205. /* harmony import */ var _modal__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/modal */ "./ts/modal/index.ts");
  3206.  
  3207.  
  3208.  
  3209.  
  3210.  
  3211. let sustainedNodes = [];
  3212. let activeNode;
  3213. function focusHovered() {
  3214. if (activeNode) {
  3215. activeNode.element.headContainer.focus();
  3216. }
  3217. }
  3218. function isActive() {
  3219. return Boolean(activeNode);
  3220. }
  3221. function removeSustained(node) {
  3222. sustainedNodes.splice(sustainedNodes.indexOf(node), 1);
  3223. // Avoid unhighlighting if it's still sustained by another action
  3224. if (node !== activeNode && !sustainedNodes.includes(node)) {
  3225. node.element.removeClass(_consts__WEBPACK_IMPORTED_MODULE_0__.HIGHLIGHT_CLASS);
  3226. }
  3227. }
  3228. function addSustained(node) {
  3229. node.element.addClass(_consts__WEBPACK_IMPORTED_MODULE_0__.HIGHLIGHT_CLASS);
  3230. sustainedNodes.push(node);
  3231. }
  3232. function setActive(node, doFocus = false) {
  3233. if (activeNode && !sustainedNodes.includes(activeNode)) {
  3234. activeNode.element.removeClass(_consts__WEBPACK_IMPORTED_MODULE_0__.HIGHLIGHT_CLASS);
  3235. }
  3236. activeNode = node;
  3237. if (node) {
  3238. node.element.addClass(_consts__WEBPACK_IMPORTED_MODULE_0__.HIGHLIGHT_CLASS);
  3239. if (doFocus) {
  3240. node.element.headContainer.focus();
  3241. }
  3242. }
  3243. }
  3244. function mount(node) {
  3245. const { backgroundContainer, headContainer, elementContainer, infoContainer, base } = node.element;
  3246. if (base.valueContainer) {
  3247. (new ResizeObserver(() => {
  3248. base.valueContainer.style.setProperty('width', `${infoContainer.clientWidth}px`);
  3249. })).observe(infoContainer);
  3250. }
  3251. backgroundContainer.appendChild((() => {
  3252. const background = document.createElement('div');
  3253. background.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.HIGHLIGHT_BACKGROUND_CLASS);
  3254. return background;
  3255. })());
  3256. headContainer.setAttribute('tabIndex', '1');
  3257. headContainer.addEventListener('focusin', (event) => {
  3258. event.stopPropagation();
  3259. // Filters out events fired from re-focusing the window
  3260. if (event.relatedTarget) {
  3261. setActive(node);
  3262. }
  3263. });
  3264. headContainer.addEventListener('mouseenter', (event) => {
  3265. event.stopPropagation();
  3266. setActive(node, !((0,_edit__WEBPACK_IMPORTED_MODULE_1__.isActive)() || (0,_focus__WEBPACK_IMPORTED_MODULE_2__.isActive)() || (0,_buttons_position__WEBPACK_IMPORTED_MODULE_3__.isActive)()));
  3267. });
  3268. elementContainer.addEventListener('mouseenter', (event) => {
  3269. event.stopPropagation();
  3270. setActive(node);
  3271. });
  3272. elementContainer.addEventListener('mouseleave', (event) => {
  3273. event.stopPropagation();
  3274. if ('parent' in node) {
  3275. setActive(node.parent);
  3276. }
  3277. else {
  3278. setActive();
  3279. }
  3280. });
  3281. }
  3282. function shouldMount() {
  3283. return true;
  3284. }
  3285. // Prevents zipping to the end of the tree when mousing over the bottom pixel
  3286. function generateEave() {
  3287. const element = document.createElement('div');
  3288. element.id = _consts__WEBPACK_IMPORTED_MODULE_0__.EAVE_ID;
  3289. element.setAttribute('tabIndex', '3');
  3290. // Prevent tabbing away from the modal
  3291. element.addEventListener('keydown', (event) => {
  3292. if (event.key === 'Tab' && !event.shiftKey && element.isSameNode(event.target)) {
  3293. event.preventDefault();
  3294. }
  3295. });
  3296. return element;
  3297. }
  3298. // Blur focused node & reset focus index
  3299. function reset() {
  3300. setActive();
  3301. (0,_modal__WEBPACK_IMPORTED_MODULE_4__.getSocket)().focus();
  3302. }
  3303. function onMount() {
  3304. const socket = (0,_modal__WEBPACK_IMPORTED_MODULE_4__.getSocket)();
  3305. socket.setAttribute('tabIndex', '1');
  3306. // Prevent tabbing away from the modal
  3307. socket.addEventListener('keydown', (event) => {
  3308. if (event.key === 'Tab' && event.shiftKey && socket.isSameNode(event.target)) {
  3309. event.preventDefault();
  3310. }
  3311. });
  3312. socket.addEventListener('focusin', () => {
  3313. setActive();
  3314. });
  3315. }
  3316.  
  3317.  
  3318. /***/ }),
  3319.  
  3320. /***/ "./ts/modal/body/nodes/actions/tooltip/consts.ts":
  3321. /*!*******************************************************!*\
  3322. !*** ./ts/modal/body/nodes/actions/tooltip/consts.ts ***!
  3323. \*******************************************************/
  3324. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  3325.  
  3326. __webpack_require__.r(__webpack_exports__);
  3327. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  3328. /* harmony export */ TOOLTIP_ANIMATION: () => (/* binding */ TOOLTIP_ANIMATION),
  3329. /* harmony export */ TOOLTIP_BOTTOM_CLASS: () => (/* binding */ TOOLTIP_BOTTOM_CLASS),
  3330. /* harmony export */ TOOLTIP_CLASS: () => (/* binding */ TOOLTIP_CLASS),
  3331. /* harmony export */ TOOLTIP_CONTAINER_CLASS: () => (/* binding */ TOOLTIP_CONTAINER_CLASS),
  3332. /* harmony export */ TOOLTIP_REVERSE_CLASS: () => (/* binding */ TOOLTIP_REVERSE_CLASS),
  3333. /* harmony export */ TOOLTIP_TOP_CLASS: () => (/* binding */ TOOLTIP_TOP_CLASS)
  3334. /* harmony export */ });
  3335. const TOOLTIP_CLASS = 'tooltip';
  3336. const TOOLTIP_CONTAINER_CLASS = 'tooltip-container';
  3337. const TOOLTIP_TOP_CLASS = 'tooltip-above';
  3338. const TOOLTIP_BOTTOM_CLASS = 'tooltip-below';
  3339. const TOOLTIP_REVERSE_CLASS = 'tooltip-reverse';
  3340. const TOOLTIP_ANIMATION = [
  3341. [
  3342. // keyframes
  3343. { opacity: 1 },
  3344. { opacity: 1 },
  3345. { opacity: 0 },
  3346. ], { duration: 2000 },
  3347. ];
  3348.  
  3349.  
  3350. /***/ }),
  3351.  
  3352. /***/ "./ts/modal/body/nodes/actions/tooltip/css.ts":
  3353. /*!****************************************************!*\
  3354. !*** ./ts/modal/body/nodes/actions/tooltip/css.ts ***!
  3355. \****************************************************/
  3356. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  3357.  
  3358. __webpack_require__.r(__webpack_exports__);
  3359. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  3360. /* harmony export */ "default": () => (/* binding */ generate)
  3361. /* harmony export */ });
  3362. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/tooltip/consts.ts");
  3363. /* harmony import */ var _nodes_consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @nodes/consts */ "./ts/modal/body/nodes/consts.ts");
  3364. /* harmony import */ var _modal_body_style_update_depth__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/body/style/update/depth */ "./ts/modal/body/style/update/depth.ts");
  3365. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  3366.  
  3367.  
  3368.  
  3369.  
  3370. function generate() {
  3371. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`.${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ELEMENT_CLASSES.VALUE_CONTAINER}`, [['position', 'relative']]);
  3372. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_CONTAINER_CLASS}`, [
  3373. ['position', 'absolute'],
  3374. ['text-align', 'center'],
  3375. ['padding', '0'],
  3376. ['z-index', '2'],
  3377. ['width', '100%'],
  3378. ['pointer-events', 'none'],
  3379. ['white-space', 'normal'],
  3380. ]);
  3381. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)([
  3382. `:not(.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_REVERSE_CLASS}).${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_CONTAINER_CLASS}.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_TOP_CLASS}`,
  3383. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_REVERSE_CLASS}.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_CONTAINER_CLASS}.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_BOTTOM_CLASS}`,
  3384. ], ['bottom', '102%']);
  3385. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)([
  3386. `:not(.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_REVERSE_CLASS}).${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_CONTAINER_CLASS}.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_BOTTOM_CLASS}`,
  3387. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_REVERSE_CLASS}.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_CONTAINER_CLASS}.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_TOP_CLASS}`,
  3388. ], ['top', '102%']);
  3389. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_CLASS}`, [
  3390. ['margin', '0 auto'],
  3391. ['font-size', '0.9em'],
  3392. ['padding', '3px 8px'],
  3393. ['border-radius', '1em'],
  3394. ['width', '10em'],
  3395. ['outline', 'solid 3px var(--borderTooltip)'],
  3396. ]);
  3397. (0,_modal_body_style_update_depth__WEBPACK_IMPORTED_MODULE_2__.addDepthChangeListener)((depth, addRule) => {
  3398. addRule(`.${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.DEPTH_CLASS_PREFIX}${depth} > :not(.${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ELEMENT_CLASSES.CHILD_CONTAINER}) .${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_CLASS}`, [
  3399. ['background-color', `var(--nodeBase${depth})`],
  3400. ['color', `var(--nodeContrast${depth})`],
  3401. ]);
  3402. });
  3403. // Don't show when there's no hint to give
  3404. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)([`.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_CLASS}:empty`], ['display', 'none']);
  3405. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_CLASS}::after`, [
  3406. ['content', '""'],
  3407. ['position', 'absolute'],
  3408. ['left', '50%'],
  3409. ['margin-left', '-0.5em'],
  3410. ['border-width', '0.5em'],
  3411. ['border-style', 'solid'],
  3412. ]);
  3413. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)([
  3414. `:not(.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_REVERSE_CLASS}).${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_TOP_CLASS} > .${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_CLASS}::after`,
  3415. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_REVERSE_CLASS}.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_BOTTOM_CLASS} > .${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_CLASS}::after`,
  3416. ], [
  3417. ['top', '100%'],
  3418. ['border-color', 'var(--borderTooltip) transparent transparent transparent'],
  3419. ]);
  3420. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)([
  3421. `:not(.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_REVERSE_CLASS}).${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_BOTTOM_CLASS} > .${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_CLASS}::after`,
  3422. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_REVERSE_CLASS}.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_TOP_CLASS} > .${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_CLASS}::after`,
  3423. ], [
  3424. ['bottom', '100%'],
  3425. ['border-color', 'transparent transparent var(--borderTooltip) transparent'],
  3426. ]);
  3427. }
  3428.  
  3429.  
  3430. /***/ }),
  3431.  
  3432. /***/ "./ts/modal/body/nodes/actions/tooltip/index.ts":
  3433. /*!******************************************************!*\
  3434. !*** ./ts/modal/body/nodes/actions/tooltip/index.ts ***!
  3435. \******************************************************/
  3436. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  3437.  
  3438. __webpack_require__.r(__webpack_exports__);
  3439. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  3440. /* harmony export */ hide: () => (/* binding */ hide),
  3441. /* harmony export */ kill: () => (/* binding */ kill),
  3442. /* harmony export */ reset: () => (/* binding */ reset),
  3443. /* harmony export */ setNode: () => (/* binding */ setNode),
  3444. /* harmony export */ show: () => (/* binding */ show)
  3445. /* harmony export */ });
  3446. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/tooltip/consts.ts");
  3447. /* harmony import */ var _edit_option__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../edit/option */ "./ts/modal/body/nodes/actions/edit/option/index.ts");
  3448. /* harmony import */ var _nodes_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @nodes/consts */ "./ts/modal/body/nodes/consts.ts");
  3449. /* harmony import */ var _modal_body__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/modal/body */ "./ts/modal/body/index.ts");
  3450.  
  3451.  
  3452.  
  3453.  
  3454. let activeParent;
  3455. let animation;
  3456. function kill() {
  3457. if (animation) {
  3458. animation.finish();
  3459. animation = undefined;
  3460. }
  3461. }
  3462. function isBelowCenter(element, yPosition = 0) {
  3463. if (!element.isSameNode(_modal_body__WEBPACK_IMPORTED_MODULE_3__.element)) {
  3464. if (element.classList.contains(_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.ELEMENT_CONTAINER)) {
  3465. yPosition += element.offsetTop;
  3466. }
  3467. return isBelowCenter(element.parentElement, yPosition);
  3468. }
  3469. const scrollPosition = _modal_body__WEBPACK_IMPORTED_MODULE_3__.element.scrollTop + (_modal_body__WEBPACK_IMPORTED_MODULE_3__.element.clientHeight / 2);
  3470. return scrollPosition < yPosition;
  3471. }
  3472. function generate(parent, doReverse = false) {
  3473. const container = document.createElement('div');
  3474. const element = document.createElement('div');
  3475. container.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_CONTAINER_CLASS);
  3476. element.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_CLASS);
  3477. if (doReverse) {
  3478. container.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_REVERSE_CLASS);
  3479. }
  3480. container.appendChild(element);
  3481. parent.insertBefore(container, parent.firstChild);
  3482. return [container, element];
  3483. }
  3484. function getAnimated(parent) {
  3485. if (!parent) {
  3486. const element = activeParent.querySelector(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_CLASS}`);
  3487. return [element.parentElement, element];
  3488. }
  3489. const [container, element] = generate(parent);
  3490. parent.parentElement.style.setProperty('z-index', '2');
  3491. animation = element.animate(..._consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_ANIMATION);
  3492. animation.onfinish = () => {
  3493. container.remove();
  3494. parent.parentElement.style.removeProperty('z-index');
  3495. };
  3496. return [container, element];
  3497. }
  3498. function show(message, parent) {
  3499. const [container, element] = getAnimated(parent);
  3500. if ((0,_edit_option__WEBPACK_IMPORTED_MODULE_1__.isActive)() || isBelowCenter(container)) {
  3501. container.classList.remove(_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_BOTTOM_CLASS);
  3502. container.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_TOP_CLASS);
  3503. }
  3504. else {
  3505. container.classList.remove(_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_TOP_CLASS);
  3506. container.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_BOTTOM_CLASS);
  3507. }
  3508. element.innerText = message;
  3509. }
  3510. function hide() {
  3511. const element = activeParent.querySelector(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_CLASS}`);
  3512. if (element) {
  3513. element.innerText = '';
  3514. }
  3515. }
  3516. function reset() {
  3517. activeParent.querySelector(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_CONTAINER_CLASS}`).remove();
  3518. activeParent = undefined;
  3519. }
  3520. function setNode(node) {
  3521. const { container, valueElement } = node.element.contrast;
  3522. generate(container, valueElement.type === 'color');
  3523. activeParent = container;
  3524. }
  3525.  
  3526.  
  3527. /***/ }),
  3528.  
  3529. /***/ "./ts/modal/body/nodes/child.ts":
  3530. /*!**************************************!*\
  3531. !*** ./ts/modal/body/nodes/child.ts ***!
  3532. \**************************************/
  3533. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  3534.  
  3535. __webpack_require__.r(__webpack_exports__);
  3536. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  3537. /* harmony export */ "default": () => (/* binding */ Child)
  3538. /* harmony export */ });
  3539. /* harmony import */ var _element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./element */ "./ts/modal/body/nodes/element.ts");
  3540. /* harmony import */ var _actions_highlight__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./actions/highlight */ "./ts/modal/body/nodes/actions/highlight/index.ts");
  3541. /* harmony import */ var _actions_edit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./actions/edit */ "./ts/modal/body/nodes/actions/edit/index.ts");
  3542. /* harmony import */ var _actions_focus__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./actions/focus */ "./ts/modal/body/nodes/actions/focus/index.ts");
  3543. /* harmony import */ var _actions_buttons_disable__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./actions/buttons/disable */ "./ts/modal/body/nodes/actions/buttons/disable/index.ts");
  3544. /* harmony import */ var _actions_buttons_move__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./actions/buttons/move */ "./ts/modal/body/nodes/actions/buttons/move/index.ts");
  3545. /* harmony import */ var _actions_buttons_duplicate__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./actions/buttons/duplicate */ "./ts/modal/body/nodes/actions/buttons/duplicate/index.ts");
  3546. /* harmony import */ var _style_update_depth__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../style/update/depth */ "./ts/modal/body/style/update/depth.ts");
  3547. /* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @types */ "./ts/library/validation/types.ts");
  3548.  
  3549.  
  3550.  
  3551.  
  3552.  
  3553.  
  3554.  
  3555.  
  3556.  
  3557. const SAVED_KEYS = _types__WEBPACK_IMPORTED_MODULE_8__.SAVED_KEYS.filter((key) => key !== 'children');
  3558. const actions = [
  3559. // No button
  3560. _actions_highlight__WEBPACK_IMPORTED_MODULE_1__,
  3561. _actions_focus__WEBPACK_IMPORTED_MODULE_3__,
  3562. _actions_edit__WEBPACK_IMPORTED_MODULE_2__,
  3563. // Button
  3564. _actions_buttons_disable__WEBPACK_IMPORTED_MODULE_4__,
  3565. _actions_buttons_move__WEBPACK_IMPORTED_MODULE_5__,
  3566. _actions_buttons_duplicate__WEBPACK_IMPORTED_MODULE_6__,
  3567. ];
  3568. class Child {
  3569. constructor(data, parent, index) {
  3570. this.isActive = true;
  3571. this.depth = parent.depth + 1;
  3572. this.element = new _element__WEBPACK_IMPORTED_MODULE_0__["default"](data);
  3573. this.element.addDepthClass(this.depth % (0,_style_update_depth__WEBPACK_IMPORTED_MODULE_7__.getDepthClassCount)());
  3574. for (const key of _types__WEBPACK_IMPORTED_MODULE_8__.LEAF_KEYS) {
  3575. if (key in data) {
  3576. this[key] = data[key];
  3577. }
  3578. }
  3579. this.forceValid = !('predicate' in data) && !('options' in data);
  3580. this.attach(parent, index);
  3581. for (const { shouldMount, mount } of actions) {
  3582. if (shouldMount(this)) {
  3583. mount(this);
  3584. }
  3585. }
  3586. }
  3587. getRoot() {
  3588. return this.parent.getRoot();
  3589. }
  3590. getAncestors() {
  3591. return [this.parent, ...this.parent.getAncestors()];
  3592. }
  3593. getIndex() {
  3594. return this.parent.children.indexOf(this);
  3595. }
  3596. getSiblings() {
  3597. const index = this.getIndex();
  3598. const siblings = this.parent.children;
  3599. return [...siblings.slice(0, index), ...siblings.slice(index + 1)];
  3600. }
  3601. updateDepthClass(classCount) {
  3602. this.element.addDepthClass(this.depth % classCount);
  3603. }
  3604. detach() {
  3605. this.parent.children.splice(this.getIndex(), 1);
  3606. this.element.remove();
  3607. this.parent = undefined;
  3608. }
  3609. attach(parent, index = parent.children.length) {
  3610. parent.children.splice(index, 0, this);
  3611. parent.element.addChild(this.element, index);
  3612. this.parent = parent;
  3613. }
  3614. move(parent, to) {
  3615. this.detach();
  3616. this.attach(parent, typeof to === 'number' ? to : to.getIndex() + 1);
  3617. }
  3618. duplicate() {
  3619. return new Child(this.getJSON(), this.parent, this.getIndex() + 1);
  3620. }
  3621. unmount() {
  3622. for (const action of actions) {
  3623. if ('unmount' in action) {
  3624. action.unmount(this);
  3625. }
  3626. }
  3627. }
  3628. disconnect() {
  3629. this.unmount();
  3630. this.detach();
  3631. }
  3632. getJSON() {
  3633. const data = {};
  3634. for (const key of _types__WEBPACK_IMPORTED_MODULE_8__.LEAF_KEYS) {
  3635. if (key in this) {
  3636. data[key] = this[key];
  3637. }
  3638. }
  3639. return data;
  3640. }
  3641. getSaveJSON() {
  3642. const data = {};
  3643. for (const key of SAVED_KEYS) {
  3644. if (key in this) {
  3645. data[key] = this[key];
  3646. }
  3647. }
  3648. return data;
  3649. }
  3650. }
  3651.  
  3652.  
  3653. /***/ }),
  3654.  
  3655. /***/ "./ts/modal/body/nodes/consts.ts":
  3656. /*!***************************************!*\
  3657. !*** ./ts/modal/body/nodes/consts.ts ***!
  3658. \***************************************/
  3659. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  3660.  
  3661. __webpack_require__.r(__webpack_exports__);
  3662. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  3663. /* harmony export */ BASE_CLASS: () => (/* binding */ BASE_CLASS),
  3664. /* harmony export */ CHECKBOX_WRAPPER_CLASS: () => (/* binding */ CHECKBOX_WRAPPER_CLASS),
  3665. /* harmony export */ CONTRAST_CLASS: () => (/* binding */ CONTRAST_CLASS),
  3666. /* harmony export */ DEPTH_CLASS_PREFIX: () => (/* binding */ DEPTH_CLASS_PREFIX),
  3667. /* harmony export */ ELEMENT_CLASSES: () => (/* binding */ ELEMENT_CLASSES),
  3668. /* harmony export */ MIDDLE_CLASS: () => (/* binding */ MIDDLE_CLASS),
  3669. /* harmony export */ ROOT_CLASS: () => (/* binding */ ROOT_CLASS)
  3670. /* harmony export */ });
  3671. const ROOT_CLASS = 'root';
  3672. const MIDDLE_CLASS = 'middle';
  3673. const ELEMENT_CLASSES = {
  3674. ELEMENT_CONTAINER: 'node',
  3675. BACKGROUND_CONTAINER: 'node-background-container',
  3676. CHILD_CONTAINER: 'node-child-container',
  3677. BUTTON_CONTAINER: 'node-button-container',
  3678. INFO_CONTAINER: 'node-info-container',
  3679. HEAD_CONTAINER: 'node-head-container',
  3680. VALUE_CONTAINER: 'node-value-container',
  3681. VALUE: 'node-value',
  3682. LABEL_CONTAINER: 'node-label-container',
  3683. LABEL: 'node-label',
  3684. };
  3685. const DEPTH_CLASS_PREFIX = 'node-depth-';
  3686. const BASE_CLASS = 'node-base';
  3687. const CONTRAST_CLASS = 'node-contrast';
  3688. const CHECKBOX_WRAPPER_CLASS = 'checkbox-wrapper';
  3689.  
  3690.  
  3691. /***/ }),
  3692.  
  3693. /***/ "./ts/modal/body/nodes/css.ts":
  3694. /*!************************************!*\
  3695. !*** ./ts/modal/body/nodes/css.ts ***!
  3696. \************************************/
  3697. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  3698.  
  3699. __webpack_require__.r(__webpack_exports__);
  3700. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  3701. /* harmony export */ "default": () => (/* binding */ generate)
  3702. /* harmony export */ });
  3703. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/consts.ts");
  3704. /* harmony import */ var _style_update_depth__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../style/update/depth */ "./ts/modal/body/style/update/depth.ts");
  3705. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  3706.  
  3707.  
  3708.  
  3709. function generate() {
  3710. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ROOT_CLASS}`, [
  3711. ['flex-grow', '1'],
  3712. // Apparently it has min-height 100% without a content-related height value
  3713. ['height', 'fit-content'],
  3714. ]);
  3715. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.ELEMENT_CONTAINER}:not(.${_consts__WEBPACK_IMPORTED_MODULE_0__.ROOT_CLASS}):first-child`, ['margin-top', '0.7px']);
  3716. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`:not(.${_consts__WEBPACK_IMPORTED_MODULE_0__.ROOT_CLASS}) > .${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.CHILD_CONTAINER}`, ['margin-left', '1.8em']);
  3717. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.ELEMENT_CONTAINER}`, ['position', 'relative']);
  3718. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.ELEMENT_CONTAINER} > :not(.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.CHILD_CONTAINER})`, ['height', '1.6em']);
  3719. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.ELEMENT_CONTAINER}`, [['user-select', 'none']]);
  3720. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.INFO_CONTAINER} > *`], [
  3721. ['position', 'absolute'],
  3722. ['width', '100%'],
  3723. ['height', '100%'],
  3724. ]);
  3725. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.VALUE_CONTAINER}`, `.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.LABEL_CONTAINER}`], [
  3726. ['position', 'absolute'],
  3727. ['white-space', 'nowrap'],
  3728. ]);
  3729. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.INFO_CONTAINER}`, [
  3730. ['width', '100%'],
  3731. ['height', '100%'],
  3732. ['position', 'relative'],
  3733. ]);
  3734. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([`.${_consts__WEBPACK_IMPORTED_MODULE_0__.BASE_CLASS} > .${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.VALUE_CONTAINER}`], [
  3735. ['position', 'absolute'],
  3736. ['right', '0'],
  3737. ['overflow', 'hidden'],
  3738. ]);
  3739. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([
  3740. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.HEAD_CONTAINER}`,
  3741. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.VALUE_CONTAINER}`,
  3742. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.LABEL_CONTAINER}`,
  3743. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.BACKGROUND_CONTAINER}`,
  3744. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.INFO_CONTAINER}`,
  3745. ], [
  3746. ['flex-grow', '1'],
  3747. ['display', 'flex'],
  3748. ['align-items', 'center'],
  3749. ]);
  3750. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.BACKGROUND_CONTAINER}`], [['position', 'absolute']]);
  3751. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.LABEL_CONTAINER}`, [
  3752. ['right', '0'],
  3753. ['pointer-events', 'none'],
  3754. ['height', '100%'],
  3755. ]);
  3756. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.VALUE_CONTAINER}`, [
  3757. ['user-select', 'none'],
  3758. ['height', '100%'],
  3759. ]);
  3760. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.BACKGROUND_CONTAINER}`, `.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.VALUE_CONTAINER}`], [['width', '100%']]);
  3761. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.BACKGROUND_CONTAINER} > *`, [
  3762. ['height', '100%'],
  3763. ['position', 'absolute'],
  3764. ]);
  3765. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.VALUE}`, `.${_consts__WEBPACK_IMPORTED_MODULE_0__.CHECKBOX_WRAPPER_CLASS}`], [
  3766. ['padding-right', '0.6em'],
  3767. ['padding-left', '0.6em'],
  3768. ]);
  3769. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.HEAD_CONTAINER}`, [
  3770. // Puts it above the backgrounds
  3771. ['position', 'relative'],
  3772. ['user-select', 'none'],
  3773. ]);
  3774. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.HEAD_CONTAINER} > *`, [['height', '100%']]);
  3775. (0,_style_update_depth__WEBPACK_IMPORTED_MODULE_1__.addDepthChangeListener)((depth, addRule) => {
  3776. addRule(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.DEPTH_CLASS_PREFIX}${depth}`, [
  3777. ['color', `var(--nodeContrast${depth})`],
  3778. ['background', `var(--nodeBase${depth})`],
  3779. ]);
  3780. addRule(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.DEPTH_CLASS_PREFIX}${depth}`, ['outline', `1px solid var(--nodeContrast${depth})`]);
  3781. addRule(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.DEPTH_CLASS_PREFIX}${depth} > .${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.HEAD_CONTAINER}`, ['outline', `1px solid var(--nodeContrast${depth})`]);
  3782. });
  3783. }
  3784.  
  3785.  
  3786. /***/ }),
  3787.  
  3788. /***/ "./ts/modal/body/nodes/element.ts":
  3789. /*!****************************************!*\
  3790. !*** ./ts/modal/body/nodes/element.ts ***!
  3791. \****************************************/
  3792. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  3793.  
  3794. __webpack_require__.r(__webpack_exports__);
  3795. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  3796. /* harmony export */ "default": () => (/* binding */ Element)
  3797. /* harmony export */ });
  3798. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/consts.ts");
  3799.  
  3800. class Element {
  3801. constructor(data) {
  3802. this.elementContainer = document.createElement('div');
  3803. this.backgroundContainer = document.createElement('div');
  3804. this.headContainer = document.createElement('span');
  3805. this.buttonContainer = document.createElement('span');
  3806. this.infoContainer = document.createElement('span');
  3807. this.base = { container: document.createElement('span') };
  3808. this.contrast = { container: document.createElement('span') };
  3809. this.childContainer = document.createElement('div');
  3810. this.elementContainer.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.ELEMENT_CONTAINER);
  3811. this.backgroundContainer.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.BACKGROUND_CONTAINER);
  3812. this.childContainer.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.CHILD_CONTAINER);
  3813. this.infoContainer.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.INFO_CONTAINER);
  3814. this.headContainer.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.HEAD_CONTAINER);
  3815. this.buttonContainer.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.BUTTON_CONTAINER);
  3816. this.base.container.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.BASE_CLASS);
  3817. this.contrast.container.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.CONTRAST_CLASS);
  3818. if ('value' in data) {
  3819. this.addValueContainer(this.contrast, data);
  3820. this.addValueContainer(this.base, data);
  3821. this.render(data.value);
  3822. }
  3823. if ('label' in data) {
  3824. this.addLabelContainer(this.contrast, data.label);
  3825. this.addLabelContainer(this.base, data.label);
  3826. }
  3827. this.infoContainer.append(this.backgroundContainer, this.contrast.container, this.base.container);
  3828. this.headContainer.append(this.buttonContainer, this.infoContainer);
  3829. this.elementContainer.appendChild(this.headContainer);
  3830. this.elementContainer.appendChild(this.childContainer);
  3831. }
  3832. addLabelContainer({ container }, label) {
  3833. const labelContainer = document.createElement('div');
  3834. const labelElement = document.createElement('span');
  3835. labelContainer.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.LABEL_CONTAINER);
  3836. labelElement.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.LABEL);
  3837. labelElement.innerText = label;
  3838. labelContainer.appendChild(labelElement);
  3839. container.appendChild(labelContainer);
  3840. }
  3841. addValueContainer(field, data) {
  3842. field.valueContainer = document.createElement('label');
  3843. field.valueContainer.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.VALUE_CONTAINER);
  3844. if ('value' in data) {
  3845. field.valueElement = document.createElement('input');
  3846. field.valueElement.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.VALUE);
  3847. field.valueElement.setAttribute('tabIndex', '-1');
  3848. if (typeof data.value === 'boolean') {
  3849. field.valueElement.type = 'checkbox';
  3850. // Positions tooltips below checkboxes
  3851. const valueWrapper = document.createElement('span');
  3852. valueWrapper.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.CHECKBOX_WRAPPER_CLASS);
  3853. valueWrapper.appendChild(field.valueElement);
  3854. field.valueContainer.appendChild(valueWrapper);
  3855. }
  3856. else {
  3857. if (typeof data.value === 'number') {
  3858. field.valueElement.type = 'number';
  3859. // Disables a tooltip implying that decimal values are invalid
  3860. field.valueElement.step = 'any';
  3861. }
  3862. else if ('input' in data) {
  3863. field.valueElement.type = data.input;
  3864. }
  3865. field.valueContainer.appendChild(field.valueElement);
  3866. }
  3867. }
  3868. field.container.appendChild(field.valueContainer);
  3869. }
  3870. render(value) {
  3871. if (typeof value === 'boolean') {
  3872. this.base.valueElement.checked = value;
  3873. this.contrast.valueElement.checked = value;
  3874. }
  3875. else {
  3876. this.base.valueElement.value = value.toString();
  3877. this.contrast.valueElement.value = value.toString();
  3878. }
  3879. }
  3880. addClass(...names) {
  3881. for (const name of names) {
  3882. this.elementContainer.classList.add(name);
  3883. }
  3884. }
  3885. removeClass(...names) {
  3886. for (const name of names) {
  3887. this.elementContainer.classList.remove(name);
  3888. }
  3889. }
  3890. addDepthClass(depth) {
  3891. if (this.depthClass) {
  3892. this.removeClass(this.depthClass);
  3893. }
  3894. const depthClass = `${_consts__WEBPACK_IMPORTED_MODULE_0__.DEPTH_CLASS_PREFIX}${depth}`;
  3895. this.addClass(depthClass);
  3896. this.depthClass = depthClass;
  3897. }
  3898. addChild(child, index) {
  3899. var _a;
  3900. this.childContainer.insertBefore(child.elementContainer, (_a = this.childContainer.children[index]) !== null && _a !== void 0 ? _a : null);
  3901. }
  3902. addButton(button) {
  3903. this.buttonContainer.appendChild(button);
  3904. }
  3905. remove() {
  3906. this.elementContainer.remove();
  3907. }
  3908. scrollIntoView() {
  3909. this.backgroundContainer.scrollIntoView({ block: 'center' });
  3910. }
  3911. }
  3912.  
  3913.  
  3914. /***/ }),
  3915.  
  3916. /***/ "./ts/modal/body/nodes/middle.ts":
  3917. /*!***************************************!*\
  3918. !*** ./ts/modal/body/nodes/middle.ts ***!
  3919. \***************************************/
  3920. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  3921.  
  3922. __webpack_require__.r(__webpack_exports__);
  3923. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  3924. /* harmony export */ "default": () => (/* binding */ Middle)
  3925. /* harmony export */ });
  3926. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/consts.ts");
  3927. /* harmony import */ var _root__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./root */ "./ts/modal/body/nodes/root.ts");
  3928. /* harmony import */ var _child__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./child */ "./ts/modal/body/nodes/child.ts");
  3929. /* harmony import */ var _actions_buttons_create__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./actions/buttons/create */ "./ts/modal/body/nodes/actions/buttons/create/index.ts");
  3930. /* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @types */ "./ts/library/validation/types.ts");
  3931.  
  3932.  
  3933.  
  3934.  
  3935.  
  3936. const MIDDLE_KEYS = _types__WEBPACK_IMPORTED_MODULE_4__.MIDDLE_KEYS.filter((key) => key !== 'children');
  3937. const actions = [_actions_buttons_create__WEBPACK_IMPORTED_MODULE_3__];
  3938. class Middle extends _child__WEBPACK_IMPORTED_MODULE_2__["default"] {
  3939. constructor(data, parent, index) {
  3940. super(data, parent, index);
  3941. this.children = [];
  3942. _root__WEBPACK_IMPORTED_MODULE_1__.setup.call(this, data);
  3943. this.element.addClass(_consts__WEBPACK_IMPORTED_MODULE_0__.MIDDLE_CLASS);
  3944. for (const { shouldMount, mount } of actions) {
  3945. if (shouldMount(this)) {
  3946. mount(this);
  3947. }
  3948. }
  3949. }
  3950. duplicate() {
  3951. return new Middle(this.getJSON(), this.parent, this.getIndex() + 1);
  3952. }
  3953. unmount() {
  3954. super.unmount();
  3955. for (const action of actions) {
  3956. if ('unmount' in action) {
  3957. action.unmount(this);
  3958. }
  3959. }
  3960. }
  3961. disconnect() {
  3962. this.unmount();
  3963. for (const child of this.children) {
  3964. child.disconnect();
  3965. }
  3966. this.detach();
  3967. }
  3968. updateDepthClass(classCount) {
  3969. super.updateDepthClass(classCount);
  3970. for (const child of this.children) {
  3971. child.updateDepthClass(classCount);
  3972. }
  3973. }
  3974. getJSON() {
  3975. const data = {};
  3976. for (const key of MIDDLE_KEYS) {
  3977. if (key in this) {
  3978. data[key] = this[key];
  3979. }
  3980. }
  3981. return Object.assign(Object.assign(Object.assign({}, super.getJSON()), data), { children: this.children.map((child) => child.getJSON()) });
  3982. }
  3983. getSaveJSON() {
  3984. return Object.assign(Object.assign({}, _root__WEBPACK_IMPORTED_MODULE_1__.getSaveJSON.call(this)), super.getSaveJSON());
  3985. }
  3986. }
  3987.  
  3988.  
  3989. /***/ }),
  3990.  
  3991. /***/ "./ts/modal/body/nodes/queue.ts":
  3992. /*!**************************************!*\
  3993. !*** ./ts/modal/body/nodes/queue.ts ***!
  3994. \**************************************/
  3995. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  3996.  
  3997. __webpack_require__.r(__webpack_exports__);
  3998. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  3999. /* harmony export */ onceVisualsUpdate: () => (/* binding */ onceVisualsUpdate)
  4000. /* harmony export */ });
  4001. const queue = [];
  4002. // No idea if this works on all machines/browsers
  4003. function onceVisualsUpdate(callback) {
  4004. if (queue.push(callback) > 1) {
  4005. return;
  4006. }
  4007. // Wait for update to start
  4008. requestAnimationFrame(() => {
  4009. // Wait for everything else to update
  4010. window.setTimeout(() => {
  4011. for (const callback of queue) {
  4012. callback();
  4013. }
  4014. queue.length = 0;
  4015. }, 0);
  4016. });
  4017. }
  4018.  
  4019.  
  4020. /***/ }),
  4021.  
  4022. /***/ "./ts/modal/body/nodes/root.ts":
  4023. /*!*************************************!*\
  4024. !*** ./ts/modal/body/nodes/root.ts ***!
  4025. \*************************************/
  4026. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4027.  
  4028. __webpack_require__.r(__webpack_exports__);
  4029. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4030. /* harmony export */ "default": () => (/* binding */ Root),
  4031. /* harmony export */ getSaveJSON: () => (/* binding */ getSaveJSON),
  4032. /* harmony export */ setup: () => (/* binding */ setup)
  4033. /* harmony export */ });
  4034. /* harmony import */ var _middle__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./middle */ "./ts/modal/body/nodes/middle.ts");
  4035. /* harmony import */ var _child__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./child */ "./ts/modal/body/nodes/child.ts");
  4036. /* harmony import */ var _element__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./element */ "./ts/modal/body/nodes/element.ts");
  4037. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/consts.ts");
  4038. /* harmony import */ var _queue__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./queue */ "./ts/modal/body/nodes/queue.ts");
  4039. /* harmony import */ var _actions_highlight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./actions/highlight */ "./ts/modal/body/nodes/actions/highlight/index.ts");
  4040. /* harmony import */ var _actions_focus__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./actions/focus */ "./ts/modal/body/nodes/actions/focus/index.ts");
  4041. /* harmony import */ var _actions_buttons_create__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./actions/buttons/create */ "./ts/modal/body/nodes/actions/buttons/create/index.ts");
  4042. /* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @types */ "./ts/library/validation/types.ts");
  4043. var __rest = (undefined && undefined.__rest) || function (s, e) {
  4044. var t = {};
  4045. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  4046. t[p] = s[p];
  4047. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  4048. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
  4049. if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
  4050. t[p[i]] = s[p[i]];
  4051. }
  4052. return t;
  4053. };
  4054.  
  4055.  
  4056.  
  4057.  
  4058.  
  4059.  
  4060.  
  4061.  
  4062.  
  4063. const actions = [_actions_highlight__WEBPACK_IMPORTED_MODULE_5__, _actions_focus__WEBPACK_IMPORTED_MODULE_6__, _actions_buttons_create__WEBPACK_IMPORTED_MODULE_7__];
  4064. function getChildSaveJson({ children }) {
  4065. return children.map((child) => child.getSaveJSON());
  4066. }
  4067. function addChildren(children) {
  4068. for (const child of children) {
  4069. if ('children' in child) {
  4070. new _middle__WEBPACK_IMPORTED_MODULE_0__["default"](child, this);
  4071. }
  4072. else {
  4073. new _child__WEBPACK_IMPORTED_MODULE_1__["default"](child, this);
  4074. }
  4075. }
  4076. }
  4077. function setup(_a) {
  4078. var { children } = _a, data = __rest(_a, ["children"]);
  4079. for (const key of _types__WEBPACK_IMPORTED_MODULE_8__.ROOT_PREDICATE_KEYS) {
  4080. if (key in data) {
  4081. this[key] = () => data[key](getChildSaveJson(this));
  4082. }
  4083. }
  4084. for (const key of _types__WEBPACK_IMPORTED_MODULE_8__.ROOT_UPDATE_KEYS) {
  4085. if (key in data) {
  4086. this[key] = () => (0,_queue__WEBPACK_IMPORTED_MODULE_4__.onceVisualsUpdate)(() => data[key](getChildSaveJson(this)));
  4087. }
  4088. }
  4089. for (const key of _types__WEBPACK_IMPORTED_MODULE_8__.ROOT_OTHER_KEYS) {
  4090. if (key in data) {
  4091. this[key] = data[key];
  4092. }
  4093. }
  4094. addChildren.call(this, children);
  4095. }
  4096. function getSaveJSON() {
  4097. return { children: getChildSaveJson(this) };
  4098. }
  4099. class Root {
  4100. constructor(data) {
  4101. this.children = [];
  4102. this.depth = 0;
  4103. this.addChildren = addChildren.bind(this);
  4104. this.getSaveJSON = getSaveJSON.bind(this);
  4105. this.element = new _element__WEBPACK_IMPORTED_MODULE_2__["default"]({});
  4106. this.element.addClass(_consts__WEBPACK_IMPORTED_MODULE_3__.ROOT_CLASS);
  4107. this.element.addDepthClass(0);
  4108. setup.call(this, data);
  4109. for (const { shouldMount, mount } of actions) {
  4110. if (shouldMount(this)) {
  4111. mount(this);
  4112. }
  4113. }
  4114. }
  4115. getRoot() {
  4116. return this;
  4117. }
  4118. getAncestors() {
  4119. return [];
  4120. }
  4121. updateDepthClass(classCount) {
  4122. for (const child of this.children) {
  4123. child.updateDepthClass(classCount);
  4124. }
  4125. }
  4126. }
  4127.  
  4128.  
  4129. /***/ }),
  4130.  
  4131. /***/ "./ts/modal/body/style/consts.ts":
  4132. /*!***************************************!*\
  4133. !*** ./ts/modal/body/style/consts.ts ***!
  4134. \***************************************/
  4135. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4136.  
  4137. __webpack_require__.r(__webpack_exports__);
  4138. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4139. /* harmony export */ DEFAULT_STYLE: () => (/* binding */ DEFAULT_STYLE),
  4140. /* harmony export */ ROOT_ID: () => (/* binding */ ROOT_ID)
  4141. /* harmony export */ });
  4142. const ROOT_ID = 'root-style';
  4143. const DEFAULT_STYLE = {
  4144. fontSize: 18,
  4145. borderTooltip: '#570000',
  4146. borderModal: '#ffffff',
  4147. headBase: '#000000',
  4148. headContrast: 'Black / White',
  4149. headButtonExit: '#f10000',
  4150. headButtonLabel: '#906300',
  4151. headButtonStyle: '#900091',
  4152. headButtonHide: '#00749a',
  4153. headButtonAlt: '#838f00',
  4154. nodeBase: ['#000000'],
  4155. nodeContrast: 'Black / White',
  4156. nodeButtonCreate: '#40ff40',
  4157. nodeButtonDuplicate: '#40ffff',
  4158. nodeButtonMove: '#ac60ff',
  4159. nodeButtonDisable: '#ffd000',
  4160. nodeButtonDelete: '#ff1111',
  4161. validBackground: '#d9ffc0',
  4162. invalidBackground: '#ffb4be',
  4163. };
  4164.  
  4165.  
  4166. /***/ }),
  4167.  
  4168. /***/ "./ts/modal/body/style/css.ts":
  4169. /*!************************************!*\
  4170. !*** ./ts/modal/body/style/css.ts ***!
  4171. \************************************/
  4172. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4173.  
  4174. __webpack_require__.r(__webpack_exports__);
  4175. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4176. /* harmony export */ "default": () => (/* binding */ generate)
  4177. /* harmony export */ });
  4178. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/style/consts.ts");
  4179. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../consts */ "./ts/modal/body/consts.ts");
  4180. /* harmony import */ var _data_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../data/consts */ "./ts/modal/body/data/consts.ts");
  4181. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  4182. /* harmony import */ var _modal_header_actions_style_consts__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/modal/header/actions/style/consts */ "./ts/modal/header/actions/style/consts.ts");
  4183.  
  4184.  
  4185.  
  4186.  
  4187.  
  4188. function generate() {
  4189. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`#${_consts__WEBPACK_IMPORTED_MODULE_1__.MODAL_BODY_ID}.${_modal_header_actions_style_consts__WEBPACK_IMPORTED_MODULE_4__.ACTION_ID} > #${_data_consts__WEBPACK_IMPORTED_MODULE_2__.ROOT_ID}`, ['display', 'none']);
  4190. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`#${_consts__WEBPACK_IMPORTED_MODULE_1__.MODAL_BODY_ID}:not(.${_modal_header_actions_style_consts__WEBPACK_IMPORTED_MODULE_4__.ACTION_ID}) > #${_consts__WEBPACK_IMPORTED_MODULE_0__.ROOT_ID}`, ['display', 'none']);
  4191. }
  4192.  
  4193.  
  4194. /***/ }),
  4195.  
  4196. /***/ "./ts/modal/body/style/index.ts":
  4197. /*!**************************************!*\
  4198. !*** ./ts/modal/body/style/index.ts ***!
  4199. \**************************************/
  4200. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4201.  
  4202. __webpack_require__.r(__webpack_exports__);
  4203. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4204. /* harmony export */ "default": () => (/* binding */ generate),
  4205. /* harmony export */ getActiveStyle: () => (/* binding */ getActiveStyle),
  4206. /* harmony export */ getRoot: () => (/* binding */ getRoot),
  4207. /* harmony export */ getUserStyles: () => (/* binding */ getUserStyles),
  4208. /* harmony export */ toJSON: () => (/* binding */ toJSON),
  4209. /* harmony export */ toRawStyle: () => (/* binding */ toRawStyle)
  4210. /* harmony export */ });
  4211. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/style/consts.ts");
  4212. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./css */ "./ts/modal/body/style/css.ts");
  4213. /* harmony import */ var _update__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./update */ "./ts/modal/body/style/update/index.ts");
  4214. /* harmony import */ var ___WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! .. */ "./ts/modal/body/index.ts");
  4215. /* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @types */ "./ts/library/validation/types.ts");
  4216.  
  4217.  
  4218.  
  4219.  
  4220.  
  4221. function getRoot() {
  4222. return ___WEBPACK_IMPORTED_MODULE_3__.ROOTS[_consts__WEBPACK_IMPORTED_MODULE_0__.ROOT_ID];
  4223. }
  4224. // Fill any missing entries
  4225. function getFilledStyle(style = {}) {
  4226. return Object.assign(Object.assign({}, _consts__WEBPACK_IMPORTED_MODULE_0__.DEFAULT_STYLE), style);
  4227. }
  4228. function getActiveStyle(userStyles, devStyle) {
  4229. const activeUserStyle = userStyles.find(({ isActive }) => isActive);
  4230. return activeUserStyle !== null && activeUserStyle !== void 0 ? activeUserStyle : getFilledStyle(devStyle);
  4231. }
  4232. function toJSON(style) {
  4233. const filledStyle = Object.assign(Object.assign({}, _consts__WEBPACK_IMPORTED_MODULE_0__.DEFAULT_STYLE), style);
  4234. const toDepthColour = (value) => ({ value, input: 'color' });
  4235. return {
  4236. label: 'Name',
  4237. value: filledStyle.name,
  4238. children: [
  4239. {
  4240. label: 'Style Is Active?',
  4241. value: filledStyle.isActive,
  4242. },
  4243. {
  4244. label: 'Modal',
  4245. children: [
  4246. {
  4247. label: 'Font Size (px)',
  4248. value: filledStyle.fontSize,
  4249. predicate: (value) => value > 0 ? true : 'Font size must be greater than zero',
  4250. },
  4251. {
  4252. label: 'Border Color',
  4253. value: filledStyle.borderModal,
  4254. input: 'color',
  4255. },
  4256. ],
  4257. },
  4258. {
  4259. label: 'Header',
  4260. children: [
  4261. {
  4262. label: 'General',
  4263. children: [
  4264. {
  4265. label: 'Base Color',
  4266. value: filledStyle.headBase,
  4267. input: 'color',
  4268. },
  4269. {
  4270. label: 'Contrast Method',
  4271. value: filledStyle.headContrast,
  4272. options: [..._types__WEBPACK_IMPORTED_MODULE_4__.CONTRAST_METHODS],
  4273. },
  4274. ],
  4275. },
  4276. {
  4277. label: 'Buttons',
  4278. children: [
  4279. {
  4280. label: 'Exit Color',
  4281. value: filledStyle.headButtonExit,
  4282. input: 'color',
  4283. },
  4284. {
  4285. label: 'Label Color',
  4286. value: filledStyle.headButtonLabel,
  4287. input: 'color',
  4288. },
  4289. {
  4290. label: 'Style Color',
  4291. value: filledStyle.headButtonStyle,
  4292. input: 'color',
  4293. },
  4294. {
  4295. label: 'Hide Color',
  4296. value: filledStyle.headButtonHide,
  4297. input: 'color',
  4298. },
  4299. {
  4300. label: 'Alt Buttons Color',
  4301. value: filledStyle.headButtonAlt,
  4302. input: 'color',
  4303. },
  4304. ],
  4305. },
  4306. ],
  4307. },
  4308. {
  4309. label: 'Body',
  4310. children: [
  4311. {
  4312. label: 'General',
  4313. children: [
  4314. {
  4315. label: 'Depth Base Colors',
  4316. seed: toDepthColour(_consts__WEBPACK_IMPORTED_MODULE_0__.DEFAULT_STYLE.nodeBase[0]),
  4317. children: filledStyle.nodeBase.map(toDepthColour),
  4318. childPredicate: (children) => children.length > 0 ? true : 'At least one color must be provided.',
  4319. },
  4320. {
  4321. label: 'Contrast Method',
  4322. value: filledStyle.nodeContrast,
  4323. options: [..._types__WEBPACK_IMPORTED_MODULE_4__.CONTRAST_METHODS],
  4324. },
  4325. ],
  4326. },
  4327. {
  4328. label: 'Buttons',
  4329. children: [
  4330. {
  4331. label: 'Create Color',
  4332. value: filledStyle.nodeButtonCreate,
  4333. input: 'color',
  4334. },
  4335. {
  4336. label: 'Duplicate Color',
  4337. value: filledStyle.nodeButtonDuplicate,
  4338. input: 'color',
  4339. },
  4340. {
  4341. label: 'Move Color',
  4342. value: filledStyle.nodeButtonMove,
  4343. input: 'color',
  4344. },
  4345. {
  4346. label: 'Disable Color',
  4347. value: filledStyle.nodeButtonDisable,
  4348. input: 'color',
  4349. },
  4350. {
  4351. label: 'Delete Color',
  4352. value: filledStyle.nodeButtonDelete,
  4353. input: 'color',
  4354. },
  4355. ],
  4356. },
  4357. {
  4358. label: 'Miscellaneous',
  4359. children: [
  4360. {
  4361. label: 'Valid Color',
  4362. value: filledStyle.validBackground,
  4363. input: 'color',
  4364. },
  4365. {
  4366. label: 'Invalid Color',
  4367. value: filledStyle.invalidBackground,
  4368. input: 'color',
  4369. },
  4370. {
  4371. label: 'Tooltip Color',
  4372. value: filledStyle.borderTooltip,
  4373. input: 'color',
  4374. },
  4375. ],
  4376. },
  4377. ],
  4378. },
  4379. ],
  4380. };
  4381. }
  4382. function toRawStyle(json) {
  4383. const [, modal, header, body] = json.children.map(({ children }) => children);
  4384. const [headerGeneral, headerButtons] = header.map(({ children }) => children);
  4385. const [bodyGeneral, bodyButtons, bodyMisc] = body.map(({ children }) => children);
  4386. return {
  4387. fontSize: modal[0].value,
  4388. borderModal: modal[1].value,
  4389. headBase: headerGeneral[0].value,
  4390. headContrast: headerGeneral[1].value,
  4391. headButtonExit: headerButtons[0].value,
  4392. headButtonLabel: headerButtons[1].value,
  4393. headButtonStyle: headerButtons[2].value,
  4394. headButtonHide: headerButtons[3].value,
  4395. headButtonAlt: headerButtons[4].value,
  4396. nodeBase: bodyGeneral[0].children
  4397. .filter(({ isActive }) => isActive)
  4398. .map((child) => child.value),
  4399. nodeContrast: bodyGeneral[1].value,
  4400. nodeButtonCreate: bodyButtons[0].value,
  4401. nodeButtonDuplicate: bodyButtons[1].value,
  4402. nodeButtonMove: bodyButtons[2].value,
  4403. nodeButtonDisable: bodyButtons[3].value,
  4404. nodeButtonDelete: bodyButtons[4].value,
  4405. validBackground: bodyMisc[0].value,
  4406. invalidBackground: bodyMisc[1].value,
  4407. borderTooltip: bodyMisc[2].value,
  4408. };
  4409. }
  4410. // For returning updated styles to the userscript
  4411. function getUserStyles() {
  4412. const { 'children': styleNodes } = getRoot().getSaveJSON();
  4413. const styles = [];
  4414. for (const json of styleNodes) {
  4415. styles.push(Object.assign({ name: json.value, isActive: json.children[0].value }, toRawStyle(json)));
  4416. }
  4417. return styles;
  4418. }
  4419. function generate(userStyles, devStyle) {
  4420. (0,_css__WEBPACK_IMPORTED_MODULE_1__["default"])();
  4421. const defaultStyle = getFilledStyle(devStyle);
  4422. return (0,___WEBPACK_IMPORTED_MODULE_3__.generateTree)({
  4423. children: userStyles.map(toJSON),
  4424. seed: toJSON(Object.assign({ name: 'New Style', isActive: false }, defaultStyle)),
  4425. descendantPredicate: (styles) => {
  4426. let count = 0;
  4427. for (const { isActive, children: [{ value }] } of styles) {
  4428. if (isActive && value && ++count > 1) {
  4429. return 'Only one color scheme may be active at a time.';
  4430. }
  4431. }
  4432. return true;
  4433. },
  4434. onDescendantUpdate: (styles) => {
  4435. for (const style of styles) {
  4436. if (style.isActive && style.children[0].value) {
  4437. (0,_update__WEBPACK_IMPORTED_MODULE_2__["default"])(toRawStyle(style));
  4438. return;
  4439. }
  4440. }
  4441. (0,_update__WEBPACK_IMPORTED_MODULE_2__["default"])(defaultStyle);
  4442. },
  4443. }, _consts__WEBPACK_IMPORTED_MODULE_0__.ROOT_ID);
  4444. }
  4445.  
  4446.  
  4447. /***/ }),
  4448.  
  4449. /***/ "./ts/modal/body/style/update/depth.ts":
  4450. /*!*********************************************!*\
  4451. !*** ./ts/modal/body/style/update/depth.ts ***!
  4452. \*********************************************/
  4453. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4454.  
  4455. __webpack_require__.r(__webpack_exports__);
  4456. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4457. /* harmony export */ addDepthChangeListener: () => (/* binding */ addDepthChangeListener),
  4458. /* harmony export */ getDepthClassCount: () => (/* binding */ getDepthClassCount),
  4459. /* harmony export */ updateDepth: () => (/* binding */ updateDepth)
  4460. /* harmony export */ });
  4461. /* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../index */ "./ts/modal/body/index.ts");
  4462. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  4463.  
  4464.  
  4465. const STYLESHEET = (0,_modal_css__WEBPACK_IMPORTED_MODULE_1__.generateStylesheet)();
  4466. const callbacks = [];
  4467. let currentClassCount;
  4468. function getDepthClassCount() {
  4469. return currentClassCount;
  4470. }
  4471. function addDepthRule(selectors, styles) {
  4472. (0,_modal_css__WEBPACK_IMPORTED_MODULE_1__.addRule)(selectors, styles, STYLESHEET);
  4473. }
  4474. function addDepthChangeListener(callback) {
  4475. callbacks.push((depth) => callback(depth, addDepthRule));
  4476. for (let i = 0; i < currentClassCount; ++i) {
  4477. callback(i, addDepthRule);
  4478. }
  4479. }
  4480. function updateDepth(depth) {
  4481. for (let i = STYLESHEET.cssRules.length - 1; i >= 0; --i) {
  4482. STYLESHEET.deleteRule(i);
  4483. }
  4484. for (const root of Object.values(_index__WEBPACK_IMPORTED_MODULE_0__.ROOTS)) {
  4485. root.updateDepthClass(depth);
  4486. }
  4487. for (let i = 0; i < depth; ++i) {
  4488. for (const callback of callbacks) {
  4489. callback(i, addDepthRule);
  4490. }
  4491. }
  4492. currentClassCount = depth;
  4493. }
  4494.  
  4495.  
  4496. /***/ }),
  4497.  
  4498. /***/ "./ts/modal/body/style/update/index.ts":
  4499. /*!*********************************************!*\
  4500. !*** ./ts/modal/body/style/update/index.ts ***!
  4501. \*********************************************/
  4502. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4503.  
  4504. __webpack_require__.r(__webpack_exports__);
  4505. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4506. /* harmony export */ "default": () => (/* binding */ updateStylesheet)
  4507. /* harmony export */ });
  4508. /* harmony import */ var _depth__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./depth */ "./ts/modal/body/style/update/depth.ts");
  4509. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  4510. var __rest = (undefined && undefined.__rest) || function (s, e) {
  4511. var t = {};
  4512. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  4513. t[p] = s[p];
  4514. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  4515. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
  4516. if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
  4517. t[p[i]] = s[p[i]];
  4518. }
  4519. return t;
  4520. };
  4521.  
  4522.  
  4523. const STYLESHEET = (0,_modal_css__WEBPACK_IMPORTED_MODULE_1__.generateStylesheet)();
  4524. function getContrast(hex, method) {
  4525. const r = parseInt(hex.slice(1, 3), 16);
  4526. const g = parseInt(hex.slice(3, 5), 16);
  4527. const b = parseInt(hex.slice(5, 7), 16);
  4528. switch (method) {
  4529. case 'Black / White': {
  4530. // https://stackoverflow.com/a/3943023/112731
  4531. const luminosity = r * 0.299 + g * 0.587 + b * 0.114;
  4532. return luminosity > 145 ? 'black' : 'white';
  4533. }
  4534. }
  4535. const toHexPart = (rgb) => {
  4536. const x = (255 - rgb).toString(16);
  4537. return x.length === 2 ? x : `0${x}`;
  4538. };
  4539. return `#${toHexPart(r)}${toHexPart((g))}${toHexPart(b)}`;
  4540. }
  4541. function updateStylesheet(_a) {
  4542. var { fontSize, headContrast, nodeBase, nodeContrast } = _a, colours = __rest(_a, ["fontSize", "headContrast", "nodeBase", "nodeContrast"]);
  4543. for (let i = STYLESHEET.cssRules.length - 1; i >= 0; --i) {
  4544. STYLESHEET.deleteRule(i);
  4545. }
  4546. (0,_depth__WEBPACK_IMPORTED_MODULE_0__.updateDepth)(nodeBase.length);
  4547. (0,_modal_css__WEBPACK_IMPORTED_MODULE_1__.addRule)('', ['font-size', `${fontSize}px`], STYLESHEET);
  4548. const colourStyles = Object.entries(colours).map(([property, value]) => [`--${property}`, value]);
  4549. for (const [depth, baseColour] of nodeBase.entries()) {
  4550. const contrastColour = getContrast(baseColour, nodeContrast);
  4551. colourStyles.push([`--nodeBase${depth}`, baseColour]);
  4552. colourStyles.push([`--nodeContrast${depth}`, contrastColour]);
  4553. }
  4554. colourStyles.push(['--headContrast', getContrast(colours.headBase, headContrast)]);
  4555. colourStyles.push(['--validFont', getContrast(colours.validBackground, nodeContrast)]);
  4556. colourStyles.push(['--invalidFont', getContrast(colours.invalidBackground, nodeContrast)]);
  4557. (0,_modal_css__WEBPACK_IMPORTED_MODULE_1__.addVariables)(colourStyles, STYLESHEET);
  4558. }
  4559.  
  4560.  
  4561. /***/ }),
  4562.  
  4563. /***/ "./ts/modal/consts.ts":
  4564. /*!****************************!*\
  4565. !*** ./ts/modal/consts.ts ***!
  4566. \****************************/
  4567. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4568.  
  4569. __webpack_require__.r(__webpack_exports__);
  4570. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4571. /* harmony export */ BUTTON_ACTIVE_CLASS: () => (/* binding */ BUTTON_ACTIVE_CLASS),
  4572. /* harmony export */ MODAL_BACKGROUND_ID: () => (/* binding */ MODAL_BACKGROUND_ID),
  4573. /* harmony export */ MODAL_ID: () => (/* binding */ MODAL_ID),
  4574. /* harmony export */ SVG_NAMESPACE: () => (/* binding */ SVG_NAMESPACE)
  4575. /* harmony export */ });
  4576. const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
  4577. // Indicates 'on' state for actions that can be turned on and off
  4578. const BUTTON_ACTIVE_CLASS = 'active';
  4579. const MODAL_BACKGROUND_ID = 'modal-background';
  4580. const MODAL_ID = 'modal-content';
  4581.  
  4582.  
  4583. /***/ }),
  4584.  
  4585. /***/ "./ts/modal/css.ts":
  4586. /*!*************************!*\
  4587. !*** ./ts/modal/css.ts ***!
  4588. \*************************/
  4589. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4590.  
  4591. __webpack_require__.r(__webpack_exports__);
  4592. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4593. /* harmony export */ addKeyframe: () => (/* binding */ addKeyframe),
  4594. /* harmony export */ addRule: () => (/* binding */ addRule),
  4595. /* harmony export */ addVariables: () => (/* binding */ addVariables),
  4596. /* harmony export */ "default": () => (/* binding */ generate),
  4597. /* harmony export */ generateStylesheet: () => (/* binding */ generateStylesheet),
  4598. /* harmony export */ getRuleString: () => (/* binding */ getRuleString),
  4599. /* harmony export */ getTargetWindow: () => (/* binding */ getTargetWindow),
  4600. /* harmony export */ setRootId: () => (/* binding */ setRootId)
  4601. /* harmony export */ });
  4602. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/consts.ts");
  4603.  
  4604. let targetWindow = window;
  4605. while (targetWindow.frameElement) {
  4606. targetWindow = window.parent;
  4607. }
  4608. function getTargetWindow() {
  4609. return targetWindow;
  4610. }
  4611. let rootSelector = 'body';
  4612. function setRootId(id) {
  4613. rootSelector = `#${id}`;
  4614. }
  4615. function generateStylesheet() {
  4616. const wrapper = document.createElement('style');
  4617. getTargetWindow().document.head.appendChild(wrapper);
  4618. return wrapper.sheet;
  4619. }
  4620. const STYLESHEET = generateStylesheet();
  4621. function isStyle(candidate) {
  4622. return candidate.length > 0 && typeof candidate[0] === 'string';
  4623. }
  4624. function getStyleString([property, value]) {
  4625. return `${property}:${value};`;
  4626. }
  4627. function getRuleStrings(styles) {
  4628. return isStyle(styles) ? getStyleString(styles) : styles.map(getStyleString).join('');
  4629. }
  4630. function getRuleString(selectors, styles) {
  4631. const styleString = getRuleStrings(styles);
  4632. const selectorString = typeof selectors === 'string' ? selectors : selectors.join(`,${rootSelector} `);
  4633. return `${rootSelector} ${selectorString}{${styleString}}`;
  4634. }
  4635. function addRule(selectors, styles, stylesheet = STYLESHEET) {
  4636. stylesheet.insertRule(getRuleString(selectors, styles));
  4637. }
  4638. function addKeyframe(name, rules, stylesheet = STYLESHEET) {
  4639. const ruleString = rules.map(([selector, styles]) => `${selector}{${getRuleStrings(styles)}}`).join('');
  4640. stylesheet.insertRule(`@keyframes ${name}{${ruleString}}`);
  4641. }
  4642. function addVariables(rules, stylesheet = STYLESHEET) {
  4643. const styleString = rules.map(getStyleString).join('');
  4644. stylesheet.insertRule(`:root{${styleString}}`);
  4645. }
  4646. function generate() {
  4647. addRule(`#${_consts__WEBPACK_IMPORTED_MODULE_0__.MODAL_BACKGROUND_ID}`, [
  4648. ['position', 'fixed'],
  4649. ['left', '0'],
  4650. ['top', '0'],
  4651. ['width', '100%'],
  4652. ['height', '100%'],
  4653. ['background-color', '#0003'],
  4654. ['display', 'flex'],
  4655. ['align-content', 'center'],
  4656. ['flex-wrap', 'wrap'],
  4657. ['justify-content', 'center'],
  4658. ]);
  4659. addRule(`#${_consts__WEBPACK_IMPORTED_MODULE_0__.MODAL_ID}`, [
  4660. ['width', '80%'],
  4661. ['height', '80%'],
  4662. ['font-family', 'Tahoma, Geneva, sans-serif'],
  4663. ['outline', 'var(--borderModal) solid 2px'],
  4664. ['box-shadow', '1px 1px 10px 4px #00000015, 0 0 30px 10px #00000065'],
  4665. ['display', 'flex'],
  4666. ['flex-direction', 'column'],
  4667. ['position', 'relative'],
  4668. ]);
  4669. addRule('button', [
  4670. ['display', 'inline-flex'],
  4671. ['cursor', 'pointer'],
  4672. ['background', 'none'],
  4673. ['font-size', 'inherit'],
  4674. ['padding', '0'],
  4675. ['margin', '0'],
  4676. ['border', 'none'],
  4677. ['outline-offset', '-2px'],
  4678. ]);
  4679. addRule('button *', [['pointer-events', 'none']]);
  4680. addRule('svg', [['fill', 'none']]);
  4681. addRule('input', [
  4682. ['font', 'inherit'],
  4683. ['background', 'inherit'],
  4684. ['color', 'inherit'],
  4685. ['border', 'none'],
  4686. ]);
  4687. addRule(':focus-visible:not(button):not(input)', [['outline', 'none']]);
  4688. addRule('label', [['cursor', 'inherit']]);
  4689. }
  4690.  
  4691.  
  4692. /***/ }),
  4693.  
  4694. /***/ "./ts/modal/header/actions/alternate/button.ts":
  4695. /*!*****************************************************!*\
  4696. !*** ./ts/modal/header/actions/alternate/button.ts ***!
  4697. \*****************************************************/
  4698. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4699.  
  4700. __webpack_require__.r(__webpack_exports__);
  4701. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4702. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  4703. /* harmony export */ });
  4704. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/alternate/consts.ts");
  4705. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../button */ "./ts/modal/header/actions/button.ts");
  4706. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  4707.  
  4708.  
  4709.  
  4710. const ALPHA = Math.PI / 5;
  4711. const RADIUS = 46;
  4712. const points = [];
  4713. // https://stackoverflow.com/questions/14580033/algorithm-for-drawing-a-5-point-star
  4714. for (let i = 0; i < 12; ++i) {
  4715. const r = RADIUS * (i % 2 + 1) / 2;
  4716. const omega = ALPHA * i;
  4717. points.push([r * Math.sin(omega), r * Math.cos(omega)]);
  4718. }
  4719. const outline = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'path');
  4720. outline.setAttribute('stroke-linecap', 'round');
  4721. outline.setAttribute('stroke-width', '7');
  4722. outline.setAttribute('d', points.map(([x, y], i) => `${i === 0 ? 'M' : 'L'} ${x},${y}`).join());
  4723. const g = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'g');
  4724. g.append(outline);
  4725. const BUTTON = (0,_button__WEBPACK_IMPORTED_MODULE_1__.getNewButton)(g, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, 'Toggle Special Buttons');
  4726. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (BUTTON);
  4727.  
  4728.  
  4729. /***/ }),
  4730.  
  4731. /***/ "./ts/modal/header/actions/alternate/consts.ts":
  4732. /*!*****************************************************!*\
  4733. !*** ./ts/modal/header/actions/alternate/consts.ts ***!
  4734. \*****************************************************/
  4735. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4736.  
  4737. __webpack_require__.r(__webpack_exports__);
  4738. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4739. /* harmony export */ ACTION_ID: () => (/* binding */ ACTION_ID)
  4740. /* harmony export */ });
  4741. const ACTION_ID = 'modal-alt';
  4742.  
  4743.  
  4744. /***/ }),
  4745.  
  4746. /***/ "./ts/modal/header/actions/alternate/css.ts":
  4747. /*!**************************************************!*\
  4748. !*** ./ts/modal/header/actions/alternate/css.ts ***!
  4749. \**************************************************/
  4750. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4751.  
  4752. __webpack_require__.r(__webpack_exports__);
  4753. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4754. /* harmony export */ "default": () => (/* binding */ generate)
  4755. /* harmony export */ });
  4756. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/alternate/consts.ts");
  4757. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../css */ "./ts/modal/header/actions/css.ts");
  4758.  
  4759.  
  4760. function generate() {
  4761. (0,_css__WEBPACK_IMPORTED_MODULE_1__.addColourRule)(_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, '--headButtonAlt');
  4762. }
  4763.  
  4764.  
  4765. /***/ }),
  4766.  
  4767. /***/ "./ts/modal/header/actions/alternate/index.ts":
  4768. /*!****************************************************!*\
  4769. !*** ./ts/modal/header/actions/alternate/index.ts ***!
  4770. \****************************************************/
  4771. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4772.  
  4773. __webpack_require__.r(__webpack_exports__);
  4774. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4775. /* harmony export */ "default": () => (/* binding */ generate),
  4776. /* harmony export */ isActive: () => (/* binding */ isActive)
  4777. /* harmony export */ });
  4778. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./button */ "./ts/modal/header/actions/alternate/button.ts");
  4779. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/alternate/consts.ts");
  4780. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./css */ "./ts/modal/header/actions/alternate/css.ts");
  4781. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../button */ "./ts/modal/header/actions/button.ts");
  4782. /* harmony import */ var _modal_body__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/modal/body */ "./ts/modal/body/index.ts");
  4783. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  4784.  
  4785.  
  4786.  
  4787.  
  4788.  
  4789.  
  4790. let _isActive = false;
  4791. let keyHeld = false;
  4792. function isActive() {
  4793. return _isActive;
  4794. }
  4795. function doAction(doActivate = !_isActive) {
  4796. (0,_modal_body__WEBPACK_IMPORTED_MODULE_4__.setActive)(_button__WEBPACK_IMPORTED_MODULE_0__["default"], _consts__WEBPACK_IMPORTED_MODULE_1__.ACTION_ID, doActivate);
  4797. _isActive = doActivate;
  4798. }
  4799. function generate() {
  4800. (0,_css__WEBPACK_IMPORTED_MODULE_2__["default"])();
  4801. (0,_button__WEBPACK_IMPORTED_MODULE_3__.bindAction)(_button__WEBPACK_IMPORTED_MODULE_0__["default"], doAction);
  4802. _button__WEBPACK_IMPORTED_MODULE_0__["default"].title += ' (Ctrl)';
  4803. const targetWindow = (0,_modal_css__WEBPACK_IMPORTED_MODULE_5__.getTargetWindow)();
  4804. targetWindow.addEventListener('keydown', (event) => {
  4805. if (event.key === 'Control') {
  4806. keyHeld = true;
  4807. doAction(true);
  4808. }
  4809. });
  4810. targetWindow.addEventListener('keyup', (event) => {
  4811. if (event.key === 'Control') {
  4812. keyHeld = false;
  4813. doAction(false);
  4814. }
  4815. });
  4816. targetWindow.addEventListener('blur', () => {
  4817. if (keyHeld) {
  4818. keyHeld = false;
  4819. doAction(false);
  4820. }
  4821. });
  4822. return _button__WEBPACK_IMPORTED_MODULE_0__["default"];
  4823. }
  4824.  
  4825.  
  4826. /***/ }),
  4827.  
  4828. /***/ "./ts/modal/header/actions/button.ts":
  4829. /*!*******************************************!*\
  4830. !*** ./ts/modal/header/actions/button.ts ***!
  4831. \*******************************************/
  4832. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4833.  
  4834. __webpack_require__.r(__webpack_exports__);
  4835. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4836. /* harmony export */ bindAction: () => (/* binding */ bindAction),
  4837. /* harmony export */ getNewButton: () => (/* binding */ getNewButton)
  4838. /* harmony export */ });
  4839. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/consts.ts");
  4840. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../consts */ "./ts/modal/consts.ts");
  4841. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  4842.  
  4843.  
  4844.  
  4845. // Adds the template to the DOM
  4846. function bindAction(button, doAction, hotkey) {
  4847. const bound = (event) => {
  4848. event.stopPropagation();
  4849. button.blur();
  4850. doAction();
  4851. };
  4852. button.addEventListener('click', bound);
  4853. if (hotkey) {
  4854. button.title += ` (Alt+${hotkey})`;
  4855. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.getTargetWindow)().addEventListener('keydown', (event) => {
  4856. if (event.altKey && event.key.toUpperCase() === hotkey) {
  4857. bound(event);
  4858. }
  4859. });
  4860. }
  4861. return bound;
  4862. }
  4863. // Creates a template
  4864. const getNewButton = (function () {
  4865. const buttonTemplate = document.createElement('button');
  4866. const svgTemplate = document.createElementNS(_consts__WEBPACK_IMPORTED_MODULE_1__.SVG_NAMESPACE, 'svg');
  4867. buttonTemplate.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS);
  4868. // Prevent tabbing to buttons until node is focused
  4869. buttonTemplate.setAttribute('tabIndex', '2');
  4870. svgTemplate.setAttribute('viewBox', `-70 -70 140 140`);
  4871. return function (group, actionId, description) {
  4872. const button = buttonTemplate.cloneNode(true);
  4873. const svg = svgTemplate.cloneNode(true);
  4874. button.id = actionId;
  4875. button.title = description;
  4876. svg.append(group);
  4877. button.append(svg);
  4878. return button;
  4879. };
  4880. })();
  4881.  
  4882.  
  4883. /***/ }),
  4884.  
  4885. /***/ "./ts/modal/header/actions/close/button.ts":
  4886. /*!*************************************************!*\
  4887. !*** ./ts/modal/header/actions/close/button.ts ***!
  4888. \*************************************************/
  4889. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4890.  
  4891. __webpack_require__.r(__webpack_exports__);
  4892. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4893. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  4894. /* harmony export */ });
  4895. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/close/consts.ts");
  4896. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../button */ "./ts/modal/header/actions/button.ts");
  4897. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  4898.  
  4899.  
  4900.  
  4901. const line0 = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'line');
  4902. line0.setAttribute('stroke-linecap', 'round');
  4903. line0.setAttribute('stroke-width', '12');
  4904. line0.setAttribute('x1', '-30');
  4905. line0.setAttribute('x2', '30');
  4906. line0.setAttribute('y1', '-30');
  4907. line0.setAttribute('y2', '30');
  4908. const line1 = line0.cloneNode(true);
  4909. line1.setAttribute('transform', 'rotate(90 0 0)');
  4910. const g = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'g');
  4911. g.append(line0, line1);
  4912. const BUTTON = (0,_button__WEBPACK_IMPORTED_MODULE_1__.getNewButton)(g, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, 'Save & Exit');
  4913. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (BUTTON);
  4914.  
  4915.  
  4916. /***/ }),
  4917.  
  4918. /***/ "./ts/modal/header/actions/close/consts.ts":
  4919. /*!*************************************************!*\
  4920. !*** ./ts/modal/header/actions/close/consts.ts ***!
  4921. \*************************************************/
  4922. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4923.  
  4924. __webpack_require__.r(__webpack_exports__);
  4925. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4926. /* harmony export */ ACTION_ID: () => (/* binding */ ACTION_ID),
  4927. /* harmony export */ HOTKEY: () => (/* binding */ HOTKEY)
  4928. /* harmony export */ });
  4929. const ACTION_ID = 'modal-close';
  4930. const HOTKEY = 'X';
  4931.  
  4932.  
  4933. /***/ }),
  4934.  
  4935. /***/ "./ts/modal/header/actions/close/css.ts":
  4936. /*!**********************************************!*\
  4937. !*** ./ts/modal/header/actions/close/css.ts ***!
  4938. \**********************************************/
  4939. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4940.  
  4941. __webpack_require__.r(__webpack_exports__);
  4942. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4943. /* harmony export */ "default": () => (/* binding */ generate)
  4944. /* harmony export */ });
  4945. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/close/consts.ts");
  4946. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  4947.  
  4948.  
  4949. function generate() {
  4950. (0,_modal_css__WEBPACK_IMPORTED_MODULE_1__.addRule)([
  4951. `#${_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID}:focus > svg`,
  4952. `#${_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID}:hover > svg`,
  4953. ], ['background-color', 'var(--headButtonExit)']);
  4954. }
  4955.  
  4956.  
  4957. /***/ }),
  4958.  
  4959. /***/ "./ts/modal/header/actions/close/index.ts":
  4960. /*!************************************************!*\
  4961. !*** ./ts/modal/header/actions/close/index.ts ***!
  4962. \************************************************/
  4963. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4964.  
  4965. __webpack_require__.r(__webpack_exports__);
  4966. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4967. /* harmony export */ "default": () => (/* binding */ generate),
  4968. /* harmony export */ setCallback: () => (/* binding */ setCallback)
  4969. /* harmony export */ });
  4970. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./button */ "./ts/modal/header/actions/close/button.ts");
  4971. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/close/consts.ts");
  4972. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./css */ "./ts/modal/header/actions/close/css.ts");
  4973. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../button */ "./ts/modal/header/actions/button.ts");
  4974. /* harmony import */ var _modal_body_data__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/modal/body/data */ "./ts/modal/body/data/index.ts");
  4975. /* harmony import */ var _modal_body_style__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @/modal/body/style */ "./ts/modal/body/style/index.ts");
  4976. /* harmony import */ var _nodes_actions_focus__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @nodes/actions/focus */ "./ts/modal/body/nodes/actions/focus/index.ts");
  4977. /* harmony import */ var _nodes_actions_edit__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @nodes/actions/edit */ "./ts/modal/body/nodes/actions/edit/index.ts");
  4978. /* harmony import */ var _nodes_actions_buttons_move__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @nodes/actions/buttons/move */ "./ts/modal/body/nodes/actions/buttons/move/index.ts");
  4979. /* harmony import */ var _nodes_actions_highlight__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! @nodes/actions/highlight */ "./ts/modal/body/nodes/actions/highlight/index.ts");
  4980. /* harmony import */ var _modal_body__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! @/modal/body */ "./ts/modal/body/index.ts");
  4981.  
  4982.  
  4983.  
  4984.  
  4985.  
  4986.  
  4987.  
  4988.  
  4989.  
  4990.  
  4991.  
  4992. let callback;
  4993. function setCallback(_callback) {
  4994. callback = _callback;
  4995. }
  4996. // TODO Maybe add a white, 0.5 opacity foreground over everything with a loading symbol.
  4997. // Do the same when waiting for a config.
  4998. // Prevent interaction during loading by adding a stopPropagation click listener to the foreground.
  4999. function doAction() {
  5000. (0,_nodes_actions_focus__WEBPACK_IMPORTED_MODULE_6__.reset)();
  5001. (0,_nodes_actions_edit__WEBPACK_IMPORTED_MODULE_7__.reset)();
  5002. (0,_nodes_actions_buttons_move__WEBPACK_IMPORTED_MODULE_8__.reset)();
  5003. (0,_nodes_actions_highlight__WEBPACK_IMPORTED_MODULE_9__.reset)();
  5004. _modal_body__WEBPACK_IMPORTED_MODULE_10__.element.scroll(0, 0);
  5005. callback === null || callback === void 0 ? void 0 : callback({
  5006. tree: (0,_modal_body_data__WEBPACK_IMPORTED_MODULE_4__.getRoot)().getSaveJSON(),
  5007. styles: (0,_modal_body_style__WEBPACK_IMPORTED_MODULE_5__.getUserStyles)(),
  5008. });
  5009. callback = undefined;
  5010. }
  5011. function generate(background) {
  5012. (0,_css__WEBPACK_IMPORTED_MODULE_2__["default"])();
  5013. (0,_button__WEBPACK_IMPORTED_MODULE_3__.bindAction)(_button__WEBPACK_IMPORTED_MODULE_0__["default"], doAction, _consts__WEBPACK_IMPORTED_MODULE_1__.HOTKEY);
  5014. background.addEventListener('click', (event) => {
  5015. if (background.isSameNode(event.target)) {
  5016. doAction();
  5017. }
  5018. });
  5019. return _button__WEBPACK_IMPORTED_MODULE_0__["default"];
  5020. }
  5021.  
  5022.  
  5023. /***/ }),
  5024.  
  5025. /***/ "./ts/modal/header/actions/consts.ts":
  5026. /*!*******************************************!*\
  5027. !*** ./ts/modal/header/actions/consts.ts ***!
  5028. \*******************************************/
  5029. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5030.  
  5031. __webpack_require__.r(__webpack_exports__);
  5032. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5033. /* harmony export */ BUTTON_CLASS: () => (/* binding */ BUTTON_CLASS),
  5034. /* harmony export */ BUTTON_CONTAINER_ID: () => (/* binding */ BUTTON_CONTAINER_ID)
  5035. /* harmony export */ });
  5036. const BUTTON_CLASS = 'modal-button';
  5037. const BUTTON_CONTAINER_ID = 'modal-button-container';
  5038.  
  5039.  
  5040. /***/ }),
  5041.  
  5042. /***/ "./ts/modal/header/actions/css.ts":
  5043. /*!****************************************!*\
  5044. !*** ./ts/modal/header/actions/css.ts ***!
  5045. \****************************************/
  5046. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5047.  
  5048. __webpack_require__.r(__webpack_exports__);
  5049. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5050. /* harmony export */ addColourRule: () => (/* binding */ addColourRule),
  5051. /* harmony export */ "default": () => (/* binding */ generate)
  5052. /* harmony export */ });
  5053. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/consts.ts");
  5054. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../consts */ "./ts/modal/consts.ts");
  5055. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../css */ "./ts/modal/css.ts");
  5056.  
  5057.  
  5058.  
  5059. const ACTIVE_SELECTOR = `.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}.${_consts__WEBPACK_IMPORTED_MODULE_1__.BUTTON_ACTIVE_CLASS}`;
  5060. function addColourRule(actionId, colour) {
  5061. (0,_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`#${actionId}${ACTIVE_SELECTOR} > svg`, [['fill', `var(${colour})`]]);
  5062. (0,_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([`#${actionId}${ACTIVE_SELECTOR}:not(:hover):not(:focus) > svg`], [['stroke', `var(${colour})`]]);
  5063. }
  5064. function generate() {
  5065. (0,_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`#${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CONTAINER_ID}`, [
  5066. ['display', 'inline-flex'],
  5067. ['flex-direction', 'row-reverse'],
  5068. ['max-width', '80%'],
  5069. ['overflow-x', 'scroll'],
  5070. ['scrollbar-width', 'none'],
  5071. ['overscroll-behavior', 'contain'],
  5072. ]);
  5073. (0,_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([
  5074. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}:focus > svg`,
  5075. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}:hover > svg`,
  5076. `${ACTIVE_SELECTOR} > svg`,
  5077. ], ['background-color', `var(--headContrast)`]);
  5078. (0,_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}`, ['border-left', '2px solid var(--headContrast)']);
  5079. (0,_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([
  5080. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}:not(:first-child):focus`,
  5081. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}:not(:first-child):hover`,
  5082. `${ACTIVE_SELECTOR}:not(:first-child)`,
  5083. ], ['border-color', 'var(--headBase)']);
  5084. (0,_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([
  5085. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}:focus > svg`,
  5086. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}:hover > svg`,
  5087. ], ['stroke', `var(--headBase)`]);
  5088. (0,_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS} > svg`, [
  5089. ['width', '1.7em'],
  5090. ['stroke', 'var(--headContrast)'],
  5091. ['fill', `var(--headContrast)`],
  5092. // Fixes pixel gap between button border & svg
  5093. ['margin-left', '-0.5px'],
  5094. ]);
  5095. }
  5096.  
  5097.  
  5098. /***/ }),
  5099.  
  5100. /***/ "./ts/modal/header/actions/hide/button.ts":
  5101. /*!************************************************!*\
  5102. !*** ./ts/modal/header/actions/hide/button.ts ***!
  5103. \************************************************/
  5104. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5105.  
  5106. __webpack_require__.r(__webpack_exports__);
  5107. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5108. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  5109. /* harmony export */ });
  5110. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/hide/consts.ts");
  5111. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../button */ "./ts/modal/header/actions/button.ts");
  5112. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  5113.  
  5114.  
  5115.  
  5116. const edgeTop = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'path');
  5117. edgeTop.setAttribute('stroke-linecap', 'round');
  5118. edgeTop.setAttribute('stroke-width', '7');
  5119. edgeTop.setAttribute('d', 'M -55, 0'
  5120. + 'Q 0,60 55,0');
  5121. edgeTop.setAttribute('fill', 'none');
  5122. const edgeBottom = edgeTop.cloneNode(true);
  5123. edgeBottom.setAttribute('transform', 'scale(1,-1)');
  5124. const circle = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'circle');
  5125. circle.setAttribute('cx', '0');
  5126. circle.setAttribute('cy', '0');
  5127. circle.setAttribute('r', '26');
  5128. circle.setAttribute('stroke-width', '6');
  5129. const g = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'g');
  5130. g.append(edgeTop, edgeBottom, circle);
  5131. const BUTTON = (0,_button__WEBPACK_IMPORTED_MODULE_1__.getNewButton)(g, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, 'Toggle Disabled Node Visibility');
  5132. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (BUTTON);
  5133.  
  5134.  
  5135. /***/ }),
  5136.  
  5137. /***/ "./ts/modal/header/actions/hide/consts.ts":
  5138. /*!************************************************!*\
  5139. !*** ./ts/modal/header/actions/hide/consts.ts ***!
  5140. \************************************************/
  5141. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5142.  
  5143. __webpack_require__.r(__webpack_exports__);
  5144. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5145. /* harmony export */ ACTION_ID: () => (/* binding */ ACTION_ID),
  5146. /* harmony export */ HOTKEY: () => (/* binding */ HOTKEY)
  5147. /* harmony export */ });
  5148. const ACTION_ID = 'modal-hide';
  5149. const HOTKEY = 'H';
  5150.  
  5151.  
  5152. /***/ }),
  5153.  
  5154. /***/ "./ts/modal/header/actions/hide/css.ts":
  5155. /*!*********************************************!*\
  5156. !*** ./ts/modal/header/actions/hide/css.ts ***!
  5157. \*********************************************/
  5158. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5159.  
  5160. __webpack_require__.r(__webpack_exports__);
  5161. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5162. /* harmony export */ "default": () => (/* binding */ generate)
  5163. /* harmony export */ });
  5164. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/hide/consts.ts");
  5165. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../css */ "./ts/modal/header/actions/css.ts");
  5166. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  5167. /* harmony import */ var _modal_body_consts__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/modal/body/consts */ "./ts/modal/body/consts.ts");
  5168. /* harmony import */ var _nodes_actions_buttons_disable_consts__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @nodes/actions/buttons/disable/consts */ "./ts/modal/body/nodes/actions/buttons/disable/consts.ts");
  5169.  
  5170.  
  5171.  
  5172.  
  5173.  
  5174. function generate() {
  5175. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`#${_modal_body_consts__WEBPACK_IMPORTED_MODULE_3__.MODAL_BODY_ID}:not(.${_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID}) .${_nodes_actions_buttons_disable_consts__WEBPACK_IMPORTED_MODULE_4__.DISABLED_CLASS}`, ['display', 'none']);
  5176. (0,_css__WEBPACK_IMPORTED_MODULE_1__.addColourRule)(_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, '--headButtonHide');
  5177. }
  5178.  
  5179.  
  5180. /***/ }),
  5181.  
  5182. /***/ "./ts/modal/header/actions/hide/index.ts":
  5183. /*!***********************************************!*\
  5184. !*** ./ts/modal/header/actions/hide/index.ts ***!
  5185. \***********************************************/
  5186. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5187.  
  5188. __webpack_require__.r(__webpack_exports__);
  5189. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5190. /* harmony export */ "default": () => (/* binding */ generate)
  5191. /* harmony export */ });
  5192. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./button */ "./ts/modal/header/actions/hide/button.ts");
  5193. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/hide/consts.ts");
  5194. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./css */ "./ts/modal/header/actions/hide/css.ts");
  5195. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../button */ "./ts/modal/header/actions/button.ts");
  5196. /* harmony import */ var _modal_body__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/modal/body */ "./ts/modal/body/index.ts");
  5197.  
  5198.  
  5199.  
  5200.  
  5201.  
  5202. let isActive = false;
  5203. function doAction() {
  5204. isActive = !isActive;
  5205. (0,_modal_body__WEBPACK_IMPORTED_MODULE_4__.setActive)(_button__WEBPACK_IMPORTED_MODULE_0__["default"], _consts__WEBPACK_IMPORTED_MODULE_1__.ACTION_ID, isActive);
  5206. }
  5207. function generate() {
  5208. (0,_css__WEBPACK_IMPORTED_MODULE_2__["default"])();
  5209. (0,_button__WEBPACK_IMPORTED_MODULE_3__.bindAction)(_button__WEBPACK_IMPORTED_MODULE_0__["default"], doAction, _consts__WEBPACK_IMPORTED_MODULE_1__.HOTKEY);
  5210. _button__WEBPACK_IMPORTED_MODULE_0__["default"].click();
  5211. return _button__WEBPACK_IMPORTED_MODULE_0__["default"];
  5212. }
  5213.  
  5214.  
  5215. /***/ }),
  5216.  
  5217. /***/ "./ts/modal/header/actions/index.ts":
  5218. /*!******************************************!*\
  5219. !*** ./ts/modal/header/actions/index.ts ***!
  5220. \******************************************/
  5221. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5222.  
  5223. __webpack_require__.r(__webpack_exports__);
  5224. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5225. /* harmony export */ "default": () => (/* binding */ generate)
  5226. /* harmony export */ });
  5227. /* harmony import */ var _close__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./close */ "./ts/modal/header/actions/close/index.ts");
  5228. /* harmony import */ var _labels__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./labels */ "./ts/modal/header/actions/labels/index.ts");
  5229. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./style */ "./ts/modal/header/actions/style/index.ts");
  5230. /* harmony import */ var _hide__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./hide */ "./ts/modal/header/actions/hide/index.ts");
  5231. /* harmony import */ var _alternate__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./alternate */ "./ts/modal/header/actions/alternate/index.ts");
  5232. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./css */ "./ts/modal/header/actions/css.ts");
  5233. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/consts.ts");
  5234.  
  5235.  
  5236.  
  5237.  
  5238.  
  5239.  
  5240.  
  5241. function generate(background) {
  5242. (0,_css__WEBPACK_IMPORTED_MODULE_5__["default"])();
  5243. const element = document.createElement('span');
  5244. element.id = _consts__WEBPACK_IMPORTED_MODULE_6__.BUTTON_CONTAINER_ID;
  5245. element.append((0,_close__WEBPACK_IMPORTED_MODULE_0__["default"])(background), (0,_style__WEBPACK_IMPORTED_MODULE_2__["default"])(), (0,_labels__WEBPACK_IMPORTED_MODULE_1__["default"])(), (0,_hide__WEBPACK_IMPORTED_MODULE_3__["default"])(), (0,_alternate__WEBPACK_IMPORTED_MODULE_4__["default"])());
  5246. return element;
  5247. }
  5248.  
  5249.  
  5250. /***/ }),
  5251.  
  5252. /***/ "./ts/modal/header/actions/labels/button.ts":
  5253. /*!**************************************************!*\
  5254. !*** ./ts/modal/header/actions/labels/button.ts ***!
  5255. \**************************************************/
  5256. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5257.  
  5258. __webpack_require__.r(__webpack_exports__);
  5259. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5260. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  5261. /* harmony export */ });
  5262. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/labels/consts.ts");
  5263. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../button */ "./ts/modal/header/actions/button.ts");
  5264. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  5265.  
  5266.  
  5267.  
  5268. const outline = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'path');
  5269. outline.setAttribute('stroke-linecap', 'round');
  5270. outline.setAttribute('stroke-width', '7');
  5271. outline.setAttribute('d', 'M 20,-30'
  5272. + 'L -40,-30'
  5273. + 'L -40,30'
  5274. + 'L 20,30'
  5275. + 'L 50,0'
  5276. + 'L 20,-30');
  5277. const circle = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'circle');
  5278. circle.setAttribute('stroke-width', '5');
  5279. circle.setAttribute('r', '5');
  5280. circle.setAttribute('cx', '20');
  5281. circle.setAttribute('cy', '0');
  5282. const loop = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'path');
  5283. loop.setAttribute('fill', 'none');
  5284. loop.setAttribute('stroke-linecap', 'round');
  5285. loop.setAttribute('stroke-width', '6');
  5286. loop.setAttribute('d', 'M 20,0'
  5287. + 'C -70,50 -30,50 15,30');
  5288. const g = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'g');
  5289. g.setAttribute('transform', 'rotate(-60 0 0)');
  5290. g.append(outline, circle, loop);
  5291. const BUTTON = (0,_button__WEBPACK_IMPORTED_MODULE_1__.getNewButton)(g, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, 'Toggle Labels');
  5292. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (BUTTON);
  5293.  
  5294.  
  5295. /***/ }),
  5296.  
  5297. /***/ "./ts/modal/header/actions/labels/consts.ts":
  5298. /*!**************************************************!*\
  5299. !*** ./ts/modal/header/actions/labels/consts.ts ***!
  5300. \**************************************************/
  5301. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5302.  
  5303. __webpack_require__.r(__webpack_exports__);
  5304. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5305. /* harmony export */ ACTION_ID: () => (/* binding */ ACTION_ID),
  5306. /* harmony export */ HOTKEY: () => (/* binding */ HOTKEY)
  5307. /* harmony export */ });
  5308. const ACTION_ID = 'modal-labels';
  5309. const HOTKEY = 'N';
  5310.  
  5311.  
  5312. /***/ }),
  5313.  
  5314. /***/ "./ts/modal/header/actions/labels/css.ts":
  5315. /*!***********************************************!*\
  5316. !*** ./ts/modal/header/actions/labels/css.ts ***!
  5317. \***********************************************/
  5318. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5319.  
  5320. __webpack_require__.r(__webpack_exports__);
  5321. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5322. /* harmony export */ "default": () => (/* binding */ generate)
  5323. /* harmony export */ });
  5324. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/labels/consts.ts");
  5325. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../css */ "./ts/modal/header/actions/css.ts");
  5326. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  5327. /* harmony import */ var _modal_body_consts__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/modal/body/consts */ "./ts/modal/body/consts.ts");
  5328. /* harmony import */ var _nodes_consts__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @nodes/consts */ "./ts/modal/body/nodes/consts.ts");
  5329.  
  5330.  
  5331.  
  5332.  
  5333.  
  5334. function generate() {
  5335. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`#${_modal_body_consts__WEBPACK_IMPORTED_MODULE_3__.MODAL_BODY_ID}:not(.${_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID}) .${_nodes_consts__WEBPACK_IMPORTED_MODULE_4__.ELEMENT_CLASSES.LABEL_CONTAINER}`, ['display', 'none']);
  5336. (0,_css__WEBPACK_IMPORTED_MODULE_1__.addColourRule)(_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, '--headButtonLabel');
  5337. }
  5338.  
  5339.  
  5340. /***/ }),
  5341.  
  5342. /***/ "./ts/modal/header/actions/labels/index.ts":
  5343. /*!*************************************************!*\
  5344. !*** ./ts/modal/header/actions/labels/index.ts ***!
  5345. \*************************************************/
  5346. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5347.  
  5348. __webpack_require__.r(__webpack_exports__);
  5349. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5350. /* harmony export */ "default": () => (/* binding */ generate)
  5351. /* harmony export */ });
  5352. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./button */ "./ts/modal/header/actions/labels/button.ts");
  5353. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/labels/consts.ts");
  5354. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./css */ "./ts/modal/header/actions/labels/css.ts");
  5355. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../button */ "./ts/modal/header/actions/button.ts");
  5356. /* harmony import */ var _modal_body__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/modal/body */ "./ts/modal/body/index.ts");
  5357.  
  5358.  
  5359.  
  5360.  
  5361.  
  5362. let isActive = false;
  5363. function doAction() {
  5364. isActive = !isActive;
  5365. (0,_modal_body__WEBPACK_IMPORTED_MODULE_4__.setActive)(_button__WEBPACK_IMPORTED_MODULE_0__["default"], _consts__WEBPACK_IMPORTED_MODULE_1__.ACTION_ID, isActive);
  5366. }
  5367. function generate() {
  5368. (0,_css__WEBPACK_IMPORTED_MODULE_2__["default"])();
  5369. (0,_button__WEBPACK_IMPORTED_MODULE_3__.bindAction)(_button__WEBPACK_IMPORTED_MODULE_0__["default"], doAction, _consts__WEBPACK_IMPORTED_MODULE_1__.HOTKEY);
  5370. _button__WEBPACK_IMPORTED_MODULE_0__["default"].click();
  5371. return _button__WEBPACK_IMPORTED_MODULE_0__["default"];
  5372. }
  5373.  
  5374.  
  5375. /***/ }),
  5376.  
  5377. /***/ "./ts/modal/header/actions/style/button.ts":
  5378. /*!*************************************************!*\
  5379. !*** ./ts/modal/header/actions/style/button.ts ***!
  5380. \*************************************************/
  5381. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5382.  
  5383. __webpack_require__.r(__webpack_exports__);
  5384. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5385. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  5386. /* harmony export */ });
  5387. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/style/consts.ts");
  5388. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../button */ "./ts/modal/header/actions/button.ts");
  5389. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  5390.  
  5391.  
  5392.  
  5393. const handle = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'rect');
  5394. handle.setAttribute('stroke-linecap', 'round');
  5395. handle.setAttribute('stroke-width', '6');
  5396. handle.setAttribute('x', '-5');
  5397. handle.setAttribute('y', '15');
  5398. handle.setAttribute('width', '15');
  5399. handle.setAttribute('height', '40');
  5400. handle.setAttribute('rx', '5');
  5401. const frame = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'path');
  5402. frame.setAttribute('fill', 'none');
  5403. frame.setAttribute('stroke-linecap', 'round');
  5404. frame.setAttribute('stroke-width', '3');
  5405. frame.setAttribute('d', 'M 2.5,15'
  5406. + 'L 2.5,0'
  5407. + 'L -36,-15'
  5408. + 'L -36,-35'
  5409. + 'L -30,-35');
  5410. const curveLeft = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'path');
  5411. curveLeft.setAttribute('fill', 'none');
  5412. curveLeft.setAttribute('stroke-linecap', 'round');
  5413. curveLeft.setAttribute('stroke-width', '6');
  5414. curveLeft.setAttribute('d', 'M -25 -30'
  5415. + 'Q -30,-35 -25,-40');
  5416. const curveRight = curveLeft.cloneNode(true);
  5417. curveRight.setAttribute('transform', 'scale(-1,1) translate(-10,0)');
  5418. const roller = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'rect');
  5419. roller.setAttribute('stroke-linecap', 'round');
  5420. roller.setAttribute('stroke-width', '6');
  5421. roller.setAttribute('x', '-22.5');
  5422. roller.setAttribute('y', '-47.5');
  5423. roller.setAttribute('width', '55');
  5424. roller.setAttribute('height', '25');
  5425. roller.setAttribute('rx', '1');
  5426. const g = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'g');
  5427. g.append(handle, frame, curveLeft, curveRight, roller);
  5428. const BUTTON = (0,_button__WEBPACK_IMPORTED_MODULE_1__.getNewButton)(g, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, 'Toggle Style Editor');
  5429. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (BUTTON);
  5430.  
  5431.  
  5432. /***/ }),
  5433.  
  5434. /***/ "./ts/modal/header/actions/style/consts.ts":
  5435. /*!*************************************************!*\
  5436. !*** ./ts/modal/header/actions/style/consts.ts ***!
  5437. \*************************************************/
  5438. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5439.  
  5440. __webpack_require__.r(__webpack_exports__);
  5441. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5442. /* harmony export */ ACTION_ID: () => (/* binding */ ACTION_ID),
  5443. /* harmony export */ HOTKEY: () => (/* binding */ HOTKEY)
  5444. /* harmony export */ });
  5445. const ACTION_ID = 'modal-style';
  5446. const HOTKEY = 'C';
  5447.  
  5448.  
  5449. /***/ }),
  5450.  
  5451. /***/ "./ts/modal/header/actions/style/css.ts":
  5452. /*!**********************************************!*\
  5453. !*** ./ts/modal/header/actions/style/css.ts ***!
  5454. \**********************************************/
  5455. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5456.  
  5457. __webpack_require__.r(__webpack_exports__);
  5458. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5459. /* harmony export */ "default": () => (/* binding */ generate)
  5460. /* harmony export */ });
  5461. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/style/consts.ts");
  5462. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../css */ "./ts/modal/header/actions/css.ts");
  5463.  
  5464.  
  5465. function generate() {
  5466. (0,_css__WEBPACK_IMPORTED_MODULE_1__.addColourRule)(_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, '--headButtonStyle');
  5467. }
  5468.  
  5469.  
  5470. /***/ }),
  5471.  
  5472. /***/ "./ts/modal/header/actions/style/index.ts":
  5473. /*!************************************************!*\
  5474. !*** ./ts/modal/header/actions/style/index.ts ***!
  5475. \************************************************/
  5476. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5477.  
  5478. __webpack_require__.r(__webpack_exports__);
  5479. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5480. /* harmony export */ "default": () => (/* binding */ generate)
  5481. /* harmony export */ });
  5482. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./button */ "./ts/modal/header/actions/style/button.ts");
  5483. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/style/consts.ts");
  5484. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./css */ "./ts/modal/header/actions/style/css.ts");
  5485. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../button */ "./ts/modal/header/actions/button.ts");
  5486. /* harmony import */ var _modal_body__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/modal/body */ "./ts/modal/body/index.ts");
  5487. /* harmony import */ var _nodes_actions_focus__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @nodes/actions/focus */ "./ts/modal/body/nodes/actions/focus/index.ts");
  5488. /* harmony import */ var _nodes_actions_edit__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @nodes/actions/edit */ "./ts/modal/body/nodes/actions/edit/index.ts");
  5489. /* harmony import */ var _nodes_actions_buttons_move__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @nodes/actions/buttons/move */ "./ts/modal/body/nodes/actions/buttons/move/index.ts");
  5490.  
  5491.  
  5492.  
  5493.  
  5494.  
  5495.  
  5496.  
  5497.  
  5498. let isActive = false;
  5499. function doAction() {
  5500. isActive = !isActive;
  5501. (0,_modal_body__WEBPACK_IMPORTED_MODULE_4__.setActive)(_button__WEBPACK_IMPORTED_MODULE_0__["default"], _consts__WEBPACK_IMPORTED_MODULE_1__.ACTION_ID, isActive);
  5502. (0,_nodes_actions_focus__WEBPACK_IMPORTED_MODULE_5__.reset)();
  5503. (0,_nodes_actions_edit__WEBPACK_IMPORTED_MODULE_6__.reset)();
  5504. (0,_nodes_actions_buttons_move__WEBPACK_IMPORTED_MODULE_7__.reset)();
  5505. // Reset tab index
  5506. document.body.focus();
  5507. }
  5508. function generate() {
  5509. (0,_css__WEBPACK_IMPORTED_MODULE_2__["default"])();
  5510. (0,_button__WEBPACK_IMPORTED_MODULE_3__.bindAction)(_button__WEBPACK_IMPORTED_MODULE_0__["default"], doAction, _consts__WEBPACK_IMPORTED_MODULE_1__.HOTKEY);
  5511. return _button__WEBPACK_IMPORTED_MODULE_0__["default"];
  5512. }
  5513.  
  5514.  
  5515. /***/ }),
  5516.  
  5517. /***/ "./ts/modal/header/consts.ts":
  5518. /*!***********************************!*\
  5519. !*** ./ts/modal/header/consts.ts ***!
  5520. \***********************************/
  5521. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5522.  
  5523. __webpack_require__.r(__webpack_exports__);
  5524. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5525. /* harmony export */ HEADER_ID: () => (/* binding */ HEADER_ID)
  5526. /* harmony export */ });
  5527. const HEADER_ID = 'modal-header';
  5528.  
  5529.  
  5530. /***/ }),
  5531.  
  5532. /***/ "./ts/modal/header/css.ts":
  5533. /*!********************************!*\
  5534. !*** ./ts/modal/header/css.ts ***!
  5535. \********************************/
  5536. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5537.  
  5538. __webpack_require__.r(__webpack_exports__);
  5539. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5540. /* harmony export */ "default": () => (/* binding */ generate)
  5541. /* harmony export */ });
  5542. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/consts.ts");
  5543. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../css */ "./ts/modal/css.ts");
  5544.  
  5545.  
  5546. function generate() {
  5547. (0,_css__WEBPACK_IMPORTED_MODULE_1__.addRule)(`#${_consts__WEBPACK_IMPORTED_MODULE_0__.HEADER_ID}`, [
  5548. ['display', 'flex'],
  5549. ['align-items', 'center'],
  5550. ['background', 'var(--headBase)'],
  5551. ['color', 'var(--headContrast)'],
  5552. ['border-bottom', '2px solid var(--borderModal)'],
  5553. ['font-size', '1.5em'],
  5554. ['text-align', 'center'],
  5555. ]);
  5556. }
  5557.  
  5558.  
  5559. /***/ }),
  5560.  
  5561. /***/ "./ts/modal/header/index.ts":
  5562. /*!**********************************!*\
  5563. !*** ./ts/modal/header/index.ts ***!
  5564. \**********************************/
  5565. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5566.  
  5567. __webpack_require__.r(__webpack_exports__);
  5568. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5569. /* harmony export */ "default": () => (/* binding */ generate)
  5570. /* harmony export */ });
  5571. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/consts.ts");
  5572. /* harmony import */ var _title__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./title */ "./ts/modal/header/title/index.ts");
  5573. /* harmony import */ var _actions__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./actions */ "./ts/modal/header/actions/index.ts");
  5574. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./css */ "./ts/modal/header/css.ts");
  5575.  
  5576.  
  5577.  
  5578.  
  5579. function generate({ title }, background) {
  5580. (0,_css__WEBPACK_IMPORTED_MODULE_3__["default"])();
  5581. const element = document.createElement('div');
  5582. element.id = _consts__WEBPACK_IMPORTED_MODULE_0__.HEADER_ID;
  5583. element.append((0,_title__WEBPACK_IMPORTED_MODULE_1__["default"])(title), (0,_actions__WEBPACK_IMPORTED_MODULE_2__["default"])(background));
  5584. return element;
  5585. }
  5586.  
  5587.  
  5588. /***/ }),
  5589.  
  5590. /***/ "./ts/modal/header/title/consts.ts":
  5591. /*!*****************************************!*\
  5592. !*** ./ts/modal/header/title/consts.ts ***!
  5593. \*****************************************/
  5594. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5595.  
  5596. __webpack_require__.r(__webpack_exports__);
  5597. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5598. /* harmony export */ TITLE_CONTAINER_ID: () => (/* binding */ TITLE_CONTAINER_ID),
  5599. /* harmony export */ TITLE_ID: () => (/* binding */ TITLE_ID)
  5600. /* harmony export */ });
  5601. const TITLE_CONTAINER_ID = 'title-container';
  5602. const TITLE_ID = 'title';
  5603.  
  5604.  
  5605. /***/ }),
  5606.  
  5607. /***/ "./ts/modal/header/title/css.ts":
  5608. /*!**************************************!*\
  5609. !*** ./ts/modal/header/title/css.ts ***!
  5610. \**************************************/
  5611. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5612.  
  5613. __webpack_require__.r(__webpack_exports__);
  5614. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5615. /* harmony export */ "default": () => (/* binding */ generate)
  5616. /* harmony export */ });
  5617. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/title/consts.ts");
  5618. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../css */ "./ts/modal/css.ts");
  5619.  
  5620.  
  5621. function generate() {
  5622. (0,_css__WEBPACK_IMPORTED_MODULE_1__.addRule)(`#${_consts__WEBPACK_IMPORTED_MODULE_0__.TITLE_CONTAINER_ID}`, [
  5623. ['flex-grow', '1'],
  5624. ['white-space', 'nowrap'],
  5625. ['overflow', 'hidden'],
  5626. ['text-overflow', 'ellipsis'],
  5627. ['padding', '0 0.5em'],
  5628. ]);
  5629. }
  5630.  
  5631.  
  5632. /***/ }),
  5633.  
  5634. /***/ "./ts/modal/header/title/index.ts":
  5635. /*!****************************************!*\
  5636. !*** ./ts/modal/header/title/index.ts ***!
  5637. \****************************************/
  5638. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5639.  
  5640. __webpack_require__.r(__webpack_exports__);
  5641. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5642. /* harmony export */ "default": () => (/* binding */ generate)
  5643. /* harmony export */ });
  5644. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/title/consts.ts");
  5645. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./css */ "./ts/modal/header/title/css.ts");
  5646.  
  5647.  
  5648. function generate(title) {
  5649. (0,_css__WEBPACK_IMPORTED_MODULE_1__["default"])();
  5650. const titleContainer = document.createElement('span');
  5651. const titleElement = document.createElement('span');
  5652. titleContainer.id = _consts__WEBPACK_IMPORTED_MODULE_0__.TITLE_CONTAINER_ID;
  5653. titleElement.id = _consts__WEBPACK_IMPORTED_MODULE_0__.TITLE_ID;
  5654. titleElement.innerText = title;
  5655. // In case the text is too long to fit
  5656. titleElement.title = title;
  5657. titleContainer.append(titleElement);
  5658. return titleContainer;
  5659. }
  5660.  
  5661.  
  5662. /***/ }),
  5663.  
  5664. /***/ "./ts/modal/index.ts":
  5665. /*!***************************!*\
  5666. !*** ./ts/modal/index.ts ***!
  5667. \***************************/
  5668. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5669.  
  5670. __webpack_require__.r(__webpack_exports__);
  5671. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5672. /* harmony export */ "default": () => (/* binding */ generate),
  5673. /* harmony export */ getSocket: () => (/* binding */ getSocket)
  5674. /* harmony export */ });
  5675. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/consts.ts");
  5676. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./css */ "./ts/modal/css.ts");
  5677. /* harmony import */ var _header__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./header */ "./ts/modal/header/index.ts");
  5678. /* harmony import */ var _body__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./body */ "./ts/modal/body/index.ts");
  5679. /* harmony import */ var _nodes_actions_highlight__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @nodes/actions/highlight */ "./ts/modal/body/nodes/actions/highlight/index.ts");
  5680.  
  5681.  
  5682.  
  5683.  
  5684.  
  5685. let socket;
  5686. function getSocket() {
  5687. return socket;
  5688. }
  5689. function generate(config, _socket) {
  5690. socket = _socket;
  5691. (0,_css__WEBPACK_IMPORTED_MODULE_1__["default"])();
  5692. const background = document.createElement('div');
  5693. const foreground = document.createElement('div');
  5694. background.id = _consts__WEBPACK_IMPORTED_MODULE_0__.MODAL_BACKGROUND_ID;
  5695. foreground.id = _consts__WEBPACK_IMPORTED_MODULE_0__.MODAL_ID;
  5696. background.append(foreground);
  5697. socket.append(background);
  5698. foreground.append((0,_header__WEBPACK_IMPORTED_MODULE_2__["default"])(config, background), (0,_body__WEBPACK_IMPORTED_MODULE_3__["default"])(config), (0,_nodes_actions_highlight__WEBPACK_IMPORTED_MODULE_4__.generateEave)());
  5699. }
  5700.  
  5701.  
  5702. /***/ }),
  5703.  
  5704. /***/ "./ts/predicate.ts":
  5705. /*!*************************!*\
  5706. !*** ./ts/predicate.ts ***!
  5707. \*************************/
  5708. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5709.  
  5710. __webpack_require__.r(__webpack_exports__);
  5711. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5712. /* harmony export */ getPredicatePromise: () => (/* binding */ getPredicatePromise)
  5713. /* harmony export */ });
  5714. var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
  5715. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  5716. return new (P || (P = Promise))(function (resolve, reject) {
  5717. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  5718. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  5719. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  5720. step((generator = generator.apply(thisArg, _arguments || [])).next());
  5721. });
  5722. };
  5723. function getPredicatePromise(_response) {
  5724. return __awaiter(this, void 0, void 0, function* () {
  5725. try {
  5726. const response = yield _response;
  5727. return typeof response === 'string' ? Promise.reject(response) : Promise[response ? 'resolve' : 'reject']();
  5728. }
  5729. catch (response) {
  5730. if (response instanceof Error) {
  5731. return Promise.reject(response.message);
  5732. }
  5733. return Promise.reject(typeof response === 'string' ? response : undefined);
  5734. }
  5735. });
  5736. }
  5737.  
  5738.  
  5739. /***/ })
  5740.  
  5741. /******/ });
  5742. /************************************************************************/
  5743. /******/ // The module cache
  5744. /******/ var __webpack_module_cache__ = {};
  5745. /******/
  5746. /******/ // The require function
  5747. /******/ function __webpack_require__(moduleId) {
  5748. /******/ // Check if module is in cache
  5749. /******/ var cachedModule = __webpack_module_cache__[moduleId];
  5750. /******/ if (cachedModule !== undefined) {
  5751. /******/ return cachedModule.exports;
  5752. /******/ }
  5753. /******/ // Create a new module (and put it into the cache)
  5754. /******/ var module = __webpack_module_cache__[moduleId] = {
  5755. /******/ // no module.id needed
  5756. /******/ // no module.loaded needed
  5757. /******/ exports: {}
  5758. /******/ };
  5759. /******/
  5760. /******/ // Execute the module function
  5761. /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
  5762. /******/
  5763. /******/ // Return the exports of the module
  5764. /******/ return module.exports;
  5765. /******/ }
  5766. /******/
  5767. /************************************************************************/
  5768. /******/ /* webpack/runtime/define property getters */
  5769. /******/ (() => {
  5770. /******/ // define getter functions for harmony exports
  5771. /******/ __webpack_require__.d = (exports, definition) => {
  5772. /******/ for(var key in definition) {
  5773. /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  5774. /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
  5775. /******/ }
  5776. /******/ }
  5777. /******/ };
  5778. /******/ })();
  5779. /******/
  5780. /******/ /* webpack/runtime/hasOwnProperty shorthand */
  5781. /******/ (() => {
  5782. /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
  5783. /******/ })();
  5784. /******/
  5785. /******/ /* webpack/runtime/make namespace object */
  5786. /******/ (() => {
  5787. /******/ // define __esModule on exports
  5788. /******/ __webpack_require__.r = (exports) => {
  5789. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  5790. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  5791. /******/ }
  5792. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  5793. /******/ };
  5794. /******/ })();
  5795. /******/
  5796. /************************************************************************/
  5797. var __webpack_exports__ = {};
  5798. // This entry need to be wrapped in an IIFE because it declares '$Config' on top-level, which conflicts with the current library output.
  5799. (() => {
  5800. /*!*******************************!*\
  5801. !*** ./ts/library/$Config.js ***!
  5802. \*******************************/
  5803. __webpack_require__.r(__webpack_exports__);
  5804. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5805. /* harmony export */ "default": () => (/* binding */ $Config)
  5806. /* harmony export */ });
  5807. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../consts */ "./ts/consts.ts");
  5808. /* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./index */ "./ts/library/index.ts");
  5809. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../modal/css */ "./ts/modal/css.ts");
  5810. /* harmony import */ var _modal_body__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../modal/body */ "./ts/modal/body/index.ts");
  5811.  
  5812.  
  5813.  
  5814.  
  5815.  
  5816.  
  5817. const VERSION = 1;
  5818.  
  5819. const KEY_VERSION = 'TREE_FRAME_VERSION';
  5820.  
  5821. const KEY_STYLES = 'TREE_FRAME_USER_STYLES';
  5822.  
  5823. const STYLE_OUTER = {
  5824. position: 'fixed',
  5825. height: '100vh',
  5826. width: '100vw',
  5827. };
  5828.  
  5829. const getStrippedForest = (children) => {
  5830. const stripped = [];
  5831. for (const child of children) {
  5832. if (child.isActive === false) {
  5833. continue;
  5834. }
  5835. const data = {};
  5836. if ('value' in child) {
  5837. data.value = child.value;
  5838. }
  5839. if ('label' in child) {
  5840. data.label = child.label;
  5841. }
  5842. if ('children' in child) {
  5843. data.children = getStrippedForest(child.children);
  5844. }
  5845. stripped.push(data);
  5846. }
  5847. return stripped;
  5848. };
  5849.  
  5850. class $Config {
  5851. constructor(KEY_TREE, TREE_DEFAULT, getConfig, TITLE, STYLE_INNER = {}, _STYLE_OUTER = {}) {
  5852. const getError = (reason, error) => {
  5853. const message = `[${TITLE}]${reason.includes('\n') ? '\n\n' : ' '}${reason}`;
  5854. if (error) {
  5855. error.message = message;
  5856. return error;
  5857. }
  5858. return new Error(message);
  5859. };
  5860. // CORE PERMISSION CHECKS
  5861. if (typeof GM.getValue !== 'function') {
  5862. throw getError('Missing GM.getValue permission.');
  5863. }
  5864. if (typeof GM.setValue !== 'function') {
  5865. throw getError('Missing GM.setValue permission.');
  5866. }
  5867. if (typeof KEY_TREE !== 'string' || !(/^[a-z_][a-z0-9_]*$/i.test(KEY_TREE))) {
  5868. throw getError(`'${KEY_TREE}' is not a valid storage key.`);
  5869. }
  5870. // PRIVATE STATE
  5871. let isOpen = false;
  5872. const styleOuter = {
  5873. ...STYLE_OUTER,
  5874. ..._STYLE_OUTER,
  5875. };
  5876. // PUBLIC FUNCTIONS
  5877. this.ready = async () => {
  5878. // Setup root element
  5879. const target = (() => {
  5880. const targetWindow = (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.getTargetWindow)();
  5881. const id = `${_consts__WEBPACK_IMPORTED_MODULE_0__.SOCKET_ID}-${KEY_TREE}`;
  5882. for (const child of targetWindow.document.body.children) {
  5883. if (child.id === id) {
  5884. child.remove();
  5885. break;
  5886. }
  5887. }
  5888. const target = document.createElement('div');
  5889. target.id = id;
  5890. for (const [property, value] of Object.entries(styleOuter)) {
  5891. target.style[property] = value;
  5892. }
  5893. target.style.display = 'none';
  5894. targetWindow.document.body.appendChild(target);
  5895. return target;
  5896. })();
  5897. // Retrieve data
  5898. const [userTree, userStyles, version] = await Promise.all([
  5899. GM.getValue(KEY_TREE),
  5900. GM.getValue(KEY_STYLES, []),
  5901. GM.getValue(KEY_VERSION, -1),
  5902. ]);
  5903. // Patch to current version
  5904. (() => {
  5905. if (!userTree) {
  5906. return;
  5907. }
  5908. switch (version) {
  5909. case -1: {
  5910. const patch = (node) => {
  5911. delete node.predicate;
  5912. delete node.childPredicate;
  5913. delete node.descendantPredicate;
  5914. delete node.seed;
  5915. if ('children' in node) {
  5916. for (const child of node.children) {
  5917. patch(child);
  5918. }
  5919. }
  5920. };
  5921. patch(userTree);
  5922. }
  5923. // eslint-disable-next-line no-fallthrough
  5924. case 0: {
  5925. const patch = (node) => {
  5926. delete node.input;
  5927. if ('children' in node) {
  5928. for (const child of node.children) {
  5929. patch(child);
  5930. }
  5931. }
  5932. };
  5933. patch(userTree);
  5934. }
  5935. }
  5936. })();
  5937. // Listen for post-init communication
  5938. const open = (doOpen = true) => new Promise((resolve) => {
  5939. isOpen = doOpen;
  5940. target.style.display = doOpen ? (styleOuter.display ?? 'initial') : 'none';
  5941. // Delay script execution until visual update
  5942. setTimeout(resolve, 0);
  5943. });
  5944. const disconnect = () => new Promise((resolve) => {
  5945. isOpen = false;
  5946. target.remove();
  5947. // Delay script execution until visual update
  5948. setTimeout(resolve, 0);
  5949. });
  5950. /**
  5951. * @name $Config#reset
  5952. * @description Deletes the user's data.
  5953. * @returns {Promise<void>} Resolves upon completing the deletion.
  5954. */
  5955. this.reset = async () => {
  5956. if (isOpen) {
  5957. throw getError('Cannot reset while the UI is open.');
  5958. }
  5959. if (typeof GM.deleteValue !== 'function') {
  5960. throw getError('Missing GM.deleteValue permission.');
  5961. }
  5962. try {
  5963. const config = getConfig(getStrippedForest(TREE_DEFAULT));
  5964. this.get = () => config;
  5965. } catch (error) {
  5966. throw getError('Unable to parse default config.', error);
  5967. }
  5968. await GM.deleteValue(KEY_TREE);
  5969. // It may have previously been a rejected promise
  5970. this.ready = Promise.resolve();
  5971. (0,_modal_body__WEBPACK_IMPORTED_MODULE_3__.reset)();
  5972. };
  5973. /**
  5974. * @name $Config#edit
  5975. * @description Allows the user to edit the active config.
  5976. * @returns {Promise<void>} Resolves when the user closes the config editor.
  5977. */
  5978. this.edit = async () => {
  5979. if (isOpen) {
  5980. throw getError('A config editor is already open.');
  5981. }
  5982. open();
  5983. const {tree, styles} = await (0,_index__WEBPACK_IMPORTED_MODULE_1__.edit)();
  5984. GM.setValue(KEY_TREE, tree);
  5985. GM.setValue(KEY_STYLES, styles);
  5986. GM.setValue(KEY_VERSION, VERSION);
  5987. const config = getConfig(tree.children);
  5988. this.get = () => config;
  5989. await open(false);
  5990. };
  5991. // Pass data
  5992. try {
  5993. const response = await (0,_index__WEBPACK_IMPORTED_MODULE_1__.init)({
  5994. userStyles,
  5995. defaultTree: TREE_DEFAULT,
  5996. title: TITLE,
  5997. defaultStyle: STYLE_INNER,
  5998. ...(userTree ? {userTree} : {}),
  5999. }, target);
  6000. if (response.requireReset) {
  6001. throw getError(
  6002. 'Your config is invalid.'
  6003. + '\nThis could be due to a script update or your data being corrupted.'
  6004. + `\n\nReason:\n${response.error.message.replaceAll(/\n+/g, '\n')}`,
  6005. response.error,
  6006. );
  6007. }
  6008. const config = getConfig(response.tree.children);
  6009. this.get = () => config;
  6010. } catch (error) {
  6011. delete this.reset;
  6012. await disconnect();
  6013. throw getError(
  6014. 'Your config is invalid.'
  6015. + '\nThis could be due to a script update or your data being corrupted.'
  6016. + `\n\nReason:\n${error.message.replaceAll(/\n+/g, '\n')}`,
  6017. error,
  6018. );
  6019. }
  6020. };
  6021. }
  6022. }
  6023.  
  6024. })();
  6025.  
  6026. $Config = __webpack_exports__["default"];
  6027. /******/ })()
  6028. ;

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址