$Config

Allows users to configure scripts

目前为 2024-06-30 提交的版本。查看 最新版本

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

QingJ © 2025

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