$Config

Allows users to configure scripts

目前为 2025-01-10 提交的版本。查看 最新版本

此脚本不应直接安装,它是一个供其他脚本使用的外部库。如果您需要使用该库,请在脚本元属性加入:// @require https://update.gf.qytechs.cn/scripts/446506/1518576/%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 _modal_body_data__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../modal/body/data */ "./ts/modal/body/data/index.ts");
  36. /* harmony import */ var _modal_header_actions_close__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../modal/header/actions/close */ "./ts/modal/header/actions/close/index.ts");
  37. /* harmony import */ var _modal_body__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../modal/body */ "./ts/modal/body/index.ts");
  38. var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
  39. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  40. return new (P || (P = Promise))(function (resolve, reject) {
  41. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  42. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  43. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  44. step((generator = generator.apply(thisArg, _arguments || [])).next());
  45. });
  46. };
  47.  
  48.  
  49.  
  50.  
  51.  
  52. function init(page, socket, targetWindow = window) {
  53. return __awaiter(this, void 0, void 0, function* () {
  54. const response = {};
  55. try {
  56. yield (0,_validation__WEBPACK_IMPORTED_MODULE_0__["default"])(page);
  57. (0,_modal__WEBPACK_IMPORTED_MODULE_1__["default"])(page, socket, targetWindow);
  58. // Config is valid
  59. response.requireReset = false;
  60. }
  61. catch (error) {
  62. if (typeof page !== 'object' || !(0,_validation__WEBPACK_IMPORTED_MODULE_0__.hasOwnProperty)(page, 'userTree')) {
  63. throw error;
  64. }
  65. delete page.userTree;
  66. // Test validity after reset
  67. yield (0,_validation__WEBPACK_IMPORTED_MODULE_0__["default"])(page);
  68. (0,_modal__WEBPACK_IMPORTED_MODULE_1__["default"])(page, socket, targetWindow);
  69. response.requireReset = true;
  70. response.error = error;
  71. }
  72. return Object.assign(Object.assign({}, response), (0,_modal_body_data__WEBPACK_IMPORTED_MODULE_2__.getSaveData)());
  73. });
  74. }
  75. function edit() {
  76. (0,_modal__WEBPACK_IMPORTED_MODULE_1__.getSocket)().focus();
  77. return new Promise((resolve) => {
  78. (0,_modal_header_actions_close__WEBPACK_IMPORTED_MODULE_3__.setCallback)(resolve);
  79. });
  80. }
  81.  
  82.  
  83. /***/ }),
  84.  
  85. /***/ "./ts/library/validation/errors.ts":
  86. /*!*****************************************!*\
  87. !*** ./ts/library/validation/errors.ts ***!
  88. \*****************************************/
  89. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  90.  
  91. __webpack_require__.r(__webpack_exports__);
  92. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  93. /* harmony export */ DeactivatedError: () => (/* binding */ DeactivatedError),
  94. /* harmony export */ DependenceError: () => (/* binding */ DependenceError),
  95. /* harmony export */ EmptyArrayError: () => (/* binding */ EmptyArrayError),
  96. /* harmony export */ EmptyStringError: () => (/* binding */ EmptyStringError),
  97. /* harmony export */ FunctionMatchError: () => (/* binding */ FunctionMatchError),
  98. /* harmony export */ JoinedError: () => (/* binding */ JoinedError),
  99. /* harmony export */ NonIntegerError: () => (/* binding */ NonIntegerError),
  100. /* harmony export */ OptionError: () => (/* binding */ OptionError),
  101. /* harmony export */ OptionMatchError: () => (/* binding */ OptionMatchError),
  102. /* harmony export */ PoolBranchError: () => (/* binding */ PoolBranchError),
  103. /* harmony export */ PoolSizeError: () => (/* binding */ PoolSizeError),
  104. /* harmony export */ PredicateError: () => (/* binding */ PredicateError),
  105. /* harmony export */ PropertyError: () => (/* binding */ PropertyError),
  106. /* harmony export */ SeedMatchError: () => (/* binding */ SeedMatchError),
  107. /* harmony export */ TypeError: () => (/* binding */ TypeError),
  108. /* harmony export */ UnexpectedStateError: () => (/* binding */ UnexpectedStateError),
  109. /* harmony export */ ValueError: () => (/* binding */ ValueError)
  110. /* harmony export */ });
  111. // Helpers
  112. function getOptionString(array) {
  113. if (array.length === 0) {
  114. throw new Error('No valid options.');
  115. }
  116. if (array.length === 1) {
  117. return `"${array[0]}"`;
  118. }
  119. return `"${array.slice(0, -1).join('", "')}" or "${array[array.length - 1]}"`;
  120. }
  121. function getPath(breadcrumbs) {
  122. return `/${breadcrumbs.join('/')}`;
  123. }
  124. // Errors
  125. class JoinedError extends Error {
  126. constructor(...errors) {
  127. super(errors.map(({ message }) => message).join(JoinedError.separator));
  128. }
  129. }
  130. JoinedError.separator = '\n\n';
  131. class UnexpectedStateError extends Error {
  132. constructor() {
  133. super('Unexpected state reached.');
  134. }
  135. }
  136. class TypeError extends Error {
  137. constructor(breadcrumbs, found, expected) {
  138. super(`Found a value of type "${found}" at ${getPath(breadcrumbs)}. Expected ${getOptionString(expected)}.`);
  139. }
  140. }
  141. class PropertyError extends Error {
  142. constructor(breadcrumbs, property, shouldExist) {
  143. super(`${shouldExist ? 'Missing' : 'Unexpected'} property "${property}" found at ${getPath(breadcrumbs)}.`);
  144. }
  145. }
  146. class ValueError extends Error {
  147. constructor(breadcrumbs, found, expected) {
  148. super(`Found a value of "${found}" at ${getPath(breadcrumbs)}. Expected ${getOptionString(expected)}.`);
  149. }
  150. }
  151. class NonIntegerError extends Error {
  152. constructor(breadcrumbs) {
  153. super(`Found illegal non-integer at ${getPath(breadcrumbs)}.`);
  154. }
  155. }
  156. class EmptyStringError extends Error {
  157. constructor(breadcrumbs) {
  158. super(`Found illegal empty string at ${getPath(breadcrumbs)}.`);
  159. }
  160. }
  161. class EmptyArrayError extends Error {
  162. constructor(breadcrumbs) {
  163. super(`Found illegal empty array at ${getPath(breadcrumbs)}.`);
  164. }
  165. }
  166. class PredicateError extends Error {
  167. constructor(breadcrumbs) {
  168. super(`Predicate failed at ${getPath(breadcrumbs)}. Predicates must succeed.`);
  169. }
  170. }
  171. class OptionError extends Error {
  172. constructor() {
  173. super('Node value not found in its options.');
  174. }
  175. }
  176. class SeedMatchError extends Error {
  177. constructor() {
  178. super('All children must be structurally similar to their parent\'s seed.');
  179. }
  180. }
  181. class PoolBranchError extends Error {
  182. constructor(ancestorBreadcrumbs, descendantBreadcrumbs, poolId) {
  183. super('No node may share a poolId value with its ancestor.' + JoinedError.separator
  184. + `Found poolId value ${poolId} at ${getPath(ancestorBreadcrumbs)} and ${getPath(descendantBreadcrumbs)}.`);
  185. }
  186. }
  187. class PoolSizeError extends Error {
  188. constructor(poolId, found, expected) {
  189. 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
  190. + `Found a size of ${found} at pool ${poolId}. Expected a size of ${expected}.`);
  191. }
  192. }
  193. class FunctionMatchError extends Error {
  194. constructor() {
  195. super('Corresponding function values in seed & non-seed branches must be the same pointer.');
  196. }
  197. }
  198. class OptionMatchError extends Error {
  199. constructor() {
  200. super('Options must have the same type as their node\'s value.');
  201. }
  202. }
  203. class DependenceError extends Error {
  204. constructor(found, missing) {
  205. super(`Nodes with a "${found}" entry must have a "${missing}" property.`);
  206. }
  207. }
  208. class DeactivatedError extends Error {
  209. constructor() {
  210. super('Nodes can\'t be deactivated unless their parent has a seed.');
  211. }
  212. }
  213.  
  214.  
  215. /***/ }),
  216.  
  217. /***/ "./ts/library/validation/index.ts":
  218. /*!****************************************!*\
  219. !*** ./ts/library/validation/index.ts ***!
  220. \****************************************/
  221. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  222.  
  223. __webpack_require__.r(__webpack_exports__);
  224. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  225. /* harmony export */ "default": () => (/* export default binding */ __WEBPACK_DEFAULT_EXPORT__),
  226. /* harmony export */ hasOwnProperty: () => (/* binding */ hasOwnProperty),
  227. /* harmony export */ validateUnexpectedKeys: () => (/* binding */ validateUnexpectedKeys)
  228. /* harmony export */ });
  229. /* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./types */ "./ts/library/validation/types.ts");
  230. /* harmony import */ var _errors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./errors */ "./ts/library/validation/errors.ts");
  231. /* harmony import */ var _styles__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./styles */ "./ts/library/validation/styles.ts");
  232. /* harmony import */ var _trees_pools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./trees/pools */ "./ts/library/validation/trees/pools.ts");
  233. /* harmony import */ var _trees_guards__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./trees/guards */ "./ts/library/validation/trees/guards.ts");
  234. /* harmony import */ var _trees_match__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./trees/match */ "./ts/library/validation/trees/match.ts");
  235. /* harmony import */ var _trees_predicates__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./trees/predicates */ "./ts/library/validation/trees/predicates.ts");
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242.  
  243. // Helpers
  244. // Credit to https://fettblog.eu/typescript-hasownproperty/
  245. function hasOwnProperty(object, property) {
  246. return Object.hasOwnProperty.call(object, property);
  247. }
  248. function validateUnexpectedKeys(breadcrumbs, object, expected) {
  249. for (const key of Object.keys(object)) {
  250. if (!expected.includes(key))
  251. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.PropertyError(breadcrumbs, key, false);
  252. }
  253. }
  254. // Guard
  255. function isPage(candidate) {
  256. if (typeof candidate !== 'object')
  257. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([], typeof candidate, ['object']);
  258. validateUnexpectedKeys([], candidate, _types__WEBPACK_IMPORTED_MODULE_0__.PAGE_KEYS);
  259. // title
  260. if (!hasOwnProperty(candidate, 'title'))
  261. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.PropertyError([], 'title', true);
  262. if (typeof candidate.title !== 'string')
  263. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError(['title'], typeof candidate.title, ['string']);
  264. // defaultStyle
  265. if (hasOwnProperty(candidate, 'defaultStyle')) {
  266. if (!(0,_styles__WEBPACK_IMPORTED_MODULE_2__.isStyles)(['defaultStyle'], candidate.defaultStyle))
  267. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.UnexpectedStateError();
  268. if (hasOwnProperty(candidate.defaultStyle, 'name'))
  269. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.PropertyError(['defaultStyle'], 'name', false);
  270. if (hasOwnProperty(candidate.defaultStyle, 'isActive'))
  271. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.PropertyError(['defaultStyle'], 'isActive', false);
  272. }
  273. // userStyles
  274. if (!hasOwnProperty(candidate, 'userStyles'))
  275. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.PropertyError([], 'userStyles', true);
  276. if (!Array.isArray(candidate.userStyles))
  277. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError(['userStyles'], typeof candidate.userStyles, ['array']);
  278. for (const [i, style] of candidate.userStyles.entries()) {
  279. if (!(0,_styles__WEBPACK_IMPORTED_MODULE_2__.isStyles)(['userStyles', i.toString()], style))
  280. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.UnexpectedStateError();
  281. if (!hasOwnProperty(style, 'name'))
  282. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.PropertyError(['userStyles', i.toString()], 'name', true);
  283. if (typeof style.name !== 'string')
  284. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError(['userStyles', i.toString(), 'name'], typeof style.name, ['string']);
  285. if (!hasOwnProperty(style, 'isActive'))
  286. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.PropertyError(['userStyles', i.toString()], 'isActive', true);
  287. if (typeof style.isActive !== 'boolean')
  288. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError(['userStyles', i.toString(), 'isActive'], typeof style.isActive, ['boolean']);
  289. }
  290. // defaultTree
  291. if (!hasOwnProperty(candidate, 'defaultTree') || !(0,_trees_guards__WEBPACK_IMPORTED_MODULE_4__.isRoot)(['defaultTree'], candidate.defaultTree))
  292. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.PropertyError([], 'defaultTree', true);
  293. // userTree
  294. if (hasOwnProperty(candidate, 'userTree') && !(0,_trees_guards__WEBPACK_IMPORTED_MODULE_4__.isRoot)(['userTree'], candidate.userTree, true))
  295. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.UnexpectedStateError();
  296. return true;
  297. }
  298. // Validator
  299. function validatePage({ title, defaultTree, userTree }) {
  300. // title
  301. if (title.length === 0)
  302. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.EmptyStringError(['title']);
  303. // trees
  304. (0,_trees_match__WEBPACK_IMPORTED_MODULE_5__.validateSeeds)(['defaultTree'], defaultTree);
  305. (0,_trees_pools__WEBPACK_IMPORTED_MODULE_3__.validatePools)(['defaultTree'], defaultTree);
  306. if (!userTree) {
  307. return Promise.all((0,_trees_predicates__WEBPACK_IMPORTED_MODULE_6__.validateParent)(['defaultTree'], defaultTree));
  308. }
  309. (0,_trees_match__WEBPACK_IMPORTED_MODULE_5__.matchUserTreeParent)(['defaultTree'], defaultTree, ['userTree'], userTree);
  310. // Has to be done after mutations since new pools may be created
  311. (0,_trees_match__WEBPACK_IMPORTED_MODULE_5__.validatePoolSizeMatch)(defaultTree, userTree);
  312. return Promise.all([
  313. ...(0,_trees_predicates__WEBPACK_IMPORTED_MODULE_6__.validateParent)(['defaultTree'], defaultTree),
  314. ...(0,_trees_predicates__WEBPACK_IMPORTED_MODULE_6__.validateParent)(['userTree'], userTree),
  315. ]);
  316. }
  317. // API
  318. /* harmony default export */ function __WEBPACK_DEFAULT_EXPORT__(candidate) {
  319. if (!isPage(candidate))
  320. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.UnexpectedStateError();
  321. return validatePage(candidate);
  322. }
  323.  
  324.  
  325. /***/ }),
  326.  
  327. /***/ "./ts/library/validation/styles.ts":
  328. /*!*****************************************!*\
  329. !*** ./ts/library/validation/styles.ts ***!
  330. \*****************************************/
  331. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  332.  
  333. __webpack_require__.r(__webpack_exports__);
  334. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  335. /* harmony export */ isStyles: () => (/* binding */ isStyles)
  336. /* harmony export */ });
  337. /* harmony import */ var _errors__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./errors */ "./ts/library/validation/errors.ts");
  338. /* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./types */ "./ts/library/validation/types.ts");
  339.  
  340.  
  341. function isStyles(breadcrumbs, candidate) {
  342. if (typeof candidate !== 'object')
  343. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.TypeError(breadcrumbs, typeof candidate, ['object']);
  344. if (Array.isArray(candidate))
  345. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.TypeError(breadcrumbs, 'array', ['object']);
  346. for (const [key, value] of Object.entries(candidate)) {
  347. switch (key) {
  348. // Colours
  349. case 'modalOutline':
  350. case 'headBase':
  351. case 'headButtonExit':
  352. case 'headButtonLabel':
  353. case 'headButtonStyle':
  354. case 'headButtonSticky':
  355. case 'nodeHeaderBase':
  356. case 'nodeBlendBase':
  357. case 'nodeValueBase':
  358. case 'nodeButtonRemove':
  359. case 'nodeButtonCreate':
  360. case 'nodeButtonMove':
  361. case 'nodeButtonDisable':
  362. case 'validBackground':
  363. case 'invalidBackground':
  364. case 'focusBackground':
  365. case 'tooltipOutline':
  366. if (typeof value !== 'string')
  367. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.TypeError([...breadcrumbs, key], typeof value, ['string']);
  368. break;
  369. // Numbers
  370. case 'fontSize':
  371. case 'width':
  372. case 'height':
  373. if (typeof value !== 'number')
  374. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.TypeError([...breadcrumbs, key], typeof value, ['number']);
  375. break;
  376. // Contrast methods
  377. case 'headContrast':
  378. case 'nodeContrast':
  379. if (typeof value !== 'string')
  380. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.TypeError([...breadcrumbs, key], typeof value, ['string']);
  381. if (!_types__WEBPACK_IMPORTED_MODULE_1__.CONTRAST_METHODS.includes(value))
  382. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.ValueError([...breadcrumbs, key], value, _types__WEBPACK_IMPORTED_MODULE_1__.CONTRAST_METHODS);
  383. break;
  384. // Booleans
  385. case 'isActive':
  386. case 'borderLeaf':
  387. case 'borderNode':
  388. if (typeof value !== 'boolean')
  389. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.TypeError([...breadcrumbs, key], typeof value, ['boolean']);
  390. break;
  391. }
  392. }
  393. return true;
  394. }
  395.  
  396.  
  397. /***/ }),
  398.  
  399. /***/ "./ts/library/validation/trees/guards.ts":
  400. /*!***********************************************!*\
  401. !*** ./ts/library/validation/trees/guards.ts ***!
  402. \***********************************************/
  403. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  404.  
  405. __webpack_require__.r(__webpack_exports__);
  406. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  407. /* harmony export */ isParent: () => (/* binding */ isParent),
  408. /* harmony export */ isRoot: () => (/* binding */ isRoot)
  409. /* harmony export */ });
  410. /* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../types */ "./ts/library/validation/types.ts");
  411. /* harmony import */ var _errors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../errors */ "./ts/library/validation/errors.ts");
  412. /* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../index */ "./ts/library/validation/index.ts");
  413.  
  414.  
  415.  
  416. function hasDependee(breadcrumbs, candidate, property, dependence) {
  417. if (!(0,_index__WEBPACK_IMPORTED_MODULE_2__.hasOwnProperty)(candidate, property)) {
  418. return false;
  419. }
  420. if ((0,_index__WEBPACK_IMPORTED_MODULE_2__.hasOwnProperty)(candidate, dependence))
  421. return true;
  422. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.JoinedError(new _errors__WEBPACK_IMPORTED_MODULE_1__.DependenceError(property, dependence), new _errors__WEBPACK_IMPORTED_MODULE_1__.PropertyError([...breadcrumbs], dependence, true));
  423. }
  424. // Type predicates
  425. function isChild(breadcrumbs, candidate, isUserTree = false) {
  426. if (typeof candidate !== 'object')
  427. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs], typeof candidate, ['object']);
  428. if (isUserTree) {
  429. (0,_index__WEBPACK_IMPORTED_MODULE_2__.validateUnexpectedKeys)(breadcrumbs, candidate, _types__WEBPACK_IMPORTED_MODULE_0__.SAVED_KEYS);
  430. }
  431. else {
  432. (0,_index__WEBPACK_IMPORTED_MODULE_2__.validateUnexpectedKeys)(breadcrumbs, candidate, 'children' in candidate ? _types__WEBPACK_IMPORTED_MODULE_0__.MIDDLE_KEYS : _types__WEBPACK_IMPORTED_MODULE_0__.LEAF_KEYS);
  433. }
  434. if ((0,_index__WEBPACK_IMPORTED_MODULE_2__.hasOwnProperty)(candidate, 'label') && typeof candidate.label !== 'string')
  435. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'label'], typeof candidate.label, ['string']);
  436. if ((0,_index__WEBPACK_IMPORTED_MODULE_2__.hasOwnProperty)(candidate, 'value') && !_types__WEBPACK_IMPORTED_MODULE_0__.VALUE_TYPES.includes(typeof candidate.value))
  437. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'value'], typeof candidate.value, _types__WEBPACK_IMPORTED_MODULE_0__.VALUE_TYPES);
  438. if (hasDependee(breadcrumbs, candidate, 'options', 'value')) {
  439. if (!Array.isArray(candidate.options))
  440. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'options'], typeof candidate.options, ['array']);
  441. for (const [i, option] of candidate.options.entries()) {
  442. if (!_types__WEBPACK_IMPORTED_MODULE_0__.VALUE_TYPES.includes(typeof option))
  443. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'options', i.toString()], typeof option, _types__WEBPACK_IMPORTED_MODULE_0__.VALUE_TYPES);
  444. }
  445. }
  446. if (hasDependee(breadcrumbs, candidate, 'predicate', 'value') && typeof candidate.predicate !== 'function')
  447. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'predicate'], typeof candidate.predicate, ['function']);
  448. if (hasDependee(breadcrumbs, candidate, 'onUpdate', 'value') && typeof candidate.onUpdate !== 'function')
  449. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'onUpdate'], typeof candidate.onUpdate, ['function']);
  450. if (hasDependee(breadcrumbs, candidate, 'listeners', 'value')) {
  451. if (typeof candidate.listeners !== 'object')
  452. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'listeners'], typeof candidate.listeners, ['object']);
  453. for (const [event, callback] of Object.entries(candidate.listeners)) {
  454. if (typeof callback !== 'function')
  455. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'listeners', event], typeof callback, ['function']);
  456. }
  457. }
  458. if (hasDependee(breadcrumbs, candidate, 'input', 'value')) {
  459. if (typeof candidate.input !== 'string')
  460. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'input'], typeof candidate.input, ['string']);
  461. if (!_types__WEBPACK_IMPORTED_MODULE_0__.INPUT_FORMATS.includes(candidate.input))
  462. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.ValueError([...breadcrumbs, 'input'], candidate.input, _types__WEBPACK_IMPORTED_MODULE_0__.INPUT_FORMATS);
  463. }
  464. if (hasDependee(breadcrumbs, candidate, 'inputAttributes', 'value') && typeof candidate.inputAttributes !== 'object')
  465. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'inputAttributes'], typeof candidate.inputAttributes, ['object']);
  466. if ((0,_index__WEBPACK_IMPORTED_MODULE_2__.hasOwnProperty)(candidate, 'get') && typeof candidate.get !== 'function')
  467. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'get'], typeof candidate.get, ['function']);
  468. if ((0,_index__WEBPACK_IMPORTED_MODULE_2__.hasOwnProperty)(candidate, 'hideId') && typeof candidate.hideId !== 'string')
  469. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'hideId'], typeof candidate.hideId, ['string']);
  470. if ((0,_index__WEBPACK_IMPORTED_MODULE_2__.hasOwnProperty)(candidate, 'isActive') && typeof candidate.isActive !== 'boolean')
  471. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'isActive'], typeof candidate.isActive, ['boolean']);
  472. if ((0,_index__WEBPACK_IMPORTED_MODULE_2__.hasOwnProperty)(candidate, 'children') && !isParent(breadcrumbs, candidate, isUserTree))
  473. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.UnexpectedStateError();
  474. return true;
  475. }
  476. function isParent(breadcrumbs, candidate, isUserTree = false) {
  477. if (!(0,_index__WEBPACK_IMPORTED_MODULE_2__.hasOwnProperty)(candidate, 'children'))
  478. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.PropertyError(breadcrumbs, 'children', true);
  479. if (!Array.isArray(candidate.children))
  480. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'children'], typeof candidate.children, ['array']);
  481. if ((0,_index__WEBPACK_IMPORTED_MODULE_2__.hasOwnProperty)(candidate, 'seed') && !isChild([...breadcrumbs, 'seed'], candidate.seed))
  482. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.UnexpectedStateError();
  483. if ((0,_index__WEBPACK_IMPORTED_MODULE_2__.hasOwnProperty)(candidate, 'poolId') && typeof candidate.poolId !== 'number')
  484. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'poolId'], typeof candidate.poolId, ['number']);
  485. if ((0,_index__WEBPACK_IMPORTED_MODULE_2__.hasOwnProperty)(candidate, 'childPredicate') && typeof candidate.childPredicate !== 'function')
  486. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'childPredicate'], typeof candidate.childPredicate, ['function']);
  487. if ((0,_index__WEBPACK_IMPORTED_MODULE_2__.hasOwnProperty)(candidate, 'descendantPredicate') && typeof candidate.descendantPredicate !== 'function')
  488. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'descendantPredicate'], typeof candidate.descendantPredicate, ['function']);
  489. if ((0,_index__WEBPACK_IMPORTED_MODULE_2__.hasOwnProperty)(candidate, 'onChildUpdate') && typeof candidate.onChildUpdate !== 'function')
  490. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'onChildUpdate'], typeof candidate.onChildUpdate, ['function']);
  491. if ((0,_index__WEBPACK_IMPORTED_MODULE_2__.hasOwnProperty)(candidate, 'onDescendantUpdate') && typeof candidate.onDescendantUpdate !== 'function')
  492. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'onDescendantUpdate'], typeof candidate.onDescendantUpdate, ['function']);
  493. for (const [i, child] of candidate.children.entries()) {
  494. if (!isChild([...breadcrumbs, 'children', i.toString()], child, isUserTree))
  495. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.UnexpectedStateError();
  496. }
  497. return true;
  498. }
  499. function isRoot(breadcrumbs, candidate, isUserTree = false) {
  500. if (typeof candidate !== 'object')
  501. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError(breadcrumbs, typeof candidate, ['object']);
  502. if (!isParent(breadcrumbs, candidate, isUserTree))
  503. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.UnexpectedStateError();
  504. (0,_index__WEBPACK_IMPORTED_MODULE_2__.validateUnexpectedKeys)(breadcrumbs, candidate, _types__WEBPACK_IMPORTED_MODULE_0__.ROOT_KEYS);
  505. return true;
  506. }
  507.  
  508.  
  509. /***/ }),
  510.  
  511. /***/ "./ts/library/validation/trees/match.ts":
  512. /*!**********************************************!*\
  513. !*** ./ts/library/validation/trees/match.ts ***!
  514. \**********************************************/
  515. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  516.  
  517. __webpack_require__.r(__webpack_exports__);
  518. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  519. /* harmony export */ matchUserTreeParent: () => (/* binding */ matchUserTreeParent),
  520. /* harmony export */ validatePoolSizeMatch: () => (/* binding */ validatePoolSizeMatch),
  521. /* harmony export */ validateSeeds: () => (/* binding */ validateSeeds)
  522. /* harmony export */ });
  523. /* harmony import */ var _errors__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../errors */ "./ts/library/validation/errors.ts");
  524.  
  525. // Helpers
  526. function validateOptionMatch(modelBreadcrumbs, model, candidateBreadcrumbs, candidate) {
  527. if ('options' in model !== 'options' in candidate)
  528. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.PropertyError(candidateBreadcrumbs, 'options', 'options' in model);
  529. if ('options' in model) {
  530. if (model.options.length !== candidate.options.length)
  531. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.ValueError([...candidateBreadcrumbs, 'options', 'length'], candidate.options.length, [model.options.length]);
  532. for (const [i, option] of model.options.entries()) {
  533. if (candidate.options[i] !== option)
  534. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.ValueError([...candidateBreadcrumbs, 'options', i.toString()], candidate.options[i], [option]);
  535. }
  536. }
  537. }
  538. function validateValueMatch(property, modelBreadcrumbs, model, candidateBreadcrumbs, candidate) {
  539. if (property in model !== property in candidate)
  540. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.PropertyError(candidateBreadcrumbs, property, property in model);
  541. if (model[property] !== candidate[property])
  542. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.ValueError([...candidateBreadcrumbs, property], candidate[property], [model[property]]);
  543. }
  544. function assignKeys(from, to) {
  545. for (const key of Object.keys(from)) {
  546. if (!(key in to)) {
  547. to[key] = from[key];
  548. }
  549. }
  550. }
  551. // Consistent userTree validators/enforcers
  552. function matchUserTreeChild(modelBreadcrumbs, model, candidateBreadcrumbs, candidate) {
  553. if ('value' in model !== 'value' in candidate) {
  554. if ('value' in candidate)
  555. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.PropertyError(candidateBreadcrumbs, 'value', false);
  556. candidate.value = model.value;
  557. }
  558. else if (typeof model.value !== typeof candidate.value) {
  559. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.TypeError([...candidateBreadcrumbs, 'value'], typeof candidate.value, [typeof model.value]);
  560. }
  561. if ('label' in model) {
  562. candidate.label = model.label;
  563. }
  564. else {
  565. delete candidate.label;
  566. }
  567. if ('children' in model !== 'children' in candidate)
  568. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.PropertyError(candidateBreadcrumbs, 'children', 'children' in model);
  569. if ('children' in model) {
  570. matchUserTreeParent(modelBreadcrumbs, model, candidateBreadcrumbs, candidate);
  571. }
  572. else {
  573. assignKeys(model, candidate);
  574. }
  575. }
  576. function matchUserTreeParent(modelBreadcrumbs, model, candidateBreadcrumbs, candidate) {
  577. assignKeys(model, candidate);
  578. if ('seed' in model) {
  579. for (const [i, child] of candidate.children.entries()) {
  580. matchUserTreeChild([...modelBreadcrumbs, 'seed'], model.seed, [...candidateBreadcrumbs, 'children', i.toString()], child);
  581. }
  582. return;
  583. }
  584. if ('poolId' in model) {
  585. return;
  586. }
  587. if (model.children.length !== candidate.children.length)
  588. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.ValueError([...candidateBreadcrumbs, 'children', 'length'], candidate.children.length, [model.children.length]);
  589. for (const [i, child] of candidate.children.entries()) {
  590. matchUserTreeChild([...modelBreadcrumbs, 'children', i.toString()], model.children[i], [...candidateBreadcrumbs, 'children', i.toString()], child);
  591. }
  592. // Done after validation to avoid validating certain matches
  593. if (model.children.length > candidate.children.length) {
  594. candidate.children.push(...model.children.slice(candidate.children.length));
  595. }
  596. }
  597. // defaultTree internal consistency validators
  598. function validateChildMatch(modelBreadcrumbs, model, candidateBreadcrumbs, candidate) {
  599. if ('value' in model !== 'value' in candidate)
  600. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.PropertyError(candidateBreadcrumbs, 'value', 'value' in model);
  601. if (typeof model.value !== typeof candidate.value)
  602. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.TypeError([...candidateBreadcrumbs, 'value'], typeof candidate.value, [typeof model.value]);
  603. validateValueMatch('label', modelBreadcrumbs, model, candidateBreadcrumbs, candidate);
  604. validateValueMatch('input', modelBreadcrumbs, model, candidateBreadcrumbs, candidate);
  605. validateOptionMatch(modelBreadcrumbs, model, candidateBreadcrumbs, candidate);
  606. try {
  607. validateValueMatch('predicate', modelBreadcrumbs, model, candidateBreadcrumbs, candidate);
  608. validateValueMatch('onUpdate', modelBreadcrumbs, model, candidateBreadcrumbs, candidate);
  609. }
  610. catch (error) {
  611. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.JoinedError(new _errors__WEBPACK_IMPORTED_MODULE_0__.FunctionMatchError(), error);
  612. }
  613. if ('children' in model !== 'children' in candidate)
  614. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.PropertyError(candidateBreadcrumbs, 'children', 'children' in model);
  615. if ('children' in model) {
  616. validateParentMatch(modelBreadcrumbs, model, candidateBreadcrumbs, candidate);
  617. }
  618. }
  619. function validateParentMatch(modelBreadcrumbs, model, candidateBreadcrumbs, candidate) {
  620. validateValueMatch('poolId', modelBreadcrumbs, model, candidateBreadcrumbs, candidate);
  621. try {
  622. validateValueMatch('childPredicate', modelBreadcrumbs, model, candidateBreadcrumbs, candidate);
  623. validateValueMatch('onChildUpdate', modelBreadcrumbs, model, candidateBreadcrumbs, candidate);
  624. validateValueMatch('descendantPredicate', modelBreadcrumbs, model, candidateBreadcrumbs, candidate);
  625. validateValueMatch('onDescendantUpdate', modelBreadcrumbs, model, candidateBreadcrumbs, candidate);
  626. }
  627. catch (error) {
  628. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.JoinedError(new _errors__WEBPACK_IMPORTED_MODULE_0__.FunctionMatchError(), error);
  629. }
  630. if ('seed' in model) {
  631. validateChildMatch([...modelBreadcrumbs, 'seed'], model.seed, [...candidateBreadcrumbs, 'seed'], candidate.seed);
  632. for (const [i, child] of candidate.children.entries()) {
  633. validateChildMatch([...modelBreadcrumbs, 'seed'], model.seed, [...candidateBreadcrumbs, 'children', i.toString()], child);
  634. }
  635. }
  636. else if (!('poolId' in model)) {
  637. if (model.children.length !== candidate.children.length)
  638. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.ValueError([...candidateBreadcrumbs, 'children', 'length'], candidate.children.length, [model.children.length]);
  639. for (const [i, child] of candidate.children.entries()) {
  640. validateChildMatch([...modelBreadcrumbs, 'children', i.toString()], model.children[i], [...candidateBreadcrumbs, 'children', i.toString()], child);
  641. }
  642. if (model.children.length > candidate.children.length) {
  643. candidate.children.push(...model.children.slice(candidate.children.length));
  644. }
  645. }
  646. }
  647. // Other validators
  648. function validateSeeds(breadcrumbs, node) {
  649. if ('children' in node) {
  650. if ('seed' in node) {
  651. try {
  652. for (const [i, child] of node.children.entries()) {
  653. validateChildMatch([...breadcrumbs, 'seed'], node.seed, [...breadcrumbs, 'children', i.toString()], child);
  654. }
  655. }
  656. catch (error) {
  657. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.JoinedError(new _errors__WEBPACK_IMPORTED_MODULE_0__.SeedMatchError(), error);
  658. }
  659. validateSeeds([...breadcrumbs, 'seed'], node.seed);
  660. }
  661. else {
  662. for (const [i, child] of node.children.entries()) {
  663. if ('isActive' in child && !child.isActive) {
  664. 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]));
  665. }
  666. }
  667. }
  668. for (const [i, child] of node.children.entries()) {
  669. validateSeeds([...breadcrumbs, 'children', i.toString()], child);
  670. }
  671. }
  672. }
  673. function getPoolSizes(node, uncapped = false) {
  674. const poolSizes = [];
  675. uncapped = uncapped || 'seed' in node;
  676. if ('poolId' in node) {
  677. poolSizes[node.poolId] = uncapped ? -1 : node.children.length;
  678. }
  679. if ('children' in node) {
  680. for (const child of node.children) {
  681. const subPoolSizes = getPoolSizes(child, uncapped);
  682. for (const id in subPoolSizes) {
  683. if (subPoolSizes[id] < 0) {
  684. poolSizes[id] = -1;
  685. }
  686. else if (id in poolSizes) {
  687. poolSizes[id] += subPoolSizes[id];
  688. }
  689. else {
  690. poolSizes[id] = subPoolSizes[id];
  691. }
  692. }
  693. }
  694. }
  695. return poolSizes;
  696. }
  697. function validatePoolSizeMatch(model, candidate) {
  698. const modelSizes = getPoolSizes(model);
  699. const candidateSizes = getPoolSizes(candidate);
  700. for (const id in modelSizes) {
  701. if (modelSizes[id] !== candidateSizes[id])
  702. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.PoolSizeError(Number.parseInt(id), candidateSizes[id], modelSizes[id]);
  703. }
  704. }
  705.  
  706.  
  707. /***/ }),
  708.  
  709. /***/ "./ts/library/validation/trees/pools.ts":
  710. /*!**********************************************!*\
  711. !*** ./ts/library/validation/trees/pools.ts ***!
  712. \**********************************************/
  713. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  714.  
  715. __webpack_require__.r(__webpack_exports__);
  716. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  717. /* harmony export */ validatePools: () => (/* binding */ validatePools)
  718. /* harmony export */ });
  719. /* harmony import */ var _errors__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../errors */ "./ts/library/validation/errors.ts");
  720.  
  721. function validatePools(breadcrumbs, node, ancestorPools = []) {
  722. if ('poolId' in node) {
  723. if (node.poolId in ancestorPools)
  724. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.PoolBranchError(ancestorPools[node.poolId], breadcrumbs, node.poolId);
  725. // Slice maintains empty entries, so the 'in' operator still works
  726. ancestorPools = ancestorPools.slice();
  727. ancestorPools[node.poolId] = breadcrumbs;
  728. }
  729. if ('children' in node) {
  730. // Recurse
  731. for (const [i, child] of node.children.entries()) {
  732. validatePools([...breadcrumbs, 'children', i.toString()], child, ancestorPools);
  733. }
  734. }
  735. }
  736.  
  737.  
  738. /***/ }),
  739.  
  740. /***/ "./ts/library/validation/trees/predicates.ts":
  741. /*!***************************************************!*\
  742. !*** ./ts/library/validation/trees/predicates.ts ***!
  743. \***************************************************/
  744. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  745.  
  746. __webpack_require__.r(__webpack_exports__);
  747. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  748. /* harmony export */ validateParent: () => (/* binding */ validateParent)
  749. /* harmony export */ });
  750. /* harmony import */ var _errors__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../errors */ "./ts/library/validation/errors.ts");
  751. /* harmony import */ var _predicate__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../predicate */ "./ts/predicate.ts");
  752.  
  753.  
  754. function getBoundPredicatePromise(response, error) {
  755. return (0,_predicate__WEBPACK_IMPORTED_MODULE_1__.getPredicatePromise)(response)
  756. .catch(() => Promise.reject(error));
  757. }
  758. function validateChild(breadcrumbs, child) {
  759. if (!('options' in child) && !('predicate' in child))
  760. return Promise.resolve();
  761. if ('options' in child) {
  762. const type = typeof child.value;
  763. let valueFound = false;
  764. for (const [i, option] of child.options.entries()) {
  765. if (typeof option !== type) {
  766. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.JoinedError(new _errors__WEBPACK_IMPORTED_MODULE_0__.OptionMatchError(), new _errors__WEBPACK_IMPORTED_MODULE_0__.TypeError([...breadcrumbs, 'options', i.toString()], typeof option, [type]));
  767. }
  768. valueFound || (valueFound = child.value === option);
  769. }
  770. if (valueFound)
  771. return Promise.resolve();
  772. }
  773. if ('predicate' in child)
  774. return getBoundPredicatePromise(child.predicate(child.value), new _errors__WEBPACK_IMPORTED_MODULE_0__.PredicateError([...breadcrumbs, 'predicate']));
  775. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.JoinedError(new _errors__WEBPACK_IMPORTED_MODULE_0__.OptionError(), new _errors__WEBPACK_IMPORTED_MODULE_0__.ValueError([...breadcrumbs, 'value'], child.value, child.options));
  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 */ CONTRAST_METHODS: () => (/* binding */ CONTRAST_METHODS),
  817. /* harmony export */ INPUT_FORMATS: () => (/* binding */ INPUT_FORMATS),
  818. /* harmony export */ LEAF_KEYS: () => (/* binding */ LEAF_KEYS),
  819. /* harmony export */ MIDDLE_KEYS: () => (/* binding */ MIDDLE_KEYS),
  820. /* harmony export */ PAGE_KEYS: () => (/* binding */ PAGE_KEYS),
  821. /* harmony export */ ROOT_KEYS: () => (/* binding */ ROOT_KEYS),
  822. /* harmony export */ ROOT_OTHER_KEYS: () => (/* binding */ ROOT_OTHER_KEYS),
  823. /* harmony export */ ROOT_PREDICATE_KEYS: () => (/* binding */ ROOT_PREDICATE_KEYS),
  824. /* harmony export */ ROOT_UPDATE_KEYS: () => (/* binding */ ROOT_UPDATE_KEYS),
  825. /* harmony export */ SAVED_KEYS: () => (/* binding */ SAVED_KEYS),
  826. /* harmony export */ VALUE_TYPES: () => (/* binding */ VALUE_TYPES)
  827. /* harmony export */ });
  828. // Basic types
  829. const VALUE_TYPES = ['boolean', 'number', 'string'];
  830. const INPUT_FORMATS = ['color', 'date', 'datetime-local', 'email', 'month', 'password', 'search', 'tel', 'text', 'time', 'url', 'week'];
  831. const CONTRAST_METHODS = ['Black / White', 'Invert'];
  832. // Key categories
  833. const SAVED_KEYS = ['label', 'value', 'isActive', 'children'];
  834. const ROOT_PREDICATE_KEYS = ['childPredicate', 'descendantPredicate'];
  835. const ROOT_UPDATE_KEYS = ['onChildUpdate', 'onDescendantUpdate'];
  836. const ROOT_OTHER_KEYS = ['children', 'seed', 'poolId', 'get'];
  837. // Node types
  838. // hacky code to avoid a duplicate "get" in MIDDLE_KEYS
  839. const _LEAF_KEYS = ['label', 'value', 'predicate', 'options', 'input', 'isActive', 'onUpdate', 'listeners', 'hideId', 'inputAttributes'];
  840. const LEAF_KEYS = [..._LEAF_KEYS, 'get'];
  841. const ROOT_KEYS = [...ROOT_PREDICATE_KEYS, ...ROOT_UPDATE_KEYS, ...ROOT_OTHER_KEYS];
  842. const MIDDLE_KEYS = [..._LEAF_KEYS, ...ROOT_KEYS];
  843. // Config type
  844. const PAGE_KEYS = ['title', 'defaultTree', 'userTree', 'defaultStyle', 'userStyles'];
  845.  
  846.  
  847. /***/ }),
  848.  
  849. /***/ "./ts/modal/body/consts.ts":
  850. /*!*********************************!*\
  851. !*** ./ts/modal/body/consts.ts ***!
  852. \*********************************/
  853. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  854.  
  855. __webpack_require__.r(__webpack_exports__);
  856. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  857. /* harmony export */ MODAL_BODY_ID: () => (/* binding */ MODAL_BODY_ID)
  858. /* harmony export */ });
  859. const MODAL_BODY_ID = 'modal-body';
  860.  
  861.  
  862. /***/ }),
  863.  
  864. /***/ "./ts/modal/body/css.ts":
  865. /*!******************************!*\
  866. !*** ./ts/modal/body/css.ts ***!
  867. \******************************/
  868. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  869.  
  870. __webpack_require__.r(__webpack_exports__);
  871. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  872. /* harmony export */ "default": () => (/* binding */ generate)
  873. /* harmony export */ });
  874. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/consts.ts");
  875. /* harmony import */ var _nodes_css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./nodes/css */ "./ts/modal/body/nodes/css.ts");
  876. /* harmony import */ var _nodes_actions_css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./nodes/actions/css */ "./ts/modal/body/nodes/actions/css.ts");
  877. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../css */ "./ts/modal/css.ts");
  878.  
  879.  
  880.  
  881.  
  882. function generate() {
  883. (0,_nodes_css__WEBPACK_IMPORTED_MODULE_1__["default"])();
  884. (0,_nodes_actions_css__WEBPACK_IMPORTED_MODULE_2__["default"])();
  885. (0,_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`#${_consts__WEBPACK_IMPORTED_MODULE_0__.MODAL_BODY_ID}`, [
  886. ['overflow-y', 'auto'],
  887. ['overflow-x', 'hidden'],
  888. ['overscroll-behavior', 'contain'],
  889. ['background-color', 'var(--nodeValueBase)'],
  890. ['flex-grow', '1'],
  891. ]);
  892. }
  893.  
  894.  
  895. /***/ }),
  896.  
  897. /***/ "./ts/modal/body/data/consts.ts":
  898. /*!**************************************!*\
  899. !*** ./ts/modal/body/data/consts.ts ***!
  900. \**************************************/
  901. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  902.  
  903. __webpack_require__.r(__webpack_exports__);
  904. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  905. /* harmony export */ ROOT_ID: () => (/* binding */ ROOT_ID)
  906. /* harmony export */ });
  907. const ROOT_ID = 'root-data';
  908.  
  909.  
  910. /***/ }),
  911.  
  912. /***/ "./ts/modal/body/data/index.ts":
  913. /*!*************************************!*\
  914. !*** ./ts/modal/body/data/index.ts ***!
  915. \*************************************/
  916. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  917.  
  918. __webpack_require__.r(__webpack_exports__);
  919. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  920. /* harmony export */ "default": () => (/* binding */ generate),
  921. /* harmony export */ getRoot: () => (/* binding */ getRoot),
  922. /* harmony export */ getSaveData: () => (/* binding */ getSaveData),
  923. /* harmony export */ setTree: () => (/* binding */ setTree)
  924. /* harmony export */ });
  925. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/data/consts.ts");
  926. /* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../index */ "./ts/modal/body/index.ts");
  927.  
  928.  
  929. function getRoot() {
  930. return _index__WEBPACK_IMPORTED_MODULE_1__.ROOTS[_consts__WEBPACK_IMPORTED_MODULE_0__.ROOT_ID];
  931. }
  932. function getSaveData() {
  933. const { tree, config } = getRoot().getSaveData();
  934. return { tree, config };
  935. }
  936. function setTree(data) {
  937. const root = getRoot();
  938. // Spread avoids looping on a shrinking array
  939. for (const child of [...root.children]) {
  940. child.disconnect();
  941. }
  942. root.addChildren(data.children);
  943. }
  944. function generate(data) {
  945. return (0,_index__WEBPACK_IMPORTED_MODULE_1__.generateTree)(data, _consts__WEBPACK_IMPORTED_MODULE_0__.ROOT_ID);
  946. }
  947.  
  948.  
  949. /***/ }),
  950.  
  951. /***/ "./ts/modal/body/index.ts":
  952. /*!********************************!*\
  953. !*** ./ts/modal/body/index.ts ***!
  954. \********************************/
  955. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  956.  
  957. __webpack_require__.r(__webpack_exports__);
  958. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  959. /* harmony export */ ROOTS: () => (/* binding */ ROOTS),
  960. /* harmony export */ "default": () => (/* binding */ generate),
  961. /* harmony export */ element: () => (/* binding */ element),
  962. /* harmony export */ generateTree: () => (/* binding */ generateTree),
  963. /* harmony export */ reset: () => (/* binding */ reset),
  964. /* harmony export */ setActive: () => (/* binding */ setActive)
  965. /* harmony export */ });
  966. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/consts.ts");
  967. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./css */ "./ts/modal/body/css.ts");
  968. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./style */ "./ts/modal/body/style/index.ts");
  969. /* harmony import */ var _data__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./data */ "./ts/modal/body/data/index.ts");
  970. /* harmony import */ var _nodes_actions_highlight__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./nodes/actions/highlight */ "./ts/modal/body/nodes/actions/highlight/index.ts");
  971. /* harmony import */ var _nodes_actions_active__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./nodes/actions/active */ "./ts/modal/body/nodes/actions/active.ts");
  972. /* harmony import */ var _nodes_actions_history__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./nodes/actions/history */ "./ts/modal/body/nodes/actions/history.ts");
  973. /* harmony import */ var _nodes_root__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./nodes/root */ "./ts/modal/body/nodes/root.ts");
  974. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../consts */ "./ts/modal/consts.ts");
  975. /* harmony import */ var _modal_header_actions_sticky_css__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! @/modal/header/actions/sticky/css */ "./ts/modal/header/actions/sticky/css.ts");
  976.  
  977.  
  978.  
  979.  
  980.  
  981.  
  982.  
  983.  
  984.  
  985.  
  986. const ROOTS = {};
  987. const element = document.createElement('div');
  988. let resetTree;
  989. function setActive(button, actionId, doActivate = true) {
  990. if (doActivate) {
  991. button.classList.add(_consts__WEBPACK_IMPORTED_MODULE_8__.BUTTON_ACTIVE_CLASS);
  992. element.classList.add(actionId);
  993. }
  994. else {
  995. button.classList.remove(_consts__WEBPACK_IMPORTED_MODULE_8__.BUTTON_ACTIVE_CLASS);
  996. element.classList.remove(actionId);
  997. }
  998. }
  999. function generateTree(data, id) {
  1000. if (ROOTS[id]) {
  1001. throw new Error(`Attempted to instantiate second tree with id '${id}'.`);
  1002. }
  1003. const root = new _nodes_root__WEBPACK_IMPORTED_MODULE_7__["default"](data);
  1004. root.element.elementContainer.id = id;
  1005. ROOTS[id] = root;
  1006. return root.element.elementContainer;
  1007. }
  1008. function generate({ userTree, defaultTree, userStyles, defaultStyle }) {
  1009. resetTree = defaultTree;
  1010. (0,_css__WEBPACK_IMPORTED_MODULE_1__["default"])();
  1011. element.id = _consts__WEBPACK_IMPORTED_MODULE_0__.MODAL_BODY_ID;
  1012. // avoid blurring an input when dragging the scrollbar
  1013. element.addEventListener('mousedown', (event) => {
  1014. event.stopPropagation();
  1015. event.preventDefault();
  1016. });
  1017. element.append((0,_style__WEBPACK_IMPORTED_MODULE_2__["default"])(userStyles, defaultStyle), (0,_data__WEBPACK_IMPORTED_MODULE_3__["default"])(userTree !== null && userTree !== void 0 ? userTree : defaultTree));
  1018. (0,_nodes_actions_highlight__WEBPACK_IMPORTED_MODULE_4__.onMount)();
  1019. (0,_nodes_actions_active__WEBPACK_IMPORTED_MODULE_5__.onMount)();
  1020. (0,_nodes_actions_history__WEBPACK_IMPORTED_MODULE_6__.onMount)();
  1021. (0,_modal_header_actions_sticky_css__WEBPACK_IMPORTED_MODULE_9__["default"])(ROOTS);
  1022. return element;
  1023. }
  1024. function reset() {
  1025. (0,_data__WEBPACK_IMPORTED_MODULE_3__.setTree)(resetTree);
  1026. }
  1027.  
  1028.  
  1029. /***/ }),
  1030.  
  1031. /***/ "./ts/modal/body/nodes/actions/active.ts":
  1032. /*!***********************************************!*\
  1033. !*** ./ts/modal/body/nodes/actions/active.ts ***!
  1034. \***********************************************/
  1035. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1036.  
  1037. __webpack_require__.r(__webpack_exports__);
  1038. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1039. /* harmony export */ onMount: () => (/* binding */ onMount),
  1040. /* harmony export */ reset: () => (/* binding */ reset)
  1041. /* harmony export */ });
  1042. /* harmony import */ var _highlight__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./highlight */ "./ts/modal/body/nodes/actions/highlight/index.ts");
  1043. /* harmony import */ var _focus__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./focus */ "./ts/modal/body/nodes/actions/focus/index.ts");
  1044. /* harmony import */ var _buttons_position__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./buttons/position */ "./ts/modal/body/nodes/actions/buttons/position/index.ts");
  1045. /* harmony import */ var _modal__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/modal */ "./ts/modal/index.ts");
  1046.  
  1047.  
  1048.  
  1049.  
  1050. function reset() {
  1051. for (const action of [_buttons_position__WEBPACK_IMPORTED_MODULE_2__, _focus__WEBPACK_IMPORTED_MODULE_1__, _highlight__WEBPACK_IMPORTED_MODULE_0__]) {
  1052. if (action.isActive()) {
  1053. action.reset();
  1054. return true;
  1055. }
  1056. }
  1057. return false;
  1058. }
  1059. function onMount() {
  1060. (0,_modal__WEBPACK_IMPORTED_MODULE_3__.getSocket)().addEventListener('keydown', (event) => {
  1061. if ((event.key === 'Escape' || event.key === 'Backspace') && reset()) {
  1062. event.stopImmediatePropagation();
  1063. }
  1064. });
  1065. }
  1066.  
  1067.  
  1068. /***/ }),
  1069.  
  1070. /***/ "./ts/modal/body/nodes/actions/buttons/button.ts":
  1071. /*!*******************************************************!*\
  1072. !*** ./ts/modal/body/nodes/actions/buttons/button.ts ***!
  1073. \*******************************************************/
  1074. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1075.  
  1076. __webpack_require__.r(__webpack_exports__);
  1077. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1078. /* harmony export */ addActionButton: () => (/* binding */ addActionButton),
  1079. /* harmony export */ getNewButton: () => (/* binding */ getNewButton)
  1080. /* harmony export */ });
  1081. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/buttons/consts.ts");
  1082. /* harmony import */ var _overlays_tooltip__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../overlays/tooltip */ "./ts/modal/body/nodes/actions/overlays/tooltip/index.ts");
  1083. /* harmony import */ var _overlays__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../overlays */ "./ts/modal/body/nodes/actions/overlays/index.ts");
  1084. /* harmony import */ var _overlays_tooltip_consts__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../overlays/tooltip/consts */ "./ts/modal/body/nodes/actions/overlays/tooltip/consts.ts");
  1085. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  1086. /* harmony import */ var _modal_header_actions_alternate__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @/modal/header/actions/alternate */ "./ts/modal/header/actions/alternate/index.ts");
  1087. /* harmony import */ var _predicate__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @/predicate */ "./ts/predicate.ts");
  1088.  
  1089.  
  1090.  
  1091.  
  1092.  
  1093.  
  1094.  
  1095. // Creates an instantiation & adds it to the DOM
  1096. function addActionButton(template, onClick, node) {
  1097. const button = template.cloneNode(true);
  1098. button.addEventListener('click', (event) => {
  1099. event.stopPropagation();
  1100. if ((0,_predicate__WEBPACK_IMPORTED_MODULE_6__.isUnresolved)()) {
  1101. (0,_overlays__WEBPACK_IMPORTED_MODULE_2__.showTooltip)(_overlays_tooltip_consts__WEBPACK_IMPORTED_MODULE_3__.MESSAGE_UNRESOLVED, node, button.querySelector('circle'));
  1102. return;
  1103. }
  1104. (0,_overlays_tooltip__WEBPACK_IMPORTED_MODULE_1__.kill)();
  1105. if (event.ctrlKey) {
  1106. (0,_modal_header_actions_alternate__WEBPACK_IMPORTED_MODULE_5__.doAction)(true);
  1107. onClick(node, button, (0,_modal_header_actions_alternate__WEBPACK_IMPORTED_MODULE_5__.isActive)());
  1108. }
  1109. else {
  1110. onClick(node, button, (0,_modal_header_actions_alternate__WEBPACK_IMPORTED_MODULE_5__.isActive)());
  1111. }
  1112. });
  1113. button.addEventListener('keydown', (event) => {
  1114. // Prevent button presses via the Enter key from triggering actions
  1115. if (event.key === 'Enter') {
  1116. event.stopPropagation();
  1117. }
  1118. });
  1119. button.addEventListener('mouseleave', () => {
  1120. button.blur();
  1121. });
  1122. node.element.addButton(button);
  1123. return button;
  1124. }
  1125. // Creates a template
  1126. const getNewButton = (function () {
  1127. const buttonTemplate = document.createElement('button');
  1128. buttonTemplate.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS);
  1129. // Prevent tabbing to buttons until node is focused
  1130. buttonTemplate.setAttribute('tabindex', '-1');
  1131. const svgTemplate = (() => {
  1132. const circle = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_4__.SVG_NAMESPACE, 'circle');
  1133. circle.setAttribute('r', '50');
  1134. circle.setAttribute('stroke-width', '10');
  1135. const svg = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_4__.SVG_NAMESPACE, 'svg');
  1136. svg.setAttribute('viewBox', '-70 -70 140 140');
  1137. svg.append(circle);
  1138. return svg;
  1139. })();
  1140. return function (group, actionId, description) {
  1141. const button = buttonTemplate.cloneNode(true);
  1142. const svg = svgTemplate.cloneNode(true);
  1143. button.classList.add(actionId);
  1144. button.title = description;
  1145. svg.append(group);
  1146. button.append(svg);
  1147. return button;
  1148. };
  1149. })();
  1150.  
  1151.  
  1152. /***/ }),
  1153.  
  1154. /***/ "./ts/modal/body/nodes/actions/buttons/consts.ts":
  1155. /*!*******************************************************!*\
  1156. !*** ./ts/modal/body/nodes/actions/buttons/consts.ts ***!
  1157. \*******************************************************/
  1158. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1159.  
  1160. __webpack_require__.r(__webpack_exports__);
  1161. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1162. /* harmony export */ ALT_CLASS: () => (/* binding */ ALT_CLASS),
  1163. /* harmony export */ BUTTON_CLASS: () => (/* binding */ BUTTON_CLASS),
  1164. /* harmony export */ TEST_ADD_CLASS: () => (/* binding */ TEST_ADD_CLASS),
  1165. /* harmony export */ TEST_REMOVE_CLASS: () => (/* binding */ TEST_REMOVE_CLASS)
  1166. /* harmony export */ });
  1167. const BUTTON_CLASS = 'node-button';
  1168. const ALT_CLASS = 'node-icon-alt';
  1169. const TEST_ADD_CLASS = 'node-test-add';
  1170. const TEST_REMOVE_CLASS = 'node-test-remove';
  1171.  
  1172.  
  1173. /***/ }),
  1174.  
  1175. /***/ "./ts/modal/body/nodes/actions/buttons/create/button.ts":
  1176. /*!**************************************************************!*\
  1177. !*** ./ts/modal/body/nodes/actions/buttons/create/button.ts ***!
  1178. \**************************************************************/
  1179. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1180.  
  1181. __webpack_require__.r(__webpack_exports__);
  1182. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1183. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  1184. /* harmony export */ });
  1185. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/buttons/create/consts.ts");
  1186. /* harmony import */ var _position_button_alt__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../position/button/alt */ "./ts/modal/body/nodes/actions/buttons/position/button/alt.ts");
  1187. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  1188.  
  1189.  
  1190.  
  1191. const lineHorizontal = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'line');
  1192. lineHorizontal.setAttribute('stroke-linecap', 'round');
  1193. lineHorizontal.setAttribute('stroke-width', '12');
  1194. lineHorizontal.setAttribute('x1', '-25');
  1195. lineHorizontal.setAttribute('x2', '25');
  1196. const lineVertical = lineHorizontal.cloneNode(true);
  1197. lineVertical.setAttribute('transform', 'rotate(90)');
  1198. const g = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'g');
  1199. g.append(lineHorizontal, lineVertical);
  1200. const BUTTON = (0,_position_button_alt__WEBPACK_IMPORTED_MODULE_1__.getPositionedButton)(g, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, 'Create', { scale: '1 1.15' });
  1201. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (BUTTON);
  1202.  
  1203.  
  1204. /***/ }),
  1205.  
  1206. /***/ "./ts/modal/body/nodes/actions/buttons/create/consts.ts":
  1207. /*!**************************************************************!*\
  1208. !*** ./ts/modal/body/nodes/actions/buttons/create/consts.ts ***!
  1209. \**************************************************************/
  1210. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1211.  
  1212. __webpack_require__.r(__webpack_exports__);
  1213. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1214. /* harmony export */ ACTION_ID: () => (/* binding */ ACTION_ID)
  1215. /* harmony export */ });
  1216. const ACTION_ID = 'node-create';
  1217.  
  1218.  
  1219. /***/ }),
  1220.  
  1221. /***/ "./ts/modal/body/nodes/actions/buttons/create/css.ts":
  1222. /*!***********************************************************!*\
  1223. !*** ./ts/modal/body/nodes/actions/buttons/create/css.ts ***!
  1224. \***********************************************************/
  1225. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1226.  
  1227. __webpack_require__.r(__webpack_exports__);
  1228. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1229. /* harmony export */ "default": () => (/* binding */ generate)
  1230. /* harmony export */ });
  1231. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/buttons/create/consts.ts");
  1232. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../css */ "./ts/modal/body/nodes/actions/buttons/css.ts");
  1233.  
  1234.  
  1235. function generate() {
  1236. (0,_css__WEBPACK_IMPORTED_MODULE_1__.addColourRule)(_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, '--nodeButtonCreate');
  1237. }
  1238.  
  1239.  
  1240. /***/ }),
  1241.  
  1242. /***/ "./ts/modal/body/nodes/actions/buttons/create/index.ts":
  1243. /*!*************************************************************!*\
  1244. !*** ./ts/modal/body/nodes/actions/buttons/create/index.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 */ mount: () => (/* binding */ mount),
  1251. /* harmony export */ shouldMount: () => (/* binding */ shouldMount)
  1252. /* harmony export */ });
  1253. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/buttons/create/consts.ts");
  1254. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button */ "./ts/modal/body/nodes/actions/buttons/create/button.ts");
  1255. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../consts */ "./ts/modal/body/nodes/actions/buttons/consts.ts");
  1256. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../button */ "./ts/modal/body/nodes/actions/buttons/button.ts");
  1257. /* harmony import */ var _position__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../position */ "./ts/modal/body/nodes/actions/buttons/position/index.ts");
  1258. /* harmony import */ var _history__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../history */ "./ts/modal/body/nodes/actions/history.ts");
  1259. /* harmony import */ var _callbacks__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../callbacks */ "./ts/modal/body/nodes/actions/callbacks/index.ts");
  1260. /* harmony import */ var _overlays__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../overlays */ "./ts/modal/body/nodes/actions/overlays/index.ts");
  1261. /* harmony import */ var _nodes_middle__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @nodes/middle */ "./ts/modal/body/nodes/middle.ts");
  1262. /* harmony import */ var _nodes_child__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! @nodes/child */ "./ts/modal/body/nodes/child.ts");
  1263.  
  1264.  
  1265.  
  1266.  
  1267.  
  1268.  
  1269.  
  1270.  
  1271.  
  1272.  
  1273. function getChild(node) {
  1274. const { seed } = node;
  1275. const child = 'children' in seed ? new _nodes_middle__WEBPACK_IMPORTED_MODULE_8__["default"](seed, node, 0) : new _nodes_child__WEBPACK_IMPORTED_MODULE_9__["default"](seed, node, 0);
  1276. child.element.addClass(_consts__WEBPACK_IMPORTED_MODULE_2__.TEST_ADD_CLASS);
  1277. return child;
  1278. }
  1279. function doAction(source, parent, index, button) {
  1280. const child = getChild(source);
  1281. child.move(parent, index);
  1282. return Promise.all(_callbacks__WEBPACK_IMPORTED_MODULE_6__["default"].predicate.getSub(child.getAncestors()))
  1283. .then(() => {
  1284. _history__WEBPACK_IMPORTED_MODULE_5__.register(child, () => child.disconnect(), () => child.attach(parent, index), false, true);
  1285. child.element.removeClass(_consts__WEBPACK_IMPORTED_MODULE_2__.TEST_ADD_CLASS);
  1286. child.isActive = true;
  1287. _callbacks__WEBPACK_IMPORTED_MODULE_6__["default"].update.triggerSub(child.getAncestors());
  1288. return child;
  1289. })
  1290. .catch((reason) => {
  1291. child.disconnect();
  1292. if (reason) {
  1293. (0,_overlays__WEBPACK_IMPORTED_MODULE_7__.showTooltip)(reason, child, button.querySelector('circle'));
  1294. }
  1295. });
  1296. }
  1297. function onClick(node, button, isAlt) {
  1298. if (isAlt) {
  1299. _position__WEBPACK_IMPORTED_MODULE_4__.mount(node, node.seed, node, node.children, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, button, doAction, false);
  1300. }
  1301. else {
  1302. _position__WEBPACK_IMPORTED_MODULE_4__.reset(node);
  1303. doAction(node, node, 0, button);
  1304. }
  1305. }
  1306. function mount(node) {
  1307. (0,_button__WEBPACK_IMPORTED_MODULE_3__.addActionButton)(_button__WEBPACK_IMPORTED_MODULE_1__["default"], onClick, node);
  1308. }
  1309. function shouldMount(node) {
  1310. return 'seed' in node;
  1311. }
  1312.  
  1313.  
  1314. /***/ }),
  1315.  
  1316. /***/ "./ts/modal/body/nodes/actions/buttons/css.ts":
  1317. /*!****************************************************!*\
  1318. !*** ./ts/modal/body/nodes/actions/buttons/css.ts ***!
  1319. \****************************************************/
  1320. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1321.  
  1322. __webpack_require__.r(__webpack_exports__);
  1323. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1324. /* harmony export */ addColourRule: () => (/* binding */ addColourRule),
  1325. /* harmony export */ "default": () => (/* binding */ generate)
  1326. /* harmony export */ });
  1327. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/buttons/consts.ts");
  1328. /* harmony import */ var _create_css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./create/css */ "./ts/modal/body/nodes/actions/buttons/create/css.ts");
  1329. /* harmony import */ var _move_css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./move/css */ "./ts/modal/body/nodes/actions/buttons/move/css.ts");
  1330. /* harmony import */ var _disable_css__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./disable/css */ "./ts/modal/body/nodes/actions/buttons/disable/css.ts");
  1331. /* harmony import */ var _duplicate_css__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./duplicate/css */ "./ts/modal/body/nodes/actions/buttons/duplicate/css.ts");
  1332. /* harmony import */ var _position_css__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./position/css */ "./ts/modal/body/nodes/actions/buttons/position/css.ts");
  1333. /* harmony import */ var _highlight_consts__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../highlight/consts */ "./ts/modal/body/nodes/actions/highlight/consts.ts");
  1334. /* harmony import */ var _nodes_consts__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @nodes/consts */ "./ts/modal/body/nodes/consts.ts");
  1335. /* harmony import */ var _modal_header_actions_alternate_consts__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @/modal/header/actions/alternate/consts */ "./ts/modal/header/actions/alternate/consts.ts");
  1336. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  1337. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  1338.  
  1339.  
  1340.  
  1341.  
  1342.  
  1343.  
  1344.  
  1345.  
  1346.  
  1347.  
  1348.  
  1349. function addColourRule(actionId, strokeVar) {
  1350. (0,_modal_css__WEBPACK_IMPORTED_MODULE_10__.addRule)([
  1351. `.${_nodes_consts__WEBPACK_IMPORTED_MODULE_7__.ELEMENT_CLASSES.ELEMENT_CONTAINER}:not(.${_highlight_consts__WEBPACK_IMPORTED_MODULE_6__.HIGHLIGHT_CLASS}) > `
  1352. + `.${_nodes_consts__WEBPACK_IMPORTED_MODULE_7__.ELEMENT_CLASSES.HEAD_CONTAINER} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_7__.ELEMENT_CLASSES.BUTTON_CONTAINER} > `
  1353. + `.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}.${actionId} > svg`,
  1354. ], ['fill', `var(${strokeVar})`]);
  1355. (0,_modal_css__WEBPACK_IMPORTED_MODULE_10__.addRule)(`.${_highlight_consts__WEBPACK_IMPORTED_MODULE_6__.HIGHLIGHT_CLASS} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_7__.ELEMENT_CLASSES.HEAD_CONTAINER} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_7__.ELEMENT_CLASSES.BUTTON_CONTAINER} > `
  1356. + `.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}.${actionId}.${_modal_consts__WEBPACK_IMPORTED_MODULE_9__.BUTTON_ACTIVE_CLASS} > svg > g`, ['stroke', `var(${strokeVar})`]);
  1357. (0,_modal_css__WEBPACK_IMPORTED_MODULE_10__.addRule)([
  1358. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}.${actionId}.${_modal_consts__WEBPACK_IMPORTED_MODULE_9__.BUTTON_ACTIVE_CLASS}:hover > svg > circle`,
  1359. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}.${actionId}.${_modal_consts__WEBPACK_IMPORTED_MODULE_9__.BUTTON_ACTIVE_CLASS}:focus > svg > circle`,
  1360. ], ['stroke', `var(${strokeVar})`]);
  1361. }
  1362. function generate() {
  1363. (0,_create_css__WEBPACK_IMPORTED_MODULE_1__["default"])();
  1364. (0,_move_css__WEBPACK_IMPORTED_MODULE_2__["default"])();
  1365. (0,_disable_css__WEBPACK_IMPORTED_MODULE_3__["default"])();
  1366. (0,_duplicate_css__WEBPACK_IMPORTED_MODULE_4__["default"])();
  1367. (0,_position_css__WEBPACK_IMPORTED_MODULE_5__["default"])();
  1368. (0,_modal_css__WEBPACK_IMPORTED_MODULE_10__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}`, [
  1369. ['height', '100%'],
  1370. ['position', 'relative'],
  1371. ]);
  1372. (0,_modal_css__WEBPACK_IMPORTED_MODULE_10__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS} > svg`, [
  1373. ['height', '100%'],
  1374. ['transform', 'scale(1.05)'],
  1375. ]);
  1376. (0,_modal_css__WEBPACK_IMPORTED_MODULE_10__.addRule)(`.${_nodes_consts__WEBPACK_IMPORTED_MODULE_7__.ELEMENT_CLASSES.BUTTON_CONTAINER}`, [
  1377. ['white-space', 'nowrap'],
  1378. ['z-index', '1'],
  1379. ]);
  1380. // Hide prospective nodes
  1381. (0,_modal_css__WEBPACK_IMPORTED_MODULE_10__.addRule)([
  1382. `.${_nodes_consts__WEBPACK_IMPORTED_MODULE_7__.ELEMENT_CLASSES.ELEMENT_CONTAINER}.${_consts__WEBPACK_IMPORTED_MODULE_0__.TEST_ADD_CLASS}`,
  1383. `.${_nodes_consts__WEBPACK_IMPORTED_MODULE_7__.ELEMENT_CLASSES.ELEMENT_CONTAINER}.${_consts__WEBPACK_IMPORTED_MODULE_0__.TEST_REMOVE_CLASS}`,
  1384. ], [['pointer-events', 'none']]);
  1385. // Hide alt icon components
  1386. (0,_modal_css__WEBPACK_IMPORTED_MODULE_10__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ALT_CLASS}:not(.${_modal_header_actions_alternate_consts__WEBPACK_IMPORTED_MODULE_8__.ACTION_ID} *)`, ['display', 'none']);
  1387. (0,_modal_css__WEBPACK_IMPORTED_MODULE_10__.addRule)(`.${_modal_header_actions_alternate_consts__WEBPACK_IMPORTED_MODULE_8__.ACTION_ID} button.${_consts__WEBPACK_IMPORTED_MODULE_0__.ALT_CLASS} + *`, ['display', 'none']);
  1388. for (const [selector, base, contrast] of _nodes_consts__WEBPACK_IMPORTED_MODULE_7__.NODE_COLOURS) {
  1389. const buttonSelector = `${selector} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_7__.ELEMENT_CLASSES.HEAD_CONTAINER} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_7__.ELEMENT_CLASSES.BUTTON_CONTAINER}`;
  1390. (0,_modal_css__WEBPACK_IMPORTED_MODULE_10__.addRule)(`.${_highlight_consts__WEBPACK_IMPORTED_MODULE_6__.HIGHLIGHT_CLASS}${buttonSelector} > .${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}:not(.${_modal_consts__WEBPACK_IMPORTED_MODULE_9__.BUTTON_ACTIVE_CLASS}):not(:focus):not(:hover) > svg > g`, ['stroke', base]);
  1391. (0,_modal_css__WEBPACK_IMPORTED_MODULE_10__.addRule)(`${buttonSelector} > .${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}:not(.${_modal_consts__WEBPACK_IMPORTED_MODULE_9__.BUTTON_ACTIVE_CLASS}:hover):not(.${_modal_consts__WEBPACK_IMPORTED_MODULE_9__.BUTTON_ACTIVE_CLASS}:focus) > svg > circle`, ['stroke', base]);
  1392. (0,_modal_css__WEBPACK_IMPORTED_MODULE_10__.addRule)([
  1393. // Not active, focused
  1394. `${buttonSelector} > .${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}:focus > svg > g`,
  1395. `${buttonSelector} > .${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}:hover > svg > g`,
  1396. ], [['stroke', contrast]]);
  1397. (0,_modal_css__WEBPACK_IMPORTED_MODULE_10__.addRule)([`${buttonSelector} > .${_modal_consts__WEBPACK_IMPORTED_MODULE_9__.BUTTON_ACTIVE_CLASS} > svg`], [['stroke', base]]);
  1398. (0,_modal_css__WEBPACK_IMPORTED_MODULE_10__.addRule)([
  1399. // Not active, focused
  1400. `${buttonSelector} > .${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}:focus > svg`,
  1401. `${buttonSelector} > .${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}:hover > svg`,
  1402. `.${_highlight_consts__WEBPACK_IMPORTED_MODULE_6__.HIGHLIGHT_CLASS}${buttonSelector} > .${_modal_consts__WEBPACK_IMPORTED_MODULE_9__.BUTTON_ACTIVE_CLASS} > svg`,
  1403. ], [['fill', base]]);
  1404. }
  1405. }
  1406.  
  1407.  
  1408. /***/ }),
  1409.  
  1410. /***/ "./ts/modal/body/nodes/actions/buttons/disable/button.ts":
  1411. /*!***************************************************************!*\
  1412. !*** ./ts/modal/body/nodes/actions/buttons/disable/button.ts ***!
  1413. \***************************************************************/
  1414. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1415.  
  1416. __webpack_require__.r(__webpack_exports__);
  1417. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1418. /* harmony export */ BUTTON_ALT: () => (/* binding */ BUTTON_ALT),
  1419. /* harmony export */ BUTTON_DEFAULT: () => (/* binding */ BUTTON_DEFAULT)
  1420. /* harmony export */ });
  1421. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/buttons/disable/consts.ts");
  1422. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../consts */ "./ts/modal/body/nodes/actions/buttons/consts.ts");
  1423. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../button */ "./ts/modal/body/nodes/actions/buttons/button.ts");
  1424. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  1425.  
  1426.  
  1427.  
  1428.  
  1429. const gDefault = (() => {
  1430. const circle = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_3__.SVG_NAMESPACE, 'circle');
  1431. circle.setAttribute('r', '30');
  1432. circle.setAttribute('stroke-width', '10');
  1433. const line = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_3__.SVG_NAMESPACE, 'line');
  1434. line.setAttribute('stroke-linecap', 'round');
  1435. line.setAttribute('stroke-width', '10');
  1436. line.setAttribute('x1', '-30');
  1437. line.setAttribute('x2', '30');
  1438. line.setAttribute('transform', 'rotate(45)');
  1439. const g = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_3__.SVG_NAMESPACE, 'g');
  1440. g.append(circle, line);
  1441. return g;
  1442. })();
  1443. const BUTTON_DEFAULT = (0,_button__WEBPACK_IMPORTED_MODULE_2__.getNewButton)(gDefault, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID_DEFAULT, 'Toggle Enabled');
  1444. const gAlt = (() => {
  1445. const line0 = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_3__.SVG_NAMESPACE, 'line');
  1446. line0.setAttribute('stroke-linecap', 'round');
  1447. line0.setAttribute('stroke-width', '12');
  1448. line0.setAttribute('x1', '-20');
  1449. line0.setAttribute('x2', '20');
  1450. line0.setAttribute('y1', '-20');
  1451. line0.setAttribute('y2', '20');
  1452. const line1 = line0.cloneNode(true);
  1453. line1.setAttribute('transform', 'rotate(90)');
  1454. const g = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_3__.SVG_NAMESPACE, 'g');
  1455. g.append(line0, line1);
  1456. return g;
  1457. })();
  1458. const BUTTON_ALT = (0,_button__WEBPACK_IMPORTED_MODULE_2__.getNewButton)(gAlt, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID_ALT, 'Delete');
  1459. BUTTON_ALT.classList.add(_consts__WEBPACK_IMPORTED_MODULE_1__.ALT_CLASS);
  1460.  
  1461.  
  1462. /***/ }),
  1463.  
  1464. /***/ "./ts/modal/body/nodes/actions/buttons/disable/consts.ts":
  1465. /*!***************************************************************!*\
  1466. !*** ./ts/modal/body/nodes/actions/buttons/disable/consts.ts ***!
  1467. \***************************************************************/
  1468. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1469.  
  1470. __webpack_require__.r(__webpack_exports__);
  1471. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1472. /* harmony export */ ACTION_ID_ALT: () => (/* binding */ ACTION_ID_ALT),
  1473. /* harmony export */ ACTION_ID_DEFAULT: () => (/* binding */ ACTION_ID_DEFAULT),
  1474. /* harmony export */ DISABLED_CLASS: () => (/* binding */ DISABLED_CLASS)
  1475. /* harmony export */ });
  1476. const ACTION_ID_DEFAULT = 'node-active';
  1477. const ACTION_ID_ALT = 'node-delete';
  1478. const DISABLED_CLASS = 'node-disable';
  1479.  
  1480.  
  1481. /***/ }),
  1482.  
  1483. /***/ "./ts/modal/body/nodes/actions/buttons/disable/css.ts":
  1484. /*!************************************************************!*\
  1485. !*** ./ts/modal/body/nodes/actions/buttons/disable/css.ts ***!
  1486. \************************************************************/
  1487. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1488.  
  1489. __webpack_require__.r(__webpack_exports__);
  1490. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1491. /* harmony export */ "default": () => (/* binding */ generate)
  1492. /* harmony export */ });
  1493. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/buttons/disable/consts.ts");
  1494. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../css */ "./ts/modal/body/nodes/actions/buttons/css.ts");
  1495. /* harmony import */ var _highlight_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../highlight/consts */ "./ts/modal/body/nodes/actions/highlight/consts.ts");
  1496. /* harmony import */ var _nodes_consts__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @nodes/consts */ "./ts/modal/body/nodes/consts.ts");
  1497. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  1498.  
  1499.  
  1500.  
  1501.  
  1502.  
  1503. function generate() {
  1504. (0,_css__WEBPACK_IMPORTED_MODULE_1__.addColourRule)(_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID_DEFAULT, '--nodeButtonDisable');
  1505. (0,_css__WEBPACK_IMPORTED_MODULE_1__.addColourRule)(_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID_ALT, '--nodeButtonDelete');
  1506. (0,_modal_css__WEBPACK_IMPORTED_MODULE_4__.addRule)([
  1507. // Self selectors
  1508. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.DISABLED_CLASS}:not(.${_highlight_consts__WEBPACK_IMPORTED_MODULE_2__.HIGHLIGHT_CLASS}) > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_3__.ELEMENT_CLASSES.HEAD_CONTAINER} .${_nodes_consts__WEBPACK_IMPORTED_MODULE_3__.ELEMENT_CLASSES.VALUE_CONTAINER}`,
  1509. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.DISABLED_CLASS}:not(.${_highlight_consts__WEBPACK_IMPORTED_MODULE_2__.HIGHLIGHT_CLASS}) > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_3__.ELEMENT_CLASSES.HEAD_CONTAINER} .${_nodes_consts__WEBPACK_IMPORTED_MODULE_3__.ELEMENT_CLASSES.LABEL_CONTAINER}`,
  1510. // Descendant selectors
  1511. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.DISABLED_CLASS} :not(.${_highlight_consts__WEBPACK_IMPORTED_MODULE_2__.HIGHLIGHT_CLASS}) > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_3__.ELEMENT_CLASSES.HEAD_CONTAINER} .${_nodes_consts__WEBPACK_IMPORTED_MODULE_3__.ELEMENT_CLASSES.VALUE_CONTAINER}`,
  1512. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.DISABLED_CLASS} :not(.${_highlight_consts__WEBPACK_IMPORTED_MODULE_2__.HIGHLIGHT_CLASS}) > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_3__.ELEMENT_CLASSES.HEAD_CONTAINER} .${_nodes_consts__WEBPACK_IMPORTED_MODULE_3__.ELEMENT_CLASSES.LABEL_CONTAINER}`,
  1513. ], ['opacity', '0.5']);
  1514. }
  1515.  
  1516.  
  1517. /***/ }),
  1518.  
  1519. /***/ "./ts/modal/body/nodes/actions/buttons/disable/index.ts":
  1520. /*!**************************************************************!*\
  1521. !*** ./ts/modal/body/nodes/actions/buttons/disable/index.ts ***!
  1522. \**************************************************************/
  1523. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1524.  
  1525. __webpack_require__.r(__webpack_exports__);
  1526. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1527. /* harmony export */ mount: () => (/* binding */ mount),
  1528. /* harmony export */ shouldMount: () => (/* binding */ shouldMount)
  1529. /* harmony export */ });
  1530. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/buttons/disable/consts.ts");
  1531. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button */ "./ts/modal/body/nodes/actions/buttons/disable/button.ts");
  1532. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../button */ "./ts/modal/body/nodes/actions/buttons/button.ts");
  1533. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../consts */ "./ts/modal/body/nodes/actions/buttons/consts.ts");
  1534. /* harmony import */ var _position__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../position */ "./ts/modal/body/nodes/actions/buttons/position/index.ts");
  1535. /* harmony import */ var _history__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../history */ "./ts/modal/body/nodes/actions/history.ts");
  1536. /* harmony import */ var _callbacks__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../callbacks */ "./ts/modal/body/nodes/actions/callbacks/index.ts");
  1537. /* harmony import */ var _overlays__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../overlays */ "./ts/modal/body/nodes/actions/overlays/index.ts");
  1538. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  1539.  
  1540.  
  1541.  
  1542.  
  1543.  
  1544.  
  1545.  
  1546.  
  1547.  
  1548. function updateButton(button, isActive) {
  1549. button.classList[isActive ? 'remove' : 'add'](_modal_consts__WEBPACK_IMPORTED_MODULE_8__.BUTTON_ACTIVE_CLASS);
  1550. }
  1551. function toggle(node) {
  1552. node.element[`${node.isActive ? 'add' : 'remove'}Class`](_consts__WEBPACK_IMPORTED_MODULE_0__.DISABLED_CLASS);
  1553. node.isActive = !node.isActive;
  1554. }
  1555. function onClick(node, button, isAlt) {
  1556. if (isAlt) {
  1557. node.element.addClass(_consts__WEBPACK_IMPORTED_MODULE_3__.TEST_REMOVE_CLASS);
  1558. _position__WEBPACK_IMPORTED_MODULE_4__.reset(node);
  1559. }
  1560. else {
  1561. toggle(node);
  1562. }
  1563. Promise.all(_callbacks__WEBPACK_IMPORTED_MODULE_6__["default"].predicate.getSub(node.getAncestors()))
  1564. .then(() => {
  1565. const ancestors = node.getAncestors();
  1566. node.element.removeClass(_consts__WEBPACK_IMPORTED_MODULE_3__.TEST_REMOVE_CLASS);
  1567. if (isAlt) {
  1568. _history__WEBPACK_IMPORTED_MODULE_5__.register(node, node.attach.bind(node, node.parent, node.getIndex()), () => node.disconnect(), true, false, true);
  1569. }
  1570. else {
  1571. const act = () => {
  1572. toggle(node);
  1573. updateButton(button, node.isActive);
  1574. };
  1575. _history__WEBPACK_IMPORTED_MODULE_5__.register(node, act, act, false);
  1576. updateButton(button, node.isActive);
  1577. }
  1578. _callbacks__WEBPACK_IMPORTED_MODULE_6__["default"].update.triggerSub(ancestors);
  1579. })
  1580. .catch((reason) => {
  1581. if (isAlt) {
  1582. node.element.removeClass(_consts__WEBPACK_IMPORTED_MODULE_3__.TEST_REMOVE_CLASS);
  1583. }
  1584. else {
  1585. toggle(node);
  1586. }
  1587. if (typeof reason === 'string') {
  1588. (0,_overlays__WEBPACK_IMPORTED_MODULE_7__.showTooltip)(reason, node, button.querySelector('circle'));
  1589. }
  1590. });
  1591. }
  1592. function mount(node) {
  1593. (0,_button__WEBPACK_IMPORTED_MODULE_2__.addActionButton)(_button__WEBPACK_IMPORTED_MODULE_1__.BUTTON_ALT, onClick, node);
  1594. const defaultButton = (0,_button__WEBPACK_IMPORTED_MODULE_2__.addActionButton)(_button__WEBPACK_IMPORTED_MODULE_1__.BUTTON_DEFAULT, onClick, node);
  1595. if (!node.isActive) {
  1596. node.element.addClass(_consts__WEBPACK_IMPORTED_MODULE_0__.DISABLED_CLASS);
  1597. updateButton(defaultButton, false);
  1598. }
  1599. }
  1600. function shouldMount(node) {
  1601. return 'seed' in node.parent;
  1602. }
  1603.  
  1604.  
  1605. /***/ }),
  1606.  
  1607. /***/ "./ts/modal/body/nodes/actions/buttons/duplicate/button.ts":
  1608. /*!*****************************************************************!*\
  1609. !*** ./ts/modal/body/nodes/actions/buttons/duplicate/button.ts ***!
  1610. \*****************************************************************/
  1611. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1612.  
  1613. __webpack_require__.r(__webpack_exports__);
  1614. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1615. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  1616. /* harmony export */ });
  1617. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/buttons/duplicate/consts.ts");
  1618. /* harmony import */ var _position_button_alt__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../position/button/alt */ "./ts/modal/body/nodes/actions/buttons/position/button/alt.ts");
  1619. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  1620.  
  1621.  
  1622.  
  1623. const RADIUS = 15;
  1624. const HEIGHT = 25;
  1625. const WIDTH = 10;
  1626. const outline0 = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'path');
  1627. outline0.setAttribute('stroke-linecap', 'round');
  1628. outline0.setAttribute('stroke-width', '8');
  1629. outline0.setAttribute('fill', 'none');
  1630. outline0.setAttribute('d', `M ${WIDTH / 2 + RADIUS} ${-HEIGHT / 2}`
  1631. + `q 0,-${RADIUS} -${RADIUS},-${RADIUS}`
  1632. + `h -${WIDTH}`
  1633. + `q -${RADIUS},0 -${RADIUS},${RADIUS}`
  1634. + `v ${HEIGHT}`
  1635. + `q 0,${RADIUS} ${RADIUS},${RADIUS}`);
  1636. outline0.setAttribute('transform', `translate(-${RADIUS / 2}, -${RADIUS / 2})`);
  1637. const outline1 = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'path');
  1638. outline1.setAttribute('stroke-linecap', 'round');
  1639. outline1.setAttribute('stroke-width', '8');
  1640. outline1.setAttribute('fill', 'none');
  1641. outline1.setAttribute('d', `M ${WIDTH / 2 + RADIUS} ${-HEIGHT / 2}`
  1642. + `q 0,-${RADIUS} -${RADIUS},-${RADIUS}`
  1643. + `h -${WIDTH}`
  1644. + `q -${RADIUS},0 -${RADIUS},${RADIUS}`
  1645. + `v ${HEIGHT}`
  1646. + `q 0,${RADIUS} ${RADIUS},${RADIUS}`
  1647. + `h ${WIDTH}`
  1648. + `q ${RADIUS},0 ${RADIUS},-${RADIUS}`
  1649. + `v -${HEIGHT}`);
  1650. outline1.setAttribute('transform', `translate(${RADIUS / 2}, ${RADIUS / 2})`);
  1651. const g = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'g');
  1652. g.setAttribute('transform', `rotate(10)`);
  1653. g.append(outline0, outline1);
  1654. 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 });
  1655. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (BUTTON);
  1656.  
  1657.  
  1658. /***/ }),
  1659.  
  1660. /***/ "./ts/modal/body/nodes/actions/buttons/duplicate/consts.ts":
  1661. /*!*****************************************************************!*\
  1662. !*** ./ts/modal/body/nodes/actions/buttons/duplicate/consts.ts ***!
  1663. \*****************************************************************/
  1664. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1665.  
  1666. __webpack_require__.r(__webpack_exports__);
  1667. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1668. /* harmony export */ ACTION_ID: () => (/* binding */ ACTION_ID)
  1669. /* harmony export */ });
  1670. const ACTION_ID = 'node-copy';
  1671.  
  1672.  
  1673. /***/ }),
  1674.  
  1675. /***/ "./ts/modal/body/nodes/actions/buttons/duplicate/css.ts":
  1676. /*!**************************************************************!*\
  1677. !*** ./ts/modal/body/nodes/actions/buttons/duplicate/css.ts ***!
  1678. \**************************************************************/
  1679. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1680.  
  1681. __webpack_require__.r(__webpack_exports__);
  1682. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1683. /* harmony export */ "default": () => (/* binding */ generate)
  1684. /* harmony export */ });
  1685. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/buttons/duplicate/consts.ts");
  1686. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../css */ "./ts/modal/body/nodes/actions/buttons/css.ts");
  1687.  
  1688.  
  1689. function generate() {
  1690. (0,_css__WEBPACK_IMPORTED_MODULE_1__.addColourRule)(_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, '--nodeButtonDuplicate');
  1691. }
  1692.  
  1693.  
  1694. /***/ }),
  1695.  
  1696. /***/ "./ts/modal/body/nodes/actions/buttons/duplicate/index.ts":
  1697. /*!****************************************************************!*\
  1698. !*** ./ts/modal/body/nodes/actions/buttons/duplicate/index.ts ***!
  1699. \****************************************************************/
  1700. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1701.  
  1702. __webpack_require__.r(__webpack_exports__);
  1703. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1704. /* harmony export */ mount: () => (/* binding */ mount),
  1705. /* harmony export */ shouldMount: () => (/* binding */ shouldMount)
  1706. /* harmony export */ });
  1707. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/buttons/duplicate/consts.ts");
  1708. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button */ "./ts/modal/body/nodes/actions/buttons/duplicate/button.ts");
  1709. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../consts */ "./ts/modal/body/nodes/actions/buttons/consts.ts");
  1710. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../button */ "./ts/modal/body/nodes/actions/buttons/button.ts");
  1711. /* harmony import */ var _position__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../position */ "./ts/modal/body/nodes/actions/buttons/position/index.ts");
  1712. /* harmony import */ var _history__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../history */ "./ts/modal/body/nodes/actions/history.ts");
  1713. /* harmony import */ var _callbacks__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../callbacks */ "./ts/modal/body/nodes/actions/callbacks/index.ts");
  1714. /* harmony import */ var _overlays__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../overlays */ "./ts/modal/body/nodes/actions/overlays/index.ts");
  1715.  
  1716.  
  1717.  
  1718.  
  1719.  
  1720.  
  1721.  
  1722.  
  1723. function validate(copy, button, node) {
  1724. return Promise.all(_callbacks__WEBPACK_IMPORTED_MODULE_6__["default"].predicate.getSub(copy.getAncestors()))
  1725. .then(() => {
  1726. _history__WEBPACK_IMPORTED_MODULE_5__.register(copy, () => copy.disconnect(), () => copy.attach.bind(copy, copy.getIndex()), false, true);
  1727. copy.element.removeClass(_consts__WEBPACK_IMPORTED_MODULE_2__.TEST_ADD_CLASS);
  1728. _callbacks__WEBPACK_IMPORTED_MODULE_6__["default"].update.triggerSub(copy.getAncestors());
  1729. return copy;
  1730. })
  1731. .catch((reason) => {
  1732. copy.disconnect();
  1733. if (reason) {
  1734. (0,_overlays__WEBPACK_IMPORTED_MODULE_7__.showTooltip)(reason, node, button.querySelector('circle'));
  1735. }
  1736. });
  1737. }
  1738. function getCopy(node) {
  1739. const copy = node.duplicate();
  1740. copy.element.addClass(_consts__WEBPACK_IMPORTED_MODULE_2__.TEST_ADD_CLASS);
  1741. return copy;
  1742. }
  1743. function doAction(node, parent, index, button) {
  1744. const copy = getCopy(node);
  1745. copy.move(parent, index);
  1746. validate(copy, button, node);
  1747. }
  1748. function onClick(node, button, isAlt) {
  1749. if (isAlt) {
  1750. _position__WEBPACK_IMPORTED_MODULE_4__.mount(node, node, node.parent, node.getSiblings(), _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, button, doAction);
  1751. }
  1752. else {
  1753. _position__WEBPACK_IMPORTED_MODULE_4__.reset(node);
  1754. validate(getCopy(node), button, node);
  1755. }
  1756. }
  1757. function mount(node) {
  1758. (0,_button__WEBPACK_IMPORTED_MODULE_3__.addActionButton)(_button__WEBPACK_IMPORTED_MODULE_1__["default"], onClick, node);
  1759. }
  1760. function shouldMount(node) {
  1761. return 'seed' in node.parent;
  1762. }
  1763.  
  1764.  
  1765. /***/ }),
  1766.  
  1767. /***/ "./ts/modal/body/nodes/actions/buttons/move/button.ts":
  1768. /*!************************************************************!*\
  1769. !*** ./ts/modal/body/nodes/actions/buttons/move/button.ts ***!
  1770. \************************************************************/
  1771. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1772.  
  1773. __webpack_require__.r(__webpack_exports__);
  1774. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1775. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  1776. /* harmony export */ });
  1777. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/buttons/move/consts.ts");
  1778. /* harmony import */ var _position_button_alt__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../position/button/alt */ "./ts/modal/body/nodes/actions/buttons/position/button/alt.ts");
  1779. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  1780.  
  1781.  
  1782.  
  1783. const arrowTrunk = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'line');
  1784. arrowTrunk.setAttribute('stroke-linecap', 'round');
  1785. arrowTrunk.setAttribute('stroke-width', '10');
  1786. arrowTrunk.setAttribute('y1', '-30');
  1787. arrowTrunk.setAttribute('y2', '30');
  1788. const arrowBottomLeft = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'line');
  1789. arrowBottomLeft.setAttribute('stroke-linecap', 'round');
  1790. arrowBottomLeft.setAttribute('stroke-width', '10');
  1791. arrowBottomLeft.setAttribute('x2', '-12');
  1792. arrowBottomLeft.setAttribute('y1', '27');
  1793. arrowBottomLeft.setAttribute('y2', '15');
  1794. const arrowBottomRight = arrowBottomLeft.cloneNode(true);
  1795. arrowBottomRight.setAttribute('x2', '12');
  1796. const g = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'g');
  1797. g.append(arrowTrunk, arrowBottomLeft, arrowBottomRight);
  1798. const BUTTON = (0,_position_button_alt__WEBPACK_IMPORTED_MODULE_1__.getPositionedButton)(g, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, 'Move');
  1799. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (BUTTON);
  1800.  
  1801.  
  1802. /***/ }),
  1803.  
  1804. /***/ "./ts/modal/body/nodes/actions/buttons/move/consts.ts":
  1805. /*!************************************************************!*\
  1806. !*** ./ts/modal/body/nodes/actions/buttons/move/consts.ts ***!
  1807. \************************************************************/
  1808. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1809.  
  1810. __webpack_require__.r(__webpack_exports__);
  1811. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1812. /* harmony export */ ACTION_ID: () => (/* binding */ ACTION_ID)
  1813. /* harmony export */ });
  1814. const ACTION_ID = 'node-move';
  1815.  
  1816.  
  1817. /***/ }),
  1818.  
  1819. /***/ "./ts/modal/body/nodes/actions/buttons/move/css.ts":
  1820. /*!*********************************************************!*\
  1821. !*** ./ts/modal/body/nodes/actions/buttons/move/css.ts ***!
  1822. \*********************************************************/
  1823. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1824.  
  1825. __webpack_require__.r(__webpack_exports__);
  1826. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1827. /* harmony export */ "default": () => (/* binding */ generate)
  1828. /* harmony export */ });
  1829. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/buttons/move/consts.ts");
  1830. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../css */ "./ts/modal/body/nodes/actions/buttons/css.ts");
  1831.  
  1832.  
  1833. function generate() {
  1834. (0,_css__WEBPACK_IMPORTED_MODULE_1__.addColourRule)(_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, '--nodeButtonMove');
  1835. }
  1836.  
  1837.  
  1838. /***/ }),
  1839.  
  1840. /***/ "./ts/modal/body/nodes/actions/buttons/move/index.ts":
  1841. /*!***********************************************************!*\
  1842. !*** ./ts/modal/body/nodes/actions/buttons/move/index.ts ***!
  1843. \***********************************************************/
  1844. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1845.  
  1846. __webpack_require__.r(__webpack_exports__);
  1847. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1848. /* harmony export */ mount: () => (/* binding */ mount),
  1849. /* harmony export */ shouldMount: () => (/* binding */ shouldMount)
  1850. /* harmony export */ });
  1851. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/buttons/move/consts.ts");
  1852. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button */ "./ts/modal/body/nodes/actions/buttons/move/button.ts");
  1853. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../consts */ "./ts/modal/body/nodes/actions/buttons/consts.ts");
  1854. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../button */ "./ts/modal/body/nodes/actions/buttons/button.ts");
  1855. /* harmony import */ var _position__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../position */ "./ts/modal/body/nodes/actions/buttons/position/index.ts");
  1856. /* harmony import */ var _history__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../history */ "./ts/modal/body/nodes/actions/history.ts");
  1857. /* harmony import */ var _callbacks__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../callbacks */ "./ts/modal/body/nodes/actions/callbacks/index.ts");
  1858. /* harmony import */ var _overlays__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../overlays */ "./ts/modal/body/nodes/actions/overlays/index.ts");
  1859.  
  1860.  
  1861.  
  1862.  
  1863.  
  1864.  
  1865.  
  1866.  
  1867. function getAncestorBranches(node, copy) {
  1868. if (node.parent === copy.parent) {
  1869. return [node.getAncestors()];
  1870. }
  1871. const oldAncestors = node.getAncestors();
  1872. const newAncestors = copy.getAncestors();
  1873. for (let i = Math.min(oldAncestors.length, newAncestors.length) - 1; i > 1; --i) {
  1874. if (oldAncestors[oldAncestors.length - i] === newAncestors[newAncestors.length - i]) {
  1875. return [oldAncestors.slice(0, -i), newAncestors];
  1876. }
  1877. }
  1878. // Branch is from the root
  1879. return [oldAncestors.slice(0, -1), newAncestors];
  1880. }
  1881. function doAction(node, newParent, index, button) {
  1882. const priorIndex = node.getIndex();
  1883. if (index === priorIndex) {
  1884. return node;
  1885. }
  1886. const copy = node.duplicate();
  1887. node.element.addClass(_consts__WEBPACK_IMPORTED_MODULE_2__.TEST_REMOVE_CLASS);
  1888. copy.element.addClass(_consts__WEBPACK_IMPORTED_MODULE_2__.TEST_ADD_CLASS);
  1889. copy.move(newParent, index);
  1890. const ancestorBranches = getAncestorBranches(node, copy);
  1891. return Promise.all(ancestorBranches.map((branch) => Promise.all(_callbacks__WEBPACK_IMPORTED_MODULE_6__["default"].predicate.getSub(branch))))
  1892. .then(() => {
  1893. _history__WEBPACK_IMPORTED_MODULE_5__.register(copy, copy.move.bind(copy, node.parent, priorIndex), () => copy.move(newParent, index));
  1894. copy.element.removeClass(_consts__WEBPACK_IMPORTED_MODULE_2__.TEST_ADD_CLASS);
  1895. node.disconnect();
  1896. for (const branch of ancestorBranches) {
  1897. _callbacks__WEBPACK_IMPORTED_MODULE_6__["default"].update.triggerSub(branch);
  1898. }
  1899. return copy;
  1900. })
  1901. .catch((reason) => {
  1902. node.element.removeClass(_consts__WEBPACK_IMPORTED_MODULE_2__.TEST_REMOVE_CLASS);
  1903. node.isActive = copy.isActive;
  1904. copy.disconnect();
  1905. if (reason) {
  1906. (0,_overlays__WEBPACK_IMPORTED_MODULE_7__.showTooltip)(reason, node, button.querySelector('circle'));
  1907. }
  1908. });
  1909. }
  1910. function onClick(node, button, isAlt) {
  1911. if (isAlt && _position__WEBPACK_IMPORTED_MODULE_4__.hasDestinations(node)) {
  1912. _position__WEBPACK_IMPORTED_MODULE_4__.mount(node, node, node.parent, node.getSiblings(), _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, button, doAction, false);
  1913. return;
  1914. }
  1915. _position__WEBPACK_IMPORTED_MODULE_4__.reset(node);
  1916. if (isAlt) {
  1917. (0,_overlays__WEBPACK_IMPORTED_MODULE_7__.showTooltip)('No other valid locations found.', node, button.querySelector('circle'));
  1918. }
  1919. const newIndex = node.getIndex() + 2;
  1920. if (newIndex < node.parent.children.length + 1) {
  1921. doAction(node, node.parent, newIndex, button);
  1922. }
  1923. else {
  1924. (0,_overlays__WEBPACK_IMPORTED_MODULE_7__.showTooltip)('Node can not be moved down.', node, button.querySelector('circle'));
  1925. }
  1926. }
  1927. function mount(node) {
  1928. (0,_button__WEBPACK_IMPORTED_MODULE_3__.addActionButton)(_button__WEBPACK_IMPORTED_MODULE_1__["default"], onClick, node);
  1929. }
  1930. function shouldMount(node) {
  1931. return Boolean(node.parent.seed) || ('poolId' in node.parent);
  1932. }
  1933.  
  1934.  
  1935. /***/ }),
  1936.  
  1937. /***/ "./ts/modal/body/nodes/actions/buttons/position/button/alt.ts":
  1938. /*!********************************************************************!*\
  1939. !*** ./ts/modal/body/nodes/actions/buttons/position/button/alt.ts ***!
  1940. \********************************************************************/
  1941. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1942.  
  1943. __webpack_require__.r(__webpack_exports__);
  1944. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1945. /* harmony export */ getPositionedButton: () => (/* binding */ getPositionedButton)
  1946. /* harmony export */ });
  1947. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../consts */ "./ts/modal/body/nodes/actions/buttons/consts.ts");
  1948. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../button */ "./ts/modal/body/nodes/actions/buttons/button.ts");
  1949. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  1950.  
  1951.  
  1952.  
  1953. const G_ALT = (() => {
  1954. const arrowTrunk = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'line');
  1955. arrowTrunk.setAttribute('stroke-linecap', 'round');
  1956. arrowTrunk.setAttribute('stroke-width', '10');
  1957. arrowTrunk.setAttribute('y1', '-30');
  1958. arrowTrunk.setAttribute('y2', '30');
  1959. const arrowBottomLeft = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'line');
  1960. arrowBottomLeft.setAttribute('stroke-linecap', 'round');
  1961. arrowBottomLeft.setAttribute('stroke-width', '10');
  1962. arrowBottomLeft.setAttribute('x2', '-12');
  1963. arrowBottomLeft.setAttribute('y1', '27');
  1964. arrowBottomLeft.setAttribute('y2', '15');
  1965. const arrowBottomRight = arrowBottomLeft.cloneNode(true);
  1966. arrowBottomRight.setAttribute('x2', '12');
  1967. const arrowTopRight = arrowBottomLeft.cloneNode(true);
  1968. arrowTopRight.setAttribute('transform', 'rotate(180)');
  1969. const arrowTopLeft = arrowBottomRight.cloneNode(true);
  1970. arrowTopLeft.setAttribute('transform', 'rotate(180)');
  1971. const g = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'g');
  1972. g.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.ALT_CLASS);
  1973. g.append(arrowTrunk, arrowBottomLeft, arrowBottomRight, arrowTopRight, arrowTopLeft);
  1974. return g;
  1975. })();
  1976. function getPositionedButton(gDefault, actionId, description, transform = {}) {
  1977. const g = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'g');
  1978. const gAlt = G_ALT.cloneNode(true);
  1979. gAlt.setAttribute('transform', Object.entries(transform).map(([key, value]) => `${key}(${value})`).join(' '));
  1980. g.append(gAlt, gDefault);
  1981. return (0,_button__WEBPACK_IMPORTED_MODULE_1__.getNewButton)(g, actionId, description);
  1982. }
  1983.  
  1984.  
  1985. /***/ }),
  1986.  
  1987. /***/ "./ts/modal/body/nodes/actions/buttons/position/button/index.ts":
  1988. /*!**********************************************************************!*\
  1989. !*** ./ts/modal/body/nodes/actions/buttons/position/button/index.ts ***!
  1990. \**********************************************************************/
  1991. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1992.  
  1993. __webpack_require__.r(__webpack_exports__);
  1994. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1995. /* harmony export */ BUTTON_PARENT: () => (/* binding */ BUTTON_PARENT),
  1996. /* harmony export */ BUTTON_SIBLING: () => (/* binding */ BUTTON_SIBLING)
  1997. /* harmony export */ });
  1998. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../consts */ "./ts/modal/body/nodes/actions/buttons/position/consts.ts");
  1999. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../button */ "./ts/modal/body/nodes/actions/buttons/button.ts");
  2000. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  2001.  
  2002.  
  2003.  
  2004. const arrowTrunk = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'line');
  2005. arrowTrunk.setAttribute('stroke-linecap', 'round');
  2006. arrowTrunk.setAttribute('stroke-width', '10');
  2007. arrowTrunk.setAttribute('y1', '-30');
  2008. arrowTrunk.setAttribute('y2', '30');
  2009. const arrowBottomLeft = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'line');
  2010. arrowBottomLeft.setAttribute('stroke-linecap', 'round');
  2011. arrowBottomLeft.setAttribute('stroke-width', '10');
  2012. arrowBottomLeft.setAttribute('x2', '-12');
  2013. arrowBottomLeft.setAttribute('y1', '27');
  2014. arrowBottomLeft.setAttribute('y2', '15');
  2015. const arrowBottomRight = arrowBottomLeft.cloneNode(true);
  2016. arrowBottomRight.setAttribute('x2', '12');
  2017. const gMain = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'g');
  2018. gMain.append(arrowTrunk, arrowBottomLeft, arrowBottomRight);
  2019. const gSibling = gMain.cloneNode(true);
  2020. const BUTTON_SIBLING = (0,_button__WEBPACK_IMPORTED_MODULE_1__.getNewButton)(gSibling, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, 'Select After');
  2021. const gParent = gMain.cloneNode(true);
  2022. gParent.setAttribute('transform', 'rotate(-45)');
  2023. const BUTTON_PARENT = (0,_button__WEBPACK_IMPORTED_MODULE_1__.getNewButton)(gParent, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, 'Select Into');
  2024.  
  2025.  
  2026. /***/ }),
  2027.  
  2028. /***/ "./ts/modal/body/nodes/actions/buttons/position/consts.ts":
  2029. /*!****************************************************************!*\
  2030. !*** ./ts/modal/body/nodes/actions/buttons/position/consts.ts ***!
  2031. \****************************************************************/
  2032. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2033.  
  2034. __webpack_require__.r(__webpack_exports__);
  2035. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2036. /* harmony export */ ACTION_ID: () => (/* binding */ ACTION_ID)
  2037. /* harmony export */ });
  2038. const ACTION_ID = 'node-position';
  2039.  
  2040.  
  2041. /***/ }),
  2042.  
  2043. /***/ "./ts/modal/body/nodes/actions/buttons/position/css.ts":
  2044. /*!*************************************************************!*\
  2045. !*** ./ts/modal/body/nodes/actions/buttons/position/css.ts ***!
  2046. \*************************************************************/
  2047. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2048.  
  2049. __webpack_require__.r(__webpack_exports__);
  2050. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2051. /* harmony export */ "default": () => (/* binding */ generate)
  2052. /* harmony export */ });
  2053. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/buttons/position/consts.ts");
  2054. /* harmony import */ var _focus_consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../focus/consts */ "./ts/modal/body/nodes/actions/focus/consts.ts");
  2055. /* harmony import */ var _nodes_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @nodes/consts */ "./ts/modal/body/nodes/consts.ts");
  2056. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  2057.  
  2058.  
  2059.  
  2060.  
  2061. function generate() {
  2062. (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} `
  2063. + `.${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.ELEMENT_CONTAINER}:not(.${_focus_consts__WEBPACK_IMPORTED_MODULE_1__.FOCUS_CLASS})`, ['display', 'none']);
  2064. }
  2065.  
  2066.  
  2067. /***/ }),
  2068.  
  2069. /***/ "./ts/modal/body/nodes/actions/buttons/position/index.ts":
  2070. /*!***************************************************************!*\
  2071. !*** ./ts/modal/body/nodes/actions/buttons/position/index.ts ***!
  2072. \***************************************************************/
  2073. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2074.  
  2075. __webpack_require__.r(__webpack_exports__);
  2076. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2077. /* harmony export */ getButton: () => (/* binding */ getButton),
  2078. /* harmony export */ hasDestinations: () => (/* binding */ hasDestinations),
  2079. /* harmony export */ isActive: () => (/* binding */ isActive),
  2080. /* harmony export */ mount: () => (/* binding */ mount),
  2081. /* harmony export */ reset: () => (/* binding */ reset)
  2082. /* harmony export */ });
  2083. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/buttons/position/consts.ts");
  2084. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button */ "./ts/modal/body/nodes/actions/buttons/position/button/index.ts");
  2085. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../button */ "./ts/modal/body/nodes/actions/buttons/button.ts");
  2086. /* harmony import */ var _focus__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../focus */ "./ts/modal/body/nodes/actions/focus/index.ts");
  2087. /* harmony import */ var _highlight__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../highlight */ "./ts/modal/body/nodes/actions/highlight/index.ts");
  2088. /* harmony import */ var _scroll__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../scroll */ "./ts/modal/body/nodes/actions/scroll.ts");
  2089. /* harmony import */ var _modal_body__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @/modal/body */ "./ts/modal/body/index.ts");
  2090. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  2091. var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
  2092. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  2093. return new (P || (P = Promise))(function (resolve, reject) {
  2094. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  2095. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  2096. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  2097. step((generator = generator.apply(thisArg, _arguments || [])).next());
  2098. });
  2099. };
  2100.  
  2101.  
  2102.  
  2103.  
  2104.  
  2105.  
  2106.  
  2107.  
  2108. const destinations = [];
  2109. let origin;
  2110. function isActive() {
  2111. return Boolean(origin);
  2112. }
  2113. function setActive(doActivate = true) {
  2114. (0,_modal_body__WEBPACK_IMPORTED_MODULE_6__.setActive)(origin.button, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, doActivate);
  2115. (0,_focus__WEBPACK_IMPORTED_MODULE_3__.reset)();
  2116. (0,_focus__WEBPACK_IMPORTED_MODULE_3__.focus)(doActivate, origin.source, false);
  2117. (0,_focus__WEBPACK_IMPORTED_MODULE_3__.focusBranch)(doActivate, origin.source, doActivate);
  2118. origin.button.setAttribute('tabindex', doActivate ? '0' : '-1');
  2119. }
  2120. function reset(scrollTarget) {
  2121. if (!origin) {
  2122. return;
  2123. }
  2124. for (const { node, isParent, button } of destinations) {
  2125. (0,_focus__WEBPACK_IMPORTED_MODULE_3__.focusBranch)(false, node, isParent);
  2126. button.remove();
  2127. }
  2128. destinations.length = 0;
  2129. (0,_highlight__WEBPACK_IMPORTED_MODULE_4__.removeSustained)(origin.source);
  2130. setActive(false);
  2131. (0,_scroll__WEBPACK_IMPORTED_MODULE_5__.scroll)(scrollTarget !== null && scrollTarget !== void 0 ? scrollTarget : origin.source);
  2132. (0,_highlight__WEBPACK_IMPORTED_MODULE_4__.setActive)(scrollTarget !== null && scrollTarget !== void 0 ? scrollTarget : origin.source, true);
  2133. origin = undefined;
  2134. }
  2135. function getButton(node, actionId, onClick, isParent) {
  2136. 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);
  2137. button.classList.add(actionId);
  2138. button.classList.add(_modal_consts__WEBPACK_IMPORTED_MODULE_7__.BUTTON_ACTIVE_CLASS);
  2139. button.setAttribute('tabindex', '0');
  2140. return button;
  2141. }
  2142. function getBoundCallback(callback, parent, index) {
  2143. return (_, button) => __awaiter(this, void 0, void 0, function* () {
  2144. const target = yield callback(parent, index, button);
  2145. if (target) {
  2146. reset(target);
  2147. }
  2148. });
  2149. }
  2150. function addButtons(parent, actionId, callback, includeSelf) {
  2151. const isCurrentParent = parent === origin.parent;
  2152. if (isCurrentParent || (origin.isPooled && parent.poolId === origin.parent.poolId)) {
  2153. destinations.push({
  2154. node: parent,
  2155. isParent: true,
  2156. button: getButton(parent, actionId, getBoundCallback(callback, parent, 0), true),
  2157. });
  2158. (0,_focus__WEBPACK_IMPORTED_MODULE_3__.focusBranch)(true, parent);
  2159. for (const target of (!includeSelf && isCurrentParent) ? origin.siblings : parent.children) {
  2160. (0,_focus__WEBPACK_IMPORTED_MODULE_3__.focusBranch)(true, target, false);
  2161. destinations.push({
  2162. node: target,
  2163. isParent: false,
  2164. button: getButton(target, actionId, getBoundCallback(callback, target.parent, target.getIndex() + 1), false),
  2165. });
  2166. }
  2167. }
  2168. // Nodes can't be their own descendants
  2169. if (!isCurrentParent) {
  2170. for (const child of parent.children) {
  2171. if ('children' in child) {
  2172. addButtons(child, actionId, callback, includeSelf);
  2173. }
  2174. }
  2175. }
  2176. }
  2177. function hasDestinations(node) {
  2178. if (node.parent.children.length > 1) {
  2179. return true;
  2180. }
  2181. if (!('poolId' in node.parent)) {
  2182. return false;
  2183. }
  2184. const hasMatchingPool = (parent, poolId) => {
  2185. if (parent !== node.parent) {
  2186. if (parent.poolId === poolId) {
  2187. return true;
  2188. }
  2189. for (const child of parent.children) {
  2190. if ('children' in child && hasMatchingPool(child, poolId)) {
  2191. return true;
  2192. }
  2193. }
  2194. }
  2195. return false;
  2196. };
  2197. return hasMatchingPool(node.getRoot(), node.parent.poolId);
  2198. }
  2199. function mount(source, child, parent, siblings, actionId, button, callback, includeSelf = true) {
  2200. reset();
  2201. origin = {
  2202. source,
  2203. child,
  2204. siblings,
  2205. parent,
  2206. isPooled: 'poolId' in parent,
  2207. button,
  2208. actionId,
  2209. };
  2210. setActive();
  2211. addButtons(parent.getRoot(), actionId, callback.bind(null, source), includeSelf);
  2212. (0,_highlight__WEBPACK_IMPORTED_MODULE_4__.addSustained)(source);
  2213. return destinations.length;
  2214. }
  2215.  
  2216.  
  2217. /***/ }),
  2218.  
  2219. /***/ "./ts/modal/body/nodes/actions/callbacks/index.ts":
  2220. /*!********************************************************!*\
  2221. !*** ./ts/modal/body/nodes/actions/callbacks/index.ts ***!
  2222. \********************************************************/
  2223. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2224.  
  2225. __webpack_require__.r(__webpack_exports__);
  2226. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2227. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  2228. /* harmony export */ });
  2229. /* harmony import */ var _update__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./update */ "./ts/modal/body/nodes/actions/callbacks/update.ts");
  2230. /* harmony import */ var _predicate__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./predicate */ "./ts/modal/body/nodes/actions/callbacks/predicate.ts");
  2231.  
  2232.  
  2233. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({ update: _update__WEBPACK_IMPORTED_MODULE_0__, predicate: _predicate__WEBPACK_IMPORTED_MODULE_1__ });
  2234.  
  2235.  
  2236. /***/ }),
  2237.  
  2238. /***/ "./ts/modal/body/nodes/actions/callbacks/predicate.ts":
  2239. /*!************************************************************!*\
  2240. !*** ./ts/modal/body/nodes/actions/callbacks/predicate.ts ***!
  2241. \************************************************************/
  2242. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2243.  
  2244. __webpack_require__.r(__webpack_exports__);
  2245. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2246. /* harmony export */ getAll: () => (/* binding */ getAll),
  2247. /* harmony export */ getSub: () => (/* binding */ getSub)
  2248. /* harmony export */ });
  2249. /* harmony import */ var _predicate__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @/predicate */ "./ts/predicate.ts");
  2250. var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
  2251. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  2252. return new (P || (P = Promise))(function (resolve, reject) {
  2253. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  2254. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  2255. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  2256. step((generator = generator.apply(thisArg, _arguments || [])).next());
  2257. });
  2258. };
  2259.  
  2260. let ongoing;
  2261. function handle(promises) {
  2262. return __awaiter(this, void 0, void 0, function* () {
  2263. ongoing === null || ongoing === void 0 ? void 0 : ongoing(true);
  2264. const callback = new Promise((resolve) => {
  2265. ongoing = resolve;
  2266. });
  2267. const response = Promise.all(promises);
  2268. if (yield Promise.any([
  2269. callback,
  2270. // result of Promise.prototype.finally() gets ignored unless it's a rejection sigh
  2271. response
  2272. .then(() => false)
  2273. .catch(() => false),
  2274. ])) {
  2275. return false;
  2276. }
  2277. return yield response;
  2278. });
  2279. }
  2280. function getSub(ancestors) {
  2281. const responses = [];
  2282. if ('childPredicate' in ancestors[0]) {
  2283. responses.push((0,_predicate__WEBPACK_IMPORTED_MODULE_0__.getPredicatePromise)(ancestors[0].childPredicate()));
  2284. }
  2285. for (const ancestor of ancestors) {
  2286. if ('descendantPredicate' in ancestor) {
  2287. responses.push((0,_predicate__WEBPACK_IMPORTED_MODULE_0__.getPredicatePromise)(ancestor.descendantPredicate()));
  2288. }
  2289. }
  2290. return responses;
  2291. }
  2292. function getAll(node) {
  2293. if (node.forceValid || ('options' in node && node.options.includes(node.value))) {
  2294. return handle(getSub(node.getAncestors()));
  2295. }
  2296. if ('predicate' in node) {
  2297. return handle([(0,_predicate__WEBPACK_IMPORTED_MODULE_0__.getPredicatePromise)(node.predicate()), ...getSub(node.getAncestors())]);
  2298. }
  2299. throw undefined;
  2300. }
  2301.  
  2302.  
  2303. /***/ }),
  2304.  
  2305. /***/ "./ts/modal/body/nodes/actions/callbacks/update.ts":
  2306. /*!*********************************************************!*\
  2307. !*** ./ts/modal/body/nodes/actions/callbacks/update.ts ***!
  2308. \*********************************************************/
  2309. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2310.  
  2311. __webpack_require__.r(__webpack_exports__);
  2312. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2313. /* harmony export */ handle: () => (/* binding */ handle),
  2314. /* harmony export */ triggerAll: () => (/* binding */ triggerAll),
  2315. /* harmony export */ triggerSub: () => (/* binding */ triggerSub)
  2316. /* harmony export */ });
  2317. /* harmony import */ var _hide__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../hide */ "./ts/modal/body/nodes/actions/hide/index.ts");
  2318. var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
  2319. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  2320. return new (P || (P = Promise))(function (resolve, reject) {
  2321. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  2322. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  2323. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  2324. step((generator = generator.apply(thisArg, _arguments || [])).next());
  2325. });
  2326. };
  2327.  
  2328. const maps = {
  2329. onUpdate: new Map(),
  2330. onChildUpdate: new Map(),
  2331. onDescendantUpdate: new Map(),
  2332. };
  2333. function isOutdated(response, map, node) {
  2334. return __awaiter(this, void 0, void 0, function* () {
  2335. if (map.has(node)) {
  2336. map.get(node)(false);
  2337. }
  2338. const callback = new Promise((resolve) => {
  2339. map.set(node, resolve);
  2340. });
  2341. if (yield Promise.any([
  2342. callback,
  2343. Promise.resolve(response)
  2344. .then(() => true)
  2345. .catch(() => true),
  2346. ])) {
  2347. map.delete(node);
  2348. return false;
  2349. }
  2350. return true;
  2351. });
  2352. }
  2353. function handle(_response, property, node) {
  2354. return __awaiter(this, void 0, void 0, function* () {
  2355. if (yield isOutdated(_response, maps[property], node)) {
  2356. return;
  2357. }
  2358. const response = yield _response;
  2359. if (typeof response !== 'object') {
  2360. return;
  2361. }
  2362. if ('hide' in response && typeof response.hide === 'object') {
  2363. for (const [id, doHide] of Object.entries(response.hide)) {
  2364. if (typeof id === 'string' && typeof doHide === 'boolean') {
  2365. (0,_hide__WEBPACK_IMPORTED_MODULE_0__["default"])(node, id, doHide);
  2366. }
  2367. }
  2368. }
  2369. });
  2370. }
  2371. function trigger(node, property) {
  2372. if (property in node) {
  2373. handle(node[property](), property, node);
  2374. }
  2375. }
  2376. function triggerSub(ancestors) {
  2377. trigger(ancestors[0], 'onChildUpdate');
  2378. for (const ancestor of ancestors) {
  2379. trigger(ancestor, 'onDescendantUpdate');
  2380. }
  2381. }
  2382. function triggerAll(node) {
  2383. trigger(node, 'onUpdate');
  2384. triggerSub(node.getAncestors());
  2385. }
  2386.  
  2387.  
  2388. /***/ }),
  2389.  
  2390. /***/ "./ts/modal/body/nodes/actions/css.ts":
  2391. /*!********************************************!*\
  2392. !*** ./ts/modal/body/nodes/actions/css.ts ***!
  2393. \********************************************/
  2394. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2395.  
  2396. __webpack_require__.r(__webpack_exports__);
  2397. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2398. /* harmony export */ "default": () => (/* binding */ generate)
  2399. /* harmony export */ });
  2400. /* harmony import */ var _edit_css__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./edit/css */ "./ts/modal/body/nodes/actions/edit/css.ts");
  2401. /* harmony import */ var _highlight_css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./highlight/css */ "./ts/modal/body/nodes/actions/highlight/css.ts");
  2402. /* harmony import */ var _focus_css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./focus/css */ "./ts/modal/body/nodes/actions/focus/css.ts");
  2403. /* harmony import */ var _overlays_css__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./overlays/css */ "./ts/modal/body/nodes/actions/overlays/css.ts");
  2404. /* harmony import */ var _buttons_css__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./buttons/css */ "./ts/modal/body/nodes/actions/buttons/css.ts");
  2405.  
  2406.  
  2407.  
  2408.  
  2409.  
  2410. function generate() {
  2411. (0,_edit_css__WEBPACK_IMPORTED_MODULE_0__["default"])();
  2412. (0,_highlight_css__WEBPACK_IMPORTED_MODULE_1__["default"])();
  2413. (0,_focus_css__WEBPACK_IMPORTED_MODULE_2__["default"])();
  2414. (0,_overlays_css__WEBPACK_IMPORTED_MODULE_3__["default"])();
  2415. (0,_buttons_css__WEBPACK_IMPORTED_MODULE_4__["default"])();
  2416. }
  2417.  
  2418.  
  2419. /***/ }),
  2420.  
  2421. /***/ "./ts/modal/body/nodes/actions/edit/consts.ts":
  2422. /*!****************************************************!*\
  2423. !*** ./ts/modal/body/nodes/actions/edit/consts.ts ***!
  2424. \****************************************************/
  2425. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2426.  
  2427. __webpack_require__.r(__webpack_exports__);
  2428. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2429. /* harmony export */ ACTIVE_CLASS: () => (/* binding */ ACTIVE_CLASS),
  2430. /* harmony export */ INVALID_BACKGROUND_CLASS: () => (/* binding */ INVALID_BACKGROUND_CLASS),
  2431. /* harmony export */ INVALID_CLASS: () => (/* binding */ INVALID_CLASS),
  2432. /* harmony export */ VALID_BACKGROUND_CLASS: () => (/* binding */ VALID_BACKGROUND_CLASS),
  2433. /* harmony export */ VALID_CLASS: () => (/* binding */ VALID_CLASS)
  2434. /* harmony export */ });
  2435. const ACTIVE_CLASS = 'edit-active';
  2436. const VALID_CLASS = 'edit-valid';
  2437. const INVALID_CLASS = 'edit-invalid';
  2438. const VALID_BACKGROUND_CLASS = 'background-valid';
  2439. const INVALID_BACKGROUND_CLASS = 'background-invalid';
  2440.  
  2441.  
  2442. /***/ }),
  2443.  
  2444. /***/ "./ts/modal/body/nodes/actions/edit/css.ts":
  2445. /*!*************************************************!*\
  2446. !*** ./ts/modal/body/nodes/actions/edit/css.ts ***!
  2447. \*************************************************/
  2448. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2449.  
  2450. __webpack_require__.r(__webpack_exports__);
  2451. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2452. /* harmony export */ "default": () => (/* binding */ generate)
  2453. /* harmony export */ });
  2454. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/edit/consts.ts");
  2455. /* harmony import */ var _nodes_consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @nodes/consts */ "./ts/modal/body/nodes/consts.ts");
  2456. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  2457.  
  2458.  
  2459.  
  2460. function generate() {
  2461. // Use pointer when the node has a value and isn't being edited
  2462. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.EDITABLE_CLASS} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ELEMENT_CLASSES.HEAD_CONTAINER}`, ['cursor', 'pointer']);
  2463. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`:not(.${_consts__WEBPACK_IMPORTED_MODULE_0__.ACTIVE_CLASS}) > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ELEMENT_CLASSES.HEAD_CONTAINER} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ELEMENT_CLASSES.INFO_CONTAINER}`, ['pointer-events', 'none']);
  2464. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ELEMENT_CLASSES.VALUE}`, [
  2465. ['flex-grow', '1'],
  2466. ['outline', 'none'],
  2467. ['min-width', '0'],
  2468. ]);
  2469. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ELEMENT_CLASSES.VALUE}[type="checkbox"]`, [
  2470. ['min-height', '1em'],
  2471. ['min-width', '1em'],
  2472. ]);
  2473. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ELEMENT_CLASSES.VALUE}[type="color"]`, [
  2474. ['height', '1.3em'],
  2475. ['cursor', 'pointer'],
  2476. ]);
  2477. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.VALID_BACKGROUND_CLASS}`, ['background-color', 'var(--validBackground)']);
  2478. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.INVALID_BACKGROUND_CLASS}`, ['background-color', 'var(--invalidBackground)']);
  2479. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([`.${_consts__WEBPACK_IMPORTED_MODULE_0__.VALID_BACKGROUND_CLASS}`, `.${_consts__WEBPACK_IMPORTED_MODULE_0__.INVALID_BACKGROUND_CLASS}`], [
  2480. ['transition-property', 'width, padding-left'],
  2481. ['transition-duration', '500ms'],
  2482. ['right', '0'],
  2483. ['width', '0'],
  2484. ['padding-left', '0'],
  2485. ]);
  2486. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([
  2487. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.VALID_CLASS} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ELEMENT_CLASSES.HEAD_CONTAINER} .${_consts__WEBPACK_IMPORTED_MODULE_0__.VALID_BACKGROUND_CLASS}`,
  2488. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.INVALID_CLASS} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ELEMENT_CLASSES.HEAD_CONTAINER} .${_consts__WEBPACK_IMPORTED_MODULE_0__.INVALID_BACKGROUND_CLASS}`,
  2489. ], ['width', '100%']);
  2490. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([
  2491. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.VALID_CLASS} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ELEMENT_CLASSES.HEAD_CONTAINER} .${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ELEMENT_CLASSES.BUTTON_CONTAINER}:not(:empty) + * .${_consts__WEBPACK_IMPORTED_MODULE_0__.VALID_BACKGROUND_CLASS}`,
  2492. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.INVALID_CLASS} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ELEMENT_CLASSES.HEAD_CONTAINER} .${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ELEMENT_CLASSES.BUTTON_CONTAINER}:not(:empty) + * .${_consts__WEBPACK_IMPORTED_MODULE_0__.INVALID_BACKGROUND_CLASS}`,
  2493. ], ['padding-left', '0.8em']);
  2494. }
  2495.  
  2496.  
  2497. /***/ }),
  2498.  
  2499. /***/ "./ts/modal/body/nodes/actions/edit/index.ts":
  2500. /*!***************************************************!*\
  2501. !*** ./ts/modal/body/nodes/actions/edit/index.ts ***!
  2502. \***************************************************/
  2503. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2504.  
  2505. __webpack_require__.r(__webpack_exports__);
  2506. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2507. /* harmony export */ doAction: () => (/* binding */ doAction),
  2508. /* harmony export */ isActive: () => (/* binding */ isActive),
  2509. /* harmony export */ mount: () => (/* binding */ mount),
  2510. /* harmony export */ reset: () => (/* binding */ reset),
  2511. /* harmony export */ shouldMount: () => (/* binding */ shouldMount),
  2512. /* harmony export */ unmount: () => (/* binding */ unmount),
  2513. /* harmony export */ update: () => (/* binding */ update)
  2514. /* harmony export */ });
  2515. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/edit/consts.ts");
  2516. /* harmony import */ var _history__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../history */ "./ts/modal/body/nodes/actions/history.ts");
  2517. /* harmony import */ var _overlays__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../overlays */ "./ts/modal/body/nodes/actions/overlays/index.ts");
  2518. /* harmony import */ var _highlight__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../highlight */ "./ts/modal/body/nodes/actions/highlight/index.ts");
  2519. /* harmony import */ var _callbacks__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../callbacks */ "./ts/modal/body/nodes/actions/callbacks/index.ts");
  2520. /* harmony import */ var _overlays_tooltip_consts__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../overlays/tooltip/consts */ "./ts/modal/body/nodes/actions/overlays/tooltip/consts.ts");
  2521. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../consts */ "./ts/modal/body/nodes/consts.ts");
  2522. /* harmony import */ var _predicate__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @/predicate */ "./ts/predicate.ts");
  2523. var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
  2524. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  2525. return new (P || (P = Promise))(function (resolve, reject) {
  2526. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  2527. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  2528. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  2529. step((generator = generator.apply(thisArg, _arguments || [])).next());
  2530. });
  2531. };
  2532.  
  2533.  
  2534.  
  2535.  
  2536.  
  2537.  
  2538.  
  2539.  
  2540. let activeNode;
  2541. let priorValue;
  2542. function isActive() {
  2543. return Boolean(activeNode);
  2544. }
  2545. function addInputListeners(node = activeNode) {
  2546. const { headContainer, contrast: { valueElement } } = node.element;
  2547. if ('listeners' in node) {
  2548. for (const [event, callback] of Object.entries(node.listeners)) {
  2549. valueElement.addEventListener(event, callback);
  2550. }
  2551. }
  2552. if (typeof node.value === 'boolean') {
  2553. valueElement.addEventListener('click', (event) => {
  2554. event.stopPropagation();
  2555. update();
  2556. });
  2557. }
  2558. else {
  2559. valueElement.addEventListener('input', (event) => {
  2560. event.stopPropagation();
  2561. update();
  2562. });
  2563. }
  2564. valueElement.addEventListener('focusin', (event) => {
  2565. event.stopPropagation();
  2566. if (event.relatedTarget) {
  2567. doAction(node);
  2568. }
  2569. });
  2570. valueElement.addEventListener('blur', (event) => {
  2571. event.stopPropagation();
  2572. if ((0,_predicate__WEBPACK_IMPORTED_MODULE_7__.isUnresolved)()) {
  2573. valueElement.focus();
  2574. return;
  2575. }
  2576. reset();
  2577. });
  2578. valueElement.addEventListener('keydown', (event) => {
  2579. switch (event.key) {
  2580. // see socket keydown listener in history
  2581. case 'z':
  2582. case 'Z':
  2583. case 'y':
  2584. case 'Y':
  2585. if (event.ctrlKey && !event.shiftKey) {
  2586. event.stopPropagation();
  2587. }
  2588. return;
  2589. case 'Enter':
  2590. case 'Escape':
  2591. if ((0,_predicate__WEBPACK_IMPORTED_MODULE_7__.isUnresolved)()) {
  2592. event.preventDefault();
  2593. }
  2594. else {
  2595. headContainer.focus();
  2596. }
  2597. // eslint-disable-next-line no-fallthrough
  2598. case 'Undo':
  2599. case 'Redo':
  2600. // see socket keydown listener in highlight
  2601. // eslint-disable-next-line no-fallthrough
  2602. case 'Home':
  2603. case 'End':
  2604. case 'Backspace':
  2605. event.stopPropagation();
  2606. }
  2607. });
  2608. }
  2609. function clearUndoStack() {
  2610. const elements = activeNode.element.contrast;
  2611. const copy = elements.valueElement.cloneNode(true);
  2612. elements.valueElement.replaceWith(copy);
  2613. elements.valueElement = copy;
  2614. addInputListeners();
  2615. }
  2616. function setValue(node, value) {
  2617. node.value = value;
  2618. node.element.render(value);
  2619. }
  2620. function reset() {
  2621. if (!activeNode) {
  2622. return;
  2623. }
  2624. const { element } = activeNode;
  2625. clearUndoStack();
  2626. if (priorValue === activeNode.lastAcceptedValue) {
  2627. setValue(activeNode, activeNode.lastAcceptedValue);
  2628. }
  2629. else {
  2630. _history__WEBPACK_IMPORTED_MODULE_1__.register(activeNode, setValue.bind(null, activeNode, priorValue), setValue.bind(null, activeNode, activeNode.lastAcceptedValue));
  2631. }
  2632. element.removeClass(_consts__WEBPACK_IMPORTED_MODULE_0__.VALID_CLASS);
  2633. element.removeClass(_consts__WEBPACK_IMPORTED_MODULE_0__.INVALID_CLASS);
  2634. element.removeClass(_consts__WEBPACK_IMPORTED_MODULE_0__.ACTIVE_CLASS);
  2635. _overlays__WEBPACK_IMPORTED_MODULE_2__.reset();
  2636. (0,_highlight__WEBPACK_IMPORTED_MODULE_3__.removeSustained)(activeNode);
  2637. activeNode = undefined;
  2638. priorValue = undefined;
  2639. }
  2640. function getValue(node) {
  2641. switch (typeof node.value) {
  2642. case 'boolean':
  2643. return Boolean(node.element.contrast.valueElement.checked);
  2644. case 'number':
  2645. return Number(node.element.contrast.valueElement.value);
  2646. default:
  2647. return node.element.contrast.valueElement.value;
  2648. }
  2649. }
  2650. function update() {
  2651. return __awaiter(this, void 0, void 0, function* () {
  2652. const value = getValue(activeNode);
  2653. activeNode.value = value;
  2654. activeNode.element.removeClass(_consts__WEBPACK_IMPORTED_MODULE_0__.INVALID_CLASS);
  2655. activeNode.element.removeClass(_consts__WEBPACK_IMPORTED_MODULE_0__.VALID_CLASS);
  2656. _overlays__WEBPACK_IMPORTED_MODULE_2__.update();
  2657. try {
  2658. if (!(yield _callbacks__WEBPACK_IMPORTED_MODULE_4__["default"].predicate.getAll(activeNode))) {
  2659. return;
  2660. }
  2661. }
  2662. catch (reason) {
  2663. activeNode.element.addClass(_consts__WEBPACK_IMPORTED_MODULE_0__.INVALID_CLASS);
  2664. if (reason) {
  2665. _overlays__WEBPACK_IMPORTED_MODULE_2__.tooltip.kill();
  2666. _overlays__WEBPACK_IMPORTED_MODULE_2__.showTooltip(reason, activeNode);
  2667. }
  2668. return;
  2669. }
  2670. activeNode.lastAcceptedValue = value;
  2671. activeNode.element.addClass(_consts__WEBPACK_IMPORTED_MODULE_0__.VALID_CLASS);
  2672. _overlays__WEBPACK_IMPORTED_MODULE_2__.hideTooltip();
  2673. _callbacks__WEBPACK_IMPORTED_MODULE_4__["default"].update.triggerAll(activeNode);
  2674. });
  2675. }
  2676. function unmount(node) {
  2677. if (node === activeNode) {
  2678. reset();
  2679. }
  2680. }
  2681. function doAction(node) {
  2682. if ((0,_predicate__WEBPACK_IMPORTED_MODULE_7__.isUnresolved)()) {
  2683. _overlays__WEBPACK_IMPORTED_MODULE_2__.showTooltip(_overlays_tooltip_consts__WEBPACK_IMPORTED_MODULE_5__.MESSAGE_UNRESOLVED, node, node.element.contrast.valueContainer);
  2684. node.element.headContainer.focus();
  2685. return;
  2686. }
  2687. reset();
  2688. _overlays__WEBPACK_IMPORTED_MODULE_2__.tooltip.kill();
  2689. activeNode = node;
  2690. priorValue = node.value;
  2691. node.element.addClass(_consts__WEBPACK_IMPORTED_MODULE_0__.ACTIVE_CLASS);
  2692. node.element.addClass(_consts__WEBPACK_IMPORTED_MODULE_0__.VALID_CLASS);
  2693. _overlays__WEBPACK_IMPORTED_MODULE_2__.setNode(node);
  2694. if (node.input === 'color') {
  2695. node.element.contrast.valueElement.click();
  2696. }
  2697. else if (typeof node.value !== 'boolean') {
  2698. const input = node.element.contrast.valueElement;
  2699. input.select();
  2700. input.scrollLeft = input.scrollWidth;
  2701. }
  2702. (0,_highlight__WEBPACK_IMPORTED_MODULE_3__.addSustained)(node);
  2703. }
  2704. function mount(node) {
  2705. const { backgroundContainer, contrast, headContainer } = node.element;
  2706. node.lastAcceptedValue = node.value;
  2707. node.element.addClass(_consts__WEBPACK_IMPORTED_MODULE_6__.EDITABLE_CLASS);
  2708. backgroundContainer.append(...(() => {
  2709. const valid = document.createElement('div');
  2710. const invalid = document.createElement('div');
  2711. valid.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.VALID_BACKGROUND_CLASS);
  2712. invalid.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.INVALID_BACKGROUND_CLASS);
  2713. return [valid, invalid];
  2714. })());
  2715. // Start
  2716. headContainer.addEventListener('click', (event) => {
  2717. event.stopPropagation();
  2718. contrast.valueElement.focus();
  2719. });
  2720. // Process new value
  2721. if (typeof node.value === 'boolean') {
  2722. headContainer.addEventListener('mousedown', (event) => {
  2723. event.stopPropagation();
  2724. event.preventDefault();
  2725. });
  2726. headContainer.addEventListener('click', () => {
  2727. contrast.valueElement.checked = !contrast.valueElement.checked;
  2728. update();
  2729. });
  2730. contrast.valueContainer.addEventListener('click', (event) => {
  2731. event.stopPropagation();
  2732. });
  2733. }
  2734. addInputListeners(node);
  2735. }
  2736. function shouldMount(node) {
  2737. return 'value' in node;
  2738. }
  2739.  
  2740.  
  2741. /***/ }),
  2742.  
  2743. /***/ "./ts/modal/body/nodes/actions/focus/consts.ts":
  2744. /*!*****************************************************!*\
  2745. !*** ./ts/modal/body/nodes/actions/focus/consts.ts ***!
  2746. \*****************************************************/
  2747. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2748.  
  2749. __webpack_require__.r(__webpack_exports__);
  2750. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2751. /* harmony export */ BACKGROUND_CLASS: () => (/* binding */ BACKGROUND_CLASS),
  2752. /* harmony export */ FOCUS_CLASS: () => (/* binding */ FOCUS_CLASS),
  2753. /* harmony export */ FOCUS_SOURCE_CLASS: () => (/* binding */ FOCUS_SOURCE_CLASS)
  2754. /* harmony export */ });
  2755. const FOCUS_CLASS = 'node-focus';
  2756. const FOCUS_SOURCE_CLASS = 'node-focus-source';
  2757. const BACKGROUND_CLASS = 'background-focus';
  2758.  
  2759.  
  2760. /***/ }),
  2761.  
  2762. /***/ "./ts/modal/body/nodes/actions/focus/css.ts":
  2763. /*!**************************************************!*\
  2764. !*** ./ts/modal/body/nodes/actions/focus/css.ts ***!
  2765. \**************************************************/
  2766. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2767.  
  2768. __webpack_require__.r(__webpack_exports__);
  2769. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2770. /* harmony export */ "default": () => (/* binding */ generate)
  2771. /* harmony export */ });
  2772. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/focus/consts.ts");
  2773. /* harmony import */ var _nodes_consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @nodes/consts */ "./ts/modal/body/nodes/consts.ts");
  2774. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  2775.  
  2776.  
  2777.  
  2778. function generate() {
  2779. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ELEMENT_CLASSES.ELEMENT_CONTAINER}`, ['cursor', 'zoom-in']);
  2780. (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']);
  2781. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ROOT_CLASS}.${_consts__WEBPACK_IMPORTED_MODULE_0__.FOCUS_CLASS} .${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ELEMENT_CLASSES.ELEMENT_CONTAINER}:not(.${_consts__WEBPACK_IMPORTED_MODULE_0__.FOCUS_CLASS}):not(.${_consts__WEBPACK_IMPORTED_MODULE_0__.FOCUS_SOURCE_CLASS} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ELEMENT_CLASSES.CHILD_CONTAINER} > *)`, ['display', 'none']);
  2782. // Makes it easy to focus down the tree
  2783. (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']]);
  2784. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.BACKGROUND_CLASS}`, ['background-color', 'var(--focusBackground)']);
  2785. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.BACKGROUND_CLASS}`, [
  2786. ['transition-property', 'width, padding-left'],
  2787. ['transition-duration', '500ms'],
  2788. ['right', '0'],
  2789. ['width', '0'],
  2790. ['padding-left', '0'],
  2791. ]);
  2792. const headSelector = `.${_consts__WEBPACK_IMPORTED_MODULE_0__.FOCUS_SOURCE_CLASS}:not(:hover:not(:has(> .${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ELEMENT_CLASSES.CHILD_CONTAINER}:hover))) > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ELEMENT_CLASSES.HEAD_CONTAINER}:not(:focus):not(:hover)`;
  2793. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`${headSelector} .${_consts__WEBPACK_IMPORTED_MODULE_0__.BACKGROUND_CLASS}`, ['width', '100%']);
  2794. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`${headSelector} .${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ELEMENT_CLASSES.BUTTON_CONTAINER}:not(:empty) + * .${_consts__WEBPACK_IMPORTED_MODULE_0__.BACKGROUND_CLASS}`, ['padding-left', '0.8em']);
  2795. }
  2796.  
  2797.  
  2798. /***/ }),
  2799.  
  2800. /***/ "./ts/modal/body/nodes/actions/focus/index.ts":
  2801. /*!****************************************************!*\
  2802. !*** ./ts/modal/body/nodes/actions/focus/index.ts ***!
  2803. \****************************************************/
  2804. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2805.  
  2806. __webpack_require__.r(__webpack_exports__);
  2807. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2808. /* harmony export */ doAction: () => (/* binding */ doAction),
  2809. /* harmony export */ focus: () => (/* binding */ focus),
  2810. /* harmony export */ focusBranch: () => (/* binding */ focusBranch),
  2811. /* harmony export */ isActive: () => (/* binding */ isActive),
  2812. /* harmony export */ mount: () => (/* binding */ mount),
  2813. /* harmony export */ reset: () => (/* binding */ reset),
  2814. /* harmony export */ setTabIndexes: () => (/* binding */ setTabIndexes),
  2815. /* harmony export */ shouldMount: () => (/* binding */ shouldMount),
  2816. /* harmony export */ unmount: () => (/* binding */ unmount)
  2817. /* harmony export */ });
  2818. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/focus/consts.ts");
  2819. /* harmony import */ var _overlays_tooltip__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../overlays/tooltip */ "./ts/modal/body/nodes/actions/overlays/tooltip/index.ts");
  2820. /* harmony import */ var _buttons_position__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../buttons/position */ "./ts/modal/body/nodes/actions/buttons/position/index.ts");
  2821. /* harmony import */ var _highlight__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../highlight */ "./ts/modal/body/nodes/actions/highlight/index.ts");
  2822. /* harmony import */ var _scroll__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../scroll */ "./ts/modal/body/nodes/actions/scroll.ts");
  2823.  
  2824.  
  2825.  
  2826.  
  2827.  
  2828. let candidateNode;
  2829. let activeNode;
  2830. function isActive() {
  2831. return Boolean(activeNode);
  2832. }
  2833. function setTabIndexes(doAdd = true, node = activeNode) {
  2834. const { 'buttonContainer': { 'children': buttons }, contrast: { valueElement } } = node.element;
  2835. for (let i = buttons.length - 1; i >= 0; --i) {
  2836. buttons[i].setAttribute('tabindex', doAdd ? '0' : '-1');
  2837. }
  2838. if (valueElement) {
  2839. valueElement.setAttribute('tabindex', doAdd ? '0' : '-1');
  2840. }
  2841. }
  2842. function focus(doFocus = true, node = activeNode, doForce = true) {
  2843. // Avoid unfocusing the active node if not forced
  2844. if (doForce || node !== activeNode) {
  2845. node.element[`${doFocus ? 'add' : 'remove'}Class`](_consts__WEBPACK_IMPORTED_MODULE_0__.FOCUS_SOURCE_CLASS);
  2846. }
  2847. if (!('children' in node)) {
  2848. return;
  2849. }
  2850. }
  2851. function focusBranch(doFocus = true, node = activeNode, focusAncestors = true) {
  2852. node.element[`${doFocus ? 'add' : 'remove'}Class`](_consts__WEBPACK_IMPORTED_MODULE_0__.FOCUS_CLASS);
  2853. if (focusAncestors && 'parent' in node) {
  2854. focusBranch(doFocus, node.parent);
  2855. }
  2856. }
  2857. function reset(doScroll = true) {
  2858. if (!activeNode) {
  2859. return;
  2860. }
  2861. focus(false);
  2862. focusBranch(false);
  2863. (0,_highlight__WEBPACK_IMPORTED_MODULE_3__.removeSustained)(activeNode);
  2864. setTabIndexes(false);
  2865. if (doScroll) {
  2866. (0,_scroll__WEBPACK_IMPORTED_MODULE_4__.stickyScroll)(activeNode);
  2867. }
  2868. activeNode = undefined;
  2869. }
  2870. function doAction(node, doForce = false) {
  2871. const toggleOn = node !== activeNode;
  2872. (0,_overlays_tooltip__WEBPACK_IMPORTED_MODULE_1__.kill)();
  2873. if ((0,_buttons_position__WEBPACK_IMPORTED_MODULE_2__.isActive)() || (doForce && !toggleOn)) {
  2874. return;
  2875. }
  2876. reset(!toggleOn);
  2877. if (toggleOn) {
  2878. activeNode = node;
  2879. node.element.headContainer.focus();
  2880. focus();
  2881. focusBranch();
  2882. node.element.scrollIntoView(false);
  2883. (0,_highlight__WEBPACK_IMPORTED_MODULE_3__.addSustained)(node);
  2884. setTabIndexes();
  2885. }
  2886. }
  2887. function unmount(node) {
  2888. if (node === activeNode) {
  2889. reset();
  2890. }
  2891. }
  2892. function mount(node) {
  2893. const { elementContainer, headContainer, backgroundContainer } = node.element;
  2894. backgroundContainer.append((() => {
  2895. const background = document.createElement('div');
  2896. background.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.BACKGROUND_CLASS);
  2897. return background;
  2898. })());
  2899. // Handle keyboard input
  2900. elementContainer.addEventListener('keydown', (event) => {
  2901. if (event.key === 'Enter') {
  2902. event.stopPropagation();
  2903. doAction(node);
  2904. }
  2905. });
  2906. // Handle side click
  2907. elementContainer.addEventListener('mousedown', (event) => {
  2908. event.stopPropagation();
  2909. candidateNode = node;
  2910. });
  2911. elementContainer.addEventListener('mouseup', (event) => {
  2912. event.stopPropagation();
  2913. if (node === candidateNode) {
  2914. doAction(node);
  2915. }
  2916. candidateNode = undefined;
  2917. });
  2918. if ('value' in node) {
  2919. headContainer.addEventListener('mousedown', (event) => {
  2920. event.stopPropagation();
  2921. candidateNode = undefined;
  2922. });
  2923. headContainer.addEventListener('mouseup', (event) => {
  2924. event.stopPropagation();
  2925. candidateNode = undefined;
  2926. });
  2927. return;
  2928. }
  2929. // Handle head click
  2930. headContainer.addEventListener('mousedown', (event) => {
  2931. event.stopPropagation();
  2932. candidateNode = node;
  2933. });
  2934. headContainer.addEventListener('mouseup', (event) => {
  2935. event.stopPropagation();
  2936. if (node === candidateNode && headContainer.isSameNode(event.target)) {
  2937. doAction(node);
  2938. }
  2939. candidateNode = undefined;
  2940. });
  2941. }
  2942. function shouldMount() {
  2943. return true;
  2944. }
  2945.  
  2946.  
  2947. /***/ }),
  2948.  
  2949. /***/ "./ts/modal/body/nodes/actions/hide/consts.ts":
  2950. /*!****************************************************!*\
  2951. !*** ./ts/modal/body/nodes/actions/hide/consts.ts ***!
  2952. \****************************************************/
  2953. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2954.  
  2955. __webpack_require__.r(__webpack_exports__);
  2956. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2957. /* harmony export */ CLASS_PREFIX_READ: () => (/* binding */ CLASS_PREFIX_READ),
  2958. /* harmony export */ CLASS_PREFIX_WRITE: () => (/* binding */ CLASS_PREFIX_WRITE)
  2959. /* harmony export */ });
  2960. const CLASS_PREFIX_WRITE = 'node-hide-write-';
  2961. const CLASS_PREFIX_READ = 'node-hide-read-';
  2962.  
  2963.  
  2964. /***/ }),
  2965.  
  2966. /***/ "./ts/modal/body/nodes/actions/hide/index.ts":
  2967. /*!***************************************************!*\
  2968. !*** ./ts/modal/body/nodes/actions/hide/index.ts ***!
  2969. \***************************************************/
  2970. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2971.  
  2972. __webpack_require__.r(__webpack_exports__);
  2973. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2974. /* harmony export */ "default": () => (/* binding */ hide),
  2975. /* harmony export */ mount: () => (/* binding */ mount),
  2976. /* harmony export */ shouldMount: () => (/* binding */ shouldMount)
  2977. /* harmony export */ });
  2978. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/hide/consts.ts");
  2979. /* harmony import */ var _nodes_consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @nodes/consts */ "./ts/modal/body/nodes/consts.ts");
  2980. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  2981.  
  2982.  
  2983.  
  2984. const ids = new Set();
  2985. function hide(node, id, doHide = true) {
  2986. node.getRoot().element[`${doHide ? 'add' : 'remove'}Class`](`${_consts__WEBPACK_IMPORTED_MODULE_0__.CLASS_PREFIX_WRITE}${id}`);
  2987. }
  2988. function mount(node) {
  2989. node.element.addClass(`${_consts__WEBPACK_IMPORTED_MODULE_0__.CLASS_PREFIX_READ}${node.hideId}`);
  2990. if (!ids.has(node.hideId)) {
  2991. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ROOT_CLASS}.${_consts__WEBPACK_IMPORTED_MODULE_0__.CLASS_PREFIX_WRITE}${node.hideId} .${_consts__WEBPACK_IMPORTED_MODULE_0__.CLASS_PREFIX_READ}${node.hideId}`, ['display', 'none']);
  2992. }
  2993. }
  2994. function shouldMount(node) {
  2995. return 'hideId' in node;
  2996. }
  2997.  
  2998.  
  2999. /***/ }),
  3000.  
  3001. /***/ "./ts/modal/body/nodes/actions/highlight/consts.ts":
  3002. /*!*********************************************************!*\
  3003. !*** ./ts/modal/body/nodes/actions/highlight/consts.ts ***!
  3004. \*********************************************************/
  3005. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  3006.  
  3007. __webpack_require__.r(__webpack_exports__);
  3008. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  3009. /* harmony export */ EAVE_ID: () => (/* binding */ EAVE_ID),
  3010. /* harmony export */ HIGHLIGHT_BACKGROUND_CLASS: () => (/* binding */ HIGHLIGHT_BACKGROUND_CLASS),
  3011. /* harmony export */ HIGHLIGHT_CLASS: () => (/* binding */ HIGHLIGHT_CLASS)
  3012. /* harmony export */ });
  3013. const HIGHLIGHT_CLASS = 'highlight';
  3014. const HIGHLIGHT_BACKGROUND_CLASS = 'background-highlight';
  3015. const EAVE_ID = 'tree-eave';
  3016.  
  3017.  
  3018. /***/ }),
  3019.  
  3020. /***/ "./ts/modal/body/nodes/actions/highlight/css.ts":
  3021. /*!******************************************************!*\
  3022. !*** ./ts/modal/body/nodes/actions/highlight/css.ts ***!
  3023. \******************************************************/
  3024. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  3025.  
  3026. __webpack_require__.r(__webpack_exports__);
  3027. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  3028. /* harmony export */ "default": () => (/* binding */ generate)
  3029. /* harmony export */ });
  3030. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/highlight/consts.ts");
  3031. /* harmony import */ var _buttons_consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../buttons/consts */ "./ts/modal/body/nodes/actions/buttons/consts.ts");
  3032. /* harmony import */ var _nodes_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @nodes/consts */ "./ts/modal/body/nodes/consts.ts");
  3033. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  3034.  
  3035.  
  3036.  
  3037.  
  3038. function generate() {
  3039. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`.${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.LABEL_CONTAINER}`, [
  3040. ['padding-right', '0.4em'],
  3041. // Extend the background further into the value
  3042. ['padding-left', '4em'],
  3043. ]);
  3044. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`.${_buttons_consts__WEBPACK_IMPORTED_MODULE_1__.BUTTON_CLASS}:last-child`, [
  3045. ['border-top-right-radius', '0.8em'],
  3046. ['border-bottom-right-radius', '0.8em'],
  3047. ]);
  3048. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)([`.${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.BASE_CLASS}`], [
  3049. ['transition-property', 'width'],
  3050. ['transition-duration', '500ms'],
  3051. ['overflow', 'hidden'],
  3052. ['right', '0'],
  3053. ]);
  3054. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)([
  3055. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.HIGHLIGHT_CLASS} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.HEAD_CONTAINER} .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.BASE_CLASS}`,
  3056. `.${_buttons_consts__WEBPACK_IMPORTED_MODULE_1__.TEST_ADD_CLASS} .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.BASE_CLASS}`,
  3057. `.${_buttons_consts__WEBPACK_IMPORTED_MODULE_1__.TEST_REMOVE_CLASS} .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.BASE_CLASS}`,
  3058. ], [['width', '0']]);
  3059. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`.${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.BUTTON_CONTAINER}:not(:empty) + * .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.BACKGROUND_CONTAINER} > *`, [['margin-left', '-0.8em']]);
  3060. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.HIGHLIGHT_BACKGROUND_CLASS}`, [
  3061. ['transition-property', 'width, padding-left'],
  3062. ['transition-duration', '500ms'],
  3063. ['width', '100%'],
  3064. ]);
  3065. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`:not(.${_consts__WEBPACK_IMPORTED_MODULE_0__.HIGHLIGHT_CLASS}) > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.HEAD_CONTAINER} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.BUTTON_CONTAINER}:not(:empty):not(.${_buttons_consts__WEBPACK_IMPORTED_MODULE_1__.TEST_ADD_CLASS} *):not(.${_buttons_consts__WEBPACK_IMPORTED_MODULE_1__.TEST_REMOVE_CLASS} *) + * .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.BACKGROUND_CONTAINER} > .${_consts__WEBPACK_IMPORTED_MODULE_0__.HIGHLIGHT_BACKGROUND_CLASS}`, [['width', '0']]);
  3066. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)([
  3067. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.HIGHLIGHT_CLASS} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.HEAD_CONTAINER} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.BUTTON_CONTAINER}:not(:empty) + * .${_consts__WEBPACK_IMPORTED_MODULE_0__.HIGHLIGHT_BACKGROUND_CLASS}`,
  3068. `.${_buttons_consts__WEBPACK_IMPORTED_MODULE_1__.TEST_ADD_CLASS} .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.BUTTON_CONTAINER}:not(:empty) + * .${_consts__WEBPACK_IMPORTED_MODULE_0__.HIGHLIGHT_BACKGROUND_CLASS}`,
  3069. `.${_buttons_consts__WEBPACK_IMPORTED_MODULE_1__.TEST_REMOVE_CLASS} .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.BUTTON_CONTAINER}:not(:empty) + * .${_consts__WEBPACK_IMPORTED_MODULE_0__.HIGHLIGHT_BACKGROUND_CLASS}`,
  3070. ], [['padding-left', '0.8em']]);
  3071. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.HIGHLIGHT_BACKGROUND_CLASS}`, [
  3072. ['height', '100%'],
  3073. ['width', '100%'],
  3074. ['padding-left', '0'],
  3075. ]);
  3076. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`.${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.HEAD_CONTAINER}`, ['position', 'relative']);
  3077. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`:not(.${_consts__WEBPACK_IMPORTED_MODULE_0__.HIGHLIGHT_CLASS}) > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.HEAD_CONTAINER}:focus::after`, [
  3078. ['content', '\'\''],
  3079. ['position', 'absolute'],
  3080. ['right', '0'],
  3081. ['height', '100%'],
  3082. ['width', '4px'],
  3083. ]);
  3084. for (const [selector, base, contrast] of _nodes_consts__WEBPACK_IMPORTED_MODULE_2__.NODE_COLOURS) {
  3085. const headSelector = `${selector} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.HEAD_CONTAINER}`;
  3086. // focus indicator
  3087. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`:not(.${_consts__WEBPACK_IMPORTED_MODULE_0__.HIGHLIGHT_CLASS})${headSelector}:focus::after`, ['background-color', contrast]);
  3088. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`${headSelector} .${_consts__WEBPACK_IMPORTED_MODULE_0__.HIGHLIGHT_BACKGROUND_CLASS}`, ['background-color', contrast]);
  3089. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`${headSelector} .${_buttons_consts__WEBPACK_IMPORTED_MODULE_1__.BUTTON_CLASS}`, ['background-color', contrast]);
  3090. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)([`${headSelector} .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.BASE_CLASS}`], [
  3091. ['color', contrast],
  3092. ['background-color', base],
  3093. ]);
  3094. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)([`${headSelector} .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.CONTRAST_CLASS}`], ['color', base]);
  3095. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`${headSelector} .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.BASE_CLASS} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.LABEL_CONTAINER}`, ['background-image', `linear-gradient(to right, transparent, 1.9em, ${base} 3.8em)`]);
  3096. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`${headSelector} .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.CONTRAST_CLASS} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.LABEL_CONTAINER}`, ['background-image', `linear-gradient(to right, transparent, 1.9em, ${contrast} 3.8em)`]);
  3097. }
  3098. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`#${_consts__WEBPACK_IMPORTED_MODULE_0__.EAVE_ID}`, [
  3099. ['position', 'absolute'],
  3100. ['bottom', '0'],
  3101. ['width', '100%'],
  3102. // Prevents zipping to the end of the tree when mousing over the bottom pixel
  3103. ['height', '1px'],
  3104. ['z-index', 'var(--overlayIndex)'],
  3105. ]);
  3106. }
  3107.  
  3108.  
  3109. /***/ }),
  3110.  
  3111. /***/ "./ts/modal/body/nodes/actions/highlight/index.ts":
  3112. /*!********************************************************!*\
  3113. !*** ./ts/modal/body/nodes/actions/highlight/index.ts ***!
  3114. \********************************************************/
  3115. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  3116.  
  3117. __webpack_require__.r(__webpack_exports__);
  3118. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  3119. /* harmony export */ addSustained: () => (/* binding */ addSustained),
  3120. /* harmony export */ generateEave: () => (/* binding */ generateEave),
  3121. /* harmony export */ isActive: () => (/* binding */ isActive),
  3122. /* harmony export */ mount: () => (/* binding */ mount),
  3123. /* harmony export */ onMount: () => (/* binding */ onMount),
  3124. /* harmony export */ removeSustained: () => (/* binding */ removeSustained),
  3125. /* harmony export */ reset: () => (/* binding */ reset),
  3126. /* harmony export */ setActive: () => (/* binding */ setActive),
  3127. /* harmony export */ shouldMount: () => (/* binding */ shouldMount),
  3128. /* harmony export */ unmount: () => (/* binding */ unmount)
  3129. /* harmony export */ });
  3130. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/highlight/consts.ts");
  3131. /* harmony import */ var _edit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../edit */ "./ts/modal/body/nodes/actions/edit/index.ts");
  3132. /* harmony import */ var _scroll__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../scroll */ "./ts/modal/body/nodes/actions/scroll.ts");
  3133. /* harmony import */ var _modal_header_actions_sticky__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/modal/header/actions/sticky */ "./ts/modal/header/actions/sticky/index.ts");
  3134. /* harmony import */ var _modal_body__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/modal/body */ "./ts/modal/body/index.ts");
  3135. /* harmony import */ var _nodes_consts__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @nodes/consts */ "./ts/modal/body/nodes/consts.ts");
  3136. /* harmony import */ var _modal__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @/modal */ "./ts/modal/index.ts");
  3137.  
  3138.  
  3139.  
  3140.  
  3141.  
  3142.  
  3143.  
  3144. let sustainedNodes = [];
  3145. let activeNode;
  3146. function isActive() {
  3147. return Boolean(activeNode);
  3148. }
  3149. function removeSustained(node) {
  3150. sustainedNodes.splice(sustainedNodes.indexOf(node), 1);
  3151. // Avoid unhighlighting if it's still sustained by another action
  3152. if (node !== activeNode && !sustainedNodes.includes(node)) {
  3153. node.element.removeClass(_consts__WEBPACK_IMPORTED_MODULE_0__.HIGHLIGHT_CLASS);
  3154. }
  3155. }
  3156. function addSustained(node) {
  3157. node.element.addClass(_consts__WEBPACK_IMPORTED_MODULE_0__.HIGHLIGHT_CLASS);
  3158. sustainedNodes.push(node);
  3159. }
  3160. function setActive(node, doFocus = false) {
  3161. if (activeNode && !sustainedNodes.includes(activeNode)) {
  3162. activeNode.element.removeClass(_consts__WEBPACK_IMPORTED_MODULE_0__.HIGHLIGHT_CLASS);
  3163. }
  3164. activeNode = node;
  3165. if (!node) {
  3166. return;
  3167. }
  3168. node.element.addClass(_consts__WEBPACK_IMPORTED_MODULE_0__.HIGHLIGHT_CLASS);
  3169. if (doFocus) {
  3170. node.element.headContainer.focus();
  3171. // focus listeners don't seem to trigger if the document isn't focused
  3172. if ((0,_modal_header_actions_sticky__WEBPACK_IMPORTED_MODULE_3__.isActive)() && !document.hasFocus()) {
  3173. (0,_scroll__WEBPACK_IMPORTED_MODULE_2__.stickyScroll)(node, false, false);
  3174. }
  3175. }
  3176. }
  3177. function unmount(node) {
  3178. if (node === activeNode) {
  3179. node.element.headContainer.blur();
  3180. }
  3181. }
  3182. let isTab = false;
  3183. let isListening = false;
  3184. function mount(node) {
  3185. const { backgroundContainer, headContainer, elementContainer, infoContainer, base } = node.element;
  3186. if (base.valueContainer) {
  3187. (new ResizeObserver(() => {
  3188. base.valueContainer.style.setProperty('width', `${infoContainer.clientWidth}px`);
  3189. })).observe(infoContainer);
  3190. }
  3191. backgroundContainer.appendChild((() => {
  3192. const background = document.createElement('div');
  3193. background.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.HIGHLIGHT_BACKGROUND_CLASS);
  3194. return background;
  3195. })());
  3196. headContainer.setAttribute('tabindex', '0');
  3197. headContainer.addEventListener('focusin', (event) => {
  3198. event.stopPropagation();
  3199. if ((0,_modal_header_actions_sticky__WEBPACK_IMPORTED_MODULE_3__.isActive)()) {
  3200. (0,_scroll__WEBPACK_IMPORTED_MODULE_2__.stickyScroll)(node, false, isTab);
  3201. }
  3202. else if (isTab) {
  3203. node.element.scrollIntoView({ block: 'center', behavior: 'smooth' });
  3204. }
  3205. if (isTab && !isListening) {
  3206. isListening = true;
  3207. (0,_modal__WEBPACK_IMPORTED_MODULE_6__.getDocument)().addEventListener('mousemove', () => {
  3208. isTab = false;
  3209. isListening = false;
  3210. }, { capture: true, once: true });
  3211. }
  3212. // Filters out events fired from re-focusing the window
  3213. if (event.relatedTarget) {
  3214. setActive(node);
  3215. }
  3216. });
  3217. headContainer.addEventListener('mouseover', (event) => {
  3218. event.stopPropagation();
  3219. if (!isTab) {
  3220. setActive(node, !(0,_edit__WEBPACK_IMPORTED_MODULE_1__.isActive)());
  3221. }
  3222. });
  3223. elementContainer.addEventListener('mouseover', (event) => {
  3224. event.stopPropagation();
  3225. if (!isTab) {
  3226. setActive(node);
  3227. }
  3228. });
  3229. elementContainer.addEventListener('mouseout', (event) => {
  3230. event.stopPropagation();
  3231. if (!isTab) {
  3232. setActive();
  3233. }
  3234. });
  3235. }
  3236. function shouldMount() {
  3237. return true;
  3238. }
  3239. function setEdge(element, isStart) {
  3240. element.setAttribute('tabindex', '0');
  3241. // Prevent tabbing away from the modal
  3242. element.addEventListener('keydown', (event) => {
  3243. if (event.key === 'Tab' && (event.shiftKey === isStart) && element.isSameNode(event.target)) {
  3244. event.preventDefault();
  3245. }
  3246. });
  3247. element.addEventListener('focusin', () => {
  3248. setActive();
  3249. });
  3250. }
  3251. function generateEave(socket) {
  3252. const element = document.createElement('div');
  3253. element.id = _consts__WEBPACK_IMPORTED_MODULE_0__.EAVE_ID;
  3254. setEdge(socket, true);
  3255. setEdge(element, false);
  3256. socket.addEventListener('keydown', (event) => {
  3257. switch (event.key) {
  3258. case 'Home':
  3259. socket.focus();
  3260. _modal_body__WEBPACK_IMPORTED_MODULE_4__.element.scrollTop = 0;
  3261. break;
  3262. case 'End':
  3263. element.focus();
  3264. _modal_body__WEBPACK_IMPORTED_MODULE_4__.element.scrollTop = _modal_body__WEBPACK_IMPORTED_MODULE_4__.element.scrollHeight;
  3265. break;
  3266. case 'Backspace':
  3267. setActive();
  3268. break;
  3269. default:
  3270. return;
  3271. }
  3272. event.preventDefault();
  3273. });
  3274. return element;
  3275. }
  3276. // Blur focused node & reset focus index
  3277. function reset() {
  3278. setActive();
  3279. }
  3280. function onMount() {
  3281. const socket = (0,_modal__WEBPACK_IMPORTED_MODULE_6__.getSocket)();
  3282. socket.setAttribute('tabindex', '0');
  3283. // Prevent tabbing away from the modal
  3284. socket.addEventListener('keydown', (event) => {
  3285. if (event.key !== 'Tab') {
  3286. return;
  3287. }
  3288. isTab = event.target.classList.contains(_nodes_consts__WEBPACK_IMPORTED_MODULE_5__.ELEMENT_CLASSES.HEAD_CONTAINER);
  3289. if (event.shiftKey && socket.isSameNode(event.target)) {
  3290. event.preventDefault();
  3291. }
  3292. });
  3293. (0,_modal__WEBPACK_IMPORTED_MODULE_6__.getWindow)().addEventListener('blur', () => {
  3294. setActive();
  3295. });
  3296. _modal_body__WEBPACK_IMPORTED_MODULE_4__.element.addEventListener('wheel', () => {
  3297. setActive();
  3298. });
  3299. }
  3300.  
  3301.  
  3302. /***/ }),
  3303.  
  3304. /***/ "./ts/modal/body/nodes/actions/history.ts":
  3305. /*!************************************************!*\
  3306. !*** ./ts/modal/body/nodes/actions/history.ts ***!
  3307. \************************************************/
  3308. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  3309.  
  3310. __webpack_require__.r(__webpack_exports__);
  3311. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  3312. /* harmony export */ onMount: () => (/* binding */ onMount),
  3313. /* harmony export */ register: () => (/* binding */ register)
  3314. /* harmony export */ });
  3315. /* harmony import */ var _scroll__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./scroll */ "./ts/modal/body/nodes/actions/scroll.ts");
  3316. /* harmony import */ var _focus__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./focus */ "./ts/modal/body/nodes/actions/focus/index.ts");
  3317. /* harmony import */ var _highlight__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./highlight */ "./ts/modal/body/nodes/actions/highlight/index.ts");
  3318. /* harmony import */ var _modal_body__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/modal/body */ "./ts/modal/body/index.ts");
  3319. /* harmony import */ var _modal_header_actions_sticky__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/modal/header/actions/sticky */ "./ts/modal/header/actions/sticky/index.ts");
  3320. /* harmony import */ var _modal__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @/modal */ "./ts/modal/index.ts");
  3321.  
  3322.  
  3323.  
  3324.  
  3325.  
  3326.  
  3327. const undoStack = [];
  3328. const redoStack = [];
  3329. function register(target, undo, redo, doAct = true, isUndoDeletion = false, isRedoDeletion = false) {
  3330. if (doAct) {
  3331. redo();
  3332. }
  3333. redoStack.length = 0;
  3334. undoStack.push({ target, undo: { act: undo, isDeletion: isUndoDeletion }, redo: { act: redo, isDeletion: isRedoDeletion } });
  3335. }
  3336. function show(node) {
  3337. const target = node.element.headContainer;
  3338. if (!target.isSameNode((0,_modal__WEBPACK_IMPORTED_MODULE_5__.getDocument)().activeElement)) {
  3339. target.addEventListener('focusin', (event) => {
  3340. event.stopImmediatePropagation();
  3341. }, { capture: true, once: true });
  3342. }
  3343. target.focus({ preventScroll: true });
  3344. const targetRect = target.getBoundingClientRect();
  3345. const scrollRect = _modal_body__WEBPACK_IMPORTED_MODULE_3__.element.getBoundingClientRect();
  3346. const top = (0,_modal_header_actions_sticky__WEBPACK_IMPORTED_MODULE_4__.isActive)() ? (0,_scroll__WEBPACK_IMPORTED_MODULE_0__.getStickyScroll)(node) : (targetRect.top - scrollRect.top + _modal_body__WEBPACK_IMPORTED_MODULE_3__.element.scrollTop);
  3347. if (top < _modal_body__WEBPACK_IMPORTED_MODULE_3__.element.scrollTop) {
  3348. _modal_body__WEBPACK_IMPORTED_MODULE_3__.element.scrollTo({ top: top });
  3349. return;
  3350. }
  3351. const bottom = targetRect.top - scrollRect.top + _modal_body__WEBPACK_IMPORTED_MODULE_3__.element.scrollTop + targetRect.height - _modal_body__WEBPACK_IMPORTED_MODULE_3__.element.clientHeight;
  3352. if (bottom > _modal_body__WEBPACK_IMPORTED_MODULE_3__.element.scrollTop) {
  3353. _modal_body__WEBPACK_IMPORTED_MODULE_3__.element.scrollTo({ top: bottom });
  3354. }
  3355. }
  3356. function act(from, to, property) {
  3357. if (from.length === 0) {
  3358. return;
  3359. }
  3360. const action = from.pop();
  3361. (0,_focus__WEBPACK_IMPORTED_MODULE_1__.reset)();
  3362. if (action[property].isDeletion) {
  3363. const index = action.target.getIndex();
  3364. const target = index === 0 ? action.target.parent : action.target.parent.children[index - 1];
  3365. action[property].act();
  3366. show(target);
  3367. }
  3368. else {
  3369. action[property].act();
  3370. (0,_highlight__WEBPACK_IMPORTED_MODULE_2__.setActive)(action.target);
  3371. show(action.target);
  3372. }
  3373. to.push(action);
  3374. }
  3375. function onMount() {
  3376. (0,_modal__WEBPACK_IMPORTED_MODULE_5__.getSocket)().addEventListener('keydown', (event) => {
  3377. if (event.key === 'Undo' || (event.key.toLowerCase() === 'z' && event.ctrlKey && !event.shiftKey)) {
  3378. act(undoStack, redoStack, 'undo');
  3379. }
  3380. else if (event.key === 'Redo' || (event.key.toLowerCase() === 'y' && event.ctrlKey && !event.shiftKey)) {
  3381. act(redoStack, undoStack, 'redo');
  3382. }
  3383. });
  3384. }
  3385.  
  3386.  
  3387. /***/ }),
  3388.  
  3389. /***/ "./ts/modal/body/nodes/actions/overlays/consts.ts":
  3390. /*!********************************************************!*\
  3391. !*** ./ts/modal/body/nodes/actions/overlays/consts.ts ***!
  3392. \********************************************************/
  3393. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  3394.  
  3395. __webpack_require__.r(__webpack_exports__);
  3396. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  3397. /* harmony export */ CONTAINER_CLASS: () => (/* binding */ CONTAINER_CLASS)
  3398. /* harmony export */ });
  3399. const CONTAINER_CLASS = 'overlay-container';
  3400.  
  3401.  
  3402. /***/ }),
  3403.  
  3404. /***/ "./ts/modal/body/nodes/actions/overlays/css.ts":
  3405. /*!*****************************************************!*\
  3406. !*** ./ts/modal/body/nodes/actions/overlays/css.ts ***!
  3407. \*****************************************************/
  3408. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  3409.  
  3410. __webpack_require__.r(__webpack_exports__);
  3411. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  3412. /* harmony export */ "default": () => (/* binding */ generate)
  3413. /* harmony export */ });
  3414. /* harmony import */ var _tooltip_css__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tooltip/css */ "./ts/modal/body/nodes/actions/overlays/tooltip/css.ts");
  3415. /* harmony import */ var _dropdown_css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./dropdown/css */ "./ts/modal/body/nodes/actions/overlays/dropdown/css.ts");
  3416. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/overlays/consts.ts");
  3417. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  3418.  
  3419.  
  3420.  
  3421.  
  3422. function generate() {
  3423. (0,_tooltip_css__WEBPACK_IMPORTED_MODULE_0__["default"])();
  3424. (0,_dropdown_css__WEBPACK_IMPORTED_MODULE_1__["default"])();
  3425. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_2__.CONTAINER_CLASS}`, [
  3426. ['z-index', 'var(--overlayIndex)'],
  3427. ['position', 'absolute'],
  3428. ['top', '0'],
  3429. ['pointer-events', 'none'],
  3430. ]);
  3431. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_2__.CONTAINER_CLASS} > *`, [
  3432. ['position', 'absolute'],
  3433. ['width', 'inherit'],
  3434. ['display', 'flex'],
  3435. ['flex-direction', 'column'],
  3436. ['align-items', 'center'],
  3437. ]);
  3438. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_2__.CONTAINER_CLASS} > :empty`, ['display', 'none']);
  3439. }
  3440.  
  3441.  
  3442. /***/ }),
  3443.  
  3444. /***/ "./ts/modal/body/nodes/actions/overlays/dropdown/consts.ts":
  3445. /*!*****************************************************************!*\
  3446. !*** ./ts/modal/body/nodes/actions/overlays/dropdown/consts.ts ***!
  3447. \*****************************************************************/
  3448. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  3449.  
  3450. __webpack_require__.r(__webpack_exports__);
  3451. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  3452. /* harmony export */ DROPDOWN_ACTIVE_CLASS: () => (/* binding */ DROPDOWN_ACTIVE_CLASS),
  3453. /* harmony export */ DROPDOWN_BACKGROUND_CLASS: () => (/* binding */ DROPDOWN_BACKGROUND_CLASS),
  3454. /* harmony export */ DROPDOWN_CLASS: () => (/* binding */ DROPDOWN_CLASS),
  3455. /* harmony export */ DROPDOWN_CONTAINER_CLASS: () => (/* binding */ DROPDOWN_CONTAINER_CLASS),
  3456. /* harmony export */ DROPDOWN_PARENT_CLASS: () => (/* binding */ DROPDOWN_PARENT_CLASS),
  3457. /* harmony export */ DROPDOWN_SHOW_CLASS: () => (/* binding */ DROPDOWN_SHOW_CLASS),
  3458. /* harmony export */ DROPDOWN_WRAPPER_CLASS: () => (/* binding */ DROPDOWN_WRAPPER_CLASS)
  3459. /* harmony export */ });
  3460. const DROPDOWN_CLASS = 'option';
  3461. const DROPDOWN_CONTAINER_CLASS = 'option-container';
  3462. const DROPDOWN_PARENT_CLASS = 'option-parent';
  3463. const DROPDOWN_WRAPPER_CLASS = 'option-wrapper';
  3464. const DROPDOWN_BACKGROUND_CLASS = 'option-background';
  3465. const DROPDOWN_SHOW_CLASS = 'option-show';
  3466. const DROPDOWN_ACTIVE_CLASS = 'option-active';
  3467.  
  3468.  
  3469. /***/ }),
  3470.  
  3471. /***/ "./ts/modal/body/nodes/actions/overlays/dropdown/css.ts":
  3472. /*!**************************************************************!*\
  3473. !*** ./ts/modal/body/nodes/actions/overlays/dropdown/css.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 */ "default": () => (/* binding */ generate)
  3480. /* harmony export */ });
  3481. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/overlays/dropdown/consts.ts");
  3482. /* harmony import */ var _nodes_consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @nodes/consts */ "./ts/modal/body/nodes/consts.ts");
  3483. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  3484.  
  3485.  
  3486.  
  3487. function generate() {
  3488. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.DROPDOWN_WRAPPER_CLASS}`, [
  3489. ['z-index', 'var(--overlayIndex)'],
  3490. ['position', 'sticky'],
  3491. ['display', 'flex'],
  3492. ['width', '100%'],
  3493. ['pointer-events', 'initial'],
  3494. ]);
  3495. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.DROPDOWN_PARENT_CLASS}`, [
  3496. ['position', 'absolute'],
  3497. ['display', 'flex'],
  3498. ['flex-direction', 'column'],
  3499. ['width', '100%'],
  3500. ['margin-left', '-1px'],
  3501. ['max-height', 'calc(4.2em + 5px)'],
  3502. ['overflow-y', 'auto'],
  3503. ['border-bottom-left-radius', '12px'],
  3504. ]);
  3505. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.DROPDOWN_CONTAINER_CLASS}`, [['position', 'relative']]);
  3506. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.DROPDOWN_CONTAINER_CLASS} > *`, [['height', '1.4em']]);
  3507. const [, base, contrast] = _nodes_consts__WEBPACK_IMPORTED_MODULE_1__.NODE_COLOURS[1];
  3508. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.DROPDOWN_PARENT_CLASS}`, ['border', `1px solid ${base}`]);
  3509. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.DROPDOWN_CONTAINER_CLASS}`, [
  3510. ['background-color', contrast],
  3511. ['color', base],
  3512. ['border', `1px solid ${base}`],
  3513. ['cursor', 'pointer'],
  3514. ]);
  3515. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.DROPDOWN_BACKGROUND_CLASS}`, [['background-color', base]]);
  3516. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.DROPDOWN_ACTIVE_CLASS} .${_consts__WEBPACK_IMPORTED_MODULE_0__.DROPDOWN_CLASS}`, [['color', contrast]]);
  3517. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.DROPDOWN_ACTIVE_CLASS} .${_consts__WEBPACK_IMPORTED_MODULE_0__.DROPDOWN_BACKGROUND_CLASS}`, [['width', '100%']]);
  3518. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.DROPDOWN_CLASS}`, [
  3519. ['position', 'relative'],
  3520. ['transition-property', 'all'],
  3521. ['transition-duration', '500ms'],
  3522. ['padding', '0 0.6rem'],
  3523. ]);
  3524. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.DROPDOWN_BACKGROUND_CLASS}`, [
  3525. ['position', 'absolute'],
  3526. ['width', '0'],
  3527. ['transition', 'width 500ms ease 0s'],
  3528. ]);
  3529. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.DROPDOWN_CONTAINER_CLASS}:not(.${_consts__WEBPACK_IMPORTED_MODULE_0__.DROPDOWN_SHOW_CLASS})`, [['display', 'none']]);
  3530. }
  3531.  
  3532.  
  3533. /***/ }),
  3534.  
  3535. /***/ "./ts/modal/body/nodes/actions/overlays/dropdown/index.ts":
  3536. /*!****************************************************************!*\
  3537. !*** ./ts/modal/body/nodes/actions/overlays/dropdown/index.ts ***!
  3538. \****************************************************************/
  3539. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  3540.  
  3541. __webpack_require__.r(__webpack_exports__);
  3542. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  3543. /* harmony export */ generate: () => (/* binding */ generate),
  3544. /* harmony export */ reset: () => (/* binding */ reset),
  3545. /* harmony export */ update: () => (/* binding */ update)
  3546. /* harmony export */ });
  3547. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/overlays/dropdown/consts.ts");
  3548. /* harmony import */ var _edit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../edit */ "./ts/modal/body/nodes/actions/edit/index.ts");
  3549. /* harmony import */ var _modal_body__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/body */ "./ts/modal/body/index.ts");
  3550. var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
  3551. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  3552. return new (P || (P = Promise))(function (resolve, reject) {
  3553. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  3554. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  3555. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  3556. step((generator = generator.apply(thisArg, _arguments || [])).next());
  3557. });
  3558. };
  3559.  
  3560.  
  3561.  
  3562. const activeOptions = [];
  3563. const resetCallbacks = [];
  3564. let activeIndex = -1;
  3565. function getTop(target, includeHeight = true) {
  3566. const scrollRect = _modal_body__WEBPACK_IMPORTED_MODULE_2__.element.getBoundingClientRect();
  3567. const targetRect = target.getBoundingClientRect();
  3568. // todo this had a `+2` before; may be necessary
  3569. return targetRect.top - scrollRect.top + _modal_body__WEBPACK_IMPORTED_MODULE_2__.element.scrollTop + (includeHeight ? targetRect.height : 0);
  3570. }
  3571. // source: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions#escaping
  3572. function escapeRegExp(string) {
  3573. return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
  3574. }
  3575. function setActive(option, isActive = true) {
  3576. option.classList[isActive ? 'add' : 'remove'](_consts__WEBPACK_IMPORTED_MODULE_0__.DROPDOWN_ACTIVE_CLASS);
  3577. }
  3578. function deselect() {
  3579. if (activeIndex === -1) {
  3580. return;
  3581. }
  3582. setActive(activeOptions[activeIndex].parentElement, false);
  3583. activeIndex = -1;
  3584. }
  3585. function update(value) {
  3586. // equivalent to `if (!('options' in node))`
  3587. if (activeOptions.length === 0) {
  3588. return;
  3589. }
  3590. const stringValue = `${value}`;
  3591. const regExp = new RegExp(escapeRegExp(stringValue), 'i');
  3592. for (const { parentElement, innerText } of activeOptions) {
  3593. if (stringValue.length <= innerText.length && regExp.test(innerText)) {
  3594. parentElement.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.DROPDOWN_SHOW_CLASS);
  3595. }
  3596. else {
  3597. parentElement.classList.remove(_consts__WEBPACK_IMPORTED_MODULE_0__.DROPDOWN_SHOW_CLASS);
  3598. }
  3599. }
  3600. const [{ parentElement: { parentElement: wrapper } }] = activeOptions;
  3601. const top = getTop(wrapper);
  3602. // todo remove? seems pointless
  3603. if (_modal_body__WEBPACK_IMPORTED_MODULE_2__.element.scrollTop + _modal_body__WEBPACK_IMPORTED_MODULE_2__.element.clientHeight < top) {
  3604. _modal_body__WEBPACK_IMPORTED_MODULE_2__.element.scrollTop = top - _modal_body__WEBPACK_IMPORTED_MODULE_2__.element.clientHeight;
  3605. }
  3606. deselect();
  3607. }
  3608. function setValue(node, value) {
  3609. return __awaiter(this, void 0, void 0, function* () {
  3610. node.element.contrast.valueElement.value = value;
  3611. deselect();
  3612. yield (0,_edit__WEBPACK_IMPORTED_MODULE_1__.update)();
  3613. });
  3614. }
  3615. function reset() {
  3616. while (resetCallbacks.length > 0) {
  3617. resetCallbacks.pop()();
  3618. }
  3619. activeOptions.length = 0;
  3620. }
  3621. function addListener(target, type, listener, useCapture = false) {
  3622. target.addEventListener(type, listener, useCapture);
  3623. resetCallbacks.push(() => target.removeEventListener(type, listener, useCapture));
  3624. }
  3625. function generate(node) {
  3626. const wrapper = document.createElement('div');
  3627. const parent = document.createElement('div');
  3628. wrapper.style.width = `${node.element.contrast.valueContainer.clientWidth}px`;
  3629. // avoid blurring an input when dragging the scrollbar
  3630. addListener(wrapper, 'mousedown', (event) => {
  3631. event.stopPropagation();
  3632. event.preventDefault();
  3633. });
  3634. for (const type of ['mouseover', 'mouseout', 'mouseup']) {
  3635. addListener(wrapper, type, (event) => {
  3636. event.stopPropagation();
  3637. });
  3638. }
  3639. for (const value of node.options) {
  3640. const container = document.createElement('div');
  3641. const background = document.createElement('div');
  3642. const option = document.createElement('div');
  3643. option.innerText = value;
  3644. container.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.DROPDOWN_CONTAINER_CLASS);
  3645. option.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.DROPDOWN_CLASS);
  3646. background.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.DROPDOWN_BACKGROUND_CLASS);
  3647. container.append(background, option);
  3648. parent.appendChild(container);
  3649. activeOptions.push(option);
  3650. addListener(container, 'mousedown', (event) => {
  3651. event.stopPropagation();
  3652. event.preventDefault();
  3653. });
  3654. addListener(container, 'click', (event) => __awaiter(this, void 0, void 0, function* () {
  3655. event.stopPropagation();
  3656. yield setValue(node, value);
  3657. node.element.headContainer.focus();
  3658. }));
  3659. addListener(container, 'mouseenter', (event) => {
  3660. event.stopPropagation();
  3661. setActive(container);
  3662. });
  3663. addListener(container, 'mouseleave', (event) => {
  3664. event.stopPropagation();
  3665. setActive(container, false);
  3666. });
  3667. }
  3668. addListener(node.element.contrast.valueElement, 'keydown', (event) => {
  3669. const priorIndex = activeIndex;
  3670. let hasChanged = false;
  3671. switch (event.key) {
  3672. case 'Tab':
  3673. case 'Enter':
  3674. if (activeIndex >= 0) {
  3675. event.stopPropagation();
  3676. event.preventDefault();
  3677. setValue(node, activeOptions[activeIndex].innerText)
  3678. .then(() => node.element.headContainer.focus());
  3679. }
  3680. return;
  3681. case 'ArrowDown':
  3682. for (let i = activeIndex + 1; i < activeOptions.length; ++i) {
  3683. const { parentElement } = activeOptions[i];
  3684. if (parentElement.classList.contains(_consts__WEBPACK_IMPORTED_MODULE_0__.DROPDOWN_SHOW_CLASS)) {
  3685. activeIndex = i;
  3686. hasChanged = true;
  3687. const optionBottom = parentElement.offsetTop + parentElement.clientHeight;
  3688. if (parentElement.parentElement.scrollTop < optionBottom) {
  3689. parentElement.parentElement.scrollTop = optionBottom - parentElement.parentElement.clientHeight;
  3690. }
  3691. const top = getTop(parentElement);
  3692. if (_modal_body__WEBPACK_IMPORTED_MODULE_2__.element.scrollTop + _modal_body__WEBPACK_IMPORTED_MODULE_2__.element.clientHeight < top - parentElement.parentElement.scrollTop) {
  3693. _modal_body__WEBPACK_IMPORTED_MODULE_2__.element.scrollTop = top - _modal_body__WEBPACK_IMPORTED_MODULE_2__.element.clientHeight - parentElement.parentElement.scrollTop;
  3694. }
  3695. break;
  3696. }
  3697. }
  3698. break;
  3699. case 'ArrowUp':
  3700. for (let i = activeIndex - 1; i >= 0; --i) {
  3701. const { parentElement } = activeOptions[i];
  3702. if (parentElement.classList.contains(_consts__WEBPACK_IMPORTED_MODULE_0__.DROPDOWN_SHOW_CLASS)) {
  3703. activeIndex = i;
  3704. hasChanged = true;
  3705. // Scroll option list if necessary
  3706. if (parentElement.parentElement.scrollTop > parentElement.offsetTop) {
  3707. parentElement.parentElement.scrollTop = parentElement.offsetTop;
  3708. }
  3709. const top = getTop(parentElement, false);
  3710. // Scroll modal body if necessary
  3711. if (_modal_body__WEBPACK_IMPORTED_MODULE_2__.element.scrollTop > top - parentElement.parentElement.scrollTop) {
  3712. _modal_body__WEBPACK_IMPORTED_MODULE_2__.element.scrollTop = top - parentElement.parentElement.scrollTop;
  3713. }
  3714. break;
  3715. }
  3716. }
  3717. if (hasChanged) {
  3718. break;
  3719. }
  3720. // eslint-disable-next-line no-fallthrough
  3721. default:
  3722. if (activeIndex >= 0) {
  3723. setActive(activeOptions[activeIndex].parentElement, false);
  3724. }
  3725. activeIndex = -1;
  3726. return;
  3727. }
  3728. if (!hasChanged) {
  3729. return;
  3730. }
  3731. if (priorIndex >= 0) {
  3732. setActive(activeOptions[priorIndex].parentElement, false);
  3733. }
  3734. const { parentElement } = activeOptions[activeIndex];
  3735. setActive(parentElement);
  3736. }, true);
  3737. wrapper.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.DROPDOWN_WRAPPER_CLASS);
  3738. parent.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.DROPDOWN_PARENT_CLASS);
  3739. wrapper.appendChild(parent);
  3740. return wrapper;
  3741. }
  3742.  
  3743.  
  3744. /***/ }),
  3745.  
  3746. /***/ "./ts/modal/body/nodes/actions/overlays/index.ts":
  3747. /*!*******************************************************!*\
  3748. !*** ./ts/modal/body/nodes/actions/overlays/index.ts ***!
  3749. \*******************************************************/
  3750. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  3751.  
  3752. __webpack_require__.r(__webpack_exports__);
  3753. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  3754. /* harmony export */ dropdown: () => (/* reexport module object */ _dropdown__WEBPACK_IMPORTED_MODULE_3__),
  3755. /* harmony export */ hideTooltip: () => (/* binding */ hideTooltip),
  3756. /* harmony export */ reset: () => (/* binding */ reset),
  3757. /* harmony export */ setNode: () => (/* binding */ setNode),
  3758. /* harmony export */ showTooltip: () => (/* binding */ showTooltip),
  3759. /* harmony export */ tooltip: () => (/* reexport module object */ _tooltip__WEBPACK_IMPORTED_MODULE_2__),
  3760. /* harmony export */ update: () => (/* binding */ update)
  3761. /* harmony export */ });
  3762. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/overlays/consts.ts");
  3763. /* harmony import */ var _tooltip_consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./tooltip/consts */ "./ts/modal/body/nodes/actions/overlays/tooltip/consts.ts");
  3764. /* harmony import */ var _tooltip__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./tooltip */ "./ts/modal/body/nodes/actions/overlays/tooltip/index.ts");
  3765. /* harmony import */ var _dropdown__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./dropdown */ "./ts/modal/body/nodes/actions/overlays/dropdown/index.ts");
  3766. /* harmony import */ var _scroll__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../scroll */ "./ts/modal/body/nodes/actions/scroll.ts");
  3767. /* harmony import */ var _modal_body__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @/modal/body */ "./ts/modal/body/index.ts");
  3768. /* harmony import */ var _modal_header_actions_sticky__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @/modal/header/actions/sticky */ "./ts/modal/header/actions/sticky/index.ts");
  3769. var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
  3770. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  3771. return new (P || (P = Promise))(function (resolve, reject) {
  3772. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  3773. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  3774. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  3775. step((generator = generator.apply(thisArg, _arguments || [])).next());
  3776. });
  3777. };
  3778.  
  3779.  
  3780.  
  3781.  
  3782.  
  3783.  
  3784.  
  3785. let activeContainer;
  3786. let activeTooltip;
  3787. let activeDropdown;
  3788. let activeNode;
  3789. let activeListener;
  3790.  
  3791. function reset() {
  3792. _dropdown__WEBPACK_IMPORTED_MODULE_3__.reset();
  3793. _modal_body__WEBPACK_IMPORTED_MODULE_5__.element.removeEventListener('scroll', activeListener);
  3794. activeContainer.remove();
  3795. activeContainer = undefined;
  3796. activeTooltip = undefined;
  3797. activeDropdown = undefined;
  3798. activeNode = undefined;
  3799. activeListener = undefined;
  3800. }
  3801. function hideTooltip() {
  3802. _tooltip__WEBPACK_IMPORTED_MODULE_2__.hide(activeTooltip);
  3803. }
  3804. function getStickyPositions(parent, space, targetMinTop, targetHeight, nodeHeight, node) {
  3805. const targetTop = (0,_scroll__WEBPACK_IMPORTED_MODULE_4__.getStickyScroll)(node);
  3806. const ancestors = node.getAncestors();
  3807. const offset = 'children' in node ? 0 : nodeHeight;
  3808. return [
  3809. () => targetMinTop - _modal_body__WEBPACK_IMPORTED_MODULE_5__.element.clientHeight / 2 > _modal_body__WEBPACK_IMPORTED_MODULE_5__.element.scrollTop, [
  3810. [targetMinTop + targetHeight, targetMinTop - targetTop + targetHeight - offset, 0], ...[node, ...ancestors]
  3811. .map((node) => (0,_scroll__WEBPACK_IMPORTED_MODULE_4__.getStickyScroll)(node, false))
  3812. .map((height, index, { length }) => ([
  3813. height + (length - index) * nodeHeight,
  3814. (length - index - 1) * nodeHeight,
  3815. height,
  3816. ])),
  3817. ].map(([height, top, start]) => ({
  3818. container: (() => {
  3819. const container = document.createElement('div');
  3820. container.style.height = `${space - height}px`;
  3821. container.style.top = `${height}px`;
  3822. container.classList.add(_tooltip_consts__WEBPACK_IMPORTED_MODULE_1__.TOOLTIP_BOTTOM_CLASS);
  3823. parent.appendChild(container);
  3824. return container;
  3825. })(),
  3826. top,
  3827. start,
  3828. })),
  3829. ];
  3830. }
  3831. function getBasicPosition(parent, space, targetMinTop, targetHeight) {
  3832. return [
  3833. () => targetMinTop - _modal_body__WEBPACK_IMPORTED_MODULE_5__.element.clientHeight / 2 > _modal_body__WEBPACK_IMPORTED_MODULE_5__.element.scrollTop,
  3834. [
  3835. {
  3836. container: (() => {
  3837. const container = document.createElement('div');
  3838. container.style.height = `${targetMinTop}px`;
  3839. container.style.top = '0';
  3840. container.classList.add(_tooltip_consts__WEBPACK_IMPORTED_MODULE_1__.TOOLTIP_TOP_CLASS);
  3841. parent.appendChild(container);
  3842. return container;
  3843. })(),
  3844. }, {
  3845. container: (() => {
  3846. const container = document.createElement('div');
  3847. container.style.position = 'absolute';
  3848. container.style.height = `${space - targetMinTop - targetHeight}px`;
  3849. container.style.top = '0';
  3850. container.classList.add(_tooltip_consts__WEBPACK_IMPORTED_MODULE_1__.TOOLTIP_BOTTOM_CLASS);
  3851. parent.appendChild(container);
  3852. return container;
  3853. })(),
  3854. top: targetMinTop + targetHeight,
  3855. },
  3856. ],
  3857. ];
  3858. }
  3859. function applyPosition(basicPositions, stickyPositions, nodeHeight, isAbove, container, tooltipElement, dropdownElement) {
  3860. const containers = [];
  3861. let target;
  3862. tooltipElement.style.removeProperty('transform');
  3863. if (isAbove) {
  3864. tooltipElement.style.top = `${_modal_body__WEBPACK_IMPORTED_MODULE_5__.element.clientHeight - tooltipElement.clientHeight}px`;
  3865. basicPositions[0].container.appendChild(tooltipElement);
  3866. containers.push(basicPositions[0].container);
  3867. if (!dropdownElement) {
  3868. return containers;
  3869. }
  3870. target = dropdownElement;
  3871. }
  3872. else {
  3873. target = tooltipElement;
  3874. }
  3875. if (!(0,_modal_header_actions_sticky__WEBPACK_IMPORTED_MODULE_6__.isActive)()) {
  3876. target.style.top = '0';
  3877. basicPositions[1].container.appendChild(target);
  3878. return [basicPositions[1].container, ...containers];
  3879. }
  3880. let index = 0;
  3881. for (; index < stickyPositions.length - 1; ++index) {
  3882. if (_modal_body__WEBPACK_IMPORTED_MODULE_5__.element.scrollTop < stickyPositions[index + 1].start) {
  3883. break;
  3884. }
  3885. }
  3886. target.style.top = `${stickyPositions[index].top}px`;
  3887. if (stickyPositions[1].start + nodeHeight < _modal_body__WEBPACK_IMPORTED_MODULE_5__.element.scrollTop) {
  3888. tooltipElement.style.top = `${stickyPositions[index].top}px`;
  3889. stickyPositions[index].container.append(target, tooltipElement);
  3890. return [stickyPositions[index].container];
  3891. }
  3892. if (dropdownElement && stickyPositions[1].start < _modal_body__WEBPACK_IMPORTED_MODULE_5__.element.scrollTop) {
  3893. tooltipElement.style.transform = `translateY(${(_modal_body__WEBPACK_IMPORTED_MODULE_5__.element.scrollTop - stickyPositions[1].start)}px)`;
  3894. }
  3895. stickyPositions[index].container.appendChild(target);
  3896. return [stickyPositions[index].container, ...containers];
  3897. }
  3898. function setPosition(node, container, target, tooltipElement, dropdownElement) {
  3899. const scrollRect = _modal_body__WEBPACK_IMPORTED_MODULE_5__.element.getBoundingClientRect();
  3900. const targetRect = target.getBoundingClientRect();
  3901. const nodeRect = node.element.headContainer.getBoundingClientRect();
  3902. const containerLeft = targetRect.left - scrollRect.left;
  3903. container.style.width = `${targetRect.width}px`;
  3904. container.style.left = `${containerLeft}px`;
  3905. const targetMinTop = targetRect.top - scrollRect.top + _modal_body__WEBPACK_IMPORTED_MODULE_5__.element.scrollTop;
  3906. const space = _modal_body__WEBPACK_IMPORTED_MODULE_5__.element.scrollHeight;
  3907. const [isUpBasic, basicPositions] = getBasicPosition(container, space, targetMinTop, targetRect.height);
  3908. const [isUpSticky, stickyPositions] = getStickyPositions(container, space, targetMinTop, targetRect.height, nodeRect.height, node);
  3909. let isAbove;
  3910. const listener = () => {
  3911. isAbove = dropdownElement || ((0,_modal_header_actions_sticky__WEBPACK_IMPORTED_MODULE_6__.isActive)() ? isUpSticky() : isUpBasic());
  3912. applyPosition(basicPositions, stickyPositions, nodeRect.height, isAbove, container, tooltipElement, dropdownElement);
  3913. };
  3914. listener();
  3915. // todo stop using scroll listeners;
  3916. // use intersection observers to detect specific scrollTops & act accordingly
  3917. // try using a branch of divs instead of manually changing styles
  3918. _modal_body__WEBPACK_IMPORTED_MODULE_5__.element.addEventListener('scroll', listener);
  3919. return listener;
  3920. }
  3921. function generate(node, target, tooltipElement, dropdownElement) {
  3922. const container = document.createElement('div');
  3923. const { elementContainer: parent } = node.getRoot().element;
  3924. container.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.CONTAINER_CLASS);
  3925. parent.appendChild(container, parent.firstChild);
  3926. return [container, setPosition(node, container, target, tooltipElement, dropdownElement)];
  3927. }
  3928. function update() {
  3929. _dropdown__WEBPACK_IMPORTED_MODULE_3__.update(activeNode.value);
  3930. _tooltip__WEBPACK_IMPORTED_MODULE_2__.fade(activeTooltip);
  3931. // handle possible dropdown height change
  3932. activeListener();
  3933. }
  3934. function setTooltipMessage(message, tooltipElement = activeTooltip, container = activeContainer, isRight = true) {
  3935. const box = tooltipElement.querySelector(`.${_tooltip_consts__WEBPACK_IMPORTED_MODULE_1__.TOOLTIP_BOX_CLASS}`);
  3936. box.innerText = message;
  3937. if (isRight) {
  3938. box.style.right = `${Math.max(0, box.offsetWidth / 2 - _modal_body__WEBPACK_IMPORTED_MODULE_5__.element.clientWidth + container.offsetLeft + container.clientWidth / 2)}px`;
  3939. }
  3940. else {
  3941. box.style.left = `${Math.max(0, box.offsetWidth / 2 - container.offsetLeft - container.clientWidth / 2)}px`;
  3942. }
  3943. }
  3944. function showTooltip(message, node, target) {
  3945. return __awaiter(this, void 0, void 0, function* () {
  3946. if (node === activeNode) {
  3947. // handle possible tooltip height change
  3948. activeListener();
  3949. // handle possible width change
  3950. setTooltipMessage(message);
  3951. return;
  3952. }
  3953. const tooltipElement = _tooltip__WEBPACK_IMPORTED_MODULE_2__.getAnimated();
  3954. const [container, listener] = generate(node, target, tooltipElement);
  3955. setTooltipMessage(message, tooltipElement, container, false);
  3956. yield _tooltip__WEBPACK_IMPORTED_MODULE_2__.animationEnd();
  3957. _modal_body__WEBPACK_IMPORTED_MODULE_5__.element.removeEventListener('scroll', listener);
  3958. container.remove();
  3959. });
  3960. }
  3961. function setNode(node) {
  3962. activeNode = node;
  3963. activeTooltip = _tooltip__WEBPACK_IMPORTED_MODULE_2__.generate(node.element.contrast.valueElement.type === 'color');
  3964. if ('options' in node) {
  3965. activeDropdown = _dropdown__WEBPACK_IMPORTED_MODULE_3__.generate(node);
  3966. _dropdown__WEBPACK_IMPORTED_MODULE_3__.update(node.value);
  3967. }
  3968. [activeContainer, activeListener] = generate(activeNode, node.element.contrast.valueContainer, activeTooltip, activeDropdown);
  3969. }
  3970.  
  3971.  
  3972. /***/ }),
  3973.  
  3974. /***/ "./ts/modal/body/nodes/actions/overlays/tooltip/consts.ts":
  3975. /*!****************************************************************!*\
  3976. !*** ./ts/modal/body/nodes/actions/overlays/tooltip/consts.ts ***!
  3977. \****************************************************************/
  3978. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  3979.  
  3980. __webpack_require__.r(__webpack_exports__);
  3981. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  3982. /* harmony export */ MESSAGE_UNRESOLVED: () => (/* binding */ MESSAGE_UNRESOLVED),
  3983. /* harmony export */ TOOLTIP_ANIMATION: () => (/* binding */ TOOLTIP_ANIMATION),
  3984. /* harmony export */ TOOLTIP_ANIMATION_FAST: () => (/* binding */ TOOLTIP_ANIMATION_FAST),
  3985. /* harmony export */ TOOLTIP_ARROW_CLASS: () => (/* binding */ TOOLTIP_ARROW_CLASS),
  3986. /* harmony export */ TOOLTIP_BOTTOM_CLASS: () => (/* binding */ TOOLTIP_BOTTOM_CLASS),
  3987. /* harmony export */ TOOLTIP_BOX_CLASS: () => (/* binding */ TOOLTIP_BOX_CLASS),
  3988. /* harmony export */ TOOLTIP_CONTAINER_CLASS: () => (/* binding */ TOOLTIP_CONTAINER_CLASS),
  3989. /* harmony export */ TOOLTIP_REVERSE_CLASS: () => (/* binding */ TOOLTIP_REVERSE_CLASS),
  3990. /* harmony export */ TOOLTIP_TOP_CLASS: () => (/* binding */ TOOLTIP_TOP_CLASS)
  3991. /* harmony export */ });
  3992. const TOOLTIP_CONTAINER_CLASS = 'tooltip-container';
  3993. const TOOLTIP_ARROW_CLASS = 'modal-arrow-wrapper';
  3994. const TOOLTIP_BOX_CLASS = 'tooltip';
  3995. const TOOLTIP_TOP_CLASS = 'tooltip-above';
  3996. const TOOLTIP_BOTTOM_CLASS = 'tooltip-below';
  3997. const TOOLTIP_REVERSE_CLASS = 'tooltip-reverse';
  3998. const TOOLTIP_ANIMATION = [
  3999. [
  4000. // keyframes
  4001. { opacity: 1 },
  4002. { opacity: 1 },
  4003. { opacity: 0 },
  4004. ], { duration: 2000 },
  4005. ];
  4006. const TOOLTIP_ANIMATION_FAST = [
  4007. [
  4008. // keyframes
  4009. { opacity: 1 },
  4010. { opacity: 0 },
  4011. ], { duration: 1000 },
  4012. ];
  4013. const MESSAGE_UNRESOLVED = 'Please wait for validation';
  4014.  
  4015.  
  4016. /***/ }),
  4017.  
  4018. /***/ "./ts/modal/body/nodes/actions/overlays/tooltip/css.ts":
  4019. /*!*************************************************************!*\
  4020. !*** ./ts/modal/body/nodes/actions/overlays/tooltip/css.ts ***!
  4021. \*************************************************************/
  4022. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4023.  
  4024. __webpack_require__.r(__webpack_exports__);
  4025. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4026. /* harmony export */ "default": () => (/* binding */ generate)
  4027. /* harmony export */ });
  4028. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/overlays/tooltip/consts.ts");
  4029. /* harmony import */ var _nodes_consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @nodes/consts */ "./ts/modal/body/nodes/consts.ts");
  4030. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  4031. /* harmony import */ var _dropdown_consts__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../dropdown/consts */ "./ts/modal/body/nodes/actions/overlays/dropdown/consts.ts");
  4032.  
  4033.  
  4034.  
  4035.  
  4036. function generate() {
  4037. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_CONTAINER_CLASS}`, [
  4038. ['position', 'sticky'],
  4039. ['text-align', 'center'],
  4040. ['display', 'flex'],
  4041. ['flex-direction', 'column'],
  4042. ['align-items', 'center'],
  4043. ['width', '10em'],
  4044. ]);
  4045. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([
  4046. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_TOP_CLASS}:not(.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_REVERSE_CLASS}) .${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_ARROW_CLASS}`,
  4047. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_BOTTOM_CLASS}.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_REVERSE_CLASS} .${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_ARROW_CLASS}`,
  4048. `.${_dropdown_consts__WEBPACK_IMPORTED_MODULE_3__.DROPDOWN_WRAPPER_CLASS} + * > .${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_ARROW_CLASS}`,
  4049. ], [
  4050. ['top', '100%'],
  4051. ['border-color', 'var(--borderTooltip) transparent transparent transparent'],
  4052. ]);
  4053. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([
  4054. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_BOTTOM_CLASS}:not(.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_REVERSE_CLASS}):not(:has(.${_dropdown_consts__WEBPACK_IMPORTED_MODULE_3__.DROPDOWN_WRAPPER_CLASS})) .${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_ARROW_CLASS}`,
  4055. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_TOP_CLASS}.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_REVERSE_CLASS}:not(:has(.${_dropdown_consts__WEBPACK_IMPORTED_MODULE_3__.DROPDOWN_WRAPPER_CLASS})) .${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_ARROW_CLASS}`,
  4056. ], [
  4057. ['bottom', '100%'],
  4058. ['border-color', 'transparent transparent var(--borderTooltip) transparent'],
  4059. ]);
  4060. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([
  4061. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_TOP_CLASS}:not(.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_REVERSE_CLASS}) .${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_CONTAINER_CLASS}`,
  4062. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_BOTTOM_CLASS}.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_REVERSE_CLASS} .${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_CONTAINER_CLASS}`,
  4063. ], ['translate', '0 -0.5em']);
  4064. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([`.${_dropdown_consts__WEBPACK_IMPORTED_MODULE_3__.DROPDOWN_WRAPPER_CLASS} + .${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_CONTAINER_CLASS}`], ['translate', '0px calc(-100% - 0.5em)']);
  4065. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([
  4066. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_BOTTOM_CLASS}:not(.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_REVERSE_CLASS}):not(:has(.${_dropdown_consts__WEBPACK_IMPORTED_MODULE_3__.DROPDOWN_WRAPPER_CLASS})) .${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_CONTAINER_CLASS}`,
  4067. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_TOP_CLASS}.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_REVERSE_CLASS}:not(:has(.${_dropdown_consts__WEBPACK_IMPORTED_MODULE_3__.DROPDOWN_WRAPPER_CLASS})) .${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_CONTAINER_CLASS}`,
  4068. ], [['translate', '0 0.5em']]);
  4069. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_BOX_CLASS}`, [
  4070. ['font-size', '0.9em'],
  4071. ['padding', '3px 15px'],
  4072. ['border-radius', '1em'],
  4073. ['border', 'solid 3px var(--borderTooltip)'],
  4074. ['background-color', _nodes_consts__WEBPACK_IMPORTED_MODULE_1__.NODE_COLOURS[1][1]],
  4075. ['color', _nodes_consts__WEBPACK_IMPORTED_MODULE_1__.NODE_COLOURS[1][2]],
  4076. ['position', 'relative'],
  4077. ]);
  4078. // Don't show when there's no hint to give
  4079. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([`:has(> .${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_BOX_CLASS}:empty)`], ['display', 'none']);
  4080. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_ARROW_CLASS}`, [
  4081. ['position', 'absolute'],
  4082. ['left', '50%'],
  4083. ['margin-left', '-0.5em'],
  4084. ['border-width', '0.5em'],
  4085. ['border-style', 'solid'],
  4086. ]);
  4087. }
  4088.  
  4089.  
  4090. /***/ }),
  4091.  
  4092. /***/ "./ts/modal/body/nodes/actions/overlays/tooltip/index.ts":
  4093. /*!***************************************************************!*\
  4094. !*** ./ts/modal/body/nodes/actions/overlays/tooltip/index.ts ***!
  4095. \***************************************************************/
  4096. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4097.  
  4098. __webpack_require__.r(__webpack_exports__);
  4099. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4100. /* harmony export */ animationEnd: () => (/* binding */ animationEnd),
  4101. /* harmony export */ fade: () => (/* binding */ fade),
  4102. /* harmony export */ generate: () => (/* binding */ generate),
  4103. /* harmony export */ getAnimated: () => (/* binding */ getAnimated),
  4104. /* harmony export */ hide: () => (/* binding */ hide),
  4105. /* harmony export */ kill: () => (/* binding */ kill)
  4106. /* harmony export */ });
  4107. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/overlays/tooltip/consts.ts");
  4108. var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
  4109. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  4110. return new (P || (P = Promise))(function (resolve, reject) {
  4111. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  4112. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  4113. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  4114. step((generator = generator.apply(thisArg, _arguments || [])).next());
  4115. });
  4116. };
  4117.  
  4118. let animation;
  4119. function animationEnd() {
  4120. return __awaiter(this, void 0, void 0, function* () {
  4121. yield new Promise((resolve) => {
  4122. animation.addEventListener('finish', resolve);
  4123. });
  4124. });
  4125. }
  4126. function kill() {
  4127. animation === null || animation === void 0 ? void 0 : animation.finish();
  4128. }
  4129. function generate(doReverse = false) {
  4130. const container = document.createElement('div');
  4131. const arrow = document.createElement('div');
  4132. const box = document.createElement('div');
  4133. container.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_CONTAINER_CLASS);
  4134. arrow.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_ARROW_CLASS);
  4135. box.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_BOX_CLASS);
  4136. if (doReverse) {
  4137. arrow.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_REVERSE_CLASS);
  4138. }
  4139. container.append(arrow, box);
  4140. return container;
  4141. }
  4142. function getAnimated() {
  4143. const element = generate();
  4144. animation = element.animate(..._consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_ANIMATION);
  4145. animation.onfinish = ({ target }) => {
  4146. element.remove();
  4147. if (target === animation) {
  4148. animation = undefined;
  4149. }
  4150. };
  4151. return element;
  4152. }
  4153. function fade(container) {
  4154. if (container.querySelector(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_BOX_CLASS}`).matches(':empty')) {
  4155. return;
  4156. }
  4157. kill();
  4158. animation = container.animate(..._consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_ANIMATION_FAST);
  4159. animation.onfinish = ({ target }) => {
  4160. if (target === animation) {
  4161. animation = undefined;
  4162. }
  4163. };
  4164. }
  4165. function hide(element) {
  4166. element.querySelector(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_BOX_CLASS}`).innerText = '';
  4167. }
  4168.  
  4169.  
  4170. /***/ }),
  4171.  
  4172. /***/ "./ts/modal/body/nodes/actions/scroll.ts":
  4173. /*!***********************************************!*\
  4174. !*** ./ts/modal/body/nodes/actions/scroll.ts ***!
  4175. \***********************************************/
  4176. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4177.  
  4178. __webpack_require__.r(__webpack_exports__);
  4179. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4180. /* harmony export */ basicScroll: () => (/* binding */ basicScroll),
  4181. /* harmony export */ getStickyScroll: () => (/* binding */ getStickyScroll),
  4182. /* harmony export */ scroll: () => (/* binding */ scroll),
  4183. /* harmony export */ stickyScroll: () => (/* binding */ stickyScroll)
  4184. /* harmony export */ });
  4185. /* harmony import */ var _focus_consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./focus/consts */ "./ts/modal/body/nodes/actions/focus/consts.ts");
  4186. /* harmony import */ var _focus__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./focus */ "./ts/modal/body/nodes/actions/focus/index.ts");
  4187. /* harmony import */ var _modal_body__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/body */ "./ts/modal/body/index.ts");
  4188. /* harmony import */ var _modal_header_actions_sticky__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/modal/header/actions/sticky */ "./ts/modal/header/actions/sticky/index.ts");
  4189. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  4190.  
  4191.  
  4192.  
  4193.  
  4194.  
  4195. // specifically returns the last *visible* descendant
  4196. function getLastDescendant(node, isFocus = (0,_focus__WEBPACK_IMPORTED_MODULE_1__.isActive)()) {
  4197. if ('children' in node && node.children.length > 0 && (!isFocus || node.element.hasClass(_focus_consts__WEBPACK_IMPORTED_MODULE_0__.FOCUS_CLASS))) {
  4198. for (let i = node.children.length - 1; i >= 0; --i) {
  4199. if (node.children[i].element.elementContainer.clientHeight > 0) {
  4200. return getLastDescendant(node.children[i], isFocus);
  4201. }
  4202. }
  4203. }
  4204. return node;
  4205. }
  4206. // a scrollIntoView replacement for sticky positioning
  4207. function getStickyScroll(node, alignToTop = true) {
  4208. const firstChild = alignToTop ? node : getLastDescendant(node);
  4209. const { height } = node.element.headContainer.getBoundingClientRect();
  4210. let depth = 0;
  4211. for (let root = node; 'parent' in root; root = root.parent) {
  4212. depth++;
  4213. }
  4214. return Math.ceil(firstChild.element.headContainer.getBoundingClientRect().top
  4215. - _modal_body__WEBPACK_IMPORTED_MODULE_2__.element.getBoundingClientRect().top
  4216. + _modal_body__WEBPACK_IMPORTED_MODULE_2__.element.scrollTop
  4217. - (height + _modal_consts__WEBPACK_IMPORTED_MODULE_4__.SUB_PIXEL_BS) * depth);
  4218. }
  4219. function stickyScroll(node, doSnap = true, alignToTop = true) {
  4220. const scroll = getStickyScroll(node, alignToTop);
  4221. if (alignToTop) {
  4222. _modal_body__WEBPACK_IMPORTED_MODULE_2__.element.scrollTo({ top: scroll, behavior: doSnap ? 'auto' : 'smooth' });
  4223. }
  4224. else if (_modal_body__WEBPACK_IMPORTED_MODULE_2__.element.scrollTop > scroll) {
  4225. _modal_body__WEBPACK_IMPORTED_MODULE_2__.element.scrollTop = scroll;
  4226. }
  4227. }
  4228. function basicScroll(node) {
  4229. node.element.scrollIntoView({ block: 'center' });
  4230. }
  4231. function scroll(node) {
  4232. if ((0,_modal_header_actions_sticky__WEBPACK_IMPORTED_MODULE_3__.isActive)()) {
  4233. stickyScroll(node);
  4234. }
  4235. else {
  4236. basicScroll(node);
  4237. }
  4238. }
  4239.  
  4240.  
  4241. /***/ }),
  4242.  
  4243. /***/ "./ts/modal/body/nodes/child.ts":
  4244. /*!**************************************!*\
  4245. !*** ./ts/modal/body/nodes/child.ts ***!
  4246. \**************************************/
  4247. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4248.  
  4249. __webpack_require__.r(__webpack_exports__);
  4250. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4251. /* harmony export */ "default": () => (/* binding */ Child)
  4252. /* harmony export */ });
  4253. /* harmony import */ var _element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./element */ "./ts/modal/body/nodes/element.ts");
  4254. /* harmony import */ var _queue__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./queue */ "./ts/modal/body/nodes/queue.ts");
  4255. /* harmony import */ var _actions_highlight__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./actions/highlight */ "./ts/modal/body/nodes/actions/highlight/index.ts");
  4256. /* harmony import */ var _actions_edit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./actions/edit */ "./ts/modal/body/nodes/actions/edit/index.ts");
  4257. /* harmony import */ var _actions_focus__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./actions/focus */ "./ts/modal/body/nodes/actions/focus/index.ts");
  4258. /* harmony import */ var _actions_hide__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./actions/hide */ "./ts/modal/body/nodes/actions/hide/index.ts");
  4259. /* harmony import */ var _actions_callbacks_update__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./actions/callbacks/update */ "./ts/modal/body/nodes/actions/callbacks/update.ts");
  4260. /* harmony import */ var _actions_buttons_disable__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./actions/buttons/disable */ "./ts/modal/body/nodes/actions/buttons/disable/index.ts");
  4261. /* harmony import */ var _actions_buttons_move__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./actions/buttons/move */ "./ts/modal/body/nodes/actions/buttons/move/index.ts");
  4262. /* harmony import */ var _actions_buttons_duplicate__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./actions/buttons/duplicate */ "./ts/modal/body/nodes/actions/buttons/duplicate/index.ts");
  4263. /* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! @types */ "./ts/library/validation/types.ts");
  4264.  
  4265.  
  4266.  
  4267.  
  4268.  
  4269.  
  4270.  
  4271.  
  4272.  
  4273.  
  4274.  
  4275. const actions = [
  4276. // No button
  4277. _actions_highlight__WEBPACK_IMPORTED_MODULE_2__,
  4278. _actions_focus__WEBPACK_IMPORTED_MODULE_4__,
  4279. _actions_edit__WEBPACK_IMPORTED_MODULE_3__,
  4280. _actions_hide__WEBPACK_IMPORTED_MODULE_5__,
  4281. // Button
  4282. _actions_buttons_disable__WEBPACK_IMPORTED_MODULE_7__,
  4283. _actions_buttons_move__WEBPACK_IMPORTED_MODULE_8__,
  4284. _actions_buttons_duplicate__WEBPACK_IMPORTED_MODULE_9__,
  4285. ];
  4286. class Child {
  4287. constructor(data, parent, index) {
  4288. this.isActive = true;
  4289. this.element = new _element__WEBPACK_IMPORTED_MODULE_0__["default"](data);
  4290. for (const key of _types__WEBPACK_IMPORTED_MODULE_10__.LEAF_KEYS) {
  4291. if (key in data) {
  4292. this[key] = data[key];
  4293. }
  4294. }
  4295. this.forceValid = !('predicate' in data) && !('options' in data);
  4296. this.attach(parent, index);
  4297. for (const { shouldMount, mount } of actions) {
  4298. if (shouldMount(this)) {
  4299. mount(this);
  4300. }
  4301. }
  4302. if ('predicate' in data) {
  4303. this.predicate = () => data.predicate(this.value);
  4304. }
  4305. if ('onUpdate' in data) {
  4306. this.onUpdate = () => (0,_queue__WEBPACK_IMPORTED_MODULE_1__.onceVisualsUpdate)(() => data.onUpdate(this.value));
  4307. (0,_actions_callbacks_update__WEBPACK_IMPORTED_MODULE_6__.handle)(this.onUpdate(), 'onUpdate', this);
  4308. }
  4309. }
  4310. getRoot() {
  4311. return this.parent.getRoot();
  4312. }
  4313. getAncestors() {
  4314. return [this.parent, ...this.parent.getAncestors()];
  4315. }
  4316. getIndex() {
  4317. return this.parent.children.indexOf(this);
  4318. }
  4319. getSiblings() {
  4320. const index = this.getIndex();
  4321. const siblings = this.parent.children;
  4322. return [...siblings.slice(0, index), ...siblings.slice(index + 1)];
  4323. }
  4324. detach() {
  4325. this.parent.children.splice(this.getIndex(), 1);
  4326. this.element.remove();
  4327. this.parent = undefined;
  4328. }
  4329. attach(parent, index = parent.children.length) {
  4330. parent.children.splice(index, 0, this);
  4331. parent.element.addChild(this.element, index);
  4332. this.parent = parent;
  4333. }
  4334. move(parent, to) {
  4335. this.detach();
  4336. this.attach(parent, typeof to === 'number' ? to : to.getIndex() + 1);
  4337. }
  4338. duplicate() {
  4339. return new Child(this.getSeedData(), this.parent, this.getIndex() + 1);
  4340. }
  4341. unmount() {
  4342. for (const action of actions) {
  4343. if ('unmount' in action) {
  4344. action.unmount(this);
  4345. }
  4346. }
  4347. }
  4348. disconnect() {
  4349. this.unmount();
  4350. this.detach();
  4351. }
  4352. getSeedData() {
  4353. const data = {};
  4354. for (const key of _types__WEBPACK_IMPORTED_MODULE_10__.LEAF_KEYS) {
  4355. if (key in this) {
  4356. data[key] = this[key];
  4357. }
  4358. }
  4359. return data;
  4360. }
  4361. getPredicateData() {
  4362. const data = {};
  4363. for (const key of _types__WEBPACK_IMPORTED_MODULE_10__.SAVED_KEYS) {
  4364. if (key in this) {
  4365. data[key] = this[key];
  4366. }
  4367. }
  4368. return data;
  4369. }
  4370. getSaveData(isActiveBranch) {
  4371. const tree = this.getPredicateData();
  4372. if (isActiveBranch) {
  4373. return {
  4374. tree,
  4375. activeTree: tree,
  4376. configs: 'get' in this ? [this.get(tree, [])] : [],
  4377. };
  4378. }
  4379. return { tree };
  4380. }
  4381. }
  4382.  
  4383.  
  4384. /***/ }),
  4385.  
  4386. /***/ "./ts/modal/body/nodes/consts.ts":
  4387. /*!***************************************!*\
  4388. !*** ./ts/modal/body/nodes/consts.ts ***!
  4389. \***************************************/
  4390. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4391.  
  4392. __webpack_require__.r(__webpack_exports__);
  4393. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4394. /* harmony export */ BASE_CLASS: () => (/* binding */ BASE_CLASS),
  4395. /* harmony export */ CHECKBOX_WRAPPER_CLASS: () => (/* binding */ CHECKBOX_WRAPPER_CLASS),
  4396. /* harmony export */ CONTRAST_CLASS: () => (/* binding */ CONTRAST_CLASS),
  4397. /* harmony export */ EDITABLE_CLASS: () => (/* binding */ EDITABLE_CLASS),
  4398. /* harmony export */ ELEMENT_CLASSES: () => (/* binding */ ELEMENT_CLASSES),
  4399. /* harmony export */ MIDDLE_CLASS: () => (/* binding */ MIDDLE_CLASS),
  4400. /* harmony export */ NODE_COLOURS: () => (/* binding */ NODE_COLOURS),
  4401. /* harmony export */ ROOT_CLASS: () => (/* binding */ ROOT_CLASS)
  4402. /* harmony export */ });
  4403. const ROOT_CLASS = 'root';
  4404. const MIDDLE_CLASS = 'middle';
  4405. const ELEMENT_CLASSES = {
  4406. ELEMENT_CONTAINER: 'node',
  4407. BACKGROUND_CONTAINER: 'node-background-container',
  4408. CHILD_CONTAINER: 'node-child-container',
  4409. BUTTON_CONTAINER: 'node-button-container',
  4410. INFO_CONTAINER: 'node-info-container',
  4411. HEAD_CONTAINER: 'node-head-container',
  4412. VALUE_CONTAINER: 'node-value-container',
  4413. VALUE: 'node-value',
  4414. LABEL_CONTAINER: 'node-label-container',
  4415. LABEL: 'node-label',
  4416. };
  4417. const BASE_CLASS = 'node-base';
  4418. const CONTRAST_CLASS = 'node-contrast';
  4419. const CHECKBOX_WRAPPER_CLASS = 'checkbox-wrapper';
  4420. const EDITABLE_CLASS = 'editable';
  4421. const NODE_COLOURS = [
  4422. [`.${ELEMENT_CLASSES.ELEMENT_CONTAINER}:not(.${EDITABLE_CLASS})`, 'var(--nodeHeaderBase)', 'var(--nodeHeaderContrast)'],
  4423. [`.${ELEMENT_CLASSES.ELEMENT_CONTAINER}.${MIDDLE_CLASS}.${EDITABLE_CLASS}`, 'var(--nodeBlendBase)', 'var(--nodeBlendContrast)'],
  4424. [`.${ELEMENT_CLASSES.ELEMENT_CONTAINER}:not(.${MIDDLE_CLASS}).${EDITABLE_CLASS}`, 'var(--nodeValueBase)', 'var(--nodeValueContrast)'],
  4425. ];
  4426.  
  4427.  
  4428. /***/ }),
  4429.  
  4430. /***/ "./ts/modal/body/nodes/css.ts":
  4431. /*!************************************!*\
  4432. !*** ./ts/modal/body/nodes/css.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 */ "default": () => (/* binding */ generate)
  4439. /* harmony export */ });
  4440. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/consts.ts");
  4441. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  4442. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  4443.  
  4444.  
  4445.  
  4446. function generate() {
  4447. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ROOT_CLASS}`, [
  4448. ['flex-grow', '1'],
  4449. // Apparently it has min-height 100% without a content-related height value
  4450. ['height', 'fit-content'],
  4451. ]);
  4452. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.CHILD_CONTAINER}:empty`, ['display', 'none']);
  4453. (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']);
  4454. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.ELEMENT_CONTAINER}`, [
  4455. ['user-select', 'none'],
  4456. ['position', 'relative'],
  4457. ['border-width', `${_modal_consts__WEBPACK_IMPORTED_MODULE_1__.SUB_PIXEL_BS}px`],
  4458. ]);
  4459. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.INFO_CONTAINER} > *`], [
  4460. ['position', 'absolute'],
  4461. ['width', '100%'],
  4462. ['height', '100%'],
  4463. ]);
  4464. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.VALUE_CONTAINER}`, `.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.LABEL_CONTAINER}`], [
  4465. ['position', 'absolute'],
  4466. ['white-space', 'nowrap'],
  4467. ]);
  4468. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.INFO_CONTAINER}`, ['position', 'relative']);
  4469. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([`.${_consts__WEBPACK_IMPORTED_MODULE_0__.BASE_CLASS} > .${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.VALUE_CONTAINER}`], [
  4470. ['position', 'absolute'],
  4471. ['right', '0'],
  4472. ['overflow', 'hidden'],
  4473. ]);
  4474. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([
  4475. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.HEAD_CONTAINER}`,
  4476. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.VALUE_CONTAINER}`,
  4477. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.LABEL_CONTAINER}`,
  4478. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.BACKGROUND_CONTAINER}`,
  4479. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.INFO_CONTAINER}`,
  4480. ], [
  4481. ['flex-grow', '1'],
  4482. ['display', 'flex'],
  4483. ['align-items', 'center'],
  4484. ]);
  4485. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.BACKGROUND_CONTAINER}`], [['position', 'absolute']]);
  4486. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.LABEL_CONTAINER}`, [
  4487. ['right', '0'],
  4488. ['pointer-events', 'none'],
  4489. ['height', '100%'],
  4490. ]);
  4491. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.VALUE_CONTAINER}`, [
  4492. ['user-select', 'none'],
  4493. ['height', '100%'],
  4494. ]);
  4495. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.BACKGROUND_CONTAINER}`, `.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.VALUE_CONTAINER}`], [['width', '100%']]);
  4496. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.BACKGROUND_CONTAINER} > *`, [
  4497. ['height', '100%'],
  4498. ['position', 'absolute'],
  4499. ]);
  4500. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.VALUE}`, `.${_consts__WEBPACK_IMPORTED_MODULE_0__.CHECKBOX_WRAPPER_CLASS}`], [
  4501. ['padding-right', '0.6em'],
  4502. ['padding-left', '0.6em'],
  4503. ]);
  4504. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.HEAD_CONTAINER}`, [
  4505. ['background-color', 'inherit'],
  4506. ['user-select', 'none'],
  4507. ['height', `${_modal_consts__WEBPACK_IMPORTED_MODULE_1__.NODE_HEIGHT}em`],
  4508. ]);
  4509. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.HEAD_CONTAINER} > *`, ['height', '100%']);
  4510. (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})`, ['border-top-style', 'solid']);
  4511. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.MIDDLE_CLASS} .${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.ELEMENT_CONTAINER}`, ['border-left-style', 'solid']);
  4512. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ROOT_CLASS}`, ['border-bottom-style', 'solid']);
  4513. for (const [selector, base, contrast] of _consts__WEBPACK_IMPORTED_MODULE_0__.NODE_COLOURS) {
  4514. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(selector, [
  4515. ['background-color', base],
  4516. ['color', contrast],
  4517. ]);
  4518. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`${selector}`, ['border-color', contrast]);
  4519. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`${selector} > .${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.HEAD_CONTAINER}`, ['outline', `1px solid ${contrast}`]);
  4520. }
  4521. }
  4522.  
  4523.  
  4524. /***/ }),
  4525.  
  4526. /***/ "./ts/modal/body/nodes/element.ts":
  4527. /*!****************************************!*\
  4528. !*** ./ts/modal/body/nodes/element.ts ***!
  4529. \****************************************/
  4530. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4531.  
  4532. __webpack_require__.r(__webpack_exports__);
  4533. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4534. /* harmony export */ "default": () => (/* binding */ Element)
  4535. /* harmony export */ });
  4536. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/consts.ts");
  4537.  
  4538. class Element {
  4539. constructor(data) {
  4540. this.elementContainer = document.createElement('div');
  4541. this.backgroundContainer = document.createElement('div');
  4542. this.headContainer = document.createElement('span');
  4543. this.buttonContainer = document.createElement('span');
  4544. this.infoContainer = document.createElement('span');
  4545. this.base = { container: document.createElement('span') };
  4546. this.contrast = { container: document.createElement('span') };
  4547. this.childContainer = document.createElement('div');
  4548. this.elementContainer.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.ELEMENT_CONTAINER);
  4549. this.backgroundContainer.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.BACKGROUND_CONTAINER);
  4550. this.childContainer.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.CHILD_CONTAINER);
  4551. this.infoContainer.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.INFO_CONTAINER);
  4552. this.headContainer.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.HEAD_CONTAINER);
  4553. this.buttonContainer.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.BUTTON_CONTAINER);
  4554. this.base.container.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.BASE_CLASS);
  4555. this.contrast.container.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.CONTRAST_CLASS);
  4556. if ('value' in data) {
  4557. this.addValueContainer(this.contrast, data);
  4558. this.addValueContainer(this.base, data);
  4559. this.render(data.value);
  4560. }
  4561. if ('label' in data) {
  4562. this.addLabelContainer(this.contrast, data.label);
  4563. this.addLabelContainer(this.base, data.label);
  4564. }
  4565. this.infoContainer.append(this.backgroundContainer, this.contrast.container, this.base.container);
  4566. this.headContainer.append(this.buttonContainer, this.infoContainer);
  4567. this.elementContainer.appendChild(this.headContainer);
  4568. this.elementContainer.appendChild(this.childContainer);
  4569. }
  4570. addLabelContainer({ container }, label) {
  4571. const labelContainer = document.createElement('div');
  4572. const labelElement = document.createElement('span');
  4573. labelContainer.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.LABEL_CONTAINER);
  4574. labelElement.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.LABEL);
  4575. labelElement.innerText = label;
  4576. labelContainer.appendChild(labelElement);
  4577. container.appendChild(labelContainer);
  4578. }
  4579. addValueContainer(field, data) {
  4580. field.valueContainer = document.createElement('label');
  4581. field.valueContainer.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.VALUE_CONTAINER);
  4582. if ('value' in data) {
  4583. field.valueElement = document.createElement('input');
  4584. field.valueElement.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.VALUE);
  4585. if ('inputAttributes' in data) {
  4586. for (const [key, value] of Object.entries(data.inputAttributes)) {
  4587. field.valueElement.setAttribute(key, value);
  4588. }
  4589. }
  4590. field.valueElement.setAttribute('tabindex', '-1');
  4591. if (typeof data.value === 'boolean') {
  4592. field.valueElement.type = 'checkbox';
  4593. // Positions tooltips below checkboxes
  4594. const valueWrapper = document.createElement('span');
  4595. valueWrapper.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.CHECKBOX_WRAPPER_CLASS);
  4596. valueWrapper.appendChild(field.valueElement);
  4597. field.valueContainer.appendChild(valueWrapper);
  4598. }
  4599. else {
  4600. if (typeof data.value === 'number') {
  4601. field.valueElement.type = 'number';
  4602. // Disables a tooltip implying that decimal values are invalid
  4603. field.valueElement.step = 'any';
  4604. }
  4605. else if ('input' in data) {
  4606. field.valueElement.type = data.input;
  4607. }
  4608. field.valueContainer.appendChild(field.valueElement);
  4609. }
  4610. }
  4611. field.container.appendChild(field.valueContainer);
  4612. }
  4613. render(value) {
  4614. if (typeof value === 'boolean') {
  4615. this.base.valueElement.checked = value;
  4616. this.contrast.valueElement.checked = value;
  4617. }
  4618. else {
  4619. this.base.valueElement.value = value.toString();
  4620. this.contrast.valueElement.value = value.toString();
  4621. }
  4622. }
  4623. hasClass(...names) {
  4624. for (const name of names) {
  4625. if (this.elementContainer.classList.contains(name)) {
  4626. return true;
  4627. }
  4628. }
  4629. return false;
  4630. }
  4631. addClass(...names) {
  4632. for (const name of names) {
  4633. this.elementContainer.classList.add(name);
  4634. }
  4635. }
  4636. removeClass(...names) {
  4637. for (const name of names) {
  4638. this.elementContainer.classList.remove(name);
  4639. }
  4640. }
  4641. addChild(child, index) {
  4642. var _a;
  4643. this.childContainer.insertBefore(child.elementContainer, (_a = this.childContainer.children[index]) !== null && _a !== void 0 ? _a : null);
  4644. }
  4645. addButton(button) {
  4646. this.buttonContainer.appendChild(button);
  4647. }
  4648. remove() {
  4649. this.elementContainer.remove();
  4650. }
  4651. scrollIntoView(options) {
  4652. this.backgroundContainer.scrollIntoView(typeof options === 'object' ? Object.assign({ block: 'center' }, options) : options);
  4653. }
  4654. }
  4655.  
  4656.  
  4657. /***/ }),
  4658.  
  4659. /***/ "./ts/modal/body/nodes/middle.ts":
  4660. /*!***************************************!*\
  4661. !*** ./ts/modal/body/nodes/middle.ts ***!
  4662. \***************************************/
  4663. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4664.  
  4665. __webpack_require__.r(__webpack_exports__);
  4666. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4667. /* harmony export */ "default": () => (/* binding */ Middle)
  4668. /* harmony export */ });
  4669. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/consts.ts");
  4670. /* harmony import */ var _root__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./root */ "./ts/modal/body/nodes/root.ts");
  4671. /* harmony import */ var _child__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./child */ "./ts/modal/body/nodes/child.ts");
  4672. /* harmony import */ var _actions_buttons_create__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./actions/buttons/create */ "./ts/modal/body/nodes/actions/buttons/create/index.ts");
  4673. /* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @types */ "./ts/library/validation/types.ts");
  4674.  
  4675.  
  4676.  
  4677.  
  4678.  
  4679. const MIDDLE_KEYS = _types__WEBPACK_IMPORTED_MODULE_4__.MIDDLE_KEYS.filter((key) => key !== 'children');
  4680. const actions = [_actions_buttons_create__WEBPACK_IMPORTED_MODULE_3__];
  4681. class Middle extends _child__WEBPACK_IMPORTED_MODULE_2__["default"] {
  4682. constructor(data, parent, index) {
  4683. super(data, parent, index);
  4684. this.children = [];
  4685. _root__WEBPACK_IMPORTED_MODULE_1__.setup.call(this, data);
  4686. this.element.addClass(_consts__WEBPACK_IMPORTED_MODULE_0__.MIDDLE_CLASS);
  4687. for (const { shouldMount, mount } of actions) {
  4688. if (shouldMount(this)) {
  4689. mount(this);
  4690. }
  4691. }
  4692. }
  4693. duplicate() {
  4694. return new Middle(this.getSeedData(), this.parent, this.getIndex() + 1);
  4695. }
  4696. unmount() {
  4697. super.unmount();
  4698. for (const action of actions) {
  4699. if ('unmount' in action) {
  4700. action.unmount(this);
  4701. }
  4702. }
  4703. for (const child of this.children) {
  4704. child.unmount();
  4705. }
  4706. }
  4707. disconnect() {
  4708. this.unmount();
  4709. this.detach();
  4710. }
  4711. // for duplication
  4712. getSeedData() {
  4713. const data = {};
  4714. for (const key of MIDDLE_KEYS) {
  4715. if (key in this) {
  4716. data[key] = this[key];
  4717. }
  4718. }
  4719. return Object.assign(Object.assign(Object.assign({}, super.getSeedData()), data), { children: this.children.map((child) => child.getSeedData()) });
  4720. }
  4721. getPredicateData() {
  4722. return Object.assign(Object.assign({}, super.getPredicateData()), _root__WEBPACK_IMPORTED_MODULE_1__.getPredicateData.call(this));
  4723. }
  4724. getSaveData(isActiveBranch) {
  4725. const data = _root__WEBPACK_IMPORTED_MODULE_1__.getSaveData.call(this, isActiveBranch);
  4726. const tree = Object.assign(Object.assign({}, super.getPredicateData()), data.tree);
  4727. if (isActiveBranch) {
  4728. const activeTree = Object.assign(Object.assign({}, tree), data.activeTree);
  4729. return {
  4730. tree,
  4731. activeTree,
  4732. configs: 'get' in this ? [this.get(activeTree, data.configs)] : data.configs,
  4733. };
  4734. }
  4735. return { tree };
  4736. }
  4737. }
  4738.  
  4739.  
  4740. /***/ }),
  4741.  
  4742. /***/ "./ts/modal/body/nodes/queue.ts":
  4743. /*!**************************************!*\
  4744. !*** ./ts/modal/body/nodes/queue.ts ***!
  4745. \**************************************/
  4746. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4747.  
  4748. __webpack_require__.r(__webpack_exports__);
  4749. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4750. /* harmony export */ onceVisualsUpdate: () => (/* binding */ onceVisualsUpdate)
  4751. /* harmony export */ });
  4752. const queue = [];
  4753. // No idea if this works on all machines/browsers
  4754. function onceVisualsUpdate(_callback) {
  4755. return new Promise((resolve) => {
  4756. const callback = () => resolve(_callback());
  4757. if (queue.push(callback) > 1) {
  4758. return;
  4759. }
  4760. // Wait for update to start
  4761. requestAnimationFrame(() => {
  4762. // Wait for everything else to update
  4763. window.setTimeout(() => {
  4764. for (const callback of queue) {
  4765. callback();
  4766. }
  4767. queue.length = 0;
  4768. }, 0);
  4769. });
  4770. });
  4771. }
  4772.  
  4773.  
  4774. /***/ }),
  4775.  
  4776. /***/ "./ts/modal/body/nodes/root.ts":
  4777. /*!*************************************!*\
  4778. !*** ./ts/modal/body/nodes/root.ts ***!
  4779. \*************************************/
  4780. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4781.  
  4782. __webpack_require__.r(__webpack_exports__);
  4783. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4784. /* harmony export */ "default": () => (/* binding */ Root),
  4785. /* harmony export */ getPredicateData: () => (/* binding */ getPredicateData),
  4786. /* harmony export */ getSaveData: () => (/* binding */ getSaveData),
  4787. /* harmony export */ setup: () => (/* binding */ setup)
  4788. /* harmony export */ });
  4789. /* harmony import */ var _middle__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./middle */ "./ts/modal/body/nodes/middle.ts");
  4790. /* harmony import */ var _child__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./child */ "./ts/modal/body/nodes/child.ts");
  4791. /* harmony import */ var _element__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./element */ "./ts/modal/body/nodes/element.ts");
  4792. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/consts.ts");
  4793. /* harmony import */ var _queue__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./queue */ "./ts/modal/body/nodes/queue.ts");
  4794. /* harmony import */ var _actions_highlight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./actions/highlight */ "./ts/modal/body/nodes/actions/highlight/index.ts");
  4795. /* harmony import */ var _actions_focus__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./actions/focus */ "./ts/modal/body/nodes/actions/focus/index.ts");
  4796. /* harmony import */ var _actions_buttons_create__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./actions/buttons/create */ "./ts/modal/body/nodes/actions/buttons/create/index.ts");
  4797. /* harmony import */ var _actions_callbacks_update__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./actions/callbacks/update */ "./ts/modal/body/nodes/actions/callbacks/update.ts");
  4798. /* harmony import */ var _actions_buttons_consts__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./actions/buttons/consts */ "./ts/modal/body/nodes/actions/buttons/consts.ts");
  4799. /* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! @types */ "./ts/library/validation/types.ts");
  4800. var __rest = (undefined && undefined.__rest) || function (s, e) {
  4801. var t = {};
  4802. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  4803. t[p] = s[p];
  4804. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  4805. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
  4806. if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
  4807. t[p[i]] = s[p[i]];
  4808. }
  4809. return t;
  4810. };
  4811.  
  4812.  
  4813.  
  4814.  
  4815.  
  4816.  
  4817.  
  4818.  
  4819.  
  4820.  
  4821.  
  4822. const actions = [_actions_highlight__WEBPACK_IMPORTED_MODULE_5__, _actions_focus__WEBPACK_IMPORTED_MODULE_6__, _actions_buttons_create__WEBPACK_IMPORTED_MODULE_7__];
  4823. function isActive(child) {
  4824. return !('isActive' in child) || child.isActive;
  4825. }
  4826. function getChildPredicateData({ children }) {
  4827. return children
  4828. .filter((child) => isActive(child) && !child.element.hasClass(_actions_buttons_consts__WEBPACK_IMPORTED_MODULE_9__.TEST_REMOVE_CLASS))
  4829. .map((child) => child.getPredicateData());
  4830. }
  4831. function getChildSaveData({ children }, isActiveBranch = true) {
  4832. return children
  4833. .filter((child) => !child.element.hasClass(_actions_buttons_consts__WEBPACK_IMPORTED_MODULE_9__.TEST_ADD_CLASS))
  4834. .map((child) => child.getSaveData(isActive(child) && isActiveBranch));
  4835. }
  4836. function addChildren(children) {
  4837. for (const child of children) {
  4838. if ('children' in child) {
  4839. new _middle__WEBPACK_IMPORTED_MODULE_0__["default"](child, this);
  4840. }
  4841. else {
  4842. new _child__WEBPACK_IMPORTED_MODULE_1__["default"](child, this);
  4843. }
  4844. }
  4845. }
  4846. function setup(_a) {
  4847. var { children } = _a, data = __rest(_a, ["children"]);
  4848. for (const key of _types__WEBPACK_IMPORTED_MODULE_10__.ROOT_OTHER_KEYS) {
  4849. if (key in data) {
  4850. this[key] = data[key];
  4851. }
  4852. }
  4853. addChildren.call(this, children);
  4854. for (const key of _types__WEBPACK_IMPORTED_MODULE_10__.ROOT_PREDICATE_KEYS) {
  4855. if (key in data) {
  4856. this[key] = () => data[key](getChildPredicateData(this));
  4857. }
  4858. }
  4859. for (const key of _types__WEBPACK_IMPORTED_MODULE_10__.ROOT_UPDATE_KEYS) {
  4860. if (key in data) {
  4861. this[key] = () => (0,_queue__WEBPACK_IMPORTED_MODULE_4__.onceVisualsUpdate)(() => data[key](getChildPredicateData(this)));
  4862. (0,_actions_callbacks_update__WEBPACK_IMPORTED_MODULE_8__.handle)(this[key](), key, this);
  4863. }
  4864. }
  4865. }
  4866. function getPredicateData() {
  4867. return { children: getChildPredicateData(this) };
  4868. }
  4869. function getSaveData(isActiveBranch) {
  4870. const activeChildren = [];
  4871. const children = [];
  4872. const configs = [];
  4873. for (const child of getChildSaveData(this, isActiveBranch)) {
  4874. children.push(child.tree);
  4875. if ('activeTree' in child) {
  4876. activeChildren.push(child.activeTree);
  4877. configs.push(...child.configs);
  4878. }
  4879. }
  4880. return { tree: { children }, activeTree: { children: activeChildren }, configs };
  4881. }
  4882. class Root {
  4883. constructor(data) {
  4884. this.children = [];
  4885. this.addChildren = addChildren;
  4886. this.getPredicateData = getPredicateData;
  4887. this.element = new _element__WEBPACK_IMPORTED_MODULE_2__["default"]({});
  4888. this.element.addClass(_consts__WEBPACK_IMPORTED_MODULE_3__.ROOT_CLASS);
  4889. setup.call(this, data);
  4890. for (const { shouldMount, mount } of actions) {
  4891. if (shouldMount(this)) {
  4892. mount(this);
  4893. }
  4894. }
  4895. }
  4896. getRoot() {
  4897. return this;
  4898. }
  4899. getAncestors() {
  4900. return [];
  4901. }
  4902. getSaveData() {
  4903. const { tree, activeTree, configs } = getSaveData.call(this);
  4904. if ('get' in this) {
  4905. return { tree, activeTree, config: this.get(activeTree, configs) };
  4906. }
  4907. return { tree, activeTree, config: configs.length === 1 ? configs[0] : configs };
  4908. }
  4909. }
  4910.  
  4911.  
  4912. /***/ }),
  4913.  
  4914. /***/ "./ts/modal/body/style/consts.ts":
  4915. /*!***************************************!*\
  4916. !*** ./ts/modal/body/style/consts.ts ***!
  4917. \***************************************/
  4918. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4919.  
  4920. __webpack_require__.r(__webpack_exports__);
  4921. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4922. /* harmony export */ DEFAULT_STYLE: () => (/* binding */ DEFAULT_STYLE),
  4923. /* harmony export */ ROOT_ID: () => (/* binding */ ROOT_ID)
  4924. /* harmony export */ });
  4925. const ROOT_ID = 'root-style';
  4926. const DEFAULT_STYLE = {
  4927. width: 80,
  4928. height: 80,
  4929. fontSize: 18,
  4930. borderTooltip: '#570000',
  4931. borderModal: '#ffffff',
  4932. headBase: '#000000',
  4933. headContrast: 'Black / White',
  4934. headButtonExit: '#f10000',
  4935. headButtonLabel: '#906300',
  4936. headButtonSticky: '#199a00',
  4937. headButtonStyle: '#900091',
  4938. headButtonHide: '#00749a',
  4939. headButtonAlt: '#838f00',
  4940. nodeHeaderBase: '#101010',
  4941. nodeBlendBase: '#101010',
  4942. nodeValueBase: '#303030',
  4943. nodeContrast: 'Black / White',
  4944. nodeButtonCreate: '#40ff40',
  4945. nodeButtonDuplicate: '#40ffff',
  4946. nodeButtonMove: '#ac60ff',
  4947. nodeButtonDisable: '#ffd000',
  4948. nodeButtonDelete: '#ff1111',
  4949. validBackground: '#d9ffc0',
  4950. invalidBackground: '#ffb4be',
  4951. focusBackground: '#e8e8e8',
  4952. };
  4953.  
  4954.  
  4955. /***/ }),
  4956.  
  4957. /***/ "./ts/modal/body/style/css.ts":
  4958. /*!************************************!*\
  4959. !*** ./ts/modal/body/style/css.ts ***!
  4960. \************************************/
  4961. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4962.  
  4963. __webpack_require__.r(__webpack_exports__);
  4964. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4965. /* harmony export */ "default": () => (/* binding */ generate)
  4966. /* harmony export */ });
  4967. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/style/consts.ts");
  4968. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../consts */ "./ts/modal/body/consts.ts");
  4969. /* harmony import */ var _data_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../data/consts */ "./ts/modal/body/data/consts.ts");
  4970. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  4971. /* 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");
  4972.  
  4973.  
  4974.  
  4975.  
  4976.  
  4977. function generate() {
  4978. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`#${_consts__WEBPACK_IMPORTED_MODULE_1__.MODAL_BODY_ID}.${_modal_header_actions_style_consts__WEBPACK_IMPORTED_MODULE_4__.ACTION_ID} > #${_data_consts__WEBPACK_IMPORTED_MODULE_2__.ROOT_ID}`, ['display', 'none']);
  4979. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`#${_consts__WEBPACK_IMPORTED_MODULE_1__.MODAL_BODY_ID}:not(.${_modal_header_actions_style_consts__WEBPACK_IMPORTED_MODULE_4__.ACTION_ID}) > #${_consts__WEBPACK_IMPORTED_MODULE_0__.ROOT_ID}`, ['display', 'none']);
  4980. }
  4981.  
  4982.  
  4983. /***/ }),
  4984.  
  4985. /***/ "./ts/modal/body/style/index.ts":
  4986. /*!**************************************!*\
  4987. !*** ./ts/modal/body/style/index.ts ***!
  4988. \**************************************/
  4989. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4990.  
  4991. __webpack_require__.r(__webpack_exports__);
  4992. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4993. /* harmony export */ "default": () => (/* binding */ generate),
  4994. /* harmony export */ getRoot: () => (/* binding */ getRoot),
  4995. /* harmony export */ getUserStyles: () => (/* binding */ getUserStyles),
  4996. /* harmony export */ toJSON: () => (/* binding */ toJSON),
  4997. /* harmony export */ toRawStyle: () => (/* binding */ toRawStyle)
  4998. /* harmony export */ });
  4999. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/style/consts.ts");
  5000. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./css */ "./ts/modal/body/style/css.ts");
  5001. /* harmony import */ var _update__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./update */ "./ts/modal/body/style/update.ts");
  5002. /* harmony import */ var ___WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! .. */ "./ts/modal/body/index.ts");
  5003. /* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @types */ "./ts/library/validation/types.ts");
  5004.  
  5005.  
  5006.  
  5007.  
  5008.  
  5009. function getRoot() {
  5010. return ___WEBPACK_IMPORTED_MODULE_3__.ROOTS[_consts__WEBPACK_IMPORTED_MODULE_0__.ROOT_ID];
  5011. }
  5012. // Fill any missing entries
  5013. function getFilledStyle(style = {}) {
  5014. return Object.assign(Object.assign({}, _consts__WEBPACK_IMPORTED_MODULE_0__.DEFAULT_STYLE), style);
  5015. }
  5016. function toJSON(style) {
  5017. const filledStyle = Object.assign(Object.assign({}, _consts__WEBPACK_IMPORTED_MODULE_0__.DEFAULT_STYLE), style);
  5018. return {
  5019. label: 'Name',
  5020. value: filledStyle.name,
  5021. children: [
  5022. {
  5023. label: 'Style Is Active?',
  5024. value: filledStyle.isActive,
  5025. },
  5026. {
  5027. label: 'Modal',
  5028. children: [
  5029. {
  5030. label: 'Width (%)',
  5031. value: filledStyle.width,
  5032. predicate: (value) => value > 0 || 'Width must be greater than zero',
  5033. },
  5034. {
  5035. label: 'Height (%)',
  5036. value: filledStyle.height,
  5037. predicate: (value) => value > 0 || 'Height must be greater than zero',
  5038. },
  5039. {
  5040. label: 'Font Size (px)',
  5041. value: filledStyle.fontSize,
  5042. predicate: (value) => value > 0 || 'Font size must be greater than zero',
  5043. },
  5044. {
  5045. label: 'Border Color',
  5046. value: filledStyle.borderModal,
  5047. input: 'color',
  5048. },
  5049. ],
  5050. },
  5051. {
  5052. label: 'Header',
  5053. children: [
  5054. {
  5055. label: 'General',
  5056. children: [
  5057. {
  5058. label: 'Base Color',
  5059. value: filledStyle.headBase,
  5060. input: 'color',
  5061. },
  5062. {
  5063. label: 'Contrast Method',
  5064. value: filledStyle.headContrast,
  5065. options: [..._types__WEBPACK_IMPORTED_MODULE_4__.CONTRAST_METHODS],
  5066. },
  5067. ],
  5068. },
  5069. {
  5070. label: 'Buttons',
  5071. children: [
  5072. {
  5073. label: 'Exit Color',
  5074. value: filledStyle.headButtonExit,
  5075. input: 'color',
  5076. },
  5077. {
  5078. label: 'Label Color',
  5079. value: filledStyle.headButtonLabel,
  5080. input: 'color',
  5081. },
  5082. {
  5083. label: 'Sticky Color',
  5084. value: filledStyle.headButtonSticky,
  5085. input: 'color',
  5086. },
  5087. {
  5088. label: 'Style Color',
  5089. value: filledStyle.headButtonStyle,
  5090. input: 'color',
  5091. },
  5092. {
  5093. label: 'Hide Color',
  5094. value: filledStyle.headButtonHide,
  5095. input: 'color',
  5096. },
  5097. {
  5098. label: 'Alt Buttons Color',
  5099. value: filledStyle.headButtonAlt,
  5100. input: 'color',
  5101. },
  5102. ],
  5103. },
  5104. ],
  5105. },
  5106. {
  5107. label: 'Body',
  5108. children: [
  5109. {
  5110. label: 'General',
  5111. children: [
  5112. {
  5113. label: 'Header Node Color',
  5114. value: _consts__WEBPACK_IMPORTED_MODULE_0__.DEFAULT_STYLE.nodeHeaderBase,
  5115. input: 'color',
  5116. },
  5117. {
  5118. label: 'Blend Node Color',
  5119. value: _consts__WEBPACK_IMPORTED_MODULE_0__.DEFAULT_STYLE.nodeBlendBase,
  5120. input: 'color',
  5121. },
  5122. {
  5123. label: 'Value Node Color',
  5124. value: _consts__WEBPACK_IMPORTED_MODULE_0__.DEFAULT_STYLE.nodeValueBase,
  5125. input: 'color',
  5126. },
  5127. {
  5128. label: 'Contrast Method',
  5129. value: filledStyle.nodeContrast,
  5130. options: [..._types__WEBPACK_IMPORTED_MODULE_4__.CONTRAST_METHODS],
  5131. },
  5132. ],
  5133. },
  5134. {
  5135. label: 'Buttons',
  5136. children: [
  5137. {
  5138. label: 'Create Color',
  5139. value: filledStyle.nodeButtonCreate,
  5140. input: 'color',
  5141. },
  5142. {
  5143. label: 'Duplicate Color',
  5144. value: filledStyle.nodeButtonDuplicate,
  5145. input: 'color',
  5146. },
  5147. {
  5148. label: 'Move Color',
  5149. value: filledStyle.nodeButtonMove,
  5150. input: 'color',
  5151. },
  5152. {
  5153. label: 'Disable Color',
  5154. value: filledStyle.nodeButtonDisable,
  5155. input: 'color',
  5156. },
  5157. {
  5158. label: 'Delete Color',
  5159. value: filledStyle.nodeButtonDelete,
  5160. input: 'color',
  5161. },
  5162. ],
  5163. },
  5164. {
  5165. label: 'Miscellaneous',
  5166. children: [
  5167. {
  5168. label: 'Valid Color',
  5169. value: filledStyle.validBackground,
  5170. input: 'color',
  5171. },
  5172. {
  5173. label: 'Invalid Color',
  5174. value: filledStyle.invalidBackground,
  5175. input: 'color',
  5176. },
  5177. {
  5178. label: 'Focus Color',
  5179. value: filledStyle.focusBackground,
  5180. input: 'color',
  5181. },
  5182. {
  5183. label: 'Tooltip Color',
  5184. value: filledStyle.borderTooltip,
  5185. input: 'color',
  5186. },
  5187. ],
  5188. },
  5189. ],
  5190. },
  5191. ],
  5192. };
  5193. }
  5194. function toRawStyle(json) {
  5195. const [, modal, header, body] = json.children.map(({ children }) => children);
  5196. const [headerGeneral, headerButtons] = header.map(({ children }) => children);
  5197. const [bodyGeneral, bodyButtons, bodyMisc] = body.map(({ children }) => children);
  5198. return {
  5199. width: modal[0].value,
  5200. height: modal[1].value,
  5201. fontSize: modal[2].value,
  5202. borderModal: modal[3].value,
  5203. headBase: headerGeneral[0].value,
  5204. headContrast: headerGeneral[1].value,
  5205. headButtonExit: headerButtons[0].value,
  5206. headButtonLabel: headerButtons[1].value,
  5207. headButtonSticky: headerButtons[2].value,
  5208. headButtonStyle: headerButtons[3].value,
  5209. headButtonHide: headerButtons[4].value,
  5210. headButtonAlt: headerButtons[5].value,
  5211. nodeHeaderBase: bodyGeneral[0].value,
  5212. nodeBlendBase: bodyGeneral[1].value,
  5213. nodeValueBase: bodyGeneral[2].value,
  5214. nodeContrast: bodyGeneral[3].value,
  5215. nodeButtonCreate: bodyButtons[0].value,
  5216. nodeButtonDuplicate: bodyButtons[1].value,
  5217. nodeButtonMove: bodyButtons[2].value,
  5218. nodeButtonDisable: bodyButtons[3].value,
  5219. nodeButtonDelete: bodyButtons[4].value,
  5220. validBackground: bodyMisc[0].value,
  5221. invalidBackground: bodyMisc[1].value,
  5222. focusBackground: bodyMisc[2].value,
  5223. borderTooltip: bodyMisc[3].value,
  5224. };
  5225. }
  5226. // For returning updated styles to the userscript
  5227. function getUserStyles() {
  5228. const { activeTree: { 'children': styleNodes } } = getRoot().getSaveData();
  5229. const styles = [];
  5230. for (const json of styleNodes) {
  5231. styles.push(Object.assign({ name: json.value, isActive: json.children[0].value }, toRawStyle(json)));
  5232. }
  5233. return styles;
  5234. }
  5235. function generate(userStyles, devStyle) {
  5236. (0,_css__WEBPACK_IMPORTED_MODULE_1__["default"])();
  5237. const defaultStyle = getFilledStyle(devStyle);
  5238. return (0,___WEBPACK_IMPORTED_MODULE_3__.generateTree)({
  5239. children: userStyles.map(toJSON),
  5240. seed: toJSON(Object.assign({ name: 'New Style', isActive: false }, defaultStyle)),
  5241. descendantPredicate: (styles) => {
  5242. let count = 0;
  5243. for (const { isActive, children: [{ value }] } of styles) {
  5244. if (isActive && value && ++count > 1) {
  5245. return 'Only one color scheme may be active at a time.';
  5246. }
  5247. }
  5248. return true;
  5249. },
  5250. onDescendantUpdate: (styles) => {
  5251. for (const style of styles) {
  5252. if (style.isActive && style.children[0].value) {
  5253. (0,_update__WEBPACK_IMPORTED_MODULE_2__["default"])(toRawStyle(style));
  5254. return;
  5255. }
  5256. }
  5257. (0,_update__WEBPACK_IMPORTED_MODULE_2__["default"])(defaultStyle);
  5258. },
  5259. }, _consts__WEBPACK_IMPORTED_MODULE_0__.ROOT_ID);
  5260. }
  5261.  
  5262.  
  5263. /***/ }),
  5264.  
  5265. /***/ "./ts/modal/body/style/update.ts":
  5266. /*!***************************************!*\
  5267. !*** ./ts/modal/body/style/update.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 */ updateStylesheet)
  5274. /* harmony export */ });
  5275. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  5276. var __rest = (undefined && undefined.__rest) || function (s, e) {
  5277. var t = {};
  5278. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  5279. t[p] = s[p];
  5280. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  5281. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
  5282. if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
  5283. t[p[i]] = s[p[i]];
  5284. }
  5285. return t;
  5286. };
  5287.  
  5288. const styleNode = document.createElement('style');
  5289. (0,_modal_css__WEBPACK_IMPORTED_MODULE_0__.registerStyleNode)(styleNode);
  5290. function getContrast(hex, method) {
  5291. const r = parseInt(hex.slice(1, 3), 16);
  5292. const g = parseInt(hex.slice(3, 5), 16);
  5293. const b = parseInt(hex.slice(5, 7), 16);
  5294. switch (method) {
  5295. case 'Black / White': {
  5296. // https://stackoverflow.com/a/3943023/112731
  5297. const luminosity = r * 0.299 + g * 0.587 + b * 0.114;
  5298. return luminosity > 145 ? 'black' : 'white';
  5299. }
  5300. }
  5301. const toHexPart = (rgb) => {
  5302. const x = (255 - rgb).toString(16);
  5303. return x.length === 2 ? x : `0${x}`;
  5304. };
  5305. return `#${toHexPart(r)}${toHexPart((g))}${toHexPart(b)}`;
  5306. }
  5307. function updateStylesheet(_a) {
  5308. var { fontSize, width, height, headContrast, nodeContrast } = _a, colours = __rest(_a, ["fontSize", "width", "height", "headContrast", "nodeContrast"]);
  5309. for (let i = styleNode.sheet.cssRules.length - 1; i >= 0; --i) {
  5310. styleNode.sheet.deleteRule(i);
  5311. }
  5312. const variables = Object.entries(colours).map(([property, value]) => [`--${property}`, value]);
  5313. variables.push(['--fontSize', `${fontSize}px`], ['--width', `${width}%`], ['--height', `${height}%`]);
  5314. variables.push(['--nodeHeaderContrast', getContrast(colours.nodeHeaderBase, nodeContrast)]);
  5315. variables.push(['--nodeBlendContrast', getContrast(colours.nodeBlendBase, nodeContrast)]);
  5316. variables.push(['--nodeValueContrast', getContrast(colours.nodeValueBase, nodeContrast)]);
  5317. variables.push(['--headContrast', getContrast(colours.headBase, headContrast)]);
  5318. (0,_modal_css__WEBPACK_IMPORTED_MODULE_0__.addVariables)(variables, styleNode);
  5319. }
  5320.  
  5321.  
  5322. /***/ }),
  5323.  
  5324. /***/ "./ts/modal/consts.ts":
  5325. /*!****************************!*\
  5326. !*** ./ts/modal/consts.ts ***!
  5327. \****************************/
  5328. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5329.  
  5330. __webpack_require__.r(__webpack_exports__);
  5331. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5332. /* harmony export */ BUTTON_ACTIVE_CLASS: () => (/* binding */ BUTTON_ACTIVE_CLASS),
  5333. /* harmony export */ MODAL_BACKGROUND_ID: () => (/* binding */ MODAL_BACKGROUND_ID),
  5334. /* harmony export */ MODAL_ID: () => (/* binding */ MODAL_ID),
  5335. /* harmony export */ NODE_HEIGHT: () => (/* binding */ NODE_HEIGHT),
  5336. /* harmony export */ SUB_PIXEL_BS: () => (/* binding */ SUB_PIXEL_BS),
  5337. /* harmony export */ SVG_NAMESPACE: () => (/* binding */ SVG_NAMESPACE)
  5338. /* harmony export */ });
  5339. const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
  5340. // Indicates 'on' state for actions that can be turned on and off
  5341. const BUTTON_ACTIVE_CLASS = 'active';
  5342. const MODAL_BACKGROUND_ID = 'modal-background';
  5343. const MODAL_ID = 'modal-content';
  5344. const SUB_PIXEL_BS = 1 / window.devicePixelRatio;
  5345. const NODE_HEIGHT = 1.6;
  5346.  
  5347.  
  5348. /***/ }),
  5349.  
  5350. /***/ "./ts/modal/css.ts":
  5351. /*!*************************!*\
  5352. !*** ./ts/modal/css.ts ***!
  5353. \*************************/
  5354. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5355.  
  5356. __webpack_require__.r(__webpack_exports__);
  5357. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5358. /* harmony export */ addRule: () => (/* binding */ addRule),
  5359. /* harmony export */ addVariables: () => (/* binding */ addVariables),
  5360. /* harmony export */ "default": () => (/* binding */ generate),
  5361. /* harmony export */ getRuleString: () => (/* binding */ getRuleString),
  5362. /* harmony export */ registerStyleNode: () => (/* binding */ registerStyleNode)
  5363. /* harmony export */ });
  5364. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/consts.ts");
  5365. /* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./index */ "./ts/modal/index.ts");
  5366.  
  5367.  
  5368. const styleNode = document.createElement('style');
  5369. const undockedStyleNodes = [styleNode];
  5370. function registerStyleNode(node) {
  5371. undockedStyleNodes.push(node);
  5372. }
  5373. function mountStyleNodes() {
  5374. const { head } = (0,_index__WEBPACK_IMPORTED_MODULE_1__.getDocument)();
  5375. for (const node of undockedStyleNodes) {
  5376. head.appendChild(node);
  5377. }
  5378. }
  5379. function isStyle(candidate) {
  5380. return candidate.length > 0 && typeof candidate[0] === 'string';
  5381. }
  5382. function getStyleString([property, value]) {
  5383. return `${property}:${value};`;
  5384. }
  5385. function getRuleStrings(styles) {
  5386. return isStyle(styles) ? getStyleString(styles) : styles.map(getStyleString).join('');
  5387. }
  5388. function getRuleString(selectors, styles) {
  5389. const styleString = getRuleStrings(styles);
  5390. const selectorString = typeof selectors === 'string' ? selectors : selectors.join(',');
  5391. return `${selectorString}{${styleString}}`;
  5392. }
  5393. function addRule(selectors, styles, { sheet } = styleNode) {
  5394. sheet.insertRule(getRuleString(selectors, styles));
  5395. }
  5396. function addVariables(rules, { sheet } = styleNode) {
  5397. const styleString = rules.map(getStyleString).join('');
  5398. sheet.insertRule(`:root{${styleString}}`);
  5399. }
  5400. function generate() {
  5401. mountStyleNodes();
  5402. addRule(`#${_consts__WEBPACK_IMPORTED_MODULE_0__.MODAL_BACKGROUND_ID}`, [
  5403. ['position', 'fixed'],
  5404. ['left', '0'],
  5405. ['top', '0'],
  5406. ['width', '100%'],
  5407. ['height', '100%'],
  5408. ['background-color', '#0003'],
  5409. ['display', 'flex'],
  5410. ['align-content', 'center'],
  5411. ['flex-wrap', 'wrap'],
  5412. ['justify-content', 'center'],
  5413. ]);
  5414. addRule(`#${_consts__WEBPACK_IMPORTED_MODULE_0__.MODAL_ID}`, [
  5415. ['width', 'var(--width)'],
  5416. ['height', 'var(--height)'],
  5417. ['font-size', 'var(--fontSize)'],
  5418. ['font-family', 'Tahoma, Geneva, sans-serif'],
  5419. ['outline', 'var(--borderModal) solid 2px'],
  5420. ['box-shadow', '1px 1px 10px 4px #00000015, 0 0 30px 10px #00000065'],
  5421. ['display', 'flex'],
  5422. ['flex-direction', 'column'],
  5423. ['position', 'relative'],
  5424. ]);
  5425. addRule('button', [
  5426. ['display', 'inline-flex'],
  5427. ['cursor', 'pointer'],
  5428. ['background', 'none'],
  5429. ['font-size', 'inherit'],
  5430. ['padding', '0'],
  5431. ['margin', '0'],
  5432. ['border', 'none'],
  5433. ['outline-offset', '-2px'],
  5434. ]);
  5435. addRule('button *', [['pointer-events', 'none']]);
  5436. addRule('svg', [['fill', 'none']]);
  5437. addRule('input', [
  5438. ['font', 'inherit'],
  5439. ['background', 'inherit'],
  5440. ['color', 'inherit'],
  5441. ['border', 'none'],
  5442. ]);
  5443. addRule(':focus-visible:not(button):not(input)', [['outline', 'none']]);
  5444. addRule('label', [['cursor', 'inherit']]);
  5445. }
  5446.  
  5447.  
  5448. /***/ }),
  5449.  
  5450. /***/ "./ts/modal/header/actions/alternate/button.ts":
  5451. /*!*****************************************************!*\
  5452. !*** ./ts/modal/header/actions/alternate/button.ts ***!
  5453. \*****************************************************/
  5454. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5455.  
  5456. __webpack_require__.r(__webpack_exports__);
  5457. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5458. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  5459. /* harmony export */ });
  5460. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/alternate/consts.ts");
  5461. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../button */ "./ts/modal/header/actions/button.ts");
  5462. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  5463.  
  5464.  
  5465.  
  5466. const ALPHA = Math.PI / 5;
  5467. const RADIUS = 46;
  5468. const points = [];
  5469. // https://stackoverflow.com/questions/14580033/algorithm-for-drawing-a-5-point-star
  5470. for (let i = 0; i < 12; ++i) {
  5471. const r = RADIUS * (i % 2 + 1) / 2;
  5472. const omega = ALPHA * i;
  5473. points.push([r * Math.sin(omega), r * Math.cos(omega)]);
  5474. }
  5475. const outline = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'path');
  5476. outline.setAttribute('stroke-linecap', 'round');
  5477. outline.setAttribute('stroke-width', '7');
  5478. outline.setAttribute('d', points.map(([x, y], i) => `${i === 0 ? 'M' : 'L'} ${x},${y}`).join());
  5479. const g = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'g');
  5480. g.append(outline);
  5481. const BUTTON = (0,_button__WEBPACK_IMPORTED_MODULE_1__.getNewButton)(g, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, 'Toggle Special Buttons');
  5482. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (BUTTON);
  5483.  
  5484.  
  5485. /***/ }),
  5486.  
  5487. /***/ "./ts/modal/header/actions/alternate/consts.ts":
  5488. /*!*****************************************************!*\
  5489. !*** ./ts/modal/header/actions/alternate/consts.ts ***!
  5490. \*****************************************************/
  5491. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5492.  
  5493. __webpack_require__.r(__webpack_exports__);
  5494. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5495. /* harmony export */ ACTION_ID: () => (/* binding */ ACTION_ID)
  5496. /* harmony export */ });
  5497. const ACTION_ID = 'modal-alt';
  5498.  
  5499.  
  5500. /***/ }),
  5501.  
  5502. /***/ "./ts/modal/header/actions/alternate/css.ts":
  5503. /*!**************************************************!*\
  5504. !*** ./ts/modal/header/actions/alternate/css.ts ***!
  5505. \**************************************************/
  5506. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5507.  
  5508. __webpack_require__.r(__webpack_exports__);
  5509. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5510. /* harmony export */ "default": () => (/* binding */ generate)
  5511. /* harmony export */ });
  5512. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/alternate/consts.ts");
  5513. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../css */ "./ts/modal/header/actions/css.ts");
  5514.  
  5515.  
  5516. function generate() {
  5517. (0,_css__WEBPACK_IMPORTED_MODULE_1__.addColourRule)(_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, '--headButtonAlt');
  5518. }
  5519.  
  5520.  
  5521. /***/ }),
  5522.  
  5523. /***/ "./ts/modal/header/actions/alternate/index.ts":
  5524. /*!****************************************************!*\
  5525. !*** ./ts/modal/header/actions/alternate/index.ts ***!
  5526. \****************************************************/
  5527. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5528.  
  5529. __webpack_require__.r(__webpack_exports__);
  5530. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5531. /* harmony export */ "default": () => (/* binding */ generate),
  5532. /* harmony export */ doAction: () => (/* binding */ doAction),
  5533. /* harmony export */ isActive: () => (/* binding */ isActive)
  5534. /* harmony export */ });
  5535. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./button */ "./ts/modal/header/actions/alternate/button.ts");
  5536. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/alternate/consts.ts");
  5537. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./css */ "./ts/modal/header/actions/alternate/css.ts");
  5538. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../button */ "./ts/modal/header/actions/button.ts");
  5539. /* harmony import */ var _modal_body__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/modal/body */ "./ts/modal/body/index.ts");
  5540. /* harmony import */ var _modal__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @/modal */ "./ts/modal/index.ts");
  5541.  
  5542.  
  5543.  
  5544.  
  5545.  
  5546.  
  5547. let _isActive = false;
  5548. let toggledOn = false;
  5549. function isActive() {
  5550. return _isActive;
  5551. }
  5552. function doAction(doActivate = !_isActive) {
  5553. (0,_modal_body__WEBPACK_IMPORTED_MODULE_4__.setActive)(_button__WEBPACK_IMPORTED_MODULE_0__["default"], _consts__WEBPACK_IMPORTED_MODULE_1__.ACTION_ID, doActivate);
  5554. _isActive = doActivate;
  5555. }
  5556. function generate() {
  5557. (0,_css__WEBPACK_IMPORTED_MODULE_2__["default"])();
  5558. (0,_button__WEBPACK_IMPORTED_MODULE_3__.bindAction)(_button__WEBPACK_IMPORTED_MODULE_0__["default"], () => {
  5559. toggledOn = !toggledOn;
  5560. doAction(toggledOn);
  5561. });
  5562. _button__WEBPACK_IMPORTED_MODULE_0__["default"].title += ' (Ctrl)';
  5563. const target = (0,_modal__WEBPACK_IMPORTED_MODULE_5__.getDocument)();
  5564. target.addEventListener('keydown', (event) => {
  5565. if (event.key === 'Control' && !toggledOn) {
  5566. doAction(true);
  5567. }
  5568. });
  5569. target.addEventListener('keyup', (event) => {
  5570. if (event.key === 'Control' && !toggledOn) {
  5571. doAction(false);
  5572. }
  5573. });
  5574. (0,_modal__WEBPACK_IMPORTED_MODULE_5__.getWindow)().addEventListener('blur', () => {
  5575. if (!toggledOn) {
  5576. doAction(false);
  5577. }
  5578. });
  5579. return _button__WEBPACK_IMPORTED_MODULE_0__["default"];
  5580. }
  5581.  
  5582.  
  5583. /***/ }),
  5584.  
  5585. /***/ "./ts/modal/header/actions/button.ts":
  5586. /*!*******************************************!*\
  5587. !*** ./ts/modal/header/actions/button.ts ***!
  5588. \*******************************************/
  5589. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5590.  
  5591. __webpack_require__.r(__webpack_exports__);
  5592. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5593. /* harmony export */ bindAction: () => (/* binding */ bindAction),
  5594. /* harmony export */ getNewButton: () => (/* binding */ getNewButton)
  5595. /* harmony export */ });
  5596. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/consts.ts");
  5597. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../consts */ "./ts/modal/consts.ts");
  5598. /* harmony import */ var _modal__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal */ "./ts/modal/index.ts");
  5599.  
  5600.  
  5601.  
  5602. // Adds the template to the DOM
  5603. function bindAction(button, doAction, hotkey) {
  5604. const bound = (event) => {
  5605. event.stopPropagation();
  5606. button.blur();
  5607. doAction();
  5608. };
  5609. button.addEventListener('click', bound);
  5610. if (hotkey) {
  5611. button.title += ` (Alt+${hotkey})`;
  5612. (0,_modal__WEBPACK_IMPORTED_MODULE_2__.getDocument)().addEventListener('keydown', (event) => {
  5613. if (event.altKey && event.key.toUpperCase() === hotkey) {
  5614. bound(event);
  5615. }
  5616. });
  5617. }
  5618. return bound;
  5619. }
  5620. // Creates a template
  5621. const getNewButton = (function () {
  5622. const buttonTemplate = document.createElement('button');
  5623. const svgTemplate = document.createElementNS(_consts__WEBPACK_IMPORTED_MODULE_1__.SVG_NAMESPACE, 'svg');
  5624. buttonTemplate.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS);
  5625. buttonTemplate.setAttribute('tabindex', '-1');
  5626. svgTemplate.setAttribute('viewBox', `-70 -70 140 140`);
  5627. return function (group, actionId, description) {
  5628. const button = buttonTemplate.cloneNode(true);
  5629. const svg = svgTemplate.cloneNode(true);
  5630. button.id = actionId;
  5631. button.title = description;
  5632. svg.append(group);
  5633. button.append(svg);
  5634. return button;
  5635. };
  5636. })();
  5637.  
  5638.  
  5639. /***/ }),
  5640.  
  5641. /***/ "./ts/modal/header/actions/close/button.ts":
  5642. /*!*************************************************!*\
  5643. !*** ./ts/modal/header/actions/close/button.ts ***!
  5644. \*************************************************/
  5645. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5646.  
  5647. __webpack_require__.r(__webpack_exports__);
  5648. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5649. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  5650. /* harmony export */ });
  5651. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/close/consts.ts");
  5652. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../button */ "./ts/modal/header/actions/button.ts");
  5653. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  5654.  
  5655.  
  5656.  
  5657. const line0 = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'line');
  5658. line0.setAttribute('stroke-linecap', 'round');
  5659. line0.setAttribute('stroke-width', '12');
  5660. line0.setAttribute('x1', '-30');
  5661. line0.setAttribute('x2', '30');
  5662. line0.setAttribute('y1', '-30');
  5663. line0.setAttribute('y2', '30');
  5664. const line1 = line0.cloneNode(true);
  5665. line1.setAttribute('transform', 'rotate(90 0 0)');
  5666. const g = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'g');
  5667. g.append(line0, line1);
  5668. const BUTTON = (0,_button__WEBPACK_IMPORTED_MODULE_1__.getNewButton)(g, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, 'Save & Exit');
  5669. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (BUTTON);
  5670.  
  5671.  
  5672. /***/ }),
  5673.  
  5674. /***/ "./ts/modal/header/actions/close/consts.ts":
  5675. /*!*************************************************!*\
  5676. !*** ./ts/modal/header/actions/close/consts.ts ***!
  5677. \*************************************************/
  5678. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5679.  
  5680. __webpack_require__.r(__webpack_exports__);
  5681. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5682. /* harmony export */ ACTION_ID: () => (/* binding */ ACTION_ID),
  5683. /* harmony export */ HOTKEY: () => (/* binding */ HOTKEY)
  5684. /* harmony export */ });
  5685. const ACTION_ID = 'modal-close';
  5686. const HOTKEY = 'X';
  5687.  
  5688.  
  5689. /***/ }),
  5690.  
  5691. /***/ "./ts/modal/header/actions/close/css.ts":
  5692. /*!**********************************************!*\
  5693. !*** ./ts/modal/header/actions/close/css.ts ***!
  5694. \**********************************************/
  5695. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5696.  
  5697. __webpack_require__.r(__webpack_exports__);
  5698. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5699. /* harmony export */ "default": () => (/* binding */ generate)
  5700. /* harmony export */ });
  5701. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/close/consts.ts");
  5702. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  5703.  
  5704.  
  5705. function generate() {
  5706. (0,_modal_css__WEBPACK_IMPORTED_MODULE_1__.addRule)([
  5707. `#${_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID}:focus > svg`,
  5708. `#${_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID}:hover > svg`,
  5709. ], ['background-color', 'var(--headButtonExit)']);
  5710. }
  5711.  
  5712.  
  5713. /***/ }),
  5714.  
  5715. /***/ "./ts/modal/header/actions/close/index.ts":
  5716. /*!************************************************!*\
  5717. !*** ./ts/modal/header/actions/close/index.ts ***!
  5718. \************************************************/
  5719. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5720.  
  5721. __webpack_require__.r(__webpack_exports__);
  5722. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5723. /* harmony export */ "default": () => (/* binding */ generate),
  5724. /* harmony export */ setCallback: () => (/* binding */ setCallback)
  5725. /* harmony export */ });
  5726. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./button */ "./ts/modal/header/actions/close/button.ts");
  5727. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/close/consts.ts");
  5728. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./css */ "./ts/modal/header/actions/close/css.ts");
  5729. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../button */ "./ts/modal/header/actions/button.ts");
  5730. /* harmony import */ var _modal_body_data__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/modal/body/data */ "./ts/modal/body/data/index.ts");
  5731. /* harmony import */ var _modal_body_style__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @/modal/body/style */ "./ts/modal/body/style/index.ts");
  5732. /* harmony import */ var _nodes_actions_buttons_position__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @nodes/actions/buttons/position */ "./ts/modal/body/nodes/actions/buttons/position/index.ts");
  5733. /* harmony import */ var _nodes_actions_highlight__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @nodes/actions/highlight */ "./ts/modal/body/nodes/actions/highlight/index.ts");
  5734.  
  5735.  
  5736.  
  5737.  
  5738.  
  5739.  
  5740.  
  5741.  
  5742. let callback;
  5743. function setCallback(_callback) {
  5744. callback = _callback;
  5745. }
  5746. // TODO Maybe add a white, 0.5 opacity foreground over everything with a loading symbol.
  5747. // Do the same when waiting for a config.
  5748. // Prevent interaction during loading by adding a stopPropagation click listener to the foreground.
  5749. function doAction() {
  5750. (0,_nodes_actions_buttons_position__WEBPACK_IMPORTED_MODULE_6__.reset)();
  5751. (0,_nodes_actions_highlight__WEBPACK_IMPORTED_MODULE_7__.reset)();
  5752. callback === null || callback === void 0 ? void 0 : callback(Object.assign(Object.assign({}, (0,_modal_body_data__WEBPACK_IMPORTED_MODULE_4__.getSaveData)()), { styles: (0,_modal_body_style__WEBPACK_IMPORTED_MODULE_5__.getUserStyles)() }));
  5753. callback = undefined;
  5754. }
  5755. function generate(background) {
  5756. (0,_css__WEBPACK_IMPORTED_MODULE_2__["default"])();
  5757. (0,_button__WEBPACK_IMPORTED_MODULE_3__.bindAction)(_button__WEBPACK_IMPORTED_MODULE_0__["default"], doAction, _consts__WEBPACK_IMPORTED_MODULE_1__.HOTKEY);
  5758. background.addEventListener('click', (event) => {
  5759. if (background.isSameNode(event.target)) {
  5760. doAction();
  5761. }
  5762. });
  5763. return _button__WEBPACK_IMPORTED_MODULE_0__["default"];
  5764. }
  5765.  
  5766.  
  5767. /***/ }),
  5768.  
  5769. /***/ "./ts/modal/header/actions/consts.ts":
  5770. /*!*******************************************!*\
  5771. !*** ./ts/modal/header/actions/consts.ts ***!
  5772. \*******************************************/
  5773. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5774.  
  5775. __webpack_require__.r(__webpack_exports__);
  5776. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5777. /* harmony export */ BUTTON_CLASS: () => (/* binding */ BUTTON_CLASS),
  5778. /* harmony export */ BUTTON_CONTAINER_ID: () => (/* binding */ BUTTON_CONTAINER_ID)
  5779. /* harmony export */ });
  5780. const BUTTON_CLASS = 'modal-button';
  5781. const BUTTON_CONTAINER_ID = 'modal-button-container';
  5782.  
  5783.  
  5784. /***/ }),
  5785.  
  5786. /***/ "./ts/modal/header/actions/css.ts":
  5787. /*!****************************************!*\
  5788. !*** ./ts/modal/header/actions/css.ts ***!
  5789. \****************************************/
  5790. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5791.  
  5792. __webpack_require__.r(__webpack_exports__);
  5793. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5794. /* harmony export */ addColourRule: () => (/* binding */ addColourRule),
  5795. /* harmony export */ "default": () => (/* binding */ generate)
  5796. /* harmony export */ });
  5797. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/consts.ts");
  5798. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../consts */ "./ts/modal/consts.ts");
  5799. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../css */ "./ts/modal/css.ts");
  5800.  
  5801.  
  5802.  
  5803. const ACTIVE_SELECTOR = `.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}.${_consts__WEBPACK_IMPORTED_MODULE_1__.BUTTON_ACTIVE_CLASS}`;
  5804. function addColourRule(actionId, colour) {
  5805. (0,_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`#${actionId}${ACTIVE_SELECTOR} > svg`, [['fill', `var(${colour})`]]);
  5806. (0,_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([`#${actionId}${ACTIVE_SELECTOR}:not(:hover):not(:focus) > svg`], [['stroke', `var(${colour})`]]);
  5807. }
  5808. function generate() {
  5809. (0,_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`#${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CONTAINER_ID}`, [
  5810. ['display', 'inline-flex'],
  5811. ['flex-direction', 'row-reverse'],
  5812. ['max-width', '80%'],
  5813. ['overflow-x', 'scroll'],
  5814. ['scrollbar-width', 'none'],
  5815. ['overscroll-behavior', 'contain'],
  5816. ['border-left', '2px solid var(--headContrast)'],
  5817. ]);
  5818. (0,_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([
  5819. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}:focus > svg`,
  5820. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}:hover > svg`,
  5821. `${ACTIVE_SELECTOR} > svg`,
  5822. ], ['background-color', `var(--headContrast)`]);
  5823. (0,_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}:not(:last-child)`, ['border-left', '2px solid var(--headContrast)']);
  5824. (0,_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([
  5825. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}:not(:first-child):focus`,
  5826. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}:not(:first-child):hover`,
  5827. `${ACTIVE_SELECTOR}:not(:first-child)`,
  5828. ], ['border-color', 'var(--headBase)']);
  5829. (0,_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([
  5830. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}:focus > svg`,
  5831. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}:hover > svg`,
  5832. ], ['stroke', `var(--headBase)`]);
  5833. (0,_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS} > svg`, [
  5834. ['width', '1.7em'],
  5835. ['stroke', 'var(--headContrast)'],
  5836. ['fill', `var(--headContrast)`],
  5837. // Fixes pixel gap between button border & svg
  5838. ['margin-left', '-0.5px'],
  5839. ]);
  5840. }
  5841.  
  5842.  
  5843. /***/ }),
  5844.  
  5845. /***/ "./ts/modal/header/actions/hide/button.ts":
  5846. /*!************************************************!*\
  5847. !*** ./ts/modal/header/actions/hide/button.ts ***!
  5848. \************************************************/
  5849. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5850.  
  5851. __webpack_require__.r(__webpack_exports__);
  5852. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5853. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  5854. /* harmony export */ });
  5855. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/hide/consts.ts");
  5856. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../button */ "./ts/modal/header/actions/button.ts");
  5857. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  5858.  
  5859.  
  5860.  
  5861. const edgeTop = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'path');
  5862. edgeTop.setAttribute('stroke-linecap', 'round');
  5863. edgeTop.setAttribute('stroke-width', '7');
  5864. edgeTop.setAttribute('d', 'M -55, 0'
  5865. + 'Q 0,60 55,0');
  5866. edgeTop.setAttribute('fill', 'none');
  5867. const edgeBottom = edgeTop.cloneNode(true);
  5868. edgeBottom.setAttribute('transform', 'scale(1,-1)');
  5869. const circle = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'circle');
  5870. circle.setAttribute('cx', '0');
  5871. circle.setAttribute('cy', '0');
  5872. circle.setAttribute('r', '26');
  5873. circle.setAttribute('stroke-width', '6');
  5874. const g = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'g');
  5875. g.append(edgeTop, edgeBottom, circle);
  5876. const BUTTON = (0,_button__WEBPACK_IMPORTED_MODULE_1__.getNewButton)(g, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, 'Toggle Disabled Node Visibility');
  5877. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (BUTTON);
  5878.  
  5879.  
  5880. /***/ }),
  5881.  
  5882. /***/ "./ts/modal/header/actions/hide/consts.ts":
  5883. /*!************************************************!*\
  5884. !*** ./ts/modal/header/actions/hide/consts.ts ***!
  5885. \************************************************/
  5886. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5887.  
  5888. __webpack_require__.r(__webpack_exports__);
  5889. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5890. /* harmony export */ ACTION_ID: () => (/* binding */ ACTION_ID),
  5891. /* harmony export */ HOTKEY: () => (/* binding */ HOTKEY)
  5892. /* harmony export */ });
  5893. const ACTION_ID = 'modal-hide';
  5894. const HOTKEY = 'H';
  5895.  
  5896.  
  5897. /***/ }),
  5898.  
  5899. /***/ "./ts/modal/header/actions/hide/css.ts":
  5900. /*!*********************************************!*\
  5901. !*** ./ts/modal/header/actions/hide/css.ts ***!
  5902. \*********************************************/
  5903. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5904.  
  5905. __webpack_require__.r(__webpack_exports__);
  5906. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5907. /* harmony export */ "default": () => (/* binding */ generate)
  5908. /* harmony export */ });
  5909. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/hide/consts.ts");
  5910. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../css */ "./ts/modal/header/actions/css.ts");
  5911. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  5912. /* harmony import */ var _modal_body_consts__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/modal/body/consts */ "./ts/modal/body/consts.ts");
  5913. /* harmony import */ var _nodes_actions_buttons_disable_consts__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @nodes/actions/buttons/disable/consts */ "./ts/modal/body/nodes/actions/buttons/disable/consts.ts");
  5914.  
  5915.  
  5916.  
  5917.  
  5918.  
  5919. function generate() {
  5920. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`#${_modal_body_consts__WEBPACK_IMPORTED_MODULE_3__.MODAL_BODY_ID}:not(.${_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID}) .${_nodes_actions_buttons_disable_consts__WEBPACK_IMPORTED_MODULE_4__.DISABLED_CLASS}`, ['display', 'none']);
  5921. (0,_css__WEBPACK_IMPORTED_MODULE_1__.addColourRule)(_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, '--headButtonHide');
  5922. }
  5923.  
  5924.  
  5925. /***/ }),
  5926.  
  5927. /***/ "./ts/modal/header/actions/hide/index.ts":
  5928. /*!***********************************************!*\
  5929. !*** ./ts/modal/header/actions/hide/index.ts ***!
  5930. \***********************************************/
  5931. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5932.  
  5933. __webpack_require__.r(__webpack_exports__);
  5934. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5935. /* harmony export */ "default": () => (/* binding */ generate)
  5936. /* harmony export */ });
  5937. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./button */ "./ts/modal/header/actions/hide/button.ts");
  5938. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/hide/consts.ts");
  5939. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./css */ "./ts/modal/header/actions/hide/css.ts");
  5940. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../button */ "./ts/modal/header/actions/button.ts");
  5941. /* harmony import */ var _modal_body__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/modal/body */ "./ts/modal/body/index.ts");
  5942.  
  5943.  
  5944.  
  5945.  
  5946.  
  5947. let isActive = false;
  5948. function doAction() {
  5949. isActive = !isActive;
  5950. (0,_modal_body__WEBPACK_IMPORTED_MODULE_4__.setActive)(_button__WEBPACK_IMPORTED_MODULE_0__["default"], _consts__WEBPACK_IMPORTED_MODULE_1__.ACTION_ID, isActive);
  5951. }
  5952. function generate() {
  5953. (0,_css__WEBPACK_IMPORTED_MODULE_2__["default"])();
  5954. (0,_button__WEBPACK_IMPORTED_MODULE_3__.bindAction)(_button__WEBPACK_IMPORTED_MODULE_0__["default"], doAction, _consts__WEBPACK_IMPORTED_MODULE_1__.HOTKEY);
  5955. _button__WEBPACK_IMPORTED_MODULE_0__["default"].click();
  5956. return _button__WEBPACK_IMPORTED_MODULE_0__["default"];
  5957. }
  5958.  
  5959.  
  5960. /***/ }),
  5961.  
  5962. /***/ "./ts/modal/header/actions/index.ts":
  5963. /*!******************************************!*\
  5964. !*** ./ts/modal/header/actions/index.ts ***!
  5965. \******************************************/
  5966. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5967.  
  5968. __webpack_require__.r(__webpack_exports__);
  5969. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5970. /* harmony export */ "default": () => (/* binding */ generate)
  5971. /* harmony export */ });
  5972. /* harmony import */ var _close__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./close */ "./ts/modal/header/actions/close/index.ts");
  5973. /* harmony import */ var _sticky__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./sticky */ "./ts/modal/header/actions/sticky/index.ts");
  5974. /* harmony import */ var _labels__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./labels */ "./ts/modal/header/actions/labels/index.ts");
  5975. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./style */ "./ts/modal/header/actions/style/index.ts");
  5976. /* harmony import */ var _hide__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./hide */ "./ts/modal/header/actions/hide/index.ts");
  5977. /* harmony import */ var _alternate__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./alternate */ "./ts/modal/header/actions/alternate/index.ts");
  5978. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./css */ "./ts/modal/header/actions/css.ts");
  5979. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/consts.ts");
  5980.  
  5981.  
  5982.  
  5983.  
  5984.  
  5985.  
  5986.  
  5987.  
  5988. function generate(background) {
  5989. (0,_css__WEBPACK_IMPORTED_MODULE_6__["default"])();
  5990. const element = document.createElement('span');
  5991. element.id = _consts__WEBPACK_IMPORTED_MODULE_7__.BUTTON_CONTAINER_ID;
  5992. element.append((0,_close__WEBPACK_IMPORTED_MODULE_0__["default"])(background), (0,_style__WEBPACK_IMPORTED_MODULE_3__["default"])(), (0,_sticky__WEBPACK_IMPORTED_MODULE_1__["default"])(), (0,_labels__WEBPACK_IMPORTED_MODULE_2__["default"])(), (0,_hide__WEBPACK_IMPORTED_MODULE_4__["default"])(), (0,_alternate__WEBPACK_IMPORTED_MODULE_5__["default"])());
  5993. return element;
  5994. }
  5995.  
  5996.  
  5997. /***/ }),
  5998.  
  5999. /***/ "./ts/modal/header/actions/labels/button.ts":
  6000. /*!**************************************************!*\
  6001. !*** ./ts/modal/header/actions/labels/button.ts ***!
  6002. \**************************************************/
  6003. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  6004.  
  6005. __webpack_require__.r(__webpack_exports__);
  6006. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6007. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  6008. /* harmony export */ });
  6009. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/labels/consts.ts");
  6010. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../button */ "./ts/modal/header/actions/button.ts");
  6011. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  6012.  
  6013.  
  6014.  
  6015. const outline = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'path');
  6016. outline.setAttribute('stroke-linecap', 'round');
  6017. outline.setAttribute('stroke-width', '7');
  6018. outline.setAttribute('d', 'M 20,-30'
  6019. + 'L -40,-30'
  6020. + 'L -40,30'
  6021. + 'L 20,30'
  6022. + 'L 50,0'
  6023. + 'L 20,-30');
  6024. const circle = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'circle');
  6025. circle.setAttribute('stroke-width', '5');
  6026. circle.setAttribute('r', '5');
  6027. circle.setAttribute('cx', '20');
  6028. circle.setAttribute('cy', '0');
  6029. const loop = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'path');
  6030. loop.setAttribute('fill', 'none');
  6031. loop.setAttribute('stroke-linecap', 'round');
  6032. loop.setAttribute('stroke-width', '6');
  6033. loop.setAttribute('d', 'M 20,0'
  6034. + 'C -70,50 -30,50 15,30');
  6035. const g = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'g');
  6036. g.setAttribute('transform', 'rotate(-60 0 0)');
  6037. g.append(outline, circle, loop);
  6038. const BUTTON = (0,_button__WEBPACK_IMPORTED_MODULE_1__.getNewButton)(g, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, 'Toggle Labels');
  6039. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (BUTTON);
  6040.  
  6041.  
  6042. /***/ }),
  6043.  
  6044. /***/ "./ts/modal/header/actions/labels/consts.ts":
  6045. /*!**************************************************!*\
  6046. !*** ./ts/modal/header/actions/labels/consts.ts ***!
  6047. \**************************************************/
  6048. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  6049.  
  6050. __webpack_require__.r(__webpack_exports__);
  6051. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6052. /* harmony export */ ACTION_ID: () => (/* binding */ ACTION_ID),
  6053. /* harmony export */ HOTKEY: () => (/* binding */ HOTKEY)
  6054. /* harmony export */ });
  6055. const ACTION_ID = 'modal-labels';
  6056. const HOTKEY = 'N';
  6057.  
  6058.  
  6059. /***/ }),
  6060.  
  6061. /***/ "./ts/modal/header/actions/labels/css.ts":
  6062. /*!***********************************************!*\
  6063. !*** ./ts/modal/header/actions/labels/css.ts ***!
  6064. \***********************************************/
  6065. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  6066.  
  6067. __webpack_require__.r(__webpack_exports__);
  6068. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6069. /* harmony export */ "default": () => (/* binding */ generate)
  6070. /* harmony export */ });
  6071. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/labels/consts.ts");
  6072. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../css */ "./ts/modal/header/actions/css.ts");
  6073. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  6074. /* harmony import */ var _modal_body_consts__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/modal/body/consts */ "./ts/modal/body/consts.ts");
  6075. /* harmony import */ var _nodes_consts__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @nodes/consts */ "./ts/modal/body/nodes/consts.ts");
  6076.  
  6077.  
  6078.  
  6079.  
  6080.  
  6081. function generate() {
  6082. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`#${_modal_body_consts__WEBPACK_IMPORTED_MODULE_3__.MODAL_BODY_ID}:not(.${_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID}) .${_nodes_consts__WEBPACK_IMPORTED_MODULE_4__.ELEMENT_CLASSES.LABEL_CONTAINER}`, ['display', 'none']);
  6083. (0,_css__WEBPACK_IMPORTED_MODULE_1__.addColourRule)(_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, '--headButtonLabel');
  6084. }
  6085.  
  6086.  
  6087. /***/ }),
  6088.  
  6089. /***/ "./ts/modal/header/actions/labels/index.ts":
  6090. /*!*************************************************!*\
  6091. !*** ./ts/modal/header/actions/labels/index.ts ***!
  6092. \*************************************************/
  6093. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  6094.  
  6095. __webpack_require__.r(__webpack_exports__);
  6096. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6097. /* harmony export */ "default": () => (/* binding */ generate)
  6098. /* harmony export */ });
  6099. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./button */ "./ts/modal/header/actions/labels/button.ts");
  6100. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/labels/consts.ts");
  6101. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./css */ "./ts/modal/header/actions/labels/css.ts");
  6102. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../button */ "./ts/modal/header/actions/button.ts");
  6103. /* harmony import */ var _modal_body__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/modal/body */ "./ts/modal/body/index.ts");
  6104.  
  6105.  
  6106.  
  6107.  
  6108.  
  6109. let isActive = false;
  6110. function doAction() {
  6111. isActive = !isActive;
  6112. (0,_modal_body__WEBPACK_IMPORTED_MODULE_4__.setActive)(_button__WEBPACK_IMPORTED_MODULE_0__["default"], _consts__WEBPACK_IMPORTED_MODULE_1__.ACTION_ID, isActive);
  6113. }
  6114. function generate() {
  6115. (0,_css__WEBPACK_IMPORTED_MODULE_2__["default"])();
  6116. (0,_button__WEBPACK_IMPORTED_MODULE_3__.bindAction)(_button__WEBPACK_IMPORTED_MODULE_0__["default"], doAction, _consts__WEBPACK_IMPORTED_MODULE_1__.HOTKEY);
  6117. _button__WEBPACK_IMPORTED_MODULE_0__["default"].click();
  6118. return _button__WEBPACK_IMPORTED_MODULE_0__["default"];
  6119. }
  6120.  
  6121.  
  6122. /***/ }),
  6123.  
  6124. /***/ "./ts/modal/header/actions/sticky/button.ts":
  6125. /*!**************************************************!*\
  6126. !*** ./ts/modal/header/actions/sticky/button.ts ***!
  6127. \**************************************************/
  6128. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  6129.  
  6130. __webpack_require__.r(__webpack_exports__);
  6131. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6132. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  6133. /* harmony export */ });
  6134. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/sticky/consts.ts");
  6135. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../button */ "./ts/modal/header/actions/button.ts");
  6136. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  6137.  
  6138.  
  6139.  
  6140. const handle = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'path');
  6141. const HANDLE_WIDTH = 50;
  6142. const CURVE_RADIUS = 10;
  6143. handle.setAttribute('stroke-width', '7');
  6144. handle.setAttribute('d', `M ${-HANDLE_WIDTH / 2} -40`
  6145. + `q 0 ${CURVE_RADIUS} ${CURVE_RADIUS} ${CURVE_RADIUS}`
  6146. + `q ${CURVE_RADIUS / 2} ${CURVE_RADIUS * 1.5} 0 ${CURVE_RADIUS * 3}`
  6147. + `q ${-CURVE_RADIUS} 0 ${-CURVE_RADIUS} ${CURVE_RADIUS}`
  6148. + `l ${HANDLE_WIDTH} 0`
  6149. + `q 0 ${-CURVE_RADIUS} ${-CURVE_RADIUS} ${-CURVE_RADIUS}`
  6150. + `q ${-CURVE_RADIUS / 2} ${-CURVE_RADIUS * 1.5} 0 ${-CURVE_RADIUS * 3}`
  6151. + `q ${CURVE_RADIUS} 0 ${CURVE_RADIUS} ${-CURVE_RADIUS}`
  6152. + 'Z');
  6153. const point = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'path');
  6154. point.setAttribute('fill', 'none');
  6155. point.setAttribute('stroke-width', '4');
  6156. point.setAttribute('d', 'M -2,-20'
  6157. + 'l 0 50'
  6158. + 'l 2 20'
  6159. + 'l 2 -20'
  6160. + 'l 0 -50Z');
  6161. const g = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'g');
  6162. g.append(point, handle);
  6163. const BUTTON = (0,_button__WEBPACK_IMPORTED_MODULE_1__.getNewButton)(g, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, 'Toggle Sticky');
  6164. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (BUTTON);
  6165.  
  6166.  
  6167. /***/ }),
  6168.  
  6169. /***/ "./ts/modal/header/actions/sticky/consts.ts":
  6170. /*!**************************************************!*\
  6171. !*** ./ts/modal/header/actions/sticky/consts.ts ***!
  6172. \**************************************************/
  6173. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  6174.  
  6175. __webpack_require__.r(__webpack_exports__);
  6176. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6177. /* harmony export */ ACTION_ID: () => (/* binding */ ACTION_ID),
  6178. /* harmony export */ HOTKEY: () => (/* binding */ HOTKEY)
  6179. /* harmony export */ });
  6180. const ACTION_ID = 'modal-sticky';
  6181. const HOTKEY = 'S';
  6182.  
  6183.  
  6184. /***/ }),
  6185.  
  6186. /***/ "./ts/modal/header/actions/sticky/css.ts":
  6187. /*!***********************************************!*\
  6188. !*** ./ts/modal/header/actions/sticky/css.ts ***!
  6189. \***********************************************/
  6190. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  6191.  
  6192. __webpack_require__.r(__webpack_exports__);
  6193. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6194. /* harmony export */ "default": () => (/* binding */ generate)
  6195. /* harmony export */ });
  6196. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/sticky/consts.ts");
  6197. /* harmony import */ var _style_consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../style/consts */ "./ts/modal/header/actions/style/consts.ts");
  6198. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../css */ "./ts/modal/header/actions/css.ts");
  6199. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  6200. /* harmony import */ var _modal_body_data_consts__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/modal/body/data/consts */ "./ts/modal/body/data/consts.ts");
  6201. /* harmony import */ var _modal_body_style_consts__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @/modal/body/style/consts */ "./ts/modal/body/style/consts.ts");
  6202. /* harmony import */ var _modal_body_consts__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @/modal/body/consts */ "./ts/modal/body/consts.ts");
  6203. /* harmony import */ var _nodes_consts__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @nodes/consts */ "./ts/modal/body/nodes/consts.ts");
  6204. /* harmony import */ var _nodes_actions_focus_consts__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @nodes/actions/focus/consts */ "./ts/modal/body/nodes/actions/focus/consts.ts");
  6205. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  6206.  
  6207.  
  6208.  
  6209.  
  6210.  
  6211.  
  6212.  
  6213.  
  6214.  
  6215.  
  6216. function _getHeight(node, pools, depth = 0) {
  6217. if ('poolId' in node) {
  6218. if (!pools[node.poolId]) {
  6219. pools[node.poolId] = [depth, 1];
  6220. }
  6221. else {
  6222. pools[node.poolId][0] = Math.max(pools[node.poolId][0], depth);
  6223. }
  6224. pools[node.poolId][1] = [...node.children, ...('seed' in node ? [node.seed] : [])]
  6225. .reduce((height, child) => Math.max(_getHeight(child, pools, 1), height), pools[node.poolId][1]);
  6226. return 0;
  6227. }
  6228. if ('seed' in node) {
  6229. return _getHeight(node.seed, pools, depth + 1);
  6230. }
  6231. if ('children' in node) {
  6232. return node.children.reduce((height, child) => Math.max(_getHeight(child, pools, depth + 1), height), depth + 1);
  6233. }
  6234. return depth;
  6235. }
  6236. function getHeight(node) {
  6237. const pools = [];
  6238. const height = _getHeight(node, pools);
  6239. return pools.reduce((max, [poolDepth, poolHeight]) => Math.max(max, poolDepth + poolHeight), height);
  6240. }
  6241. function generate(roots) {
  6242. const heights = {
  6243. [_modal_body_data_consts__WEBPACK_IMPORTED_MODULE_4__.ROOT_ID]: getHeight(roots[_modal_body_data_consts__WEBPACK_IMPORTED_MODULE_4__.ROOT_ID]),
  6244. [_modal_body_style_consts__WEBPACK_IMPORTED_MODULE_5__.ROOT_ID]: getHeight(roots[_modal_body_style_consts__WEBPACK_IMPORTED_MODULE_5__.ROOT_ID]),
  6245. };
  6246. const maxHeight = Math.max(heights[_modal_body_data_consts__WEBPACK_IMPORTED_MODULE_4__.ROOT_ID], heights[_modal_body_style_consts__WEBPACK_IMPORTED_MODULE_5__.ROOT_ID]);
  6247. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addVariables)([['--overlayIndex', `${maxHeight + 1}`]]);
  6248. (0,_css__WEBPACK_IMPORTED_MODULE_2__.addColourRule)(_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, '--headButtonSticky');
  6249. let nodeSelector = `#${_modal_body_consts__WEBPACK_IMPORTED_MODULE_6__.MODAL_BODY_ID}.${_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_7__.ELEMENT_CLASSES.ELEMENT_CONTAINER}`;
  6250. for (let depth = 0; depth <= maxHeight; ++depth) {
  6251. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`${nodeSelector} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_7__.ELEMENT_CLASSES.HEAD_CONTAINER}`, [
  6252. ['position', 'sticky'],
  6253. ['top', `calc(${depth * _modal_consts__WEBPACK_IMPORTED_MODULE_9__.NODE_HEIGHT}em + ${depth * _modal_consts__WEBPACK_IMPORTED_MODULE_9__.SUB_PIXEL_BS}px)`],
  6254. ['z-index', `${maxHeight - depth}`],
  6255. ]);
  6256. nodeSelector += ` > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_7__.ELEMENT_CLASSES.CHILD_CONTAINER} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_7__.ELEMENT_CLASSES.ELEMENT_CONTAINER}`;
  6257. }
  6258. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`#${_modal_body_consts__WEBPACK_IMPORTED_MODULE_6__.MODAL_BODY_ID}.${_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID}::after`, [
  6259. ['content', '\'\''],
  6260. ['display', 'block'],
  6261. ['visibility', 'hidden'],
  6262. ]);
  6263. const selectors = {
  6264. basic: {
  6265. [_modal_body_data_consts__WEBPACK_IMPORTED_MODULE_4__.ROOT_ID]: `#${_modal_body_consts__WEBPACK_IMPORTED_MODULE_6__.MODAL_BODY_ID}.${_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID}:has(> #${_modal_body_data_consts__WEBPACK_IMPORTED_MODULE_4__.ROOT_ID}:not(.${_nodes_actions_focus_consts__WEBPACK_IMPORTED_MODULE_8__.FOCUS_CLASS}) > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_7__.ELEMENT_CLASSES.CHILD_CONTAINER}`,
  6266. [_modal_body_style_consts__WEBPACK_IMPORTED_MODULE_5__.ROOT_ID]: `#${_modal_body_consts__WEBPACK_IMPORTED_MODULE_6__.MODAL_BODY_ID}.${_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID}.${_style_consts__WEBPACK_IMPORTED_MODULE_1__.ACTION_ID}:has(> #${_modal_body_style_consts__WEBPACK_IMPORTED_MODULE_5__.ROOT_ID}:not(.${_nodes_actions_focus_consts__WEBPACK_IMPORTED_MODULE_8__.FOCUS_CLASS}) > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_7__.ELEMENT_CLASSES.CHILD_CONTAINER}`,
  6267. },
  6268. focus: {
  6269. [_modal_body_data_consts__WEBPACK_IMPORTED_MODULE_4__.ROOT_ID]: `#${_modal_body_consts__WEBPACK_IMPORTED_MODULE_6__.MODAL_BODY_ID}.${_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID}:has(> #${_modal_body_data_consts__WEBPACK_IMPORTED_MODULE_4__.ROOT_ID}.${_nodes_actions_focus_consts__WEBPACK_IMPORTED_MODULE_8__.FOCUS_CLASS}`,
  6270. [_modal_body_style_consts__WEBPACK_IMPORTED_MODULE_5__.ROOT_ID]: `#${_modal_body_consts__WEBPACK_IMPORTED_MODULE_6__.MODAL_BODY_ID}.${_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID}.${_style_consts__WEBPACK_IMPORTED_MODULE_1__.ACTION_ID}:has(> #${_modal_body_style_consts__WEBPACK_IMPORTED_MODULE_5__.ROOT_ID}.${_nodes_actions_focus_consts__WEBPACK_IMPORTED_MODULE_8__.FOCUS_CLASS}`,
  6271. },
  6272. };
  6273. for (const [id, height] of Object.entries(heights)) {
  6274. for (let depth = 1; depth <= height + 1; ++depth) {
  6275. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`${selectors.basic[id]}:empty)::after`, ['height', `calc(100% - ${(depth) * _modal_consts__WEBPACK_IMPORTED_MODULE_9__.SUB_PIXEL_BS}px - ${depth * _modal_consts__WEBPACK_IMPORTED_MODULE_9__.NODE_HEIGHT}em)`]);
  6276. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`${selectors.focus[id]}.${_nodes_actions_focus_consts__WEBPACK_IMPORTED_MODULE_8__.FOCUS_SOURCE_CLASS})::after`, ['height', `calc(100% - ${(depth + 1) * _modal_consts__WEBPACK_IMPORTED_MODULE_9__.SUB_PIXEL_BS}px - ${(depth + 1) * _modal_consts__WEBPACK_IMPORTED_MODULE_9__.NODE_HEIGHT}em)`]);
  6277. selectors.basic[id] += ` > :last-child > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_7__.ELEMENT_CLASSES.CHILD_CONTAINER}`;
  6278. selectors.focus[id] += ` > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_7__.ELEMENT_CLASSES.CHILD_CONTAINER} > *`;
  6279. }
  6280. }
  6281. }
  6282.  
  6283.  
  6284. /***/ }),
  6285.  
  6286. /***/ "./ts/modal/header/actions/sticky/index.ts":
  6287. /*!*************************************************!*\
  6288. !*** ./ts/modal/header/actions/sticky/index.ts ***!
  6289. \*************************************************/
  6290. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  6291.  
  6292. __webpack_require__.r(__webpack_exports__);
  6293. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6294. /* harmony export */ "default": () => (/* binding */ generate),
  6295. /* harmony export */ isActive: () => (/* binding */ isActive)
  6296. /* harmony export */ });
  6297. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./button */ "./ts/modal/header/actions/sticky/button.ts");
  6298. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/sticky/consts.ts");
  6299. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../button */ "./ts/modal/header/actions/button.ts");
  6300. /* harmony import */ var _modal_body__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/modal/body */ "./ts/modal/body/index.ts");
  6301.  
  6302.  
  6303.  
  6304.  
  6305. let _isActive = false;
  6306. function isActive() {
  6307. return _isActive;
  6308. }
  6309. function doAction() {
  6310. _isActive = !_isActive;
  6311. (0,_modal_body__WEBPACK_IMPORTED_MODULE_3__.setActive)(_button__WEBPACK_IMPORTED_MODULE_0__["default"], _consts__WEBPACK_IMPORTED_MODULE_1__.ACTION_ID, _isActive);
  6312. }
  6313. function generate() {
  6314. (0,_button__WEBPACK_IMPORTED_MODULE_2__.bindAction)(_button__WEBPACK_IMPORTED_MODULE_0__["default"], doAction, _consts__WEBPACK_IMPORTED_MODULE_1__.HOTKEY);
  6315. _button__WEBPACK_IMPORTED_MODULE_0__["default"].click();
  6316. return _button__WEBPACK_IMPORTED_MODULE_0__["default"];
  6317. }
  6318.  
  6319.  
  6320. /***/ }),
  6321.  
  6322. /***/ "./ts/modal/header/actions/style/button.ts":
  6323. /*!*************************************************!*\
  6324. !*** ./ts/modal/header/actions/style/button.ts ***!
  6325. \*************************************************/
  6326. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  6327.  
  6328. __webpack_require__.r(__webpack_exports__);
  6329. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6330. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  6331. /* harmony export */ });
  6332. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/style/consts.ts");
  6333. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../button */ "./ts/modal/header/actions/button.ts");
  6334. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  6335.  
  6336.  
  6337.  
  6338. const handle = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'rect');
  6339. handle.setAttribute('stroke-linecap', 'round');
  6340. handle.setAttribute('stroke-width', '6');
  6341. handle.setAttribute('x', '-5');
  6342. handle.setAttribute('y', '15');
  6343. handle.setAttribute('width', '15');
  6344. handle.setAttribute('height', '40');
  6345. handle.setAttribute('rx', '5');
  6346. const frame = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'path');
  6347. frame.setAttribute('fill', 'none');
  6348. frame.setAttribute('stroke-linecap', 'round');
  6349. frame.setAttribute('stroke-width', '3');
  6350. frame.setAttribute('d', 'M 2.5,15'
  6351. + 'L 2.5,0'
  6352. + 'L -36,-15'
  6353. + 'L -36,-35'
  6354. + 'L -30,-35');
  6355. const curveLeft = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'path');
  6356. curveLeft.setAttribute('fill', 'none');
  6357. curveLeft.setAttribute('stroke-linecap', 'round');
  6358. curveLeft.setAttribute('stroke-width', '6');
  6359. curveLeft.setAttribute('d', 'M -25 -30'
  6360. + 'Q -30,-35 -25,-40');
  6361. const curveRight = curveLeft.cloneNode(true);
  6362. curveRight.setAttribute('transform', 'scale(-1,1) translate(-10,0)');
  6363. const roller = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'rect');
  6364. roller.setAttribute('stroke-linecap', 'round');
  6365. roller.setAttribute('stroke-width', '6');
  6366. roller.setAttribute('x', '-22.5');
  6367. roller.setAttribute('y', '-47.5');
  6368. roller.setAttribute('width', '55');
  6369. roller.setAttribute('height', '25');
  6370. roller.setAttribute('rx', '1');
  6371. const g = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'g');
  6372. g.append(handle, frame, curveLeft, curveRight, roller);
  6373. const BUTTON = (0,_button__WEBPACK_IMPORTED_MODULE_1__.getNewButton)(g, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, 'Toggle Style Editor');
  6374. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (BUTTON);
  6375.  
  6376.  
  6377. /***/ }),
  6378.  
  6379. /***/ "./ts/modal/header/actions/style/consts.ts":
  6380. /*!*************************************************!*\
  6381. !*** ./ts/modal/header/actions/style/consts.ts ***!
  6382. \*************************************************/
  6383. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  6384.  
  6385. __webpack_require__.r(__webpack_exports__);
  6386. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6387. /* harmony export */ ACTION_ID: () => (/* binding */ ACTION_ID),
  6388. /* harmony export */ HOTKEY: () => (/* binding */ HOTKEY)
  6389. /* harmony export */ });
  6390. const ACTION_ID = 'modal-style';
  6391. const HOTKEY = 'C';
  6392.  
  6393.  
  6394. /***/ }),
  6395.  
  6396. /***/ "./ts/modal/header/actions/style/css.ts":
  6397. /*!**********************************************!*\
  6398. !*** ./ts/modal/header/actions/style/css.ts ***!
  6399. \**********************************************/
  6400. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  6401.  
  6402. __webpack_require__.r(__webpack_exports__);
  6403. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6404. /* harmony export */ "default": () => (/* binding */ generate)
  6405. /* harmony export */ });
  6406. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/style/consts.ts");
  6407. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../css */ "./ts/modal/header/actions/css.ts");
  6408.  
  6409.  
  6410. function generate() {
  6411. (0,_css__WEBPACK_IMPORTED_MODULE_1__.addColourRule)(_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, '--headButtonStyle');
  6412. }
  6413.  
  6414.  
  6415. /***/ }),
  6416.  
  6417. /***/ "./ts/modal/header/actions/style/index.ts":
  6418. /*!************************************************!*\
  6419. !*** ./ts/modal/header/actions/style/index.ts ***!
  6420. \************************************************/
  6421. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  6422.  
  6423. __webpack_require__.r(__webpack_exports__);
  6424. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6425. /* harmony export */ "default": () => (/* binding */ generate)
  6426. /* harmony export */ });
  6427. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./button */ "./ts/modal/header/actions/style/button.ts");
  6428. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/style/consts.ts");
  6429. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./css */ "./ts/modal/header/actions/style/css.ts");
  6430. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../button */ "./ts/modal/header/actions/button.ts");
  6431. /* harmony import */ var _modal_body__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/modal/body */ "./ts/modal/body/index.ts");
  6432. /* harmony import */ var _nodes_actions_focus__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @nodes/actions/focus */ "./ts/modal/body/nodes/actions/focus/index.ts");
  6433. /* harmony import */ var _nodes_actions_buttons_position__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @nodes/actions/buttons/position */ "./ts/modal/body/nodes/actions/buttons/position/index.ts");
  6434.  
  6435.  
  6436.  
  6437.  
  6438.  
  6439.  
  6440.  
  6441. let isActive = false;
  6442. function doAction() {
  6443. isActive = !isActive;
  6444. (0,_modal_body__WEBPACK_IMPORTED_MODULE_4__.setActive)(_button__WEBPACK_IMPORTED_MODULE_0__["default"], _consts__WEBPACK_IMPORTED_MODULE_1__.ACTION_ID, isActive);
  6445. _modal_body__WEBPACK_IMPORTED_MODULE_4__.element.scrollTop = 0;
  6446. (0,_nodes_actions_focus__WEBPACK_IMPORTED_MODULE_5__.reset)();
  6447. (0,_nodes_actions_buttons_position__WEBPACK_IMPORTED_MODULE_6__.reset)();
  6448. // Reset tab index & highlight
  6449. _modal_body__WEBPACK_IMPORTED_MODULE_4__.element.focus();
  6450. }
  6451. function generate() {
  6452. (0,_css__WEBPACK_IMPORTED_MODULE_2__["default"])();
  6453. (0,_button__WEBPACK_IMPORTED_MODULE_3__.bindAction)(_button__WEBPACK_IMPORTED_MODULE_0__["default"], doAction, _consts__WEBPACK_IMPORTED_MODULE_1__.HOTKEY);
  6454. return _button__WEBPACK_IMPORTED_MODULE_0__["default"];
  6455. }
  6456.  
  6457.  
  6458. /***/ }),
  6459.  
  6460. /***/ "./ts/modal/header/consts.ts":
  6461. /*!***********************************!*\
  6462. !*** ./ts/modal/header/consts.ts ***!
  6463. \***********************************/
  6464. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  6465.  
  6466. __webpack_require__.r(__webpack_exports__);
  6467. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6468. /* harmony export */ HEADER_ID: () => (/* binding */ HEADER_ID)
  6469. /* harmony export */ });
  6470. const HEADER_ID = 'modal-header';
  6471.  
  6472.  
  6473. /***/ }),
  6474.  
  6475. /***/ "./ts/modal/header/css.ts":
  6476. /*!********************************!*\
  6477. !*** ./ts/modal/header/css.ts ***!
  6478. \********************************/
  6479. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  6480.  
  6481. __webpack_require__.r(__webpack_exports__);
  6482. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6483. /* harmony export */ "default": () => (/* binding */ generate)
  6484. /* harmony export */ });
  6485. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/consts.ts");
  6486. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../css */ "./ts/modal/css.ts");
  6487.  
  6488.  
  6489. function generate() {
  6490. (0,_css__WEBPACK_IMPORTED_MODULE_1__.addRule)(`#${_consts__WEBPACK_IMPORTED_MODULE_0__.HEADER_ID}`, [
  6491. ['display', 'flex'],
  6492. ['align-items', 'center'],
  6493. ['background-color', 'var(--headBase)'],
  6494. ['color', 'var(--headContrast)'],
  6495. ['border-bottom', '2px solid var(--borderModal)'],
  6496. ['font-size', '1.5em'],
  6497. ['text-align', 'center'],
  6498. ]);
  6499. }
  6500.  
  6501.  
  6502. /***/ }),
  6503.  
  6504. /***/ "./ts/modal/header/index.ts":
  6505. /*!**********************************!*\
  6506. !*** ./ts/modal/header/index.ts ***!
  6507. \**********************************/
  6508. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  6509.  
  6510. __webpack_require__.r(__webpack_exports__);
  6511. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6512. /* harmony export */ "default": () => (/* binding */ generate)
  6513. /* harmony export */ });
  6514. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/consts.ts");
  6515. /* harmony import */ var _title__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./title */ "./ts/modal/header/title/index.ts");
  6516. /* harmony import */ var _actions__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./actions */ "./ts/modal/header/actions/index.ts");
  6517. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./css */ "./ts/modal/header/css.ts");
  6518.  
  6519.  
  6520.  
  6521.  
  6522. function generate({ title }, background) {
  6523. (0,_css__WEBPACK_IMPORTED_MODULE_3__["default"])();
  6524. const element = document.createElement('div');
  6525. element.id = _consts__WEBPACK_IMPORTED_MODULE_0__.HEADER_ID;
  6526. element.append((0,_title__WEBPACK_IMPORTED_MODULE_1__["default"])(title), (0,_actions__WEBPACK_IMPORTED_MODULE_2__["default"])(background));
  6527. return element;
  6528. }
  6529.  
  6530.  
  6531. /***/ }),
  6532.  
  6533. /***/ "./ts/modal/header/title/consts.ts":
  6534. /*!*****************************************!*\
  6535. !*** ./ts/modal/header/title/consts.ts ***!
  6536. \*****************************************/
  6537. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  6538.  
  6539. __webpack_require__.r(__webpack_exports__);
  6540. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6541. /* harmony export */ TITLE_CONTAINER_ID: () => (/* binding */ TITLE_CONTAINER_ID),
  6542. /* harmony export */ TITLE_ID: () => (/* binding */ TITLE_ID)
  6543. /* harmony export */ });
  6544. const TITLE_CONTAINER_ID = 'title-container';
  6545. const TITLE_ID = 'title';
  6546.  
  6547.  
  6548. /***/ }),
  6549.  
  6550. /***/ "./ts/modal/header/title/css.ts":
  6551. /*!**************************************!*\
  6552. !*** ./ts/modal/header/title/css.ts ***!
  6553. \**************************************/
  6554. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  6555.  
  6556. __webpack_require__.r(__webpack_exports__);
  6557. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6558. /* harmony export */ "default": () => (/* binding */ generate)
  6559. /* harmony export */ });
  6560. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/title/consts.ts");
  6561. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../css */ "./ts/modal/css.ts");
  6562.  
  6563.  
  6564. function generate() {
  6565. (0,_css__WEBPACK_IMPORTED_MODULE_1__.addRule)(`#${_consts__WEBPACK_IMPORTED_MODULE_0__.TITLE_CONTAINER_ID}`, [
  6566. ['flex-grow', '1'],
  6567. ['white-space', 'nowrap'],
  6568. ['overflow', 'hidden'],
  6569. ['text-overflow', 'ellipsis'],
  6570. ['padding', '0 0.5em'],
  6571. ]);
  6572. }
  6573.  
  6574.  
  6575. /***/ }),
  6576.  
  6577. /***/ "./ts/modal/header/title/index.ts":
  6578. /*!****************************************!*\
  6579. !*** ./ts/modal/header/title/index.ts ***!
  6580. \****************************************/
  6581. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  6582.  
  6583. __webpack_require__.r(__webpack_exports__);
  6584. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6585. /* harmony export */ "default": () => (/* binding */ generate)
  6586. /* harmony export */ });
  6587. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/title/consts.ts");
  6588. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./css */ "./ts/modal/header/title/css.ts");
  6589.  
  6590.  
  6591. function generate(title) {
  6592. (0,_css__WEBPACK_IMPORTED_MODULE_1__["default"])();
  6593. const titleContainer = document.createElement('span');
  6594. const titleElement = document.createElement('span');
  6595. titleContainer.id = _consts__WEBPACK_IMPORTED_MODULE_0__.TITLE_CONTAINER_ID;
  6596. titleElement.id = _consts__WEBPACK_IMPORTED_MODULE_0__.TITLE_ID;
  6597. titleElement.innerText = title;
  6598. // In case the text is too long to fit
  6599. titleElement.title = title;
  6600. titleContainer.append(titleElement);
  6601. return titleContainer;
  6602. }
  6603.  
  6604.  
  6605. /***/ }),
  6606.  
  6607. /***/ "./ts/modal/index.ts":
  6608. /*!***************************!*\
  6609. !*** ./ts/modal/index.ts ***!
  6610. \***************************/
  6611. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  6612.  
  6613. __webpack_require__.r(__webpack_exports__);
  6614. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6615. /* harmony export */ "default": () => (/* binding */ generate),
  6616. /* harmony export */ getDocument: () => (/* binding */ getDocument),
  6617. /* harmony export */ getSocket: () => (/* binding */ getSocket),
  6618. /* harmony export */ getWindow: () => (/* binding */ getWindow)
  6619. /* harmony export */ });
  6620. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/consts.ts");
  6621. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./css */ "./ts/modal/css.ts");
  6622. /* harmony import */ var _header__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./header */ "./ts/modal/header/index.ts");
  6623. /* harmony import */ var _body__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./body */ "./ts/modal/body/index.ts");
  6624. /* harmony import */ var _nodes_actions_highlight__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @nodes/actions/highlight */ "./ts/modal/body/nodes/actions/highlight/index.ts");
  6625.  
  6626.  
  6627.  
  6628.  
  6629.  
  6630. let socket;
  6631. let ownerDocument;
  6632. let ownerWindow;
  6633. function getSocket() {
  6634. return socket;
  6635. }
  6636. function getDocument() {
  6637. return ownerDocument;
  6638. }
  6639. function getWindow() {
  6640. return ownerWindow;
  6641. }
  6642. function generate(config, _socket, _window) {
  6643. socket = _socket;
  6644. ownerDocument = socket.ownerDocument;
  6645. ownerWindow = _window;
  6646. (0,_css__WEBPACK_IMPORTED_MODULE_1__["default"])();
  6647. const background = document.createElement('div');
  6648. const foreground = document.createElement('div');
  6649. background.id = _consts__WEBPACK_IMPORTED_MODULE_0__.MODAL_BACKGROUND_ID;
  6650. foreground.id = _consts__WEBPACK_IMPORTED_MODULE_0__.MODAL_ID;
  6651. background.append(foreground);
  6652. socket.append(background);
  6653. foreground.append((0,_header__WEBPACK_IMPORTED_MODULE_2__["default"])(config, background), (0,_body__WEBPACK_IMPORTED_MODULE_3__["default"])(config), (0,_nodes_actions_highlight__WEBPACK_IMPORTED_MODULE_4__.generateEave)(socket));
  6654. }
  6655.  
  6656.  
  6657. /***/ }),
  6658.  
  6659. /***/ "./ts/predicate.ts":
  6660. /*!*************************!*\
  6661. !*** ./ts/predicate.ts ***!
  6662. \*************************/
  6663. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  6664.  
  6665. __webpack_require__.r(__webpack_exports__);
  6666. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6667. /* harmony export */ getPredicatePromise: () => (/* binding */ getPredicatePromise),
  6668. /* harmony export */ isUnresolved: () => (/* binding */ isUnresolved)
  6669. /* harmony export */ });
  6670. var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
  6671. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  6672. return new (P || (P = Promise))(function (resolve, reject) {
  6673. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  6674. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  6675. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  6676. step((generator = generator.apply(thisArg, _arguments || [])).next());
  6677. });
  6678. };
  6679. let count = 0;
  6680. function isUnresolved() {
  6681. return count > 0;
  6682. }
  6683. function getPredicatePromise(_response) {
  6684. return __awaiter(this, void 0, void 0, function* () {
  6685. count++;
  6686. try {
  6687. const response = yield _response;
  6688. count--;
  6689. return typeof response === 'string' ? Promise.reject(response) : Promise[response ? 'resolve' : 'reject']();
  6690. }
  6691. catch (response) {
  6692. count--;
  6693. if (response instanceof Error) {
  6694. return Promise.reject(response.message);
  6695. }
  6696. return Promise.reject(typeof response === 'string' ? response : undefined);
  6697. }
  6698. });
  6699. }
  6700.  
  6701.  
  6702. /***/ })
  6703.  
  6704. /******/ });
  6705. /************************************************************************/
  6706. /******/ // The module cache
  6707. /******/ var __webpack_module_cache__ = {};
  6708. /******/
  6709. /******/ // The require function
  6710. /******/ function __webpack_require__(moduleId) {
  6711. /******/ // Check if module is in cache
  6712. /******/ var cachedModule = __webpack_module_cache__[moduleId];
  6713. /******/ if (cachedModule !== undefined) {
  6714. /******/ return cachedModule.exports;
  6715. /******/ }
  6716. /******/ // Create a new module (and put it into the cache)
  6717. /******/ var module = __webpack_module_cache__[moduleId] = {
  6718. /******/ // no module.id needed
  6719. /******/ // no module.loaded needed
  6720. /******/ exports: {}
  6721. /******/ };
  6722. /******/
  6723. /******/ // Execute the module function
  6724. /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
  6725. /******/
  6726. /******/ // Return the exports of the module
  6727. /******/ return module.exports;
  6728. /******/ }
  6729. /******/
  6730. /************************************************************************/
  6731. /******/ /* webpack/runtime/define property getters */
  6732. /******/ (() => {
  6733. /******/ // define getter functions for harmony exports
  6734. /******/ __webpack_require__.d = (exports, definition) => {
  6735. /******/ for(var key in definition) {
  6736. /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  6737. /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
  6738. /******/ }
  6739. /******/ }
  6740. /******/ };
  6741. /******/ })();
  6742. /******/
  6743. /******/ /* webpack/runtime/hasOwnProperty shorthand */
  6744. /******/ (() => {
  6745. /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
  6746. /******/ })();
  6747. /******/
  6748. /******/ /* webpack/runtime/make namespace object */
  6749. /******/ (() => {
  6750. /******/ // define __esModule on exports
  6751. /******/ __webpack_require__.r = (exports) => {
  6752. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  6753. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  6754. /******/ }
  6755. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  6756. /******/ };
  6757. /******/ })();
  6758. /******/
  6759. /************************************************************************/
  6760. var __webpack_exports__ = {};
  6761. // This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk.
  6762. (() => {
  6763. /*!*******************************!*\
  6764. !*** ./ts/library/$Config.js ***!
  6765. \*******************************/
  6766. __webpack_require__.r(__webpack_exports__);
  6767. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6768. /* harmony export */ "default": () => (/* binding */ $Config)
  6769. /* harmony export */ });
  6770. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../consts */ "./ts/consts.ts");
  6771. /* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./index */ "./ts/library/index.ts");
  6772. /* harmony import */ var _modal_body__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../modal/body */ "./ts/modal/body/index.ts");
  6773.  
  6774.  
  6775.  
  6776.  
  6777.  
  6778. const VERSION = 1;
  6779.  
  6780. const KEY_VERSION = 'TREE_FRAME_VERSION';
  6781.  
  6782. const KEY_STYLES = 'TREE_FRAME_USER_STYLES';
  6783.  
  6784. const STYLE_OUTER = {
  6785. position: 'fixed',
  6786. height: '100vh',
  6787. width: '100vw',
  6788. };
  6789.  
  6790. class $Config {
  6791. constructor(KEY_TREE, TREE_DEFAULT, STYLE_INNER = {}, _STYLE_OUTER = {}) {
  6792. // PERMISSION CHECKS
  6793. const getError = (reason, error) => {
  6794. const message = `[${GM.info.script.name}]${reason.includes('\n') ? '\n\n' : ' '}${reason}`;
  6795. if (error) {
  6796. error.message = message;
  6797. return error;
  6798. }
  6799. return new Error(message);
  6800. };
  6801. if (typeof GM.getValue !== 'function') {
  6802. throw getError('Missing GM.getValue permission.');
  6803. }
  6804. if (typeof GM.setValue !== 'function') {
  6805. throw getError('Missing GM.setValue permission.');
  6806. }
  6807. if (typeof KEY_TREE !== 'string' || !(/^[a-z_][a-z0-9_]*$/i.test(KEY_TREE))) {
  6808. throw getError(`'${KEY_TREE}' is not a valid storage key.`);
  6809. }
  6810. // PRIVATE
  6811. const styleOuter = {
  6812. ...STYLE_OUTER,
  6813. ..._STYLE_OUTER,
  6814. };
  6815. const target = (() => {
  6816. let targetWindow = window;
  6817. while (targetWindow.frameElement) {
  6818. targetWindow = window.parent;
  6819. }
  6820. const id = `${_consts__WEBPACK_IMPORTED_MODULE_0__.SOCKET_ID}-${KEY_TREE}`;
  6821. for (const child of targetWindow.document.body.children) {
  6822. if (child.id === id) {
  6823. child.remove();
  6824. break;
  6825. }
  6826. }
  6827. const target = document.createElement('iframe');
  6828. target.id = id;
  6829. for (const [property, value] of Object.entries(styleOuter)) {
  6830. target.style[property] = value;
  6831. }
  6832. target.style.display = 'none';
  6833. targetWindow.document.body.appendChild(target);
  6834. return target;
  6835. })();
  6836. let isOpen = false;
  6837. const open = (doOpen = true) => new Promise((resolve) => {
  6838. isOpen = doOpen;
  6839. target.style.display = doOpen ? (styleOuter.display ?? 'initial') : 'none';
  6840. // Delay script execution until visual update
  6841. setTimeout(resolve, 0);
  6842. });
  6843. const disconnect = () => new Promise((resolve) => {
  6844. isOpen = false;
  6845. target.remove();
  6846. // Delay script execution until visual update
  6847. setTimeout(resolve, 0);
  6848. });
  6849. // PUBLIC
  6850. this.ready = Promise.all([
  6851. GM.getValue(KEY_TREE),
  6852. GM.getValue(KEY_STYLES, []),
  6853. GM.getValue(KEY_VERSION, -1),
  6854. ])
  6855. // Retrieve data
  6856. .then(([userTree, userStyles, version]) => {
  6857. // Patch to current version
  6858. (() => {
  6859. if (!userTree) {
  6860. return;
  6861. }
  6862. switch (version) {
  6863. case -1: {
  6864. const patch = (node) => {
  6865. delete node.predicate;
  6866. delete node.childPredicate;
  6867. delete node.descendantPredicate;
  6868. delete node.seed;
  6869. if ('children' in node) {
  6870. for (const child of node.children) {
  6871. patch(child);
  6872. }
  6873. }
  6874. };
  6875. patch(userTree);
  6876. }
  6877. // eslint-disable-next-line no-fallthrough
  6878. case 0: {
  6879. const patch = (node) => {
  6880. delete node.input;
  6881. if ('children' in node) {
  6882. for (const child of node.children) {
  6883. patch(child);
  6884. }
  6885. }
  6886. };
  6887. patch(userTree);
  6888. }
  6889. }
  6890. })();
  6891. /**
  6892. * @name $Config#reset
  6893. * @description Deletes the user's data.
  6894. * @returns {Promise<void>} Resolves upon completing the deletion.
  6895. */
  6896. this.reset = async () => {
  6897. if (isOpen) {
  6898. throw getError('Cannot reset while the UI is open.');
  6899. }
  6900. if (typeof GM.deleteValue !== 'function') {
  6901. throw getError('Missing GM.deleteValue permission.');
  6902. }
  6903. await GM.deleteValue(KEY_TREE);
  6904. // It may have previously been a rejected promise
  6905. this.ready = () => Promise.resolve();
  6906. (0,_modal_body__WEBPACK_IMPORTED_MODULE_2__.reset)();
  6907. };
  6908. /**
  6909. * @name $Config#edit
  6910. * @description Allows the user to edit the active config.
  6911. * @returns {Promise<void>} Resolves when the user closes the config editor.
  6912. */
  6913. this.edit = async () => {
  6914. if (isOpen) {
  6915. throw getError('A config editor is already open.');
  6916. }
  6917. open();
  6918. const {tree, config, styles} = await (0,_index__WEBPACK_IMPORTED_MODULE_1__.edit)();
  6919. GM.setValue(KEY_TREE, tree);
  6920. GM.setValue(KEY_STYLES, styles);
  6921. GM.setValue(KEY_VERSION, VERSION);
  6922. this.get = ((config) => config).bind(null, Object.freeze(config));
  6923. await open(false);
  6924. };
  6925. // Pass data
  6926. return (0,_index__WEBPACK_IMPORTED_MODULE_1__.init)({
  6927. userStyles,
  6928. defaultTree: TREE_DEFAULT,
  6929. title: GM.info.script.name,
  6930. defaultStyle: STYLE_INNER,
  6931. ...(userTree ? {userTree} : {}),
  6932. }, target.contentDocument.body, target.contentWindow);
  6933. })
  6934. .catch(async (error) => {
  6935. delete this.reset;
  6936. await disconnect();
  6937. throw getError(
  6938. 'Your config is invalid.'
  6939. + '\nThis could be due to a script update or your data being corrupted.'
  6940. + `\n\nReason:\n${error.message.replaceAll(/\n+/g, '\n')}`,
  6941. error,
  6942. );
  6943. })
  6944. .then((response) => {
  6945. this.get = ((config) => config).bind(null, Object.freeze(response.config));
  6946. if (response.requireReset) {
  6947. throw getError(
  6948. 'Your config is invalid.'
  6949. + '\nThis could be due to a script update or your data being corrupted.'
  6950. + `\n\nReason:\n${response.error.message.replaceAll(/\n+/g, '\n')}`,
  6951. response.error,
  6952. );
  6953. }
  6954. });
  6955. }
  6956. }
  6957.  
  6958. })();
  6959.  
  6960. $Config = __webpack_exports__["default"];
  6961. /******/ })()
  6962. ;

QingJ © 2025

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