$Config

Allows users to configure scripts

此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.gf.qytechs.cn/scripts/446506/1588535/%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 */ NonPosIntError: () => (/* binding */ NonPosIntError),
  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 NonPosIntError extends Error {
  152. constructor(breadcrumbs, value) {
  153. super(`Found a value of "${value}" at ${getPath(breadcrumbs)}. Expected a positive integer.`);
  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') && typeof style.isActive !== 'boolean')
  286. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError(['userStyles', i.toString(), 'isActive'], typeof style.isActive, ['boolean']);
  287. }
  288. // defaultTree
  289. if (!hasOwnProperty(candidate, 'defaultTree') || !(0,_trees_guards__WEBPACK_IMPORTED_MODULE_4__.isRoot)(['defaultTree'], candidate.defaultTree))
  290. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.PropertyError([], 'defaultTree', true);
  291. // userTree
  292. if (hasOwnProperty(candidate, 'userTree') && !(0,_trees_guards__WEBPACK_IMPORTED_MODULE_4__.isRoot)(['userTree'], candidate.userTree, true))
  293. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.UnexpectedStateError();
  294. return true;
  295. }
  296. // Validator
  297. function validatePage({ title, defaultTree, userTree }) {
  298. // title
  299. if (title.length === 0)
  300. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.EmptyStringError(['title']);
  301. // trees
  302. (0,_trees_match__WEBPACK_IMPORTED_MODULE_5__.validateSeeds)(['defaultTree'], defaultTree);
  303. (0,_trees_pools__WEBPACK_IMPORTED_MODULE_3__.validatePools)(['defaultTree'], defaultTree);
  304. if (!userTree) {
  305. return Promise.all((0,_trees_predicates__WEBPACK_IMPORTED_MODULE_6__.validateParent)(['defaultTree'], defaultTree));
  306. }
  307. (0,_trees_match__WEBPACK_IMPORTED_MODULE_5__.matchUserTreeParent)(['defaultTree'], defaultTree, ['userTree'], userTree);
  308. // Has to be done after mutations since new pools may be created
  309. (0,_trees_match__WEBPACK_IMPORTED_MODULE_5__.validatePoolSizeMatch)(defaultTree, userTree);
  310. return Promise.all([
  311. ...(0,_trees_predicates__WEBPACK_IMPORTED_MODULE_6__.validateParent)(['defaultTree'], defaultTree),
  312. ...(0,_trees_predicates__WEBPACK_IMPORTED_MODULE_6__.validateParent)(['userTree'], userTree),
  313. ]);
  314. }
  315. // API
  316. /* harmony default export */ function __WEBPACK_DEFAULT_EXPORT__(candidate) {
  317. if (!isPage(candidate))
  318. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.UnexpectedStateError();
  319. return validatePage(candidate);
  320. }
  321.  
  322.  
  323. /***/ }),
  324.  
  325. /***/ "./ts/library/validation/styles.ts":
  326. /*!*****************************************!*\
  327. !*** ./ts/library/validation/styles.ts ***!
  328. \*****************************************/
  329. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  330.  
  331. __webpack_require__.r(__webpack_exports__);
  332. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  333. /* harmony export */ isStyles: () => (/* binding */ isStyles)
  334. /* harmony export */ });
  335. /* harmony import */ var _errors__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./errors */ "./ts/library/validation/errors.ts");
  336. /* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./types */ "./ts/library/validation/types.ts");
  337.  
  338.  
  339. function isStyles(breadcrumbs, candidate) {
  340. if (typeof candidate !== 'object')
  341. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.TypeError(breadcrumbs, typeof candidate, ['object']);
  342. if (Array.isArray(candidate))
  343. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.TypeError(breadcrumbs, 'array', ['object']);
  344. for (const [key, value] of Object.entries(candidate)) {
  345. switch (key) {
  346. // Colours
  347. case 'modalOutline':
  348. case 'headBase':
  349. case 'headButtonExit':
  350. case 'headButtonLabel':
  351. case 'headButtonStyle':
  352. case 'headButtonSticky':
  353. case 'nodeHeaderBase':
  354. case 'nodeBlendBase':
  355. case 'nodeValueBase':
  356. case 'nodeButtonRemove':
  357. case 'nodeButtonCreate':
  358. case 'nodeButtonMove':
  359. case 'nodeButtonDisable':
  360. case 'validBackground':
  361. case 'invalidBackground':
  362. case 'focusBackground':
  363. case 'tooltipOutline':
  364. if (typeof value !== 'string')
  365. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.TypeError([...breadcrumbs, key], typeof value, ['string']);
  366. break;
  367. // Numbers
  368. case 'fontSize':
  369. case 'width':
  370. case 'height':
  371. if (typeof value !== 'number')
  372. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.TypeError([...breadcrumbs, key], typeof value, ['number']);
  373. break;
  374. // Contrast methods
  375. case 'headContrast':
  376. case 'nodeContrast':
  377. if (typeof value !== 'string')
  378. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.TypeError([...breadcrumbs, key], typeof value, ['string']);
  379. if (!_types__WEBPACK_IMPORTED_MODULE_1__.CONTRAST_METHODS.includes(value))
  380. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.ValueError([...breadcrumbs, key], value, _types__WEBPACK_IMPORTED_MODULE_1__.CONTRAST_METHODS);
  381. break;
  382. // Booleans
  383. case 'isActive':
  384. case 'borderLeaf':
  385. case 'borderNode':
  386. if (typeof value !== 'boolean')
  387. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.TypeError([...breadcrumbs, key], typeof value, ['boolean']);
  388. break;
  389. }
  390. }
  391. return true;
  392. }
  393.  
  394.  
  395. /***/ }),
  396.  
  397. /***/ "./ts/library/validation/trees/guards.ts":
  398. /*!***********************************************!*\
  399. !*** ./ts/library/validation/trees/guards.ts ***!
  400. \***********************************************/
  401. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  402.  
  403. __webpack_require__.r(__webpack_exports__);
  404. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  405. /* harmony export */ isParent: () => (/* binding */ isParent),
  406. /* harmony export */ isRoot: () => (/* binding */ isRoot)
  407. /* harmony export */ });
  408. /* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../types */ "./ts/library/validation/types.ts");
  409. /* harmony import */ var _errors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../errors */ "./ts/library/validation/errors.ts");
  410. /* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../index */ "./ts/library/validation/index.ts");
  411.  
  412.  
  413.  
  414. function hasDependee(breadcrumbs, candidate, property, dependence) {
  415. if (!(0,_index__WEBPACK_IMPORTED_MODULE_2__.hasOwnProperty)(candidate, property)) {
  416. return false;
  417. }
  418. if ((0,_index__WEBPACK_IMPORTED_MODULE_2__.hasOwnProperty)(candidate, dependence))
  419. return true;
  420. 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));
  421. }
  422. function hasId(breadcrumbs, candidate, property) {
  423. if (!(0,_index__WEBPACK_IMPORTED_MODULE_2__.hasOwnProperty)(candidate, property)) {
  424. return false;
  425. }
  426. if (typeof candidate[property] !== 'number')
  427. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, property], typeof candidate[property], ['number']);
  428. if (Object.is(candidate[property] % 1, 0))
  429. return true;
  430. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.NonPosIntError([...breadcrumbs, property], candidate[property]);
  431. }
  432. // Type predicates
  433. function isChild(breadcrumbs, candidate, isUserTree = false) {
  434. if (typeof candidate !== 'object')
  435. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs], typeof candidate, ['object']);
  436. if (isUserTree) {
  437. (0,_index__WEBPACK_IMPORTED_MODULE_2__.validateUnexpectedKeys)(breadcrumbs, candidate, _types__WEBPACK_IMPORTED_MODULE_0__.SAVED_KEYS);
  438. }
  439. else {
  440. (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);
  441. }
  442. if ((0,_index__WEBPACK_IMPORTED_MODULE_2__.hasOwnProperty)(candidate, 'label') && typeof candidate.label !== 'string')
  443. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'label'], typeof candidate.label, ['string']);
  444. if ((0,_index__WEBPACK_IMPORTED_MODULE_2__.hasOwnProperty)(candidate, 'value') && !_types__WEBPACK_IMPORTED_MODULE_0__.VALUE_TYPES.includes(typeof candidate.value))
  445. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'value'], typeof candidate.value, _types__WEBPACK_IMPORTED_MODULE_0__.VALUE_TYPES);
  446. if (hasDependee(breadcrumbs, candidate, 'options', 'value')) {
  447. if (!Array.isArray(candidate.options))
  448. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'options'], typeof candidate.options, ['array']);
  449. for (const [i, option] of candidate.options.entries()) {
  450. if (!_types__WEBPACK_IMPORTED_MODULE_0__.VALUE_TYPES.includes(typeof option))
  451. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'options', i.toString()], typeof option, _types__WEBPACK_IMPORTED_MODULE_0__.VALUE_TYPES);
  452. }
  453. }
  454. if (hasDependee(breadcrumbs, candidate, 'predicate', 'value') && typeof candidate.predicate !== 'function')
  455. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'predicate'], typeof candidate.predicate, ['function']);
  456. if (hasDependee(breadcrumbs, candidate, 'onUpdate', 'value') && typeof candidate.onUpdate !== 'function')
  457. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'onUpdate'], typeof candidate.onUpdate, ['function']);
  458. if (hasDependee(breadcrumbs, candidate, 'listeners', 'value')) {
  459. if (typeof candidate.listeners !== 'object')
  460. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'listeners'], typeof candidate.listeners, ['object']);
  461. for (const [event, callback] of Object.entries(candidate.listeners)) {
  462. if (typeof callback !== 'function')
  463. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'listeners', event], typeof callback, ['function']);
  464. }
  465. }
  466. if (hasDependee(breadcrumbs, candidate, 'input', 'value')) {
  467. if (typeof candidate.input !== 'string')
  468. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'input'], typeof candidate.input, ['string']);
  469. if (!_types__WEBPACK_IMPORTED_MODULE_0__.INPUT_FORMATS.includes(candidate.input))
  470. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.ValueError([...breadcrumbs, 'input'], candidate.input, _types__WEBPACK_IMPORTED_MODULE_0__.INPUT_FORMATS);
  471. }
  472. if (hasDependee(breadcrumbs, candidate, 'inputAttributes', 'value') && typeof candidate.inputAttributes !== 'object')
  473. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'inputAttributes'], typeof candidate.inputAttributes, ['object']);
  474. if ((0,_index__WEBPACK_IMPORTED_MODULE_2__.hasOwnProperty)(candidate, 'get') && typeof candidate.get !== 'function')
  475. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'get'], typeof candidate.get, ['function']);
  476. hasId(breadcrumbs, candidate, 'hideId');
  477. if ((0,_index__WEBPACK_IMPORTED_MODULE_2__.hasOwnProperty)(candidate, 'isActive') && typeof candidate.isActive !== 'boolean')
  478. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'isActive'], typeof candidate.isActive, ['boolean']);
  479. if ((0,_index__WEBPACK_IMPORTED_MODULE_2__.hasOwnProperty)(candidate, 'children') && !isParent(breadcrumbs, candidate, isUserTree))
  480. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.UnexpectedStateError();
  481. return true;
  482. }
  483. function isParent(breadcrumbs, candidate, isUserTree = false) {
  484. if (!(0,_index__WEBPACK_IMPORTED_MODULE_2__.hasOwnProperty)(candidate, 'children'))
  485. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.PropertyError(breadcrumbs, 'children', true);
  486. if (!Array.isArray(candidate.children))
  487. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'children'], typeof candidate.children, ['array']);
  488. if ((0,_index__WEBPACK_IMPORTED_MODULE_2__.hasOwnProperty)(candidate, 'seed') && !isChild([...breadcrumbs, 'seed'], candidate.seed))
  489. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.UnexpectedStateError();
  490. hasId(breadcrumbs, candidate, 'poolId');
  491. if ((0,_index__WEBPACK_IMPORTED_MODULE_2__.hasOwnProperty)(candidate, 'childPredicate') && typeof candidate.childPredicate !== 'function')
  492. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'childPredicate'], typeof candidate.childPredicate, ['function']);
  493. if ((0,_index__WEBPACK_IMPORTED_MODULE_2__.hasOwnProperty)(candidate, 'descendantPredicate') && typeof candidate.descendantPredicate !== 'function')
  494. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'descendantPredicate'], typeof candidate.descendantPredicate, ['function']);
  495. if ((0,_index__WEBPACK_IMPORTED_MODULE_2__.hasOwnProperty)(candidate, 'onChildUpdate') && typeof candidate.onChildUpdate !== 'function')
  496. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'onChildUpdate'], typeof candidate.onChildUpdate, ['function']);
  497. if ((0,_index__WEBPACK_IMPORTED_MODULE_2__.hasOwnProperty)(candidate, 'onDescendantUpdate') && typeof candidate.onDescendantUpdate !== 'function')
  498. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'onDescendantUpdate'], typeof candidate.onDescendantUpdate, ['function']);
  499. for (const [i, child] of candidate.children.entries()) {
  500. if (!isChild([...breadcrumbs, 'children', i.toString()], child, isUserTree))
  501. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.UnexpectedStateError();
  502. }
  503. return true;
  504. }
  505. function isRoot(breadcrumbs, candidate, isUserTree = false) {
  506. if (typeof candidate !== 'object')
  507. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError(breadcrumbs, typeof candidate, ['object']);
  508. if (!isParent(breadcrumbs, candidate, isUserTree))
  509. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.UnexpectedStateError();
  510. (0,_index__WEBPACK_IMPORTED_MODULE_2__.validateUnexpectedKeys)(breadcrumbs, candidate, _types__WEBPACK_IMPORTED_MODULE_0__.ROOT_KEYS);
  511. return true;
  512. }
  513.  
  514.  
  515. /***/ }),
  516.  
  517. /***/ "./ts/library/validation/trees/match.ts":
  518. /*!**********************************************!*\
  519. !*** ./ts/library/validation/trees/match.ts ***!
  520. \**********************************************/
  521. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  522.  
  523. __webpack_require__.r(__webpack_exports__);
  524. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  525. /* harmony export */ matchUserTreeParent: () => (/* binding */ matchUserTreeParent),
  526. /* harmony export */ validatePoolSizeMatch: () => (/* binding */ validatePoolSizeMatch),
  527. /* harmony export */ validateSeeds: () => (/* binding */ validateSeeds)
  528. /* harmony export */ });
  529. /* harmony import */ var _errors__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../errors */ "./ts/library/validation/errors.ts");
  530.  
  531. // Helpers
  532. function validateOptionMatch(modelBreadcrumbs, model, candidateBreadcrumbs, candidate) {
  533. if ('options' in model !== 'options' in candidate)
  534. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.PropertyError(candidateBreadcrumbs, 'options', 'options' in model);
  535. if ('options' in model) {
  536. if (model.options.length !== candidate.options.length)
  537. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.ValueError([...candidateBreadcrumbs, 'options', 'length'], candidate.options.length, [model.options.length]);
  538. for (const [i, option] of model.options.entries()) {
  539. if (candidate.options[i] !== option)
  540. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.ValueError([...candidateBreadcrumbs, 'options', i.toString()], candidate.options[i], [option]);
  541. }
  542. }
  543. }
  544. function validateValueMatch(property, modelBreadcrumbs, model, candidateBreadcrumbs, candidate) {
  545. if (property in model !== property in candidate)
  546. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.PropertyError(candidateBreadcrumbs, property, property in model);
  547. if (model[property] !== candidate[property])
  548. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.ValueError([...candidateBreadcrumbs, property], candidate[property], [model[property]]);
  549. }
  550. function assignKeys(from, to) {
  551. for (const key of Object.keys(from)) {
  552. if (!(key in to)) {
  553. to[key] = from[key];
  554. }
  555. }
  556. }
  557. // Consistent userTree validators/enforcers
  558. function matchUserTreeChild(modelBreadcrumbs, model, candidateBreadcrumbs, candidate) {
  559. if ('value' in model !== 'value' in candidate) {
  560. if ('value' in candidate)
  561. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.PropertyError(candidateBreadcrumbs, 'value', false);
  562. candidate.value = model.value;
  563. }
  564. else if (typeof model.value !== typeof candidate.value) {
  565. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.TypeError([...candidateBreadcrumbs, 'value'], typeof candidate.value, [typeof model.value]);
  566. }
  567. if ('label' in model) {
  568. candidate.label = model.label;
  569. }
  570. else {
  571. delete candidate.label;
  572. }
  573. if ('children' in model !== 'children' in candidate)
  574. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.PropertyError(candidateBreadcrumbs, 'children', 'children' in model);
  575. if ('children' in model) {
  576. matchUserTreeParent(modelBreadcrumbs, model, candidateBreadcrumbs, candidate);
  577. }
  578. else {
  579. assignKeys(model, candidate);
  580. }
  581. }
  582. function matchUserTreeParent(modelBreadcrumbs, model, candidateBreadcrumbs, candidate) {
  583. assignKeys(model, candidate);
  584. if ('seed' in model) {
  585. for (const [i, child] of candidate.children.entries()) {
  586. matchUserTreeChild([...modelBreadcrumbs, 'seed'], model.seed, [...candidateBreadcrumbs, 'children', i.toString()], child);
  587. }
  588. return;
  589. }
  590. if ('poolId' in model) {
  591. return;
  592. }
  593. if (model.children.length !== candidate.children.length)
  594. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.ValueError([...candidateBreadcrumbs, 'children', 'length'], candidate.children.length, [model.children.length]);
  595. for (const [i, child] of candidate.children.entries()) {
  596. matchUserTreeChild([...modelBreadcrumbs, 'children', i.toString()], model.children[i], [...candidateBreadcrumbs, 'children', i.toString()], child);
  597. }
  598. // Done after validation to avoid validating certain matches
  599. if (model.children.length > candidate.children.length) {
  600. candidate.children.push(...model.children.slice(candidate.children.length));
  601. }
  602. }
  603. // defaultTree internal consistency validators
  604. function validateChildMatch(modelBreadcrumbs, model, candidateBreadcrumbs, candidate) {
  605. if ('value' in model !== 'value' in candidate)
  606. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.PropertyError(candidateBreadcrumbs, 'value', 'value' in model);
  607. if (typeof model.value !== typeof candidate.value)
  608. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.TypeError([...candidateBreadcrumbs, 'value'], typeof candidate.value, [typeof model.value]);
  609. validateValueMatch('label', modelBreadcrumbs, model, candidateBreadcrumbs, candidate);
  610. validateValueMatch('input', modelBreadcrumbs, model, candidateBreadcrumbs, candidate);
  611. validateOptionMatch(modelBreadcrumbs, model, candidateBreadcrumbs, candidate);
  612. try {
  613. validateValueMatch('predicate', modelBreadcrumbs, model, candidateBreadcrumbs, candidate);
  614. validateValueMatch('onUpdate', modelBreadcrumbs, model, candidateBreadcrumbs, candidate);
  615. }
  616. catch (error) {
  617. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.JoinedError(new _errors__WEBPACK_IMPORTED_MODULE_0__.FunctionMatchError(), error);
  618. }
  619. if ('children' in model !== 'children' in candidate)
  620. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.PropertyError(candidateBreadcrumbs, 'children', 'children' in model);
  621. if ('children' in model) {
  622. validateParentMatch(modelBreadcrumbs, model, candidateBreadcrumbs, candidate);
  623. }
  624. }
  625. function validateParentMatch(modelBreadcrumbs, model, candidateBreadcrumbs, candidate) {
  626. validateValueMatch('poolId', modelBreadcrumbs, model, candidateBreadcrumbs, candidate);
  627. try {
  628. validateValueMatch('childPredicate', modelBreadcrumbs, model, candidateBreadcrumbs, candidate);
  629. validateValueMatch('onChildUpdate', modelBreadcrumbs, model, candidateBreadcrumbs, candidate);
  630. validateValueMatch('descendantPredicate', modelBreadcrumbs, model, candidateBreadcrumbs, candidate);
  631. validateValueMatch('onDescendantUpdate', modelBreadcrumbs, model, candidateBreadcrumbs, candidate);
  632. }
  633. catch (error) {
  634. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.JoinedError(new _errors__WEBPACK_IMPORTED_MODULE_0__.FunctionMatchError(), error);
  635. }
  636. if ('seed' in model) {
  637. validateChildMatch([...modelBreadcrumbs, 'seed'], model.seed, [...candidateBreadcrumbs, 'seed'], candidate.seed);
  638. for (const [i, child] of candidate.children.entries()) {
  639. validateChildMatch([...modelBreadcrumbs, 'seed'], model.seed, [...candidateBreadcrumbs, 'children', i.toString()], child);
  640. }
  641. }
  642. else if (!('poolId' in model)) {
  643. if (model.children.length !== candidate.children.length)
  644. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.ValueError([...candidateBreadcrumbs, 'children', 'length'], candidate.children.length, [model.children.length]);
  645. for (const [i, child] of candidate.children.entries()) {
  646. validateChildMatch([...modelBreadcrumbs, 'children', i.toString()], model.children[i], [...candidateBreadcrumbs, 'children', i.toString()], child);
  647. }
  648. if (model.children.length > candidate.children.length) {
  649. candidate.children.push(...model.children.slice(candidate.children.length));
  650. }
  651. }
  652. }
  653. // Other validators
  654. function validateSeeds(breadcrumbs, node) {
  655. if ('children' in node) {
  656. if ('seed' in node) {
  657. try {
  658. for (const [i, child] of node.children.entries()) {
  659. validateChildMatch([...breadcrumbs, 'seed'], node.seed, [...breadcrumbs, 'children', i.toString()], child);
  660. }
  661. }
  662. catch (error) {
  663. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.JoinedError(new _errors__WEBPACK_IMPORTED_MODULE_0__.SeedMatchError(), error);
  664. }
  665. validateSeeds([...breadcrumbs, 'seed'], node.seed);
  666. }
  667. else {
  668. for (const [i, child] of node.children.entries()) {
  669. if ('isActive' in child && !child.isActive) {
  670. 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]));
  671. }
  672. }
  673. }
  674. for (const [i, child] of node.children.entries()) {
  675. validateSeeds([...breadcrumbs, 'children', i.toString()], child);
  676. }
  677. }
  678. }
  679. function getPoolSizes(node, uncapped = false) {
  680. const poolSizes = [];
  681. uncapped = uncapped || 'seed' in node;
  682. if ('poolId' in node) {
  683. poolSizes[node.poolId] = uncapped ? -1 : node.children.length;
  684. }
  685. if ('children' in node) {
  686. for (const child of node.children) {
  687. const subPoolSizes = getPoolSizes(child, uncapped);
  688. for (const id in subPoolSizes) {
  689. if (subPoolSizes[id] < 0) {
  690. poolSizes[id] = -1;
  691. }
  692. else if (id in poolSizes) {
  693. poolSizes[id] += subPoolSizes[id];
  694. }
  695. else {
  696. poolSizes[id] = subPoolSizes[id];
  697. }
  698. }
  699. }
  700. }
  701. return poolSizes;
  702. }
  703. function validatePoolSizeMatch(model, candidate) {
  704. const modelSizes = getPoolSizes(model);
  705. const candidateSizes = getPoolSizes(candidate);
  706. for (const id in modelSizes) {
  707. if (modelSizes[id] !== candidateSizes[id])
  708. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.PoolSizeError(Number.parseInt(id), candidateSizes[id], modelSizes[id]);
  709. }
  710. }
  711.  
  712.  
  713. /***/ }),
  714.  
  715. /***/ "./ts/library/validation/trees/pools.ts":
  716. /*!**********************************************!*\
  717. !*** ./ts/library/validation/trees/pools.ts ***!
  718. \**********************************************/
  719. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  720.  
  721. __webpack_require__.r(__webpack_exports__);
  722. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  723. /* harmony export */ validatePools: () => (/* binding */ validatePools)
  724. /* harmony export */ });
  725. /* harmony import */ var _errors__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../errors */ "./ts/library/validation/errors.ts");
  726.  
  727. function validatePools(breadcrumbs, node, ancestorPools = []) {
  728. if ('poolId' in node) {
  729. if (node.poolId in ancestorPools)
  730. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.PoolBranchError(ancestorPools[node.poolId], breadcrumbs, node.poolId);
  731. // Slice maintains empty entries, so the 'in' operator still works
  732. ancestorPools = ancestorPools.slice();
  733. ancestorPools[node.poolId] = breadcrumbs;
  734. }
  735. if ('children' in node) {
  736. // Recurse
  737. for (const [i, child] of node.children.entries()) {
  738. validatePools([...breadcrumbs, 'children', i.toString()], child, ancestorPools);
  739. }
  740. }
  741. }
  742.  
  743.  
  744. /***/ }),
  745.  
  746. /***/ "./ts/library/validation/trees/predicates.ts":
  747. /*!***************************************************!*\
  748. !*** ./ts/library/validation/trees/predicates.ts ***!
  749. \***************************************************/
  750. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  751.  
  752. __webpack_require__.r(__webpack_exports__);
  753. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  754. /* harmony export */ validateParent: () => (/* binding */ validateParent)
  755. /* harmony export */ });
  756. /* harmony import */ var _errors__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../errors */ "./ts/library/validation/errors.ts");
  757. /* harmony import */ var _predicate__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../predicate */ "./ts/predicate.ts");
  758.  
  759.  
  760. function getBoundPredicatePromise(response, error) {
  761. return (0,_predicate__WEBPACK_IMPORTED_MODULE_1__.getPredicatePromise)(response)
  762. .catch(() => Promise.reject(error));
  763. }
  764. function validateChild(breadcrumbs, child) {
  765. if (!('options' in child) && !('predicate' in child))
  766. return Promise.resolve();
  767. if ('options' in child) {
  768. const type = typeof child.value;
  769. let valueFound = false;
  770. for (const [i, option] of child.options.entries()) {
  771. if (typeof option !== type) {
  772. 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]));
  773. }
  774. valueFound || (valueFound = child.value === option);
  775. }
  776. if (valueFound)
  777. return Promise.resolve();
  778. }
  779. if ('predicate' in child)
  780. return getBoundPredicatePromise(child.predicate(child.value), new _errors__WEBPACK_IMPORTED_MODULE_0__.PredicateError([...breadcrumbs, 'predicate']));
  781. 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));
  782. }
  783. function validateParent(breadcrumbs, parent) {
  784. const promises = [];
  785. if ('seed' in parent) {
  786. const { seed } = parent;
  787. promises.push(validateChild([...breadcrumbs, 'seed'], seed));
  788. if ('children' in seed) {
  789. promises.push(...validateParent([...breadcrumbs, 'seed'], seed));
  790. }
  791. }
  792. const { children } = parent;
  793. if ('childPredicate' in parent) {
  794. promises.push(getBoundPredicatePromise(parent.childPredicate(children), new _errors__WEBPACK_IMPORTED_MODULE_0__.PredicateError([...breadcrumbs, 'childPredicate'])));
  795. }
  796. if ('descendantPredicate' in parent) {
  797. promises.push(getBoundPredicatePromise(parent.descendantPredicate(children), new _errors__WEBPACK_IMPORTED_MODULE_0__.PredicateError([...breadcrumbs, 'descendantPredicate'])));
  798. }
  799. for (const [i, child] of children.entries()) {
  800. const childBreadcrumbs = [...breadcrumbs, 'children', i.toString()];
  801. promises.push(validateChild(childBreadcrumbs, child));
  802. if ('children' in child) {
  803. promises.push(...validateParent(childBreadcrumbs, child));
  804. }
  805. }
  806. return promises;
  807. }
  808.  
  809.  
  810. /***/ }),
  811.  
  812. /***/ "./ts/library/validation/types.ts":
  813. /*!****************************************!*\
  814. !*** ./ts/library/validation/types.ts ***!
  815. \****************************************/
  816. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  817.  
  818. __webpack_require__.r(__webpack_exports__);
  819. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  820. /* harmony export */ CONTRAST_METHODS: () => (/* binding */ CONTRAST_METHODS),
  821. /* harmony export */ INPUT_FORMATS: () => (/* binding */ INPUT_FORMATS),
  822. /* harmony export */ LEAF_KEYS: () => (/* binding */ LEAF_KEYS),
  823. /* harmony export */ MIDDLE_KEYS: () => (/* binding */ MIDDLE_KEYS),
  824. /* harmony export */ PAGE_KEYS: () => (/* binding */ PAGE_KEYS),
  825. /* harmony export */ ROOT_KEYS: () => (/* binding */ ROOT_KEYS),
  826. /* harmony export */ ROOT_OTHER_KEYS: () => (/* binding */ ROOT_OTHER_KEYS),
  827. /* harmony export */ ROOT_PREDICATE_KEYS: () => (/* binding */ ROOT_PREDICATE_KEYS),
  828. /* harmony export */ ROOT_UPDATE_KEYS: () => (/* binding */ ROOT_UPDATE_KEYS),
  829. /* harmony export */ SAVED_KEYS: () => (/* binding */ SAVED_KEYS),
  830. /* harmony export */ VALUE_TYPES: () => (/* binding */ VALUE_TYPES)
  831. /* harmony export */ });
  832. // Basic types
  833. const VALUE_TYPES = ['boolean', 'number', 'string'];
  834. const INPUT_FORMATS = ['color', 'date', 'datetime-local', 'email', 'month', 'password', 'search', 'tel', 'text', 'time', 'url', 'week'];
  835. const CONTRAST_METHODS = ['Black / White', 'Invert'];
  836. // Key categories
  837. const SAVED_KEYS = ['label', 'value', 'isActive', 'children'];
  838. const ROOT_PREDICATE_KEYS = ['childPredicate', 'descendantPredicate'];
  839. const ROOT_UPDATE_KEYS = ['onChildUpdate', 'onDescendantUpdate'];
  840. const ROOT_OTHER_KEYS = ['children', 'seed', 'poolId', 'get'];
  841. // Node types
  842. // hacky code to avoid a duplicate "get" in MIDDLE_KEYS
  843. const _LEAF_KEYS = ['label', 'value', 'predicate', 'options', 'input', 'isActive', 'onUpdate', 'listeners', 'hideId', 'inputAttributes'];
  844. const LEAF_KEYS = [..._LEAF_KEYS, 'get'];
  845. const ROOT_KEYS = [...ROOT_PREDICATE_KEYS, ...ROOT_UPDATE_KEYS, ...ROOT_OTHER_KEYS];
  846. const MIDDLE_KEYS = [..._LEAF_KEYS, ...ROOT_KEYS];
  847. // Config type
  848. const PAGE_KEYS = ['title', 'defaultTree', 'userTree', 'defaultStyle', 'userStyles'];
  849.  
  850.  
  851. /***/ }),
  852.  
  853. /***/ "./ts/modal/body/consts.ts":
  854. /*!*********************************!*\
  855. !*** ./ts/modal/body/consts.ts ***!
  856. \*********************************/
  857. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  858.  
  859. __webpack_require__.r(__webpack_exports__);
  860. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  861. /* harmony export */ MODAL_BODY_ID: () => (/* binding */ MODAL_BODY_ID)
  862. /* harmony export */ });
  863. const MODAL_BODY_ID = 'modal-body';
  864.  
  865.  
  866. /***/ }),
  867.  
  868. /***/ "./ts/modal/body/css.ts":
  869. /*!******************************!*\
  870. !*** ./ts/modal/body/css.ts ***!
  871. \******************************/
  872. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  873.  
  874. __webpack_require__.r(__webpack_exports__);
  875. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  876. /* harmony export */ "default": () => (/* binding */ generate)
  877. /* harmony export */ });
  878. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/consts.ts");
  879. /* harmony import */ var _nodes_css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./nodes/css */ "./ts/modal/body/nodes/css.ts");
  880. /* harmony import */ var _nodes_actions_css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./nodes/actions/css */ "./ts/modal/body/nodes/actions/css.ts");
  881. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../css */ "./ts/modal/css.ts");
  882.  
  883.  
  884.  
  885.  
  886. function generate() {
  887. (0,_nodes_css__WEBPACK_IMPORTED_MODULE_1__["default"])();
  888. (0,_nodes_actions_css__WEBPACK_IMPORTED_MODULE_2__["default"])();
  889. (0,_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`#${_consts__WEBPACK_IMPORTED_MODULE_0__.MODAL_BODY_ID}`, [
  890. ['overflow-y', 'auto'],
  891. ['overflow-x', 'hidden'],
  892. ['overscroll-behavior', 'contain'],
  893. ['background-color', 'var(--nodeValueBase)'],
  894. ['flex-grow', '1'],
  895. ]);
  896. }
  897.  
  898.  
  899. /***/ }),
  900.  
  901. /***/ "./ts/modal/body/data/consts.ts":
  902. /*!**************************************!*\
  903. !*** ./ts/modal/body/data/consts.ts ***!
  904. \**************************************/
  905. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  906.  
  907. __webpack_require__.r(__webpack_exports__);
  908. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  909. /* harmony export */ ROOT_ID: () => (/* binding */ ROOT_ID)
  910. /* harmony export */ });
  911. const ROOT_ID = 'root-data';
  912.  
  913.  
  914. /***/ }),
  915.  
  916. /***/ "./ts/modal/body/data/index.ts":
  917. /*!*************************************!*\
  918. !*** ./ts/modal/body/data/index.ts ***!
  919. \*************************************/
  920. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  921.  
  922. __webpack_require__.r(__webpack_exports__);
  923. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  924. /* harmony export */ "default": () => (/* binding */ generate),
  925. /* harmony export */ getRoot: () => (/* binding */ getRoot),
  926. /* harmony export */ getSaveData: () => (/* binding */ getSaveData),
  927. /* harmony export */ setTree: () => (/* binding */ setTree)
  928. /* harmony export */ });
  929. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/data/consts.ts");
  930. /* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../index */ "./ts/modal/body/index.ts");
  931.  
  932.  
  933. function getRoot() {
  934. return _index__WEBPACK_IMPORTED_MODULE_1__.ROOTS[_consts__WEBPACK_IMPORTED_MODULE_0__.ROOT_ID];
  935. }
  936. function getSaveData() {
  937. const { tree, config } = getRoot().getSaveData();
  938. return { tree, config };
  939. }
  940. function setTree(data) {
  941. const root = getRoot();
  942. // Spread avoids looping on a shrinking array
  943. for (const child of [...root.children]) {
  944. child.disconnect();
  945. }
  946. root.addChildren(data.children);
  947. }
  948. function generate(data) {
  949. return (0,_index__WEBPACK_IMPORTED_MODULE_1__.generateTree)(data, _consts__WEBPACK_IMPORTED_MODULE_0__.ROOT_ID);
  950. }
  951.  
  952.  
  953. /***/ }),
  954.  
  955. /***/ "./ts/modal/body/index.ts":
  956. /*!********************************!*\
  957. !*** ./ts/modal/body/index.ts ***!
  958. \********************************/
  959. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  960.  
  961. __webpack_require__.r(__webpack_exports__);
  962. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  963. /* harmony export */ ROOTS: () => (/* binding */ ROOTS),
  964. /* harmony export */ "default": () => (/* binding */ generate),
  965. /* harmony export */ element: () => (/* binding */ element),
  966. /* harmony export */ generateTree: () => (/* binding */ generateTree),
  967. /* harmony export */ reset: () => (/* binding */ reset),
  968. /* harmony export */ setActive: () => (/* binding */ setActive)
  969. /* harmony export */ });
  970. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/consts.ts");
  971. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./css */ "./ts/modal/body/css.ts");
  972. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./style */ "./ts/modal/body/style/index.ts");
  973. /* harmony import */ var _data__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./data */ "./ts/modal/body/data/index.ts");
  974. /* harmony import */ var _nodes_actions_highlight__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./nodes/actions/highlight */ "./ts/modal/body/nodes/actions/highlight/index.ts");
  975. /* harmony import */ var _nodes_actions_active__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./nodes/actions/active */ "./ts/modal/body/nodes/actions/active.ts");
  976. /* harmony import */ var _nodes_actions_history__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./nodes/actions/history */ "./ts/modal/body/nodes/actions/history.ts");
  977. /* harmony import */ var _nodes_root__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./nodes/root */ "./ts/modal/body/nodes/root.ts");
  978. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../consts */ "./ts/modal/consts.ts");
  979. /* 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");
  980.  
  981.  
  982.  
  983.  
  984.  
  985.  
  986.  
  987.  
  988.  
  989.  
  990. const ROOTS = {};
  991. const element = document.createElement('div');
  992. let resetTree;
  993. function setActive(button, actionId, doActivate = true) {
  994. if (doActivate) {
  995. button.classList.add(_consts__WEBPACK_IMPORTED_MODULE_8__.BUTTON_ACTIVE_CLASS);
  996. element.classList.add(actionId);
  997. }
  998. else {
  999. button.classList.remove(_consts__WEBPACK_IMPORTED_MODULE_8__.BUTTON_ACTIVE_CLASS);
  1000. element.classList.remove(actionId);
  1001. }
  1002. }
  1003. function generateTree(data, id) {
  1004. if (ROOTS[id]) {
  1005. throw new Error(`Attempted to instantiate second tree with id '${id}'.`);
  1006. }
  1007. const root = new _nodes_root__WEBPACK_IMPORTED_MODULE_7__["default"](data);
  1008. root.element.elementContainer.id = id;
  1009. ROOTS[id] = root;
  1010. return root.element.elementContainer;
  1011. }
  1012. function generate({ userTree, defaultTree, userStyles, defaultStyle }) {
  1013. resetTree = defaultTree;
  1014. (0,_css__WEBPACK_IMPORTED_MODULE_1__["default"])();
  1015. element.id = _consts__WEBPACK_IMPORTED_MODULE_0__.MODAL_BODY_ID;
  1016. // avoid blurring an input when dragging the scrollbar
  1017. element.addEventListener('mousedown', (event) => {
  1018. event.stopPropagation();
  1019. event.preventDefault();
  1020. });
  1021. 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));
  1022. (0,_nodes_actions_highlight__WEBPACK_IMPORTED_MODULE_4__.onMount)();
  1023. (0,_nodes_actions_active__WEBPACK_IMPORTED_MODULE_5__.onMount)();
  1024. (0,_nodes_actions_history__WEBPACK_IMPORTED_MODULE_6__.onMount)();
  1025. (0,_modal_header_actions_sticky_css__WEBPACK_IMPORTED_MODULE_9__["default"])(ROOTS);
  1026. return element;
  1027. }
  1028. function reset() {
  1029. (0,_data__WEBPACK_IMPORTED_MODULE_3__.setTree)(resetTree);
  1030. }
  1031.  
  1032.  
  1033. /***/ }),
  1034.  
  1035. /***/ "./ts/modal/body/nodes/actions/active.ts":
  1036. /*!***********************************************!*\
  1037. !*** ./ts/modal/body/nodes/actions/active.ts ***!
  1038. \***********************************************/
  1039. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1040.  
  1041. __webpack_require__.r(__webpack_exports__);
  1042. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1043. /* harmony export */ onMount: () => (/* binding */ onMount),
  1044. /* harmony export */ reset: () => (/* binding */ reset)
  1045. /* harmony export */ });
  1046. /* harmony import */ var _highlight__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./highlight */ "./ts/modal/body/nodes/actions/highlight/index.ts");
  1047. /* harmony import */ var _focus__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./focus */ "./ts/modal/body/nodes/actions/focus/index.ts");
  1048. /* harmony import */ var _buttons_position__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./buttons/position */ "./ts/modal/body/nodes/actions/buttons/position/index.ts");
  1049. /* harmony import */ var _modal__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/modal */ "./ts/modal/index.ts");
  1050.  
  1051.  
  1052.  
  1053.  
  1054. function reset() {
  1055. for (const action of [_buttons_position__WEBPACK_IMPORTED_MODULE_2__, _focus__WEBPACK_IMPORTED_MODULE_1__, _highlight__WEBPACK_IMPORTED_MODULE_0__]) {
  1056. if (action.isActive()) {
  1057. action.reset();
  1058. return true;
  1059. }
  1060. }
  1061. return false;
  1062. }
  1063. function onMount() {
  1064. (0,_modal__WEBPACK_IMPORTED_MODULE_3__.getSocket)().addEventListener('keydown', (event) => {
  1065. if ((event.key === 'Escape' || event.key === 'Backspace') && reset()) {
  1066. event.stopImmediatePropagation();
  1067. }
  1068. });
  1069. }
  1070.  
  1071.  
  1072. /***/ }),
  1073.  
  1074. /***/ "./ts/modal/body/nodes/actions/buttons/button.ts":
  1075. /*!*******************************************************!*\
  1076. !*** ./ts/modal/body/nodes/actions/buttons/button.ts ***!
  1077. \*******************************************************/
  1078. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1079.  
  1080. __webpack_require__.r(__webpack_exports__);
  1081. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1082. /* harmony export */ addActionButton: () => (/* binding */ addActionButton),
  1083. /* harmony export */ getNewButton: () => (/* binding */ getNewButton)
  1084. /* harmony export */ });
  1085. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/buttons/consts.ts");
  1086. /* harmony import */ var _overlays_tooltip__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../overlays/tooltip */ "./ts/modal/body/nodes/actions/overlays/tooltip/index.ts");
  1087. /* harmony import */ var _overlays__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../overlays */ "./ts/modal/body/nodes/actions/overlays/index.ts");
  1088. /* harmony import */ var _overlays_tooltip_consts__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../overlays/tooltip/consts */ "./ts/modal/body/nodes/actions/overlays/tooltip/consts.ts");
  1089. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  1090. /* harmony import */ var _modal_header_actions_alternate__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @/modal/header/actions/alternate */ "./ts/modal/header/actions/alternate/index.ts");
  1091. /* harmony import */ var _predicate__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @/predicate */ "./ts/predicate.ts");
  1092.  
  1093.  
  1094.  
  1095.  
  1096.  
  1097.  
  1098.  
  1099. // Creates an instantiation & adds it to the DOM
  1100. function addActionButton(template, onClick, node) {
  1101. const button = template.cloneNode(true);
  1102. button.addEventListener('click', (event) => {
  1103. event.stopPropagation();
  1104. if ((0,_predicate__WEBPACK_IMPORTED_MODULE_6__.isUnresolved)()) {
  1105. (0,_overlays__WEBPACK_IMPORTED_MODULE_2__.showTooltip)(_overlays_tooltip_consts__WEBPACK_IMPORTED_MODULE_3__.MESSAGE_UNRESOLVED, node, button.querySelector('circle'));
  1106. return;
  1107. }
  1108. (0,_overlays_tooltip__WEBPACK_IMPORTED_MODULE_1__.kill)();
  1109. if (event.ctrlKey) {
  1110. (0,_modal_header_actions_alternate__WEBPACK_IMPORTED_MODULE_5__.doAction)(true);
  1111. onClick(node, button, (0,_modal_header_actions_alternate__WEBPACK_IMPORTED_MODULE_5__.isActive)());
  1112. }
  1113. else {
  1114. onClick(node, button, (0,_modal_header_actions_alternate__WEBPACK_IMPORTED_MODULE_5__.isActive)());
  1115. }
  1116. });
  1117. button.addEventListener('keydown', (event) => {
  1118. // Prevent button presses via the Enter key from triggering actions
  1119. if (event.key === 'Enter') {
  1120. event.stopPropagation();
  1121. }
  1122. });
  1123. button.addEventListener('mouseleave', () => {
  1124. button.blur();
  1125. });
  1126. node.element.addButton(button);
  1127. return button;
  1128. }
  1129. // Creates a template
  1130. const getNewButton = (function () {
  1131. const buttonTemplate = document.createElement('button');
  1132. buttonTemplate.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS);
  1133. // Prevent tabbing to buttons until node is focused
  1134. buttonTemplate.setAttribute('tabindex', '-1');
  1135. const svgTemplate = (() => {
  1136. const circle = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_4__.SVG_NAMESPACE, 'circle');
  1137. circle.setAttribute('r', '50');
  1138. circle.setAttribute('stroke-width', '10');
  1139. const svg = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_4__.SVG_NAMESPACE, 'svg');
  1140. svg.setAttribute('viewBox', '-70 -70 140 140');
  1141. svg.append(circle);
  1142. return svg;
  1143. })();
  1144. return function (group, actionId, description) {
  1145. const button = buttonTemplate.cloneNode(true);
  1146. const svg = svgTemplate.cloneNode(true);
  1147. button.classList.add(actionId);
  1148. button.title = description;
  1149. svg.append(group);
  1150. button.append(svg);
  1151. return button;
  1152. };
  1153. })();
  1154.  
  1155.  
  1156. /***/ }),
  1157.  
  1158. /***/ "./ts/modal/body/nodes/actions/buttons/consts.ts":
  1159. /*!*******************************************************!*\
  1160. !*** ./ts/modal/body/nodes/actions/buttons/consts.ts ***!
  1161. \*******************************************************/
  1162. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1163.  
  1164. __webpack_require__.r(__webpack_exports__);
  1165. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1166. /* harmony export */ ALT_CLASS: () => (/* binding */ ALT_CLASS),
  1167. /* harmony export */ BUTTON_CLASS: () => (/* binding */ BUTTON_CLASS),
  1168. /* harmony export */ TEST_ADD_CLASS: () => (/* binding */ TEST_ADD_CLASS),
  1169. /* harmony export */ TEST_REMOVE_CLASS: () => (/* binding */ TEST_REMOVE_CLASS)
  1170. /* harmony export */ });
  1171. const BUTTON_CLASS = 'node-button';
  1172. const ALT_CLASS = 'node-icon-alt';
  1173. const TEST_ADD_CLASS = 'node-test-add';
  1174. const TEST_REMOVE_CLASS = 'node-test-remove';
  1175.  
  1176.  
  1177. /***/ }),
  1178.  
  1179. /***/ "./ts/modal/body/nodes/actions/buttons/create/button.ts":
  1180. /*!**************************************************************!*\
  1181. !*** ./ts/modal/body/nodes/actions/buttons/create/button.ts ***!
  1182. \**************************************************************/
  1183. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1184.  
  1185. __webpack_require__.r(__webpack_exports__);
  1186. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1187. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  1188. /* harmony export */ });
  1189. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/buttons/create/consts.ts");
  1190. /* 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");
  1191. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  1192.  
  1193.  
  1194.  
  1195. const lineHorizontal = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'line');
  1196. lineHorizontal.setAttribute('stroke-linecap', 'round');
  1197. lineHorizontal.setAttribute('stroke-width', '12');
  1198. lineHorizontal.setAttribute('x1', '-25');
  1199. lineHorizontal.setAttribute('x2', '25');
  1200. const lineVertical = lineHorizontal.cloneNode(true);
  1201. lineVertical.setAttribute('transform', 'rotate(90)');
  1202. const g = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'g');
  1203. g.append(lineHorizontal, lineVertical);
  1204. const BUTTON = (0,_position_button_alt__WEBPACK_IMPORTED_MODULE_1__.getPositionedButton)(g, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, 'Create', { scale: '1 1.15' });
  1205. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (BUTTON);
  1206.  
  1207.  
  1208. /***/ }),
  1209.  
  1210. /***/ "./ts/modal/body/nodes/actions/buttons/create/consts.ts":
  1211. /*!**************************************************************!*\
  1212. !*** ./ts/modal/body/nodes/actions/buttons/create/consts.ts ***!
  1213. \**************************************************************/
  1214. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1215.  
  1216. __webpack_require__.r(__webpack_exports__);
  1217. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1218. /* harmony export */ ACTION_ID: () => (/* binding */ ACTION_ID)
  1219. /* harmony export */ });
  1220. const ACTION_ID = 'node-create';
  1221.  
  1222.  
  1223. /***/ }),
  1224.  
  1225. /***/ "./ts/modal/body/nodes/actions/buttons/create/css.ts":
  1226. /*!***********************************************************!*\
  1227. !*** ./ts/modal/body/nodes/actions/buttons/create/css.ts ***!
  1228. \***********************************************************/
  1229. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1230.  
  1231. __webpack_require__.r(__webpack_exports__);
  1232. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1233. /* harmony export */ "default": () => (/* binding */ generate)
  1234. /* harmony export */ });
  1235. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/buttons/create/consts.ts");
  1236. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../css */ "./ts/modal/body/nodes/actions/buttons/css.ts");
  1237.  
  1238.  
  1239. function generate() {
  1240. (0,_css__WEBPACK_IMPORTED_MODULE_1__.addColourRule)(_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, '--nodeButtonCreate');
  1241. }
  1242.  
  1243.  
  1244. /***/ }),
  1245.  
  1246. /***/ "./ts/modal/body/nodes/actions/buttons/create/index.ts":
  1247. /*!*************************************************************!*\
  1248. !*** ./ts/modal/body/nodes/actions/buttons/create/index.ts ***!
  1249. \*************************************************************/
  1250. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1251.  
  1252. __webpack_require__.r(__webpack_exports__);
  1253. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1254. /* harmony export */ mount: () => (/* binding */ mount),
  1255. /* harmony export */ shouldMount: () => (/* binding */ shouldMount)
  1256. /* harmony export */ });
  1257. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/buttons/create/consts.ts");
  1258. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button */ "./ts/modal/body/nodes/actions/buttons/create/button.ts");
  1259. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../consts */ "./ts/modal/body/nodes/actions/buttons/consts.ts");
  1260. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../button */ "./ts/modal/body/nodes/actions/buttons/button.ts");
  1261. /* harmony import */ var _position__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../position */ "./ts/modal/body/nodes/actions/buttons/position/index.ts");
  1262. /* harmony import */ var _history__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../history */ "./ts/modal/body/nodes/actions/history.ts");
  1263. /* harmony import */ var _callbacks__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../callbacks */ "./ts/modal/body/nodes/actions/callbacks/index.ts");
  1264. /* harmony import */ var _overlays__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../overlays */ "./ts/modal/body/nodes/actions/overlays/index.ts");
  1265. /* harmony import */ var _nodes_child__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @nodes/child */ "./ts/modal/body/nodes/child.ts");
  1266. /* harmony import */ var _nodes_middle__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! @nodes/middle */ "./ts/modal/body/nodes/middle.ts");
  1267.  
  1268.  
  1269.  
  1270.  
  1271.  
  1272.  
  1273.  
  1274.  
  1275.  
  1276.  
  1277. function getChild(node) {
  1278. const { seed } = node;
  1279. const child = 'children' in seed ? new _nodes_middle__WEBPACK_IMPORTED_MODULE_9__["default"](seed, node, 0) : new _nodes_child__WEBPACK_IMPORTED_MODULE_8__["default"](seed, node, 0);
  1280. child.element.addClass(_consts__WEBPACK_IMPORTED_MODULE_2__.TEST_ADD_CLASS);
  1281. return child;
  1282. }
  1283. function redo(child, ancestors) {
  1284. child.disconnect();
  1285. _callbacks__WEBPACK_IMPORTED_MODULE_6__["default"].update.triggerSub(ancestors);
  1286. }
  1287. function undo(child, parent, index, ancestors) {
  1288. child.attach(child, parent, index);
  1289. _callbacks__WEBPACK_IMPORTED_MODULE_6__["default"].update.triggerSub(ancestors);
  1290. }
  1291. function validate(child, target, button, index) {
  1292. const ancestors = child.getAncestors();
  1293. return Promise.all(_callbacks__WEBPACK_IMPORTED_MODULE_6__["default"].predicate.getSub(ancestors))
  1294. .then(() => {
  1295. _history__WEBPACK_IMPORTED_MODULE_5__.register(child, redo.bind(null, child, ancestors), undo.bind(null, child, child.parent, index, ancestors), false, true);
  1296. child.element.removeClass(_consts__WEBPACK_IMPORTED_MODULE_2__.TEST_ADD_CLASS);
  1297. // child.isActive = true;
  1298. _callbacks__WEBPACK_IMPORTED_MODULE_6__["default"].update.triggerSub(ancestors);
  1299. return child;
  1300. })
  1301. .catch((reason) => {
  1302. child.disconnect();
  1303. if (reason) {
  1304. (0,_overlays__WEBPACK_IMPORTED_MODULE_7__.showTooltip)(reason, target, button.querySelector('circle'));
  1305. }
  1306. });
  1307. }
  1308. function doAction(source, target, button, index) {
  1309. const child = getChild(source);
  1310. child.move(index === 0 ? target : target.parent, index);
  1311. return validate(child, target, button, index);
  1312. }
  1313. function onClick(node, button, isAlt) {
  1314. if (_position__WEBPACK_IMPORTED_MODULE_4__.isToggle(node, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID)) {
  1315. _position__WEBPACK_IMPORTED_MODULE_4__.reset(node);
  1316. return;
  1317. }
  1318. if (isAlt) {
  1319. _position__WEBPACK_IMPORTED_MODULE_4__.mount(node, node.seed, node, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, button, doAction);
  1320. return;
  1321. }
  1322. validate(getChild(node), node, button, 0);
  1323. }
  1324. function mount(node) {
  1325. (0,_button__WEBPACK_IMPORTED_MODULE_3__.addActionButton)(_button__WEBPACK_IMPORTED_MODULE_1__["default"], onClick, node);
  1326. }
  1327. function shouldMount(node) {
  1328. return 'seed' in node;
  1329. }
  1330.  
  1331.  
  1332. /***/ }),
  1333.  
  1334. /***/ "./ts/modal/body/nodes/actions/buttons/css.ts":
  1335. /*!****************************************************!*\
  1336. !*** ./ts/modal/body/nodes/actions/buttons/css.ts ***!
  1337. \****************************************************/
  1338. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1339.  
  1340. __webpack_require__.r(__webpack_exports__);
  1341. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1342. /* harmony export */ addColourRule: () => (/* binding */ addColourRule),
  1343. /* harmony export */ "default": () => (/* binding */ generate)
  1344. /* harmony export */ });
  1345. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/buttons/consts.ts");
  1346. /* harmony import */ var _create_css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./create/css */ "./ts/modal/body/nodes/actions/buttons/create/css.ts");
  1347. /* harmony import */ var _move_css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./move/css */ "./ts/modal/body/nodes/actions/buttons/move/css.ts");
  1348. /* harmony import */ var _disable_css__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./disable/css */ "./ts/modal/body/nodes/actions/buttons/disable/css.ts");
  1349. /* harmony import */ var _duplicate_css__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./duplicate/css */ "./ts/modal/body/nodes/actions/buttons/duplicate/css.ts");
  1350. /* harmony import */ var _position_css__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./position/css */ "./ts/modal/body/nodes/actions/buttons/position/css.ts");
  1351. /* harmony import */ var _highlight_consts__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../highlight/consts */ "./ts/modal/body/nodes/actions/highlight/consts.ts");
  1352. /* harmony import */ var _nodes_consts__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @nodes/consts */ "./ts/modal/body/nodes/consts.ts");
  1353. /* 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");
  1354. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  1355. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  1356.  
  1357.  
  1358.  
  1359.  
  1360.  
  1361.  
  1362.  
  1363.  
  1364.  
  1365.  
  1366.  
  1367. function addColourRule(actionId, strokeVar) {
  1368. (0,_modal_css__WEBPACK_IMPORTED_MODULE_10__.addRule)([
  1369. `.${_nodes_consts__WEBPACK_IMPORTED_MODULE_7__.ELEMENT_CLASSES.ELEMENT_CONTAINER}:not(.${_highlight_consts__WEBPACK_IMPORTED_MODULE_6__.HIGHLIGHT_CLASS}) > `
  1370. + `.${_nodes_consts__WEBPACK_IMPORTED_MODULE_7__.ELEMENT_CLASSES.HEAD_CONTAINER} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_7__.ELEMENT_CLASSES.BUTTON_CONTAINER} > `
  1371. + `.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}.${actionId} > svg`,
  1372. ], ['fill', `var(${strokeVar})`]);
  1373. (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} > `
  1374. + `.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}.${actionId}.${_modal_consts__WEBPACK_IMPORTED_MODULE_9__.BUTTON_ACTIVE_CLASS} > svg > g`, ['stroke', `var(${strokeVar})`]);
  1375. (0,_modal_css__WEBPACK_IMPORTED_MODULE_10__.addRule)([
  1376. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}.${actionId}.${_modal_consts__WEBPACK_IMPORTED_MODULE_9__.BUTTON_ACTIVE_CLASS}:hover > svg > circle`,
  1377. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}.${actionId}.${_modal_consts__WEBPACK_IMPORTED_MODULE_9__.BUTTON_ACTIVE_CLASS}:focus > svg > circle`,
  1378. ], ['stroke', `var(${strokeVar})`]);
  1379. }
  1380. function generate() {
  1381. (0,_create_css__WEBPACK_IMPORTED_MODULE_1__["default"])();
  1382. (0,_move_css__WEBPACK_IMPORTED_MODULE_2__["default"])();
  1383. (0,_disable_css__WEBPACK_IMPORTED_MODULE_3__["default"])();
  1384. (0,_duplicate_css__WEBPACK_IMPORTED_MODULE_4__["default"])();
  1385. (0,_position_css__WEBPACK_IMPORTED_MODULE_5__["default"])();
  1386. (0,_modal_css__WEBPACK_IMPORTED_MODULE_10__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}`, [
  1387. ['height', '100%'],
  1388. ['position', 'relative'],
  1389. ]);
  1390. (0,_modal_css__WEBPACK_IMPORTED_MODULE_10__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS} > svg`, [
  1391. ['height', '100%'],
  1392. ['transform', 'scale(1.05)'],
  1393. ]);
  1394. (0,_modal_css__WEBPACK_IMPORTED_MODULE_10__.addRule)(`.${_nodes_consts__WEBPACK_IMPORTED_MODULE_7__.ELEMENT_CLASSES.BUTTON_CONTAINER}`, [
  1395. ['white-space', 'nowrap'],
  1396. ['z-index', '1'],
  1397. ]);
  1398. // Hide prospective nodes
  1399. (0,_modal_css__WEBPACK_IMPORTED_MODULE_10__.addRule)([
  1400. `.${_nodes_consts__WEBPACK_IMPORTED_MODULE_7__.ELEMENT_CLASSES.ELEMENT_CONTAINER}.${_consts__WEBPACK_IMPORTED_MODULE_0__.TEST_ADD_CLASS}`,
  1401. `.${_nodes_consts__WEBPACK_IMPORTED_MODULE_7__.ELEMENT_CLASSES.ELEMENT_CONTAINER}.${_consts__WEBPACK_IMPORTED_MODULE_0__.TEST_REMOVE_CLASS}`,
  1402. ], [['pointer-events', 'none']]);
  1403. // Hide alt icon components
  1404. (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']);
  1405. (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']);
  1406. for (const [selector, base, contrast] of _nodes_consts__WEBPACK_IMPORTED_MODULE_7__.NODE_COLOURS) {
  1407. const buttonSelector = `${selector} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_7__.ELEMENT_CLASSES.HEAD_CONTAINER} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_7__.ELEMENT_CLASSES.BUTTON_CONTAINER}`;
  1408. (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]);
  1409. (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]);
  1410. (0,_modal_css__WEBPACK_IMPORTED_MODULE_10__.addRule)([
  1411. // Not active, focused
  1412. `${buttonSelector} > .${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}:focus > svg > g`,
  1413. `${buttonSelector} > .${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}:hover > svg > g`,
  1414. ], [['stroke', contrast]]);
  1415. (0,_modal_css__WEBPACK_IMPORTED_MODULE_10__.addRule)([`${buttonSelector} > .${_modal_consts__WEBPACK_IMPORTED_MODULE_9__.BUTTON_ACTIVE_CLASS} > svg`], [['stroke', base]]);
  1416. (0,_modal_css__WEBPACK_IMPORTED_MODULE_10__.addRule)([
  1417. // Not active, focused
  1418. `${buttonSelector} > .${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}:focus > svg`,
  1419. `${buttonSelector} > .${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}:hover > svg`,
  1420. `.${_highlight_consts__WEBPACK_IMPORTED_MODULE_6__.HIGHLIGHT_CLASS}${buttonSelector} > .${_modal_consts__WEBPACK_IMPORTED_MODULE_9__.BUTTON_ACTIVE_CLASS} > svg`,
  1421. ], [['fill', base]]);
  1422. }
  1423. }
  1424.  
  1425.  
  1426. /***/ }),
  1427.  
  1428. /***/ "./ts/modal/body/nodes/actions/buttons/disable/button.ts":
  1429. /*!***************************************************************!*\
  1430. !*** ./ts/modal/body/nodes/actions/buttons/disable/button.ts ***!
  1431. \***************************************************************/
  1432. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1433.  
  1434. __webpack_require__.r(__webpack_exports__);
  1435. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1436. /* harmony export */ BUTTON_ALT: () => (/* binding */ BUTTON_ALT),
  1437. /* harmony export */ BUTTON_DEFAULT: () => (/* binding */ BUTTON_DEFAULT)
  1438. /* harmony export */ });
  1439. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/buttons/disable/consts.ts");
  1440. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../consts */ "./ts/modal/body/nodes/actions/buttons/consts.ts");
  1441. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../button */ "./ts/modal/body/nodes/actions/buttons/button.ts");
  1442. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  1443.  
  1444.  
  1445.  
  1446.  
  1447. const gDefault = (() => {
  1448. const circle = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_3__.SVG_NAMESPACE, 'circle');
  1449. circle.setAttribute('r', '30');
  1450. circle.setAttribute('stroke-width', '10');
  1451. const line = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_3__.SVG_NAMESPACE, 'line');
  1452. line.setAttribute('stroke-linecap', 'round');
  1453. line.setAttribute('stroke-width', '10');
  1454. line.setAttribute('x1', '-30');
  1455. line.setAttribute('x2', '30');
  1456. line.setAttribute('transform', 'rotate(45)');
  1457. const g = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_3__.SVG_NAMESPACE, 'g');
  1458. g.append(circle, line);
  1459. return g;
  1460. })();
  1461. const BUTTON_DEFAULT = (0,_button__WEBPACK_IMPORTED_MODULE_2__.getNewButton)(gDefault, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID_DEFAULT, 'Toggle Enabled');
  1462. const gAlt = (() => {
  1463. const line0 = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_3__.SVG_NAMESPACE, 'line');
  1464. line0.setAttribute('stroke-linecap', 'round');
  1465. line0.setAttribute('stroke-width', '12');
  1466. line0.setAttribute('x1', '-20');
  1467. line0.setAttribute('x2', '20');
  1468. line0.setAttribute('y1', '-20');
  1469. line0.setAttribute('y2', '20');
  1470. const line1 = line0.cloneNode(true);
  1471. line1.setAttribute('transform', 'rotate(90)');
  1472. const g = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_3__.SVG_NAMESPACE, 'g');
  1473. g.append(line0, line1);
  1474. return g;
  1475. })();
  1476. const BUTTON_ALT = (0,_button__WEBPACK_IMPORTED_MODULE_2__.getNewButton)(gAlt, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID_ALT, 'Delete');
  1477. BUTTON_ALT.classList.add(_consts__WEBPACK_IMPORTED_MODULE_1__.ALT_CLASS);
  1478.  
  1479.  
  1480. /***/ }),
  1481.  
  1482. /***/ "./ts/modal/body/nodes/actions/buttons/disable/consts.ts":
  1483. /*!***************************************************************!*\
  1484. !*** ./ts/modal/body/nodes/actions/buttons/disable/consts.ts ***!
  1485. \***************************************************************/
  1486. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1487.  
  1488. __webpack_require__.r(__webpack_exports__);
  1489. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1490. /* harmony export */ ACTION_ID_ALT: () => (/* binding */ ACTION_ID_ALT),
  1491. /* harmony export */ ACTION_ID_DEFAULT: () => (/* binding */ ACTION_ID_DEFAULT),
  1492. /* harmony export */ DISABLED_CLASS: () => (/* binding */ DISABLED_CLASS)
  1493. /* harmony export */ });
  1494. const ACTION_ID_DEFAULT = 'node-active';
  1495. const ACTION_ID_ALT = 'node-delete';
  1496. const DISABLED_CLASS = 'node-disable';
  1497.  
  1498.  
  1499. /***/ }),
  1500.  
  1501. /***/ "./ts/modal/body/nodes/actions/buttons/disable/css.ts":
  1502. /*!************************************************************!*\
  1503. !*** ./ts/modal/body/nodes/actions/buttons/disable/css.ts ***!
  1504. \************************************************************/
  1505. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1506.  
  1507. __webpack_require__.r(__webpack_exports__);
  1508. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1509. /* harmony export */ "default": () => (/* binding */ generate)
  1510. /* harmony export */ });
  1511. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/buttons/disable/consts.ts");
  1512. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../css */ "./ts/modal/body/nodes/actions/buttons/css.ts");
  1513. /* harmony import */ var _nodes_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @nodes/consts */ "./ts/modal/body/nodes/consts.ts");
  1514. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  1515.  
  1516.  
  1517.  
  1518.  
  1519. function generate() {
  1520. (0,_css__WEBPACK_IMPORTED_MODULE_1__.addColourRule)(_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID_DEFAULT, '--nodeButtonDisable');
  1521. (0,_css__WEBPACK_IMPORTED_MODULE_1__.addColourRule)(_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID_ALT, '--nodeButtonDelete');
  1522. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)([
  1523. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.DISABLED_CLASS} .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.HEAD_CONTAINER} .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.BASE_CLASS} .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.VALUE}`,
  1524. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.DISABLED_CLASS} .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.HEAD_CONTAINER} .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.BASE_CLASS} .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.LABEL}`,
  1525. ], ['opacity', '0.5']);
  1526. }
  1527.  
  1528.  
  1529. /***/ }),
  1530.  
  1531. /***/ "./ts/modal/body/nodes/actions/buttons/disable/index.ts":
  1532. /*!**************************************************************!*\
  1533. !*** ./ts/modal/body/nodes/actions/buttons/disable/index.ts ***!
  1534. \**************************************************************/
  1535. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1536.  
  1537. __webpack_require__.r(__webpack_exports__);
  1538. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1539. /* harmony export */ mount: () => (/* binding */ mount),
  1540. /* harmony export */ shouldMount: () => (/* binding */ shouldMount)
  1541. /* harmony export */ });
  1542. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/buttons/disable/consts.ts");
  1543. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button */ "./ts/modal/body/nodes/actions/buttons/disable/button.ts");
  1544. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../button */ "./ts/modal/body/nodes/actions/buttons/button.ts");
  1545. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../consts */ "./ts/modal/body/nodes/actions/buttons/consts.ts");
  1546. /* harmony import */ var _position__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../position */ "./ts/modal/body/nodes/actions/buttons/position/index.ts");
  1547. /* harmony import */ var _history__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../history */ "./ts/modal/body/nodes/actions/history.ts");
  1548. /* harmony import */ var _callbacks__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../callbacks */ "./ts/modal/body/nodes/actions/callbacks/index.ts");
  1549. /* harmony import */ var _overlays__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../overlays */ "./ts/modal/body/nodes/actions/overlays/index.ts");
  1550. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  1551.  
  1552.  
  1553.  
  1554.  
  1555.  
  1556.  
  1557.  
  1558.  
  1559.  
  1560. function updateButton(button, isActive) {
  1561. button.classList[isActive ? 'remove' : 'add'](_modal_consts__WEBPACK_IMPORTED_MODULE_8__.BUTTON_ACTIVE_CLASS);
  1562. }
  1563. function toggle(node) {
  1564. node.element[`${node.isActive ? 'add' : 'remove'}Class`](_consts__WEBPACK_IMPORTED_MODULE_0__.DISABLED_CLASS);
  1565. node.isActive = !node.isActive;
  1566. }
  1567. function undo(node, parent, index, ancestors) {
  1568. node.attach(parent, index);
  1569. _callbacks__WEBPACK_IMPORTED_MODULE_6__["default"].update.triggerSub(ancestors);
  1570. }
  1571. function redo(node, ancestors) {
  1572. node.disconnect();
  1573. _callbacks__WEBPACK_IMPORTED_MODULE_6__["default"].update.triggerSub(ancestors);
  1574. }
  1575. function onClick(node, button, isAlt) {
  1576. if (isAlt) {
  1577. node.element.addClass(_consts__WEBPACK_IMPORTED_MODULE_3__.TEST_REMOVE_CLASS);
  1578. _position__WEBPACK_IMPORTED_MODULE_4__.reset(node);
  1579. }
  1580. else {
  1581. toggle(node);
  1582. }
  1583. const ancestors = node.getAncestors();
  1584. Promise.all(_callbacks__WEBPACK_IMPORTED_MODULE_6__["default"].predicate.getSub(ancestors))
  1585. .then(() => {
  1586. node.element.removeClass(_consts__WEBPACK_IMPORTED_MODULE_3__.TEST_REMOVE_CLASS);
  1587. if (isAlt) {
  1588. _history__WEBPACK_IMPORTED_MODULE_5__.register(node, undo.bind(null, node, node.parent, node.getIndex(), ancestors), redo.bind(null, node, ancestors), true, false, true);
  1589. }
  1590. else {
  1591. const act = () => {
  1592. toggle(node);
  1593. updateButton(button, node.isActive);
  1594. _callbacks__WEBPACK_IMPORTED_MODULE_6__["default"].update.triggerSub(ancestors);
  1595. };
  1596. _history__WEBPACK_IMPORTED_MODULE_5__.register(node, act, act, false);
  1597. updateButton(button, node.isActive);
  1598. }
  1599. _callbacks__WEBPACK_IMPORTED_MODULE_6__["default"].update.triggerSub(ancestors);
  1600. })
  1601. .catch((reason) => {
  1602. if (isAlt) {
  1603. node.element.removeClass(_consts__WEBPACK_IMPORTED_MODULE_3__.TEST_REMOVE_CLASS);
  1604. }
  1605. else {
  1606. toggle(node);
  1607. }
  1608. if (typeof reason === 'string') {
  1609. (0,_overlays__WEBPACK_IMPORTED_MODULE_7__.showTooltip)(reason, node, button.querySelector('circle'));
  1610. }
  1611. });
  1612. }
  1613. function mount(node) {
  1614. (0,_button__WEBPACK_IMPORTED_MODULE_2__.addActionButton)(_button__WEBPACK_IMPORTED_MODULE_1__.BUTTON_ALT, onClick, node);
  1615. const defaultButton = (0,_button__WEBPACK_IMPORTED_MODULE_2__.addActionButton)(_button__WEBPACK_IMPORTED_MODULE_1__.BUTTON_DEFAULT, onClick, node);
  1616. if (!node.isActive) {
  1617. node.element.addClass(_consts__WEBPACK_IMPORTED_MODULE_0__.DISABLED_CLASS);
  1618. updateButton(defaultButton, false);
  1619. }
  1620. }
  1621. function shouldMount(node) {
  1622. return 'seed' in node.parent;
  1623. }
  1624.  
  1625.  
  1626. /***/ }),
  1627.  
  1628. /***/ "./ts/modal/body/nodes/actions/buttons/duplicate/button.ts":
  1629. /*!*****************************************************************!*\
  1630. !*** ./ts/modal/body/nodes/actions/buttons/duplicate/button.ts ***!
  1631. \*****************************************************************/
  1632. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1633.  
  1634. __webpack_require__.r(__webpack_exports__);
  1635. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1636. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  1637. /* harmony export */ });
  1638. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/buttons/duplicate/consts.ts");
  1639. /* 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");
  1640. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  1641.  
  1642.  
  1643.  
  1644. const RADIUS = 15;
  1645. const HEIGHT = 25;
  1646. const WIDTH = 10;
  1647. const outline0 = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'path');
  1648. outline0.setAttribute('stroke-linecap', 'round');
  1649. outline0.setAttribute('stroke-width', '8');
  1650. outline0.setAttribute('fill', 'none');
  1651. outline0.setAttribute('d', `M ${WIDTH / 2 + RADIUS} ${-HEIGHT / 2}`
  1652. + `q 0 -${RADIUS} -${RADIUS} -${RADIUS}`
  1653. + `h -${WIDTH}`
  1654. + `q -${RADIUS} 0 -${RADIUS} ${RADIUS}`
  1655. + `v ${HEIGHT}`
  1656. + `q 0 ${RADIUS} ${RADIUS} ${RADIUS}`);
  1657. outline0.setAttribute('transform', `translate(-${RADIUS / 2}, -${RADIUS / 2})`);
  1658. const outline1 = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'path');
  1659. outline1.setAttribute('stroke-linecap', 'round');
  1660. outline1.setAttribute('stroke-width', '8');
  1661. outline1.setAttribute('fill', 'none');
  1662. outline1.setAttribute('d', `M ${WIDTH / 2 + RADIUS} ${-HEIGHT / 2}`
  1663. + `q 0 -${RADIUS} -${RADIUS} -${RADIUS}`
  1664. + `h -${WIDTH}`
  1665. + `q -${RADIUS} 0 -${RADIUS} ${RADIUS}`
  1666. + `v ${HEIGHT}`
  1667. + `q 0 ${RADIUS} ${RADIUS} ${RADIUS}`
  1668. + `h ${WIDTH}`
  1669. + `q ${RADIUS} 0 ${RADIUS} -${RADIUS}`
  1670. + `v -${HEIGHT}`);
  1671. outline1.setAttribute('transform', `translate(${RADIUS / 2}, ${RADIUS / 2})`);
  1672. const g = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'g');
  1673. g.setAttribute('transform', `rotate(10)`);
  1674. g.append(outline0, outline1);
  1675. 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 });
  1676. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (BUTTON);
  1677.  
  1678.  
  1679. /***/ }),
  1680.  
  1681. /***/ "./ts/modal/body/nodes/actions/buttons/duplicate/consts.ts":
  1682. /*!*****************************************************************!*\
  1683. !*** ./ts/modal/body/nodes/actions/buttons/duplicate/consts.ts ***!
  1684. \*****************************************************************/
  1685. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1686.  
  1687. __webpack_require__.r(__webpack_exports__);
  1688. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1689. /* harmony export */ ACTION_ID: () => (/* binding */ ACTION_ID)
  1690. /* harmony export */ });
  1691. const ACTION_ID = 'node-copy';
  1692.  
  1693.  
  1694. /***/ }),
  1695.  
  1696. /***/ "./ts/modal/body/nodes/actions/buttons/duplicate/css.ts":
  1697. /*!**************************************************************!*\
  1698. !*** ./ts/modal/body/nodes/actions/buttons/duplicate/css.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 */ "default": () => (/* binding */ generate)
  1705. /* harmony export */ });
  1706. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/buttons/duplicate/consts.ts");
  1707. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../css */ "./ts/modal/body/nodes/actions/buttons/css.ts");
  1708.  
  1709.  
  1710. function generate() {
  1711. (0,_css__WEBPACK_IMPORTED_MODULE_1__.addColourRule)(_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, '--nodeButtonDuplicate');
  1712. }
  1713.  
  1714.  
  1715. /***/ }),
  1716.  
  1717. /***/ "./ts/modal/body/nodes/actions/buttons/duplicate/index.ts":
  1718. /*!****************************************************************!*\
  1719. !*** ./ts/modal/body/nodes/actions/buttons/duplicate/index.ts ***!
  1720. \****************************************************************/
  1721. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1722.  
  1723. __webpack_require__.r(__webpack_exports__);
  1724. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1725. /* harmony export */ mount: () => (/* binding */ mount),
  1726. /* harmony export */ shouldMount: () => (/* binding */ shouldMount)
  1727. /* harmony export */ });
  1728. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/buttons/duplicate/consts.ts");
  1729. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button */ "./ts/modal/body/nodes/actions/buttons/duplicate/button.ts");
  1730. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../consts */ "./ts/modal/body/nodes/actions/buttons/consts.ts");
  1731. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../button */ "./ts/modal/body/nodes/actions/buttons/button.ts");
  1732. /* harmony import */ var _position__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../position */ "./ts/modal/body/nodes/actions/buttons/position/index.ts");
  1733. /* harmony import */ var _history__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../history */ "./ts/modal/body/nodes/actions/history.ts");
  1734. /* harmony import */ var _callbacks__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../callbacks */ "./ts/modal/body/nodes/actions/callbacks/index.ts");
  1735. /* harmony import */ var _overlays__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../overlays */ "./ts/modal/body/nodes/actions/overlays/index.ts");
  1736.  
  1737.  
  1738.  
  1739.  
  1740.  
  1741.  
  1742.  
  1743.  
  1744. function undo(node, ancestors) {
  1745. node.disconnect();
  1746. _callbacks__WEBPACK_IMPORTED_MODULE_6__["default"].update.triggerSub(ancestors);
  1747. }
  1748. function redo(node, parent, index, ancestors) {
  1749. node.attach(parent, index);
  1750. _callbacks__WEBPACK_IMPORTED_MODULE_6__["default"].update.triggerSub(ancestors);
  1751. }
  1752. function validate(copy, target, button, index) {
  1753. const ancestors = copy.getAncestors();
  1754. return Promise.all(_callbacks__WEBPACK_IMPORTED_MODULE_6__["default"].predicate.getSub(ancestors))
  1755. .then(() => {
  1756. _history__WEBPACK_IMPORTED_MODULE_5__.register(copy, undo.bind(null, copy, ancestors), redo.bind(null, copy, copy.parent, index, ancestors), false, true);
  1757. copy.element.removeClass(_consts__WEBPACK_IMPORTED_MODULE_2__.TEST_ADD_CLASS);
  1758. _callbacks__WEBPACK_IMPORTED_MODULE_6__["default"].update.triggerSub(ancestors);
  1759. return copy;
  1760. })
  1761. .catch((reason) => {
  1762. copy.disconnect();
  1763. if (reason) {
  1764. (0,_overlays__WEBPACK_IMPORTED_MODULE_7__.showTooltip)(reason, target, button.querySelector('circle'));
  1765. }
  1766. });
  1767. }
  1768. function getCopy(node) {
  1769. const copy = node.duplicate();
  1770. copy.element.addClass(_consts__WEBPACK_IMPORTED_MODULE_2__.TEST_ADD_CLASS);
  1771. return copy;
  1772. }
  1773. function doAction(source, target, button, index) {
  1774. const copy = getCopy(source);
  1775. copy.move(index === 0 ? target : target.parent, index);
  1776. return validate(copy, target, button, index);
  1777. }
  1778. function onClick(node, button, isAlt) {
  1779. if (_position__WEBPACK_IMPORTED_MODULE_4__.isToggle(node, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID)) {
  1780. _position__WEBPACK_IMPORTED_MODULE_4__.reset(node);
  1781. return;
  1782. }
  1783. if (isAlt) {
  1784. _position__WEBPACK_IMPORTED_MODULE_4__.mount(node, node, node.parent, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, button, doAction);
  1785. return;
  1786. }
  1787. const copy = getCopy(node);
  1788. validate(copy, node, button, copy.getIndex());
  1789. }
  1790. function mount(node) {
  1791. (0,_button__WEBPACK_IMPORTED_MODULE_3__.addActionButton)(_button__WEBPACK_IMPORTED_MODULE_1__["default"], onClick, node);
  1792. }
  1793. function shouldMount(node) {
  1794. return 'seed' in node.parent;
  1795. }
  1796.  
  1797.  
  1798. /***/ }),
  1799.  
  1800. /***/ "./ts/modal/body/nodes/actions/buttons/move/button.ts":
  1801. /*!************************************************************!*\
  1802. !*** ./ts/modal/body/nodes/actions/buttons/move/button.ts ***!
  1803. \************************************************************/
  1804. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1805.  
  1806. __webpack_require__.r(__webpack_exports__);
  1807. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1808. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  1809. /* harmony export */ });
  1810. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/buttons/move/consts.ts");
  1811. /* 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");
  1812. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  1813.  
  1814.  
  1815.  
  1816. const arrowTrunk = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'line');
  1817. arrowTrunk.setAttribute('stroke-linecap', 'round');
  1818. arrowTrunk.setAttribute('stroke-width', '10');
  1819. arrowTrunk.setAttribute('y1', '-30');
  1820. arrowTrunk.setAttribute('y2', '30');
  1821. const arrowBottomLeft = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'line');
  1822. arrowBottomLeft.setAttribute('stroke-linecap', 'round');
  1823. arrowBottomLeft.setAttribute('stroke-width', '10');
  1824. arrowBottomLeft.setAttribute('x2', '-12');
  1825. arrowBottomLeft.setAttribute('y1', '27');
  1826. arrowBottomLeft.setAttribute('y2', '15');
  1827. const arrowBottomRight = arrowBottomLeft.cloneNode(true);
  1828. arrowBottomRight.setAttribute('x2', '12');
  1829. const g = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'g');
  1830. g.append(arrowTrunk, arrowBottomLeft, arrowBottomRight);
  1831. const BUTTON = (0,_position_button_alt__WEBPACK_IMPORTED_MODULE_1__.getPositionedButton)(g, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, 'Move');
  1832. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (BUTTON);
  1833.  
  1834.  
  1835. /***/ }),
  1836.  
  1837. /***/ "./ts/modal/body/nodes/actions/buttons/move/consts.ts":
  1838. /*!************************************************************!*\
  1839. !*** ./ts/modal/body/nodes/actions/buttons/move/consts.ts ***!
  1840. \************************************************************/
  1841. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1842.  
  1843. __webpack_require__.r(__webpack_exports__);
  1844. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1845. /* harmony export */ ACTION_ID: () => (/* binding */ ACTION_ID)
  1846. /* harmony export */ });
  1847. const ACTION_ID = 'node-move';
  1848.  
  1849.  
  1850. /***/ }),
  1851.  
  1852. /***/ "./ts/modal/body/nodes/actions/buttons/move/css.ts":
  1853. /*!*********************************************************!*\
  1854. !*** ./ts/modal/body/nodes/actions/buttons/move/css.ts ***!
  1855. \*********************************************************/
  1856. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1857.  
  1858. __webpack_require__.r(__webpack_exports__);
  1859. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1860. /* harmony export */ "default": () => (/* binding */ generate)
  1861. /* harmony export */ });
  1862. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/buttons/move/consts.ts");
  1863. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../css */ "./ts/modal/body/nodes/actions/buttons/css.ts");
  1864.  
  1865.  
  1866. function generate() {
  1867. (0,_css__WEBPACK_IMPORTED_MODULE_1__.addColourRule)(_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, '--nodeButtonMove');
  1868. }
  1869.  
  1870.  
  1871. /***/ }),
  1872.  
  1873. /***/ "./ts/modal/body/nodes/actions/buttons/move/index.ts":
  1874. /*!***********************************************************!*\
  1875. !*** ./ts/modal/body/nodes/actions/buttons/move/index.ts ***!
  1876. \***********************************************************/
  1877. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1878.  
  1879. __webpack_require__.r(__webpack_exports__);
  1880. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1881. /* harmony export */ mount: () => (/* binding */ mount),
  1882. /* harmony export */ shouldMount: () => (/* binding */ shouldMount)
  1883. /* harmony export */ });
  1884. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/buttons/move/consts.ts");
  1885. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button */ "./ts/modal/body/nodes/actions/buttons/move/button.ts");
  1886. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../consts */ "./ts/modal/body/nodes/actions/buttons/consts.ts");
  1887. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../button */ "./ts/modal/body/nodes/actions/buttons/button.ts");
  1888. /* harmony import */ var _position__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../position */ "./ts/modal/body/nodes/actions/buttons/position/index.ts");
  1889. /* harmony import */ var _history__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../history */ "./ts/modal/body/nodes/actions/history.ts");
  1890. /* harmony import */ var _callbacks__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../callbacks */ "./ts/modal/body/nodes/actions/callbacks/index.ts");
  1891. /* harmony import */ var _overlays__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../overlays */ "./ts/modal/body/nodes/actions/overlays/index.ts");
  1892. /* harmony import */ var _nodes_pools__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @nodes/pools */ "./ts/modal/body/nodes/pools.ts");
  1893.  
  1894.  
  1895.  
  1896.  
  1897.  
  1898.  
  1899.  
  1900.  
  1901.  
  1902. function getAncestorBranches(node, temp) {
  1903. if (node.parent === temp.parent) {
  1904. return [node.getAncestors()];
  1905. }
  1906. const oldAncestors = node.getAncestors();
  1907. const newAncestors = temp.getAncestors();
  1908. for (let i = Math.min(oldAncestors.length, newAncestors.length) - 1; i > 1; --i) {
  1909. if (oldAncestors[oldAncestors.length - i] === newAncestors[newAncestors.length - i]) {
  1910. return [oldAncestors.slice(0, -i), newAncestors];
  1911. }
  1912. }
  1913. // Branch is from the root
  1914. return [oldAncestors.slice(0, -1), newAncestors];
  1915. }
  1916. function act(node, to, index, ancestorBranches) {
  1917. node.move(to, index);
  1918. for (const branch of ancestorBranches) {
  1919. _callbacks__WEBPACK_IMPORTED_MODULE_6__["default"].update.triggerSub(branch);
  1920. }
  1921. }
  1922. function doAction(source, target, button, index) {
  1923. const priorIndex = source.getIndex();
  1924. if (index === priorIndex) {
  1925. return source;
  1926. }
  1927. const temp = source.duplicate();
  1928. source.element.addClass(_consts__WEBPACK_IMPORTED_MODULE_2__.TEST_REMOVE_CLASS);
  1929. temp.element.addClass(_consts__WEBPACK_IMPORTED_MODULE_2__.TEST_ADD_CLASS);
  1930. temp.move(index === 0 ? target : target.parent, index);
  1931. const ancestorBranches = getAncestorBranches(source, temp);
  1932. return Promise.all(ancestorBranches.map((branch) => Promise.all(_callbacks__WEBPACK_IMPORTED_MODULE_6__["default"].predicate.getSub(branch))))
  1933. .then(() => {
  1934. const priorParent = source.parent;
  1935. source.move(index === 0 ? target : target.parent, index);
  1936. _history__WEBPACK_IMPORTED_MODULE_5__.register(source, act.bind(null, source, priorParent, priorIndex, ancestorBranches), act.bind(null, source, source.parent, index, ancestorBranches));
  1937. for (const branch of ancestorBranches) {
  1938. _callbacks__WEBPACK_IMPORTED_MODULE_6__["default"].update.triggerSub(branch);
  1939. }
  1940. return source;
  1941. })
  1942. .catch((reason) => {
  1943. if (reason) {
  1944. (0,_overlays__WEBPACK_IMPORTED_MODULE_7__.showTooltip)(reason, source, button.querySelector('circle'));
  1945. }
  1946. })
  1947. .finally(() => {
  1948. temp.disconnect();
  1949. source.element.removeClass(_consts__WEBPACK_IMPORTED_MODULE_2__.TEST_REMOVE_CLASS);
  1950. });
  1951. }
  1952. function hasDestinations(node) {
  1953. return node.parent.children.length > 1 || (0,_nodes_pools__WEBPACK_IMPORTED_MODULE_8__.get)(node.parent).length > 1;
  1954. }
  1955. function onClick(node, button, isAlt) {
  1956. if (_position__WEBPACK_IMPORTED_MODULE_4__.isToggle(node, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID)) {
  1957. _position__WEBPACK_IMPORTED_MODULE_4__.reset(node);
  1958. return;
  1959. }
  1960. if (isAlt) {
  1961. if (hasDestinations(node)) {
  1962. _position__WEBPACK_IMPORTED_MODULE_4__.mount(node, node, node.parent, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, button, doAction);
  1963. }
  1964. else {
  1965. (0,_overlays__WEBPACK_IMPORTED_MODULE_7__.showTooltip)('No other valid locations found.', node, button.querySelector('circle'));
  1966. }
  1967. return;
  1968. }
  1969. const newIndex = node.getIndex() + 2;
  1970. if (newIndex < node.parent.children.length + 1) {
  1971. doAction(node, node, button, newIndex);
  1972. }
  1973. else {
  1974. (0,_overlays__WEBPACK_IMPORTED_MODULE_7__.showTooltip)('Node can not be moved down.', node, button.querySelector('circle'));
  1975. }
  1976. }
  1977. function mount(node) {
  1978. (0,_button__WEBPACK_IMPORTED_MODULE_3__.addActionButton)(_button__WEBPACK_IMPORTED_MODULE_1__["default"], onClick, node);
  1979. }
  1980. function shouldMount(node) {
  1981. return Boolean(node.parent.seed) || ('poolId' in node.parent);
  1982. }
  1983.  
  1984.  
  1985. /***/ }),
  1986.  
  1987. /***/ "./ts/modal/body/nodes/actions/buttons/position/button/alt.ts":
  1988. /*!********************************************************************!*\
  1989. !*** ./ts/modal/body/nodes/actions/buttons/position/button/alt.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 */ getPositionedButton: () => (/* binding */ getPositionedButton)
  1996. /* harmony export */ });
  1997. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../consts */ "./ts/modal/body/nodes/actions/buttons/consts.ts");
  1998. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../button */ "./ts/modal/body/nodes/actions/buttons/button.ts");
  1999. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  2000.  
  2001.  
  2002.  
  2003. const G_ALT = (() => {
  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 arrowTopRight = arrowBottomLeft.cloneNode(true);
  2018. arrowTopRight.setAttribute('transform', 'rotate(180)');
  2019. const arrowTopLeft = arrowBottomRight.cloneNode(true);
  2020. arrowTopLeft.setAttribute('transform', 'rotate(180)');
  2021. const g = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'g');
  2022. g.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.ALT_CLASS);
  2023. g.append(arrowTrunk, arrowBottomLeft, arrowBottomRight, arrowTopRight, arrowTopLeft);
  2024. return g;
  2025. })();
  2026. function getPositionedButton(gDefault, actionId, description, transform = {}) {
  2027. const g = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'g');
  2028. const gAlt = G_ALT.cloneNode(true);
  2029. gAlt.setAttribute('transform', Object.entries(transform).map(([key, value]) => `${key}(${value})`).join(' '));
  2030. g.append(gAlt, gDefault);
  2031. return (0,_button__WEBPACK_IMPORTED_MODULE_1__.getNewButton)(g, actionId, description);
  2032. }
  2033.  
  2034.  
  2035. /***/ }),
  2036.  
  2037. /***/ "./ts/modal/body/nodes/actions/buttons/position/button/index.ts":
  2038. /*!**********************************************************************!*\
  2039. !*** ./ts/modal/body/nodes/actions/buttons/position/button/index.ts ***!
  2040. \**********************************************************************/
  2041. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2042.  
  2043. __webpack_require__.r(__webpack_exports__);
  2044. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2045. /* harmony export */ BUTTON_PARENT: () => (/* binding */ BUTTON_PARENT),
  2046. /* harmony export */ BUTTON_SIBLING: () => (/* binding */ BUTTON_SIBLING)
  2047. /* harmony export */ });
  2048. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../consts */ "./ts/modal/body/nodes/actions/buttons/position/consts.ts");
  2049. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../button */ "./ts/modal/body/nodes/actions/buttons/button.ts");
  2050. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  2051.  
  2052.  
  2053.  
  2054. const arrowTrunk = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'line');
  2055. arrowTrunk.setAttribute('stroke-linecap', 'round');
  2056. arrowTrunk.setAttribute('stroke-width', '10');
  2057. arrowTrunk.setAttribute('y1', '-30');
  2058. arrowTrunk.setAttribute('y2', '30');
  2059. const arrowBottomLeft = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'line');
  2060. arrowBottomLeft.setAttribute('stroke-linecap', 'round');
  2061. arrowBottomLeft.setAttribute('stroke-width', '10');
  2062. arrowBottomLeft.setAttribute('x2', '-12');
  2063. arrowBottomLeft.setAttribute('y1', '27');
  2064. arrowBottomLeft.setAttribute('y2', '15');
  2065. const arrowBottomRight = arrowBottomLeft.cloneNode(true);
  2066. arrowBottomRight.setAttribute('x2', '12');
  2067. const gMain = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'g');
  2068. gMain.append(arrowTrunk, arrowBottomLeft, arrowBottomRight);
  2069. const gSibling = gMain.cloneNode(true);
  2070. const BUTTON_SIBLING = (0,_button__WEBPACK_IMPORTED_MODULE_1__.getNewButton)(gSibling, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, 'Select After');
  2071. const gParent = gMain.cloneNode(true);
  2072. gParent.setAttribute('transform', 'rotate(-45)');
  2073. const BUTTON_PARENT = (0,_button__WEBPACK_IMPORTED_MODULE_1__.getNewButton)(gParent, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, 'Select Into');
  2074.  
  2075.  
  2076. /***/ }),
  2077.  
  2078. /***/ "./ts/modal/body/nodes/actions/buttons/position/consts.ts":
  2079. /*!****************************************************************!*\
  2080. !*** ./ts/modal/body/nodes/actions/buttons/position/consts.ts ***!
  2081. \****************************************************************/
  2082. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2083.  
  2084. __webpack_require__.r(__webpack_exports__);
  2085. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2086. /* harmony export */ ACTION_ID: () => (/* binding */ ACTION_ID)
  2087. /* harmony export */ });
  2088. const ACTION_ID = 'node-position';
  2089.  
  2090.  
  2091. /***/ }),
  2092.  
  2093. /***/ "./ts/modal/body/nodes/actions/buttons/position/css.ts":
  2094. /*!*************************************************************!*\
  2095. !*** ./ts/modal/body/nodes/actions/buttons/position/css.ts ***!
  2096. \*************************************************************/
  2097. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2098.  
  2099. __webpack_require__.r(__webpack_exports__);
  2100. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2101. /* harmony export */ "default": () => (/* binding */ generate)
  2102. /* harmony export */ });
  2103. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/buttons/position/consts.ts");
  2104. /* harmony import */ var _focus_consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../focus/consts */ "./ts/modal/body/nodes/actions/focus/consts.ts");
  2105. /* harmony import */ var _nodes_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @nodes/consts */ "./ts/modal/body/nodes/consts.ts");
  2106. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  2107. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  2108.  
  2109.  
  2110.  
  2111.  
  2112.  
  2113. function generate() {
  2114. (0,_modal_css__WEBPACK_IMPORTED_MODULE_4__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ROOT_CLASS}.${_focus_consts__WEBPACK_IMPORTED_MODULE_1__.FOCUS_CLASS} `
  2115. + `.${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.ELEMENT_CONTAINER}:not(.${_focus_consts__WEBPACK_IMPORTED_MODULE_1__.FOCUS_CLASS})`, ['display', 'none']);
  2116. (0,_modal_css__WEBPACK_IMPORTED_MODULE_4__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID} button:not(.${_modal_consts__WEBPACK_IMPORTED_MODULE_3__.BUTTON_ACTIVE_CLASS})`, ['display', 'none']);
  2117. (0,_modal_css__WEBPACK_IMPORTED_MODULE_4__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID} .${_modal_consts__WEBPACK_IMPORTED_MODULE_3__.BUTTON_ACTIVE_CLASS}:not(:has(~ .${_modal_consts__WEBPACK_IMPORTED_MODULE_3__.BUTTON_ACTIVE_CLASS}))`, [
  2118. ['border-top-right-radius', '0.8em'],
  2119. ['border-bottom-right-radius', '0.8em'],
  2120. ]);
  2121. }
  2122.  
  2123.  
  2124. /***/ }),
  2125.  
  2126. /***/ "./ts/modal/body/nodes/actions/buttons/position/index.ts":
  2127. /*!***************************************************************!*\
  2128. !*** ./ts/modal/body/nodes/actions/buttons/position/index.ts ***!
  2129. \***************************************************************/
  2130. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2131.  
  2132. __webpack_require__.r(__webpack_exports__);
  2133. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2134. /* harmony export */ getButton: () => (/* binding */ getButton),
  2135. /* harmony export */ isActive: () => (/* binding */ isActive),
  2136. /* harmony export */ isToggle: () => (/* binding */ isToggle),
  2137. /* harmony export */ mount: () => (/* binding */ mount),
  2138. /* harmony export */ reset: () => (/* binding */ reset)
  2139. /* harmony export */ });
  2140. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/buttons/position/consts.ts");
  2141. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button */ "./ts/modal/body/nodes/actions/buttons/position/button/index.ts");
  2142. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../button */ "./ts/modal/body/nodes/actions/buttons/button.ts");
  2143. /* harmony import */ var _focus__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../focus */ "./ts/modal/body/nodes/actions/focus/index.ts");
  2144. /* harmony import */ var _highlight__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../highlight */ "./ts/modal/body/nodes/actions/highlight/index.ts");
  2145. /* harmony import */ var _scroll__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../scroll */ "./ts/modal/body/nodes/actions/scroll.ts");
  2146. /* harmony import */ var _nodes_pools__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @nodes/pools */ "./ts/modal/body/nodes/pools.ts");
  2147. /* harmony import */ var _modal_body__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @/modal/body */ "./ts/modal/body/index.ts");
  2148. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  2149. var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
  2150. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  2151. return new (P || (P = Promise))(function (resolve, reject) {
  2152. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  2153. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  2154. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  2155. step((generator = generator.apply(thisArg, _arguments || [])).next());
  2156. });
  2157. };
  2158.  
  2159.  
  2160.  
  2161.  
  2162.  
  2163.  
  2164.  
  2165.  
  2166.  
  2167. const destinations = [];
  2168. let origin;
  2169. function isActive() {
  2170. return Boolean(origin);
  2171. }
  2172. function isToggle(source, id) {
  2173. return isActive() && origin.source === source && origin.actionId === id;
  2174. }
  2175. function setActive(doActivate = true) {
  2176. (0,_modal_body__WEBPACK_IMPORTED_MODULE_7__.setActive)(origin.button, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, doActivate);
  2177. (0,_focus__WEBPACK_IMPORTED_MODULE_3__.reset)();
  2178. (0,_focus__WEBPACK_IMPORTED_MODULE_3__.focus)(doActivate, origin.source, false);
  2179. (0,_focus__WEBPACK_IMPORTED_MODULE_3__.focusBranch)(doActivate, origin.source, doActivate);
  2180. origin.button.setAttribute('tabindex', doActivate ? '0' : '-1');
  2181. }
  2182. function reset(scrollTarget) {
  2183. if (!origin) {
  2184. return;
  2185. }
  2186. for (const { node, isParent, button } of destinations) {
  2187. (0,_focus__WEBPACK_IMPORTED_MODULE_3__.focusBranch)(false, node, isParent);
  2188. button.remove();
  2189. }
  2190. destinations.length = 0;
  2191. (0,_highlight__WEBPACK_IMPORTED_MODULE_4__.removeSustained)(origin.source);
  2192. setActive(false);
  2193. (0,_scroll__WEBPACK_IMPORTED_MODULE_5__.scroll)(scrollTarget !== null && scrollTarget !== void 0 ? scrollTarget : origin.source);
  2194. (0,_highlight__WEBPACK_IMPORTED_MODULE_4__.setActive)(scrollTarget !== null && scrollTarget !== void 0 ? scrollTarget : origin.source, true);
  2195. origin = undefined;
  2196. }
  2197. function getButton(node, actionId, onClick, isParent) {
  2198. 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);
  2199. button.classList.add(actionId, _modal_consts__WEBPACK_IMPORTED_MODULE_8__.BUTTON_ACTIVE_CLASS);
  2200. button.setAttribute('tabindex', '0');
  2201. return button;
  2202. }
  2203. function getBoundCallback(callback, target, index) {
  2204. return (_, button) => __awaiter(this, void 0, void 0, function* () {
  2205. const node = yield callback(origin.source, target, button, index);
  2206. if (node) {
  2207. reset(node);
  2208. }
  2209. });
  2210. }
  2211. function addButtons(parent, actionId, callback) {
  2212. (0,_focus__WEBPACK_IMPORTED_MODULE_3__.focusBranch)(true, parent);
  2213. destinations.push({
  2214. node: parent,
  2215. isParent: true,
  2216. button: getButton(parent, actionId, getBoundCallback(callback, parent, 0), true),
  2217. });
  2218. for (const [i, target] of parent.children.entries()) {
  2219. if (target === origin.source) {
  2220. continue;
  2221. }
  2222. (0,_focus__WEBPACK_IMPORTED_MODULE_3__.focusBranch)(true, target, false);
  2223. destinations.push({
  2224. node: target,
  2225. isParent: false,
  2226. button: getButton(target, actionId, getBoundCallback(callback, target, i + 1), false),
  2227. });
  2228. }
  2229. }
  2230. function mount(source, child, parent, actionId, button, callback) {
  2231. reset();
  2232. origin = {
  2233. source,
  2234. child,
  2235. parent,
  2236. button,
  2237. actionId,
  2238. };
  2239. setActive();
  2240. for (const pool of (0,_nodes_pools__WEBPACK_IMPORTED_MODULE_6__.get)(parent)) {
  2241. addButtons(pool, actionId, callback);
  2242. }
  2243. (0,_highlight__WEBPACK_IMPORTED_MODULE_4__.addSustained)(source);
  2244. return destinations.length;
  2245. }
  2246.  
  2247.  
  2248. /***/ }),
  2249.  
  2250. /***/ "./ts/modal/body/nodes/actions/callbacks/index.ts":
  2251. /*!********************************************************!*\
  2252. !*** ./ts/modal/body/nodes/actions/callbacks/index.ts ***!
  2253. \********************************************************/
  2254. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2255.  
  2256. __webpack_require__.r(__webpack_exports__);
  2257. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2258. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  2259. /* harmony export */ });
  2260. /* harmony import */ var _update__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./update */ "./ts/modal/body/nodes/actions/callbacks/update.ts");
  2261. /* harmony import */ var _predicate__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./predicate */ "./ts/modal/body/nodes/actions/callbacks/predicate.ts");
  2262.  
  2263.  
  2264. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({ update: _update__WEBPACK_IMPORTED_MODULE_0__, predicate: _predicate__WEBPACK_IMPORTED_MODULE_1__ });
  2265.  
  2266.  
  2267. /***/ }),
  2268.  
  2269. /***/ "./ts/modal/body/nodes/actions/callbacks/predicate.ts":
  2270. /*!************************************************************!*\
  2271. !*** ./ts/modal/body/nodes/actions/callbacks/predicate.ts ***!
  2272. \************************************************************/
  2273. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2274.  
  2275. __webpack_require__.r(__webpack_exports__);
  2276. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2277. /* harmony export */ getAll: () => (/* binding */ getAll),
  2278. /* harmony export */ getSub: () => (/* binding */ getSub)
  2279. /* harmony export */ });
  2280. /* harmony import */ var _predicate__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @/predicate */ "./ts/predicate.ts");
  2281. var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
  2282. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  2283. return new (P || (P = Promise))(function (resolve, reject) {
  2284. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  2285. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  2286. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  2287. step((generator = generator.apply(thisArg, _arguments || [])).next());
  2288. });
  2289. };
  2290.  
  2291. let ongoing;
  2292. function handle(promises) {
  2293. return __awaiter(this, void 0, void 0, function* () {
  2294. ongoing === null || ongoing === void 0 ? void 0 : ongoing(true);
  2295. const callback = new Promise((resolve) => {
  2296. ongoing = resolve;
  2297. });
  2298. const response = Promise.all(promises);
  2299. if (yield Promise.any([
  2300. callback,
  2301. // result of Promise.prototype.finally() gets ignored unless it's a rejection sigh
  2302. response
  2303. .then(() => false)
  2304. .catch(() => false),
  2305. ])) {
  2306. return false;
  2307. }
  2308. return yield response;
  2309. });
  2310. }
  2311. function getSub(ancestors) {
  2312. const responses = [];
  2313. if ('childPredicate' in ancestors[0]) {
  2314. responses.push((0,_predicate__WEBPACK_IMPORTED_MODULE_0__.getPredicatePromise)(ancestors[0].childPredicate()));
  2315. }
  2316. for (const ancestor of ancestors) {
  2317. if ('descendantPredicate' in ancestor) {
  2318. responses.push((0,_predicate__WEBPACK_IMPORTED_MODULE_0__.getPredicatePromise)(ancestor.descendantPredicate()));
  2319. }
  2320. }
  2321. return responses;
  2322. }
  2323. function getAll(node) {
  2324. if (node.forceValid || ('options' in node && node.options.includes(node.value))) {
  2325. return handle(getSub(node.getAncestors()));
  2326. }
  2327. if ('predicate' in node) {
  2328. return handle([(0,_predicate__WEBPACK_IMPORTED_MODULE_0__.getPredicatePromise)(node.predicate()), ...getSub(node.getAncestors())]);
  2329. }
  2330. throw undefined;
  2331. }
  2332.  
  2333.  
  2334. /***/ }),
  2335.  
  2336. /***/ "./ts/modal/body/nodes/actions/callbacks/update.ts":
  2337. /*!*********************************************************!*\
  2338. !*** ./ts/modal/body/nodes/actions/callbacks/update.ts ***!
  2339. \*********************************************************/
  2340. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2341.  
  2342. __webpack_require__.r(__webpack_exports__);
  2343. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2344. /* harmony export */ handle: () => (/* binding */ handle),
  2345. /* harmony export */ triggerAll: () => (/* binding */ triggerAll),
  2346. /* harmony export */ triggerSub: () => (/* binding */ triggerSub)
  2347. /* harmony export */ });
  2348. /* harmony import */ var _hide__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../hide */ "./ts/modal/body/nodes/actions/hide/index.ts");
  2349. var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
  2350. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  2351. return new (P || (P = Promise))(function (resolve, reject) {
  2352. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  2353. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  2354. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  2355. step((generator = generator.apply(thisArg, _arguments || [])).next());
  2356. });
  2357. };
  2358.  
  2359. const maps = {
  2360. onUpdate: new Map(),
  2361. onChildUpdate: new Map(),
  2362. onDescendantUpdate: new Map(),
  2363. };
  2364. function isOutdated(response, map, node) {
  2365. return __awaiter(this, void 0, void 0, function* () {
  2366. if (map.has(node)) {
  2367. map.get(node)(false);
  2368. }
  2369. const callback = new Promise((resolve) => {
  2370. map.set(node, resolve);
  2371. });
  2372. if (yield Promise.any([
  2373. callback,
  2374. Promise.resolve(response)
  2375. .then(() => true)
  2376. .catch(() => true),
  2377. ])) {
  2378. map.delete(node);
  2379. return false;
  2380. }
  2381. return true;
  2382. });
  2383. }
  2384. function handle(_response, property, node) {
  2385. return __awaiter(this, void 0, void 0, function* () {
  2386. if (yield isOutdated(_response, maps[property], node)) {
  2387. return;
  2388. }
  2389. const response = yield _response;
  2390. if (typeof response !== 'object') {
  2391. return;
  2392. }
  2393. if ('hide' in response && typeof response.hide === 'object') {
  2394. for (const [id, doHide] of Object.entries(response.hide)) {
  2395. if (typeof doHide === 'boolean') {
  2396. (0,_hide__WEBPACK_IMPORTED_MODULE_0__["default"])(node, id, doHide);
  2397. }
  2398. }
  2399. }
  2400. });
  2401. }
  2402. function trigger(node, property) {
  2403. if (property in node) {
  2404. handle(node[property](), property, node);
  2405. }
  2406. }
  2407. function triggerSub(ancestors) {
  2408. trigger(ancestors[0], 'onChildUpdate');
  2409. for (const ancestor of ancestors) {
  2410. trigger(ancestor, 'onDescendantUpdate');
  2411. }
  2412. }
  2413. function triggerAll(node) {
  2414. trigger(node, 'onUpdate');
  2415. triggerSub(node.getAncestors());
  2416. }
  2417.  
  2418.  
  2419. /***/ }),
  2420.  
  2421. /***/ "./ts/modal/body/nodes/actions/css.ts":
  2422. /*!********************************************!*\
  2423. !*** ./ts/modal/body/nodes/actions/css.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 */ "default": () => (/* binding */ generate)
  2430. /* harmony export */ });
  2431. /* harmony import */ var _edit_css__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./edit/css */ "./ts/modal/body/nodes/actions/edit/css.ts");
  2432. /* harmony import */ var _highlight_css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./highlight/css */ "./ts/modal/body/nodes/actions/highlight/css.ts");
  2433. /* harmony import */ var _focus_css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./focus/css */ "./ts/modal/body/nodes/actions/focus/css.ts");
  2434. /* harmony import */ var _overlays_css__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./overlays/css */ "./ts/modal/body/nodes/actions/overlays/css.ts");
  2435. /* harmony import */ var _buttons_css__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./buttons/css */ "./ts/modal/body/nodes/actions/buttons/css.ts");
  2436.  
  2437.  
  2438.  
  2439.  
  2440.  
  2441. function generate() {
  2442. (0,_edit_css__WEBPACK_IMPORTED_MODULE_0__["default"])();
  2443. (0,_highlight_css__WEBPACK_IMPORTED_MODULE_1__["default"])();
  2444. (0,_focus_css__WEBPACK_IMPORTED_MODULE_2__["default"])();
  2445. (0,_overlays_css__WEBPACK_IMPORTED_MODULE_3__["default"])();
  2446. (0,_buttons_css__WEBPACK_IMPORTED_MODULE_4__["default"])();
  2447. }
  2448.  
  2449.  
  2450. /***/ }),
  2451.  
  2452. /***/ "./ts/modal/body/nodes/actions/edit/consts.ts":
  2453. /*!****************************************************!*\
  2454. !*** ./ts/modal/body/nodes/actions/edit/consts.ts ***!
  2455. \****************************************************/
  2456. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2457.  
  2458. __webpack_require__.r(__webpack_exports__);
  2459. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2460. /* harmony export */ ACTIVE_CLASS: () => (/* binding */ ACTIVE_CLASS),
  2461. /* harmony export */ INVALID_BACKGROUND_CLASS: () => (/* binding */ INVALID_BACKGROUND_CLASS),
  2462. /* harmony export */ INVALID_CLASS: () => (/* binding */ INVALID_CLASS),
  2463. /* harmony export */ VALID_BACKGROUND_CLASS: () => (/* binding */ VALID_BACKGROUND_CLASS),
  2464. /* harmony export */ VALID_CLASS: () => (/* binding */ VALID_CLASS)
  2465. /* harmony export */ });
  2466. const ACTIVE_CLASS = 'edit-active';
  2467. const VALID_CLASS = 'edit-valid';
  2468. const INVALID_CLASS = 'edit-invalid';
  2469. const VALID_BACKGROUND_CLASS = 'background-valid';
  2470. const INVALID_BACKGROUND_CLASS = 'background-invalid';
  2471.  
  2472.  
  2473. /***/ }),
  2474.  
  2475. /***/ "./ts/modal/body/nodes/actions/edit/css.ts":
  2476. /*!*************************************************!*\
  2477. !*** ./ts/modal/body/nodes/actions/edit/css.ts ***!
  2478. \*************************************************/
  2479. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2480.  
  2481. __webpack_require__.r(__webpack_exports__);
  2482. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2483. /* harmony export */ "default": () => (/* binding */ generate)
  2484. /* harmony export */ });
  2485. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/edit/consts.ts");
  2486. /* harmony import */ var _nodes_consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @nodes/consts */ "./ts/modal/body/nodes/consts.ts");
  2487. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  2488.  
  2489.  
  2490.  
  2491. function generate() {
  2492. // Use pointer when the node has a value and isn't being edited
  2493. (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']);
  2494. (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']);
  2495. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ELEMENT_CLASSES.VALUE}`, [
  2496. ['flex-grow', '1'],
  2497. ['outline', 'none'],
  2498. ['min-width', '0'],
  2499. ]);
  2500. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ELEMENT_CLASSES.VALUE}[type="checkbox"]`, [
  2501. ['min-height', '1em'],
  2502. ['min-width', '1em'],
  2503. ]);
  2504. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ELEMENT_CLASSES.VALUE}[type="color"]`, [
  2505. ['height', '1.3em'],
  2506. ['cursor', 'pointer'],
  2507. ]);
  2508. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.VALID_BACKGROUND_CLASS}`, ['background-color', 'var(--validBackground)']);
  2509. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.INVALID_BACKGROUND_CLASS}`, ['background-color', 'var(--invalidBackground)']);
  2510. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([`.${_consts__WEBPACK_IMPORTED_MODULE_0__.VALID_BACKGROUND_CLASS}`, `.${_consts__WEBPACK_IMPORTED_MODULE_0__.INVALID_BACKGROUND_CLASS}`], [
  2511. ['transition-property', 'width, padding-left'],
  2512. ['transition-duration', '500ms'],
  2513. ['right', '0'],
  2514. ['width', '0'],
  2515. ['padding-left', '0'],
  2516. ]);
  2517. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([
  2518. `.${_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}`,
  2519. `.${_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}`,
  2520. ], ['width', '100%']);
  2521. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([
  2522. `.${_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}`,
  2523. `.${_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}`,
  2524. ], ['padding-left', '0.8em']);
  2525. }
  2526.  
  2527.  
  2528. /***/ }),
  2529.  
  2530. /***/ "./ts/modal/body/nodes/actions/edit/index.ts":
  2531. /*!***************************************************!*\
  2532. !*** ./ts/modal/body/nodes/actions/edit/index.ts ***!
  2533. \***************************************************/
  2534. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2535.  
  2536. __webpack_require__.r(__webpack_exports__);
  2537. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2538. /* harmony export */ doAction: () => (/* binding */ doAction),
  2539. /* harmony export */ isActive: () => (/* binding */ isActive),
  2540. /* harmony export */ mount: () => (/* binding */ mount),
  2541. /* harmony export */ reset: () => (/* binding */ reset),
  2542. /* harmony export */ shouldMount: () => (/* binding */ shouldMount),
  2543. /* harmony export */ unmount: () => (/* binding */ unmount),
  2544. /* harmony export */ update: () => (/* binding */ update)
  2545. /* harmony export */ });
  2546. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/edit/consts.ts");
  2547. /* harmony import */ var _history__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../history */ "./ts/modal/body/nodes/actions/history.ts");
  2548. /* harmony import */ var _overlays__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../overlays */ "./ts/modal/body/nodes/actions/overlays/index.ts");
  2549. /* harmony import */ var _highlight__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../highlight */ "./ts/modal/body/nodes/actions/highlight/index.ts");
  2550. /* harmony import */ var _callbacks__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../callbacks */ "./ts/modal/body/nodes/actions/callbacks/index.ts");
  2551. /* harmony import */ var _overlays_tooltip_consts__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../overlays/tooltip/consts */ "./ts/modal/body/nodes/actions/overlays/tooltip/consts.ts");
  2552. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../consts */ "./ts/modal/body/nodes/consts.ts");
  2553. /* harmony import */ var _predicate__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @/predicate */ "./ts/predicate.ts");
  2554. var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
  2555. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  2556. return new (P || (P = Promise))(function (resolve, reject) {
  2557. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  2558. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  2559. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  2560. step((generator = generator.apply(thisArg, _arguments || [])).next());
  2561. });
  2562. };
  2563.  
  2564.  
  2565.  
  2566.  
  2567.  
  2568.  
  2569.  
  2570.  
  2571. let activeNode;
  2572. let priorValue;
  2573. function isActive() {
  2574. return Boolean(activeNode);
  2575. }
  2576. function addInputListeners(node = activeNode) {
  2577. const { headContainer, contrast: { valueElement } } = node.element;
  2578. if ('listeners' in node) {
  2579. for (const [event, callback] of Object.entries(node.listeners)) {
  2580. valueElement.addEventListener(event, callback);
  2581. }
  2582. }
  2583. if (typeof node.value === 'boolean') {
  2584. valueElement.addEventListener('click', (event) => {
  2585. event.stopPropagation();
  2586. update();
  2587. });
  2588. }
  2589. else {
  2590. valueElement.addEventListener('input', (event) => {
  2591. event.stopPropagation();
  2592. update();
  2593. });
  2594. }
  2595. valueElement.addEventListener('focusin', (event) => {
  2596. event.stopPropagation();
  2597. if (event.relatedTarget) {
  2598. doAction(node);
  2599. }
  2600. });
  2601. valueElement.addEventListener('blur', (event) => {
  2602. event.stopPropagation();
  2603. if ((0,_predicate__WEBPACK_IMPORTED_MODULE_7__.isUnresolved)()) {
  2604. valueElement.focus();
  2605. return;
  2606. }
  2607. reset();
  2608. });
  2609. valueElement.addEventListener('keydown', (event) => {
  2610. switch (event.key) {
  2611. // see socket keydown listener in history
  2612. case 'z':
  2613. case 'Z':
  2614. case 'y':
  2615. case 'Y':
  2616. if (event.ctrlKey && !event.shiftKey) {
  2617. event.stopPropagation();
  2618. }
  2619. return;
  2620. case 'Enter':
  2621. case 'Escape':
  2622. if ((0,_predicate__WEBPACK_IMPORTED_MODULE_7__.isUnresolved)()) {
  2623. event.preventDefault();
  2624. }
  2625. else {
  2626. headContainer.focus();
  2627. }
  2628. // eslint-disable-next-line no-fallthrough
  2629. case 'Undo':
  2630. case 'Redo':
  2631. // see socket keydown listener in highlight
  2632. // eslint-disable-next-line no-fallthrough
  2633. case 'Home':
  2634. case 'End':
  2635. case 'Backspace':
  2636. event.stopPropagation();
  2637. }
  2638. });
  2639. }
  2640. function clearUndoStack() {
  2641. const elements = activeNode.element.contrast;
  2642. const copy = elements.valueElement.cloneNode(true);
  2643. elements.valueElement.replaceWith(copy);
  2644. elements.valueElement = copy;
  2645. addInputListeners();
  2646. }
  2647. function setValue(node, value) {
  2648. node.value = value;
  2649. node.element.render(value);
  2650. _callbacks__WEBPACK_IMPORTED_MODULE_4__["default"].update.triggerAll(node);
  2651. }
  2652. function reset() {
  2653. if (!activeNode) {
  2654. return;
  2655. }
  2656. const { element } = activeNode;
  2657. clearUndoStack();
  2658. if (priorValue === activeNode.lastAcceptedValue) {
  2659. activeNode.value = activeNode.lastAcceptedValue;
  2660. activeNode.element.render(activeNode.lastAcceptedValue);
  2661. }
  2662. else {
  2663. _history__WEBPACK_IMPORTED_MODULE_1__.register(activeNode, setValue.bind(null, activeNode, priorValue), setValue.bind(null, activeNode, activeNode.lastAcceptedValue));
  2664. }
  2665. element.removeClass(_consts__WEBPACK_IMPORTED_MODULE_0__.VALID_CLASS);
  2666. element.removeClass(_consts__WEBPACK_IMPORTED_MODULE_0__.INVALID_CLASS);
  2667. element.removeClass(_consts__WEBPACK_IMPORTED_MODULE_0__.ACTIVE_CLASS);
  2668. _overlays__WEBPACK_IMPORTED_MODULE_2__.reset();
  2669. (0,_highlight__WEBPACK_IMPORTED_MODULE_3__.removeSustained)(activeNode);
  2670. activeNode = undefined;
  2671. priorValue = undefined;
  2672. }
  2673. function getValue(node) {
  2674. switch (typeof node.value) {
  2675. case 'boolean':
  2676. return Boolean(node.element.contrast.valueElement.checked);
  2677. case 'number':
  2678. return Number(node.element.contrast.valueElement.value);
  2679. default:
  2680. return node.element.contrast.valueElement.value;
  2681. }
  2682. }
  2683. function update() {
  2684. return __awaiter(this, void 0, void 0, function* () {
  2685. const value = getValue(activeNode);
  2686. activeNode.value = value;
  2687. activeNode.element.removeClass(_consts__WEBPACK_IMPORTED_MODULE_0__.INVALID_CLASS);
  2688. activeNode.element.removeClass(_consts__WEBPACK_IMPORTED_MODULE_0__.VALID_CLASS);
  2689. _overlays__WEBPACK_IMPORTED_MODULE_2__.update();
  2690. try {
  2691. if (!(yield _callbacks__WEBPACK_IMPORTED_MODULE_4__["default"].predicate.getAll(activeNode))) {
  2692. return;
  2693. }
  2694. }
  2695. catch (reason) {
  2696. activeNode.element.addClass(_consts__WEBPACK_IMPORTED_MODULE_0__.INVALID_CLASS);
  2697. if (reason) {
  2698. _overlays__WEBPACK_IMPORTED_MODULE_2__.tooltip.kill();
  2699. _overlays__WEBPACK_IMPORTED_MODULE_2__.showTooltip(reason, activeNode);
  2700. }
  2701. return;
  2702. }
  2703. activeNode.lastAcceptedValue = value;
  2704. activeNode.element.addClass(_consts__WEBPACK_IMPORTED_MODULE_0__.VALID_CLASS);
  2705. _overlays__WEBPACK_IMPORTED_MODULE_2__.hideTooltip();
  2706. _callbacks__WEBPACK_IMPORTED_MODULE_4__["default"].update.triggerAll(activeNode);
  2707. });
  2708. }
  2709. function unmount(node) {
  2710. if (node === activeNode) {
  2711. reset();
  2712. }
  2713. }
  2714. function doAction(node) {
  2715. if ((0,_predicate__WEBPACK_IMPORTED_MODULE_7__.isUnresolved)()) {
  2716. _overlays__WEBPACK_IMPORTED_MODULE_2__.showTooltip(_overlays_tooltip_consts__WEBPACK_IMPORTED_MODULE_5__.MESSAGE_UNRESOLVED, node, node.element.contrast.valueContainer);
  2717. node.element.headContainer.focus();
  2718. return;
  2719. }
  2720. reset();
  2721. _overlays__WEBPACK_IMPORTED_MODULE_2__.tooltip.kill();
  2722. activeNode = node;
  2723. priorValue = node.value;
  2724. node.element.addClass(_consts__WEBPACK_IMPORTED_MODULE_0__.ACTIVE_CLASS);
  2725. node.element.addClass(_consts__WEBPACK_IMPORTED_MODULE_0__.VALID_CLASS);
  2726. _overlays__WEBPACK_IMPORTED_MODULE_2__.setNode(node);
  2727. if (node.input === 'color') {
  2728. node.element.contrast.valueElement.click();
  2729. }
  2730. else if (typeof node.value !== 'boolean') {
  2731. const input = node.element.contrast.valueElement;
  2732. input.select();
  2733. input.scrollLeft = input.scrollWidth;
  2734. }
  2735. (0,_highlight__WEBPACK_IMPORTED_MODULE_3__.addSustained)(node);
  2736. }
  2737. function mount(node) {
  2738. const { backgroundContainer, contrast, headContainer } = node.element;
  2739. node.lastAcceptedValue = node.value;
  2740. node.element.addClass(_consts__WEBPACK_IMPORTED_MODULE_6__.EDITABLE_CLASS);
  2741. backgroundContainer.append(...(() => {
  2742. const valid = document.createElement('div');
  2743. const invalid = document.createElement('div');
  2744. valid.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.VALID_BACKGROUND_CLASS);
  2745. invalid.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.INVALID_BACKGROUND_CLASS);
  2746. return [valid, invalid];
  2747. })());
  2748. // Start
  2749. headContainer.addEventListener('click', (event) => {
  2750. event.stopPropagation();
  2751. contrast.valueElement.focus();
  2752. });
  2753. // Process new value
  2754. if (typeof node.value === 'boolean') {
  2755. headContainer.addEventListener('mousedown', (event) => {
  2756. event.stopPropagation();
  2757. event.preventDefault();
  2758. });
  2759. headContainer.addEventListener('click', () => {
  2760. contrast.valueElement.checked = !contrast.valueElement.checked;
  2761. update();
  2762. });
  2763. contrast.valueContainer.addEventListener('click', (event) => {
  2764. event.stopPropagation();
  2765. });
  2766. }
  2767. addInputListeners(node);
  2768. }
  2769. function shouldMount(node) {
  2770. return 'value' in node;
  2771. }
  2772.  
  2773.  
  2774. /***/ }),
  2775.  
  2776. /***/ "./ts/modal/body/nodes/actions/focus/consts.ts":
  2777. /*!*****************************************************!*\
  2778. !*** ./ts/modal/body/nodes/actions/focus/consts.ts ***!
  2779. \*****************************************************/
  2780. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2781.  
  2782. __webpack_require__.r(__webpack_exports__);
  2783. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2784. /* harmony export */ BACKGROUND_CLASS: () => (/* binding */ BACKGROUND_CLASS),
  2785. /* harmony export */ FOCUS_CLASS: () => (/* binding */ FOCUS_CLASS),
  2786. /* harmony export */ FOCUS_SOURCE_CLASS: () => (/* binding */ FOCUS_SOURCE_CLASS)
  2787. /* harmony export */ });
  2788. const FOCUS_CLASS = 'node-focus';
  2789. const FOCUS_SOURCE_CLASS = 'node-focus-source';
  2790. const BACKGROUND_CLASS = 'background-focus';
  2791.  
  2792.  
  2793. /***/ }),
  2794.  
  2795. /***/ "./ts/modal/body/nodes/actions/focus/css.ts":
  2796. /*!**************************************************!*\
  2797. !*** ./ts/modal/body/nodes/actions/focus/css.ts ***!
  2798. \**************************************************/
  2799. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2800.  
  2801. __webpack_require__.r(__webpack_exports__);
  2802. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2803. /* harmony export */ "default": () => (/* binding */ generate)
  2804. /* harmony export */ });
  2805. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/focus/consts.ts");
  2806. /* harmony import */ var _highlight_consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../highlight/consts */ "./ts/modal/body/nodes/actions/highlight/consts.ts");
  2807. /* harmony import */ var _nodes_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @nodes/consts */ "./ts/modal/body/nodes/consts.ts");
  2808. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  2809.  
  2810.  
  2811.  
  2812.  
  2813. function generate() {
  2814. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`.${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.ELEMENT_CONTAINER}`, ['cursor', 'zoom-in']);
  2815. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`.${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.ELEMENT_CONTAINER}.${_consts__WEBPACK_IMPORTED_MODULE_0__.FOCUS_SOURCE_CLASS}`, ['cursor', 'zoom-out']);
  2816. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`.${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ROOT_CLASS}.${_consts__WEBPACK_IMPORTED_MODULE_0__.FOCUS_CLASS} .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.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_2__.ELEMENT_CLASSES.CHILD_CONTAINER} > *)`, ['display', 'none']);
  2817. // Makes it easy to focus down the tree
  2818. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.FOCUS_SOURCE_CLASS} .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.MIDDLE_CLASS} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.HEAD_CONTAINER}`, [['margin-left', '1.8em']]);
  2819. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.BACKGROUND_CLASS}`, ['background-color', 'var(--focusBackground)']);
  2820. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.BACKGROUND_CLASS}`, [
  2821. ['transition-property', 'width, padding-left'],
  2822. ['transition-duration', '500ms'],
  2823. ['right', '0'],
  2824. ['width', '0'],
  2825. ['padding-left', '0'],
  2826. ]);
  2827. const headSelector = `.${_consts__WEBPACK_IMPORTED_MODULE_0__.FOCUS_SOURCE_CLASS}:not(:hover:not(:has(> .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.CHILD_CONTAINER}:hover))) > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.HEAD_CONTAINER}:not(.${_highlight_consts__WEBPACK_IMPORTED_MODULE_1__.TAB_CLASS} :focus):not(:hover)`;
  2828. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`${headSelector} .${_consts__WEBPACK_IMPORTED_MODULE_0__.BACKGROUND_CLASS}`, ['width', '100%']);
  2829. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`${headSelector} .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.BUTTON_CONTAINER}:not(:empty) + * .${_consts__WEBPACK_IMPORTED_MODULE_0__.BACKGROUND_CLASS}`, ['padding-left', '0.8em']);
  2830. }
  2831.  
  2832.  
  2833. /***/ }),
  2834.  
  2835. /***/ "./ts/modal/body/nodes/actions/focus/index.ts":
  2836. /*!****************************************************!*\
  2837. !*** ./ts/modal/body/nodes/actions/focus/index.ts ***!
  2838. \****************************************************/
  2839. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2840.  
  2841. __webpack_require__.r(__webpack_exports__);
  2842. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2843. /* harmony export */ doAction: () => (/* binding */ doAction),
  2844. /* harmony export */ focus: () => (/* binding */ focus),
  2845. /* harmony export */ focusBranch: () => (/* binding */ focusBranch),
  2846. /* harmony export */ isActive: () => (/* binding */ isActive),
  2847. /* harmony export */ mount: () => (/* binding */ mount),
  2848. /* harmony export */ reset: () => (/* binding */ reset),
  2849. /* harmony export */ setTabIndexes: () => (/* binding */ setTabIndexes),
  2850. /* harmony export */ shouldMount: () => (/* binding */ shouldMount),
  2851. /* harmony export */ unmount: () => (/* binding */ unmount)
  2852. /* harmony export */ });
  2853. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/focus/consts.ts");
  2854. /* harmony import */ var _overlays_tooltip__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../overlays/tooltip */ "./ts/modal/body/nodes/actions/overlays/tooltip/index.ts");
  2855. /* harmony import */ var _buttons_position__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../buttons/position */ "./ts/modal/body/nodes/actions/buttons/position/index.ts");
  2856. /* harmony import */ var _highlight__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../highlight */ "./ts/modal/body/nodes/actions/highlight/index.ts");
  2857. /* harmony import */ var _scroll__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../scroll */ "./ts/modal/body/nodes/actions/scroll.ts");
  2858.  
  2859.  
  2860.  
  2861.  
  2862.  
  2863. let candidateNode;
  2864. let activeNode;
  2865. function isActive() {
  2866. return Boolean(activeNode);
  2867. }
  2868. function setTabIndexes(doAdd = true, node = activeNode) {
  2869. const { 'buttonContainer': { 'children': buttons }, contrast: { valueElement } } = node.element;
  2870. for (let i = buttons.length - 1; i >= 0; --i) {
  2871. buttons[i].setAttribute('tabindex', doAdd ? '0' : '-1');
  2872. }
  2873. if (valueElement) {
  2874. valueElement.setAttribute('tabindex', doAdd ? '0' : '-1');
  2875. }
  2876. }
  2877. function focus(doFocus = true, node = activeNode, doForce = true) {
  2878. // Avoid unfocusing the active node if not forced
  2879. if (doForce || node !== activeNode) {
  2880. node.element[`${doFocus ? 'add' : 'remove'}Class`](_consts__WEBPACK_IMPORTED_MODULE_0__.FOCUS_SOURCE_CLASS);
  2881. }
  2882. if (!('children' in node)) {
  2883. return;
  2884. }
  2885. }
  2886. function focusBranch(doFocus = true, node = activeNode, focusAncestors = true) {
  2887. node.element[`${doFocus ? 'add' : 'remove'}Class`](_consts__WEBPACK_IMPORTED_MODULE_0__.FOCUS_CLASS);
  2888. if (focusAncestors && 'parent' in node) {
  2889. focusBranch(doFocus, node.parent);
  2890. }
  2891. }
  2892. function reset(doScroll = true) {
  2893. if (!activeNode) {
  2894. return;
  2895. }
  2896. focus(false);
  2897. focusBranch(false);
  2898. (0,_highlight__WEBPACK_IMPORTED_MODULE_3__.removeSustained)(activeNode);
  2899. setTabIndexes(false);
  2900. if (doScroll) {
  2901. (0,_scroll__WEBPACK_IMPORTED_MODULE_4__.stickyScroll)(activeNode);
  2902. }
  2903. activeNode = undefined;
  2904. }
  2905. function doAction(node, doForce = false) {
  2906. const toggleOn = node !== activeNode;
  2907. (0,_overlays_tooltip__WEBPACK_IMPORTED_MODULE_1__.kill)();
  2908. if ((0,_buttons_position__WEBPACK_IMPORTED_MODULE_2__.isActive)() || (doForce && !toggleOn)) {
  2909. return;
  2910. }
  2911. reset(!toggleOn);
  2912. if (toggleOn) {
  2913. activeNode = node;
  2914. node.element.headContainer.focus();
  2915. focus();
  2916. focusBranch();
  2917. node.element.scrollIntoView(false);
  2918. (0,_highlight__WEBPACK_IMPORTED_MODULE_3__.addSustained)(node);
  2919. setTabIndexes();
  2920. }
  2921. }
  2922. function unmount(node) {
  2923. if (node === activeNode) {
  2924. reset();
  2925. }
  2926. }
  2927. function mount(node) {
  2928. const { elementContainer, headContainer, backgroundContainer } = node.element;
  2929. backgroundContainer.append((() => {
  2930. const background = document.createElement('div');
  2931. background.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.BACKGROUND_CLASS);
  2932. return background;
  2933. })());
  2934. // Handle keyboard input
  2935. elementContainer.addEventListener('keydown', (event) => {
  2936. if (event.key === 'Enter') {
  2937. event.stopPropagation();
  2938. doAction(node);
  2939. }
  2940. });
  2941. // Handle side click
  2942. elementContainer.addEventListener('mousedown', (event) => {
  2943. event.stopPropagation();
  2944. candidateNode = node;
  2945. });
  2946. elementContainer.addEventListener('mouseup', (event) => {
  2947. event.stopPropagation();
  2948. if (node === candidateNode) {
  2949. doAction(node);
  2950. }
  2951. candidateNode = undefined;
  2952. });
  2953. if ('value' in node) {
  2954. headContainer.addEventListener('mousedown', (event) => {
  2955. event.stopPropagation();
  2956. candidateNode = undefined;
  2957. });
  2958. headContainer.addEventListener('mouseup', (event) => {
  2959. event.stopPropagation();
  2960. candidateNode = undefined;
  2961. });
  2962. return;
  2963. }
  2964. // Handle head click
  2965. headContainer.addEventListener('mousedown', (event) => {
  2966. event.stopPropagation();
  2967. candidateNode = node;
  2968. });
  2969. headContainer.addEventListener('mouseup', (event) => {
  2970. event.stopPropagation();
  2971. if (node === candidateNode && headContainer.isSameNode(event.target)) {
  2972. doAction(node);
  2973. }
  2974. candidateNode = undefined;
  2975. });
  2976. }
  2977. function shouldMount() {
  2978. return true;
  2979. }
  2980.  
  2981.  
  2982. /***/ }),
  2983.  
  2984. /***/ "./ts/modal/body/nodes/actions/hide/consts.ts":
  2985. /*!****************************************************!*\
  2986. !*** ./ts/modal/body/nodes/actions/hide/consts.ts ***!
  2987. \****************************************************/
  2988. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2989.  
  2990. __webpack_require__.r(__webpack_exports__);
  2991. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2992. /* harmony export */ CLASS_PREFIX_READ: () => (/* binding */ CLASS_PREFIX_READ),
  2993. /* harmony export */ CLASS_PREFIX_WRITE: () => (/* binding */ CLASS_PREFIX_WRITE)
  2994. /* harmony export */ });
  2995. const CLASS_PREFIX_WRITE = 'node-hide-write-';
  2996. const CLASS_PREFIX_READ = 'node-hide-read-';
  2997.  
  2998.  
  2999. /***/ }),
  3000.  
  3001. /***/ "./ts/modal/body/nodes/actions/hide/index.ts":
  3002. /*!***************************************************!*\
  3003. !*** ./ts/modal/body/nodes/actions/hide/index.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 */ "default": () => (/* binding */ hide),
  3010. /* harmony export */ mount: () => (/* binding */ mount),
  3011. /* harmony export */ shouldMount: () => (/* binding */ shouldMount)
  3012. /* harmony export */ });
  3013. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/hide/consts.ts");
  3014. /* harmony import */ var _nodes_pools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @nodes/pools */ "./ts/modal/body/nodes/pools.ts");
  3015. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  3016.  
  3017.  
  3018.  
  3019. const ids = [];
  3020. function setWriteClass(node, id, doHide) {
  3021. node.element[`${doHide ? 'add' : 'remove'}Class`](`${_consts__WEBPACK_IMPORTED_MODULE_0__.CLASS_PREFIX_WRITE}${id}`);
  3022. }
  3023. function hide(node, id, doHide = true) {
  3024. if (!('parent' in node) || 'seed' in node.parent) {
  3025. setWriteClass(node, id, doHide);
  3026. return;
  3027. }
  3028. for (const parent of (0,_nodes_pools__WEBPACK_IMPORTED_MODULE_1__.get)(node.parent)) {
  3029. hide(parent, id, doHide);
  3030. }
  3031. }
  3032. function mount(node) {
  3033. node.element.addClass(`${_consts__WEBPACK_IMPORTED_MODULE_0__.CLASS_PREFIX_READ}${node.hideId}`);
  3034. if (!ids[node.hideId]) {
  3035. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.CLASS_PREFIX_WRITE}${node.hideId} .${_consts__WEBPACK_IMPORTED_MODULE_0__.CLASS_PREFIX_READ}${node.hideId}`, ['display', 'none']);
  3036. ids[node.hideId] = true;
  3037. }
  3038. }
  3039. function shouldMount(node) {
  3040. return 'hideId' in node;
  3041. }
  3042.  
  3043.  
  3044. /***/ }),
  3045.  
  3046. /***/ "./ts/modal/body/nodes/actions/highlight/consts.ts":
  3047. /*!*********************************************************!*\
  3048. !*** ./ts/modal/body/nodes/actions/highlight/consts.ts ***!
  3049. \*********************************************************/
  3050. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  3051.  
  3052. __webpack_require__.r(__webpack_exports__);
  3053. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  3054. /* harmony export */ EAVE_ID: () => (/* binding */ EAVE_ID),
  3055. /* harmony export */ HIGHLIGHT_BACKGROUND_CLASS: () => (/* binding */ HIGHLIGHT_BACKGROUND_CLASS),
  3056. /* harmony export */ HIGHLIGHT_CLASS: () => (/* binding */ HIGHLIGHT_CLASS),
  3057. /* harmony export */ TAB_CLASS: () => (/* binding */ TAB_CLASS)
  3058. /* harmony export */ });
  3059. const HIGHLIGHT_CLASS = 'highlight';
  3060. const HIGHLIGHT_BACKGROUND_CLASS = 'background-highlight';
  3061. const TAB_CLASS = 'tab-naving';
  3062. const EAVE_ID = 'tree-eave';
  3063.  
  3064.  
  3065. /***/ }),
  3066.  
  3067. /***/ "./ts/modal/body/nodes/actions/highlight/css.ts":
  3068. /*!******************************************************!*\
  3069. !*** ./ts/modal/body/nodes/actions/highlight/css.ts ***!
  3070. \******************************************************/
  3071. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  3072.  
  3073. __webpack_require__.r(__webpack_exports__);
  3074. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  3075. /* harmony export */ "default": () => (/* binding */ generate)
  3076. /* harmony export */ });
  3077. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/highlight/consts.ts");
  3078. /* harmony import */ var _buttons_consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../buttons/consts */ "./ts/modal/body/nodes/actions/buttons/consts.ts");
  3079. /* harmony import */ var _nodes_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @nodes/consts */ "./ts/modal/body/nodes/consts.ts");
  3080. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  3081.  
  3082.  
  3083.  
  3084.  
  3085. function generate() {
  3086. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`.${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.LABEL_CONTAINER}`, [
  3087. ['padding-right', '0.4em'],
  3088. // Extend the background further into the value
  3089. ['padding-left', '4em'],
  3090. ]);
  3091. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`.${_buttons_consts__WEBPACK_IMPORTED_MODULE_1__.BUTTON_CLASS}:last-child`, [
  3092. ['border-top-right-radius', '0.8em'],
  3093. ['border-bottom-right-radius', '0.8em'],
  3094. ]);
  3095. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)([`.${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.BASE_CLASS}`], [
  3096. ['transition-property', 'width'],
  3097. ['transition-duration', '500ms'],
  3098. ['overflow', 'hidden'],
  3099. ['right', '0'],
  3100. ]);
  3101. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)([
  3102. `.${_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}`,
  3103. `.${_buttons_consts__WEBPACK_IMPORTED_MODULE_1__.TEST_ADD_CLASS} .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.BASE_CLASS}`,
  3104. `.${_buttons_consts__WEBPACK_IMPORTED_MODULE_1__.TEST_REMOVE_CLASS} .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.BASE_CLASS}`,
  3105. ], [['width', '0']]);
  3106. (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']]);
  3107. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.HIGHLIGHT_BACKGROUND_CLASS}`, [
  3108. ['transition-property', 'width, padding-left'],
  3109. ['transition-duration', '500ms'],
  3110. ['width', '100%'],
  3111. ]);
  3112. (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']]);
  3113. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)([
  3114. `.${_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}`,
  3115. `.${_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}`,
  3116. `.${_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}`,
  3117. ], [['padding-left', '0.8em']]);
  3118. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.HIGHLIGHT_BACKGROUND_CLASS}`, [
  3119. ['height', '100%'],
  3120. ['width', '100%'],
  3121. ['padding-left', '0'],
  3122. ]);
  3123. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`.${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.HEAD_CONTAINER}`, ['position', 'relative']);
  3124. (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`, [
  3125. ['content', '\'\''],
  3126. ['position', 'absolute'],
  3127. ['right', '0'],
  3128. ['height', '100%'],
  3129. ['width', '4px'],
  3130. ]);
  3131. for (const [selector, base, contrast] of _nodes_consts__WEBPACK_IMPORTED_MODULE_2__.NODE_COLOURS) {
  3132. const headSelector = `${selector} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.HEAD_CONTAINER}`;
  3133. // focus indicator
  3134. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`:not(.${_consts__WEBPACK_IMPORTED_MODULE_0__.HIGHLIGHT_CLASS})${headSelector}:focus::after`, ['background-color', contrast]);
  3135. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`${headSelector} .${_consts__WEBPACK_IMPORTED_MODULE_0__.HIGHLIGHT_BACKGROUND_CLASS}`, ['background-color', contrast]);
  3136. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`${headSelector} .${_buttons_consts__WEBPACK_IMPORTED_MODULE_1__.BUTTON_CLASS}`, ['background-color', contrast]);
  3137. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)([`${headSelector} .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.BASE_CLASS}`], [
  3138. ['color', contrast],
  3139. ['background-color', base],
  3140. ]);
  3141. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)([`${headSelector} .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.CONTRAST_CLASS}`], ['color', base]);
  3142. (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)`]);
  3143. (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)`]);
  3144. }
  3145. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`#${_consts__WEBPACK_IMPORTED_MODULE_0__.EAVE_ID}`, [
  3146. ['position', 'absolute'],
  3147. ['bottom', '0'],
  3148. ['width', '100%'],
  3149. // Prevents zipping to the end of the tree when mousing over the bottom pixel
  3150. ['height', '1px'],
  3151. ['z-index', 'var(--overlayIndex)'],
  3152. ]);
  3153. }
  3154.  
  3155.  
  3156. /***/ }),
  3157.  
  3158. /***/ "./ts/modal/body/nodes/actions/highlight/index.ts":
  3159. /*!********************************************************!*\
  3160. !*** ./ts/modal/body/nodes/actions/highlight/index.ts ***!
  3161. \********************************************************/
  3162. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  3163.  
  3164. __webpack_require__.r(__webpack_exports__);
  3165. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  3166. /* harmony export */ addSustained: () => (/* binding */ addSustained),
  3167. /* harmony export */ generateEave: () => (/* binding */ generateEave),
  3168. /* harmony export */ isActive: () => (/* binding */ isActive),
  3169. /* harmony export */ mount: () => (/* binding */ mount),
  3170. /* harmony export */ onMount: () => (/* binding */ onMount),
  3171. /* harmony export */ removeSustained: () => (/* binding */ removeSustained),
  3172. /* harmony export */ reset: () => (/* binding */ reset),
  3173. /* harmony export */ setActive: () => (/* binding */ setActive),
  3174. /* harmony export */ shouldMount: () => (/* binding */ shouldMount),
  3175. /* harmony export */ unmount: () => (/* binding */ unmount)
  3176. /* harmony export */ });
  3177. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/highlight/consts.ts");
  3178. /* harmony import */ var _edit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../edit */ "./ts/modal/body/nodes/actions/edit/index.ts");
  3179. /* harmony import */ var _scroll__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../scroll */ "./ts/modal/body/nodes/actions/scroll.ts");
  3180. /* harmony import */ var _modal_header_actions_sticky__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/modal/header/actions/sticky */ "./ts/modal/header/actions/sticky/index.ts");
  3181. /* harmony import */ var _modal_body__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/modal/body */ "./ts/modal/body/index.ts");
  3182. /* harmony import */ var _modal__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @/modal */ "./ts/modal/index.ts");
  3183.  
  3184.  
  3185.  
  3186.  
  3187.  
  3188.  
  3189. let sustainedNodes = [];
  3190. let activeNode;
  3191. function isActive() {
  3192. return Boolean(activeNode);
  3193. }
  3194. function removeSustained(node) {
  3195. sustainedNodes.splice(sustainedNodes.indexOf(node), 1);
  3196. // Avoid unhighlighting if it's still sustained by another action
  3197. if (node !== activeNode && !sustainedNodes.includes(node)) {
  3198. node.element.removeClass(_consts__WEBPACK_IMPORTED_MODULE_0__.HIGHLIGHT_CLASS);
  3199. }
  3200. }
  3201. function addSustained(node) {
  3202. node.element.addClass(_consts__WEBPACK_IMPORTED_MODULE_0__.HIGHLIGHT_CLASS);
  3203. sustainedNodes.push(node);
  3204. }
  3205. function setActive(node, doFocus = false) {
  3206. if (activeNode && !sustainedNodes.includes(activeNode)) {
  3207. activeNode.element.removeClass(_consts__WEBPACK_IMPORTED_MODULE_0__.HIGHLIGHT_CLASS);
  3208. }
  3209. activeNode = node;
  3210. if (!node) {
  3211. return;
  3212. }
  3213. node.element.addClass(_consts__WEBPACK_IMPORTED_MODULE_0__.HIGHLIGHT_CLASS);
  3214. if (doFocus) {
  3215. node.element.headContainer.focus();
  3216. // focus listeners don't seem to trigger if the document isn't focused
  3217. if ((0,_modal_header_actions_sticky__WEBPACK_IMPORTED_MODULE_3__.isActive)() && !document.hasFocus()) {
  3218. (0,_scroll__WEBPACK_IMPORTED_MODULE_2__.stickyScroll)(node, false, false);
  3219. }
  3220. }
  3221. }
  3222. function unmount(node) {
  3223. if (node === activeNode) {
  3224. node.element.headContainer.blur();
  3225. }
  3226. }
  3227. let isTab = false;
  3228. let isListening = false;
  3229. function setTab(value = true) {
  3230. isTab = value;
  3231. _modal_body__WEBPACK_IMPORTED_MODULE_4__.element.classList[isTab ? 'add' : 'remove'](_consts__WEBPACK_IMPORTED_MODULE_0__.TAB_CLASS);
  3232. }
  3233. function mount(node) {
  3234. const { backgroundContainer, headContainer, elementContainer, infoContainer, base } = node.element;
  3235. if (base.valueContainer) {
  3236. (new ResizeObserver(() => {
  3237. if (infoContainer.clientWidth > 0) {
  3238. base.valueContainer.style.setProperty('width', `${infoContainer.clientWidth}px`);
  3239. }
  3240. })).observe(infoContainer);
  3241. }
  3242. backgroundContainer.appendChild((() => {
  3243. const background = document.createElement('div');
  3244. background.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.HIGHLIGHT_BACKGROUND_CLASS);
  3245. return background;
  3246. })());
  3247. headContainer.setAttribute('tabindex', '0');
  3248. headContainer.addEventListener('focusin', (event) => {
  3249. event.stopPropagation();
  3250. if ((0,_modal_header_actions_sticky__WEBPACK_IMPORTED_MODULE_3__.isActive)()) {
  3251. (0,_scroll__WEBPACK_IMPORTED_MODULE_2__.stickyScroll)(node, false, isTab);
  3252. }
  3253. else if (isTab) {
  3254. node.element.scrollIntoView({ block: 'center', behavior: 'smooth' });
  3255. }
  3256. if (isTab && !isListening) {
  3257. isListening = true;
  3258. (0,_modal__WEBPACK_IMPORTED_MODULE_5__.getDocument)().addEventListener('mousemove', () => {
  3259. setTab(false);
  3260. isListening = false;
  3261. }, { capture: true, once: true });
  3262. }
  3263. // Filters out events fired from re-focusing the window
  3264. if (event.relatedTarget) {
  3265. setActive(node);
  3266. }
  3267. });
  3268. headContainer.addEventListener('mouseover', (event) => {
  3269. event.stopPropagation();
  3270. if (!isTab) {
  3271. setActive(node, !(0,_edit__WEBPACK_IMPORTED_MODULE_1__.isActive)());
  3272. }
  3273. });
  3274. elementContainer.addEventListener('mouseover', (event) => {
  3275. event.stopPropagation();
  3276. if (!isTab) {
  3277. setActive(node);
  3278. }
  3279. });
  3280. elementContainer.addEventListener('mouseout', (event) => {
  3281. event.stopPropagation();
  3282. if (!isTab) {
  3283. setActive();
  3284. }
  3285. });
  3286. }
  3287. function shouldMount() {
  3288. return true;
  3289. }
  3290. function setEdge(element, isStart) {
  3291. element.setAttribute('tabindex', '0');
  3292. // Prevent tabbing away from the modal
  3293. element.addEventListener('keydown', (event) => {
  3294. if (event.key === 'Tab' && (event.shiftKey === isStart) && element.isSameNode(event.target)) {
  3295. event.preventDefault();
  3296. }
  3297. });
  3298. element.addEventListener('focusin', () => {
  3299. setActive();
  3300. });
  3301. }
  3302. function generateEave(socket) {
  3303. const element = document.createElement('div');
  3304. element.id = _consts__WEBPACK_IMPORTED_MODULE_0__.EAVE_ID;
  3305. setEdge(socket, true);
  3306. setEdge(element, false);
  3307. socket.addEventListener('keydown', (event) => {
  3308. switch (event.key) {
  3309. case 'Home':
  3310. socket.focus();
  3311. _modal_body__WEBPACK_IMPORTED_MODULE_4__.element.scrollTop = 0;
  3312. break;
  3313. case 'End':
  3314. element.focus();
  3315. _modal_body__WEBPACK_IMPORTED_MODULE_4__.element.scrollTop = _modal_body__WEBPACK_IMPORTED_MODULE_4__.element.scrollHeight;
  3316. break;
  3317. case 'Backspace':
  3318. setActive();
  3319. break;
  3320. default:
  3321. return;
  3322. }
  3323. event.preventDefault();
  3324. });
  3325. return element;
  3326. }
  3327. // Blur focused node & reset focus index
  3328. function reset() {
  3329. setActive();
  3330. }
  3331. function onMount() {
  3332. const socket = (0,_modal__WEBPACK_IMPORTED_MODULE_5__.getSocket)();
  3333. socket.setAttribute('tabindex', '0');
  3334. // Prevent tabbing away from the modal
  3335. socket.addEventListener('keydown', (event) => {
  3336. if (event.key !== 'Tab') {
  3337. return;
  3338. }
  3339. setTab();
  3340. if (event.shiftKey && socket.isSameNode(event.target)) {
  3341. event.preventDefault();
  3342. }
  3343. });
  3344. (0,_modal__WEBPACK_IMPORTED_MODULE_5__.getWindow)().addEventListener('blur', () => {
  3345. setActive();
  3346. });
  3347. _modal_body__WEBPACK_IMPORTED_MODULE_4__.element.addEventListener('wheel', () => {
  3348. setActive();
  3349. });
  3350. }
  3351.  
  3352.  
  3353. /***/ }),
  3354.  
  3355. /***/ "./ts/modal/body/nodes/actions/history.ts":
  3356. /*!************************************************!*\
  3357. !*** ./ts/modal/body/nodes/actions/history.ts ***!
  3358. \************************************************/
  3359. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  3360.  
  3361. __webpack_require__.r(__webpack_exports__);
  3362. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  3363. /* harmony export */ onMount: () => (/* binding */ onMount),
  3364. /* harmony export */ register: () => (/* binding */ register)
  3365. /* harmony export */ });
  3366. /* harmony import */ var _scroll__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./scroll */ "./ts/modal/body/nodes/actions/scroll.ts");
  3367. /* harmony import */ var _focus__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./focus */ "./ts/modal/body/nodes/actions/focus/index.ts");
  3368. /* harmony import */ var _highlight__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./highlight */ "./ts/modal/body/nodes/actions/highlight/index.ts");
  3369. /* harmony import */ var _modal_body__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/modal/body */ "./ts/modal/body/index.ts");
  3370. /* harmony import */ var _modal_header_actions_sticky__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/modal/header/actions/sticky */ "./ts/modal/header/actions/sticky/index.ts");
  3371. /* harmony import */ var _modal__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @/modal */ "./ts/modal/index.ts");
  3372.  
  3373.  
  3374.  
  3375.  
  3376.  
  3377.  
  3378. const undoStack = [];
  3379. const redoStack = [];
  3380. function register(target, undo, redo, doAct = true, isUndoDeletion = false, isRedoDeletion = false) {
  3381. if (doAct) {
  3382. redo();
  3383. }
  3384. redoStack.length = 0;
  3385. undoStack.push({ target, undo: { act: undo, isDeletion: isUndoDeletion }, redo: { act: redo, isDeletion: isRedoDeletion } });
  3386. }
  3387. function show(node) {
  3388. const target = node.element.headContainer;
  3389. if (!target.isSameNode((0,_modal__WEBPACK_IMPORTED_MODULE_5__.getDocument)().activeElement)) {
  3390. target.addEventListener('focusin', (event) => {
  3391. event.stopImmediatePropagation();
  3392. }, { capture: true, once: true });
  3393. }
  3394. target.focus({ preventScroll: true });
  3395. const targetRect = target.getBoundingClientRect();
  3396. const scrollRect = _modal_body__WEBPACK_IMPORTED_MODULE_3__.element.getBoundingClientRect();
  3397. 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);
  3398. if (top < _modal_body__WEBPACK_IMPORTED_MODULE_3__.element.scrollTop) {
  3399. _modal_body__WEBPACK_IMPORTED_MODULE_3__.element.scrollTo({ top: top });
  3400. return;
  3401. }
  3402. const bottom = targetRect.top - scrollRect.top + _modal_body__WEBPACK_IMPORTED_MODULE_3__.element.scrollTop + targetRect.height - _modal_body__WEBPACK_IMPORTED_MODULE_3__.element.clientHeight;
  3403. if (bottom > _modal_body__WEBPACK_IMPORTED_MODULE_3__.element.scrollTop) {
  3404. _modal_body__WEBPACK_IMPORTED_MODULE_3__.element.scrollTo({ top: bottom });
  3405. }
  3406. }
  3407. function act(from, to, property) {
  3408. if (from.length === 0) {
  3409. return;
  3410. }
  3411. const action = from.pop();
  3412. (0,_focus__WEBPACK_IMPORTED_MODULE_1__.reset)();
  3413. if (action[property].isDeletion) {
  3414. const index = action.target.getIndex();
  3415. const target = index === 0 ? action.target.parent : action.target.parent.children[index - 1];
  3416. action[property].act();
  3417. show(target);
  3418. }
  3419. else {
  3420. action[property].act();
  3421. (0,_highlight__WEBPACK_IMPORTED_MODULE_2__.setActive)(action.target);
  3422. show(action.target);
  3423. }
  3424. to.push(action);
  3425. }
  3426. function onMount() {
  3427. (0,_modal__WEBPACK_IMPORTED_MODULE_5__.getSocket)().addEventListener('keydown', (event) => {
  3428. if (event.key === 'Undo' || (event.key.toLowerCase() === 'z' && event.ctrlKey && !event.shiftKey)) {
  3429. act(undoStack, redoStack, 'undo');
  3430. }
  3431. else if (event.key === 'Redo' || (event.key.toLowerCase() === 'y' && event.ctrlKey && !event.shiftKey)) {
  3432. act(redoStack, undoStack, 'redo');
  3433. }
  3434. });
  3435. }
  3436.  
  3437.  
  3438. /***/ }),
  3439.  
  3440. /***/ "./ts/modal/body/nodes/actions/overlays/consts.ts":
  3441. /*!********************************************************!*\
  3442. !*** ./ts/modal/body/nodes/actions/overlays/consts.ts ***!
  3443. \********************************************************/
  3444. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  3445.  
  3446. __webpack_require__.r(__webpack_exports__);
  3447. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  3448. /* harmony export */ CONTAINER_CLASS: () => (/* binding */ CONTAINER_CLASS)
  3449. /* harmony export */ });
  3450. const CONTAINER_CLASS = 'overlay-container';
  3451.  
  3452.  
  3453. /***/ }),
  3454.  
  3455. /***/ "./ts/modal/body/nodes/actions/overlays/css.ts":
  3456. /*!*****************************************************!*\
  3457. !*** ./ts/modal/body/nodes/actions/overlays/css.ts ***!
  3458. \*****************************************************/
  3459. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  3460.  
  3461. __webpack_require__.r(__webpack_exports__);
  3462. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  3463. /* harmony export */ "default": () => (/* binding */ generate)
  3464. /* harmony export */ });
  3465. /* harmony import */ var _tooltip_css__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tooltip/css */ "./ts/modal/body/nodes/actions/overlays/tooltip/css.ts");
  3466. /* harmony import */ var _dropdown_css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./dropdown/css */ "./ts/modal/body/nodes/actions/overlays/dropdown/css.ts");
  3467. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/overlays/consts.ts");
  3468. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  3469.  
  3470.  
  3471.  
  3472.  
  3473. function generate() {
  3474. (0,_tooltip_css__WEBPACK_IMPORTED_MODULE_0__["default"])();
  3475. (0,_dropdown_css__WEBPACK_IMPORTED_MODULE_1__["default"])();
  3476. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_2__.CONTAINER_CLASS}`, [
  3477. ['z-index', 'var(--overlayIndex)'],
  3478. ['position', 'absolute'],
  3479. ['top', '0'],
  3480. ['pointer-events', 'none'],
  3481. ]);
  3482. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_2__.CONTAINER_CLASS} > *`, [
  3483. ['position', 'absolute'],
  3484. ['width', 'inherit'],
  3485. ['display', 'flex'],
  3486. ['flex-direction', 'column'],
  3487. ['align-items', 'center'],
  3488. ]);
  3489. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_2__.CONTAINER_CLASS} > :empty`, ['display', 'none']);
  3490. }
  3491.  
  3492.  
  3493. /***/ }),
  3494.  
  3495. /***/ "./ts/modal/body/nodes/actions/overlays/dropdown/consts.ts":
  3496. /*!*****************************************************************!*\
  3497. !*** ./ts/modal/body/nodes/actions/overlays/dropdown/consts.ts ***!
  3498. \*****************************************************************/
  3499. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  3500.  
  3501. __webpack_require__.r(__webpack_exports__);
  3502. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  3503. /* harmony export */ DROPDOWN_ACTIVE_CLASS: () => (/* binding */ DROPDOWN_ACTIVE_CLASS),
  3504. /* harmony export */ DROPDOWN_BACKGROUND_CLASS: () => (/* binding */ DROPDOWN_BACKGROUND_CLASS),
  3505. /* harmony export */ DROPDOWN_CLASS: () => (/* binding */ DROPDOWN_CLASS),
  3506. /* harmony export */ DROPDOWN_CONTAINER_CLASS: () => (/* binding */ DROPDOWN_CONTAINER_CLASS),
  3507. /* harmony export */ DROPDOWN_PARENT_CLASS: () => (/* binding */ DROPDOWN_PARENT_CLASS),
  3508. /* harmony export */ DROPDOWN_SHOW_CLASS: () => (/* binding */ DROPDOWN_SHOW_CLASS),
  3509. /* harmony export */ DROPDOWN_WRAPPER_CLASS: () => (/* binding */ DROPDOWN_WRAPPER_CLASS)
  3510. /* harmony export */ });
  3511. const DROPDOWN_CLASS = 'option';
  3512. const DROPDOWN_CONTAINER_CLASS = 'option-container';
  3513. const DROPDOWN_PARENT_CLASS = 'option-parent';
  3514. const DROPDOWN_WRAPPER_CLASS = 'option-wrapper';
  3515. const DROPDOWN_BACKGROUND_CLASS = 'option-background';
  3516. const DROPDOWN_SHOW_CLASS = 'option-show';
  3517. const DROPDOWN_ACTIVE_CLASS = 'option-active';
  3518.  
  3519.  
  3520. /***/ }),
  3521.  
  3522. /***/ "./ts/modal/body/nodes/actions/overlays/dropdown/css.ts":
  3523. /*!**************************************************************!*\
  3524. !*** ./ts/modal/body/nodes/actions/overlays/dropdown/css.ts ***!
  3525. \**************************************************************/
  3526. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  3527.  
  3528. __webpack_require__.r(__webpack_exports__);
  3529. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  3530. /* harmony export */ "default": () => (/* binding */ generate)
  3531. /* harmony export */ });
  3532. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/overlays/dropdown/consts.ts");
  3533. /* harmony import */ var _nodes_consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @nodes/consts */ "./ts/modal/body/nodes/consts.ts");
  3534. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  3535.  
  3536.  
  3537.  
  3538. function generate() {
  3539. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.DROPDOWN_WRAPPER_CLASS}`, [
  3540. ['z-index', 'var(--overlayIndex)'],
  3541. ['position', 'sticky'],
  3542. ['display', 'flex'],
  3543. ['width', '100%'],
  3544. ['pointer-events', 'initial'],
  3545. ]);
  3546. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.DROPDOWN_PARENT_CLASS}`, [
  3547. ['position', 'absolute'],
  3548. ['display', 'flex'],
  3549. ['flex-direction', 'column'],
  3550. ['width', '100%'],
  3551. ['margin-left', '-1px'],
  3552. ['max-height', 'calc(4.2em + 5px)'],
  3553. ['overflow-y', 'auto'],
  3554. ['border-bottom-left-radius', '12px'],
  3555. ]);
  3556. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.DROPDOWN_CONTAINER_CLASS}`, [['position', 'relative']]);
  3557. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.DROPDOWN_CONTAINER_CLASS} > *`, [['height', '1.4em']]);
  3558. const [, base, contrast] = _nodes_consts__WEBPACK_IMPORTED_MODULE_1__.NODE_COLOURS[1];
  3559. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.DROPDOWN_PARENT_CLASS}`, ['border', `1px solid ${base}`]);
  3560. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.DROPDOWN_CONTAINER_CLASS}`, [
  3561. ['background-color', contrast],
  3562. ['color', base],
  3563. ['border', `1px solid ${base}`],
  3564. ['cursor', 'pointer'],
  3565. ]);
  3566. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.DROPDOWN_BACKGROUND_CLASS}`, [['background-color', base]]);
  3567. (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]]);
  3568. (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%']]);
  3569. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.DROPDOWN_CLASS}`, [
  3570. ['position', 'relative'],
  3571. ['transition-property', 'all'],
  3572. ['transition-duration', '500ms'],
  3573. ['padding', '0 0.6rem'],
  3574. ]);
  3575. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.DROPDOWN_BACKGROUND_CLASS}`, [
  3576. ['position', 'absolute'],
  3577. ['width', '0'],
  3578. ['transition', 'width 500ms ease 0s'],
  3579. ]);
  3580. (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']]);
  3581. }
  3582.  
  3583.  
  3584. /***/ }),
  3585.  
  3586. /***/ "./ts/modal/body/nodes/actions/overlays/dropdown/index.ts":
  3587. /*!****************************************************************!*\
  3588. !*** ./ts/modal/body/nodes/actions/overlays/dropdown/index.ts ***!
  3589. \****************************************************************/
  3590. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  3591.  
  3592. __webpack_require__.r(__webpack_exports__);
  3593. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  3594. /* harmony export */ generate: () => (/* binding */ generate),
  3595. /* harmony export */ reset: () => (/* binding */ reset),
  3596. /* harmony export */ update: () => (/* binding */ update)
  3597. /* harmony export */ });
  3598. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/overlays/dropdown/consts.ts");
  3599. /* harmony import */ var _edit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../edit */ "./ts/modal/body/nodes/actions/edit/index.ts");
  3600. /* harmony import */ var _modal_body__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/body */ "./ts/modal/body/index.ts");
  3601. var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
  3602. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  3603. return new (P || (P = Promise))(function (resolve, reject) {
  3604. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  3605. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  3606. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  3607. step((generator = generator.apply(thisArg, _arguments || [])).next());
  3608. });
  3609. };
  3610.  
  3611.  
  3612.  
  3613. const activeOptions = [];
  3614. const resetCallbacks = [];
  3615. let activeIndex = -1;
  3616. function getTop(target, includeHeight = true) {
  3617. const scrollRect = _modal_body__WEBPACK_IMPORTED_MODULE_2__.element.getBoundingClientRect();
  3618. const targetRect = target.getBoundingClientRect();
  3619. // todo this had a `+2` before; may be necessary
  3620. return targetRect.top - scrollRect.top + _modal_body__WEBPACK_IMPORTED_MODULE_2__.element.scrollTop + (includeHeight ? targetRect.height : 0);
  3621. }
  3622. // source: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions#escaping
  3623. function escapeRegExp(string) {
  3624. return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
  3625. }
  3626. function setActive(option, isActive = true) {
  3627. option.classList[isActive ? 'add' : 'remove'](_consts__WEBPACK_IMPORTED_MODULE_0__.DROPDOWN_ACTIVE_CLASS);
  3628. }
  3629. function deselect() {
  3630. if (activeIndex === -1) {
  3631. return;
  3632. }
  3633. setActive(activeOptions[activeIndex].parentElement, false);
  3634. activeIndex = -1;
  3635. }
  3636. function update(value) {
  3637. // equivalent to `if (!('options' in node))`
  3638. if (activeOptions.length === 0) {
  3639. return;
  3640. }
  3641. const stringValue = `${value}`;
  3642. const regExp = new RegExp(escapeRegExp(stringValue), 'i');
  3643. for (const { parentElement, innerText } of activeOptions) {
  3644. if (stringValue.length <= innerText.length && regExp.test(innerText)) {
  3645. parentElement.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.DROPDOWN_SHOW_CLASS);
  3646. }
  3647. else {
  3648. parentElement.classList.remove(_consts__WEBPACK_IMPORTED_MODULE_0__.DROPDOWN_SHOW_CLASS);
  3649. }
  3650. }
  3651. const [{ parentElement: { parentElement: wrapper } }] = activeOptions;
  3652. const top = getTop(wrapper);
  3653. // todo remove? seems pointless
  3654. if (_modal_body__WEBPACK_IMPORTED_MODULE_2__.element.scrollTop + _modal_body__WEBPACK_IMPORTED_MODULE_2__.element.clientHeight < top) {
  3655. _modal_body__WEBPACK_IMPORTED_MODULE_2__.element.scrollTop = top - _modal_body__WEBPACK_IMPORTED_MODULE_2__.element.clientHeight;
  3656. }
  3657. deselect();
  3658. }
  3659. function setValue(node, value) {
  3660. return __awaiter(this, void 0, void 0, function* () {
  3661. node.element.contrast.valueElement.value = value;
  3662. deselect();
  3663. yield (0,_edit__WEBPACK_IMPORTED_MODULE_1__.update)();
  3664. });
  3665. }
  3666. function reset() {
  3667. while (resetCallbacks.length > 0) {
  3668. resetCallbacks.pop()();
  3669. }
  3670. activeOptions.length = 0;
  3671. }
  3672. function addListener(target, type, listener, useCapture = false) {
  3673. target.addEventListener(type, listener, useCapture);
  3674. resetCallbacks.push(() => target.removeEventListener(type, listener, useCapture));
  3675. }
  3676. function generate(node) {
  3677. const wrapper = document.createElement('div');
  3678. const parent = document.createElement('div');
  3679. wrapper.style.width = `${node.element.contrast.valueContainer.clientWidth}px`;
  3680. // avoid blurring an input when dragging the scrollbar
  3681. addListener(wrapper, 'mousedown', (event) => {
  3682. event.stopPropagation();
  3683. event.preventDefault();
  3684. });
  3685. for (const type of ['mouseover', 'mouseout', 'mouseup']) {
  3686. addListener(wrapper, type, (event) => {
  3687. event.stopPropagation();
  3688. });
  3689. }
  3690. for (const value of node.options) {
  3691. const container = document.createElement('div');
  3692. const background = document.createElement('div');
  3693. const option = document.createElement('div');
  3694. option.innerText = value;
  3695. container.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.DROPDOWN_CONTAINER_CLASS);
  3696. option.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.DROPDOWN_CLASS);
  3697. background.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.DROPDOWN_BACKGROUND_CLASS);
  3698. container.append(background, option);
  3699. parent.appendChild(container);
  3700. activeOptions.push(option);
  3701. addListener(container, 'mousedown', (event) => {
  3702. event.stopPropagation();
  3703. event.preventDefault();
  3704. });
  3705. addListener(container, 'click', (event) => __awaiter(this, void 0, void 0, function* () {
  3706. event.stopPropagation();
  3707. yield setValue(node, value);
  3708. node.element.headContainer.focus();
  3709. }));
  3710. addListener(container, 'mouseenter', (event) => {
  3711. event.stopPropagation();
  3712. setActive(container);
  3713. });
  3714. addListener(container, 'mouseleave', (event) => {
  3715. event.stopPropagation();
  3716. setActive(container, false);
  3717. });
  3718. }
  3719. addListener(node.element.contrast.valueElement, 'keydown', (event) => {
  3720. const priorIndex = activeIndex;
  3721. let hasChanged = false;
  3722. switch (event.key) {
  3723. case 'Tab':
  3724. case 'Enter':
  3725. if (activeIndex >= 0) {
  3726. event.stopPropagation();
  3727. event.preventDefault();
  3728. setValue(node, activeOptions[activeIndex].innerText)
  3729. .then(() => node.element.headContainer.focus());
  3730. }
  3731. return;
  3732. case 'ArrowDown':
  3733. for (let i = activeIndex + 1; i < activeOptions.length; ++i) {
  3734. const { parentElement } = activeOptions[i];
  3735. if (parentElement.classList.contains(_consts__WEBPACK_IMPORTED_MODULE_0__.DROPDOWN_SHOW_CLASS)) {
  3736. activeIndex = i;
  3737. hasChanged = true;
  3738. const optionBottom = parentElement.offsetTop + parentElement.clientHeight;
  3739. if (parentElement.parentElement.scrollTop < optionBottom) {
  3740. parentElement.parentElement.scrollTop = optionBottom - parentElement.parentElement.clientHeight;
  3741. }
  3742. const top = getTop(parentElement);
  3743. if (_modal_body__WEBPACK_IMPORTED_MODULE_2__.element.scrollTop + _modal_body__WEBPACK_IMPORTED_MODULE_2__.element.clientHeight < top - parentElement.parentElement.scrollTop) {
  3744. _modal_body__WEBPACK_IMPORTED_MODULE_2__.element.scrollTop = top - _modal_body__WEBPACK_IMPORTED_MODULE_2__.element.clientHeight - parentElement.parentElement.scrollTop;
  3745. }
  3746. break;
  3747. }
  3748. }
  3749. break;
  3750. case 'ArrowUp':
  3751. for (let i = activeIndex - 1; i >= 0; --i) {
  3752. const { parentElement } = activeOptions[i];
  3753. if (parentElement.classList.contains(_consts__WEBPACK_IMPORTED_MODULE_0__.DROPDOWN_SHOW_CLASS)) {
  3754. activeIndex = i;
  3755. hasChanged = true;
  3756. // Scroll option list if necessary
  3757. if (parentElement.parentElement.scrollTop > parentElement.offsetTop) {
  3758. parentElement.parentElement.scrollTop = parentElement.offsetTop;
  3759. }
  3760. const top = getTop(parentElement, false);
  3761. // Scroll modal body if necessary
  3762. if (_modal_body__WEBPACK_IMPORTED_MODULE_2__.element.scrollTop > top - parentElement.parentElement.scrollTop) {
  3763. _modal_body__WEBPACK_IMPORTED_MODULE_2__.element.scrollTop = top - parentElement.parentElement.scrollTop;
  3764. }
  3765. break;
  3766. }
  3767. }
  3768. if (hasChanged) {
  3769. break;
  3770. }
  3771. // eslint-disable-next-line no-fallthrough
  3772. default:
  3773. if (activeIndex >= 0) {
  3774. setActive(activeOptions[activeIndex].parentElement, false);
  3775. }
  3776. activeIndex = -1;
  3777. return;
  3778. }
  3779. if (!hasChanged) {
  3780. return;
  3781. }
  3782. if (priorIndex >= 0) {
  3783. setActive(activeOptions[priorIndex].parentElement, false);
  3784. }
  3785. const { parentElement } = activeOptions[activeIndex];
  3786. setActive(parentElement);
  3787. }, true);
  3788. wrapper.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.DROPDOWN_WRAPPER_CLASS);
  3789. parent.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.DROPDOWN_PARENT_CLASS);
  3790. wrapper.appendChild(parent);
  3791. return wrapper;
  3792. }
  3793.  
  3794.  
  3795. /***/ }),
  3796.  
  3797. /***/ "./ts/modal/body/nodes/actions/overlays/index.ts":
  3798. /*!*******************************************************!*\
  3799. !*** ./ts/modal/body/nodes/actions/overlays/index.ts ***!
  3800. \*******************************************************/
  3801. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  3802.  
  3803. __webpack_require__.r(__webpack_exports__);
  3804. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  3805. /* harmony export */ dropdown: () => (/* reexport module object */ _dropdown__WEBPACK_IMPORTED_MODULE_3__),
  3806. /* harmony export */ hideTooltip: () => (/* binding */ hideTooltip),
  3807. /* harmony export */ reset: () => (/* binding */ reset),
  3808. /* harmony export */ setNode: () => (/* binding */ setNode),
  3809. /* harmony export */ showTooltip: () => (/* binding */ showTooltip),
  3810. /* harmony export */ tooltip: () => (/* reexport module object */ _tooltip__WEBPACK_IMPORTED_MODULE_2__),
  3811. /* harmony export */ update: () => (/* binding */ update)
  3812. /* harmony export */ });
  3813. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/overlays/consts.ts");
  3814. /* harmony import */ var _tooltip_consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./tooltip/consts */ "./ts/modal/body/nodes/actions/overlays/tooltip/consts.ts");
  3815. /* harmony import */ var _tooltip__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./tooltip */ "./ts/modal/body/nodes/actions/overlays/tooltip/index.ts");
  3816. /* harmony import */ var _dropdown__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./dropdown */ "./ts/modal/body/nodes/actions/overlays/dropdown/index.ts");
  3817. /* harmony import */ var _scroll__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../scroll */ "./ts/modal/body/nodes/actions/scroll.ts");
  3818. /* harmony import */ var _modal_body__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @/modal/body */ "./ts/modal/body/index.ts");
  3819. /* harmony import */ var _modal_header_actions_sticky__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @/modal/header/actions/sticky */ "./ts/modal/header/actions/sticky/index.ts");
  3820. var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
  3821. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  3822. return new (P || (P = Promise))(function (resolve, reject) {
  3823. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  3824. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  3825. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  3826. step((generator = generator.apply(thisArg, _arguments || [])).next());
  3827. });
  3828. };
  3829.  
  3830.  
  3831.  
  3832.  
  3833.  
  3834.  
  3835.  
  3836. let activeContainer;
  3837. let activeTooltip;
  3838. let activeDropdown;
  3839. let activeNode;
  3840. let activeListener;
  3841.  
  3842. function reset() {
  3843. _dropdown__WEBPACK_IMPORTED_MODULE_3__.reset();
  3844. _modal_body__WEBPACK_IMPORTED_MODULE_5__.element.removeEventListener('scroll', activeListener);
  3845. activeContainer.remove();
  3846. activeContainer = undefined;
  3847. activeTooltip = undefined;
  3848. activeDropdown = undefined;
  3849. activeNode = undefined;
  3850. activeListener = undefined;
  3851. }
  3852. function hideTooltip() {
  3853. _tooltip__WEBPACK_IMPORTED_MODULE_2__.hide(activeTooltip);
  3854. }
  3855. function getStickyPositions(parent, space, targetMinTop, targetHeight, nodeHeight, node) {
  3856. const targetTop = (0,_scroll__WEBPACK_IMPORTED_MODULE_4__.getStickyScroll)(node);
  3857. const ancestors = node.getAncestors();
  3858. const offset = 'children' in node ? 0 : nodeHeight;
  3859. return [
  3860. () => targetMinTop - _modal_body__WEBPACK_IMPORTED_MODULE_5__.element.clientHeight / 2 > _modal_body__WEBPACK_IMPORTED_MODULE_5__.element.scrollTop, [
  3861. [targetMinTop + targetHeight, targetMinTop - targetTop + targetHeight - offset, 0], ...[node, ...ancestors]
  3862. .map((node) => (0,_scroll__WEBPACK_IMPORTED_MODULE_4__.getStickyScroll)(node, false))
  3863. .map((height, index, { length }) => ([
  3864. height + (length - index) * nodeHeight,
  3865. (length - index - 1) * nodeHeight,
  3866. height,
  3867. ])),
  3868. ].map(([height, top, start]) => ({
  3869. container: (() => {
  3870. const container = document.createElement('div');
  3871. container.style.height = `${space - height}px`;
  3872. container.style.top = `${height}px`;
  3873. container.classList.add(_tooltip_consts__WEBPACK_IMPORTED_MODULE_1__.TOOLTIP_BOTTOM_CLASS);
  3874. parent.appendChild(container);
  3875. return container;
  3876. })(),
  3877. top,
  3878. start,
  3879. })),
  3880. ];
  3881. }
  3882. function getBasicPosition(parent, space, targetMinTop, targetHeight) {
  3883. return [
  3884. () => targetMinTop - _modal_body__WEBPACK_IMPORTED_MODULE_5__.element.clientHeight / 2 > _modal_body__WEBPACK_IMPORTED_MODULE_5__.element.scrollTop,
  3885. [
  3886. {
  3887. container: (() => {
  3888. const container = document.createElement('div');
  3889. container.style.height = `${targetMinTop}px`;
  3890. container.style.top = '0';
  3891. container.classList.add(_tooltip_consts__WEBPACK_IMPORTED_MODULE_1__.TOOLTIP_TOP_CLASS);
  3892. parent.appendChild(container);
  3893. return container;
  3894. })(),
  3895. }, {
  3896. container: (() => {
  3897. const container = document.createElement('div');
  3898. container.style.position = 'absolute';
  3899. container.style.height = `${space - targetMinTop - targetHeight}px`;
  3900. container.style.top = '0';
  3901. container.classList.add(_tooltip_consts__WEBPACK_IMPORTED_MODULE_1__.TOOLTIP_BOTTOM_CLASS);
  3902. parent.appendChild(container);
  3903. return container;
  3904. })(),
  3905. top: targetMinTop + targetHeight,
  3906. },
  3907. ],
  3908. ];
  3909. }
  3910. function applyPosition(basicPositions, stickyPositions, nodeHeight, isAbove, container, tooltipElement, dropdownElement) {
  3911. const containers = [];
  3912. let target;
  3913. tooltipElement.style.removeProperty('transform');
  3914. if (isAbove) {
  3915. tooltipElement.style.top = `${_modal_body__WEBPACK_IMPORTED_MODULE_5__.element.clientHeight - tooltipElement.clientHeight}px`;
  3916. basicPositions[0].container.appendChild(tooltipElement);
  3917. containers.push(basicPositions[0].container);
  3918. if (!dropdownElement) {
  3919. return containers;
  3920. }
  3921. target = dropdownElement;
  3922. }
  3923. else {
  3924. target = tooltipElement;
  3925. }
  3926. if (!(0,_modal_header_actions_sticky__WEBPACK_IMPORTED_MODULE_6__.isActive)()) {
  3927. target.style.top = '0';
  3928. basicPositions[1].container.appendChild(target);
  3929. return [basicPositions[1].container, ...containers];
  3930. }
  3931. let index = 0;
  3932. for (; index < stickyPositions.length - 1; ++index) {
  3933. if (_modal_body__WEBPACK_IMPORTED_MODULE_5__.element.scrollTop < stickyPositions[index + 1].start) {
  3934. break;
  3935. }
  3936. }
  3937. target.style.top = `${stickyPositions[index].top}px`;
  3938. if (stickyPositions[1].start + nodeHeight < _modal_body__WEBPACK_IMPORTED_MODULE_5__.element.scrollTop) {
  3939. tooltipElement.style.top = `${stickyPositions[index].top}px`;
  3940. stickyPositions[index].container.append(target, tooltipElement);
  3941. return [stickyPositions[index].container];
  3942. }
  3943. if (dropdownElement && stickyPositions[1].start < _modal_body__WEBPACK_IMPORTED_MODULE_5__.element.scrollTop) {
  3944. tooltipElement.style.transform = `translateY(${(_modal_body__WEBPACK_IMPORTED_MODULE_5__.element.scrollTop - stickyPositions[1].start)}px)`;
  3945. }
  3946. stickyPositions[index].container.appendChild(target);
  3947. return [stickyPositions[index].container, ...containers];
  3948. }
  3949. function setPosition(node, container, target, tooltipElement, dropdownElement) {
  3950. const scrollRect = _modal_body__WEBPACK_IMPORTED_MODULE_5__.element.getBoundingClientRect();
  3951. const targetRect = target.getBoundingClientRect();
  3952. const nodeRect = node.element.headContainer.getBoundingClientRect();
  3953. const containerLeft = targetRect.left - scrollRect.left;
  3954. container.style.width = `${targetRect.width}px`;
  3955. container.style.left = `${containerLeft}px`;
  3956. const targetMinTop = targetRect.top - scrollRect.top + _modal_body__WEBPACK_IMPORTED_MODULE_5__.element.scrollTop;
  3957. const space = _modal_body__WEBPACK_IMPORTED_MODULE_5__.element.scrollHeight;
  3958. const [isUpBasic, basicPositions] = getBasicPosition(container, space, targetMinTop, targetRect.height);
  3959. const [isUpSticky, stickyPositions] = getStickyPositions(container, space, targetMinTop, targetRect.height, nodeRect.height, node);
  3960. let isAbove;
  3961. const listener = () => {
  3962. isAbove = dropdownElement || ((0,_modal_header_actions_sticky__WEBPACK_IMPORTED_MODULE_6__.isActive)() ? isUpSticky() : isUpBasic());
  3963. applyPosition(basicPositions, stickyPositions, nodeRect.height, isAbove, container, tooltipElement, dropdownElement);
  3964. };
  3965. listener();
  3966. // todo stop using scroll listeners;
  3967. // use intersection observers to detect specific scrollTops & act accordingly
  3968. // try using a branch of divs instead of manually changing styles
  3969. _modal_body__WEBPACK_IMPORTED_MODULE_5__.element.addEventListener('scroll', listener);
  3970. return listener;
  3971. }
  3972. function generate(node, target, tooltipElement, dropdownElement) {
  3973. const container = document.createElement('div');
  3974. const { elementContainer: parent } = node.getRoot().element;
  3975. container.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.CONTAINER_CLASS);
  3976. parent.appendChild(container, parent.firstChild);
  3977. return [container, setPosition(node, container, target, tooltipElement, dropdownElement)];
  3978. }
  3979. function update() {
  3980. _dropdown__WEBPACK_IMPORTED_MODULE_3__.update(activeNode.value);
  3981. _tooltip__WEBPACK_IMPORTED_MODULE_2__.fade(activeTooltip);
  3982. // handle possible dropdown height change
  3983. activeListener();
  3984. }
  3985. function setTooltipMessage(message, tooltipElement = activeTooltip, container = activeContainer, isRight = true) {
  3986. const box = tooltipElement.querySelector(`.${_tooltip_consts__WEBPACK_IMPORTED_MODULE_1__.TOOLTIP_BOX_CLASS}`);
  3987. box.innerText = message;
  3988. if (isRight) {
  3989. box.style.right = `${Math.max(0, box.offsetWidth / 2 - _modal_body__WEBPACK_IMPORTED_MODULE_5__.element.clientWidth + container.offsetLeft + container.clientWidth / 2)}px`;
  3990. }
  3991. else {
  3992. box.style.left = `${Math.max(0, box.offsetWidth / 2 - container.offsetLeft - container.clientWidth / 2)}px`;
  3993. }
  3994. }
  3995. function showTooltip(message, node, target) {
  3996. return __awaiter(this, void 0, void 0, function* () {
  3997. if (node === activeNode) {
  3998. // handle possible tooltip height change
  3999. activeListener();
  4000. // handle possible width change
  4001. setTooltipMessage(message);
  4002. return;
  4003. }
  4004. const tooltipElement = _tooltip__WEBPACK_IMPORTED_MODULE_2__.getAnimated();
  4005. const [container, listener] = generate(node, target, tooltipElement);
  4006. setTooltipMessage(message, tooltipElement, container, false);
  4007. yield _tooltip__WEBPACK_IMPORTED_MODULE_2__.animationEnd();
  4008. _modal_body__WEBPACK_IMPORTED_MODULE_5__.element.removeEventListener('scroll', listener);
  4009. container.remove();
  4010. });
  4011. }
  4012. function setNode(node) {
  4013. activeNode = node;
  4014. activeTooltip = _tooltip__WEBPACK_IMPORTED_MODULE_2__.generate(node.element.contrast.valueElement.type === 'color');
  4015. if ('options' in node) {
  4016. activeDropdown = _dropdown__WEBPACK_IMPORTED_MODULE_3__.generate(node);
  4017. _dropdown__WEBPACK_IMPORTED_MODULE_3__.update(node.value);
  4018. }
  4019. [activeContainer, activeListener] = generate(activeNode, node.element.contrast.valueContainer, activeTooltip, activeDropdown);
  4020. }
  4021.  
  4022.  
  4023. /***/ }),
  4024.  
  4025. /***/ "./ts/modal/body/nodes/actions/overlays/tooltip/consts.ts":
  4026. /*!****************************************************************!*\
  4027. !*** ./ts/modal/body/nodes/actions/overlays/tooltip/consts.ts ***!
  4028. \****************************************************************/
  4029. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4030.  
  4031. __webpack_require__.r(__webpack_exports__);
  4032. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4033. /* harmony export */ MESSAGE_UNRESOLVED: () => (/* binding */ MESSAGE_UNRESOLVED),
  4034. /* harmony export */ TOOLTIP_ANIMATION: () => (/* binding */ TOOLTIP_ANIMATION),
  4035. /* harmony export */ TOOLTIP_ANIMATION_FAST: () => (/* binding */ TOOLTIP_ANIMATION_FAST),
  4036. /* harmony export */ TOOLTIP_ARROW_CLASS: () => (/* binding */ TOOLTIP_ARROW_CLASS),
  4037. /* harmony export */ TOOLTIP_BOTTOM_CLASS: () => (/* binding */ TOOLTIP_BOTTOM_CLASS),
  4038. /* harmony export */ TOOLTIP_BOX_CLASS: () => (/* binding */ TOOLTIP_BOX_CLASS),
  4039. /* harmony export */ TOOLTIP_CONTAINER_CLASS: () => (/* binding */ TOOLTIP_CONTAINER_CLASS),
  4040. /* harmony export */ TOOLTIP_REVERSE_CLASS: () => (/* binding */ TOOLTIP_REVERSE_CLASS),
  4041. /* harmony export */ TOOLTIP_TOP_CLASS: () => (/* binding */ TOOLTIP_TOP_CLASS)
  4042. /* harmony export */ });
  4043. const TOOLTIP_CONTAINER_CLASS = 'tooltip-container';
  4044. const TOOLTIP_ARROW_CLASS = 'modal-arrow-wrapper';
  4045. const TOOLTIP_BOX_CLASS = 'tooltip';
  4046. const TOOLTIP_TOP_CLASS = 'tooltip-above';
  4047. const TOOLTIP_BOTTOM_CLASS = 'tooltip-below';
  4048. const TOOLTIP_REVERSE_CLASS = 'tooltip-reverse';
  4049. const TOOLTIP_ANIMATION = [
  4050. [
  4051. // keyframes
  4052. { opacity: 1 },
  4053. { opacity: 1 },
  4054. { opacity: 0 },
  4055. ], { duration: 2000 },
  4056. ];
  4057. const TOOLTIP_ANIMATION_FAST = [
  4058. [
  4059. // keyframes
  4060. { opacity: 1 },
  4061. { opacity: 0 },
  4062. ], { duration: 1000 },
  4063. ];
  4064. const MESSAGE_UNRESOLVED = 'Please wait for validation';
  4065.  
  4066.  
  4067. /***/ }),
  4068.  
  4069. /***/ "./ts/modal/body/nodes/actions/overlays/tooltip/css.ts":
  4070. /*!*************************************************************!*\
  4071. !*** ./ts/modal/body/nodes/actions/overlays/tooltip/css.ts ***!
  4072. \*************************************************************/
  4073. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4074.  
  4075. __webpack_require__.r(__webpack_exports__);
  4076. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4077. /* harmony export */ "default": () => (/* binding */ generate)
  4078. /* harmony export */ });
  4079. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/overlays/tooltip/consts.ts");
  4080. /* harmony import */ var _nodes_consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @nodes/consts */ "./ts/modal/body/nodes/consts.ts");
  4081. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  4082. /* harmony import */ var _dropdown_consts__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../dropdown/consts */ "./ts/modal/body/nodes/actions/overlays/dropdown/consts.ts");
  4083.  
  4084.  
  4085.  
  4086.  
  4087. function generate() {
  4088. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_CONTAINER_CLASS}`, [
  4089. ['position', 'sticky'],
  4090. ['text-align', 'center'],
  4091. ['display', 'flex'],
  4092. ['flex-direction', 'column'],
  4093. ['align-items', 'center'],
  4094. ['width', '10em'],
  4095. ]);
  4096. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([
  4097. `.${_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}`,
  4098. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_BOTTOM_CLASS}.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_REVERSE_CLASS} .${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_ARROW_CLASS}`,
  4099. `.${_dropdown_consts__WEBPACK_IMPORTED_MODULE_3__.DROPDOWN_WRAPPER_CLASS} + * > .${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_ARROW_CLASS}`,
  4100. ], [
  4101. ['top', '100%'],
  4102. ['border-color', 'var(--borderTooltip) transparent transparent transparent'],
  4103. ]);
  4104. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([
  4105. `.${_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}`,
  4106. `.${_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}`,
  4107. ], [
  4108. ['bottom', '100%'],
  4109. ['border-color', 'transparent transparent var(--borderTooltip) transparent'],
  4110. ]);
  4111. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([
  4112. `.${_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}`,
  4113. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_BOTTOM_CLASS}.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_REVERSE_CLASS} .${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_CONTAINER_CLASS}`,
  4114. ], ['translate', '0 -0.5em']);
  4115. (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)']);
  4116. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([
  4117. `.${_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}`,
  4118. `.${_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}`,
  4119. ], [['translate', '0 0.5em']]);
  4120. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_BOX_CLASS}`, [
  4121. ['font-size', '0.9em'],
  4122. ['padding', '3px 15px'],
  4123. ['border-radius', '1em'],
  4124. ['border', 'solid 3px var(--borderTooltip)'],
  4125. ['background-color', _nodes_consts__WEBPACK_IMPORTED_MODULE_1__.NODE_COLOURS[1][1]],
  4126. ['color', _nodes_consts__WEBPACK_IMPORTED_MODULE_1__.NODE_COLOURS[1][2]],
  4127. ['position', 'relative'],
  4128. ]);
  4129. // Don't show when there's no hint to give
  4130. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([`:has(> .${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_BOX_CLASS}:empty)`], ['display', 'none']);
  4131. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_ARROW_CLASS}`, [
  4132. ['position', 'absolute'],
  4133. ['left', '50%'],
  4134. ['margin-left', '-0.5em'],
  4135. ['border-width', '0.5em'],
  4136. ['border-style', 'solid'],
  4137. ]);
  4138. }
  4139.  
  4140.  
  4141. /***/ }),
  4142.  
  4143. /***/ "./ts/modal/body/nodes/actions/overlays/tooltip/index.ts":
  4144. /*!***************************************************************!*\
  4145. !*** ./ts/modal/body/nodes/actions/overlays/tooltip/index.ts ***!
  4146. \***************************************************************/
  4147. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4148.  
  4149. __webpack_require__.r(__webpack_exports__);
  4150. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4151. /* harmony export */ animationEnd: () => (/* binding */ animationEnd),
  4152. /* harmony export */ fade: () => (/* binding */ fade),
  4153. /* harmony export */ generate: () => (/* binding */ generate),
  4154. /* harmony export */ getAnimated: () => (/* binding */ getAnimated),
  4155. /* harmony export */ hide: () => (/* binding */ hide),
  4156. /* harmony export */ kill: () => (/* binding */ kill)
  4157. /* harmony export */ });
  4158. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/overlays/tooltip/consts.ts");
  4159. var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
  4160. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  4161. return new (P || (P = Promise))(function (resolve, reject) {
  4162. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  4163. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  4164. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  4165. step((generator = generator.apply(thisArg, _arguments || [])).next());
  4166. });
  4167. };
  4168.  
  4169. let animation;
  4170. function animationEnd() {
  4171. return __awaiter(this, void 0, void 0, function* () {
  4172. yield new Promise((resolve) => {
  4173. animation.addEventListener('finish', resolve);
  4174. });
  4175. });
  4176. }
  4177. function kill() {
  4178. animation === null || animation === void 0 ? void 0 : animation.finish();
  4179. }
  4180. function generate(doReverse = false) {
  4181. const container = document.createElement('div');
  4182. const arrow = document.createElement('div');
  4183. const box = document.createElement('div');
  4184. container.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_CONTAINER_CLASS);
  4185. arrow.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_ARROW_CLASS);
  4186. box.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_BOX_CLASS);
  4187. if (doReverse) {
  4188. arrow.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_REVERSE_CLASS);
  4189. }
  4190. container.append(arrow, box);
  4191. return container;
  4192. }
  4193. function getAnimated() {
  4194. const element = generate();
  4195. animation = element.animate(..._consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_ANIMATION);
  4196. animation.onfinish = ({ target }) => {
  4197. element.remove();
  4198. if (target === animation) {
  4199. animation = undefined;
  4200. }
  4201. };
  4202. return element;
  4203. }
  4204. function fade(container) {
  4205. if (container.querySelector(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_BOX_CLASS}`).matches(':empty')) {
  4206. return;
  4207. }
  4208. kill();
  4209. animation = container.animate(..._consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_ANIMATION_FAST);
  4210. animation.onfinish = ({ target }) => {
  4211. if (target === animation) {
  4212. animation = undefined;
  4213. }
  4214. };
  4215. }
  4216. function hide(element) {
  4217. element.querySelector(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_BOX_CLASS}`).innerText = '';
  4218. }
  4219.  
  4220.  
  4221. /***/ }),
  4222.  
  4223. /***/ "./ts/modal/body/nodes/actions/scroll.ts":
  4224. /*!***********************************************!*\
  4225. !*** ./ts/modal/body/nodes/actions/scroll.ts ***!
  4226. \***********************************************/
  4227. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4228.  
  4229. __webpack_require__.r(__webpack_exports__);
  4230. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4231. /* harmony export */ basicScroll: () => (/* binding */ basicScroll),
  4232. /* harmony export */ getStickyScroll: () => (/* binding */ getStickyScroll),
  4233. /* harmony export */ scroll: () => (/* binding */ scroll),
  4234. /* harmony export */ stickyScroll: () => (/* binding */ stickyScroll)
  4235. /* harmony export */ });
  4236. /* harmony import */ var _focus_consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./focus/consts */ "./ts/modal/body/nodes/actions/focus/consts.ts");
  4237. /* harmony import */ var _focus__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./focus */ "./ts/modal/body/nodes/actions/focus/index.ts");
  4238. /* harmony import */ var _modal_body__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/body */ "./ts/modal/body/index.ts");
  4239. /* harmony import */ var _modal_header_actions_sticky__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/modal/header/actions/sticky */ "./ts/modal/header/actions/sticky/index.ts");
  4240. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  4241.  
  4242.  
  4243.  
  4244.  
  4245.  
  4246. // specifically returns the last *visible* descendant
  4247. function getLastDescendant(node, isFocus = (0,_focus__WEBPACK_IMPORTED_MODULE_1__.isActive)()) {
  4248. if ('children' in node && node.children.length > 0 && (!isFocus || node.element.hasClass(_focus_consts__WEBPACK_IMPORTED_MODULE_0__.FOCUS_CLASS))) {
  4249. for (let i = node.children.length - 1; i >= 0; --i) {
  4250. if (node.children[i].element.elementContainer.clientHeight > 0) {
  4251. return getLastDescendant(node.children[i], isFocus);
  4252. }
  4253. }
  4254. }
  4255. return node;
  4256. }
  4257. // a scrollIntoView replacement for sticky positioning
  4258. function getStickyScroll(node, alignToTop = true) {
  4259. const firstChild = alignToTop ? node : getLastDescendant(node);
  4260. const { height } = node.element.headContainer.getBoundingClientRect();
  4261. let depth = 0;
  4262. for (let root = node; 'parent' in root; root = root.parent) {
  4263. depth++;
  4264. }
  4265. return Math.ceil(firstChild.element.headContainer.getBoundingClientRect().top
  4266. - _modal_body__WEBPACK_IMPORTED_MODULE_2__.element.getBoundingClientRect().top
  4267. + _modal_body__WEBPACK_IMPORTED_MODULE_2__.element.scrollTop
  4268. - (height + _modal_consts__WEBPACK_IMPORTED_MODULE_4__.SUB_PIXEL_BS) * depth);
  4269. }
  4270. function stickyScroll(node, doSnap = true, alignToTop = true) {
  4271. const scroll = getStickyScroll(node, alignToTop);
  4272. if (alignToTop) {
  4273. _modal_body__WEBPACK_IMPORTED_MODULE_2__.element.scrollTo({ top: scroll, behavior: doSnap ? 'auto' : 'smooth' });
  4274. }
  4275. else if (_modal_body__WEBPACK_IMPORTED_MODULE_2__.element.scrollTop > scroll) {
  4276. _modal_body__WEBPACK_IMPORTED_MODULE_2__.element.scrollTop = scroll;
  4277. }
  4278. }
  4279. function basicScroll(node) {
  4280. node.element.scrollIntoView({ block: 'center' });
  4281. }
  4282. function scroll(node) {
  4283. if ((0,_modal_header_actions_sticky__WEBPACK_IMPORTED_MODULE_3__.isActive)()) {
  4284. stickyScroll(node);
  4285. }
  4286. else {
  4287. basicScroll(node);
  4288. }
  4289. }
  4290.  
  4291.  
  4292. /***/ }),
  4293.  
  4294. /***/ "./ts/modal/body/nodes/child.ts":
  4295. /*!**************************************!*\
  4296. !*** ./ts/modal/body/nodes/child.ts ***!
  4297. \**************************************/
  4298. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4299.  
  4300. __webpack_require__.r(__webpack_exports__);
  4301. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4302. /* harmony export */ "default": () => (/* binding */ Child)
  4303. /* harmony export */ });
  4304. /* harmony import */ var _element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./element */ "./ts/modal/body/nodes/element.ts");
  4305. /* harmony import */ var _queue__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./queue */ "./ts/modal/body/nodes/queue.ts");
  4306. /* harmony import */ var _actions_highlight__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./actions/highlight */ "./ts/modal/body/nodes/actions/highlight/index.ts");
  4307. /* harmony import */ var _actions_edit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./actions/edit */ "./ts/modal/body/nodes/actions/edit/index.ts");
  4308. /* harmony import */ var _actions_focus__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./actions/focus */ "./ts/modal/body/nodes/actions/focus/index.ts");
  4309. /* harmony import */ var _actions_hide__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./actions/hide */ "./ts/modal/body/nodes/actions/hide/index.ts");
  4310. /* harmony import */ var _actions_callbacks_update__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./actions/callbacks/update */ "./ts/modal/body/nodes/actions/callbacks/update.ts");
  4311. /* harmony import */ var _actions_buttons_disable__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./actions/buttons/disable */ "./ts/modal/body/nodes/actions/buttons/disable/index.ts");
  4312. /* harmony import */ var _actions_buttons_move__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./actions/buttons/move */ "./ts/modal/body/nodes/actions/buttons/move/index.ts");
  4313. /* harmony import */ var _actions_buttons_duplicate__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./actions/buttons/duplicate */ "./ts/modal/body/nodes/actions/buttons/duplicate/index.ts");
  4314. /* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! @types */ "./ts/library/validation/types.ts");
  4315.  
  4316.  
  4317.  
  4318.  
  4319.  
  4320.  
  4321.  
  4322.  
  4323.  
  4324.  
  4325.  
  4326. const actions = [
  4327. // No button
  4328. _actions_highlight__WEBPACK_IMPORTED_MODULE_2__,
  4329. _actions_focus__WEBPACK_IMPORTED_MODULE_4__,
  4330. _actions_edit__WEBPACK_IMPORTED_MODULE_3__,
  4331. _actions_hide__WEBPACK_IMPORTED_MODULE_5__,
  4332. // Button
  4333. _actions_buttons_disable__WEBPACK_IMPORTED_MODULE_7__,
  4334. _actions_buttons_move__WEBPACK_IMPORTED_MODULE_8__,
  4335. _actions_buttons_duplicate__WEBPACK_IMPORTED_MODULE_9__,
  4336. ];
  4337. class Child {
  4338. constructor(data, parent, index) {
  4339. this.isActive = true;
  4340. this.element = new _element__WEBPACK_IMPORTED_MODULE_0__["default"](data);
  4341. for (const key of _types__WEBPACK_IMPORTED_MODULE_10__.LEAF_KEYS) {
  4342. if (key in data) {
  4343. this[key] = data[key];
  4344. }
  4345. }
  4346. this.forceValid = !('predicate' in data) && !('options' in data);
  4347. this.attach(parent, index);
  4348. for (const { shouldMount, mount } of actions) {
  4349. if (shouldMount(this)) {
  4350. mount(this);
  4351. }
  4352. }
  4353. if ('predicate' in data) {
  4354. this.predicate = () => data.predicate(this.value);
  4355. }
  4356. if ('onUpdate' in data) {
  4357. this.onUpdate = () => (0,_queue__WEBPACK_IMPORTED_MODULE_1__.onceVisualsUpdate)(() => data.onUpdate(this.value));
  4358. (0,_actions_callbacks_update__WEBPACK_IMPORTED_MODULE_6__.handle)(this.onUpdate(), 'onUpdate', this);
  4359. }
  4360. }
  4361. getRoot() {
  4362. return this.parent.getRoot();
  4363. }
  4364. getAncestors() {
  4365. return [this.parent, ...this.parent.getAncestors()];
  4366. }
  4367. getIndex() {
  4368. return this.parent.children.indexOf(this);
  4369. }
  4370. detach() {
  4371. this.parent.children.splice(this.getIndex(), 1);
  4372. this.element.remove();
  4373. this.parent = undefined;
  4374. }
  4375. attach(parent, index = parent.children.length) {
  4376. parent.children.splice(index, 0, this);
  4377. parent.element.addChild(this.element, index);
  4378. this.parent = parent;
  4379. }
  4380. move(parent, to) {
  4381. this.detach();
  4382. this.attach(parent, typeof to === 'number' ? to : to.getIndex() + 1);
  4383. }
  4384. duplicate() {
  4385. return new Child(this.getSeedData(), this.parent, this.getIndex() + 1);
  4386. }
  4387. unmount() {
  4388. for (const action of actions) {
  4389. if ('unmount' in action) {
  4390. action.unmount(this);
  4391. }
  4392. }
  4393. }
  4394. disconnect() {
  4395. this.unmount();
  4396. this.detach();
  4397. }
  4398. getSeedData() {
  4399. const data = {};
  4400. for (const key of _types__WEBPACK_IMPORTED_MODULE_10__.LEAF_KEYS) {
  4401. if (key in this) {
  4402. data[key] = this[key];
  4403. }
  4404. }
  4405. return data;
  4406. }
  4407. getPredicateData() {
  4408. const data = {};
  4409. for (const key of _types__WEBPACK_IMPORTED_MODULE_10__.SAVED_KEYS) {
  4410. if (key in this) {
  4411. data[key] = this[key];
  4412. }
  4413. }
  4414. if (data.isActive) {
  4415. delete data.isActive;
  4416. }
  4417. return data;
  4418. }
  4419. getSaveData(isActiveBranch) {
  4420. const tree = this.getPredicateData();
  4421. if (isActiveBranch) {
  4422. return {
  4423. tree,
  4424. activeTree: tree,
  4425. configs: 'get' in this ? [this.get(tree, [])] : [],
  4426. };
  4427. }
  4428. return { tree };
  4429. }
  4430. }
  4431.  
  4432.  
  4433. /***/ }),
  4434.  
  4435. /***/ "./ts/modal/body/nodes/consts.ts":
  4436. /*!***************************************!*\
  4437. !*** ./ts/modal/body/nodes/consts.ts ***!
  4438. \***************************************/
  4439. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4440.  
  4441. __webpack_require__.r(__webpack_exports__);
  4442. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4443. /* harmony export */ BASE_CLASS: () => (/* binding */ BASE_CLASS),
  4444. /* harmony export */ CHECKBOX_WRAPPER_CLASS: () => (/* binding */ CHECKBOX_WRAPPER_CLASS),
  4445. /* harmony export */ CONTRAST_CLASS: () => (/* binding */ CONTRAST_CLASS),
  4446. /* harmony export */ EDITABLE_CLASS: () => (/* binding */ EDITABLE_CLASS),
  4447. /* harmony export */ ELEMENT_CLASSES: () => (/* binding */ ELEMENT_CLASSES),
  4448. /* harmony export */ MIDDLE_CLASS: () => (/* binding */ MIDDLE_CLASS),
  4449. /* harmony export */ NODE_COLOURS: () => (/* binding */ NODE_COLOURS),
  4450. /* harmony export */ ROOT_CLASS: () => (/* binding */ ROOT_CLASS)
  4451. /* harmony export */ });
  4452. const ROOT_CLASS = 'root';
  4453. const MIDDLE_CLASS = 'middle';
  4454. const ELEMENT_CLASSES = {
  4455. ELEMENT_CONTAINER: 'node',
  4456. BACKGROUND_CONTAINER: 'node-background-container',
  4457. CHILD_CONTAINER: 'node-child-container',
  4458. BUTTON_CONTAINER: 'node-button-container',
  4459. INFO_CONTAINER: 'node-info-container',
  4460. HEAD_CONTAINER: 'node-head-container',
  4461. VALUE_CONTAINER: 'node-value-container',
  4462. VALUE: 'node-value',
  4463. LABEL_CONTAINER: 'node-label-container',
  4464. LABEL: 'node-label',
  4465. };
  4466. const BASE_CLASS = 'node-base';
  4467. const CONTRAST_CLASS = 'node-contrast';
  4468. const CHECKBOX_WRAPPER_CLASS = 'checkbox-wrapper';
  4469. const EDITABLE_CLASS = 'editable';
  4470. const NODE_COLOURS = [
  4471. [`.${ELEMENT_CLASSES.ELEMENT_CONTAINER}:not(.${EDITABLE_CLASS})`, 'var(--nodeHeaderBase)', 'var(--nodeHeaderContrast)'],
  4472. [`.${ELEMENT_CLASSES.ELEMENT_CONTAINER}.${MIDDLE_CLASS}.${EDITABLE_CLASS}`, 'var(--nodeBlendBase)', 'var(--nodeBlendContrast)'],
  4473. [`.${ELEMENT_CLASSES.ELEMENT_CONTAINER}:not(.${MIDDLE_CLASS}).${EDITABLE_CLASS}`, 'var(--nodeValueBase)', 'var(--nodeValueContrast)'],
  4474. ];
  4475.  
  4476.  
  4477. /***/ }),
  4478.  
  4479. /***/ "./ts/modal/body/nodes/css.ts":
  4480. /*!************************************!*\
  4481. !*** ./ts/modal/body/nodes/css.ts ***!
  4482. \************************************/
  4483. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4484.  
  4485. __webpack_require__.r(__webpack_exports__);
  4486. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4487. /* harmony export */ "default": () => (/* binding */ generate)
  4488. /* harmony export */ });
  4489. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/consts.ts");
  4490. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  4491. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  4492.  
  4493.  
  4494.  
  4495. function generate() {
  4496. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ROOT_CLASS}`, [
  4497. ['flex-grow', '1'],
  4498. // Apparently it has min-height 100% without a content-related height value
  4499. ['height', 'fit-content'],
  4500. ]);
  4501. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.CHILD_CONTAINER}:empty`, ['display', 'none']);
  4502. (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']);
  4503. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.ELEMENT_CONTAINER}`, [
  4504. ['user-select', 'none'],
  4505. ['position', 'relative'],
  4506. ['border-width', `${_modal_consts__WEBPACK_IMPORTED_MODULE_1__.SUB_PIXEL_BS}px`],
  4507. ]);
  4508. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.INFO_CONTAINER} > *`], [
  4509. ['position', 'absolute'],
  4510. ['width', '100%'],
  4511. ['height', '100%'],
  4512. ]);
  4513. (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}`], [
  4514. ['position', 'absolute'],
  4515. ['white-space', 'nowrap'],
  4516. ]);
  4517. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.INFO_CONTAINER}`, ['position', 'relative']);
  4518. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([`.${_consts__WEBPACK_IMPORTED_MODULE_0__.BASE_CLASS} > .${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.VALUE_CONTAINER}`], [
  4519. ['position', 'absolute'],
  4520. ['right', '0'],
  4521. ['overflow', 'hidden'],
  4522. ]);
  4523. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([
  4524. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.HEAD_CONTAINER}`,
  4525. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.VALUE_CONTAINER}`,
  4526. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.LABEL_CONTAINER}`,
  4527. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.BACKGROUND_CONTAINER}`,
  4528. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.INFO_CONTAINER}`,
  4529. ], [
  4530. ['flex-grow', '1'],
  4531. ['display', 'flex'],
  4532. ['align-items', 'center'],
  4533. ]);
  4534. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.BACKGROUND_CONTAINER}`], [['position', 'absolute']]);
  4535. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.LABEL_CONTAINER}`, [
  4536. ['right', '0'],
  4537. ['pointer-events', 'none'],
  4538. ['height', '100%'],
  4539. ]);
  4540. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.VALUE_CONTAINER}`, [
  4541. ['user-select', 'none'],
  4542. ['height', '100%'],
  4543. ]);
  4544. (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%']]);
  4545. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.BACKGROUND_CONTAINER} > *`, [
  4546. ['height', '100%'],
  4547. ['position', 'absolute'],
  4548. ]);
  4549. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.VALUE}`, `.${_consts__WEBPACK_IMPORTED_MODULE_0__.CHECKBOX_WRAPPER_CLASS}`], [
  4550. ['padding-right', '0.6em'],
  4551. ['padding-left', '0.6em'],
  4552. ]);
  4553. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.HEAD_CONTAINER}`, [
  4554. ['background-color', 'inherit'],
  4555. ['user-select', 'none'],
  4556. ['height', `${_modal_consts__WEBPACK_IMPORTED_MODULE_1__.NODE_HEIGHT}em`],
  4557. ]);
  4558. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.HEAD_CONTAINER} > *`, ['height', '100%']);
  4559. (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']);
  4560. (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']);
  4561. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ROOT_CLASS}`, ['border-bottom-style', 'solid']);
  4562. for (const [selector, base, contrast] of _consts__WEBPACK_IMPORTED_MODULE_0__.NODE_COLOURS) {
  4563. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(selector, [
  4564. ['background-color', base],
  4565. ['color', contrast],
  4566. ]);
  4567. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`${selector}`, ['border-color', contrast]);
  4568. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`${selector} > .${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.HEAD_CONTAINER}`, ['outline', `1px solid ${contrast}`]);
  4569. }
  4570. }
  4571.  
  4572.  
  4573. /***/ }),
  4574.  
  4575. /***/ "./ts/modal/body/nodes/element.ts":
  4576. /*!****************************************!*\
  4577. !*** ./ts/modal/body/nodes/element.ts ***!
  4578. \****************************************/
  4579. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4580.  
  4581. __webpack_require__.r(__webpack_exports__);
  4582. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4583. /* harmony export */ "default": () => (/* binding */ Element)
  4584. /* harmony export */ });
  4585. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/consts.ts");
  4586.  
  4587. class Element {
  4588. constructor(data) {
  4589. this.elementContainer = document.createElement('div');
  4590. this.backgroundContainer = document.createElement('div');
  4591. this.headContainer = document.createElement('span');
  4592. this.buttonContainer = document.createElement('span');
  4593. this.infoContainer = document.createElement('span');
  4594. this.base = { container: document.createElement('span') };
  4595. this.contrast = { container: document.createElement('span') };
  4596. this.childContainer = document.createElement('div');
  4597. this.elementContainer.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.ELEMENT_CONTAINER);
  4598. this.backgroundContainer.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.BACKGROUND_CONTAINER);
  4599. this.childContainer.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.CHILD_CONTAINER);
  4600. this.infoContainer.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.INFO_CONTAINER);
  4601. this.headContainer.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.HEAD_CONTAINER);
  4602. this.buttonContainer.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.BUTTON_CONTAINER);
  4603. this.base.container.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.BASE_CLASS);
  4604. this.contrast.container.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.CONTRAST_CLASS);
  4605. if ('value' in data) {
  4606. this.addValueContainer(this.contrast, data);
  4607. this.addValueContainer(this.base, data);
  4608. this.render(data.value);
  4609. }
  4610. if ('label' in data) {
  4611. this.addLabelContainer(this.contrast, data.label);
  4612. this.addLabelContainer(this.base, data.label);
  4613. }
  4614. this.infoContainer.append(this.backgroundContainer, this.contrast.container, this.base.container);
  4615. this.headContainer.append(this.buttonContainer, this.infoContainer);
  4616. this.elementContainer.appendChild(this.headContainer);
  4617. this.elementContainer.appendChild(this.childContainer);
  4618. }
  4619. addLabelContainer({ container }, label) {
  4620. const labelContainer = document.createElement('div');
  4621. const labelElement = document.createElement('span');
  4622. labelContainer.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.LABEL_CONTAINER);
  4623. labelElement.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.LABEL);
  4624. labelElement.innerText = label;
  4625. labelContainer.appendChild(labelElement);
  4626. container.appendChild(labelContainer);
  4627. }
  4628. addValueContainer(field, data) {
  4629. field.valueContainer = document.createElement('label');
  4630. field.valueContainer.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.VALUE_CONTAINER);
  4631. if ('value' in data) {
  4632. field.valueElement = document.createElement('input');
  4633. field.valueElement.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.VALUE);
  4634. if ('inputAttributes' in data) {
  4635. for (const [key, value] of Object.entries(data.inputAttributes)) {
  4636. field.valueElement.setAttribute(key, value);
  4637. }
  4638. }
  4639. field.valueElement.setAttribute('tabindex', '-1');
  4640. if (typeof data.value === 'boolean') {
  4641. field.valueElement.type = 'checkbox';
  4642. // Positions tooltips below checkboxes
  4643. const valueWrapper = document.createElement('span');
  4644. valueWrapper.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.CHECKBOX_WRAPPER_CLASS);
  4645. valueWrapper.appendChild(field.valueElement);
  4646. field.valueContainer.appendChild(valueWrapper);
  4647. }
  4648. else {
  4649. if (typeof data.value === 'number') {
  4650. field.valueElement.type = 'number';
  4651. // Disables a tooltip implying that decimal values are invalid
  4652. field.valueElement.step = 'any';
  4653. }
  4654. else if ('input' in data) {
  4655. field.valueElement.type = data.input;
  4656. }
  4657. field.valueContainer.appendChild(field.valueElement);
  4658. }
  4659. }
  4660. field.container.appendChild(field.valueContainer);
  4661. }
  4662. render(value) {
  4663. if (typeof value === 'boolean') {
  4664. this.base.valueElement.checked = value;
  4665. this.contrast.valueElement.checked = value;
  4666. }
  4667. else {
  4668. this.base.valueElement.value = value.toString();
  4669. this.contrast.valueElement.value = value.toString();
  4670. }
  4671. }
  4672. hasClass(...names) {
  4673. for (const name of names) {
  4674. if (this.elementContainer.classList.contains(name)) {
  4675. return true;
  4676. }
  4677. }
  4678. return false;
  4679. }
  4680. addClass(...names) {
  4681. for (const name of names) {
  4682. this.elementContainer.classList.add(name);
  4683. }
  4684. }
  4685. removeClass(...names) {
  4686. for (const name of names) {
  4687. this.elementContainer.classList.remove(name);
  4688. }
  4689. }
  4690. addChild(child, index) {
  4691. var _a;
  4692. this.childContainer.insertBefore(child.elementContainer, (_a = this.childContainer.children[index]) !== null && _a !== void 0 ? _a : null);
  4693. }
  4694. addButton(button) {
  4695. this.buttonContainer.appendChild(button);
  4696. }
  4697. remove() {
  4698. this.elementContainer.remove();
  4699. }
  4700. scrollIntoView(options) {
  4701. this.backgroundContainer.scrollIntoView(typeof options === 'object' ? Object.assign({ block: 'center' }, options) : options);
  4702. }
  4703. }
  4704.  
  4705.  
  4706. /***/ }),
  4707.  
  4708. /***/ "./ts/modal/body/nodes/middle.ts":
  4709. /*!***************************************!*\
  4710. !*** ./ts/modal/body/nodes/middle.ts ***!
  4711. \***************************************/
  4712. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4713.  
  4714. __webpack_require__.r(__webpack_exports__);
  4715. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4716. /* harmony export */ "default": () => (/* binding */ Middle)
  4717. /* harmony export */ });
  4718. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/consts.ts");
  4719. /* harmony import */ var _root__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./root */ "./ts/modal/body/nodes/root.ts");
  4720. /* harmony import */ var _child__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./child */ "./ts/modal/body/nodes/child.ts");
  4721. /* harmony import */ var _pools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./pools */ "./ts/modal/body/nodes/pools.ts");
  4722. /* harmony import */ var _actions_buttons_create__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./actions/buttons/create */ "./ts/modal/body/nodes/actions/buttons/create/index.ts");
  4723. /* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @types */ "./ts/library/validation/types.ts");
  4724.  
  4725.  
  4726.  
  4727.  
  4728.  
  4729.  
  4730. const MIDDLE_KEYS = _types__WEBPACK_IMPORTED_MODULE_5__.MIDDLE_KEYS.filter((key) => key !== 'children');
  4731. const actions = [_actions_buttons_create__WEBPACK_IMPORTED_MODULE_4__];
  4732. class Middle extends _child__WEBPACK_IMPORTED_MODULE_2__["default"] {
  4733. constructor(data, parent, index) {
  4734. super(data, parent, index);
  4735. this.children = [];
  4736. _root__WEBPACK_IMPORTED_MODULE_1__.setup.call(this, data);
  4737. this.element.addClass(_consts__WEBPACK_IMPORTED_MODULE_0__.MIDDLE_CLASS);
  4738. for (const { shouldMount, mount } of actions) {
  4739. if (shouldMount(this)) {
  4740. mount(this);
  4741. }
  4742. }
  4743. }
  4744. duplicate() {
  4745. return new Middle(this.getSeedData(), this.parent, this.getIndex() + 1);
  4746. }
  4747. unmount() {
  4748. super.unmount();
  4749. for (const action of actions) {
  4750. if ('unmount' in action) {
  4751. action.unmount(this);
  4752. }
  4753. }
  4754. if ('poolId' in this) {
  4755. (0,_pools__WEBPACK_IMPORTED_MODULE_3__.remove)(this.poolId, this);
  4756. }
  4757. for (const child of this.children) {
  4758. child.unmount();
  4759. }
  4760. }
  4761. disconnect() {
  4762. this.unmount();
  4763. this.detach();
  4764. }
  4765. // for duplication
  4766. getSeedData() {
  4767. const data = {};
  4768. for (const key of MIDDLE_KEYS) {
  4769. if (key in this) {
  4770. data[key] = this[key];
  4771. }
  4772. }
  4773. return Object.assign(Object.assign(Object.assign({}, super.getSeedData()), data), { children: this.children.map((child) => child.getSeedData()) });
  4774. }
  4775. getPredicateData() {
  4776. return Object.assign(Object.assign({}, super.getPredicateData()), _root__WEBPACK_IMPORTED_MODULE_1__.getPredicateData.call(this));
  4777. }
  4778. getSaveData(isActiveBranch) {
  4779. const data = _root__WEBPACK_IMPORTED_MODULE_1__.getSaveData.call(this, isActiveBranch);
  4780. const tree = Object.assign(Object.assign({}, super.getPredicateData()), data.tree);
  4781. if (isActiveBranch) {
  4782. const activeTree = Object.assign(Object.assign({}, tree), data.activeTree);
  4783. return {
  4784. tree,
  4785. activeTree,
  4786. configs: 'get' in this ? [this.get(activeTree, data.configs)] : data.configs,
  4787. };
  4788. }
  4789. return { tree };
  4790. }
  4791. }
  4792.  
  4793.  
  4794. /***/ }),
  4795.  
  4796. /***/ "./ts/modal/body/nodes/pools.ts":
  4797. /*!**************************************!*\
  4798. !*** ./ts/modal/body/nodes/pools.ts ***!
  4799. \**************************************/
  4800. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4801.  
  4802. __webpack_require__.r(__webpack_exports__);
  4803. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4804. /* harmony export */ add: () => (/* binding */ add),
  4805. /* harmony export */ get: () => (/* binding */ get),
  4806. /* harmony export */ remove: () => (/* binding */ remove)
  4807. /* harmony export */ });
  4808. const pools = [];
  4809. function get(node) {
  4810. var _a;
  4811. return [...((_a = pools[node.poolId]) !== null && _a !== void 0 ? _a : [node])];
  4812. }
  4813. function add(id, node) {
  4814. var _a;
  4815. (_a = pools[id]) !== null && _a !== void 0 ? _a : (pools[id] = []);
  4816. pools[id].push(node);
  4817. }
  4818. function remove(id, node) {
  4819. pools[id].splice(pools[id].indexOf(node), 1);
  4820. }
  4821.  
  4822.  
  4823. /***/ }),
  4824.  
  4825. /***/ "./ts/modal/body/nodes/queue.ts":
  4826. /*!**************************************!*\
  4827. !*** ./ts/modal/body/nodes/queue.ts ***!
  4828. \**************************************/
  4829. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4830.  
  4831. __webpack_require__.r(__webpack_exports__);
  4832. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4833. /* harmony export */ onceVisualsUpdate: () => (/* binding */ onceVisualsUpdate)
  4834. /* harmony export */ });
  4835. const queue = [];
  4836. // No idea if this works on all machines/browsers
  4837. function onceVisualsUpdate(_callback) {
  4838. return new Promise((resolve) => {
  4839. const callback = () => resolve(_callback());
  4840. if (queue.push(callback) > 1) {
  4841. return;
  4842. }
  4843. // Wait for update to start
  4844. requestAnimationFrame(() => {
  4845. // Wait for everything else to update
  4846. window.setTimeout(() => {
  4847. for (const callback of queue) {
  4848. callback();
  4849. }
  4850. queue.length = 0;
  4851. }, 0);
  4852. });
  4853. });
  4854. }
  4855.  
  4856.  
  4857. /***/ }),
  4858.  
  4859. /***/ "./ts/modal/body/nodes/root.ts":
  4860. /*!*************************************!*\
  4861. !*** ./ts/modal/body/nodes/root.ts ***!
  4862. \*************************************/
  4863. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4864.  
  4865. __webpack_require__.r(__webpack_exports__);
  4866. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4867. /* harmony export */ "default": () => (/* binding */ Root),
  4868. /* harmony export */ getPredicateData: () => (/* binding */ getPredicateData),
  4869. /* harmony export */ getSaveData: () => (/* binding */ getSaveData),
  4870. /* harmony export */ setup: () => (/* binding */ setup)
  4871. /* harmony export */ });
  4872. /* harmony import */ var _middle__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./middle */ "./ts/modal/body/nodes/middle.ts");
  4873. /* harmony import */ var _child__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./child */ "./ts/modal/body/nodes/child.ts");
  4874. /* harmony import */ var _element__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./element */ "./ts/modal/body/nodes/element.ts");
  4875. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/consts.ts");
  4876. /* harmony import */ var _queue__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./queue */ "./ts/modal/body/nodes/queue.ts");
  4877. /* harmony import */ var _pools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./pools */ "./ts/modal/body/nodes/pools.ts");
  4878. /* harmony import */ var _actions_highlight__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./actions/highlight */ "./ts/modal/body/nodes/actions/highlight/index.ts");
  4879. /* harmony import */ var _actions_focus__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./actions/focus */ "./ts/modal/body/nodes/actions/focus/index.ts");
  4880. /* harmony import */ var _actions_buttons_create__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./actions/buttons/create */ "./ts/modal/body/nodes/actions/buttons/create/index.ts");
  4881. /* harmony import */ var _actions_callbacks_update__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./actions/callbacks/update */ "./ts/modal/body/nodes/actions/callbacks/update.ts");
  4882. /* harmony import */ var _actions_buttons_consts__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./actions/buttons/consts */ "./ts/modal/body/nodes/actions/buttons/consts.ts");
  4883. /* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! @types */ "./ts/library/validation/types.ts");
  4884. var __rest = (undefined && undefined.__rest) || function (s, e) {
  4885. var t = {};
  4886. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  4887. t[p] = s[p];
  4888. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  4889. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
  4890. if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
  4891. t[p[i]] = s[p[i]];
  4892. }
  4893. return t;
  4894. };
  4895.  
  4896.  
  4897.  
  4898.  
  4899.  
  4900.  
  4901.  
  4902.  
  4903.  
  4904.  
  4905.  
  4906.  
  4907. const actions = [_actions_highlight__WEBPACK_IMPORTED_MODULE_6__, _actions_focus__WEBPACK_IMPORTED_MODULE_7__, _actions_buttons_create__WEBPACK_IMPORTED_MODULE_8__];
  4908. function isActive(child) {
  4909. return !('isActive' in child) || child.isActive;
  4910. }
  4911. function getChildPredicateData({ children }) {
  4912. return children
  4913. .filter((child) => isActive(child) && !child.element.hasClass(_actions_buttons_consts__WEBPACK_IMPORTED_MODULE_10__.TEST_REMOVE_CLASS))
  4914. .map((child) => child.getPredicateData());
  4915. }
  4916. function getChildSaveData({ children }, isActiveBranch = true) {
  4917. return children
  4918. .filter((child) => !child.element.hasClass(_actions_buttons_consts__WEBPACK_IMPORTED_MODULE_10__.TEST_ADD_CLASS))
  4919. .map((child) => child.getSaveData(isActive(child) && isActiveBranch));
  4920. }
  4921. function addChildren(children) {
  4922. for (const child of children) {
  4923. if ('children' in child) {
  4924. new _middle__WEBPACK_IMPORTED_MODULE_0__["default"](child, this);
  4925. }
  4926. else {
  4927. new _child__WEBPACK_IMPORTED_MODULE_1__["default"](child, this);
  4928. }
  4929. }
  4930. }
  4931. function setup(_a) {
  4932. var { children } = _a, data = __rest(_a, ["children"]);
  4933. for (const key of _types__WEBPACK_IMPORTED_MODULE_11__.ROOT_OTHER_KEYS) {
  4934. if (key in data) {
  4935. this[key] = data[key];
  4936. }
  4937. }
  4938. addChildren.call(this, children);
  4939. for (const key of _types__WEBPACK_IMPORTED_MODULE_11__.ROOT_PREDICATE_KEYS) {
  4940. if (key in data) {
  4941. this[key] = () => data[key](getChildPredicateData(this));
  4942. }
  4943. }
  4944. for (const key of _types__WEBPACK_IMPORTED_MODULE_11__.ROOT_UPDATE_KEYS) {
  4945. if (key in data) {
  4946. this[key] = () => (0,_queue__WEBPACK_IMPORTED_MODULE_4__.onceVisualsUpdate)(() => data[key](getChildPredicateData(this)));
  4947. (0,_actions_callbacks_update__WEBPACK_IMPORTED_MODULE_9__.handle)(this[key](), key, this);
  4948. }
  4949. }
  4950. if ('poolId' in data) {
  4951. (0,_pools__WEBPACK_IMPORTED_MODULE_5__.add)(data.poolId, this);
  4952. }
  4953. }
  4954. function getPredicateData() {
  4955. return { children: getChildPredicateData(this) };
  4956. }
  4957. function getSaveData(isActiveBranch) {
  4958. const activeChildren = [];
  4959. const children = [];
  4960. const configs = [];
  4961. for (const child of getChildSaveData(this, isActiveBranch)) {
  4962. children.push(child.tree);
  4963. if ('activeTree' in child) {
  4964. activeChildren.push(child.activeTree);
  4965. configs.push(...child.configs);
  4966. }
  4967. }
  4968. return { tree: { children }, activeTree: { children: activeChildren }, configs };
  4969. }
  4970. class Root {
  4971. constructor(data) {
  4972. this.children = [];
  4973. this.addChildren = addChildren;
  4974. this.getPredicateData = getPredicateData;
  4975. this.element = new _element__WEBPACK_IMPORTED_MODULE_2__["default"]({});
  4976. this.element.addClass(_consts__WEBPACK_IMPORTED_MODULE_3__.ROOT_CLASS);
  4977. setup.call(this, data);
  4978. for (const { shouldMount, mount } of actions) {
  4979. if (shouldMount(this)) {
  4980. mount(this);
  4981. }
  4982. }
  4983. }
  4984. getRoot() {
  4985. return this;
  4986. }
  4987. getAncestors() {
  4988. return [];
  4989. }
  4990. getSaveData() {
  4991. const { tree, activeTree, configs } = getSaveData.call(this);
  4992. if ('get' in this) {
  4993. return { tree, config: this.get(activeTree, configs) };
  4994. }
  4995. return { tree, config: configs.length === 1 ? configs[0] : configs };
  4996. }
  4997. }
  4998.  
  4999.  
  5000. /***/ }),
  5001.  
  5002. /***/ "./ts/modal/body/style/consts.ts":
  5003. /*!***************************************!*\
  5004. !*** ./ts/modal/body/style/consts.ts ***!
  5005. \***************************************/
  5006. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5007.  
  5008. __webpack_require__.r(__webpack_exports__);
  5009. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5010. /* harmony export */ DEFAULT_STYLE: () => (/* binding */ DEFAULT_STYLE),
  5011. /* harmony export */ ROOT_ID: () => (/* binding */ ROOT_ID)
  5012. /* harmony export */ });
  5013. const ROOT_ID = 'root-style';
  5014. const DEFAULT_STYLE = {
  5015. width: 80,
  5016. height: 80,
  5017. fontSize: 18,
  5018. borderTooltip: '#570000',
  5019. borderModal: '#ffffff',
  5020. headBase: '#000000',
  5021. headContrast: 'Black / White',
  5022. headButtonExit: '#f10000',
  5023. headButtonLabel: '#906300',
  5024. headButtonSticky: '#199a00',
  5025. headButtonStyle: '#900091',
  5026. headButtonHide: '#00749a',
  5027. headButtonAlt: '#838f00',
  5028. nodeHeaderBase: '#101010',
  5029. nodeBlendBase: '#101010',
  5030. nodeValueBase: '#303030',
  5031. nodeContrast: 'Black / White',
  5032. nodeButtonCreate: '#40ff40',
  5033. nodeButtonDuplicate: '#40ffff',
  5034. nodeButtonMove: '#ac60ff',
  5035. nodeButtonDisable: '#ffd000',
  5036. nodeButtonDelete: '#ff1111',
  5037. validBackground: '#d9ffc0',
  5038. invalidBackground: '#ffb4be',
  5039. focusBackground: '#e8e8e8',
  5040. };
  5041.  
  5042.  
  5043. /***/ }),
  5044.  
  5045. /***/ "./ts/modal/body/style/css.ts":
  5046. /*!************************************!*\
  5047. !*** ./ts/modal/body/style/css.ts ***!
  5048. \************************************/
  5049. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5050.  
  5051. __webpack_require__.r(__webpack_exports__);
  5052. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5053. /* harmony export */ "default": () => (/* binding */ generate)
  5054. /* harmony export */ });
  5055. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/style/consts.ts");
  5056. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../consts */ "./ts/modal/body/consts.ts");
  5057. /* harmony import */ var _data_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../data/consts */ "./ts/modal/body/data/consts.ts");
  5058. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  5059. /* 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");
  5060.  
  5061.  
  5062.  
  5063.  
  5064.  
  5065. function generate() {
  5066. (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']);
  5067. (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']);
  5068. }
  5069.  
  5070.  
  5071. /***/ }),
  5072.  
  5073. /***/ "./ts/modal/body/style/index.ts":
  5074. /*!**************************************!*\
  5075. !*** ./ts/modal/body/style/index.ts ***!
  5076. \**************************************/
  5077. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5078.  
  5079. __webpack_require__.r(__webpack_exports__);
  5080. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5081. /* harmony export */ "default": () => (/* binding */ generate),
  5082. /* harmony export */ getRoot: () => (/* binding */ getRoot),
  5083. /* harmony export */ getUserStyles: () => (/* binding */ getUserStyles),
  5084. /* harmony export */ toJSON: () => (/* binding */ toJSON),
  5085. /* harmony export */ toRawStyle: () => (/* binding */ toRawStyle)
  5086. /* harmony export */ });
  5087. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/style/consts.ts");
  5088. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./css */ "./ts/modal/body/style/css.ts");
  5089. /* harmony import */ var _update__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./update */ "./ts/modal/body/style/update.ts");
  5090. /* harmony import */ var ___WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! .. */ "./ts/modal/body/index.ts");
  5091. /* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @types */ "./ts/library/validation/types.ts");
  5092.  
  5093.  
  5094.  
  5095.  
  5096.  
  5097. function getRoot() {
  5098. return ___WEBPACK_IMPORTED_MODULE_3__.ROOTS[_consts__WEBPACK_IMPORTED_MODULE_0__.ROOT_ID];
  5099. }
  5100. // Fill any missing entries
  5101. function getFilledStyle(style = {}) {
  5102. return Object.assign(Object.assign({}, _consts__WEBPACK_IMPORTED_MODULE_0__.DEFAULT_STYLE), style);
  5103. }
  5104. function toJSON(style) {
  5105. var _a;
  5106. const filledStyle = Object.assign(Object.assign({}, _consts__WEBPACK_IMPORTED_MODULE_0__.DEFAULT_STYLE), style);
  5107. return {
  5108. label: 'Name',
  5109. value: filledStyle.name,
  5110. isActive: (_a = filledStyle.isActive) !== null && _a !== void 0 ? _a : true,
  5111. children: [
  5112. {
  5113. label: 'Modal',
  5114. children: [
  5115. {
  5116. label: 'Width (%)',
  5117. value: filledStyle.width,
  5118. predicate: (value) => value > 0 || 'Width must be greater than zero',
  5119. },
  5120. {
  5121. label: 'Height (%)',
  5122. value: filledStyle.height,
  5123. predicate: (value) => value > 0 || 'Height must be greater than zero',
  5124. },
  5125. {
  5126. label: 'Font Size (px)',
  5127. value: filledStyle.fontSize,
  5128. predicate: (value) => value > 0 || 'Font size must be greater than zero',
  5129. },
  5130. {
  5131. label: 'Border Color',
  5132. value: filledStyle.borderModal,
  5133. input: 'color',
  5134. },
  5135. ],
  5136. },
  5137. {
  5138. label: 'Header',
  5139. children: [
  5140. {
  5141. label: 'General',
  5142. children: [
  5143. {
  5144. label: 'Base Color',
  5145. value: filledStyle.headBase,
  5146. input: 'color',
  5147. },
  5148. {
  5149. label: 'Contrast Method',
  5150. value: filledStyle.headContrast,
  5151. options: [..._types__WEBPACK_IMPORTED_MODULE_4__.CONTRAST_METHODS],
  5152. },
  5153. ],
  5154. },
  5155. {
  5156. label: 'Buttons',
  5157. children: [
  5158. {
  5159. label: 'Exit Color',
  5160. value: filledStyle.headButtonExit,
  5161. input: 'color',
  5162. },
  5163. {
  5164. label: 'Label Color',
  5165. value: filledStyle.headButtonLabel,
  5166. input: 'color',
  5167. },
  5168. {
  5169. label: 'Sticky Color',
  5170. value: filledStyle.headButtonSticky,
  5171. input: 'color',
  5172. },
  5173. {
  5174. label: 'Style Color',
  5175. value: filledStyle.headButtonStyle,
  5176. input: 'color',
  5177. },
  5178. {
  5179. label: 'Hide Color',
  5180. value: filledStyle.headButtonHide,
  5181. input: 'color',
  5182. },
  5183. {
  5184. label: 'Alt Buttons Color',
  5185. value: filledStyle.headButtonAlt,
  5186. input: 'color',
  5187. },
  5188. ],
  5189. },
  5190. ],
  5191. },
  5192. {
  5193. label: 'Body',
  5194. children: [
  5195. {
  5196. label: 'General',
  5197. children: [
  5198. {
  5199. label: 'Header Node Color',
  5200. value: _consts__WEBPACK_IMPORTED_MODULE_0__.DEFAULT_STYLE.nodeHeaderBase,
  5201. input: 'color',
  5202. },
  5203. {
  5204. label: 'Blend Node Color',
  5205. value: _consts__WEBPACK_IMPORTED_MODULE_0__.DEFAULT_STYLE.nodeBlendBase,
  5206. input: 'color',
  5207. },
  5208. {
  5209. label: 'Value Node Color',
  5210. value: _consts__WEBPACK_IMPORTED_MODULE_0__.DEFAULT_STYLE.nodeValueBase,
  5211. input: 'color',
  5212. },
  5213. {
  5214. label: 'Contrast Method',
  5215. value: filledStyle.nodeContrast,
  5216. options: [..._types__WEBPACK_IMPORTED_MODULE_4__.CONTRAST_METHODS],
  5217. },
  5218. ],
  5219. },
  5220. {
  5221. label: 'Buttons',
  5222. children: [
  5223. {
  5224. label: 'Create Color',
  5225. value: filledStyle.nodeButtonCreate,
  5226. input: 'color',
  5227. },
  5228. {
  5229. label: 'Duplicate Color',
  5230. value: filledStyle.nodeButtonDuplicate,
  5231. input: 'color',
  5232. },
  5233. {
  5234. label: 'Move Color',
  5235. value: filledStyle.nodeButtonMove,
  5236. input: 'color',
  5237. },
  5238. {
  5239. label: 'Disable Color',
  5240. value: filledStyle.nodeButtonDisable,
  5241. input: 'color',
  5242. },
  5243. {
  5244. label: 'Delete Color',
  5245. value: filledStyle.nodeButtonDelete,
  5246. input: 'color',
  5247. },
  5248. ],
  5249. },
  5250. {
  5251. label: 'Miscellaneous',
  5252. children: [
  5253. {
  5254. label: 'Valid Color',
  5255. value: filledStyle.validBackground,
  5256. input: 'color',
  5257. },
  5258. {
  5259. label: 'Invalid Color',
  5260. value: filledStyle.invalidBackground,
  5261. input: 'color',
  5262. },
  5263. {
  5264. label: 'Focus Color',
  5265. value: filledStyle.focusBackground,
  5266. input: 'color',
  5267. },
  5268. {
  5269. label: 'Tooltip Color',
  5270. value: filledStyle.borderTooltip,
  5271. input: 'color',
  5272. },
  5273. ],
  5274. },
  5275. ],
  5276. },
  5277. ],
  5278. };
  5279. }
  5280. function toRawStyle(json) {
  5281. const [modal, header, body] = json.children.map(({ children }) => children);
  5282. const [headerGeneral, headerButtons] = header.map(({ children }) => children);
  5283. const [bodyGeneral, bodyButtons, bodyMisc] = body.map(({ children }) => children);
  5284. return {
  5285. width: modal[0].value,
  5286. height: modal[1].value,
  5287. fontSize: modal[2].value,
  5288. borderModal: modal[3].value,
  5289. headBase: headerGeneral[0].value,
  5290. headContrast: headerGeneral[1].value,
  5291. headButtonExit: headerButtons[0].value,
  5292. headButtonLabel: headerButtons[1].value,
  5293. headButtonSticky: headerButtons[2].value,
  5294. headButtonStyle: headerButtons[3].value,
  5295. headButtonHide: headerButtons[4].value,
  5296. headButtonAlt: headerButtons[5].value,
  5297. nodeHeaderBase: bodyGeneral[0].value,
  5298. nodeBlendBase: bodyGeneral[1].value,
  5299. nodeValueBase: bodyGeneral[2].value,
  5300. nodeContrast: bodyGeneral[3].value,
  5301. nodeButtonCreate: bodyButtons[0].value,
  5302. nodeButtonDuplicate: bodyButtons[1].value,
  5303. nodeButtonMove: bodyButtons[2].value,
  5304. nodeButtonDisable: bodyButtons[3].value,
  5305. nodeButtonDelete: bodyButtons[4].value,
  5306. validBackground: bodyMisc[0].value,
  5307. invalidBackground: bodyMisc[1].value,
  5308. focusBackground: bodyMisc[2].value,
  5309. borderTooltip: bodyMisc[3].value,
  5310. };
  5311. }
  5312. // For returning updated styles to the userscript
  5313. function getUserStyles() {
  5314. const { tree: { 'children': styleNodes } } = getRoot().getSaveData();
  5315. return styleNodes.map((json) => {
  5316. var _a;
  5317. return (Object.assign(Object.assign({ name: json.value }, (((_a = json.isActive) !== null && _a !== void 0 ? _a : true) ? {} : { isActive: false })), toRawStyle(json)));
  5318. });
  5319. }
  5320. function generate(userStyles, devStyle) {
  5321. (0,_css__WEBPACK_IMPORTED_MODULE_1__["default"])();
  5322. const defaultStyle = getFilledStyle(devStyle);
  5323. return (0,___WEBPACK_IMPORTED_MODULE_3__.generateTree)({
  5324. children: userStyles.map(toJSON),
  5325. seed: toJSON(Object.assign({ name: 'New Style', isActive: false }, defaultStyle)),
  5326. descendantPredicate: (styles) => styles.length <= 1 || 'Only one style may be active at a time.',
  5327. onDescendantUpdate: (styles) => {
  5328. (0,_update__WEBPACK_IMPORTED_MODULE_2__["default"])(styles.length === 0 ? defaultStyle : toRawStyle(styles[0]));
  5329. },
  5330. }, _consts__WEBPACK_IMPORTED_MODULE_0__.ROOT_ID);
  5331. }
  5332.  
  5333.  
  5334. /***/ }),
  5335.  
  5336. /***/ "./ts/modal/body/style/update.ts":
  5337. /*!***************************************!*\
  5338. !*** ./ts/modal/body/style/update.ts ***!
  5339. \***************************************/
  5340. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5341.  
  5342. __webpack_require__.r(__webpack_exports__);
  5343. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5344. /* harmony export */ "default": () => (/* binding */ updateStylesheet)
  5345. /* harmony export */ });
  5346. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  5347. var __rest = (undefined && undefined.__rest) || function (s, e) {
  5348. var t = {};
  5349. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  5350. t[p] = s[p];
  5351. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  5352. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
  5353. if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
  5354. t[p[i]] = s[p[i]];
  5355. }
  5356. return t;
  5357. };
  5358.  
  5359. const styleNode = document.createElement('style');
  5360. (0,_modal_css__WEBPACK_IMPORTED_MODULE_0__.registerStyleNode)(styleNode);
  5361. function getContrast(hex, method) {
  5362. const r = parseInt(hex.slice(1, 3), 16);
  5363. const g = parseInt(hex.slice(3, 5), 16);
  5364. const b = parseInt(hex.slice(5, 7), 16);
  5365. switch (method) {
  5366. case 'Black / White': {
  5367. // https://stackoverflow.com/a/3943023/112731
  5368. const luminosity = r * 0.299 + g * 0.587 + b * 0.114;
  5369. return luminosity > 145 ? 'black' : 'white';
  5370. }
  5371. }
  5372. const toHexPart = (rgb) => {
  5373. const x = (255 - rgb).toString(16);
  5374. return x.length === 2 ? x : `0${x}`;
  5375. };
  5376. return `#${toHexPart(r)}${toHexPart((g))}${toHexPart(b)}`;
  5377. }
  5378. function updateStylesheet(_a) {
  5379. var { fontSize, width, height, headContrast, nodeContrast } = _a, colours = __rest(_a, ["fontSize", "width", "height", "headContrast", "nodeContrast"]);
  5380. for (let i = styleNode.sheet.cssRules.length - 1; i >= 0; --i) {
  5381. styleNode.sheet.deleteRule(i);
  5382. }
  5383. const variables = Object.entries(colours).map(([property, value]) => [`--${property}`, value]);
  5384. variables.push(['--fontSize', `${fontSize}px`], ['--width', `${width}%`], ['--height', `${height}%`]);
  5385. variables.push(['--nodeHeaderContrast', getContrast(colours.nodeHeaderBase, nodeContrast)]);
  5386. variables.push(['--nodeBlendContrast', getContrast(colours.nodeBlendBase, nodeContrast)]);
  5387. variables.push(['--nodeValueContrast', getContrast(colours.nodeValueBase, nodeContrast)]);
  5388. variables.push(['--headContrast', getContrast(colours.headBase, headContrast)]);
  5389. (0,_modal_css__WEBPACK_IMPORTED_MODULE_0__.addVariables)(variables, styleNode);
  5390. }
  5391.  
  5392.  
  5393. /***/ }),
  5394.  
  5395. /***/ "./ts/modal/consts.ts":
  5396. /*!****************************!*\
  5397. !*** ./ts/modal/consts.ts ***!
  5398. \****************************/
  5399. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5400.  
  5401. __webpack_require__.r(__webpack_exports__);
  5402. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5403. /* harmony export */ BUTTON_ACTIVE_CLASS: () => (/* binding */ BUTTON_ACTIVE_CLASS),
  5404. /* harmony export */ MODAL_BACKGROUND_ID: () => (/* binding */ MODAL_BACKGROUND_ID),
  5405. /* harmony export */ MODAL_ID: () => (/* binding */ MODAL_ID),
  5406. /* harmony export */ NODE_HEIGHT: () => (/* binding */ NODE_HEIGHT),
  5407. /* harmony export */ SUB_PIXEL_BS: () => (/* binding */ SUB_PIXEL_BS),
  5408. /* harmony export */ SVG_NAMESPACE: () => (/* binding */ SVG_NAMESPACE)
  5409. /* harmony export */ });
  5410. const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
  5411. // Indicates 'on' state for actions that can be turned on and off
  5412. const BUTTON_ACTIVE_CLASS = 'active';
  5413. const MODAL_BACKGROUND_ID = 'modal-background';
  5414. const MODAL_ID = 'modal-content';
  5415. const SUB_PIXEL_BS = 1 / window.devicePixelRatio;
  5416. const NODE_HEIGHT = 1.6;
  5417.  
  5418.  
  5419. /***/ }),
  5420.  
  5421. /***/ "./ts/modal/css.ts":
  5422. /*!*************************!*\
  5423. !*** ./ts/modal/css.ts ***!
  5424. \*************************/
  5425. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5426.  
  5427. __webpack_require__.r(__webpack_exports__);
  5428. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5429. /* harmony export */ addRule: () => (/* binding */ addRule),
  5430. /* harmony export */ addVariables: () => (/* binding */ addVariables),
  5431. /* harmony export */ "default": () => (/* binding */ generate),
  5432. /* harmony export */ getRuleString: () => (/* binding */ getRuleString),
  5433. /* harmony export */ registerStyleNode: () => (/* binding */ registerStyleNode)
  5434. /* harmony export */ });
  5435. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/consts.ts");
  5436. /* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./index */ "./ts/modal/index.ts");
  5437.  
  5438.  
  5439. const styleNode = document.createElement('style');
  5440. const undockedStyleNodes = [styleNode];
  5441. function registerStyleNode(node) {
  5442. undockedStyleNodes.push(node);
  5443. }
  5444. function mountStyleNodes() {
  5445. const { head } = (0,_index__WEBPACK_IMPORTED_MODULE_1__.getDocument)();
  5446. for (const node of undockedStyleNodes) {
  5447. head.appendChild(node);
  5448. }
  5449. }
  5450. function isStyle(candidate) {
  5451. return candidate.length > 0 && typeof candidate[0] === 'string';
  5452. }
  5453. function getStyleString([property, value]) {
  5454. return `${property}:${value};`;
  5455. }
  5456. function getRuleStrings(styles) {
  5457. return isStyle(styles) ? getStyleString(styles) : styles.map(getStyleString).join('');
  5458. }
  5459. function getRuleString(selectors, styles) {
  5460. const styleString = getRuleStrings(styles);
  5461. const selectorString = typeof selectors === 'string' ? selectors : selectors.join(',');
  5462. return `${selectorString}{${styleString}}`;
  5463. }
  5464. function addRule(selectors, styles, { sheet } = styleNode) {
  5465. sheet.insertRule(getRuleString(selectors, styles));
  5466. }
  5467. function addVariables(rules, { sheet } = styleNode) {
  5468. const styleString = rules.map(getStyleString).join('');
  5469. sheet.insertRule(`:root{${styleString}}`);
  5470. }
  5471. function generate() {
  5472. mountStyleNodes();
  5473. addRule(`#${_consts__WEBPACK_IMPORTED_MODULE_0__.MODAL_BACKGROUND_ID}`, [
  5474. ['position', 'fixed'],
  5475. ['left', '0'],
  5476. ['top', '0'],
  5477. ['width', '100%'],
  5478. ['height', '100%'],
  5479. ['background-color', '#0003'],
  5480. ['display', 'flex'],
  5481. ['align-content', 'center'],
  5482. ['flex-wrap', 'wrap'],
  5483. ['justify-content', 'center'],
  5484. ]);
  5485. addRule(`#${_consts__WEBPACK_IMPORTED_MODULE_0__.MODAL_ID}`, [
  5486. ['width', 'var(--width)'],
  5487. ['height', 'var(--height)'],
  5488. ['font-size', 'var(--fontSize)'],
  5489. ['font-family', 'Tahoma, Geneva, sans-serif'],
  5490. ['outline', 'var(--borderModal) solid 2px'],
  5491. ['box-shadow', '1px 1px 10px 4px #00000015, 0 0 30px 10px #00000065'],
  5492. ['display', 'flex'],
  5493. ['flex-direction', 'column'],
  5494. ['position', 'relative'],
  5495. ]);
  5496. addRule('button', [
  5497. ['display', 'inline-flex'],
  5498. ['cursor', 'pointer'],
  5499. ['background', 'none'],
  5500. ['font-size', 'inherit'],
  5501. ['padding', '0'],
  5502. ['margin', '0'],
  5503. ['border', 'none'],
  5504. ['outline-offset', '-2px'],
  5505. ]);
  5506. addRule('button *', [['pointer-events', 'none']]);
  5507. addRule('svg', [['fill', 'none']]);
  5508. addRule('input', [
  5509. ['font', 'inherit'],
  5510. ['background', 'inherit'],
  5511. ['color', 'inherit'],
  5512. ['border', 'none'],
  5513. ]);
  5514. addRule(':focus-visible:not(button):not(input)', [['outline', 'none']]);
  5515. addRule('label', [['cursor', 'inherit']]);
  5516. }
  5517.  
  5518.  
  5519. /***/ }),
  5520.  
  5521. /***/ "./ts/modal/header/actions/alternate/button.ts":
  5522. /*!*****************************************************!*\
  5523. !*** ./ts/modal/header/actions/alternate/button.ts ***!
  5524. \*****************************************************/
  5525. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5526.  
  5527. __webpack_require__.r(__webpack_exports__);
  5528. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5529. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  5530. /* harmony export */ });
  5531. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/alternate/consts.ts");
  5532. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../button */ "./ts/modal/header/actions/button.ts");
  5533. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  5534.  
  5535.  
  5536.  
  5537. const ALPHA = Math.PI / 5;
  5538. const RADIUS = 46;
  5539. const points = [];
  5540. // https://stackoverflow.com/questions/14580033/algorithm-for-drawing-a-5-point-star
  5541. for (let i = 0; i < 12; ++i) {
  5542. const r = RADIUS * (i % 2 + 1) / 2;
  5543. const omega = ALPHA * i;
  5544. points.push([r * Math.sin(omega), r * Math.cos(omega)]);
  5545. }
  5546. const outline = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'path');
  5547. outline.setAttribute('stroke-linecap', 'round');
  5548. outline.setAttribute('stroke-width', '7');
  5549. outline.setAttribute('d', points.map(([x, y], i) => `${i === 0 ? 'M' : 'L'} ${x} ${y}`).join(' '));
  5550. const g = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'g');
  5551. g.append(outline);
  5552. const BUTTON = (0,_button__WEBPACK_IMPORTED_MODULE_1__.getNewButton)(g, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, 'Toggle Special Buttons');
  5553. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (BUTTON);
  5554.  
  5555.  
  5556. /***/ }),
  5557.  
  5558. /***/ "./ts/modal/header/actions/alternate/consts.ts":
  5559. /*!*****************************************************!*\
  5560. !*** ./ts/modal/header/actions/alternate/consts.ts ***!
  5561. \*****************************************************/
  5562. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5563.  
  5564. __webpack_require__.r(__webpack_exports__);
  5565. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5566. /* harmony export */ ACTION_ID: () => (/* binding */ ACTION_ID)
  5567. /* harmony export */ });
  5568. const ACTION_ID = 'modal-alt';
  5569.  
  5570.  
  5571. /***/ }),
  5572.  
  5573. /***/ "./ts/modal/header/actions/alternate/css.ts":
  5574. /*!**************************************************!*\
  5575. !*** ./ts/modal/header/actions/alternate/css.ts ***!
  5576. \**************************************************/
  5577. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5578.  
  5579. __webpack_require__.r(__webpack_exports__);
  5580. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5581. /* harmony export */ "default": () => (/* binding */ generate)
  5582. /* harmony export */ });
  5583. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/alternate/consts.ts");
  5584. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../css */ "./ts/modal/header/actions/css.ts");
  5585.  
  5586.  
  5587. function generate() {
  5588. (0,_css__WEBPACK_IMPORTED_MODULE_1__.addColourRule)(_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, '--headButtonAlt');
  5589. }
  5590.  
  5591.  
  5592. /***/ }),
  5593.  
  5594. /***/ "./ts/modal/header/actions/alternate/index.ts":
  5595. /*!****************************************************!*\
  5596. !*** ./ts/modal/header/actions/alternate/index.ts ***!
  5597. \****************************************************/
  5598. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5599.  
  5600. __webpack_require__.r(__webpack_exports__);
  5601. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5602. /* harmony export */ "default": () => (/* binding */ generate),
  5603. /* harmony export */ doAction: () => (/* binding */ doAction),
  5604. /* harmony export */ isActive: () => (/* binding */ isActive)
  5605. /* harmony export */ });
  5606. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./button */ "./ts/modal/header/actions/alternate/button.ts");
  5607. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/alternate/consts.ts");
  5608. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./css */ "./ts/modal/header/actions/alternate/css.ts");
  5609. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../button */ "./ts/modal/header/actions/button.ts");
  5610. /* harmony import */ var _modal_body__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/modal/body */ "./ts/modal/body/index.ts");
  5611. /* harmony import */ var _modal__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @/modal */ "./ts/modal/index.ts");
  5612.  
  5613.  
  5614.  
  5615.  
  5616.  
  5617.  
  5618. let _isActive = false;
  5619. let toggledOn = false;
  5620. function isActive() {
  5621. return _isActive;
  5622. }
  5623. function doAction(doActivate = !_isActive) {
  5624. (0,_modal_body__WEBPACK_IMPORTED_MODULE_4__.setActive)(_button__WEBPACK_IMPORTED_MODULE_0__["default"], _consts__WEBPACK_IMPORTED_MODULE_1__.ACTION_ID, doActivate);
  5625. _isActive = doActivate;
  5626. }
  5627. function generate() {
  5628. (0,_css__WEBPACK_IMPORTED_MODULE_2__["default"])();
  5629. (0,_button__WEBPACK_IMPORTED_MODULE_3__.bindAction)(_button__WEBPACK_IMPORTED_MODULE_0__["default"], () => {
  5630. toggledOn = !toggledOn;
  5631. doAction(toggledOn);
  5632. });
  5633. _button__WEBPACK_IMPORTED_MODULE_0__["default"].title += ' (Ctrl)';
  5634. const target = (0,_modal__WEBPACK_IMPORTED_MODULE_5__.getDocument)();
  5635. target.addEventListener('keydown', (event) => {
  5636. if (event.key === 'Control' && !toggledOn) {
  5637. doAction(true);
  5638. }
  5639. });
  5640. target.addEventListener('keyup', (event) => {
  5641. if (event.key === 'Control' && !toggledOn) {
  5642. doAction(false);
  5643. }
  5644. });
  5645. (0,_modal__WEBPACK_IMPORTED_MODULE_5__.getWindow)().addEventListener('blur', () => {
  5646. if (!toggledOn) {
  5647. doAction(false);
  5648. }
  5649. });
  5650. return _button__WEBPACK_IMPORTED_MODULE_0__["default"];
  5651. }
  5652.  
  5653.  
  5654. /***/ }),
  5655.  
  5656. /***/ "./ts/modal/header/actions/button.ts":
  5657. /*!*******************************************!*\
  5658. !*** ./ts/modal/header/actions/button.ts ***!
  5659. \*******************************************/
  5660. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5661.  
  5662. __webpack_require__.r(__webpack_exports__);
  5663. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5664. /* harmony export */ bindAction: () => (/* binding */ bindAction),
  5665. /* harmony export */ getNewButton: () => (/* binding */ getNewButton)
  5666. /* harmony export */ });
  5667. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/consts.ts");
  5668. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../consts */ "./ts/modal/consts.ts");
  5669. /* harmony import */ var _modal__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal */ "./ts/modal/index.ts");
  5670.  
  5671.  
  5672.  
  5673. // Adds the template to the DOM
  5674. function bindAction(button, doAction, hotkey) {
  5675. const bound = (event) => {
  5676. event.stopPropagation();
  5677. button.blur();
  5678. doAction();
  5679. };
  5680. button.addEventListener('click', bound);
  5681. if (hotkey) {
  5682. button.title += ` (Alt+${hotkey})`;
  5683. (0,_modal__WEBPACK_IMPORTED_MODULE_2__.getDocument)().addEventListener('keydown', (event) => {
  5684. if (event.altKey && event.key.toUpperCase() === hotkey) {
  5685. bound(event);
  5686. }
  5687. });
  5688. }
  5689. return bound;
  5690. }
  5691. // Creates a template
  5692. const getNewButton = (function () {
  5693. const buttonTemplate = document.createElement('button');
  5694. const svgTemplate = document.createElementNS(_consts__WEBPACK_IMPORTED_MODULE_1__.SVG_NAMESPACE, 'svg');
  5695. buttonTemplate.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS);
  5696. buttonTemplate.setAttribute('tabindex', '-1');
  5697. svgTemplate.setAttribute('viewBox', `-70 -70 140 140`);
  5698. return function (group, actionId, description) {
  5699. const button = buttonTemplate.cloneNode(true);
  5700. const svg = svgTemplate.cloneNode(true);
  5701. button.id = actionId;
  5702. button.title = description;
  5703. svg.append(group);
  5704. button.append(svg);
  5705. return button;
  5706. };
  5707. })();
  5708.  
  5709.  
  5710. /***/ }),
  5711.  
  5712. /***/ "./ts/modal/header/actions/close/button.ts":
  5713. /*!*************************************************!*\
  5714. !*** ./ts/modal/header/actions/close/button.ts ***!
  5715. \*************************************************/
  5716. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5717.  
  5718. __webpack_require__.r(__webpack_exports__);
  5719. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5720. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  5721. /* harmony export */ });
  5722. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/close/consts.ts");
  5723. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../button */ "./ts/modal/header/actions/button.ts");
  5724. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  5725.  
  5726.  
  5727.  
  5728. const line0 = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'line');
  5729. line0.setAttribute('stroke-linecap', 'round');
  5730. line0.setAttribute('stroke-width', '12');
  5731. line0.setAttribute('x1', '-30');
  5732. line0.setAttribute('x2', '30');
  5733. line0.setAttribute('y1', '-30');
  5734. line0.setAttribute('y2', '30');
  5735. const line1 = line0.cloneNode(true);
  5736. line1.setAttribute('transform', 'rotate(90 0 0)');
  5737. const g = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'g');
  5738. g.append(line0, line1);
  5739. const BUTTON = (0,_button__WEBPACK_IMPORTED_MODULE_1__.getNewButton)(g, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, 'Save & Exit');
  5740. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (BUTTON);
  5741.  
  5742.  
  5743. /***/ }),
  5744.  
  5745. /***/ "./ts/modal/header/actions/close/consts.ts":
  5746. /*!*************************************************!*\
  5747. !*** ./ts/modal/header/actions/close/consts.ts ***!
  5748. \*************************************************/
  5749. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5750.  
  5751. __webpack_require__.r(__webpack_exports__);
  5752. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5753. /* harmony export */ ACTION_ID: () => (/* binding */ ACTION_ID),
  5754. /* harmony export */ HOTKEY: () => (/* binding */ HOTKEY)
  5755. /* harmony export */ });
  5756. const ACTION_ID = 'modal-close';
  5757. const HOTKEY = 'X';
  5758.  
  5759.  
  5760. /***/ }),
  5761.  
  5762. /***/ "./ts/modal/header/actions/close/css.ts":
  5763. /*!**********************************************!*\
  5764. !*** ./ts/modal/header/actions/close/css.ts ***!
  5765. \**********************************************/
  5766. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5767.  
  5768. __webpack_require__.r(__webpack_exports__);
  5769. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5770. /* harmony export */ "default": () => (/* binding */ generate)
  5771. /* harmony export */ });
  5772. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/close/consts.ts");
  5773. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  5774.  
  5775.  
  5776. function generate() {
  5777. (0,_modal_css__WEBPACK_IMPORTED_MODULE_1__.addRule)([
  5778. `#${_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID}:focus > svg`,
  5779. `#${_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID}:hover > svg`,
  5780. ], ['background-color', 'var(--headButtonExit)']);
  5781. }
  5782.  
  5783.  
  5784. /***/ }),
  5785.  
  5786. /***/ "./ts/modal/header/actions/close/index.ts":
  5787. /*!************************************************!*\
  5788. !*** ./ts/modal/header/actions/close/index.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 */ "default": () => (/* binding */ generate),
  5795. /* harmony export */ setCallback: () => (/* binding */ setCallback)
  5796. /* harmony export */ });
  5797. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./button */ "./ts/modal/header/actions/close/button.ts");
  5798. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/close/consts.ts");
  5799. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./css */ "./ts/modal/header/actions/close/css.ts");
  5800. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../button */ "./ts/modal/header/actions/button.ts");
  5801. /* harmony import */ var _modal_body_data__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/modal/body/data */ "./ts/modal/body/data/index.ts");
  5802. /* harmony import */ var _modal_body_style__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @/modal/body/style */ "./ts/modal/body/style/index.ts");
  5803. /* 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");
  5804. /* harmony import */ var _nodes_actions_highlight__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @nodes/actions/highlight */ "./ts/modal/body/nodes/actions/highlight/index.ts");
  5805.  
  5806.  
  5807.  
  5808.  
  5809.  
  5810.  
  5811.  
  5812.  
  5813. let callback;
  5814. function setCallback(_callback) {
  5815. callback = _callback;
  5816. }
  5817. // TODO Maybe add a white, 0.5 opacity foreground over everything with a loading symbol.
  5818. // Do the same when waiting for a config.
  5819. // Prevent interaction during loading by adding a stopPropagation click listener to the foreground.
  5820. function doAction() {
  5821. (0,_nodes_actions_buttons_position__WEBPACK_IMPORTED_MODULE_6__.reset)();
  5822. (0,_nodes_actions_highlight__WEBPACK_IMPORTED_MODULE_7__.reset)();
  5823. 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)() }));
  5824. callback = undefined;
  5825. }
  5826. function generate(background) {
  5827. (0,_css__WEBPACK_IMPORTED_MODULE_2__["default"])();
  5828. (0,_button__WEBPACK_IMPORTED_MODULE_3__.bindAction)(_button__WEBPACK_IMPORTED_MODULE_0__["default"], doAction, _consts__WEBPACK_IMPORTED_MODULE_1__.HOTKEY);
  5829. background.addEventListener('click', (event) => {
  5830. if (background.isSameNode(event.target)) {
  5831. doAction();
  5832. }
  5833. });
  5834. return _button__WEBPACK_IMPORTED_MODULE_0__["default"];
  5835. }
  5836.  
  5837.  
  5838. /***/ }),
  5839.  
  5840. /***/ "./ts/modal/header/actions/consts.ts":
  5841. /*!*******************************************!*\
  5842. !*** ./ts/modal/header/actions/consts.ts ***!
  5843. \*******************************************/
  5844. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5845.  
  5846. __webpack_require__.r(__webpack_exports__);
  5847. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5848. /* harmony export */ BUTTON_CLASS: () => (/* binding */ BUTTON_CLASS),
  5849. /* harmony export */ BUTTON_CONTAINER_ID: () => (/* binding */ BUTTON_CONTAINER_ID)
  5850. /* harmony export */ });
  5851. const BUTTON_CLASS = 'modal-button';
  5852. const BUTTON_CONTAINER_ID = 'modal-button-container';
  5853.  
  5854.  
  5855. /***/ }),
  5856.  
  5857. /***/ "./ts/modal/header/actions/css.ts":
  5858. /*!****************************************!*\
  5859. !*** ./ts/modal/header/actions/css.ts ***!
  5860. \****************************************/
  5861. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5862.  
  5863. __webpack_require__.r(__webpack_exports__);
  5864. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5865. /* harmony export */ addColourRule: () => (/* binding */ addColourRule),
  5866. /* harmony export */ "default": () => (/* binding */ generate)
  5867. /* harmony export */ });
  5868. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/consts.ts");
  5869. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../consts */ "./ts/modal/consts.ts");
  5870. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../css */ "./ts/modal/css.ts");
  5871.  
  5872.  
  5873.  
  5874. const ACTIVE_SELECTOR = `.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}.${_consts__WEBPACK_IMPORTED_MODULE_1__.BUTTON_ACTIVE_CLASS}`;
  5875. function addColourRule(actionId, colour) {
  5876. (0,_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`#${actionId}${ACTIVE_SELECTOR} > svg`, [['fill', `var(${colour})`]]);
  5877. (0,_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([`#${actionId}${ACTIVE_SELECTOR}:not(:hover):not(:focus) > svg`], [['stroke', `var(${colour})`]]);
  5878. }
  5879. function generate() {
  5880. (0,_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`#${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CONTAINER_ID}`, [
  5881. ['display', 'inline-flex'],
  5882. ['flex-direction', 'row-reverse'],
  5883. ['max-width', '80%'],
  5884. ['overflow-x', 'scroll'],
  5885. ['scrollbar-width', 'none'],
  5886. ['overscroll-behavior', 'contain'],
  5887. ['border-left', '2px solid var(--headContrast)'],
  5888. ]);
  5889. (0,_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([
  5890. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}:focus > svg`,
  5891. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}:hover > svg`,
  5892. `${ACTIVE_SELECTOR} > svg`,
  5893. ], ['background-color', `var(--headContrast)`]);
  5894. (0,_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}:not(:last-child)`, ['border-left', '2px solid var(--headContrast)']);
  5895. (0,_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([
  5896. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}:not(:first-child):focus`,
  5897. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}:not(:first-child):hover`,
  5898. `${ACTIVE_SELECTOR}:not(:first-child)`,
  5899. ], ['border-color', 'var(--headBase)']);
  5900. (0,_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([
  5901. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}:focus > svg`,
  5902. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}:hover > svg`,
  5903. ], ['stroke', `var(--headBase)`]);
  5904. (0,_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS} > svg`, [
  5905. ['width', '1.7em'],
  5906. ['stroke', 'var(--headContrast)'],
  5907. ['fill', `var(--headContrast)`],
  5908. // Fixes pixel gap between button border & svg
  5909. ['margin-left', '-0.5px'],
  5910. ]);
  5911. }
  5912.  
  5913.  
  5914. /***/ }),
  5915.  
  5916. /***/ "./ts/modal/header/actions/hide/button.ts":
  5917. /*!************************************************!*\
  5918. !*** ./ts/modal/header/actions/hide/button.ts ***!
  5919. \************************************************/
  5920. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5921.  
  5922. __webpack_require__.r(__webpack_exports__);
  5923. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5924. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  5925. /* harmony export */ });
  5926. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/hide/consts.ts");
  5927. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../button */ "./ts/modal/header/actions/button.ts");
  5928. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  5929.  
  5930.  
  5931.  
  5932. const edgeTop = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'path');
  5933. edgeTop.setAttribute('stroke-linecap', 'round');
  5934. edgeTop.setAttribute('stroke-width', '7');
  5935. edgeTop.setAttribute('d', 'M -55 0'
  5936. + ' Q 0 60 55 0');
  5937. edgeTop.setAttribute('fill', 'none');
  5938. const edgeBottom = edgeTop.cloneNode(true);
  5939. edgeBottom.setAttribute('transform', 'scale(1,-1)');
  5940. const circle = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'circle');
  5941. circle.setAttribute('cx', '0');
  5942. circle.setAttribute('cy', '0');
  5943. circle.setAttribute('r', '26');
  5944. circle.setAttribute('stroke-width', '6');
  5945. const g = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'g');
  5946. g.append(edgeTop, edgeBottom, circle);
  5947. const BUTTON = (0,_button__WEBPACK_IMPORTED_MODULE_1__.getNewButton)(g, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, 'Toggle Disabled Node Visibility');
  5948. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (BUTTON);
  5949.  
  5950.  
  5951. /***/ }),
  5952.  
  5953. /***/ "./ts/modal/header/actions/hide/consts.ts":
  5954. /*!************************************************!*\
  5955. !*** ./ts/modal/header/actions/hide/consts.ts ***!
  5956. \************************************************/
  5957. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5958.  
  5959. __webpack_require__.r(__webpack_exports__);
  5960. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5961. /* harmony export */ ACTION_ID: () => (/* binding */ ACTION_ID),
  5962. /* harmony export */ HOTKEY: () => (/* binding */ HOTKEY)
  5963. /* harmony export */ });
  5964. const ACTION_ID = 'modal-hide';
  5965. const HOTKEY = 'H';
  5966.  
  5967.  
  5968. /***/ }),
  5969.  
  5970. /***/ "./ts/modal/header/actions/hide/css.ts":
  5971. /*!*********************************************!*\
  5972. !*** ./ts/modal/header/actions/hide/css.ts ***!
  5973. \*********************************************/
  5974. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5975.  
  5976. __webpack_require__.r(__webpack_exports__);
  5977. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5978. /* harmony export */ "default": () => (/* binding */ generate)
  5979. /* harmony export */ });
  5980. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/hide/consts.ts");
  5981. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../css */ "./ts/modal/header/actions/css.ts");
  5982. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  5983. /* harmony import */ var _modal_body_consts__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/modal/body/consts */ "./ts/modal/body/consts.ts");
  5984. /* 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");
  5985.  
  5986.  
  5987.  
  5988.  
  5989.  
  5990. function generate() {
  5991. (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']);
  5992. (0,_css__WEBPACK_IMPORTED_MODULE_1__.addColourRule)(_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, '--headButtonHide');
  5993. }
  5994.  
  5995.  
  5996. /***/ }),
  5997.  
  5998. /***/ "./ts/modal/header/actions/hide/index.ts":
  5999. /*!***********************************************!*\
  6000. !*** ./ts/modal/header/actions/hide/index.ts ***!
  6001. \***********************************************/
  6002. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  6003.  
  6004. __webpack_require__.r(__webpack_exports__);
  6005. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6006. /* harmony export */ "default": () => (/* binding */ generate)
  6007. /* harmony export */ });
  6008. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./button */ "./ts/modal/header/actions/hide/button.ts");
  6009. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/hide/consts.ts");
  6010. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./css */ "./ts/modal/header/actions/hide/css.ts");
  6011. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../button */ "./ts/modal/header/actions/button.ts");
  6012. /* harmony import */ var _modal_body__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/modal/body */ "./ts/modal/body/index.ts");
  6013.  
  6014.  
  6015.  
  6016.  
  6017.  
  6018. let isActive = false;
  6019. function doAction() {
  6020. isActive = !isActive;
  6021. (0,_modal_body__WEBPACK_IMPORTED_MODULE_4__.setActive)(_button__WEBPACK_IMPORTED_MODULE_0__["default"], _consts__WEBPACK_IMPORTED_MODULE_1__.ACTION_ID, isActive);
  6022. }
  6023. function generate() {
  6024. (0,_css__WEBPACK_IMPORTED_MODULE_2__["default"])();
  6025. (0,_button__WEBPACK_IMPORTED_MODULE_3__.bindAction)(_button__WEBPACK_IMPORTED_MODULE_0__["default"], doAction, _consts__WEBPACK_IMPORTED_MODULE_1__.HOTKEY);
  6026. _button__WEBPACK_IMPORTED_MODULE_0__["default"].click();
  6027. return _button__WEBPACK_IMPORTED_MODULE_0__["default"];
  6028. }
  6029.  
  6030.  
  6031. /***/ }),
  6032.  
  6033. /***/ "./ts/modal/header/actions/index.ts":
  6034. /*!******************************************!*\
  6035. !*** ./ts/modal/header/actions/index.ts ***!
  6036. \******************************************/
  6037. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  6038.  
  6039. __webpack_require__.r(__webpack_exports__);
  6040. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6041. /* harmony export */ "default": () => (/* binding */ generate)
  6042. /* harmony export */ });
  6043. /* harmony import */ var _close__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./close */ "./ts/modal/header/actions/close/index.ts");
  6044. /* harmony import */ var _sticky__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./sticky */ "./ts/modal/header/actions/sticky/index.ts");
  6045. /* harmony import */ var _labels__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./labels */ "./ts/modal/header/actions/labels/index.ts");
  6046. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./style */ "./ts/modal/header/actions/style/index.ts");
  6047. /* harmony import */ var _hide__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./hide */ "./ts/modal/header/actions/hide/index.ts");
  6048. /* harmony import */ var _alternate__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./alternate */ "./ts/modal/header/actions/alternate/index.ts");
  6049. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./css */ "./ts/modal/header/actions/css.ts");
  6050. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/consts.ts");
  6051.  
  6052.  
  6053.  
  6054.  
  6055.  
  6056.  
  6057.  
  6058.  
  6059. function generate(background) {
  6060. (0,_css__WEBPACK_IMPORTED_MODULE_6__["default"])();
  6061. const element = document.createElement('span');
  6062. element.id = _consts__WEBPACK_IMPORTED_MODULE_7__.BUTTON_CONTAINER_ID;
  6063. element.setAttribute('tabindex', '-1');
  6064. 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"])());
  6065. return element;
  6066. }
  6067.  
  6068.  
  6069. /***/ }),
  6070.  
  6071. /***/ "./ts/modal/header/actions/labels/button.ts":
  6072. /*!**************************************************!*\
  6073. !*** ./ts/modal/header/actions/labels/button.ts ***!
  6074. \**************************************************/
  6075. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  6076.  
  6077. __webpack_require__.r(__webpack_exports__);
  6078. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6079. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  6080. /* harmony export */ });
  6081. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/labels/consts.ts");
  6082. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../button */ "./ts/modal/header/actions/button.ts");
  6083. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  6084.  
  6085.  
  6086.  
  6087. const outline = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'path');
  6088. outline.setAttribute('stroke-linecap', 'round');
  6089. outline.setAttribute('stroke-width', '7');
  6090. outline.setAttribute('d', 'M 20 -30'
  6091. + ' L -40 -30'
  6092. + ' L -40 30'
  6093. + ' L 20 30'
  6094. + ' L 50 0'
  6095. + ' L 20 -30');
  6096. const circle = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'circle');
  6097. circle.setAttribute('stroke-width', '5');
  6098. circle.setAttribute('r', '5');
  6099. circle.setAttribute('cx', '20');
  6100. circle.setAttribute('cy', '0');
  6101. const loop = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'path');
  6102. loop.setAttribute('fill', 'none');
  6103. loop.setAttribute('stroke-linecap', 'round');
  6104. loop.setAttribute('stroke-width', '6');
  6105. loop.setAttribute('d', 'M 20 0'
  6106. + ' C -70 50 -30 50 15 30');
  6107. const g = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'g');
  6108. g.setAttribute('transform', 'rotate(-60 0 0)');
  6109. g.append(outline, circle, loop);
  6110. const BUTTON = (0,_button__WEBPACK_IMPORTED_MODULE_1__.getNewButton)(g, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, 'Toggle Labels');
  6111. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (BUTTON);
  6112.  
  6113.  
  6114. /***/ }),
  6115.  
  6116. /***/ "./ts/modal/header/actions/labels/consts.ts":
  6117. /*!**************************************************!*\
  6118. !*** ./ts/modal/header/actions/labels/consts.ts ***!
  6119. \**************************************************/
  6120. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  6121.  
  6122. __webpack_require__.r(__webpack_exports__);
  6123. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6124. /* harmony export */ ACTION_ID: () => (/* binding */ ACTION_ID),
  6125. /* harmony export */ HOTKEY: () => (/* binding */ HOTKEY)
  6126. /* harmony export */ });
  6127. const ACTION_ID = 'modal-labels';
  6128. const HOTKEY = 'N';
  6129.  
  6130.  
  6131. /***/ }),
  6132.  
  6133. /***/ "./ts/modal/header/actions/labels/css.ts":
  6134. /*!***********************************************!*\
  6135. !*** ./ts/modal/header/actions/labels/css.ts ***!
  6136. \***********************************************/
  6137. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  6138.  
  6139. __webpack_require__.r(__webpack_exports__);
  6140. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6141. /* harmony export */ "default": () => (/* binding */ generate)
  6142. /* harmony export */ });
  6143. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/labels/consts.ts");
  6144. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../css */ "./ts/modal/header/actions/css.ts");
  6145. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  6146. /* harmony import */ var _modal_body_consts__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/modal/body/consts */ "./ts/modal/body/consts.ts");
  6147. /* harmony import */ var _nodes_consts__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @nodes/consts */ "./ts/modal/body/nodes/consts.ts");
  6148.  
  6149.  
  6150.  
  6151.  
  6152.  
  6153. function generate() {
  6154. (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']);
  6155. (0,_css__WEBPACK_IMPORTED_MODULE_1__.addColourRule)(_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, '--headButtonLabel');
  6156. }
  6157.  
  6158.  
  6159. /***/ }),
  6160.  
  6161. /***/ "./ts/modal/header/actions/labels/index.ts":
  6162. /*!*************************************************!*\
  6163. !*** ./ts/modal/header/actions/labels/index.ts ***!
  6164. \*************************************************/
  6165. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  6166.  
  6167. __webpack_require__.r(__webpack_exports__);
  6168. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6169. /* harmony export */ "default": () => (/* binding */ generate)
  6170. /* harmony export */ });
  6171. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./button */ "./ts/modal/header/actions/labels/button.ts");
  6172. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/labels/consts.ts");
  6173. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./css */ "./ts/modal/header/actions/labels/css.ts");
  6174. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../button */ "./ts/modal/header/actions/button.ts");
  6175. /* harmony import */ var _modal_body__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/modal/body */ "./ts/modal/body/index.ts");
  6176.  
  6177.  
  6178.  
  6179.  
  6180.  
  6181. let isActive = false;
  6182. function doAction() {
  6183. isActive = !isActive;
  6184. (0,_modal_body__WEBPACK_IMPORTED_MODULE_4__.setActive)(_button__WEBPACK_IMPORTED_MODULE_0__["default"], _consts__WEBPACK_IMPORTED_MODULE_1__.ACTION_ID, isActive);
  6185. }
  6186. function generate() {
  6187. (0,_css__WEBPACK_IMPORTED_MODULE_2__["default"])();
  6188. (0,_button__WEBPACK_IMPORTED_MODULE_3__.bindAction)(_button__WEBPACK_IMPORTED_MODULE_0__["default"], doAction, _consts__WEBPACK_IMPORTED_MODULE_1__.HOTKEY);
  6189. _button__WEBPACK_IMPORTED_MODULE_0__["default"].click();
  6190. return _button__WEBPACK_IMPORTED_MODULE_0__["default"];
  6191. }
  6192.  
  6193.  
  6194. /***/ }),
  6195.  
  6196. /***/ "./ts/modal/header/actions/sticky/button.ts":
  6197. /*!**************************************************!*\
  6198. !*** ./ts/modal/header/actions/sticky/button.ts ***!
  6199. \**************************************************/
  6200. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  6201.  
  6202. __webpack_require__.r(__webpack_exports__);
  6203. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6204. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  6205. /* harmony export */ });
  6206. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/sticky/consts.ts");
  6207. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../button */ "./ts/modal/header/actions/button.ts");
  6208. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  6209.  
  6210.  
  6211.  
  6212. const handle = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'path');
  6213. const HANDLE_WIDTH = 50;
  6214. const CURVE_RADIUS = 10;
  6215. handle.setAttribute('stroke-width', '7');
  6216. handle.setAttribute('d', `M ${-HANDLE_WIDTH / 2} -40`
  6217. + ` q 0 ${CURVE_RADIUS} ${CURVE_RADIUS} ${CURVE_RADIUS}`
  6218. + ` q ${CURVE_RADIUS / 2} ${CURVE_RADIUS * 1.5} 0 ${CURVE_RADIUS * 3}`
  6219. + ` q ${-CURVE_RADIUS} 0 ${-CURVE_RADIUS} ${CURVE_RADIUS}`
  6220. + ` l ${HANDLE_WIDTH} 0`
  6221. + ` q 0 ${-CURVE_RADIUS} ${-CURVE_RADIUS} ${-CURVE_RADIUS}`
  6222. + ` q ${-CURVE_RADIUS / 2} ${-CURVE_RADIUS * 1.5} 0 ${-CURVE_RADIUS * 3}`
  6223. + ` q ${CURVE_RADIUS} 0 ${CURVE_RADIUS} ${-CURVE_RADIUS}`
  6224. + ' Z');
  6225. const point = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'path');
  6226. point.setAttribute('fill', 'none');
  6227. point.setAttribute('stroke-width', '4');
  6228. point.setAttribute('d', 'M -2 -20'
  6229. + ' l 0 50'
  6230. + ' l 2 20'
  6231. + ' l 2 -20'
  6232. + ' l 0 -50'
  6233. + ' Z');
  6234. const g = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'g');
  6235. g.append(point, handle);
  6236. const BUTTON = (0,_button__WEBPACK_IMPORTED_MODULE_1__.getNewButton)(g, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, 'Toggle Sticky');
  6237. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (BUTTON);
  6238.  
  6239.  
  6240. /***/ }),
  6241.  
  6242. /***/ "./ts/modal/header/actions/sticky/consts.ts":
  6243. /*!**************************************************!*\
  6244. !*** ./ts/modal/header/actions/sticky/consts.ts ***!
  6245. \**************************************************/
  6246. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  6247.  
  6248. __webpack_require__.r(__webpack_exports__);
  6249. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6250. /* harmony export */ ACTION_ID: () => (/* binding */ ACTION_ID),
  6251. /* harmony export */ HOTKEY: () => (/* binding */ HOTKEY)
  6252. /* harmony export */ });
  6253. const ACTION_ID = 'modal-sticky';
  6254. const HOTKEY = 'S';
  6255.  
  6256.  
  6257. /***/ }),
  6258.  
  6259. /***/ "./ts/modal/header/actions/sticky/css.ts":
  6260. /*!***********************************************!*\
  6261. !*** ./ts/modal/header/actions/sticky/css.ts ***!
  6262. \***********************************************/
  6263. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  6264.  
  6265. __webpack_require__.r(__webpack_exports__);
  6266. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6267. /* harmony export */ "default": () => (/* binding */ generate)
  6268. /* harmony export */ });
  6269. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/sticky/consts.ts");
  6270. /* harmony import */ var _style_consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../style/consts */ "./ts/modal/header/actions/style/consts.ts");
  6271. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../css */ "./ts/modal/header/actions/css.ts");
  6272. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  6273. /* harmony import */ var _modal_body_data_consts__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/modal/body/data/consts */ "./ts/modal/body/data/consts.ts");
  6274. /* harmony import */ var _modal_body_style_consts__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @/modal/body/style/consts */ "./ts/modal/body/style/consts.ts");
  6275. /* harmony import */ var _modal_body_consts__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @/modal/body/consts */ "./ts/modal/body/consts.ts");
  6276. /* harmony import */ var _nodes_consts__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @nodes/consts */ "./ts/modal/body/nodes/consts.ts");
  6277. /* 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");
  6278. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  6279.  
  6280.  
  6281.  
  6282.  
  6283.  
  6284.  
  6285.  
  6286.  
  6287.  
  6288.  
  6289. function _getHeight(node, pools, depth = 0) {
  6290. if ('poolId' in node) {
  6291. if (!pools[node.poolId]) {
  6292. pools[node.poolId] = [depth, 1];
  6293. }
  6294. else {
  6295. pools[node.poolId][0] = Math.max(pools[node.poolId][0], depth);
  6296. }
  6297. pools[node.poolId][1] = [...node.children, ...('seed' in node ? [node.seed] : [])]
  6298. .reduce((height, child) => Math.max(_getHeight(child, pools, 1), height), pools[node.poolId][1]);
  6299. return 0;
  6300. }
  6301. if ('seed' in node) {
  6302. return _getHeight(node.seed, pools, depth + 1);
  6303. }
  6304. if ('children' in node) {
  6305. return node.children.reduce((height, child) => Math.max(_getHeight(child, pools, depth + 1), height), depth + 1);
  6306. }
  6307. return depth;
  6308. }
  6309. function getHeight(node) {
  6310. const pools = [];
  6311. const height = _getHeight(node, pools);
  6312. return pools.reduce((max, [poolDepth, poolHeight]) => Math.max(max, poolDepth + poolHeight), height);
  6313. }
  6314. function generate(roots) {
  6315. const heights = {
  6316. [_modal_body_data_consts__WEBPACK_IMPORTED_MODULE_4__.ROOT_ID]: getHeight(roots[_modal_body_data_consts__WEBPACK_IMPORTED_MODULE_4__.ROOT_ID]),
  6317. [_modal_body_style_consts__WEBPACK_IMPORTED_MODULE_5__.ROOT_ID]: getHeight(roots[_modal_body_style_consts__WEBPACK_IMPORTED_MODULE_5__.ROOT_ID]),
  6318. };
  6319. 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]);
  6320. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addVariables)([['--overlayIndex', `${maxHeight + 1}`]]);
  6321. (0,_css__WEBPACK_IMPORTED_MODULE_2__.addColourRule)(_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, '--headButtonSticky');
  6322. 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}`;
  6323. for (let depth = 0; depth <= maxHeight; ++depth) {
  6324. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`${nodeSelector} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_7__.ELEMENT_CLASSES.HEAD_CONTAINER}`, [
  6325. ['position', 'sticky'],
  6326. ['top', `calc(${depth * _modal_consts__WEBPACK_IMPORTED_MODULE_9__.NODE_HEIGHT}em + ${depth * _modal_consts__WEBPACK_IMPORTED_MODULE_9__.SUB_PIXEL_BS}px)`],
  6327. ['z-index', `${maxHeight - depth}`],
  6328. ]);
  6329. nodeSelector += ` > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_7__.ELEMENT_CLASSES.CHILD_CONTAINER} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_7__.ELEMENT_CLASSES.ELEMENT_CONTAINER}`;
  6330. }
  6331. (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`, [
  6332. ['content', '\'\''],
  6333. ['display', 'block'],
  6334. ['visibility', 'hidden'],
  6335. ]);
  6336. const selectors = {
  6337. basic: {
  6338. [_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}`,
  6339. [_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}`,
  6340. },
  6341. focus: {
  6342. [_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}`,
  6343. [_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}`,
  6344. },
  6345. };
  6346. for (const [id, height] of Object.entries(heights)) {
  6347. for (let depth = 1; depth <= height + 1; ++depth) {
  6348. (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)`]);
  6349. (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)`]);
  6350. selectors.basic[id] += ` > :last-child > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_7__.ELEMENT_CLASSES.CHILD_CONTAINER}`;
  6351. selectors.focus[id] += ` > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_7__.ELEMENT_CLASSES.CHILD_CONTAINER} > *`;
  6352. }
  6353. }
  6354. }
  6355.  
  6356.  
  6357. /***/ }),
  6358.  
  6359. /***/ "./ts/modal/header/actions/sticky/index.ts":
  6360. /*!*************************************************!*\
  6361. !*** ./ts/modal/header/actions/sticky/index.ts ***!
  6362. \*************************************************/
  6363. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  6364.  
  6365. __webpack_require__.r(__webpack_exports__);
  6366. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6367. /* harmony export */ "default": () => (/* binding */ generate),
  6368. /* harmony export */ isActive: () => (/* binding */ isActive)
  6369. /* harmony export */ });
  6370. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./button */ "./ts/modal/header/actions/sticky/button.ts");
  6371. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/sticky/consts.ts");
  6372. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../button */ "./ts/modal/header/actions/button.ts");
  6373. /* harmony import */ var _modal_body__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/modal/body */ "./ts/modal/body/index.ts");
  6374.  
  6375.  
  6376.  
  6377.  
  6378. let _isActive = false;
  6379. function isActive() {
  6380. return _isActive;
  6381. }
  6382. function doAction() {
  6383. _isActive = !_isActive;
  6384. (0,_modal_body__WEBPACK_IMPORTED_MODULE_3__.setActive)(_button__WEBPACK_IMPORTED_MODULE_0__["default"], _consts__WEBPACK_IMPORTED_MODULE_1__.ACTION_ID, _isActive);
  6385. }
  6386. function generate() {
  6387. (0,_button__WEBPACK_IMPORTED_MODULE_2__.bindAction)(_button__WEBPACK_IMPORTED_MODULE_0__["default"], doAction, _consts__WEBPACK_IMPORTED_MODULE_1__.HOTKEY);
  6388. _button__WEBPACK_IMPORTED_MODULE_0__["default"].click();
  6389. return _button__WEBPACK_IMPORTED_MODULE_0__["default"];
  6390. }
  6391.  
  6392.  
  6393. /***/ }),
  6394.  
  6395. /***/ "./ts/modal/header/actions/style/button.ts":
  6396. /*!*************************************************!*\
  6397. !*** ./ts/modal/header/actions/style/button.ts ***!
  6398. \*************************************************/
  6399. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  6400.  
  6401. __webpack_require__.r(__webpack_exports__);
  6402. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6403. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  6404. /* harmony export */ });
  6405. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/style/consts.ts");
  6406. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../button */ "./ts/modal/header/actions/button.ts");
  6407. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  6408.  
  6409.  
  6410.  
  6411. const handle = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'rect');
  6412. handle.setAttribute('stroke-linecap', 'round');
  6413. handle.setAttribute('stroke-width', '6');
  6414. handle.setAttribute('x', '-5');
  6415. handle.setAttribute('y', '15');
  6416. handle.setAttribute('width', '15');
  6417. handle.setAttribute('height', '40');
  6418. handle.setAttribute('rx', '5');
  6419. const frame = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'path');
  6420. frame.setAttribute('fill', 'none');
  6421. frame.setAttribute('stroke-linecap', 'round');
  6422. frame.setAttribute('stroke-width', '3');
  6423. frame.setAttribute('d', 'M 2.5 15'
  6424. + ' L 2.5 0'
  6425. + ' L -36 -15'
  6426. + ' L -36 -35'
  6427. + ' L -30 -35');
  6428. const curveLeft = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'path');
  6429. curveLeft.setAttribute('fill', 'none');
  6430. curveLeft.setAttribute('stroke-linecap', 'round');
  6431. curveLeft.setAttribute('stroke-width', '6');
  6432. curveLeft.setAttribute('d', 'M -25 -30'
  6433. + ' Q -30 -35 -25 -40');
  6434. const curveRight = curveLeft.cloneNode(true);
  6435. curveRight.setAttribute('transform', 'scale(-1,1) translate(-10,0)');
  6436. const roller = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'rect');
  6437. roller.setAttribute('stroke-linecap', 'round');
  6438. roller.setAttribute('stroke-width', '6');
  6439. roller.setAttribute('x', '-22.5');
  6440. roller.setAttribute('y', '-47.5');
  6441. roller.setAttribute('width', '55');
  6442. roller.setAttribute('height', '25');
  6443. roller.setAttribute('rx', '1');
  6444. const g = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'g');
  6445. g.append(handle, frame, curveLeft, curveRight, roller);
  6446. const BUTTON = (0,_button__WEBPACK_IMPORTED_MODULE_1__.getNewButton)(g, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, 'Toggle Style Editor');
  6447. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (BUTTON);
  6448.  
  6449.  
  6450. /***/ }),
  6451.  
  6452. /***/ "./ts/modal/header/actions/style/consts.ts":
  6453. /*!*************************************************!*\
  6454. !*** ./ts/modal/header/actions/style/consts.ts ***!
  6455. \*************************************************/
  6456. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  6457.  
  6458. __webpack_require__.r(__webpack_exports__);
  6459. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6460. /* harmony export */ ACTION_ID: () => (/* binding */ ACTION_ID),
  6461. /* harmony export */ HOTKEY: () => (/* binding */ HOTKEY)
  6462. /* harmony export */ });
  6463. const ACTION_ID = 'modal-style';
  6464. const HOTKEY = 'C';
  6465.  
  6466.  
  6467. /***/ }),
  6468.  
  6469. /***/ "./ts/modal/header/actions/style/css.ts":
  6470. /*!**********************************************!*\
  6471. !*** ./ts/modal/header/actions/style/css.ts ***!
  6472. \**********************************************/
  6473. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  6474.  
  6475. __webpack_require__.r(__webpack_exports__);
  6476. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6477. /* harmony export */ "default": () => (/* binding */ generate)
  6478. /* harmony export */ });
  6479. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/style/consts.ts");
  6480. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../css */ "./ts/modal/header/actions/css.ts");
  6481.  
  6482.  
  6483. function generate() {
  6484. (0,_css__WEBPACK_IMPORTED_MODULE_1__.addColourRule)(_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, '--headButtonStyle');
  6485. }
  6486.  
  6487.  
  6488. /***/ }),
  6489.  
  6490. /***/ "./ts/modal/header/actions/style/index.ts":
  6491. /*!************************************************!*\
  6492. !*** ./ts/modal/header/actions/style/index.ts ***!
  6493. \************************************************/
  6494. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  6495.  
  6496. __webpack_require__.r(__webpack_exports__);
  6497. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6498. /* harmony export */ "default": () => (/* binding */ generate)
  6499. /* harmony export */ });
  6500. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./button */ "./ts/modal/header/actions/style/button.ts");
  6501. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/style/consts.ts");
  6502. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./css */ "./ts/modal/header/actions/style/css.ts");
  6503. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../button */ "./ts/modal/header/actions/button.ts");
  6504. /* harmony import */ var _modal_body__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/modal/body */ "./ts/modal/body/index.ts");
  6505. /* harmony import */ var _nodes_actions_focus__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @nodes/actions/focus */ "./ts/modal/body/nodes/actions/focus/index.ts");
  6506. /* 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");
  6507.  
  6508.  
  6509.  
  6510.  
  6511.  
  6512.  
  6513.  
  6514. let isActive = false;
  6515. function doAction() {
  6516. isActive = !isActive;
  6517. (0,_modal_body__WEBPACK_IMPORTED_MODULE_4__.setActive)(_button__WEBPACK_IMPORTED_MODULE_0__["default"], _consts__WEBPACK_IMPORTED_MODULE_1__.ACTION_ID, isActive);
  6518. _modal_body__WEBPACK_IMPORTED_MODULE_4__.element.scrollTop = 0;
  6519. (0,_nodes_actions_focus__WEBPACK_IMPORTED_MODULE_5__.reset)();
  6520. (0,_nodes_actions_buttons_position__WEBPACK_IMPORTED_MODULE_6__.reset)();
  6521. // Reset tab index & highlight
  6522. _modal_body__WEBPACK_IMPORTED_MODULE_4__.element.focus();
  6523. }
  6524. function generate() {
  6525. (0,_css__WEBPACK_IMPORTED_MODULE_2__["default"])();
  6526. (0,_button__WEBPACK_IMPORTED_MODULE_3__.bindAction)(_button__WEBPACK_IMPORTED_MODULE_0__["default"], doAction, _consts__WEBPACK_IMPORTED_MODULE_1__.HOTKEY);
  6527. return _button__WEBPACK_IMPORTED_MODULE_0__["default"];
  6528. }
  6529.  
  6530.  
  6531. /***/ }),
  6532.  
  6533. /***/ "./ts/modal/header/consts.ts":
  6534. /*!***********************************!*\
  6535. !*** ./ts/modal/header/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 */ HEADER_ID: () => (/* binding */ HEADER_ID)
  6542. /* harmony export */ });
  6543. const HEADER_ID = 'modal-header';
  6544.  
  6545.  
  6546. /***/ }),
  6547.  
  6548. /***/ "./ts/modal/header/css.ts":
  6549. /*!********************************!*\
  6550. !*** ./ts/modal/header/css.ts ***!
  6551. \********************************/
  6552. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  6553.  
  6554. __webpack_require__.r(__webpack_exports__);
  6555. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6556. /* harmony export */ "default": () => (/* binding */ generate)
  6557. /* harmony export */ });
  6558. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/consts.ts");
  6559. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../css */ "./ts/modal/css.ts");
  6560.  
  6561.  
  6562. function generate() {
  6563. (0,_css__WEBPACK_IMPORTED_MODULE_1__.addRule)(`#${_consts__WEBPACK_IMPORTED_MODULE_0__.HEADER_ID}`, [
  6564. ['display', 'flex'],
  6565. ['align-items', 'center'],
  6566. ['background-color', 'var(--headBase)'],
  6567. ['color', 'var(--headContrast)'],
  6568. ['border-bottom', '2px solid var(--borderModal)'],
  6569. ['font-size', '1.5em'],
  6570. ['text-align', 'center'],
  6571. ]);
  6572. }
  6573.  
  6574.  
  6575. /***/ }),
  6576.  
  6577. /***/ "./ts/modal/header/index.ts":
  6578. /*!**********************************!*\
  6579. !*** ./ts/modal/header/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/consts.ts");
  6588. /* harmony import */ var _title__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./title */ "./ts/modal/header/title/index.ts");
  6589. /* harmony import */ var _actions__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./actions */ "./ts/modal/header/actions/index.ts");
  6590. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./css */ "./ts/modal/header/css.ts");
  6591.  
  6592.  
  6593.  
  6594.  
  6595. function generate({ title }, background) {
  6596. (0,_css__WEBPACK_IMPORTED_MODULE_3__["default"])();
  6597. const element = document.createElement('div');
  6598. element.id = _consts__WEBPACK_IMPORTED_MODULE_0__.HEADER_ID;
  6599. element.append((0,_title__WEBPACK_IMPORTED_MODULE_1__["default"])(title), (0,_actions__WEBPACK_IMPORTED_MODULE_2__["default"])(background));
  6600. return element;
  6601. }
  6602.  
  6603.  
  6604. /***/ }),
  6605.  
  6606. /***/ "./ts/modal/header/title/consts.ts":
  6607. /*!*****************************************!*\
  6608. !*** ./ts/modal/header/title/consts.ts ***!
  6609. \*****************************************/
  6610. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  6611.  
  6612. __webpack_require__.r(__webpack_exports__);
  6613. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6614. /* harmony export */ TITLE_CONTAINER_ID: () => (/* binding */ TITLE_CONTAINER_ID),
  6615. /* harmony export */ TITLE_ID: () => (/* binding */ TITLE_ID)
  6616. /* harmony export */ });
  6617. const TITLE_CONTAINER_ID = 'title-container';
  6618. const TITLE_ID = 'title';
  6619.  
  6620.  
  6621. /***/ }),
  6622.  
  6623. /***/ "./ts/modal/header/title/css.ts":
  6624. /*!**************************************!*\
  6625. !*** ./ts/modal/header/title/css.ts ***!
  6626. \**************************************/
  6627. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  6628.  
  6629. __webpack_require__.r(__webpack_exports__);
  6630. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6631. /* harmony export */ "default": () => (/* binding */ generate)
  6632. /* harmony export */ });
  6633. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/title/consts.ts");
  6634. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../css */ "./ts/modal/css.ts");
  6635.  
  6636.  
  6637. function generate() {
  6638. (0,_css__WEBPACK_IMPORTED_MODULE_1__.addRule)(`#${_consts__WEBPACK_IMPORTED_MODULE_0__.TITLE_CONTAINER_ID}`, [
  6639. ['flex-grow', '1'],
  6640. ['white-space', 'nowrap'],
  6641. ['overflow', 'hidden'],
  6642. ['text-overflow', 'ellipsis'],
  6643. ['padding', '0 0.5em'],
  6644. ]);
  6645. }
  6646.  
  6647.  
  6648. /***/ }),
  6649.  
  6650. /***/ "./ts/modal/header/title/index.ts":
  6651. /*!****************************************!*\
  6652. !*** ./ts/modal/header/title/index.ts ***!
  6653. \****************************************/
  6654. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  6655.  
  6656. __webpack_require__.r(__webpack_exports__);
  6657. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6658. /* harmony export */ "default": () => (/* binding */ generate)
  6659. /* harmony export */ });
  6660. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/title/consts.ts");
  6661. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./css */ "./ts/modal/header/title/css.ts");
  6662.  
  6663.  
  6664. function generate(title) {
  6665. (0,_css__WEBPACK_IMPORTED_MODULE_1__["default"])();
  6666. const titleContainer = document.createElement('span');
  6667. const titleElement = document.createElement('span');
  6668. titleContainer.id = _consts__WEBPACK_IMPORTED_MODULE_0__.TITLE_CONTAINER_ID;
  6669. titleElement.id = _consts__WEBPACK_IMPORTED_MODULE_0__.TITLE_ID;
  6670. titleElement.innerText = title;
  6671. // In case the text is too long to fit
  6672. titleElement.title = title;
  6673. titleContainer.append(titleElement);
  6674. return titleContainer;
  6675. }
  6676.  
  6677.  
  6678. /***/ }),
  6679.  
  6680. /***/ "./ts/modal/index.ts":
  6681. /*!***************************!*\
  6682. !*** ./ts/modal/index.ts ***!
  6683. \***************************/
  6684. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  6685.  
  6686. __webpack_require__.r(__webpack_exports__);
  6687. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6688. /* harmony export */ "default": () => (/* binding */ generate),
  6689. /* harmony export */ getDocument: () => (/* binding */ getDocument),
  6690. /* harmony export */ getSocket: () => (/* binding */ getSocket),
  6691. /* harmony export */ getWindow: () => (/* binding */ getWindow)
  6692. /* harmony export */ });
  6693. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/consts.ts");
  6694. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./css */ "./ts/modal/css.ts");
  6695. /* harmony import */ var _header__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./header */ "./ts/modal/header/index.ts");
  6696. /* harmony import */ var _body__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./body */ "./ts/modal/body/index.ts");
  6697. /* harmony import */ var _nodes_actions_highlight__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @nodes/actions/highlight */ "./ts/modal/body/nodes/actions/highlight/index.ts");
  6698.  
  6699.  
  6700.  
  6701.  
  6702.  
  6703. let socket;
  6704. let ownerDocument;
  6705. let ownerWindow;
  6706. function getSocket() {
  6707. return socket;
  6708. }
  6709. function getDocument() {
  6710. return ownerDocument;
  6711. }
  6712. function getWindow() {
  6713. return ownerWindow;
  6714. }
  6715. function generate(config, _socket, _window) {
  6716. socket = _socket;
  6717. ownerDocument = socket.ownerDocument;
  6718. ownerWindow = _window;
  6719. (0,_css__WEBPACK_IMPORTED_MODULE_1__["default"])();
  6720. const background = document.createElement('div');
  6721. const foreground = document.createElement('div');
  6722. background.id = _consts__WEBPACK_IMPORTED_MODULE_0__.MODAL_BACKGROUND_ID;
  6723. foreground.id = _consts__WEBPACK_IMPORTED_MODULE_0__.MODAL_ID;
  6724. background.append(foreground);
  6725. socket.append(background);
  6726. 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));
  6727. }
  6728.  
  6729.  
  6730. /***/ }),
  6731.  
  6732. /***/ "./ts/predicate.ts":
  6733. /*!*************************!*\
  6734. !*** ./ts/predicate.ts ***!
  6735. \*************************/
  6736. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  6737.  
  6738. __webpack_require__.r(__webpack_exports__);
  6739. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6740. /* harmony export */ getPredicatePromise: () => (/* binding */ getPredicatePromise),
  6741. /* harmony export */ isUnresolved: () => (/* binding */ isUnresolved)
  6742. /* harmony export */ });
  6743. var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
  6744. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  6745. return new (P || (P = Promise))(function (resolve, reject) {
  6746. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  6747. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  6748. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  6749. step((generator = generator.apply(thisArg, _arguments || [])).next());
  6750. });
  6751. };
  6752. let count = 0;
  6753. function isUnresolved() {
  6754. return count > 0;
  6755. }
  6756. function getPredicatePromise(_response) {
  6757. return __awaiter(this, void 0, void 0, function* () {
  6758. count++;
  6759. try {
  6760. const response = yield _response;
  6761. count--;
  6762. return typeof response === 'string' ? Promise.reject(response) : Promise[response ? 'resolve' : 'reject']();
  6763. }
  6764. catch (response) {
  6765. count--;
  6766. if (response instanceof Error) {
  6767. return Promise.reject(response.message);
  6768. }
  6769. return Promise.reject(typeof response === 'string' ? response : undefined);
  6770. }
  6771. });
  6772. }
  6773.  
  6774.  
  6775. /***/ })
  6776.  
  6777. /******/ });
  6778. /************************************************************************/
  6779. /******/ // The module cache
  6780. /******/ var __webpack_module_cache__ = {};
  6781. /******/
  6782. /******/ // The require function
  6783. /******/ function __webpack_require__(moduleId) {
  6784. /******/ // Check if module is in cache
  6785. /******/ var cachedModule = __webpack_module_cache__[moduleId];
  6786. /******/ if (cachedModule !== undefined) {
  6787. /******/ return cachedModule.exports;
  6788. /******/ }
  6789. /******/ // Create a new module (and put it into the cache)
  6790. /******/ var module = __webpack_module_cache__[moduleId] = {
  6791. /******/ // no module.id needed
  6792. /******/ // no module.loaded needed
  6793. /******/ exports: {}
  6794. /******/ };
  6795. /******/
  6796. /******/ // Execute the module function
  6797. /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
  6798. /******/
  6799. /******/ // Return the exports of the module
  6800. /******/ return module.exports;
  6801. /******/ }
  6802. /******/
  6803. /************************************************************************/
  6804. /******/ /* webpack/runtime/define property getters */
  6805. /******/ (() => {
  6806. /******/ // define getter functions for harmony exports
  6807. /******/ __webpack_require__.d = (exports, definition) => {
  6808. /******/ for(var key in definition) {
  6809. /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  6810. /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
  6811. /******/ }
  6812. /******/ }
  6813. /******/ };
  6814. /******/ })();
  6815. /******/
  6816. /******/ /* webpack/runtime/hasOwnProperty shorthand */
  6817. /******/ (() => {
  6818. /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
  6819. /******/ })();
  6820. /******/
  6821. /******/ /* webpack/runtime/make namespace object */
  6822. /******/ (() => {
  6823. /******/ // define __esModule on exports
  6824. /******/ __webpack_require__.r = (exports) => {
  6825. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  6826. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  6827. /******/ }
  6828. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  6829. /******/ };
  6830. /******/ })();
  6831. /******/
  6832. /************************************************************************/
  6833. var __webpack_exports__ = {};
  6834. // This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk.
  6835. (() => {
  6836. /*!*******************************!*\
  6837. !*** ./ts/library/$Config.js ***!
  6838. \*******************************/
  6839. __webpack_require__.r(__webpack_exports__);
  6840. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6841. /* harmony export */ "default": () => (/* binding */ $Config)
  6842. /* harmony export */ });
  6843. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../consts */ "./ts/consts.ts");
  6844. /* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./index */ "./ts/library/index.ts");
  6845. /* harmony import */ var _modal_body__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../modal/body */ "./ts/modal/body/index.ts");
  6846.  
  6847.  
  6848.  
  6849.  
  6850.  
  6851. const PATCHES = [
  6852. (node) => {
  6853. delete node.predicate;
  6854. delete node.childPredicate;
  6855. delete node.descendantPredicate;
  6856. delete node.seed;
  6857. },
  6858. (node) => {
  6859. delete node.input;
  6860. },
  6861. ];
  6862.  
  6863. const KEY_VERSION_CONFIG = 'TREE_FRAME_VERSION';
  6864. const KEY_VERSION_SCRIPT = 'SCRIPT_VERSION';
  6865. const KEY_STYLES = 'TREE_FRAME_USER_STYLES';
  6866.  
  6867. const STYLE_OUTER_DEFAULTS = {
  6868. position: 'fixed',
  6869. top: '0',
  6870. height: '100vh',
  6871. width: '100vw',
  6872. };
  6873.  
  6874. class $Config {
  6875. constructor(treeKey, defaultTree, {defaultStyle = {}, outerStyle = {}, patches = []} = {}) {
  6876. // PERMISSION CHECKS
  6877. const getError = (reason, error) => {
  6878. const message = `[${GM.info.script.name}]${reason.includes('\n') ? '\n\n' : ' '}${reason}`;
  6879. if (error) {
  6880. error.message = message;
  6881. return error;
  6882. }
  6883. return new Error(message);
  6884. };
  6885. if (typeof GM.getValue !== 'function') {
  6886. throw getError('Missing GM.getValue permission.');
  6887. }
  6888. if (typeof GM.setValue !== 'function') {
  6889. throw getError('Missing GM.setValue permission.');
  6890. }
  6891. if (typeof treeKey !== 'string' || !(/^[a-z_][a-z0-9_]*$/i.test(treeKey))) {
  6892. throw getError(`'${treeKey}' is not a valid storage key.`);
  6893. }
  6894. // PRIVATE
  6895. const displayStyle = outerStyle.display ?? 'initial';
  6896. const target = (() => {
  6897. let targetWindow = window;
  6898. while (targetWindow.frameElement) {
  6899. targetWindow = window.parent;
  6900. }
  6901. const id = `${_consts__WEBPACK_IMPORTED_MODULE_0__.SOCKET_ID}-${treeKey}`;
  6902. for (const child of targetWindow.document.body.children) {
  6903. if (child.id === id) {
  6904. child.remove();
  6905. break;
  6906. }
  6907. }
  6908. const target = document.createElement('iframe');
  6909. target.id = id;
  6910. for (const [property, value] of Object.entries({...STYLE_OUTER_DEFAULTS, ...outerStyle})) {
  6911. target.style[property] = value;
  6912. }
  6913. target.style.display = 'none';
  6914. targetWindow.document.body.appendChild(target);
  6915. return target;
  6916. })();
  6917. let isOpen = false;
  6918. const open = (doOpen = true) => new Promise((resolve) => {
  6919. isOpen = doOpen;
  6920. target.style.display = doOpen ? displayStyle : 'none';
  6921. // Delay script execution until visual update
  6922. setTimeout(resolve, 0);
  6923. });
  6924. const disconnect = () => new Promise((resolve) => {
  6925. isOpen = false;
  6926. target.remove();
  6927. // Delay script execution until visual update
  6928. setTimeout(resolve, 0);
  6929. });
  6930. // PUBLIC
  6931. this.ready = Promise.all([
  6932. GM.getValue(treeKey),
  6933. GM.getValue(KEY_STYLES, []),
  6934. GM.getValue(KEY_VERSION_CONFIG, -1),
  6935. GM.getValue(KEY_VERSION_SCRIPT, 0),
  6936. ])
  6937. // Retrieve data
  6938. .then(([userTree, userStyles, configVersion, scriptVersion]) => {
  6939. // Patch to current version
  6940. (() => {
  6941. if (!userTree) {
  6942. return;
  6943. }
  6944. // patch to make configVersion start from 0 instead of -1
  6945. if (configVersion < 2) {
  6946. configVersion++;
  6947. }
  6948. if (configVersion < PATCHES.length) {
  6949. const patchAllNodes = (doPatch, node = userTree) => {
  6950. doPatch(node);
  6951. if ('children' in node) {
  6952. for (const child of node.children) {
  6953. patchAllNodes(doPatch, child);
  6954. }
  6955. }
  6956. };
  6957. for (let i = configVersion; i < PATCHES.length; ++i) {
  6958. patchAllNodes(PATCHES[i]);
  6959. }
  6960. }
  6961. for (let i = scriptVersion; i < patches.length; ++i) {
  6962. patches[i](userTree);
  6963. }
  6964. })();
  6965. /**
  6966. * @name $Config#reset
  6967. * @description Deletes the user's data.
  6968. * @returns {Promise<void>} Resolves upon completing the deletion.
  6969. */
  6970. this.reset = async () => {
  6971. if (isOpen) {
  6972. throw getError('Cannot reset while the UI is open.');
  6973. }
  6974. if (typeof GM.deleteValue !== 'function') {
  6975. throw getError('Missing GM.deleteValue permission.');
  6976. }
  6977. await GM.deleteValue(treeKey);
  6978. // It may have previously been a rejected promise
  6979. this.ready = () => Promise.resolve();
  6980. (0,_modal_body__WEBPACK_IMPORTED_MODULE_2__.reset)();
  6981. };
  6982. /**
  6983. * @name $Config#edit
  6984. * @description Allows the user to edit the active config.
  6985. * @returns {Promise<void>} Resolves when the user closes the config editor.
  6986. */
  6987. this.edit = async () => {
  6988. if (isOpen) {
  6989. throw getError('A config editor is already open.');
  6990. }
  6991. open();
  6992. const {tree, config, styles} = await (0,_index__WEBPACK_IMPORTED_MODULE_1__.edit)();
  6993. GM.setValue(treeKey, tree);
  6994. GM.setValue(KEY_STYLES, styles);
  6995. GM.setValue(KEY_VERSION_CONFIG, PATCHES.length);
  6996. GM.setValue(KEY_VERSION_SCRIPT, patches.length);
  6997. this.get = ((config) => config).bind(null, Object.freeze(config));
  6998. await open(false);
  6999. };
  7000. // Pass data
  7001. return (0,_index__WEBPACK_IMPORTED_MODULE_1__.init)({
  7002. userStyles,
  7003. defaultTree,
  7004. title: GM.info.script.name,
  7005. defaultStyle,
  7006. ...(userTree ? {userTree} : {}),
  7007. }, target.contentDocument.body, target.contentWindow);
  7008. })
  7009. .catch(async (error) => {
  7010. delete this.reset;
  7011. await disconnect();
  7012. throw getError(
  7013. 'Your config is invalid.'
  7014. + '\nThis could be due to a script update or your data being corrupted.'
  7015. + `\n\nReason:\n${error.message.replaceAll(/\n+/g, '\n')}`,
  7016. error,
  7017. );
  7018. })
  7019. .then((response) => {
  7020. this.get = ((config) => config).bind(null, Object.freeze(response.config));
  7021. if (response.requireReset) {
  7022. throw getError(
  7023. 'Your config is invalid.'
  7024. + '\nThis could be due to a script update or your data being corrupted.'
  7025. + `\n\nReason:\n${response.error.message.replaceAll(/\n+/g, '\n')}`,
  7026. response.error,
  7027. );
  7028. }
  7029. });
  7030. }
  7031. }
  7032.  
  7033. })();
  7034.  
  7035. $Config = __webpack_exports__["default"];
  7036. /******/ })()
  7037. ;

QingJ © 2025

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