| [ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 "use strict"; 2 var wp; 3 (wp ||= {}).editSite = (() => { 4 var __create = Object.create; 5 var __defProp = Object.defineProperty; 6 var __getOwnPropDesc = Object.getOwnPropertyDescriptor; 7 var __getOwnPropNames = Object.getOwnPropertyNames; 8 var __getProtoOf = Object.getPrototypeOf; 9 var __hasOwnProp = Object.prototype.hasOwnProperty; 10 var __require = /* @__PURE__ */ ((x2) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x2, { 11 get: (a2, b2) => (typeof require !== "undefined" ? require : a2)[b2] 12 }) : x2)(function(x2) { 13 if (typeof require !== "undefined") return require.apply(this, arguments); 14 throw Error('Dynamic require of "' + x2 + '" is not supported'); 15 }); 16 var __commonJS = (cb, mod) => function __require4() { 17 return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; 18 }; 19 var __export = (target, all) => { 20 for (var name2 in all) 21 __defProp(target, name2, { get: all[name2], enumerable: true }); 22 }; 23 var __copyProps = (to2, from, except, desc) => { 24 if (from && typeof from === "object" || typeof from === "function") { 25 for (let key of __getOwnPropNames(from)) 26 if (!__hasOwnProp.call(to2, key) && key !== except) 27 __defProp(to2, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); 28 } 29 return to2; 30 }; 31 var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( 32 // If the importer is in node compatibility mode or this is not an ESM 33 // file that has been converted to a CommonJS file using a Babel- 34 // compatible transform (i.e. "__esModule" has not been set), then set 35 // "default" to the CommonJS "module.exports" for node compatibility. 36 isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, 37 mod 38 )); 39 var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); 40 41 // package-external:@wordpress/blocks 42 var require_blocks = __commonJS({ 43 "package-external:@wordpress/blocks"(exports, module) { 44 module.exports = window.wp.blocks; 45 } 46 }); 47 48 // package-external:@wordpress/block-library 49 var require_block_library = __commonJS({ 50 "package-external:@wordpress/block-library"(exports, module) { 51 module.exports = window.wp.blockLibrary; 52 } 53 }); 54 55 // package-external:@wordpress/data 56 var require_data = __commonJS({ 57 "package-external:@wordpress/data"(exports, module) { 58 module.exports = window.wp.data; 59 } 60 }); 61 62 // package-external:@wordpress/deprecated 63 var require_deprecated = __commonJS({ 64 "package-external:@wordpress/deprecated"(exports, module) { 65 module.exports = window.wp.deprecated; 66 } 67 }); 68 69 // package-external:@wordpress/element 70 var require_element = __commonJS({ 71 "package-external:@wordpress/element"(exports, module) { 72 module.exports = window.wp.element; 73 } 74 }); 75 76 // package-external:@wordpress/editor 77 var require_editor = __commonJS({ 78 "package-external:@wordpress/editor"(exports, module) { 79 module.exports = window.wp.editor; 80 } 81 }); 82 83 // package-external:@wordpress/preferences 84 var require_preferences = __commonJS({ 85 "package-external:@wordpress/preferences"(exports, module) { 86 module.exports = window.wp.preferences; 87 } 88 }); 89 90 // package-external:@wordpress/widgets 91 var require_widgets = __commonJS({ 92 "package-external:@wordpress/widgets"(exports, module) { 93 module.exports = window.wp.widgets; 94 } 95 }); 96 97 // package-external:@wordpress/core-data 98 var require_core_data = __commonJS({ 99 "package-external:@wordpress/core-data"(exports, module) { 100 module.exports = window.wp.coreData; 101 } 102 }); 103 104 // package-external:@wordpress/block-editor 105 var require_block_editor = __commonJS({ 106 "package-external:@wordpress/block-editor"(exports, module) { 107 module.exports = window.wp.blockEditor; 108 } 109 }); 110 111 // package-external:@wordpress/i18n 112 var require_i18n = __commonJS({ 113 "package-external:@wordpress/i18n"(exports, module) { 114 module.exports = window.wp.i18n; 115 } 116 }); 117 118 // package-external:@wordpress/patterns 119 var require_patterns = __commonJS({ 120 "package-external:@wordpress/patterns"(exports, module) { 121 module.exports = window.wp.patterns; 122 } 123 }); 124 125 // package-external:@wordpress/private-apis 126 var require_private_apis = __commonJS({ 127 "package-external:@wordpress/private-apis"(exports, module) { 128 module.exports = window.wp.privateApis; 129 } 130 }); 131 132 // package-external:@wordpress/router 133 var require_router = __commonJS({ 134 "package-external:@wordpress/router"(exports, module) { 135 module.exports = window.wp.router; 136 } 137 }); 138 139 // package-external:@wordpress/components 140 var require_components = __commonJS({ 141 "package-external:@wordpress/components"(exports, module) { 142 module.exports = window.wp.components; 143 } 144 }); 145 146 // vendor-external:react/jsx-runtime 147 var require_jsx_runtime = __commonJS({ 148 "vendor-external:react/jsx-runtime"(exports, module) { 149 module.exports = window.ReactJSXRuntime; 150 } 151 }); 152 153 // package-external:@wordpress/compose 154 var require_compose = __commonJS({ 155 "package-external:@wordpress/compose"(exports, module) { 156 module.exports = window.wp.compose; 157 } 158 }); 159 160 // package-external:@wordpress/plugins 161 var require_plugins = __commonJS({ 162 "package-external:@wordpress/plugins"(exports, module) { 163 module.exports = window.wp.plugins; 164 } 165 }); 166 167 // package-external:@wordpress/notices 168 var require_notices = __commonJS({ 169 "package-external:@wordpress/notices"(exports, module) { 170 module.exports = window.wp.notices; 171 } 172 }); 173 174 // package-external:@wordpress/html-entities 175 var require_html_entities = __commonJS({ 176 "package-external:@wordpress/html-entities"(exports, module) { 177 module.exports = window.wp.htmlEntities; 178 } 179 }); 180 181 // package-external:@wordpress/primitives 182 var require_primitives = __commonJS({ 183 "package-external:@wordpress/primitives"(exports, module) { 184 module.exports = window.wp.primitives; 185 } 186 }); 187 188 // package-external:@wordpress/commands 189 var require_commands = __commonJS({ 190 "package-external:@wordpress/commands"(exports, module) { 191 module.exports = window.wp.commands; 192 } 193 }); 194 195 // package-external:@wordpress/keycodes 196 var require_keycodes = __commonJS({ 197 "package-external:@wordpress/keycodes"(exports, module) { 198 module.exports = window.wp.keycodes; 199 } 200 }); 201 202 // package-external:@wordpress/url 203 var require_url = __commonJS({ 204 "package-external:@wordpress/url"(exports, module) { 205 module.exports = window.wp.url; 206 } 207 }); 208 209 // package-external:@wordpress/dom 210 var require_dom = __commonJS({ 211 "package-external:@wordpress/dom"(exports, module) { 212 module.exports = window.wp.dom; 213 } 214 }); 215 216 // package-external:@wordpress/keyboard-shortcuts 217 var require_keyboard_shortcuts = __commonJS({ 218 "package-external:@wordpress/keyboard-shortcuts"(exports, module) { 219 module.exports = window.wp.keyboardShortcuts; 220 } 221 }); 222 223 // vendor-external:react 224 var require_react = __commonJS({ 225 "vendor-external:react"(exports, module) { 226 module.exports = window.React; 227 } 228 }); 229 230 // vendor-external:react-dom 231 var require_react_dom = __commonJS({ 232 "vendor-external:react-dom"(exports, module) { 233 module.exports = window.ReactDOM; 234 } 235 }); 236 237 // package-external:@wordpress/api-fetch 238 var require_api_fetch = __commonJS({ 239 "package-external:@wordpress/api-fetch"(exports, module) { 240 module.exports = window.wp.apiFetch; 241 } 242 }); 243 244 // package-external:@wordpress/style-engine 245 var require_style_engine = __commonJS({ 246 "package-external:@wordpress/style-engine"(exports, module) { 247 module.exports = window.wp.styleEngine; 248 } 249 }); 250 251 // node_modules/fast-deep-equal/es6/index.js 252 var require_es6 = __commonJS({ 253 "node_modules/fast-deep-equal/es6/index.js"(exports, module) { 254 "use strict"; 255 module.exports = function equal(a2, b2) { 256 if (a2 === b2) return true; 257 if (a2 && b2 && typeof a2 == "object" && typeof b2 == "object") { 258 if (a2.constructor !== b2.constructor) return false; 259 var length, i2, keys; 260 if (Array.isArray(a2)) { 261 length = a2.length; 262 if (length != b2.length) return false; 263 for (i2 = length; i2-- !== 0; ) 264 if (!equal(a2[i2], b2[i2])) return false; 265 return true; 266 } 267 if (a2 instanceof Map && b2 instanceof Map) { 268 if (a2.size !== b2.size) return false; 269 for (i2 of a2.entries()) 270 if (!b2.has(i2[0])) return false; 271 for (i2 of a2.entries()) 272 if (!equal(i2[1], b2.get(i2[0]))) return false; 273 return true; 274 } 275 if (a2 instanceof Set && b2 instanceof Set) { 276 if (a2.size !== b2.size) return false; 277 for (i2 of a2.entries()) 278 if (!b2.has(i2[0])) return false; 279 return true; 280 } 281 if (ArrayBuffer.isView(a2) && ArrayBuffer.isView(b2)) { 282 length = a2.length; 283 if (length != b2.length) return false; 284 for (i2 = length; i2-- !== 0; ) 285 if (a2[i2] !== b2[i2]) return false; 286 return true; 287 } 288 if (a2.constructor === RegExp) return a2.source === b2.source && a2.flags === b2.flags; 289 if (a2.valueOf !== Object.prototype.valueOf) return a2.valueOf() === b2.valueOf(); 290 if (a2.toString !== Object.prototype.toString) return a2.toString() === b2.toString(); 291 keys = Object.keys(a2); 292 length = keys.length; 293 if (length !== Object.keys(b2).length) return false; 294 for (i2 = length; i2-- !== 0; ) 295 if (!Object.prototype.hasOwnProperty.call(b2, keys[i2])) return false; 296 for (i2 = length; i2-- !== 0; ) { 297 var key = keys[i2]; 298 if (!equal(a2[key], b2[key])) return false; 299 } 300 return true; 301 } 302 return a2 !== a2 && b2 !== b2; 303 }; 304 } 305 }); 306 307 // node_modules/deepmerge/dist/cjs.js 308 var require_cjs = __commonJS({ 309 "node_modules/deepmerge/dist/cjs.js"(exports, module) { 310 "use strict"; 311 var isMergeableObject = function isMergeableObject2(value) { 312 return isNonNullObject(value) && !isSpecial(value); 313 }; 314 function isNonNullObject(value) { 315 return !!value && typeof value === "object"; 316 } 317 function isSpecial(value) { 318 var stringValue = Object.prototype.toString.call(value); 319 return stringValue === "[object RegExp]" || stringValue === "[object Date]" || isReactElement(value); 320 } 321 var canUseSymbol = typeof Symbol === "function" && Symbol.for; 322 var REACT_ELEMENT_TYPE = canUseSymbol ? Symbol.for("react.element") : 60103; 323 function isReactElement(value) { 324 return value.$$typeof === REACT_ELEMENT_TYPE; 325 } 326 function emptyTarget(val) { 327 return Array.isArray(val) ? [] : {}; 328 } 329 function cloneUnlessOtherwiseSpecified(value, options) { 330 return options.clone !== false && options.isMergeableObject(value) ? deepmerge2(emptyTarget(value), value, options) : value; 331 } 332 function defaultArrayMerge(target, source, options) { 333 return target.concat(source).map(function(element) { 334 return cloneUnlessOtherwiseSpecified(element, options); 335 }); 336 } 337 function getMergeFunction(key, options) { 338 if (!options.customMerge) { 339 return deepmerge2; 340 } 341 var customMerge = options.customMerge(key); 342 return typeof customMerge === "function" ? customMerge : deepmerge2; 343 } 344 function getEnumerableOwnPropertySymbols(target) { 345 return Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(target).filter(function(symbol3) { 346 return Object.propertyIsEnumerable.call(target, symbol3); 347 }) : []; 348 } 349 function getKeys2(target) { 350 return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target)); 351 } 352 function propertyIsOnObject(object, property) { 353 try { 354 return property in object; 355 } catch (_) { 356 return false; 357 } 358 } 359 function propertyIsUnsafe(target, key) { 360 return propertyIsOnObject(target, key) && !(Object.hasOwnProperty.call(target, key) && Object.propertyIsEnumerable.call(target, key)); 361 } 362 function mergeObject(target, source, options) { 363 var destination = {}; 364 if (options.isMergeableObject(target)) { 365 getKeys2(target).forEach(function(key) { 366 destination[key] = cloneUnlessOtherwiseSpecified(target[key], options); 367 }); 368 } 369 getKeys2(source).forEach(function(key) { 370 if (propertyIsUnsafe(target, key)) { 371 return; 372 } 373 if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) { 374 destination[key] = getMergeFunction(key, options)(target[key], source[key], options); 375 } else { 376 destination[key] = cloneUnlessOtherwiseSpecified(source[key], options); 377 } 378 }); 379 return destination; 380 } 381 function deepmerge2(target, source, options) { 382 options = options || {}; 383 options.arrayMerge = options.arrayMerge || defaultArrayMerge; 384 options.isMergeableObject = options.isMergeableObject || isMergeableObject; 385 options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified; 386 var sourceIsArray = Array.isArray(source); 387 var targetIsArray = Array.isArray(target); 388 var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray; 389 if (!sourceAndTargetTypesMatch) { 390 return cloneUnlessOtherwiseSpecified(source, options); 391 } else if (sourceIsArray) { 392 return options.arrayMerge(target, source, options); 393 } else { 394 return mergeObject(target, source, options); 395 } 396 } 397 deepmerge2.all = function deepmergeAll(array, options) { 398 if (!Array.isArray(array)) { 399 throw new Error("first argument should be an array"); 400 } 401 return array.reduce(function(prev, next) { 402 return deepmerge2(prev, next, options); 403 }, {}); 404 }; 405 var deepmerge_1 = deepmerge2; 406 module.exports = deepmerge_1; 407 } 408 }); 409 410 // package-external:@wordpress/a11y 411 var require_a11y = __commonJS({ 412 "package-external:@wordpress/a11y"(exports, module) { 413 module.exports = window.wp.a11y; 414 } 415 }); 416 417 // package-external:@wordpress/date 418 var require_date = __commonJS({ 419 "package-external:@wordpress/date"(exports, module) { 420 module.exports = window.wp.date; 421 } 422 }); 423 424 // package-external:@wordpress/blob 425 var require_blob = __commonJS({ 426 "package-external:@wordpress/blob"(exports, module) { 427 module.exports = window.wp.blob; 428 } 429 }); 430 431 // node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js 432 var require_use_sync_external_store_shim_development = __commonJS({ 433 "node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js"(exports) { 434 "use strict"; 435 (function() { 436 function is2(x2, y2) { 437 return x2 === y2 && (0 !== x2 || 1 / x2 === 1 / y2) || x2 !== x2 && y2 !== y2; 438 } 439 function useSyncExternalStore$2(subscribe2, getSnapshot) { 440 didWarnOld18Alpha || void 0 === React6.startTransition || (didWarnOld18Alpha = true, console.error( 441 "You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release." 442 )); 443 var value = getSnapshot(); 444 if (!didWarnUncachedGetSnapshot) { 445 var cachedValue = getSnapshot(); 446 objectIs(value, cachedValue) || (console.error( 447 "The result of getSnapshot should be cached to avoid an infinite loop" 448 ), didWarnUncachedGetSnapshot = true); 449 } 450 cachedValue = useState68({ 451 inst: { value, getSnapshot } 452 }); 453 var inst = cachedValue[0].inst, forceUpdate = cachedValue[1]; 454 useLayoutEffect7( 455 function() { 456 inst.value = value; 457 inst.getSnapshot = getSnapshot; 458 checkIfSnapshotChanged(inst) && forceUpdate({ inst }); 459 }, 460 [subscribe2, value, getSnapshot] 461 ); 462 useEffect45( 463 function() { 464 checkIfSnapshotChanged(inst) && forceUpdate({ inst }); 465 return subscribe2(function() { 466 checkIfSnapshotChanged(inst) && forceUpdate({ inst }); 467 }); 468 }, 469 [subscribe2] 470 ); 471 useDebugValue(value); 472 return value; 473 } 474 function checkIfSnapshotChanged(inst) { 475 var latestGetSnapshot = inst.getSnapshot; 476 inst = inst.value; 477 try { 478 var nextValue = latestGetSnapshot(); 479 return !objectIs(inst, nextValue); 480 } catch (error) { 481 return true; 482 } 483 } 484 function useSyncExternalStore$1(subscribe2, getSnapshot) { 485 return getSnapshot(); 486 } 487 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error()); 488 var React6 = require_react(), objectIs = "function" === typeof Object.is ? Object.is : is2, useState68 = React6.useState, useEffect45 = React6.useEffect, useLayoutEffect7 = React6.useLayoutEffect, useDebugValue = React6.useDebugValue, didWarnOld18Alpha = false, didWarnUncachedGetSnapshot = false, shim = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? useSyncExternalStore$1 : useSyncExternalStore$2; 489 exports.useSyncExternalStore = void 0 !== React6.useSyncExternalStore ? React6.useSyncExternalStore : shim; 490 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error()); 491 })(); 492 } 493 }); 494 495 // node_modules/use-sync-external-store/shim/index.js 496 var require_shim = __commonJS({ 497 "node_modules/use-sync-external-store/shim/index.js"(exports, module) { 498 "use strict"; 499 if (false) { 500 module.exports = null; 501 } else { 502 module.exports = require_use_sync_external_store_shim_development(); 503 } 504 } 505 }); 506 507 // node_modules/remove-accents/index.js 508 var require_remove_accents = __commonJS({ 509 "node_modules/remove-accents/index.js"(exports, module) { 510 var characterMap = { 511 "\xC0": "A", 512 "\xC1": "A", 513 "\xC2": "A", 514 "\xC3": "A", 515 "\xC4": "A", 516 "\xC5": "A", 517 "\u1EA4": "A", 518 "\u1EAE": "A", 519 "\u1EB2": "A", 520 "\u1EB4": "A", 521 "\u1EB6": "A", 522 "\xC6": "AE", 523 "\u1EA6": "A", 524 "\u1EB0": "A", 525 "\u0202": "A", 526 "\u1EA2": "A", 527 "\u1EA0": "A", 528 "\u1EA8": "A", 529 "\u1EAA": "A", 530 "\u1EAC": "A", 531 "\xC7": "C", 532 "\u1E08": "C", 533 "\xC8": "E", 534 "\xC9": "E", 535 "\xCA": "E", 536 "\xCB": "E", 537 "\u1EBE": "E", 538 "\u1E16": "E", 539 "\u1EC0": "E", 540 "\u1E14": "E", 541 "\u1E1C": "E", 542 "\u0206": "E", 543 "\u1EBA": "E", 544 "\u1EBC": "E", 545 "\u1EB8": "E", 546 "\u1EC2": "E", 547 "\u1EC4": "E", 548 "\u1EC6": "E", 549 "\xCC": "I", 550 "\xCD": "I", 551 "\xCE": "I", 552 "\xCF": "I", 553 "\u1E2E": "I", 554 "\u020A": "I", 555 "\u1EC8": "I", 556 "\u1ECA": "I", 557 "\xD0": "D", 558 "\xD1": "N", 559 "\xD2": "O", 560 "\xD3": "O", 561 "\xD4": "O", 562 "\xD5": "O", 563 "\xD6": "O", 564 "\xD8": "O", 565 "\u1ED0": "O", 566 "\u1E4C": "O", 567 "\u1E52": "O", 568 "\u020E": "O", 569 "\u1ECE": "O", 570 "\u1ECC": "O", 571 "\u1ED4": "O", 572 "\u1ED6": "O", 573 "\u1ED8": "O", 574 "\u1EDC": "O", 575 "\u1EDE": "O", 576 "\u1EE0": "O", 577 "\u1EDA": "O", 578 "\u1EE2": "O", 579 "\xD9": "U", 580 "\xDA": "U", 581 "\xDB": "U", 582 "\xDC": "U", 583 "\u1EE6": "U", 584 "\u1EE4": "U", 585 "\u1EEC": "U", 586 "\u1EEE": "U", 587 "\u1EF0": "U", 588 "\xDD": "Y", 589 "\xE0": "a", 590 "\xE1": "a", 591 "\xE2": "a", 592 "\xE3": "a", 593 "\xE4": "a", 594 "\xE5": "a", 595 "\u1EA5": "a", 596 "\u1EAF": "a", 597 "\u1EB3": "a", 598 "\u1EB5": "a", 599 "\u1EB7": "a", 600 "\xE6": "ae", 601 "\u1EA7": "a", 602 "\u1EB1": "a", 603 "\u0203": "a", 604 "\u1EA3": "a", 605 "\u1EA1": "a", 606 "\u1EA9": "a", 607 "\u1EAB": "a", 608 "\u1EAD": "a", 609 "\xE7": "c", 610 "\u1E09": "c", 611 "\xE8": "e", 612 "\xE9": "e", 613 "\xEA": "e", 614 "\xEB": "e", 615 "\u1EBF": "e", 616 "\u1E17": "e", 617 "\u1EC1": "e", 618 "\u1E15": "e", 619 "\u1E1D": "e", 620 "\u0207": "e", 621 "\u1EBB": "e", 622 "\u1EBD": "e", 623 "\u1EB9": "e", 624 "\u1EC3": "e", 625 "\u1EC5": "e", 626 "\u1EC7": "e", 627 "\xEC": "i", 628 "\xED": "i", 629 "\xEE": "i", 630 "\xEF": "i", 631 "\u1E2F": "i", 632 "\u020B": "i", 633 "\u1EC9": "i", 634 "\u1ECB": "i", 635 "\xF0": "d", 636 "\xF1": "n", 637 "\xF2": "o", 638 "\xF3": "o", 639 "\xF4": "o", 640 "\xF5": "o", 641 "\xF6": "o", 642 "\xF8": "o", 643 "\u1ED1": "o", 644 "\u1E4D": "o", 645 "\u1E53": "o", 646 "\u020F": "o", 647 "\u1ECF": "o", 648 "\u1ECD": "o", 649 "\u1ED5": "o", 650 "\u1ED7": "o", 651 "\u1ED9": "o", 652 "\u1EDD": "o", 653 "\u1EDF": "o", 654 "\u1EE1": "o", 655 "\u1EDB": "o", 656 "\u1EE3": "o", 657 "\xF9": "u", 658 "\xFA": "u", 659 "\xFB": "u", 660 "\xFC": "u", 661 "\u1EE7": "u", 662 "\u1EE5": "u", 663 "\u1EED": "u", 664 "\u1EEF": "u", 665 "\u1EF1": "u", 666 "\xFD": "y", 667 "\xFF": "y", 668 "\u0100": "A", 669 "\u0101": "a", 670 "\u0102": "A", 671 "\u0103": "a", 672 "\u0104": "A", 673 "\u0105": "a", 674 "\u0106": "C", 675 "\u0107": "c", 676 "\u0108": "C", 677 "\u0109": "c", 678 "\u010A": "C", 679 "\u010B": "c", 680 "\u010C": "C", 681 "\u010D": "c", 682 "C\u0306": "C", 683 "c\u0306": "c", 684 "\u010E": "D", 685 "\u010F": "d", 686 "\u0110": "D", 687 "\u0111": "d", 688 "\u0112": "E", 689 "\u0113": "e", 690 "\u0114": "E", 691 "\u0115": "e", 692 "\u0116": "E", 693 "\u0117": "e", 694 "\u0118": "E", 695 "\u0119": "e", 696 "\u011A": "E", 697 "\u011B": "e", 698 "\u011C": "G", 699 "\u01F4": "G", 700 "\u011D": "g", 701 "\u01F5": "g", 702 "\u011E": "G", 703 "\u011F": "g", 704 "\u0120": "G", 705 "\u0121": "g", 706 "\u0122": "G", 707 "\u0123": "g", 708 "\u0124": "H", 709 "\u0125": "h", 710 "\u0126": "H", 711 "\u0127": "h", 712 "\u1E2A": "H", 713 "\u1E2B": "h", 714 "\u0128": "I", 715 "\u0129": "i", 716 "\u012A": "I", 717 "\u012B": "i", 718 "\u012C": "I", 719 "\u012D": "i", 720 "\u012E": "I", 721 "\u012F": "i", 722 "\u0130": "I", 723 "\u0131": "i", 724 "\u0132": "IJ", 725 "\u0133": "ij", 726 "\u0134": "J", 727 "\u0135": "j", 728 "\u0136": "K", 729 "\u0137": "k", 730 "\u1E30": "K", 731 "\u1E31": "k", 732 "K\u0306": "K", 733 "k\u0306": "k", 734 "\u0139": "L", 735 "\u013A": "l", 736 "\u013B": "L", 737 "\u013C": "l", 738 "\u013D": "L", 739 "\u013E": "l", 740 "\u013F": "L", 741 "\u0140": "l", 742 "\u0141": "l", 743 "\u0142": "l", 744 "\u1E3E": "M", 745 "\u1E3F": "m", 746 "M\u0306": "M", 747 "m\u0306": "m", 748 "\u0143": "N", 749 "\u0144": "n", 750 "\u0145": "N", 751 "\u0146": "n", 752 "\u0147": "N", 753 "\u0148": "n", 754 "\u0149": "n", 755 "N\u0306": "N", 756 "n\u0306": "n", 757 "\u014C": "O", 758 "\u014D": "o", 759 "\u014E": "O", 760 "\u014F": "o", 761 "\u0150": "O", 762 "\u0151": "o", 763 "\u0152": "OE", 764 "\u0153": "oe", 765 "P\u0306": "P", 766 "p\u0306": "p", 767 "\u0154": "R", 768 "\u0155": "r", 769 "\u0156": "R", 770 "\u0157": "r", 771 "\u0158": "R", 772 "\u0159": "r", 773 "R\u0306": "R", 774 "r\u0306": "r", 775 "\u0212": "R", 776 "\u0213": "r", 777 "\u015A": "S", 778 "\u015B": "s", 779 "\u015C": "S", 780 "\u015D": "s", 781 "\u015E": "S", 782 "\u0218": "S", 783 "\u0219": "s", 784 "\u015F": "s", 785 "\u0160": "S", 786 "\u0161": "s", 787 "\u0162": "T", 788 "\u0163": "t", 789 "\u021B": "t", 790 "\u021A": "T", 791 "\u0164": "T", 792 "\u0165": "t", 793 "\u0166": "T", 794 "\u0167": "t", 795 "T\u0306": "T", 796 "t\u0306": "t", 797 "\u0168": "U", 798 "\u0169": "u", 799 "\u016A": "U", 800 "\u016B": "u", 801 "\u016C": "U", 802 "\u016D": "u", 803 "\u016E": "U", 804 "\u016F": "u", 805 "\u0170": "U", 806 "\u0171": "u", 807 "\u0172": "U", 808 "\u0173": "u", 809 "\u0216": "U", 810 "\u0217": "u", 811 "V\u0306": "V", 812 "v\u0306": "v", 813 "\u0174": "W", 814 "\u0175": "w", 815 "\u1E82": "W", 816 "\u1E83": "w", 817 "X\u0306": "X", 818 "x\u0306": "x", 819 "\u0176": "Y", 820 "\u0177": "y", 821 "\u0178": "Y", 822 "Y\u0306": "Y", 823 "y\u0306": "y", 824 "\u0179": "Z", 825 "\u017A": "z", 826 "\u017B": "Z", 827 "\u017C": "z", 828 "\u017D": "Z", 829 "\u017E": "z", 830 "\u017F": "s", 831 "\u0192": "f", 832 "\u01A0": "O", 833 "\u01A1": "o", 834 "\u01AF": "U", 835 "\u01B0": "u", 836 "\u01CD": "A", 837 "\u01CE": "a", 838 "\u01CF": "I", 839 "\u01D0": "i", 840 "\u01D1": "O", 841 "\u01D2": "o", 842 "\u01D3": "U", 843 "\u01D4": "u", 844 "\u01D5": "U", 845 "\u01D6": "u", 846 "\u01D7": "U", 847 "\u01D8": "u", 848 "\u01D9": "U", 849 "\u01DA": "u", 850 "\u01DB": "U", 851 "\u01DC": "u", 852 "\u1EE8": "U", 853 "\u1EE9": "u", 854 "\u1E78": "U", 855 "\u1E79": "u", 856 "\u01FA": "A", 857 "\u01FB": "a", 858 "\u01FC": "AE", 859 "\u01FD": "ae", 860 "\u01FE": "O", 861 "\u01FF": "o", 862 "\xDE": "TH", 863 "\xFE": "th", 864 "\u1E54": "P", 865 "\u1E55": "p", 866 "\u1E64": "S", 867 "\u1E65": "s", 868 "X\u0301": "X", 869 "x\u0301": "x", 870 "\u0403": "\u0413", 871 "\u0453": "\u0433", 872 "\u040C": "\u041A", 873 "\u045C": "\u043A", 874 "A\u030B": "A", 875 "a\u030B": "a", 876 "E\u030B": "E", 877 "e\u030B": "e", 878 "I\u030B": "I", 879 "i\u030B": "i", 880 "\u01F8": "N", 881 "\u01F9": "n", 882 "\u1ED2": "O", 883 "\u1ED3": "o", 884 "\u1E50": "O", 885 "\u1E51": "o", 886 "\u1EEA": "U", 887 "\u1EEB": "u", 888 "\u1E80": "W", 889 "\u1E81": "w", 890 "\u1EF2": "Y", 891 "\u1EF3": "y", 892 "\u0200": "A", 893 "\u0201": "a", 894 "\u0204": "E", 895 "\u0205": "e", 896 "\u0208": "I", 897 "\u0209": "i", 898 "\u020C": "O", 899 "\u020D": "o", 900 "\u0210": "R", 901 "\u0211": "r", 902 "\u0214": "U", 903 "\u0215": "u", 904 "B\u030C": "B", 905 "b\u030C": "b", 906 "\u010C\u0323": "C", 907 "\u010D\u0323": "c", 908 "\xCA\u030C": "E", 909 "\xEA\u030C": "e", 910 "F\u030C": "F", 911 "f\u030C": "f", 912 "\u01E6": "G", 913 "\u01E7": "g", 914 "\u021E": "H", 915 "\u021F": "h", 916 "J\u030C": "J", 917 "\u01F0": "j", 918 "\u01E8": "K", 919 "\u01E9": "k", 920 "M\u030C": "M", 921 "m\u030C": "m", 922 "P\u030C": "P", 923 "p\u030C": "p", 924 "Q\u030C": "Q", 925 "q\u030C": "q", 926 "\u0158\u0329": "R", 927 "\u0159\u0329": "r", 928 "\u1E66": "S", 929 "\u1E67": "s", 930 "V\u030C": "V", 931 "v\u030C": "v", 932 "W\u030C": "W", 933 "w\u030C": "w", 934 "X\u030C": "X", 935 "x\u030C": "x", 936 "Y\u030C": "Y", 937 "y\u030C": "y", 938 "A\u0327": "A", 939 "a\u0327": "a", 940 "B\u0327": "B", 941 "b\u0327": "b", 942 "\u1E10": "D", 943 "\u1E11": "d", 944 "\u0228": "E", 945 "\u0229": "e", 946 "\u0190\u0327": "E", 947 "\u025B\u0327": "e", 948 "\u1E28": "H", 949 "\u1E29": "h", 950 "I\u0327": "I", 951 "i\u0327": "i", 952 "\u0197\u0327": "I", 953 "\u0268\u0327": "i", 954 "M\u0327": "M", 955 "m\u0327": "m", 956 "O\u0327": "O", 957 "o\u0327": "o", 958 "Q\u0327": "Q", 959 "q\u0327": "q", 960 "U\u0327": "U", 961 "u\u0327": "u", 962 "X\u0327": "X", 963 "x\u0327": "x", 964 "Z\u0327": "Z", 965 "z\u0327": "z", 966 "\u0439": "\u0438", 967 "\u0419": "\u0418", 968 "\u0451": "\u0435", 969 "\u0401": "\u0415" 970 }; 971 var chars = Object.keys(characterMap).join("|"); 972 var allAccents = new RegExp(chars, "g"); 973 var firstAccent = new RegExp(chars, ""); 974 function matcher(match3) { 975 return characterMap[match3]; 976 } 977 var removeAccents3 = function(string) { 978 return string.replace(allAccents, matcher); 979 }; 980 var hasAccents = function(string) { 981 return !!string.match(firstAccent); 982 }; 983 module.exports = removeAccents3; 984 module.exports.has = hasAccents; 985 module.exports.remove = removeAccents3; 986 } 987 }); 988 989 // package-external:@wordpress/warning 990 var require_warning = __commonJS({ 991 "package-external:@wordpress/warning"(exports, module) { 992 module.exports = window.wp.warning; 993 } 994 }); 995 996 // packages/edit-site/build-module/index.js 997 var index_exports = {}; 998 __export(index_exports, { 999 PluginMoreMenuItem: () => PluginMoreMenuItem, 1000 PluginSidebar: () => PluginSidebar, 1001 PluginSidebarMoreMenuItem: () => PluginSidebarMoreMenuItem, 1002 PluginTemplateSettingPanel: () => plugin_template_setting_panel_default, 1003 initializeEditor: () => initializeEditor, 1004 reinitializeEditor: () => reinitializeEditor, 1005 store: () => store 1006 }); 1007 var import_blocks15 = __toESM(require_blocks()); 1008 var import_block_library2 = __toESM(require_block_library()); 1009 var import_data83 = __toESM(require_data()); 1010 var import_deprecated6 = __toESM(require_deprecated()); 1011 var import_element154 = __toESM(require_element()); 1012 var import_editor44 = __toESM(require_editor()); 1013 var import_preferences13 = __toESM(require_preferences()); 1014 var import_widgets = __toESM(require_widgets()); 1015 1016 // packages/edit-site/build-module/store/index.js 1017 var import_data3 = __toESM(require_data()); 1018 1019 // packages/edit-site/build-module/store/reducer.js 1020 var import_data = __toESM(require_data()); 1021 function settings(state = {}, action) { 1022 switch (action.type) { 1023 case "UPDATE_SETTINGS": 1024 return { 1025 ...state, 1026 ...action.settings 1027 }; 1028 } 1029 return state; 1030 } 1031 function editedPost(state = {}, action) { 1032 switch (action.type) { 1033 case "SET_EDITED_POST": 1034 return { 1035 postType: action.postType, 1036 id: action.id, 1037 context: action.context 1038 }; 1039 case "SET_EDITED_POST_CONTEXT": 1040 return { 1041 ...state, 1042 context: action.context 1043 }; 1044 } 1045 return state; 1046 } 1047 function saveViewPanel(state = false, action) { 1048 switch (action.type) { 1049 case "SET_IS_SAVE_VIEW_OPENED": 1050 return action.isOpen; 1051 } 1052 return state; 1053 } 1054 function routes(state = [], action) { 1055 switch (action.type) { 1056 case "REGISTER_ROUTE": 1057 return [...state, action.route]; 1058 case "UNREGISTER_ROUTE": 1059 return state.filter((route) => route.name !== action.name); 1060 } 1061 return state; 1062 } 1063 var reducer_default = (0, import_data.combineReducers)({ 1064 settings, 1065 editedPost, 1066 saveViewPanel, 1067 routes 1068 }); 1069 1070 // packages/edit-site/build-module/store/actions.js 1071 var actions_exports = {}; 1072 __export(actions_exports, { 1073 __experimentalSetPreviewDeviceType: () => __experimentalSetPreviewDeviceType, 1074 addTemplate: () => addTemplate, 1075 closeGeneralSidebar: () => closeGeneralSidebar, 1076 openGeneralSidebar: () => openGeneralSidebar, 1077 openNavigationPanelToMenu: () => openNavigationPanelToMenu, 1078 removeTemplate: () => removeTemplate, 1079 revertTemplate: () => revertTemplate, 1080 setEditedEntity: () => setEditedEntity, 1081 setEditedPostContext: () => setEditedPostContext, 1082 setHasPageContentFocus: () => setHasPageContentFocus, 1083 setHomeTemplateId: () => setHomeTemplateId, 1084 setIsInserterOpened: () => setIsInserterOpened, 1085 setIsListViewOpened: () => setIsListViewOpened, 1086 setIsNavigationPanelOpened: () => setIsNavigationPanelOpened, 1087 setIsSaveViewOpened: () => setIsSaveViewOpened, 1088 setNavigationMenu: () => setNavigationMenu, 1089 setNavigationPanelActiveMenu: () => setNavigationPanelActiveMenu, 1090 setPage: () => setPage, 1091 setTemplate: () => setTemplate, 1092 setTemplatePart: () => setTemplatePart, 1093 switchEditorMode: () => switchEditorMode, 1094 toggleDistractionFree: () => toggleDistractionFree, 1095 toggleFeature: () => toggleFeature, 1096 updateSettings: () => updateSettings 1097 }); 1098 var import_blocks = __toESM(require_blocks()); 1099 var import_deprecated = __toESM(require_deprecated()); 1100 var import_core_data = __toESM(require_core_data()); 1101 var import_block_editor = __toESM(require_block_editor()); 1102 var import_editor = __toESM(require_editor()); 1103 var import_preferences = __toESM(require_preferences()); 1104 1105 // packages/edit-site/build-module/utils/constants.js 1106 var import_i18n = __toESM(require_i18n()); 1107 var import_patterns = __toESM(require_patterns()); 1108 1109 // packages/edit-site/build-module/lock-unlock.js 1110 var import_private_apis = __toESM(require_private_apis()); 1111 var { lock, unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)( 1112 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.", 1113 "@wordpress/edit-site" 1114 ); 1115 1116 // packages/edit-site/build-module/utils/constants.js 1117 var NAVIGATION_POST_TYPE = "wp_navigation"; 1118 var TEMPLATE_POST_TYPE = "wp_template"; 1119 var TEMPLATE_PART_POST_TYPE = "wp_template_part"; 1120 var TEMPLATE_ORIGINS = { 1121 custom: "custom", 1122 theme: "theme", 1123 plugin: "plugin" 1124 }; 1125 var TEMPLATE_PART_AREA_DEFAULT_CATEGORY = "uncategorized"; 1126 var TEMPLATE_PART_ALL_AREAS_CATEGORY = "all-parts"; 1127 var { 1128 PATTERN_TYPES, 1129 PATTERN_DEFAULT_CATEGORY, 1130 PATTERN_USER_CATEGORY, 1131 EXCLUDED_PATTERN_SOURCES, 1132 PATTERN_SYNC_TYPES 1133 } = unlock(import_patterns.privateApis); 1134 var FOCUSABLE_ENTITIES = [ 1135 TEMPLATE_PART_POST_TYPE, 1136 NAVIGATION_POST_TYPE, 1137 PATTERN_TYPES.user 1138 ]; 1139 var POST_TYPE_LABELS = { 1140 [TEMPLATE_POST_TYPE]: (0, import_i18n.__)("Template"), 1141 [TEMPLATE_PART_POST_TYPE]: (0, import_i18n.__)("Template part"), 1142 [PATTERN_TYPES.user]: (0, import_i18n.__)("Pattern"), 1143 [NAVIGATION_POST_TYPE]: (0, import_i18n.__)("Navigation") 1144 }; 1145 var LAYOUT_GRID = "grid"; 1146 var LAYOUT_TABLE = "table"; 1147 var LAYOUT_LIST = "list"; 1148 var OPERATOR_IS = "is"; 1149 var OPERATOR_IS_ANY = "isAny"; 1150 var OPERATOR_IS_NONE = "isNone"; 1151 var OPERATOR_BEFORE = "before"; 1152 var OPERATOR_AFTER = "after"; 1153 1154 // packages/edit-site/build-module/store/actions.js 1155 var { interfaceStore } = unlock(import_editor.privateApis); 1156 function toggleFeature(featureName) { 1157 return function({ registry }) { 1158 (0, import_deprecated.default)( 1159 "dispatch( 'core/edit-site' ).toggleFeature( featureName )", 1160 { 1161 since: "6.0", 1162 alternative: "dispatch( 'core/preferences').toggle( 'core/edit-site', featureName )" 1163 } 1164 ); 1165 registry.dispatch(import_preferences.store).toggle("core/edit-site", featureName); 1166 }; 1167 } 1168 var __experimentalSetPreviewDeviceType = (deviceType) => ({ registry }) => { 1169 (0, import_deprecated.default)( 1170 "dispatch( 'core/edit-site' ).__experimentalSetPreviewDeviceType", 1171 { 1172 since: "6.5", 1173 version: "6.7", 1174 hint: "registry.dispatch( editorStore ).setDeviceType" 1175 } 1176 ); 1177 registry.dispatch(import_editor.store).setDeviceType(deviceType); 1178 }; 1179 function setTemplate() { 1180 (0, import_deprecated.default)("dispatch( 'core/edit-site' ).setTemplate", { 1181 since: "6.5", 1182 version: "6.8", 1183 hint: "The setTemplate is not needed anymore, the correct entity is resolved from the URL automatically." 1184 }); 1185 return { 1186 type: "NOTHING" 1187 }; 1188 } 1189 var addTemplate = (template) => async ({ dispatch: dispatch2, registry }) => { 1190 (0, import_deprecated.default)("dispatch( 'core/edit-site' ).addTemplate", { 1191 since: "6.5", 1192 version: "6.8", 1193 hint: "use saveEntityRecord directly" 1194 }); 1195 const newTemplate = await registry.dispatch(import_core_data.store).saveEntityRecord("postType", TEMPLATE_POST_TYPE, template); 1196 if (template.content) { 1197 registry.dispatch(import_core_data.store).editEntityRecord( 1198 "postType", 1199 TEMPLATE_POST_TYPE, 1200 newTemplate.id, 1201 { blocks: (0, import_blocks.parse)(template.content) }, 1202 { undoIgnore: true } 1203 ); 1204 } 1205 dispatch2({ 1206 type: "SET_EDITED_POST", 1207 postType: TEMPLATE_POST_TYPE, 1208 id: newTemplate.id 1209 }); 1210 }; 1211 var removeTemplate = (template) => ({ registry }) => { 1212 return unlock(registry.dispatch(import_editor.store)).removeTemplates([ 1213 template 1214 ]); 1215 }; 1216 function setTemplatePart(templatePartId) { 1217 (0, import_deprecated.default)("dispatch( 'core/edit-site' ).setTemplatePart", { 1218 since: "6.8" 1219 }); 1220 return { 1221 type: "SET_EDITED_POST", 1222 postType: TEMPLATE_PART_POST_TYPE, 1223 id: templatePartId 1224 }; 1225 } 1226 function setNavigationMenu(navigationMenuId) { 1227 (0, import_deprecated.default)("dispatch( 'core/edit-site' ).setNavigationMenu", { 1228 since: "6.8" 1229 }); 1230 return { 1231 type: "SET_EDITED_POST", 1232 postType: NAVIGATION_POST_TYPE, 1233 id: navigationMenuId 1234 }; 1235 } 1236 function setEditedEntity(postType2, postId, context) { 1237 return { 1238 type: "SET_EDITED_POST", 1239 postType: postType2, 1240 id: postId, 1241 context 1242 }; 1243 } 1244 function setHomeTemplateId() { 1245 (0, import_deprecated.default)("dispatch( 'core/edit-site' ).setHomeTemplateId", { 1246 since: "6.2", 1247 version: "6.4" 1248 }); 1249 return { 1250 type: "NOTHING" 1251 }; 1252 } 1253 function setEditedPostContext(context) { 1254 (0, import_deprecated.default)("dispatch( 'core/edit-site' ).setEditedPostContext", { 1255 since: "6.8" 1256 }); 1257 return { 1258 type: "SET_EDITED_POST_CONTEXT", 1259 context 1260 }; 1261 } 1262 function setPage() { 1263 (0, import_deprecated.default)("dispatch( 'core/edit-site' ).setPage", { 1264 since: "6.5", 1265 version: "6.8", 1266 hint: "The setPage is not needed anymore, the correct entity is resolved from the URL automatically." 1267 }); 1268 return { type: "NOTHING" }; 1269 } 1270 function setNavigationPanelActiveMenu() { 1271 (0, import_deprecated.default)("dispatch( 'core/edit-site' ).setNavigationPanelActiveMenu", { 1272 since: "6.2", 1273 version: "6.4" 1274 }); 1275 return { type: "NOTHING" }; 1276 } 1277 function openNavigationPanelToMenu() { 1278 (0, import_deprecated.default)("dispatch( 'core/edit-site' ).openNavigationPanelToMenu", { 1279 since: "6.2", 1280 version: "6.4" 1281 }); 1282 return { type: "NOTHING" }; 1283 } 1284 function setIsNavigationPanelOpened() { 1285 (0, import_deprecated.default)("dispatch( 'core/edit-site' ).setIsNavigationPanelOpened", { 1286 since: "6.2", 1287 version: "6.4" 1288 }); 1289 return { type: "NOTHING" }; 1290 } 1291 var setIsInserterOpened = (value) => ({ registry }) => { 1292 (0, import_deprecated.default)("dispatch( 'core/edit-site' ).setIsInserterOpened", { 1293 since: "6.5", 1294 alternative: "dispatch( 'core/editor').setIsInserterOpened" 1295 }); 1296 registry.dispatch(import_editor.store).setIsInserterOpened(value); 1297 }; 1298 var setIsListViewOpened = (isOpen) => ({ registry }) => { 1299 (0, import_deprecated.default)("dispatch( 'core/edit-site' ).setIsListViewOpened", { 1300 since: "6.5", 1301 alternative: "dispatch( 'core/editor').setIsListViewOpened" 1302 }); 1303 registry.dispatch(import_editor.store).setIsListViewOpened(isOpen); 1304 }; 1305 function updateSettings(settings2) { 1306 return { 1307 type: "UPDATE_SETTINGS", 1308 settings: settings2 1309 }; 1310 } 1311 function setIsSaveViewOpened(isOpen) { 1312 return { 1313 type: "SET_IS_SAVE_VIEW_OPENED", 1314 isOpen 1315 }; 1316 } 1317 var revertTemplate = (template, options) => ({ registry }) => { 1318 return unlock(registry.dispatch(import_editor.store)).revertTemplate( 1319 template, 1320 options 1321 ); 1322 }; 1323 var openGeneralSidebar = (name2) => ({ registry }) => { 1324 registry.dispatch(interfaceStore).enableComplementaryArea("core", name2); 1325 }; 1326 var closeGeneralSidebar = () => ({ registry }) => { 1327 registry.dispatch(interfaceStore).disableComplementaryArea("core"); 1328 }; 1329 var switchEditorMode = (mode) => ({ registry }) => { 1330 (0, import_deprecated.default)("dispatch( 'core/edit-site' ).switchEditorMode", { 1331 since: "6.6", 1332 alternative: "dispatch( 'core/editor').switchEditorMode" 1333 }); 1334 registry.dispatch(import_editor.store).switchEditorMode(mode); 1335 }; 1336 var setHasPageContentFocus = (hasPageContentFocus2) => ({ dispatch: dispatch2, registry }) => { 1337 (0, import_deprecated.default)(`dispatch( 'core/edit-site' ).setHasPageContentFocus`, { 1338 since: "6.5" 1339 }); 1340 if (hasPageContentFocus2) { 1341 registry.dispatch(import_block_editor.store).clearSelectedBlock(); 1342 } 1343 dispatch2({ 1344 type: "SET_HAS_PAGE_CONTENT_FOCUS", 1345 hasPageContentFocus: hasPageContentFocus2 1346 }); 1347 }; 1348 var toggleDistractionFree = () => ({ registry }) => { 1349 (0, import_deprecated.default)("dispatch( 'core/edit-site' ).toggleDistractionFree", { 1350 since: "6.6", 1351 alternative: "dispatch( 'core/editor').toggleDistractionFree" 1352 }); 1353 registry.dispatch(import_editor.store).toggleDistractionFree(); 1354 }; 1355 1356 // packages/edit-site/build-module/store/private-actions.js 1357 var private_actions_exports = {}; 1358 __export(private_actions_exports, { 1359 registerRoute: () => registerRoute, 1360 unregisterRoute: () => unregisterRoute 1361 }); 1362 function registerRoute(route) { 1363 return { 1364 type: "REGISTER_ROUTE", 1365 route 1366 }; 1367 } 1368 function unregisterRoute(name2) { 1369 return { 1370 type: "UNREGISTER_ROUTE", 1371 name: name2 1372 }; 1373 } 1374 1375 // packages/edit-site/build-module/store/selectors.js 1376 var selectors_exports = {}; 1377 __export(selectors_exports, { 1378 __experimentalGetInsertionPoint: () => __experimentalGetInsertionPoint, 1379 __experimentalGetPreviewDeviceType: () => __experimentalGetPreviewDeviceType, 1380 getCanUserCreateMedia: () => getCanUserCreateMedia, 1381 getCurrentTemplateNavigationPanelSubMenu: () => getCurrentTemplateNavigationPanelSubMenu, 1382 getCurrentTemplateTemplateParts: () => getCurrentTemplateTemplateParts, 1383 getEditedPostContext: () => getEditedPostContext, 1384 getEditedPostId: () => getEditedPostId, 1385 getEditedPostType: () => getEditedPostType, 1386 getEditorMode: () => getEditorMode, 1387 getHomeTemplateId: () => getHomeTemplateId, 1388 getNavigationPanelActiveMenu: () => getNavigationPanelActiveMenu, 1389 getPage: () => getPage, 1390 getReusableBlocks: () => getReusableBlocks, 1391 getSettings: () => getSettings, 1392 hasPageContentFocus: () => hasPageContentFocus, 1393 isFeatureActive: () => isFeatureActive, 1394 isInserterOpened: () => isInserterOpened, 1395 isListViewOpened: () => isListViewOpened, 1396 isNavigationOpened: () => isNavigationOpened, 1397 isPage: () => isPage, 1398 isSaveViewOpened: () => isSaveViewOpened 1399 }); 1400 var import_core_data2 = __toESM(require_core_data()); 1401 var import_data2 = __toESM(require_data()); 1402 var import_deprecated2 = __toESM(require_deprecated()); 1403 var import_element = __toESM(require_element()); 1404 var import_preferences2 = __toESM(require_preferences()); 1405 var import_editor2 = __toESM(require_editor()); 1406 var import_block_editor2 = __toESM(require_block_editor()); 1407 1408 // packages/edit-site/build-module/utils/get-filtered-template-parts.js 1409 var import_blocks2 = __toESM(require_blocks()); 1410 var EMPTY_ARRAY = []; 1411 function getFilteredTemplatePartBlocks(blocks = EMPTY_ARRAY, templateParts) { 1412 const templatePartsById = templateParts ? ( 1413 // Key template parts by their ID. 1414 templateParts.reduce( 1415 (newTemplateParts, part) => ({ 1416 ...newTemplateParts, 1417 [part.id]: part 1418 }), 1419 {} 1420 ) 1421 ) : {}; 1422 const result = []; 1423 const stack = [...blocks]; 1424 while (stack.length) { 1425 const { innerBlocks, ...block } = stack.shift(); 1426 stack.unshift(...innerBlocks); 1427 if ((0, import_blocks2.isTemplatePart)(block)) { 1428 const { 1429 attributes: { theme, slug } 1430 } = block; 1431 const templatePartId = `$theme}//${slug}`; 1432 const templatePart = templatePartsById[templatePartId]; 1433 if (templatePart) { 1434 result.push({ 1435 templatePart, 1436 block 1437 }); 1438 } 1439 } 1440 } 1441 return result; 1442 } 1443 1444 // packages/edit-site/build-module/store/selectors.js 1445 var isFeatureActive = (0, import_data2.createRegistrySelector)( 1446 (select3) => (_, featureName) => { 1447 (0, import_deprecated2.default)(`select( 'core/edit-site' ).isFeatureActive`, { 1448 since: "6.0", 1449 alternative: `select( 'core/preferences' ).get` 1450 }); 1451 return !!select3(import_preferences2.store).get( 1452 "core/edit-site", 1453 featureName 1454 ); 1455 } 1456 ); 1457 var __experimentalGetPreviewDeviceType = (0, import_data2.createRegistrySelector)( 1458 (select3) => () => { 1459 (0, import_deprecated2.default)( 1460 `select( 'core/edit-site' ).__experimentalGetPreviewDeviceType`, 1461 { 1462 since: "6.5", 1463 version: "6.7", 1464 alternative: `select( 'core/editor' ).getDeviceType` 1465 } 1466 ); 1467 return select3(import_editor2.store).getDeviceType(); 1468 } 1469 ); 1470 var getCanUserCreateMedia = (0, import_data2.createRegistrySelector)( 1471 (select3) => () => { 1472 (0, import_deprecated2.default)( 1473 `wp.data.select( 'core/edit-site' ).getCanUserCreateMedia()`, 1474 { 1475 since: "6.7", 1476 alternative: `wp.data.select( 'core' ).canUser( 'create', { kind: 'postType', type: 'attachment' } )` 1477 } 1478 ); 1479 return select3(import_core_data2.store).canUser("create", "media"); 1480 } 1481 ); 1482 var getReusableBlocks = (0, import_data2.createRegistrySelector)((select3) => () => { 1483 (0, import_deprecated2.default)(`select( 'core/edit-site' ).getReusableBlocks()`, { 1484 since: "6.5", 1485 version: "6.8", 1486 alternative: `select( 'core/core' ).getEntityRecords( 'postType', 'wp_block' )` 1487 }); 1488 const isWeb = import_element.Platform.OS === "web"; 1489 return isWeb ? select3(import_core_data2.store).getEntityRecords("postType", "wp_block", { 1490 per_page: -1 1491 }) : []; 1492 }); 1493 function getSettings(state) { 1494 return state.settings; 1495 } 1496 function getHomeTemplateId() { 1497 (0, import_deprecated2.default)("select( 'core/edit-site' ).getHomeTemplateId", { 1498 since: "6.2", 1499 version: "6.4" 1500 }); 1501 } 1502 function getEditedPostType(state) { 1503 (0, import_deprecated2.default)("select( 'core/edit-site' ).getEditedPostType", { 1504 since: "6.8", 1505 alternative: "select( 'core/editor' ).getCurrentPostType" 1506 }); 1507 return state.editedPost.postType; 1508 } 1509 function getEditedPostId(state) { 1510 (0, import_deprecated2.default)("select( 'core/edit-site' ).getEditedPostId", { 1511 since: "6.8", 1512 alternative: "select( 'core/editor' ).getCurrentPostId" 1513 }); 1514 return state.editedPost.id; 1515 } 1516 function getEditedPostContext(state) { 1517 (0, import_deprecated2.default)("select( 'core/edit-site' ).getEditedPostContext", { 1518 since: "6.8" 1519 }); 1520 return state.editedPost.context; 1521 } 1522 function getPage(state) { 1523 (0, import_deprecated2.default)("select( 'core/edit-site' ).getPage", { 1524 since: "6.8" 1525 }); 1526 return { context: state.editedPost.context }; 1527 } 1528 var isInserterOpened = (0, import_data2.createRegistrySelector)((select3) => () => { 1529 (0, import_deprecated2.default)(`select( 'core/edit-site' ).isInserterOpened`, { 1530 since: "6.5", 1531 alternative: `select( 'core/editor' ).isInserterOpened` 1532 }); 1533 return select3(import_editor2.store).isInserterOpened(); 1534 }); 1535 var __experimentalGetInsertionPoint = (0, import_data2.createRegistrySelector)( 1536 (select3) => () => { 1537 (0, import_deprecated2.default)( 1538 `select( 'core/edit-site' ).__experimentalGetInsertionPoint`, 1539 { 1540 since: "6.5", 1541 version: "6.7" 1542 } 1543 ); 1544 return unlock(select3(import_editor2.store)).getInserter(); 1545 } 1546 ); 1547 var isListViewOpened = (0, import_data2.createRegistrySelector)((select3) => () => { 1548 (0, import_deprecated2.default)(`select( 'core/edit-site' ).isListViewOpened`, { 1549 since: "6.5", 1550 alternative: `select( 'core/editor' ).isListViewOpened` 1551 }); 1552 return select3(import_editor2.store).isListViewOpened(); 1553 }); 1554 function isSaveViewOpened(state) { 1555 return state.saveViewPanel; 1556 } 1557 function getBlocksAndTemplateParts(select3) { 1558 const templateParts = select3(import_core_data2.store).getEntityRecords( 1559 "postType", 1560 TEMPLATE_PART_POST_TYPE, 1561 { per_page: -1 } 1562 ); 1563 const { getBlocksByName, getBlocksByClientId } = select3(import_block_editor2.store); 1564 const clientIds = getBlocksByName("core/template-part"); 1565 const blocks = getBlocksByClientId(clientIds); 1566 return [blocks, templateParts]; 1567 } 1568 var getCurrentTemplateTemplateParts = (0, import_data2.createRegistrySelector)( 1569 (select3) => (0, import_data2.createSelector)( 1570 () => { 1571 (0, import_deprecated2.default)( 1572 `select( 'core/edit-site' ).getCurrentTemplateTemplateParts()`, 1573 { 1574 since: "6.7", 1575 version: "6.9", 1576 alternative: `select( 'core/block-editor' ).getBlocksByName( 'core/template-part' )` 1577 } 1578 ); 1579 return getFilteredTemplatePartBlocks( 1580 ...getBlocksAndTemplateParts(select3) 1581 ); 1582 }, 1583 () => getBlocksAndTemplateParts(select3) 1584 ) 1585 ); 1586 var getEditorMode = (0, import_data2.createRegistrySelector)((select3) => () => { 1587 return select3(import_preferences2.store).get("core", "editorMode"); 1588 }); 1589 function getCurrentTemplateNavigationPanelSubMenu() { 1590 (0, import_deprecated2.default)( 1591 "dispatch( 'core/edit-site' ).getCurrentTemplateNavigationPanelSubMenu", 1592 { 1593 since: "6.2", 1594 version: "6.4" 1595 } 1596 ); 1597 } 1598 function getNavigationPanelActiveMenu() { 1599 (0, import_deprecated2.default)("dispatch( 'core/edit-site' ).getNavigationPanelActiveMenu", { 1600 since: "6.2", 1601 version: "6.4" 1602 }); 1603 } 1604 function isNavigationOpened() { 1605 (0, import_deprecated2.default)("dispatch( 'core/edit-site' ).isNavigationOpened", { 1606 since: "6.2", 1607 version: "6.4" 1608 }); 1609 } 1610 function isPage(state) { 1611 (0, import_deprecated2.default)("select( 'core/edit-site' ).isPage", { 1612 since: "6.8", 1613 alternative: "select( 'core/editor' ).getCurrentPostType" 1614 }); 1615 return !!state.editedPost.context?.postId; 1616 } 1617 function hasPageContentFocus() { 1618 (0, import_deprecated2.default)(`select( 'core/edit-site' ).hasPageContentFocus`, { 1619 since: "6.5" 1620 }); 1621 return false; 1622 } 1623 1624 // packages/edit-site/build-module/store/private-selectors.js 1625 var private_selectors_exports = {}; 1626 __export(private_selectors_exports, { 1627 getRoutes: () => getRoutes 1628 }); 1629 function getRoutes(state) { 1630 return state.routes; 1631 } 1632 1633 // packages/edit-site/build-module/store/constants.js 1634 var STORE_NAME = "core/edit-site"; 1635 1636 // packages/edit-site/build-module/store/index.js 1637 var storeConfig = { 1638 reducer: reducer_default, 1639 actions: actions_exports, 1640 selectors: selectors_exports 1641 }; 1642 var store = (0, import_data3.createReduxStore)(STORE_NAME, storeConfig); 1643 (0, import_data3.register)(store); 1644 unlock(store).registerPrivateSelectors(private_selectors_exports); 1645 unlock(store).registerPrivateActions(private_actions_exports); 1646 1647 // packages/edit-site/build-module/components/app/index.js 1648 var import_data82 = __toESM(require_data()); 1649 var import_router41 = __toESM(require_router()); 1650 var import_element153 = __toESM(require_element()); 1651 var import_core_data65 = __toESM(require_core_data()); 1652 1653 // node_modules/clsx/dist/clsx.mjs 1654 function r(e2) { 1655 var t3, f2, n2 = ""; 1656 if ("string" == typeof e2 || "number" == typeof e2) n2 += e2; 1657 else if ("object" == typeof e2) if (Array.isArray(e2)) { 1658 var o3 = e2.length; 1659 for (t3 = 0; t3 < o3; t3++) e2[t3] && (f2 = r(e2[t3])) && (n2 && (n2 += " "), n2 += f2); 1660 } else for (f2 in e2) e2[f2] && (n2 && (n2 += " "), n2 += f2); 1661 return n2; 1662 } 1663 function clsx() { 1664 for (var e2, t3, f2 = 0, n2 = "", o3 = arguments.length; f2 < o3; f2++) (e2 = arguments[f2]) && (t3 = r(e2)) && (n2 && (n2 += " "), n2 += t3); 1665 return n2; 1666 } 1667 var clsx_default = clsx; 1668 1669 // packages/admin-ui/build-module/navigable-region/index.js 1670 var import_element2 = __toESM(require_element()); 1671 var import_jsx_runtime = __toESM(require_jsx_runtime()); 1672 var NavigableRegion = (0, import_element2.forwardRef)( 1673 ({ children, className, ariaLabel, as: Tag = "div", ...props }, ref) => { 1674 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)( 1675 Tag, 1676 { 1677 ref, 1678 className: clsx_default("admin-ui-navigable-region", className), 1679 "aria-label": ariaLabel, 1680 role: "region", 1681 tabIndex: "-1", 1682 ...props, 1683 children 1684 } 1685 ); 1686 } 1687 ); 1688 NavigableRegion.displayName = "NavigableRegion"; 1689 var navigable_region_default = NavigableRegion; 1690 1691 // packages/admin-ui/build-module/page/header.js 1692 var import_components2 = __toESM(require_components()); 1693 1694 // packages/admin-ui/build-module/page/sidebar-toggle-slot.js 1695 var import_components = __toESM(require_components()); 1696 var { Fill: SidebarToggleFill, Slot: SidebarToggleSlot } = (0, import_components.createSlotFill)("SidebarToggle"); 1697 1698 // packages/admin-ui/build-module/page/header.js 1699 var import_jsx_runtime2 = __toESM(require_jsx_runtime()); 1700 function Header({ 1701 breadcrumbs, 1702 badges, 1703 title, 1704 subTitle, 1705 actions, 1706 showSidebarToggle = true 1707 }) { 1708 return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_components2.__experimentalVStack, { className: "admin-ui-page__header", as: "header", children: [ 1709 /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_components2.__experimentalHStack, { justify: "space-between", spacing: 2, children: [ 1710 /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_components2.__experimentalHStack, { spacing: 2, justify: "left", children: [ 1711 showSidebarToggle && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)( 1712 SidebarToggleSlot, 1713 { 1714 bubblesVirtually: true, 1715 className: "admin-ui-page__sidebar-toggle-slot" 1716 } 1717 ), 1718 title && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_components2.__experimentalHeading, { as: "h2", level: 3, weight: 500, truncate: true, children: title }), 1719 breadcrumbs, 1720 badges 1721 ] }), 1722 /* @__PURE__ */ (0, import_jsx_runtime2.jsx)( 1723 import_components2.__experimentalHStack, 1724 { 1725 style: { width: "auto", flexShrink: 0 }, 1726 spacing: 2, 1727 className: "admin-ui-page__header-actions", 1728 children: actions 1729 } 1730 ) 1731 ] }), 1732 subTitle && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "admin-ui-page__header-subtitle", children: subTitle }) 1733 ] }); 1734 } 1735 1736 // packages/admin-ui/build-module/page/index.js 1737 var import_jsx_runtime3 = __toESM(require_jsx_runtime()); 1738 function Page({ 1739 breadcrumbs, 1740 badges, 1741 title, 1742 subTitle, 1743 children, 1744 className, 1745 actions, 1746 hasPadding = false, 1747 showSidebarToggle = true 1748 }) { 1749 const classes = clsx_default("admin-ui-page", className); 1750 return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(navigable_region_default, { className: classes, ariaLabel: title, children: [ 1751 (title || breadcrumbs || badges) && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)( 1752 Header, 1753 { 1754 breadcrumbs, 1755 badges, 1756 title, 1757 subTitle, 1758 actions, 1759 showSidebarToggle 1760 } 1761 ), 1762 hasPadding ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "admin-ui-page__content has-padding", children }) : children 1763 ] }); 1764 } 1765 Page.SidebarToggleFill = SidebarToggleFill; 1766 var page_default = Page; 1767 1768 // packages/edit-site/build-module/components/layout/index.js 1769 var import_components9 = __toESM(require_components()); 1770 var import_compose2 = __toESM(require_compose()); 1771 var import_i18n8 = __toESM(require_i18n()); 1772 var import_element12 = __toESM(require_element()); 1773 var import_editor6 = __toESM(require_editor()); 1774 var import_router6 = __toESM(require_router()); 1775 var import_plugins2 = __toESM(require_plugins()); 1776 var import_notices = __toESM(require_notices()); 1777 var import_data13 = __toESM(require_data()); 1778 var import_preferences3 = __toESM(require_preferences()); 1779 1780 // packages/edit-site/build-module/components/site-hub/index.js 1781 var import_data5 = __toESM(require_data()); 1782 var import_components4 = __toESM(require_components()); 1783 var import_i18n3 = __toESM(require_i18n()); 1784 var import_core_data4 = __toESM(require_core_data()); 1785 var import_html_entities = __toESM(require_html_entities()); 1786 var import_element5 = __toESM(require_element()); 1787 1788 // packages/icons/build-module/icon/index.js 1789 var import_element3 = __toESM(require_element()); 1790 var icon_default = (0, import_element3.forwardRef)( 1791 ({ icon, size = 24, ...props }, ref) => { 1792 return (0, import_element3.cloneElement)(icon, { 1793 width: size, 1794 height: size, 1795 ...props, 1796 ref 1797 }); 1798 } 1799 ); 1800 1801 // packages/icons/build-module/library/archive.js 1802 var import_primitives = __toESM(require_primitives()); 1803 var import_jsx_runtime4 = __toESM(require_jsx_runtime()); 1804 var archive_default = /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_primitives.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)( 1805 import_primitives.Path, 1806 { 1807 fillRule: "evenodd", 1808 clipRule: "evenodd", 1809 d: "M11.934 7.406a1 1 0 0 0 .914.594H19a.5.5 0 0 1 .5.5v9a.5.5 0 0 1-.5.5H5a.5.5 0 0 1-.5-.5V6a.5.5 0 0 1 .5-.5h5.764a.5.5 0 0 1 .447.276l.723 1.63Zm1.064-1.216a.5.5 0 0 0 .462.31H19a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h5.764a2 2 0 0 1 1.789 1.106l.445 1.084ZM8.5 10.5h7V12h-7v-1.5Zm7 3.5h-7v1.5h7V14Z" 1810 } 1811 ) }); 1812 1813 // packages/icons/build-module/library/arrow-down.js 1814 var import_primitives2 = __toESM(require_primitives()); 1815 var import_jsx_runtime5 = __toESM(require_jsx_runtime()); 1816 var arrow_down_default = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_primitives2.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_primitives2.Path, { d: "m16.5 13.5-3.7 3.7V4h-1.5v13.2l-3.8-3.7-1 1 5.5 5.6 5.5-5.6z" }) }); 1817 1818 // packages/icons/build-module/library/arrow-left.js 1819 var import_primitives3 = __toESM(require_primitives()); 1820 var import_jsx_runtime6 = __toESM(require_jsx_runtime()); 1821 var arrow_left_default = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_primitives3.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_primitives3.Path, { d: "M20 11.2H6.8l3.7-3.7-1-1L3.9 12l5.6 5.5 1-1-3.7-3.7H20z" }) }); 1822 1823 // packages/icons/build-module/library/arrow-right.js 1824 var import_primitives4 = __toESM(require_primitives()); 1825 var import_jsx_runtime7 = __toESM(require_jsx_runtime()); 1826 var arrow_right_default = /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_primitives4.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_primitives4.Path, { d: "m14.5 6.5-1 1 3.7 3.7H4v1.6h13.2l-3.7 3.7 1 1 5.6-5.5z" }) }); 1827 1828 // packages/icons/build-module/library/arrow-up-left.js 1829 var import_primitives5 = __toESM(require_primitives()); 1830 var import_jsx_runtime8 = __toESM(require_jsx_runtime()); 1831 var arrow_up_left_default = /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_primitives5.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_primitives5.Path, { d: "M14 6H6v8h1.5V8.5L17 18l1-1-9.5-9.5H14V6Z" }) }); 1832 1833 // packages/icons/build-module/library/arrow-up.js 1834 var import_primitives6 = __toESM(require_primitives()); 1835 var import_jsx_runtime9 = __toESM(require_jsx_runtime()); 1836 var arrow_up_default = /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_primitives6.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_primitives6.Path, { d: "M12 3.9 6.5 9.5l1 1 3.8-3.7V20h1.5V6.8l3.7 3.7 1-1z" }) }); 1837 1838 // packages/icons/build-module/library/backup.js 1839 var import_primitives7 = __toESM(require_primitives()); 1840 var import_jsx_runtime10 = __toESM(require_jsx_runtime()); 1841 var backup_default = /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_primitives7.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_primitives7.Path, { d: "M5.5 12h1.75l-2.5 3-2.5-3H4a8 8 0 113.134 6.35l.907-1.194A6.5 6.5 0 105.5 12zm9.53 1.97l-2.28-2.28V8.5a.75.75 0 00-1.5 0V12a.747.747 0 00.218.529l1.282-.84-1.28.842 2.5 2.5a.75.75 0 101.06-1.061z" }) }); 1842 1843 // packages/icons/build-module/library/block-meta.js 1844 var import_primitives8 = __toESM(require_primitives()); 1845 var import_jsx_runtime11 = __toESM(require_jsx_runtime()); 1846 var block_meta_default = /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_primitives8.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)( 1847 import_primitives8.Path, 1848 { 1849 fillRule: "evenodd", 1850 d: "M8.95 11.25H4v1.5h4.95v4.5H13V18c0 1.1.9 2 2 2h3c1.1 0 2-.9 2-2v-3c0-1.1-.9-2-2-2h-3c-1.1 0-2 .9-2 2v.75h-2.55v-7.5H13V9c0 1.1.9 2 2 2h3c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2h-3c-1.1 0-2 .9-2 2v.75H8.95v4.5ZM14.5 15v3c0 .3.2.5.5.5h3c.3 0 .5-.2.5-.5v-3c0-.3-.2-.5-.5-.5h-3c-.3 0-.5.2-.5.5Zm0-6V6c0-.3.2-.5.5-.5h3c.3 0 .5.2.5.5v3c0 .3-.2.5-.5.5h-3c-.3 0-.5-.2-.5-.5Z", 1851 clipRule: "evenodd" 1852 } 1853 ) }); 1854 1855 // packages/icons/build-module/library/block-table.js 1856 var import_primitives9 = __toESM(require_primitives()); 1857 var import_jsx_runtime12 = __toESM(require_jsx_runtime()); 1858 var block_table_default = /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_primitives9.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_primitives9.Path, { d: "M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM5 4.5h14c.3 0 .5.2.5.5v3.5h-15V5c0-.3.2-.5.5-.5zm8 5.5h6.5v3.5H13V10zm-1.5 3.5h-7V10h7v3.5zm-7 5.5v-4h7v4.5H5c-.3 0-.5-.2-.5-.5zm14.5.5h-6V15h6.5v4c0 .3-.2.5-.5.5z" }) }); 1859 1860 // packages/icons/build-module/library/calendar.js 1861 var import_primitives10 = __toESM(require_primitives()); 1862 var import_jsx_runtime13 = __toESM(require_jsx_runtime()); 1863 var calendar_default = /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_primitives10.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_primitives10.Path, { d: "M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm.5 16c0 .3-.2.5-.5.5H5c-.3 0-.5-.2-.5-.5V7h15v12zM9 10H7v2h2v-2zm0 4H7v2h2v-2zm4-4h-2v2h2v-2zm4 0h-2v2h2v-2zm-4 4h-2v2h2v-2zm4 0h-2v2h2v-2z" }) }); 1864 1865 // packages/icons/build-module/library/category.js 1866 var import_primitives11 = __toESM(require_primitives()); 1867 var import_jsx_runtime14 = __toESM(require_jsx_runtime()); 1868 var category_default = /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_primitives11.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)( 1869 import_primitives11.Path, 1870 { 1871 d: "M6 5.5h3a.5.5 0 01.5.5v3a.5.5 0 01-.5.5H6a.5.5 0 01-.5-.5V6a.5.5 0 01.5-.5zM4 6a2 2 0 012-2h3a2 2 0 012 2v3a2 2 0 01-2 2H6a2 2 0 01-2-2V6zm11-.5h3a.5.5 0 01.5.5v3a.5.5 0 01-.5.5h-3a.5.5 0 01-.5-.5V6a.5.5 0 01.5-.5zM13 6a2 2 0 012-2h3a2 2 0 012 2v3a2 2 0 01-2 2h-3a2 2 0 01-2-2V6zm5 8.5h-3a.5.5 0 00-.5.5v3a.5.5 0 00.5.5h3a.5.5 0 00.5-.5v-3a.5.5 0 00-.5-.5zM15 13a2 2 0 00-2 2v3a2 2 0 002 2h3a2 2 0 002-2v-3a2 2 0 00-2-2h-3zm-9 1.5h3a.5.5 0 01.5.5v3a.5.5 0 01-.5.5H6a.5.5 0 01-.5-.5v-3a.5.5 0 01.5-.5zM4 15a2 2 0 012-2h3a2 2 0 012 2v3a2 2 0 01-2 2H6a2 2 0 01-2-2v-3z", 1872 fillRule: "evenodd", 1873 clipRule: "evenodd" 1874 } 1875 ) }); 1876 1877 // packages/icons/build-module/library/check.js 1878 var import_primitives12 = __toESM(require_primitives()); 1879 var import_jsx_runtime15 = __toESM(require_jsx_runtime()); 1880 var check_default = /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_primitives12.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_primitives12.Path, { d: "M16.5 7.5 10 13.9l-2.5-2.4-1 1 3.5 3.6 7.5-7.6z" }) }); 1881 1882 // packages/icons/build-module/library/chevron-down.js 1883 var import_primitives13 = __toESM(require_primitives()); 1884 var import_jsx_runtime16 = __toESM(require_jsx_runtime()); 1885 var chevron_down_default = /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_primitives13.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_primitives13.Path, { d: "M17.5 11.6L12 16l-5.5-4.4.9-1.2L12 14l4.5-3.6 1 1.2z" }) }); 1886 1887 // packages/icons/build-module/library/chevron-left-small.js 1888 var import_primitives14 = __toESM(require_primitives()); 1889 var import_jsx_runtime17 = __toESM(require_jsx_runtime()); 1890 var chevron_left_small_default = /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_primitives14.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_primitives14.Path, { d: "m13.1 16-3.4-4 3.4-4 1.1 1-2.6 3 2.6 3-1.1 1z" }) }); 1891 1892 // packages/icons/build-module/library/chevron-left.js 1893 var import_primitives15 = __toESM(require_primitives()); 1894 var import_jsx_runtime18 = __toESM(require_jsx_runtime()); 1895 var chevron_left_default = /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_primitives15.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_primitives15.Path, { d: "M14.6 7l-1.2-1L8 12l5.4 6 1.2-1-4.6-5z" }) }); 1896 1897 // packages/icons/build-module/library/chevron-right-small.js 1898 var import_primitives16 = __toESM(require_primitives()); 1899 var import_jsx_runtime19 = __toESM(require_jsx_runtime()); 1900 var chevron_right_small_default = /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_primitives16.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_primitives16.Path, { d: "M10.8622 8.04053L14.2805 12.0286L10.8622 16.0167L9.72327 15.0405L12.3049 12.0286L9.72327 9.01672L10.8622 8.04053Z" }) }); 1901 1902 // packages/icons/build-module/library/chevron-right.js 1903 var import_primitives17 = __toESM(require_primitives()); 1904 var import_jsx_runtime20 = __toESM(require_jsx_runtime()); 1905 var chevron_right_default = /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_primitives17.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_primitives17.Path, { d: "M10.6 6L9.4 7l4.6 5-4.6 5 1.2 1 5.4-6z" }) }); 1906 1907 // packages/icons/build-module/library/chevron-up.js 1908 var import_primitives18 = __toESM(require_primitives()); 1909 var import_jsx_runtime21 = __toESM(require_jsx_runtime()); 1910 var chevron_up_default = /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_primitives18.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_primitives18.Path, { d: "M6.5 12.4L12 8l5.5 4.4-.9 1.2L12 10l-4.5 3.6-1-1.2z" }) }); 1911 1912 // packages/icons/build-module/library/close-small.js 1913 var import_primitives19 = __toESM(require_primitives()); 1914 var import_jsx_runtime22 = __toESM(require_jsx_runtime()); 1915 var close_small_default = /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_primitives19.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_primitives19.Path, { d: "M12 13.06l3.712 3.713 1.061-1.06L13.061 12l3.712-3.712-1.06-1.06L12 10.938 8.288 7.227l-1.061 1.06L10.939 12l-3.712 3.712 1.06 1.061L12 13.061z" }) }); 1916 1917 // packages/icons/build-module/library/cog.js 1918 var import_primitives20 = __toESM(require_primitives()); 1919 var import_jsx_runtime23 = __toESM(require_jsx_runtime()); 1920 var cog_default = /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_primitives20.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)( 1921 import_primitives20.Path, 1922 { 1923 fillRule: "evenodd", 1924 d: "M10.289 4.836A1 1 0 0111.275 4h1.306a1 1 0 01.987.836l.244 1.466c.787.26 1.503.679 2.108 1.218l1.393-.522a1 1 0 011.216.437l.653 1.13a1 1 0 01-.23 1.273l-1.148.944a6.025 6.025 0 010 2.435l1.149.946a1 1 0 01.23 1.272l-.653 1.13a1 1 0 01-1.216.437l-1.394-.522c-.605.54-1.32.958-2.108 1.218l-.244 1.466a1 1 0 01-.987.836h-1.306a1 1 0 01-.986-.836l-.244-1.466a5.995 5.995 0 01-2.108-1.218l-1.394.522a1 1 0 01-1.217-.436l-.653-1.131a1 1 0 01.23-1.272l1.149-.946a6.026 6.026 0 010-2.435l-1.148-.944a1 1 0 01-.23-1.272l.653-1.131a1 1 0 011.217-.437l1.393.522a5.994 5.994 0 012.108-1.218l.244-1.466zM14.929 12a3 3 0 11-6 0 3 3 0 016 0z", 1925 clipRule: "evenodd" 1926 } 1927 ) }); 1928 1929 // packages/icons/build-module/library/comment-author-avatar.js 1930 var import_primitives21 = __toESM(require_primitives()); 1931 var import_jsx_runtime24 = __toESM(require_jsx_runtime()); 1932 var comment_author_avatar_default = /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_primitives21.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)( 1933 import_primitives21.Path, 1934 { 1935 fillRule: "evenodd", 1936 d: "M7.25 16.437a6.5 6.5 0 1 1 9.5 0V16A2.75 2.75 0 0 0 14 13.25h-4A2.75 2.75 0 0 0 7.25 16v.437Zm1.5 1.193a6.47 6.47 0 0 0 3.25.87 6.47 6.47 0 0 0 3.25-.87V16c0-.69-.56-1.25-1.25-1.25h-4c-.69 0-1.25.56-1.25 1.25v1.63ZM4 12a8 8 0 1 1 16 0 8 8 0 0 1-16 0Zm10-2a2 2 0 1 1-4 0 2 2 0 0 1 4 0Z", 1937 clipRule: "evenodd" 1938 } 1939 ) }); 1940 1941 // packages/icons/build-module/library/download.js 1942 var import_primitives22 = __toESM(require_primitives()); 1943 var import_jsx_runtime25 = __toESM(require_jsx_runtime()); 1944 var download_default = /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_primitives22.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_primitives22.Path, { d: "M18 11.3l-1-1.1-4 4V3h-1.5v11.3L7 10.2l-1 1.1 6.2 5.8 5.8-5.8zm.5 3.7v3.5h-13V15H4v5h16v-5h-1.5z" }) }); 1945 1946 // packages/icons/build-module/library/drafts.js 1947 var import_primitives23 = __toESM(require_primitives()); 1948 var import_jsx_runtime26 = __toESM(require_jsx_runtime()); 1949 var drafts_default = /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_primitives23.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)( 1950 import_primitives23.Path, 1951 { 1952 fillRule: "evenodd", 1953 clipRule: "evenodd", 1954 d: "M12 18.5a6.5 6.5 0 1 1 0-13 6.5 6.5 0 0 1 0 13ZM4 12a8 8 0 1 1 16 0 8 8 0 0 1-16 0Zm8 4a4 4 0 0 0 4-4H8a4 4 0 0 0 4 4Z" 1955 } 1956 ) }); 1957 1958 // packages/icons/build-module/library/drawer-right.js 1959 var import_primitives24 = __toESM(require_primitives()); 1960 var import_jsx_runtime27 = __toESM(require_jsx_runtime()); 1961 var drawer_right_default = /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_primitives24.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)( 1962 import_primitives24.Path, 1963 { 1964 fillRule: "evenodd", 1965 clipRule: "evenodd", 1966 d: "M18 4H6c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm-4 14.5H6c-.3 0-.5-.2-.5-.5V6c0-.3.2-.5.5-.5h8v13zm4.5-.5c0 .3-.2.5-.5.5h-2.5v-13H18c.3 0 .5.2.5.5v12z" 1967 } 1968 ) }); 1969 1970 // packages/icons/build-module/library/envelope.js 1971 var import_primitives25 = __toESM(require_primitives()); 1972 var import_jsx_runtime28 = __toESM(require_jsx_runtime()); 1973 var envelope_default = /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_primitives25.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)( 1974 import_primitives25.Path, 1975 { 1976 fillRule: "evenodd", 1977 clipRule: "evenodd", 1978 d: "M3 7c0-1.1.9-2 2-2h14a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7Zm2-.5h14c.3 0 .5.2.5.5v1L12 13.5 4.5 7.9V7c0-.3.2-.5.5-.5Zm-.5 3.3V17c0 .3.2.5.5.5h14c.3 0 .5-.2.5-.5V9.8L12 15.4 4.5 9.8Z" 1979 } 1980 ) }); 1981 1982 // packages/icons/build-module/library/error.js 1983 var import_primitives26 = __toESM(require_primitives()); 1984 var import_jsx_runtime29 = __toESM(require_jsx_runtime()); 1985 var error_default = /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_primitives26.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)( 1986 import_primitives26.Path, 1987 { 1988 fillRule: "evenodd", 1989 clipRule: "evenodd", 1990 d: "M12.218 5.377a.25.25 0 0 0-.436 0l-7.29 12.96a.25.25 0 0 0 .218.373h14.58a.25.25 0 0 0 .218-.372l-7.29-12.96Zm-1.743-.735c.669-1.19 2.381-1.19 3.05 0l7.29 12.96a1.75 1.75 0 0 1-1.525 2.608H4.71a1.75 1.75 0 0 1-1.525-2.608l7.29-12.96ZM12.75 17.46h-1.5v-1.5h1.5v1.5Zm-1.5-3h1.5v-5h-1.5v5Z" 1991 } 1992 ) }); 1993 1994 // packages/icons/build-module/library/file.js 1995 var import_primitives27 = __toESM(require_primitives()); 1996 var import_jsx_runtime30 = __toESM(require_jsx_runtime()); 1997 var file_default = /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_primitives27.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)( 1998 import_primitives27.Path, 1999 { 2000 fillRule: "evenodd", 2001 clipRule: "evenodd", 2002 d: "M12.848 8a1 1 0 0 1-.914-.594l-.723-1.63a.5.5 0 0 0-.447-.276H5a.5.5 0 0 0-.5.5v11.5a.5.5 0 0 0 .5.5h14a.5.5 0 0 0 .5-.5v-9A.5.5 0 0 0 19 8h-6.152Zm.612-1.5a.5.5 0 0 1-.462-.31l-.445-1.084A2 2 0 0 0 10.763 4H5a2 2 0 0 0-2 2v11.5a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-9a2 2 0 0 0-2-2h-5.54Z" 2003 } 2004 ) }); 2005 2006 // packages/icons/build-module/library/format-list-bullets-rtl.js 2007 var import_primitives28 = __toESM(require_primitives()); 2008 var import_jsx_runtime31 = __toESM(require_jsx_runtime()); 2009 var format_list_bullets_rtl_default = /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_primitives28.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_primitives28.Path, { d: "M4 8.8h8.9V7.2H4v1.6zm0 7h8.9v-1.5H4v1.5zM18 13c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0-3c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2z" }) }); 2010 2011 // packages/icons/build-module/library/format-list-bullets.js 2012 var import_primitives29 = __toESM(require_primitives()); 2013 var import_jsx_runtime32 = __toESM(require_jsx_runtime()); 2014 var format_list_bullets_default = /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_primitives29.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_primitives29.Path, { d: "M11.1 15.8H20v-1.5h-8.9v1.5zm0-8.6v1.5H20V7.2h-8.9zM6 13c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0-7c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z" }) }); 2015 2016 // packages/icons/build-module/library/funnel.js 2017 var import_primitives30 = __toESM(require_primitives()); 2018 var import_jsx_runtime33 = __toESM(require_jsx_runtime()); 2019 var funnel_default = /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_primitives30.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_primitives30.Path, { d: "M10 17.5H14V16H10V17.5ZM6 6V7.5H18V6H6ZM8 12.5H16V11H8V12.5Z" }) }); 2020 2021 // packages/icons/build-module/library/globe.js 2022 var import_primitives31 = __toESM(require_primitives()); 2023 var import_jsx_runtime34 = __toESM(require_jsx_runtime()); 2024 var globe_default = /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_primitives31.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_primitives31.Path, { d: "M12 4c-4.4 0-8 3.6-8 8s3.6 8 8 8 8-3.6 8-8-3.6-8-8-8Zm6.5 8c0 .6 0 1.2-.2 1.8h-2.7c0-.6.2-1.1.2-1.8s0-1.2-.2-1.8h2.7c.2.6.2 1.1.2 1.8Zm-.9-3.2h-2.4c-.3-.9-.7-1.8-1.1-2.4-.1-.2-.2-.4-.3-.5 1.6.5 3 1.6 3.8 3ZM12.8 17c-.3.5-.6 1-.8 1.3-.2-.3-.5-.8-.8-1.3-.3-.5-.6-1.1-.8-1.7h3.3c-.2.6-.5 1.2-.8 1.7Zm-2.9-3.2c-.1-.6-.2-1.1-.2-1.8s0-1.2.2-1.8H14c.1.6.2 1.1.2 1.8s0 1.2-.2 1.8H9.9ZM11.2 7c.3-.5.6-1 .8-1.3.2.3.5.8.8 1.3.3.5.6 1.1.8 1.7h-3.3c.2-.6.5-1.2.8-1.7Zm-1-1.2c-.1.2-.2.3-.3.5-.4.7-.8 1.5-1.1 2.4H6.4c.8-1.4 2.2-2.5 3.8-3Zm-1.8 8H5.7c-.2-.6-.2-1.1-.2-1.8s0-1.2.2-1.8h2.7c0 .6-.2 1.1-.2 1.8s0 1.2.2 1.8Zm-2 1.4h2.4c.3.9.7 1.8 1.1 2.4.1.2.2.4.3.5-1.6-.5-3-1.6-3.8-3Zm7.4 3c.1-.2.2-.3.3-.5.4-.7.8-1.5 1.1-2.4h2.4c-.8 1.4-2.2 2.5-3.8 3Z" }) }); 2025 2026 // packages/icons/build-module/library/help.js 2027 var import_primitives32 = __toESM(require_primitives()); 2028 var import_jsx_runtime35 = __toESM(require_jsx_runtime()); 2029 var help_default = /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_primitives32.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_primitives32.Path, { d: "M12 4a8 8 0 1 1 .001 16.001A8 8 0 0 1 12 4Zm0 1.5a6.5 6.5 0 1 0-.001 13.001A6.5 6.5 0 0 0 12 5.5Zm.75 11h-1.5V15h1.5v1.5Zm-.445-9.234a3 3 0 0 1 .445 5.89V14h-1.5v-1.25c0-.57.452-.958.917-1.01A1.5 1.5 0 0 0 12 8.75a1.5 1.5 0 0 0-1.5 1.5H9a3 3 0 0 1 3.305-2.984Z" }) }); 2030 2031 // packages/icons/build-module/library/home.js 2032 var import_primitives33 = __toESM(require_primitives()); 2033 var import_jsx_runtime36 = __toESM(require_jsx_runtime()); 2034 var home_default = /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_primitives33.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_primitives33.Path, { d: "M12 4L4 7.9V20h16V7.9L12 4zm6.5 14.5H14V13h-4v5.5H5.5V8.8L12 5.7l6.5 3.1v9.7z" }) }); 2035 2036 // packages/icons/build-module/library/layout.js 2037 var import_primitives34 = __toESM(require_primitives()); 2038 var import_jsx_runtime37 = __toESM(require_jsx_runtime()); 2039 var layout_default = /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_primitives34.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_primitives34.Path, { d: "M18 5.5H6a.5.5 0 00-.5.5v3h13V6a.5.5 0 00-.5-.5zm.5 5H10v8h8a.5.5 0 00.5-.5v-7.5zm-10 0h-3V18a.5.5 0 00.5.5h2.5v-8zM6 4h12a2 2 0 012 2v12a2 2 0 01-2 2H6a2 2 0 01-2-2V6a2 2 0 012-2z" }) }); 2040 2041 // packages/icons/build-module/library/link.js 2042 var import_primitives35 = __toESM(require_primitives()); 2043 var import_jsx_runtime38 = __toESM(require_jsx_runtime()); 2044 var link_default = /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_primitives35.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_primitives35.Path, { d: "M10 17.389H8.444A5.194 5.194 0 1 1 8.444 7H10v1.5H8.444a3.694 3.694 0 0 0 0 7.389H10v1.5ZM14 7h1.556a5.194 5.194 0 0 1 0 10.39H14v-1.5h1.556a3.694 3.694 0 0 0 0-7.39H14V7Zm-4.5 6h5v-1.5h-5V13Z" }) }); 2045 2046 // packages/icons/build-module/library/list.js 2047 var import_primitives36 = __toESM(require_primitives()); 2048 var import_jsx_runtime39 = __toESM(require_jsx_runtime()); 2049 var list_default = /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_primitives36.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_primitives36.Path, { d: "M4 4v1.5h16V4H4zm8 8.5h8V11h-8v1.5zM4 20h16v-1.5H4V20zm4-8c0-1.1-.9-2-2-2s-2 .9-2 2 .9 2 2 2 2-.9 2-2z" }) }); 2050 2051 // packages/icons/build-module/library/media.js 2052 var import_primitives37 = __toESM(require_primitives()); 2053 var import_jsx_runtime40 = __toESM(require_jsx_runtime()); 2054 var media_default = /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(import_primitives37.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: [ 2055 /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_primitives37.Path, { d: "m7 6.5 4 2.5-4 2.5z" }), 2056 /* @__PURE__ */ (0, import_jsx_runtime40.jsx)( 2057 import_primitives37.Path, 2058 { 2059 fillRule: "evenodd", 2060 clipRule: "evenodd", 2061 d: "m5 3c-1.10457 0-2 .89543-2 2v14c0 1.1046.89543 2 2 2h14c1.1046 0 2-.8954 2-2v-14c0-1.10457-.8954-2-2-2zm14 1.5h-14c-.27614 0-.5.22386-.5.5v10.7072l3.62953-2.6465c.25108-.1831.58905-.1924.84981-.0234l2.92666 1.8969 3.5712-3.4719c.2911-.2831.7545-.2831 1.0456 0l2.9772 2.8945v-9.3568c0-.27614-.2239-.5-.5-.5zm-14.5 14.5v-1.4364l4.09643-2.987 2.99567 1.9417c.2936.1903.6798.1523.9307-.0917l3.4772-3.3806 3.4772 3.3806.0228-.0234v2.5968c0 .2761-.2239.5-.5.5h-14c-.27614 0-.5-.2239-.5-.5z" 2062 } 2063 ) 2064 ] }); 2065 2066 // packages/icons/build-module/library/mobile.js 2067 var import_primitives38 = __toESM(require_primitives()); 2068 var import_jsx_runtime41 = __toESM(require_jsx_runtime()); 2069 var mobile_default = /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(import_primitives38.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(import_primitives38.Path, { d: "M15 4H9c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h6c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm.5 14c0 .3-.2.5-.5.5H9c-.3 0-.5-.2-.5-.5V6c0-.3.2-.5.5-.5h6c.3 0 .5.2.5.5v12zm-4.5-.5h2V16h-2v1.5z" }) }); 2070 2071 // packages/icons/build-module/library/more-vertical.js 2072 var import_primitives39 = __toESM(require_primitives()); 2073 var import_jsx_runtime42 = __toESM(require_jsx_runtime()); 2074 var more_vertical_default = /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_primitives39.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_primitives39.Path, { d: "M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z" }) }); 2075 2076 // packages/icons/build-module/library/navigation.js 2077 var import_primitives40 = __toESM(require_primitives()); 2078 var import_jsx_runtime43 = __toESM(require_jsx_runtime()); 2079 var navigation_default = /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_primitives40.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_primitives40.Path, { d: "M12 4c-4.4 0-8 3.6-8 8s3.6 8 8 8 8-3.6 8-8-3.6-8-8-8zm0 14.5c-3.6 0-6.5-2.9-6.5-6.5S8.4 5.5 12 5.5s6.5 2.9 6.5 6.5-2.9 6.5-6.5 6.5zM9 16l4.5-3L15 8.4l-4.5 3L9 16z" }) }); 2080 2081 // packages/icons/build-module/library/next.js 2082 var import_primitives41 = __toESM(require_primitives()); 2083 var import_jsx_runtime44 = __toESM(require_jsx_runtime()); 2084 var next_default = /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_primitives41.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_primitives41.Path, { d: "M6.6 6L5.4 7l4.5 5-4.5 5 1.1 1 5.5-6-5.4-6zm6 0l-1.1 1 4.5 5-4.5 5 1.1 1 5.5-6-5.5-6z" }) }); 2085 2086 // packages/icons/build-module/library/not-allowed.js 2087 var import_primitives42 = __toESM(require_primitives()); 2088 var import_jsx_runtime45 = __toESM(require_jsx_runtime()); 2089 var not_allowed_default = /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_primitives42.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)( 2090 import_primitives42.Path, 2091 { 2092 fillRule: "evenodd", 2093 clipRule: "evenodd", 2094 d: "M12 18.5A6.5 6.5 0 0 1 6.93 7.931l9.139 9.138A6.473 6.473 0 0 1 12 18.5Zm5.123-2.498a6.5 6.5 0 0 0-9.124-9.124l9.124 9.124ZM4 12a8 8 0 1 1 16 0 8 8 0 0 1-16 0Z" 2095 } 2096 ) }); 2097 2098 // packages/icons/build-module/library/not-found.js 2099 var import_primitives43 = __toESM(require_primitives()); 2100 var import_jsx_runtime46 = __toESM(require_jsx_runtime()); 2101 var not_found_default = /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_primitives43.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_primitives43.Path, { d: "M19 5c1.1 0 2 .9 2 2v10c0 1.1-.9 2-2 2H5c-1.1 0-2-.9-2-2V7c0-1.1.9-2 2-2zM5 6.5c-.3 0-.5.2-.5.5v10c0 .3.2.5.5.5h14c.3 0 .5-.2.5-.5V7c0-.3-.2-.5-.5-.5zm7.01 2.75q.711 0 1.24.364.533.364.824 1.012.296.645.296 1.488 0 .887-.296 1.556-.292.664-.824 1.036-.528.368-1.24.368-.708 0-1.24-.368-.527-.372-.824-1.036-.296-.668-.296-1.556 0-.848.296-1.492.296-.648.824-1.008a2.14 2.14 0 0 1 1.24-.364m-3.484 3.6h.72v.832h-.72v1.28h-.984v-1.28H4.75l3.08-4.32h.696zm9.522 0h.72v.832h-.72v1.28h-.983v-1.28h-2.793l3.08-4.32h.696zm-6.038-2.696q-.568 0-.952.48-.384.475-.384 1.48 0 .716.176 1.168.176.45.476.66.304.212.684.212t.68-.208q.304-.207.48-.656.176-.451.176-1.176 0-.996-.384-1.476-.38-.484-.952-.484M6.33 12.85h1.212v-1.722zm9.523 0h1.211v-1.722z" }) }); 2102 2103 // packages/icons/build-module/library/page.js 2104 var import_primitives44 = __toESM(require_primitives()); 2105 var import_jsx_runtime47 = __toESM(require_jsx_runtime()); 2106 var page_default2 = /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(import_primitives44.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: [ 2107 /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(import_primitives44.Path, { d: "M15.5 7.5h-7V9h7V7.5Zm-7 3.5h7v1.5h-7V11Zm7 3.5h-7V16h7v-1.5Z" }), 2108 /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(import_primitives44.Path, { d: "M17 4H7a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2ZM7 5.5h10a.5.5 0 0 1 .5.5v12a.5.5 0 0 1-.5.5H7a.5.5 0 0 1-.5-.5V6a.5.5 0 0 1 .5-.5Z" }) 2109 ] }); 2110 2111 // packages/icons/build-module/library/pages.js 2112 var import_primitives45 = __toESM(require_primitives()); 2113 var import_jsx_runtime48 = __toESM(require_jsx_runtime()); 2114 var pages_default = /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(import_primitives45.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: [ 2115 /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_primitives45.Path, { d: "M14.5 5.5h-7V7h7V5.5ZM7.5 9h7v1.5h-7V9Zm7 3.5h-7V14h7v-1.5Z" }), 2116 /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_primitives45.Path, { d: "M16 2H6a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2ZM6 3.5h10a.5.5 0 0 1 .5.5v12a.5.5 0 0 1-.5.5H6a.5.5 0 0 1-.5-.5V4a.5.5 0 0 1 .5-.5Z" }), 2117 /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_primitives45.Path, { d: "M20 8v11c0 .69-.31 1-.999 1H6v1.5h13.001c1.52 0 2.499-.982 2.499-2.5V8H20Z" }) 2118 ] }); 2119 2120 // packages/icons/build-module/library/pencil.js 2121 var import_primitives46 = __toESM(require_primitives()); 2122 var import_jsx_runtime49 = __toESM(require_jsx_runtime()); 2123 var pencil_default = /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(import_primitives46.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(import_primitives46.Path, { d: "m19 7-3-3-8.5 8.5-1 4 4-1L19 7Zm-7 11.5H5V20h7v-1.5Z" }) }); 2124 2125 // packages/icons/build-module/library/pending.js 2126 var import_primitives47 = __toESM(require_primitives()); 2127 var import_jsx_runtime50 = __toESM(require_jsx_runtime()); 2128 var pending_default = /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_primitives47.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)( 2129 import_primitives47.Path, 2130 { 2131 fillRule: "evenodd", 2132 clipRule: "evenodd", 2133 d: "M12 18.5a6.5 6.5 0 1 1 0-13 6.5 6.5 0 0 1 0 13ZM4 12a8 8 0 1 1 16 0 8 8 0 0 1-16 0Zm8 4a4 4 0 0 1-4-4h4V8a4 4 0 0 1 0 8Z" 2134 } 2135 ) }); 2136 2137 // packages/icons/build-module/library/pin.js 2138 var import_primitives48 = __toESM(require_primitives()); 2139 var import_jsx_runtime51 = __toESM(require_jsx_runtime()); 2140 var pin_default = /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_primitives48.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_primitives48.Path, { d: "m21.5 9.1-6.6-6.6-4.2 5.6c-1.2-.1-2.4.1-3.6.7-.1 0-.1.1-.2.1-.5.3-.9.6-1.2.9l3.7 3.7-5.7 5.7v1.1h1.1l5.7-5.7 3.7 3.7c.4-.4.7-.8.9-1.2.1-.1.1-.2.2-.3.6-1.1.8-2.4.6-3.6l5.6-4.1zm-7.3 3.5.1.9c.1.9 0 1.8-.4 2.6l-6-6c.8-.4 1.7-.5 2.6-.4l.9.1L15 4.9 19.1 9l-4.9 3.6z" }) }); 2141 2142 // packages/icons/build-module/library/plugins.js 2143 var import_primitives49 = __toESM(require_primitives()); 2144 var import_jsx_runtime52 = __toESM(require_jsx_runtime()); 2145 var plugins_default = /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_primitives49.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_primitives49.Path, { d: "M10.5 4v4h3V4H15v4h1.5a1 1 0 011 1v4l-3 4v2a1 1 0 01-1 1h-3a1 1 0 01-1-1v-2l-3-4V9a1 1 0 011-1H9V4h1.5zm.5 12.5v2h2v-2l3-4v-3H8v3l3 4z" }) }); 2146 2147 // packages/icons/build-module/library/post.js 2148 var import_primitives50 = __toESM(require_primitives()); 2149 var import_jsx_runtime53 = __toESM(require_jsx_runtime()); 2150 var post_default = /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_primitives50.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_primitives50.Path, { d: "m7.3 9.7 1.4 1.4c.2-.2.3-.3.4-.5 0 0 0-.1.1-.1.3-.5.4-1.1.3-1.6L12 7 9 4 7.2 6.5c-.6-.1-1.1 0-1.6.3 0 0-.1 0-.1.1-.3.1-.4.2-.6.4l1.4 1.4L4 11v1h1l2.3-2.3zM4 20h9v-1.5H4V20zm0-5.5V16h16v-1.5H4z" }) }); 2151 2152 // packages/icons/build-module/library/previous.js 2153 var import_primitives51 = __toESM(require_primitives()); 2154 var import_jsx_runtime54 = __toESM(require_jsx_runtime()); 2155 var previous_default = /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_primitives51.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_primitives51.Path, { d: "M11.6 7l-1.1-1L5 12l5.5 6 1.1-1L7 12l4.6-5zm6 0l-1.1-1-5.5 6 5.5 6 1.1-1-4.6-5 4.6-5z" }) }); 2156 2157 // packages/icons/build-module/library/published.js 2158 var import_primitives52 = __toESM(require_primitives()); 2159 var import_jsx_runtime55 = __toESM(require_jsx_runtime()); 2160 var published_default = /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(import_primitives52.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)( 2161 import_primitives52.Path, 2162 { 2163 fillRule: "evenodd", 2164 clipRule: "evenodd", 2165 d: "M12 18.5a6.5 6.5 0 1 1 0-13 6.5 6.5 0 0 1 0 13ZM4 12a8 8 0 1 1 16 0 8 8 0 0 1-16 0Zm11.53-1.47-1.06-1.06L11 12.94l-1.47-1.47-1.06 1.06L11 15.06l4.53-4.53Z" 2166 } 2167 ) }); 2168 2169 // packages/icons/build-module/library/rotate-left.js 2170 var import_primitives53 = __toESM(require_primitives()); 2171 var import_jsx_runtime56 = __toESM(require_jsx_runtime()); 2172 var rotate_left_default = /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(import_primitives53.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(import_primitives53.Path, { d: "M12 4V2.2L9 4.8l3 2.5V5.5c3.6 0 6.5 2.9 6.5 6.5 0 2.9-1.9 5.3-4.5 6.2v.2l-.1-.2c-.4.1-.7.2-1.1.2l.2 1.5c.3 0 .6-.1 1-.2 3.5-.9 6-4 6-7.7 0-4.4-3.6-8-8-8zm-7.9 7l1.5.2c.1-1.2.5-2.3 1.2-3.2l-1.1-.9C4.8 8.2 4.3 9.6 4.1 11zm1.5 1.8l-1.5.2c.1.7.3 1.4.5 2 .3.7.6 1.3 1 1.8l1.2-.8c-.3-.5-.6-1-.8-1.5s-.4-1.1-.4-1.7zm1.5 5.5c1.1.9 2.4 1.4 3.8 1.6l.2-1.5c-1.1-.1-2.2-.5-3.1-1.2l-.9 1.1z" }) }); 2173 2174 // packages/icons/build-module/library/rotate-right.js 2175 var import_primitives54 = __toESM(require_primitives()); 2176 var import_jsx_runtime57 = __toESM(require_jsx_runtime()); 2177 var rotate_right_default = /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(import_primitives54.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(import_primitives54.Path, { d: "M15.1 4.8l-3-2.5V4c-4.4 0-8 3.6-8 8 0 3.7 2.5 6.9 6 7.7.3.1.6.1 1 .2l.2-1.5c-.4 0-.7-.1-1.1-.2l-.1.2v-.2c-2.6-.8-4.5-3.3-4.5-6.2 0-3.6 2.9-6.5 6.5-6.5v1.8l3-2.5zM20 11c-.2-1.4-.7-2.7-1.6-3.8l-1.2.8c.7.9 1.1 2 1.3 3.1L20 11zm-1.5 1.8c-.1.5-.2 1.1-.4 1.6s-.5 1-.8 1.5l1.2.9c.4-.5.8-1.1 1-1.8s.5-1.3.5-2l-1.5-.2zm-5.6 5.6l.2 1.5c1.4-.2 2.7-.7 3.8-1.6l-.9-1.1c-.9.7-2 1.1-3.1 1.2z" }) }); 2178 2179 // packages/icons/build-module/library/scheduled.js 2180 var import_primitives55 = __toESM(require_primitives()); 2181 var import_jsx_runtime58 = __toESM(require_jsx_runtime()); 2182 var scheduled_default = /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_primitives55.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)( 2183 import_primitives55.Path, 2184 { 2185 fillRule: "evenodd", 2186 clipRule: "evenodd", 2187 d: "M12 18.5a6.5 6.5 0 1 1 0-13 6.5 6.5 0 0 1 0 13ZM4 12a8 8 0 1 1 16 0 8 8 0 0 1-16 0Zm9 1V8h-1.5v3.5h-2V13H13Z" 2188 } 2189 ) }); 2190 2191 // packages/icons/build-module/library/search.js 2192 var import_primitives56 = __toESM(require_primitives()); 2193 var import_jsx_runtime59 = __toESM(require_jsx_runtime()); 2194 var search_default = /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_primitives56.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_primitives56.Path, { d: "M13 5c-3.3 0-6 2.7-6 6 0 1.4.5 2.7 1.3 3.7l-3.8 3.8 1.1 1.1 3.8-3.8c1 .8 2.3 1.3 3.7 1.3 3.3 0 6-2.7 6-6S16.3 5 13 5zm0 10.5c-2.5 0-4.5-2-4.5-4.5s2-4.5 4.5-4.5 4.5 2 4.5 4.5-2 4.5-4.5 4.5z" }) }); 2195 2196 // packages/icons/build-module/library/seen.js 2197 var import_primitives57 = __toESM(require_primitives()); 2198 var import_jsx_runtime60 = __toESM(require_jsx_runtime()); 2199 var seen_default = /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(import_primitives57.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(import_primitives57.Path, { d: "M3.99961 13C4.67043 13.3354 4.6703 13.3357 4.67017 13.3359L4.67298 13.3305C4.67621 13.3242 4.68184 13.3135 4.68988 13.2985C4.70595 13.2686 4.7316 13.2218 4.76695 13.1608C4.8377 13.0385 4.94692 12.8592 5.09541 12.6419C5.39312 12.2062 5.84436 11.624 6.45435 11.0431C7.67308 9.88241 9.49719 8.75 11.9996 8.75C14.502 8.75 16.3261 9.88241 17.5449 11.0431C18.1549 11.624 18.6061 12.2062 18.9038 12.6419C19.0523 12.8592 19.1615 13.0385 19.2323 13.1608C19.2676 13.2218 19.2933 13.2686 19.3093 13.2985C19.3174 13.3135 19.323 13.3242 19.3262 13.3305L19.3291 13.3359C19.3289 13.3357 19.3288 13.3354 19.9996 13C20.6704 12.6646 20.6703 12.6643 20.6701 12.664L20.6697 12.6632L20.6688 12.6614L20.6662 12.6563L20.6583 12.6408C20.6517 12.6282 20.6427 12.6108 20.631 12.5892C20.6078 12.5459 20.5744 12.4852 20.5306 12.4096C20.4432 12.2584 20.3141 12.0471 20.1423 11.7956C19.7994 11.2938 19.2819 10.626 18.5794 9.9569C17.1731 8.61759 14.9972 7.25 11.9996 7.25C9.00203 7.25 6.82614 8.61759 5.41987 9.9569C4.71736 10.626 4.19984 11.2938 3.85694 11.7956C3.68511 12.0471 3.55605 12.2584 3.4686 12.4096C3.42484 12.4852 3.39142 12.5459 3.36818 12.5892C3.35656 12.6108 3.34748 12.6282 3.34092 12.6408L3.33297 12.6563L3.33041 12.6614L3.32948 12.6632L3.32911 12.664C3.32894 12.6643 3.32879 12.6646 3.99961 13ZM11.9996 16C13.9326 16 15.4996 14.433 15.4996 12.5C15.4996 10.567 13.9326 9 11.9996 9C10.0666 9 8.49961 10.567 8.49961 12.5C8.49961 14.433 10.0666 16 11.9996 16Z" }) }); 2200 2201 // packages/icons/build-module/library/styles.js 2202 var import_primitives58 = __toESM(require_primitives()); 2203 var import_jsx_runtime61 = __toESM(require_jsx_runtime()); 2204 var styles_default = /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(import_primitives58.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)( 2205 import_primitives58.Path, 2206 { 2207 fillRule: "evenodd", 2208 clipRule: "evenodd", 2209 d: "M20 12a8 8 0 1 1-16 0 8 8 0 0 1 16 0Zm-1.5 0a6.5 6.5 0 0 1-6.5 6.5v-13a6.5 6.5 0 0 1 6.5 6.5Z" 2210 } 2211 ) }); 2212 2213 // packages/icons/build-module/library/symbol-filled.js 2214 var import_primitives59 = __toESM(require_primitives()); 2215 var import_jsx_runtime62 = __toESM(require_jsx_runtime()); 2216 var symbol_filled_default = /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(import_primitives59.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(import_primitives59.Path, { d: "M21.3 10.8l-5.6-5.6c-.7-.7-1.8-.7-2.5 0l-5.6 5.6c-.7.7-.7 1.8 0 2.5l5.6 5.6c.3.3.8.5 1.2.5s.9-.2 1.2-.5l5.6-5.6c.8-.7.8-1.9.1-2.5zm-17.6 1L10 5.5l-1-1-6.3 6.3c-.7.7-.7 1.8 0 2.5L9 19.5l1.1-1.1-6.3-6.3c-.2 0-.2-.2-.1-.3z" }) }); 2217 2218 // packages/icons/build-module/library/symbol.js 2219 var import_primitives60 = __toESM(require_primitives()); 2220 var import_jsx_runtime63 = __toESM(require_jsx_runtime()); 2221 var symbol_default = /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(import_primitives60.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(import_primitives60.Path, { d: "M21.3 10.8l-5.6-5.6c-.7-.7-1.8-.7-2.5 0l-5.6 5.6c-.7.7-.7 1.8 0 2.5l5.6 5.6c.3.3.8.5 1.2.5s.9-.2 1.2-.5l5.6-5.6c.8-.7.8-1.9.1-2.5zm-1 1.4l-5.6 5.6c-.1.1-.3.1-.4 0l-5.6-5.6c-.1-.1-.1-.3 0-.4l5.6-5.6s.1-.1.2-.1.1 0 .2.1l5.6 5.6c.1.1.1.3 0 .4zm-16.6-.4L10 5.5l-1-1-6.3 6.3c-.7.7-.7 1.8 0 2.5L9 19.5l1.1-1.1-6.3-6.3c-.2 0-.2-.2-.1-.3z" }) }); 2222 2223 // packages/icons/build-module/library/tag.js 2224 var import_primitives61 = __toESM(require_primitives()); 2225 var import_jsx_runtime64 = __toESM(require_jsx_runtime()); 2226 var tag_default = /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(import_primitives61.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(import_primitives61.Path, { d: "M4.75 4a.75.75 0 0 0-.75.75v7.826c0 .2.08.39.22.53l6.72 6.716a2.313 2.313 0 0 0 3.276-.001l5.61-5.611-.531-.53.532.528a2.315 2.315 0 0 0 0-3.264L13.104 4.22a.75.75 0 0 0-.53-.22H4.75ZM19 12.576a.815.815 0 0 1-.236.574l-5.61 5.611a.814.814 0 0 1-1.153 0L5.5 12.264V5.5h6.763l6.5 6.502a.816.816 0 0 1 .237.574ZM8.75 9.75a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z" }) }); 2227 2228 // packages/icons/build-module/library/trash.js 2229 var import_primitives62 = __toESM(require_primitives()); 2230 var import_jsx_runtime65 = __toESM(require_jsx_runtime()); 2231 var trash_default = /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(import_primitives62.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)( 2232 import_primitives62.Path, 2233 { 2234 fillRule: "evenodd", 2235 clipRule: "evenodd", 2236 d: "M12 5.5A2.25 2.25 0 0 0 9.878 7h4.244A2.251 2.251 0 0 0 12 5.5ZM12 4a3.751 3.751 0 0 0-3.675 3H5v1.5h1.27l.818 8.997a2.75 2.75 0 0 0 2.739 2.501h4.347a2.75 2.75 0 0 0 2.738-2.5L17.73 8.5H19V7h-3.325A3.751 3.751 0 0 0 12 4Zm4.224 4.5H7.776l.806 8.861a1.25 1.25 0 0 0 1.245 1.137h4.347a1.25 1.25 0 0 0 1.245-1.137l.805-8.861Z" 2237 } 2238 ) }); 2239 2240 // packages/icons/build-module/library/unseen.js 2241 var import_primitives63 = __toESM(require_primitives()); 2242 var import_jsx_runtime66 = __toESM(require_jsx_runtime()); 2243 var unseen_default = /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_primitives63.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_primitives63.Path, { d: "M20.7 12.7s0-.1-.1-.2c0-.2-.2-.4-.4-.6-.3-.5-.9-1.2-1.6-1.8-.7-.6-1.5-1.3-2.6-1.8l-.6 1.4c.9.4 1.6 1 2.1 1.5.6.6 1.1 1.2 1.4 1.6.1.2.3.4.3.5v.1l.7-.3.7-.3Zm-5.2-9.3-1.8 4c-.5-.1-1.1-.2-1.7-.2-3 0-5.2 1.4-6.6 2.7-.7.7-1.2 1.3-1.6 1.8-.2.3-.3.5-.4.6 0 0 0 .1-.1.2s0 0 .7.3l.7.3V13c0-.1.2-.3.3-.5.3-.4.7-1 1.4-1.6 1.2-1.2 3-2.3 5.5-2.3H13v.3c-.4 0-.8-.1-1.1-.1-1.9 0-3.5 1.6-3.5 3.5s.6 2.3 1.6 2.9l-2 4.4.9.4 7.6-16.2-.9-.4Zm-3 12.6c1.7-.2 3-1.7 3-3.5s-.2-1.4-.6-1.9L12.4 16Z" }) }); 2244 2245 // packages/icons/build-module/library/upload.js 2246 var import_primitives64 = __toESM(require_primitives()); 2247 var import_jsx_runtime67 = __toESM(require_jsx_runtime()); 2248 var upload_default = /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(import_primitives64.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(import_primitives64.Path, { d: "M18.5 15v3.5H13V6.7l4.5 4.1 1-1.1-6.2-5.8-5.8 5.8 1 1.1 4-4v11.7h-6V15H4v5h16v-5z" }) }); 2249 2250 // packages/icons/build-module/library/verse.js 2251 var import_primitives65 = __toESM(require_primitives()); 2252 var import_jsx_runtime68 = __toESM(require_jsx_runtime()); 2253 var verse_default = /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(import_primitives65.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(import_primitives65.Path, { d: "M17.8 2l-.9.3c-.1 0-3.6 1-5.2 2.1C10 5.5 9.3 6.5 8.9 7.1c-.6.9-1.7 4.7-1.7 6.3l-.9 2.3c-.2.4 0 .8.4 1 .1 0 .2.1.3.1.3 0 .6-.2.7-.5l.6-1.5c.3 0 .7-.1 1.2-.2.7-.1 1.4-.3 2.2-.5.8-.2 1.6-.5 2.4-.8.7-.3 1.4-.7 1.9-1.2s.8-1.2 1-1.9c.2-.7.3-1.6.4-2.4.1-.8.1-1.7.2-2.5 0-.8.1-1.5.2-2.1V2zm-1.9 5.6c-.1.8-.2 1.5-.3 2.1-.2.6-.4 1-.6 1.3-.3.3-.8.6-1.4.9-.7.3-1.4.5-2.2.8-.6.2-1.3.3-1.8.4L15 7.5c.3-.3.6-.7 1-1.1 0 .4 0 .8-.1 1.2zM6 20h8v-1.5H6V20z" }) }); 2254 2255 // packages/icons/build-module/library/wordpress.js 2256 var import_primitives66 = __toESM(require_primitives()); 2257 var import_jsx_runtime69 = __toESM(require_jsx_runtime()); 2258 var wordpress_default = /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(import_primitives66.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "-2 -2 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(import_primitives66.Path, { d: "M20 10c0-5.51-4.49-10-10-10C4.48 0 0 4.49 0 10c0 5.52 4.48 10 10 10 5.51 0 10-4.48 10-10zM7.78 15.37L4.37 6.22c.55-.02 1.17-.08 1.17-.08.5-.06.44-1.13-.06-1.11 0 0-1.45.11-2.37.11-.18 0-.37 0-.58-.01C4.12 2.69 6.87 1.11 10 1.11c2.33 0 4.45.87 6.05 2.34-.68-.11-1.65.39-1.65 1.58 0 .74.45 1.36.9 2.1.35.61.55 1.36.55 2.46 0 1.49-1.4 5-1.4 5l-3.03-8.37c.54-.02.82-.17.82-.17.5-.05.44-1.25-.06-1.22 0 0-1.44.12-2.38.12-.87 0-2.33-.12-2.33-.12-.5-.03-.56 1.2-.06 1.22l.92.08 1.26 3.41zM17.41 10c.24-.64.74-1.87.43-4.25.7 1.29 1.05 2.71 1.05 4.25 0 3.29-1.73 6.24-4.4 7.78.97-2.59 1.94-5.2 2.92-7.78zM6.1 18.09C3.12 16.65 1.11 13.53 1.11 10c0-1.3.23-2.48.72-3.59C3.25 10.3 4.67 14.2 6.1 18.09zm4.03-6.63l2.58 6.98c-.86.29-1.76.45-2.71.45-.79 0-1.57-.11-2.29-.33.81-2.38 1.62-4.74 2.42-7.1z" }) }); 2259 2260 // packages/edit-site/build-module/components/site-hub/index.js 2261 var import_commands = __toESM(require_commands()); 2262 var import_keycodes = __toESM(require_keycodes()); 2263 var import_url = __toESM(require_url()); 2264 var import_router = __toESM(require_router()); 2265 2266 // packages/edit-site/build-module/components/site-icon/index.js 2267 var import_data4 = __toESM(require_data()); 2268 var import_components3 = __toESM(require_components()); 2269 var import_i18n2 = __toESM(require_i18n()); 2270 var import_core_data3 = __toESM(require_core_data()); 2271 var import_jsx_runtime70 = __toESM(require_jsx_runtime()); 2272 function SiteIcon({ className }) { 2273 const { isRequestingSite, siteIconUrl } = (0, import_data4.useSelect)((select3) => { 2274 const { getEntityRecord } = select3(import_core_data3.store); 2275 const siteData = getEntityRecord("root", "__unstableBase", void 0); 2276 return { 2277 isRequestingSite: !siteData, 2278 siteIconUrl: siteData?.site_icon_url 2279 }; 2280 }, []); 2281 if (isRequestingSite && !siteIconUrl) { 2282 return /* @__PURE__ */ (0, import_jsx_runtime70.jsx)("div", { className: "edit-site-site-icon__image" }); 2283 } 2284 const icon = siteIconUrl ? /* @__PURE__ */ (0, import_jsx_runtime70.jsx)( 2285 "img", 2286 { 2287 className: "edit-site-site-icon__image", 2288 alt: (0, import_i18n2.__)("Site Icon"), 2289 src: siteIconUrl 2290 } 2291 ) : /* @__PURE__ */ (0, import_jsx_runtime70.jsx)( 2292 import_components3.Icon, 2293 { 2294 className: "edit-site-site-icon__icon", 2295 icon: wordpress_default, 2296 size: 48 2297 } 2298 ); 2299 return /* @__PURE__ */ (0, import_jsx_runtime70.jsx)("div", { className: clsx_default(className, "edit-site-site-icon"), children: icon }); 2300 } 2301 var site_icon_default = SiteIcon; 2302 2303 // packages/edit-site/build-module/components/sidebar/index.js 2304 var import_element4 = __toESM(require_element()); 2305 var import_dom = __toESM(require_dom()); 2306 var import_jsx_runtime71 = __toESM(require_jsx_runtime()); 2307 var SidebarNavigationContext = (0, import_element4.createContext)(() => { 2308 }); 2309 SidebarNavigationContext.displayName = "SidebarNavigationContext"; 2310 function focusSidebarElement(el, direction, focusSelector) { 2311 let elementToFocus; 2312 if (direction === "back" && focusSelector) { 2313 elementToFocus = el.querySelector(focusSelector); 2314 } 2315 if (direction !== null && !elementToFocus) { 2316 const [firstTabbable] = import_dom.focus.tabbable.find(el); 2317 elementToFocus = firstTabbable ?? el; 2318 } 2319 elementToFocus?.focus(); 2320 } 2321 function createNavState() { 2322 let state = { 2323 direction: null, 2324 focusSelector: null 2325 }; 2326 return { 2327 get() { 2328 return state; 2329 }, 2330 navigate(direction, focusSelector = null) { 2331 state = { 2332 direction, 2333 focusSelector: direction === "forward" && focusSelector ? focusSelector : state.focusSelector 2334 }; 2335 } 2336 }; 2337 } 2338 function SidebarContentWrapper({ children, shouldAnimate }) { 2339 const navState = (0, import_element4.useContext)(SidebarNavigationContext); 2340 const wrapperRef = (0, import_element4.useRef)(); 2341 const [navAnimation, setNavAnimation] = (0, import_element4.useState)(null); 2342 (0, import_element4.useLayoutEffect)(() => { 2343 const { direction, focusSelector } = navState.get(); 2344 focusSidebarElement(wrapperRef.current, direction, focusSelector); 2345 setNavAnimation(direction); 2346 }, [navState]); 2347 const wrapperCls = clsx_default( 2348 "edit-site-sidebar__screen-wrapper", 2349 /* 2350 * Some panes do not have sub-panes and therefore 2351 * should not animate when clicked on. 2352 */ 2353 shouldAnimate ? { 2354 "slide-from-left": navAnimation === "back", 2355 "slide-from-right": navAnimation === "forward" 2356 } : {} 2357 ); 2358 return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("div", { ref: wrapperRef, className: wrapperCls, children }); 2359 } 2360 function SidebarNavigationProvider({ children }) { 2361 const [navState] = (0, import_element4.useState)(createNavState); 2362 return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(SidebarNavigationContext.Provider, { value: navState, children }); 2363 } 2364 function SidebarContent({ routeKey, shouldAnimate, children }) { 2365 return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("div", { className: "edit-site-sidebar__content", children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)( 2366 SidebarContentWrapper, 2367 { 2368 shouldAnimate, 2369 children 2370 }, 2371 routeKey 2372 ) }); 2373 } 2374 2375 // packages/edit-site/build-module/components/site-hub/index.js 2376 var import_jsx_runtime72 = __toESM(require_jsx_runtime()); 2377 var { useLocation, useHistory } = unlock(import_router.privateApis); 2378 var SiteHub = (0, import_element5.memo)( 2379 (0, import_element5.forwardRef)(({ isTransparent }, ref) => { 2380 const { dashboardLink, homeUrl, siteTitle } = (0, import_data5.useSelect)((select3) => { 2381 const { getSettings: getSettings7 } = unlock(select3(store)); 2382 const { getEntityRecord } = select3(import_core_data4.store); 2383 const _site = getEntityRecord("root", "site"); 2384 return { 2385 dashboardLink: getSettings7().__experimentalDashboardLink, 2386 homeUrl: getEntityRecord("root", "__unstableBase")?.home, 2387 siteTitle: !_site?.title && !!_site?.url ? (0, import_url.filterURLForDisplay)(_site?.url) : _site?.title 2388 }; 2389 }, []); 2390 const { open: openCommandCenter } = (0, import_data5.useDispatch)(import_commands.store); 2391 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("div", { className: "edit-site-site-hub", children: /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(import_components4.__experimentalHStack, { justify: "flex-start", spacing: "0", children: [ 2392 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)( 2393 "div", 2394 { 2395 className: clsx_default( 2396 "edit-site-site-hub__view-mode-toggle-container", 2397 { 2398 "has-transparent-background": isTransparent 2399 } 2400 ), 2401 children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)( 2402 import_components4.Button, 2403 { 2404 __next40pxDefaultSize: true, 2405 ref, 2406 href: dashboardLink, 2407 label: (0, import_i18n3.__)("Go to the Dashboard"), 2408 className: "edit-site-layout__view-mode-toggle", 2409 style: { 2410 transform: "scale(0.5333) translateX(-4px)", 2411 // Offset to position the icon 12px from viewport edge 2412 borderRadius: 4 2413 }, 2414 children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(site_icon_default, { className: "edit-site-layout__view-mode-toggle-icon" }) 2415 } 2416 ) 2417 } 2418 ), 2419 /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(import_components4.__experimentalHStack, { children: [ 2420 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("div", { className: "edit-site-site-hub__title", children: /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)( 2421 import_components4.Button, 2422 { 2423 __next40pxDefaultSize: true, 2424 variant: "link", 2425 href: homeUrl, 2426 target: "_blank", 2427 children: [ 2428 (0, import_html_entities.decodeEntities)(siteTitle), 2429 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(import_components4.VisuallyHidden, { 2430 as: "span", 2431 /* translators: accessibility text */ 2432 children: (0, import_i18n3.__)("(opens in a new tab)") 2433 }) 2434 ] 2435 } 2436 ) }), 2437 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)( 2438 import_components4.__experimentalHStack, 2439 { 2440 spacing: 0, 2441 expanded: false, 2442 className: "edit-site-site-hub__actions", 2443 children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)( 2444 import_components4.Button, 2445 { 2446 size: "compact", 2447 className: "edit-site-site-hub_toggle-command-center", 2448 icon: search_default, 2449 onClick: () => openCommandCenter(), 2450 label: (0, import_i18n3.__)("Open command palette"), 2451 shortcut: import_keycodes.displayShortcut.primary("k") 2452 } 2453 ) 2454 } 2455 ) 2456 ] }) 2457 ] }) }); 2458 }) 2459 ); 2460 var site_hub_default = SiteHub; 2461 var SiteHubMobile = (0, import_element5.memo)( 2462 (0, import_element5.forwardRef)(({ isTransparent }, ref) => { 2463 const { path } = useLocation(); 2464 const history = useHistory(); 2465 const { navigate } = (0, import_element5.useContext)(SidebarNavigationContext); 2466 const { 2467 dashboardLink, 2468 homeUrl, 2469 siteTitle, 2470 isBlockTheme, 2471 isClassicThemeWithStyleBookSupport: isClassicThemeWithStyleBookSupport2 2472 } = (0, import_data5.useSelect)((select3) => { 2473 const { getSettings: getSettings7 } = unlock(select3(store)); 2474 const { getEntityRecord, getCurrentTheme } = select3(import_core_data4.store); 2475 const _site = getEntityRecord("root", "site"); 2476 const currentTheme = getCurrentTheme(); 2477 const settings2 = getSettings7(); 2478 const supportsEditorStyles = currentTheme?.theme_supports["editor-styles"]; 2479 const hasThemeJson = settings2.supportsLayout; 2480 return { 2481 dashboardLink: settings2.__experimentalDashboardLink, 2482 homeUrl: getEntityRecord("root", "__unstableBase")?.home, 2483 siteTitle: !_site?.title && !!_site?.url ? (0, import_url.filterURLForDisplay)(_site?.url) : _site?.title, 2484 isBlockTheme: currentTheme?.is_block_theme, 2485 isClassicThemeWithStyleBookSupport: !currentTheme?.is_block_theme && (supportsEditorStyles || hasThemeJson) 2486 }; 2487 }, []); 2488 const { open: openCommandCenter } = (0, import_data5.useDispatch)(import_commands.store); 2489 let backPath; 2490 if (path !== "/") { 2491 if (isBlockTheme || isClassicThemeWithStyleBookSupport2) { 2492 backPath = "/"; 2493 } else if (path !== "/pattern") { 2494 backPath = "/pattern"; 2495 } 2496 } 2497 const backButtonProps = { 2498 href: !!backPath ? void 0 : dashboardLink, 2499 label: !!backPath ? (0, import_i18n3.__)("Go to Site Editor") : (0, import_i18n3.__)("Go to the Dashboard"), 2500 onClick: !!backPath ? () => { 2501 history.navigate(backPath); 2502 navigate("back"); 2503 } : void 0 2504 }; 2505 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("div", { className: "edit-site-site-hub", children: /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(import_components4.__experimentalHStack, { justify: "flex-start", spacing: "0", children: [ 2506 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)( 2507 "div", 2508 { 2509 className: clsx_default( 2510 "edit-site-site-hub__view-mode-toggle-container", 2511 { 2512 "has-transparent-background": isTransparent 2513 } 2514 ), 2515 children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)( 2516 import_components4.Button, 2517 { 2518 __next40pxDefaultSize: true, 2519 ref, 2520 className: "edit-site-layout__view-mode-toggle", 2521 style: { 2522 transform: "scale(0.5)", 2523 borderRadius: 4 2524 }, 2525 ...backButtonProps, 2526 children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(site_icon_default, { className: "edit-site-layout__view-mode-toggle-icon" }) 2527 } 2528 ) 2529 } 2530 ), 2531 /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(import_components4.__experimentalHStack, { children: [ 2532 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("div", { className: "edit-site-site-hub__title", children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)( 2533 import_components4.Button, 2534 { 2535 __next40pxDefaultSize: true, 2536 variant: "link", 2537 href: homeUrl, 2538 target: "_blank", 2539 label: (0, import_i18n3.__)("View site (opens in a new tab)"), 2540 children: (0, import_html_entities.decodeEntities)(siteTitle) 2541 } 2542 ) }), 2543 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)( 2544 import_components4.__experimentalHStack, 2545 { 2546 spacing: 0, 2547 expanded: false, 2548 className: "edit-site-site-hub__actions", 2549 children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)( 2550 import_components4.Button, 2551 { 2552 __next40pxDefaultSize: true, 2553 className: "edit-site-site-hub_toggle-command-center", 2554 icon: search_default, 2555 onClick: () => openCommandCenter(), 2556 label: (0, import_i18n3.__)("Open command palette"), 2557 shortcut: import_keycodes.displayShortcut.primary("k") 2558 } 2559 ) 2560 } 2561 ) 2562 ] }) 2563 ] }) }); 2564 }) 2565 ); 2566 2567 // packages/edit-site/build-module/components/resizable-frame/index.js 2568 var import_element6 = __toESM(require_element()); 2569 var import_components5 = __toESM(require_components()); 2570 var import_compose = __toESM(require_compose()); 2571 var import_i18n4 = __toESM(require_i18n()); 2572 var import_router2 = __toESM(require_router()); 2573 var import_data6 = __toESM(require_data()); 2574 var import_core_data5 = __toESM(require_core_data()); 2575 var import_url2 = __toESM(require_url()); 2576 var import_jsx_runtime73 = __toESM(require_jsx_runtime()); 2577 var { useLocation: useLocation2, useHistory: useHistory2 } = unlock(import_router2.privateApis); 2578 var HANDLE_STYLES_OVERRIDE = { 2579 position: void 0, 2580 userSelect: void 0, 2581 cursor: void 0, 2582 width: void 0, 2583 height: void 0, 2584 top: void 0, 2585 right: void 0, 2586 bottom: void 0, 2587 left: void 0 2588 }; 2589 var FRAME_MIN_WIDTH = 320; 2590 var FRAME_REFERENCE_WIDTH = 1300; 2591 var FRAME_TARGET_ASPECT_RATIO = 9 / 19.5; 2592 var SNAP_TO_EDIT_CANVAS_MODE_THRESHOLD = 200; 2593 var INITIAL_FRAME_SIZE = { width: "100%", height: "100%" }; 2594 function calculateNewHeight(width, initialAspectRatio) { 2595 const lerp = (a2, b2, amount) => { 2596 return a2 + (b2 - a2) * amount; 2597 }; 2598 const lerpFactor = 1 - Math.max( 2599 0, 2600 Math.min( 2601 1, 2602 (width - FRAME_MIN_WIDTH) / (FRAME_REFERENCE_WIDTH - FRAME_MIN_WIDTH) 2603 ) 2604 ); 2605 const intermediateAspectRatio = lerp( 2606 initialAspectRatio, 2607 FRAME_TARGET_ASPECT_RATIO, 2608 lerpFactor 2609 ); 2610 return width / intermediateAspectRatio; 2611 } 2612 function ResizableFrame({ 2613 isFullWidth, 2614 isOversized, 2615 setIsOversized, 2616 isReady, 2617 children, 2618 /** The default (unresized) width/height of the frame, based on the space available in the viewport. */ 2619 defaultSize, 2620 innerContentStyle 2621 }) { 2622 const history = useHistory2(); 2623 const { path, query } = useLocation2(); 2624 const { canvas = "view" } = query; 2625 const disableMotion = (0, import_compose.useReducedMotion)(); 2626 const [frameSize, setFrameSize] = (0, import_element6.useState)(INITIAL_FRAME_SIZE); 2627 const [startingWidth, setStartingWidth] = (0, import_element6.useState)(); 2628 const [isResizing, setIsResizing] = (0, import_element6.useState)(false); 2629 const [shouldShowHandle, setShouldShowHandle] = (0, import_element6.useState)(false); 2630 const [resizeRatio, setResizeRatio] = (0, import_element6.useState)(1); 2631 const FRAME_TRANSITION = { type: "tween", duration: isResizing ? 0 : 0.5 }; 2632 const frameRef = (0, import_element6.useRef)(null); 2633 const resizableHandleHelpId = (0, import_compose.useInstanceId)( 2634 ResizableFrame, 2635 "edit-site-resizable-frame-handle-help" 2636 ); 2637 const defaultAspectRatio = defaultSize.width / defaultSize.height; 2638 const isBlockTheme = (0, import_data6.useSelect)((select3) => { 2639 const { getCurrentTheme } = select3(import_core_data5.store); 2640 return getCurrentTheme()?.is_block_theme; 2641 }, []); 2642 const handleResizeStart = (_event, _direction, ref) => { 2643 setStartingWidth(ref.offsetWidth); 2644 setIsResizing(true); 2645 }; 2646 const handleResize = (_event, _direction, _ref, delta) => { 2647 const normalizedDelta = delta.width / resizeRatio; 2648 const deltaAbs = Math.abs(normalizedDelta); 2649 const maxDoubledDelta = delta.width < 0 ? deltaAbs : (defaultSize.width - startingWidth) / 2; 2650 const deltaToDouble = Math.min(deltaAbs, maxDoubledDelta); 2651 const doubleSegment = deltaAbs === 0 ? 0 : deltaToDouble / deltaAbs; 2652 const singleSegment = 1 - doubleSegment; 2653 setResizeRatio(singleSegment + doubleSegment * 2); 2654 const updatedWidth = startingWidth + delta.width; 2655 setIsOversized(updatedWidth > defaultSize.width); 2656 setFrameSize({ 2657 height: isOversized ? "100%" : calculateNewHeight(updatedWidth, defaultAspectRatio) 2658 }); 2659 }; 2660 const handleResizeStop = (_event, _direction, ref) => { 2661 setIsResizing(false); 2662 if (!isOversized) { 2663 return; 2664 } 2665 setIsOversized(false); 2666 const remainingWidth = ref.ownerDocument.documentElement.offsetWidth - ref.offsetWidth; 2667 if (remainingWidth > SNAP_TO_EDIT_CANVAS_MODE_THRESHOLD || !isBlockTheme) { 2668 setFrameSize(INITIAL_FRAME_SIZE); 2669 } else { 2670 history.navigate( 2671 (0, import_url2.addQueryArgs)(path, { 2672 canvas: "edit" 2673 }), 2674 { 2675 transition: "canvas-mode-edit-transition" 2676 } 2677 ); 2678 } 2679 }; 2680 const handleResizableHandleKeyDown = (event) => { 2681 if (!["ArrowLeft", "ArrowRight"].includes(event.key)) { 2682 return; 2683 } 2684 event.preventDefault(); 2685 const step = 20 * (event.shiftKey ? 5 : 1); 2686 const delta = step * (event.key === "ArrowLeft" ? 1 : -1) * ((0, import_i18n4.isRTL)() ? -1 : 1); 2687 const newWidth = Math.min( 2688 Math.max( 2689 FRAME_MIN_WIDTH, 2690 frameRef.current.resizable.offsetWidth + delta 2691 ), 2692 defaultSize.width 2693 ); 2694 setFrameSize({ 2695 width: newWidth, 2696 height: calculateNewHeight(newWidth, defaultAspectRatio) 2697 }); 2698 }; 2699 const frameAnimationVariants = { 2700 default: { 2701 flexGrow: 0, 2702 height: frameSize.height 2703 }, 2704 fullWidth: { 2705 flexGrow: 1, 2706 height: frameSize.height 2707 } 2708 }; 2709 const resizeHandleVariants = { 2710 hidden: { 2711 opacity: 0, 2712 ...(0, import_i18n4.isRTL)() ? { right: 0 } : { left: 0 } 2713 }, 2714 visible: { 2715 opacity: 1, 2716 // Account for the handle's width. 2717 ...(0, import_i18n4.isRTL)() ? { right: -14 } : { left: -14 } 2718 }, 2719 active: { 2720 opacity: 1, 2721 // Account for the handle's width. 2722 ...(0, import_i18n4.isRTL)() ? { right: -14 } : { left: -14 }, 2723 scaleY: 1.3 2724 } 2725 }; 2726 const currentResizeHandleVariant = (() => { 2727 if (isResizing) { 2728 return "active"; 2729 } 2730 return shouldShowHandle ? "visible" : "hidden"; 2731 })(); 2732 return /* @__PURE__ */ (0, import_jsx_runtime73.jsx)( 2733 import_components5.ResizableBox, 2734 { 2735 as: import_components5.__unstableMotion.div, 2736 ref: frameRef, 2737 initial: false, 2738 variants: frameAnimationVariants, 2739 animate: isFullWidth ? "fullWidth" : "default", 2740 onAnimationComplete: (definition) => { 2741 if (definition === "fullWidth") { 2742 setFrameSize({ width: "100%", height: "100%" }); 2743 } 2744 }, 2745 whileHover: canvas === "view" && isBlockTheme ? { 2746 scale: 1.005, 2747 transition: { 2748 duration: disableMotion ? 0 : 0.5, 2749 ease: "easeOut" 2750 } 2751 } : {}, 2752 transition: FRAME_TRANSITION, 2753 size: frameSize, 2754 enable: { 2755 top: false, 2756 bottom: false, 2757 // Resizing will be disabled until the editor content is loaded. 2758 ...(0, import_i18n4.isRTL)() ? { right: isReady, left: false } : { left: isReady, right: false }, 2759 topRight: false, 2760 bottomRight: false, 2761 bottomLeft: false, 2762 topLeft: false 2763 }, 2764 resizeRatio, 2765 handleClasses: void 0, 2766 handleStyles: { 2767 left: HANDLE_STYLES_OVERRIDE, 2768 right: HANDLE_STYLES_OVERRIDE 2769 }, 2770 minWidth: FRAME_MIN_WIDTH, 2771 maxWidth: isFullWidth ? "100%" : "150%", 2772 maxHeight: "100%", 2773 onFocus: () => setShouldShowHandle(true), 2774 onBlur: () => setShouldShowHandle(false), 2775 onMouseOver: () => setShouldShowHandle(true), 2776 onMouseOut: () => setShouldShowHandle(false), 2777 handleComponent: { 2778 [(0, import_i18n4.isRTL)() ? "right" : "left"]: canvas === "view" && /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)(import_jsx_runtime73.Fragment, { children: [ 2779 /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(import_components5.Tooltip, { text: (0, import_i18n4.__)("Drag to resize"), children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)( 2780 import_components5.__unstableMotion.button, 2781 { 2782 role: "separator", 2783 "aria-orientation": "vertical", 2784 className: clsx_default( 2785 "edit-site-resizable-frame__handle", 2786 { "is-resizing": isResizing } 2787 ), 2788 variants: resizeHandleVariants, 2789 animate: currentResizeHandleVariant, 2790 "aria-label": (0, import_i18n4.__)("Drag to resize"), 2791 "aria-describedby": resizableHandleHelpId, 2792 "aria-valuenow": frameRef.current?.resizable?.offsetWidth || void 0, 2793 "aria-valuemin": FRAME_MIN_WIDTH, 2794 "aria-valuemax": defaultSize.width, 2795 onKeyDown: handleResizableHandleKeyDown, 2796 initial: "hidden", 2797 exit: "hidden", 2798 whileFocus: "active", 2799 whileHover: "active" 2800 }, 2801 "handle" 2802 ) }), 2803 /* @__PURE__ */ (0, import_jsx_runtime73.jsx)("div", { hidden: true, id: resizableHandleHelpId, children: (0, import_i18n4.__)( 2804 "Use left and right arrow keys to resize the canvas. Hold shift to resize in larger increments." 2805 ) }) 2806 ] }) 2807 }, 2808 onResizeStart: handleResizeStart, 2809 onResize: handleResize, 2810 onResizeStop: handleResizeStop, 2811 className: clsx_default("edit-site-resizable-frame__inner", { 2812 "is-resizing": isResizing 2813 }), 2814 showHandle: false, 2815 children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)( 2816 "div", 2817 { 2818 className: "edit-site-resizable-frame__inner-content", 2819 style: innerContentStyle, 2820 children 2821 } 2822 ) 2823 } 2824 ); 2825 } 2826 var resizable_frame_default = ResizableFrame; 2827 2828 // packages/edit-site/build-module/components/save-keyboard-shortcut/index.js 2829 var import_element7 = __toESM(require_element()); 2830 var import_keyboard_shortcuts = __toESM(require_keyboard_shortcuts()); 2831 var import_i18n5 = __toESM(require_i18n()); 2832 var import_data7 = __toESM(require_data()); 2833 var import_core_data6 = __toESM(require_core_data()); 2834 var import_editor3 = __toESM(require_editor()); 2835 var shortcutName = "core/edit-site/save"; 2836 function SaveKeyboardShortcut() { 2837 const { __experimentalGetDirtyEntityRecords, isSavingEntityRecord } = (0, import_data7.useSelect)(import_core_data6.store); 2838 const { hasNonPostEntityChanges, isPostSavingLocked } = (0, import_data7.useSelect)(import_editor3.store); 2839 const { savePost } = (0, import_data7.useDispatch)(import_editor3.store); 2840 const { setIsSaveViewOpened: setIsSaveViewOpened2 } = (0, import_data7.useDispatch)(store); 2841 const { registerShortcut, unregisterShortcut } = (0, import_data7.useDispatch)( 2842 import_keyboard_shortcuts.store 2843 ); 2844 (0, import_element7.useEffect)(() => { 2845 registerShortcut({ 2846 name: shortcutName, 2847 category: "global", 2848 description: (0, import_i18n5.__)("Save your changes."), 2849 keyCombination: { 2850 modifier: "primary", 2851 character: "s" 2852 } 2853 }); 2854 return () => { 2855 unregisterShortcut(shortcutName); 2856 }; 2857 }, [registerShortcut, unregisterShortcut]); 2858 (0, import_keyboard_shortcuts.useShortcut)("core/edit-site/save", (event) => { 2859 event.preventDefault(); 2860 const dirtyEntityRecords = __experimentalGetDirtyEntityRecords(); 2861 const hasDirtyEntities = !!dirtyEntityRecords.length; 2862 const isSaving = dirtyEntityRecords.some( 2863 (record) => isSavingEntityRecord(record.kind, record.name, record.key) 2864 ); 2865 if (!hasDirtyEntities || isSaving) { 2866 return; 2867 } 2868 if (hasNonPostEntityChanges()) { 2869 setIsSaveViewOpened2(true); 2870 } else if (!isPostSavingLocked()) { 2871 savePost(); 2872 } 2873 }); 2874 return null; 2875 } 2876 2877 // packages/edit-site/build-module/components/layout/hooks.js 2878 var import_element8 = __toESM(require_element()); 2879 var import_data8 = __toESM(require_data()); 2880 var import_core_data7 = __toESM(require_core_data()); 2881 var MAX_LOADING_TIME = 1e4; 2882 function useIsSiteEditorLoading() { 2883 const [loaded, setLoaded] = (0, import_element8.useState)(false); 2884 const inLoadingPause = (0, import_data8.useSelect)( 2885 (select3) => { 2886 const hasResolvingSelectors = select3(import_core_data7.store).hasResolvingSelectors(); 2887 return !loaded && !hasResolvingSelectors; 2888 }, 2889 [loaded] 2890 ); 2891 (0, import_element8.useEffect)(() => { 2892 let timeout; 2893 if (!loaded) { 2894 timeout = setTimeout(() => { 2895 setLoaded(true); 2896 }, MAX_LOADING_TIME); 2897 } 2898 return () => { 2899 clearTimeout(timeout); 2900 }; 2901 }, [loaded]); 2902 (0, import_element8.useEffect)(() => { 2903 if (inLoadingPause) { 2904 const ARTIFICIAL_DELAY = 100; 2905 const timeout = setTimeout(() => { 2906 setLoaded(true); 2907 }, ARTIFICIAL_DELAY); 2908 return () => { 2909 clearTimeout(timeout); 2910 }; 2911 } 2912 }, [inLoadingPause]); 2913 return !loaded; 2914 } 2915 2916 // node_modules/@react-spring/rafz/dist/react-spring-rafz.esm.js 2917 var updateQueue = makeQueue(); 2918 var raf = (fn) => schedule(fn, updateQueue); 2919 var writeQueue = makeQueue(); 2920 raf.write = (fn) => schedule(fn, writeQueue); 2921 var onStartQueue = makeQueue(); 2922 raf.onStart = (fn) => schedule(fn, onStartQueue); 2923 var onFrameQueue = makeQueue(); 2924 raf.onFrame = (fn) => schedule(fn, onFrameQueue); 2925 var onFinishQueue = makeQueue(); 2926 raf.onFinish = (fn) => schedule(fn, onFinishQueue); 2927 var timeouts = []; 2928 raf.setTimeout = (handler, ms) => { 2929 let time = raf.now() + ms; 2930 let cancel = () => { 2931 let i2 = timeouts.findIndex((t3) => t3.cancel == cancel); 2932 if (~i2) timeouts.splice(i2, 1); 2933 pendingCount -= ~i2 ? 1 : 0; 2934 }; 2935 let timeout = { 2936 time, 2937 handler, 2938 cancel 2939 }; 2940 timeouts.splice(findTimeout(time), 0, timeout); 2941 pendingCount += 1; 2942 start(); 2943 return timeout; 2944 }; 2945 var findTimeout = (time) => ~(~timeouts.findIndex((t3) => t3.time > time) || ~timeouts.length); 2946 raf.cancel = (fn) => { 2947 onStartQueue.delete(fn); 2948 onFrameQueue.delete(fn); 2949 onFinishQueue.delete(fn); 2950 updateQueue.delete(fn); 2951 writeQueue.delete(fn); 2952 }; 2953 raf.sync = (fn) => { 2954 sync = true; 2955 raf.batchedUpdates(fn); 2956 sync = false; 2957 }; 2958 raf.throttle = (fn) => { 2959 let lastArgs; 2960 function queuedFn() { 2961 try { 2962 fn(...lastArgs); 2963 } finally { 2964 lastArgs = null; 2965 } 2966 } 2967 function throttled(...args) { 2968 lastArgs = args; 2969 raf.onStart(queuedFn); 2970 } 2971 throttled.handler = fn; 2972 throttled.cancel = () => { 2973 onStartQueue.delete(queuedFn); 2974 lastArgs = null; 2975 }; 2976 return throttled; 2977 }; 2978 var nativeRaf = typeof window != "undefined" ? window.requestAnimationFrame : () => { 2979 }; 2980 raf.use = (impl) => nativeRaf = impl; 2981 raf.now = typeof performance != "undefined" ? () => performance.now() : Date.now; 2982 raf.batchedUpdates = (fn) => fn(); 2983 raf.catch = console.error; 2984 raf.frameLoop = "always"; 2985 raf.advance = () => { 2986 if (raf.frameLoop !== "demand") { 2987 console.warn("Cannot call the manual advancement of rafz whilst frameLoop is not set as demand"); 2988 } else { 2989 update(); 2990 } 2991 }; 2992 var ts = -1; 2993 var pendingCount = 0; 2994 var sync = false; 2995 function schedule(fn, queue) { 2996 if (sync) { 2997 queue.delete(fn); 2998 fn(0); 2999 } else { 3000 queue.add(fn); 3001 start(); 3002 } 3003 } 3004 function start() { 3005 if (ts < 0) { 3006 ts = 0; 3007 if (raf.frameLoop !== "demand") { 3008 nativeRaf(loop); 3009 } 3010 } 3011 } 3012 function stop() { 3013 ts = -1; 3014 } 3015 function loop() { 3016 if (~ts) { 3017 nativeRaf(loop); 3018 raf.batchedUpdates(update); 3019 } 3020 } 3021 function update() { 3022 let prevTs = ts; 3023 ts = raf.now(); 3024 let count = findTimeout(ts); 3025 if (count) { 3026 eachSafely(timeouts.splice(0, count), (t3) => t3.handler()); 3027 pendingCount -= count; 3028 } 3029 if (!pendingCount) { 3030 stop(); 3031 return; 3032 } 3033 onStartQueue.flush(); 3034 updateQueue.flush(prevTs ? Math.min(64, ts - prevTs) : 16.667); 3035 onFrameQueue.flush(); 3036 writeQueue.flush(); 3037 onFinishQueue.flush(); 3038 } 3039 function makeQueue() { 3040 let next = /* @__PURE__ */ new Set(); 3041 let current = next; 3042 return { 3043 add(fn) { 3044 pendingCount += current == next && !next.has(fn) ? 1 : 0; 3045 next.add(fn); 3046 }, 3047 delete(fn) { 3048 pendingCount -= current == next && next.has(fn) ? 1 : 0; 3049 return next.delete(fn); 3050 }, 3051 flush(arg) { 3052 if (current.size) { 3053 next = /* @__PURE__ */ new Set(); 3054 pendingCount -= current.size; 3055 eachSafely(current, (fn) => fn(arg) && next.add(fn)); 3056 pendingCount += next.size; 3057 current = next; 3058 } 3059 } 3060 }; 3061 } 3062 function eachSafely(values, each2) { 3063 values.forEach((value) => { 3064 try { 3065 each2(value); 3066 } catch (e2) { 3067 raf.catch(e2); 3068 } 3069 }); 3070 } 3071 3072 // node_modules/@react-spring/shared/dist/react-spring-shared.esm.js 3073 var import_react = __toESM(require_react()); 3074 function noop() { 3075 } 3076 var defineHidden = (obj, key, value) => Object.defineProperty(obj, key, { 3077 value, 3078 writable: true, 3079 configurable: true 3080 }); 3081 var is = { 3082 arr: Array.isArray, 3083 obj: (a2) => !!a2 && a2.constructor.name === "Object", 3084 fun: (a2) => typeof a2 === "function", 3085 str: (a2) => typeof a2 === "string", 3086 num: (a2) => typeof a2 === "number", 3087 und: (a2) => a2 === void 0 3088 }; 3089 function isEqual(a2, b2) { 3090 if (is.arr(a2)) { 3091 if (!is.arr(b2) || a2.length !== b2.length) return false; 3092 for (let i2 = 0; i2 < a2.length; i2++) { 3093 if (a2[i2] !== b2[i2]) return false; 3094 } 3095 return true; 3096 } 3097 return a2 === b2; 3098 } 3099 var each = (obj, fn) => obj.forEach(fn); 3100 function eachProp(obj, fn, ctx9) { 3101 if (is.arr(obj)) { 3102 for (let i2 = 0; i2 < obj.length; i2++) { 3103 fn.call(ctx9, obj[i2], `$i2}`); 3104 } 3105 return; 3106 } 3107 for (const key in obj) { 3108 if (obj.hasOwnProperty(key)) { 3109 fn.call(ctx9, obj[key], key); 3110 } 3111 } 3112 } 3113 var toArray = (a2) => is.und(a2) ? [] : is.arr(a2) ? a2 : [a2]; 3114 function flush(queue, iterator) { 3115 if (queue.size) { 3116 const items = Array.from(queue); 3117 queue.clear(); 3118 each(items, iterator); 3119 } 3120 } 3121 var flushCalls = (queue, ...args) => flush(queue, (fn) => fn(...args)); 3122 var isSSR = () => typeof window === "undefined" || !window.navigator || /ServerSideRendering|^Deno\//.test(window.navigator.userAgent); 3123 var createStringInterpolator$1; 3124 var to; 3125 var colors$1 = null; 3126 var skipAnimation = false; 3127 var willAdvance = noop; 3128 var assign = (globals2) => { 3129 if (globals2.to) to = globals2.to; 3130 if (globals2.now) raf.now = globals2.now; 3131 if (globals2.colors !== void 0) colors$1 = globals2.colors; 3132 if (globals2.skipAnimation != null) skipAnimation = globals2.skipAnimation; 3133 if (globals2.createStringInterpolator) createStringInterpolator$1 = globals2.createStringInterpolator; 3134 if (globals2.requestAnimationFrame) raf.use(globals2.requestAnimationFrame); 3135 if (globals2.batchedUpdates) raf.batchedUpdates = globals2.batchedUpdates; 3136 if (globals2.willAdvance) willAdvance = globals2.willAdvance; 3137 if (globals2.frameLoop) raf.frameLoop = globals2.frameLoop; 3138 }; 3139 var globals = /* @__PURE__ */ Object.freeze({ 3140 __proto__: null, 3141 get createStringInterpolator() { 3142 return createStringInterpolator$1; 3143 }, 3144 get to() { 3145 return to; 3146 }, 3147 get colors() { 3148 return colors$1; 3149 }, 3150 get skipAnimation() { 3151 return skipAnimation; 3152 }, 3153 get willAdvance() { 3154 return willAdvance; 3155 }, 3156 assign 3157 }); 3158 var startQueue = /* @__PURE__ */ new Set(); 3159 var currentFrame = []; 3160 var prevFrame = []; 3161 var priority = 0; 3162 var frameLoop = { 3163 get idle() { 3164 return !startQueue.size && !currentFrame.length; 3165 }, 3166 start(animation) { 3167 if (priority > animation.priority) { 3168 startQueue.add(animation); 3169 raf.onStart(flushStartQueue); 3170 } else { 3171 startSafely(animation); 3172 raf(advance); 3173 } 3174 }, 3175 advance, 3176 sort(animation) { 3177 if (priority) { 3178 raf.onFrame(() => frameLoop.sort(animation)); 3179 } else { 3180 const prevIndex = currentFrame.indexOf(animation); 3181 if (~prevIndex) { 3182 currentFrame.splice(prevIndex, 1); 3183 startUnsafely(animation); 3184 } 3185 } 3186 }, 3187 clear() { 3188 currentFrame = []; 3189 startQueue.clear(); 3190 } 3191 }; 3192 function flushStartQueue() { 3193 startQueue.forEach(startSafely); 3194 startQueue.clear(); 3195 raf(advance); 3196 } 3197 function startSafely(animation) { 3198 if (!currentFrame.includes(animation)) startUnsafely(animation); 3199 } 3200 function startUnsafely(animation) { 3201 currentFrame.splice(findIndex(currentFrame, (other) => other.priority > animation.priority), 0, animation); 3202 } 3203 function advance(dt) { 3204 const nextFrame = prevFrame; 3205 for (let i2 = 0; i2 < currentFrame.length; i2++) { 3206 const animation = currentFrame[i2]; 3207 priority = animation.priority; 3208 if (!animation.idle) { 3209 willAdvance(animation); 3210 animation.advance(dt); 3211 if (!animation.idle) { 3212 nextFrame.push(animation); 3213 } 3214 } 3215 } 3216 priority = 0; 3217 prevFrame = currentFrame; 3218 prevFrame.length = 0; 3219 currentFrame = nextFrame; 3220 return currentFrame.length > 0; 3221 } 3222 function findIndex(arr, test) { 3223 const index = arr.findIndex(test); 3224 return index < 0 ? arr.length : index; 3225 } 3226 var colors = { 3227 transparent: 0, 3228 aliceblue: 4042850303, 3229 antiquewhite: 4209760255, 3230 aqua: 16777215, 3231 aquamarine: 2147472639, 3232 azure: 4043309055, 3233 beige: 4126530815, 3234 bisque: 4293182719, 3235 black: 255, 3236 blanchedalmond: 4293643775, 3237 blue: 65535, 3238 blueviolet: 2318131967, 3239 brown: 2771004159, 3240 burlywood: 3736635391, 3241 burntsienna: 3934150143, 3242 cadetblue: 1604231423, 3243 chartreuse: 2147418367, 3244 chocolate: 3530104575, 3245 coral: 4286533887, 3246 cornflowerblue: 1687547391, 3247 cornsilk: 4294499583, 3248 crimson: 3692313855, 3249 cyan: 16777215, 3250 darkblue: 35839, 3251 darkcyan: 9145343, 3252 darkgoldenrod: 3095792639, 3253 darkgray: 2846468607, 3254 darkgreen: 6553855, 3255 darkgrey: 2846468607, 3256 darkkhaki: 3182914559, 3257 darkmagenta: 2332068863, 3258 darkolivegreen: 1433087999, 3259 darkorange: 4287365375, 3260 darkorchid: 2570243327, 3261 darkred: 2332033279, 3262 darksalmon: 3918953215, 3263 darkseagreen: 2411499519, 3264 darkslateblue: 1211993087, 3265 darkslategray: 793726975, 3266 darkslategrey: 793726975, 3267 darkturquoise: 13554175, 3268 darkviolet: 2483082239, 3269 deeppink: 4279538687, 3270 deepskyblue: 12582911, 3271 dimgray: 1768516095, 3272 dimgrey: 1768516095, 3273 dodgerblue: 512819199, 3274 firebrick: 2988581631, 3275 floralwhite: 4294635775, 3276 forestgreen: 579543807, 3277 fuchsia: 4278255615, 3278 gainsboro: 3705462015, 3279 ghostwhite: 4177068031, 3280 gold: 4292280575, 3281 goldenrod: 3668254975, 3282 gray: 2155905279, 3283 green: 8388863, 3284 greenyellow: 2919182335, 3285 grey: 2155905279, 3286 honeydew: 4043305215, 3287 hotpink: 4285117695, 3288 indianred: 3445382399, 3289 indigo: 1258324735, 3290 ivory: 4294963455, 3291 khaki: 4041641215, 3292 lavender: 3873897215, 3293 lavenderblush: 4293981695, 3294 lawngreen: 2096890111, 3295 lemonchiffon: 4294626815, 3296 lightblue: 2916673279, 3297 lightcoral: 4034953471, 3298 lightcyan: 3774873599, 3299 lightgoldenrodyellow: 4210742015, 3300 lightgray: 3553874943, 3301 lightgreen: 2431553791, 3302 lightgrey: 3553874943, 3303 lightpink: 4290167295, 3304 lightsalmon: 4288707327, 3305 lightseagreen: 548580095, 3306 lightskyblue: 2278488831, 3307 lightslategray: 2005441023, 3308 lightslategrey: 2005441023, 3309 lightsteelblue: 2965692159, 3310 lightyellow: 4294959359, 3311 lime: 16711935, 3312 limegreen: 852308735, 3313 linen: 4210091775, 3314 magenta: 4278255615, 3315 maroon: 2147483903, 3316 mediumaquamarine: 1724754687, 3317 mediumblue: 52735, 3318 mediumorchid: 3126187007, 3319 mediumpurple: 2473647103, 3320 mediumseagreen: 1018393087, 3321 mediumslateblue: 2070474495, 3322 mediumspringgreen: 16423679, 3323 mediumturquoise: 1221709055, 3324 mediumvioletred: 3340076543, 3325 midnightblue: 421097727, 3326 mintcream: 4127193855, 3327 mistyrose: 4293190143, 3328 moccasin: 4293178879, 3329 navajowhite: 4292783615, 3330 navy: 33023, 3331 oldlace: 4260751103, 3332 olive: 2155872511, 3333 olivedrab: 1804477439, 3334 orange: 4289003775, 3335 orangered: 4282712319, 3336 orchid: 3664828159, 3337 palegoldenrod: 4008225535, 3338 palegreen: 2566625535, 3339 paleturquoise: 2951671551, 3340 palevioletred: 3681588223, 3341 papayawhip: 4293907967, 3342 peachpuff: 4292524543, 3343 peru: 3448061951, 3344 pink: 4290825215, 3345 plum: 3718307327, 3346 powderblue: 2967529215, 3347 purple: 2147516671, 3348 rebeccapurple: 1714657791, 3349 red: 4278190335, 3350 rosybrown: 3163525119, 3351 royalblue: 1097458175, 3352 saddlebrown: 2336560127, 3353 salmon: 4202722047, 3354 sandybrown: 4104413439, 3355 seagreen: 780883967, 3356 seashell: 4294307583, 3357 sienna: 2689740287, 3358 silver: 3233857791, 3359 skyblue: 2278484991, 3360 slateblue: 1784335871, 3361 slategray: 1887473919, 3362 slategrey: 1887473919, 3363 snow: 4294638335, 3364 springgreen: 16744447, 3365 steelblue: 1182971135, 3366 tan: 3535047935, 3367 teal: 8421631, 3368 thistle: 3636451583, 3369 tomato: 4284696575, 3370 turquoise: 1088475391, 3371 violet: 4001558271, 3372 wheat: 4125012991, 3373 white: 4294967295, 3374 whitesmoke: 4126537215, 3375 yellow: 4294902015, 3376 yellowgreen: 2597139199 3377 }; 3378 var NUMBER = "[-+]?\\d*\\.?\\d+"; 3379 var PERCENTAGE = NUMBER + "%"; 3380 function call(...parts) { 3381 return "\\(\\s*(" + parts.join(")\\s*,\\s*(") + ")\\s*\\)"; 3382 } 3383 var rgb = new RegExp("rgb" + call(NUMBER, NUMBER, NUMBER)); 3384 var rgba = new RegExp("rgba" + call(NUMBER, NUMBER, NUMBER, NUMBER)); 3385 var hsl = new RegExp("hsl" + call(NUMBER, PERCENTAGE, PERCENTAGE)); 3386 var hsla = new RegExp("hsla" + call(NUMBER, PERCENTAGE, PERCENTAGE, NUMBER)); 3387 var hex3 = /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/; 3388 var hex4 = /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/; 3389 var hex6 = /^#([0-9a-fA-F]{6})$/; 3390 var hex8 = /^#([0-9a-fA-F]{8})$/; 3391 function normalizeColor(color) { 3392 let match3; 3393 if (typeof color === "number") { 3394 return color >>> 0 === color && color >= 0 && color <= 4294967295 ? color : null; 3395 } 3396 if (match3 = hex6.exec(color)) return parseInt(match3[1] + "ff", 16) >>> 0; 3397 if (colors$1 && colors$1[color] !== void 0) { 3398 return colors$1[color]; 3399 } 3400 if (match3 = rgb.exec(color)) { 3401 return (parse255(match3[1]) << 24 | parse255(match3[2]) << 16 | parse255(match3[3]) << 8 | 255) >>> 0; 3402 } 3403 if (match3 = rgba.exec(color)) { 3404 return (parse255(match3[1]) << 24 | parse255(match3[2]) << 16 | parse255(match3[3]) << 8 | parse1(match3[4])) >>> 0; 3405 } 3406 if (match3 = hex3.exec(color)) { 3407 return parseInt(match3[1] + match3[1] + match3[2] + match3[2] + match3[3] + match3[3] + "ff", 16) >>> 0; 3408 } 3409 if (match3 = hex8.exec(color)) return parseInt(match3[1], 16) >>> 0; 3410 if (match3 = hex4.exec(color)) { 3411 return parseInt(match3[1] + match3[1] + match3[2] + match3[2] + match3[3] + match3[3] + match3[4] + match3[4], 16) >>> 0; 3412 } 3413 if (match3 = hsl.exec(color)) { 3414 return (hslToRgb(parse360(match3[1]), parsePercentage(match3[2]), parsePercentage(match3[3])) | 255) >>> 0; 3415 } 3416 if (match3 = hsla.exec(color)) { 3417 return (hslToRgb(parse360(match3[1]), parsePercentage(match3[2]), parsePercentage(match3[3])) | parse1(match3[4])) >>> 0; 3418 } 3419 return null; 3420 } 3421 function hue2rgb(p3, q, t3) { 3422 if (t3 < 0) t3 += 1; 3423 if (t3 > 1) t3 -= 1; 3424 if (t3 < 1 / 6) return p3 + (q - p3) * 6 * t3; 3425 if (t3 < 1 / 2) return q; 3426 if (t3 < 2 / 3) return p3 + (q - p3) * (2 / 3 - t3) * 6; 3427 return p3; 3428 } 3429 function hslToRgb(h2, s2, l2) { 3430 const q = l2 < 0.5 ? l2 * (1 + s2) : l2 + s2 - l2 * s2; 3431 const p3 = 2 * l2 - q; 3432 const r3 = hue2rgb(p3, q, h2 + 1 / 3); 3433 const g2 = hue2rgb(p3, q, h2); 3434 const b2 = hue2rgb(p3, q, h2 - 1 / 3); 3435 return Math.round(r3 * 255) << 24 | Math.round(g2 * 255) << 16 | Math.round(b2 * 255) << 8; 3436 } 3437 function parse255(str) { 3438 const int = parseInt(str, 10); 3439 if (int < 0) return 0; 3440 if (int > 255) return 255; 3441 return int; 3442 } 3443 function parse360(str) { 3444 const int = parseFloat(str); 3445 return (int % 360 + 360) % 360 / 360; 3446 } 3447 function parse1(str) { 3448 const num = parseFloat(str); 3449 if (num < 0) return 0; 3450 if (num > 1) return 255; 3451 return Math.round(num * 255); 3452 } 3453 function parsePercentage(str) { 3454 const int = parseFloat(str); 3455 if (int < 0) return 0; 3456 if (int > 100) return 1; 3457 return int / 100; 3458 } 3459 function colorToRgba(input) { 3460 let int32Color = normalizeColor(input); 3461 if (int32Color === null) return input; 3462 int32Color = int32Color || 0; 3463 let r3 = (int32Color & 4278190080) >>> 24; 3464 let g2 = (int32Color & 16711680) >>> 16; 3465 let b2 = (int32Color & 65280) >>> 8; 3466 let a2 = (int32Color & 255) / 255; 3467 return `rgba($r3}, $g2}, $b2}, $a2})`; 3468 } 3469 var createInterpolator = (range, output, extrapolate) => { 3470 if (is.fun(range)) { 3471 return range; 3472 } 3473 if (is.arr(range)) { 3474 return createInterpolator({ 3475 range, 3476 output, 3477 extrapolate 3478 }); 3479 } 3480 if (is.str(range.output[0])) { 3481 return createStringInterpolator$1(range); 3482 } 3483 const config2 = range; 3484 const outputRange = config2.output; 3485 const inputRange = config2.range || [0, 1]; 3486 const extrapolateLeft = config2.extrapolateLeft || config2.extrapolate || "extend"; 3487 const extrapolateRight = config2.extrapolateRight || config2.extrapolate || "extend"; 3488 const easing = config2.easing || ((t3) => t3); 3489 return (input) => { 3490 const range2 = findRange(input, inputRange); 3491 return interpolate(input, inputRange[range2], inputRange[range2 + 1], outputRange[range2], outputRange[range2 + 1], easing, extrapolateLeft, extrapolateRight, config2.map); 3492 }; 3493 }; 3494 function interpolate(input, inputMin, inputMax, outputMin, outputMax, easing, extrapolateLeft, extrapolateRight, map) { 3495 let result = map ? map(input) : input; 3496 if (result < inputMin) { 3497 if (extrapolateLeft === "identity") return result; 3498 else if (extrapolateLeft === "clamp") result = inputMin; 3499 } 3500 if (result > inputMax) { 3501 if (extrapolateRight === "identity") return result; 3502 else if (extrapolateRight === "clamp") result = inputMax; 3503 } 3504 if (outputMin === outputMax) return outputMin; 3505 if (inputMin === inputMax) return input <= inputMin ? outputMin : outputMax; 3506 if (inputMin === -Infinity) result = -result; 3507 else if (inputMax === Infinity) result = result - inputMin; 3508 else result = (result - inputMin) / (inputMax - inputMin); 3509 result = easing(result); 3510 if (outputMin === -Infinity) result = -result; 3511 else if (outputMax === Infinity) result = result + outputMin; 3512 else result = result * (outputMax - outputMin) + outputMin; 3513 return result; 3514 } 3515 function findRange(input, inputRange) { 3516 for (var i2 = 1; i2 < inputRange.length - 1; ++i2) if (inputRange[i2] >= input) break; 3517 return i2 - 1; 3518 } 3519 function _extends() { 3520 _extends = Object.assign ? Object.assign.bind() : function(target) { 3521 for (var i2 = 1; i2 < arguments.length; i2++) { 3522 var source = arguments[i2]; 3523 for (var key in source) { 3524 if (Object.prototype.hasOwnProperty.call(source, key)) { 3525 target[key] = source[key]; 3526 } 3527 } 3528 } 3529 return target; 3530 }; 3531 return _extends.apply(this, arguments); 3532 } 3533 var $get = Symbol.for("FluidValue.get"); 3534 var $observers = Symbol.for("FluidValue.observers"); 3535 var hasFluidValue = (arg) => Boolean(arg && arg[$get]); 3536 var getFluidValue = (arg) => arg && arg[$get] ? arg[$get]() : arg; 3537 var getFluidObservers = (target) => target[$observers] || null; 3538 function callFluidObserver(observer, event) { 3539 if (observer.eventObserved) { 3540 observer.eventObserved(event); 3541 } else { 3542 observer(event); 3543 } 3544 } 3545 function callFluidObservers(target, event) { 3546 let observers = target[$observers]; 3547 if (observers) { 3548 observers.forEach((observer) => { 3549 callFluidObserver(observer, event); 3550 }); 3551 } 3552 } 3553 var FluidValue = class { 3554 constructor(get) { 3555 this[$get] = void 0; 3556 this[$observers] = void 0; 3557 if (!get && !(get = this.get)) { 3558 throw Error("Unknown getter"); 3559 } 3560 setFluidGetter(this, get); 3561 } 3562 }; 3563 var setFluidGetter = (target, get) => setHidden(target, $get, get); 3564 function addFluidObserver(target, observer) { 3565 if (target[$get]) { 3566 let observers = target[$observers]; 3567 if (!observers) { 3568 setHidden(target, $observers, observers = /* @__PURE__ */ new Set()); 3569 } 3570 if (!observers.has(observer)) { 3571 observers.add(observer); 3572 if (target.observerAdded) { 3573 target.observerAdded(observers.size, observer); 3574 } 3575 } 3576 } 3577 return observer; 3578 } 3579 function removeFluidObserver(target, observer) { 3580 let observers = target[$observers]; 3581 if (observers && observers.has(observer)) { 3582 const count = observers.size - 1; 3583 if (count) { 3584 observers.delete(observer); 3585 } else { 3586 target[$observers] = null; 3587 } 3588 if (target.observerRemoved) { 3589 target.observerRemoved(count, observer); 3590 } 3591 } 3592 } 3593 var setHidden = (target, key, value) => Object.defineProperty(target, key, { 3594 value, 3595 writable: true, 3596 configurable: true 3597 }); 3598 var numberRegex = /[+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?/g; 3599 var colorRegex = /(#(?:[0-9a-f]{2}){2,4}|(#[0-9a-f]{3})|(rgb|hsl)a?\((-?\d+%?[,\s]+){2,3}\s*[\d\.]+%?\))/gi; 3600 var unitRegex = new RegExp(`($numberRegex.source})(%|[a-z]+)`, "i"); 3601 var rgbaRegex = /rgba\(([0-9\.-]+), ([0-9\.-]+), ([0-9\.-]+), ([0-9\.-]+)\)/gi; 3602 var cssVariableRegex = /var\((--[a-zA-Z0-9-_]+),? ?([a-zA-Z0-9 ()%#.,-]+)?\)/; 3603 var variableToRgba = (input) => { 3604 const [token, fallback] = parseCSSVariable(input); 3605 if (!token || isSSR()) { 3606 return input; 3607 } 3608 const value = window.getComputedStyle(document.documentElement).getPropertyValue(token); 3609 if (value) { 3610 return value.trim(); 3611 } else if (fallback && fallback.startsWith("--")) { 3612 const _value = window.getComputedStyle(document.documentElement).getPropertyValue(fallback); 3613 if (_value) { 3614 return _value; 3615 } else { 3616 return input; 3617 } 3618 } else if (fallback && cssVariableRegex.test(fallback)) { 3619 return variableToRgba(fallback); 3620 } else if (fallback) { 3621 return fallback; 3622 } 3623 return input; 3624 }; 3625 var parseCSSVariable = (current) => { 3626 const match3 = cssVariableRegex.exec(current); 3627 if (!match3) return [,]; 3628 const [, token, fallback] = match3; 3629 return [token, fallback]; 3630 }; 3631 var namedColorRegex; 3632 var rgbaRound = (_, p1, p22, p3, p4) => `rgba($Math.round(p1)}, $Math.round(p22)}, $Math.round(p3)}, $p4})`; 3633 var createStringInterpolator = (config2) => { 3634 if (!namedColorRegex) namedColorRegex = colors$1 ? new RegExp(`($Object.keys(colors$1).join("|")})(?!\\w)`, "g") : /^\b$/; 3635 const output = config2.output.map((value) => { 3636 return getFluidValue(value).replace(cssVariableRegex, variableToRgba).replace(colorRegex, colorToRgba).replace(namedColorRegex, colorToRgba); 3637 }); 3638 const keyframes = output.map((value) => value.match(numberRegex).map(Number)); 3639 const outputRanges = keyframes[0].map((_, i2) => keyframes.map((values) => { 3640 if (!(i2 in values)) { 3641 throw Error('The arity of each "output" value must be equal'); 3642 } 3643 return values[i2]; 3644 })); 3645 const interpolators = outputRanges.map((output2) => createInterpolator(_extends({}, config2, { 3646 output: output2 3647 }))); 3648 return (input) => { 3649 var _output$find; 3650 const missingUnit = !unitRegex.test(output[0]) && ((_output$find = output.find((value) => unitRegex.test(value))) == null ? void 0 : _output$find.replace(numberRegex, "")); 3651 let i2 = 0; 3652 return output[0].replace(numberRegex, () => `$interpolators[i2++](input)}$missingUnit || ""}`).replace(rgbaRegex, rgbaRound); 3653 }; 3654 }; 3655 var prefix = "react-spring: "; 3656 var once = (fn) => { 3657 const func = fn; 3658 let called = false; 3659 if (typeof func != "function") { 3660 throw new TypeError(`$prefix}once requires a function parameter`); 3661 } 3662 return (...args) => { 3663 if (!called) { 3664 func(...args); 3665 called = true; 3666 } 3667 }; 3668 }; 3669 var warnInterpolate = once(console.warn); 3670 function deprecateInterpolate() { 3671 warnInterpolate(`$prefix}The "interpolate" function is deprecated in v9 (use "to" instead)`); 3672 } 3673 var warnDirectCall = once(console.warn); 3674 function isAnimatedString(value) { 3675 return is.str(value) && (value[0] == "#" || /\d/.test(value) || !isSSR() && cssVariableRegex.test(value) || value in (colors$1 || {})); 3676 } 3677 var useIsomorphicLayoutEffect = isSSR() ? import_react.useEffect : import_react.useLayoutEffect; 3678 var useIsMounted = () => { 3679 const isMounted = (0, import_react.useRef)(false); 3680 useIsomorphicLayoutEffect(() => { 3681 isMounted.current = true; 3682 return () => { 3683 isMounted.current = false; 3684 }; 3685 }, []); 3686 return isMounted; 3687 }; 3688 function useForceUpdate() { 3689 const update3 = (0, import_react.useState)()[1]; 3690 const isMounted = useIsMounted(); 3691 return () => { 3692 if (isMounted.current) { 3693 update3(Math.random()); 3694 } 3695 }; 3696 } 3697 function useMemoOne(getResult, inputs) { 3698 const [initial] = (0, import_react.useState)(() => ({ 3699 inputs, 3700 result: getResult() 3701 })); 3702 const committed = (0, import_react.useRef)(); 3703 const prevCache = committed.current; 3704 let cache = prevCache; 3705 if (cache) { 3706 const useCache = Boolean(inputs && cache.inputs && areInputsEqual(inputs, cache.inputs)); 3707 if (!useCache) { 3708 cache = { 3709 inputs, 3710 result: getResult() 3711 }; 3712 } 3713 } else { 3714 cache = initial; 3715 } 3716 (0, import_react.useEffect)(() => { 3717 committed.current = cache; 3718 if (prevCache == initial) { 3719 initial.inputs = initial.result = void 0; 3720 } 3721 }, [cache]); 3722 return cache.result; 3723 } 3724 function areInputsEqual(next, prev) { 3725 if (next.length !== prev.length) { 3726 return false; 3727 } 3728 for (let i2 = 0; i2 < next.length; i2++) { 3729 if (next[i2] !== prev[i2]) { 3730 return false; 3731 } 3732 } 3733 return true; 3734 } 3735 var useOnce = (effect) => (0, import_react.useEffect)(effect, emptyDeps); 3736 var emptyDeps = []; 3737 3738 // node_modules/@react-spring/core/dist/react-spring-core.esm.js 3739 var React2 = __toESM(require_react()); 3740 var import_react3 = __toESM(require_react()); 3741 3742 // node_modules/@react-spring/animated/dist/react-spring-animated.esm.js 3743 var React = __toESM(require_react()); 3744 var import_react2 = __toESM(require_react()); 3745 var $node = Symbol.for("Animated:node"); 3746 var isAnimated = (value) => !!value && value[$node] === value; 3747 var getAnimated = (owner) => owner && owner[$node]; 3748 var setAnimated = (owner, node) => defineHidden(owner, $node, node); 3749 var getPayload = (owner) => owner && owner[$node] && owner[$node].getPayload(); 3750 var Animated = class { 3751 constructor() { 3752 this.payload = void 0; 3753 setAnimated(this, this); 3754 } 3755 getPayload() { 3756 return this.payload || []; 3757 } 3758 }; 3759 var AnimatedValue = class _AnimatedValue extends Animated { 3760 constructor(_value) { 3761 super(); 3762 this.done = true; 3763 this.elapsedTime = void 0; 3764 this.lastPosition = void 0; 3765 this.lastVelocity = void 0; 3766 this.v0 = void 0; 3767 this.durationProgress = 0; 3768 this._value = _value; 3769 if (is.num(this._value)) { 3770 this.lastPosition = this._value; 3771 } 3772 } 3773 static create(value) { 3774 return new _AnimatedValue(value); 3775 } 3776 getPayload() { 3777 return [this]; 3778 } 3779 getValue() { 3780 return this._value; 3781 } 3782 setValue(value, step) { 3783 if (is.num(value)) { 3784 this.lastPosition = value; 3785 if (step) { 3786 value = Math.round(value / step) * step; 3787 if (this.done) { 3788 this.lastPosition = value; 3789 } 3790 } 3791 } 3792 if (this._value === value) { 3793 return false; 3794 } 3795 this._value = value; 3796 return true; 3797 } 3798 reset() { 3799 const { 3800 done 3801 } = this; 3802 this.done = false; 3803 if (is.num(this._value)) { 3804 this.elapsedTime = 0; 3805 this.durationProgress = 0; 3806 this.lastPosition = this._value; 3807 if (done) this.lastVelocity = null; 3808 this.v0 = null; 3809 } 3810 } 3811 }; 3812 var AnimatedString = class _AnimatedString extends AnimatedValue { 3813 constructor(value) { 3814 super(0); 3815 this._string = null; 3816 this._toString = void 0; 3817 this._toString = createInterpolator({ 3818 output: [value, value] 3819 }); 3820 } 3821 static create(value) { 3822 return new _AnimatedString(value); 3823 } 3824 getValue() { 3825 let value = this._string; 3826 return value == null ? this._string = this._toString(this._value) : value; 3827 } 3828 setValue(value) { 3829 if (is.str(value)) { 3830 if (value == this._string) { 3831 return false; 3832 } 3833 this._string = value; 3834 this._value = 1; 3835 } else if (super.setValue(value)) { 3836 this._string = null; 3837 } else { 3838 return false; 3839 } 3840 return true; 3841 } 3842 reset(goal) { 3843 if (goal) { 3844 this._toString = createInterpolator({ 3845 output: [this.getValue(), goal] 3846 }); 3847 } 3848 this._value = 0; 3849 super.reset(); 3850 } 3851 }; 3852 var TreeContext = { 3853 dependencies: null 3854 }; 3855 var AnimatedObject = class extends Animated { 3856 constructor(source) { 3857 super(); 3858 this.source = source; 3859 this.setValue(source); 3860 } 3861 getValue(animated2) { 3862 const values = {}; 3863 eachProp(this.source, (source, key) => { 3864 if (isAnimated(source)) { 3865 values[key] = source.getValue(animated2); 3866 } else if (hasFluidValue(source)) { 3867 values[key] = getFluidValue(source); 3868 } else if (!animated2) { 3869 values[key] = source; 3870 } 3871 }); 3872 return values; 3873 } 3874 setValue(source) { 3875 this.source = source; 3876 this.payload = this._makePayload(source); 3877 } 3878 reset() { 3879 if (this.payload) { 3880 each(this.payload, (node) => node.reset()); 3881 } 3882 } 3883 _makePayload(source) { 3884 if (source) { 3885 const payload = /* @__PURE__ */ new Set(); 3886 eachProp(source, this._addToPayload, payload); 3887 return Array.from(payload); 3888 } 3889 } 3890 _addToPayload(source) { 3891 if (TreeContext.dependencies && hasFluidValue(source)) { 3892 TreeContext.dependencies.add(source); 3893 } 3894 const payload = getPayload(source); 3895 if (payload) { 3896 each(payload, (node) => this.add(node)); 3897 } 3898 } 3899 }; 3900 var AnimatedArray = class _AnimatedArray extends AnimatedObject { 3901 constructor(source) { 3902 super(source); 3903 } 3904 static create(source) { 3905 return new _AnimatedArray(source); 3906 } 3907 getValue() { 3908 return this.source.map((node) => node.getValue()); 3909 } 3910 setValue(source) { 3911 const payload = this.getPayload(); 3912 if (source.length == payload.length) { 3913 return payload.map((node, i2) => node.setValue(source[i2])).some(Boolean); 3914 } 3915 super.setValue(source.map(makeAnimated)); 3916 return true; 3917 } 3918 }; 3919 function makeAnimated(value) { 3920 const nodeType = isAnimatedString(value) ? AnimatedString : AnimatedValue; 3921 return nodeType.create(value); 3922 } 3923 function getAnimatedType(value) { 3924 const parentNode = getAnimated(value); 3925 return parentNode ? parentNode.constructor : is.arr(value) ? AnimatedArray : isAnimatedString(value) ? AnimatedString : AnimatedValue; 3926 } 3927 function _extends2() { 3928 _extends2 = Object.assign ? Object.assign.bind() : function(target) { 3929 for (var i2 = 1; i2 < arguments.length; i2++) { 3930 var source = arguments[i2]; 3931 for (var key in source) { 3932 if (Object.prototype.hasOwnProperty.call(source, key)) { 3933 target[key] = source[key]; 3934 } 3935 } 3936 } 3937 return target; 3938 }; 3939 return _extends2.apply(this, arguments); 3940 } 3941 var withAnimated = (Component, host2) => { 3942 const hasInstance = !is.fun(Component) || Component.prototype && Component.prototype.isReactComponent; 3943 return (0, import_react2.forwardRef)((givenProps, givenRef) => { 3944 const instanceRef = (0, import_react2.useRef)(null); 3945 const ref = hasInstance && (0, import_react2.useCallback)((value) => { 3946 instanceRef.current = updateRef(givenRef, value); 3947 }, [givenRef]); 3948 const [props, deps] = getAnimatedState(givenProps, host2); 3949 const forceUpdate = useForceUpdate(); 3950 const callback = () => { 3951 const instance = instanceRef.current; 3952 if (hasInstance && !instance) { 3953 return; 3954 } 3955 const didUpdate = instance ? host2.applyAnimatedValues(instance, props.getValue(true)) : false; 3956 if (didUpdate === false) { 3957 forceUpdate(); 3958 } 3959 }; 3960 const observer = new PropsObserver(callback, deps); 3961 const observerRef = (0, import_react2.useRef)(); 3962 useIsomorphicLayoutEffect(() => { 3963 observerRef.current = observer; 3964 each(deps, (dep) => addFluidObserver(dep, observer)); 3965 return () => { 3966 if (observerRef.current) { 3967 each(observerRef.current.deps, (dep) => removeFluidObserver(dep, observerRef.current)); 3968 raf.cancel(observerRef.current.update); 3969 } 3970 }; 3971 }); 3972 (0, import_react2.useEffect)(callback, []); 3973 useOnce(() => () => { 3974 const observer2 = observerRef.current; 3975 each(observer2.deps, (dep) => removeFluidObserver(dep, observer2)); 3976 }); 3977 const usedProps = host2.getComponentProps(props.getValue()); 3978 return React.createElement(Component, _extends2({}, usedProps, { 3979 ref 3980 })); 3981 }); 3982 }; 3983 var PropsObserver = class { 3984 constructor(update3, deps) { 3985 this.update = update3; 3986 this.deps = deps; 3987 } 3988 eventObserved(event) { 3989 if (event.type == "change") { 3990 raf.write(this.update); 3991 } 3992 } 3993 }; 3994 function getAnimatedState(props, host2) { 3995 const dependencies = /* @__PURE__ */ new Set(); 3996 TreeContext.dependencies = dependencies; 3997 if (props.style) props = _extends2({}, props, { 3998 style: host2.createAnimatedStyle(props.style) 3999 }); 4000 props = new AnimatedObject(props); 4001 TreeContext.dependencies = null; 4002 return [props, dependencies]; 4003 } 4004 function updateRef(ref, value) { 4005 if (ref) { 4006 if (is.fun(ref)) ref(value); 4007 else ref.current = value; 4008 } 4009 return value; 4010 } 4011 var cacheKey = Symbol.for("AnimatedComponent"); 4012 var createHost = (components, { 4013 applyAnimatedValues: _applyAnimatedValues = () => false, 4014 createAnimatedStyle: _createAnimatedStyle = (style) => new AnimatedObject(style), 4015 getComponentProps: _getComponentProps = (props) => props 4016 } = {}) => { 4017 const hostConfig = { 4018 applyAnimatedValues: _applyAnimatedValues, 4019 createAnimatedStyle: _createAnimatedStyle, 4020 getComponentProps: _getComponentProps 4021 }; 4022 const animated2 = (Component) => { 4023 const displayName = getDisplayName(Component) || "Anonymous"; 4024 if (is.str(Component)) { 4025 Component = animated2[Component] || (animated2[Component] = withAnimated(Component, hostConfig)); 4026 } else { 4027 Component = Component[cacheKey] || (Component[cacheKey] = withAnimated(Component, hostConfig)); 4028 } 4029 Component.displayName = `Animated($displayName})`; 4030 return Component; 4031 }; 4032 eachProp(components, (Component, key) => { 4033 if (is.arr(components)) { 4034 key = getDisplayName(Component); 4035 } 4036 animated2[key] = animated2(Component); 4037 }); 4038 return { 4039 animated: animated2 4040 }; 4041 }; 4042 var getDisplayName = (arg) => is.str(arg) ? arg : arg && is.str(arg.displayName) ? arg.displayName : is.fun(arg) && arg.name || null; 4043 4044 // node_modules/@react-spring/core/dist/react-spring-core.esm.js 4045 function _extends3() { 4046 _extends3 = Object.assign ? Object.assign.bind() : function(target) { 4047 for (var i2 = 1; i2 < arguments.length; i2++) { 4048 var source = arguments[i2]; 4049 for (var key in source) { 4050 if (Object.prototype.hasOwnProperty.call(source, key)) { 4051 target[key] = source[key]; 4052 } 4053 } 4054 } 4055 return target; 4056 }; 4057 return _extends3.apply(this, arguments); 4058 } 4059 function callProp(value, ...args) { 4060 return is.fun(value) ? value(...args) : value; 4061 } 4062 var matchProp = (value, key) => value === true || !!(key && value && (is.fun(value) ? value(key) : toArray(value).includes(key))); 4063 var resolveProp = (prop, key) => is.obj(prop) ? key && prop[key] : prop; 4064 var getDefaultProp = (props, key) => props.default === true ? props[key] : props.default ? props.default[key] : void 0; 4065 var noopTransform = (value) => value; 4066 var getDefaultProps = (props, transform = noopTransform) => { 4067 let keys = DEFAULT_PROPS; 4068 if (props.default && props.default !== true) { 4069 props = props.default; 4070 keys = Object.keys(props); 4071 } 4072 const defaults2 = {}; 4073 for (const key of keys) { 4074 const value = transform(props[key], key); 4075 if (!is.und(value)) { 4076 defaults2[key] = value; 4077 } 4078 } 4079 return defaults2; 4080 }; 4081 var DEFAULT_PROPS = ["config", "onProps", "onStart", "onChange", "onPause", "onResume", "onRest"]; 4082 var RESERVED_PROPS = { 4083 config: 1, 4084 from: 1, 4085 to: 1, 4086 ref: 1, 4087 loop: 1, 4088 reset: 1, 4089 pause: 1, 4090 cancel: 1, 4091 reverse: 1, 4092 immediate: 1, 4093 default: 1, 4094 delay: 1, 4095 onProps: 1, 4096 onStart: 1, 4097 onChange: 1, 4098 onPause: 1, 4099 onResume: 1, 4100 onRest: 1, 4101 onResolve: 1, 4102 items: 1, 4103 trail: 1, 4104 sort: 1, 4105 expires: 1, 4106 initial: 1, 4107 enter: 1, 4108 update: 1, 4109 leave: 1, 4110 children: 1, 4111 onDestroyed: 1, 4112 keys: 1, 4113 callId: 1, 4114 parentId: 1 4115 }; 4116 function getForwardProps(props) { 4117 const forward = {}; 4118 let count = 0; 4119 eachProp(props, (value, prop) => { 4120 if (!RESERVED_PROPS[prop]) { 4121 forward[prop] = value; 4122 count++; 4123 } 4124 }); 4125 if (count) { 4126 return forward; 4127 } 4128 } 4129 function inferTo(props) { 4130 const to2 = getForwardProps(props); 4131 if (to2) { 4132 const out = { 4133 to: to2 4134 }; 4135 eachProp(props, (val, key) => key in to2 || (out[key] = val)); 4136 return out; 4137 } 4138 return _extends3({}, props); 4139 } 4140 function computeGoal(value) { 4141 value = getFluidValue(value); 4142 return is.arr(value) ? value.map(computeGoal) : isAnimatedString(value) ? globals.createStringInterpolator({ 4143 range: [0, 1], 4144 output: [value, value] 4145 })(1) : value; 4146 } 4147 function isAsyncTo(to2) { 4148 return is.fun(to2) || is.arr(to2) && is.obj(to2[0]); 4149 } 4150 var config = { 4151 default: { 4152 tension: 170, 4153 friction: 26 4154 }, 4155 gentle: { 4156 tension: 120, 4157 friction: 14 4158 }, 4159 wobbly: { 4160 tension: 180, 4161 friction: 12 4162 }, 4163 stiff: { 4164 tension: 210, 4165 friction: 20 4166 }, 4167 slow: { 4168 tension: 280, 4169 friction: 60 4170 }, 4171 molasses: { 4172 tension: 280, 4173 friction: 120 4174 } 4175 }; 4176 var c1 = 1.70158; 4177 var c2 = c1 * 1.525; 4178 var c3 = c1 + 1; 4179 var c4 = 2 * Math.PI / 3; 4180 var c5 = 2 * Math.PI / 4.5; 4181 var bounceOut = (x2) => { 4182 const n1 = 7.5625; 4183 const d1 = 2.75; 4184 if (x2 < 1 / d1) { 4185 return n1 * x2 * x2; 4186 } else if (x2 < 2 / d1) { 4187 return n1 * (x2 -= 1.5 / d1) * x2 + 0.75; 4188 } else if (x2 < 2.5 / d1) { 4189 return n1 * (x2 -= 2.25 / d1) * x2 + 0.9375; 4190 } else { 4191 return n1 * (x2 -= 2.625 / d1) * x2 + 0.984375; 4192 } 4193 }; 4194 var easings = { 4195 linear: (x2) => x2, 4196 easeInQuad: (x2) => x2 * x2, 4197 easeOutQuad: (x2) => 1 - (1 - x2) * (1 - x2), 4198 easeInOutQuad: (x2) => x2 < 0.5 ? 2 * x2 * x2 : 1 - Math.pow(-2 * x2 + 2, 2) / 2, 4199 easeInCubic: (x2) => x2 * x2 * x2, 4200 easeOutCubic: (x2) => 1 - Math.pow(1 - x2, 3), 4201 easeInOutCubic: (x2) => x2 < 0.5 ? 4 * x2 * x2 * x2 : 1 - Math.pow(-2 * x2 + 2, 3) / 2, 4202 easeInQuart: (x2) => x2 * x2 * x2 * x2, 4203 easeOutQuart: (x2) => 1 - Math.pow(1 - x2, 4), 4204 easeInOutQuart: (x2) => x2 < 0.5 ? 8 * x2 * x2 * x2 * x2 : 1 - Math.pow(-2 * x2 + 2, 4) / 2, 4205 easeInQuint: (x2) => x2 * x2 * x2 * x2 * x2, 4206 easeOutQuint: (x2) => 1 - Math.pow(1 - x2, 5), 4207 easeInOutQuint: (x2) => x2 < 0.5 ? 16 * x2 * x2 * x2 * x2 * x2 : 1 - Math.pow(-2 * x2 + 2, 5) / 2, 4208 easeInSine: (x2) => 1 - Math.cos(x2 * Math.PI / 2), 4209 easeOutSine: (x2) => Math.sin(x2 * Math.PI / 2), 4210 easeInOutSine: (x2) => -(Math.cos(Math.PI * x2) - 1) / 2, 4211 easeInExpo: (x2) => x2 === 0 ? 0 : Math.pow(2, 10 * x2 - 10), 4212 easeOutExpo: (x2) => x2 === 1 ? 1 : 1 - Math.pow(2, -10 * x2), 4213 easeInOutExpo: (x2) => x2 === 0 ? 0 : x2 === 1 ? 1 : x2 < 0.5 ? Math.pow(2, 20 * x2 - 10) / 2 : (2 - Math.pow(2, -20 * x2 + 10)) / 2, 4214 easeInCirc: (x2) => 1 - Math.sqrt(1 - Math.pow(x2, 2)), 4215 easeOutCirc: (x2) => Math.sqrt(1 - Math.pow(x2 - 1, 2)), 4216 easeInOutCirc: (x2) => x2 < 0.5 ? (1 - Math.sqrt(1 - Math.pow(2 * x2, 2))) / 2 : (Math.sqrt(1 - Math.pow(-2 * x2 + 2, 2)) + 1) / 2, 4217 easeInBack: (x2) => c3 * x2 * x2 * x2 - c1 * x2 * x2, 4218 easeOutBack: (x2) => 1 + c3 * Math.pow(x2 - 1, 3) + c1 * Math.pow(x2 - 1, 2), 4219 easeInOutBack: (x2) => x2 < 0.5 ? Math.pow(2 * x2, 2) * ((c2 + 1) * 2 * x2 - c2) / 2 : (Math.pow(2 * x2 - 2, 2) * ((c2 + 1) * (x2 * 2 - 2) + c2) + 2) / 2, 4220 easeInElastic: (x2) => x2 === 0 ? 0 : x2 === 1 ? 1 : -Math.pow(2, 10 * x2 - 10) * Math.sin((x2 * 10 - 10.75) * c4), 4221 easeOutElastic: (x2) => x2 === 0 ? 0 : x2 === 1 ? 1 : Math.pow(2, -10 * x2) * Math.sin((x2 * 10 - 0.75) * c4) + 1, 4222 easeInOutElastic: (x2) => x2 === 0 ? 0 : x2 === 1 ? 1 : x2 < 0.5 ? -(Math.pow(2, 20 * x2 - 10) * Math.sin((20 * x2 - 11.125) * c5)) / 2 : Math.pow(2, -20 * x2 + 10) * Math.sin((20 * x2 - 11.125) * c5) / 2 + 1, 4223 easeInBounce: (x2) => 1 - bounceOut(1 - x2), 4224 easeOutBounce: bounceOut, 4225 easeInOutBounce: (x2) => x2 < 0.5 ? (1 - bounceOut(1 - 2 * x2)) / 2 : (1 + bounceOut(2 * x2 - 1)) / 2 4226 }; 4227 var defaults = _extends3({}, config.default, { 4228 mass: 1, 4229 damping: 1, 4230 easing: easings.linear, 4231 clamp: false 4232 }); 4233 var AnimationConfig = class { 4234 constructor() { 4235 this.tension = void 0; 4236 this.friction = void 0; 4237 this.frequency = void 0; 4238 this.damping = void 0; 4239 this.mass = void 0; 4240 this.velocity = 0; 4241 this.restVelocity = void 0; 4242 this.precision = void 0; 4243 this.progress = void 0; 4244 this.duration = void 0; 4245 this.easing = void 0; 4246 this.clamp = void 0; 4247 this.bounce = void 0; 4248 this.decay = void 0; 4249 this.round = void 0; 4250 Object.assign(this, defaults); 4251 } 4252 }; 4253 function mergeConfig(config2, newConfig, defaultConfig) { 4254 if (defaultConfig) { 4255 defaultConfig = _extends3({}, defaultConfig); 4256 sanitizeConfig(defaultConfig, newConfig); 4257 newConfig = _extends3({}, defaultConfig, newConfig); 4258 } 4259 sanitizeConfig(config2, newConfig); 4260 Object.assign(config2, newConfig); 4261 for (const key in defaults) { 4262 if (config2[key] == null) { 4263 config2[key] = defaults[key]; 4264 } 4265 } 4266 let { 4267 mass, 4268 frequency, 4269 damping 4270 } = config2; 4271 if (!is.und(frequency)) { 4272 if (frequency < 0.01) frequency = 0.01; 4273 if (damping < 0) damping = 0; 4274 config2.tension = Math.pow(2 * Math.PI / frequency, 2) * mass; 4275 config2.friction = 4 * Math.PI * damping * mass / frequency; 4276 } 4277 return config2; 4278 } 4279 function sanitizeConfig(config2, props) { 4280 if (!is.und(props.decay)) { 4281 config2.duration = void 0; 4282 } else { 4283 const isTensionConfig = !is.und(props.tension) || !is.und(props.friction); 4284 if (isTensionConfig || !is.und(props.frequency) || !is.und(props.damping) || !is.und(props.mass)) { 4285 config2.duration = void 0; 4286 config2.decay = void 0; 4287 } 4288 if (isTensionConfig) { 4289 config2.frequency = void 0; 4290 } 4291 } 4292 } 4293 var emptyArray = []; 4294 var Animation = class { 4295 constructor() { 4296 this.changed = false; 4297 this.values = emptyArray; 4298 this.toValues = null; 4299 this.fromValues = emptyArray; 4300 this.to = void 0; 4301 this.from = void 0; 4302 this.config = new AnimationConfig(); 4303 this.immediate = false; 4304 } 4305 }; 4306 function scheduleProps(callId, { 4307 key, 4308 props, 4309 defaultProps, 4310 state, 4311 actions 4312 }) { 4313 return new Promise((resolve, reject) => { 4314 var _props$cancel; 4315 let delay; 4316 let timeout; 4317 let cancel = matchProp((_props$cancel = props.cancel) != null ? _props$cancel : defaultProps == null ? void 0 : defaultProps.cancel, key); 4318 if (cancel) { 4319 onStart(); 4320 } else { 4321 if (!is.und(props.pause)) { 4322 state.paused = matchProp(props.pause, key); 4323 } 4324 let pause = defaultProps == null ? void 0 : defaultProps.pause; 4325 if (pause !== true) { 4326 pause = state.paused || matchProp(pause, key); 4327 } 4328 delay = callProp(props.delay || 0, key); 4329 if (pause) { 4330 state.resumeQueue.add(onResume); 4331 actions.pause(); 4332 } else { 4333 actions.resume(); 4334 onResume(); 4335 } 4336 } 4337 function onPause() { 4338 state.resumeQueue.add(onResume); 4339 state.timeouts.delete(timeout); 4340 timeout.cancel(); 4341 delay = timeout.time - raf.now(); 4342 } 4343 function onResume() { 4344 if (delay > 0 && !globals.skipAnimation) { 4345 state.delayed = true; 4346 timeout = raf.setTimeout(onStart, delay); 4347 state.pauseQueue.add(onPause); 4348 state.timeouts.add(timeout); 4349 } else { 4350 onStart(); 4351 } 4352 } 4353 function onStart() { 4354 if (state.delayed) { 4355 state.delayed = false; 4356 } 4357 state.pauseQueue.delete(onPause); 4358 state.timeouts.delete(timeout); 4359 if (callId <= (state.cancelId || 0)) { 4360 cancel = true; 4361 } 4362 try { 4363 actions.start(_extends3({}, props, { 4364 callId, 4365 cancel 4366 }), resolve); 4367 } catch (err) { 4368 reject(err); 4369 } 4370 } 4371 }); 4372 } 4373 var getCombinedResult = (target, results) => results.length == 1 ? results[0] : results.some((result) => result.cancelled) ? getCancelledResult(target.get()) : results.every((result) => result.noop) ? getNoopResult(target.get()) : getFinishedResult(target.get(), results.every((result) => result.finished)); 4374 var getNoopResult = (value) => ({ 4375 value, 4376 noop: true, 4377 finished: true, 4378 cancelled: false 4379 }); 4380 var getFinishedResult = (value, finished, cancelled = false) => ({ 4381 value, 4382 finished, 4383 cancelled 4384 }); 4385 var getCancelledResult = (value) => ({ 4386 value, 4387 cancelled: true, 4388 finished: false 4389 }); 4390 function runAsync(to2, props, state, target) { 4391 const { 4392 callId, 4393 parentId, 4394 onRest 4395 } = props; 4396 const { 4397 asyncTo: prevTo, 4398 promise: prevPromise 4399 } = state; 4400 if (!parentId && to2 === prevTo && !props.reset) { 4401 return prevPromise; 4402 } 4403 return state.promise = (async () => { 4404 state.asyncId = callId; 4405 state.asyncTo = to2; 4406 const defaultProps = getDefaultProps(props, (value, key) => key === "onRest" ? void 0 : value); 4407 let preventBail; 4408 let bail; 4409 const bailPromise = new Promise((resolve, reject) => (preventBail = resolve, bail = reject)); 4410 const bailIfEnded = (bailSignal) => { 4411 const bailResult = callId <= (state.cancelId || 0) && getCancelledResult(target) || callId !== state.asyncId && getFinishedResult(target, false); 4412 if (bailResult) { 4413 bailSignal.result = bailResult; 4414 bail(bailSignal); 4415 throw bailSignal; 4416 } 4417 }; 4418 const animate = (arg1, arg2) => { 4419 const bailSignal = new BailSignal(); 4420 const skipAnimationSignal = new SkipAniamtionSignal(); 4421 return (async () => { 4422 if (globals.skipAnimation) { 4423 stopAsync(state); 4424 skipAnimationSignal.result = getFinishedResult(target, false); 4425 bail(skipAnimationSignal); 4426 throw skipAnimationSignal; 4427 } 4428 bailIfEnded(bailSignal); 4429 const props2 = is.obj(arg1) ? _extends3({}, arg1) : _extends3({}, arg2, { 4430 to: arg1 4431 }); 4432 props2.parentId = callId; 4433 eachProp(defaultProps, (value, key) => { 4434 if (is.und(props2[key])) { 4435 props2[key] = value; 4436 } 4437 }); 4438 const result2 = await target.start(props2); 4439 bailIfEnded(bailSignal); 4440 if (state.paused) { 4441 await new Promise((resume) => { 4442 state.resumeQueue.add(resume); 4443 }); 4444 } 4445 return result2; 4446 })(); 4447 }; 4448 let result; 4449 if (globals.skipAnimation) { 4450 stopAsync(state); 4451 return getFinishedResult(target, false); 4452 } 4453 try { 4454 let animating; 4455 if (is.arr(to2)) { 4456 animating = (async (queue) => { 4457 for (const props2 of queue) { 4458 await animate(props2); 4459 } 4460 })(to2); 4461 } else { 4462 animating = Promise.resolve(to2(animate, target.stop.bind(target))); 4463 } 4464 await Promise.all([animating.then(preventBail), bailPromise]); 4465 result = getFinishedResult(target.get(), true, false); 4466 } catch (err) { 4467 if (err instanceof BailSignal) { 4468 result = err.result; 4469 } else if (err instanceof SkipAniamtionSignal) { 4470 result = err.result; 4471 } else { 4472 throw err; 4473 } 4474 } finally { 4475 if (callId == state.asyncId) { 4476 state.asyncId = parentId; 4477 state.asyncTo = parentId ? prevTo : void 0; 4478 state.promise = parentId ? prevPromise : void 0; 4479 } 4480 } 4481 if (is.fun(onRest)) { 4482 raf.batchedUpdates(() => { 4483 onRest(result, target, target.item); 4484 }); 4485 } 4486 return result; 4487 })(); 4488 } 4489 function stopAsync(state, cancelId) { 4490 flush(state.timeouts, (t3) => t3.cancel()); 4491 state.pauseQueue.clear(); 4492 state.resumeQueue.clear(); 4493 state.asyncId = state.asyncTo = state.promise = void 0; 4494 if (cancelId) state.cancelId = cancelId; 4495 } 4496 var BailSignal = class extends Error { 4497 constructor() { 4498 super("An async animation has been interrupted. You see this error because you forgot to use `await` or `.catch(...)` on its returned promise."); 4499 this.result = void 0; 4500 } 4501 }; 4502 var SkipAniamtionSignal = class extends Error { 4503 constructor() { 4504 super("SkipAnimationSignal"); 4505 this.result = void 0; 4506 } 4507 }; 4508 var isFrameValue = (value) => value instanceof FrameValue; 4509 var nextId$1 = 1; 4510 var FrameValue = class extends FluidValue { 4511 constructor(...args) { 4512 super(...args); 4513 this.id = nextId$1++; 4514 this.key = void 0; 4515 this._priority = 0; 4516 } 4517 get priority() { 4518 return this._priority; 4519 } 4520 set priority(priority2) { 4521 if (this._priority != priority2) { 4522 this._priority = priority2; 4523 this._onPriorityChange(priority2); 4524 } 4525 } 4526 get() { 4527 const node = getAnimated(this); 4528 return node && node.getValue(); 4529 } 4530 to(...args) { 4531 return globals.to(this, args); 4532 } 4533 interpolate(...args) { 4534 deprecateInterpolate(); 4535 return globals.to(this, args); 4536 } 4537 toJSON() { 4538 return this.get(); 4539 } 4540 observerAdded(count) { 4541 if (count == 1) this._attach(); 4542 } 4543 observerRemoved(count) { 4544 if (count == 0) this._detach(); 4545 } 4546 _attach() { 4547 } 4548 _detach() { 4549 } 4550 _onChange(value, idle = false) { 4551 callFluidObservers(this, { 4552 type: "change", 4553 parent: this, 4554 value, 4555 idle 4556 }); 4557 } 4558 _onPriorityChange(priority2) { 4559 if (!this.idle) { 4560 frameLoop.sort(this); 4561 } 4562 callFluidObservers(this, { 4563 type: "priority", 4564 parent: this, 4565 priority: priority2 4566 }); 4567 } 4568 }; 4569 var $P = Symbol.for("SpringPhase"); 4570 var HAS_ANIMATED = 1; 4571 var IS_ANIMATING = 2; 4572 var IS_PAUSED = 4; 4573 var hasAnimated = (target) => (target[$P] & HAS_ANIMATED) > 0; 4574 var isAnimating = (target) => (target[$P] & IS_ANIMATING) > 0; 4575 var isPaused = (target) => (target[$P] & IS_PAUSED) > 0; 4576 var setActiveBit = (target, active) => active ? target[$P] |= IS_ANIMATING | HAS_ANIMATED : target[$P] &= ~IS_ANIMATING; 4577 var setPausedBit = (target, paused) => paused ? target[$P] |= IS_PAUSED : target[$P] &= ~IS_PAUSED; 4578 var SpringValue = class extends FrameValue { 4579 constructor(arg1, arg2) { 4580 super(); 4581 this.key = void 0; 4582 this.animation = new Animation(); 4583 this.queue = void 0; 4584 this.defaultProps = {}; 4585 this._state = { 4586 paused: false, 4587 delayed: false, 4588 pauseQueue: /* @__PURE__ */ new Set(), 4589 resumeQueue: /* @__PURE__ */ new Set(), 4590 timeouts: /* @__PURE__ */ new Set() 4591 }; 4592 this._pendingCalls = /* @__PURE__ */ new Set(); 4593 this._lastCallId = 0; 4594 this._lastToId = 0; 4595 this._memoizedDuration = 0; 4596 if (!is.und(arg1) || !is.und(arg2)) { 4597 const props = is.obj(arg1) ? _extends3({}, arg1) : _extends3({}, arg2, { 4598 from: arg1 4599 }); 4600 if (is.und(props.default)) { 4601 props.default = true; 4602 } 4603 this.start(props); 4604 } 4605 } 4606 get idle() { 4607 return !(isAnimating(this) || this._state.asyncTo) || isPaused(this); 4608 } 4609 get goal() { 4610 return getFluidValue(this.animation.to); 4611 } 4612 get velocity() { 4613 const node = getAnimated(this); 4614 return node instanceof AnimatedValue ? node.lastVelocity || 0 : node.getPayload().map((node2) => node2.lastVelocity || 0); 4615 } 4616 get hasAnimated() { 4617 return hasAnimated(this); 4618 } 4619 get isAnimating() { 4620 return isAnimating(this); 4621 } 4622 get isPaused() { 4623 return isPaused(this); 4624 } 4625 get isDelayed() { 4626 return this._state.delayed; 4627 } 4628 advance(dt) { 4629 let idle = true; 4630 let changed = false; 4631 const anim = this.animation; 4632 let { 4633 config: config2, 4634 toValues 4635 } = anim; 4636 const payload = getPayload(anim.to); 4637 if (!payload && hasFluidValue(anim.to)) { 4638 toValues = toArray(getFluidValue(anim.to)); 4639 } 4640 anim.values.forEach((node2, i2) => { 4641 if (node2.done) return; 4642 const to2 = node2.constructor == AnimatedString ? 1 : payload ? payload[i2].lastPosition : toValues[i2]; 4643 let finished = anim.immediate; 4644 let position = to2; 4645 if (!finished) { 4646 position = node2.lastPosition; 4647 if (config2.tension <= 0) { 4648 node2.done = true; 4649 return; 4650 } 4651 let elapsed = node2.elapsedTime += dt; 4652 const from = anim.fromValues[i2]; 4653 const v0 = node2.v0 != null ? node2.v0 : node2.v0 = is.arr(config2.velocity) ? config2.velocity[i2] : config2.velocity; 4654 let velocity; 4655 const precision = config2.precision || (from == to2 ? 5e-3 : Math.min(1, Math.abs(to2 - from) * 1e-3)); 4656 if (!is.und(config2.duration)) { 4657 let p3 = 1; 4658 if (config2.duration > 0) { 4659 if (this._memoizedDuration !== config2.duration) { 4660 this._memoizedDuration = config2.duration; 4661 if (node2.durationProgress > 0) { 4662 node2.elapsedTime = config2.duration * node2.durationProgress; 4663 elapsed = node2.elapsedTime += dt; 4664 } 4665 } 4666 p3 = (config2.progress || 0) + elapsed / this._memoizedDuration; 4667 p3 = p3 > 1 ? 1 : p3 < 0 ? 0 : p3; 4668 node2.durationProgress = p3; 4669 } 4670 position = from + config2.easing(p3) * (to2 - from); 4671 velocity = (position - node2.lastPosition) / dt; 4672 finished = p3 == 1; 4673 } else if (config2.decay) { 4674 const decay = config2.decay === true ? 0.998 : config2.decay; 4675 const e2 = Math.exp(-(1 - decay) * elapsed); 4676 position = from + v0 / (1 - decay) * (1 - e2); 4677 finished = Math.abs(node2.lastPosition - position) <= precision; 4678 velocity = v0 * e2; 4679 } else { 4680 velocity = node2.lastVelocity == null ? v0 : node2.lastVelocity; 4681 const restVelocity = config2.restVelocity || precision / 10; 4682 const bounceFactor = config2.clamp ? 0 : config2.bounce; 4683 const canBounce = !is.und(bounceFactor); 4684 const isGrowing = from == to2 ? node2.v0 > 0 : from < to2; 4685 let isMoving; 4686 let isBouncing = false; 4687 const step = 1; 4688 const numSteps = Math.ceil(dt / step); 4689 for (let n2 = 0; n2 < numSteps; ++n2) { 4690 isMoving = Math.abs(velocity) > restVelocity; 4691 if (!isMoving) { 4692 finished = Math.abs(to2 - position) <= precision; 4693 if (finished) { 4694 break; 4695 } 4696 } 4697 if (canBounce) { 4698 isBouncing = position == to2 || position > to2 == isGrowing; 4699 if (isBouncing) { 4700 velocity = -velocity * bounceFactor; 4701 position = to2; 4702 } 4703 } 4704 const springForce = -config2.tension * 1e-6 * (position - to2); 4705 const dampingForce = -config2.friction * 1e-3 * velocity; 4706 const acceleration = (springForce + dampingForce) / config2.mass; 4707 velocity = velocity + acceleration * step; 4708 position = position + velocity * step; 4709 } 4710 } 4711 node2.lastVelocity = velocity; 4712 if (Number.isNaN(position)) { 4713 console.warn(`Got NaN while animating:`, this); 4714 finished = true; 4715 } 4716 } 4717 if (payload && !payload[i2].done) { 4718 finished = false; 4719 } 4720 if (finished) { 4721 node2.done = true; 4722 } else { 4723 idle = false; 4724 } 4725 if (node2.setValue(position, config2.round)) { 4726 changed = true; 4727 } 4728 }); 4729 const node = getAnimated(this); 4730 const currVal = node.getValue(); 4731 if (idle) { 4732 const finalVal = getFluidValue(anim.to); 4733 if ((currVal !== finalVal || changed) && !config2.decay) { 4734 node.setValue(finalVal); 4735 this._onChange(finalVal); 4736 } else if (changed && config2.decay) { 4737 this._onChange(currVal); 4738 } 4739 this._stop(); 4740 } else if (changed) { 4741 this._onChange(currVal); 4742 } 4743 } 4744 set(value) { 4745 raf.batchedUpdates(() => { 4746 this._stop(); 4747 this._focus(value); 4748 this._set(value); 4749 }); 4750 return this; 4751 } 4752 pause() { 4753 this._update({ 4754 pause: true 4755 }); 4756 } 4757 resume() { 4758 this._update({ 4759 pause: false 4760 }); 4761 } 4762 finish() { 4763 if (isAnimating(this)) { 4764 const { 4765 to: to2, 4766 config: config2 4767 } = this.animation; 4768 raf.batchedUpdates(() => { 4769 this._onStart(); 4770 if (!config2.decay) { 4771 this._set(to2, false); 4772 } 4773 this._stop(); 4774 }); 4775 } 4776 return this; 4777 } 4778 update(props) { 4779 const queue = this.queue || (this.queue = []); 4780 queue.push(props); 4781 return this; 4782 } 4783 start(to2, arg2) { 4784 let queue; 4785 if (!is.und(to2)) { 4786 queue = [is.obj(to2) ? to2 : _extends3({}, arg2, { 4787 to: to2 4788 })]; 4789 } else { 4790 queue = this.queue || []; 4791 this.queue = []; 4792 } 4793 return Promise.all(queue.map((props) => { 4794 const up = this._update(props); 4795 return up; 4796 })).then((results) => getCombinedResult(this, results)); 4797 } 4798 stop(cancel) { 4799 const { 4800 to: to2 4801 } = this.animation; 4802 this._focus(this.get()); 4803 stopAsync(this._state, cancel && this._lastCallId); 4804 raf.batchedUpdates(() => this._stop(to2, cancel)); 4805 return this; 4806 } 4807 reset() { 4808 this._update({ 4809 reset: true 4810 }); 4811 } 4812 eventObserved(event) { 4813 if (event.type == "change") { 4814 this._start(); 4815 } else if (event.type == "priority") { 4816 this.priority = event.priority + 1; 4817 } 4818 } 4819 _prepareNode(props) { 4820 const key = this.key || ""; 4821 let { 4822 to: to2, 4823 from 4824 } = props; 4825 to2 = is.obj(to2) ? to2[key] : to2; 4826 if (to2 == null || isAsyncTo(to2)) { 4827 to2 = void 0; 4828 } 4829 from = is.obj(from) ? from[key] : from; 4830 if (from == null) { 4831 from = void 0; 4832 } 4833 const range = { 4834 to: to2, 4835 from 4836 }; 4837 if (!hasAnimated(this)) { 4838 if (props.reverse) [to2, from] = [from, to2]; 4839 from = getFluidValue(from); 4840 if (!is.und(from)) { 4841 this._set(from); 4842 } else if (!getAnimated(this)) { 4843 this._set(to2); 4844 } 4845 } 4846 return range; 4847 } 4848 _update(_ref, isLoop) { 4849 let props = _extends3({}, _ref); 4850 const { 4851 key, 4852 defaultProps 4853 } = this; 4854 if (props.default) Object.assign(defaultProps, getDefaultProps(props, (value, prop) => /^on/.test(prop) ? resolveProp(value, key) : value)); 4855 mergeActiveFn(this, props, "onProps"); 4856 sendEvent(this, "onProps", props, this); 4857 const range = this._prepareNode(props); 4858 if (Object.isFrozen(this)) { 4859 throw Error("Cannot animate a `SpringValue` object that is frozen. Did you forget to pass your component to `animated(...)` before animating its props?"); 4860 } 4861 const state = this._state; 4862 return scheduleProps(++this._lastCallId, { 4863 key, 4864 props, 4865 defaultProps, 4866 state, 4867 actions: { 4868 pause: () => { 4869 if (!isPaused(this)) { 4870 setPausedBit(this, true); 4871 flushCalls(state.pauseQueue); 4872 sendEvent(this, "onPause", getFinishedResult(this, checkFinished(this, this.animation.to)), this); 4873 } 4874 }, 4875 resume: () => { 4876 if (isPaused(this)) { 4877 setPausedBit(this, false); 4878 if (isAnimating(this)) { 4879 this._resume(); 4880 } 4881 flushCalls(state.resumeQueue); 4882 sendEvent(this, "onResume", getFinishedResult(this, checkFinished(this, this.animation.to)), this); 4883 } 4884 }, 4885 start: this._merge.bind(this, range) 4886 } 4887 }).then((result) => { 4888 if (props.loop && result.finished && !(isLoop && result.noop)) { 4889 const nextProps = createLoopUpdate(props); 4890 if (nextProps) { 4891 return this._update(nextProps, true); 4892 } 4893 } 4894 return result; 4895 }); 4896 } 4897 _merge(range, props, resolve) { 4898 if (props.cancel) { 4899 this.stop(true); 4900 return resolve(getCancelledResult(this)); 4901 } 4902 const hasToProp = !is.und(range.to); 4903 const hasFromProp = !is.und(range.from); 4904 if (hasToProp || hasFromProp) { 4905 if (props.callId > this._lastToId) { 4906 this._lastToId = props.callId; 4907 } else { 4908 return resolve(getCancelledResult(this)); 4909 } 4910 } 4911 const { 4912 key, 4913 defaultProps, 4914 animation: anim 4915 } = this; 4916 const { 4917 to: prevTo, 4918 from: prevFrom 4919 } = anim; 4920 let { 4921 to: to2 = prevTo, 4922 from = prevFrom 4923 } = range; 4924 if (hasFromProp && !hasToProp && (!props.default || is.und(to2))) { 4925 to2 = from; 4926 } 4927 if (props.reverse) [to2, from] = [from, to2]; 4928 const hasFromChanged = !isEqual(from, prevFrom); 4929 if (hasFromChanged) { 4930 anim.from = from; 4931 } 4932 from = getFluidValue(from); 4933 const hasToChanged = !isEqual(to2, prevTo); 4934 if (hasToChanged) { 4935 this._focus(to2); 4936 } 4937 const hasAsyncTo = isAsyncTo(props.to); 4938 const { 4939 config: config2 4940 } = anim; 4941 const { 4942 decay, 4943 velocity 4944 } = config2; 4945 if (hasToProp || hasFromProp) { 4946 config2.velocity = 0; 4947 } 4948 if (props.config && !hasAsyncTo) { 4949 mergeConfig(config2, callProp(props.config, key), props.config !== defaultProps.config ? callProp(defaultProps.config, key) : void 0); 4950 } 4951 let node = getAnimated(this); 4952 if (!node || is.und(to2)) { 4953 return resolve(getFinishedResult(this, true)); 4954 } 4955 const reset = is.und(props.reset) ? hasFromProp && !props.default : !is.und(from) && matchProp(props.reset, key); 4956 const value = reset ? from : this.get(); 4957 const goal = computeGoal(to2); 4958 const isAnimatable = is.num(goal) || is.arr(goal) || isAnimatedString(goal); 4959 const immediate = !hasAsyncTo && (!isAnimatable || matchProp(defaultProps.immediate || props.immediate, key)); 4960 if (hasToChanged) { 4961 const nodeType = getAnimatedType(to2); 4962 if (nodeType !== node.constructor) { 4963 if (immediate) { 4964 node = this._set(goal); 4965 } else throw Error(`Cannot animate between $node.constructor.name} and $nodeType.name}, as the "to" prop suggests`); 4966 } 4967 } 4968 const goalType = node.constructor; 4969 let started = hasFluidValue(to2); 4970 let finished = false; 4971 if (!started) { 4972 const hasValueChanged = reset || !hasAnimated(this) && hasFromChanged; 4973 if (hasToChanged || hasValueChanged) { 4974 finished = isEqual(computeGoal(value), goal); 4975 started = !finished; 4976 } 4977 if (!isEqual(anim.immediate, immediate) && !immediate || !isEqual(config2.decay, decay) || !isEqual(config2.velocity, velocity)) { 4978 started = true; 4979 } 4980 } 4981 if (finished && isAnimating(this)) { 4982 if (anim.changed && !reset) { 4983 started = true; 4984 } else if (!started) { 4985 this._stop(prevTo); 4986 } 4987 } 4988 if (!hasAsyncTo) { 4989 if (started || hasFluidValue(prevTo)) { 4990 anim.values = node.getPayload(); 4991 anim.toValues = hasFluidValue(to2) ? null : goalType == AnimatedString ? [1] : toArray(goal); 4992 } 4993 if (anim.immediate != immediate) { 4994 anim.immediate = immediate; 4995 if (!immediate && !reset) { 4996 this._set(prevTo); 4997 } 4998 } 4999 if (started) { 5000 const { 5001 onRest 5002 } = anim; 5003 each(ACTIVE_EVENTS, (type) => mergeActiveFn(this, props, type)); 5004 const result = getFinishedResult(this, checkFinished(this, prevTo)); 5005 flushCalls(this._pendingCalls, result); 5006 this._pendingCalls.add(resolve); 5007 if (anim.changed) raf.batchedUpdates(() => { 5008 anim.changed = !reset; 5009 onRest == null ? void 0 : onRest(result, this); 5010 if (reset) { 5011 callProp(defaultProps.onRest, result); 5012 } else { 5013 anim.onStart == null ? void 0 : anim.onStart(result, this); 5014 } 5015 }); 5016 } 5017 } 5018 if (reset) { 5019 this._set(value); 5020 } 5021 if (hasAsyncTo) { 5022 resolve(runAsync(props.to, props, this._state, this)); 5023 } else if (started) { 5024 this._start(); 5025 } else if (isAnimating(this) && !hasToChanged) { 5026 this._pendingCalls.add(resolve); 5027 } else { 5028 resolve(getNoopResult(value)); 5029 } 5030 } 5031 _focus(value) { 5032 const anim = this.animation; 5033 if (value !== anim.to) { 5034 if (getFluidObservers(this)) { 5035 this._detach(); 5036 } 5037 anim.to = value; 5038 if (getFluidObservers(this)) { 5039 this._attach(); 5040 } 5041 } 5042 } 5043 _attach() { 5044 let priority2 = 0; 5045 const { 5046 to: to2 5047 } = this.animation; 5048 if (hasFluidValue(to2)) { 5049 addFluidObserver(to2, this); 5050 if (isFrameValue(to2)) { 5051 priority2 = to2.priority + 1; 5052 } 5053 } 5054 this.priority = priority2; 5055 } 5056 _detach() { 5057 const { 5058 to: to2 5059 } = this.animation; 5060 if (hasFluidValue(to2)) { 5061 removeFluidObserver(to2, this); 5062 } 5063 } 5064 _set(arg, idle = true) { 5065 const value = getFluidValue(arg); 5066 if (!is.und(value)) { 5067 const oldNode = getAnimated(this); 5068 if (!oldNode || !isEqual(value, oldNode.getValue())) { 5069 const nodeType = getAnimatedType(value); 5070 if (!oldNode || oldNode.constructor != nodeType) { 5071 setAnimated(this, nodeType.create(value)); 5072 } else { 5073 oldNode.setValue(value); 5074 } 5075 if (oldNode) { 5076 raf.batchedUpdates(() => { 5077 this._onChange(value, idle); 5078 }); 5079 } 5080 } 5081 } 5082 return getAnimated(this); 5083 } 5084 _onStart() { 5085 const anim = this.animation; 5086 if (!anim.changed) { 5087 anim.changed = true; 5088 sendEvent(this, "onStart", getFinishedResult(this, checkFinished(this, anim.to)), this); 5089 } 5090 } 5091 _onChange(value, idle) { 5092 if (!idle) { 5093 this._onStart(); 5094 callProp(this.animation.onChange, value, this); 5095 } 5096 callProp(this.defaultProps.onChange, value, this); 5097 super._onChange(value, idle); 5098 } 5099 _start() { 5100 const anim = this.animation; 5101 getAnimated(this).reset(getFluidValue(anim.to)); 5102 if (!anim.immediate) { 5103 anim.fromValues = anim.values.map((node) => node.lastPosition); 5104 } 5105 if (!isAnimating(this)) { 5106 setActiveBit(this, true); 5107 if (!isPaused(this)) { 5108 this._resume(); 5109 } 5110 } 5111 } 5112 _resume() { 5113 if (globals.skipAnimation) { 5114 this.finish(); 5115 } else { 5116 frameLoop.start(this); 5117 } 5118 } 5119 _stop(goal, cancel) { 5120 if (isAnimating(this)) { 5121 setActiveBit(this, false); 5122 const anim = this.animation; 5123 each(anim.values, (node) => { 5124 node.done = true; 5125 }); 5126 if (anim.toValues) { 5127 anim.onChange = anim.onPause = anim.onResume = void 0; 5128 } 5129 callFluidObservers(this, { 5130 type: "idle", 5131 parent: this 5132 }); 5133 const result = cancel ? getCancelledResult(this.get()) : getFinishedResult(this.get(), checkFinished(this, goal != null ? goal : anim.to)); 5134 flushCalls(this._pendingCalls, result); 5135 if (anim.changed) { 5136 anim.changed = false; 5137 sendEvent(this, "onRest", result, this); 5138 } 5139 } 5140 } 5141 }; 5142 function checkFinished(target, to2) { 5143 const goal = computeGoal(to2); 5144 const value = computeGoal(target.get()); 5145 return isEqual(value, goal); 5146 } 5147 function createLoopUpdate(props, loop2 = props.loop, to2 = props.to) { 5148 let loopRet = callProp(loop2); 5149 if (loopRet) { 5150 const overrides = loopRet !== true && inferTo(loopRet); 5151 const reverse = (overrides || props).reverse; 5152 const reset = !overrides || overrides.reset; 5153 return createUpdate(_extends3({}, props, { 5154 loop: loop2, 5155 default: false, 5156 pause: void 0, 5157 to: !reverse || isAsyncTo(to2) ? to2 : void 0, 5158 from: reset ? props.from : void 0, 5159 reset 5160 }, overrides)); 5161 } 5162 } 5163 function createUpdate(props) { 5164 const { 5165 to: to2, 5166 from 5167 } = props = inferTo(props); 5168 const keys = /* @__PURE__ */ new Set(); 5169 if (is.obj(to2)) findDefined(to2, keys); 5170 if (is.obj(from)) findDefined(from, keys); 5171 props.keys = keys.size ? Array.from(keys) : null; 5172 return props; 5173 } 5174 function findDefined(values, keys) { 5175 eachProp(values, (value, key) => value != null && keys.add(key)); 5176 } 5177 var ACTIVE_EVENTS = ["onStart", "onRest", "onChange", "onPause", "onResume"]; 5178 function mergeActiveFn(target, props, type) { 5179 target.animation[type] = props[type] !== getDefaultProp(props, type) ? resolveProp(props[type], target.key) : void 0; 5180 } 5181 function sendEvent(target, type, ...args) { 5182 var _target$animation$typ, _target$animation, _target$defaultProps$, _target$defaultProps; 5183 (_target$animation$typ = (_target$animation = target.animation)[type]) == null ? void 0 : _target$animation$typ.call(_target$animation, ...args); 5184 (_target$defaultProps$ = (_target$defaultProps = target.defaultProps)[type]) == null ? void 0 : _target$defaultProps$.call(_target$defaultProps, ...args); 5185 } 5186 var BATCHED_EVENTS = ["onStart", "onChange", "onRest"]; 5187 var nextId = 1; 5188 var Controller = class { 5189 constructor(props, flush2) { 5190 this.id = nextId++; 5191 this.springs = {}; 5192 this.queue = []; 5193 this.ref = void 0; 5194 this._flush = void 0; 5195 this._initialProps = void 0; 5196 this._lastAsyncId = 0; 5197 this._active = /* @__PURE__ */ new Set(); 5198 this._changed = /* @__PURE__ */ new Set(); 5199 this._started = false; 5200 this._item = void 0; 5201 this._state = { 5202 paused: false, 5203 pauseQueue: /* @__PURE__ */ new Set(), 5204 resumeQueue: /* @__PURE__ */ new Set(), 5205 timeouts: /* @__PURE__ */ new Set() 5206 }; 5207 this._events = { 5208 onStart: /* @__PURE__ */ new Map(), 5209 onChange: /* @__PURE__ */ new Map(), 5210 onRest: /* @__PURE__ */ new Map() 5211 }; 5212 this._onFrame = this._onFrame.bind(this); 5213 if (flush2) { 5214 this._flush = flush2; 5215 } 5216 if (props) { 5217 this.start(_extends3({ 5218 default: true 5219 }, props)); 5220 } 5221 } 5222 get idle() { 5223 return !this._state.asyncTo && Object.values(this.springs).every((spring) => { 5224 return spring.idle && !spring.isDelayed && !spring.isPaused; 5225 }); 5226 } 5227 get item() { 5228 return this._item; 5229 } 5230 set item(item) { 5231 this._item = item; 5232 } 5233 get() { 5234 const values = {}; 5235 this.each((spring, key) => values[key] = spring.get()); 5236 return values; 5237 } 5238 set(values) { 5239 for (const key in values) { 5240 const value = values[key]; 5241 if (!is.und(value)) { 5242 this.springs[key].set(value); 5243 } 5244 } 5245 } 5246 update(props) { 5247 if (props) { 5248 this.queue.push(createUpdate(props)); 5249 } 5250 return this; 5251 } 5252 start(props) { 5253 let { 5254 queue 5255 } = this; 5256 if (props) { 5257 queue = toArray(props).map(createUpdate); 5258 } else { 5259 this.queue = []; 5260 } 5261 if (this._flush) { 5262 return this._flush(this, queue); 5263 } 5264 prepareKeys(this, queue); 5265 return flushUpdateQueue(this, queue); 5266 } 5267 stop(arg, keys) { 5268 if (arg !== !!arg) { 5269 keys = arg; 5270 } 5271 if (keys) { 5272 const springs = this.springs; 5273 each(toArray(keys), (key) => springs[key].stop(!!arg)); 5274 } else { 5275 stopAsync(this._state, this._lastAsyncId); 5276 this.each((spring) => spring.stop(!!arg)); 5277 } 5278 return this; 5279 } 5280 pause(keys) { 5281 if (is.und(keys)) { 5282 this.start({ 5283 pause: true 5284 }); 5285 } else { 5286 const springs = this.springs; 5287 each(toArray(keys), (key) => springs[key].pause()); 5288 } 5289 return this; 5290 } 5291 resume(keys) { 5292 if (is.und(keys)) { 5293 this.start({ 5294 pause: false 5295 }); 5296 } else { 5297 const springs = this.springs; 5298 each(toArray(keys), (key) => springs[key].resume()); 5299 } 5300 return this; 5301 } 5302 each(iterator) { 5303 eachProp(this.springs, iterator); 5304 } 5305 _onFrame() { 5306 const { 5307 onStart, 5308 onChange, 5309 onRest 5310 } = this._events; 5311 const active = this._active.size > 0; 5312 const changed = this._changed.size > 0; 5313 if (active && !this._started || changed && !this._started) { 5314 this._started = true; 5315 flush(onStart, ([onStart2, result]) => { 5316 result.value = this.get(); 5317 onStart2(result, this, this._item); 5318 }); 5319 } 5320 const idle = !active && this._started; 5321 const values = changed || idle && onRest.size ? this.get() : null; 5322 if (changed && onChange.size) { 5323 flush(onChange, ([onChange2, result]) => { 5324 result.value = values; 5325 onChange2(result, this, this._item); 5326 }); 5327 } 5328 if (idle) { 5329 this._started = false; 5330 flush(onRest, ([onRest2, result]) => { 5331 result.value = values; 5332 onRest2(result, this, this._item); 5333 }); 5334 } 5335 } 5336 eventObserved(event) { 5337 if (event.type == "change") { 5338 this._changed.add(event.parent); 5339 if (!event.idle) { 5340 this._active.add(event.parent); 5341 } 5342 } else if (event.type == "idle") { 5343 this._active.delete(event.parent); 5344 } else return; 5345 raf.onFrame(this._onFrame); 5346 } 5347 }; 5348 function flushUpdateQueue(ctrl, queue) { 5349 return Promise.all(queue.map((props) => flushUpdate(ctrl, props))).then((results) => getCombinedResult(ctrl, results)); 5350 } 5351 async function flushUpdate(ctrl, props, isLoop) { 5352 const { 5353 keys, 5354 to: to2, 5355 from, 5356 loop: loop2, 5357 onRest, 5358 onResolve 5359 } = props; 5360 const defaults2 = is.obj(props.default) && props.default; 5361 if (loop2) { 5362 props.loop = false; 5363 } 5364 if (to2 === false) props.to = null; 5365 if (from === false) props.from = null; 5366 const asyncTo = is.arr(to2) || is.fun(to2) ? to2 : void 0; 5367 if (asyncTo) { 5368 props.to = void 0; 5369 props.onRest = void 0; 5370 if (defaults2) { 5371 defaults2.onRest = void 0; 5372 } 5373 } else { 5374 each(BATCHED_EVENTS, (key) => { 5375 const handler = props[key]; 5376 if (is.fun(handler)) { 5377 const queue = ctrl["_events"][key]; 5378 props[key] = ({ 5379 finished, 5380 cancelled 5381 }) => { 5382 const result2 = queue.get(handler); 5383 if (result2) { 5384 if (!finished) result2.finished = false; 5385 if (cancelled) result2.cancelled = true; 5386 } else { 5387 queue.set(handler, { 5388 value: null, 5389 finished: finished || false, 5390 cancelled: cancelled || false 5391 }); 5392 } 5393 }; 5394 if (defaults2) { 5395 defaults2[key] = props[key]; 5396 } 5397 } 5398 }); 5399 } 5400 const state = ctrl["_state"]; 5401 if (props.pause === !state.paused) { 5402 state.paused = props.pause; 5403 flushCalls(props.pause ? state.pauseQueue : state.resumeQueue); 5404 } else if (state.paused) { 5405 props.pause = true; 5406 } 5407 const promises = (keys || Object.keys(ctrl.springs)).map((key) => ctrl.springs[key].start(props)); 5408 const cancel = props.cancel === true || getDefaultProp(props, "cancel") === true; 5409 if (asyncTo || cancel && state.asyncId) { 5410 promises.push(scheduleProps(++ctrl["_lastAsyncId"], { 5411 props, 5412 state, 5413 actions: { 5414 pause: noop, 5415 resume: noop, 5416 start(props2, resolve) { 5417 if (cancel) { 5418 stopAsync(state, ctrl["_lastAsyncId"]); 5419 resolve(getCancelledResult(ctrl)); 5420 } else { 5421 props2.onRest = onRest; 5422 resolve(runAsync(asyncTo, props2, state, ctrl)); 5423 } 5424 } 5425 } 5426 })); 5427 } 5428 if (state.paused) { 5429 await new Promise((resume) => { 5430 state.resumeQueue.add(resume); 5431 }); 5432 } 5433 const result = getCombinedResult(ctrl, await Promise.all(promises)); 5434 if (loop2 && result.finished && !(isLoop && result.noop)) { 5435 const nextProps = createLoopUpdate(props, loop2, to2); 5436 if (nextProps) { 5437 prepareKeys(ctrl, [nextProps]); 5438 return flushUpdate(ctrl, nextProps, true); 5439 } 5440 } 5441 if (onResolve) { 5442 raf.batchedUpdates(() => onResolve(result, ctrl, ctrl.item)); 5443 } 5444 return result; 5445 } 5446 function createSpring(key, observer) { 5447 const spring = new SpringValue(); 5448 spring.key = key; 5449 if (observer) { 5450 addFluidObserver(spring, observer); 5451 } 5452 return spring; 5453 } 5454 function prepareSprings(springs, props, create) { 5455 if (props.keys) { 5456 each(props.keys, (key) => { 5457 const spring = springs[key] || (springs[key] = create(key)); 5458 spring["_prepareNode"](props); 5459 }); 5460 } 5461 } 5462 function prepareKeys(ctrl, queue) { 5463 each(queue, (props) => { 5464 prepareSprings(ctrl.springs, props, (key) => { 5465 return createSpring(key, ctrl); 5466 }); 5467 }); 5468 } 5469 function _objectWithoutPropertiesLoose(source, excluded) { 5470 if (source == null) return {}; 5471 var target = {}; 5472 var sourceKeys = Object.keys(source); 5473 var key, i2; 5474 for (i2 = 0; i2 < sourceKeys.length; i2++) { 5475 key = sourceKeys[i2]; 5476 if (excluded.indexOf(key) >= 0) continue; 5477 target[key] = source[key]; 5478 } 5479 return target; 5480 } 5481 var _excluded$3 = ["children"]; 5482 var SpringContext = (_ref) => { 5483 let { 5484 children 5485 } = _ref, props = _objectWithoutPropertiesLoose(_ref, _excluded$3); 5486 const inherited = (0, import_react3.useContext)(ctx); 5487 const pause = props.pause || !!inherited.pause, immediate = props.immediate || !!inherited.immediate; 5488 props = useMemoOne(() => ({ 5489 pause, 5490 immediate 5491 }), [pause, immediate]); 5492 const { 5493 Provider 5494 } = ctx; 5495 return React2.createElement(Provider, { 5496 value: props 5497 }, children); 5498 }; 5499 var ctx = makeContext(SpringContext, {}); 5500 SpringContext.Provider = ctx.Provider; 5501 SpringContext.Consumer = ctx.Consumer; 5502 function makeContext(target, init2) { 5503 Object.assign(target, React2.createContext(init2)); 5504 target.Provider._context = target; 5505 target.Consumer._context = target; 5506 return target; 5507 } 5508 var TransitionPhase; 5509 (function(TransitionPhase2) { 5510 TransitionPhase2["MOUNT"] = "mount"; 5511 TransitionPhase2["ENTER"] = "enter"; 5512 TransitionPhase2["UPDATE"] = "update"; 5513 TransitionPhase2["LEAVE"] = "leave"; 5514 })(TransitionPhase || (TransitionPhase = {})); 5515 var Interpolation = class extends FrameValue { 5516 constructor(source, args) { 5517 super(); 5518 this.key = void 0; 5519 this.idle = true; 5520 this.calc = void 0; 5521 this._active = /* @__PURE__ */ new Set(); 5522 this.source = source; 5523 this.calc = createInterpolator(...args); 5524 const value = this._get(); 5525 const nodeType = getAnimatedType(value); 5526 setAnimated(this, nodeType.create(value)); 5527 } 5528 advance(_dt) { 5529 const value = this._get(); 5530 const oldValue = this.get(); 5531 if (!isEqual(value, oldValue)) { 5532 getAnimated(this).setValue(value); 5533 this._onChange(value, this.idle); 5534 } 5535 if (!this.idle && checkIdle(this._active)) { 5536 becomeIdle(this); 5537 } 5538 } 5539 _get() { 5540 const inputs = is.arr(this.source) ? this.source.map(getFluidValue) : toArray(getFluidValue(this.source)); 5541 return this.calc(...inputs); 5542 } 5543 _start() { 5544 if (this.idle && !checkIdle(this._active)) { 5545 this.idle = false; 5546 each(getPayload(this), (node) => { 5547 node.done = false; 5548 }); 5549 if (globals.skipAnimation) { 5550 raf.batchedUpdates(() => this.advance()); 5551 becomeIdle(this); 5552 } else { 5553 frameLoop.start(this); 5554 } 5555 } 5556 } 5557 _attach() { 5558 let priority2 = 1; 5559 each(toArray(this.source), (source) => { 5560 if (hasFluidValue(source)) { 5561 addFluidObserver(source, this); 5562 } 5563 if (isFrameValue(source)) { 5564 if (!source.idle) { 5565 this._active.add(source); 5566 } 5567 priority2 = Math.max(priority2, source.priority + 1); 5568 } 5569 }); 5570 this.priority = priority2; 5571 this._start(); 5572 } 5573 _detach() { 5574 each(toArray(this.source), (source) => { 5575 if (hasFluidValue(source)) { 5576 removeFluidObserver(source, this); 5577 } 5578 }); 5579 this._active.clear(); 5580 becomeIdle(this); 5581 } 5582 eventObserved(event) { 5583 if (event.type == "change") { 5584 if (event.idle) { 5585 this.advance(); 5586 } else { 5587 this._active.add(event.parent); 5588 this._start(); 5589 } 5590 } else if (event.type == "idle") { 5591 this._active.delete(event.parent); 5592 } else if (event.type == "priority") { 5593 this.priority = toArray(this.source).reduce((highest, parent) => Math.max(highest, (isFrameValue(parent) ? parent.priority : 0) + 1), 0); 5594 } 5595 } 5596 }; 5597 function isIdle(source) { 5598 return source.idle !== false; 5599 } 5600 function checkIdle(active) { 5601 return !active.size || Array.from(active).every(isIdle); 5602 } 5603 function becomeIdle(self2) { 5604 if (!self2.idle) { 5605 self2.idle = true; 5606 each(getPayload(self2), (node) => { 5607 node.done = true; 5608 }); 5609 callFluidObservers(self2, { 5610 type: "idle", 5611 parent: self2 5612 }); 5613 } 5614 } 5615 globals.assign({ 5616 createStringInterpolator, 5617 to: (source, args) => new Interpolation(source, args) 5618 }); 5619 var update2 = frameLoop.advance; 5620 5621 // node_modules/@react-spring/web/dist/react-spring-web.esm.js 5622 var import_react_dom = __toESM(require_react_dom()); 5623 function _objectWithoutPropertiesLoose2(source, excluded) { 5624 if (source == null) return {}; 5625 var target = {}; 5626 var sourceKeys = Object.keys(source); 5627 var key, i2; 5628 for (i2 = 0; i2 < sourceKeys.length; i2++) { 5629 key = sourceKeys[i2]; 5630 if (excluded.indexOf(key) >= 0) continue; 5631 target[key] = source[key]; 5632 } 5633 return target; 5634 } 5635 var _excluded$2 = ["style", "children", "scrollTop", "scrollLeft"]; 5636 var isCustomPropRE = /^--/; 5637 function dangerousStyleValue(name2, value) { 5638 if (value == null || typeof value === "boolean" || value === "") return ""; 5639 if (typeof value === "number" && value !== 0 && !isCustomPropRE.test(name2) && !(isUnitlessNumber.hasOwnProperty(name2) && isUnitlessNumber[name2])) return value + "px"; 5640 return ("" + value).trim(); 5641 } 5642 var attributeCache = {}; 5643 function applyAnimatedValues(instance, props) { 5644 if (!instance.nodeType || !instance.setAttribute) { 5645 return false; 5646 } 5647 const isFilterElement = instance.nodeName === "filter" || instance.parentNode && instance.parentNode.nodeName === "filter"; 5648 const _ref = props, { 5649 style, 5650 children, 5651 scrollTop, 5652 scrollLeft 5653 } = _ref, attributes = _objectWithoutPropertiesLoose2(_ref, _excluded$2); 5654 const values = Object.values(attributes); 5655 const names = Object.keys(attributes).map((name2) => isFilterElement || instance.hasAttribute(name2) ? name2 : attributeCache[name2] || (attributeCache[name2] = name2.replace(/([A-Z])/g, (n2) => "-" + n2.toLowerCase()))); 5656 if (children !== void 0) { 5657 instance.textContent = children; 5658 } 5659 for (let name2 in style) { 5660 if (style.hasOwnProperty(name2)) { 5661 const value = dangerousStyleValue(name2, style[name2]); 5662 if (isCustomPropRE.test(name2)) { 5663 instance.style.setProperty(name2, value); 5664 } else { 5665 instance.style[name2] = value; 5666 } 5667 } 5668 } 5669 names.forEach((name2, i2) => { 5670 instance.setAttribute(name2, values[i2]); 5671 }); 5672 if (scrollTop !== void 0) { 5673 instance.scrollTop = scrollTop; 5674 } 5675 if (scrollLeft !== void 0) { 5676 instance.scrollLeft = scrollLeft; 5677 } 5678 } 5679 var isUnitlessNumber = { 5680 animationIterationCount: true, 5681 borderImageOutset: true, 5682 borderImageSlice: true, 5683 borderImageWidth: true, 5684 boxFlex: true, 5685 boxFlexGroup: true, 5686 boxOrdinalGroup: true, 5687 columnCount: true, 5688 columns: true, 5689 flex: true, 5690 flexGrow: true, 5691 flexPositive: true, 5692 flexShrink: true, 5693 flexNegative: true, 5694 flexOrder: true, 5695 gridRow: true, 5696 gridRowEnd: true, 5697 gridRowSpan: true, 5698 gridRowStart: true, 5699 gridColumn: true, 5700 gridColumnEnd: true, 5701 gridColumnSpan: true, 5702 gridColumnStart: true, 5703 fontWeight: true, 5704 lineClamp: true, 5705 lineHeight: true, 5706 opacity: true, 5707 order: true, 5708 orphans: true, 5709 tabSize: true, 5710 widows: true, 5711 zIndex: true, 5712 zoom: true, 5713 fillOpacity: true, 5714 floodOpacity: true, 5715 stopOpacity: true, 5716 strokeDasharray: true, 5717 strokeDashoffset: true, 5718 strokeMiterlimit: true, 5719 strokeOpacity: true, 5720 strokeWidth: true 5721 }; 5722 var prefixKey = (prefix2, key) => prefix2 + key.charAt(0).toUpperCase() + key.substring(1); 5723 var prefixes = ["Webkit", "Ms", "Moz", "O"]; 5724 isUnitlessNumber = Object.keys(isUnitlessNumber).reduce((acc, prop) => { 5725 prefixes.forEach((prefix2) => acc[prefixKey(prefix2, prop)] = acc[prop]); 5726 return acc; 5727 }, isUnitlessNumber); 5728 var _excluded$1 = ["x", "y", "z"]; 5729 var domTransforms = /^(matrix|translate|scale|rotate|skew)/; 5730 var pxTransforms = /^(translate)/; 5731 var degTransforms = /^(rotate|skew)/; 5732 var addUnit = (value, unit) => is.num(value) && value !== 0 ? value + unit : value; 5733 var isValueIdentity = (value, id) => is.arr(value) ? value.every((v2) => isValueIdentity(v2, id)) : is.num(value) ? value === id : parseFloat(value) === id; 5734 var AnimatedStyle = class extends AnimatedObject { 5735 constructor(_ref) { 5736 let { 5737 x: x2, 5738 y: y2, 5739 z 5740 } = _ref, style = _objectWithoutPropertiesLoose2(_ref, _excluded$1); 5741 const inputs = []; 5742 const transforms = []; 5743 if (x2 || y2 || z) { 5744 inputs.push([x2 || 0, y2 || 0, z || 0]); 5745 transforms.push((xyz) => [`translate3d($xyz.map((v2) => addUnit(v2, "px")).join(",")})`, isValueIdentity(xyz, 0)]); 5746 } 5747 eachProp(style, (value, key) => { 5748 if (key === "transform") { 5749 inputs.push([value || ""]); 5750 transforms.push((transform) => [transform, transform === ""]); 5751 } else if (domTransforms.test(key)) { 5752 delete style[key]; 5753 if (is.und(value)) return; 5754 const unit = pxTransforms.test(key) ? "px" : degTransforms.test(key) ? "deg" : ""; 5755 inputs.push(toArray(value)); 5756 transforms.push(key === "rotate3d" ? ([x3, y3, z2, deg]) => [`rotate3d($x3},$y3},$z2},$addUnit(deg, unit)})`, isValueIdentity(deg, 0)] : (input) => [`$key}($input.map((v2) => addUnit(v2, unit)).join(",")})`, isValueIdentity(input, key.startsWith("scale") ? 1 : 0)]); 5757 } 5758 }); 5759 if (inputs.length) { 5760 style.transform = new FluidTransform(inputs, transforms); 5761 } 5762 super(style); 5763 } 5764 }; 5765 var FluidTransform = class extends FluidValue { 5766 constructor(inputs, transforms) { 5767 super(); 5768 this._value = null; 5769 this.inputs = inputs; 5770 this.transforms = transforms; 5771 } 5772 get() { 5773 return this._value || (this._value = this._get()); 5774 } 5775 _get() { 5776 let transform = ""; 5777 let identity2 = true; 5778 each(this.inputs, (input, i2) => { 5779 const arg1 = getFluidValue(input[0]); 5780 const [t3, id] = this.transforms[i2](is.arr(arg1) ? arg1 : input.map(getFluidValue)); 5781 transform += " " + t3; 5782 identity2 = identity2 && id; 5783 }); 5784 return identity2 ? "none" : transform; 5785 } 5786 observerAdded(count) { 5787 if (count == 1) each(this.inputs, (input) => each(input, (value) => hasFluidValue(value) && addFluidObserver(value, this))); 5788 } 5789 observerRemoved(count) { 5790 if (count == 0) each(this.inputs, (input) => each(input, (value) => hasFluidValue(value) && removeFluidObserver(value, this))); 5791 } 5792 eventObserved(event) { 5793 if (event.type == "change") { 5794 this._value = null; 5795 } 5796 callFluidObservers(this, event); 5797 } 5798 }; 5799 var primitives = ["a", "abbr", "address", "area", "article", "aside", "audio", "b", "base", "bdi", "bdo", "big", "blockquote", "body", "br", "button", "canvas", "caption", "cite", "code", "col", "colgroup", "data", "datalist", "dd", "del", "details", "dfn", "dialog", "div", "dl", "dt", "em", "embed", "fieldset", "figcaption", "figure", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hgroup", "hr", "html", "i", "iframe", "img", "input", "ins", "kbd", "keygen", "label", "legend", "li", "link", "main", "map", "mark", "menu", "menuitem", "meta", "meter", "nav", "noscript", "object", "ol", "optgroup", "option", "output", "p", "param", "picture", "pre", "progress", "q", "rp", "rt", "ruby", "s", "samp", "script", "section", "select", "small", "source", "span", "strong", "style", "sub", "summary", "sup", "table", "tbody", "td", "textarea", "tfoot", "th", "thead", "time", "title", "tr", "track", "u", "ul", "var", "video", "wbr", "circle", "clipPath", "defs", "ellipse", "foreignObject", "g", "image", "line", "linearGradient", "mask", "path", "pattern", "polygon", "polyline", "radialGradient", "rect", "stop", "svg", "text", "tspan"]; 5800 var _excluded = ["scrollTop", "scrollLeft"]; 5801 globals.assign({ 5802 batchedUpdates: import_react_dom.unstable_batchedUpdates, 5803 createStringInterpolator, 5804 colors 5805 }); 5806 var host = createHost(primitives, { 5807 applyAnimatedValues, 5808 createAnimatedStyle: (style) => new AnimatedStyle(style), 5809 getComponentProps: (_ref) => { 5810 let props = _objectWithoutPropertiesLoose2(_ref, _excluded); 5811 return props; 5812 } 5813 }); 5814 var animated = host.animated; 5815 5816 // packages/edit-site/build-module/components/layout/animation.js 5817 var import_element9 = __toESM(require_element()); 5818 function getAbsolutePosition(element) { 5819 return { 5820 top: element.offsetTop, 5821 left: element.offsetLeft 5822 }; 5823 } 5824 var ANIMATION_DURATION = 400; 5825 function useMovingAnimation({ triggerAnimationOnChange }) { 5826 const ref = (0, import_element9.useRef)(); 5827 const { previous, prevRect } = (0, import_element9.useMemo)( 5828 () => ({ 5829 previous: ref.current && getAbsolutePosition(ref.current), 5830 prevRect: ref.current && ref.current.getBoundingClientRect() 5831 }), 5832 [triggerAnimationOnChange] 5833 ); 5834 (0, import_element9.useLayoutEffect)(() => { 5835 if (!previous || !ref.current) { 5836 return; 5837 } 5838 const disableAnimation = window.matchMedia( 5839 "(prefers-reduced-motion: reduce)" 5840 ).matches; 5841 if (disableAnimation) { 5842 return; 5843 } 5844 const controller = new Controller({ 5845 x: 0, 5846 y: 0, 5847 width: prevRect.width, 5848 height: prevRect.height, 5849 config: { 5850 duration: ANIMATION_DURATION, 5851 easing: easings.easeInOutQuint 5852 }, 5853 onChange({ value }) { 5854 if (!ref.current) { 5855 return; 5856 } 5857 let { x: x22, y: y22, width: width2, height: height2 } = value; 5858 x22 = Math.round(x22); 5859 y22 = Math.round(y22); 5860 width2 = Math.round(width2); 5861 height2 = Math.round(height2); 5862 const finishedMoving = x22 === 0 && y22 === 0; 5863 ref.current.style.transformOrigin = "center center"; 5864 ref.current.style.transform = finishedMoving ? null : `translate3d($x22}px,$y22}px,0)`; 5865 ref.current.style.width = finishedMoving ? null : `$width2}px`; 5866 ref.current.style.height = finishedMoving ? null : `$height2}px`; 5867 } 5868 }); 5869 ref.current.style.transform = void 0; 5870 const destination = ref.current.getBoundingClientRect(); 5871 const x2 = Math.round(prevRect.left - destination.left); 5872 const y2 = Math.round(prevRect.top - destination.top); 5873 const width = destination.width; 5874 const height = destination.height; 5875 controller.start({ 5876 x: 0, 5877 y: 0, 5878 width, 5879 height, 5880 from: { x: x2, y: y2, width: prevRect.width, height: prevRect.height } 5881 }); 5882 return () => { 5883 controller.stop(); 5884 controller.set({ 5885 x: 0, 5886 y: 0, 5887 width: prevRect.width, 5888 height: prevRect.height 5889 }); 5890 }; 5891 }, [previous, prevRect]); 5892 return ref; 5893 } 5894 var animation_default = useMovingAnimation; 5895 5896 // packages/edit-site/build-module/components/save-hub/index.js 5897 var import_data10 = __toESM(require_data()); 5898 var import_components7 = __toESM(require_components()); 5899 var import_core_data9 = __toESM(require_core_data()); 5900 5901 // packages/edit-site/build-module/components/save-button/index.js 5902 var import_data9 = __toESM(require_data()); 5903 var import_components6 = __toESM(require_components()); 5904 var import_i18n6 = __toESM(require_i18n()); 5905 var import_core_data8 = __toESM(require_core_data()); 5906 var import_keycodes2 = __toESM(require_keycodes()); 5907 var import_router3 = __toESM(require_router()); 5908 var import_editor4 = __toESM(require_editor()); 5909 5910 // packages/edit-site/build-module/utils/is-previewing-theme.js 5911 var import_url3 = __toESM(require_url()); 5912 function isPreviewingTheme() { 5913 return !!(0, import_url3.getQueryArg)(window.location.href, "wp_theme_preview"); 5914 } 5915 function currentlyPreviewingTheme() { 5916 if (isPreviewingTheme()) { 5917 return (0, import_url3.getQueryArg)(window.location.href, "wp_theme_preview"); 5918 } 5919 return null; 5920 } 5921 5922 // packages/edit-site/build-module/components/save-button/index.js 5923 var import_jsx_runtime74 = __toESM(require_jsx_runtime()); 5924 var { useLocation: useLocation3 } = unlock(import_router3.privateApis); 5925 function SaveButton({ 5926 className = "edit-site-save-button__button", 5927 variant = "primary", 5928 showTooltip = true, 5929 showReviewMessage, 5930 icon, 5931 size, 5932 __next40pxDefaultSize = false 5933 }) { 5934 const { params } = useLocation3(); 5935 const { setIsSaveViewOpened: setIsSaveViewOpened2 } = (0, import_data9.useDispatch)(store); 5936 const { saveDirtyEntities } = unlock((0, import_data9.useDispatch)(import_editor4.store)); 5937 const { dirtyEntityRecords } = (0, import_editor4.useEntitiesSavedStatesIsDirty)(); 5938 const { isSaving, isSaveViewOpen, previewingThemeName } = (0, import_data9.useSelect)( 5939 (select3) => { 5940 const { isSavingEntityRecord, isResolving } = select3(import_core_data8.store); 5941 const { isSaveViewOpened: isSaveViewOpened2 } = select3(store); 5942 const isActivatingTheme = isResolving("activateTheme"); 5943 const currentlyPreviewingThemeId = currentlyPreviewingTheme(); 5944 return { 5945 isSaving: dirtyEntityRecords.some( 5946 (record) => isSavingEntityRecord( 5947 record.kind, 5948 record.name, 5949 record.key 5950 ) 5951 ) || isActivatingTheme, 5952 isSaveViewOpen: isSaveViewOpened2(), 5953 // Do not call `getTheme` with null, it will cause a request to 5954 // the server. 5955 previewingThemeName: currentlyPreviewingThemeId ? select3(import_core_data8.store).getTheme(currentlyPreviewingThemeId)?.name?.rendered : void 0 5956 }; 5957 }, 5958 [dirtyEntityRecords] 5959 ); 5960 const hasDirtyEntities = !!dirtyEntityRecords.length; 5961 let isOnlyCurrentEntityDirty; 5962 if (dirtyEntityRecords.length === 1) { 5963 if (params.postId) { 5964 isOnlyCurrentEntityDirty = `$dirtyEntityRecords[0].key}` === params.postId && dirtyEntityRecords[0].name === params.postType; 5965 } else if (params.path?.includes("wp_global_styles")) { 5966 isOnlyCurrentEntityDirty = dirtyEntityRecords[0].name === "globalStyles"; 5967 } 5968 } 5969 const disabled = isSaving || !hasDirtyEntities && !isPreviewingTheme(); 5970 const getLabel = () => { 5971 if (isPreviewingTheme()) { 5972 if (isSaving) { 5973 return (0, import_i18n6.sprintf)( 5974 /* translators: %s: The name of theme to be activated. */ 5975 (0, import_i18n6.__)("Activating %s"), 5976 previewingThemeName 5977 ); 5978 } else if (disabled) { 5979 return (0, import_i18n6.__)("Saved"); 5980 } else if (hasDirtyEntities) { 5981 return (0, import_i18n6.sprintf)( 5982 /* translators: %s: The name of theme to be activated. */ 5983 (0, import_i18n6.__)("Activate %s & Save"), 5984 previewingThemeName 5985 ); 5986 } 5987 return (0, import_i18n6.sprintf)( 5988 /* translators: %s: The name of theme to be activated. */ 5989 (0, import_i18n6.__)("Activate %s"), 5990 previewingThemeName 5991 ); 5992 } 5993 if (isSaving) { 5994 return (0, import_i18n6.__)("Saving"); 5995 } 5996 if (disabled) { 5997 return (0, import_i18n6.__)("Saved"); 5998 } 5999 if (!isOnlyCurrentEntityDirty && showReviewMessage) { 6000 return (0, import_i18n6.sprintf)( 6001 // translators: %d: number of unsaved changes (number). 6002 (0, import_i18n6._n)( 6003 "Review %d change\u2026", 6004 "Review %d changes\u2026", 6005 dirtyEntityRecords.length 6006 ), 6007 dirtyEntityRecords.length 6008 ); 6009 } 6010 return (0, import_i18n6.__)("Save"); 6011 }; 6012 const label = getLabel(); 6013 const onClick = isOnlyCurrentEntityDirty ? () => saveDirtyEntities({ dirtyEntityRecords }) : () => setIsSaveViewOpened2(true); 6014 return /* @__PURE__ */ (0, import_jsx_runtime74.jsx)( 6015 import_components6.Button, 6016 { 6017 variant, 6018 className, 6019 "aria-disabled": disabled, 6020 "aria-expanded": isSaveViewOpen, 6021 isBusy: isSaving, 6022 onClick: disabled ? void 0 : onClick, 6023 label, 6024 shortcut: disabled ? void 0 : import_keycodes2.displayShortcut.primary("s"), 6025 showTooltip, 6026 icon, 6027 __next40pxDefaultSize, 6028 size, 6029 children: label 6030 } 6031 ); 6032 } 6033 6034 // packages/edit-site/build-module/components/save-hub/index.js 6035 var import_jsx_runtime75 = __toESM(require_jsx_runtime()); 6036 function SaveHub() { 6037 const { isDisabled, isSaving } = (0, import_data10.useSelect)((select3) => { 6038 const { __experimentalGetDirtyEntityRecords, isSavingEntityRecord } = select3(import_core_data9.store); 6039 const dirtyEntityRecords = __experimentalGetDirtyEntityRecords(); 6040 const _isSaving = dirtyEntityRecords.some( 6041 (record) => isSavingEntityRecord(record.kind, record.name, record.key) 6042 ); 6043 return { 6044 isSaving: _isSaving, 6045 isDisabled: _isSaving || !dirtyEntityRecords.length && !isPreviewingTheme() 6046 }; 6047 }, []); 6048 return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(import_components7.__experimentalHStack, { className: "edit-site-save-hub", alignment: "right", spacing: 4, children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)( 6049 SaveButton, 6050 { 6051 className: "edit-site-save-hub__button", 6052 variant: isDisabled ? null : "primary", 6053 showTooltip: false, 6054 icon: isDisabled && !isSaving ? check_default : null, 6055 showReviewMessage: true, 6056 __next40pxDefaultSize: true 6057 } 6058 ) }); 6059 } 6060 6061 // packages/edit-site/build-module/components/save-panel/index.js 6062 var import_components8 = __toESM(require_components()); 6063 var import_editor5 = __toESM(require_editor()); 6064 var import_data12 = __toESM(require_data()); 6065 var import_i18n7 = __toESM(require_i18n()); 6066 var import_core_data11 = __toESM(require_core_data()); 6067 var import_router5 = __toESM(require_router()); 6068 var import_element11 = __toESM(require_element()); 6069 6070 // packages/edit-site/build-module/utils/use-activate-theme.js 6071 var import_core_data10 = __toESM(require_core_data()); 6072 var import_data11 = __toESM(require_data()); 6073 var import_router4 = __toESM(require_router()); 6074 var import_url4 = __toESM(require_url()); 6075 var { useHistory: useHistory3, useLocation: useLocation4 } = unlock(import_router4.privateApis); 6076 function useActivateTheme() { 6077 const history = useHistory3(); 6078 const { path } = useLocation4(); 6079 const { startResolution, finishResolution } = (0, import_data11.useDispatch)(import_core_data10.store); 6080 return async () => { 6081 if (isPreviewingTheme()) { 6082 const activationURL = "themes.php?action=activate&stylesheet=" + currentlyPreviewingTheme() + "&_wpnonce=" + window.WP_BLOCK_THEME_ACTIVATE_NONCE; 6083 startResolution("activateTheme"); 6084 await window.fetch(activationURL); 6085 finishResolution("activateTheme"); 6086 history.navigate((0, import_url4.addQueryArgs)(path, { wp_theme_preview: "" })); 6087 } 6088 }; 6089 } 6090 6091 // packages/edit-site/build-module/utils/use-actual-current-theme.js 6092 var import_api_fetch = __toESM(require_api_fetch()); 6093 var import_element10 = __toESM(require_element()); 6094 var import_url5 = __toESM(require_url()); 6095 var ACTIVE_THEMES_URL = "/wp/v2/themes?status=active"; 6096 function useActualCurrentTheme() { 6097 const [currentTheme, setCurrentTheme] = (0, import_element10.useState)(); 6098 (0, import_element10.useEffect)(() => { 6099 const path = (0, import_url5.addQueryArgs)(ACTIVE_THEMES_URL, { 6100 context: "edit", 6101 wp_theme_preview: "" 6102 }); 6103 (0, import_api_fetch.default)({ path }).then((activeThemes) => setCurrentTheme(activeThemes[0])).catch(() => { 6104 }); 6105 }, []); 6106 return currentTheme; 6107 } 6108 6109 // packages/edit-site/build-module/components/save-panel/index.js 6110 var import_jsx_runtime76 = __toESM(require_jsx_runtime()); 6111 var { EntitiesSavedStatesExtensible } = unlock(import_editor5.privateApis); 6112 var { useLocation: useLocation5 } = unlock(import_router5.privateApis); 6113 var EntitiesSavedStatesForPreview = ({ 6114 onClose, 6115 renderDialog, 6116 variant 6117 }) => { 6118 const isDirtyProps = (0, import_editor5.useEntitiesSavedStatesIsDirty)(); 6119 let activateSaveLabel; 6120 if (isDirtyProps.isDirty) { 6121 activateSaveLabel = (0, import_i18n7.__)("Activate & Save"); 6122 } else { 6123 activateSaveLabel = (0, import_i18n7.__)("Activate"); 6124 } 6125 const currentTheme = useActualCurrentTheme(); 6126 const previewingTheme = (0, import_data12.useSelect)( 6127 (select3) => select3(import_core_data11.store).getCurrentTheme(), 6128 [] 6129 ); 6130 const additionalPrompt = /* @__PURE__ */ (0, import_jsx_runtime76.jsx)("p", { children: (0, import_i18n7.sprintf)( 6131 /* translators: 1: The name of active theme, 2: The name of theme to be activated. */ 6132 (0, import_i18n7.__)( 6133 "Saving your changes will change your active theme from %1$s to %2$s." 6134 ), 6135 currentTheme?.name?.rendered ?? "...", 6136 previewingTheme?.name?.rendered ?? "..." 6137 ) }); 6138 const activateTheme = useActivateTheme(); 6139 const onSave = async (values) => { 6140 await activateTheme(); 6141 return values; 6142 }; 6143 return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)( 6144 EntitiesSavedStatesExtensible, 6145 { 6146 ...{ 6147 ...isDirtyProps, 6148 additionalPrompt, 6149 close: onClose, 6150 onSave, 6151 saveEnabled: true, 6152 saveLabel: activateSaveLabel, 6153 renderDialog, 6154 variant 6155 } 6156 } 6157 ); 6158 }; 6159 var _EntitiesSavedStates = ({ onClose, renderDialog, variant }) => { 6160 if (isPreviewingTheme()) { 6161 return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)( 6162 EntitiesSavedStatesForPreview, 6163 { 6164 onClose, 6165 renderDialog, 6166 variant 6167 } 6168 ); 6169 } 6170 return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)( 6171 import_editor5.EntitiesSavedStates, 6172 { 6173 close: onClose, 6174 renderDialog, 6175 variant 6176 } 6177 ); 6178 }; 6179 function SavePanel() { 6180 const { query } = useLocation5(); 6181 const { canvas = "view" } = query; 6182 const { isSaveViewOpen, isDirty, isSaving } = (0, import_data12.useSelect)((select3) => { 6183 const { 6184 __experimentalGetDirtyEntityRecords, 6185 isSavingEntityRecord, 6186 isResolving 6187 } = select3(import_core_data11.store); 6188 const dirtyEntityRecords = __experimentalGetDirtyEntityRecords(); 6189 const isActivatingTheme = isResolving("activateTheme"); 6190 const { isSaveViewOpened: isSaveViewOpened2 } = unlock(select3(store)); 6191 return { 6192 isSaveViewOpen: isSaveViewOpened2(), 6193 isDirty: dirtyEntityRecords.length > 0, 6194 isSaving: dirtyEntityRecords.some( 6195 (record) => isSavingEntityRecord(record.kind, record.name, record.key) 6196 ) || isActivatingTheme 6197 }; 6198 }, []); 6199 const { setIsSaveViewOpened: setIsSaveViewOpened2 } = (0, import_data12.useDispatch)(store); 6200 const onClose = () => setIsSaveViewOpened2(false); 6201 (0, import_element11.useEffect)(() => { 6202 setIsSaveViewOpened2(false); 6203 }, [canvas, setIsSaveViewOpened2]); 6204 if (canvas === "view") { 6205 return isSaveViewOpen ? /* @__PURE__ */ (0, import_jsx_runtime76.jsx)( 6206 import_components8.Modal, 6207 { 6208 className: "edit-site-save-panel__modal", 6209 onRequestClose: onClose, 6210 title: (0, import_i18n7.__)("Review changes"), 6211 size: "small", 6212 children: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(_EntitiesSavedStates, { onClose, variant: "inline" }) 6213 } 6214 ) : null; 6215 } 6216 const activateSaveEnabled = isPreviewingTheme() || isDirty; 6217 const disabled = isSaving || !activateSaveEnabled; 6218 return /* @__PURE__ */ (0, import_jsx_runtime76.jsxs)( 6219 navigable_region_default, 6220 { 6221 className: clsx_default("edit-site-layout__actions", { 6222 "is-entity-save-view-open": isSaveViewOpen 6223 }), 6224 ariaLabel: (0, import_i18n7.__)("Save panel"), 6225 children: [ 6226 /* @__PURE__ */ (0, import_jsx_runtime76.jsx)( 6227 "div", 6228 { 6229 className: clsx_default("edit-site-editor__toggle-save-panel", { 6230 "screen-reader-text": isSaveViewOpen 6231 }), 6232 children: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)( 6233 import_components8.Button, 6234 { 6235 __next40pxDefaultSize: true, 6236 variant: "secondary", 6237 className: "edit-site-editor__toggle-save-panel-button", 6238 onClick: () => setIsSaveViewOpened2(true), 6239 "aria-haspopup": "dialog", 6240 disabled, 6241 accessibleWhenDisabled: true, 6242 children: (0, import_i18n7.__)("Open save panel") 6243 } 6244 ) 6245 } 6246 ), 6247 isSaveViewOpen && /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(_EntitiesSavedStates, { onClose, renderDialog: true }) 6248 ] 6249 } 6250 ); 6251 } 6252 6253 // packages/edit-site/build-module/components/layout/index.js 6254 var import_jsx_runtime77 = __toESM(require_jsx_runtime()); 6255 var { useLocation: useLocation6 } = unlock(import_router6.privateApis); 6256 var { useStyle } = unlock(import_editor6.privateApis); 6257 var ANIMATION_DURATION2 = 0.3; 6258 function Layout() { 6259 const { query, name: routeKey, areas: areas2, widths } = useLocation6(); 6260 const { canvas = "view" } = query; 6261 const isMobileViewport = (0, import_compose2.useViewportMatch)("medium", "<"); 6262 const toggleRef = (0, import_element12.useRef)(); 6263 const navigateRegionsProps = (0, import_components9.__unstableUseNavigateRegions)(); 6264 const disableMotion = (0, import_compose2.useReducedMotion)(); 6265 const [canvasResizer, canvasSize] = (0, import_compose2.useResizeObserver)(); 6266 const isEditorLoading = useIsSiteEditorLoading(); 6267 const [isResizableFrameOversized, setIsResizableFrameOversized] = (0, import_element12.useState)(false); 6268 const animationRef = animation_default({ 6269 triggerAnimationOnChange: routeKey + "-" + canvas 6270 }); 6271 const { showIconLabels } = (0, import_data13.useSelect)((select3) => { 6272 return { 6273 showIconLabels: select3(import_preferences3.store).get( 6274 "core", 6275 "showIconLabels" 6276 ) 6277 }; 6278 }); 6279 const backgroundColor = useStyle("color.background"); 6280 const gradientValue = useStyle("color.gradient"); 6281 const previousCanvaMode = (0, import_compose2.usePrevious)(canvas); 6282 (0, import_element12.useEffect)(() => { 6283 if (previousCanvaMode === "edit") { 6284 toggleRef.current?.focus(); 6285 } 6286 }, [canvas]); 6287 return /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(import_jsx_runtime77.Fragment, { children: [ 6288 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(import_editor6.UnsavedChangesWarning, {}), 6289 canvas === "view" && /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(SaveKeyboardShortcut, {}), 6290 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)( 6291 "div", 6292 { 6293 ...navigateRegionsProps, 6294 ref: navigateRegionsProps.ref, 6295 className: clsx_default( 6296 "edit-site-layout", 6297 navigateRegionsProps.className, 6298 { 6299 "is-full-canvas": canvas === "edit", 6300 "show-icon-labels": showIconLabels 6301 } 6302 ), 6303 children: /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)("div", { className: "edit-site-layout__content", children: [ 6304 (!isMobileViewport || !areas2.mobile) && /* @__PURE__ */ (0, import_jsx_runtime77.jsx)( 6305 navigable_region_default, 6306 { 6307 ariaLabel: (0, import_i18n8.__)("Navigation"), 6308 className: "edit-site-layout__sidebar-region", 6309 children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(import_components9.__unstableAnimatePresence, { children: canvas === "view" && /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)( 6310 import_components9.__unstableMotion.div, 6311 { 6312 initial: { opacity: 0 }, 6313 animate: { opacity: 1 }, 6314 exit: { opacity: 0 }, 6315 transition: { 6316 type: "tween", 6317 duration: ( 6318 // Disable transition in mobile to emulate a full page transition. 6319 disableMotion || isMobileViewport ? 0 : ANIMATION_DURATION2 6320 ), 6321 ease: "easeOut" 6322 }, 6323 className: "edit-site-layout__sidebar", 6324 children: [ 6325 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)( 6326 site_hub_default, 6327 { 6328 ref: toggleRef, 6329 isTransparent: isResizableFrameOversized 6330 } 6331 ), 6332 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(SidebarNavigationProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)( 6333 SidebarContent, 6334 { 6335 shouldAnimate: routeKey !== "styles", 6336 routeKey, 6337 children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(import_editor6.ErrorBoundary, { children: areas2.sidebar }) 6338 } 6339 ) }), 6340 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(SaveHub, {}), 6341 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(SavePanel, {}) 6342 ] 6343 } 6344 ) }) 6345 } 6346 ), 6347 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(import_editor6.EditorSnackbars, {}), 6348 isMobileViewport && areas2.mobile && /* @__PURE__ */ (0, import_jsx_runtime77.jsx)("div", { className: "edit-site-layout__mobile", children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(SidebarNavigationProvider, { children: canvas !== "edit" ? /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(import_jsx_runtime77.Fragment, { children: [ 6349 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)( 6350 SiteHubMobile, 6351 { 6352 ref: toggleRef, 6353 isTransparent: isResizableFrameOversized 6354 } 6355 ), 6356 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(SidebarContent, { routeKey, children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(import_editor6.ErrorBoundary, { children: areas2.mobile }) }), 6357 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(SaveHub, {}), 6358 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(SavePanel, {}) 6359 ] }) : /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(import_editor6.ErrorBoundary, { children: areas2.mobile }) }) }), 6360 !isMobileViewport && areas2.content && canvas !== "edit" && /* @__PURE__ */ (0, import_jsx_runtime77.jsx)( 6361 "div", 6362 { 6363 className: "edit-site-layout__area", 6364 style: { 6365 maxWidth: widths?.content 6366 }, 6367 children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(import_editor6.ErrorBoundary, { children: areas2.content }) 6368 } 6369 ), 6370 !isMobileViewport && areas2.edit && canvas !== "edit" && /* @__PURE__ */ (0, import_jsx_runtime77.jsx)( 6371 "div", 6372 { 6373 className: "edit-site-layout__area", 6374 style: { 6375 maxWidth: widths?.edit 6376 }, 6377 children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(import_editor6.ErrorBoundary, { children: areas2.edit }) 6378 } 6379 ), 6380 !isMobileViewport && areas2.preview && /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)("div", { className: "edit-site-layout__canvas-container", children: [ 6381 canvasResizer, 6382 !!canvasSize.width && /* @__PURE__ */ (0, import_jsx_runtime77.jsx)( 6383 "div", 6384 { 6385 className: clsx_default( 6386 "edit-site-layout__canvas", 6387 { 6388 "is-right-aligned": isResizableFrameOversized 6389 } 6390 ), 6391 ref: animationRef, 6392 children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(import_editor6.ErrorBoundary, { children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)( 6393 resizable_frame_default, 6394 { 6395 isReady: !isEditorLoading, 6396 isFullWidth: canvas === "edit", 6397 defaultSize: { 6398 width: canvasSize.width - 24, 6399 height: canvasSize.height 6400 }, 6401 isOversized: isResizableFrameOversized, 6402 setIsOversized: setIsResizableFrameOversized, 6403 innerContentStyle: { 6404 background: gradientValue ?? backgroundColor 6405 }, 6406 children: areas2.preview 6407 } 6408 ) }) 6409 } 6410 ) 6411 ] }) 6412 ] }) 6413 } 6414 ) 6415 ] }); 6416 } 6417 function LayoutWithGlobalStylesProvider(props) { 6418 const { createErrorNotice } = (0, import_data13.useDispatch)(import_notices.store); 6419 function onPluginAreaError(name2) { 6420 createErrorNotice( 6421 (0, import_i18n8.sprintf)( 6422 /* translators: %s: plugin name */ 6423 (0, import_i18n8.__)( 6424 'The "%s" plugin has encountered an error and cannot be rendered.' 6425 ), 6426 name2 6427 ) 6428 ); 6429 } 6430 return /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(import_components9.SlotFillProvider, { children: [ 6431 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(import_plugins2.PluginArea, { onError: onPluginAreaError }), 6432 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(Layout, { ...props }) 6433 ] }); 6434 } 6435 6436 // packages/edit-site/build-module/hooks/commands/use-common-commands.js 6437 var import_element13 = __toESM(require_element()); 6438 var import_data14 = __toESM(require_data()); 6439 var import_i18n9 = __toESM(require_i18n()); 6440 var import_commands2 = __toESM(require_commands()); 6441 var import_router7 = __toESM(require_router()); 6442 var import_preferences4 = __toESM(require_preferences()); 6443 var import_core_data12 = __toESM(require_core_data()); 6444 var import_editor7 = __toESM(require_editor()); 6445 var { useHistory: useHistory4, useLocation: useLocation7 } = unlock(import_router7.privateApis); 6446 var { useGlobalStyles } = unlock(import_editor7.privateApis); 6447 var getGlobalStylesToggleWelcomeGuideCommands = () => function useGlobalStylesToggleWelcomeGuideCommands() { 6448 const { openGeneralSidebar: openGeneralSidebar2 } = unlock((0, import_data14.useDispatch)(store)); 6449 const { params } = useLocation7(); 6450 const { canvas = "view" } = params; 6451 const { set } = (0, import_data14.useDispatch)(import_preferences4.store); 6452 const history = useHistory4(); 6453 const isBlockBasedTheme = (0, import_data14.useSelect)((select3) => { 6454 return select3(import_core_data12.store).getCurrentTheme().is_block_theme; 6455 }, []); 6456 const commands = (0, import_element13.useMemo)(() => { 6457 if (!isBlockBasedTheme) { 6458 return []; 6459 } 6460 return [ 6461 { 6462 name: "core/edit-site/toggle-styles-welcome-guide", 6463 label: (0, import_i18n9.__)("Learn about styles"), 6464 callback: ({ close }) => { 6465 close(); 6466 if (canvas !== "edit") { 6467 history.navigate("/styles?canvas=edit", { 6468 transition: "canvas-mode-edit-transition" 6469 }); 6470 } 6471 openGeneralSidebar2("edit-site/global-styles"); 6472 set("core/edit-site", "welcomeGuideStyles", true); 6473 setTimeout(() => { 6474 set("core/edit-site", "welcomeGuideStyles", true); 6475 }, 500); 6476 }, 6477 icon: help_default 6478 } 6479 ]; 6480 }, [history, openGeneralSidebar2, canvas, isBlockBasedTheme, set]); 6481 return { 6482 isLoading: false, 6483 commands 6484 }; 6485 }; 6486 var getGlobalStylesResetCommands = () => function useGlobalStylesResetCommands() { 6487 const { user, setUser } = useGlobalStyles(); 6488 const canReset = !!user && (Object.keys(user?.styles ?? {}).length > 0 || Object.keys(user?.settings ?? {}).length > 0); 6489 const commands = (0, import_element13.useMemo)(() => { 6490 if (!canReset) { 6491 return []; 6492 } 6493 return [ 6494 { 6495 name: "core/edit-site/reset-global-styles", 6496 label: (0, import_i18n9.__)("Reset styles"), 6497 icon: (0, import_i18n9.isRTL)() ? rotate_right_default : rotate_left_default, 6498 callback: ({ close }) => { 6499 close(); 6500 setUser({ styles: {}, settings: {} }); 6501 } 6502 } 6503 ]; 6504 }, [canReset, setUser]); 6505 return { 6506 isLoading: false, 6507 commands 6508 }; 6509 }; 6510 var getGlobalStylesOpenRevisionsCommands = () => function useGlobalStylesOpenRevisionsCommands() { 6511 const { openGeneralSidebar: openGeneralSidebar2 } = unlock((0, import_data14.useDispatch)(store)); 6512 const { setStylesPath } = unlock((0, import_data14.useDispatch)(import_editor7.store)); 6513 const { params } = useLocation7(); 6514 const { canvas = "view" } = params; 6515 const history = useHistory4(); 6516 const hasRevisions = (0, import_data14.useSelect)((select3) => { 6517 const { getEntityRecord, __experimentalGetCurrentGlobalStylesId } = select3(import_core_data12.store); 6518 const globalStylesId = __experimentalGetCurrentGlobalStylesId(); 6519 const globalStyles = globalStylesId ? getEntityRecord("root", "globalStyles", globalStylesId) : void 0; 6520 return !!globalStyles?._links?.["version-history"]?.[0]?.count; 6521 }, []); 6522 const commands = (0, import_element13.useMemo)(() => { 6523 if (!hasRevisions) { 6524 return []; 6525 } 6526 return [ 6527 { 6528 name: "core/edit-site/open-styles-revisions", 6529 label: (0, import_i18n9.__)("Open style revisions"), 6530 icon: backup_default, 6531 callback: ({ close }) => { 6532 close(); 6533 if (canvas !== "edit") { 6534 history.navigate("/styles?canvas=edit", { 6535 transition: "canvas-mode-edit-transition" 6536 }); 6537 } 6538 openGeneralSidebar2("edit-site/global-styles"); 6539 setStylesPath("/revisions"); 6540 } 6541 } 6542 ]; 6543 }, [ 6544 history, 6545 openGeneralSidebar2, 6546 setStylesPath, 6547 hasRevisions, 6548 canvas 6549 ]); 6550 return { 6551 isLoading: false, 6552 commands 6553 }; 6554 }; 6555 function useCommonCommands() { 6556 (0, import_commands2.useCommandLoader)({ 6557 name: "core/edit-site/toggle-styles-welcome-guide", 6558 hook: getGlobalStylesToggleWelcomeGuideCommands() 6559 }); 6560 (0, import_commands2.useCommandLoader)({ 6561 name: "core/edit-site/reset-global-styles", 6562 hook: getGlobalStylesResetCommands() 6563 }); 6564 (0, import_commands2.useCommandLoader)({ 6565 name: "core/edit-site/open-styles-revisions", 6566 hook: getGlobalStylesOpenRevisionsCommands() 6567 }); 6568 } 6569 6570 // packages/edit-site/build-module/hooks/commands/use-set-command-context.js 6571 var import_data15 = __toESM(require_data()); 6572 var import_commands3 = __toESM(require_commands()); 6573 var import_block_editor3 = __toESM(require_block_editor()); 6574 var import_router8 = __toESM(require_router()); 6575 var { useCommandContext } = unlock(import_commands3.privateApis); 6576 var { useLocation: useLocation8 } = unlock(import_router8.privateApis); 6577 function useSetCommandContext() { 6578 const { query = {} } = useLocation8(); 6579 const { canvas = "view" } = query; 6580 const hasBlockSelected = (0, import_data15.useSelect)((select3) => { 6581 return select3(import_block_editor3.store).getBlockSelectionStart(); 6582 }, []); 6583 let commandContext = "site-editor"; 6584 if (canvas === "edit") { 6585 commandContext = "entity-edit"; 6586 } 6587 if (hasBlockSelected) { 6588 commandContext = "block-selection-edit"; 6589 } 6590 useCommandContext(commandContext); 6591 } 6592 6593 // packages/edit-site/build-module/components/site-editor-routes/index.js 6594 var import_data81 = __toESM(require_data()); 6595 var import_element152 = __toESM(require_element()); 6596 6597 // packages/edit-site/build-module/components/sidebar-navigation-screen-main/index.js 6598 var import_components74 = __toESM(require_components()); 6599 var import_i18n59 = __toESM(require_i18n()); 6600 var import_data31 = __toESM(require_data()); 6601 var import_core_data25 = __toESM(require_core_data()); 6602 6603 // packages/edit-site/build-module/components/sidebar-navigation-screen/index.js 6604 var import_components11 = __toESM(require_components()); 6605 var import_i18n10 = __toESM(require_i18n()); 6606 var import_core_data13 = __toESM(require_core_data()); 6607 var import_data16 = __toESM(require_data()); 6608 var import_router9 = __toESM(require_router()); 6609 var import_element14 = __toESM(require_element()); 6610 6611 // packages/edit-site/build-module/components/sidebar-button/index.js 6612 var import_components10 = __toESM(require_components()); 6613 var import_jsx_runtime78 = __toESM(require_jsx_runtime()); 6614 function SidebarButton(props) { 6615 return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)( 6616 import_components10.Button, 6617 { 6618 size: "compact", 6619 ...props, 6620 className: clsx_default("edit-site-sidebar-button", props.className) 6621 } 6622 ); 6623 } 6624 6625 // packages/edit-site/build-module/components/sidebar-navigation-screen/index.js 6626 var import_jsx_runtime79 = __toESM(require_jsx_runtime()); 6627 var { useHistory: useHistory5, useLocation: useLocation9 } = unlock(import_router9.privateApis); 6628 function SidebarNavigationScreen({ 6629 isRoot, 6630 title, 6631 actions, 6632 content, 6633 footer, 6634 description, 6635 backPath: backPathProp 6636 }) { 6637 const { dashboardLink, dashboardLinkText, previewingThemeName } = (0, import_data16.useSelect)( 6638 (select3) => { 6639 const { getSettings: getSettings7 } = unlock(select3(store)); 6640 const currentlyPreviewingThemeId = currentlyPreviewingTheme(); 6641 return { 6642 dashboardLink: getSettings7().__experimentalDashboardLink, 6643 dashboardLinkText: getSettings7().__experimentalDashboardLinkText, 6644 // Do not call `getTheme` with null, it will cause a request to 6645 // the server. 6646 previewingThemeName: currentlyPreviewingThemeId ? select3(import_core_data13.store).getTheme(currentlyPreviewingThemeId)?.name?.rendered : void 0 6647 }; 6648 }, 6649 [] 6650 ); 6651 const location = useLocation9(); 6652 const history = useHistory5(); 6653 const { navigate } = (0, import_element14.useContext)(SidebarNavigationContext); 6654 const backPath = backPathProp ?? location.state?.backPath; 6655 const icon = (0, import_i18n10.isRTL)() ? chevron_right_default : chevron_left_default; 6656 return /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)(import_jsx_runtime79.Fragment, { children: [ 6657 /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)( 6658 import_components11.__experimentalVStack, 6659 { 6660 className: clsx_default("edit-site-sidebar-navigation-screen__main", { 6661 "has-footer": !!footer 6662 }), 6663 spacing: 0, 6664 justify: "flex-start", 6665 children: [ 6666 /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)( 6667 import_components11.__experimentalHStack, 6668 { 6669 spacing: 3, 6670 alignment: "flex-start", 6671 className: "edit-site-sidebar-navigation-screen__title-icon", 6672 children: [ 6673 !isRoot && /* @__PURE__ */ (0, import_jsx_runtime79.jsx)( 6674 SidebarButton, 6675 { 6676 onClick: () => { 6677 history.navigate(backPath); 6678 navigate("back"); 6679 }, 6680 icon, 6681 label: (0, import_i18n10.__)("Back"), 6682 showTooltip: false 6683 } 6684 ), 6685 isRoot && /* @__PURE__ */ (0, import_jsx_runtime79.jsx)( 6686 SidebarButton, 6687 { 6688 icon, 6689 label: dashboardLinkText || (0, import_i18n10.__)("Go to the Dashboard"), 6690 href: dashboardLink 6691 } 6692 ), 6693 /* @__PURE__ */ (0, import_jsx_runtime79.jsx)( 6694 import_components11.__experimentalHeading, 6695 { 6696 className: "edit-site-sidebar-navigation-screen__title", 6697 color: "#e0e0e0", 6698 level: 1, 6699 size: 20, 6700 children: !isPreviewingTheme() ? title : (0, import_i18n10.sprintf)( 6701 /* translators: 1: theme name. 2: title */ 6702 (0, import_i18n10.__)("Previewing %1$s: %2$s"), 6703 previewingThemeName, 6704 title 6705 ) 6706 } 6707 ), 6708 actions && /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("div", { className: "edit-site-sidebar-navigation-screen__actions", children: actions }) 6709 ] 6710 } 6711 ), 6712 /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)("div", { className: "edit-site-sidebar-navigation-screen__content", children: [ 6713 description && /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("div", { className: "edit-site-sidebar-navigation-screen__description", children: description }), 6714 content 6715 ] }) 6716 ] 6717 } 6718 ), 6719 footer && /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("footer", { className: "edit-site-sidebar-navigation-screen__footer", children: footer }) 6720 ] }); 6721 } 6722 6723 // packages/edit-site/build-module/components/sidebar-navigation-item/index.js 6724 var import_components12 = __toESM(require_components()); 6725 var import_i18n11 = __toESM(require_i18n()); 6726 var import_router10 = __toESM(require_router()); 6727 var import_element15 = __toESM(require_element()); 6728 var import_jsx_runtime80 = __toESM(require_jsx_runtime()); 6729 var { useHistory: useHistory6, useLink } = unlock(import_router10.privateApis); 6730 function SidebarNavigationItem({ 6731 className, 6732 icon, 6733 withChevron = false, 6734 suffix, 6735 uid, 6736 to: to2, 6737 onClick, 6738 children, 6739 ...props 6740 }) { 6741 const history = useHistory6(); 6742 const { navigate } = (0, import_element15.useContext)(SidebarNavigationContext); 6743 function handleClick(e2) { 6744 if (onClick) { 6745 onClick(e2); 6746 navigate("forward"); 6747 } else if (to2) { 6748 e2.preventDefault(); 6749 history.navigate(to2); 6750 navigate("forward", `[id="$uid}"]`); 6751 } 6752 } 6753 const linkProps = useLink(to2); 6754 return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)( 6755 import_components12.__experimentalItem, 6756 { 6757 className: clsx_default( 6758 "edit-site-sidebar-navigation-item", 6759 { "with-suffix": !withChevron && suffix }, 6760 className 6761 ), 6762 id: uid, 6763 onClick: handleClick, 6764 href: to2 ? linkProps.href : void 0, 6765 ...props, 6766 children: /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)(import_components12.__experimentalHStack, { justify: "flex-start", children: [ 6767 icon && /* @__PURE__ */ (0, import_jsx_runtime80.jsx)( 6768 icon_default, 6769 { 6770 style: { fill: "currentcolor" }, 6771 icon, 6772 size: 24 6773 } 6774 ), 6775 /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(import_components12.FlexBlock, { children }), 6776 withChevron && /* @__PURE__ */ (0, import_jsx_runtime80.jsx)( 6777 icon_default, 6778 { 6779 icon: (0, import_i18n11.isRTL)() ? chevron_left_small_default : chevron_right_small_default, 6780 className: "edit-site-sidebar-navigation-item__drilldown-indicator", 6781 size: 24 6782 } 6783 ), 6784 !withChevron && suffix 6785 ] }) 6786 } 6787 ); 6788 } 6789 6790 // packages/edit-site/build-module/components/sidebar-navigation-screen-global-styles/index.js 6791 var import_i18n58 = __toESM(require_i18n()); 6792 var import_data30 = __toESM(require_data()); 6793 var import_element47 = __toESM(require_element()); 6794 var import_preferences5 = __toESM(require_preferences()); 6795 var import_editor8 = __toESM(require_editor()); 6796 var import_router11 = __toESM(require_router()); 6797 var import_url7 = __toESM(require_url()); 6798 6799 // packages/global-styles-ui/build-module/global-styles-ui.js 6800 var import_components72 = __toESM(require_components()); 6801 var import_blocks8 = __toESM(require_blocks()); 6802 var import_data29 = __toESM(require_data()); 6803 var import_block_editor16 = __toESM(require_block_editor()); 6804 var import_element46 = __toESM(require_element()); 6805 var import_compose8 = __toESM(require_compose()); 6806 6807 // packages/global-styles-engine/build-module/utils/object.js 6808 function setImmutably(object, path, value) { 6809 path = Array.isArray(path) ? [...path] : [path]; 6810 object = Array.isArray(object) ? [...object] : { ...object }; 6811 const leaf = path.pop(); 6812 let prev = object; 6813 for (const key of path) { 6814 const lvl = prev[key]; 6815 prev = prev[key] = Array.isArray(lvl) ? [...lvl] : { ...lvl }; 6816 } 6817 prev[leaf] = value; 6818 return object; 6819 } 6820 var getValueFromObjectPath = (object, path, defaultValue2) => { 6821 const arrayPath = Array.isArray(path) ? path : path.split("."); 6822 let value = object; 6823 arrayPath.forEach((fieldName) => { 6824 value = value?.[fieldName]; 6825 }); 6826 return value ?? defaultValue2; 6827 }; 6828 6829 // packages/global-styles-engine/build-module/settings/get-setting.js 6830 var VALID_SETTINGS = [ 6831 "appearanceTools", 6832 "useRootPaddingAwareAlignments", 6833 "background.backgroundImage", 6834 "background.backgroundRepeat", 6835 "background.backgroundSize", 6836 "background.backgroundPosition", 6837 "border.color", 6838 "border.radius", 6839 "border.radiusSizes", 6840 "border.style", 6841 "border.width", 6842 "shadow.presets", 6843 "shadow.defaultPresets", 6844 "color.background", 6845 "color.button", 6846 "color.caption", 6847 "color.custom", 6848 "color.customDuotone", 6849 "color.customGradient", 6850 "color.defaultDuotone", 6851 "color.defaultGradients", 6852 "color.defaultPalette", 6853 "color.duotone", 6854 "color.gradients", 6855 "color.heading", 6856 "color.link", 6857 "color.palette", 6858 "color.text", 6859 "custom", 6860 "dimensions.aspectRatio", 6861 "dimensions.height", 6862 "dimensions.minHeight", 6863 "dimensions.width", 6864 "dimensions.dimensionSizes", 6865 "layout.contentSize", 6866 "layout.definitions", 6867 "layout.wideSize", 6868 "lightbox.enabled", 6869 "lightbox.allowEditing", 6870 "position.fixed", 6871 "position.sticky", 6872 "spacing.customSpacingSize", 6873 "spacing.defaultSpacingSizes", 6874 "spacing.spacingSizes", 6875 "spacing.spacingScale", 6876 "spacing.blockGap", 6877 "spacing.margin", 6878 "spacing.padding", 6879 "spacing.units", 6880 "typography.fluid", 6881 "typography.customFontSize", 6882 "typography.defaultFontSizes", 6883 "typography.dropCap", 6884 "typography.fontFamilies", 6885 "typography.fontSizes", 6886 "typography.fontStyle", 6887 "typography.fontWeight", 6888 "typography.letterSpacing", 6889 "typography.lineHeight", 6890 "typography.textAlign", 6891 "typography.textColumns", 6892 "typography.textDecoration", 6893 "typography.textTransform", 6894 "typography.writingMode" 6895 ]; 6896 function getSetting(globalStyles, path, blockName) { 6897 const appendedBlockPath = blockName ? ".blocks." + blockName : ""; 6898 const appendedPropertyPath = path ? "." + path : ""; 6899 const contextualPath = `settings$appendedBlockPath}$appendedPropertyPath}`; 6900 const globalPath = `settings$appendedPropertyPath}`; 6901 if (path) { 6902 return getValueFromObjectPath(globalStyles, contextualPath) ?? getValueFromObjectPath(globalStyles, globalPath); 6903 } 6904 let result = {}; 6905 VALID_SETTINGS.forEach((setting) => { 6906 const value = getValueFromObjectPath( 6907 globalStyles, 6908 `settings$appendedBlockPath}.$setting}` 6909 ) ?? getValueFromObjectPath(globalStyles, `settings.$setting}`); 6910 if (value !== void 0) { 6911 result = setImmutably(result, setting.split("."), value); 6912 } 6913 }); 6914 return result; 6915 } 6916 6917 // packages/global-styles-engine/build-module/settings/set-setting.js 6918 function setSetting(globalStyles, path, newValue, blockName) { 6919 const appendedBlockPath = blockName ? ".blocks." + blockName : ""; 6920 const appendedPropertyPath = path ? "." + path : ""; 6921 const finalPath = `settings$appendedBlockPath}$appendedPropertyPath}`; 6922 return setImmutably( 6923 globalStyles, 6924 finalPath.split("."), 6925 newValue 6926 ); 6927 } 6928 6929 // packages/global-styles-engine/build-module/utils/common.js 6930 var import_style_engine = __toESM(require_style_engine()); 6931 6932 // packages/global-styles-engine/build-module/utils/fluid.js 6933 var DEFAULT_MAXIMUM_VIEWPORT_WIDTH = "1600px"; 6934 var DEFAULT_MINIMUM_VIEWPORT_WIDTH = "320px"; 6935 var DEFAULT_SCALE_FACTOR = 1; 6936 var DEFAULT_MINIMUM_FONT_SIZE_FACTOR_MIN = 0.25; 6937 var DEFAULT_MINIMUM_FONT_SIZE_FACTOR_MAX = 0.75; 6938 var DEFAULT_MINIMUM_FONT_SIZE_LIMIT = "14px"; 6939 function getComputedFluidTypographyValue({ 6940 minimumFontSize, 6941 maximumFontSize, 6942 fontSize, 6943 minimumViewportWidth = DEFAULT_MINIMUM_VIEWPORT_WIDTH, 6944 maximumViewportWidth = DEFAULT_MAXIMUM_VIEWPORT_WIDTH, 6945 scaleFactor = DEFAULT_SCALE_FACTOR, 6946 minimumFontSizeLimit 6947 }) { 6948 minimumFontSizeLimit = !!getTypographyValueAndUnit(minimumFontSizeLimit) ? minimumFontSizeLimit : DEFAULT_MINIMUM_FONT_SIZE_LIMIT; 6949 if (fontSize) { 6950 const fontSizeParsed = getTypographyValueAndUnit(fontSize); 6951 if (!fontSizeParsed?.unit || !fontSizeParsed?.value) { 6952 return null; 6953 } 6954 const minimumFontSizeLimitParsed = getTypographyValueAndUnit( 6955 minimumFontSizeLimit, 6956 { 6957 coerceTo: fontSizeParsed.unit 6958 } 6959 ); 6960 if (!!minimumFontSizeLimitParsed?.value && !minimumFontSize && !maximumFontSize) { 6961 if (fontSizeParsed?.value <= minimumFontSizeLimitParsed?.value) { 6962 return null; 6963 } 6964 } 6965 if (!maximumFontSize) { 6966 maximumFontSize = `$fontSizeParsed.value}$fontSizeParsed.unit}`; 6967 } 6968 if (!minimumFontSize) { 6969 const fontSizeValueInPx = fontSizeParsed.unit === "px" ? fontSizeParsed.value : fontSizeParsed.value * 16; 6970 const minimumFontSizeFactor = Math.min( 6971 Math.max( 6972 1 - 0.075 * Math.log2(fontSizeValueInPx), 6973 DEFAULT_MINIMUM_FONT_SIZE_FACTOR_MIN 6974 ), 6975 DEFAULT_MINIMUM_FONT_SIZE_FACTOR_MAX 6976 ); 6977 const calculatedMinimumFontSize = roundToPrecision( 6978 fontSizeParsed.value * minimumFontSizeFactor, 6979 3 6980 ); 6981 if (!!minimumFontSizeLimitParsed?.value && calculatedMinimumFontSize < minimumFontSizeLimitParsed?.value) { 6982 minimumFontSize = `$minimumFontSizeLimitParsed.value}$minimumFontSizeLimitParsed.unit}`; 6983 } else { 6984 minimumFontSize = `$calculatedMinimumFontSize}$fontSizeParsed.unit}`; 6985 } 6986 } 6987 } 6988 const minimumFontSizeParsed = getTypographyValueAndUnit(minimumFontSize); 6989 const fontSizeUnit = minimumFontSizeParsed?.unit || "rem"; 6990 const maximumFontSizeParsed = getTypographyValueAndUnit(maximumFontSize, { 6991 coerceTo: fontSizeUnit 6992 }); 6993 if (!minimumFontSizeParsed || !maximumFontSizeParsed) { 6994 return null; 6995 } 6996 const minimumFontSizeRem = getTypographyValueAndUnit(minimumFontSize, { 6997 coerceTo: "rem" 6998 }); 6999 const maximumViewportWidthParsed = getTypographyValueAndUnit( 7000 maximumViewportWidth, 7001 { coerceTo: fontSizeUnit } 7002 ); 7003 const minimumViewportWidthParsed = getTypographyValueAndUnit( 7004 minimumViewportWidth, 7005 { coerceTo: fontSizeUnit } 7006 ); 7007 if (!maximumViewportWidthParsed || !minimumViewportWidthParsed || !minimumFontSizeRem) { 7008 return null; 7009 } 7010 const linearDenominator = maximumViewportWidthParsed.value - minimumViewportWidthParsed.value; 7011 if (!linearDenominator) { 7012 return null; 7013 } 7014 const minViewportWidthOffsetValue = roundToPrecision( 7015 minimumViewportWidthParsed.value / 100, 7016 3 7017 ); 7018 const viewportWidthOffset = roundToPrecision(minViewportWidthOffsetValue, 3) + fontSizeUnit; 7019 const linearFactor = 100 * ((maximumFontSizeParsed.value - minimumFontSizeParsed.value) / linearDenominator); 7020 const linearFactorScaled = roundToPrecision( 7021 (linearFactor || 1) * scaleFactor, 7022 3 7023 ); 7024 const fluidTargetFontSize = `$minimumFontSizeRem.value}$minimumFontSizeRem.unit} + ((1vw - $viewportWidthOffset}) * $linearFactorScaled})`; 7025 return `clamp($minimumFontSize}, $fluidTargetFontSize}, $maximumFontSize})`; 7026 } 7027 function getTypographyValueAndUnit(rawValue, options = {}) { 7028 if (typeof rawValue !== "string" && typeof rawValue !== "number") { 7029 return null; 7030 } 7031 if (isFinite(rawValue)) { 7032 rawValue = `$rawValue}px`; 7033 } 7034 const { coerceTo, rootSizeValue, acceptableUnits } = { 7035 coerceTo: "", 7036 // Default browser font size. Later we could inject some JS to compute this `getComputedStyle( document.querySelector( "html" ) ).fontSize`. 7037 rootSizeValue: 16, 7038 acceptableUnits: ["rem", "px", "em"], 7039 ...options 7040 }; 7041 const acceptableUnitsGroup = acceptableUnits?.join("|"); 7042 const regexUnits = new RegExp( 7043 `^(\\d*\\.?\\d+)($acceptableUnitsGroup}){1,1}$` 7044 ); 7045 const matches = rawValue.toString().match(regexUnits); 7046 if (!matches || matches.length < 3) { 7047 return null; 7048 } 7049 let [, value, unit] = matches; 7050 let returnValue = parseFloat(value); 7051 if ("px" === coerceTo && ("em" === unit || "rem" === unit)) { 7052 returnValue = returnValue * rootSizeValue; 7053 unit = coerceTo; 7054 } 7055 if ("px" === unit && ("em" === coerceTo || "rem" === coerceTo)) { 7056 returnValue = returnValue / rootSizeValue; 7057 unit = coerceTo; 7058 } 7059 if (("em" === coerceTo || "rem" === coerceTo) && ("em" === unit || "rem" === unit)) { 7060 unit = coerceTo; 7061 } 7062 if (!unit) { 7063 return null; 7064 } 7065 return { 7066 value: roundToPrecision(returnValue, 3), 7067 unit 7068 }; 7069 } 7070 function roundToPrecision(value, digits = 3) { 7071 const base = Math.pow(10, digits); 7072 return Math.round(value * base) / base; 7073 } 7074 7075 // packages/global-styles-engine/build-module/utils/typography.js 7076 function isFluidTypographyEnabled(typographySettings) { 7077 const fluidSettings = typographySettings?.fluid; 7078 return true === fluidSettings || fluidSettings && typeof fluidSettings === "object" && Object.keys(fluidSettings).length > 0; 7079 } 7080 function getFluidTypographyOptionsFromSettings(settings2) { 7081 const typographySettings = settings2?.typography ?? {}; 7082 const layoutSettings = settings2?.layout; 7083 const defaultMaxViewportWidth = getTypographyValueAndUnit( 7084 layoutSettings?.wideSize 7085 ) ? layoutSettings?.wideSize : null; 7086 return isFluidTypographyEnabled(typographySettings) && defaultMaxViewportWidth ? { 7087 fluid: { 7088 maxViewportWidth: defaultMaxViewportWidth, 7089 ...typeof typographySettings.fluid === "object" ? typographySettings.fluid : {} 7090 } 7091 } : { 7092 fluid: typographySettings?.fluid 7093 }; 7094 } 7095 function getTypographyFontSizeValue(preset, settings2) { 7096 const { size: defaultSize } = preset; 7097 if (!defaultSize || "0" === defaultSize || false === preset?.fluid) { 7098 return defaultSize; 7099 } 7100 if (!isFluidTypographyEnabled(settings2?.typography) && !isFluidTypographyEnabled(preset)) { 7101 return defaultSize; 7102 } 7103 const fluidTypographySettings = getFluidTypographyOptionsFromSettings(settings2)?.fluid ?? {}; 7104 const fluidFontSizeValue = getComputedFluidTypographyValue({ 7105 minimumFontSize: typeof preset?.fluid === "boolean" ? void 0 : preset?.fluid?.min, 7106 maximumFontSize: typeof preset?.fluid === "boolean" ? void 0 : preset?.fluid?.max, 7107 fontSize: defaultSize, 7108 minimumFontSizeLimit: typeof fluidTypographySettings === "object" ? fluidTypographySettings?.minFontSize : void 0, 7109 maximumViewportWidth: typeof fluidTypographySettings === "object" ? fluidTypographySettings?.maxViewportWidth : void 0, 7110 minimumViewportWidth: typeof fluidTypographySettings === "object" ? fluidTypographySettings?.minViewportWidth : void 0 7111 }); 7112 if (!!fluidFontSizeValue) { 7113 return fluidFontSizeValue; 7114 } 7115 return defaultSize; 7116 } 7117 7118 // packages/global-styles-engine/build-module/utils/common.js 7119 var ROOT_BLOCK_SELECTOR = "body"; 7120 var ROOT_CSS_PROPERTIES_SELECTOR = ":root"; 7121 var PRESET_METADATA = [ 7122 { 7123 path: ["color", "palette"], 7124 valueKey: "color", 7125 cssVarInfix: "color", 7126 classes: [ 7127 { classSuffix: "color", propertyName: "color" }, 7128 { 7129 classSuffix: "background-color", 7130 propertyName: "background-color" 7131 }, 7132 { 7133 classSuffix: "border-color", 7134 propertyName: "border-color" 7135 } 7136 ] 7137 }, 7138 { 7139 path: ["color", "gradients"], 7140 valueKey: "gradient", 7141 cssVarInfix: "gradient", 7142 classes: [ 7143 { 7144 classSuffix: "gradient-background", 7145 propertyName: "background" 7146 } 7147 ] 7148 }, 7149 { 7150 path: ["color", "duotone"], 7151 valueKey: "colors", 7152 cssVarInfix: "duotone", 7153 valueFunc: ({ slug }) => `url( '#wp-duotone-$slug}' )`, 7154 classes: [] 7155 }, 7156 { 7157 path: ["shadow", "presets"], 7158 valueKey: "shadow", 7159 cssVarInfix: "shadow", 7160 classes: [] 7161 }, 7162 { 7163 path: ["typography", "fontSizes"], 7164 valueFunc: (preset, settings2) => getTypographyFontSizeValue(preset, settings2), 7165 valueKey: "size", 7166 cssVarInfix: "font-size", 7167 classes: [{ classSuffix: "font-size", propertyName: "font-size" }] 7168 }, 7169 { 7170 path: ["typography", "fontFamilies"], 7171 valueKey: "fontFamily", 7172 cssVarInfix: "font-family", 7173 classes: [ 7174 { classSuffix: "font-family", propertyName: "font-family" } 7175 ] 7176 }, 7177 { 7178 path: ["spacing", "spacingSizes"], 7179 valueKey: "size", 7180 cssVarInfix: "spacing", 7181 valueFunc: ({ size }) => size, 7182 classes: [] 7183 }, 7184 { 7185 path: ["border", "radiusSizes"], 7186 valueKey: "size", 7187 cssVarInfix: "border-radius", 7188 classes: [] 7189 }, 7190 { 7191 path: ["dimensions", "dimensionSizes"], 7192 valueKey: "size", 7193 cssVarInfix: "dimension", 7194 classes: [] 7195 } 7196 ]; 7197 function scopeSelector(scope, selector2) { 7198 if (!scope || !selector2) { 7199 return selector2; 7200 } 7201 const scopes = scope.split(","); 7202 const selectors = selector2.split(","); 7203 const selectorsScoped = []; 7204 scopes.forEach((outer) => { 7205 selectors.forEach((inner) => { 7206 selectorsScoped.push(`$outer.trim()} $inner.trim()}`); 7207 }); 7208 }); 7209 return selectorsScoped.join(", "); 7210 } 7211 function scopeFeatureSelectors(scope, selectors) { 7212 if (!scope || !selectors) { 7213 return; 7214 } 7215 const featureSelectors = {}; 7216 Object.entries(selectors).forEach(([feature, selector2]) => { 7217 if (typeof selector2 === "string") { 7218 featureSelectors[feature] = scopeSelector(scope, selector2); 7219 } 7220 if (typeof selector2 === "object") { 7221 featureSelectors[feature] = {}; 7222 Object.entries(selector2).forEach( 7223 ([subfeature, subfeatureSelector]) => { 7224 featureSelectors[feature][subfeature] = scopeSelector( 7225 scope, 7226 subfeatureSelector 7227 ); 7228 } 7229 ); 7230 } 7231 }); 7232 return featureSelectors; 7233 } 7234 function appendToSelector(selector2, toAppend) { 7235 if (!selector2.includes(",")) { 7236 return selector2 + toAppend; 7237 } 7238 const selectors = selector2.split(","); 7239 const newSelectors = selectors.map((sel) => sel + toAppend); 7240 return newSelectors.join(","); 7241 } 7242 function getBlockStyleVariationSelector(variation, blockSelector) { 7243 const variationClass = `.is-style-$variation}`; 7244 if (!blockSelector) { 7245 return variationClass; 7246 } 7247 const ancestorRegex = /((?::\([^)]+\))?\s*)([^\s:]+)/; 7248 const addVariationClass = (_match, group1, group2) => { 7249 return group1 + group2 + variationClass; 7250 }; 7251 const result = blockSelector.split(",").map((part) => part.replace(ancestorRegex, addVariationClass)); 7252 return result.join(","); 7253 } 7254 function getResolvedRefValue(ruleValue, tree) { 7255 if (!ruleValue || !tree) { 7256 return ruleValue; 7257 } 7258 if (typeof ruleValue === "object" && "ref" in ruleValue && ruleValue?.ref) { 7259 const resolvedRuleValue = (0, import_style_engine.getCSSValueFromRawStyle)( 7260 getValueFromObjectPath(tree, ruleValue.ref) 7261 ); 7262 if (typeof resolvedRuleValue === "object" && resolvedRuleValue !== null && "ref" in resolvedRuleValue && resolvedRuleValue?.ref) { 7263 return void 0; 7264 } 7265 if (resolvedRuleValue === void 0) { 7266 return ruleValue; 7267 } 7268 return resolvedRuleValue; 7269 } 7270 return ruleValue; 7271 } 7272 function getResolvedThemeFilePath(file, themeFileURIs) { 7273 if (!file || !themeFileURIs || !Array.isArray(themeFileURIs)) { 7274 return file; 7275 } 7276 const uri = themeFileURIs.find( 7277 (themeFileUri) => themeFileUri?.name === file 7278 ); 7279 if (!uri?.href) { 7280 return file; 7281 } 7282 return uri?.href; 7283 } 7284 function getResolvedValue(ruleValue, tree) { 7285 if (!ruleValue || !tree) { 7286 return ruleValue; 7287 } 7288 const resolvedValue = getResolvedRefValue(ruleValue, tree); 7289 if (typeof resolvedValue === "object" && resolvedValue !== null && "url" in resolvedValue && resolvedValue?.url) { 7290 resolvedValue.url = getResolvedThemeFilePath( 7291 resolvedValue.url, 7292 tree?._links?.["wp:theme-file"] 7293 ); 7294 } 7295 return resolvedValue; 7296 } 7297 function findInPresetsBy(settings2, blockName, presetPath = [], presetProperty = "slug", presetValueValue) { 7298 const orderedPresetsByOrigin = [ 7299 blockName ? getValueFromObjectPath(settings2, [ 7300 "blocks", 7301 blockName, 7302 ...presetPath 7303 ]) : void 0, 7304 getValueFromObjectPath(settings2, presetPath) 7305 ].filter(Boolean); 7306 for (const presetByOrigin of orderedPresetsByOrigin) { 7307 if (presetByOrigin) { 7308 const origins = ["custom", "theme", "default"]; 7309 for (const origin of origins) { 7310 const presets = presetByOrigin[origin]; 7311 if (presets) { 7312 const presetObject = presets.find( 7313 (preset) => preset[presetProperty] === presetValueValue 7314 ); 7315 if (presetObject) { 7316 if (presetProperty === "slug") { 7317 return presetObject; 7318 } 7319 const highestPresetObjectWithSameSlug = findInPresetsBy( 7320 settings2, 7321 blockName, 7322 presetPath, 7323 "slug", 7324 presetObject.slug 7325 ); 7326 if (highestPresetObjectWithSameSlug[presetProperty] === presetObject[presetProperty]) { 7327 return presetObject; 7328 } 7329 return void 0; 7330 } 7331 } 7332 } 7333 } 7334 } 7335 } 7336 function getValueFromPresetVariable(features, blockName, variable, [presetType, slug] = []) { 7337 const metadata = PRESET_METADATA.find( 7338 (data) => data.cssVarInfix === presetType 7339 ); 7340 if (!metadata || !features.settings) { 7341 return variable; 7342 } 7343 const presetObject = findInPresetsBy( 7344 features.settings, 7345 blockName, 7346 metadata.path, 7347 "slug", 7348 slug 7349 ); 7350 if (presetObject) { 7351 const { valueKey } = metadata; 7352 const result = presetObject[valueKey]; 7353 return getValueFromVariable(features, blockName, result); 7354 } 7355 return variable; 7356 } 7357 function getValueFromCustomVariable(features, blockName, variable, path = []) { 7358 const result = (blockName ? getValueFromObjectPath(features?.settings ?? {}, [ 7359 "blocks", 7360 blockName, 7361 "custom", 7362 ...path 7363 ]) : void 0) ?? getValueFromObjectPath(features?.settings ?? {}, [ 7364 "custom", 7365 ...path 7366 ]); 7367 if (!result) { 7368 return variable; 7369 } 7370 return getValueFromVariable(features, blockName, result); 7371 } 7372 function getValueFromVariable(features, blockName, variable) { 7373 if (!variable || typeof variable !== "string") { 7374 if (typeof variable === "object" && variable !== null && "ref" in variable && typeof variable.ref === "string") { 7375 const resolvedVariable = getValueFromObjectPath( 7376 features, 7377 variable.ref 7378 ); 7379 if (!resolvedVariable || typeof resolvedVariable === "object" && "ref" in resolvedVariable) { 7380 return resolvedVariable; 7381 } 7382 variable = resolvedVariable; 7383 } else { 7384 return variable; 7385 } 7386 } 7387 const USER_VALUE_PREFIX = "var:"; 7388 const THEME_VALUE_PREFIX = "var(--wp--"; 7389 const THEME_VALUE_SUFFIX = ")"; 7390 let parsedVar; 7391 if (variable.startsWith(USER_VALUE_PREFIX)) { 7392 parsedVar = variable.slice(USER_VALUE_PREFIX.length).split("|"); 7393 } else if (variable.startsWith(THEME_VALUE_PREFIX) && variable.endsWith(THEME_VALUE_SUFFIX)) { 7394 parsedVar = variable.slice(THEME_VALUE_PREFIX.length, -THEME_VALUE_SUFFIX.length).split("--"); 7395 } else { 7396 return variable; 7397 } 7398 const [type, ...path] = parsedVar; 7399 if (type === "preset") { 7400 return getValueFromPresetVariable( 7401 features, 7402 blockName, 7403 variable, 7404 path 7405 ); 7406 } 7407 if (type === "custom") { 7408 return getValueFromCustomVariable( 7409 features, 7410 blockName, 7411 variable, 7412 path 7413 ); 7414 } 7415 return variable; 7416 } 7417 7418 // packages/global-styles-engine/build-module/settings/get-style.js 7419 function getStyle(globalStyles, path, blockName, shouldDecodeEncode = true) { 7420 const appendedPath = path ? "." + path : ""; 7421 const finalPath = !blockName ? `styles$appendedPath}` : `styles.blocks.$blockName}$appendedPath}`; 7422 if (!globalStyles) { 7423 return void 0; 7424 } 7425 const rawResult = getValueFromObjectPath(globalStyles, finalPath); 7426 const result = shouldDecodeEncode ? getValueFromVariable(globalStyles, blockName, rawResult) : rawResult; 7427 return result; 7428 } 7429 7430 // packages/global-styles-engine/build-module/settings/set-style.js 7431 function setStyle(globalStyles, path, newValue, blockName) { 7432 const appendedPath = path ? "." + path : ""; 7433 const finalPath = !blockName ? `styles$appendedPath}` : `styles.blocks.$blockName}$appendedPath}`; 7434 return setImmutably( 7435 globalStyles, 7436 finalPath.split("."), 7437 newValue 7438 ); 7439 } 7440 7441 // packages/global-styles-engine/build-module/core/equal.js 7442 var import_es6 = __toESM(require_es6()); 7443 function areGlobalStylesEqual(original, variation) { 7444 if (typeof original !== "object" || typeof variation !== "object") { 7445 return original === variation; 7446 } 7447 return (0, import_es6.default)(original?.styles, variation?.styles) && (0, import_es6.default)(original?.settings, variation?.settings); 7448 } 7449 7450 // packages/global-styles-engine/build-module/core/merge.js 7451 var import_deepmerge = __toESM(require_cjs()); 7452 7453 // node_modules/is-plain-object/dist/is-plain-object.mjs 7454 function isObject(o3) { 7455 return Object.prototype.toString.call(o3) === "[object Object]"; 7456 } 7457 function isPlainObject(o3) { 7458 var ctor, prot; 7459 if (isObject(o3) === false) return false; 7460 ctor = o3.constructor; 7461 if (ctor === void 0) return true; 7462 prot = ctor.prototype; 7463 if (isObject(prot) === false) return false; 7464 if (prot.hasOwnProperty("isPrototypeOf") === false) { 7465 return false; 7466 } 7467 return true; 7468 } 7469 7470 // packages/global-styles-engine/build-module/core/merge.js 7471 function mergeGlobalStyles(base, user) { 7472 return (0, import_deepmerge.default)(base, user, { 7473 /* 7474 * We only pass as arrays the presets, 7475 * in which case we want the new array of values 7476 * to override the old array (no merging). 7477 */ 7478 isMergeableObject: isPlainObject, 7479 /* 7480 * Exceptions to the above rule. 7481 * Background images should be replaced, not merged, 7482 * as they themselves are specific object definitions for the style. 7483 */ 7484 customMerge: (key) => { 7485 if (key === "backgroundImage") { 7486 return (baseConfig, userConfig) => userConfig ?? baseConfig; 7487 } 7488 return void 0; 7489 } 7490 }); 7491 } 7492 7493 // packages/global-styles-engine/build-module/core/render.js 7494 var import_blocks3 = __toESM(require_blocks()); 7495 var import_style_engine2 = __toESM(require_style_engine()); 7496 var import_data17 = __toESM(require_data()); 7497 7498 // packages/global-styles-engine/build-module/core/selectors.js 7499 function getBlockSelector(blockType, target = "root", options = {}) { 7500 if (!target) { 7501 return null; 7502 } 7503 const { fallback = false } = options; 7504 const { name: name2, selectors, supports } = blockType; 7505 const hasSelectors = selectors && Object.keys(selectors).length > 0; 7506 const path = Array.isArray(target) ? target.join(".") : target; 7507 let rootSelector = null; 7508 if (hasSelectors && selectors.root) { 7509 rootSelector = selectors?.root; 7510 } else if (supports?.__experimentalSelector) { 7511 rootSelector = supports.__experimentalSelector; 7512 } else { 7513 rootSelector = ".wp-block-" + name2.replace("core/", "").replace("/", "-"); 7514 } 7515 if (path === "root") { 7516 return rootSelector; 7517 } 7518 const pathArray = Array.isArray(target) ? target : target.split("."); 7519 if (pathArray.length === 1) { 7520 const fallbackSelector = fallback ? rootSelector : null; 7521 if (hasSelectors) { 7522 const featureSelector2 = getValueFromObjectPath( 7523 selectors, 7524 `$path}.root`, 7525 null 7526 ) || getValueFromObjectPath(selectors, path, null); 7527 return featureSelector2 || fallbackSelector; 7528 } 7529 const featureSelector = supports ? getValueFromObjectPath( 7530 supports, 7531 `$path}.__experimentalSelector`, 7532 null 7533 ) : void 0; 7534 if (!featureSelector) { 7535 return fallbackSelector; 7536 } 7537 return scopeSelector(rootSelector, featureSelector); 7538 } 7539 let subfeatureSelector; 7540 if (hasSelectors) { 7541 subfeatureSelector = getValueFromObjectPath(selectors, path, null); 7542 } 7543 if (subfeatureSelector) { 7544 return subfeatureSelector; 7545 } 7546 if (fallback) { 7547 return getBlockSelector(blockType, pathArray[0], options); 7548 } 7549 return null; 7550 } 7551 7552 // node_modules/colord/index.mjs 7553 var r2 = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }; 7554 var t = function(r3) { 7555 return "string" == typeof r3 ? r3.length > 0 : "number" == typeof r3; 7556 }; 7557 var n = function(r3, t3, n2) { 7558 return void 0 === t3 && (t3 = 0), void 0 === n2 && (n2 = Math.pow(10, t3)), Math.round(n2 * r3) / n2 + 0; 7559 }; 7560 var e = function(r3, t3, n2) { 7561 return void 0 === t3 && (t3 = 0), void 0 === n2 && (n2 = 1), r3 > n2 ? n2 : r3 > t3 ? r3 : t3; 7562 }; 7563 var u = function(r3) { 7564 return (r3 = isFinite(r3) ? r3 % 360 : 0) > 0 ? r3 : r3 + 360; 7565 }; 7566 var a = function(r3) { 7567 return { r: e(r3.r, 0, 255), g: e(r3.g, 0, 255), b: e(r3.b, 0, 255), a: e(r3.a) }; 7568 }; 7569 var o = function(r3) { 7570 return { r: n(r3.r), g: n(r3.g), b: n(r3.b), a: n(r3.a, 3) }; 7571 }; 7572 var i = /^#([0-9a-f]{3,8})$/i; 7573 var s = function(r3) { 7574 var t3 = r3.toString(16); 7575 return t3.length < 2 ? "0" + t3 : t3; 7576 }; 7577 var h = function(r3) { 7578 var t3 = r3.r, n2 = r3.g, e2 = r3.b, u2 = r3.a, a2 = Math.max(t3, n2, e2), o3 = a2 - Math.min(t3, n2, e2), i2 = o3 ? a2 === t3 ? (n2 - e2) / o3 : a2 === n2 ? 2 + (e2 - t3) / o3 : 4 + (t3 - n2) / o3 : 0; 7579 return { h: 60 * (i2 < 0 ? i2 + 6 : i2), s: a2 ? o3 / a2 * 100 : 0, v: a2 / 255 * 100, a: u2 }; 7580 }; 7581 var b = function(r3) { 7582 var t3 = r3.h, n2 = r3.s, e2 = r3.v, u2 = r3.a; 7583 t3 = t3 / 360 * 6, n2 /= 100, e2 /= 100; 7584 var a2 = Math.floor(t3), o3 = e2 * (1 - n2), i2 = e2 * (1 - (t3 - a2) * n2), s2 = e2 * (1 - (1 - t3 + a2) * n2), h2 = a2 % 6; 7585 return { r: 255 * [e2, i2, o3, o3, s2, e2][h2], g: 255 * [s2, e2, e2, i2, o3, o3][h2], b: 255 * [o3, o3, s2, e2, e2, i2][h2], a: u2 }; 7586 }; 7587 var g = function(r3) { 7588 return { h: u(r3.h), s: e(r3.s, 0, 100), l: e(r3.l, 0, 100), a: e(r3.a) }; 7589 }; 7590 var d = function(r3) { 7591 return { h: n(r3.h), s: n(r3.s), l: n(r3.l), a: n(r3.a, 3) }; 7592 }; 7593 var f = function(r3) { 7594 return b((n2 = (t3 = r3).s, { h: t3.h, s: (n2 *= ((e2 = t3.l) < 50 ? e2 : 100 - e2) / 100) > 0 ? 2 * n2 / (e2 + n2) * 100 : 0, v: e2 + n2, a: t3.a })); 7595 var t3, n2, e2; 7596 }; 7597 var c = function(r3) { 7598 return { h: (t3 = h(r3)).h, s: (u2 = (200 - (n2 = t3.s)) * (e2 = t3.v) / 100) > 0 && u2 < 200 ? n2 * e2 / 100 / (u2 <= 100 ? u2 : 200 - u2) * 100 : 0, l: u2 / 2, a: t3.a }; 7599 var t3, n2, e2, u2; 7600 }; 7601 var l = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i; 7602 var p2 = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i; 7603 var v = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i; 7604 var m = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i; 7605 var y = { string: [[function(r3) { 7606 var t3 = i.exec(r3); 7607 return t3 ? (r3 = t3[1]).length <= 4 ? { r: parseInt(r3[0] + r3[0], 16), g: parseInt(r3[1] + r3[1], 16), b: parseInt(r3[2] + r3[2], 16), a: 4 === r3.length ? n(parseInt(r3[3] + r3[3], 16) / 255, 2) : 1 } : 6 === r3.length || 8 === r3.length ? { r: parseInt(r3.substr(0, 2), 16), g: parseInt(r3.substr(2, 2), 16), b: parseInt(r3.substr(4, 2), 16), a: 8 === r3.length ? n(parseInt(r3.substr(6, 2), 16) / 255, 2) : 1 } : null : null; 7608 }, "hex"], [function(r3) { 7609 var t3 = v.exec(r3) || m.exec(r3); 7610 return t3 ? t3[2] !== t3[4] || t3[4] !== t3[6] ? null : a({ r: Number(t3[1]) / (t3[2] ? 100 / 255 : 1), g: Number(t3[3]) / (t3[4] ? 100 / 255 : 1), b: Number(t3[5]) / (t3[6] ? 100 / 255 : 1), a: void 0 === t3[7] ? 1 : Number(t3[7]) / (t3[8] ? 100 : 1) }) : null; 7611 }, "rgb"], [function(t3) { 7612 var n2 = l.exec(t3) || p2.exec(t3); 7613 if (!n2) return null; 7614 var e2, u2, a2 = g({ h: (e2 = n2[1], u2 = n2[2], void 0 === u2 && (u2 = "deg"), Number(e2) * (r2[u2] || 1)), s: Number(n2[3]), l: Number(n2[4]), a: void 0 === n2[5] ? 1 : Number(n2[5]) / (n2[6] ? 100 : 1) }); 7615 return f(a2); 7616 }, "hsl"]], object: [[function(r3) { 7617 var n2 = r3.r, e2 = r3.g, u2 = r3.b, o3 = r3.a, i2 = void 0 === o3 ? 1 : o3; 7618 return t(n2) && t(e2) && t(u2) ? a({ r: Number(n2), g: Number(e2), b: Number(u2), a: Number(i2) }) : null; 7619 }, "rgb"], [function(r3) { 7620 var n2 = r3.h, e2 = r3.s, u2 = r3.l, a2 = r3.a, o3 = void 0 === a2 ? 1 : a2; 7621 if (!t(n2) || !t(e2) || !t(u2)) return null; 7622 var i2 = g({ h: Number(n2), s: Number(e2), l: Number(u2), a: Number(o3) }); 7623 return f(i2); 7624 }, "hsl"], [function(r3) { 7625 var n2 = r3.h, a2 = r3.s, o3 = r3.v, i2 = r3.a, s2 = void 0 === i2 ? 1 : i2; 7626 if (!t(n2) || !t(a2) || !t(o3)) return null; 7627 var h2 = (function(r4) { 7628 return { h: u(r4.h), s: e(r4.s, 0, 100), v: e(r4.v, 0, 100), a: e(r4.a) }; 7629 })({ h: Number(n2), s: Number(a2), v: Number(o3), a: Number(s2) }); 7630 return b(h2); 7631 }, "hsv"]] }; 7632 var N = function(r3, t3) { 7633 for (var n2 = 0; n2 < t3.length; n2++) { 7634 var e2 = t3[n2][0](r3); 7635 if (e2) return [e2, t3[n2][1]]; 7636 } 7637 return [null, void 0]; 7638 }; 7639 var x = function(r3) { 7640 return "string" == typeof r3 ? N(r3.trim(), y.string) : "object" == typeof r3 && null !== r3 ? N(r3, y.object) : [null, void 0]; 7641 }; 7642 var M = function(r3, t3) { 7643 var n2 = c(r3); 7644 return { h: n2.h, s: e(n2.s + 100 * t3, 0, 100), l: n2.l, a: n2.a }; 7645 }; 7646 var H = function(r3) { 7647 return (299 * r3.r + 587 * r3.g + 114 * r3.b) / 1e3 / 255; 7648 }; 7649 var $ = function(r3, t3) { 7650 var n2 = c(r3); 7651 return { h: n2.h, s: n2.s, l: e(n2.l + 100 * t3, 0, 100), a: n2.a }; 7652 }; 7653 var j = (function() { 7654 function r3(r4) { 7655 this.parsed = x(r4)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 }; 7656 } 7657 return r3.prototype.isValid = function() { 7658 return null !== this.parsed; 7659 }, r3.prototype.brightness = function() { 7660 return n(H(this.rgba), 2); 7661 }, r3.prototype.isDark = function() { 7662 return H(this.rgba) < 0.5; 7663 }, r3.prototype.isLight = function() { 7664 return H(this.rgba) >= 0.5; 7665 }, r3.prototype.toHex = function() { 7666 return r4 = o(this.rgba), t3 = r4.r, e2 = r4.g, u2 = r4.b, i2 = (a2 = r4.a) < 1 ? s(n(255 * a2)) : "", "#" + s(t3) + s(e2) + s(u2) + i2; 7667 var r4, t3, e2, u2, a2, i2; 7668 }, r3.prototype.toRgb = function() { 7669 return o(this.rgba); 7670 }, r3.prototype.toRgbString = function() { 7671 return r4 = o(this.rgba), t3 = r4.r, n2 = r4.g, e2 = r4.b, (u2 = r4.a) < 1 ? "rgba(" + t3 + ", " + n2 + ", " + e2 + ", " + u2 + ")" : "rgb(" + t3 + ", " + n2 + ", " + e2 + ")"; 7672 var r4, t3, n2, e2, u2; 7673 }, r3.prototype.toHsl = function() { 7674 return d(c(this.rgba)); 7675 }, r3.prototype.toHslString = function() { 7676 return r4 = d(c(this.rgba)), t3 = r4.h, n2 = r4.s, e2 = r4.l, (u2 = r4.a) < 1 ? "hsla(" + t3 + ", " + n2 + "%, " + e2 + "%, " + u2 + ")" : "hsl(" + t3 + ", " + n2 + "%, " + e2 + "%)"; 7677 var r4, t3, n2, e2, u2; 7678 }, r3.prototype.toHsv = function() { 7679 return r4 = h(this.rgba), { h: n(r4.h), s: n(r4.s), v: n(r4.v), a: n(r4.a, 3) }; 7680 var r4; 7681 }, r3.prototype.invert = function() { 7682 return w({ r: 255 - (r4 = this.rgba).r, g: 255 - r4.g, b: 255 - r4.b, a: r4.a }); 7683 var r4; 7684 }, r3.prototype.saturate = function(r4) { 7685 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, r4)); 7686 }, r3.prototype.desaturate = function(r4) { 7687 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, -r4)); 7688 }, r3.prototype.grayscale = function() { 7689 return w(M(this.rgba, -1)); 7690 }, r3.prototype.lighten = function(r4) { 7691 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, r4)); 7692 }, r3.prototype.darken = function(r4) { 7693 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, -r4)); 7694 }, r3.prototype.rotate = function(r4) { 7695 return void 0 === r4 && (r4 = 15), this.hue(this.hue() + r4); 7696 }, r3.prototype.alpha = function(r4) { 7697 return "number" == typeof r4 ? w({ r: (t3 = this.rgba).r, g: t3.g, b: t3.b, a: r4 }) : n(this.rgba.a, 3); 7698 var t3; 7699 }, r3.prototype.hue = function(r4) { 7700 var t3 = c(this.rgba); 7701 return "number" == typeof r4 ? w({ h: r4, s: t3.s, l: t3.l, a: t3.a }) : n(t3.h); 7702 }, r3.prototype.isEqual = function(r4) { 7703 return this.toHex() === w(r4).toHex(); 7704 }, r3; 7705 })(); 7706 var w = function(r3) { 7707 return r3 instanceof j ? r3 : new j(r3); 7708 }; 7709 var S = []; 7710 var k = function(r3) { 7711 r3.forEach(function(r4) { 7712 S.indexOf(r4) < 0 && (r4(j, y), S.push(r4)); 7713 }); 7714 }; 7715 7716 // packages/global-styles-engine/build-module/utils/duotone.js 7717 function getValuesFromColors(colors2 = []) { 7718 const values = { 7719 r: [], 7720 g: [], 7721 b: [], 7722 a: [] 7723 }; 7724 colors2.forEach((color) => { 7725 const rgbColor = w(color).toRgb(); 7726 values.r.push(rgbColor.r / 255); 7727 values.g.push(rgbColor.g / 255); 7728 values.b.push(rgbColor.b / 255); 7729 values.a.push(rgbColor.a); 7730 }); 7731 return values; 7732 } 7733 function getDuotoneFilter(id, colors2) { 7734 const values = getValuesFromColors(colors2); 7735 return ` 7736 <svg 7737 xmlns:xlink="http://www.w3.org/1999/xlink" 7738 viewBox="0 0 0 0" 7739 width="0" 7740 height="0" 7741 focusable="false" 7742 role="none" 7743 aria-hidden="true" 7744 style="visibility: hidden; position: absolute; left: -9999px; overflow: hidden;" 7745 > 7746 <defs> 7747 <filter id="$id}"> 7748 <!-- 7749 Use sRGB instead of linearRGB so transparency looks correct. 7750 Use perceptual brightness to convert to grayscale. 7751 --> 7752 <feColorMatrix color-interpolation-filters="sRGB" type="matrix" values=" .299 .587 .114 0 0 .299 .587 .114 0 0 .299 .587 .114 0 0 .299 .587 .114 0 0 "></feColorMatrix> 7753 <!-- Use sRGB instead of linearRGB to be consistent with how CSS gradients work. --> 7754 <feComponentTransfer color-interpolation-filters="sRGB"> 7755 <feFuncR type="table" tableValues="$values.r.join(" ")}"></feFuncR> 7756 <feFuncG type="table" tableValues="$values.g.join(" ")}"></feFuncG> 7757 <feFuncB type="table" tableValues="$values.b.join(" ")}"></feFuncB> 7758 <feFuncA type="table" tableValues="$values.a.join(" ")}"></feFuncA> 7759 </feComponentTransfer> 7760 <!-- Re-mask the image with the original transparency since the feColorMatrix above loses that information. --> 7761 <feComposite in2="SourceGraphic" operator="in"></feComposite> 7762 </filter> 7763 </defs> 7764 </svg>`; 7765 } 7766 7767 // packages/global-styles-engine/build-module/utils/string.js 7768 function kebabCase(str) { 7769 return str.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/([0-9])([a-zA-Z])/g, "$1-$2").replace(/([a-zA-Z])([0-9])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase(); 7770 } 7771 7772 // packages/global-styles-engine/build-module/utils/spacing.js 7773 function getSpacingPresetCssVar(value) { 7774 if (!value) { 7775 return; 7776 } 7777 const slug = value.match(/var:preset\|spacing\|(.+)/); 7778 if (!slug) { 7779 return value; 7780 } 7781 return `var(--wp--preset--spacing--$slug[1]})`; 7782 } 7783 7784 // packages/global-styles-engine/build-module/utils/gap.js 7785 function getGapBoxControlValueFromStyle(blockGapValue) { 7786 if (!blockGapValue) { 7787 return null; 7788 } 7789 const isValueString = typeof blockGapValue === "string"; 7790 return { 7791 top: isValueString ? blockGapValue : blockGapValue?.top, 7792 left: isValueString ? blockGapValue : blockGapValue?.left 7793 }; 7794 } 7795 function getGapCSSValue(blockGapValue, defaultValue2 = "0") { 7796 const blockGapBoxControlValue = getGapBoxControlValueFromStyle(blockGapValue); 7797 if (!blockGapBoxControlValue) { 7798 return null; 7799 } 7800 const row = getSpacingPresetCssVar(blockGapBoxControlValue?.top) || defaultValue2; 7801 const column = getSpacingPresetCssVar(blockGapBoxControlValue?.left) || defaultValue2; 7802 return row === column ? row : `$row} $column}`; 7803 } 7804 7805 // packages/global-styles-engine/build-module/utils/background.js 7806 var BACKGROUND_BLOCK_DEFAULT_VALUES = { 7807 backgroundSize: "cover", 7808 backgroundPosition: "50% 50%" 7809 // used only when backgroundSize is 'contain'. 7810 }; 7811 function setBackgroundStyleDefaults(backgroundStyle) { 7812 if (!backgroundStyle || // @ts-expect-error 7813 !backgroundStyle?.backgroundImage?.url) { 7814 return; 7815 } 7816 let backgroundStylesWithDefaults; 7817 if (!backgroundStyle?.backgroundSize) { 7818 backgroundStylesWithDefaults = { 7819 backgroundSize: BACKGROUND_BLOCK_DEFAULT_VALUES.backgroundSize 7820 }; 7821 } 7822 if ("contain" === backgroundStyle?.backgroundSize && !backgroundStyle?.backgroundPosition) { 7823 backgroundStylesWithDefaults = { 7824 backgroundPosition: BACKGROUND_BLOCK_DEFAULT_VALUES.backgroundPosition 7825 }; 7826 } 7827 return backgroundStylesWithDefaults; 7828 } 7829 7830 // packages/global-styles-engine/build-module/utils/layout.js 7831 var LAYOUT_DEFINITIONS = { 7832 default: { 7833 name: "default", 7834 slug: "flow", 7835 className: "is-layout-flow", 7836 baseStyles: [ 7837 { 7838 selector: " > .alignleft", 7839 rules: { 7840 float: "left", 7841 "margin-inline-start": "0", 7842 "margin-inline-end": "2em" 7843 } 7844 }, 7845 { 7846 selector: " > .alignright", 7847 rules: { 7848 float: "right", 7849 "margin-inline-start": "2em", 7850 "margin-inline-end": "0" 7851 } 7852 }, 7853 { 7854 selector: " > .aligncenter", 7855 rules: { 7856 "margin-left": "auto !important", 7857 "margin-right": "auto !important" 7858 } 7859 } 7860 ], 7861 spacingStyles: [ 7862 { 7863 selector: " > :first-child", 7864 rules: { 7865 "margin-block-start": "0" 7866 } 7867 }, 7868 { 7869 selector: " > :last-child", 7870 rules: { 7871 "margin-block-end": "0" 7872 } 7873 }, 7874 { 7875 selector: " > *", 7876 rules: { 7877 "margin-block-start": null, 7878 "margin-block-end": "0" 7879 } 7880 } 7881 ] 7882 }, 7883 constrained: { 7884 name: "constrained", 7885 slug: "constrained", 7886 className: "is-layout-constrained", 7887 baseStyles: [ 7888 { 7889 selector: " > .alignleft", 7890 rules: { 7891 float: "left", 7892 "margin-inline-start": "0", 7893 "margin-inline-end": "2em" 7894 } 7895 }, 7896 { 7897 selector: " > .alignright", 7898 rules: { 7899 float: "right", 7900 "margin-inline-start": "2em", 7901 "margin-inline-end": "0" 7902 } 7903 }, 7904 { 7905 selector: " > .aligncenter", 7906 rules: { 7907 "margin-left": "auto !important", 7908 "margin-right": "auto !important" 7909 } 7910 }, 7911 { 7912 selector: " > :where(:not(.alignleft):not(.alignright):not(.alignfull))", 7913 rules: { 7914 "max-width": "var(--wp--style--global--content-size)", 7915 "margin-left": "auto !important", 7916 "margin-right": "auto !important" 7917 } 7918 }, 7919 { 7920 selector: " > .alignwide", 7921 rules: { 7922 "max-width": "var(--wp--style--global--wide-size)" 7923 } 7924 } 7925 ], 7926 spacingStyles: [ 7927 { 7928 selector: " > :first-child", 7929 rules: { 7930 "margin-block-start": "0" 7931 } 7932 }, 7933 { 7934 selector: " > :last-child", 7935 rules: { 7936 "margin-block-end": "0" 7937 } 7938 }, 7939 { 7940 selector: " > *", 7941 rules: { 7942 "margin-block-start": null, 7943 "margin-block-end": "0" 7944 } 7945 } 7946 ] 7947 }, 7948 flex: { 7949 name: "flex", 7950 slug: "flex", 7951 className: "is-layout-flex", 7952 displayMode: "flex", 7953 baseStyles: [ 7954 { 7955 selector: "", 7956 rules: { 7957 "flex-wrap": "wrap", 7958 "align-items": "center" 7959 } 7960 }, 7961 { 7962 selector: " > :is(*, div)", 7963 // :is(*, div) instead of just * increases the specificity by 001. 7964 rules: { 7965 margin: "0" 7966 } 7967 } 7968 ], 7969 spacingStyles: [ 7970 { 7971 selector: "", 7972 rules: { 7973 gap: null 7974 } 7975 } 7976 ] 7977 }, 7978 grid: { 7979 name: "grid", 7980 slug: "grid", 7981 className: "is-layout-grid", 7982 displayMode: "grid", 7983 baseStyles: [ 7984 { 7985 selector: " > :is(*, div)", 7986 // :is(*, div) instead of just * increases the specificity by 001. 7987 rules: { 7988 margin: "0" 7989 } 7990 } 7991 ], 7992 spacingStyles: [ 7993 { 7994 selector: "", 7995 rules: { 7996 gap: null 7997 } 7998 } 7999 ] 8000 } 8001 }; 8002 8003 // packages/global-styles-engine/build-module/core/render.js 8004 var ELEMENT_CLASS_NAMES = { 8005 button: "wp-element-button", 8006 caption: "wp-element-caption" 8007 }; 8008 var BLOCK_SUPPORT_FEATURE_LEVEL_SELECTORS = { 8009 __experimentalBorder: "border", 8010 color: "color", 8011 dimensions: "dimensions", 8012 spacing: "spacing", 8013 typography: "typography" 8014 }; 8015 function getPresetsDeclarations(blockPresets = {}, mergedSettings) { 8016 return PRESET_METADATA.reduce( 8017 (declarations, { path, valueKey, valueFunc, cssVarInfix }) => { 8018 const presetByOrigin = getValueFromObjectPath( 8019 blockPresets, 8020 path, 8021 [] 8022 ); 8023 ["default", "theme", "custom"].forEach((origin) => { 8024 if (presetByOrigin[origin]) { 8025 presetByOrigin[origin].forEach((value) => { 8026 if (valueKey && !valueFunc) { 8027 declarations.push( 8028 `--wp--preset--$cssVarInfix}--$kebabCase( 8029 value.slug 8030 )}: $value[valueKey]}` 8031 ); 8032 } else if (valueFunc && typeof valueFunc === "function") { 8033 declarations.push( 8034 `--wp--preset--$cssVarInfix}--$kebabCase( 8035 value.slug 8036 )}: $valueFunc(value, mergedSettings)}` 8037 ); 8038 } 8039 }); 8040 } 8041 }); 8042 return declarations; 8043 }, 8044 [] 8045 ); 8046 } 8047 function getPresetsClasses(blockSelector = "*", blockPresets = {}) { 8048 return PRESET_METADATA.reduce( 8049 (declarations, { path, cssVarInfix, classes }) => { 8050 if (!classes) { 8051 return declarations; 8052 } 8053 const presetByOrigin = getValueFromObjectPath( 8054 blockPresets, 8055 path, 8056 [] 8057 ); 8058 ["default", "theme", "custom"].forEach((origin) => { 8059 if (presetByOrigin[origin]) { 8060 presetByOrigin[origin].forEach( 8061 ({ slug }) => { 8062 classes.forEach( 8063 ({ 8064 classSuffix, 8065 propertyName 8066 }) => { 8067 const classSelectorToUse = `.has-$kebabCase( 8068 slug 8069 )}-$classSuffix}`; 8070 const selectorToUse = blockSelector.split(",").map( 8071 (selector2) => `$selector2}$classSelectorToUse}` 8072 ).join(","); 8073 const value = `var(--wp--preset--$cssVarInfix}--$kebabCase( 8074 slug 8075 )})`; 8076 declarations += `$selectorToUse}{$propertyName}: $value} !important;}`; 8077 } 8078 ); 8079 } 8080 ); 8081 } 8082 }); 8083 return declarations; 8084 }, 8085 "" 8086 ); 8087 } 8088 function getPresetsSvgFilters(blockPresets = {}) { 8089 return PRESET_METADATA.filter( 8090 // Duotone are the only type of filters for now. 8091 (metadata) => metadata.path.at(-1) === "duotone" 8092 ).flatMap((metadata) => { 8093 const presetByOrigin = getValueFromObjectPath( 8094 blockPresets, 8095 metadata.path, 8096 {} 8097 ); 8098 return ["default", "theme"].filter((origin) => presetByOrigin[origin]).flatMap( 8099 (origin) => presetByOrigin[origin].map( 8100 (preset) => getDuotoneFilter( 8101 `wp-duotone-$preset.slug}`, 8102 preset.colors 8103 ) 8104 ) 8105 ).join(""); 8106 }); 8107 } 8108 function flattenTree(input = {}, prefix2, token) { 8109 let result = []; 8110 Object.keys(input).forEach((key) => { 8111 const newKey = prefix2 + kebabCase(key.replace("/", "-")); 8112 const newLeaf = input[key]; 8113 if (newLeaf instanceof Object) { 8114 const newPrefix = newKey + token; 8115 result = [...result, ...flattenTree(newLeaf, newPrefix, token)]; 8116 } else { 8117 result.push(`$newKey}: $newLeaf}`); 8118 } 8119 }); 8120 return result; 8121 } 8122 function concatFeatureVariationSelectorString(featureSelector, styleVariationSelector) { 8123 const featureSelectors = featureSelector.split(","); 8124 const combinedSelectors = []; 8125 featureSelectors.forEach((selector2) => { 8126 combinedSelectors.push( 8127 `$styleVariationSelector.trim()}$selector2.trim()}` 8128 ); 8129 }); 8130 return combinedSelectors.join(", "); 8131 } 8132 var getFeatureDeclarations = (selectors, styles) => { 8133 const declarations = {}; 8134 Object.entries(selectors).forEach(([feature, selector2]) => { 8135 if (feature === "root" || !styles?.[feature]) { 8136 return; 8137 } 8138 const isShorthand = typeof selector2 === "string"; 8139 if (!isShorthand && typeof selector2 === "object" && selector2 !== null) { 8140 Object.entries(selector2).forEach( 8141 ([subfeature, subfeatureSelector]) => { 8142 if (subfeature === "root" || !styles?.[feature][subfeature]) { 8143 return; 8144 } 8145 const subfeatureStyles = { 8146 [feature]: { 8147 [subfeature]: styles[feature][subfeature] 8148 } 8149 }; 8150 const newDeclarations = getStylesDeclarations(subfeatureStyles); 8151 declarations[subfeatureSelector] = [ 8152 ...declarations[subfeatureSelector] || [], 8153 ...newDeclarations 8154 ]; 8155 delete styles[feature][subfeature]; 8156 } 8157 ); 8158 } 8159 if (isShorthand || typeof selector2 === "object" && selector2 !== null && "root" in selector2) { 8160 const featureSelector = isShorthand ? selector2 : selector2.root; 8161 const featureStyles = { [feature]: styles[feature] }; 8162 const newDeclarations = getStylesDeclarations(featureStyles); 8163 declarations[featureSelector] = [ 8164 ...declarations[featureSelector] || [], 8165 ...newDeclarations 8166 ]; 8167 delete styles[feature]; 8168 } 8169 }); 8170 return declarations; 8171 }; 8172 function getStylesDeclarations(blockStyles = {}, selector2 = "", useRootPaddingAlign, tree = {}, disableRootPadding = false) { 8173 const isRoot = ROOT_BLOCK_SELECTOR === selector2; 8174 const output = Object.entries( 8175 import_blocks3.__EXPERIMENTAL_STYLE_PROPERTY 8176 ).reduce( 8177 (declarations, [key, { value, properties, useEngine, rootOnly }]) => { 8178 if (rootOnly && !isRoot) { 8179 return declarations; 8180 } 8181 const pathToValue = value; 8182 if (pathToValue[0] === "elements" || useEngine) { 8183 return declarations; 8184 } 8185 const styleValue = getValueFromObjectPath( 8186 blockStyles, 8187 pathToValue 8188 ); 8189 if (key === "--wp--style--root--padding" && (typeof styleValue === "string" || !useRootPaddingAlign)) { 8190 return declarations; 8191 } 8192 if (properties && typeof styleValue !== "string") { 8193 Object.entries(properties).forEach((entry) => { 8194 const [name2, prop] = entry; 8195 if (!getValueFromObjectPath(styleValue, [prop], false)) { 8196 return; 8197 } 8198 const cssProperty = name2.startsWith("--") ? name2 : kebabCase(name2); 8199 declarations.push( 8200 `$cssProperty}: ${(0, import_style_engine2.getCSSValueFromRawStyle)( 8201 getValueFromObjectPath(styleValue, [prop]) 8202 )}` 8203 ); 8204 }); 8205 } else if (getValueFromObjectPath(blockStyles, pathToValue, false)) { 8206 const cssProperty = key.startsWith("--") ? key : kebabCase(key); 8207 declarations.push( 8208 `$cssProperty}: ${(0, import_style_engine2.getCSSValueFromRawStyle)( 8209 getValueFromObjectPath(blockStyles, pathToValue) 8210 )}` 8211 ); 8212 } 8213 return declarations; 8214 }, 8215 [] 8216 ); 8217 if (!!blockStyles.background) { 8218 if (blockStyles.background?.backgroundImage) { 8219 blockStyles.background.backgroundImage = getResolvedValue( 8220 blockStyles.background.backgroundImage, 8221 tree 8222 ); 8223 } 8224 if (!isRoot && !!blockStyles.background?.backgroundImage?.id) { 8225 blockStyles = { 8226 ...blockStyles, 8227 background: { 8228 ...blockStyles.background, 8229 ...setBackgroundStyleDefaults(blockStyles.background) 8230 } 8231 }; 8232 } 8233 } 8234 const extraRules = (0, import_style_engine2.getCSSRules)(blockStyles); 8235 extraRules.forEach((rule) => { 8236 if (isRoot && (useRootPaddingAlign || disableRootPadding) && rule.key.startsWith("padding")) { 8237 return; 8238 } 8239 const cssProperty = rule.key.startsWith("--") ? rule.key : kebabCase(rule.key); 8240 let ruleValue = getResolvedValue(rule.value, tree); 8241 if (cssProperty === "font-size") { 8242 ruleValue = getTypographyFontSizeValue( 8243 { name: "", slug: "", size: ruleValue }, 8244 tree?.settings 8245 ); 8246 } 8247 if (cssProperty === "aspect-ratio") { 8248 output.push("min-height: unset"); 8249 } 8250 output.push(`$cssProperty}: $ruleValue}`); 8251 }); 8252 return output; 8253 } 8254 function getLayoutStyles({ 8255 layoutDefinitions = LAYOUT_DEFINITIONS, 8256 style, 8257 selector: selector2, 8258 hasBlockGapSupport, 8259 hasFallbackGapSupport, 8260 fallbackGapValue 8261 }) { 8262 let ruleset = ""; 8263 let gapValue = hasBlockGapSupport ? getGapCSSValue(style?.spacing?.blockGap) : ""; 8264 if (hasFallbackGapSupport) { 8265 if (selector2 === ROOT_BLOCK_SELECTOR) { 8266 gapValue = !gapValue ? "0.5em" : gapValue; 8267 } else if (!hasBlockGapSupport && fallbackGapValue) { 8268 gapValue = fallbackGapValue; 8269 } 8270 } 8271 if (gapValue && layoutDefinitions) { 8272 Object.values(layoutDefinitions).forEach( 8273 ({ className, name: name2, spacingStyles }) => { 8274 if (!hasBlockGapSupport && "flex" !== name2 && "grid" !== name2) { 8275 return; 8276 } 8277 if (spacingStyles?.length) { 8278 spacingStyles.forEach((spacingStyle) => { 8279 const declarations = []; 8280 if (spacingStyle.rules) { 8281 Object.entries(spacingStyle.rules).forEach( 8282 ([cssProperty, cssValue]) => { 8283 declarations.push( 8284 `$cssProperty}: $cssValue ? cssValue : gapValue}` 8285 ); 8286 } 8287 ); 8288 } 8289 if (declarations.length) { 8290 let combinedSelector = ""; 8291 if (!hasBlockGapSupport) { 8292 combinedSelector = selector2 === ROOT_BLOCK_SELECTOR ? `:where(.$className}$spacingStyle?.selector || ""})` : `:where($selector2}.$className}$spacingStyle?.selector || ""})`; 8293 } else { 8294 combinedSelector = selector2 === ROOT_BLOCK_SELECTOR ? `:root :where(.$className})$spacingStyle?.selector || ""}` : `:root :where($selector2}-$className})$spacingStyle?.selector || ""}`; 8295 } 8296 ruleset += `$combinedSelector} { $declarations.join( 8297 "; " 8298 )}; }`; 8299 } 8300 }); 8301 } 8302 } 8303 ); 8304 if (selector2 === ROOT_BLOCK_SELECTOR && hasBlockGapSupport) { 8305 ruleset += `$ROOT_CSS_PROPERTIES_SELECTOR} { --wp--style--block-gap: $gapValue}; }`; 8306 } 8307 } 8308 if (selector2 === ROOT_BLOCK_SELECTOR && layoutDefinitions) { 8309 const validDisplayModes = ["block", "flex", "grid"]; 8310 Object.values(layoutDefinitions).forEach( 8311 ({ className, displayMode, baseStyles }) => { 8312 if (displayMode && validDisplayModes.includes(displayMode)) { 8313 ruleset += `$selector2} .$className} { display:$displayMode}; }`; 8314 } 8315 if (baseStyles?.length) { 8316 baseStyles.forEach((baseStyle) => { 8317 const declarations = []; 8318 if (baseStyle.rules) { 8319 Object.entries(baseStyle.rules).forEach( 8320 ([cssProperty, cssValue]) => { 8321 declarations.push( 8322 `$cssProperty}: $cssValue}` 8323 ); 8324 } 8325 ); 8326 } 8327 if (declarations.length) { 8328 const combinedSelector = `.$className}$baseStyle?.selector || ""}`; 8329 ruleset += `$combinedSelector} { $declarations.join( 8330 "; " 8331 )}; }`; 8332 } 8333 }); 8334 } 8335 } 8336 ); 8337 } 8338 return ruleset; 8339 } 8340 var STYLE_KEYS = [ 8341 "border", 8342 "color", 8343 "dimensions", 8344 "spacing", 8345 "typography", 8346 "filter", 8347 "outline", 8348 "shadow", 8349 "background" 8350 ]; 8351 function pickStyleKeys(treeToPickFrom) { 8352 if (!treeToPickFrom) { 8353 return {}; 8354 } 8355 const entries = Object.entries(treeToPickFrom); 8356 const pickedEntries = entries.filter( 8357 ([key]) => STYLE_KEYS.includes(key) 8358 ); 8359 const clonedEntries = pickedEntries.map(([key, style]) => [ 8360 key, 8361 JSON.parse(JSON.stringify(style)) 8362 ]); 8363 return Object.fromEntries(clonedEntries); 8364 } 8365 var getNodesWithStyles = (tree, blockSelectors) => { 8366 const nodes = []; 8367 if (!tree?.styles) { 8368 return nodes; 8369 } 8370 const styles = pickStyleKeys(tree.styles); 8371 if (styles) { 8372 nodes.push({ 8373 styles, 8374 selector: ROOT_BLOCK_SELECTOR, 8375 // Root selector (body) styles should not be wrapped in `:root where()` to keep 8376 // specificity at (0,0,1) and maintain backwards compatibility. 8377 skipSelectorWrapper: true 8378 }); 8379 } 8380 Object.entries(import_blocks3.__EXPERIMENTAL_ELEMENTS).forEach(([name2, selector2]) => { 8381 if (tree.styles?.elements?.[name2]) { 8382 nodes.push({ 8383 styles: tree.styles?.elements?.[name2] ?? {}, 8384 selector: selector2, 8385 // Top level elements that don't use a class name should not receive the 8386 // `:root :where()` wrapper to maintain backwards compatibility. 8387 skipSelectorWrapper: !ELEMENT_CLASS_NAMES[name2] 8388 }); 8389 } 8390 }); 8391 Object.entries(tree.styles?.blocks ?? {}).forEach( 8392 ([blockName, node]) => { 8393 const blockStyles = pickStyleKeys(node); 8394 const typedNode = node; 8395 if (typedNode?.variations) { 8396 const variations = {}; 8397 Object.entries(typedNode.variations).forEach( 8398 ([variationName, variation]) => { 8399 const typedVariation = variation; 8400 variations[variationName] = pickStyleKeys(typedVariation); 8401 if (typedVariation?.css) { 8402 variations[variationName].css = typedVariation.css; 8403 } 8404 const variationSelector = typeof blockSelectors !== "string" ? blockSelectors[blockName]?.styleVariationSelectors?.[variationName] : void 0; 8405 Object.entries( 8406 typedVariation?.elements ?? {} 8407 ).forEach(([element, elementStyles]) => { 8408 if (elementStyles && import_blocks3.__EXPERIMENTAL_ELEMENTS[element]) { 8409 nodes.push({ 8410 styles: elementStyles, 8411 selector: scopeSelector( 8412 variationSelector, 8413 import_blocks3.__EXPERIMENTAL_ELEMENTS[element] 8414 ) 8415 }); 8416 } 8417 }); 8418 Object.entries(typedVariation?.blocks ?? {}).forEach( 8419 ([ 8420 variationBlockName, 8421 variationBlockStyles 8422 ]) => { 8423 const variationBlockSelector = typeof blockSelectors !== "string" ? scopeSelector( 8424 variationSelector, 8425 blockSelectors[variationBlockName]?.selector 8426 ) : void 0; 8427 const variationDuotoneSelector = typeof blockSelectors !== "string" ? scopeSelector( 8428 variationSelector, 8429 blockSelectors[variationBlockName]?.duotoneSelector 8430 ) : void 0; 8431 const variationFeatureSelectors = typeof blockSelectors !== "string" ? scopeFeatureSelectors( 8432 variationSelector, 8433 blockSelectors[variationBlockName]?.featureSelectors ?? {} 8434 ) : void 0; 8435 const variationBlockStyleNodes = pickStyleKeys(variationBlockStyles); 8436 if (variationBlockStyles?.css) { 8437 variationBlockStyleNodes.css = variationBlockStyles.css; 8438 } 8439 if (!variationBlockSelector || typeof blockSelectors === "string") { 8440 return; 8441 } 8442 nodes.push({ 8443 selector: variationBlockSelector, 8444 duotoneSelector: variationDuotoneSelector, 8445 featureSelectors: variationFeatureSelectors, 8446 fallbackGapValue: blockSelectors[variationBlockName]?.fallbackGapValue, 8447 hasLayoutSupport: blockSelectors[variationBlockName]?.hasLayoutSupport, 8448 styles: variationBlockStyleNodes 8449 }); 8450 Object.entries( 8451 variationBlockStyles.elements ?? {} 8452 ).forEach( 8453 ([ 8454 variationBlockElement, 8455 variationBlockElementStyles 8456 ]) => { 8457 if (variationBlockElementStyles && import_blocks3.__EXPERIMENTAL_ELEMENTS[variationBlockElement]) { 8458 nodes.push({ 8459 styles: variationBlockElementStyles, 8460 selector: scopeSelector( 8461 variationBlockSelector, 8462 import_blocks3.__EXPERIMENTAL_ELEMENTS[variationBlockElement] 8463 ) 8464 }); 8465 } 8466 } 8467 ); 8468 } 8469 ); 8470 } 8471 ); 8472 blockStyles.variations = variations; 8473 } 8474 if (typeof blockSelectors !== "string" && blockSelectors?.[blockName]?.selector) { 8475 nodes.push({ 8476 duotoneSelector: blockSelectors[blockName].duotoneSelector, 8477 fallbackGapValue: blockSelectors[blockName].fallbackGapValue, 8478 hasLayoutSupport: blockSelectors[blockName].hasLayoutSupport, 8479 selector: blockSelectors[blockName].selector, 8480 styles: blockStyles, 8481 featureSelectors: blockSelectors[blockName].featureSelectors, 8482 styleVariationSelectors: blockSelectors[blockName].styleVariationSelectors 8483 }); 8484 } 8485 Object.entries(typedNode?.elements ?? {}).forEach( 8486 ([elementName, value]) => { 8487 if (typeof blockSelectors !== "string" && value && blockSelectors?.[blockName] && import_blocks3.__EXPERIMENTAL_ELEMENTS[elementName]) { 8488 nodes.push({ 8489 styles: value, 8490 selector: blockSelectors[blockName]?.selector.split(",").map((sel) => { 8491 const elementSelectors = import_blocks3.__EXPERIMENTAL_ELEMENTS[elementName].split(","); 8492 return elementSelectors.map( 8493 (elementSelector) => sel + " " + elementSelector 8494 ); 8495 }).join(",") 8496 }); 8497 } 8498 } 8499 ); 8500 } 8501 ); 8502 return nodes; 8503 }; 8504 var getNodesWithSettings = (tree, blockSelectors) => { 8505 const nodes = []; 8506 if (!tree?.settings) { 8507 return nodes; 8508 } 8509 const pickPresets = (treeToPickFrom) => { 8510 let presets2 = {}; 8511 PRESET_METADATA.forEach(({ path }) => { 8512 const value = getValueFromObjectPath(treeToPickFrom, path, false); 8513 if (value !== false) { 8514 presets2 = setImmutably(presets2, path, value); 8515 } 8516 }); 8517 return presets2; 8518 }; 8519 const presets = pickPresets(tree.settings); 8520 const custom = tree.settings?.custom; 8521 if (Object.keys(presets).length > 0 || custom) { 8522 nodes.push({ 8523 presets, 8524 custom, 8525 selector: ROOT_CSS_PROPERTIES_SELECTOR 8526 }); 8527 } 8528 Object.entries(tree.settings?.blocks ?? {}).forEach( 8529 ([blockName, node]) => { 8530 const blockCustom = node.custom; 8531 if (typeof blockSelectors === "string" || !blockSelectors[blockName]) { 8532 return; 8533 } 8534 const blockPresets = pickPresets(node); 8535 if (Object.keys(blockPresets).length > 0 || blockCustom) { 8536 nodes.push({ 8537 presets: blockPresets, 8538 custom: blockCustom, 8539 selector: blockSelectors[blockName]?.selector 8540 }); 8541 } 8542 } 8543 ); 8544 return nodes; 8545 }; 8546 var generateCustomProperties = (tree, blockSelectors) => { 8547 const settings2 = getNodesWithSettings(tree, blockSelectors); 8548 let ruleset = ""; 8549 settings2.forEach(({ presets, custom, selector: selector2 }) => { 8550 const declarations = tree?.settings ? getPresetsDeclarations(presets, tree?.settings) : []; 8551 const customProps = flattenTree(custom, "--wp--custom--", "--"); 8552 if (customProps.length > 0) { 8553 declarations.push(...customProps); 8554 } 8555 if (declarations.length > 0) { 8556 ruleset += `$selector2}{$declarations.join(";")};}`; 8557 } 8558 }); 8559 return ruleset; 8560 }; 8561 var transformToStyles = (tree, blockSelectors, hasBlockGapSupport, hasFallbackGapSupport, disableLayoutStyles = false, disableRootPadding = false, styleOptions = {}) => { 8562 const options = { 8563 blockGap: true, 8564 blockStyles: true, 8565 layoutStyles: true, 8566 marginReset: true, 8567 presets: true, 8568 rootPadding: true, 8569 variationStyles: false, 8570 ...styleOptions 8571 }; 8572 const nodesWithStyles = getNodesWithStyles(tree, blockSelectors); 8573 const nodesWithSettings = getNodesWithSettings(tree, blockSelectors); 8574 const useRootPaddingAlign = tree?.settings?.useRootPaddingAwareAlignments; 8575 const { contentSize, wideSize } = tree?.settings?.layout || {}; 8576 const hasBodyStyles = options.marginReset || options.rootPadding || options.layoutStyles; 8577 let ruleset = ""; 8578 if (options.presets && (contentSize || wideSize)) { 8579 ruleset += `$ROOT_CSS_PROPERTIES_SELECTOR} {`; 8580 ruleset = contentSize ? ruleset + ` --wp--style--global--content-size: $contentSize};` : ruleset; 8581 ruleset = wideSize ? ruleset + ` --wp--style--global--wide-size: $wideSize};` : ruleset; 8582 ruleset += "}"; 8583 } 8584 if (hasBodyStyles) { 8585 ruleset += ":where(body) {margin: 0;"; 8586 if (options.rootPadding && useRootPaddingAlign) { 8587 ruleset += `padding-right: 0; padding-left: 0; padding-top: var(--wp--style--root--padding-top); padding-bottom: var(--wp--style--root--padding-bottom) } 8588 .has-global-padding { padding-right: var(--wp--style--root--padding-right); padding-left: var(--wp--style--root--padding-left); } 8589 .has-global-padding > .alignfull { margin-right: calc(var(--wp--style--root--padding-right) * -1); margin-left: calc(var(--wp--style--root--padding-left) * -1); } 8590 .has-global-padding :where(:not(.alignfull.is-layout-flow) > .has-global-padding:not(.wp-block-block, .alignfull)) { padding-right: 0; padding-left: 0; } 8591 .has-global-padding :where(:not(.alignfull.is-layout-flow) > .has-global-padding:not(.wp-block-block, .alignfull)) > .alignfull { margin-left: 0; margin-right: 0; 8592 `; 8593 } 8594 ruleset += "}"; 8595 } 8596 if (options.blockStyles) { 8597 nodesWithStyles.forEach( 8598 ({ 8599 selector: selector2, 8600 duotoneSelector, 8601 styles, 8602 fallbackGapValue, 8603 hasLayoutSupport, 8604 featureSelectors, 8605 styleVariationSelectors, 8606 skipSelectorWrapper 8607 }) => { 8608 if (featureSelectors) { 8609 const featureDeclarations = getFeatureDeclarations( 8610 featureSelectors, 8611 styles 8612 ); 8613 Object.entries(featureDeclarations).forEach( 8614 ([cssSelector, declarations]) => { 8615 if (declarations.length) { 8616 const rules = declarations.join(";"); 8617 ruleset += `:root :where($cssSelector}){$rules};}`; 8618 } 8619 } 8620 ); 8621 } 8622 if (duotoneSelector) { 8623 const duotoneStyles = {}; 8624 if (styles?.filter) { 8625 duotoneStyles.filter = styles.filter; 8626 delete styles.filter; 8627 } 8628 const duotoneDeclarations = getStylesDeclarations(duotoneStyles); 8629 if (duotoneDeclarations.length) { 8630 ruleset += `$duotoneSelector}{$duotoneDeclarations.join( 8631 ";" 8632 )};}`; 8633 } 8634 } 8635 if (!disableLayoutStyles && (ROOT_BLOCK_SELECTOR === selector2 || hasLayoutSupport)) { 8636 ruleset += getLayoutStyles({ 8637 style: styles, 8638 selector: selector2, 8639 hasBlockGapSupport, 8640 hasFallbackGapSupport, 8641 fallbackGapValue 8642 }); 8643 } 8644 const styleDeclarations = getStylesDeclarations( 8645 styles, 8646 selector2, 8647 useRootPaddingAlign, 8648 tree, 8649 disableRootPadding 8650 ); 8651 if (styleDeclarations?.length) { 8652 const generalSelector = skipSelectorWrapper ? selector2 : `:root :where($selector2})`; 8653 ruleset += `$generalSelector}{$styleDeclarations.join( 8654 ";" 8655 )};}`; 8656 } 8657 if (styles?.css) { 8658 ruleset += processCSSNesting( 8659 styles.css, 8660 `:root :where($selector2})` 8661 ); 8662 } 8663 if (options.variationStyles && styleVariationSelectors) { 8664 Object.entries(styleVariationSelectors).forEach( 8665 ([styleVariationName, styleVariationSelector]) => { 8666 const styleVariations = styles?.variations?.[styleVariationName]; 8667 if (styleVariations) { 8668 if (featureSelectors) { 8669 const featureDeclarations = getFeatureDeclarations( 8670 featureSelectors, 8671 styleVariations 8672 ); 8673 Object.entries( 8674 featureDeclarations 8675 ).forEach( 8676 ([baseSelector, declarations]) => { 8677 if (declarations.length) { 8678 const cssSelector = concatFeatureVariationSelectorString( 8679 baseSelector, 8680 styleVariationSelector 8681 ); 8682 const rules = declarations.join(";"); 8683 ruleset += `:root :where($cssSelector}){$rules};}`; 8684 } 8685 } 8686 ); 8687 } 8688 const styleVariationDeclarations = getStylesDeclarations( 8689 styleVariations, 8690 styleVariationSelector, 8691 useRootPaddingAlign, 8692 tree 8693 ); 8694 if (styleVariationDeclarations.length) { 8695 ruleset += `:root :where($styleVariationSelector}){$styleVariationDeclarations.join( 8696 ";" 8697 )};}`; 8698 } 8699 if (styleVariations?.css) { 8700 ruleset += processCSSNesting( 8701 styleVariations.css, 8702 `:root :where($styleVariationSelector})` 8703 ); 8704 } 8705 } 8706 } 8707 ); 8708 } 8709 const pseudoSelectorStyles = Object.entries(styles).filter( 8710 ([key]) => key.startsWith(":") 8711 ); 8712 if (pseudoSelectorStyles?.length) { 8713 pseudoSelectorStyles.forEach( 8714 ([pseudoKey, pseudoStyle]) => { 8715 const pseudoDeclarations = getStylesDeclarations(pseudoStyle); 8716 if (!pseudoDeclarations?.length) { 8717 return; 8718 } 8719 const _selector = selector2.split(",").map((sel) => sel + pseudoKey).join(","); 8720 const pseudoRule = `:root :where($_selector}){$pseudoDeclarations.join( 8721 ";" 8722 )};}`; 8723 ruleset += pseudoRule; 8724 } 8725 ); 8726 } 8727 } 8728 ); 8729 } 8730 if (options.layoutStyles) { 8731 ruleset = ruleset + ".wp-site-blocks > .alignleft { float: left; margin-right: 2em; }"; 8732 ruleset = ruleset + ".wp-site-blocks > .alignright { float: right; margin-left: 2em; }"; 8733 ruleset = ruleset + ".wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }"; 8734 } 8735 if (options.blockGap && hasBlockGapSupport) { 8736 const gapValue = getGapCSSValue(tree?.styles?.spacing?.blockGap) || "0.5em"; 8737 ruleset = ruleset + `:root :where(.wp-site-blocks) > * { margin-block-start: $gapValue}; margin-block-end: 0; }`; 8738 ruleset = ruleset + ":root :where(.wp-site-blocks) > :first-child { margin-block-start: 0; }"; 8739 ruleset = ruleset + ":root :where(.wp-site-blocks) > :last-child { margin-block-end: 0; }"; 8740 } 8741 if (options.presets) { 8742 nodesWithSettings.forEach(({ selector: selector2, presets }) => { 8743 if (ROOT_BLOCK_SELECTOR === selector2 || ROOT_CSS_PROPERTIES_SELECTOR === selector2) { 8744 selector2 = ""; 8745 } 8746 const classes = getPresetsClasses(selector2, presets); 8747 if (classes.length > 0) { 8748 ruleset += classes; 8749 } 8750 }); 8751 } 8752 return ruleset; 8753 }; 8754 function generateSvgFilters(tree, blockSelectors) { 8755 const nodesWithSettings = getNodesWithSettings(tree, blockSelectors); 8756 return nodesWithSettings.flatMap(({ presets }) => { 8757 return getPresetsSvgFilters(presets); 8758 }); 8759 } 8760 var getSelectorsConfig = (blockType, rootSelector) => { 8761 if (blockType?.selectors && Object.keys(blockType.selectors).length > 0) { 8762 return blockType.selectors; 8763 } 8764 const config2 = { 8765 root: rootSelector 8766 }; 8767 Object.entries(BLOCK_SUPPORT_FEATURE_LEVEL_SELECTORS).forEach( 8768 ([featureKey, featureName]) => { 8769 const featureSelector = getBlockSelector(blockType, featureKey); 8770 if (featureSelector) { 8771 config2[featureName] = featureSelector; 8772 } 8773 } 8774 ); 8775 return config2; 8776 }; 8777 var getBlockSelectors = (blockTypes, variationInstanceId) => { 8778 const { getBlockStyles } = (0, import_data17.select)(import_blocks3.store); 8779 const result = {}; 8780 blockTypes.forEach((blockType) => { 8781 const name2 = blockType.name; 8782 const selector2 = getBlockSelector(blockType); 8783 if (!selector2) { 8784 return; 8785 } 8786 let duotoneSelector = getBlockSelector(blockType, "filter.duotone"); 8787 if (!duotoneSelector) { 8788 const rootSelector = getBlockSelector(blockType); 8789 const duotoneSupport = (0, import_blocks3.getBlockSupport)( 8790 blockType, 8791 "color.__experimentalDuotone", 8792 false 8793 ); 8794 duotoneSelector = duotoneSupport && rootSelector && scopeSelector(rootSelector, duotoneSupport); 8795 } 8796 const hasLayoutSupport = !!blockType?.supports?.layout || !!blockType?.supports?.__experimentalLayout; 8797 const fallbackGapValue = ( 8798 // @ts-expect-error 8799 blockType?.supports?.spacing?.blockGap?.__experimentalDefault 8800 ); 8801 const blockStyleVariations = getBlockStyles(name2); 8802 const styleVariationSelectors = {}; 8803 blockStyleVariations?.forEach((variation) => { 8804 const variationSuffix = variationInstanceId ? `-$variationInstanceId}` : ""; 8805 const variationName = `$variation.name}$variationSuffix}`; 8806 const styleVariationSelector = getBlockStyleVariationSelector( 8807 variationName, 8808 selector2 8809 ); 8810 styleVariationSelectors[variationName] = styleVariationSelector; 8811 }); 8812 const featureSelectors = getSelectorsConfig(blockType, selector2); 8813 result[name2] = { 8814 duotoneSelector: duotoneSelector ?? void 0, 8815 fallbackGapValue, 8816 featureSelectors: Object.keys(featureSelectors).length ? featureSelectors : void 0, 8817 hasLayoutSupport, 8818 name: name2, 8819 selector: selector2, 8820 styleVariationSelectors: blockStyleVariations?.length ? styleVariationSelectors : void 0 8821 }; 8822 }); 8823 return result; 8824 }; 8825 function updateConfigWithSeparator(config2) { 8826 const blocks = config2.styles?.blocks; 8827 const separatorBlock = blocks?.["core/separator"]; 8828 const needsSeparatorStyleUpdate = separatorBlock && separatorBlock.color?.background && !separatorBlock.color?.text && !separatorBlock.border?.color; 8829 if (needsSeparatorStyleUpdate) { 8830 return { 8831 ...config2, 8832 styles: { 8833 ...config2.styles, 8834 blocks: { 8835 ...blocks, 8836 "core/separator": { 8837 ...separatorBlock, 8838 color: { 8839 ...separatorBlock.color, 8840 text: separatorBlock.color?.background 8841 } 8842 } 8843 } 8844 } 8845 }; 8846 } 8847 return config2; 8848 } 8849 function processCSSNesting(css, blockSelector) { 8850 let processedCSS = ""; 8851 if (!css || css.trim() === "") { 8852 return processedCSS; 8853 } 8854 const parts = css.split("&"); 8855 parts.forEach((part) => { 8856 if (!part || part.trim() === "") { 8857 return; 8858 } 8859 const isRootCss = !part.includes("{"); 8860 if (isRootCss) { 8861 processedCSS += `:root :where($blockSelector}){$part.trim()}}`; 8862 } else { 8863 const splitPart = part.replace("}", "").split("{"); 8864 if (splitPart.length !== 2) { 8865 return; 8866 } 8867 const [nestedSelector, cssValue] = splitPart; 8868 const matches = nestedSelector.match(/([>+~\s]*::[a-zA-Z-]+)/); 8869 const pseudoPart = matches ? matches[1] : ""; 8870 const withoutPseudoElement = matches ? nestedSelector.replace(pseudoPart, "").trim() : nestedSelector.trim(); 8871 let combinedSelector; 8872 if (withoutPseudoElement === "") { 8873 combinedSelector = blockSelector; 8874 } else { 8875 combinedSelector = nestedSelector.startsWith(" ") ? scopeSelector(blockSelector, withoutPseudoElement) : appendToSelector(blockSelector, withoutPseudoElement); 8876 } 8877 processedCSS += `:root :where($combinedSelector})$pseudoPart}{$cssValue.trim()}}`; 8878 } 8879 }); 8880 return processedCSS; 8881 } 8882 function generateGlobalStyles(config2 = {}, blockTypes = [], options = {}) { 8883 const { 8884 hasBlockGapSupport: hasBlockGapSupportOption, 8885 hasFallbackGapSupport: hasFallbackGapSupportOption, 8886 disableLayoutStyles = false, 8887 disableRootPadding = false, 8888 styleOptions = {} 8889 } = options; 8890 const blocks = blockTypes.length > 0 ? blockTypes : (0, import_blocks3.getBlockTypes)(); 8891 const blockGap = getSetting(config2, "spacing.blockGap"); 8892 const hasBlockGapSupport = hasBlockGapSupportOption ?? blockGap !== null; 8893 const hasFallbackGapSupport = hasFallbackGapSupportOption ?? !hasBlockGapSupport; 8894 if (!config2?.styles || !config2?.settings) { 8895 return [[], {}]; 8896 } 8897 const updatedConfig = updateConfigWithSeparator(config2); 8898 const blockSelectors = getBlockSelectors(blocks); 8899 const customProperties = generateCustomProperties( 8900 updatedConfig, 8901 blockSelectors 8902 ); 8903 const globalStyles = transformToStyles( 8904 updatedConfig, 8905 blockSelectors, 8906 hasBlockGapSupport, 8907 hasFallbackGapSupport, 8908 disableLayoutStyles, 8909 disableRootPadding, 8910 styleOptions 8911 ); 8912 const svgs = generateSvgFilters(updatedConfig, blockSelectors); 8913 const styles = [ 8914 { 8915 css: customProperties, 8916 isGlobalStyles: true 8917 }, 8918 { 8919 css: globalStyles, 8920 isGlobalStyles: true 8921 }, 8922 // Load custom CSS in own stylesheet so that any invalid CSS entered in the input won't break all the global styles in the editor. 8923 { 8924 css: updatedConfig?.styles?.css ?? "", 8925 isGlobalStyles: true 8926 }, 8927 { 8928 assets: svgs, 8929 __unstableType: "svg", 8930 isGlobalStyles: true 8931 } 8932 ]; 8933 blocks.forEach((blockType) => { 8934 const blockStyles = updatedConfig?.styles?.blocks?.[blockType.name]; 8935 if (blockStyles?.css) { 8936 const selector2 = blockSelectors[blockType.name].selector; 8937 styles.push({ 8938 css: processCSSNesting(blockStyles.css, selector2), 8939 isGlobalStyles: true 8940 }); 8941 } 8942 }); 8943 return [styles, updatedConfig.settings]; 8944 } 8945 8946 // packages/global-styles-ui/build-module/provider.js 8947 var import_element17 = __toESM(require_element()); 8948 8949 // packages/global-styles-ui/build-module/context.js 8950 var import_element16 = __toESM(require_element()); 8951 var GlobalStylesContext = (0, import_element16.createContext)({ 8952 user: { styles: {}, settings: {} }, 8953 base: { styles: {}, settings: {} }, 8954 merged: { styles: {}, settings: {} }, 8955 onChange: () => { 8956 }, 8957 fontLibraryEnabled: false 8958 }); 8959 8960 // packages/global-styles-ui/build-module/provider.js 8961 var import_jsx_runtime81 = __toESM(require_jsx_runtime()); 8962 function GlobalStylesProvider({ 8963 children, 8964 value, 8965 baseValue, 8966 onChange, 8967 fontLibraryEnabled 8968 }) { 8969 const merged = (0, import_element17.useMemo)(() => { 8970 return mergeGlobalStyles(baseValue, value); 8971 }, [baseValue, value]); 8972 const contextValue = (0, import_element17.useMemo)( 8973 () => ({ 8974 user: value, 8975 base: baseValue, 8976 merged, 8977 onChange, 8978 fontLibraryEnabled 8979 }), 8980 [value, baseValue, merged, onChange, fontLibraryEnabled] 8981 ); 8982 return /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(GlobalStylesContext.Provider, { value: contextValue, children }); 8983 } 8984 8985 // packages/global-styles-ui/build-module/screen-root.js 8986 var import_components19 = __toESM(require_components()); 8987 var import_i18n15 = __toESM(require_i18n()); 8988 var import_data19 = __toESM(require_data()); 8989 var import_core_data15 = __toESM(require_core_data()); 8990 8991 // packages/global-styles-ui/build-module/icon-with-current-color.js 8992 var import_jsx_runtime82 = __toESM(require_jsx_runtime()); 8993 function IconWithCurrentColor({ 8994 className, 8995 ...props 8996 }) { 8997 return /* @__PURE__ */ (0, import_jsx_runtime82.jsx)( 8998 icon_default, 8999 { 9000 className: clsx_default( 9001 className, 9002 "global-styles-ui-icon-with-current-color" 9003 ), 9004 ...props 9005 } 9006 ); 9007 } 9008 9009 // packages/global-styles-ui/build-module/navigation-button.js 9010 var import_components13 = __toESM(require_components()); 9011 var import_jsx_runtime83 = __toESM(require_jsx_runtime()); 9012 function GenericNavigationButton({ 9013 icon, 9014 children, 9015 ...props 9016 }) { 9017 return /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(import_components13.__experimentalItem, { ...props, children: [ 9018 icon && /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(import_components13.__experimentalHStack, { justify: "flex-start", children: [ 9019 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(IconWithCurrentColor, { icon, size: 24 }), 9020 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(import_components13.FlexItem, { children }) 9021 ] }), 9022 !icon && children 9023 ] }); 9024 } 9025 function NavigationButtonAsItem(props) { 9026 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(import_components13.Navigator.Button, { as: GenericNavigationButton, ...props }); 9027 } 9028 9029 // packages/global-styles-ui/build-module/root-menu.js 9030 var import_components14 = __toESM(require_components()); 9031 var import_i18n13 = __toESM(require_i18n()); 9032 var import_block_editor4 = __toESM(require_block_editor()); 9033 9034 // node_modules/colord/plugins/a11y.mjs 9035 var o2 = function(o3) { 9036 var t3 = o3 / 255; 9037 return t3 < 0.04045 ? t3 / 12.92 : Math.pow((t3 + 0.055) / 1.055, 2.4); 9038 }; 9039 var t2 = function(t3) { 9040 return 0.2126 * o2(t3.r) + 0.7152 * o2(t3.g) + 0.0722 * o2(t3.b); 9041 }; 9042 function a11y_default(o3) { 9043 o3.prototype.luminance = function() { 9044 return o4 = t2(this.rgba), void 0 === (r3 = 2) && (r3 = 0), void 0 === n2 && (n2 = Math.pow(10, r3)), Math.round(n2 * o4) / n2 + 0; 9045 var o4, r3, n2; 9046 }, o3.prototype.contrast = function(r3) { 9047 void 0 === r3 && (r3 = "#FFF"); 9048 var n2, a2, i2, e2, v2, u2, d2, c6 = r3 instanceof o3 ? r3 : new o3(r3); 9049 return e2 = this.rgba, v2 = c6.toRgb(), u2 = t2(e2), d2 = t2(v2), n2 = u2 > d2 ? (u2 + 0.05) / (d2 + 0.05) : (d2 + 0.05) / (u2 + 0.05), void 0 === (a2 = 2) && (a2 = 0), void 0 === i2 && (i2 = Math.pow(10, a2)), Math.floor(i2 * n2) / i2 + 0; 9050 }, o3.prototype.isReadable = function(o4, t3) { 9051 return void 0 === o4 && (o4 = "#FFF"), void 0 === t3 && (t3 = {}), this.contrast(o4) >= (e2 = void 0 === (i2 = (r3 = t3).size) ? "normal" : i2, "AAA" === (a2 = void 0 === (n2 = r3.level) ? "AA" : n2) && "normal" === e2 ? 7 : "AA" === a2 && "large" === e2 ? 3 : 4.5); 9052 var r3, n2, a2, i2, e2; 9053 }; 9054 } 9055 9056 // packages/global-styles-ui/build-module/hooks.js 9057 var import_element18 = __toESM(require_element()); 9058 var import_data18 = __toESM(require_data()); 9059 var import_core_data14 = __toESM(require_core_data()); 9060 var import_i18n12 = __toESM(require_i18n()); 9061 9062 // packages/global-styles-ui/build-module/utils.js 9063 function removePropertiesFromObject(object, properties) { 9064 if (!properties?.length) { 9065 return object; 9066 } 9067 if (typeof object !== "object" || !object || !Object.keys(object).length) { 9068 return object; 9069 } 9070 for (const key in object) { 9071 if (properties.includes(key)) { 9072 delete object[key]; 9073 } else if (typeof object[key] === "object") { 9074 removePropertiesFromObject(object[key], properties); 9075 } 9076 } 9077 return object; 9078 } 9079 var filterObjectByProperties = (object, properties) => { 9080 if (!object || !properties?.length) { 9081 return {}; 9082 } 9083 const newObject = {}; 9084 Object.keys(object).forEach((key) => { 9085 if (properties.includes(key)) { 9086 newObject[key] = object[key]; 9087 } else if (typeof object[key] === "object") { 9088 const newFilter = filterObjectByProperties( 9089 object[key], 9090 properties 9091 ); 9092 if (Object.keys(newFilter).length) { 9093 newObject[key] = newFilter; 9094 } 9095 } 9096 }); 9097 return newObject; 9098 }; 9099 function isVariationWithProperties(variation, properties) { 9100 const variationWithProperties = filterObjectByProperties( 9101 structuredClone(variation), 9102 properties 9103 ); 9104 return areGlobalStylesEqual(variationWithProperties, variation); 9105 } 9106 function getFontFamilyFromSetting(fontFamilies, setting) { 9107 if (!Array.isArray(fontFamilies) || !setting) { 9108 return null; 9109 } 9110 const fontFamilyVariable = setting.replace("var(", "").replace(")", ""); 9111 const fontFamilySlug = fontFamilyVariable?.split("--").slice(-1)[0]; 9112 return fontFamilies.find( 9113 (fontFamily) => fontFamily.slug === fontFamilySlug 9114 ); 9115 } 9116 function getFontFamilies(themeJson) { 9117 const themeFontFamilies = themeJson?.settings?.typography?.fontFamilies?.theme; 9118 const customFontFamilies = themeJson?.settings?.typography?.fontFamilies?.custom; 9119 let fontFamilies = []; 9120 if (themeFontFamilies && customFontFamilies) { 9121 fontFamilies = [...themeFontFamilies, ...customFontFamilies]; 9122 } else if (themeFontFamilies) { 9123 fontFamilies = themeFontFamilies; 9124 } else if (customFontFamilies) { 9125 fontFamilies = customFontFamilies; 9126 } 9127 const bodyFontFamilySetting = themeJson?.styles?.typography?.fontFamily; 9128 const bodyFontFamily = getFontFamilyFromSetting( 9129 fontFamilies, 9130 bodyFontFamilySetting 9131 ); 9132 const headingFontFamilySetting = themeJson?.styles?.elements?.heading?.typography?.fontFamily; 9133 let headingFontFamily; 9134 if (!headingFontFamilySetting) { 9135 headingFontFamily = bodyFontFamily; 9136 } else { 9137 headingFontFamily = getFontFamilyFromSetting( 9138 fontFamilies, 9139 themeJson?.styles?.elements?.heading?.typography?.fontFamily 9140 ); 9141 } 9142 return [bodyFontFamily, headingFontFamily]; 9143 } 9144 9145 // packages/global-styles-ui/build-module/hooks.js 9146 k([a11y_default]); 9147 function useStyle2(path, blockName, readFrom = "merged", shouldDecodeEncode = true) { 9148 const { user, base, merged, onChange } = (0, import_element18.useContext)(GlobalStylesContext); 9149 let sourceValue = merged; 9150 if (readFrom === "base") { 9151 sourceValue = base; 9152 } else if (readFrom === "user") { 9153 sourceValue = user; 9154 } 9155 const styleValue = (0, import_element18.useMemo)( 9156 () => getStyle(sourceValue, path, blockName, shouldDecodeEncode), 9157 [sourceValue, path, blockName, shouldDecodeEncode] 9158 ); 9159 const setStyleValue = (0, import_element18.useCallback)( 9160 (newValue) => { 9161 const newGlobalStyles = setStyle( 9162 user, 9163 path, 9164 newValue, 9165 blockName 9166 ); 9167 onChange(newGlobalStyles); 9168 }, 9169 [user, onChange, path, blockName] 9170 ); 9171 return [styleValue, setStyleValue]; 9172 } 9173 function useSetting(path, blockName, readFrom = "merged") { 9174 const { user, base, merged, onChange } = (0, import_element18.useContext)(GlobalStylesContext); 9175 let sourceValue = merged; 9176 if (readFrom === "base") { 9177 sourceValue = base; 9178 } else if (readFrom === "user") { 9179 sourceValue = user; 9180 } 9181 const settingValue = (0, import_element18.useMemo)( 9182 () => getSetting(sourceValue, path, blockName), 9183 [sourceValue, path, blockName] 9184 ); 9185 const setSettingValue = (0, import_element18.useCallback)( 9186 (newValue) => { 9187 const newGlobalStyles = setSetting( 9188 user, 9189 path, 9190 newValue, 9191 blockName 9192 ); 9193 onChange(newGlobalStyles); 9194 }, 9195 [user, onChange, path, blockName] 9196 ); 9197 return [settingValue, setSettingValue]; 9198 } 9199 var EMPTY_ARRAY2 = []; 9200 function hasThemeVariation({ 9201 title, 9202 settings: settings2, 9203 styles 9204 }) { 9205 return title === (0, import_i18n12.__)("Default") || Object.keys(settings2 || {}).length > 0 || Object.keys(styles || {}).length > 0; 9206 } 9207 function useCurrentMergeThemeStyleVariationsWithUserConfig(properties = []) { 9208 const { variationsFromTheme } = (0, import_data18.useSelect)((select3) => { 9209 const _variationsFromTheme = select3( 9210 import_core_data14.store 9211 ).__experimentalGetCurrentThemeGlobalStylesVariations?.(); 9212 return { 9213 variationsFromTheme: _variationsFromTheme || EMPTY_ARRAY2 9214 }; 9215 }, []); 9216 const { user: userVariation } = (0, import_element18.useContext)(GlobalStylesContext); 9217 return (0, import_element18.useMemo)(() => { 9218 const clonedUserVariation = structuredClone(userVariation); 9219 const userVariationWithoutProperties = removePropertiesFromObject( 9220 clonedUserVariation, 9221 properties 9222 ); 9223 userVariationWithoutProperties.title = (0, import_i18n12.__)("Default"); 9224 const variationsWithPropertiesAndBase = variationsFromTheme.filter((variation) => { 9225 return isVariationWithProperties(variation, properties); 9226 }).map((variation) => { 9227 return mergeGlobalStyles( 9228 userVariationWithoutProperties, 9229 variation 9230 ); 9231 }); 9232 const variationsByProperties = [ 9233 userVariationWithoutProperties, 9234 ...variationsWithPropertiesAndBase 9235 ]; 9236 return variationsByProperties?.length ? variationsByProperties.filter(hasThemeVariation) : []; 9237 }, [properties, userVariation, variationsFromTheme]); 9238 } 9239 9240 // packages/global-styles-ui/build-module/lock-unlock.js 9241 var import_private_apis2 = __toESM(require_private_apis()); 9242 var { lock: lock2, unlock: unlock2 } = (0, import_private_apis2.__dangerousOptInToUnstableAPIsOnlyForCoreModules)( 9243 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.", 9244 "@wordpress/global-styles-ui" 9245 ); 9246 9247 // packages/global-styles-ui/build-module/root-menu.js 9248 var import_jsx_runtime84 = __toESM(require_jsx_runtime()); 9249 var { 9250 useHasDimensionsPanel, 9251 useHasTypographyPanel, 9252 useHasColorPanel, 9253 useSettingsForBlockElement, 9254 useHasBackgroundPanel 9255 } = unlock2(import_block_editor4.privateApis); 9256 9257 // packages/global-styles-ui/build-module/preview-styles.js 9258 var import_components18 = __toESM(require_components()); 9259 9260 // packages/global-styles-ui/build-module/preview-hooks.js 9261 function useStylesPreviewColors() { 9262 const [textColor = "black"] = useStyle2("color.text"); 9263 const [backgroundColor = "white"] = useStyle2("color.background"); 9264 const [headingColor = textColor] = useStyle2( 9265 "elements.h1.color.text" 9266 ); 9267 const [linkColor = headingColor] = useStyle2( 9268 "elements.link.color.text" 9269 ); 9270 const [buttonBackgroundColor = linkColor] = useStyle2( 9271 "elements.button.color.background" 9272 ); 9273 const [coreColors] = useSetting("color.palette.core") || []; 9274 const [themeColors] = useSetting("color.palette.theme") || []; 9275 const [customColors] = useSetting("color.palette.custom") || []; 9276 const paletteColors = (themeColors ?? []).concat(customColors ?? []).concat(coreColors ?? []); 9277 const textColorObject = paletteColors.filter( 9278 ({ color }) => color === textColor 9279 ); 9280 const buttonBackgroundColorObject = paletteColors.filter( 9281 ({ color }) => color === buttonBackgroundColor 9282 ); 9283 const highlightedColors = textColorObject.concat(buttonBackgroundColorObject).concat(paletteColors).filter( 9284 // we exclude these background color because it is already visible in the preview. 9285 ({ color }) => color !== backgroundColor 9286 ).slice(0, 2); 9287 return { 9288 paletteColors, 9289 highlightedColors 9290 }; 9291 } 9292 9293 // packages/global-styles-ui/build-module/typography-example.js 9294 var import_element19 = __toESM(require_element()); 9295 var import_components15 = __toESM(require_components()); 9296 var import_i18n14 = __toESM(require_i18n()); 9297 9298 // packages/global-styles-ui/build-module/font-library/utils/preview-styles.js 9299 function findNearest(input, numbers) { 9300 if (numbers.length === 0) { 9301 return null; 9302 } 9303 numbers.sort((a2, b2) => Math.abs(input - a2) - Math.abs(input - b2)); 9304 return numbers[0]; 9305 } 9306 function extractFontWeights(fontFaces) { 9307 const result = []; 9308 fontFaces.forEach((face) => { 9309 const weights = String(face.fontWeight).split(" "); 9310 if (weights.length === 2) { 9311 const start2 = parseInt(weights[0]); 9312 const end = parseInt(weights[1]); 9313 for (let i2 = start2; i2 <= end; i2 += 100) { 9314 result.push(i2); 9315 } 9316 } else if (weights.length === 1) { 9317 result.push(parseInt(weights[0])); 9318 } 9319 }); 9320 return result; 9321 } 9322 function formatFontFamily(input) { 9323 const regex = /^(?!generic\([ a-zA-Z\-]+\)$)(?!^[a-zA-Z\-]+$).+/; 9324 const output = input.trim(); 9325 const formatItem = (item) => { 9326 item = item.trim(); 9327 if (item.match(regex)) { 9328 item = item.replace(/^["']|["']$/g, ""); 9329 return `"$item}"`; 9330 } 9331 return item; 9332 }; 9333 if (output.includes(",")) { 9334 return output.split(",").map(formatItem).filter((item) => item !== "").join(", "); 9335 } 9336 return formatItem(output); 9337 } 9338 function getFamilyPreviewStyle(family) { 9339 const style = { 9340 fontFamily: formatFontFamily(family.fontFamily) 9341 }; 9342 if (!("fontFace" in family) || !Array.isArray(family.fontFace)) { 9343 style.fontWeight = "400"; 9344 style.fontStyle = "normal"; 9345 return style; 9346 } 9347 if (family.fontFace) { 9348 const normalFaces = family.fontFace.filter( 9349 (face) => face?.fontStyle && face.fontStyle.toLowerCase() === "normal" 9350 ); 9351 if (normalFaces.length > 0) { 9352 style.fontStyle = "normal"; 9353 const normalWeights = extractFontWeights(normalFaces); 9354 const nearestWeight = findNearest(400, normalWeights); 9355 style.fontWeight = String(nearestWeight) || "400"; 9356 } else { 9357 style.fontStyle = family.fontFace.length && family.fontFace[0].fontStyle || "normal"; 9358 style.fontWeight = family.fontFace.length && String(family.fontFace[0].fontWeight) || "400"; 9359 } 9360 } 9361 return style; 9362 } 9363 9364 // packages/global-styles-ui/build-module/typography-example.js 9365 var import_jsx_runtime85 = __toESM(require_jsx_runtime()); 9366 function PreviewTypography({ 9367 fontSize, 9368 variation 9369 }) { 9370 const { base } = (0, import_element19.useContext)(GlobalStylesContext); 9371 let config2 = base; 9372 if (variation) { 9373 config2 = { ...base, ...variation }; 9374 } 9375 const [textColor] = useStyle2("color.text"); 9376 const [bodyFontFamilies, headingFontFamilies] = getFontFamilies(config2); 9377 const bodyPreviewStyle = bodyFontFamilies ? getFamilyPreviewStyle(bodyFontFamilies) : {}; 9378 const headingPreviewStyle = headingFontFamilies ? getFamilyPreviewStyle(headingFontFamilies) : {}; 9379 if (textColor) { 9380 bodyPreviewStyle.color = textColor; 9381 headingPreviewStyle.color = textColor; 9382 } 9383 if (fontSize) { 9384 bodyPreviewStyle.fontSize = fontSize; 9385 headingPreviewStyle.fontSize = fontSize; 9386 } 9387 return /* @__PURE__ */ (0, import_jsx_runtime85.jsxs)( 9388 import_components15.__unstableMotion.div, 9389 { 9390 animate: { 9391 scale: 1, 9392 opacity: 1 9393 }, 9394 initial: { 9395 scale: 0.1, 9396 opacity: 0 9397 }, 9398 transition: { 9399 delay: 0.3, 9400 type: "tween" 9401 }, 9402 style: { 9403 textAlign: "center", 9404 lineHeight: 1 9405 }, 9406 children: [ 9407 /* @__PURE__ */ (0, import_jsx_runtime85.jsx)("span", { style: headingPreviewStyle, children: (0, import_i18n14._x)("A", "Uppercase letter A") }), 9408 /* @__PURE__ */ (0, import_jsx_runtime85.jsx)("span", { style: bodyPreviewStyle, children: (0, import_i18n14._x)("a", "Lowercase letter A") }) 9409 ] 9410 } 9411 ); 9412 } 9413 9414 // packages/global-styles-ui/build-module/highlighted-colors.js 9415 var import_components16 = __toESM(require_components()); 9416 var import_jsx_runtime86 = __toESM(require_jsx_runtime()); 9417 function HighlightedColors({ 9418 normalizedColorSwatchSize, 9419 ratio 9420 }) { 9421 const { highlightedColors } = useStylesPreviewColors(); 9422 const scaledSwatchSize = normalizedColorSwatchSize * ratio; 9423 return highlightedColors.map(({ slug, color }, index) => /* @__PURE__ */ (0, import_jsx_runtime86.jsx)( 9424 import_components16.__unstableMotion.div, 9425 { 9426 style: { 9427 height: scaledSwatchSize, 9428 width: scaledSwatchSize, 9429 background: color, 9430 borderRadius: scaledSwatchSize / 2 9431 }, 9432 animate: { 9433 scale: 1, 9434 opacity: 1 9435 }, 9436 initial: { 9437 scale: 0.1, 9438 opacity: 0 9439 }, 9440 transition: { 9441 delay: index === 1 ? 0.2 : 0.1 9442 } 9443 }, 9444 `$slug}-$index}` 9445 )); 9446 } 9447 9448 // packages/global-styles-ui/build-module/preview-wrapper.js 9449 var import_components17 = __toESM(require_components()); 9450 var import_compose3 = __toESM(require_compose()); 9451 var import_element20 = __toESM(require_element()); 9452 var import_jsx_runtime87 = __toESM(require_jsx_runtime()); 9453 var normalizedWidth = 248; 9454 var normalizedHeight = 152; 9455 var THROTTLE_OPTIONS = { 9456 leading: true, 9457 trailing: true 9458 }; 9459 function PreviewWrapper({ 9460 children, 9461 label, 9462 isFocused, 9463 withHoverView 9464 }) { 9465 const [backgroundColor = "white"] = useStyle2("color.background"); 9466 const [gradientValue] = useStyle2("color.gradient"); 9467 const disableMotion = (0, import_compose3.useReducedMotion)(); 9468 const [isHovered, setIsHovered] = (0, import_element20.useState)(false); 9469 const [containerResizeListener, { width }] = (0, import_compose3.useResizeObserver)(); 9470 const [throttledWidth, setThrottledWidthState] = (0, import_element20.useState)(width); 9471 const [ratioState, setRatioState] = (0, import_element20.useState)(); 9472 const setThrottledWidth = (0, import_compose3.useThrottle)( 9473 setThrottledWidthState, 9474 250, 9475 THROTTLE_OPTIONS 9476 ); 9477 (0, import_element20.useLayoutEffect)(() => { 9478 if (width) { 9479 setThrottledWidth(width); 9480 } 9481 }, [width, setThrottledWidth]); 9482 (0, import_element20.useLayoutEffect)(() => { 9483 const newRatio = throttledWidth ? throttledWidth / normalizedWidth : 1; 9484 const ratioDiff = newRatio - (ratioState || 0); 9485 const isRatioDiffBigEnough = Math.abs(ratioDiff) > 0.1; 9486 if (isRatioDiffBigEnough || !ratioState) { 9487 setRatioState(newRatio); 9488 } 9489 }, [throttledWidth, ratioState]); 9490 const fallbackRatio = width ? width / normalizedWidth : 1; 9491 const ratio = ratioState ? ratioState : fallbackRatio; 9492 const isReady = !!width; 9493 return /* @__PURE__ */ (0, import_jsx_runtime87.jsxs)(import_jsx_runtime87.Fragment, { children: [ 9494 /* @__PURE__ */ (0, import_jsx_runtime87.jsx)("div", { style: { position: "relative" }, children: containerResizeListener }), 9495 isReady && /* @__PURE__ */ (0, import_jsx_runtime87.jsx)( 9496 "div", 9497 { 9498 className: "global-styles-ui-preview__wrapper", 9499 style: { 9500 height: normalizedHeight * ratio 9501 }, 9502 onMouseEnter: () => setIsHovered(true), 9503 onMouseLeave: () => setIsHovered(false), 9504 tabIndex: -1, 9505 children: /* @__PURE__ */ (0, import_jsx_runtime87.jsx)( 9506 import_components17.__unstableMotion.div, 9507 { 9508 style: { 9509 height: normalizedHeight * ratio, 9510 width: "100%", 9511 background: gradientValue ?? backgroundColor, 9512 cursor: withHoverView ? "pointer" : void 0 9513 }, 9514 initial: "start", 9515 animate: (isHovered || isFocused) && !disableMotion && label ? "hover" : "start", 9516 children: [].concat(children).map( 9517 (child, key) => child({ ratio, key }) 9518 ) 9519 } 9520 ) 9521 } 9522 ) 9523 ] }); 9524 } 9525 var preview_wrapper_default = PreviewWrapper; 9526 9527 // packages/global-styles-ui/build-module/preview-styles.js 9528 var import_jsx_runtime88 = __toESM(require_jsx_runtime()); 9529 var firstFrameVariants = { 9530 start: { 9531 scale: 1, 9532 opacity: 1 9533 }, 9534 hover: { 9535 scale: 0, 9536 opacity: 0 9537 } 9538 }; 9539 var midFrameVariants = { 9540 hover: { 9541 opacity: 1 9542 }, 9543 start: { 9544 opacity: 0.5 9545 } 9546 }; 9547 var secondFrameVariants = { 9548 hover: { 9549 scale: 1, 9550 opacity: 1 9551 }, 9552 start: { 9553 scale: 0, 9554 opacity: 0 9555 } 9556 }; 9557 function PreviewStyles({ 9558 label, 9559 isFocused, 9560 withHoverView, 9561 variation 9562 }) { 9563 const [fontWeight] = useStyle2("typography.fontWeight"); 9564 const [fontFamily = "serif"] = useStyle2( 9565 "typography.fontFamily" 9566 ); 9567 const [headingFontFamily = fontFamily] = useStyle2( 9568 "elements.h1.typography.fontFamily" 9569 ); 9570 const [headingFontWeight = fontWeight] = useStyle2( 9571 "elements.h1.typography.fontWeight" 9572 ); 9573 const [textColor = "black"] = useStyle2("color.text"); 9574 const [headingColor = textColor] = useStyle2( 9575 "elements.h1.color.text" 9576 ); 9577 const { paletteColors } = useStylesPreviewColors(); 9578 return /* @__PURE__ */ (0, import_jsx_runtime88.jsxs)( 9579 preview_wrapper_default, 9580 { 9581 label, 9582 isFocused, 9583 withHoverView, 9584 children: [ 9585 ({ ratio, key }) => /* @__PURE__ */ (0, import_jsx_runtime88.jsx)( 9586 import_components18.__unstableMotion.div, 9587 { 9588 variants: firstFrameVariants, 9589 style: { 9590 height: "100%", 9591 overflow: "hidden" 9592 }, 9593 children: /* @__PURE__ */ (0, import_jsx_runtime88.jsxs)( 9594 import_components18.__experimentalHStack, 9595 { 9596 spacing: 10 * ratio, 9597 justify: "center", 9598 style: { 9599 height: "100%", 9600 overflow: "hidden" 9601 }, 9602 children: [ 9603 /* @__PURE__ */ (0, import_jsx_runtime88.jsx)( 9604 PreviewTypography, 9605 { 9606 fontSize: 65 * ratio, 9607 variation 9608 } 9609 ), 9610 /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(import_components18.__experimentalVStack, { spacing: 4 * ratio, children: /* @__PURE__ */ (0, import_jsx_runtime88.jsx)( 9611 HighlightedColors, 9612 { 9613 normalizedColorSwatchSize: 32, 9614 ratio 9615 } 9616 ) }) 9617 ] 9618 } 9619 ) 9620 }, 9621 key 9622 ), 9623 ({ key }) => /* @__PURE__ */ (0, import_jsx_runtime88.jsx)( 9624 import_components18.__unstableMotion.div, 9625 { 9626 variants: withHoverView ? midFrameVariants : void 0, 9627 style: { 9628 height: "100%", 9629 width: "100%", 9630 position: "absolute", 9631 top: 0, 9632 overflow: "hidden", 9633 filter: "blur(60px)", 9634 opacity: 0.1 9635 }, 9636 children: /* @__PURE__ */ (0, import_jsx_runtime88.jsx)( 9637 import_components18.__experimentalHStack, 9638 { 9639 spacing: 0, 9640 justify: "flex-start", 9641 style: { 9642 height: "100%", 9643 overflow: "hidden" 9644 }, 9645 children: paletteColors.slice(0, 4).map(({ color }, index) => /* @__PURE__ */ (0, import_jsx_runtime88.jsx)( 9646 "div", 9647 { 9648 style: { 9649 height: "100%", 9650 background: color, 9651 flexGrow: 1 9652 } 9653 }, 9654 index 9655 )) 9656 } 9657 ) 9658 }, 9659 key 9660 ), 9661 ({ ratio, key }) => /* @__PURE__ */ (0, import_jsx_runtime88.jsx)( 9662 import_components18.__unstableMotion.div, 9663 { 9664 variants: secondFrameVariants, 9665 style: { 9666 height: "100%", 9667 width: "100%", 9668 overflow: "hidden", 9669 position: "absolute", 9670 top: 0 9671 }, 9672 children: /* @__PURE__ */ (0, import_jsx_runtime88.jsx)( 9673 import_components18.__experimentalVStack, 9674 { 9675 spacing: 3 * ratio, 9676 justify: "center", 9677 style: { 9678 height: "100%", 9679 overflow: "hidden", 9680 padding: 10 * ratio, 9681 boxSizing: "border-box" 9682 }, 9683 children: label && /* @__PURE__ */ (0, import_jsx_runtime88.jsx)( 9684 "div", 9685 { 9686 style: { 9687 fontSize: 40 * ratio, 9688 fontFamily: headingFontFamily, 9689 color: headingColor, 9690 fontWeight: headingFontWeight, 9691 lineHeight: "1em", 9692 textAlign: "center" 9693 }, 9694 children: label 9695 } 9696 ) 9697 } 9698 ) 9699 }, 9700 key 9701 ) 9702 ] 9703 } 9704 ); 9705 } 9706 var preview_styles_default = PreviewStyles; 9707 9708 // packages/global-styles-ui/build-module/screen-root.js 9709 var import_jsx_runtime89 = __toESM(require_jsx_runtime()); 9710 9711 // packages/global-styles-ui/build-module/screen-block-list.js 9712 var import_blocks5 = __toESM(require_blocks()); 9713 var import_i18n17 = __toESM(require_i18n()); 9714 var import_components22 = __toESM(require_components()); 9715 var import_data21 = __toESM(require_data()); 9716 var import_element21 = __toESM(require_element()); 9717 var import_block_editor5 = __toESM(require_block_editor()); 9718 var import_compose4 = __toESM(require_compose()); 9719 var import_a11y2 = __toESM(require_a11y()); 9720 9721 // packages/global-styles-ui/build-module/variations/variations-panel.js 9722 var import_blocks4 = __toESM(require_blocks()); 9723 var import_data20 = __toESM(require_data()); 9724 var import_components20 = __toESM(require_components()); 9725 var import_jsx_runtime90 = __toESM(require_jsx_runtime()); 9726 function getFilteredBlockStyles(blockStyles, variations) { 9727 return blockStyles?.filter( 9728 (style) => style.source === "block" || variations.includes(style.name) 9729 ) || []; 9730 } 9731 function useBlockVariations(name2) { 9732 const blockStyles = (0, import_data20.useSelect)( 9733 (select3) => { 9734 const { getBlockStyles } = select3(import_blocks4.store); 9735 return getBlockStyles(name2); 9736 }, 9737 [name2] 9738 ); 9739 const [variations] = useStyle2("variations", name2); 9740 const variationNames = Object.keys(variations ?? {}); 9741 return getFilteredBlockStyles(blockStyles, variationNames); 9742 } 9743 9744 // packages/global-styles-ui/build-module/screen-header.js 9745 var import_components21 = __toESM(require_components()); 9746 var import_i18n16 = __toESM(require_i18n()); 9747 var import_jsx_runtime91 = __toESM(require_jsx_runtime()); 9748 9749 // packages/global-styles-ui/build-module/screen-block-list.js 9750 var import_jsx_runtime92 = __toESM(require_jsx_runtime()); 9751 var { 9752 useHasDimensionsPanel: useHasDimensionsPanel2, 9753 useHasTypographyPanel: useHasTypographyPanel2, 9754 useHasBorderPanel, 9755 useSettingsForBlockElement: useSettingsForBlockElement2, 9756 useHasColorPanel: useHasColorPanel2 9757 } = unlock2(import_block_editor5.privateApis); 9758 function useSortedBlockTypes() { 9759 const blockItems = (0, import_data21.useSelect)( 9760 (select3) => select3(import_blocks5.store).getBlockTypes(), 9761 [] 9762 ); 9763 const groupByType = (blocks, block) => { 9764 const { core, noncore } = blocks; 9765 const type = block.name.startsWith("core/") ? core : noncore; 9766 type.push(block); 9767 return blocks; 9768 }; 9769 const { core: coreItems, noncore: nonCoreItems } = blockItems.reduce( 9770 groupByType, 9771 { core: [], noncore: [] } 9772 ); 9773 return [...coreItems, ...nonCoreItems]; 9774 } 9775 function useBlockHasGlobalStyles(blockName) { 9776 const [rawSettings] = useSetting("", blockName); 9777 const settings2 = useSettingsForBlockElement2(rawSettings, blockName); 9778 const hasTypographyPanel = useHasTypographyPanel2(settings2); 9779 const hasColorPanel = useHasColorPanel2(settings2); 9780 const hasBorderPanel = useHasBorderPanel(settings2); 9781 const hasDimensionsPanel = useHasDimensionsPanel2(settings2); 9782 const hasLayoutPanel = hasBorderPanel || hasDimensionsPanel; 9783 const hasVariationsPanel = !!useBlockVariations(blockName)?.length; 9784 const hasGlobalStyles = hasTypographyPanel || hasColorPanel || hasLayoutPanel || hasVariationsPanel; 9785 return hasGlobalStyles; 9786 } 9787 function BlockMenuItem({ block }) { 9788 const hasBlockMenuItem = useBlockHasGlobalStyles(block.name); 9789 if (!hasBlockMenuItem) { 9790 return null; 9791 } 9792 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)( 9793 NavigationButtonAsItem, 9794 { 9795 path: "/blocks/" + encodeURIComponent(block.name), 9796 children: /* @__PURE__ */ (0, import_jsx_runtime92.jsxs)(import_components22.__experimentalHStack, { justify: "flex-start", children: [ 9797 /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(import_block_editor5.BlockIcon, { icon: block.icon }), 9798 /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(import_components22.FlexItem, { children: block.title }) 9799 ] }) 9800 } 9801 ); 9802 } 9803 function BlockList({ filterValue }) { 9804 const sortedBlockTypes = useSortedBlockTypes(); 9805 const debouncedSpeak = (0, import_compose4.useDebounce)(import_a11y2.speak, 500); 9806 const { isMatchingSearchTerm } = (0, import_data21.useSelect)(import_blocks5.store); 9807 const filteredBlockTypes = !filterValue ? sortedBlockTypes : sortedBlockTypes.filter( 9808 (blockType) => isMatchingSearchTerm(blockType, filterValue) 9809 ); 9810 const blockTypesListRef = (0, import_element21.useRef)(null); 9811 (0, import_element21.useEffect)(() => { 9812 if (!filterValue) { 9813 return; 9814 } 9815 const count = blockTypesListRef.current?.childElementCount || 0; 9816 const resultsFoundMessage = (0, import_i18n17.sprintf)( 9817 /* translators: %d: number of results. */ 9818 (0, import_i18n17._n)("%d result found.", "%d results found.", count), 9819 count 9820 ); 9821 debouncedSpeak(resultsFoundMessage, "polite"); 9822 }, [filterValue, debouncedSpeak]); 9823 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)( 9824 "div", 9825 { 9826 ref: blockTypesListRef, 9827 className: "global-styles-ui-block-types-item-list", 9828 role: "list", 9829 children: filteredBlockTypes.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(import_components22.__experimentalText, { align: "center", as: "p", children: (0, import_i18n17.__)("No blocks found.") }) : filteredBlockTypes.map((block) => /* @__PURE__ */ (0, import_jsx_runtime92.jsx)( 9830 BlockMenuItem, 9831 { 9832 block 9833 }, 9834 "menu-itemblock-" + block.name 9835 )) 9836 } 9837 ); 9838 } 9839 var MemoizedBlockList = (0, import_element21.memo)(BlockList); 9840 9841 // packages/global-styles-ui/build-module/screen-block.js 9842 var import_blocks7 = __toESM(require_blocks()); 9843 var import_block_editor7 = __toESM(require_block_editor()); 9844 var import_element23 = __toESM(require_element()); 9845 var import_data22 = __toESM(require_data()); 9846 var import_core_data16 = __toESM(require_core_data()); 9847 var import_components25 = __toESM(require_components()); 9848 var import_i18n18 = __toESM(require_i18n()); 9849 9850 // packages/global-styles-ui/build-module/block-preview-panel.js 9851 var import_block_editor6 = __toESM(require_block_editor()); 9852 var import_blocks6 = __toESM(require_blocks()); 9853 var import_components23 = __toESM(require_components()); 9854 var import_element22 = __toESM(require_element()); 9855 var import_jsx_runtime93 = __toESM(require_jsx_runtime()); 9856 9857 // packages/global-styles-ui/build-module/subtitle.js 9858 var import_components24 = __toESM(require_components()); 9859 var import_jsx_runtime94 = __toESM(require_jsx_runtime()); 9860 function Subtitle({ children, level = 2 }) { 9861 return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(import_components24.__experimentalHeading, { className: "global-styles-ui-subtitle", level, children }); 9862 } 9863 9864 // packages/global-styles-ui/build-module/screen-block.js 9865 var import_jsx_runtime95 = __toESM(require_jsx_runtime()); 9866 var { 9867 useHasDimensionsPanel: useHasDimensionsPanel3, 9868 useHasTypographyPanel: useHasTypographyPanel3, 9869 useHasBorderPanel: useHasBorderPanel2, 9870 useSettingsForBlockElement: useSettingsForBlockElement3, 9871 useHasColorPanel: useHasColorPanel3, 9872 useHasFiltersPanel, 9873 useHasImageSettingsPanel, 9874 useHasBackgroundPanel: useHasBackgroundPanel2, 9875 BackgroundPanel: StylesBackgroundPanel, 9876 BorderPanel: StylesBorderPanel, 9877 ColorPanel: StylesColorPanel, 9878 TypographyPanel: StylesTypographyPanel, 9879 DimensionsPanel: StylesDimensionsPanel, 9880 FiltersPanel: StylesFiltersPanel, 9881 ImageSettingsPanel, 9882 AdvancedPanel: StylesAdvancedPanel 9883 } = unlock2(import_block_editor7.privateApis); 9884 9885 // packages/global-styles-ui/build-module/screen-typography.js 9886 var import_i18n32 = __toESM(require_i18n()); 9887 var import_components45 = __toESM(require_components()); 9888 var import_element34 = __toESM(require_element()); 9889 9890 // packages/global-styles-ui/build-module/screen-body.js 9891 var import_components26 = __toESM(require_components()); 9892 var import_jsx_runtime96 = __toESM(require_jsx_runtime()); 9893 9894 // packages/global-styles-ui/build-module/typography-elements.js 9895 var import_i18n19 = __toESM(require_i18n()); 9896 var import_components27 = __toESM(require_components()); 9897 var import_jsx_runtime97 = __toESM(require_jsx_runtime()); 9898 9899 // packages/global-styles-ui/build-module/variations/variations-typography.js 9900 var import_components30 = __toESM(require_components()); 9901 9902 // packages/global-styles-ui/build-module/preview-typography.js 9903 var import_components28 = __toESM(require_components()); 9904 var import_jsx_runtime98 = __toESM(require_jsx_runtime()); 9905 var StylesPreviewTypography = ({ 9906 variation, 9907 isFocused, 9908 withHoverView 9909 }) => { 9910 return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)( 9911 preview_wrapper_default, 9912 { 9913 label: variation.title, 9914 isFocused, 9915 withHoverView, 9916 children: ({ ratio, key }) => /* @__PURE__ */ (0, import_jsx_runtime98.jsx)( 9917 import_components28.__experimentalHStack, 9918 { 9919 spacing: 10 * ratio, 9920 justify: "center", 9921 style: { 9922 height: "100%", 9923 overflow: "hidden" 9924 }, 9925 children: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)( 9926 PreviewTypography, 9927 { 9928 variation, 9929 fontSize: 85 * ratio 9930 } 9931 ) 9932 }, 9933 key 9934 ) 9935 } 9936 ); 9937 }; 9938 var preview_typography_default = StylesPreviewTypography; 9939 9940 // packages/global-styles-ui/build-module/variations/variation.js 9941 var import_components29 = __toESM(require_components()); 9942 var import_element24 = __toESM(require_element()); 9943 var import_keycodes3 = __toESM(require_keycodes()); 9944 var import_i18n20 = __toESM(require_i18n()); 9945 var import_jsx_runtime99 = __toESM(require_jsx_runtime()); 9946 function Variation({ 9947 variation, 9948 children, 9949 isPill = false, 9950 properties, 9951 showTooltip = false 9952 }) { 9953 const [isFocused, setIsFocused] = (0, import_element24.useState)(false); 9954 const { 9955 base, 9956 user, 9957 onChange: setUserConfig 9958 } = (0, import_element24.useContext)(GlobalStylesContext); 9959 const context = (0, import_element24.useMemo)(() => { 9960 let merged = mergeGlobalStyles(base, variation); 9961 if (properties) { 9962 merged = filterObjectByProperties(merged, properties); 9963 } 9964 return { 9965 user: variation, 9966 base, 9967 merged, 9968 onChange: () => { 9969 } 9970 }; 9971 }, [variation, base, properties]); 9972 const selectVariation = () => setUserConfig(variation); 9973 const selectOnEnter = (event) => { 9974 if (event.keyCode === import_keycodes3.ENTER) { 9975 event.preventDefault(); 9976 selectVariation(); 9977 } 9978 }; 9979 const isActive = (0, import_element24.useMemo)( 9980 () => areGlobalStylesEqual(user, variation), 9981 [user, variation] 9982 ); 9983 let label = variation?.title; 9984 if (variation?.description) { 9985 label = (0, import_i18n20.sprintf)( 9986 /* translators: 1: variation title. 2: variation description. */ 9987 (0, import_i18n20._x)("%1$s (%2$s)", "variation label"), 9988 variation?.title, 9989 variation?.description 9990 ); 9991 } 9992 const content = /* @__PURE__ */ (0, import_jsx_runtime99.jsx)( 9993 "div", 9994 { 9995 className: clsx_default("global-styles-ui-variations_item", { 9996 "is-active": isActive 9997 }), 9998 role: "button", 9999 onClick: selectVariation, 10000 onKeyDown: selectOnEnter, 10001 tabIndex: 0, 10002 "aria-label": label, 10003 "aria-current": isActive, 10004 onFocus: () => setIsFocused(true), 10005 onBlur: () => setIsFocused(false), 10006 children: /* @__PURE__ */ (0, import_jsx_runtime99.jsx)( 10007 "div", 10008 { 10009 className: clsx_default("global-styles-ui-variations_item-preview", { 10010 "is-pill": isPill 10011 }), 10012 children: children(isFocused) 10013 } 10014 ) 10015 } 10016 ); 10017 return /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(GlobalStylesContext.Provider, { value: context, children: showTooltip ? /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(import_components29.Tooltip, { text: variation?.title, children: content }) : content }); 10018 } 10019 10020 // packages/global-styles-ui/build-module/variations/variations-typography.js 10021 var import_jsx_runtime100 = __toESM(require_jsx_runtime()); 10022 var propertiesToFilter = ["typography"]; 10023 function TypographyVariations({ 10024 title, 10025 gap = 2 10026 }) { 10027 const typographyVariations = useCurrentMergeThemeStyleVariationsWithUserConfig(propertiesToFilter); 10028 if (typographyVariations?.length <= 1) { 10029 return null; 10030 } 10031 return /* @__PURE__ */ (0, import_jsx_runtime100.jsxs)(import_components30.__experimentalVStack, { spacing: 3, children: [ 10032 title && /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(Subtitle, { level: 3, children: title }), 10033 /* @__PURE__ */ (0, import_jsx_runtime100.jsx)( 10034 import_components30.__experimentalGrid, 10035 { 10036 columns: 3, 10037 gap, 10038 className: "global-styles-ui-style-variations-container", 10039 children: typographyVariations.map( 10040 (variation, index) => { 10041 return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)( 10042 Variation, 10043 { 10044 variation, 10045 properties: propertiesToFilter, 10046 showTooltip: true, 10047 children: () => /* @__PURE__ */ (0, import_jsx_runtime100.jsx)( 10048 preview_typography_default, 10049 { 10050 variation 10051 } 10052 ) 10053 }, 10054 index 10055 ); 10056 } 10057 ) 10058 } 10059 ) 10060 ] }); 10061 } 10062 10063 // packages/global-styles-ui/build-module/font-families.js 10064 var import_i18n30 = __toESM(require_i18n()); 10065 var import_components43 = __toESM(require_components()); 10066 var import_element33 = __toESM(require_element()); 10067 10068 // packages/global-styles-ui/build-module/font-library/context.js 10069 var import_element25 = __toESM(require_element()); 10070 var import_data23 = __toESM(require_data()); 10071 var import_core_data18 = __toESM(require_core_data()); 10072 var import_i18n22 = __toESM(require_i18n()); 10073 10074 // packages/global-styles-ui/build-module/font-library/api.js 10075 var import_api_fetch2 = __toESM(require_api_fetch()); 10076 var import_core_data17 = __toESM(require_core_data()); 10077 10078 // packages/global-styles-ui/build-module/font-library/utils/index.js 10079 var import_components31 = __toESM(require_components()); 10080 10081 // packages/global-styles-ui/build-module/font-library/utils/constants.js 10082 var import_i18n21 = __toESM(require_i18n()); 10083 var FONT_WEIGHTS = { 10084 100: (0, import_i18n21._x)("Thin", "font weight"), 10085 200: (0, import_i18n21._x)("Extra-light", "font weight"), 10086 300: (0, import_i18n21._x)("Light", "font weight"), 10087 400: (0, import_i18n21._x)("Normal", "font weight"), 10088 500: (0, import_i18n21._x)("Medium", "font weight"), 10089 600: (0, import_i18n21._x)("Semi-bold", "font weight"), 10090 700: (0, import_i18n21._x)("Bold", "font weight"), 10091 800: (0, import_i18n21._x)("Extra-bold", "font weight"), 10092 900: (0, import_i18n21._x)("Black", "font weight") 10093 }; 10094 var FONT_STYLES = { 10095 normal: (0, import_i18n21._x)("Normal", "font style"), 10096 italic: (0, import_i18n21._x)("Italic", "font style") 10097 }; 10098 10099 // packages/global-styles-ui/build-module/font-library/utils/index.js 10100 var { File } = window; 10101 var { kebabCase: kebabCase2 } = unlock2(import_components31.privateApis); 10102 10103 // packages/global-styles-ui/build-module/font-library/context.js 10104 var import_jsx_runtime101 = __toESM(require_jsx_runtime()); 10105 var FontLibraryContext = (0, import_element25.createContext)( 10106 {} 10107 ); 10108 FontLibraryContext.displayName = "FontLibraryContext"; 10109 10110 // packages/global-styles-ui/build-module/font-library/modal.js 10111 var import_i18n28 = __toESM(require_i18n()); 10112 var import_components41 = __toESM(require_components()); 10113 var import_core_data21 = __toESM(require_core_data()); 10114 var import_data25 = __toESM(require_data()); 10115 10116 // packages/global-styles-ui/build-module/font-library/installed-fonts.js 10117 var import_components35 = __toESM(require_components()); 10118 var import_core_data19 = __toESM(require_core_data()); 10119 var import_data24 = __toESM(require_data()); 10120 var import_element28 = __toESM(require_element()); 10121 var import_i18n24 = __toESM(require_i18n()); 10122 10123 // packages/global-styles-ui/build-module/font-library/font-card.js 10124 var import_i18n23 = __toESM(require_i18n()); 10125 var import_components33 = __toESM(require_components()); 10126 10127 // packages/global-styles-ui/build-module/font-library/font-demo.js 10128 var import_components32 = __toESM(require_components()); 10129 var import_element26 = __toESM(require_element()); 10130 var import_jsx_runtime102 = __toESM(require_jsx_runtime()); 10131 10132 // packages/global-styles-ui/build-module/font-library/font-card.js 10133 var import_jsx_runtime103 = __toESM(require_jsx_runtime()); 10134 10135 // packages/global-styles-ui/build-module/font-library/library-font-variant.js 10136 var import_element27 = __toESM(require_element()); 10137 var import_components34 = __toESM(require_components()); 10138 var import_jsx_runtime104 = __toESM(require_jsx_runtime()); 10139 10140 // packages/global-styles-ui/build-module/font-library/installed-fonts.js 10141 var import_jsx_runtime105 = __toESM(require_jsx_runtime()); 10142 10143 // packages/global-styles-ui/build-module/font-library/font-collection.js 10144 var import_element30 = __toESM(require_element()); 10145 var import_components38 = __toESM(require_components()); 10146 var import_compose5 = __toESM(require_compose()); 10147 var import_i18n26 = __toESM(require_i18n()); 10148 var import_core_data20 = __toESM(require_core_data()); 10149 10150 // packages/global-styles-ui/build-module/font-library/google-fonts-confirm-dialog.js 10151 var import_i18n25 = __toESM(require_i18n()); 10152 var import_components36 = __toESM(require_components()); 10153 var import_jsx_runtime106 = __toESM(require_jsx_runtime()); 10154 10155 // packages/global-styles-ui/build-module/font-library/collection-font-variant.js 10156 var import_element29 = __toESM(require_element()); 10157 var import_components37 = __toESM(require_components()); 10158 var import_jsx_runtime107 = __toESM(require_jsx_runtime()); 10159 10160 // packages/global-styles-ui/build-module/font-library/font-collection.js 10161 var import_jsx_runtime108 = __toESM(require_jsx_runtime()); 10162 var DEFAULT_CATEGORY = { 10163 slug: "all", 10164 name: (0, import_i18n26._x)("All", "font categories") 10165 }; 10166 10167 // packages/global-styles-ui/build-module/font-library/upload-fonts.js 10168 var import_i18n27 = __toESM(require_i18n()); 10169 var import_components40 = __toESM(require_components()); 10170 var import_element31 = __toESM(require_element()); 10171 10172 // packages/global-styles-ui/build-module/font-library/lib/unbrotli.js 10173 var __getOwnPropNames2 = Object.getOwnPropertyNames; 10174 var __require2 = /* @__PURE__ */ ((x2) => typeof __require !== "undefined" ? __require : typeof Proxy !== "undefined" ? new Proxy(x2, { 10175 get: (a2, b2) => (typeof __require !== "undefined" ? __require : a2)[b2] 10176 }) : x2)(function(x2) { 10177 if (typeof __require !== "undefined") return __require.apply(this, arguments); 10178 throw Error('Dynamic require of "' + x2 + '" is not supported'); 10179 }); 10180 var __commonJS2 = (cb, mod) => function __require22() { 10181 return mod || (0, cb[__getOwnPropNames2(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; 10182 }; 10183 var require_unbrotli = __commonJS2({ 10184 "packages/global-styles-ui/src/font-library/lib/unbrotli.js"(exports, module) { 10185 (function(f2) { 10186 if (typeof exports === "object" && typeof module !== "undefined") { 10187 module.exports = f2(); 10188 } else if (typeof define === "function" && define.amd) { 10189 define([], f2); 10190 } else { 10191 var g2; 10192 if (typeof window !== "undefined") { 10193 g2 = window; 10194 } else if (typeof global !== "undefined") { 10195 g2 = global; 10196 } else if (typeof self !== "undefined") { 10197 g2 = self; 10198 } else { 10199 g2 = this; 10200 } 10201 g2.unbrotli = f2(); 10202 } 10203 })(function() { 10204 var define2, module2, exports2; 10205 return (/* @__PURE__ */ (function() { 10206 function r3(e2, n2, t3) { 10207 function o3(i22, f2) { 10208 if (!n2[i22]) { 10209 if (!e2[i22]) { 10210 var c6 = "function" == typeof __require2 && __require2; 10211 if (!f2 && c6) return c6(i22, true); 10212 if (u2) return u2(i22, true); 10213 var a2 = new Error("Cannot find module '" + i22 + "'"); 10214 throw a2.code = "MODULE_NOT_FOUND", a2; 10215 } 10216 var p3 = n2[i22] = { exports: {} }; 10217 e2[i22][0].call( 10218 p3.exports, 10219 function(r22) { 10220 var n22 = e2[i22][1][r22]; 10221 return o3(n22 || r22); 10222 }, 10223 p3, 10224 p3.exports, 10225 r3, 10226 e2, 10227 n2, 10228 t3 10229 ); 10230 } 10231 return n2[i22].exports; 10232 } 10233 for (var u2 = "function" == typeof __require2 && __require2, i2 = 0; i2 < t3.length; i2++) 10234 o3(t3[i2]); 10235 return o3; 10236 } 10237 return r3; 10238 })())( 10239 { 10240 1: [ 10241 function(require2, module3, exports3) { 10242 var BROTLI_READ_SIZE = 4096; 10243 var BROTLI_IBUF_SIZE = 2 * BROTLI_READ_SIZE + 32; 10244 var BROTLI_IBUF_MASK = 2 * BROTLI_READ_SIZE - 1; 10245 var kBitMask = new Uint32Array([ 10246 0, 10247 1, 10248 3, 10249 7, 10250 15, 10251 31, 10252 63, 10253 127, 10254 255, 10255 511, 10256 1023, 10257 2047, 10258 4095, 10259 8191, 10260 16383, 10261 32767, 10262 65535, 10263 131071, 10264 262143, 10265 524287, 10266 1048575, 10267 2097151, 10268 4194303, 10269 8388607, 10270 16777215 10271 ]); 10272 function BrotliBitReader(input) { 10273 this.buf_ = new Uint8Array(BROTLI_IBUF_SIZE); 10274 this.input_ = input; 10275 this.reset(); 10276 } 10277 BrotliBitReader.READ_SIZE = BROTLI_READ_SIZE; 10278 BrotliBitReader.IBUF_MASK = BROTLI_IBUF_MASK; 10279 BrotliBitReader.prototype.reset = function() { 10280 this.buf_ptr_ = 0; 10281 this.val_ = 0; 10282 this.pos_ = 0; 10283 this.bit_pos_ = 0; 10284 this.bit_end_pos_ = 0; 10285 this.eos_ = 0; 10286 this.readMoreInput(); 10287 for (var i2 = 0; i2 < 4; i2++) { 10288 this.val_ |= this.buf_[this.pos_] << 8 * i2; 10289 ++this.pos_; 10290 } 10291 return this.bit_end_pos_ > 0; 10292 }; 10293 BrotliBitReader.prototype.readMoreInput = function() { 10294 if (this.bit_end_pos_ > 256) { 10295 return; 10296 } else if (this.eos_) { 10297 if (this.bit_pos_ > this.bit_end_pos_) 10298 throw new Error( 10299 "Unexpected end of input " + this.bit_pos_ + " " + this.bit_end_pos_ 10300 ); 10301 } else { 10302 var dst = this.buf_ptr_; 10303 var bytes_read = this.input_.read( 10304 this.buf_, 10305 dst, 10306 BROTLI_READ_SIZE 10307 ); 10308 if (bytes_read < 0) { 10309 throw new Error("Unexpected end of input"); 10310 } 10311 if (bytes_read < BROTLI_READ_SIZE) { 10312 this.eos_ = 1; 10313 for (var p3 = 0; p3 < 32; p3++) 10314 this.buf_[dst + bytes_read + p3] = 0; 10315 } 10316 if (dst === 0) { 10317 for (var p3 = 0; p3 < 32; p3++) 10318 this.buf_[(BROTLI_READ_SIZE << 1) + p3] = this.buf_[p3]; 10319 this.buf_ptr_ = BROTLI_READ_SIZE; 10320 } else { 10321 this.buf_ptr_ = 0; 10322 } 10323 this.bit_end_pos_ += bytes_read << 3; 10324 } 10325 }; 10326 BrotliBitReader.prototype.fillBitWindow = function() { 10327 while (this.bit_pos_ >= 8) { 10328 this.val_ >>>= 8; 10329 this.val_ |= this.buf_[this.pos_ & BROTLI_IBUF_MASK] << 24; 10330 ++this.pos_; 10331 this.bit_pos_ = this.bit_pos_ - 8 >>> 0; 10332 this.bit_end_pos_ = this.bit_end_pos_ - 8 >>> 0; 10333 } 10334 }; 10335 BrotliBitReader.prototype.readBits = function(n_bits) { 10336 if (32 - this.bit_pos_ < n_bits) { 10337 this.fillBitWindow(); 10338 } 10339 var val = this.val_ >>> this.bit_pos_ & kBitMask[n_bits]; 10340 this.bit_pos_ += n_bits; 10341 return val; 10342 }; 10343 module3.exports = BrotliBitReader; 10344 }, 10345 {} 10346 ], 10347 2: [ 10348 function(require2, module3, exports3) { 10349 var CONTEXT_LSB6 = 0; 10350 var CONTEXT_MSB6 = 1; 10351 var CONTEXT_UTF8 = 2; 10352 var CONTEXT_SIGNED = 3; 10353 exports3.lookup = new Uint8Array([ 10354 /* CONTEXT_UTF8, last byte. */ 10355 /* ASCII range. */ 10356 0, 10357 0, 10358 0, 10359 0, 10360 0, 10361 0, 10362 0, 10363 0, 10364 0, 10365 4, 10366 4, 10367 0, 10368 0, 10369 4, 10370 0, 10371 0, 10372 0, 10373 0, 10374 0, 10375 0, 10376 0, 10377 0, 10378 0, 10379 0, 10380 0, 10381 0, 10382 0, 10383 0, 10384 0, 10385 0, 10386 0, 10387 0, 10388 8, 10389 12, 10390 16, 10391 12, 10392 12, 10393 20, 10394 12, 10395 16, 10396 24, 10397 28, 10398 12, 10399 12, 10400 32, 10401 12, 10402 36, 10403 12, 10404 44, 10405 44, 10406 44, 10407 44, 10408 44, 10409 44, 10410 44, 10411 44, 10412 44, 10413 44, 10414 32, 10415 32, 10416 24, 10417 40, 10418 28, 10419 12, 10420 12, 10421 48, 10422 52, 10423 52, 10424 52, 10425 48, 10426 52, 10427 52, 10428 52, 10429 48, 10430 52, 10431 52, 10432 52, 10433 52, 10434 52, 10435 48, 10436 52, 10437 52, 10438 52, 10439 52, 10440 52, 10441 48, 10442 52, 10443 52, 10444 52, 10445 52, 10446 52, 10447 24, 10448 12, 10449 28, 10450 12, 10451 12, 10452 12, 10453 56, 10454 60, 10455 60, 10456 60, 10457 56, 10458 60, 10459 60, 10460 60, 10461 56, 10462 60, 10463 60, 10464 60, 10465 60, 10466 60, 10467 56, 10468 60, 10469 60, 10470 60, 10471 60, 10472 60, 10473 56, 10474 60, 10475 60, 10476 60, 10477 60, 10478 60, 10479 24, 10480 12, 10481 28, 10482 12, 10483 0, 10484 /* UTF8 continuation byte range. */ 10485 0, 10486 1, 10487 0, 10488 1, 10489 0, 10490 1, 10491 0, 10492 1, 10493 0, 10494 1, 10495 0, 10496 1, 10497 0, 10498 1, 10499 0, 10500 1, 10501 0, 10502 1, 10503 0, 10504 1, 10505 0, 10506 1, 10507 0, 10508 1, 10509 0, 10510 1, 10511 0, 10512 1, 10513 0, 10514 1, 10515 0, 10516 1, 10517 0, 10518 1, 10519 0, 10520 1, 10521 0, 10522 1, 10523 0, 10524 1, 10525 0, 10526 1, 10527 0, 10528 1, 10529 0, 10530 1, 10531 0, 10532 1, 10533 0, 10534 1, 10535 0, 10536 1, 10537 0, 10538 1, 10539 0, 10540 1, 10541 0, 10542 1, 10543 0, 10544 1, 10545 0, 10546 1, 10547 0, 10548 1, 10549 2, 10550 3, 10551 2, 10552 3, 10553 2, 10554 3, 10555 2, 10556 3, 10557 2, 10558 3, 10559 2, 10560 3, 10561 2, 10562 3, 10563 2, 10564 3, 10565 2, 10566 3, 10567 2, 10568 3, 10569 2, 10570 3, 10571 2, 10572 3, 10573 2, 10574 3, 10575 2, 10576 3, 10577 2, 10578 3, 10579 2, 10580 3, 10581 2, 10582 3, 10583 2, 10584 3, 10585 2, 10586 3, 10587 2, 10588 3, 10589 2, 10590 3, 10591 2, 10592 3, 10593 2, 10594 3, 10595 2, 10596 3, 10597 2, 10598 3, 10599 2, 10600 3, 10601 2, 10602 3, 10603 2, 10604 3, 10605 2, 10606 3, 10607 2, 10608 3, 10609 2, 10610 3, 10611 2, 10612 3, 10613 /* ASCII range. */ 10614 0, 10615 0, 10616 0, 10617 0, 10618 0, 10619 0, 10620 0, 10621 0, 10622 0, 10623 0, 10624 0, 10625 0, 10626 0, 10627 0, 10628 0, 10629 0, 10630 0, 10631 0, 10632 0, 10633 0, 10634 0, 10635 0, 10636 0, 10637 0, 10638 0, 10639 0, 10640 0, 10641 0, 10642 0, 10643 0, 10644 0, 10645 0, 10646 0, 10647 1, 10648 1, 10649 1, 10650 1, 10651 1, 10652 1, 10653 1, 10654 1, 10655 1, 10656 1, 10657 1, 10658 1, 10659 1, 10660 1, 10661 1, 10662 2, 10663 2, 10664 2, 10665 2, 10666 2, 10667 2, 10668 2, 10669 2, 10670 2, 10671 2, 10672 1, 10673 1, 10674 1, 10675 1, 10676 1, 10677 1, 10678 1, 10679 2, 10680 2, 10681 2, 10682 2, 10683 2, 10684 2, 10685 2, 10686 2, 10687 2, 10688 2, 10689 2, 10690 2, 10691 2, 10692 2, 10693 2, 10694 2, 10695 2, 10696 2, 10697 2, 10698 2, 10699 2, 10700 2, 10701 2, 10702 2, 10703 2, 10704 2, 10705 1, 10706 1, 10707 1, 10708 1, 10709 1, 10710 1, 10711 3, 10712 3, 10713 3, 10714 3, 10715 3, 10716 3, 10717 3, 10718 3, 10719 3, 10720 3, 10721 3, 10722 3, 10723 3, 10724 3, 10725 3, 10726 3, 10727 3, 10728 3, 10729 3, 10730 3, 10731 3, 10732 3, 10733 3, 10734 3, 10735 3, 10736 3, 10737 1, 10738 1, 10739 1, 10740 1, 10741 0, 10742 /* UTF8 continuation byte range. */ 10743 0, 10744 0, 10745 0, 10746 0, 10747 0, 10748 0, 10749 0, 10750 0, 10751 0, 10752 0, 10753 0, 10754 0, 10755 0, 10756 0, 10757 0, 10758 0, 10759 0, 10760 0, 10761 0, 10762 0, 10763 0, 10764 0, 10765 0, 10766 0, 10767 0, 10768 0, 10769 0, 10770 0, 10771 0, 10772 0, 10773 0, 10774 0, 10775 0, 10776 0, 10777 0, 10778 0, 10779 0, 10780 0, 10781 0, 10782 0, 10783 0, 10784 0, 10785 0, 10786 0, 10787 0, 10788 0, 10789 0, 10790 0, 10791 0, 10792 0, 10793 0, 10794 0, 10795 0, 10796 0, 10797 0, 10798 0, 10799 0, 10800 0, 10801 0, 10802 0, 10803 0, 10804 0, 10805 0, 10806 0, 10807 0, 10808 0, 10809 0, 10810 0, 10811 0, 10812 0, 10813 0, 10814 0, 10815 0, 10816 0, 10817 0, 10818 0, 10819 0, 10820 0, 10821 0, 10822 0, 10823 0, 10824 0, 10825 0, 10826 0, 10827 0, 10828 0, 10829 0, 10830 0, 10831 0, 10832 0, 10833 0, 10834 0, 10835 0, 10836 0, 10837 0, 10838 0, 10839 2, 10840 2, 10841 2, 10842 2, 10843 2, 10844 2, 10845 2, 10846 2, 10847 2, 10848 2, 10849 2, 10850 2, 10851 2, 10852 2, 10853 2, 10854 2, 10855 2, 10856 2, 10857 2, 10858 2, 10859 2, 10860 2, 10861 2, 10862 2, 10863 2, 10864 2, 10865 2, 10866 2, 10867 2, 10868 2, 10869 2, 10870 2, 10871 0, 10872 1, 10873 1, 10874 1, 10875 1, 10876 1, 10877 1, 10878 1, 10879 1, 10880 1, 10881 1, 10882 1, 10883 1, 10884 1, 10885 1, 10886 1, 10887 2, 10888 2, 10889 2, 10890 2, 10891 2, 10892 2, 10893 2, 10894 2, 10895 2, 10896 2, 10897 2, 10898 2, 10899 2, 10900 2, 10901 2, 10902 2, 10903 2, 10904 2, 10905 2, 10906 2, 10907 2, 10908 2, 10909 2, 10910 2, 10911 2, 10912 2, 10913 2, 10914 2, 10915 2, 10916 2, 10917 2, 10918 2, 10919 2, 10920 2, 10921 2, 10922 2, 10923 2, 10924 2, 10925 2, 10926 2, 10927 2, 10928 2, 10929 2, 10930 2, 10931 2, 10932 2, 10933 2, 10934 2, 10935 3, 10936 3, 10937 3, 10938 3, 10939 3, 10940 3, 10941 3, 10942 3, 10943 3, 10944 3, 10945 3, 10946 3, 10947 3, 10948 3, 10949 3, 10950 3, 10951 3, 10952 3, 10953 3, 10954 3, 10955 3, 10956 3, 10957 3, 10958 3, 10959 3, 10960 3, 10961 3, 10962 3, 10963 3, 10964 3, 10965 3, 10966 3, 10967 3, 10968 3, 10969 3, 10970 3, 10971 3, 10972 3, 10973 3, 10974 3, 10975 3, 10976 3, 10977 3, 10978 3, 10979 3, 10980 3, 10981 3, 10982 3, 10983 3, 10984 3, 10985 3, 10986 3, 10987 3, 10988 3, 10989 3, 10990 3, 10991 3, 10992 3, 10993 3, 10994 3, 10995 3, 10996 3, 10997 3, 10998 3, 10999 4, 11000 4, 11001 4, 11002 4, 11003 4, 11004 4, 11005 4, 11006 4, 11007 4, 11008 4, 11009 4, 11010 4, 11011 4, 11012 4, 11013 4, 11014 4, 11015 4, 11016 4, 11017 4, 11018 4, 11019 4, 11020 4, 11021 4, 11022 4, 11023 4, 11024 4, 11025 4, 11026 4, 11027 4, 11028 4, 11029 4, 11030 4, 11031 4, 11032 4, 11033 4, 11034 4, 11035 4, 11036 4, 11037 4, 11038 4, 11039 4, 11040 4, 11041 4, 11042 4, 11043 4, 11044 4, 11045 4, 11046 4, 11047 4, 11048 4, 11049 4, 11050 4, 11051 4, 11052 4, 11053 4, 11054 4, 11055 4, 11056 4, 11057 4, 11058 4, 11059 4, 11060 4, 11061 4, 11062 4, 11063 5, 11064 5, 11065 5, 11066 5, 11067 5, 11068 5, 11069 5, 11070 5, 11071 5, 11072 5, 11073 5, 11074 5, 11075 5, 11076 5, 11077 5, 11078 5, 11079 5, 11080 5, 11081 5, 11082 5, 11083 5, 11084 5, 11085 5, 11086 5, 11087 5, 11088 5, 11089 5, 11090 5, 11091 5, 11092 5, 11093 5, 11094 5, 11095 5, 11096 5, 11097 5, 11098 5, 11099 5, 11100 5, 11101 5, 11102 5, 11103 5, 11104 5, 11105 5, 11106 5, 11107 5, 11108 5, 11109 5, 11110 5, 11111 6, 11112 6, 11113 6, 11114 6, 11115 6, 11116 6, 11117 6, 11118 6, 11119 6, 11120 6, 11121 6, 11122 6, 11123 6, 11124 6, 11125 6, 11126 7, 11127 /* CONTEXT_SIGNED, last byte, same as the above values shifted by 3 bits. */ 11128 0, 11129 8, 11130 8, 11131 8, 11132 8, 11133 8, 11134 8, 11135 8, 11136 8, 11137 8, 11138 8, 11139 8, 11140 8, 11141 8, 11142 8, 11143 8, 11144 16, 11145 16, 11146 16, 11147 16, 11148 16, 11149 16, 11150 16, 11151 16, 11152 16, 11153 16, 11154 16, 11155 16, 11156 16, 11157 16, 11158 16, 11159 16, 11160 16, 11161 16, 11162 16, 11163 16, 11164 16, 11165 16, 11166 16, 11167 16, 11168 16, 11169 16, 11170 16, 11171 16, 11172 16, 11173 16, 11174 16, 11175 16, 11176 16, 11177 16, 11178 16, 11179 16, 11180 16, 11181 16, 11182 16, 11183 16, 11184 16, 11185 16, 11186 16, 11187 16, 11188 16, 11189 16, 11190 16, 11191 16, 11192 24, 11193 24, 11194 24, 11195 24, 11196 24, 11197 24, 11198 24, 11199 24, 11200 24, 11201 24, 11202 24, 11203 24, 11204 24, 11205 24, 11206 24, 11207 24, 11208 24, 11209 24, 11210 24, 11211 24, 11212 24, 11213 24, 11214 24, 11215 24, 11216 24, 11217 24, 11218 24, 11219 24, 11220 24, 11221 24, 11222 24, 11223 24, 11224 24, 11225 24, 11226 24, 11227 24, 11228 24, 11229 24, 11230 24, 11231 24, 11232 24, 11233 24, 11234 24, 11235 24, 11236 24, 11237 24, 11238 24, 11239 24, 11240 24, 11241 24, 11242 24, 11243 24, 11244 24, 11245 24, 11246 24, 11247 24, 11248 24, 11249 24, 11250 24, 11251 24, 11252 24, 11253 24, 11254 24, 11255 24, 11256 32, 11257 32, 11258 32, 11259 32, 11260 32, 11261 32, 11262 32, 11263 32, 11264 32, 11265 32, 11266 32, 11267 32, 11268 32, 11269 32, 11270 32, 11271 32, 11272 32, 11273 32, 11274 32, 11275 32, 11276 32, 11277 32, 11278 32, 11279 32, 11280 32, 11281 32, 11282 32, 11283 32, 11284 32, 11285 32, 11286 32, 11287 32, 11288 32, 11289 32, 11290 32, 11291 32, 11292 32, 11293 32, 11294 32, 11295 32, 11296 32, 11297 32, 11298 32, 11299 32, 11300 32, 11301 32, 11302 32, 11303 32, 11304 32, 11305 32, 11306 32, 11307 32, 11308 32, 11309 32, 11310 32, 11311 32, 11312 32, 11313 32, 11314 32, 11315 32, 11316 32, 11317 32, 11318 32, 11319 32, 11320 40, 11321 40, 11322 40, 11323 40, 11324 40, 11325 40, 11326 40, 11327 40, 11328 40, 11329 40, 11330 40, 11331 40, 11332 40, 11333 40, 11334 40, 11335 40, 11336 40, 11337 40, 11338 40, 11339 40, 11340 40, 11341 40, 11342 40, 11343 40, 11344 40, 11345 40, 11346 40, 11347 40, 11348 40, 11349 40, 11350 40, 11351 40, 11352 40, 11353 40, 11354 40, 11355 40, 11356 40, 11357 40, 11358 40, 11359 40, 11360 40, 11361 40, 11362 40, 11363 40, 11364 40, 11365 40, 11366 40, 11367 40, 11368 48, 11369 48, 11370 48, 11371 48, 11372 48, 11373 48, 11374 48, 11375 48, 11376 48, 11377 48, 11378 48, 11379 48, 11380 48, 11381 48, 11382 48, 11383 56, 11384 /* CONTEXT_LSB6, last byte. */ 11385 0, 11386 1, 11387 2, 11388 3, 11389 4, 11390 5, 11391 6, 11392 7, 11393 8, 11394 9, 11395 10, 11396 11, 11397 12, 11398 13, 11399 14, 11400 15, 11401 16, 11402 17, 11403 18, 11404 19, 11405 20, 11406 21, 11407 22, 11408 23, 11409 24, 11410 25, 11411 26, 11412 27, 11413 28, 11414 29, 11415 30, 11416 31, 11417 32, 11418 33, 11419 34, 11420 35, 11421 36, 11422 37, 11423 38, 11424 39, 11425 40, 11426 41, 11427 42, 11428 43, 11429 44, 11430 45, 11431 46, 11432 47, 11433 48, 11434 49, 11435 50, 11436 51, 11437 52, 11438 53, 11439 54, 11440 55, 11441 56, 11442 57, 11443 58, 11444 59, 11445 60, 11446 61, 11447 62, 11448 63, 11449 0, 11450 1, 11451 2, 11452 3, 11453 4, 11454 5, 11455 6, 11456 7, 11457 8, 11458 9, 11459 10, 11460 11, 11461 12, 11462 13, 11463 14, 11464 15, 11465 16, 11466 17, 11467 18, 11468 19, 11469 20, 11470 21, 11471 22, 11472 23, 11473 24, 11474 25, 11475 26, 11476 27, 11477 28, 11478 29, 11479 30, 11480 31, 11481 32, 11482 33, 11483 34, 11484 35, 11485 36, 11486 37, 11487 38, 11488 39, 11489 40, 11490 41, 11491 42, 11492 43, 11493 44, 11494 45, 11495 46, 11496 47, 11497 48, 11498 49, 11499 50, 11500 51, 11501 52, 11502 53, 11503 54, 11504 55, 11505 56, 11506 57, 11507 58, 11508 59, 11509 60, 11510 61, 11511 62, 11512 63, 11513 0, 11514 1, 11515 2, 11516 3, 11517 4, 11518 5, 11519 6, 11520 7, 11521 8, 11522 9, 11523 10, 11524 11, 11525 12, 11526 13, 11527 14, 11528 15, 11529 16, 11530 17, 11531 18, 11532 19, 11533 20, 11534 21, 11535 22, 11536 23, 11537 24, 11538 25, 11539 26, 11540 27, 11541 28, 11542 29, 11543 30, 11544 31, 11545 32, 11546 33, 11547 34, 11548 35, 11549 36, 11550 37, 11551 38, 11552 39, 11553 40, 11554 41, 11555 42, 11556 43, 11557 44, 11558 45, 11559 46, 11560 47, 11561 48, 11562 49, 11563 50, 11564 51, 11565 52, 11566 53, 11567 54, 11568 55, 11569 56, 11570 57, 11571 58, 11572 59, 11573 60, 11574 61, 11575 62, 11576 63, 11577 0, 11578 1, 11579 2, 11580 3, 11581 4, 11582 5, 11583 6, 11584 7, 11585 8, 11586 9, 11587 10, 11588 11, 11589 12, 11590 13, 11591 14, 11592 15, 11593 16, 11594 17, 11595 18, 11596 19, 11597 20, 11598 21, 11599 22, 11600 23, 11601 24, 11602 25, 11603 26, 11604 27, 11605 28, 11606 29, 11607 30, 11608 31, 11609 32, 11610 33, 11611 34, 11612 35, 11613 36, 11614 37, 11615 38, 11616 39, 11617 40, 11618 41, 11619 42, 11620 43, 11621 44, 11622 45, 11623 46, 11624 47, 11625 48, 11626 49, 11627 50, 11628 51, 11629 52, 11630 53, 11631 54, 11632 55, 11633 56, 11634 57, 11635 58, 11636 59, 11637 60, 11638 61, 11639 62, 11640 63, 11641 /* CONTEXT_MSB6, last byte. */ 11642 0, 11643 0, 11644 0, 11645 0, 11646 1, 11647 1, 11648 1, 11649 1, 11650 2, 11651 2, 11652 2, 11653 2, 11654 3, 11655 3, 11656 3, 11657 3, 11658 4, 11659 4, 11660 4, 11661 4, 11662 5, 11663 5, 11664 5, 11665 5, 11666 6, 11667 6, 11668 6, 11669 6, 11670 7, 11671 7, 11672 7, 11673 7, 11674 8, 11675 8, 11676 8, 11677 8, 11678 9, 11679 9, 11680 9, 11681 9, 11682 10, 11683 10, 11684 10, 11685 10, 11686 11, 11687 11, 11688 11, 11689 11, 11690 12, 11691 12, 11692 12, 11693 12, 11694 13, 11695 13, 11696 13, 11697 13, 11698 14, 11699 14, 11700 14, 11701 14, 11702 15, 11703 15, 11704 15, 11705 15, 11706 16, 11707 16, 11708 16, 11709 16, 11710 17, 11711 17, 11712 17, 11713 17, 11714 18, 11715 18, 11716 18, 11717 18, 11718 19, 11719 19, 11720 19, 11721 19, 11722 20, 11723 20, 11724 20, 11725 20, 11726 21, 11727 21, 11728 21, 11729 21, 11730 22, 11731 22, 11732 22, 11733 22, 11734 23, 11735 23, 11736 23, 11737 23, 11738 24, 11739 24, 11740 24, 11741 24, 11742 25, 11743 25, 11744 25, 11745 25, 11746 26, 11747 26, 11748 26, 11749 26, 11750 27, 11751 27, 11752 27, 11753 27, 11754 28, 11755 28, 11756 28, 11757 28, 11758 29, 11759 29, 11760 29, 11761 29, 11762 30, 11763 30, 11764 30, 11765 30, 11766 31, 11767 31, 11768 31, 11769 31, 11770 32, 11771 32, 11772 32, 11773 32, 11774 33, 11775 33, 11776 33, 11777 33, 11778 34, 11779 34, 11780 34, 11781 34, 11782 35, 11783 35, 11784 35, 11785 35, 11786 36, 11787 36, 11788 36, 11789 36, 11790 37, 11791 37, 11792 37, 11793 37, 11794 38, 11795 38, 11796 38, 11797 38, 11798 39, 11799 39, 11800 39, 11801 39, 11802 40, 11803 40, 11804 40, 11805 40, 11806 41, 11807 41, 11808 41, 11809 41, 11810 42, 11811 42, 11812 42, 11813 42, 11814 43, 11815 43, 11816 43, 11817 43, 11818 44, 11819 44, 11820 44, 11821 44, 11822 45, 11823 45, 11824 45, 11825 45, 11826 46, 11827 46, 11828 46, 11829 46, 11830 47, 11831 47, 11832 47, 11833 47, 11834 48, 11835 48, 11836 48, 11837 48, 11838 49, 11839 49, 11840 49, 11841 49, 11842 50, 11843 50, 11844 50, 11845 50, 11846 51, 11847 51, 11848 51, 11849 51, 11850 52, 11851 52, 11852 52, 11853 52, 11854 53, 11855 53, 11856 53, 11857 53, 11858 54, 11859 54, 11860 54, 11861 54, 11862 55, 11863 55, 11864 55, 11865 55, 11866 56, 11867 56, 11868 56, 11869 56, 11870 57, 11871 57, 11872 57, 11873 57, 11874 58, 11875 58, 11876 58, 11877 58, 11878 59, 11879 59, 11880 59, 11881 59, 11882 60, 11883 60, 11884 60, 11885 60, 11886 61, 11887 61, 11888 61, 11889 61, 11890 62, 11891 62, 11892 62, 11893 62, 11894 63, 11895 63, 11896 63, 11897 63, 11898 /* CONTEXT_{M,L}SB6, second last byte, */ 11899 0, 11900 0, 11901 0, 11902 0, 11903 0, 11904 0, 11905 0, 11906 0, 11907 0, 11908 0, 11909 0, 11910 0, 11911 0, 11912 0, 11913 0, 11914 0, 11915 0, 11916 0, 11917 0, 11918 0, 11919 0, 11920 0, 11921 0, 11922 0, 11923 0, 11924 0, 11925 0, 11926 0, 11927 0, 11928 0, 11929 0, 11930 0, 11931 0, 11932 0, 11933 0, 11934 0, 11935 0, 11936 0, 11937 0, 11938 0, 11939 0, 11940 0, 11941 0, 11942 0, 11943 0, 11944 0, 11945 0, 11946 0, 11947 0, 11948 0, 11949 0, 11950 0, 11951 0, 11952 0, 11953 0, 11954 0, 11955 0, 11956 0, 11957 0, 11958 0, 11959 0, 11960 0, 11961 0, 11962 0, 11963 0, 11964 0, 11965 0, 11966 0, 11967 0, 11968 0, 11969 0, 11970 0, 11971 0, 11972 0, 11973 0, 11974 0, 11975 0, 11976 0, 11977 0, 11978 0, 11979 0, 11980 0, 11981 0, 11982 0, 11983 0, 11984 0, 11985 0, 11986 0, 11987 0, 11988 0, 11989 0, 11990 0, 11991 0, 11992 0, 11993 0, 11994 0, 11995 0, 11996 0, 11997 0, 11998 0, 11999 0, 12000 0, 12001 0, 12002 0, 12003 0, 12004 0, 12005 0, 12006 0, 12007 0, 12008 0, 12009 0, 12010 0, 12011 0, 12012 0, 12013 0, 12014 0, 12015 0, 12016 0, 12017 0, 12018 0, 12019 0, 12020 0, 12021 0, 12022 0, 12023 0, 12024 0, 12025 0, 12026 0, 12027 0, 12028 0, 12029 0, 12030 0, 12031 0, 12032 0, 12033 0, 12034 0, 12035 0, 12036 0, 12037 0, 12038 0, 12039 0, 12040 0, 12041 0, 12042 0, 12043 0, 12044 0, 12045 0, 12046 0, 12047 0, 12048 0, 12049 0, 12050 0, 12051 0, 12052 0, 12053 0, 12054 0, 12055 0, 12056 0, 12057 0, 12058 0, 12059 0, 12060 0, 12061 0, 12062 0, 12063 0, 12064 0, 12065 0, 12066 0, 12067 0, 12068 0, 12069 0, 12070 0, 12071 0, 12072 0, 12073 0, 12074 0, 12075 0, 12076 0, 12077 0, 12078 0, 12079 0, 12080 0, 12081 0, 12082 0, 12083 0, 12084 0, 12085 0, 12086 0, 12087 0, 12088 0, 12089 0, 12090 0, 12091 0, 12092 0, 12093 0, 12094 0, 12095 0, 12096 0, 12097 0, 12098 0, 12099 0, 12100 0, 12101 0, 12102 0, 12103 0, 12104 0, 12105 0, 12106 0, 12107 0, 12108 0, 12109 0, 12110 0, 12111 0, 12112 0, 12113 0, 12114 0, 12115 0, 12116 0, 12117 0, 12118 0, 12119 0, 12120 0, 12121 0, 12122 0, 12123 0, 12124 0, 12125 0, 12126 0, 12127 0, 12128 0, 12129 0, 12130 0, 12131 0, 12132 0, 12133 0, 12134 0, 12135 0, 12136 0, 12137 0, 12138 0, 12139 0, 12140 0, 12141 0, 12142 0, 12143 0, 12144 0, 12145 0, 12146 0, 12147 0, 12148 0, 12149 0, 12150 0, 12151 0, 12152 0, 12153 0, 12154 0 12155 ]); 12156 exports3.lookupOffsets = new Uint16Array([ 12157 /* CONTEXT_LSB6 */ 12158 1024, 12159 1536, 12160 1280, 12161 1536, 12162 0, 12163 256, 12164 768, 12165 512 12166 ]); 12167 }, 12168 {} 12169 ], 12170 3: [ 12171 function(require2, module3, exports3) { 12172 var BrotliInput = require2("./streams").BrotliInput; 12173 var BrotliOutput = require2("./streams").BrotliOutput; 12174 var BrotliBitReader = require2("./bit_reader"); 12175 var BrotliDictionary = require2("./dictionary"); 12176 var HuffmanCode = require2("./huffman").HuffmanCode; 12177 var BrotliBuildHuffmanTable = require2("./huffman").BrotliBuildHuffmanTable; 12178 var Context = require2("./context"); 12179 var Prefix = require2("./prefix"); 12180 var Transform = require2("./transform"); 12181 var kDefaultCodeLength = 8; 12182 var kCodeLengthRepeatCode = 16; 12183 var kNumLiteralCodes = 256; 12184 var kNumInsertAndCopyCodes = 704; 12185 var kNumBlockLengthCodes = 26; 12186 var kLiteralContextBits = 6; 12187 var kDistanceContextBits = 2; 12188 var HUFFMAN_TABLE_BITS = 8; 12189 var HUFFMAN_TABLE_MASK = 255; 12190 var HUFFMAN_MAX_TABLE_SIZE = 1080; 12191 var CODE_LENGTH_CODES = 18; 12192 var kCodeLengthCodeOrder = new Uint8Array([ 12193 1, 12194 2, 12195 3, 12196 4, 12197 0, 12198 5, 12199 17, 12200 6, 12201 16, 12202 7, 12203 8, 12204 9, 12205 10, 12206 11, 12207 12, 12208 13, 12209 14, 12210 15 12211 ]); 12212 var NUM_DISTANCE_SHORT_CODES = 16; 12213 var kDistanceShortCodeIndexOffset = new Uint8Array([ 12214 3, 12215 2, 12216 1, 12217 0, 12218 3, 12219 3, 12220 3, 12221 3, 12222 3, 12223 3, 12224 2, 12225 2, 12226 2, 12227 2, 12228 2, 12229 2 12230 ]); 12231 var kDistanceShortCodeValueOffset = new Int8Array([ 12232 0, 12233 0, 12234 0, 12235 0, 12236 -1, 12237 1, 12238 -2, 12239 2, 12240 -3, 12241 3, 12242 -1, 12243 1, 12244 -2, 12245 2, 12246 -3, 12247 3 12248 ]); 12249 var kMaxHuffmanTableSize = new Uint16Array([ 12250 256, 12251 402, 12252 436, 12253 468, 12254 500, 12255 534, 12256 566, 12257 598, 12258 630, 12259 662, 12260 694, 12261 726, 12262 758, 12263 790, 12264 822, 12265 854, 12266 886, 12267 920, 12268 952, 12269 984, 12270 1016, 12271 1048, 12272 1080 12273 ]); 12274 function DecodeWindowBits(br) { 12275 var n2; 12276 if (br.readBits(1) === 0) { 12277 return 16; 12278 } 12279 n2 = br.readBits(3); 12280 if (n2 > 0) { 12281 return 17 + n2; 12282 } 12283 n2 = br.readBits(3); 12284 if (n2 > 0) { 12285 return 8 + n2; 12286 } 12287 return 17; 12288 } 12289 function DecodeVarLenUint8(br) { 12290 if (br.readBits(1)) { 12291 var nbits = br.readBits(3); 12292 if (nbits === 0) { 12293 return 1; 12294 } else { 12295 return br.readBits(nbits) + (1 << nbits); 12296 } 12297 } 12298 return 0; 12299 } 12300 function MetaBlockLength() { 12301 this.meta_block_length = 0; 12302 this.input_end = 0; 12303 this.is_uncompressed = 0; 12304 this.is_metadata = false; 12305 } 12306 function DecodeMetaBlockLength(br) { 12307 var out = new MetaBlockLength(); 12308 var size_nibbles; 12309 var size_bytes; 12310 var i2; 12311 out.input_end = br.readBits(1); 12312 if (out.input_end && br.readBits(1)) { 12313 return out; 12314 } 12315 size_nibbles = br.readBits(2) + 4; 12316 if (size_nibbles === 7) { 12317 out.is_metadata = true; 12318 if (br.readBits(1) !== 0) 12319 throw new Error("Invalid reserved bit"); 12320 size_bytes = br.readBits(2); 12321 if (size_bytes === 0) return out; 12322 for (i2 = 0; i2 < size_bytes; i2++) { 12323 var next_byte = br.readBits(8); 12324 if (i2 + 1 === size_bytes && size_bytes > 1 && next_byte === 0) 12325 throw new Error("Invalid size byte"); 12326 out.meta_block_length |= next_byte << i2 * 8; 12327 } 12328 } else { 12329 for (i2 = 0; i2 < size_nibbles; ++i2) { 12330 var next_nibble = br.readBits(4); 12331 if (i2 + 1 === size_nibbles && size_nibbles > 4 && next_nibble === 0) 12332 throw new Error("Invalid size nibble"); 12333 out.meta_block_length |= next_nibble << i2 * 4; 12334 } 12335 } 12336 ++out.meta_block_length; 12337 if (!out.input_end && !out.is_metadata) { 12338 out.is_uncompressed = br.readBits(1); 12339 } 12340 return out; 12341 } 12342 function ReadSymbol(table, index, br) { 12343 var start_index = index; 12344 var nbits; 12345 br.fillBitWindow(); 12346 index += br.val_ >>> br.bit_pos_ & HUFFMAN_TABLE_MASK; 12347 nbits = table[index].bits - HUFFMAN_TABLE_BITS; 12348 if (nbits > 0) { 12349 br.bit_pos_ += HUFFMAN_TABLE_BITS; 12350 index += table[index].value; 12351 index += br.val_ >>> br.bit_pos_ & (1 << nbits) - 1; 12352 } 12353 br.bit_pos_ += table[index].bits; 12354 return table[index].value; 12355 } 12356 function ReadHuffmanCodeLengths(code_length_code_lengths, num_symbols, code_lengths, br) { 12357 var symbol3 = 0; 12358 var prev_code_len = kDefaultCodeLength; 12359 var repeat = 0; 12360 var repeat_code_len = 0; 12361 var space = 32768; 12362 var table = []; 12363 for (var i2 = 0; i2 < 32; i2++) 12364 table.push(new HuffmanCode(0, 0)); 12365 BrotliBuildHuffmanTable( 12366 table, 12367 0, 12368 5, 12369 code_length_code_lengths, 12370 CODE_LENGTH_CODES 12371 ); 12372 while (symbol3 < num_symbols && space > 0) { 12373 var p3 = 0; 12374 var code_len; 12375 br.readMoreInput(); 12376 br.fillBitWindow(); 12377 p3 += br.val_ >>> br.bit_pos_ & 31; 12378 br.bit_pos_ += table[p3].bits; 12379 code_len = table[p3].value & 255; 12380 if (code_len < kCodeLengthRepeatCode) { 12381 repeat = 0; 12382 code_lengths[symbol3++] = code_len; 12383 if (code_len !== 0) { 12384 prev_code_len = code_len; 12385 space -= 32768 >> code_len; 12386 } 12387 } else { 12388 var extra_bits = code_len - 14; 12389 var old_repeat; 12390 var repeat_delta; 12391 var new_len = 0; 12392 if (code_len === kCodeLengthRepeatCode) { 12393 new_len = prev_code_len; 12394 } 12395 if (repeat_code_len !== new_len) { 12396 repeat = 0; 12397 repeat_code_len = new_len; 12398 } 12399 old_repeat = repeat; 12400 if (repeat > 0) { 12401 repeat -= 2; 12402 repeat <<= extra_bits; 12403 } 12404 repeat += br.readBits(extra_bits) + 3; 12405 repeat_delta = repeat - old_repeat; 12406 if (symbol3 + repeat_delta > num_symbols) { 12407 throw new Error( 12408 "[ReadHuffmanCodeLengths] symbol + repeat_delta > num_symbols" 12409 ); 12410 } 12411 for (var x2 = 0; x2 < repeat_delta; x2++) 12412 code_lengths[symbol3 + x2] = repeat_code_len; 12413 symbol3 += repeat_delta; 12414 if (repeat_code_len !== 0) { 12415 space -= repeat_delta << 15 - repeat_code_len; 12416 } 12417 } 12418 } 12419 if (space !== 0) { 12420 throw new Error( 12421 "[ReadHuffmanCodeLengths] space = " + space 12422 ); 12423 } 12424 for (; symbol3 < num_symbols; symbol3++) 12425 code_lengths[symbol3] = 0; 12426 } 12427 function ReadHuffmanCode(alphabet_size, tables, table, br) { 12428 var table_size = 0; 12429 var simple_code_or_skip; 12430 var code_lengths = new Uint8Array(alphabet_size); 12431 br.readMoreInput(); 12432 simple_code_or_skip = br.readBits(2); 12433 if (simple_code_or_skip === 1) { 12434 var i2; 12435 var max_bits_counter = alphabet_size - 1; 12436 var max_bits = 0; 12437 var symbols = new Int32Array(4); 12438 var num_symbols = br.readBits(2) + 1; 12439 while (max_bits_counter) { 12440 max_bits_counter >>= 1; 12441 ++max_bits; 12442 } 12443 for (i2 = 0; i2 < num_symbols; ++i2) { 12444 symbols[i2] = br.readBits(max_bits) % alphabet_size; 12445 code_lengths[symbols[i2]] = 2; 12446 } 12447 code_lengths[symbols[0]] = 1; 12448 switch (num_symbols) { 12449 case 1: 12450 break; 12451 case 3: 12452 if (symbols[0] === symbols[1] || symbols[0] === symbols[2] || symbols[1] === symbols[2]) { 12453 throw new Error( 12454 "[ReadHuffmanCode] invalid symbols" 12455 ); 12456 } 12457 break; 12458 case 2: 12459 if (symbols[0] === symbols[1]) { 12460 throw new Error( 12461 "[ReadHuffmanCode] invalid symbols" 12462 ); 12463 } 12464 code_lengths[symbols[1]] = 1; 12465 break; 12466 case 4: 12467 if (symbols[0] === symbols[1] || symbols[0] === symbols[2] || symbols[0] === symbols[3] || symbols[1] === symbols[2] || symbols[1] === symbols[3] || symbols[2] === symbols[3]) { 12468 throw new Error( 12469 "[ReadHuffmanCode] invalid symbols" 12470 ); 12471 } 12472 if (br.readBits(1)) { 12473 code_lengths[symbols[2]] = 3; 12474 code_lengths[symbols[3]] = 3; 12475 } else { 12476 code_lengths[symbols[0]] = 2; 12477 } 12478 break; 12479 } 12480 } else { 12481 var i2; 12482 var code_length_code_lengths = new Uint8Array( 12483 CODE_LENGTH_CODES 12484 ); 12485 var space = 32; 12486 var num_codes = 0; 12487 var huff = [ 12488 new HuffmanCode(2, 0), 12489 new HuffmanCode(2, 4), 12490 new HuffmanCode(2, 3), 12491 new HuffmanCode(3, 2), 12492 new HuffmanCode(2, 0), 12493 new HuffmanCode(2, 4), 12494 new HuffmanCode(2, 3), 12495 new HuffmanCode(4, 1), 12496 new HuffmanCode(2, 0), 12497 new HuffmanCode(2, 4), 12498 new HuffmanCode(2, 3), 12499 new HuffmanCode(3, 2), 12500 new HuffmanCode(2, 0), 12501 new HuffmanCode(2, 4), 12502 new HuffmanCode(2, 3), 12503 new HuffmanCode(4, 5) 12504 ]; 12505 for (i2 = simple_code_or_skip; i2 < CODE_LENGTH_CODES && space > 0; ++i2) { 12506 var code_len_idx = kCodeLengthCodeOrder[i2]; 12507 var p3 = 0; 12508 var v2; 12509 br.fillBitWindow(); 12510 p3 += br.val_ >>> br.bit_pos_ & 15; 12511 br.bit_pos_ += huff[p3].bits; 12512 v2 = huff[p3].value; 12513 code_length_code_lengths[code_len_idx] = v2; 12514 if (v2 !== 0) { 12515 space -= 32 >> v2; 12516 ++num_codes; 12517 } 12518 } 12519 if (!(num_codes === 1 || space === 0)) 12520 throw new Error( 12521 "[ReadHuffmanCode] invalid num_codes or space" 12522 ); 12523 ReadHuffmanCodeLengths( 12524 code_length_code_lengths, 12525 alphabet_size, 12526 code_lengths, 12527 br 12528 ); 12529 } 12530 table_size = BrotliBuildHuffmanTable( 12531 tables, 12532 table, 12533 HUFFMAN_TABLE_BITS, 12534 code_lengths, 12535 alphabet_size 12536 ); 12537 if (table_size === 0) { 12538 throw new Error( 12539 "[ReadHuffmanCode] BuildHuffmanTable failed: " 12540 ); 12541 } 12542 return table_size; 12543 } 12544 function ReadBlockLength(table, index, br) { 12545 var code; 12546 var nbits; 12547 code = ReadSymbol(table, index, br); 12548 nbits = Prefix.kBlockLengthPrefixCode[code].nbits; 12549 return Prefix.kBlockLengthPrefixCode[code].offset + br.readBits(nbits); 12550 } 12551 function TranslateShortCodes(code, ringbuffer, index) { 12552 var val; 12553 if (code < NUM_DISTANCE_SHORT_CODES) { 12554 index += kDistanceShortCodeIndexOffset[code]; 12555 index &= 3; 12556 val = ringbuffer[index] + kDistanceShortCodeValueOffset[code]; 12557 } else { 12558 val = code - NUM_DISTANCE_SHORT_CODES + 1; 12559 } 12560 return val; 12561 } 12562 function MoveToFront(v2, index) { 12563 var value = v2[index]; 12564 var i2 = index; 12565 for (; i2; --i2) v2[i2] = v2[i2 - 1]; 12566 v2[0] = value; 12567 } 12568 function InverseMoveToFrontTransform(v2, v_len) { 12569 var mtf = new Uint8Array(256); 12570 var i2; 12571 for (i2 = 0; i2 < 256; ++i2) { 12572 mtf[i2] = i2; 12573 } 12574 for (i2 = 0; i2 < v_len; ++i2) { 12575 var index = v2[i2]; 12576 v2[i2] = mtf[index]; 12577 if (index) MoveToFront(mtf, index); 12578 } 12579 } 12580 function HuffmanTreeGroup(alphabet_size, num_htrees) { 12581 this.alphabet_size = alphabet_size; 12582 this.num_htrees = num_htrees; 12583 this.codes = new Array( 12584 num_htrees + num_htrees * kMaxHuffmanTableSize[alphabet_size + 31 >>> 5] 12585 ); 12586 this.htrees = new Uint32Array(num_htrees); 12587 } 12588 HuffmanTreeGroup.prototype.decode = function(br) { 12589 var i2; 12590 var table_size; 12591 var next = 0; 12592 for (i2 = 0; i2 < this.num_htrees; ++i2) { 12593 this.htrees[i2] = next; 12594 table_size = ReadHuffmanCode( 12595 this.alphabet_size, 12596 this.codes, 12597 next, 12598 br 12599 ); 12600 next += table_size; 12601 } 12602 }; 12603 function DecodeContextMap(context_map_size, br) { 12604 var out = { num_htrees: null, context_map: null }; 12605 var use_rle_for_zeros; 12606 var max_run_length_prefix = 0; 12607 var table; 12608 var i2; 12609 br.readMoreInput(); 12610 var num_htrees = out.num_htrees = DecodeVarLenUint8(br) + 1; 12611 var context_map = out.context_map = new Uint8Array( 12612 context_map_size 12613 ); 12614 if (num_htrees <= 1) { 12615 return out; 12616 } 12617 use_rle_for_zeros = br.readBits(1); 12618 if (use_rle_for_zeros) { 12619 max_run_length_prefix = br.readBits(4) + 1; 12620 } 12621 table = []; 12622 for (i2 = 0; i2 < HUFFMAN_MAX_TABLE_SIZE; i2++) { 12623 table[i2] = new HuffmanCode(0, 0); 12624 } 12625 ReadHuffmanCode( 12626 num_htrees + max_run_length_prefix, 12627 table, 12628 0, 12629 br 12630 ); 12631 for (i2 = 0; i2 < context_map_size; ) { 12632 var code; 12633 br.readMoreInput(); 12634 code = ReadSymbol(table, 0, br); 12635 if (code === 0) { 12636 context_map[i2] = 0; 12637 ++i2; 12638 } else if (code <= max_run_length_prefix) { 12639 var reps = 1 + (1 << code) + br.readBits(code); 12640 while (--reps) { 12641 if (i2 >= context_map_size) { 12642 throw new Error( 12643 "[DecodeContextMap] i >= context_map_size" 12644 ); 12645 } 12646 context_map[i2] = 0; 12647 ++i2; 12648 } 12649 } else { 12650 context_map[i2] = code - max_run_length_prefix; 12651 ++i2; 12652 } 12653 } 12654 if (br.readBits(1)) { 12655 InverseMoveToFrontTransform( 12656 context_map, 12657 context_map_size 12658 ); 12659 } 12660 return out; 12661 } 12662 function DecodeBlockType(max_block_type, trees, tree_type, block_types, ringbuffers, indexes, br) { 12663 var ringbuffer = tree_type * 2; 12664 var index = tree_type; 12665 var type_code = ReadSymbol( 12666 trees, 12667 tree_type * HUFFMAN_MAX_TABLE_SIZE, 12668 br 12669 ); 12670 var block_type; 12671 if (type_code === 0) { 12672 block_type = ringbuffers[ringbuffer + (indexes[index] & 1)]; 12673 } else if (type_code === 1) { 12674 block_type = ringbuffers[ringbuffer + (indexes[index] - 1 & 1)] + 1; 12675 } else { 12676 block_type = type_code - 2; 12677 } 12678 if (block_type >= max_block_type) { 12679 block_type -= max_block_type; 12680 } 12681 block_types[tree_type] = block_type; 12682 ringbuffers[ringbuffer + (indexes[index] & 1)] = block_type; 12683 ++indexes[index]; 12684 } 12685 function CopyUncompressedBlockToOutput(output, len, pos, ringbuffer, ringbuffer_mask, br) { 12686 var rb_size = ringbuffer_mask + 1; 12687 var rb_pos = pos & ringbuffer_mask; 12688 var br_pos = br.pos_ & BrotliBitReader.IBUF_MASK; 12689 var nbytes; 12690 if (len < 8 || br.bit_pos_ + (len << 3) < br.bit_end_pos_) { 12691 while (len-- > 0) { 12692 br.readMoreInput(); 12693 ringbuffer[rb_pos++] = br.readBits(8); 12694 if (rb_pos === rb_size) { 12695 output.write(ringbuffer, rb_size); 12696 rb_pos = 0; 12697 } 12698 } 12699 return; 12700 } 12701 if (br.bit_end_pos_ < 32) { 12702 throw new Error( 12703 "[CopyUncompressedBlockToOutput] br.bit_end_pos_ < 32" 12704 ); 12705 } 12706 while (br.bit_pos_ < 32) { 12707 ringbuffer[rb_pos] = br.val_ >>> br.bit_pos_; 12708 br.bit_pos_ += 8; 12709 ++rb_pos; 12710 --len; 12711 } 12712 nbytes = br.bit_end_pos_ - br.bit_pos_ >> 3; 12713 if (br_pos + nbytes > BrotliBitReader.IBUF_MASK) { 12714 var tail = BrotliBitReader.IBUF_MASK + 1 - br_pos; 12715 for (var x2 = 0; x2 < tail; x2++) 12716 ringbuffer[rb_pos + x2] = br.buf_[br_pos + x2]; 12717 nbytes -= tail; 12718 rb_pos += tail; 12719 len -= tail; 12720 br_pos = 0; 12721 } 12722 for (var x2 = 0; x2 < nbytes; x2++) 12723 ringbuffer[rb_pos + x2] = br.buf_[br_pos + x2]; 12724 rb_pos += nbytes; 12725 len -= nbytes; 12726 if (rb_pos >= rb_size) { 12727 output.write(ringbuffer, rb_size); 12728 rb_pos -= rb_size; 12729 for (var x2 = 0; x2 < rb_pos; x2++) 12730 ringbuffer[x2] = ringbuffer[rb_size + x2]; 12731 } 12732 while (rb_pos + len >= rb_size) { 12733 nbytes = rb_size - rb_pos; 12734 if (br.input_.read(ringbuffer, rb_pos, nbytes) < nbytes) { 12735 throw new Error( 12736 "[CopyUncompressedBlockToOutput] not enough bytes" 12737 ); 12738 } 12739 output.write(ringbuffer, rb_size); 12740 len -= nbytes; 12741 rb_pos = 0; 12742 } 12743 if (br.input_.read(ringbuffer, rb_pos, len) < len) { 12744 throw new Error( 12745 "[CopyUncompressedBlockToOutput] not enough bytes" 12746 ); 12747 } 12748 br.reset(); 12749 } 12750 function JumpToByteBoundary(br) { 12751 var new_bit_pos = br.bit_pos_ + 7 & ~7; 12752 var pad_bits = br.readBits(new_bit_pos - br.bit_pos_); 12753 return pad_bits == 0; 12754 } 12755 function BrotliDecompressedSize(buffer) { 12756 var input = new BrotliInput(buffer); 12757 var br = new BrotliBitReader(input); 12758 DecodeWindowBits(br); 12759 var out = DecodeMetaBlockLength(br); 12760 return out.meta_block_length; 12761 } 12762 exports3.BrotliDecompressedSize = BrotliDecompressedSize; 12763 function BrotliDecompressBuffer(buffer, output_size) { 12764 var input = new BrotliInput(buffer); 12765 if (output_size == null) { 12766 output_size = BrotliDecompressedSize(buffer); 12767 } 12768 var output_buffer = new Uint8Array(output_size); 12769 var output = new BrotliOutput(output_buffer); 12770 BrotliDecompress(input, output); 12771 if (output.pos < output.buffer.length) { 12772 output.buffer = output.buffer.subarray( 12773 0, 12774 output.pos 12775 ); 12776 } 12777 return output.buffer; 12778 } 12779 exports3.BrotliDecompressBuffer = BrotliDecompressBuffer; 12780 function BrotliDecompress(input, output) { 12781 var i2; 12782 var pos = 0; 12783 var input_end = 0; 12784 var window_bits = 0; 12785 var max_backward_distance; 12786 var max_distance = 0; 12787 var ringbuffer_size; 12788 var ringbuffer_mask; 12789 var ringbuffer; 12790 var ringbuffer_end; 12791 var dist_rb = [16, 15, 11, 4]; 12792 var dist_rb_idx = 0; 12793 var prev_byte1 = 0; 12794 var prev_byte2 = 0; 12795 var hgroup = [ 12796 new HuffmanTreeGroup(0, 0), 12797 new HuffmanTreeGroup(0, 0), 12798 new HuffmanTreeGroup(0, 0) 12799 ]; 12800 var block_type_trees; 12801 var block_len_trees; 12802 var br; 12803 var kRingBufferWriteAheadSlack = 128 + BrotliBitReader.READ_SIZE; 12804 br = new BrotliBitReader(input); 12805 window_bits = DecodeWindowBits(br); 12806 max_backward_distance = (1 << window_bits) - 16; 12807 ringbuffer_size = 1 << window_bits; 12808 ringbuffer_mask = ringbuffer_size - 1; 12809 ringbuffer = new Uint8Array( 12810 ringbuffer_size + kRingBufferWriteAheadSlack + BrotliDictionary.maxDictionaryWordLength 12811 ); 12812 ringbuffer_end = ringbuffer_size; 12813 block_type_trees = []; 12814 block_len_trees = []; 12815 for (var x2 = 0; x2 < 3 * HUFFMAN_MAX_TABLE_SIZE; x2++) { 12816 block_type_trees[x2] = new HuffmanCode(0, 0); 12817 block_len_trees[x2] = new HuffmanCode(0, 0); 12818 } 12819 while (!input_end) { 12820 var meta_block_remaining_len = 0; 12821 var is_uncompressed; 12822 var block_length = [1 << 28, 1 << 28, 1 << 28]; 12823 var block_type = [0]; 12824 var num_block_types = [1, 1, 1]; 12825 var block_type_rb = [0, 1, 0, 1, 0, 1]; 12826 var block_type_rb_index = [0]; 12827 var distance_postfix_bits; 12828 var num_direct_distance_codes; 12829 var distance_postfix_mask; 12830 var num_distance_codes; 12831 var context_map = null; 12832 var context_modes = null; 12833 var num_literal_htrees; 12834 var dist_context_map = null; 12835 var num_dist_htrees; 12836 var context_offset = 0; 12837 var context_map_slice = null; 12838 var literal_htree_index = 0; 12839 var dist_context_offset = 0; 12840 var dist_context_map_slice = null; 12841 var dist_htree_index = 0; 12842 var context_lookup_offset1 = 0; 12843 var context_lookup_offset2 = 0; 12844 var context_mode; 12845 var htree_command; 12846 for (i2 = 0; i2 < 3; ++i2) { 12847 hgroup[i2].codes = null; 12848 hgroup[i2].htrees = null; 12849 } 12850 br.readMoreInput(); 12851 var _out = DecodeMetaBlockLength(br); 12852 meta_block_remaining_len = _out.meta_block_length; 12853 if (pos + meta_block_remaining_len > output.buffer.length) { 12854 var tmp = new Uint8Array( 12855 pos + meta_block_remaining_len 12856 ); 12857 tmp.set(output.buffer); 12858 output.buffer = tmp; 12859 } 12860 input_end = _out.input_end; 12861 is_uncompressed = _out.is_uncompressed; 12862 if (_out.is_metadata) { 12863 JumpToByteBoundary(br); 12864 for (; meta_block_remaining_len > 0; --meta_block_remaining_len) { 12865 br.readMoreInput(); 12866 br.readBits(8); 12867 } 12868 continue; 12869 } 12870 if (meta_block_remaining_len === 0) { 12871 continue; 12872 } 12873 if (is_uncompressed) { 12874 br.bit_pos_ = br.bit_pos_ + 7 & ~7; 12875 CopyUncompressedBlockToOutput( 12876 output, 12877 meta_block_remaining_len, 12878 pos, 12879 ringbuffer, 12880 ringbuffer_mask, 12881 br 12882 ); 12883 pos += meta_block_remaining_len; 12884 continue; 12885 } 12886 for (i2 = 0; i2 < 3; ++i2) { 12887 num_block_types[i2] = DecodeVarLenUint8(br) + 1; 12888 if (num_block_types[i2] >= 2) { 12889 ReadHuffmanCode( 12890 num_block_types[i2] + 2, 12891 block_type_trees, 12892 i2 * HUFFMAN_MAX_TABLE_SIZE, 12893 br 12894 ); 12895 ReadHuffmanCode( 12896 kNumBlockLengthCodes, 12897 block_len_trees, 12898 i2 * HUFFMAN_MAX_TABLE_SIZE, 12899 br 12900 ); 12901 block_length[i2] = ReadBlockLength( 12902 block_len_trees, 12903 i2 * HUFFMAN_MAX_TABLE_SIZE, 12904 br 12905 ); 12906 block_type_rb_index[i2] = 1; 12907 } 12908 } 12909 br.readMoreInput(); 12910 distance_postfix_bits = br.readBits(2); 12911 num_direct_distance_codes = NUM_DISTANCE_SHORT_CODES + (br.readBits(4) << distance_postfix_bits); 12912 distance_postfix_mask = (1 << distance_postfix_bits) - 1; 12913 num_distance_codes = num_direct_distance_codes + (48 << distance_postfix_bits); 12914 context_modes = new Uint8Array( 12915 num_block_types[0] 12916 ); 12917 for (i2 = 0; i2 < num_block_types[0]; ++i2) { 12918 br.readMoreInput(); 12919 context_modes[i2] = br.readBits(2) << 1; 12920 } 12921 var _o1 = DecodeContextMap( 12922 num_block_types[0] << kLiteralContextBits, 12923 br 12924 ); 12925 num_literal_htrees = _o1.num_htrees; 12926 context_map = _o1.context_map; 12927 var _o2 = DecodeContextMap( 12928 num_block_types[2] << kDistanceContextBits, 12929 br 12930 ); 12931 num_dist_htrees = _o2.num_htrees; 12932 dist_context_map = _o2.context_map; 12933 hgroup[0] = new HuffmanTreeGroup( 12934 kNumLiteralCodes, 12935 num_literal_htrees 12936 ); 12937 hgroup[1] = new HuffmanTreeGroup( 12938 kNumInsertAndCopyCodes, 12939 num_block_types[1] 12940 ); 12941 hgroup[2] = new HuffmanTreeGroup( 12942 num_distance_codes, 12943 num_dist_htrees 12944 ); 12945 for (i2 = 0; i2 < 3; ++i2) { 12946 hgroup[i2].decode(br); 12947 } 12948 context_map_slice = 0; 12949 dist_context_map_slice = 0; 12950 context_mode = context_modes[block_type[0]]; 12951 context_lookup_offset1 = Context.lookupOffsets[context_mode]; 12952 context_lookup_offset2 = Context.lookupOffsets[context_mode + 1]; 12953 htree_command = hgroup[1].htrees[0]; 12954 while (meta_block_remaining_len > 0) { 12955 var cmd_code; 12956 var range_idx; 12957 var insert_code; 12958 var copy_code; 12959 var insert_length; 12960 var copy_length; 12961 var distance_code; 12962 var distance; 12963 var context; 12964 var j2; 12965 var copy_dst; 12966 br.readMoreInput(); 12967 if (block_length[1] === 0) { 12968 DecodeBlockType( 12969 num_block_types[1], 12970 block_type_trees, 12971 1, 12972 block_type, 12973 block_type_rb, 12974 block_type_rb_index, 12975 br 12976 ); 12977 block_length[1] = ReadBlockLength( 12978 block_len_trees, 12979 HUFFMAN_MAX_TABLE_SIZE, 12980 br 12981 ); 12982 htree_command = hgroup[1].htrees[block_type[1]]; 12983 } 12984 --block_length[1]; 12985 cmd_code = ReadSymbol( 12986 hgroup[1].codes, 12987 htree_command, 12988 br 12989 ); 12990 range_idx = cmd_code >> 6; 12991 if (range_idx >= 2) { 12992 range_idx -= 2; 12993 distance_code = -1; 12994 } else { 12995 distance_code = 0; 12996 } 12997 insert_code = Prefix.kInsertRangeLut[range_idx] + (cmd_code >> 3 & 7); 12998 copy_code = Prefix.kCopyRangeLut[range_idx] + (cmd_code & 7); 12999 insert_length = Prefix.kInsertLengthPrefixCode[insert_code].offset + br.readBits( 13000 Prefix.kInsertLengthPrefixCode[insert_code].nbits 13001 ); 13002 copy_length = Prefix.kCopyLengthPrefixCode[copy_code].offset + br.readBits( 13003 Prefix.kCopyLengthPrefixCode[copy_code].nbits 13004 ); 13005 prev_byte1 = ringbuffer[pos - 1 & ringbuffer_mask]; 13006 prev_byte2 = ringbuffer[pos - 2 & ringbuffer_mask]; 13007 for (j2 = 0; j2 < insert_length; ++j2) { 13008 br.readMoreInput(); 13009 if (block_length[0] === 0) { 13010 DecodeBlockType( 13011 num_block_types[0], 13012 block_type_trees, 13013 0, 13014 block_type, 13015 block_type_rb, 13016 block_type_rb_index, 13017 br 13018 ); 13019 block_length[0] = ReadBlockLength( 13020 block_len_trees, 13021 0, 13022 br 13023 ); 13024 context_offset = block_type[0] << kLiteralContextBits; 13025 context_map_slice = context_offset; 13026 context_mode = context_modes[block_type[0]]; 13027 context_lookup_offset1 = Context.lookupOffsets[context_mode]; 13028 context_lookup_offset2 = Context.lookupOffsets[context_mode + 1]; 13029 } 13030 context = Context.lookup[context_lookup_offset1 + prev_byte1] | Context.lookup[context_lookup_offset2 + prev_byte2]; 13031 literal_htree_index = context_map[context_map_slice + context]; 13032 --block_length[0]; 13033 prev_byte2 = prev_byte1; 13034 prev_byte1 = ReadSymbol( 13035 hgroup[0].codes, 13036 hgroup[0].htrees[literal_htree_index], 13037 br 13038 ); 13039 ringbuffer[pos & ringbuffer_mask] = prev_byte1; 13040 if ((pos & ringbuffer_mask) === ringbuffer_mask) { 13041 output.write( 13042 ringbuffer, 13043 ringbuffer_size 13044 ); 13045 } 13046 ++pos; 13047 } 13048 meta_block_remaining_len -= insert_length; 13049 if (meta_block_remaining_len <= 0) break; 13050 if (distance_code < 0) { 13051 var context; 13052 br.readMoreInput(); 13053 if (block_length[2] === 0) { 13054 DecodeBlockType( 13055 num_block_types[2], 13056 block_type_trees, 13057 2, 13058 block_type, 13059 block_type_rb, 13060 block_type_rb_index, 13061 br 13062 ); 13063 block_length[2] = ReadBlockLength( 13064 block_len_trees, 13065 2 * HUFFMAN_MAX_TABLE_SIZE, 13066 br 13067 ); 13068 dist_context_offset = block_type[2] << kDistanceContextBits; 13069 dist_context_map_slice = dist_context_offset; 13070 } 13071 --block_length[2]; 13072 context = (copy_length > 4 ? 3 : copy_length - 2) & 255; 13073 dist_htree_index = dist_context_map[dist_context_map_slice + context]; 13074 distance_code = ReadSymbol( 13075 hgroup[2].codes, 13076 hgroup[2].htrees[dist_htree_index], 13077 br 13078 ); 13079 if (distance_code >= num_direct_distance_codes) { 13080 var nbits; 13081 var postfix; 13082 var offset; 13083 distance_code -= num_direct_distance_codes; 13084 postfix = distance_code & distance_postfix_mask; 13085 distance_code >>= distance_postfix_bits; 13086 nbits = (distance_code >> 1) + 1; 13087 offset = (2 + (distance_code & 1) << nbits) - 4; 13088 distance_code = num_direct_distance_codes + (offset + br.readBits(nbits) << distance_postfix_bits) + postfix; 13089 } 13090 } 13091 distance = TranslateShortCodes( 13092 distance_code, 13093 dist_rb, 13094 dist_rb_idx 13095 ); 13096 if (distance < 0) { 13097 throw new Error( 13098 "[BrotliDecompress] invalid distance" 13099 ); 13100 } 13101 if (pos < max_backward_distance && max_distance !== max_backward_distance) { 13102 max_distance = pos; 13103 } else { 13104 max_distance = max_backward_distance; 13105 } 13106 copy_dst = pos & ringbuffer_mask; 13107 if (distance > max_distance) { 13108 if (copy_length >= BrotliDictionary.minDictionaryWordLength && copy_length <= BrotliDictionary.maxDictionaryWordLength) { 13109 var offset = BrotliDictionary.offsetsByLength[copy_length]; 13110 var word_id = distance - max_distance - 1; 13111 var shift = BrotliDictionary.sizeBitsByLength[copy_length]; 13112 var mask = (1 << shift) - 1; 13113 var word_idx = word_id & mask; 13114 var transform_idx = word_id >> shift; 13115 offset += word_idx * copy_length; 13116 if (transform_idx < Transform.kNumTransforms) { 13117 var len = Transform.transformDictionaryWord( 13118 ringbuffer, 13119 copy_dst, 13120 offset, 13121 copy_length, 13122 transform_idx 13123 ); 13124 copy_dst += len; 13125 pos += len; 13126 meta_block_remaining_len -= len; 13127 if (copy_dst >= ringbuffer_end) { 13128 output.write( 13129 ringbuffer, 13130 ringbuffer_size 13131 ); 13132 for (var _x24 = 0; _x24 < copy_dst - ringbuffer_end; _x24++) 13133 ringbuffer[_x24] = ringbuffer[ringbuffer_end + _x24]; 13134 } 13135 } else { 13136 throw new Error( 13137 "Invalid backward reference. pos: " + pos + " distance: " + distance + " len: " + copy_length + " bytes left: " + meta_block_remaining_len 13138 ); 13139 } 13140 } else { 13141 throw new Error( 13142 "Invalid backward reference. pos: " + pos + " distance: " + distance + " len: " + copy_length + " bytes left: " + meta_block_remaining_len 13143 ); 13144 } 13145 } else { 13146 if (distance_code > 0) { 13147 dist_rb[dist_rb_idx & 3] = distance; 13148 ++dist_rb_idx; 13149 } 13150 if (copy_length > meta_block_remaining_len) { 13151 throw new Error( 13152 "Invalid backward reference. pos: " + pos + " distance: " + distance + " len: " + copy_length + " bytes left: " + meta_block_remaining_len 13153 ); 13154 } 13155 for (j2 = 0; j2 < copy_length; ++j2) { 13156 ringbuffer[pos & ringbuffer_mask] = ringbuffer[pos - distance & ringbuffer_mask]; 13157 if ((pos & ringbuffer_mask) === ringbuffer_mask) { 13158 output.write( 13159 ringbuffer, 13160 ringbuffer_size 13161 ); 13162 } 13163 ++pos; 13164 --meta_block_remaining_len; 13165 } 13166 } 13167 prev_byte1 = ringbuffer[pos - 1 & ringbuffer_mask]; 13168 prev_byte2 = ringbuffer[pos - 2 & ringbuffer_mask]; 13169 } 13170 pos &= 1073741823; 13171 } 13172 output.write(ringbuffer, pos & ringbuffer_mask); 13173 } 13174 exports3.BrotliDecompress = BrotliDecompress; 13175 BrotliDictionary.init(); 13176 }, 13177 { 13178 "./bit_reader": 1, 13179 "./context": 2, 13180 "./dictionary": 6, 13181 "./huffman": 7, 13182 "./prefix": 9, 13183 "./streams": 10, 13184 "./transform": 11 13185 } 13186 ], 13187 4: [ 13188 function(require2, module3, exports3) { 13189 var base64 = require2("base64-js"); 13190 exports3.init = function() { 13191 var BrotliDecompressBuffer = require2("./decode").BrotliDecompressBuffer; 13192 var compressed = base64.toByteArray( 13193 require2("./dictionary.bin.js") 13194 ); 13195 return BrotliDecompressBuffer(compressed); 13196 }; 13197 }, 13198 { "./decode": 3, "./dictionary.bin.js": 5, "base64-js": 8 } 13199 ], 13200 5: [ 13201 function(require2, module3, exports3) { 13202 module3.exports = "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"; 13203 }, 13204 {} 13205 ], 13206 6: [ 13207 function(require2, module3, exports3) { 13208 var data = require2("./dictionary-browser"); 13209 exports3.init = function() { 13210 exports3.dictionary = data.init(); 13211 }; 13212 exports3.offsetsByLength = new Uint32Array([ 13213 0, 13214 0, 13215 0, 13216 0, 13217 0, 13218 4096, 13219 9216, 13220 21504, 13221 35840, 13222 44032, 13223 53248, 13224 63488, 13225 74752, 13226 87040, 13227 93696, 13228 100864, 13229 104704, 13230 106752, 13231 108928, 13232 113536, 13233 115968, 13234 118528, 13235 119872, 13236 121280, 13237 122016 13238 ]); 13239 exports3.sizeBitsByLength = new Uint8Array([ 13240 0, 13241 0, 13242 0, 13243 0, 13244 10, 13245 10, 13246 11, 13247 11, 13248 10, 13249 10, 13250 10, 13251 10, 13252 10, 13253 9, 13254 9, 13255 8, 13256 7, 13257 7, 13258 8, 13259 7, 13260 7, 13261 6, 13262 6, 13263 5, 13264 5 13265 ]); 13266 exports3.minDictionaryWordLength = 4; 13267 exports3.maxDictionaryWordLength = 24; 13268 }, 13269 { "./dictionary-browser": 4 } 13270 ], 13271 7: [ 13272 function(require2, module3, exports3) { 13273 function HuffmanCode(bits, value) { 13274 this.bits = bits; 13275 this.value = value; 13276 } 13277 exports3.HuffmanCode = HuffmanCode; 13278 var MAX_LENGTH = 15; 13279 function GetNextKey(key, len) { 13280 var step = 1 << len - 1; 13281 while (key & step) { 13282 step >>= 1; 13283 } 13284 return (key & step - 1) + step; 13285 } 13286 function ReplicateValue(table, i2, step, end, code) { 13287 do { 13288 end -= step; 13289 table[i2 + end] = new HuffmanCode( 13290 code.bits, 13291 code.value 13292 ); 13293 } while (end > 0); 13294 } 13295 function NextTableBitSize(count, len, root_bits) { 13296 var left = 1 << len - root_bits; 13297 while (len < MAX_LENGTH) { 13298 left -= count[len]; 13299 if (left <= 0) break; 13300 ++len; 13301 left <<= 1; 13302 } 13303 return len - root_bits; 13304 } 13305 exports3.BrotliBuildHuffmanTable = function(root_table, table, root_bits, code_lengths, code_lengths_size) { 13306 var start_table = table; 13307 var code; 13308 var len; 13309 var symbol3; 13310 var key; 13311 var step; 13312 var low; 13313 var mask; 13314 var table_bits; 13315 var table_size; 13316 var total_size; 13317 var sorted; 13318 var count = new Int32Array( 13319 MAX_LENGTH + 1 13320 ); 13321 var offset = new Int32Array( 13322 MAX_LENGTH + 1 13323 ); 13324 sorted = new Int32Array(code_lengths_size); 13325 for (symbol3 = 0; symbol3 < code_lengths_size; symbol3++) { 13326 count[code_lengths[symbol3]]++; 13327 } 13328 offset[1] = 0; 13329 for (len = 1; len < MAX_LENGTH; len++) { 13330 offset[len + 1] = offset[len] + count[len]; 13331 } 13332 for (symbol3 = 0; symbol3 < code_lengths_size; symbol3++) { 13333 if (code_lengths[symbol3] !== 0) { 13334 sorted[offset[code_lengths[symbol3]]++] = symbol3; 13335 } 13336 } 13337 table_bits = root_bits; 13338 table_size = 1 << table_bits; 13339 total_size = table_size; 13340 if (offset[MAX_LENGTH] === 1) { 13341 for (key = 0; key < total_size; ++key) { 13342 root_table[table + key] = new HuffmanCode( 13343 0, 13344 sorted[0] & 65535 13345 ); 13346 } 13347 return total_size; 13348 } 13349 key = 0; 13350 symbol3 = 0; 13351 for (len = 1, step = 2; len <= root_bits; ++len, step <<= 1) { 13352 for (; count[len] > 0; --count[len]) { 13353 code = new HuffmanCode( 13354 len & 255, 13355 sorted[symbol3++] & 65535 13356 ); 13357 ReplicateValue( 13358 root_table, 13359 table + key, 13360 step, 13361 table_size, 13362 code 13363 ); 13364 key = GetNextKey(key, len); 13365 } 13366 } 13367 mask = total_size - 1; 13368 low = -1; 13369 for (len = root_bits + 1, step = 2; len <= MAX_LENGTH; ++len, step <<= 1) { 13370 for (; count[len] > 0; --count[len]) { 13371 if ((key & mask) !== low) { 13372 table += table_size; 13373 table_bits = NextTableBitSize( 13374 count, 13375 len, 13376 root_bits 13377 ); 13378 table_size = 1 << table_bits; 13379 total_size += table_size; 13380 low = key & mask; 13381 root_table[start_table + low] = new HuffmanCode( 13382 table_bits + root_bits & 255, 13383 table - start_table - low & 65535 13384 ); 13385 } 13386 code = new HuffmanCode( 13387 len - root_bits & 255, 13388 sorted[symbol3++] & 65535 13389 ); 13390 ReplicateValue( 13391 root_table, 13392 table + (key >> root_bits), 13393 step, 13394 table_size, 13395 code 13396 ); 13397 key = GetNextKey(key, len); 13398 } 13399 } 13400 return total_size; 13401 }; 13402 }, 13403 {} 13404 ], 13405 8: [ 13406 function(require2, module3, exports3) { 13407 "use strict"; 13408 exports3.byteLength = byteLength; 13409 exports3.toByteArray = toByteArray; 13410 exports3.fromByteArray = fromByteArray; 13411 var lookup = []; 13412 var revLookup = []; 13413 var Arr = typeof Uint8Array !== "undefined" ? Uint8Array : Array; 13414 var code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; 13415 for (var i2 = 0, len = code.length; i2 < len; ++i2) { 13416 lookup[i2] = code[i2]; 13417 revLookup[code.charCodeAt(i2)] = i2; 13418 } 13419 revLookup["-".charCodeAt(0)] = 62; 13420 revLookup["_".charCodeAt(0)] = 63; 13421 function getLens(b64) { 13422 var len2 = b64.length; 13423 if (len2 % 4 > 0) { 13424 throw new Error( 13425 "Invalid string. Length must be a multiple of 4" 13426 ); 13427 } 13428 var validLen = b64.indexOf("="); 13429 if (validLen === -1) validLen = len2; 13430 var placeHoldersLen = validLen === len2 ? 0 : 4 - validLen % 4; 13431 return [validLen, placeHoldersLen]; 13432 } 13433 function byteLength(b64) { 13434 var lens = getLens(b64); 13435 var validLen = lens[0]; 13436 var placeHoldersLen = lens[1]; 13437 return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen; 13438 } 13439 function _byteLength(b64, validLen, placeHoldersLen) { 13440 return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen; 13441 } 13442 function toByteArray(b64) { 13443 var tmp; 13444 var lens = getLens(b64); 13445 var validLen = lens[0]; 13446 var placeHoldersLen = lens[1]; 13447 var arr = new Arr( 13448 _byteLength(b64, validLen, placeHoldersLen) 13449 ); 13450 var curByte = 0; 13451 var len2 = placeHoldersLen > 0 ? validLen - 4 : validLen; 13452 for (var i22 = 0; i22 < len2; i22 += 4) { 13453 tmp = revLookup[b64.charCodeAt(i22)] << 18 | revLookup[b64.charCodeAt(i22 + 1)] << 12 | revLookup[b64.charCodeAt(i22 + 2)] << 6 | revLookup[b64.charCodeAt(i22 + 3)]; 13454 arr[curByte++] = tmp >> 16 & 255; 13455 arr[curByte++] = tmp >> 8 & 255; 13456 arr[curByte++] = tmp & 255; 13457 } 13458 if (placeHoldersLen === 2) { 13459 tmp = revLookup[b64.charCodeAt(i22)] << 2 | revLookup[b64.charCodeAt(i22 + 1)] >> 4; 13460 arr[curByte++] = tmp & 255; 13461 } 13462 if (placeHoldersLen === 1) { 13463 tmp = revLookup[b64.charCodeAt(i22)] << 10 | revLookup[b64.charCodeAt(i22 + 1)] << 4 | revLookup[b64.charCodeAt(i22 + 2)] >> 2; 13464 arr[curByte++] = tmp >> 8 & 255; 13465 arr[curByte++] = tmp & 255; 13466 } 13467 return arr; 13468 } 13469 function tripletToBase64(num) { 13470 return lookup[num >> 18 & 63] + lookup[num >> 12 & 63] + lookup[num >> 6 & 63] + lookup[num & 63]; 13471 } 13472 function encodeChunk(uint8, start2, end) { 13473 var tmp; 13474 var output = []; 13475 for (var i22 = start2; i22 < end; i22 += 3) { 13476 tmp = (uint8[i22] << 16 & 16711680) + (uint8[i22 + 1] << 8 & 65280) + (uint8[i22 + 2] & 255); 13477 output.push(tripletToBase64(tmp)); 13478 } 13479 return output.join(""); 13480 } 13481 function fromByteArray(uint8) { 13482 var tmp; 13483 var len2 = uint8.length; 13484 var extraBytes = len2 % 3; 13485 var parts = []; 13486 var maxChunkLength = 16383; 13487 for (var i22 = 0, len22 = len2 - extraBytes; i22 < len22; i22 += maxChunkLength) { 13488 parts.push( 13489 encodeChunk( 13490 uint8, 13491 i22, 13492 i22 + maxChunkLength > len22 ? len22 : i22 + maxChunkLength 13493 ) 13494 ); 13495 } 13496 if (extraBytes === 1) { 13497 tmp = uint8[len2 - 1]; 13498 parts.push( 13499 lookup[tmp >> 2] + lookup[tmp << 4 & 63] + "==" 13500 ); 13501 } else if (extraBytes === 2) { 13502 tmp = (uint8[len2 - 2] << 8) + uint8[len2 - 1]; 13503 parts.push( 13504 lookup[tmp >> 10] + lookup[tmp >> 4 & 63] + lookup[tmp << 2 & 63] + "=" 13505 ); 13506 } 13507 return parts.join(""); 13508 } 13509 }, 13510 {} 13511 ], 13512 9: [ 13513 function(require2, module3, exports3) { 13514 function PrefixCodeRange(offset, nbits) { 13515 this.offset = offset; 13516 this.nbits = nbits; 13517 } 13518 exports3.kBlockLengthPrefixCode = [ 13519 new PrefixCodeRange(1, 2), 13520 new PrefixCodeRange(5, 2), 13521 new PrefixCodeRange(9, 2), 13522 new PrefixCodeRange(13, 2), 13523 new PrefixCodeRange(17, 3), 13524 new PrefixCodeRange(25, 3), 13525 new PrefixCodeRange(33, 3), 13526 new PrefixCodeRange(41, 3), 13527 new PrefixCodeRange(49, 4), 13528 new PrefixCodeRange(65, 4), 13529 new PrefixCodeRange(81, 4), 13530 new PrefixCodeRange(97, 4), 13531 new PrefixCodeRange(113, 5), 13532 new PrefixCodeRange(145, 5), 13533 new PrefixCodeRange(177, 5), 13534 new PrefixCodeRange(209, 5), 13535 new PrefixCodeRange(241, 6), 13536 new PrefixCodeRange(305, 6), 13537 new PrefixCodeRange(369, 7), 13538 new PrefixCodeRange(497, 8), 13539 new PrefixCodeRange(753, 9), 13540 new PrefixCodeRange(1265, 10), 13541 new PrefixCodeRange(2289, 11), 13542 new PrefixCodeRange(4337, 12), 13543 new PrefixCodeRange(8433, 13), 13544 new PrefixCodeRange(16625, 24) 13545 ]; 13546 exports3.kInsertLengthPrefixCode = [ 13547 new PrefixCodeRange(0, 0), 13548 new PrefixCodeRange(1, 0), 13549 new PrefixCodeRange(2, 0), 13550 new PrefixCodeRange(3, 0), 13551 new PrefixCodeRange(4, 0), 13552 new PrefixCodeRange(5, 0), 13553 new PrefixCodeRange(6, 1), 13554 new PrefixCodeRange(8, 1), 13555 new PrefixCodeRange(10, 2), 13556 new PrefixCodeRange(14, 2), 13557 new PrefixCodeRange(18, 3), 13558 new PrefixCodeRange(26, 3), 13559 new PrefixCodeRange(34, 4), 13560 new PrefixCodeRange(50, 4), 13561 new PrefixCodeRange(66, 5), 13562 new PrefixCodeRange(98, 5), 13563 new PrefixCodeRange(130, 6), 13564 new PrefixCodeRange(194, 7), 13565 new PrefixCodeRange(322, 8), 13566 new PrefixCodeRange(578, 9), 13567 new PrefixCodeRange(1090, 10), 13568 new PrefixCodeRange(2114, 12), 13569 new PrefixCodeRange(6210, 14), 13570 new PrefixCodeRange(22594, 24) 13571 ]; 13572 exports3.kCopyLengthPrefixCode = [ 13573 new PrefixCodeRange(2, 0), 13574 new PrefixCodeRange(3, 0), 13575 new PrefixCodeRange(4, 0), 13576 new PrefixCodeRange(5, 0), 13577 new PrefixCodeRange(6, 0), 13578 new PrefixCodeRange(7, 0), 13579 new PrefixCodeRange(8, 0), 13580 new PrefixCodeRange(9, 0), 13581 new PrefixCodeRange(10, 1), 13582 new PrefixCodeRange(12, 1), 13583 new PrefixCodeRange(14, 2), 13584 new PrefixCodeRange(18, 2), 13585 new PrefixCodeRange(22, 3), 13586 new PrefixCodeRange(30, 3), 13587 new PrefixCodeRange(38, 4), 13588 new PrefixCodeRange(54, 4), 13589 new PrefixCodeRange(70, 5), 13590 new PrefixCodeRange(102, 5), 13591 new PrefixCodeRange(134, 6), 13592 new PrefixCodeRange(198, 7), 13593 new PrefixCodeRange(326, 8), 13594 new PrefixCodeRange(582, 9), 13595 new PrefixCodeRange(1094, 10), 13596 new PrefixCodeRange(2118, 24) 13597 ]; 13598 exports3.kInsertRangeLut = [0, 0, 8, 8, 0, 16, 8, 16, 16]; 13599 exports3.kCopyRangeLut = [0, 8, 0, 8, 16, 0, 16, 8, 16]; 13600 }, 13601 {} 13602 ], 13603 10: [ 13604 function(require2, module3, exports3) { 13605 function BrotliInput(buffer) { 13606 this.buffer = buffer; 13607 this.pos = 0; 13608 } 13609 BrotliInput.prototype.read = function(buf, i2, count) { 13610 if (this.pos + count > this.buffer.length) { 13611 count = this.buffer.length - this.pos; 13612 } 13613 for (var p3 = 0; p3 < count; p3++) 13614 buf[i2 + p3] = this.buffer[this.pos + p3]; 13615 this.pos += count; 13616 return count; 13617 }; 13618 exports3.BrotliInput = BrotliInput; 13619 function BrotliOutput(buf) { 13620 this.buffer = buf; 13621 this.pos = 0; 13622 } 13623 BrotliOutput.prototype.write = function(buf, count) { 13624 if (this.pos + count > this.buffer.length) 13625 throw new Error( 13626 "Output buffer is not large enough" 13627 ); 13628 this.buffer.set(buf.subarray(0, count), this.pos); 13629 this.pos += count; 13630 return count; 13631 }; 13632 exports3.BrotliOutput = BrotliOutput; 13633 }, 13634 {} 13635 ], 13636 11: [ 13637 function(require2, module3, exports3) { 13638 var BrotliDictionary = require2("./dictionary"); 13639 var kIdentity = 0; 13640 var kOmitLast1 = 1; 13641 var kOmitLast2 = 2; 13642 var kOmitLast3 = 3; 13643 var kOmitLast4 = 4; 13644 var kOmitLast5 = 5; 13645 var kOmitLast6 = 6; 13646 var kOmitLast7 = 7; 13647 var kOmitLast8 = 8; 13648 var kOmitLast9 = 9; 13649 var kUppercaseFirst = 10; 13650 var kUppercaseAll = 11; 13651 var kOmitFirst1 = 12; 13652 var kOmitFirst2 = 13; 13653 var kOmitFirst3 = 14; 13654 var kOmitFirst4 = 15; 13655 var kOmitFirst5 = 16; 13656 var kOmitFirst6 = 17; 13657 var kOmitFirst7 = 18; 13658 var kOmitFirst8 = 19; 13659 var kOmitFirst9 = 20; 13660 function Transform(prefix2, transform, suffix) { 13661 this.prefix = new Uint8Array(prefix2.length); 13662 this.transform = transform; 13663 this.suffix = new Uint8Array(suffix.length); 13664 for (var i2 = 0; i2 < prefix2.length; i2++) 13665 this.prefix[i2] = prefix2.charCodeAt(i2); 13666 for (var i2 = 0; i2 < suffix.length; i2++) 13667 this.suffix[i2] = suffix.charCodeAt(i2); 13668 } 13669 var kTransforms = [ 13670 new Transform("", kIdentity, ""), 13671 new Transform("", kIdentity, " "), 13672 new Transform(" ", kIdentity, " "), 13673 new Transform("", kOmitFirst1, ""), 13674 new Transform("", kUppercaseFirst, " "), 13675 new Transform("", kIdentity, " the "), 13676 new Transform(" ", kIdentity, ""), 13677 new Transform("s ", kIdentity, " "), 13678 new Transform("", kIdentity, " of "), 13679 new Transform("", kUppercaseFirst, ""), 13680 new Transform("", kIdentity, " and "), 13681 new Transform("", kOmitFirst2, ""), 13682 new Transform("", kOmitLast1, ""), 13683 new Transform(", ", kIdentity, " "), 13684 new Transform("", kIdentity, ", "), 13685 new Transform(" ", kUppercaseFirst, " "), 13686 new Transform("", kIdentity, " in "), 13687 new Transform("", kIdentity, " to "), 13688 new Transform("e ", kIdentity, " "), 13689 new Transform("", kIdentity, '"'), 13690 new Transform("", kIdentity, "."), 13691 new Transform("", kIdentity, '">'), 13692 new Transform("", kIdentity, "\n"), 13693 new Transform("", kOmitLast3, ""), 13694 new Transform("", kIdentity, "]"), 13695 new Transform("", kIdentity, " for "), 13696 new Transform("", kOmitFirst3, ""), 13697 new Transform("", kOmitLast2, ""), 13698 new Transform("", kIdentity, " a "), 13699 new Transform("", kIdentity, " that "), 13700 new Transform(" ", kUppercaseFirst, ""), 13701 new Transform("", kIdentity, ". "), 13702 new Transform(".", kIdentity, ""), 13703 new Transform(" ", kIdentity, ", "), 13704 new Transform("", kOmitFirst4, ""), 13705 new Transform("", kIdentity, " with "), 13706 new Transform("", kIdentity, "'"), 13707 new Transform("", kIdentity, " from "), 13708 new Transform("", kIdentity, " by "), 13709 new Transform("", kOmitFirst5, ""), 13710 new Transform("", kOmitFirst6, ""), 13711 new Transform(" the ", kIdentity, ""), 13712 new Transform("", kOmitLast4, ""), 13713 new Transform("", kIdentity, ". The "), 13714 new Transform("", kUppercaseAll, ""), 13715 new Transform("", kIdentity, " on "), 13716 new Transform("", kIdentity, " as "), 13717 new Transform("", kIdentity, " is "), 13718 new Transform("", kOmitLast7, ""), 13719 new Transform("", kOmitLast1, "ing "), 13720 new Transform("", kIdentity, "\n "), 13721 new Transform("", kIdentity, ":"), 13722 new Transform(" ", kIdentity, ". "), 13723 new Transform("", kIdentity, "ed "), 13724 new Transform("", kOmitFirst9, ""), 13725 new Transform("", kOmitFirst7, ""), 13726 new Transform("", kOmitLast6, ""), 13727 new Transform("", kIdentity, "("), 13728 new Transform("", kUppercaseFirst, ", "), 13729 new Transform("", kOmitLast8, ""), 13730 new Transform("", kIdentity, " at "), 13731 new Transform("", kIdentity, "ly "), 13732 new Transform(" the ", kIdentity, " of "), 13733 new Transform("", kOmitLast5, ""), 13734 new Transform("", kOmitLast9, ""), 13735 new Transform(" ", kUppercaseFirst, ", "), 13736 new Transform("", kUppercaseFirst, '"'), 13737 new Transform(".", kIdentity, "("), 13738 new Transform("", kUppercaseAll, " "), 13739 new Transform("", kUppercaseFirst, '">'), 13740 new Transform("", kIdentity, '="'), 13741 new Transform(" ", kIdentity, "."), 13742 new Transform(".com/", kIdentity, ""), 13743 new Transform(" the ", kIdentity, " of the "), 13744 new Transform("", kUppercaseFirst, "'"), 13745 new Transform("", kIdentity, ". This "), 13746 new Transform("", kIdentity, ","), 13747 new Transform(".", kIdentity, " "), 13748 new Transform("", kUppercaseFirst, "("), 13749 new Transform("", kUppercaseFirst, "."), 13750 new Transform("", kIdentity, " not "), 13751 new Transform(" ", kIdentity, '="'), 13752 new Transform("", kIdentity, "er "), 13753 new Transform(" ", kUppercaseAll, " "), 13754 new Transform("", kIdentity, "al "), 13755 new Transform(" ", kUppercaseAll, ""), 13756 new Transform("", kIdentity, "='"), 13757 new Transform("", kUppercaseAll, '"'), 13758 new Transform("", kUppercaseFirst, ". "), 13759 new Transform(" ", kIdentity, "("), 13760 new Transform("", kIdentity, "ful "), 13761 new Transform(" ", kUppercaseFirst, ". "), 13762 new Transform("", kIdentity, "ive "), 13763 new Transform("", kIdentity, "less "), 13764 new Transform("", kUppercaseAll, "'"), 13765 new Transform("", kIdentity, "est "), 13766 new Transform(" ", kUppercaseFirst, "."), 13767 new Transform("", kUppercaseAll, '">'), 13768 new Transform(" ", kIdentity, "='"), 13769 new Transform("", kUppercaseFirst, ","), 13770 new Transform("", kIdentity, "ize "), 13771 new Transform("", kUppercaseAll, "."), 13772 new Transform("\xC2\xA0", kIdentity, ""), 13773 new Transform(" ", kIdentity, ","), 13774 new Transform("", kUppercaseFirst, '="'), 13775 new Transform("", kUppercaseAll, '="'), 13776 new Transform("", kIdentity, "ous "), 13777 new Transform("", kUppercaseAll, ", "), 13778 new Transform("", kUppercaseFirst, "='"), 13779 new Transform(" ", kUppercaseFirst, ","), 13780 new Transform(" ", kUppercaseAll, '="'), 13781 new Transform(" ", kUppercaseAll, ", "), 13782 new Transform("", kUppercaseAll, ","), 13783 new Transform("", kUppercaseAll, "("), 13784 new Transform("", kUppercaseAll, ". "), 13785 new Transform(" ", kUppercaseAll, "."), 13786 new Transform("", kUppercaseAll, "='"), 13787 new Transform(" ", kUppercaseAll, ". "), 13788 new Transform(" ", kUppercaseFirst, '="'), 13789 new Transform(" ", kUppercaseAll, "='"), 13790 new Transform(" ", kUppercaseFirst, "='") 13791 ]; 13792 exports3.kTransforms = kTransforms; 13793 exports3.kNumTransforms = kTransforms.length; 13794 function ToUpperCase(p3, i2) { 13795 if (p3[i2] < 192) { 13796 if (p3[i2] >= 97 && p3[i2] <= 122) { 13797 p3[i2] ^= 32; 13798 } 13799 return 1; 13800 } 13801 if (p3[i2] < 224) { 13802 p3[i2 + 1] ^= 32; 13803 return 2; 13804 } 13805 p3[i2 + 2] ^= 5; 13806 return 3; 13807 } 13808 exports3.transformDictionaryWord = function(dst, idx, word, len, transform) { 13809 var prefix2 = kTransforms[transform].prefix; 13810 var suffix = kTransforms[transform].suffix; 13811 var t3 = kTransforms[transform].transform; 13812 var skip = t3 < kOmitFirst1 ? 0 : t3 - (kOmitFirst1 - 1); 13813 var i2 = 0; 13814 var start_idx = idx; 13815 var uppercase; 13816 if (skip > len) { 13817 skip = len; 13818 } 13819 var prefix_pos = 0; 13820 while (prefix_pos < prefix2.length) { 13821 dst[idx++] = prefix2[prefix_pos++]; 13822 } 13823 word += skip; 13824 len -= skip; 13825 if (t3 <= kOmitLast9) { 13826 len -= t3; 13827 } 13828 for (i2 = 0; i2 < len; i2++) { 13829 dst[idx++] = BrotliDictionary.dictionary[word + i2]; 13830 } 13831 uppercase = idx - len; 13832 if (t3 === kUppercaseFirst) { 13833 ToUpperCase(dst, uppercase); 13834 } else if (t3 === kUppercaseAll) { 13835 while (len > 0) { 13836 var step = ToUpperCase(dst, uppercase); 13837 uppercase += step; 13838 len -= step; 13839 } 13840 } 13841 var suffix_pos = 0; 13842 while (suffix_pos < suffix.length) { 13843 dst[idx++] = suffix[suffix_pos++]; 13844 } 13845 return idx - start_idx; 13846 }; 13847 }, 13848 { "./dictionary": 6 } 13849 ], 13850 12: [ 13851 function(require2, module3, exports3) { 13852 module3.exports = require2("./dec/decode").BrotliDecompressBuffer; 13853 }, 13854 { "./dec/decode": 3 } 13855 ] 13856 }, 13857 {}, 13858 [12] 13859 )(12); 13860 }); 13861 } 13862 }); 13863 var unbrotli_default = require_unbrotli(); 13864 13865 // packages/global-styles-ui/build-module/font-library/lib/inflate.js 13866 var __getOwnPropNames3 = Object.getOwnPropertyNames; 13867 var __require3 = /* @__PURE__ */ ((x2) => typeof __require !== "undefined" ? __require : typeof Proxy !== "undefined" ? new Proxy(x2, { 13868 get: (a2, b2) => (typeof __require !== "undefined" ? __require : a2)[b2] 13869 }) : x2)(function(x2) { 13870 if (typeof __require !== "undefined") return __require.apply(this, arguments); 13871 throw Error('Dynamic require of "' + x2 + '" is not supported'); 13872 }); 13873 var __commonJS3 = (cb, mod) => function __require22() { 13874 return mod || (0, cb[__getOwnPropNames3(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; 13875 }; 13876 var require_inflate = __commonJS3({ 13877 "packages/global-styles-ui/src/font-library/lib/inflate.js"(exports, module) { 13878 (function(f2) { 13879 if (typeof exports === "object" && typeof module !== "undefined") { 13880 module.exports = f2(); 13881 } else if (typeof define === "function" && define.amd) { 13882 define([], f2); 13883 } else { 13884 var g2; 13885 if (typeof window !== "undefined") { 13886 g2 = window; 13887 } else if (typeof global !== "undefined") { 13888 g2 = global; 13889 } else if (typeof self !== "undefined") { 13890 g2 = self; 13891 } else { 13892 g2 = this; 13893 } 13894 g2.pako = f2(); 13895 } 13896 })(function() { 13897 var define2, module2, exports2; 13898 return (/* @__PURE__ */ (function() { 13899 function r3(e2, n2, t3) { 13900 function o3(i22, f2) { 13901 if (!n2[i22]) { 13902 if (!e2[i22]) { 13903 var c6 = "function" == typeof __require3 && __require3; 13904 if (!f2 && c6) return c6(i22, true); 13905 if (u2) return u2(i22, true); 13906 var a2 = new Error("Cannot find module '" + i22 + "'"); 13907 throw a2.code = "MODULE_NOT_FOUND", a2; 13908 } 13909 var p3 = n2[i22] = { exports: {} }; 13910 e2[i22][0].call( 13911 p3.exports, 13912 function(r22) { 13913 var n22 = e2[i22][1][r22]; 13914 return o3(n22 || r22); 13915 }, 13916 p3, 13917 p3.exports, 13918 r3, 13919 e2, 13920 n2, 13921 t3 13922 ); 13923 } 13924 return n2[i22].exports; 13925 } 13926 for (var u2 = "function" == typeof __require3 && __require3, i2 = 0; i2 < t3.length; i2++) 13927 o3(t3[i2]); 13928 return o3; 13929 } 13930 return r3; 13931 })())( 13932 { 13933 1: [ 13934 function(require2, module3, exports3) { 13935 "use strict"; 13936 var TYPED_OK = typeof Uint8Array !== "undefined" && typeof Uint16Array !== "undefined" && typeof Int32Array !== "undefined"; 13937 function _has(obj, key) { 13938 return Object.prototype.hasOwnProperty.call(obj, key); 13939 } 13940 exports3.assign = function(obj) { 13941 var sources = Array.prototype.slice.call( 13942 arguments, 13943 1 13944 ); 13945 while (sources.length) { 13946 var source = sources.shift(); 13947 if (!source) { 13948 continue; 13949 } 13950 if (typeof source !== "object") { 13951 throw new TypeError( 13952 source + "must be non-object" 13953 ); 13954 } 13955 for (var p3 in source) { 13956 if (_has(source, p3)) { 13957 obj[p3] = source[p3]; 13958 } 13959 } 13960 } 13961 return obj; 13962 }; 13963 exports3.shrinkBuf = function(buf, size) { 13964 if (buf.length === size) { 13965 return buf; 13966 } 13967 if (buf.subarray) { 13968 return buf.subarray(0, size); 13969 } 13970 buf.length = size; 13971 return buf; 13972 }; 13973 var fnTyped = { 13974 arraySet: function(dest, src, src_offs, len, dest_offs) { 13975 if (src.subarray && dest.subarray) { 13976 dest.set( 13977 src.subarray(src_offs, src_offs + len), 13978 dest_offs 13979 ); 13980 return; 13981 } 13982 for (var i2 = 0; i2 < len; i2++) { 13983 dest[dest_offs + i2] = src[src_offs + i2]; 13984 } 13985 }, 13986 // Join array of chunks to single array. 13987 flattenChunks: function(chunks) { 13988 var i2, l2, len, pos, chunk2, result; 13989 len = 0; 13990 for (i2 = 0, l2 = chunks.length; i2 < l2; i2++) { 13991 len += chunks[i2].length; 13992 } 13993 result = new Uint8Array(len); 13994 pos = 0; 13995 for (i2 = 0, l2 = chunks.length; i2 < l2; i2++) { 13996 chunk2 = chunks[i2]; 13997 result.set(chunk2, pos); 13998 pos += chunk2.length; 13999 } 14000 return result; 14001 } 14002 }; 14003 var fnUntyped = { 14004 arraySet: function(dest, src, src_offs, len, dest_offs) { 14005 for (var i2 = 0; i2 < len; i2++) { 14006 dest[dest_offs + i2] = src[src_offs + i2]; 14007 } 14008 }, 14009 // Join array of chunks to single array. 14010 flattenChunks: function(chunks) { 14011 return [].concat.apply([], chunks); 14012 } 14013 }; 14014 exports3.setTyped = function(on) { 14015 if (on) { 14016 exports3.Buf8 = Uint8Array; 14017 exports3.Buf16 = Uint16Array; 14018 exports3.Buf32 = Int32Array; 14019 exports3.assign(exports3, fnTyped); 14020 } else { 14021 exports3.Buf8 = Array; 14022 exports3.Buf16 = Array; 14023 exports3.Buf32 = Array; 14024 exports3.assign(exports3, fnUntyped); 14025 } 14026 }; 14027 exports3.setTyped(TYPED_OK); 14028 }, 14029 {} 14030 ], 14031 2: [ 14032 function(require2, module3, exports3) { 14033 "use strict"; 14034 var utils = require2("./common"); 14035 var STR_APPLY_OK = true; 14036 var STR_APPLY_UIA_OK = true; 14037 try { 14038 String.fromCharCode.apply(null, [0]); 14039 } catch (__148) { 14040 STR_APPLY_OK = false; 14041 } 14042 try { 14043 String.fromCharCode.apply(null, new Uint8Array(1)); 14044 } catch (__148) { 14045 STR_APPLY_UIA_OK = false; 14046 } 14047 var _utf8len = new utils.Buf8(256); 14048 for (var q = 0; q < 256; q++) { 14049 _utf8len[q] = q >= 252 ? 6 : q >= 248 ? 5 : q >= 240 ? 4 : q >= 224 ? 3 : q >= 192 ? 2 : 1; 14050 } 14051 _utf8len[254] = _utf8len[254] = 1; 14052 exports3.string2buf = function(str) { 14053 var buf, c6, c22, m_pos, i2, str_len = str.length, buf_len = 0; 14054 for (m_pos = 0; m_pos < str_len; m_pos++) { 14055 c6 = str.charCodeAt(m_pos); 14056 if ((c6 & 64512) === 55296 && m_pos + 1 < str_len) { 14057 c22 = str.charCodeAt(m_pos + 1); 14058 if ((c22 & 64512) === 56320) { 14059 c6 = 65536 + (c6 - 55296 << 10) + (c22 - 56320); 14060 m_pos++; 14061 } 14062 } 14063 buf_len += c6 < 128 ? 1 : c6 < 2048 ? 2 : c6 < 65536 ? 3 : 4; 14064 } 14065 buf = new utils.Buf8(buf_len); 14066 for (i2 = 0, m_pos = 0; i2 < buf_len; m_pos++) { 14067 c6 = str.charCodeAt(m_pos); 14068 if ((c6 & 64512) === 55296 && m_pos + 1 < str_len) { 14069 c22 = str.charCodeAt(m_pos + 1); 14070 if ((c22 & 64512) === 56320) { 14071 c6 = 65536 + (c6 - 55296 << 10) + (c22 - 56320); 14072 m_pos++; 14073 } 14074 } 14075 if (c6 < 128) { 14076 buf[i2++] = c6; 14077 } else if (c6 < 2048) { 14078 buf[i2++] = 192 | c6 >>> 6; 14079 buf[i2++] = 128 | c6 & 63; 14080 } else if (c6 < 65536) { 14081 buf[i2++] = 224 | c6 >>> 12; 14082 buf[i2++] = 128 | c6 >>> 6 & 63; 14083 buf[i2++] = 128 | c6 & 63; 14084 } else { 14085 buf[i2++] = 240 | c6 >>> 18; 14086 buf[i2++] = 128 | c6 >>> 12 & 63; 14087 buf[i2++] = 128 | c6 >>> 6 & 63; 14088 buf[i2++] = 128 | c6 & 63; 14089 } 14090 } 14091 return buf; 14092 }; 14093 function buf2binstring(buf, len) { 14094 if (len < 65534) { 14095 if (buf.subarray && STR_APPLY_UIA_OK || !buf.subarray && STR_APPLY_OK) { 14096 return String.fromCharCode.apply( 14097 null, 14098 utils.shrinkBuf(buf, len) 14099 ); 14100 } 14101 } 14102 var result = ""; 14103 for (var i2 = 0; i2 < len; i2++) { 14104 result += String.fromCharCode(buf[i2]); 14105 } 14106 return result; 14107 } 14108 exports3.buf2binstring = function(buf) { 14109 return buf2binstring(buf, buf.length); 14110 }; 14111 exports3.binstring2buf = function(str) { 14112 var buf = new utils.Buf8(str.length); 14113 for (var i2 = 0, len = buf.length; i2 < len; i2++) { 14114 buf[i2] = str.charCodeAt(i2); 14115 } 14116 return buf; 14117 }; 14118 exports3.buf2string = function(buf, max) { 14119 var i2, out, c6, c_len; 14120 var len = max || buf.length; 14121 var utf16buf = new Array(len * 2); 14122 for (out = 0, i2 = 0; i2 < len; ) { 14123 c6 = buf[i2++]; 14124 if (c6 < 128) { 14125 utf16buf[out++] = c6; 14126 continue; 14127 } 14128 c_len = _utf8len[c6]; 14129 if (c_len > 4) { 14130 utf16buf[out++] = 65533; 14131 i2 += c_len - 1; 14132 continue; 14133 } 14134 c6 &= c_len === 2 ? 31 : c_len === 3 ? 15 : 7; 14135 while (c_len > 1 && i2 < len) { 14136 c6 = c6 << 6 | buf[i2++] & 63; 14137 c_len--; 14138 } 14139 if (c_len > 1) { 14140 utf16buf[out++] = 65533; 14141 continue; 14142 } 14143 if (c6 < 65536) { 14144 utf16buf[out++] = c6; 14145 } else { 14146 c6 -= 65536; 14147 utf16buf[out++] = 55296 | c6 >> 10 & 1023; 14148 utf16buf[out++] = 56320 | c6 & 1023; 14149 } 14150 } 14151 return buf2binstring(utf16buf, out); 14152 }; 14153 exports3.utf8border = function(buf, max) { 14154 var pos; 14155 max = max || buf.length; 14156 if (max > buf.length) { 14157 max = buf.length; 14158 } 14159 pos = max - 1; 14160 while (pos >= 0 && (buf[pos] & 192) === 128) { 14161 pos--; 14162 } 14163 if (pos < 0) { 14164 return max; 14165 } 14166 if (pos === 0) { 14167 return max; 14168 } 14169 return pos + _utf8len[buf[pos]] > max ? pos : max; 14170 }; 14171 }, 14172 { "./common": 1 } 14173 ], 14174 3: [ 14175 function(require2, module3, exports3) { 14176 "use strict"; 14177 function adler32(adler, buf, len, pos) { 14178 var s1 = adler & 65535 | 0, s2 = adler >>> 16 & 65535 | 0, n2 = 0; 14179 while (len !== 0) { 14180 n2 = len > 2e3 ? 2e3 : len; 14181 len -= n2; 14182 do { 14183 s1 = s1 + buf[pos++] | 0; 14184 s2 = s2 + s1 | 0; 14185 } while (--n2); 14186 s1 %= 65521; 14187 s2 %= 65521; 14188 } 14189 return s1 | s2 << 16 | 0; 14190 } 14191 module3.exports = adler32; 14192 }, 14193 {} 14194 ], 14195 4: [ 14196 function(require2, module3, exports3) { 14197 "use strict"; 14198 module3.exports = { 14199 /* Allowed flush values; see deflate() and inflate() below for details */ 14200 Z_NO_FLUSH: 0, 14201 Z_PARTIAL_FLUSH: 1, 14202 Z_SYNC_FLUSH: 2, 14203 Z_FULL_FLUSH: 3, 14204 Z_FINISH: 4, 14205 Z_BLOCK: 5, 14206 Z_TREES: 6, 14207 /* Return codes for the compression/decompression functions. Negative values 14208 * are errors, positive values are used for special but normal events. 14209 */ 14210 Z_OK: 0, 14211 Z_STREAM_END: 1, 14212 Z_NEED_DICT: 2, 14213 Z_ERRNO: -1, 14214 Z_STREAM_ERROR: -2, 14215 Z_DATA_ERROR: -3, 14216 //Z_MEM_ERROR: -4, 14217 Z_BUF_ERROR: -5, 14218 //Z_VERSION_ERROR: -6, 14219 /* compression levels */ 14220 Z_NO_COMPRESSION: 0, 14221 Z_BEST_SPEED: 1, 14222 Z_BEST_COMPRESSION: 9, 14223 Z_DEFAULT_COMPRESSION: -1, 14224 Z_FILTERED: 1, 14225 Z_HUFFMAN_ONLY: 2, 14226 Z_RLE: 3, 14227 Z_FIXED: 4, 14228 Z_DEFAULT_STRATEGY: 0, 14229 /* Possible values of the data_type field (though see inflate()) */ 14230 Z_BINARY: 0, 14231 Z_TEXT: 1, 14232 //Z_ASCII: 1, // = Z_TEXT (deprecated) 14233 Z_UNKNOWN: 2, 14234 /* The deflate compression method */ 14235 Z_DEFLATED: 8 14236 //Z_NULL: null // Use -1 or null inline, depending on var type 14237 }; 14238 }, 14239 {} 14240 ], 14241 5: [ 14242 function(require2, module3, exports3) { 14243 "use strict"; 14244 function makeTable() { 14245 var c6, table = []; 14246 for (var n2 = 0; n2 < 256; n2++) { 14247 c6 = n2; 14248 for (var k2 = 0; k2 < 8; k2++) { 14249 c6 = c6 & 1 ? 3988292384 ^ c6 >>> 1 : c6 >>> 1; 14250 } 14251 table[n2] = c6; 14252 } 14253 return table; 14254 } 14255 var crcTable = makeTable(); 14256 function crc32(crc, buf, len, pos) { 14257 var t3 = crcTable, end = pos + len; 14258 crc ^= -1; 14259 for (var i2 = pos; i2 < end; i2++) { 14260 crc = crc >>> 8 ^ t3[(crc ^ buf[i2]) & 255]; 14261 } 14262 return crc ^ -1; 14263 } 14264 module3.exports = crc32; 14265 }, 14266 {} 14267 ], 14268 6: [ 14269 function(require2, module3, exports3) { 14270 "use strict"; 14271 function GZheader() { 14272 this.text = 0; 14273 this.time = 0; 14274 this.xflags = 0; 14275 this.os = 0; 14276 this.extra = null; 14277 this.extra_len = 0; 14278 this.name = ""; 14279 this.comment = ""; 14280 this.hcrc = 0; 14281 this.done = false; 14282 } 14283 module3.exports = GZheader; 14284 }, 14285 {} 14286 ], 14287 7: [ 14288 function(require2, module3, exports3) { 14289 "use strict"; 14290 var BAD = 30; 14291 var TYPE = 12; 14292 module3.exports = function inflate_fast(strm, start2) { 14293 var state; 14294 var _in; 14295 var last; 14296 var _out; 14297 var beg; 14298 var end; 14299 var dmax; 14300 var wsize; 14301 var whave; 14302 var wnext; 14303 var s_window; 14304 var hold; 14305 var bits; 14306 var lcode; 14307 var dcode; 14308 var lmask; 14309 var dmask; 14310 var here; 14311 var op; 14312 var len; 14313 var dist; 14314 var from; 14315 var from_source; 14316 var input, output; 14317 state = strm.state; 14318 _in = strm.next_in; 14319 input = strm.input; 14320 last = _in + (strm.avail_in - 5); 14321 _out = strm.next_out; 14322 output = strm.output; 14323 beg = _out - (start2 - strm.avail_out); 14324 end = _out + (strm.avail_out - 257); 14325 dmax = state.dmax; 14326 wsize = state.wsize; 14327 whave = state.whave; 14328 wnext = state.wnext; 14329 s_window = state.window; 14330 hold = state.hold; 14331 bits = state.bits; 14332 lcode = state.lencode; 14333 dcode = state.distcode; 14334 lmask = (1 << state.lenbits) - 1; 14335 dmask = (1 << state.distbits) - 1; 14336 top: do { 14337 if (bits < 15) { 14338 hold += input[_in++] << bits; 14339 bits += 8; 14340 hold += input[_in++] << bits; 14341 bits += 8; 14342 } 14343 here = lcode[hold & lmask]; 14344 dolen: for (; ; ) { 14345 op = here >>> 24; 14346 hold >>>= op; 14347 bits -= op; 14348 op = here >>> 16 & 255; 14349 if (op === 0) { 14350 output[_out++] = here & 65535; 14351 } else if (op & 16) { 14352 len = here & 65535; 14353 op &= 15; 14354 if (op) { 14355 if (bits < op) { 14356 hold += input[_in++] << bits; 14357 bits += 8; 14358 } 14359 len += hold & (1 << op) - 1; 14360 hold >>>= op; 14361 bits -= op; 14362 } 14363 if (bits < 15) { 14364 hold += input[_in++] << bits; 14365 bits += 8; 14366 hold += input[_in++] << bits; 14367 bits += 8; 14368 } 14369 here = dcode[hold & dmask]; 14370 dodist: for (; ; ) { 14371 op = here >>> 24; 14372 hold >>>= op; 14373 bits -= op; 14374 op = here >>> 16 & 255; 14375 if (op & 16) { 14376 dist = here & 65535; 14377 op &= 15; 14378 if (bits < op) { 14379 hold += input[_in++] << bits; 14380 bits += 8; 14381 if (bits < op) { 14382 hold += input[_in++] << bits; 14383 bits += 8; 14384 } 14385 } 14386 dist += hold & (1 << op) - 1; 14387 if (dist > dmax) { 14388 strm.msg = "invalid distance too far back"; 14389 state.mode = BAD; 14390 break top; 14391 } 14392 hold >>>= op; 14393 bits -= op; 14394 op = _out - beg; 14395 if (dist > op) { 14396 op = dist - op; 14397 if (op > whave) { 14398 if (state.sane) { 14399 strm.msg = "invalid distance too far back"; 14400 state.mode = BAD; 14401 break top; 14402 } 14403 } 14404 from = 0; 14405 from_source = s_window; 14406 if (wnext === 0) { 14407 from += wsize - op; 14408 if (op < len) { 14409 len -= op; 14410 do { 14411 output[_out++] = s_window[from++]; 14412 } while (--op); 14413 from = _out - dist; 14414 from_source = output; 14415 } 14416 } else if (wnext < op) { 14417 from += wsize + wnext - op; 14418 op -= wnext; 14419 if (op < len) { 14420 len -= op; 14421 do { 14422 output[_out++] = s_window[from++]; 14423 } while (--op); 14424 from = 0; 14425 if (wnext < len) { 14426 op = wnext; 14427 len -= op; 14428 do { 14429 output[_out++] = s_window[from++]; 14430 } while (--op); 14431 from = _out - dist; 14432 from_source = output; 14433 } 14434 } 14435 } else { 14436 from += wnext - op; 14437 if (op < len) { 14438 len -= op; 14439 do { 14440 output[_out++] = s_window[from++]; 14441 } while (--op); 14442 from = _out - dist; 14443 from_source = output; 14444 } 14445 } 14446 while (len > 2) { 14447 output[_out++] = from_source[from++]; 14448 output[_out++] = from_source[from++]; 14449 output[_out++] = from_source[from++]; 14450 len -= 3; 14451 } 14452 if (len) { 14453 output[_out++] = from_source[from++]; 14454 if (len > 1) { 14455 output[_out++] = from_source[from++]; 14456 } 14457 } 14458 } else { 14459 from = _out - dist; 14460 do { 14461 output[_out++] = output[from++]; 14462 output[_out++] = output[from++]; 14463 output[_out++] = output[from++]; 14464 len -= 3; 14465 } while (len > 2); 14466 if (len) { 14467 output[_out++] = output[from++]; 14468 if (len > 1) { 14469 output[_out++] = output[from++]; 14470 } 14471 } 14472 } 14473 } else if ((op & 64) === 0) { 14474 here = dcode[(here & 65535) + (hold & (1 << op) - 1)]; 14475 continue dodist; 14476 } else { 14477 strm.msg = "invalid distance code"; 14478 state.mode = BAD; 14479 break top; 14480 } 14481 break; 14482 } 14483 } else if ((op & 64) === 0) { 14484 here = lcode[(here & 65535) + (hold & (1 << op) - 1)]; 14485 continue dolen; 14486 } else if (op & 32) { 14487 state.mode = TYPE; 14488 break top; 14489 } else { 14490 strm.msg = "invalid literal/length code"; 14491 state.mode = BAD; 14492 break top; 14493 } 14494 break; 14495 } 14496 } while (_in < last && _out < end); 14497 len = bits >> 3; 14498 _in -= len; 14499 bits -= len << 3; 14500 hold &= (1 << bits) - 1; 14501 strm.next_in = _in; 14502 strm.next_out = _out; 14503 strm.avail_in = _in < last ? 5 + (last - _in) : 5 - (_in - last); 14504 strm.avail_out = _out < end ? 257 + (end - _out) : 257 - (_out - end); 14505 state.hold = hold; 14506 state.bits = bits; 14507 return; 14508 }; 14509 }, 14510 {} 14511 ], 14512 8: [ 14513 function(require2, module3, exports3) { 14514 "use strict"; 14515 var utils = require2("../utils/common"); 14516 var adler32 = require2("./adler32"); 14517 var crc32 = require2("./crc32"); 14518 var inflate_fast = require2("./inffast"); 14519 var inflate_table = require2("./inftrees"); 14520 var CODES = 0; 14521 var LENS = 1; 14522 var DISTS = 2; 14523 var Z_FINISH = 4; 14524 var Z_BLOCK = 5; 14525 var Z_TREES = 6; 14526 var Z_OK = 0; 14527 var Z_STREAM_END = 1; 14528 var Z_NEED_DICT = 2; 14529 var Z_STREAM_ERROR = -2; 14530 var Z_DATA_ERROR = -3; 14531 var Z_MEM_ERROR = -4; 14532 var Z_BUF_ERROR = -5; 14533 var Z_DEFLATED = 8; 14534 var HEAD = 1; 14535 var FLAGS = 2; 14536 var TIME = 3; 14537 var OS = 4; 14538 var EXLEN = 5; 14539 var EXTRA = 6; 14540 var NAME = 7; 14541 var COMMENT = 8; 14542 var HCRC = 9; 14543 var DICTID = 10; 14544 var DICT = 11; 14545 var TYPE = 12; 14546 var TYPEDO = 13; 14547 var STORED = 14; 14548 var COPY_ = 15; 14549 var COPY = 16; 14550 var TABLE = 17; 14551 var LENLENS = 18; 14552 var CODELENS = 19; 14553 var LEN_ = 20; 14554 var LEN = 21; 14555 var LENEXT = 22; 14556 var DIST = 23; 14557 var DISTEXT = 24; 14558 var MATCH = 25; 14559 var LIT = 26; 14560 var CHECK = 27; 14561 var LENGTH = 28; 14562 var DONE = 29; 14563 var BAD = 30; 14564 var MEM = 31; 14565 var SYNC = 32; 14566 var ENOUGH_LENS = 852; 14567 var ENOUGH_DISTS = 592; 14568 var MAX_WBITS = 15; 14569 var DEF_WBITS = MAX_WBITS; 14570 function zswap32(q) { 14571 return (q >>> 24 & 255) + (q >>> 8 & 65280) + ((q & 65280) << 8) + ((q & 255) << 24); 14572 } 14573 function InflateState() { 14574 this.mode = 0; 14575 this.last = false; 14576 this.wrap = 0; 14577 this.havedict = false; 14578 this.flags = 0; 14579 this.dmax = 0; 14580 this.check = 0; 14581 this.total = 0; 14582 this.head = null; 14583 this.wbits = 0; 14584 this.wsize = 0; 14585 this.whave = 0; 14586 this.wnext = 0; 14587 this.window = null; 14588 this.hold = 0; 14589 this.bits = 0; 14590 this.length = 0; 14591 this.offset = 0; 14592 this.extra = 0; 14593 this.lencode = null; 14594 this.distcode = null; 14595 this.lenbits = 0; 14596 this.distbits = 0; 14597 this.ncode = 0; 14598 this.nlen = 0; 14599 this.ndist = 0; 14600 this.have = 0; 14601 this.next = null; 14602 this.lens = new utils.Buf16( 14603 320 14604 ); 14605 this.work = new utils.Buf16( 14606 288 14607 ); 14608 this.lendyn = null; 14609 this.distdyn = null; 14610 this.sane = 0; 14611 this.back = 0; 14612 this.was = 0; 14613 } 14614 function inflateResetKeep(strm) { 14615 var state; 14616 if (!strm || !strm.state) { 14617 return Z_STREAM_ERROR; 14618 } 14619 state = strm.state; 14620 strm.total_in = strm.total_out = state.total = 0; 14621 strm.msg = ""; 14622 if (state.wrap) { 14623 strm.adler = state.wrap & 1; 14624 } 14625 state.mode = HEAD; 14626 state.last = 0; 14627 state.havedict = 0; 14628 state.dmax = 32768; 14629 state.head = null; 14630 state.hold = 0; 14631 state.bits = 0; 14632 state.lencode = state.lendyn = new utils.Buf32( 14633 ENOUGH_LENS 14634 ); 14635 state.distcode = state.distdyn = new utils.Buf32( 14636 ENOUGH_DISTS 14637 ); 14638 state.sane = 1; 14639 state.back = -1; 14640 return Z_OK; 14641 } 14642 function inflateReset(strm) { 14643 var state; 14644 if (!strm || !strm.state) { 14645 return Z_STREAM_ERROR; 14646 } 14647 state = strm.state; 14648 state.wsize = 0; 14649 state.whave = 0; 14650 state.wnext = 0; 14651 return inflateResetKeep(strm); 14652 } 14653 function inflateReset2(strm, windowBits) { 14654 var wrap; 14655 var state; 14656 if (!strm || !strm.state) { 14657 return Z_STREAM_ERROR; 14658 } 14659 state = strm.state; 14660 if (windowBits < 0) { 14661 wrap = 0; 14662 windowBits = -windowBits; 14663 } else { 14664 wrap = (windowBits >> 4) + 1; 14665 if (windowBits < 48) { 14666 windowBits &= 15; 14667 } 14668 } 14669 if (windowBits && (windowBits < 8 || windowBits > 15)) { 14670 return Z_STREAM_ERROR; 14671 } 14672 if (state.window !== null && state.wbits !== windowBits) { 14673 state.window = null; 14674 } 14675 state.wrap = wrap; 14676 state.wbits = windowBits; 14677 return inflateReset(strm); 14678 } 14679 function inflateInit2(strm, windowBits) { 14680 var ret; 14681 var state; 14682 if (!strm) { 14683 return Z_STREAM_ERROR; 14684 } 14685 state = new InflateState(); 14686 strm.state = state; 14687 state.window = null; 14688 ret = inflateReset2(strm, windowBits); 14689 if (ret !== Z_OK) { 14690 strm.state = null; 14691 } 14692 return ret; 14693 } 14694 function inflateInit(strm) { 14695 return inflateInit2(strm, DEF_WBITS); 14696 } 14697 var virgin = true; 14698 var lenfix, distfix; 14699 function fixedtables(state) { 14700 if (virgin) { 14701 var sym; 14702 lenfix = new utils.Buf32(512); 14703 distfix = new utils.Buf32(32); 14704 sym = 0; 14705 while (sym < 144) { 14706 state.lens[sym++] = 8; 14707 } 14708 while (sym < 256) { 14709 state.lens[sym++] = 9; 14710 } 14711 while (sym < 280) { 14712 state.lens[sym++] = 7; 14713 } 14714 while (sym < 288) { 14715 state.lens[sym++] = 8; 14716 } 14717 inflate_table( 14718 LENS, 14719 state.lens, 14720 0, 14721 288, 14722 lenfix, 14723 0, 14724 state.work, 14725 { bits: 9 } 14726 ); 14727 sym = 0; 14728 while (sym < 32) { 14729 state.lens[sym++] = 5; 14730 } 14731 inflate_table( 14732 DISTS, 14733 state.lens, 14734 0, 14735 32, 14736 distfix, 14737 0, 14738 state.work, 14739 { bits: 5 } 14740 ); 14741 virgin = false; 14742 } 14743 state.lencode = lenfix; 14744 state.lenbits = 9; 14745 state.distcode = distfix; 14746 state.distbits = 5; 14747 } 14748 function updatewindow(strm, src, end, copy) { 14749 var dist; 14750 var state = strm.state; 14751 if (state.window === null) { 14752 state.wsize = 1 << state.wbits; 14753 state.wnext = 0; 14754 state.whave = 0; 14755 state.window = new utils.Buf8(state.wsize); 14756 } 14757 if (copy >= state.wsize) { 14758 utils.arraySet( 14759 state.window, 14760 src, 14761 end - state.wsize, 14762 state.wsize, 14763 0 14764 ); 14765 state.wnext = 0; 14766 state.whave = state.wsize; 14767 } else { 14768 dist = state.wsize - state.wnext; 14769 if (dist > copy) { 14770 dist = copy; 14771 } 14772 utils.arraySet( 14773 state.window, 14774 src, 14775 end - copy, 14776 dist, 14777 state.wnext 14778 ); 14779 copy -= dist; 14780 if (copy) { 14781 utils.arraySet( 14782 state.window, 14783 src, 14784 end - copy, 14785 copy, 14786 0 14787 ); 14788 state.wnext = copy; 14789 state.whave = state.wsize; 14790 } else { 14791 state.wnext += dist; 14792 if (state.wnext === state.wsize) { 14793 state.wnext = 0; 14794 } 14795 if (state.whave < state.wsize) { 14796 state.whave += dist; 14797 } 14798 } 14799 } 14800 return 0; 14801 } 14802 function inflate(strm, flush2) { 14803 var state; 14804 var input, output; 14805 var next; 14806 var put; 14807 var have, left; 14808 var hold; 14809 var bits; 14810 var _in, _out; 14811 var copy; 14812 var from; 14813 var from_source; 14814 var here = 0; 14815 var here_bits, here_op, here_val; 14816 var last_bits, last_op, last_val; 14817 var len; 14818 var ret; 14819 var hbuf = new utils.Buf8( 14820 4 14821 ); 14822 var opts; 14823 var n2; 14824 var order = ( 14825 /* permutation of code lengths */ 14826 [ 14827 16, 14828 17, 14829 18, 14830 0, 14831 8, 14832 7, 14833 9, 14834 6, 14835 10, 14836 5, 14837 11, 14838 4, 14839 12, 14840 3, 14841 13, 14842 2, 14843 14, 14844 1, 14845 15 14846 ] 14847 ); 14848 if (!strm || !strm.state || !strm.output || !strm.input && strm.avail_in !== 0) { 14849 return Z_STREAM_ERROR; 14850 } 14851 state = strm.state; 14852 if (state.mode === TYPE) { 14853 state.mode = TYPEDO; 14854 } 14855 put = strm.next_out; 14856 output = strm.output; 14857 left = strm.avail_out; 14858 next = strm.next_in; 14859 input = strm.input; 14860 have = strm.avail_in; 14861 hold = state.hold; 14862 bits = state.bits; 14863 _in = have; 14864 _out = left; 14865 ret = Z_OK; 14866 inf_leave: for (; ; ) { 14867 switch (state.mode) { 14868 case HEAD: 14869 if (state.wrap === 0) { 14870 state.mode = TYPEDO; 14871 break; 14872 } 14873 while (bits < 16) { 14874 if (have === 0) { 14875 break inf_leave; 14876 } 14877 have--; 14878 hold += input[next++] << bits; 14879 bits += 8; 14880 } 14881 if (state.wrap & 2 && hold === 35615) { 14882 state.check = 0; 14883 hbuf[0] = hold & 255; 14884 hbuf[1] = hold >>> 8 & 255; 14885 state.check = crc32( 14886 state.check, 14887 hbuf, 14888 2, 14889 0 14890 ); 14891 hold = 0; 14892 bits = 0; 14893 state.mode = FLAGS; 14894 break; 14895 } 14896 state.flags = 0; 14897 if (state.head) { 14898 state.head.done = false; 14899 } 14900 if (!(state.wrap & 1) || (((hold & 255) << 8) + (hold >> 8)) % 31) { 14901 strm.msg = "incorrect header check"; 14902 state.mode = BAD; 14903 break; 14904 } 14905 if ((hold & 15) !== Z_DEFLATED) { 14906 strm.msg = "unknown compression method"; 14907 state.mode = BAD; 14908 break; 14909 } 14910 hold >>>= 4; 14911 bits -= 4; 14912 len = (hold & 15) + 8; 14913 if (state.wbits === 0) { 14914 state.wbits = len; 14915 } else if (len > state.wbits) { 14916 strm.msg = "invalid window size"; 14917 state.mode = BAD; 14918 break; 14919 } 14920 state.dmax = 1 << len; 14921 strm.adler = state.check = 1; 14922 state.mode = hold & 512 ? DICTID : TYPE; 14923 hold = 0; 14924 bits = 0; 14925 break; 14926 case FLAGS: 14927 while (bits < 16) { 14928 if (have === 0) { 14929 break inf_leave; 14930 } 14931 have--; 14932 hold += input[next++] << bits; 14933 bits += 8; 14934 } 14935 state.flags = hold; 14936 if ((state.flags & 255) !== Z_DEFLATED) { 14937 strm.msg = "unknown compression method"; 14938 state.mode = BAD; 14939 break; 14940 } 14941 if (state.flags & 57344) { 14942 strm.msg = "unknown header flags set"; 14943 state.mode = BAD; 14944 break; 14945 } 14946 if (state.head) { 14947 state.head.text = hold >> 8 & 1; 14948 } 14949 if (state.flags & 512) { 14950 hbuf[0] = hold & 255; 14951 hbuf[1] = hold >>> 8 & 255; 14952 state.check = crc32( 14953 state.check, 14954 hbuf, 14955 2, 14956 0 14957 ); 14958 } 14959 hold = 0; 14960 bits = 0; 14961 state.mode = TIME; 14962 /* falls through */ 14963 case TIME: 14964 while (bits < 32) { 14965 if (have === 0) { 14966 break inf_leave; 14967 } 14968 have--; 14969 hold += input[next++] << bits; 14970 bits += 8; 14971 } 14972 if (state.head) { 14973 state.head.time = hold; 14974 } 14975 if (state.flags & 512) { 14976 hbuf[0] = hold & 255; 14977 hbuf[1] = hold >>> 8 & 255; 14978 hbuf[2] = hold >>> 16 & 255; 14979 hbuf[3] = hold >>> 24 & 255; 14980 state.check = crc32( 14981 state.check, 14982 hbuf, 14983 4, 14984 0 14985 ); 14986 } 14987 hold = 0; 14988 bits = 0; 14989 state.mode = OS; 14990 /* falls through */ 14991 case OS: 14992 while (bits < 16) { 14993 if (have === 0) { 14994 break inf_leave; 14995 } 14996 have--; 14997 hold += input[next++] << bits; 14998 bits += 8; 14999 } 15000 if (state.head) { 15001 state.head.xflags = hold & 255; 15002 state.head.os = hold >> 8; 15003 } 15004 if (state.flags & 512) { 15005 hbuf[0] = hold & 255; 15006 hbuf[1] = hold >>> 8 & 255; 15007 state.check = crc32( 15008 state.check, 15009 hbuf, 15010 2, 15011 0 15012 ); 15013 } 15014 hold = 0; 15015 bits = 0; 15016 state.mode = EXLEN; 15017 /* falls through */ 15018 case EXLEN: 15019 if (state.flags & 1024) { 15020 while (bits < 16) { 15021 if (have === 0) { 15022 break inf_leave; 15023 } 15024 have--; 15025 hold += input[next++] << bits; 15026 bits += 8; 15027 } 15028 state.length = hold; 15029 if (state.head) { 15030 state.head.extra_len = hold; 15031 } 15032 if (state.flags & 512) { 15033 hbuf[0] = hold & 255; 15034 hbuf[1] = hold >>> 8 & 255; 15035 state.check = crc32( 15036 state.check, 15037 hbuf, 15038 2, 15039 0 15040 ); 15041 } 15042 hold = 0; 15043 bits = 0; 15044 } else if (state.head) { 15045 state.head.extra = null; 15046 } 15047 state.mode = EXTRA; 15048 /* falls through */ 15049 case EXTRA: 15050 if (state.flags & 1024) { 15051 copy = state.length; 15052 if (copy > have) { 15053 copy = have; 15054 } 15055 if (copy) { 15056 if (state.head) { 15057 len = state.head.extra_len - state.length; 15058 if (!state.head.extra) { 15059 state.head.extra = new Array( 15060 state.head.extra_len 15061 ); 15062 } 15063 utils.arraySet( 15064 state.head.extra, 15065 input, 15066 next, 15067 // extra field is limited to 65536 bytes 15068 // - no need for additional size check 15069 copy, 15070 /*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/ 15071 len 15072 ); 15073 } 15074 if (state.flags & 512) { 15075 state.check = crc32( 15076 state.check, 15077 input, 15078 copy, 15079 next 15080 ); 15081 } 15082 have -= copy; 15083 next += copy; 15084 state.length -= copy; 15085 } 15086 if (state.length) { 15087 break inf_leave; 15088 } 15089 } 15090 state.length = 0; 15091 state.mode = NAME; 15092 /* falls through */ 15093 case NAME: 15094 if (state.flags & 2048) { 15095 if (have === 0) { 15096 break inf_leave; 15097 } 15098 copy = 0; 15099 do { 15100 len = input[next + copy++]; 15101 if (state.head && len && state.length < 65536) { 15102 state.head.name += String.fromCharCode(len); 15103 } 15104 } while (len && copy < have); 15105 if (state.flags & 512) { 15106 state.check = crc32( 15107 state.check, 15108 input, 15109 copy, 15110 next 15111 ); 15112 } 15113 have -= copy; 15114 next += copy; 15115 if (len) { 15116 break inf_leave; 15117 } 15118 } else if (state.head) { 15119 state.head.name = null; 15120 } 15121 state.length = 0; 15122 state.mode = COMMENT; 15123 /* falls through */ 15124 case COMMENT: 15125 if (state.flags & 4096) { 15126 if (have === 0) { 15127 break inf_leave; 15128 } 15129 copy = 0; 15130 do { 15131 len = input[next + copy++]; 15132 if (state.head && len && state.length < 65536) { 15133 state.head.comment += String.fromCharCode(len); 15134 } 15135 } while (len && copy < have); 15136 if (state.flags & 512) { 15137 state.check = crc32( 15138 state.check, 15139 input, 15140 copy, 15141 next 15142 ); 15143 } 15144 have -= copy; 15145 next += copy; 15146 if (len) { 15147 break inf_leave; 15148 } 15149 } else if (state.head) { 15150 state.head.comment = null; 15151 } 15152 state.mode = HCRC; 15153 /* falls through */ 15154 case HCRC: 15155 if (state.flags & 512) { 15156 while (bits < 16) { 15157 if (have === 0) { 15158 break inf_leave; 15159 } 15160 have--; 15161 hold += input[next++] << bits; 15162 bits += 8; 15163 } 15164 if (hold !== (state.check & 65535)) { 15165 strm.msg = "header crc mismatch"; 15166 state.mode = BAD; 15167 break; 15168 } 15169 hold = 0; 15170 bits = 0; 15171 } 15172 if (state.head) { 15173 state.head.hcrc = state.flags >> 9 & 1; 15174 state.head.done = true; 15175 } 15176 strm.adler = state.check = 0; 15177 state.mode = TYPE; 15178 break; 15179 case DICTID: 15180 while (bits < 32) { 15181 if (have === 0) { 15182 break inf_leave; 15183 } 15184 have--; 15185 hold += input[next++] << bits; 15186 bits += 8; 15187 } 15188 strm.adler = state.check = zswap32(hold); 15189 hold = 0; 15190 bits = 0; 15191 state.mode = DICT; 15192 /* falls through */ 15193 case DICT: 15194 if (state.havedict === 0) { 15195 strm.next_out = put; 15196 strm.avail_out = left; 15197 strm.next_in = next; 15198 strm.avail_in = have; 15199 state.hold = hold; 15200 state.bits = bits; 15201 return Z_NEED_DICT; 15202 } 15203 strm.adler = state.check = 1; 15204 state.mode = TYPE; 15205 /* falls through */ 15206 case TYPE: 15207 if (flush2 === Z_BLOCK || flush2 === Z_TREES) { 15208 break inf_leave; 15209 } 15210 /* falls through */ 15211 case TYPEDO: 15212 if (state.last) { 15213 hold >>>= bits & 7; 15214 bits -= bits & 7; 15215 state.mode = CHECK; 15216 break; 15217 } 15218 while (bits < 3) { 15219 if (have === 0) { 15220 break inf_leave; 15221 } 15222 have--; 15223 hold += input[next++] << bits; 15224 bits += 8; 15225 } 15226 state.last = hold & 1; 15227 hold >>>= 1; 15228 bits -= 1; 15229 switch (hold & 3) { 15230 case 0: 15231 state.mode = STORED; 15232 break; 15233 case 1: 15234 fixedtables(state); 15235 state.mode = LEN_; 15236 if (flush2 === Z_TREES) { 15237 hold >>>= 2; 15238 bits -= 2; 15239 break inf_leave; 15240 } 15241 break; 15242 case 2: 15243 state.mode = TABLE; 15244 break; 15245 case 3: 15246 strm.msg = "invalid block type"; 15247 state.mode = BAD; 15248 } 15249 hold >>>= 2; 15250 bits -= 2; 15251 break; 15252 case STORED: 15253 hold >>>= bits & 7; 15254 bits -= bits & 7; 15255 while (bits < 32) { 15256 if (have === 0) { 15257 break inf_leave; 15258 } 15259 have--; 15260 hold += input[next++] << bits; 15261 bits += 8; 15262 } 15263 if ((hold & 65535) !== (hold >>> 16 ^ 65535)) { 15264 strm.msg = "invalid stored block lengths"; 15265 state.mode = BAD; 15266 break; 15267 } 15268 state.length = hold & 65535; 15269 hold = 0; 15270 bits = 0; 15271 state.mode = COPY_; 15272 if (flush2 === Z_TREES) { 15273 break inf_leave; 15274 } 15275 /* falls through */ 15276 case COPY_: 15277 state.mode = COPY; 15278 /* falls through */ 15279 case COPY: 15280 copy = state.length; 15281 if (copy) { 15282 if (copy > have) { 15283 copy = have; 15284 } 15285 if (copy > left) { 15286 copy = left; 15287 } 15288 if (copy === 0) { 15289 break inf_leave; 15290 } 15291 utils.arraySet( 15292 output, 15293 input, 15294 next, 15295 copy, 15296 put 15297 ); 15298 have -= copy; 15299 next += copy; 15300 left -= copy; 15301 put += copy; 15302 state.length -= copy; 15303 break; 15304 } 15305 state.mode = TYPE; 15306 break; 15307 case TABLE: 15308 while (bits < 14) { 15309 if (have === 0) { 15310 break inf_leave; 15311 } 15312 have--; 15313 hold += input[next++] << bits; 15314 bits += 8; 15315 } 15316 state.nlen = (hold & 31) + 257; 15317 hold >>>= 5; 15318 bits -= 5; 15319 state.ndist = (hold & 31) + 1; 15320 hold >>>= 5; 15321 bits -= 5; 15322 state.ncode = (hold & 15) + 4; 15323 hold >>>= 4; 15324 bits -= 4; 15325 if (state.nlen > 286 || state.ndist > 30) { 15326 strm.msg = "too many length or distance symbols"; 15327 state.mode = BAD; 15328 break; 15329 } 15330 state.have = 0; 15331 state.mode = LENLENS; 15332 /* falls through */ 15333 case LENLENS: 15334 while (state.have < state.ncode) { 15335 while (bits < 3) { 15336 if (have === 0) { 15337 break inf_leave; 15338 } 15339 have--; 15340 hold += input[next++] << bits; 15341 bits += 8; 15342 } 15343 state.lens[order[state.have++]] = hold & 7; 15344 hold >>>= 3; 15345 bits -= 3; 15346 } 15347 while (state.have < 19) { 15348 state.lens[order[state.have++]] = 0; 15349 } 15350 state.lencode = state.lendyn; 15351 state.lenbits = 7; 15352 opts = { bits: state.lenbits }; 15353 ret = inflate_table( 15354 CODES, 15355 state.lens, 15356 0, 15357 19, 15358 state.lencode, 15359 0, 15360 state.work, 15361 opts 15362 ); 15363 state.lenbits = opts.bits; 15364 if (ret) { 15365 strm.msg = "invalid code lengths set"; 15366 state.mode = BAD; 15367 break; 15368 } 15369 state.have = 0; 15370 state.mode = CODELENS; 15371 /* falls through */ 15372 case CODELENS: 15373 while (state.have < state.nlen + state.ndist) { 15374 for (; ; ) { 15375 here = state.lencode[hold & (1 << state.lenbits) - 1]; 15376 here_bits = here >>> 24; 15377 here_op = here >>> 16 & 255; 15378 here_val = here & 65535; 15379 if (here_bits <= bits) { 15380 break; 15381 } 15382 if (have === 0) { 15383 break inf_leave; 15384 } 15385 have--; 15386 hold += input[next++] << bits; 15387 bits += 8; 15388 } 15389 if (here_val < 16) { 15390 hold >>>= here_bits; 15391 bits -= here_bits; 15392 state.lens[state.have++] = here_val; 15393 } else { 15394 if (here_val === 16) { 15395 n2 = here_bits + 2; 15396 while (bits < n2) { 15397 if (have === 0) { 15398 break inf_leave; 15399 } 15400 have--; 15401 hold += input[next++] << bits; 15402 bits += 8; 15403 } 15404 hold >>>= here_bits; 15405 bits -= here_bits; 15406 if (state.have === 0) { 15407 strm.msg = "invalid bit length repeat"; 15408 state.mode = BAD; 15409 break; 15410 } 15411 len = state.lens[state.have - 1]; 15412 copy = 3 + (hold & 3); 15413 hold >>>= 2; 15414 bits -= 2; 15415 } else if (here_val === 17) { 15416 n2 = here_bits + 3; 15417 while (bits < n2) { 15418 if (have === 0) { 15419 break inf_leave; 15420 } 15421 have--; 15422 hold += input[next++] << bits; 15423 bits += 8; 15424 } 15425 hold >>>= here_bits; 15426 bits -= here_bits; 15427 len = 0; 15428 copy = 3 + (hold & 7); 15429 hold >>>= 3; 15430 bits -= 3; 15431 } else { 15432 n2 = here_bits + 7; 15433 while (bits < n2) { 15434 if (have === 0) { 15435 break inf_leave; 15436 } 15437 have--; 15438 hold += input[next++] << bits; 15439 bits += 8; 15440 } 15441 hold >>>= here_bits; 15442 bits -= here_bits; 15443 len = 0; 15444 copy = 11 + (hold & 127); 15445 hold >>>= 7; 15446 bits -= 7; 15447 } 15448 if (state.have + copy > state.nlen + state.ndist) { 15449 strm.msg = "invalid bit length repeat"; 15450 state.mode = BAD; 15451 break; 15452 } 15453 while (copy--) { 15454 state.lens[state.have++] = len; 15455 } 15456 } 15457 } 15458 if (state.mode === BAD) { 15459 break; 15460 } 15461 if (state.lens[256] === 0) { 15462 strm.msg = "invalid code -- missing end-of-block"; 15463 state.mode = BAD; 15464 break; 15465 } 15466 state.lenbits = 9; 15467 opts = { bits: state.lenbits }; 15468 ret = inflate_table( 15469 LENS, 15470 state.lens, 15471 0, 15472 state.nlen, 15473 state.lencode, 15474 0, 15475 state.work, 15476 opts 15477 ); 15478 state.lenbits = opts.bits; 15479 if (ret) { 15480 strm.msg = "invalid literal/lengths set"; 15481 state.mode = BAD; 15482 break; 15483 } 15484 state.distbits = 6; 15485 state.distcode = state.distdyn; 15486 opts = { bits: state.distbits }; 15487 ret = inflate_table( 15488 DISTS, 15489 state.lens, 15490 state.nlen, 15491 state.ndist, 15492 state.distcode, 15493 0, 15494 state.work, 15495 opts 15496 ); 15497 state.distbits = opts.bits; 15498 if (ret) { 15499 strm.msg = "invalid distances set"; 15500 state.mode = BAD; 15501 break; 15502 } 15503 state.mode = LEN_; 15504 if (flush2 === Z_TREES) { 15505 break inf_leave; 15506 } 15507 /* falls through */ 15508 case LEN_: 15509 state.mode = LEN; 15510 /* falls through */ 15511 case LEN: 15512 if (have >= 6 && left >= 258) { 15513 strm.next_out = put; 15514 strm.avail_out = left; 15515 strm.next_in = next; 15516 strm.avail_in = have; 15517 state.hold = hold; 15518 state.bits = bits; 15519 inflate_fast(strm, _out); 15520 put = strm.next_out; 15521 output = strm.output; 15522 left = strm.avail_out; 15523 next = strm.next_in; 15524 input = strm.input; 15525 have = strm.avail_in; 15526 hold = state.hold; 15527 bits = state.bits; 15528 if (state.mode === TYPE) { 15529 state.back = -1; 15530 } 15531 break; 15532 } 15533 state.back = 0; 15534 for (; ; ) { 15535 here = state.lencode[hold & (1 << state.lenbits) - 1]; 15536 here_bits = here >>> 24; 15537 here_op = here >>> 16 & 255; 15538 here_val = here & 65535; 15539 if (here_bits <= bits) { 15540 break; 15541 } 15542 if (have === 0) { 15543 break inf_leave; 15544 } 15545 have--; 15546 hold += input[next++] << bits; 15547 bits += 8; 15548 } 15549 if (here_op && (here_op & 240) === 0) { 15550 last_bits = here_bits; 15551 last_op = here_op; 15552 last_val = here_val; 15553 for (; ; ) { 15554 here = state.lencode[last_val + ((hold & (1 << last_bits + last_op) - 1) >> last_bits)]; 15555 here_bits = here >>> 24; 15556 here_op = here >>> 16 & 255; 15557 here_val = here & 65535; 15558 if (last_bits + here_bits <= bits) { 15559 break; 15560 } 15561 if (have === 0) { 15562 break inf_leave; 15563 } 15564 have--; 15565 hold += input[next++] << bits; 15566 bits += 8; 15567 } 15568 hold >>>= last_bits; 15569 bits -= last_bits; 15570 state.back += last_bits; 15571 } 15572 hold >>>= here_bits; 15573 bits -= here_bits; 15574 state.back += here_bits; 15575 state.length = here_val; 15576 if (here_op === 0) { 15577 state.mode = LIT; 15578 break; 15579 } 15580 if (here_op & 32) { 15581 state.back = -1; 15582 state.mode = TYPE; 15583 break; 15584 } 15585 if (here_op & 64) { 15586 strm.msg = "invalid literal/length code"; 15587 state.mode = BAD; 15588 break; 15589 } 15590 state.extra = here_op & 15; 15591 state.mode = LENEXT; 15592 /* falls through */ 15593 case LENEXT: 15594 if (state.extra) { 15595 n2 = state.extra; 15596 while (bits < n2) { 15597 if (have === 0) { 15598 break inf_leave; 15599 } 15600 have--; 15601 hold += input[next++] << bits; 15602 bits += 8; 15603 } 15604 state.length += hold & (1 << state.extra) - 1; 15605 hold >>>= state.extra; 15606 bits -= state.extra; 15607 state.back += state.extra; 15608 } 15609 state.was = state.length; 15610 state.mode = DIST; 15611 /* falls through */ 15612 case DIST: 15613 for (; ; ) { 15614 here = state.distcode[hold & (1 << state.distbits) - 1]; 15615 here_bits = here >>> 24; 15616 here_op = here >>> 16 & 255; 15617 here_val = here & 65535; 15618 if (here_bits <= bits) { 15619 break; 15620 } 15621 if (have === 0) { 15622 break inf_leave; 15623 } 15624 have--; 15625 hold += input[next++] << bits; 15626 bits += 8; 15627 } 15628 if ((here_op & 240) === 0) { 15629 last_bits = here_bits; 15630 last_op = here_op; 15631 last_val = here_val; 15632 for (; ; ) { 15633 here = state.distcode[last_val + ((hold & (1 << last_bits + last_op) - 1) >> last_bits)]; 15634 here_bits = here >>> 24; 15635 here_op = here >>> 16 & 255; 15636 here_val = here & 65535; 15637 if (last_bits + here_bits <= bits) { 15638 break; 15639 } 15640 if (have === 0) { 15641 break inf_leave; 15642 } 15643 have--; 15644 hold += input[next++] << bits; 15645 bits += 8; 15646 } 15647 hold >>>= last_bits; 15648 bits -= last_bits; 15649 state.back += last_bits; 15650 } 15651 hold >>>= here_bits; 15652 bits -= here_bits; 15653 state.back += here_bits; 15654 if (here_op & 64) { 15655 strm.msg = "invalid distance code"; 15656 state.mode = BAD; 15657 break; 15658 } 15659 state.offset = here_val; 15660 state.extra = here_op & 15; 15661 state.mode = DISTEXT; 15662 /* falls through */ 15663 case DISTEXT: 15664 if (state.extra) { 15665 n2 = state.extra; 15666 while (bits < n2) { 15667 if (have === 0) { 15668 break inf_leave; 15669 } 15670 have--; 15671 hold += input[next++] << bits; 15672 bits += 8; 15673 } 15674 state.offset += hold & (1 << state.extra) - 1; 15675 hold >>>= state.extra; 15676 bits -= state.extra; 15677 state.back += state.extra; 15678 } 15679 if (state.offset > state.dmax) { 15680 strm.msg = "invalid distance too far back"; 15681 state.mode = BAD; 15682 break; 15683 } 15684 state.mode = MATCH; 15685 /* falls through */ 15686 case MATCH: 15687 if (left === 0) { 15688 break inf_leave; 15689 } 15690 copy = _out - left; 15691 if (state.offset > copy) { 15692 copy = state.offset - copy; 15693 if (copy > state.whave) { 15694 if (state.sane) { 15695 strm.msg = "invalid distance too far back"; 15696 state.mode = BAD; 15697 break; 15698 } 15699 } 15700 if (copy > state.wnext) { 15701 copy -= state.wnext; 15702 from = state.wsize - copy; 15703 } else { 15704 from = state.wnext - copy; 15705 } 15706 if (copy > state.length) { 15707 copy = state.length; 15708 } 15709 from_source = state.window; 15710 } else { 15711 from_source = output; 15712 from = put - state.offset; 15713 copy = state.length; 15714 } 15715 if (copy > left) { 15716 copy = left; 15717 } 15718 left -= copy; 15719 state.length -= copy; 15720 do { 15721 output[put++] = from_source[from++]; 15722 } while (--copy); 15723 if (state.length === 0) { 15724 state.mode = LEN; 15725 } 15726 break; 15727 case LIT: 15728 if (left === 0) { 15729 break inf_leave; 15730 } 15731 output[put++] = state.length; 15732 left--; 15733 state.mode = LEN; 15734 break; 15735 case CHECK: 15736 if (state.wrap) { 15737 while (bits < 32) { 15738 if (have === 0) { 15739 break inf_leave; 15740 } 15741 have--; 15742 hold |= input[next++] << bits; 15743 bits += 8; 15744 } 15745 _out -= left; 15746 strm.total_out += _out; 15747 state.total += _out; 15748 if (_out) { 15749 strm.adler = state.check = /*UPDATE(state.check, put - _out, _out);*/ 15750 state.flags ? crc32( 15751 state.check, 15752 output, 15753 _out, 15754 put - _out 15755 ) : adler32( 15756 state.check, 15757 output, 15758 _out, 15759 put - _out 15760 ); 15761 } 15762 _out = left; 15763 if ((state.flags ? hold : zswap32(hold)) !== state.check) { 15764 strm.msg = "incorrect data check"; 15765 state.mode = BAD; 15766 break; 15767 } 15768 hold = 0; 15769 bits = 0; 15770 } 15771 state.mode = LENGTH; 15772 /* falls through */ 15773 case LENGTH: 15774 if (state.wrap && state.flags) { 15775 while (bits < 32) { 15776 if (have === 0) { 15777 break inf_leave; 15778 } 15779 have--; 15780 hold += input[next++] << bits; 15781 bits += 8; 15782 } 15783 if (hold !== (state.total & 4294967295)) { 15784 strm.msg = "incorrect length check"; 15785 state.mode = BAD; 15786 break; 15787 } 15788 hold = 0; 15789 bits = 0; 15790 } 15791 state.mode = DONE; 15792 /* falls through */ 15793 case DONE: 15794 ret = Z_STREAM_END; 15795 break inf_leave; 15796 case BAD: 15797 ret = Z_DATA_ERROR; 15798 break inf_leave; 15799 case MEM: 15800 return Z_MEM_ERROR; 15801 case SYNC: 15802 /* falls through */ 15803 default: 15804 return Z_STREAM_ERROR; 15805 } 15806 } 15807 strm.next_out = put; 15808 strm.avail_out = left; 15809 strm.next_in = next; 15810 strm.avail_in = have; 15811 state.hold = hold; 15812 state.bits = bits; 15813 if (state.wsize || _out !== strm.avail_out && state.mode < BAD && (state.mode < CHECK || flush2 !== Z_FINISH)) { 15814 if (updatewindow( 15815 strm, 15816 strm.output, 15817 strm.next_out, 15818 _out - strm.avail_out 15819 )) { 15820 state.mode = MEM; 15821 return Z_MEM_ERROR; 15822 } 15823 } 15824 _in -= strm.avail_in; 15825 _out -= strm.avail_out; 15826 strm.total_in += _in; 15827 strm.total_out += _out; 15828 state.total += _out; 15829 if (state.wrap && _out) { 15830 strm.adler = state.check = /*UPDATE(state.check, strm.next_out - _out, _out);*/ 15831 state.flags ? crc32( 15832 state.check, 15833 output, 15834 _out, 15835 strm.next_out - _out 15836 ) : adler32( 15837 state.check, 15838 output, 15839 _out, 15840 strm.next_out - _out 15841 ); 15842 } 15843 strm.data_type = state.bits + (state.last ? 64 : 0) + (state.mode === TYPE ? 128 : 0) + (state.mode === LEN_ || state.mode === COPY_ ? 256 : 0); 15844 if ((_in === 0 && _out === 0 || flush2 === Z_FINISH) && ret === Z_OK) { 15845 ret = Z_BUF_ERROR; 15846 } 15847 return ret; 15848 } 15849 function inflateEnd(strm) { 15850 if (!strm || !strm.state) { 15851 return Z_STREAM_ERROR; 15852 } 15853 var state = strm.state; 15854 if (state.window) { 15855 state.window = null; 15856 } 15857 strm.state = null; 15858 return Z_OK; 15859 } 15860 function inflateGetHeader(strm, head2) { 15861 var state; 15862 if (!strm || !strm.state) { 15863 return Z_STREAM_ERROR; 15864 } 15865 state = strm.state; 15866 if ((state.wrap & 2) === 0) { 15867 return Z_STREAM_ERROR; 15868 } 15869 state.head = head2; 15870 head2.done = false; 15871 return Z_OK; 15872 } 15873 function inflateSetDictionary(strm, dictionary) { 15874 var dictLength = dictionary.length; 15875 var state; 15876 var dictid; 15877 var ret; 15878 if (!strm || !strm.state) { 15879 return Z_STREAM_ERROR; 15880 } 15881 state = strm.state; 15882 if (state.wrap !== 0 && state.mode !== DICT) { 15883 return Z_STREAM_ERROR; 15884 } 15885 if (state.mode === DICT) { 15886 dictid = 1; 15887 dictid = adler32( 15888 dictid, 15889 dictionary, 15890 dictLength, 15891 0 15892 ); 15893 if (dictid !== state.check) { 15894 return Z_DATA_ERROR; 15895 } 15896 } 15897 ret = updatewindow( 15898 strm, 15899 dictionary, 15900 dictLength, 15901 dictLength 15902 ); 15903 if (ret) { 15904 state.mode = MEM; 15905 return Z_MEM_ERROR; 15906 } 15907 state.havedict = 1; 15908 return Z_OK; 15909 } 15910 exports3.inflateReset = inflateReset; 15911 exports3.inflateReset2 = inflateReset2; 15912 exports3.inflateResetKeep = inflateResetKeep; 15913 exports3.inflateInit = inflateInit; 15914 exports3.inflateInit2 = inflateInit2; 15915 exports3.inflate = inflate; 15916 exports3.inflateEnd = inflateEnd; 15917 exports3.inflateGetHeader = inflateGetHeader; 15918 exports3.inflateSetDictionary = inflateSetDictionary; 15919 exports3.inflateInfo = "pako inflate (from Nodeca project)"; 15920 }, 15921 { 15922 "../utils/common": 1, 15923 "./adler32": 3, 15924 "./crc32": 5, 15925 "./inffast": 7, 15926 "./inftrees": 9 15927 } 15928 ], 15929 9: [ 15930 function(require2, module3, exports3) { 15931 "use strict"; 15932 var utils = require2("../utils/common"); 15933 var MAXBITS = 15; 15934 var ENOUGH_LENS = 852; 15935 var ENOUGH_DISTS = 592; 15936 var CODES = 0; 15937 var LENS = 1; 15938 var DISTS = 2; 15939 var lbase = [ 15940 /* Length codes 257..285 base */ 15941 3, 15942 4, 15943 5, 15944 6, 15945 7, 15946 8, 15947 9, 15948 10, 15949 11, 15950 13, 15951 15, 15952 17, 15953 19, 15954 23, 15955 27, 15956 31, 15957 35, 15958 43, 15959 51, 15960 59, 15961 67, 15962 83, 15963 99, 15964 115, 15965 131, 15966 163, 15967 195, 15968 227, 15969 258, 15970 0, 15971 0 15972 ]; 15973 var lext = [ 15974 /* Length codes 257..285 extra */ 15975 16, 15976 16, 15977 16, 15978 16, 15979 16, 15980 16, 15981 16, 15982 16, 15983 17, 15984 17, 15985 17, 15986 17, 15987 18, 15988 18, 15989 18, 15990 18, 15991 19, 15992 19, 15993 19, 15994 19, 15995 20, 15996 20, 15997 20, 15998 20, 15999 21, 16000 21, 16001 21, 16002 21, 16003 16, 16004 72, 16005 78 16006 ]; 16007 var dbase = [ 16008 /* Distance codes 0..29 base */ 16009 1, 16010 2, 16011 3, 16012 4, 16013 5, 16014 7, 16015 9, 16016 13, 16017 17, 16018 25, 16019 33, 16020 49, 16021 65, 16022 97, 16023 129, 16024 193, 16025 257, 16026 385, 16027 513, 16028 769, 16029 1025, 16030 1537, 16031 2049, 16032 3073, 16033 4097, 16034 6145, 16035 8193, 16036 12289, 16037 16385, 16038 24577, 16039 0, 16040 0 16041 ]; 16042 var dext = [ 16043 /* Distance codes 0..29 extra */ 16044 16, 16045 16, 16046 16, 16047 16, 16048 17, 16049 17, 16050 18, 16051 18, 16052 19, 16053 19, 16054 20, 16055 20, 16056 21, 16057 21, 16058 22, 16059 22, 16060 23, 16061 23, 16062 24, 16063 24, 16064 25, 16065 25, 16066 26, 16067 26, 16068 27, 16069 27, 16070 28, 16071 28, 16072 29, 16073 29, 16074 64, 16075 64 16076 ]; 16077 module3.exports = function inflate_table(type, lens, lens_index, codes, table, table_index, work, opts) { 16078 var bits = opts.bits; 16079 var len = 0; 16080 var sym = 0; 16081 var min = 0, max = 0; 16082 var root = 0; 16083 var curr = 0; 16084 var drop = 0; 16085 var left = 0; 16086 var used = 0; 16087 var huff = 0; 16088 var incr; 16089 var fill; 16090 var low; 16091 var mask; 16092 var next; 16093 var base = null; 16094 var base_index = 0; 16095 var end; 16096 var count = new utils.Buf16(MAXBITS + 1); 16097 var offs = new utils.Buf16(MAXBITS + 1); 16098 var extra = null; 16099 var extra_index = 0; 16100 var here_bits, here_op, here_val; 16101 for (len = 0; len <= MAXBITS; len++) { 16102 count[len] = 0; 16103 } 16104 for (sym = 0; sym < codes; sym++) { 16105 count[lens[lens_index + sym]]++; 16106 } 16107 root = bits; 16108 for (max = MAXBITS; max >= 1; max--) { 16109 if (count[max] !== 0) { 16110 break; 16111 } 16112 } 16113 if (root > max) { 16114 root = max; 16115 } 16116 if (max === 0) { 16117 table[table_index++] = 1 << 24 | 64 << 16 | 0; 16118 table[table_index++] = 1 << 24 | 64 << 16 | 0; 16119 opts.bits = 1; 16120 return 0; 16121 } 16122 for (min = 1; min < max; min++) { 16123 if (count[min] !== 0) { 16124 break; 16125 } 16126 } 16127 if (root < min) { 16128 root = min; 16129 } 16130 left = 1; 16131 for (len = 1; len <= MAXBITS; len++) { 16132 left <<= 1; 16133 left -= count[len]; 16134 if (left < 0) { 16135 return -1; 16136 } 16137 } 16138 if (left > 0 && (type === CODES || max !== 1)) { 16139 return -1; 16140 } 16141 offs[1] = 0; 16142 for (len = 1; len < MAXBITS; len++) { 16143 offs[len + 1] = offs[len] + count[len]; 16144 } 16145 for (sym = 0; sym < codes; sym++) { 16146 if (lens[lens_index + sym] !== 0) { 16147 work[offs[lens[lens_index + sym]]++] = sym; 16148 } 16149 } 16150 if (type === CODES) { 16151 base = extra = work; 16152 end = 19; 16153 } else if (type === LENS) { 16154 base = lbase; 16155 base_index -= 257; 16156 extra = lext; 16157 extra_index -= 257; 16158 end = 256; 16159 } else { 16160 base = dbase; 16161 extra = dext; 16162 end = -1; 16163 } 16164 huff = 0; 16165 sym = 0; 16166 len = min; 16167 next = table_index; 16168 curr = root; 16169 drop = 0; 16170 low = -1; 16171 used = 1 << root; 16172 mask = used - 1; 16173 if (type === LENS && used > ENOUGH_LENS || type === DISTS && used > ENOUGH_DISTS) { 16174 return 1; 16175 } 16176 for (; ; ) { 16177 here_bits = len - drop; 16178 if (work[sym] < end) { 16179 here_op = 0; 16180 here_val = work[sym]; 16181 } else if (work[sym] > end) { 16182 here_op = extra[extra_index + work[sym]]; 16183 here_val = base[base_index + work[sym]]; 16184 } else { 16185 here_op = 32 + 64; 16186 here_val = 0; 16187 } 16188 incr = 1 << len - drop; 16189 fill = 1 << curr; 16190 min = fill; 16191 do { 16192 fill -= incr; 16193 table[next + (huff >> drop) + fill] = here_bits << 24 | here_op << 16 | here_val | 0; 16194 } while (fill !== 0); 16195 incr = 1 << len - 1; 16196 while (huff & incr) { 16197 incr >>= 1; 16198 } 16199 if (incr !== 0) { 16200 huff &= incr - 1; 16201 huff += incr; 16202 } else { 16203 huff = 0; 16204 } 16205 sym++; 16206 if (--count[len] === 0) { 16207 if (len === max) { 16208 break; 16209 } 16210 len = lens[lens_index + work[sym]]; 16211 } 16212 if (len > root && (huff & mask) !== low) { 16213 if (drop === 0) { 16214 drop = root; 16215 } 16216 next += min; 16217 curr = len - drop; 16218 left = 1 << curr; 16219 while (curr + drop < max) { 16220 left -= count[curr + drop]; 16221 if (left <= 0) { 16222 break; 16223 } 16224 curr++; 16225 left <<= 1; 16226 } 16227 used += 1 << curr; 16228 if (type === LENS && used > ENOUGH_LENS || type === DISTS && used > ENOUGH_DISTS) { 16229 return 1; 16230 } 16231 low = huff & mask; 16232 table[low] = root << 24 | curr << 16 | next - table_index | 0; 16233 } 16234 } 16235 if (huff !== 0) { 16236 table[next + huff] = len - drop << 24 | 64 << 16 | 0; 16237 } 16238 opts.bits = root; 16239 return 0; 16240 }; 16241 }, 16242 { "../utils/common": 1 } 16243 ], 16244 10: [ 16245 function(require2, module3, exports3) { 16246 "use strict"; 16247 module3.exports = { 16248 2: "need dictionary", 16249 1: "stream end", 16250 0: "", 16251 "-1": "file error", 16252 "-2": "stream error", 16253 "-3": "data error", 16254 "-4": "insufficient memory", 16255 "-5": "buffer error", 16256 "-6": "incompatible version" 16257 }; 16258 }, 16259 {} 16260 ], 16261 11: [ 16262 function(require2, module3, exports3) { 16263 "use strict"; 16264 function ZStream() { 16265 this.input = null; 16266 this.next_in = 0; 16267 this.avail_in = 0; 16268 this.total_in = 0; 16269 this.output = null; 16270 this.next_out = 0; 16271 this.avail_out = 0; 16272 this.total_out = 0; 16273 this.msg = ""; 16274 this.state = null; 16275 this.data_type = 2; 16276 this.adler = 0; 16277 } 16278 module3.exports = ZStream; 16279 }, 16280 {} 16281 ], 16282 "/lib/inflate.js": [ 16283 function(require2, module3, exports3) { 16284 "use strict"; 16285 var zlib_inflate = require2("./zlib/inflate"); 16286 var utils = require2("./utils/common"); 16287 var strings = require2("./utils/strings"); 16288 var c6 = require2("./zlib/constants"); 16289 var msg = require2("./zlib/messages"); 16290 var ZStream = require2("./zlib/zstream"); 16291 var GZheader = require2("./zlib/gzheader"); 16292 var toString = Object.prototype.toString; 16293 function Inflate(options) { 16294 if (!(this instanceof Inflate)) 16295 return new Inflate(options); 16296 this.options = utils.assign( 16297 { 16298 chunkSize: 16384, 16299 windowBits: 0, 16300 to: "" 16301 }, 16302 options || {} 16303 ); 16304 var opt = this.options; 16305 if (opt.raw && opt.windowBits >= 0 && opt.windowBits < 16) { 16306 opt.windowBits = -opt.windowBits; 16307 if (opt.windowBits === 0) { 16308 opt.windowBits = -15; 16309 } 16310 } 16311 if (opt.windowBits >= 0 && opt.windowBits < 16 && !(options && options.windowBits)) { 16312 opt.windowBits += 32; 16313 } 16314 if (opt.windowBits > 15 && opt.windowBits < 48) { 16315 if ((opt.windowBits & 15) === 0) { 16316 opt.windowBits |= 15; 16317 } 16318 } 16319 this.err = 0; 16320 this.msg = ""; 16321 this.ended = false; 16322 this.chunks = []; 16323 this.strm = new ZStream(); 16324 this.strm.avail_out = 0; 16325 var status = zlib_inflate.inflateInit2( 16326 this.strm, 16327 opt.windowBits 16328 ); 16329 if (status !== c6.Z_OK) { 16330 throw new Error(msg[status]); 16331 } 16332 this.header = new GZheader(); 16333 zlib_inflate.inflateGetHeader(this.strm, this.header); 16334 if (opt.dictionary) { 16335 if (typeof opt.dictionary === "string") { 16336 opt.dictionary = strings.string2buf( 16337 opt.dictionary 16338 ); 16339 } else if (toString.call(opt.dictionary) === "[object ArrayBuffer]") { 16340 opt.dictionary = new Uint8Array( 16341 opt.dictionary 16342 ); 16343 } 16344 if (opt.raw) { 16345 status = zlib_inflate.inflateSetDictionary( 16346 this.strm, 16347 opt.dictionary 16348 ); 16349 if (status !== c6.Z_OK) { 16350 throw new Error(msg[status]); 16351 } 16352 } 16353 } 16354 } 16355 Inflate.prototype.push = function(data, mode) { 16356 var strm = this.strm; 16357 var chunkSize = this.options.chunkSize; 16358 var dictionary = this.options.dictionary; 16359 var status, _mode; 16360 var next_out_utf8, tail, utf8str; 16361 var allowBufError = false; 16362 if (this.ended) { 16363 return false; 16364 } 16365 _mode = mode === ~~mode ? mode : mode === true ? c6.Z_FINISH : c6.Z_NO_FLUSH; 16366 if (typeof data === "string") { 16367 strm.input = strings.binstring2buf(data); 16368 } else if (toString.call(data) === "[object ArrayBuffer]") { 16369 strm.input = new Uint8Array(data); 16370 } else { 16371 strm.input = data; 16372 } 16373 strm.next_in = 0; 16374 strm.avail_in = strm.input.length; 16375 do { 16376 if (strm.avail_out === 0) { 16377 strm.output = new utils.Buf8(chunkSize); 16378 strm.next_out = 0; 16379 strm.avail_out = chunkSize; 16380 } 16381 status = zlib_inflate.inflate( 16382 strm, 16383 c6.Z_NO_FLUSH 16384 ); 16385 if (status === c6.Z_NEED_DICT && dictionary) { 16386 status = zlib_inflate.inflateSetDictionary( 16387 this.strm, 16388 dictionary 16389 ); 16390 } 16391 if (status === c6.Z_BUF_ERROR && allowBufError === true) { 16392 status = c6.Z_OK; 16393 allowBufError = false; 16394 } 16395 if (status !== c6.Z_STREAM_END && status !== c6.Z_OK) { 16396 this.onEnd(status); 16397 this.ended = true; 16398 return false; 16399 } 16400 if (strm.next_out) { 16401 if (strm.avail_out === 0 || status === c6.Z_STREAM_END || strm.avail_in === 0 && (_mode === c6.Z_FINISH || _mode === c6.Z_SYNC_FLUSH)) { 16402 if (this.options.to === "string") { 16403 next_out_utf8 = strings.utf8border( 16404 strm.output, 16405 strm.next_out 16406 ); 16407 tail = strm.next_out - next_out_utf8; 16408 utf8str = strings.buf2string( 16409 strm.output, 16410 next_out_utf8 16411 ); 16412 strm.next_out = tail; 16413 strm.avail_out = chunkSize - tail; 16414 if (tail) { 16415 utils.arraySet( 16416 strm.output, 16417 strm.output, 16418 next_out_utf8, 16419 tail, 16420 0 16421 ); 16422 } 16423 this.onData(utf8str); 16424 } else { 16425 this.onData( 16426 utils.shrinkBuf( 16427 strm.output, 16428 strm.next_out 16429 ) 16430 ); 16431 } 16432 } 16433 } 16434 if (strm.avail_in === 0 && strm.avail_out === 0) { 16435 allowBufError = true; 16436 } 16437 } while ((strm.avail_in > 0 || strm.avail_out === 0) && status !== c6.Z_STREAM_END); 16438 if (status === c6.Z_STREAM_END) { 16439 _mode = c6.Z_FINISH; 16440 } 16441 if (_mode === c6.Z_FINISH) { 16442 status = zlib_inflate.inflateEnd(this.strm); 16443 this.onEnd(status); 16444 this.ended = true; 16445 return status === c6.Z_OK; 16446 } 16447 if (_mode === c6.Z_SYNC_FLUSH) { 16448 this.onEnd(c6.Z_OK); 16449 strm.avail_out = 0; 16450 return true; 16451 } 16452 return true; 16453 }; 16454 Inflate.prototype.onData = function(chunk2) { 16455 this.chunks.push(chunk2); 16456 }; 16457 Inflate.prototype.onEnd = function(status) { 16458 if (status === c6.Z_OK) { 16459 if (this.options.to === "string") { 16460 this.result = this.chunks.join(""); 16461 } else { 16462 this.result = utils.flattenChunks( 16463 this.chunks 16464 ); 16465 } 16466 } 16467 this.chunks = []; 16468 this.err = status; 16469 this.msg = this.strm.msg; 16470 }; 16471 function inflate(input, options) { 16472 var inflator = new Inflate(options); 16473 inflator.push(input, true); 16474 if (inflator.err) { 16475 throw inflator.msg || msg[inflator.err]; 16476 } 16477 return inflator.result; 16478 } 16479 function inflateRaw(input, options) { 16480 options = options || {}; 16481 options.raw = true; 16482 return inflate(input, options); 16483 } 16484 exports3.Inflate = Inflate; 16485 exports3.inflate = inflate; 16486 exports3.inflateRaw = inflateRaw; 16487 exports3.ungzip = inflate; 16488 }, 16489 { 16490 "./utils/common": 1, 16491 "./utils/strings": 2, 16492 "./zlib/constants": 4, 16493 "./zlib/gzheader": 6, 16494 "./zlib/inflate": 8, 16495 "./zlib/messages": 10, 16496 "./zlib/zstream": 11 16497 } 16498 ] 16499 }, 16500 {}, 16501 [] 16502 )("/lib/inflate.js"); 16503 }); 16504 } 16505 }); 16506 var inflate_default = require_inflate(); 16507 16508 // packages/global-styles-ui/build-module/font-library/lib/lib-font.browser.js 16509 var fetchFunction = globalThis.fetch; 16510 var Event2 = class { 16511 constructor(type, detail = {}, msg) { 16512 this.type = type; 16513 this.detail = detail; 16514 this.msg = msg; 16515 Object.defineProperty(this, `__mayPropagate`, { 16516 enumerable: false, 16517 writable: true 16518 }); 16519 this.__mayPropagate = true; 16520 } 16521 preventDefault() { 16522 } 16523 stopPropagation() { 16524 this.__mayPropagate = false; 16525 } 16526 valueOf() { 16527 return this; 16528 } 16529 toString() { 16530 return this.msg ? `[$this.type} event]: $this.msg}` : `[$this.type} event]`; 16531 } 16532 }; 16533 var EventManager = class { 16534 constructor() { 16535 this.listeners = {}; 16536 } 16537 addEventListener(type, listener, useCapture) { 16538 let bin = this.listeners[type] || []; 16539 if (useCapture) bin.unshift(listener); 16540 else bin.push(listener); 16541 this.listeners[type] = bin; 16542 } 16543 removeEventListener(type, listener) { 16544 let bin = this.listeners[type] || []; 16545 let pos = bin.findIndex((e2) => e2 === listener); 16546 if (pos > -1) { 16547 bin.splice(pos, 1); 16548 this.listeners[type] = bin; 16549 } 16550 } 16551 dispatch(event) { 16552 let bin = this.listeners[event.type]; 16553 if (bin) { 16554 for (let l2 = 0, e2 = bin.length; l2 < e2; l2++) { 16555 if (!event.__mayPropagate) break; 16556 bin[l2](event); 16557 } 16558 } 16559 } 16560 }; 16561 var startDate = (/* @__PURE__ */ new Date(`1904-01-01T00:00:00+0000`)).getTime(); 16562 function asText(data) { 16563 return Array.from(data).map((v2) => String.fromCharCode(v2)).join(``); 16564 } 16565 var Parser = class { 16566 constructor(dict, dataview, name2) { 16567 this.name = (name2 || dict.tag || ``).trim(); 16568 this.length = dict.length; 16569 this.start = dict.offset; 16570 this.offset = 0; 16571 this.data = dataview; 16572 [ 16573 `getInt8`, 16574 `getUint8`, 16575 `getInt16`, 16576 `getUint16`, 16577 `getInt32`, 16578 `getUint32`, 16579 `getBigInt64`, 16580 `getBigUint64` 16581 ].forEach((name3) => { 16582 let fn = name3.replace(/get(Big)?/, "").toLowerCase(); 16583 let increment = parseInt(name3.replace(/[^\d]/g, "")) / 8; 16584 Object.defineProperty(this, fn, { 16585 get: () => this.getValue(name3, increment) 16586 }); 16587 }); 16588 } 16589 get currentPosition() { 16590 return this.start + this.offset; 16591 } 16592 set currentPosition(position) { 16593 this.start = position; 16594 this.offset = 0; 16595 } 16596 skip(n2 = 0, bits = 8) { 16597 this.offset += n2 * bits / 8; 16598 } 16599 getValue(type, increment) { 16600 let pos = this.start + this.offset; 16601 this.offset += increment; 16602 try { 16603 return this.data[type](pos); 16604 } catch (e2) { 16605 console.error(`parser`, type, increment, this); 16606 console.error(`parser`, this.start, this.offset); 16607 throw e2; 16608 } 16609 } 16610 flags(n2) { 16611 if (n2 === 8 || n2 === 16 || n2 === 32 || n2 === 64) { 16612 return this[`uint$n2}`].toString(2).padStart(n2, 0).split(``).map((v2) => v2 === "1"); 16613 } 16614 console.error( 16615 `Error parsing flags: flag types can only be 1, 2, 4, or 8 bytes long` 16616 ); 16617 console.trace(); 16618 } 16619 get tag() { 16620 const t3 = this.uint32; 16621 return asText([ 16622 t3 >> 24 & 255, 16623 t3 >> 16 & 255, 16624 t3 >> 8 & 255, 16625 t3 & 255 16626 ]); 16627 } 16628 get fixed() { 16629 let major = this.int16; 16630 let minor = Math.round(1e3 * this.uint16 / 65356); 16631 return major + minor / 1e3; 16632 } 16633 get legacyFixed() { 16634 let major = this.uint16; 16635 let minor = this.uint16.toString(16).padStart(4, 0); 16636 return parseFloat(`$major}.$minor}`); 16637 } 16638 get uint24() { 16639 return (this.uint8 << 16) + (this.uint8 << 8) + this.uint8; 16640 } 16641 get uint128() { 16642 let value = 0; 16643 for (let i2 = 0; i2 < 5; i2++) { 16644 let byte = this.uint8; 16645 value = value * 128 + (byte & 127); 16646 if (byte < 128) break; 16647 } 16648 return value; 16649 } 16650 get longdatetime() { 16651 return new Date(startDate + 1e3 * parseInt(this.int64.toString())); 16652 } 16653 get fword() { 16654 return this.int16; 16655 } 16656 get ufword() { 16657 return this.uint16; 16658 } 16659 get Offset16() { 16660 return this.uint16; 16661 } 16662 get Offset32() { 16663 return this.uint32; 16664 } 16665 get F2DOT14() { 16666 const bits = p.uint16; 16667 const integer = [0, 1, -2, -1][bits >> 14]; 16668 const fraction = bits & 16383; 16669 return integer + fraction / 16384; 16670 } 16671 verifyLength() { 16672 if (this.offset != this.length) { 16673 console.error( 16674 `unexpected parsed table size ($this.offset}) for "$this.name}" (expected $this.length})` 16675 ); 16676 } 16677 } 16678 readBytes(n2 = 0, position = 0, bits = 8, signed = false) { 16679 n2 = n2 || this.length; 16680 if (n2 === 0) return []; 16681 if (position) this.currentPosition = position; 16682 const fn = `$signed ? `` : `u`}int$bits}`, slice = []; 16683 while (n2--) slice.push(this[fn]); 16684 return slice; 16685 } 16686 }; 16687 var ParsedData = class { 16688 constructor(parser) { 16689 const pGetter = { enumerable: false, get: () => parser }; 16690 Object.defineProperty(this, `parser`, pGetter); 16691 const start2 = parser.currentPosition; 16692 const startGetter = { enumerable: false, get: () => start2 }; 16693 Object.defineProperty(this, `start`, startGetter); 16694 } 16695 load(struct) { 16696 Object.keys(struct).forEach((p22) => { 16697 let props = Object.getOwnPropertyDescriptor(struct, p22); 16698 if (props.get) { 16699 this[p22] = props.get.bind(this); 16700 } else if (props.value !== void 0) { 16701 this[p22] = props.value; 16702 } 16703 }); 16704 if (this.parser.length) { 16705 this.parser.verifyLength(); 16706 } 16707 } 16708 }; 16709 var SimpleTable = class extends ParsedData { 16710 constructor(dict, dataview, name2) { 16711 const { parser, start: start2 } = super( 16712 new Parser(dict, dataview, name2) 16713 ); 16714 const pGetter = { enumerable: false, get: () => parser }; 16715 Object.defineProperty(this, `p`, pGetter); 16716 const startGetter = { enumerable: false, get: () => start2 }; 16717 Object.defineProperty(this, `tableStart`, startGetter); 16718 } 16719 }; 16720 function lazy$1(object, property, getter) { 16721 let val; 16722 Object.defineProperty(object, property, { 16723 get: () => { 16724 if (val) return val; 16725 val = getter(); 16726 return val; 16727 }, 16728 enumerable: true 16729 }); 16730 } 16731 var SFNT = class extends SimpleTable { 16732 constructor(font2, dataview, createTable2) { 16733 const { p: p22 } = super({ offset: 0, length: 12 }, dataview, `sfnt`); 16734 this.version = p22.uint32; 16735 this.numTables = p22.uint16; 16736 this.searchRange = p22.uint16; 16737 this.entrySelector = p22.uint16; 16738 this.rangeShift = p22.uint16; 16739 p22.verifyLength(); 16740 this.directory = [...new Array(this.numTables)].map( 16741 (_) => new TableRecord(p22) 16742 ); 16743 this.tables = {}; 16744 this.directory.forEach((entry) => { 16745 const getter = () => createTable2( 16746 this.tables, 16747 { 16748 tag: entry.tag, 16749 offset: entry.offset, 16750 length: entry.length 16751 }, 16752 dataview 16753 ); 16754 lazy$1(this.tables, entry.tag.trim(), getter); 16755 }); 16756 } 16757 }; 16758 var TableRecord = class { 16759 constructor(p22) { 16760 this.tag = p22.tag; 16761 this.checksum = p22.uint32; 16762 this.offset = p22.uint32; 16763 this.length = p22.uint32; 16764 } 16765 }; 16766 var gzipDecode = inflate_default.inflate || void 0; 16767 var nativeGzipDecode = void 0; 16768 var WOFF$1 = class extends SimpleTable { 16769 constructor(font2, dataview, createTable2) { 16770 const { p: p22 } = super({ offset: 0, length: 44 }, dataview, `woff`); 16771 this.signature = p22.tag; 16772 this.flavor = p22.uint32; 16773 this.length = p22.uint32; 16774 this.numTables = p22.uint16; 16775 p22.uint16; 16776 this.totalSfntSize = p22.uint32; 16777 this.majorVersion = p22.uint16; 16778 this.minorVersion = p22.uint16; 16779 this.metaOffset = p22.uint32; 16780 this.metaLength = p22.uint32; 16781 this.metaOrigLength = p22.uint32; 16782 this.privOffset = p22.uint32; 16783 this.privLength = p22.uint32; 16784 p22.verifyLength(); 16785 this.directory = [...new Array(this.numTables)].map( 16786 (_) => new WoffTableDirectoryEntry(p22) 16787 ); 16788 buildWoffLazyLookups(this, dataview, createTable2); 16789 } 16790 }; 16791 var WoffTableDirectoryEntry = class { 16792 constructor(p22) { 16793 this.tag = p22.tag; 16794 this.offset = p22.uint32; 16795 this.compLength = p22.uint32; 16796 this.origLength = p22.uint32; 16797 this.origChecksum = p22.uint32; 16798 } 16799 }; 16800 function buildWoffLazyLookups(woff, dataview, createTable2) { 16801 woff.tables = {}; 16802 woff.directory.forEach((entry) => { 16803 lazy$1(woff.tables, entry.tag.trim(), () => { 16804 let offset = 0; 16805 let view = dataview; 16806 if (entry.compLength !== entry.origLength) { 16807 const data = dataview.buffer.slice( 16808 entry.offset, 16809 entry.offset + entry.compLength 16810 ); 16811 let unpacked; 16812 if (gzipDecode) { 16813 unpacked = gzipDecode(new Uint8Array(data)); 16814 } else if (nativeGzipDecode) { 16815 unpacked = nativeGzipDecode(new Uint8Array(data)); 16816 } else { 16817 const msg = `no brotli decoder available to decode WOFF2 font`; 16818 if (font.onerror) font.onerror(msg); 16819 throw new Error(msg); 16820 } 16821 view = new DataView(unpacked.buffer); 16822 } else { 16823 offset = entry.offset; 16824 } 16825 return createTable2( 16826 woff.tables, 16827 { tag: entry.tag, offset, length: entry.origLength }, 16828 view 16829 ); 16830 }); 16831 }); 16832 } 16833 var brotliDecode = unbrotli_default; 16834 var nativeBrotliDecode = void 0; 16835 var WOFF2$1 = class extends SimpleTable { 16836 constructor(font2, dataview, createTable2) { 16837 const { p: p22 } = super({ offset: 0, length: 48 }, dataview, `woff2`); 16838 this.signature = p22.tag; 16839 this.flavor = p22.uint32; 16840 this.length = p22.uint32; 16841 this.numTables = p22.uint16; 16842 p22.uint16; 16843 this.totalSfntSize = p22.uint32; 16844 this.totalCompressedSize = p22.uint32; 16845 this.majorVersion = p22.uint16; 16846 this.minorVersion = p22.uint16; 16847 this.metaOffset = p22.uint32; 16848 this.metaLength = p22.uint32; 16849 this.metaOrigLength = p22.uint32; 16850 this.privOffset = p22.uint32; 16851 this.privLength = p22.uint32; 16852 p22.verifyLength(); 16853 this.directory = [...new Array(this.numTables)].map( 16854 (_) => new Woff2TableDirectoryEntry(p22) 16855 ); 16856 let dictOffset = p22.currentPosition; 16857 this.directory[0].offset = 0; 16858 this.directory.forEach((e2, i2) => { 16859 let next = this.directory[i2 + 1]; 16860 if (next) { 16861 next.offset = e2.offset + (e2.transformLength !== void 0 ? e2.transformLength : e2.origLength); 16862 } 16863 }); 16864 let decoded; 16865 let buffer = dataview.buffer.slice(dictOffset); 16866 if (brotliDecode) { 16867 decoded = brotliDecode(new Uint8Array(buffer)); 16868 } else if (nativeBrotliDecode) { 16869 decoded = new Uint8Array(nativeBrotliDecode(buffer)); 16870 } else { 16871 const msg = `no brotli decoder available to decode WOFF2 font`; 16872 if (font2.onerror) font2.onerror(msg); 16873 throw new Error(msg); 16874 } 16875 buildWoff2LazyLookups(this, decoded, createTable2); 16876 } 16877 }; 16878 var Woff2TableDirectoryEntry = class { 16879 constructor(p22) { 16880 this.flags = p22.uint8; 16881 const tagNumber = this.tagNumber = this.flags & 63; 16882 if (tagNumber === 63) { 16883 this.tag = p22.tag; 16884 } else { 16885 this.tag = getWOFF2Tag(tagNumber); 16886 } 16887 const transformVersion = this.transformVersion = (this.flags & 192) >> 6; 16888 let hasTransforms = transformVersion !== 0; 16889 if (this.tag === `glyf` || this.tag === `loca`) { 16890 hasTransforms = this.transformVersion !== 3; 16891 } 16892 this.origLength = p22.uint128; 16893 if (hasTransforms) { 16894 this.transformLength = p22.uint128; 16895 } 16896 } 16897 }; 16898 function buildWoff2LazyLookups(woff2, decoded, createTable2) { 16899 woff2.tables = {}; 16900 woff2.directory.forEach((entry) => { 16901 lazy$1(woff2.tables, entry.tag.trim(), () => { 16902 const start2 = entry.offset; 16903 const end = start2 + (entry.transformLength ? entry.transformLength : entry.origLength); 16904 const data = new DataView(decoded.slice(start2, end).buffer); 16905 try { 16906 return createTable2( 16907 woff2.tables, 16908 { tag: entry.tag, offset: 0, length: entry.origLength }, 16909 data 16910 ); 16911 } catch (e2) { 16912 console.error(e2); 16913 } 16914 }); 16915 }); 16916 } 16917 function getWOFF2Tag(flag) { 16918 return [ 16919 `cmap`, 16920 `head`, 16921 `hhea`, 16922 `hmtx`, 16923 `maxp`, 16924 `name`, 16925 `OS/2`, 16926 `post`, 16927 `cvt `, 16928 `fpgm`, 16929 `glyf`, 16930 `loca`, 16931 `prep`, 16932 `CFF `, 16933 `VORG`, 16934 `EBDT`, 16935 `EBLC`, 16936 `gasp`, 16937 `hdmx`, 16938 `kern`, 16939 `LTSH`, 16940 `PCLT`, 16941 `VDMX`, 16942 `vhea`, 16943 `vmtx`, 16944 `BASE`, 16945 `GDEF`, 16946 `GPOS`, 16947 `GSUB`, 16948 `EBSC`, 16949 `JSTF`, 16950 `MATH`, 16951 `CBDT`, 16952 `CBLC`, 16953 `COLR`, 16954 `CPAL`, 16955 `SVG `, 16956 `sbix`, 16957 `acnt`, 16958 `avar`, 16959 `bdat`, 16960 `bloc`, 16961 `bsln`, 16962 `cvar`, 16963 `fdsc`, 16964 `feat`, 16965 `fmtx`, 16966 `fvar`, 16967 `gvar`, 16968 `hsty`, 16969 `just`, 16970 `lcar`, 16971 `mort`, 16972 `morx`, 16973 `opbd`, 16974 `prop`, 16975 `trak`, 16976 `Zapf`, 16977 `Silf`, 16978 `Glat`, 16979 `Gloc`, 16980 `Feat`, 16981 `Sill` 16982 ][flag & 63]; 16983 } 16984 var tableClasses = {}; 16985 var tableClassesLoaded = false; 16986 Promise.all([ 16987 Promise.resolve().then(function() { 16988 return cmap$1; 16989 }), 16990 Promise.resolve().then(function() { 16991 return head$1; 16992 }), 16993 Promise.resolve().then(function() { 16994 return hhea$1; 16995 }), 16996 Promise.resolve().then(function() { 16997 return hmtx$1; 16998 }), 16999 Promise.resolve().then(function() { 17000 return maxp$1; 17001 }), 17002 Promise.resolve().then(function() { 17003 return name$1; 17004 }), 17005 Promise.resolve().then(function() { 17006 return OS2$1; 17007 }), 17008 Promise.resolve().then(function() { 17009 return post$1; 17010 }), 17011 Promise.resolve().then(function() { 17012 return BASE$1; 17013 }), 17014 Promise.resolve().then(function() { 17015 return GDEF$1; 17016 }), 17017 Promise.resolve().then(function() { 17018 return GSUB$1; 17019 }), 17020 Promise.resolve().then(function() { 17021 return GPOS$1; 17022 }), 17023 Promise.resolve().then(function() { 17024 return SVG$1; 17025 }), 17026 Promise.resolve().then(function() { 17027 return fvar$1; 17028 }), 17029 Promise.resolve().then(function() { 17030 return cvt$1; 17031 }), 17032 Promise.resolve().then(function() { 17033 return fpgm$1; 17034 }), 17035 Promise.resolve().then(function() { 17036 return gasp$1; 17037 }), 17038 Promise.resolve().then(function() { 17039 return glyf$1; 17040 }), 17041 Promise.resolve().then(function() { 17042 return loca$1; 17043 }), 17044 Promise.resolve().then(function() { 17045 return prep$1; 17046 }), 17047 Promise.resolve().then(function() { 17048 return CFF$1; 17049 }), 17050 Promise.resolve().then(function() { 17051 return CFF2$1; 17052 }), 17053 Promise.resolve().then(function() { 17054 return VORG$1; 17055 }), 17056 Promise.resolve().then(function() { 17057 return EBLC$1; 17058 }), 17059 Promise.resolve().then(function() { 17060 return EBDT$1; 17061 }), 17062 Promise.resolve().then(function() { 17063 return EBSC$1; 17064 }), 17065 Promise.resolve().then(function() { 17066 return CBLC$1; 17067 }), 17068 Promise.resolve().then(function() { 17069 return CBDT$1; 17070 }), 17071 Promise.resolve().then(function() { 17072 return sbix$1; 17073 }), 17074 Promise.resolve().then(function() { 17075 return COLR$1; 17076 }), 17077 Promise.resolve().then(function() { 17078 return CPAL$1; 17079 }), 17080 Promise.resolve().then(function() { 17081 return DSIG$1; 17082 }), 17083 Promise.resolve().then(function() { 17084 return hdmx$1; 17085 }), 17086 Promise.resolve().then(function() { 17087 return kern$1; 17088 }), 17089 Promise.resolve().then(function() { 17090 return LTSH$1; 17091 }), 17092 Promise.resolve().then(function() { 17093 return MERG$1; 17094 }), 17095 Promise.resolve().then(function() { 17096 return meta$1; 17097 }), 17098 Promise.resolve().then(function() { 17099 return PCLT$1; 17100 }), 17101 Promise.resolve().then(function() { 17102 return VDMX$1; 17103 }), 17104 Promise.resolve().then(function() { 17105 return vhea$1; 17106 }), 17107 Promise.resolve().then(function() { 17108 return vmtx$1; 17109 }) 17110 ]).then((data) => { 17111 data.forEach((e2) => { 17112 let name2 = Object.keys(e2)[0]; 17113 tableClasses[name2] = e2[name2]; 17114 }); 17115 tableClassesLoaded = true; 17116 }); 17117 function createTable(tables, dict, dataview) { 17118 let name2 = dict.tag.replace(/[^\w\d]/g, ``); 17119 let Type = tableClasses[name2]; 17120 if (Type) return new Type(dict, dataview, tables); 17121 console.warn( 17122 `lib-font has no definition for $name2}. The table was skipped.` 17123 ); 17124 return {}; 17125 } 17126 function loadTableClasses() { 17127 let count = 0; 17128 function checkLoaded(resolve, reject) { 17129 if (!tableClassesLoaded) { 17130 if (count > 10) { 17131 return reject(new Error(`loading took too long`)); 17132 } 17133 count++; 17134 return setTimeout(() => checkLoaded(resolve), 250); 17135 } 17136 resolve(createTable); 17137 } 17138 return new Promise((resolve, reject) => checkLoaded(resolve)); 17139 } 17140 function getFontCSSFormat(path, errorOnStyle) { 17141 let pos = path.lastIndexOf(`.`); 17142 let ext = (path.substring(pos + 1) || ``).toLowerCase(); 17143 let format6 = { 17144 ttf: `truetype`, 17145 otf: `opentype`, 17146 woff: `woff`, 17147 woff2: `woff2` 17148 }[ext]; 17149 if (format6) return format6; 17150 let msg = { 17151 eot: `The .eot format is not supported: it died in January 12, 2016, when Microsoft retired all versions of IE that didn't already support WOFF.`, 17152 svg: `The .svg format is not supported: SVG fonts (not to be confused with OpenType with embedded SVG) were so bad we took the entire fonts chapter out of the SVG specification again.`, 17153 fon: `The .fon format is not supported: this is an ancient Windows bitmap font format.`, 17154 ttc: `Based on the current CSS specification, font collections are not (yet?) supported.` 17155 }[ext]; 17156 if (!msg) msg = `$path} is not a known webfont format.`; 17157 if (errorOnStyle) { 17158 throw new Error(msg); 17159 } else { 17160 console.warn(`Could not load font: $msg}`); 17161 } 17162 } 17163 async function setupFontFace(name2, url, options = {}) { 17164 if (!globalThis.document) return; 17165 let format6 = getFontCSSFormat(url, options.errorOnStyle); 17166 if (!format6) return; 17167 let style = document.createElement(`style`); 17168 style.className = `injected-by-Font-js`; 17169 let rules = []; 17170 if (options.styleRules) { 17171 rules = Object.entries(options.styleRules).map( 17172 ([key, value]) => `$key}: $value};` 17173 ); 17174 } 17175 style.textContent = ` 17176 @font-face { 17177 font-family: "$name2}"; 17178 $rules.join( 17179 ` 17180 ` 17181 )} 17182 src: url("$url}") format("$format6}"); 17183 }`; 17184 globalThis.document.head.appendChild(style); 17185 return style; 17186 } 17187 var TTF = [0, 1, 0, 0]; 17188 var OTF = [79, 84, 84, 79]; 17189 var WOFF = [119, 79, 70, 70]; 17190 var WOFF2 = [119, 79, 70, 50]; 17191 function match(ar1, ar2) { 17192 if (ar1.length !== ar2.length) return; 17193 for (let i2 = 0; i2 < ar1.length; i2++) { 17194 if (ar1[i2] !== ar2[i2]) return; 17195 } 17196 return true; 17197 } 17198 function validFontFormat(dataview) { 17199 const LEAD_BYTES = [ 17200 dataview.getUint8(0), 17201 dataview.getUint8(1), 17202 dataview.getUint8(2), 17203 dataview.getUint8(3) 17204 ]; 17205 if (match(LEAD_BYTES, TTF) || match(LEAD_BYTES, OTF)) return `SFNT`; 17206 if (match(LEAD_BYTES, WOFF)) return `WOFF`; 17207 if (match(LEAD_BYTES, WOFF2)) return `WOFF2`; 17208 } 17209 function checkFetchResponseStatus(response) { 17210 if (!response.ok) { 17211 throw new Error( 17212 `HTTP $response.status} - $response.statusText}` 17213 ); 17214 } 17215 return response; 17216 } 17217 var Font = class extends EventManager { 17218 constructor(name2, options = {}) { 17219 super(); 17220 this.name = name2; 17221 this.options = options; 17222 this.metrics = false; 17223 } 17224 get src() { 17225 return this.__src; 17226 } 17227 set src(src) { 17228 this.__src = src; 17229 (async () => { 17230 if (globalThis.document && !this.options.skipStyleSheet) { 17231 await setupFontFace(this.name, src, this.options); 17232 } 17233 this.loadFont(src); 17234 })(); 17235 } 17236 async loadFont(url, filename) { 17237 fetch(url).then( 17238 (response) => checkFetchResponseStatus(response) && response.arrayBuffer() 17239 ).then( 17240 (buffer) => this.fromDataBuffer(buffer, filename || url) 17241 ).catch((err) => { 17242 const evt = new Event2( 17243 `error`, 17244 err, 17245 `Failed to load font at $filename || url}` 17246 ); 17247 this.dispatch(evt); 17248 if (this.onerror) this.onerror(evt); 17249 }); 17250 } 17251 async fromDataBuffer(buffer, filenameOrUrL) { 17252 this.fontData = new DataView(buffer); 17253 let type = validFontFormat(this.fontData); 17254 if (!type) { 17255 throw new Error( 17256 `$filenameOrUrL} is either an unsupported font format, or not a font at all.` 17257 ); 17258 } 17259 await this.parseBasicData(type); 17260 const evt = new Event2("load", { font: this }); 17261 this.dispatch(evt); 17262 if (this.onload) this.onload(evt); 17263 } 17264 async parseBasicData(type) { 17265 return loadTableClasses().then((createTable2) => { 17266 if (type === `SFNT`) { 17267 this.opentype = new SFNT(this, this.fontData, createTable2); 17268 } 17269 if (type === `WOFF`) { 17270 this.opentype = new WOFF$1(this, this.fontData, createTable2); 17271 } 17272 if (type === `WOFF2`) { 17273 this.opentype = new WOFF2$1(this, this.fontData, createTable2); 17274 } 17275 return this.opentype; 17276 }); 17277 } 17278 getGlyphId(char) { 17279 return this.opentype.tables.cmap.getGlyphId(char); 17280 } 17281 reverse(glyphid) { 17282 return this.opentype.tables.cmap.reverse(glyphid); 17283 } 17284 supports(char) { 17285 return this.getGlyphId(char) !== 0; 17286 } 17287 supportsVariation(variation) { 17288 return this.opentype.tables.cmap.supportsVariation(variation) !== false; 17289 } 17290 measureText(text, size = 16) { 17291 if (this.__unloaded) 17292 throw new Error( 17293 "Cannot measure text: font was unloaded. Please reload before calling measureText()" 17294 ); 17295 let d2 = document.createElement("div"); 17296 d2.textContent = text; 17297 d2.style.fontFamily = this.name; 17298 d2.style.fontSize = `$size}px`; 17299 d2.style.color = `transparent`; 17300 d2.style.background = `transparent`; 17301 d2.style.top = `0`; 17302 d2.style.left = `0`; 17303 d2.style.position = `absolute`; 17304 document.body.appendChild(d2); 17305 let bbox = d2.getBoundingClientRect(); 17306 document.body.removeChild(d2); 17307 const OS22 = this.opentype.tables["OS/2"]; 17308 bbox.fontSize = size; 17309 bbox.ascender = OS22.sTypoAscender; 17310 bbox.descender = OS22.sTypoDescender; 17311 return bbox; 17312 } 17313 unload() { 17314 if (this.styleElement.parentNode) { 17315 this.styleElement.parentNode.removeElement(this.styleElement); 17316 const evt = new Event2("unload", { font: this }); 17317 this.dispatch(evt); 17318 if (this.onunload) this.onunload(evt); 17319 } 17320 this._unloaded = true; 17321 } 17322 load() { 17323 if (this.__unloaded) { 17324 delete this.__unloaded; 17325 document.head.appendChild(this.styleElement); 17326 const evt = new Event2("load", { font: this }); 17327 this.dispatch(evt); 17328 if (this.onload) this.onload(evt); 17329 } 17330 } 17331 }; 17332 globalThis.Font = Font; 17333 var Subtable = class extends ParsedData { 17334 constructor(p22, plaformID, encodingID) { 17335 super(p22); 17336 this.plaformID = plaformID; 17337 this.encodingID = encodingID; 17338 } 17339 }; 17340 var Format0 = class extends Subtable { 17341 constructor(p22, platformID, encodingID) { 17342 super(p22, platformID, encodingID); 17343 this.format = 0; 17344 this.length = p22.uint16; 17345 this.language = p22.uint16; 17346 this.glyphIdArray = [...new Array(256)].map((_) => p22.uint8); 17347 } 17348 supports(charCode) { 17349 if (charCode.charCodeAt) { 17350 charCode = -1; 17351 console.warn( 17352 `supports(character) not implemented for cmap subtable format 0. only supports(id) is implemented.` 17353 ); 17354 } 17355 return 0 <= charCode && charCode <= 255; 17356 } 17357 reverse(glyphID) { 17358 console.warn(`reverse not implemented for cmap subtable format 0`); 17359 return {}; 17360 } 17361 getSupportedCharCodes() { 17362 return [{ start: 1, end: 256 }]; 17363 } 17364 }; 17365 var Format2 = class extends Subtable { 17366 constructor(p22, platformID, encodingID) { 17367 super(p22, platformID, encodingID); 17368 this.format = 2; 17369 this.length = p22.uint16; 17370 this.language = p22.uint16; 17371 this.subHeaderKeys = [...new Array(256)].map((_) => p22.uint16); 17372 const subHeaderCount = Math.max(...this.subHeaderKeys); 17373 const subHeaderOffset = p22.currentPosition; 17374 lazy$1(this, `subHeaders`, () => { 17375 p22.currentPosition = subHeaderOffset; 17376 return [...new Array(subHeaderCount)].map( 17377 (_) => new SubHeader(p22) 17378 ); 17379 }); 17380 const glyphIndexOffset = subHeaderOffset + subHeaderCount * 8; 17381 lazy$1(this, `glyphIndexArray`, () => { 17382 p22.currentPosition = glyphIndexOffset; 17383 return [...new Array(subHeaderCount)].map((_) => p22.uint16); 17384 }); 17385 } 17386 supports(charCode) { 17387 if (charCode.charCodeAt) { 17388 charCode = -1; 17389 console.warn( 17390 `supports(character) not implemented for cmap subtable format 2. only supports(id) is implemented.` 17391 ); 17392 } 17393 const low = charCode && 255; 17394 const high = charCode && 65280; 17395 const subHeaderKey = this.subHeaders[high]; 17396 const subheader = this.subHeaders[subHeaderKey]; 17397 const first = subheader.firstCode; 17398 const last = first + subheader.entryCount; 17399 return first <= low && low <= last; 17400 } 17401 reverse(glyphID) { 17402 console.warn(`reverse not implemented for cmap subtable format 2`); 17403 return {}; 17404 } 17405 getSupportedCharCodes(preservePropNames = false) { 17406 if (preservePropNames) { 17407 return this.subHeaders.map((h2) => ({ 17408 firstCode: h2.firstCode, 17409 lastCode: h2.lastCode 17410 })); 17411 } 17412 return this.subHeaders.map((h2) => ({ 17413 start: h2.firstCode, 17414 end: h2.lastCode 17415 })); 17416 } 17417 }; 17418 var SubHeader = class { 17419 constructor(p22) { 17420 this.firstCode = p22.uint16; 17421 this.entryCount = p22.uint16; 17422 this.lastCode = this.first + this.entryCount; 17423 this.idDelta = p22.int16; 17424 this.idRangeOffset = p22.uint16; 17425 } 17426 }; 17427 var Format4 = class extends Subtable { 17428 constructor(p22, platformID, encodingID) { 17429 super(p22, platformID, encodingID); 17430 this.format = 4; 17431 this.length = p22.uint16; 17432 this.language = p22.uint16; 17433 this.segCountX2 = p22.uint16; 17434 this.segCount = this.segCountX2 / 2; 17435 this.searchRange = p22.uint16; 17436 this.entrySelector = p22.uint16; 17437 this.rangeShift = p22.uint16; 17438 const endCodePosition = p22.currentPosition; 17439 lazy$1( 17440 this, 17441 `endCode`, 17442 () => p22.readBytes(this.segCount, endCodePosition, 16) 17443 ); 17444 const startCodePosition = endCodePosition + 2 + this.segCountX2; 17445 lazy$1( 17446 this, 17447 `startCode`, 17448 () => p22.readBytes(this.segCount, startCodePosition, 16) 17449 ); 17450 const idDeltaPosition = startCodePosition + this.segCountX2; 17451 lazy$1( 17452 this, 17453 `idDelta`, 17454 () => p22.readBytes(this.segCount, idDeltaPosition, 16, true) 17455 ); 17456 const idRangePosition = idDeltaPosition + this.segCountX2; 17457 lazy$1( 17458 this, 17459 `idRangeOffset`, 17460 () => p22.readBytes(this.segCount, idRangePosition, 16) 17461 ); 17462 const glyphIdArrayPosition = idRangePosition + this.segCountX2; 17463 const glyphIdArrayLength = this.length - (glyphIdArrayPosition - this.tableStart); 17464 lazy$1( 17465 this, 17466 `glyphIdArray`, 17467 () => p22.readBytes(glyphIdArrayLength, glyphIdArrayPosition, 16) 17468 ); 17469 lazy$1( 17470 this, 17471 `segments`, 17472 () => this.buildSegments(idRangePosition, glyphIdArrayPosition, p22) 17473 ); 17474 } 17475 buildSegments(idRangePosition, glyphIdArrayPosition, p22) { 17476 const build = (_, i2) => { 17477 let startCode = this.startCode[i2], endCode = this.endCode[i2], idDelta = this.idDelta[i2], idRangeOffset = this.idRangeOffset[i2], idRangeOffsetPointer = idRangePosition + 2 * i2, glyphIDs = []; 17478 if (idRangeOffset === 0) { 17479 for (let i22 = startCode + idDelta, e2 = endCode + idDelta; i22 <= e2; i22++) { 17480 glyphIDs.push(i22); 17481 } 17482 } else { 17483 for (let i22 = 0, e2 = endCode - startCode; i22 <= e2; i22++) { 17484 p22.currentPosition = idRangeOffsetPointer + idRangeOffset + i22 * 2; 17485 glyphIDs.push(p22.uint16); 17486 } 17487 } 17488 return { 17489 startCode, 17490 endCode, 17491 idDelta, 17492 idRangeOffset, 17493 glyphIDs 17494 }; 17495 }; 17496 return [...new Array(this.segCount)].map(build); 17497 } 17498 reverse(glyphID) { 17499 let s2 = this.segments.find((v2) => v2.glyphIDs.includes(glyphID)); 17500 if (!s2) return {}; 17501 const code = s2.startCode + s2.glyphIDs.indexOf(glyphID); 17502 return { code, unicode: String.fromCodePoint(code) }; 17503 } 17504 getGlyphId(charCode) { 17505 if (charCode.charCodeAt) charCode = charCode.charCodeAt(0); 17506 if (55296 <= charCode && charCode <= 57343) return 0; 17507 if ((charCode & 65534) === 65534 || (charCode & 65535) === 65535) 17508 return 0; 17509 let segment = this.segments.find( 17510 (s2) => s2.startCode <= charCode && charCode <= s2.endCode 17511 ); 17512 if (!segment) return 0; 17513 return segment.glyphIDs[charCode - segment.startCode]; 17514 } 17515 supports(charCode) { 17516 return this.getGlyphId(charCode) !== 0; 17517 } 17518 getSupportedCharCodes(preservePropNames = false) { 17519 if (preservePropNames) return this.segments; 17520 return this.segments.map((v2) => ({ 17521 start: v2.startCode, 17522 end: v2.endCode 17523 })); 17524 } 17525 }; 17526 var Format6 = class extends Subtable { 17527 constructor(p22, platformID, encodingID) { 17528 super(p22, platformID, encodingID); 17529 this.format = 6; 17530 this.length = p22.uint16; 17531 this.language = p22.uint16; 17532 this.firstCode = p22.uint16; 17533 this.entryCount = p22.uint16; 17534 this.lastCode = this.firstCode + this.entryCount - 1; 17535 const getter = () => [...new Array(this.entryCount)].map((_) => p22.uint16); 17536 lazy$1(this, `glyphIdArray`, getter); 17537 } 17538 supports(charCode) { 17539 if (charCode.charCodeAt) { 17540 charCode = -1; 17541 console.warn( 17542 `supports(character) not implemented for cmap subtable format 6. only supports(id) is implemented.` 17543 ); 17544 } 17545 if (charCode < this.firstCode) return {}; 17546 if (charCode > this.firstCode + this.entryCount) return {}; 17547 const code = charCode - this.firstCode; 17548 return { code, unicode: String.fromCodePoint(code) }; 17549 } 17550 reverse(glyphID) { 17551 let pos = this.glyphIdArray.indexOf(glyphID); 17552 if (pos > -1) return this.firstCode + pos; 17553 } 17554 getSupportedCharCodes(preservePropNames = false) { 17555 if (preservePropNames) { 17556 return [{ firstCode: this.firstCode, lastCode: this.lastCode }]; 17557 } 17558 return [{ start: this.firstCode, end: this.lastCode }]; 17559 } 17560 }; 17561 var Format8 = class extends Subtable { 17562 constructor(p22, platformID, encodingID) { 17563 super(p22, platformID, encodingID); 17564 this.format = 8; 17565 p22.uint16; 17566 this.length = p22.uint32; 17567 this.language = p22.uint32; 17568 this.is32 = [...new Array(8192)].map((_) => p22.uint8); 17569 this.numGroups = p22.uint32; 17570 const getter = () => [...new Array(this.numGroups)].map( 17571 (_) => new SequentialMapGroup$1(p22) 17572 ); 17573 lazy$1(this, `groups`, getter); 17574 } 17575 supports(charCode) { 17576 if (charCode.charCodeAt) { 17577 charCode = -1; 17578 console.warn( 17579 `supports(character) not implemented for cmap subtable format 8. only supports(id) is implemented.` 17580 ); 17581 } 17582 return this.groups.findIndex( 17583 (s2) => s2.startcharCode <= charCode && charCode <= s2.endcharCode 17584 ) !== -1; 17585 } 17586 reverse(glyphID) { 17587 console.warn(`reverse not implemented for cmap subtable format 8`); 17588 return {}; 17589 } 17590 getSupportedCharCodes(preservePropNames = false) { 17591 if (preservePropNames) return this.groups; 17592 return this.groups.map((v2) => ({ 17593 start: v2.startcharCode, 17594 end: v2.endcharCode 17595 })); 17596 } 17597 }; 17598 var SequentialMapGroup$1 = class { 17599 constructor(p22) { 17600 this.startcharCode = p22.uint32; 17601 this.endcharCode = p22.uint32; 17602 this.startGlyphID = p22.uint32; 17603 } 17604 }; 17605 var Format10 = class extends Subtable { 17606 constructor(p22, platformID, encodingID) { 17607 super(p22, platformID, encodingID); 17608 this.format = 10; 17609 p22.uint16; 17610 this.length = p22.uint32; 17611 this.language = p22.uint32; 17612 this.startCharCode = p22.uint32; 17613 this.numChars = p22.uint32; 17614 this.endCharCode = this.startCharCode + this.numChars; 17615 const getter = () => [...new Array(this.numChars)].map((_) => p22.uint16); 17616 lazy$1(this, `glyphs`, getter); 17617 } 17618 supports(charCode) { 17619 if (charCode.charCodeAt) { 17620 charCode = -1; 17621 console.warn( 17622 `supports(character) not implemented for cmap subtable format 10. only supports(id) is implemented.` 17623 ); 17624 } 17625 if (charCode < this.startCharCode) return false; 17626 if (charCode > this.startCharCode + this.numChars) return false; 17627 return charCode - this.startCharCode; 17628 } 17629 reverse(glyphID) { 17630 console.warn(`reverse not implemented for cmap subtable format 10`); 17631 return {}; 17632 } 17633 getSupportedCharCodes(preservePropNames = false) { 17634 if (preservePropNames) { 17635 return [ 17636 { 17637 startCharCode: this.startCharCode, 17638 endCharCode: this.endCharCode 17639 } 17640 ]; 17641 } 17642 return [{ start: this.startCharCode, end: this.endCharCode }]; 17643 } 17644 }; 17645 var Format12 = class extends Subtable { 17646 constructor(p22, platformID, encodingID) { 17647 super(p22, platformID, encodingID); 17648 this.format = 12; 17649 p22.uint16; 17650 this.length = p22.uint32; 17651 this.language = p22.uint32; 17652 this.numGroups = p22.uint32; 17653 const getter = () => [...new Array(this.numGroups)].map( 17654 (_) => new SequentialMapGroup(p22) 17655 ); 17656 lazy$1(this, `groups`, getter); 17657 } 17658 supports(charCode) { 17659 if (charCode.charCodeAt) charCode = charCode.charCodeAt(0); 17660 if (55296 <= charCode && charCode <= 57343) return 0; 17661 if ((charCode & 65534) === 65534 || (charCode & 65535) === 65535) 17662 return 0; 17663 return this.groups.findIndex( 17664 (s2) => s2.startCharCode <= charCode && charCode <= s2.endCharCode 17665 ) !== -1; 17666 } 17667 reverse(glyphID) { 17668 for (let group of this.groups) { 17669 let start2 = group.startGlyphID; 17670 if (start2 > glyphID) continue; 17671 if (start2 === glyphID) return group.startCharCode; 17672 let end = start2 + (group.endCharCode - group.startCharCode); 17673 if (end < glyphID) continue; 17674 const code = group.startCharCode + (glyphID - start2); 17675 return { code, unicode: String.fromCodePoint(code) }; 17676 } 17677 return {}; 17678 } 17679 getSupportedCharCodes(preservePropNames = false) { 17680 if (preservePropNames) return this.groups; 17681 return this.groups.map((v2) => ({ 17682 start: v2.startCharCode, 17683 end: v2.endCharCode 17684 })); 17685 } 17686 }; 17687 var SequentialMapGroup = class { 17688 constructor(p22) { 17689 this.startCharCode = p22.uint32; 17690 this.endCharCode = p22.uint32; 17691 this.startGlyphID = p22.uint32; 17692 } 17693 }; 17694 var Format13 = class extends Subtable { 17695 constructor(p22, platformID, encodingID) { 17696 super(p22, platformID, encodingID); 17697 this.format = 13; 17698 p22.uint16; 17699 this.length = p22.uint32; 17700 this.language = p22.uint32; 17701 this.numGroups = p22.uint32; 17702 const getter = [...new Array(this.numGroups)].map( 17703 (_) => new ConstantMapGroup(p22) 17704 ); 17705 lazy$1(this, `groups`, getter); 17706 } 17707 supports(charCode) { 17708 if (charCode.charCodeAt) charCode = charCode.charCodeAt(0); 17709 return this.groups.findIndex( 17710 (s2) => s2.startCharCode <= charCode && charCode <= s2.endCharCode 17711 ) !== -1; 17712 } 17713 reverse(glyphID) { 17714 console.warn(`reverse not implemented for cmap subtable format 13`); 17715 return {}; 17716 } 17717 getSupportedCharCodes(preservePropNames = false) { 17718 if (preservePropNames) return this.groups; 17719 return this.groups.map((v2) => ({ 17720 start: v2.startCharCode, 17721 end: v2.endCharCode 17722 })); 17723 } 17724 }; 17725 var ConstantMapGroup = class { 17726 constructor(p22) { 17727 this.startCharCode = p22.uint32; 17728 this.endCharCode = p22.uint32; 17729 this.glyphID = p22.uint32; 17730 } 17731 }; 17732 var Format14 = class extends Subtable { 17733 constructor(p22, platformID, encodingID) { 17734 super(p22, platformID, encodingID); 17735 this.subTableStart = p22.currentPosition; 17736 this.format = 14; 17737 this.length = p22.uint32; 17738 this.numVarSelectorRecords = p22.uint32; 17739 lazy$1( 17740 this, 17741 `varSelectors`, 17742 () => [...new Array(this.numVarSelectorRecords)].map( 17743 (_) => new VariationSelector(p22) 17744 ) 17745 ); 17746 } 17747 supports() { 17748 console.warn(`supports not implemented for cmap subtable format 14`); 17749 return 0; 17750 } 17751 getSupportedCharCodes() { 17752 console.warn( 17753 `getSupportedCharCodes not implemented for cmap subtable format 14` 17754 ); 17755 return []; 17756 } 17757 reverse(glyphID) { 17758 console.warn(`reverse not implemented for cmap subtable format 14`); 17759 return {}; 17760 } 17761 supportsVariation(variation) { 17762 let v2 = this.varSelector.find( 17763 (uvs) => uvs.varSelector === variation 17764 ); 17765 return v2 ? v2 : false; 17766 } 17767 getSupportedVariations() { 17768 return this.varSelectors.map((v2) => v2.varSelector); 17769 } 17770 }; 17771 var VariationSelector = class { 17772 constructor(p22) { 17773 this.varSelector = p22.uint24; 17774 this.defaultUVSOffset = p22.Offset32; 17775 this.nonDefaultUVSOffset = p22.Offset32; 17776 } 17777 }; 17778 function createSubTable(parser, platformID, encodingID) { 17779 const format6 = parser.uint16; 17780 if (format6 === 0) return new Format0(parser, platformID, encodingID); 17781 if (format6 === 2) return new Format2(parser, platformID, encodingID); 17782 if (format6 === 4) return new Format4(parser, platformID, encodingID); 17783 if (format6 === 6) return new Format6(parser, platformID, encodingID); 17784 if (format6 === 8) return new Format8(parser, platformID, encodingID); 17785 if (format6 === 10) return new Format10(parser, platformID, encodingID); 17786 if (format6 === 12) return new Format12(parser, platformID, encodingID); 17787 if (format6 === 13) return new Format13(parser, platformID, encodingID); 17788 if (format6 === 14) return new Format14(parser, platformID, encodingID); 17789 return {}; 17790 } 17791 var cmap = class extends SimpleTable { 17792 constructor(dict, dataview) { 17793 const { p: p22 } = super(dict, dataview); 17794 this.version = p22.uint16; 17795 this.numTables = p22.uint16; 17796 this.encodingRecords = [...new Array(this.numTables)].map( 17797 (_) => new EncodingRecord(p22, this.tableStart) 17798 ); 17799 } 17800 getSubTable(tableID) { 17801 return this.encodingRecords[tableID].table; 17802 } 17803 getSupportedEncodings() { 17804 return this.encodingRecords.map((r3) => ({ 17805 platformID: r3.platformID, 17806 encodingId: r3.encodingID 17807 })); 17808 } 17809 getSupportedCharCodes(platformID, encodingID) { 17810 const recordID = this.encodingRecords.findIndex( 17811 (r3) => r3.platformID === platformID && r3.encodingID === encodingID 17812 ); 17813 if (recordID === -1) return false; 17814 const subtable = this.getSubTable(recordID); 17815 return subtable.getSupportedCharCodes(); 17816 } 17817 reverse(glyphid) { 17818 for (let i2 = 0; i2 < this.numTables; i2++) { 17819 let code = this.getSubTable(i2).reverse(glyphid); 17820 if (code) return code; 17821 } 17822 } 17823 getGlyphId(char) { 17824 let last = 0; 17825 this.encodingRecords.some((_, tableID) => { 17826 let t3 = this.getSubTable(tableID); 17827 if (!t3.getGlyphId) return false; 17828 last = t3.getGlyphId(char); 17829 return last !== 0; 17830 }); 17831 return last; 17832 } 17833 supports(char) { 17834 return this.encodingRecords.some((_, tableID) => { 17835 const t3 = this.getSubTable(tableID); 17836 return t3.supports && t3.supports(char) !== false; 17837 }); 17838 } 17839 supportsVariation(variation) { 17840 return this.encodingRecords.some((_, tableID) => { 17841 const t3 = this.getSubTable(tableID); 17842 return t3.supportsVariation && t3.supportsVariation(variation) !== false; 17843 }); 17844 } 17845 }; 17846 var EncodingRecord = class { 17847 constructor(p22, tableStart) { 17848 const platformID = this.platformID = p22.uint16; 17849 const encodingID = this.encodingID = p22.uint16; 17850 const offset = this.offset = p22.Offset32; 17851 lazy$1(this, `table`, () => { 17852 p22.currentPosition = tableStart + offset; 17853 return createSubTable(p22, platformID, encodingID); 17854 }); 17855 } 17856 }; 17857 var cmap$1 = Object.freeze({ __proto__: null, cmap }); 17858 var head = class extends SimpleTable { 17859 constructor(dict, dataview) { 17860 const { p: p22 } = super(dict, dataview); 17861 this.load({ 17862 majorVersion: p22.uint16, 17863 minorVersion: p22.uint16, 17864 fontRevision: p22.fixed, 17865 checkSumAdjustment: p22.uint32, 17866 magicNumber: p22.uint32, 17867 flags: p22.flags(16), 17868 unitsPerEm: p22.uint16, 17869 created: p22.longdatetime, 17870 modified: p22.longdatetime, 17871 xMin: p22.int16, 17872 yMin: p22.int16, 17873 xMax: p22.int16, 17874 yMax: p22.int16, 17875 macStyle: p22.flags(16), 17876 lowestRecPPEM: p22.uint16, 17877 fontDirectionHint: p22.uint16, 17878 indexToLocFormat: p22.uint16, 17879 glyphDataFormat: p22.uint16 17880 }); 17881 } 17882 }; 17883 var head$1 = Object.freeze({ __proto__: null, head }); 17884 var hhea = class extends SimpleTable { 17885 constructor(dict, dataview) { 17886 const { p: p22 } = super(dict, dataview); 17887 this.majorVersion = p22.uint16; 17888 this.minorVersion = p22.uint16; 17889 this.ascender = p22.fword; 17890 this.descender = p22.fword; 17891 this.lineGap = p22.fword; 17892 this.advanceWidthMax = p22.ufword; 17893 this.minLeftSideBearing = p22.fword; 17894 this.minRightSideBearing = p22.fword; 17895 this.xMaxExtent = p22.fword; 17896 this.caretSlopeRise = p22.int16; 17897 this.caretSlopeRun = p22.int16; 17898 this.caretOffset = p22.int16; 17899 p22.int16; 17900 p22.int16; 17901 p22.int16; 17902 p22.int16; 17903 this.metricDataFormat = p22.int16; 17904 this.numberOfHMetrics = p22.uint16; 17905 p22.verifyLength(); 17906 } 17907 }; 17908 var hhea$1 = Object.freeze({ __proto__: null, hhea }); 17909 var hmtx = class extends SimpleTable { 17910 constructor(dict, dataview, tables) { 17911 const { p: p22 } = super(dict, dataview); 17912 const numberOfHMetrics = tables.hhea.numberOfHMetrics; 17913 const numGlyphs = tables.maxp.numGlyphs; 17914 const metricsStart = p22.currentPosition; 17915 lazy$1(this, `hMetrics`, () => { 17916 p22.currentPosition = metricsStart; 17917 return [...new Array(numberOfHMetrics)].map( 17918 (_) => new LongHorMetric(p22.uint16, p22.int16) 17919 ); 17920 }); 17921 if (numberOfHMetrics < numGlyphs) { 17922 const lsbStart = metricsStart + numberOfHMetrics * 4; 17923 lazy$1(this, `leftSideBearings`, () => { 17924 p22.currentPosition = lsbStart; 17925 return [...new Array(numGlyphs - numberOfHMetrics)].map( 17926 (_) => p22.int16 17927 ); 17928 }); 17929 } 17930 } 17931 }; 17932 var LongHorMetric = class { 17933 constructor(w2, b2) { 17934 this.advanceWidth = w2; 17935 this.lsb = b2; 17936 } 17937 }; 17938 var hmtx$1 = Object.freeze({ __proto__: null, hmtx }); 17939 var maxp = class extends SimpleTable { 17940 constructor(dict, dataview) { 17941 const { p: p22 } = super(dict, dataview); 17942 this.version = p22.legacyFixed; 17943 this.numGlyphs = p22.uint16; 17944 if (this.version === 1) { 17945 this.maxPoints = p22.uint16; 17946 this.maxContours = p22.uint16; 17947 this.maxCompositePoints = p22.uint16; 17948 this.maxCompositeContours = p22.uint16; 17949 this.maxZones = p22.uint16; 17950 this.maxTwilightPoints = p22.uint16; 17951 this.maxStorage = p22.uint16; 17952 this.maxFunctionDefs = p22.uint16; 17953 this.maxInstructionDefs = p22.uint16; 17954 this.maxStackElements = p22.uint16; 17955 this.maxSizeOfInstructions = p22.uint16; 17956 this.maxComponentElements = p22.uint16; 17957 this.maxComponentDepth = p22.uint16; 17958 } 17959 p22.verifyLength(); 17960 } 17961 }; 17962 var maxp$1 = Object.freeze({ __proto__: null, maxp }); 17963 var name = class extends SimpleTable { 17964 constructor(dict, dataview) { 17965 const { p: p22 } = super(dict, dataview); 17966 this.format = p22.uint16; 17967 this.count = p22.uint16; 17968 this.stringOffset = p22.Offset16; 17969 this.nameRecords = [...new Array(this.count)].map( 17970 (_) => new NameRecord(p22, this) 17971 ); 17972 if (this.format === 1) { 17973 this.langTagCount = p22.uint16; 17974 this.langTagRecords = [...new Array(this.langTagCount)].map( 17975 (_) => new LangTagRecord(p22.uint16, p22.Offset16) 17976 ); 17977 } 17978 this.stringStart = this.tableStart + this.stringOffset; 17979 } 17980 get(nameID) { 17981 let record = this.nameRecords.find( 17982 (record2) => record2.nameID === nameID 17983 ); 17984 if (record) return record.string; 17985 } 17986 }; 17987 var LangTagRecord = class { 17988 constructor(length, offset) { 17989 this.length = length; 17990 this.offset = offset; 17991 } 17992 }; 17993 var NameRecord = class { 17994 constructor(p22, nameTable) { 17995 this.platformID = p22.uint16; 17996 this.encodingID = p22.uint16; 17997 this.languageID = p22.uint16; 17998 this.nameID = p22.uint16; 17999 this.length = p22.uint16; 18000 this.offset = p22.Offset16; 18001 lazy$1(this, `string`, () => { 18002 p22.currentPosition = nameTable.stringStart + this.offset; 18003 return decodeString(p22, this); 18004 }); 18005 } 18006 }; 18007 function decodeString(p22, record) { 18008 const { platformID, length } = record; 18009 if (length === 0) return ``; 18010 if (platformID === 0 || platformID === 3) { 18011 const str2 = []; 18012 for (let i2 = 0, e2 = length / 2; i2 < e2; i2++) 18013 str2[i2] = String.fromCharCode(p22.uint16); 18014 return str2.join(``); 18015 } 18016 const bytes = p22.readBytes(length); 18017 const str = []; 18018 bytes.forEach(function(b2, i2) { 18019 str[i2] = String.fromCharCode(b2); 18020 }); 18021 return str.join(``); 18022 } 18023 var name$1 = Object.freeze({ __proto__: null, name }); 18024 var OS2 = class extends SimpleTable { 18025 constructor(dict, dataview) { 18026 const { p: p22 } = super(dict, dataview); 18027 this.version = p22.uint16; 18028 this.xAvgCharWidth = p22.int16; 18029 this.usWeightClass = p22.uint16; 18030 this.usWidthClass = p22.uint16; 18031 this.fsType = p22.uint16; 18032 this.ySubscriptXSize = p22.int16; 18033 this.ySubscriptYSize = p22.int16; 18034 this.ySubscriptXOffset = p22.int16; 18035 this.ySubscriptYOffset = p22.int16; 18036 this.ySuperscriptXSize = p22.int16; 18037 this.ySuperscriptYSize = p22.int16; 18038 this.ySuperscriptXOffset = p22.int16; 18039 this.ySuperscriptYOffset = p22.int16; 18040 this.yStrikeoutSize = p22.int16; 18041 this.yStrikeoutPosition = p22.int16; 18042 this.sFamilyClass = p22.int16; 18043 this.panose = [...new Array(10)].map((_) => p22.uint8); 18044 this.ulUnicodeRange1 = p22.flags(32); 18045 this.ulUnicodeRange2 = p22.flags(32); 18046 this.ulUnicodeRange3 = p22.flags(32); 18047 this.ulUnicodeRange4 = p22.flags(32); 18048 this.achVendID = p22.tag; 18049 this.fsSelection = p22.uint16; 18050 this.usFirstCharIndex = p22.uint16; 18051 this.usLastCharIndex = p22.uint16; 18052 this.sTypoAscender = p22.int16; 18053 this.sTypoDescender = p22.int16; 18054 this.sTypoLineGap = p22.int16; 18055 this.usWinAscent = p22.uint16; 18056 this.usWinDescent = p22.uint16; 18057 if (this.version === 0) return p22.verifyLength(); 18058 this.ulCodePageRange1 = p22.flags(32); 18059 this.ulCodePageRange2 = p22.flags(32); 18060 if (this.version === 1) return p22.verifyLength(); 18061 this.sxHeight = p22.int16; 18062 this.sCapHeight = p22.int16; 18063 this.usDefaultChar = p22.uint16; 18064 this.usBreakChar = p22.uint16; 18065 this.usMaxContext = p22.uint16; 18066 if (this.version <= 4) return p22.verifyLength(); 18067 this.usLowerOpticalPointSize = p22.uint16; 18068 this.usUpperOpticalPointSize = p22.uint16; 18069 if (this.version === 5) return p22.verifyLength(); 18070 } 18071 }; 18072 var OS2$1 = Object.freeze({ __proto__: null, OS2 }); 18073 var post = class extends SimpleTable { 18074 constructor(dict, dataview) { 18075 const { p: p22 } = super(dict, dataview); 18076 this.version = p22.legacyFixed; 18077 this.italicAngle = p22.fixed; 18078 this.underlinePosition = p22.fword; 18079 this.underlineThickness = p22.fword; 18080 this.isFixedPitch = p22.uint32; 18081 this.minMemType42 = p22.uint32; 18082 this.maxMemType42 = p22.uint32; 18083 this.minMemType1 = p22.uint32; 18084 this.maxMemType1 = p22.uint32; 18085 if (this.version === 1 || this.version === 3) return p22.verifyLength(); 18086 this.numGlyphs = p22.uint16; 18087 if (this.version === 2) { 18088 this.glyphNameIndex = [...new Array(this.numGlyphs)].map( 18089 (_) => p22.uint16 18090 ); 18091 this.namesOffset = p22.currentPosition; 18092 this.glyphNameOffsets = [1]; 18093 for (let i2 = 0; i2 < this.numGlyphs; i2++) { 18094 let index = this.glyphNameIndex[i2]; 18095 if (index < macStrings.length) { 18096 this.glyphNameOffsets.push(this.glyphNameOffsets[i2]); 18097 continue; 18098 } 18099 let bytelength = p22.int8; 18100 p22.skip(bytelength); 18101 this.glyphNameOffsets.push( 18102 this.glyphNameOffsets[i2] + bytelength + 1 18103 ); 18104 } 18105 } 18106 if (this.version === 2.5) { 18107 this.offset = [...new Array(this.numGlyphs)].map( 18108 (_) => p22.int8 18109 ); 18110 } 18111 } 18112 getGlyphName(glyphid) { 18113 if (this.version !== 2) { 18114 console.warn( 18115 `post table version $this.version} does not support glyph name lookups` 18116 ); 18117 return ``; 18118 } 18119 let index = this.glyphNameIndex[glyphid]; 18120 if (index < 258) return macStrings[index]; 18121 let offset = this.glyphNameOffsets[glyphid]; 18122 let next = this.glyphNameOffsets[glyphid + 1]; 18123 let len = next - offset - 1; 18124 if (len === 0) return `.notdef.`; 18125 this.parser.currentPosition = this.namesOffset + offset; 18126 const data = this.parser.readBytes( 18127 len, 18128 this.namesOffset + offset, 18129 8, 18130 true 18131 ); 18132 return data.map((b2) => String.fromCharCode(b2)).join(``); 18133 } 18134 }; 18135 var macStrings = [ 18136 `.notdef`, 18137 `.null`, 18138 `nonmarkingreturn`, 18139 `space`, 18140 `exclam`, 18141 `quotedbl`, 18142 `numbersign`, 18143 `dollar`, 18144 `percent`, 18145 `ampersand`, 18146 `quotesingle`, 18147 `parenleft`, 18148 `parenright`, 18149 `asterisk`, 18150 `plus`, 18151 `comma`, 18152 `hyphen`, 18153 `period`, 18154 `slash`, 18155 `zero`, 18156 `one`, 18157 `two`, 18158 `three`, 18159 `four`, 18160 `five`, 18161 `six`, 18162 `seven`, 18163 `eight`, 18164 `nine`, 18165 `colon`, 18166 `semicolon`, 18167 `less`, 18168 `equal`, 18169 `greater`, 18170 `question`, 18171 `at`, 18172 `A`, 18173 `B`, 18174 `C`, 18175 `D`, 18176 `E`, 18177 `F`, 18178 `G`, 18179 `H`, 18180 `I`, 18181 `J`, 18182 `K`, 18183 `L`, 18184 `M`, 18185 `N`, 18186 `O`, 18187 `P`, 18188 `Q`, 18189 `R`, 18190 `S`, 18191 `T`, 18192 `U`, 18193 `V`, 18194 `W`, 18195 `X`, 18196 `Y`, 18197 `Z`, 18198 `bracketleft`, 18199 `backslash`, 18200 `bracketright`, 18201 `asciicircum`, 18202 `underscore`, 18203 `grave`, 18204 `a`, 18205 `b`, 18206 `c`, 18207 `d`, 18208 `e`, 18209 `f`, 18210 `g`, 18211 `h`, 18212 `i`, 18213 `j`, 18214 `k`, 18215 `l`, 18216 `m`, 18217 `n`, 18218 `o`, 18219 `p`, 18220 `q`, 18221 `r`, 18222 `s`, 18223 `t`, 18224 `u`, 18225 `v`, 18226 `w`, 18227 `x`, 18228 `y`, 18229 `z`, 18230 `braceleft`, 18231 `bar`, 18232 `braceright`, 18233 `asciitilde`, 18234 `Adieresis`, 18235 `Aring`, 18236 `Ccedilla`, 18237 `Eacute`, 18238 `Ntilde`, 18239 `Odieresis`, 18240 `Udieresis`, 18241 `aacute`, 18242 `agrave`, 18243 `acircumflex`, 18244 `adieresis`, 18245 `atilde`, 18246 `aring`, 18247 `ccedilla`, 18248 `eacute`, 18249 `egrave`, 18250 `ecircumflex`, 18251 `edieresis`, 18252 `iacute`, 18253 `igrave`, 18254 `icircumflex`, 18255 `idieresis`, 18256 `ntilde`, 18257 `oacute`, 18258 `ograve`, 18259 `ocircumflex`, 18260 `odieresis`, 18261 `otilde`, 18262 `uacute`, 18263 `ugrave`, 18264 `ucircumflex`, 18265 `udieresis`, 18266 `dagger`, 18267 `degree`, 18268 `cent`, 18269 `sterling`, 18270 `section`, 18271 `bullet`, 18272 `paragraph`, 18273 `germandbls`, 18274 `registered`, 18275 `copyright`, 18276 `trademark`, 18277 `acute`, 18278 `dieresis`, 18279 `notequal`, 18280 `AE`, 18281 `Oslash`, 18282 `infinity`, 18283 `plusminus`, 18284 `lessequal`, 18285 `greaterequal`, 18286 `yen`, 18287 `mu`, 18288 `partialdiff`, 18289 `summation`, 18290 `product`, 18291 `pi`, 18292 `integral`, 18293 `ordfeminine`, 18294 `ordmasculine`, 18295 `Omega`, 18296 `ae`, 18297 `oslash`, 18298 `questiondown`, 18299 `exclamdown`, 18300 `logicalnot`, 18301 `radical`, 18302 `florin`, 18303 `approxequal`, 18304 `Delta`, 18305 `guillemotleft`, 18306 `guillemotright`, 18307 `ellipsis`, 18308 `nonbreakingspace`, 18309 `Agrave`, 18310 `Atilde`, 18311 `Otilde`, 18312 `OE`, 18313 `oe`, 18314 `endash`, 18315 `emdash`, 18316 `quotedblleft`, 18317 `quotedblright`, 18318 `quoteleft`, 18319 `quoteright`, 18320 `divide`, 18321 `lozenge`, 18322 `ydieresis`, 18323 `Ydieresis`, 18324 `fraction`, 18325 `currency`, 18326 `guilsinglleft`, 18327 `guilsinglright`, 18328 `fi`, 18329 `fl`, 18330 `daggerdbl`, 18331 `periodcentered`, 18332 `quotesinglbase`, 18333 `quotedblbase`, 18334 `perthousand`, 18335 `Acircumflex`, 18336 `Ecircumflex`, 18337 `Aacute`, 18338 `Edieresis`, 18339 `Egrave`, 18340 `Iacute`, 18341 `Icircumflex`, 18342 `Idieresis`, 18343 `Igrave`, 18344 `Oacute`, 18345 `Ocircumflex`, 18346 `apple`, 18347 `Ograve`, 18348 `Uacute`, 18349 `Ucircumflex`, 18350 `Ugrave`, 18351 `dotlessi`, 18352 `circumflex`, 18353 `tilde`, 18354 `macron`, 18355 `breve`, 18356 `dotaccent`, 18357 `ring`, 18358 `cedilla`, 18359 `hungarumlaut`, 18360 `ogonek`, 18361 `caron`, 18362 `Lslash`, 18363 `lslash`, 18364 `Scaron`, 18365 `scaron`, 18366 `Zcaron`, 18367 `zcaron`, 18368 `brokenbar`, 18369 `Eth`, 18370 `eth`, 18371 `Yacute`, 18372 `yacute`, 18373 `Thorn`, 18374 `thorn`, 18375 `minus`, 18376 `multiply`, 18377 `onesuperior`, 18378 `twosuperior`, 18379 `threesuperior`, 18380 `onehalf`, 18381 `onequarter`, 18382 `threequarters`, 18383 `franc`, 18384 `Gbreve`, 18385 `gbreve`, 18386 `Idotaccent`, 18387 `Scedilla`, 18388 `scedilla`, 18389 `Cacute`, 18390 `cacute`, 18391 `Ccaron`, 18392 `ccaron`, 18393 `dcroat` 18394 ]; 18395 var post$1 = Object.freeze({ __proto__: null, post }); 18396 var BASE = class extends SimpleTable { 18397 constructor(dict, dataview) { 18398 const { p: p22 } = super(dict, dataview); 18399 this.majorVersion = p22.uint16; 18400 this.minorVersion = p22.uint16; 18401 this.horizAxisOffset = p22.Offset16; 18402 this.vertAxisOffset = p22.Offset16; 18403 lazy$1( 18404 this, 18405 `horizAxis`, 18406 () => new AxisTable( 18407 { offset: dict.offset + this.horizAxisOffset }, 18408 dataview 18409 ) 18410 ); 18411 lazy$1( 18412 this, 18413 `vertAxis`, 18414 () => new AxisTable( 18415 { offset: dict.offset + this.vertAxisOffset }, 18416 dataview 18417 ) 18418 ); 18419 if (this.majorVersion === 1 && this.minorVersion === 1) { 18420 this.itemVarStoreOffset = p22.Offset32; 18421 lazy$1( 18422 this, 18423 `itemVarStore`, 18424 () => new AxisTable( 18425 { offset: dict.offset + this.itemVarStoreOffset }, 18426 dataview 18427 ) 18428 ); 18429 } 18430 } 18431 }; 18432 var AxisTable = class extends SimpleTable { 18433 constructor(dict, dataview) { 18434 const { p: p22 } = super(dict, dataview, `AxisTable`); 18435 this.baseTagListOffset = p22.Offset16; 18436 this.baseScriptListOffset = p22.Offset16; 18437 lazy$1( 18438 this, 18439 `baseTagList`, 18440 () => new BaseTagListTable( 18441 { offset: dict.offset + this.baseTagListOffset }, 18442 dataview 18443 ) 18444 ); 18445 lazy$1( 18446 this, 18447 `baseScriptList`, 18448 () => new BaseScriptListTable( 18449 { offset: dict.offset + this.baseScriptListOffset }, 18450 dataview 18451 ) 18452 ); 18453 } 18454 }; 18455 var BaseTagListTable = class extends SimpleTable { 18456 constructor(dict, dataview) { 18457 const { p: p22 } = super(dict, dataview, `BaseTagListTable`); 18458 this.baseTagCount = p22.uint16; 18459 this.baselineTags = [...new Array(this.baseTagCount)].map( 18460 (_) => p22.tag 18461 ); 18462 } 18463 }; 18464 var BaseScriptListTable = class extends SimpleTable { 18465 constructor(dict, dataview) { 18466 const { p: p22 } = super(dict, dataview, `BaseScriptListTable`); 18467 this.baseScriptCount = p22.uint16; 18468 const recordStart = p22.currentPosition; 18469 lazy$1(this, `baseScriptRecords`, () => { 18470 p22.currentPosition = recordStart; 18471 return [...new Array(this.baseScriptCount)].map( 18472 (_) => new BaseScriptRecord(this.start, p22) 18473 ); 18474 }); 18475 } 18476 }; 18477 var BaseScriptRecord = class { 18478 constructor(baseScriptListTableStart, p22) { 18479 this.baseScriptTag = p22.tag; 18480 this.baseScriptOffset = p22.Offset16; 18481 lazy$1(this, `baseScriptTable`, () => { 18482 p22.currentPosition = baseScriptListTableStart + this.baseScriptOffset; 18483 return new BaseScriptTable(p22); 18484 }); 18485 } 18486 }; 18487 var BaseScriptTable = class { 18488 constructor(p22) { 18489 this.start = p22.currentPosition; 18490 this.baseValuesOffset = p22.Offset16; 18491 this.defaultMinMaxOffset = p22.Offset16; 18492 this.baseLangSysCount = p22.uint16; 18493 this.baseLangSysRecords = [...new Array(this.baseLangSysCount)].map( 18494 (_) => new BaseLangSysRecord(this.start, p22) 18495 ); 18496 lazy$1(this, `baseValues`, () => { 18497 p22.currentPosition = this.start + this.baseValuesOffset; 18498 return new BaseValuesTable(p22); 18499 }); 18500 lazy$1(this, `defaultMinMax`, () => { 18501 p22.currentPosition = this.start + this.defaultMinMaxOffset; 18502 return new MinMaxTable(p22); 18503 }); 18504 } 18505 }; 18506 var BaseLangSysRecord = class { 18507 constructor(baseScriptTableStart, p22) { 18508 this.baseLangSysTag = p22.tag; 18509 this.minMaxOffset = p22.Offset16; 18510 lazy$1(this, `minMax`, () => { 18511 p22.currentPosition = baseScriptTableStart + this.minMaxOffset; 18512 return new MinMaxTable(p22); 18513 }); 18514 } 18515 }; 18516 var BaseValuesTable = class { 18517 constructor(p22) { 18518 this.parser = p22; 18519 this.start = p22.currentPosition; 18520 this.defaultBaselineIndex = p22.uint16; 18521 this.baseCoordCount = p22.uint16; 18522 this.baseCoords = [...new Array(this.baseCoordCount)].map( 18523 (_) => p22.Offset16 18524 ); 18525 } 18526 getTable(id) { 18527 this.parser.currentPosition = this.start + this.baseCoords[id]; 18528 return new BaseCoordTable(this.parser); 18529 } 18530 }; 18531 var MinMaxTable = class { 18532 constructor(p22) { 18533 this.minCoord = p22.Offset16; 18534 this.maxCoord = p22.Offset16; 18535 this.featMinMaxCount = p22.uint16; 18536 const recordStart = p22.currentPosition; 18537 lazy$1(this, `featMinMaxRecords`, () => { 18538 p22.currentPosition = recordStart; 18539 return [...new Array(this.featMinMaxCount)].map( 18540 (_) => new FeatMinMaxRecord(p22) 18541 ); 18542 }); 18543 } 18544 }; 18545 var FeatMinMaxRecord = class { 18546 constructor(p22) { 18547 this.featureTableTag = p22.tag; 18548 this.minCoord = p22.Offset16; 18549 this.maxCoord = p22.Offset16; 18550 } 18551 }; 18552 var BaseCoordTable = class { 18553 constructor(p22) { 18554 this.baseCoordFormat = p22.uint16; 18555 this.coordinate = p22.int16; 18556 if (this.baseCoordFormat === 2) { 18557 this.referenceGlyph = p22.uint16; 18558 this.baseCoordPoint = p22.uint16; 18559 } 18560 if (this.baseCoordFormat === 3) { 18561 this.deviceTable = p22.Offset16; 18562 } 18563 } 18564 }; 18565 var BASE$1 = Object.freeze({ __proto__: null, BASE }); 18566 var ClassDefinition = class { 18567 constructor(p22) { 18568 this.classFormat = p22.uint16; 18569 if (this.classFormat === 1) { 18570 this.startGlyphID = p22.uint16; 18571 this.glyphCount = p22.uint16; 18572 this.classValueArray = [...new Array(this.glyphCount)].map( 18573 (_) => p22.uint16 18574 ); 18575 } 18576 if (this.classFormat === 2) { 18577 this.classRangeCount = p22.uint16; 18578 this.classRangeRecords = [ 18579 ...new Array(this.classRangeCount) 18580 ].map((_) => new ClassRangeRecord(p22)); 18581 } 18582 } 18583 }; 18584 var ClassRangeRecord = class { 18585 constructor(p22) { 18586 this.startGlyphID = p22.uint16; 18587 this.endGlyphID = p22.uint16; 18588 this.class = p22.uint16; 18589 } 18590 }; 18591 var CoverageTable = class extends ParsedData { 18592 constructor(p22) { 18593 super(p22); 18594 this.coverageFormat = p22.uint16; 18595 if (this.coverageFormat === 1) { 18596 this.glyphCount = p22.uint16; 18597 this.glyphArray = [...new Array(this.glyphCount)].map( 18598 (_) => p22.uint16 18599 ); 18600 } 18601 if (this.coverageFormat === 2) { 18602 this.rangeCount = p22.uint16; 18603 this.rangeRecords = [...new Array(this.rangeCount)].map( 18604 (_) => new CoverageRangeRecord(p22) 18605 ); 18606 } 18607 } 18608 }; 18609 var CoverageRangeRecord = class { 18610 constructor(p22) { 18611 this.startGlyphID = p22.uint16; 18612 this.endGlyphID = p22.uint16; 18613 this.startCoverageIndex = p22.uint16; 18614 } 18615 }; 18616 var ItemVariationStoreTable = class { 18617 constructor(table, p22) { 18618 this.table = table; 18619 this.parser = p22; 18620 this.start = p22.currentPosition; 18621 this.format = p22.uint16; 18622 this.variationRegionListOffset = p22.Offset32; 18623 this.itemVariationDataCount = p22.uint16; 18624 this.itemVariationDataOffsets = [ 18625 ...new Array(this.itemVariationDataCount) 18626 ].map((_) => p22.Offset32); 18627 } 18628 }; 18629 var GDEF = class extends SimpleTable { 18630 constructor(dict, dataview) { 18631 const { p: p22 } = super(dict, dataview); 18632 this.majorVersion = p22.uint16; 18633 this.minorVersion = p22.uint16; 18634 this.glyphClassDefOffset = p22.Offset16; 18635 lazy$1(this, `glyphClassDefs`, () => { 18636 if (this.glyphClassDefOffset === 0) return void 0; 18637 p22.currentPosition = this.tableStart + this.glyphClassDefOffset; 18638 return new ClassDefinition(p22); 18639 }); 18640 this.attachListOffset = p22.Offset16; 18641 lazy$1(this, `attachList`, () => { 18642 if (this.attachListOffset === 0) return void 0; 18643 p22.currentPosition = this.tableStart + this.attachListOffset; 18644 return new AttachList(p22); 18645 }); 18646 this.ligCaretListOffset = p22.Offset16; 18647 lazy$1(this, `ligCaretList`, () => { 18648 if (this.ligCaretListOffset === 0) return void 0; 18649 p22.currentPosition = this.tableStart + this.ligCaretListOffset; 18650 return new LigCaretList(p22); 18651 }); 18652 this.markAttachClassDefOffset = p22.Offset16; 18653 lazy$1(this, `markAttachClassDef`, () => { 18654 if (this.markAttachClassDefOffset === 0) return void 0; 18655 p22.currentPosition = this.tableStart + this.markAttachClassDefOffset; 18656 return new ClassDefinition(p22); 18657 }); 18658 if (this.minorVersion >= 2) { 18659 this.markGlyphSetsDefOffset = p22.Offset16; 18660 lazy$1(this, `markGlyphSetsDef`, () => { 18661 if (this.markGlyphSetsDefOffset === 0) return void 0; 18662 p22.currentPosition = this.tableStart + this.markGlyphSetsDefOffset; 18663 return new MarkGlyphSetsTable(p22); 18664 }); 18665 } 18666 if (this.minorVersion === 3) { 18667 this.itemVarStoreOffset = p22.Offset32; 18668 lazy$1(this, `itemVarStore`, () => { 18669 if (this.itemVarStoreOffset === 0) return void 0; 18670 p22.currentPosition = this.tableStart + this.itemVarStoreOffset; 18671 return new ItemVariationStoreTable(p22); 18672 }); 18673 } 18674 } 18675 }; 18676 var AttachList = class extends ParsedData { 18677 constructor(p22) { 18678 super(p22); 18679 this.coverageOffset = p22.Offset16; 18680 this.glyphCount = p22.uint16; 18681 this.attachPointOffsets = [...new Array(this.glyphCount)].map( 18682 (_) => p22.Offset16 18683 ); 18684 } 18685 getPoint(pointID) { 18686 this.parser.currentPosition = this.start + this.attachPointOffsets[pointID]; 18687 return new AttachPoint(this.parser); 18688 } 18689 }; 18690 var AttachPoint = class { 18691 constructor(p22) { 18692 this.pointCount = p22.uint16; 18693 this.pointIndices = [...new Array(this.pointCount)].map( 18694 (_) => p22.uint16 18695 ); 18696 } 18697 }; 18698 var LigCaretList = class extends ParsedData { 18699 constructor(p22) { 18700 super(p22); 18701 this.coverageOffset = p22.Offset16; 18702 lazy$1(this, `coverage`, () => { 18703 p22.currentPosition = this.start + this.coverageOffset; 18704 return new CoverageTable(p22); 18705 }); 18706 this.ligGlyphCount = p22.uint16; 18707 this.ligGlyphOffsets = [...new Array(this.ligGlyphCount)].map( 18708 (_) => p22.Offset16 18709 ); 18710 } 18711 getLigGlyph(ligGlyphID) { 18712 this.parser.currentPosition = this.start + this.ligGlyphOffsets[ligGlyphID]; 18713 return new LigGlyph(this.parser); 18714 } 18715 }; 18716 var LigGlyph = class extends ParsedData { 18717 constructor(p22) { 18718 super(p22); 18719 this.caretCount = p22.uint16; 18720 this.caretValueOffsets = [...new Array(this.caretCount)].map( 18721 (_) => p22.Offset16 18722 ); 18723 } 18724 getCaretValue(caretID) { 18725 this.parser.currentPosition = this.start + this.caretValueOffsets[caretID]; 18726 return new CaretValue(this.parser); 18727 } 18728 }; 18729 var CaretValue = class { 18730 constructor(p22) { 18731 this.caretValueFormat = p22.uint16; 18732 if (this.caretValueFormat === 1) { 18733 this.coordinate = p22.int16; 18734 } 18735 if (this.caretValueFormat === 2) { 18736 this.caretValuePointIndex = p22.uint16; 18737 } 18738 if (this.caretValueFormat === 3) { 18739 this.coordinate = p22.int16; 18740 this.deviceOffset = p22.Offset16; 18741 } 18742 } 18743 }; 18744 var MarkGlyphSetsTable = class extends ParsedData { 18745 constructor(p22) { 18746 super(p22); 18747 this.markGlyphSetTableFormat = p22.uint16; 18748 this.markGlyphSetCount = p22.uint16; 18749 this.coverageOffsets = [...new Array(this.markGlyphSetCount)].map( 18750 (_) => p22.Offset32 18751 ); 18752 } 18753 getMarkGlyphSet(markGlyphSetID) { 18754 this.parser.currentPosition = this.start + this.coverageOffsets[markGlyphSetID]; 18755 return new CoverageTable(this.parser); 18756 } 18757 }; 18758 var GDEF$1 = Object.freeze({ __proto__: null, GDEF }); 18759 var ScriptList = class extends ParsedData { 18760 static EMPTY = { scriptCount: 0, scriptRecords: [] }; 18761 constructor(p22) { 18762 super(p22); 18763 this.scriptCount = p22.uint16; 18764 this.scriptRecords = [...new Array(this.scriptCount)].map( 18765 (_) => new ScriptRecord(p22) 18766 ); 18767 } 18768 }; 18769 var ScriptRecord = class { 18770 constructor(p22) { 18771 this.scriptTag = p22.tag; 18772 this.scriptOffset = p22.Offset16; 18773 } 18774 }; 18775 var ScriptTable = class extends ParsedData { 18776 constructor(p22) { 18777 super(p22); 18778 this.defaultLangSys = p22.Offset16; 18779 this.langSysCount = p22.uint16; 18780 this.langSysRecords = [...new Array(this.langSysCount)].map( 18781 (_) => new LangSysRecord(p22) 18782 ); 18783 } 18784 }; 18785 var LangSysRecord = class { 18786 constructor(p22) { 18787 this.langSysTag = p22.tag; 18788 this.langSysOffset = p22.Offset16; 18789 } 18790 }; 18791 var LangSysTable = class { 18792 constructor(p22) { 18793 this.lookupOrder = p22.Offset16; 18794 this.requiredFeatureIndex = p22.uint16; 18795 this.featureIndexCount = p22.uint16; 18796 this.featureIndices = [...new Array(this.featureIndexCount)].map( 18797 (_) => p22.uint16 18798 ); 18799 } 18800 }; 18801 var FeatureList = class extends ParsedData { 18802 static EMPTY = { featureCount: 0, featureRecords: [] }; 18803 constructor(p22) { 18804 super(p22); 18805 this.featureCount = p22.uint16; 18806 this.featureRecords = [...new Array(this.featureCount)].map( 18807 (_) => new FeatureRecord(p22) 18808 ); 18809 } 18810 }; 18811 var FeatureRecord = class { 18812 constructor(p22) { 18813 this.featureTag = p22.tag; 18814 this.featureOffset = p22.Offset16; 18815 } 18816 }; 18817 var FeatureTable = class extends ParsedData { 18818 constructor(p22) { 18819 super(p22); 18820 this.featureParams = p22.Offset16; 18821 this.lookupIndexCount = p22.uint16; 18822 this.lookupListIndices = [...new Array(this.lookupIndexCount)].map( 18823 (_) => p22.uint16 18824 ); 18825 } 18826 getFeatureParams() { 18827 if (this.featureParams > 0) { 18828 const p22 = this.parser; 18829 p22.currentPosition = this.start + this.featureParams; 18830 const tag = this.featureTag; 18831 if (tag === `size`) return new Size(p22); 18832 if (tag.startsWith(`cc`)) return new CharacterVariant(p22); 18833 if (tag.startsWith(`ss`)) return new StylisticSet(p22); 18834 } 18835 } 18836 }; 18837 var CharacterVariant = class { 18838 constructor(p22) { 18839 this.format = p22.uint16; 18840 this.featUiLabelNameId = p22.uint16; 18841 this.featUiTooltipTextNameId = p22.uint16; 18842 this.sampleTextNameId = p22.uint16; 18843 this.numNamedParameters = p22.uint16; 18844 this.firstParamUiLabelNameId = p22.uint16; 18845 this.charCount = p22.uint16; 18846 this.character = [...new Array(this.charCount)].map( 18847 (_) => p22.uint24 18848 ); 18849 } 18850 }; 18851 var Size = class { 18852 constructor(p22) { 18853 this.designSize = p22.uint16; 18854 this.subfamilyIdentifier = p22.uint16; 18855 this.subfamilyNameID = p22.uint16; 18856 this.smallEnd = p22.uint16; 18857 this.largeEnd = p22.uint16; 18858 } 18859 }; 18860 var StylisticSet = class { 18861 constructor(p22) { 18862 this.version = p22.uint16; 18863 this.UINameID = p22.uint16; 18864 } 18865 }; 18866 function undoCoverageOffsetParsing(instance) { 18867 instance.parser.currentPosition -= 2; 18868 delete instance.coverageOffset; 18869 delete instance.getCoverageTable; 18870 } 18871 var LookupType$1 = class extends ParsedData { 18872 constructor(p22) { 18873 super(p22); 18874 this.substFormat = p22.uint16; 18875 this.coverageOffset = p22.Offset16; 18876 } 18877 getCoverageTable() { 18878 let p22 = this.parser; 18879 p22.currentPosition = this.start + this.coverageOffset; 18880 return new CoverageTable(p22); 18881 } 18882 }; 18883 var SubstLookupRecord = class { 18884 constructor(p22) { 18885 this.glyphSequenceIndex = p22.uint16; 18886 this.lookupListIndex = p22.uint16; 18887 } 18888 }; 18889 var LookupType1$1 = class extends LookupType$1 { 18890 constructor(p22) { 18891 super(p22); 18892 this.deltaGlyphID = p22.int16; 18893 } 18894 }; 18895 var LookupType2$1 = class extends LookupType$1 { 18896 constructor(p22) { 18897 super(p22); 18898 this.sequenceCount = p22.uint16; 18899 this.sequenceOffsets = [...new Array(this.sequenceCount)].map( 18900 (_) => p22.Offset16 18901 ); 18902 } 18903 getSequence(index) { 18904 let p22 = this.parser; 18905 p22.currentPosition = this.start + this.sequenceOffsets[index]; 18906 return new SequenceTable(p22); 18907 } 18908 }; 18909 var SequenceTable = class { 18910 constructor(p22) { 18911 this.glyphCount = p22.uint16; 18912 this.substituteGlyphIDs = [...new Array(this.glyphCount)].map( 18913 (_) => p22.uint16 18914 ); 18915 } 18916 }; 18917 var LookupType3$1 = class extends LookupType$1 { 18918 constructor(p22) { 18919 super(p22); 18920 this.alternateSetCount = p22.uint16; 18921 this.alternateSetOffsets = [ 18922 ...new Array(this.alternateSetCount) 18923 ].map((_) => p22.Offset16); 18924 } 18925 getAlternateSet(index) { 18926 let p22 = this.parser; 18927 p22.currentPosition = this.start + this.alternateSetOffsets[index]; 18928 return new AlternateSetTable(p22); 18929 } 18930 }; 18931 var AlternateSetTable = class { 18932 constructor(p22) { 18933 this.glyphCount = p22.uint16; 18934 this.alternateGlyphIDs = [...new Array(this.glyphCount)].map( 18935 (_) => p22.uint16 18936 ); 18937 } 18938 }; 18939 var LookupType4$1 = class extends LookupType$1 { 18940 constructor(p22) { 18941 super(p22); 18942 this.ligatureSetCount = p22.uint16; 18943 this.ligatureSetOffsets = [...new Array(this.ligatureSetCount)].map( 18944 (_) => p22.Offset16 18945 ); 18946 } 18947 getLigatureSet(index) { 18948 let p22 = this.parser; 18949 p22.currentPosition = this.start + this.ligatureSetOffsets[index]; 18950 return new LigatureSetTable(p22); 18951 } 18952 }; 18953 var LigatureSetTable = class extends ParsedData { 18954 constructor(p22) { 18955 super(p22); 18956 this.ligatureCount = p22.uint16; 18957 this.ligatureOffsets = [...new Array(this.ligatureCount)].map( 18958 (_) => p22.Offset16 18959 ); 18960 } 18961 getLigature(index) { 18962 let p22 = this.parser; 18963 p22.currentPosition = this.start + this.ligatureOffsets[index]; 18964 return new LigatureTable(p22); 18965 } 18966 }; 18967 var LigatureTable = class { 18968 constructor(p22) { 18969 this.ligatureGlyph = p22.uint16; 18970 this.componentCount = p22.uint16; 18971 this.componentGlyphIDs = [ 18972 ...new Array(this.componentCount - 1) 18973 ].map((_) => p22.uint16); 18974 } 18975 }; 18976 var LookupType5$1 = class extends LookupType$1 { 18977 constructor(p22) { 18978 super(p22); 18979 if (this.substFormat === 1) { 18980 this.subRuleSetCount = p22.uint16; 18981 this.subRuleSetOffsets = [ 18982 ...new Array(this.subRuleSetCount) 18983 ].map((_) => p22.Offset16); 18984 } 18985 if (this.substFormat === 2) { 18986 this.classDefOffset = p22.Offset16; 18987 this.subClassSetCount = p22.uint16; 18988 this.subClassSetOffsets = [ 18989 ...new Array(this.subClassSetCount) 18990 ].map((_) => p22.Offset16); 18991 } 18992 if (this.substFormat === 3) { 18993 undoCoverageOffsetParsing(this); 18994 this.glyphCount = p22.uint16; 18995 this.substitutionCount = p22.uint16; 18996 this.coverageOffsets = [...new Array(this.glyphCount)].map( 18997 (_) => p22.Offset16 18998 ); 18999 this.substLookupRecords = [ 19000 ...new Array(this.substitutionCount) 19001 ].map((_) => new SubstLookupRecord(p22)); 19002 } 19003 } 19004 getSubRuleSet(index) { 19005 if (this.substFormat !== 1) 19006 throw new Error( 19007 `lookup type 5.$this.substFormat} has no subrule sets.` 19008 ); 19009 let p22 = this.parser; 19010 p22.currentPosition = this.start + this.subRuleSetOffsets[index]; 19011 return new SubRuleSetTable(p22); 19012 } 19013 getSubClassSet(index) { 19014 if (this.substFormat !== 2) 19015 throw new Error( 19016 `lookup type 5.$this.substFormat} has no subclass sets.` 19017 ); 19018 let p22 = this.parser; 19019 p22.currentPosition = this.start + this.subClassSetOffsets[index]; 19020 return new SubClassSetTable(p22); 19021 } 19022 getCoverageTable(index) { 19023 if (this.substFormat !== 3 && !index) 19024 return super.getCoverageTable(); 19025 if (!index) 19026 throw new Error( 19027 `lookup type 5.$this.substFormat} requires an coverage table index.` 19028 ); 19029 let p22 = this.parser; 19030 p22.currentPosition = this.start + this.coverageOffsets[index]; 19031 return new CoverageTable(p22); 19032 } 19033 }; 19034 var SubRuleSetTable = class extends ParsedData { 19035 constructor(p22) { 19036 super(p22); 19037 this.subRuleCount = p22.uint16; 19038 this.subRuleOffsets = [...new Array(this.subRuleCount)].map( 19039 (_) => p22.Offset16 19040 ); 19041 } 19042 getSubRule(index) { 19043 let p22 = this.parser; 19044 p22.currentPosition = this.start + this.subRuleOffsets[index]; 19045 return new SubRuleTable(p22); 19046 } 19047 }; 19048 var SubRuleTable = class { 19049 constructor(p22) { 19050 this.glyphCount = p22.uint16; 19051 this.substitutionCount = p22.uint16; 19052 this.inputSequence = [...new Array(this.glyphCount - 1)].map( 19053 (_) => p22.uint16 19054 ); 19055 this.substLookupRecords = [ 19056 ...new Array(this.substitutionCount) 19057 ].map((_) => new SubstLookupRecord(p22)); 19058 } 19059 }; 19060 var SubClassSetTable = class extends ParsedData { 19061 constructor(p22) { 19062 super(p22); 19063 this.subClassRuleCount = p22.uint16; 19064 this.subClassRuleOffsets = [ 19065 ...new Array(this.subClassRuleCount) 19066 ].map((_) => p22.Offset16); 19067 } 19068 getSubClass(index) { 19069 let p22 = this.parser; 19070 p22.currentPosition = this.start + this.subClassRuleOffsets[index]; 19071 return new SubClassRuleTable(p22); 19072 } 19073 }; 19074 var SubClassRuleTable = class extends SubRuleTable { 19075 constructor(p22) { 19076 super(p22); 19077 } 19078 }; 19079 var LookupType6$1 = class extends LookupType$1 { 19080 constructor(p22) { 19081 super(p22); 19082 if (this.substFormat === 1) { 19083 this.chainSubRuleSetCount = p22.uint16; 19084 this.chainSubRuleSetOffsets = [ 19085 ...new Array(this.chainSubRuleSetCount) 19086 ].map((_) => p22.Offset16); 19087 } 19088 if (this.substFormat === 2) { 19089 this.backtrackClassDefOffset = p22.Offset16; 19090 this.inputClassDefOffset = p22.Offset16; 19091 this.lookaheadClassDefOffset = p22.Offset16; 19092 this.chainSubClassSetCount = p22.uint16; 19093 this.chainSubClassSetOffsets = [ 19094 ...new Array(this.chainSubClassSetCount) 19095 ].map((_) => p22.Offset16); 19096 } 19097 if (this.substFormat === 3) { 19098 undoCoverageOffsetParsing(this); 19099 this.backtrackGlyphCount = p22.uint16; 19100 this.backtrackCoverageOffsets = [ 19101 ...new Array(this.backtrackGlyphCount) 19102 ].map((_) => p22.Offset16); 19103 this.inputGlyphCount = p22.uint16; 19104 this.inputCoverageOffsets = [ 19105 ...new Array(this.inputGlyphCount) 19106 ].map((_) => p22.Offset16); 19107 this.lookaheadGlyphCount = p22.uint16; 19108 this.lookaheadCoverageOffsets = [ 19109 ...new Array(this.lookaheadGlyphCount) 19110 ].map((_) => p22.Offset16); 19111 this.seqLookupCount = p22.uint16; 19112 this.seqLookupRecords = [ 19113 ...new Array(this.substitutionCount) 19114 ].map((_) => new SequenceLookupRecord(p22)); 19115 } 19116 } 19117 getChainSubRuleSet(index) { 19118 if (this.substFormat !== 1) 19119 throw new Error( 19120 `lookup type 6.$this.substFormat} has no chainsubrule sets.` 19121 ); 19122 let p22 = this.parser; 19123 p22.currentPosition = this.start + this.chainSubRuleSetOffsets[index]; 19124 return new ChainSubRuleSetTable(p22); 19125 } 19126 getChainSubClassSet(index) { 19127 if (this.substFormat !== 2) 19128 throw new Error( 19129 `lookup type 6.$this.substFormat} has no chainsubclass sets.` 19130 ); 19131 let p22 = this.parser; 19132 p22.currentPosition = this.start + this.chainSubClassSetOffsets[index]; 19133 return new ChainSubClassSetTable(p22); 19134 } 19135 getCoverageFromOffset(offset) { 19136 if (this.substFormat !== 3) 19137 throw new Error( 19138 `lookup type 6.$this.substFormat} does not use contextual coverage offsets.` 19139 ); 19140 let p22 = this.parser; 19141 p22.currentPosition = this.start + offset; 19142 return new CoverageTable(p22); 19143 } 19144 }; 19145 var ChainSubRuleSetTable = class extends ParsedData { 19146 constructor(p22) { 19147 super(p22); 19148 this.chainSubRuleCount = p22.uint16; 19149 this.chainSubRuleOffsets = [ 19150 ...new Array(this.chainSubRuleCount) 19151 ].map((_) => p22.Offset16); 19152 } 19153 getSubRule(index) { 19154 let p22 = this.parser; 19155 p22.currentPosition = this.start + this.chainSubRuleOffsets[index]; 19156 return new ChainSubRuleTable(p22); 19157 } 19158 }; 19159 var ChainSubRuleTable = class { 19160 constructor(p22) { 19161 this.backtrackGlyphCount = p22.uint16; 19162 this.backtrackSequence = [ 19163 ...new Array(this.backtrackGlyphCount) 19164 ].map((_) => p22.uint16); 19165 this.inputGlyphCount = p22.uint16; 19166 this.inputSequence = [...new Array(this.inputGlyphCount - 1)].map( 19167 (_) => p22.uint16 19168 ); 19169 this.lookaheadGlyphCount = p22.uint16; 19170 this.lookAheadSequence = [ 19171 ...new Array(this.lookAheadGlyphCount) 19172 ].map((_) => p22.uint16); 19173 this.substitutionCount = p22.uint16; 19174 this.substLookupRecords = [...new Array(this.SubstCount)].map( 19175 (_) => new SubstLookupRecord(p22) 19176 ); 19177 } 19178 }; 19179 var ChainSubClassSetTable = class extends ParsedData { 19180 constructor(p22) { 19181 super(p22); 19182 this.chainSubClassRuleCount = p22.uint16; 19183 this.chainSubClassRuleOffsets = [ 19184 ...new Array(this.chainSubClassRuleCount) 19185 ].map((_) => p22.Offset16); 19186 } 19187 getSubClass(index) { 19188 let p22 = this.parser; 19189 p22.currentPosition = this.start + this.chainSubRuleOffsets[index]; 19190 return new ChainSubClassRuleTable(p22); 19191 } 19192 }; 19193 var ChainSubClassRuleTable = class { 19194 constructor(p22) { 19195 this.backtrackGlyphCount = p22.uint16; 19196 this.backtrackSequence = [ 19197 ...new Array(this.backtrackGlyphCount) 19198 ].map((_) => p22.uint16); 19199 this.inputGlyphCount = p22.uint16; 19200 this.inputSequence = [...new Array(this.inputGlyphCount - 1)].map( 19201 (_) => p22.uint16 19202 ); 19203 this.lookaheadGlyphCount = p22.uint16; 19204 this.lookAheadSequence = [ 19205 ...new Array(this.lookAheadGlyphCount) 19206 ].map((_) => p22.uint16); 19207 this.substitutionCount = p22.uint16; 19208 this.substLookupRecords = [ 19209 ...new Array(this.substitutionCount) 19210 ].map((_) => new SequenceLookupRecord(p22)); 19211 } 19212 }; 19213 var SequenceLookupRecord = class extends ParsedData { 19214 constructor(p22) { 19215 super(p22); 19216 this.sequenceIndex = p22.uint16; 19217 this.lookupListIndex = p22.uint16; 19218 } 19219 }; 19220 var LookupType7$1 = class extends ParsedData { 19221 constructor(p22) { 19222 super(p22); 19223 this.substFormat = p22.uint16; 19224 this.extensionLookupType = p22.uint16; 19225 this.extensionOffset = p22.Offset32; 19226 } 19227 }; 19228 var LookupType8$1 = class extends LookupType$1 { 19229 constructor(p22) { 19230 super(p22); 19231 this.backtrackGlyphCount = p22.uint16; 19232 this.backtrackCoverageOffsets = [ 19233 ...new Array(this.backtrackGlyphCount) 19234 ].map((_) => p22.Offset16); 19235 this.lookaheadGlyphCount = p22.uint16; 19236 this.lookaheadCoverageOffsets = [ 19237 new Array(this.lookaheadGlyphCount) 19238 ].map((_) => p22.Offset16); 19239 this.glyphCount = p22.uint16; 19240 this.substituteGlyphIDs = [...new Array(this.glyphCount)].map( 19241 (_) => p22.uint16 19242 ); 19243 } 19244 }; 19245 var GSUBtables = { 19246 buildSubtable: function(type, p22) { 19247 const subtable = new [ 19248 void 0, 19249 LookupType1$1, 19250 LookupType2$1, 19251 LookupType3$1, 19252 LookupType4$1, 19253 LookupType5$1, 19254 LookupType6$1, 19255 LookupType7$1, 19256 LookupType8$1 19257 ][type](p22); 19258 subtable.type = type; 19259 return subtable; 19260 } 19261 }; 19262 var LookupType = class extends ParsedData { 19263 constructor(p22) { 19264 super(p22); 19265 } 19266 }; 19267 var LookupType1 = class extends LookupType { 19268 constructor(p22) { 19269 super(p22); 19270 console.log(`lookup type 1`); 19271 } 19272 }; 19273 var LookupType2 = class extends LookupType { 19274 constructor(p22) { 19275 super(p22); 19276 console.log(`lookup type 2`); 19277 } 19278 }; 19279 var LookupType3 = class extends LookupType { 19280 constructor(p22) { 19281 super(p22); 19282 console.log(`lookup type 3`); 19283 } 19284 }; 19285 var LookupType4 = class extends LookupType { 19286 constructor(p22) { 19287 super(p22); 19288 console.log(`lookup type 4`); 19289 } 19290 }; 19291 var LookupType5 = class extends LookupType { 19292 constructor(p22) { 19293 super(p22); 19294 console.log(`lookup type 5`); 19295 } 19296 }; 19297 var LookupType6 = class extends LookupType { 19298 constructor(p22) { 19299 super(p22); 19300 console.log(`lookup type 6`); 19301 } 19302 }; 19303 var LookupType7 = class extends LookupType { 19304 constructor(p22) { 19305 super(p22); 19306 console.log(`lookup type 7`); 19307 } 19308 }; 19309 var LookupType8 = class extends LookupType { 19310 constructor(p22) { 19311 super(p22); 19312 console.log(`lookup type 8`); 19313 } 19314 }; 19315 var LookupType9 = class extends LookupType { 19316 constructor(p22) { 19317 super(p22); 19318 console.log(`lookup type 9`); 19319 } 19320 }; 19321 var GPOStables = { 19322 buildSubtable: function(type, p22) { 19323 const subtable = new [ 19324 void 0, 19325 LookupType1, 19326 LookupType2, 19327 LookupType3, 19328 LookupType4, 19329 LookupType5, 19330 LookupType6, 19331 LookupType7, 19332 LookupType8, 19333 LookupType9 19334 ][type](p22); 19335 subtable.type = type; 19336 return subtable; 19337 } 19338 }; 19339 var LookupList = class extends ParsedData { 19340 static EMPTY = { lookupCount: 0, lookups: [] }; 19341 constructor(p22) { 19342 super(p22); 19343 this.lookupCount = p22.uint16; 19344 this.lookups = [...new Array(this.lookupCount)].map( 19345 (_) => p22.Offset16 19346 ); 19347 } 19348 }; 19349 var LookupTable = class extends ParsedData { 19350 constructor(p22, type) { 19351 super(p22); 19352 this.ctType = type; 19353 this.lookupType = p22.uint16; 19354 this.lookupFlag = p22.uint16; 19355 this.subTableCount = p22.uint16; 19356 this.subtableOffsets = [...new Array(this.subTableCount)].map( 19357 (_) => p22.Offset16 19358 ); 19359 this.markFilteringSet = p22.uint16; 19360 } 19361 get rightToLeft() { 19362 return this.lookupFlag & true; 19363 } 19364 get ignoreBaseGlyphs() { 19365 return this.lookupFlag & true; 19366 } 19367 get ignoreLigatures() { 19368 return this.lookupFlag & true; 19369 } 19370 get ignoreMarks() { 19371 return this.lookupFlag & true; 19372 } 19373 get useMarkFilteringSet() { 19374 return this.lookupFlag & true; 19375 } 19376 get markAttachmentType() { 19377 return this.lookupFlag & true; 19378 } 19379 getSubTable(index) { 19380 const builder = this.ctType === `GSUB` ? GSUBtables : GPOStables; 19381 this.parser.currentPosition = this.start + this.subtableOffsets[index]; 19382 return builder.buildSubtable(this.lookupType, this.parser); 19383 } 19384 }; 19385 var CommonLayoutTable = class extends SimpleTable { 19386 constructor(dict, dataview, name2) { 19387 const { p: p22, tableStart } = super(dict, dataview, name2); 19388 this.majorVersion = p22.uint16; 19389 this.minorVersion = p22.uint16; 19390 this.scriptListOffset = p22.Offset16; 19391 this.featureListOffset = p22.Offset16; 19392 this.lookupListOffset = p22.Offset16; 19393 if (this.majorVersion === 1 && this.minorVersion === 1) { 19394 this.featureVariationsOffset = p22.Offset32; 19395 } 19396 const no_content = !(this.scriptListOffset || this.featureListOffset || this.lookupListOffset); 19397 lazy$1(this, `scriptList`, () => { 19398 if (no_content) return ScriptList.EMPTY; 19399 p22.currentPosition = tableStart + this.scriptListOffset; 19400 return new ScriptList(p22); 19401 }); 19402 lazy$1(this, `featureList`, () => { 19403 if (no_content) return FeatureList.EMPTY; 19404 p22.currentPosition = tableStart + this.featureListOffset; 19405 return new FeatureList(p22); 19406 }); 19407 lazy$1(this, `lookupList`, () => { 19408 if (no_content) return LookupList.EMPTY; 19409 p22.currentPosition = tableStart + this.lookupListOffset; 19410 return new LookupList(p22); 19411 }); 19412 if (this.featureVariationsOffset) { 19413 lazy$1(this, `featureVariations`, () => { 19414 if (no_content) return FeatureVariations.EMPTY; 19415 p22.currentPosition = tableStart + this.featureVariationsOffset; 19416 return new FeatureVariations(p22); 19417 }); 19418 } 19419 } 19420 getSupportedScripts() { 19421 return this.scriptList.scriptRecords.map((r3) => r3.scriptTag); 19422 } 19423 getScriptTable(scriptTag) { 19424 let record = this.scriptList.scriptRecords.find( 19425 (r3) => r3.scriptTag === scriptTag 19426 ); 19427 this.parser.currentPosition = this.scriptList.start + record.scriptOffset; 19428 let table = new ScriptTable(this.parser); 19429 table.scriptTag = scriptTag; 19430 return table; 19431 } 19432 ensureScriptTable(arg) { 19433 if (typeof arg === "string") { 19434 return this.getScriptTable(arg); 19435 } 19436 return arg; 19437 } 19438 getSupportedLangSys(scriptTable) { 19439 scriptTable = this.ensureScriptTable(scriptTable); 19440 const hasDefault = scriptTable.defaultLangSys !== 0; 19441 const supported = scriptTable.langSysRecords.map( 19442 (l2) => l2.langSysTag 19443 ); 19444 if (hasDefault) supported.unshift(`dflt`); 19445 return supported; 19446 } 19447 getDefaultLangSysTable(scriptTable) { 19448 scriptTable = this.ensureScriptTable(scriptTable); 19449 let offset = scriptTable.defaultLangSys; 19450 if (offset !== 0) { 19451 this.parser.currentPosition = scriptTable.start + offset; 19452 let table = new LangSysTable(this.parser); 19453 table.langSysTag = ``; 19454 table.defaultForScript = scriptTable.scriptTag; 19455 return table; 19456 } 19457 } 19458 getLangSysTable(scriptTable, langSysTag = `dflt`) { 19459 if (langSysTag === `dflt`) 19460 return this.getDefaultLangSysTable(scriptTable); 19461 scriptTable = this.ensureScriptTable(scriptTable); 19462 let record = scriptTable.langSysRecords.find( 19463 (l2) => l2.langSysTag === langSysTag 19464 ); 19465 this.parser.currentPosition = scriptTable.start + record.langSysOffset; 19466 let table = new LangSysTable(this.parser); 19467 table.langSysTag = langSysTag; 19468 return table; 19469 } 19470 getFeatures(langSysTable) { 19471 return langSysTable.featureIndices.map( 19472 (index) => this.getFeature(index) 19473 ); 19474 } 19475 getFeature(indexOrTag) { 19476 let record; 19477 if (parseInt(indexOrTag) == indexOrTag) { 19478 record = this.featureList.featureRecords[indexOrTag]; 19479 } else { 19480 record = this.featureList.featureRecords.find( 19481 (f2) => f2.featureTag === indexOrTag 19482 ); 19483 } 19484 if (!record) return; 19485 this.parser.currentPosition = this.featureList.start + record.featureOffset; 19486 let table = new FeatureTable(this.parser); 19487 table.featureTag = record.featureTag; 19488 return table; 19489 } 19490 getLookups(featureTable) { 19491 return featureTable.lookupListIndices.map( 19492 (index) => this.getLookup(index) 19493 ); 19494 } 19495 getLookup(lookupIndex, type) { 19496 let lookupOffset = this.lookupList.lookups[lookupIndex]; 19497 this.parser.currentPosition = this.lookupList.start + lookupOffset; 19498 return new LookupTable(this.parser, type); 19499 } 19500 }; 19501 var GSUB = class extends CommonLayoutTable { 19502 constructor(dict, dataview) { 19503 super(dict, dataview, `GSUB`); 19504 } 19505 getLookup(lookupIndex) { 19506 return super.getLookup(lookupIndex, `GSUB`); 19507 } 19508 }; 19509 var GSUB$1 = Object.freeze({ __proto__: null, GSUB }); 19510 var GPOS = class extends CommonLayoutTable { 19511 constructor(dict, dataview) { 19512 super(dict, dataview, `GPOS`); 19513 } 19514 getLookup(lookupIndex) { 19515 return super.getLookup(lookupIndex, `GPOS`); 19516 } 19517 }; 19518 var GPOS$1 = Object.freeze({ __proto__: null, GPOS }); 19519 var SVG67 = class extends SimpleTable { 19520 constructor(dict, dataview) { 19521 const { p: p22 } = super(dict, dataview); 19522 this.version = p22.uint16; 19523 this.offsetToSVGDocumentList = p22.Offset32; 19524 p22.currentPosition = this.tableStart + this.offsetToSVGDocumentList; 19525 this.documentList = new SVGDocumentList(p22); 19526 } 19527 }; 19528 var SVGDocumentList = class extends ParsedData { 19529 constructor(p22) { 19530 super(p22); 19531 this.numEntries = p22.uint16; 19532 this.documentRecords = [...new Array(this.numEntries)].map( 19533 (_) => new SVGDocumentRecord(p22) 19534 ); 19535 } 19536 getDocument(documentID) { 19537 let record = this.documentRecords[documentID]; 19538 if (!record) return ""; 19539 let offset = this.start + record.svgDocOffset; 19540 this.parser.currentPosition = offset; 19541 return this.parser.readBytes(record.svgDocLength); 19542 } 19543 getDocumentForGlyph(glyphID) { 19544 let id = this.documentRecords.findIndex( 19545 (d2) => d2.startGlyphID <= glyphID && glyphID <= d2.endGlyphID 19546 ); 19547 if (id === -1) return ""; 19548 return this.getDocument(id); 19549 } 19550 }; 19551 var SVGDocumentRecord = class { 19552 constructor(p22) { 19553 this.startGlyphID = p22.uint16; 19554 this.endGlyphID = p22.uint16; 19555 this.svgDocOffset = p22.Offset32; 19556 this.svgDocLength = p22.uint32; 19557 } 19558 }; 19559 var SVG$1 = Object.freeze({ __proto__: null, SVG: SVG67 }); 19560 var fvar = class extends SimpleTable { 19561 constructor(dict, dataview) { 19562 const { p: p22 } = super(dict, dataview); 19563 this.majorVersion = p22.uint16; 19564 this.minorVersion = p22.uint16; 19565 this.axesArrayOffset = p22.Offset16; 19566 p22.uint16; 19567 this.axisCount = p22.uint16; 19568 this.axisSize = p22.uint16; 19569 this.instanceCount = p22.uint16; 19570 this.instanceSize = p22.uint16; 19571 const axisStart = this.tableStart + this.axesArrayOffset; 19572 lazy$1(this, `axes`, () => { 19573 p22.currentPosition = axisStart; 19574 return [...new Array(this.axisCount)].map( 19575 (_) => new VariationAxisRecord(p22) 19576 ); 19577 }); 19578 const instanceStart = axisStart + this.axisCount * this.axisSize; 19579 lazy$1(this, `instances`, () => { 19580 let instances = []; 19581 for (let i2 = 0; i2 < this.instanceCount; i2++) { 19582 p22.currentPosition = instanceStart + i2 * this.instanceSize; 19583 instances.push( 19584 new InstanceRecord(p22, this.axisCount, this.instanceSize) 19585 ); 19586 } 19587 return instances; 19588 }); 19589 } 19590 getSupportedAxes() { 19591 return this.axes.map((a2) => a2.tag); 19592 } 19593 getAxis(name2) { 19594 return this.axes.find((a2) => a2.tag === name2); 19595 } 19596 }; 19597 var VariationAxisRecord = class { 19598 constructor(p22) { 19599 this.tag = p22.tag; 19600 this.minValue = p22.fixed; 19601 this.defaultValue = p22.fixed; 19602 this.maxValue = p22.fixed; 19603 this.flags = p22.flags(16); 19604 this.axisNameID = p22.uint16; 19605 } 19606 }; 19607 var InstanceRecord = class { 19608 constructor(p22, axisCount, size) { 19609 let start2 = p22.currentPosition; 19610 this.subfamilyNameID = p22.uint16; 19611 p22.uint16; 19612 this.coordinates = [...new Array(axisCount)].map( 19613 (_) => p22.fixed 19614 ); 19615 if (p22.currentPosition - start2 < size) { 19616 this.postScriptNameID = p22.uint16; 19617 } 19618 } 19619 }; 19620 var fvar$1 = Object.freeze({ __proto__: null, fvar }); 19621 var cvt = class extends SimpleTable { 19622 constructor(dict, dataview) { 19623 const { p: p22 } = super(dict, dataview); 19624 const n2 = dict.length / 2; 19625 lazy$1( 19626 this, 19627 `items`, 19628 () => [...new Array(n2)].map((_) => p22.fword) 19629 ); 19630 } 19631 }; 19632 var cvt$1 = Object.freeze({ __proto__: null, cvt }); 19633 var fpgm = class extends SimpleTable { 19634 constructor(dict, dataview) { 19635 const { p: p22 } = super(dict, dataview); 19636 lazy$1( 19637 this, 19638 `instructions`, 19639 () => [...new Array(dict.length)].map((_) => p22.uint8) 19640 ); 19641 } 19642 }; 19643 var fpgm$1 = Object.freeze({ __proto__: null, fpgm }); 19644 var gasp = class extends SimpleTable { 19645 constructor(dict, dataview) { 19646 const { p: p22 } = super(dict, dataview); 19647 this.version = p22.uint16; 19648 this.numRanges = p22.uint16; 19649 const getter = () => [...new Array(this.numRanges)].map( 19650 (_) => new GASPRange(p22) 19651 ); 19652 lazy$1(this, `gaspRanges`, getter); 19653 } 19654 }; 19655 var GASPRange = class { 19656 constructor(p22) { 19657 this.rangeMaxPPEM = p22.uint16; 19658 this.rangeGaspBehavior = p22.uint16; 19659 } 19660 }; 19661 var gasp$1 = Object.freeze({ __proto__: null, gasp }); 19662 var glyf = class extends SimpleTable { 19663 constructor(dict, dataview) { 19664 super(dict, dataview); 19665 } 19666 getGlyphData(offset, length) { 19667 this.parser.currentPosition = this.tableStart + offset; 19668 return this.parser.readBytes(length); 19669 } 19670 }; 19671 var glyf$1 = Object.freeze({ __proto__: null, glyf }); 19672 var loca = class extends SimpleTable { 19673 constructor(dict, dataview, tables) { 19674 const { p: p22 } = super(dict, dataview); 19675 const n2 = tables.maxp.numGlyphs + 1; 19676 if (tables.head.indexToLocFormat === 0) { 19677 this.x2 = true; 19678 lazy$1( 19679 this, 19680 `offsets`, 19681 () => [...new Array(n2)].map((_) => p22.Offset16) 19682 ); 19683 } else { 19684 lazy$1( 19685 this, 19686 `offsets`, 19687 () => [...new Array(n2)].map((_) => p22.Offset32) 19688 ); 19689 } 19690 } 19691 getGlyphDataOffsetAndLength(glyphID) { 19692 let offset = this.offsets[glyphID] * this.x2 ? 2 : 1; 19693 let nextOffset = this.offsets[glyphID + 1] * this.x2 ? 2 : 1; 19694 return { offset, length: nextOffset - offset }; 19695 } 19696 }; 19697 var loca$1 = Object.freeze({ __proto__: null, loca }); 19698 var prep = class extends SimpleTable { 19699 constructor(dict, dataview) { 19700 const { p: p22 } = super(dict, dataview); 19701 lazy$1( 19702 this, 19703 `instructions`, 19704 () => [...new Array(dict.length)].map((_) => p22.uint8) 19705 ); 19706 } 19707 }; 19708 var prep$1 = Object.freeze({ __proto__: null, prep }); 19709 var CFF = class extends SimpleTable { 19710 constructor(dict, dataview) { 19711 const { p: p22 } = super(dict, dataview); 19712 lazy$1(this, `data`, () => p22.readBytes()); 19713 } 19714 }; 19715 var CFF$1 = Object.freeze({ __proto__: null, CFF }); 19716 var CFF2 = class extends SimpleTable { 19717 constructor(dict, dataview) { 19718 const { p: p22 } = super(dict, dataview); 19719 lazy$1(this, `data`, () => p22.readBytes()); 19720 } 19721 }; 19722 var CFF2$1 = Object.freeze({ __proto__: null, CFF2 }); 19723 var VORG = class extends SimpleTable { 19724 constructor(dict, dataview) { 19725 const { p: p22 } = super(dict, dataview); 19726 this.majorVersion = p22.uint16; 19727 this.minorVersion = p22.uint16; 19728 this.defaultVertOriginY = p22.int16; 19729 this.numVertOriginYMetrics = p22.uint16; 19730 lazy$1( 19731 this, 19732 `vertORiginYMetrics`, 19733 () => [...new Array(this.numVertOriginYMetrics)].map( 19734 (_) => new VertOriginYMetric(p22) 19735 ) 19736 ); 19737 } 19738 }; 19739 var VertOriginYMetric = class { 19740 constructor(p22) { 19741 this.glyphIndex = p22.uint16; 19742 this.vertOriginY = p22.int16; 19743 } 19744 }; 19745 var VORG$1 = Object.freeze({ __proto__: null, VORG }); 19746 var BitmapSize = class { 19747 constructor(p22) { 19748 this.indexSubTableArrayOffset = p22.Offset32; 19749 this.indexTablesSize = p22.uint32; 19750 this.numberofIndexSubTables = p22.uint32; 19751 this.colorRef = p22.uint32; 19752 this.hori = new SbitLineMetrics(p22); 19753 this.vert = new SbitLineMetrics(p22); 19754 this.startGlyphIndex = p22.uint16; 19755 this.endGlyphIndex = p22.uint16; 19756 this.ppemX = p22.uint8; 19757 this.ppemY = p22.uint8; 19758 this.bitDepth = p22.uint8; 19759 this.flags = p22.int8; 19760 } 19761 }; 19762 var BitmapScale = class { 19763 constructor(p22) { 19764 this.hori = new SbitLineMetrics(p22); 19765 this.vert = new SbitLineMetrics(p22); 19766 this.ppemX = p22.uint8; 19767 this.ppemY = p22.uint8; 19768 this.substitutePpemX = p22.uint8; 19769 this.substitutePpemY = p22.uint8; 19770 } 19771 }; 19772 var SbitLineMetrics = class { 19773 constructor(p22) { 19774 this.ascender = p22.int8; 19775 this.descender = p22.int8; 19776 this.widthMax = p22.uint8; 19777 this.caretSlopeNumerator = p22.int8; 19778 this.caretSlopeDenominator = p22.int8; 19779 this.caretOffset = p22.int8; 19780 this.minOriginSB = p22.int8; 19781 this.minAdvanceSB = p22.int8; 19782 this.maxBeforeBL = p22.int8; 19783 this.minAfterBL = p22.int8; 19784 this.pad1 = p22.int8; 19785 this.pad2 = p22.int8; 19786 } 19787 }; 19788 var EBLC = class extends SimpleTable { 19789 constructor(dict, dataview, name2) { 19790 const { p: p22 } = super(dict, dataview, name2); 19791 this.majorVersion = p22.uint16; 19792 this.minorVersion = p22.uint16; 19793 this.numSizes = p22.uint32; 19794 lazy$1( 19795 this, 19796 `bitMapSizes`, 19797 () => [...new Array(this.numSizes)].map( 19798 (_) => new BitmapSize(p22) 19799 ) 19800 ); 19801 } 19802 }; 19803 var EBLC$1 = Object.freeze({ __proto__: null, EBLC }); 19804 var EBDT = class extends SimpleTable { 19805 constructor(dict, dataview, name2) { 19806 const { p: p22 } = super(dict, dataview, name2); 19807 this.majorVersion = p22.uint16; 19808 this.minorVersion = p22.uint16; 19809 } 19810 }; 19811 var EBDT$1 = Object.freeze({ __proto__: null, EBDT }); 19812 var EBSC = class extends SimpleTable { 19813 constructor(dict, dataview) { 19814 const { p: p22 } = super(dict, dataview); 19815 this.majorVersion = p22.uint16; 19816 this.minorVersion = p22.uint16; 19817 this.numSizes = p22.uint32; 19818 lazy$1( 19819 this, 19820 `bitmapScales`, 19821 () => [...new Array(this.numSizes)].map( 19822 (_) => new BitmapScale(p22) 19823 ) 19824 ); 19825 } 19826 }; 19827 var EBSC$1 = Object.freeze({ __proto__: null, EBSC }); 19828 var CBLC = class extends EBLC { 19829 constructor(dict, dataview) { 19830 super(dict, dataview, `CBLC`); 19831 } 19832 }; 19833 var CBLC$1 = Object.freeze({ __proto__: null, CBLC }); 19834 var CBDT = class extends EBDT { 19835 constructor(dict, dataview) { 19836 super(dict, dataview, `CBDT`); 19837 } 19838 }; 19839 var CBDT$1 = Object.freeze({ __proto__: null, CBDT }); 19840 var sbix = class extends SimpleTable { 19841 constructor(dict, dataview) { 19842 const { p: p22 } = super(dict, dataview); 19843 this.version = p22.uint16; 19844 this.flags = p22.flags(16); 19845 this.numStrikes = p22.uint32; 19846 lazy$1( 19847 this, 19848 `strikeOffsets`, 19849 () => [...new Array(this.numStrikes)].map((_) => p22.Offset32) 19850 ); 19851 } 19852 }; 19853 var sbix$1 = Object.freeze({ __proto__: null, sbix }); 19854 var COLR = class extends SimpleTable { 19855 constructor(dict, dataview) { 19856 const { p: p22 } = super(dict, dataview); 19857 this.version = p22.uint16; 19858 this.numBaseGlyphRecords = p22.uint16; 19859 this.baseGlyphRecordsOffset = p22.Offset32; 19860 this.layerRecordsOffset = p22.Offset32; 19861 this.numLayerRecords = p22.uint16; 19862 } 19863 getBaseGlyphRecord(glyphID) { 19864 let start2 = this.tableStart + this.baseGlyphRecordsOffset; 19865 this.parser.currentPosition = start2; 19866 let first = new BaseGlyphRecord(this.parser); 19867 let firstID = first.gID; 19868 let end = this.tableStart + this.layerRecordsOffset - 6; 19869 this.parser.currentPosition = end; 19870 let last = new BaseGlyphRecord(this.parser); 19871 let lastID = last.gID; 19872 if (firstID === glyphID) return first; 19873 if (lastID === glyphID) return last; 19874 while (true) { 19875 if (start2 === end) break; 19876 let mid = start2 + (end - start2) / 12; 19877 this.parser.currentPosition = mid; 19878 let middle = new BaseGlyphRecord(this.parser); 19879 let midID = middle.gID; 19880 if (midID === glyphID) return middle; 19881 else if (midID > glyphID) { 19882 end = mid; 19883 } else if (midID < glyphID) { 19884 start2 = mid; 19885 } 19886 } 19887 return false; 19888 } 19889 getLayers(glyphID) { 19890 let record = this.getBaseGlyphRecord(glyphID); 19891 this.parser.currentPosition = this.tableStart + this.layerRecordsOffset + 4 * record.firstLayerIndex; 19892 return [...new Array(record.numLayers)].map( 19893 (_) => new LayerRecord(p) 19894 ); 19895 } 19896 }; 19897 var BaseGlyphRecord = class { 19898 constructor(p22) { 19899 this.gID = p22.uint16; 19900 this.firstLayerIndex = p22.uint16; 19901 this.numLayers = p22.uint16; 19902 } 19903 }; 19904 var LayerRecord = class { 19905 constructor(p22) { 19906 this.gID = p22.uint16; 19907 this.paletteIndex = p22.uint16; 19908 } 19909 }; 19910 var COLR$1 = Object.freeze({ __proto__: null, COLR }); 19911 var CPAL = class extends SimpleTable { 19912 constructor(dict, dataview) { 19913 const { p: p22 } = super(dict, dataview); 19914 this.version = p22.uint16; 19915 this.numPaletteEntries = p22.uint16; 19916 const numPalettes = this.numPalettes = p22.uint16; 19917 this.numColorRecords = p22.uint16; 19918 this.offsetFirstColorRecord = p22.Offset32; 19919 this.colorRecordIndices = [...new Array(this.numPalettes)].map( 19920 (_) => p22.uint16 19921 ); 19922 lazy$1(this, `colorRecords`, () => { 19923 p22.currentPosition = this.tableStart + this.offsetFirstColorRecord; 19924 return [...new Array(this.numColorRecords)].map( 19925 (_) => new ColorRecord(p22) 19926 ); 19927 }); 19928 if (this.version === 1) { 19929 this.offsetPaletteTypeArray = p22.Offset32; 19930 this.offsetPaletteLabelArray = p22.Offset32; 19931 this.offsetPaletteEntryLabelArray = p22.Offset32; 19932 lazy$1(this, `paletteTypeArray`, () => { 19933 p22.currentPosition = this.tableStart + this.offsetPaletteTypeArray; 19934 return new PaletteTypeArray(p22, numPalettes); 19935 }); 19936 lazy$1(this, `paletteLabelArray`, () => { 19937 p22.currentPosition = this.tableStart + this.offsetPaletteLabelArray; 19938 return new PaletteLabelsArray(p22, numPalettes); 19939 }); 19940 lazy$1(this, `paletteEntryLabelArray`, () => { 19941 p22.currentPosition = this.tableStart + this.offsetPaletteEntryLabelArray; 19942 return new PaletteEntryLabelArray(p22, numPalettes); 19943 }); 19944 } 19945 } 19946 }; 19947 var ColorRecord = class { 19948 constructor(p22) { 19949 this.blue = p22.uint8; 19950 this.green = p22.uint8; 19951 this.red = p22.uint8; 19952 this.alpha = p22.uint8; 19953 } 19954 }; 19955 var PaletteTypeArray = class { 19956 constructor(p22, numPalettes) { 19957 this.paletteTypes = [...new Array(numPalettes)].map( 19958 (_) => p22.uint32 19959 ); 19960 } 19961 }; 19962 var PaletteLabelsArray = class { 19963 constructor(p22, numPalettes) { 19964 this.paletteLabels = [...new Array(numPalettes)].map( 19965 (_) => p22.uint16 19966 ); 19967 } 19968 }; 19969 var PaletteEntryLabelArray = class { 19970 constructor(p22, numPalettes) { 19971 this.paletteEntryLabels = [...new Array(numPalettes)].map( 19972 (_) => p22.uint16 19973 ); 19974 } 19975 }; 19976 var CPAL$1 = Object.freeze({ __proto__: null, CPAL }); 19977 var DSIG = class extends SimpleTable { 19978 constructor(dict, dataview) { 19979 const { p: p22 } = super(dict, dataview); 19980 this.version = p22.uint32; 19981 this.numSignatures = p22.uint16; 19982 this.flags = p22.uint16; 19983 this.signatureRecords = [...new Array(this.numSignatures)].map( 19984 (_) => new SignatureRecord(p22) 19985 ); 19986 } 19987 getData(signatureID) { 19988 const record = this.signatureRecords[signatureID]; 19989 this.parser.currentPosition = this.tableStart + record.offset; 19990 return new SignatureBlockFormat1(this.parser); 19991 } 19992 }; 19993 var SignatureRecord = class { 19994 constructor(p22) { 19995 this.format = p22.uint32; 19996 this.length = p22.uint32; 19997 this.offset = p22.Offset32; 19998 } 19999 }; 20000 var SignatureBlockFormat1 = class { 20001 constructor(p22) { 20002 p22.uint16; 20003 p22.uint16; 20004 this.signatureLength = p22.uint32; 20005 this.signature = p22.readBytes(this.signatureLength); 20006 } 20007 }; 20008 var DSIG$1 = Object.freeze({ __proto__: null, DSIG }); 20009 var hdmx = class extends SimpleTable { 20010 constructor(dict, dataview, tables) { 20011 const { p: p22 } = super(dict, dataview); 20012 const numGlyphs = tables.hmtx.numGlyphs; 20013 this.version = p22.uint16; 20014 this.numRecords = p22.int16; 20015 this.sizeDeviceRecord = p22.int32; 20016 this.records = [...new Array(numRecords)].map( 20017 (_) => new DeviceRecord(p22, numGlyphs) 20018 ); 20019 } 20020 }; 20021 var DeviceRecord = class { 20022 constructor(p22, numGlyphs) { 20023 this.pixelSize = p22.uint8; 20024 this.maxWidth = p22.uint8; 20025 this.widths = p22.readBytes(numGlyphs); 20026 } 20027 }; 20028 var hdmx$1 = Object.freeze({ __proto__: null, hdmx }); 20029 var kern = class extends SimpleTable { 20030 constructor(dict, dataview) { 20031 const { p: p22 } = super(dict, dataview); 20032 this.version = p22.uint16; 20033 this.nTables = p22.uint16; 20034 lazy$1(this, `tables`, () => { 20035 let offset = this.tableStart + 4; 20036 const tables = []; 20037 for (let i2 = 0; i2 < this.nTables; i2++) { 20038 p22.currentPosition = offset; 20039 let subtable = new KernSubTable(p22); 20040 tables.push(subtable); 20041 offset += subtable; 20042 } 20043 return tables; 20044 }); 20045 } 20046 }; 20047 var KernSubTable = class { 20048 constructor(p22) { 20049 this.version = p22.uint16; 20050 this.length = p22.uint16; 20051 this.coverage = p22.flags(8); 20052 this.format = p22.uint8; 20053 if (this.format === 0) { 20054 this.nPairs = p22.uint16; 20055 this.searchRange = p22.uint16; 20056 this.entrySelector = p22.uint16; 20057 this.rangeShift = p22.uint16; 20058 lazy$1( 20059 this, 20060 `pairs`, 20061 () => [...new Array(this.nPairs)].map((_) => new Pair(p22)) 20062 ); 20063 } 20064 if (this.format === 2) { 20065 console.warn( 20066 `Kern subtable format 2 is not supported: this parser currently only parses universal table data.` 20067 ); 20068 } 20069 } 20070 get horizontal() { 20071 return this.coverage[0]; 20072 } 20073 get minimum() { 20074 return this.coverage[1]; 20075 } 20076 get crossstream() { 20077 return this.coverage[2]; 20078 } 20079 get override() { 20080 return this.coverage[3]; 20081 } 20082 }; 20083 var Pair = class { 20084 constructor(p22) { 20085 this.left = p22.uint16; 20086 this.right = p22.uint16; 20087 this.value = p22.fword; 20088 } 20089 }; 20090 var kern$1 = Object.freeze({ __proto__: null, kern }); 20091 var LTSH = class extends SimpleTable { 20092 constructor(dict, dataview) { 20093 const { p: p22 } = super(dict, dataview); 20094 this.version = p22.uint16; 20095 this.numGlyphs = p22.uint16; 20096 this.yPels = p22.readBytes(this.numGlyphs); 20097 } 20098 }; 20099 var LTSH$1 = Object.freeze({ __proto__: null, LTSH }); 20100 var MERG = class extends SimpleTable { 20101 constructor(dict, dataview) { 20102 const { p: p22 } = super(dict, dataview); 20103 this.version = p22.uint16; 20104 this.mergeClassCount = p22.uint16; 20105 this.mergeDataOffset = p22.Offset16; 20106 this.classDefCount = p22.uint16; 20107 this.offsetToClassDefOffsets = p22.Offset16; 20108 lazy$1( 20109 this, 20110 `mergeEntryMatrix`, 20111 () => [...new Array(this.mergeClassCount)].map( 20112 (_) => p22.readBytes(this.mergeClassCount) 20113 ) 20114 ); 20115 console.warn(`Full MERG parsing is currently not supported.`); 20116 console.warn( 20117 `If you need this table parsed, please file an issue, or better yet, a PR.` 20118 ); 20119 } 20120 }; 20121 var MERG$1 = Object.freeze({ __proto__: null, MERG }); 20122 var meta = class extends SimpleTable { 20123 constructor(dict, dataview) { 20124 const { p: p22 } = super(dict, dataview); 20125 this.version = p22.uint32; 20126 this.flags = p22.uint32; 20127 p22.uint32; 20128 this.dataMapsCount = p22.uint32; 20129 this.dataMaps = [...new Array(this.dataMapsCount)].map( 20130 (_) => new DataMap(this.tableStart, p22) 20131 ); 20132 } 20133 }; 20134 var DataMap = class { 20135 constructor(tableStart, p22) { 20136 this.tableStart = tableStart; 20137 this.parser = p22; 20138 this.tag = p22.tag; 20139 this.dataOffset = p22.Offset32; 20140 this.dataLength = p22.uint32; 20141 } 20142 getData() { 20143 this.parser.currentField = this.tableStart + this.dataOffset; 20144 return this.parser.readBytes(this.dataLength); 20145 } 20146 }; 20147 var meta$1 = Object.freeze({ __proto__: null, meta }); 20148 var PCLT = class extends SimpleTable { 20149 constructor(dict, dataview) { 20150 super(dict, dataview); 20151 console.warn( 20152 `This font uses a PCLT table, which is currently not supported by this parser.` 20153 ); 20154 console.warn( 20155 `If you need this table parsed, please file an issue, or better yet, a PR.` 20156 ); 20157 } 20158 }; 20159 var PCLT$1 = Object.freeze({ __proto__: null, PCLT }); 20160 var VDMX = class extends SimpleTable { 20161 constructor(dict, dataview) { 20162 const { p: p22 } = super(dict, dataview); 20163 this.version = p22.uint16; 20164 this.numRecs = p22.uint16; 20165 this.numRatios = p22.uint16; 20166 this.ratRanges = [...new Array(this.numRatios)].map( 20167 (_) => new RatioRange(p22) 20168 ); 20169 this.offsets = [...new Array(this.numRatios)].map( 20170 (_) => p22.Offset16 20171 ); 20172 this.VDMXGroups = [...new Array(this.numRecs)].map( 20173 (_) => new VDMXGroup(p22) 20174 ); 20175 } 20176 }; 20177 var RatioRange = class { 20178 constructor(p22) { 20179 this.bCharSet = p22.uint8; 20180 this.xRatio = p22.uint8; 20181 this.yStartRatio = p22.uint8; 20182 this.yEndRatio = p22.uint8; 20183 } 20184 }; 20185 var VDMXGroup = class { 20186 constructor(p22) { 20187 this.recs = p22.uint16; 20188 this.startsz = p22.uint8; 20189 this.endsz = p22.uint8; 20190 this.records = [...new Array(this.recs)].map( 20191 (_) => new vTable(p22) 20192 ); 20193 } 20194 }; 20195 var vTable = class { 20196 constructor(p22) { 20197 this.yPelHeight = p22.uint16; 20198 this.yMax = p22.int16; 20199 this.yMin = p22.int16; 20200 } 20201 }; 20202 var VDMX$1 = Object.freeze({ __proto__: null, VDMX }); 20203 var vhea = class extends SimpleTable { 20204 constructor(dict, dataview) { 20205 const { p: p22 } = super(dict, dataview); 20206 this.version = p22.fixed; 20207 this.ascent = this.vertTypoAscender = p22.int16; 20208 this.descent = this.vertTypoDescender = p22.int16; 20209 this.lineGap = this.vertTypoLineGap = p22.int16; 20210 this.advanceHeightMax = p22.int16; 20211 this.minTopSideBearing = p22.int16; 20212 this.minBottomSideBearing = p22.int16; 20213 this.yMaxExtent = p22.int16; 20214 this.caretSlopeRise = p22.int16; 20215 this.caretSlopeRun = p22.int16; 20216 this.caretOffset = p22.int16; 20217 this.reserved = p22.int16; 20218 this.reserved = p22.int16; 20219 this.reserved = p22.int16; 20220 this.reserved = p22.int16; 20221 this.metricDataFormat = p22.int16; 20222 this.numOfLongVerMetrics = p22.uint16; 20223 p22.verifyLength(); 20224 } 20225 }; 20226 var vhea$1 = Object.freeze({ __proto__: null, vhea }); 20227 var vmtx = class extends SimpleTable { 20228 constructor(dict, dataview, tables) { 20229 super(dict, dataview); 20230 const numOfLongVerMetrics = tables.vhea.numOfLongVerMetrics; 20231 const numGlyphs = tables.maxp.numGlyphs; 20232 const metricsStart = p.currentPosition; 20233 lazy(this, `vMetrics`, () => { 20234 p.currentPosition = metricsStart; 20235 return [...new Array(numOfLongVerMetrics)].map( 20236 (_) => new LongVertMetric(p.uint16, p.int16) 20237 ); 20238 }); 20239 if (numOfLongVerMetrics < numGlyphs) { 20240 const tsbStart = metricsStart + numOfLongVerMetrics * 4; 20241 lazy(this, `topSideBearings`, () => { 20242 p.currentPosition = tsbStart; 20243 return [...new Array(numGlyphs - numOfLongVerMetrics)].map( 20244 (_) => p.int16 20245 ); 20246 }); 20247 } 20248 } 20249 }; 20250 var LongVertMetric = class { 20251 constructor(h2, b2) { 20252 this.advanceHeight = h2; 20253 this.topSideBearing = b2; 20254 } 20255 }; 20256 var vmtx$1 = Object.freeze({ __proto__: null, vmtx }); 20257 20258 // packages/global-styles-ui/build-module/font-library/utils/make-families-from-faces.js 20259 var import_components39 = __toESM(require_components()); 20260 var { kebabCase: kebabCase3 } = unlock2(import_components39.privateApis); 20261 20262 // packages/global-styles-ui/build-module/font-library/upload-fonts.js 20263 var import_jsx_runtime109 = __toESM(require_jsx_runtime()); 20264 20265 // packages/global-styles-ui/build-module/font-library/modal.js 20266 var import_jsx_runtime110 = __toESM(require_jsx_runtime()); 20267 var { Tabs } = unlock2(import_components41.privateApis); 20268 var DEFAULT_TAB = { 20269 id: "installed-fonts", 20270 title: (0, import_i18n28._x)("Library", "Font library") 20271 }; 20272 var UPLOAD_TAB = { 20273 id: "upload-fonts", 20274 title: (0, import_i18n28._x)("Upload", "noun") 20275 }; 20276 20277 // packages/global-styles-ui/build-module/font-family-item.js 20278 var import_i18n29 = __toESM(require_i18n()); 20279 var import_components42 = __toESM(require_components()); 20280 var import_element32 = __toESM(require_element()); 20281 var import_jsx_runtime111 = __toESM(require_jsx_runtime()); 20282 20283 // packages/global-styles-ui/build-module/font-families.js 20284 var import_jsx_runtime112 = __toESM(require_jsx_runtime()); 20285 20286 // packages/global-styles-ui/build-module/font-sizes/font-sizes-count.js 20287 var import_i18n31 = __toESM(require_i18n()); 20288 var import_components44 = __toESM(require_components()); 20289 var import_jsx_runtime113 = __toESM(require_jsx_runtime()); 20290 20291 // packages/global-styles-ui/build-module/screen-typography.js 20292 var import_jsx_runtime114 = __toESM(require_jsx_runtime()); 20293 20294 // packages/global-styles-ui/build-module/screen-typography-element.js 20295 var import_i18n33 = __toESM(require_i18n()); 20296 var import_components46 = __toESM(require_components()); 20297 var import_element35 = __toESM(require_element()); 20298 20299 // packages/global-styles-ui/build-module/typography-panel.js 20300 var import_block_editor8 = __toESM(require_block_editor()); 20301 var import_jsx_runtime115 = __toESM(require_jsx_runtime()); 20302 var { useSettingsForBlockElement: useSettingsForBlockElement4, TypographyPanel: StylesTypographyPanel2 } = unlock2(import_block_editor8.privateApis); 20303 20304 // packages/global-styles-ui/build-module/typography-preview.js 20305 var import_jsx_runtime116 = __toESM(require_jsx_runtime()); 20306 20307 // packages/global-styles-ui/build-module/screen-typography-element.js 20308 var import_jsx_runtime117 = __toESM(require_jsx_runtime()); 20309 var elements = { 20310 text: { 20311 description: (0, import_i18n33.__)("Manage the fonts used on the site."), 20312 title: (0, import_i18n33.__)("Text") 20313 }, 20314 link: { 20315 description: (0, import_i18n33.__)("Manage the fonts and typography used on the links."), 20316 title: (0, import_i18n33.__)("Links") 20317 }, 20318 heading: { 20319 description: (0, import_i18n33.__)("Manage the fonts and typography used on headings."), 20320 title: (0, import_i18n33.__)("Headings") 20321 }, 20322 caption: { 20323 description: (0, import_i18n33.__)("Manage the fonts and typography used on captions."), 20324 title: (0, import_i18n33.__)("Captions") 20325 }, 20326 button: { 20327 description: (0, import_i18n33.__)("Manage the fonts and typography used on buttons."), 20328 title: (0, import_i18n33.__)("Buttons") 20329 } 20330 }; 20331 20332 // packages/global-styles-ui/build-module/screen-colors.js 20333 var import_i18n35 = __toESM(require_i18n()); 20334 var import_components49 = __toESM(require_components()); 20335 var import_block_editor9 = __toESM(require_block_editor()); 20336 20337 // packages/global-styles-ui/build-module/palette.js 20338 var import_components48 = __toESM(require_components()); 20339 var import_i18n34 = __toESM(require_i18n()); 20340 var import_element36 = __toESM(require_element()); 20341 20342 // packages/global-styles-ui/build-module/color-indicator-wrapper.js 20343 var import_components47 = __toESM(require_components()); 20344 var import_jsx_runtime118 = __toESM(require_jsx_runtime()); 20345 20346 // packages/global-styles-ui/build-module/palette.js 20347 var import_jsx_runtime119 = __toESM(require_jsx_runtime()); 20348 20349 // packages/global-styles-ui/build-module/screen-colors.js 20350 var import_jsx_runtime120 = __toESM(require_jsx_runtime()); 20351 var { useSettingsForBlockElement: useSettingsForBlockElement5, ColorPanel: StylesColorPanel2 } = unlock2( 20352 import_block_editor9.privateApis 20353 ); 20354 20355 // packages/global-styles-ui/build-module/screen-color-palette.js 20356 var import_i18n38 = __toESM(require_i18n()); 20357 var import_components54 = __toESM(require_components()); 20358 20359 // packages/global-styles-ui/build-module/color-palette-panel.js 20360 var import_compose6 = __toESM(require_compose()); 20361 var import_components52 = __toESM(require_components()); 20362 var import_i18n36 = __toESM(require_i18n()); 20363 20364 // packages/global-styles-ui/build-module/variations/variations-color.js 20365 var import_components51 = __toESM(require_components()); 20366 20367 // packages/global-styles-ui/build-module/preview-colors.js 20368 var import_components50 = __toESM(require_components()); 20369 20370 // packages/global-styles-ui/build-module/preset-colors.js 20371 var import_jsx_runtime121 = __toESM(require_jsx_runtime()); 20372 function PresetColors() { 20373 const { paletteColors } = useStylesPreviewColors(); 20374 return paletteColors.slice(0, 4).map(({ slug, color }, index) => /* @__PURE__ */ (0, import_jsx_runtime121.jsx)( 20375 "div", 20376 { 20377 style: { 20378 flexGrow: 1, 20379 height: "100%", 20380 background: color 20381 } 20382 }, 20383 `$slug}-$index}` 20384 )); 20385 } 20386 20387 // packages/global-styles-ui/build-module/preview-colors.js 20388 var import_jsx_runtime122 = __toESM(require_jsx_runtime()); 20389 var firstFrameVariants2 = { 20390 start: { 20391 scale: 1, 20392 opacity: 1 20393 }, 20394 hover: { 20395 scale: 0, 20396 opacity: 0 20397 } 20398 }; 20399 var StylesPreviewColors = ({ 20400 label, 20401 isFocused, 20402 withHoverView 20403 }) => { 20404 return /* @__PURE__ */ (0, import_jsx_runtime122.jsx)( 20405 preview_wrapper_default, 20406 { 20407 label, 20408 isFocused, 20409 withHoverView, 20410 children: ({ key }) => /* @__PURE__ */ (0, import_jsx_runtime122.jsx)( 20411 import_components50.__unstableMotion.div, 20412 { 20413 variants: firstFrameVariants2, 20414 style: { 20415 height: "100%", 20416 overflow: "hidden" 20417 }, 20418 children: /* @__PURE__ */ (0, import_jsx_runtime122.jsx)( 20419 import_components50.__experimentalHStack, 20420 { 20421 spacing: 0, 20422 justify: "center", 20423 style: { 20424 height: "100%", 20425 overflow: "hidden" 20426 }, 20427 children: /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(PresetColors, {}) 20428 } 20429 ) 20430 }, 20431 key 20432 ) 20433 } 20434 ); 20435 }; 20436 var preview_colors_default = StylesPreviewColors; 20437 20438 // packages/global-styles-ui/build-module/variations/variations-color.js 20439 var import_jsx_runtime123 = __toESM(require_jsx_runtime()); 20440 var propertiesToFilter2 = ["color"]; 20441 function ColorVariations({ 20442 title, 20443 gap = 2 20444 }) { 20445 const colorVariations = useCurrentMergeThemeStyleVariationsWithUserConfig(propertiesToFilter2); 20446 if (colorVariations?.length <= 1) { 20447 return null; 20448 } 20449 return /* @__PURE__ */ (0, import_jsx_runtime123.jsxs)(import_components51.__experimentalVStack, { spacing: 3, children: [ 20450 title && /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(Subtitle, { level: 3, children: title }), 20451 /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(import_components51.__experimentalGrid, { gap, children: colorVariations.map((variation, index) => /* @__PURE__ */ (0, import_jsx_runtime123.jsx)( 20452 Variation, 20453 { 20454 variation, 20455 isPill: true, 20456 properties: propertiesToFilter2, 20457 showTooltip: true, 20458 children: () => /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(preview_colors_default, {}) 20459 }, 20460 index 20461 )) }) 20462 ] }); 20463 } 20464 20465 // packages/global-styles-ui/build-module/color-palette-panel.js 20466 var import_jsx_runtime124 = __toESM(require_jsx_runtime()); 20467 20468 // packages/global-styles-ui/build-module/gradients-palette-panel.js 20469 var import_compose7 = __toESM(require_compose()); 20470 var import_components53 = __toESM(require_components()); 20471 var import_i18n37 = __toESM(require_i18n()); 20472 var import_jsx_runtime125 = __toESM(require_jsx_runtime()); 20473 20474 // packages/global-styles-ui/build-module/screen-color-palette.js 20475 var import_jsx_runtime126 = __toESM(require_jsx_runtime()); 20476 var { Tabs: Tabs2 } = unlock2(import_components54.privateApis); 20477 20478 // packages/global-styles-ui/build-module/screen-background.js 20479 var import_i18n39 = __toESM(require_i18n()); 20480 var import_block_editor11 = __toESM(require_block_editor()); 20481 var import_components55 = __toESM(require_components()); 20482 20483 // packages/global-styles-ui/build-module/background-panel.js 20484 var import_block_editor10 = __toESM(require_block_editor()); 20485 var import_jsx_runtime127 = __toESM(require_jsx_runtime()); 20486 var { BackgroundPanel: StylesBackgroundPanel2 } = unlock2( 20487 import_block_editor10.privateApis 20488 ); 20489 20490 // packages/global-styles-ui/build-module/screen-background.js 20491 var import_jsx_runtime128 = __toESM(require_jsx_runtime()); 20492 var { useHasBackgroundPanel: useHasBackgroundPanel3 } = unlock2(import_block_editor11.privateApis); 20493 20494 // packages/global-styles-ui/build-module/shadows-panel.js 20495 var import_components57 = __toESM(require_components()); 20496 var import_i18n41 = __toESM(require_i18n()); 20497 var import_element37 = __toESM(require_element()); 20498 20499 // packages/global-styles-ui/build-module/confirm-reset-shadow-dialog.js 20500 var import_components56 = __toESM(require_components()); 20501 var import_i18n40 = __toESM(require_i18n()); 20502 var import_jsx_runtime129 = __toESM(require_jsx_runtime()); 20503 20504 // packages/global-styles-ui/build-module/shadows-panel.js 20505 var import_jsx_runtime130 = __toESM(require_jsx_runtime()); 20506 var { Menu } = unlock2(import_components57.privateApis); 20507 20508 // packages/global-styles-ui/build-module/shadows-edit-panel.js 20509 var import_components58 = __toESM(require_components()); 20510 var import_i18n42 = __toESM(require_i18n()); 20511 var import_element38 = __toESM(require_element()); 20512 var import_jsx_runtime131 = __toESM(require_jsx_runtime()); 20513 var { Menu: Menu2 } = unlock2(import_components58.privateApis); 20514 var customShadowMenuItems = [ 20515 { 20516 label: (0, import_i18n42.__)("Rename"), 20517 action: "rename" 20518 }, 20519 { 20520 label: (0, import_i18n42.__)("Delete"), 20521 action: "delete" 20522 } 20523 ]; 20524 var presetShadowMenuItems = [ 20525 { 20526 label: (0, import_i18n42.__)("Reset"), 20527 action: "reset" 20528 } 20529 ]; 20530 20531 // packages/global-styles-ui/build-module/screen-shadows.js 20532 var import_jsx_runtime132 = __toESM(require_jsx_runtime()); 20533 20534 // packages/global-styles-ui/build-module/screen-layout.js 20535 var import_i18n43 = __toESM(require_i18n()); 20536 var import_block_editor13 = __toESM(require_block_editor()); 20537 20538 // packages/global-styles-ui/build-module/dimensions-panel.js 20539 var import_block_editor12 = __toESM(require_block_editor()); 20540 var import_element39 = __toESM(require_element()); 20541 var import_jsx_runtime133 = __toESM(require_jsx_runtime()); 20542 var { useSettingsForBlockElement: useSettingsForBlockElement6, DimensionsPanel: StylesDimensionsPanel2 } = unlock2(import_block_editor12.privateApis); 20543 20544 // packages/global-styles-ui/build-module/screen-layout.js 20545 var import_jsx_runtime134 = __toESM(require_jsx_runtime()); 20546 var { useHasDimensionsPanel: useHasDimensionsPanel4, useSettingsForBlockElement: useSettingsForBlockElement7 } = unlock2( 20547 import_block_editor13.privateApis 20548 ); 20549 20550 // packages/global-styles-ui/build-module/screen-style-variations.js 20551 var import_components61 = __toESM(require_components()); 20552 var import_i18n46 = __toESM(require_i18n()); 20553 20554 // packages/global-styles-ui/build-module/style-variations-content.js 20555 var import_i18n45 = __toESM(require_i18n()); 20556 var import_components60 = __toESM(require_components()); 20557 20558 // packages/global-styles-ui/build-module/style-variations-container.js 20559 var import_core_data22 = __toESM(require_core_data()); 20560 var import_data26 = __toESM(require_data()); 20561 var import_element40 = __toESM(require_element()); 20562 var import_components59 = __toESM(require_components()); 20563 var import_i18n44 = __toESM(require_i18n()); 20564 var import_jsx_runtime135 = __toESM(require_jsx_runtime()); 20565 function StyleVariationsContainer({ 20566 gap = 2 20567 }) { 20568 const { user } = (0, import_element40.useContext)(GlobalStylesContext); 20569 const userStyles = user?.styles; 20570 const variations = (0, import_data26.useSelect)((select3) => { 20571 const result = select3( 20572 import_core_data22.store 20573 ).__experimentalGetCurrentThemeGlobalStylesVariations(); 20574 return Array.isArray(result) ? result : void 0; 20575 }, []); 20576 const fullStyleVariations = variations?.filter( 20577 (variation) => { 20578 return !isVariationWithProperties(variation, ["color"]) && !isVariationWithProperties(variation, [ 20579 "typography", 20580 "spacing" 20581 ]); 20582 } 20583 ); 20584 const themeVariations = (0, import_element40.useMemo)(() => { 20585 const withEmptyVariation = [ 20586 { 20587 title: (0, import_i18n44.__)("Default"), 20588 settings: {}, 20589 styles: {} 20590 }, 20591 ...fullStyleVariations ?? [] 20592 ]; 20593 return [ 20594 ...withEmptyVariation.map((variation) => { 20595 const blockStyles = variation?.styles?.blocks ? { ...variation.styles.blocks } : {}; 20596 if (userStyles?.blocks) { 20597 Object.keys(userStyles.blocks).forEach((blockName) => { 20598 if (userStyles.blocks?.[blockName]?.css) { 20599 const variationBlockStyles = blockStyles[blockName] || {}; 20600 const customCSS = { 20601 css: `$blockStyles[blockName]?.css || ""} $userStyles.blocks?.[blockName]?.css?.trim() || ""}` 20602 }; 20603 blockStyles[blockName] = { 20604 ...variationBlockStyles, 20605 ...customCSS 20606 }; 20607 } 20608 }); 20609 } 20610 const css = userStyles?.css || variation.styles?.css ? { 20611 css: `$variation.styles?.css || ""} $userStyles?.css || ""}` 20612 } : {}; 20613 const blocks = Object.keys(blockStyles).length > 0 ? { blocks: blockStyles } : {}; 20614 const styles = { 20615 ...variation.styles, 20616 ...css, 20617 ...blocks 20618 }; 20619 return { 20620 ...variation, 20621 settings: variation.settings ?? {}, 20622 styles 20623 }; 20624 }) 20625 ]; 20626 }, [fullStyleVariations, userStyles?.blocks, userStyles?.css]); 20627 if (!fullStyleVariations || fullStyleVariations.length < 1) { 20628 return null; 20629 } 20630 return /* @__PURE__ */ (0, import_jsx_runtime135.jsx)( 20631 import_components59.__experimentalGrid, 20632 { 20633 columns: 2, 20634 className: "global-styles-ui-style-variations-container", 20635 gap, 20636 children: themeVariations.map( 20637 (variation, index) => /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(Variation, { variation, children: (isFocused) => /* @__PURE__ */ (0, import_jsx_runtime135.jsx)( 20638 preview_styles_default, 20639 { 20640 label: variation?.title, 20641 withHoverView: true, 20642 isFocused, 20643 variation 20644 } 20645 ) }, index) 20646 ) 20647 } 20648 ); 20649 } 20650 var style_variations_container_default = StyleVariationsContainer; 20651 20652 // packages/global-styles-ui/build-module/style-variations-content.js 20653 var import_jsx_runtime136 = __toESM(require_jsx_runtime()); 20654 20655 // packages/global-styles-ui/build-module/screen-style-variations.js 20656 var import_jsx_runtime137 = __toESM(require_jsx_runtime()); 20657 20658 // packages/global-styles-ui/build-module/screen-css.js 20659 var import_i18n47 = __toESM(require_i18n()); 20660 var import_components62 = __toESM(require_components()); 20661 var import_block_editor14 = __toESM(require_block_editor()); 20662 var import_jsx_runtime138 = __toESM(require_jsx_runtime()); 20663 var { AdvancedPanel: StylesAdvancedPanel2 } = unlock2(import_block_editor14.privateApis); 20664 20665 // packages/global-styles-ui/build-module/screen-revisions/index.js 20666 var import_i18n50 = __toESM(require_i18n()); 20667 var import_components65 = __toESM(require_components()); 20668 var import_element42 = __toESM(require_element()); 20669 20670 // packages/global-styles-ui/build-module/screen-revisions/use-global-styles-revisions.js 20671 var import_data27 = __toESM(require_data()); 20672 var import_core_data23 = __toESM(require_core_data()); 20673 var import_element41 = __toESM(require_element()); 20674 var SITE_EDITOR_AUTHORS_QUERY = { 20675 per_page: -1, 20676 _fields: "id,name,avatar_urls", 20677 context: "view", 20678 capabilities: ["edit_theme_options"] 20679 }; 20680 var DEFAULT_QUERY = { per_page: 100, page: 1 }; 20681 var EMPTY_ARRAY3 = []; 20682 function useGlobalStylesRevisions({ 20683 query 20684 } = {}) { 20685 const { user: userConfig } = (0, import_element41.useContext)(GlobalStylesContext); 20686 const _query = (0, import_element41.useMemo)( 20687 () => ({ ...DEFAULT_QUERY, ...query }), 20688 [query] 20689 ); 20690 const { 20691 authors, 20692 currentUser, 20693 isDirty, 20694 revisions, 20695 isLoadingGlobalStylesRevisions, 20696 revisionsCount 20697 } = (0, import_data27.useSelect)( 20698 (select3) => { 20699 const { 20700 __experimentalGetDirtyEntityRecords, 20701 getCurrentUser, 20702 getUsers, 20703 getRevisions, 20704 __experimentalGetCurrentGlobalStylesId, 20705 getEntityRecord, 20706 // @ts-expect-error 20707 isResolving 20708 } = select3(import_core_data23.store); 20709 const dirtyEntityRecords = __experimentalGetDirtyEntityRecords() || []; 20710 const _currentUser = getCurrentUser(); 20711 const _isDirty = dirtyEntityRecords.length > 0; 20712 const globalStylesId = __experimentalGetCurrentGlobalStylesId(); 20713 const globalStyles = globalStylesId ? getEntityRecord( 20714 "root", 20715 "globalStyles", 20716 globalStylesId 20717 ) : void 0; 20718 const _revisionsCount = ( 20719 // @ts-expect-error - _links is not typed in GlobalStylesRevision 20720 globalStyles?._links?.["version-history"]?.[0]?.count ?? 0 20721 ); 20722 const globalStylesRevisions = globalStylesId ? getRevisions( 20723 "root", 20724 "globalStyles", 20725 globalStylesId, 20726 _query 20727 ) || EMPTY_ARRAY3 : EMPTY_ARRAY3; 20728 const _authors = getUsers(SITE_EDITOR_AUTHORS_QUERY) || EMPTY_ARRAY3; 20729 const _isResolving = globalStylesId ? isResolving("getRevisions", [ 20730 "root", 20731 "globalStyles", 20732 globalStylesId, 20733 _query 20734 ]) : false; 20735 return { 20736 authors: _authors, 20737 currentUser: _currentUser, 20738 isDirty: _isDirty, 20739 revisions: globalStylesRevisions, 20740 isLoadingGlobalStylesRevisions: _isResolving, 20741 revisionsCount: _revisionsCount 20742 }; 20743 }, 20744 [_query] 20745 ); 20746 return (0, import_element41.useMemo)(() => { 20747 if (!authors.length || isLoadingGlobalStylesRevisions) { 20748 return { 20749 revisions: EMPTY_ARRAY3, 20750 hasUnsavedChanges: isDirty, 20751 isLoading: true, 20752 revisionsCount 20753 }; 20754 } 20755 const _modifiedRevisions = revisions.map((revision) => { 20756 return { 20757 ...revision, 20758 author: authors.find( 20759 (author) => author.id === revision.author 20760 ) 20761 }; 20762 }); 20763 const fetchedRevisionsCount = revisions.length; 20764 if (fetchedRevisionsCount) { 20765 if (_modifiedRevisions[0].id !== "unsaved" && _query.page === 1) { 20766 _modifiedRevisions[0].isLatest = true; 20767 } 20768 if (isDirty && userConfig && Object.keys(userConfig).length > 0 && currentUser && _query.page === 1) { 20769 const unsavedRevision = { 20770 id: "unsaved", 20771 styles: userConfig?.styles, 20772 settings: userConfig?.settings, 20773 _links: userConfig?._links, 20774 author: { 20775 name: currentUser?.name || "", 20776 // @ts-expect-error - avatar_urls is not typed in User 20777 avatar_urls: currentUser?.avatar_urls || {} 20778 }, 20779 modified: /* @__PURE__ */ new Date() 20780 }; 20781 _modifiedRevisions.unshift(unsavedRevision); 20782 } 20783 if (_query.per_page && _query.page === Math.ceil(revisionsCount / _query.per_page)) { 20784 _modifiedRevisions.push({ 20785 id: "parent", 20786 styles: {}, 20787 settings: {} 20788 }); 20789 } 20790 } 20791 return { 20792 revisions: _modifiedRevisions, 20793 hasUnsavedChanges: isDirty, 20794 isLoading: false, 20795 revisionsCount 20796 }; 20797 }, [ 20798 isDirty, 20799 revisions, 20800 currentUser, 20801 authors, 20802 userConfig, 20803 isLoadingGlobalStylesRevisions, 20804 revisionsCount, 20805 _query.page, 20806 _query.per_page 20807 ]); 20808 } 20809 20810 // packages/global-styles-ui/build-module/screen-revisions/revisions-buttons.js 20811 var import_i18n48 = __toESM(require_i18n()); 20812 var import_components63 = __toESM(require_components()); 20813 var import_date = __toESM(require_date()); 20814 var import_core_data24 = __toESM(require_core_data()); 20815 var import_data28 = __toESM(require_data()); 20816 var import_keycodes4 = __toESM(require_keycodes()); 20817 var import_jsx_runtime139 = __toESM(require_jsx_runtime()); 20818 var DAY_IN_MILLISECONDS = 60 * 60 * 1e3 * 24; 20819 20820 // packages/global-styles-ui/build-module/pagination/index.js 20821 var import_components64 = __toESM(require_components()); 20822 var import_i18n49 = __toESM(require_i18n()); 20823 var import_jsx_runtime140 = __toESM(require_jsx_runtime()); 20824 20825 // packages/global-styles-ui/build-module/screen-revisions/index.js 20826 var import_jsx_runtime141 = __toESM(require_jsx_runtime()); 20827 20828 // packages/global-styles-ui/build-module/font-sizes/font-sizes.js 20829 var import_i18n52 = __toESM(require_i18n()); 20830 var import_components67 = __toESM(require_components()); 20831 var import_element43 = __toESM(require_element()); 20832 20833 // packages/global-styles-ui/build-module/font-sizes/confirm-reset-font-sizes-dialog.js 20834 var import_components66 = __toESM(require_components()); 20835 var import_i18n51 = __toESM(require_i18n()); 20836 var import_jsx_runtime142 = __toESM(require_jsx_runtime()); 20837 20838 // packages/global-styles-ui/build-module/font-sizes/font-sizes.js 20839 var import_jsx_runtime143 = __toESM(require_jsx_runtime()); 20840 var { Menu: Menu3 } = unlock2(import_components67.privateApis); 20841 20842 // packages/global-styles-ui/build-module/font-sizes/font-size.js 20843 var import_i18n56 = __toESM(require_i18n()); 20844 var import_components71 = __toESM(require_components()); 20845 var import_element45 = __toESM(require_element()); 20846 20847 // packages/global-styles-ui/build-module/font-sizes/font-size-preview.js 20848 var import_block_editor15 = __toESM(require_block_editor()); 20849 var import_i18n53 = __toESM(require_i18n()); 20850 var import_jsx_runtime144 = __toESM(require_jsx_runtime()); 20851 20852 // packages/global-styles-ui/build-module/font-sizes/confirm-delete-font-size-dialog.js 20853 var import_components68 = __toESM(require_components()); 20854 var import_i18n54 = __toESM(require_i18n()); 20855 var import_jsx_runtime145 = __toESM(require_jsx_runtime()); 20856 20857 // packages/global-styles-ui/build-module/font-sizes/rename-font-size-dialog.js 20858 var import_components69 = __toESM(require_components()); 20859 var import_i18n55 = __toESM(require_i18n()); 20860 var import_element44 = __toESM(require_element()); 20861 var import_jsx_runtime146 = __toESM(require_jsx_runtime()); 20862 20863 // packages/global-styles-ui/build-module/size-control/index.js 20864 var import_components70 = __toESM(require_components()); 20865 var import_jsx_runtime147 = __toESM(require_jsx_runtime()); 20866 20867 // packages/global-styles-ui/build-module/font-sizes/font-size.js 20868 var import_jsx_runtime148 = __toESM(require_jsx_runtime()); 20869 var { Menu: Menu4 } = unlock2(import_components71.privateApis); 20870 20871 // packages/global-styles-ui/build-module/global-styles-ui.js 20872 var import_jsx_runtime149 = __toESM(require_jsx_runtime()); 20873 20874 // packages/global-styles-ui/build-module/with-global-styles-provider.js 20875 var import_jsx_runtime150 = __toESM(require_jsx_runtime()); 20876 function withGlobalStylesProvider(Component) { 20877 return function WrappedComponent({ 20878 value, 20879 baseValue, 20880 onChange, 20881 ...props 20882 }) { 20883 return /* @__PURE__ */ (0, import_jsx_runtime150.jsx)( 20884 GlobalStylesProvider, 20885 { 20886 value, 20887 baseValue, 20888 onChange, 20889 children: /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(Component, { ...props }) 20890 } 20891 ); 20892 }; 20893 } 20894 20895 // packages/global-styles-ui/build-module/style-variations.js 20896 var StyleVariations = withGlobalStylesProvider(style_variations_container_default); 20897 20898 // packages/global-styles-ui/build-module/color-variations.js 20899 var ColorVariations2 = withGlobalStylesProvider(ColorVariations); 20900 20901 // packages/global-styles-ui/build-module/typography-variations.js 20902 var TypographyVariations2 = withGlobalStylesProvider(TypographyVariations); 20903 20904 // packages/global-styles-ui/build-module/font-library/font-library.js 20905 var import_jsx_runtime151 = __toESM(require_jsx_runtime()); 20906 20907 // packages/edit-site/build-module/components/sidebar-navigation-screen-details-footer/index.js 20908 var import_i18n57 = __toESM(require_i18n()); 20909 var import_url6 = __toESM(require_url()); 20910 var import_components73 = __toESM(require_components()); 20911 var import_jsx_runtime152 = __toESM(require_jsx_runtime()); 20912 function SidebarNavigationScreenDetailsFooter({ 20913 record, 20914 revisionsCount, 20915 ...otherProps 20916 }) { 20917 const hrefProps = {}; 20918 const lastRevisionId = record?._links?.["predecessor-version"]?.[0]?.id ?? null; 20919 revisionsCount = revisionsCount || record?._links?.["version-history"]?.[0]?.count || 0; 20920 if (lastRevisionId && revisionsCount > 1) { 20921 hrefProps.href = (0, import_url6.addQueryArgs)("revision.php", { 20922 revision: record?._links["predecessor-version"][0].id 20923 }); 20924 hrefProps.as = "a"; 20925 } 20926 return /* @__PURE__ */ (0, import_jsx_runtime152.jsx)( 20927 import_components73.__experimentalItemGroup, 20928 { 20929 size: "large", 20930 className: "edit-site-sidebar-navigation-screen-details-footer", 20931 children: /* @__PURE__ */ (0, import_jsx_runtime152.jsx)( 20932 SidebarNavigationItem, 20933 { 20934 icon: backup_default, 20935 ...hrefProps, 20936 ...otherProps, 20937 children: (0, import_i18n57.sprintf)( 20938 /* translators: %d: Number of Styles revisions. */ 20939 (0, import_i18n57._n)("%d Revision", "%d Revisions", revisionsCount), 20940 revisionsCount 20941 ) 20942 } 20943 ) 20944 } 20945 ); 20946 } 20947 20948 // packages/edit-site/build-module/components/sidebar-navigation-screen-global-styles/index.js 20949 var import_jsx_runtime153 = __toESM(require_jsx_runtime()); 20950 var { useLocation: useLocation10, useHistory: useHistory7 } = unlock(import_router11.privateApis); 20951 function SidebarNavigationItemGlobalStyles(props) { 20952 const { name: name2 } = useLocation10(); 20953 return /* @__PURE__ */ (0, import_jsx_runtime153.jsx)( 20954 SidebarNavigationItem, 20955 { 20956 ...props, 20957 "aria-current": name2 === "styles" 20958 } 20959 ); 20960 } 20961 function SidebarNavigationScreenGlobalStyles() { 20962 const history = useHistory7(); 20963 const { path } = useLocation10(); 20964 const { 20965 revisions, 20966 isLoading: isLoadingRevisions, 20967 revisionsCount 20968 } = useGlobalStylesRevisions(); 20969 const { openGeneralSidebar: openGeneralSidebar2 } = (0, import_data30.useDispatch)(store); 20970 const { setStylesPath } = unlock((0, import_data30.useDispatch)(import_editor8.store)); 20971 const { set: setPreference } = (0, import_data30.useDispatch)(import_preferences5.store); 20972 const openGlobalStyles = (0, import_element47.useCallback)(async () => { 20973 history.navigate((0, import_url7.addQueryArgs)(path, { canvas: "edit" }), { 20974 transition: "canvas-mode-edit-transition" 20975 }); 20976 return Promise.all([ 20977 setPreference("core", "distractionFree", false), 20978 openGeneralSidebar2("edit-site/global-styles") 20979 ]); 20980 }, [path, history, openGeneralSidebar2, setPreference]); 20981 const openRevisions = (0, import_element47.useCallback)(async () => { 20982 await openGlobalStyles(); 20983 setStylesPath("/revisions"); 20984 }, [openGlobalStyles, setStylesPath]); 20985 const shouldShowGlobalStylesFooter = !!revisionsCount && !isLoadingRevisions; 20986 return /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(import_jsx_runtime153.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime153.jsx)( 20987 SidebarNavigationScreen, 20988 { 20989 title: (0, import_i18n58.__)("Design"), 20990 isRoot: true, 20991 description: (0, import_i18n58.__)( 20992 "Customize the appearance of your website using the block editor." 20993 ), 20994 content: /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(MainSidebarNavigationContent, { activeItem: "styles-navigation-item" }), 20995 footer: shouldShowGlobalStylesFooter && /* @__PURE__ */ (0, import_jsx_runtime153.jsx)( 20996 SidebarNavigationScreenDetailsFooter, 20997 { 20998 record: revisions?.[0], 20999 revisionsCount, 21000 onClick: openRevisions 21001 } 21002 ) 21003 } 21004 ) }); 21005 } 21006 21007 // packages/edit-site/build-module/components/sidebar-navigation-screen-main/index.js 21008 var import_jsx_runtime154 = __toESM(require_jsx_runtime()); 21009 function MainSidebarNavigationContent({ isBlockBasedTheme = true }) { 21010 return /* @__PURE__ */ (0, import_jsx_runtime154.jsxs)(import_components74.__experimentalItemGroup, { className: "edit-site-sidebar-navigation-screen-main", children: [ 21011 isBlockBasedTheme && /* @__PURE__ */ (0, import_jsx_runtime154.jsxs)(import_jsx_runtime154.Fragment, { children: [ 21012 /* @__PURE__ */ (0, import_jsx_runtime154.jsx)( 21013 SidebarNavigationItemGlobalStyles, 21014 { 21015 to: "/styles", 21016 uid: "global-styles-navigation-item", 21017 icon: styles_default, 21018 children: (0, import_i18n59.__)("Styles") 21019 } 21020 ), 21021 /* @__PURE__ */ (0, import_jsx_runtime154.jsx)( 21022 SidebarNavigationItem, 21023 { 21024 uid: "navigation-navigation-item", 21025 to: "/navigation", 21026 withChevron: true, 21027 icon: navigation_default, 21028 children: (0, import_i18n59.__)("Navigation") 21029 } 21030 ), 21031 /* @__PURE__ */ (0, import_jsx_runtime154.jsx)( 21032 SidebarNavigationItem, 21033 { 21034 uid: "page-navigation-item", 21035 to: "/page", 21036 withChevron: true, 21037 icon: page_default2, 21038 children: (0, import_i18n59.__)("Pages") 21039 } 21040 ), 21041 /* @__PURE__ */ (0, import_jsx_runtime154.jsx)( 21042 SidebarNavigationItem, 21043 { 21044 uid: "template-navigation-item", 21045 to: "/template", 21046 withChevron: true, 21047 icon: layout_default, 21048 children: (0, import_i18n59.__)("Templates") 21049 } 21050 ) 21051 ] }), 21052 !isBlockBasedTheme && /* @__PURE__ */ (0, import_jsx_runtime154.jsx)( 21053 SidebarNavigationItem, 21054 { 21055 uid: "stylebook-navigation-item", 21056 to: "/stylebook", 21057 withChevron: true, 21058 icon: styles_default, 21059 children: (0, import_i18n59.__)("Styles") 21060 } 21061 ), 21062 /* @__PURE__ */ (0, import_jsx_runtime154.jsx)( 21063 SidebarNavigationItem, 21064 { 21065 uid: "patterns-navigation-item", 21066 to: "/pattern", 21067 withChevron: true, 21068 icon: symbol_default, 21069 children: (0, import_i18n59.__)("Patterns") 21070 } 21071 ) 21072 ] }); 21073 } 21074 function SidebarNavigationScreenMain({ customDescription }) { 21075 const isBlockBasedTheme = (0, import_data31.useSelect)( 21076 (select3) => select3(import_core_data25.store).getCurrentTheme()?.is_block_theme, 21077 [] 21078 ); 21079 let description; 21080 if (customDescription) { 21081 description = customDescription; 21082 } else if (isBlockBasedTheme) { 21083 description = (0, import_i18n59.__)( 21084 "Customize the appearance of your website using the block editor." 21085 ); 21086 } else { 21087 description = (0, import_i18n59.__)( 21088 "Explore block styles and patterns to refine your site." 21089 ); 21090 } 21091 return /* @__PURE__ */ (0, import_jsx_runtime154.jsx)( 21092 SidebarNavigationScreen, 21093 { 21094 isRoot: true, 21095 title: (0, import_i18n59.__)("Design"), 21096 description, 21097 content: /* @__PURE__ */ (0, import_jsx_runtime154.jsx)( 21098 MainSidebarNavigationContent, 21099 { 21100 isBlockBasedTheme 21101 } 21102 ) 21103 } 21104 ); 21105 } 21106 21107 // packages/edit-site/build-module/components/sidebar-navigation-screen-unsupported/index.js 21108 var import_i18n60 = __toESM(require_i18n()); 21109 var import_components75 = __toESM(require_components()); 21110 var import_jsx_runtime155 = __toESM(require_jsx_runtime()); 21111 function SidebarNavigationScreenUnsupported() { 21112 return /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(import_components75.__experimentalSpacer, { padding: 3, children: /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(import_components75.Notice, { status: "warning", isDismissible: false, children: (0, import_i18n60.__)( 21113 "The theme you are currently using does not support this screen." 21114 ) }) }); 21115 } 21116 21117 // packages/edit-site/build-module/components/editor/index.js 21118 var import_data46 = __toESM(require_data()); 21119 var import_components83 = __toESM(require_components()); 21120 var import_compose10 = __toESM(require_compose()); 21121 var import_editor19 = __toESM(require_editor()); 21122 var import_i18n70 = __toESM(require_i18n()); 21123 var import_core_data33 = __toESM(require_core_data()); 21124 var import_block_library = __toESM(require_block_library()); 21125 var import_element55 = __toESM(require_element()); 21126 var import_notices3 = __toESM(require_notices()); 21127 var import_router17 = __toESM(require_router()); 21128 var import_html_entities4 = __toESM(require_html_entities()); 21129 var import_block_editor18 = __toESM(require_block_editor()); 21130 var import_url11 = __toESM(require_url()); 21131 21132 // packages/edit-site/build-module/components/welcome-guide/editor.js 21133 var import_data32 = __toESM(require_data()); 21134 var import_components76 = __toESM(require_components()); 21135 var import_i18n61 = __toESM(require_i18n()); 21136 var import_element48 = __toESM(require_element()); 21137 var import_preferences6 = __toESM(require_preferences()); 21138 var import_core_data26 = __toESM(require_core_data()); 21139 21140 // packages/edit-site/build-module/components/welcome-guide/image.js 21141 var import_jsx_runtime156 = __toESM(require_jsx_runtime()); 21142 function WelcomeGuideImage({ nonAnimatedSrc, animatedSrc }) { 21143 return /* @__PURE__ */ (0, import_jsx_runtime156.jsxs)("picture", { className: "edit-site-welcome-guide__image", children: [ 21144 /* @__PURE__ */ (0, import_jsx_runtime156.jsx)( 21145 "source", 21146 { 21147 srcSet: nonAnimatedSrc, 21148 media: "(prefers-reduced-motion: reduce)" 21149 } 21150 ), 21151 /* @__PURE__ */ (0, import_jsx_runtime156.jsx)("img", { src: animatedSrc, width: "312", height: "240", alt: "" }) 21152 ] }); 21153 } 21154 21155 // packages/edit-site/build-module/components/welcome-guide/editor.js 21156 var import_jsx_runtime157 = __toESM(require_jsx_runtime()); 21157 function WelcomeGuideEditor() { 21158 const { toggle } = (0, import_data32.useDispatch)(import_preferences6.store); 21159 const { isActive, isBlockBasedTheme } = (0, import_data32.useSelect)((select3) => { 21160 return { 21161 isActive: !!select3(import_preferences6.store).get( 21162 "core/edit-site", 21163 "welcomeGuide" 21164 ), 21165 isBlockBasedTheme: select3(import_core_data26.store).getCurrentTheme()?.is_block_theme 21166 }; 21167 }, []); 21168 if (!isActive || !isBlockBasedTheme) { 21169 return null; 21170 } 21171 return /* @__PURE__ */ (0, import_jsx_runtime157.jsx)( 21172 import_components76.Guide, 21173 { 21174 className: "edit-site-welcome-guide guide-editor", 21175 contentLabel: (0, import_i18n61.__)("Welcome to the site editor"), 21176 finishButtonText: (0, import_i18n61.__)("Get started"), 21177 onFinish: () => toggle("core/edit-site", "welcomeGuide"), 21178 pages: [ 21179 { 21180 image: /* @__PURE__ */ (0, import_jsx_runtime157.jsx)( 21181 WelcomeGuideImage, 21182 { 21183 nonAnimatedSrc: "https://s.w.org/images/block-editor/edit-your-site.svg?1", 21184 animatedSrc: "https://s.w.org/images/block-editor/edit-your-site.gif?1" 21185 } 21186 ), 21187 content: /* @__PURE__ */ (0, import_jsx_runtime157.jsxs)(import_jsx_runtime157.Fragment, { children: [ 21188 /* @__PURE__ */ (0, import_jsx_runtime157.jsx)("h1", { className: "edit-site-welcome-guide__heading", children: (0, import_i18n61.__)("Edit your site") }), 21189 /* @__PURE__ */ (0, import_jsx_runtime157.jsx)("p", { className: "edit-site-welcome-guide__text", children: (0, import_i18n61.__)( 21190 "Design everything on your site \u2014 from the header right down to the footer \u2014 using blocks." 21191 ) }), 21192 /* @__PURE__ */ (0, import_jsx_runtime157.jsx)("p", { className: "edit-site-welcome-guide__text", children: (0, import_element48.createInterpolateElement)( 21193 (0, import_i18n61.__)( 21194 "Click <StylesIconImage /> to start designing your blocks, and choose your typography, layout, and colors." 21195 ), 21196 { 21197 StylesIconImage: /* @__PURE__ */ (0, import_jsx_runtime157.jsx)( 21198 "img", 21199 { 21200 alt: (0, import_i18n61.__)("styles"), 21201 src: "data:image/svg+xml,%3Csvg width='18' height='18' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12 4c-4.4 0-8 3.6-8 8v.1c0 4.1 3.2 7.5 7.2 7.9h.8c4.4 0 8-3.6 8-8s-3.6-8-8-8zm0 15V5c3.9 0 7 3.1 7 7s-3.1 7-7 7z' fill='%231E1E1E'/%3E%3C/svg%3E%0A" 21202 } 21203 ) 21204 } 21205 ) }) 21206 ] }) 21207 } 21208 ] 21209 } 21210 ); 21211 } 21212 21213 // packages/edit-site/build-module/components/welcome-guide/page.js 21214 var import_data33 = __toESM(require_data()); 21215 var import_components77 = __toESM(require_components()); 21216 var import_i18n62 = __toESM(require_i18n()); 21217 var import_preferences7 = __toESM(require_preferences()); 21218 var import_jsx_runtime158 = __toESM(require_jsx_runtime()); 21219 function WelcomeGuidePage() { 21220 const { toggle } = (0, import_data33.useDispatch)(import_preferences7.store); 21221 const isVisible2 = (0, import_data33.useSelect)((select3) => { 21222 const isPageActive = !!select3(import_preferences7.store).get( 21223 "core/edit-site", 21224 "welcomeGuidePage" 21225 ); 21226 const isEditorActive = !!select3(import_preferences7.store).get( 21227 "core/edit-site", 21228 "welcomeGuide" 21229 ); 21230 return isPageActive && !isEditorActive; 21231 }, []); 21232 if (!isVisible2) { 21233 return null; 21234 } 21235 const heading = (0, import_i18n62.__)("Editing a page"); 21236 return /* @__PURE__ */ (0, import_jsx_runtime158.jsx)( 21237 import_components77.Guide, 21238 { 21239 className: "edit-site-welcome-guide guide-page", 21240 contentLabel: heading, 21241 finishButtonText: (0, import_i18n62.__)("Continue"), 21242 onFinish: () => toggle("core/edit-site", "welcomeGuidePage"), 21243 pages: [ 21244 { 21245 image: /* @__PURE__ */ (0, import_jsx_runtime158.jsx)( 21246 "video", 21247 { 21248 className: "edit-site-welcome-guide__video", 21249 autoPlay: true, 21250 loop: true, 21251 muted: true, 21252 width: "312", 21253 height: "240", 21254 children: /* @__PURE__ */ (0, import_jsx_runtime158.jsx)( 21255 "source", 21256 { 21257 src: "https://s.w.org/images/block-editor/editing-your-page.mp4", 21258 type: "video/mp4" 21259 } 21260 ) 21261 } 21262 ), 21263 content: /* @__PURE__ */ (0, import_jsx_runtime158.jsxs)(import_jsx_runtime158.Fragment, { children: [ 21264 /* @__PURE__ */ (0, import_jsx_runtime158.jsx)("h1", { className: "edit-site-welcome-guide__heading", children: heading }), 21265 /* @__PURE__ */ (0, import_jsx_runtime158.jsx)("p", { className: "edit-site-welcome-guide__text", children: (0, import_i18n62.__)( 21266 // eslint-disable-next-line no-restricted-syntax -- 'sidebar' is a common web design term for layouts 21267 "It\u2019s now possible to edit page content in the site editor. To customise other parts of the page like the header and footer switch to editing the template using the settings sidebar." 21268 ) }) 21269 ] }) 21270 } 21271 ] 21272 } 21273 ); 21274 } 21275 21276 // packages/edit-site/build-module/components/welcome-guide/template.js 21277 var import_data34 = __toESM(require_data()); 21278 var import_components78 = __toESM(require_components()); 21279 var import_i18n63 = __toESM(require_i18n()); 21280 var import_preferences8 = __toESM(require_preferences()); 21281 var import_editor9 = __toESM(require_editor()); 21282 var import_jsx_runtime159 = __toESM(require_jsx_runtime()); 21283 function WelcomeGuideTemplate() { 21284 const { toggle } = (0, import_data34.useDispatch)(import_preferences8.store); 21285 const { isActive, hasPreviousEntity } = (0, import_data34.useSelect)((select3) => { 21286 const { getEditorSettings } = select3(import_editor9.store); 21287 const { get } = select3(import_preferences8.store); 21288 return { 21289 isActive: get("core/edit-site", "welcomeGuideTemplate"), 21290 hasPreviousEntity: !!getEditorSettings().onNavigateToPreviousEntityRecord 21291 }; 21292 }, []); 21293 const isVisible2 = isActive && hasPreviousEntity; 21294 if (!isVisible2) { 21295 return null; 21296 } 21297 const heading = (0, import_i18n63.__)("Editing a template"); 21298 return /* @__PURE__ */ (0, import_jsx_runtime159.jsx)( 21299 import_components78.Guide, 21300 { 21301 className: "edit-site-welcome-guide guide-template", 21302 contentLabel: heading, 21303 finishButtonText: (0, import_i18n63.__)("Continue"), 21304 onFinish: () => toggle("core/edit-site", "welcomeGuideTemplate"), 21305 pages: [ 21306 { 21307 image: /* @__PURE__ */ (0, import_jsx_runtime159.jsx)( 21308 "video", 21309 { 21310 className: "edit-site-welcome-guide__video", 21311 autoPlay: true, 21312 loop: true, 21313 muted: true, 21314 width: "312", 21315 height: "240", 21316 children: /* @__PURE__ */ (0, import_jsx_runtime159.jsx)( 21317 "source", 21318 { 21319 src: "https://s.w.org/images/block-editor/editing-your-template.mp4", 21320 type: "video/mp4" 21321 } 21322 ) 21323 } 21324 ), 21325 content: /* @__PURE__ */ (0, import_jsx_runtime159.jsxs)(import_jsx_runtime159.Fragment, { children: [ 21326 /* @__PURE__ */ (0, import_jsx_runtime159.jsx)("h1", { className: "edit-site-welcome-guide__heading", children: heading }), 21327 /* @__PURE__ */ (0, import_jsx_runtime159.jsx)("p", { className: "edit-site-welcome-guide__text", children: (0, import_i18n63.__)( 21328 "Note that the same template can be used by multiple pages, so any changes made here may affect other pages on the site. To switch back to editing the page content click the \u2018Back\u2019 button in the toolbar." 21329 ) }) 21330 ] }) 21331 } 21332 ] 21333 } 21334 ); 21335 } 21336 21337 // packages/edit-site/build-module/components/welcome-guide/index.js 21338 var import_jsx_runtime160 = __toESM(require_jsx_runtime()); 21339 function WelcomeGuide({ postType: postType2 }) { 21340 return /* @__PURE__ */ (0, import_jsx_runtime160.jsxs)(import_jsx_runtime160.Fragment, { children: [ 21341 /* @__PURE__ */ (0, import_jsx_runtime160.jsx)(WelcomeGuideEditor, {}), 21342 postType2 === "page" && /* @__PURE__ */ (0, import_jsx_runtime160.jsx)(WelcomeGuidePage, {}), 21343 postType2 === "wp_template" && /* @__PURE__ */ (0, import_jsx_runtime160.jsx)(WelcomeGuideTemplate, {}) 21344 ] }); 21345 } 21346 21347 // packages/edit-site/build-module/components/canvas-loader/index.js 21348 var import_components79 = __toESM(require_components()); 21349 var import_core_data27 = __toESM(require_core_data()); 21350 var import_data35 = __toESM(require_data()); 21351 var import_editor11 = __toESM(require_editor()); 21352 var import_jsx_runtime161 = __toESM(require_jsx_runtime()); 21353 var { Theme } = unlock(import_components79.privateApis); 21354 var { useStyle: useStyle3 } = unlock(import_editor11.privateApis); 21355 function CanvasLoader({ id }) { 21356 const textColor = useStyle3("color.text"); 21357 const backgroundColor = useStyle3("color.background"); 21358 const { elapsed, total } = (0, import_data35.useSelect)((select3) => { 21359 const selectorsByStatus = select3(import_core_data27.store).countSelectorsByStatus(); 21360 const resolving = selectorsByStatus.resolving ?? 0; 21361 const finished = selectorsByStatus.finished ?? 0; 21362 return { 21363 elapsed: finished, 21364 total: finished + resolving 21365 }; 21366 }, []); 21367 return /* @__PURE__ */ (0, import_jsx_runtime161.jsx)("div", { className: "edit-site-canvas-loader", children: /* @__PURE__ */ (0, import_jsx_runtime161.jsx)(Theme, { accent: textColor, background: backgroundColor, children: /* @__PURE__ */ (0, import_jsx_runtime161.jsx)(import_components79.ProgressBar, { id, max: total, value: elapsed }) }) }); 21368 } 21369 21370 // packages/edit-site/build-module/components/block-editor/use-site-editor-settings.js 21371 var import_data36 = __toESM(require_data()); 21372 var import_element50 = __toESM(require_element()); 21373 var import_router13 = __toESM(require_router()); 21374 var import_compose9 = __toESM(require_compose()); 21375 var import_editor13 = __toESM(require_editor()); 21376 21377 // packages/edit-site/build-module/components/block-editor/use-navigate-to-entity-record.js 21378 var import_router12 = __toESM(require_router()); 21379 var import_element49 = __toESM(require_element()); 21380 var import_url8 = __toESM(require_url()); 21381 var import_editor12 = __toESM(require_editor()); 21382 var { useHistory: useHistory8, useLocation: useLocation11 } = unlock(import_router12.privateApis); 21383 var { useGenerateBlockPath } = unlock(import_editor12.privateApis); 21384 function useNavigateToEntityRecord() { 21385 const history = useHistory8(); 21386 const { query, path } = useLocation11(); 21387 const generateBlockPath = useGenerateBlockPath(); 21388 let initialBlockSelection = null; 21389 if (query.selectedBlock) { 21390 try { 21391 initialBlockSelection = JSON.parse( 21392 decodeURIComponent(query.selectedBlock) 21393 ); 21394 } catch (e2) { 21395 initialBlockSelection = null; 21396 } 21397 } 21398 const onNavigateToEntityRecord = (0, import_element49.useCallback)( 21399 (params) => { 21400 if (params.selectedBlockClientId) { 21401 const blockPath = generateBlockPath( 21402 params.selectedBlockClientId 21403 ); 21404 if (blockPath) { 21405 const currentUrl = (0, import_url8.addQueryArgs)(path, { 21406 ...query, 21407 selectedBlock: encodeURIComponent( 21408 JSON.stringify(blockPath) 21409 ) 21410 }); 21411 history.navigate(currentUrl, { replace: true }); 21412 } 21413 } 21414 const url = (0, import_url8.addQueryArgs)( 21415 `/$params.postType}/$params.postId}`, 21416 { 21417 canvas: "edit", 21418 focusMode: true 21419 } 21420 ); 21421 history.navigate(url); 21422 }, 21423 [history, path, query, generateBlockPath] 21424 ); 21425 return [onNavigateToEntityRecord, initialBlockSelection]; 21426 } 21427 21428 // packages/edit-site/build-module/components/block-editor/use-site-editor-settings.js 21429 var { useLocation: useLocation12, useHistory: useHistory9 } = unlock(import_router13.privateApis); 21430 var { useGlobalStyles: useGlobalStyles2 } = unlock(import_editor13.privateApis); 21431 function useNavigateToPreviousEntityRecord() { 21432 const location = useLocation12(); 21433 const previousCanvas = (0, import_compose9.usePrevious)(location.query.canvas); 21434 const history = useHistory9(); 21435 const goBack = (0, import_element50.useMemo)(() => { 21436 const isFocusMode = location.query.focusMode || location?.params?.postId && FOCUSABLE_ENTITIES.includes(location?.params?.postType); 21437 const didComeFromEditorCanvas = previousCanvas === "edit"; 21438 const showBackButton = isFocusMode && didComeFromEditorCanvas; 21439 return showBackButton ? () => history.back() : void 0; 21440 }, [location, history, previousCanvas]); 21441 return goBack; 21442 } 21443 function useSpecificEditorSettings() { 21444 const { query } = useLocation12(); 21445 const { canvas = "view" } = query; 21446 const [onNavigateToEntityRecord, initialBlockSelection] = useNavigateToEntityRecord(); 21447 const { merged: mergedConfig } = useGlobalStyles2(); 21448 const { settings: settings2, currentPostIsTrashed } = (0, import_data36.useSelect)((select3) => { 21449 const { getSettings: getSettings7 } = select3(store); 21450 const { getCurrentPostAttribute } = select3(import_editor13.store); 21451 return { 21452 settings: getSettings7(), 21453 currentPostIsTrashed: getCurrentPostAttribute("status") === "trash" 21454 }; 21455 }, []); 21456 const onNavigateToPreviousEntityRecord = useNavigateToPreviousEntityRecord(); 21457 const [globalStyles, globalSettings] = (0, import_element50.useMemo)(() => { 21458 return generateGlobalStyles(mergedConfig, [], { 21459 disableRootPadding: false 21460 }); 21461 }, [mergedConfig]); 21462 const defaultEditorSettings = (0, import_element50.useMemo)(() => { 21463 const nonGlobalStyles = (settings2?.styles ?? []).filter( 21464 (style) => !style.isGlobalStyles 21465 ); 21466 return { 21467 ...settings2, 21468 styles: [ 21469 ...nonGlobalStyles, 21470 ...globalStyles, 21471 { 21472 // Forming a "block formatting context" to prevent margin collapsing. 21473 // @see https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Block_formatting_context 21474 css: canvas === "view" ? `body{min-height: 100vh; $currentPostIsTrashed ? "" : "cursor: pointer;"}}` : void 0 21475 } 21476 ], 21477 __experimentalFeatures: globalSettings, 21478 richEditingEnabled: true, 21479 supportsTemplateMode: true, 21480 focusMode: canvas !== "view", 21481 onNavigateToEntityRecord, 21482 onNavigateToPreviousEntityRecord, 21483 isPreviewMode: canvas === "view", 21484 initialBlockSelection 21485 }; 21486 }, [ 21487 settings2, 21488 globalStyles, 21489 globalSettings, 21490 canvas, 21491 currentPostIsTrashed, 21492 onNavigateToEntityRecord, 21493 onNavigateToPreviousEntityRecord, 21494 initialBlockSelection 21495 ]); 21496 return defaultEditorSettings; 21497 } 21498 21499 // packages/edit-site/build-module/components/plugin-template-setting-panel/index.js 21500 var import_editor14 = __toESM(require_editor()); 21501 var import_data37 = __toESM(require_data()); 21502 var import_components80 = __toESM(require_components()); 21503 var import_deprecated3 = __toESM(require_deprecated()); 21504 var import_jsx_runtime162 = __toESM(require_jsx_runtime()); 21505 var { Fill, Slot } = (0, import_components80.createSlotFill)("PluginTemplateSettingPanel"); 21506 var PluginTemplateSettingPanel = ({ children }) => { 21507 (0, import_deprecated3.default)("wp.editSite.PluginTemplateSettingPanel", { 21508 since: "6.6", 21509 version: "6.8", 21510 alternative: "wp.editor.PluginDocumentSettingPanel" 21511 }); 21512 const isCurrentEntityTemplate = (0, import_data37.useSelect)( 21513 (select3) => select3(import_editor14.store).getCurrentPostType() === "wp_template", 21514 [] 21515 ); 21516 if (!isCurrentEntityTemplate) { 21517 return null; 21518 } 21519 return /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(Fill, { children }); 21520 }; 21521 PluginTemplateSettingPanel.Slot = Slot; 21522 var plugin_template_setting_panel_default = PluginTemplateSettingPanel; 21523 21524 // packages/edit-site/build-module/components/more-menu/index.js 21525 var import_editor15 = __toESM(require_editor()); 21526 21527 // packages/edit-site/build-module/components/more-menu/site-export.js 21528 var import_i18n64 = __toESM(require_i18n()); 21529 var import_components81 = __toESM(require_components()); 21530 var import_api_fetch3 = __toESM(require_api_fetch()); 21531 var import_data38 = __toESM(require_data()); 21532 var import_blob = __toESM(require_blob()); 21533 var import_core_data28 = __toESM(require_core_data()); 21534 var import_notices2 = __toESM(require_notices()); 21535 var import_jsx_runtime163 = __toESM(require_jsx_runtime()); 21536 function SiteExport() { 21537 const canExport = (0, import_data38.useSelect)((select3) => { 21538 const targetHints = select3(import_core_data28.store).getCurrentTheme()?._links?.["wp:export-theme"]?.[0]?.targetHints ?? {}; 21539 return !!targetHints.allow?.includes("GET"); 21540 }, []); 21541 const { createErrorNotice } = (0, import_data38.useDispatch)(import_notices2.store); 21542 if (!canExport) { 21543 return null; 21544 } 21545 async function handleExport() { 21546 try { 21547 const response = await (0, import_api_fetch3.default)({ 21548 path: "/wp-block-editor/v1/export", 21549 parse: false, 21550 headers: { 21551 Accept: "application/zip" 21552 } 21553 }); 21554 const blob = await response.blob(); 21555 const contentDisposition = response.headers.get( 21556 "content-disposition" 21557 ); 21558 const contentDispositionMatches = contentDisposition.match(/=(.+)\.zip/); 21559 const fileName = contentDispositionMatches[1] ? contentDispositionMatches[1] : "edit-site-export"; 21560 (0, import_blob.downloadBlob)(fileName + ".zip", blob, "application/zip"); 21561 } catch (errorResponse) { 21562 let error = {}; 21563 try { 21564 error = await errorResponse.json(); 21565 } catch (e2) { 21566 } 21567 const errorMessage = error.message && error.code !== "unknown_error" ? error.message : (0, import_i18n64.__)("An error occurred while creating the site export."); 21568 createErrorNotice(errorMessage, { type: "snackbar" }); 21569 } 21570 } 21571 return /* @__PURE__ */ (0, import_jsx_runtime163.jsx)( 21572 import_components81.MenuItem, 21573 { 21574 role: "menuitem", 21575 icon: download_default, 21576 onClick: handleExport, 21577 info: (0, import_i18n64.__)( 21578 "Download your theme with updated templates and styles." 21579 ), 21580 children: (0, import_i18n64._x)("Export", "site exporter menu item") 21581 } 21582 ); 21583 } 21584 21585 // packages/edit-site/build-module/components/more-menu/welcome-guide-menu-item.js 21586 var import_i18n65 = __toESM(require_i18n()); 21587 var import_data39 = __toESM(require_data()); 21588 var import_components82 = __toESM(require_components()); 21589 var import_preferences9 = __toESM(require_preferences()); 21590 var import_jsx_runtime164 = __toESM(require_jsx_runtime()); 21591 function WelcomeGuideMenuItem() { 21592 const { toggle } = (0, import_data39.useDispatch)(import_preferences9.store); 21593 return /* @__PURE__ */ (0, import_jsx_runtime164.jsx)(import_components82.MenuItem, { onClick: () => toggle("core/edit-site", "welcomeGuide"), children: (0, import_i18n65.__)("Welcome Guide") }); 21594 } 21595 21596 // packages/edit-site/build-module/components/more-menu/index.js 21597 var import_jsx_runtime165 = __toESM(require_jsx_runtime()); 21598 var { ToolsMoreMenuGroup, PreferencesModal } = unlock(import_editor15.privateApis); 21599 function MoreMenu() { 21600 return /* @__PURE__ */ (0, import_jsx_runtime165.jsxs)(import_jsx_runtime165.Fragment, { children: [ 21601 /* @__PURE__ */ (0, import_jsx_runtime165.jsxs)(ToolsMoreMenuGroup, { children: [ 21602 /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(SiteExport, {}), 21603 /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(WelcomeGuideMenuItem, {}) 21604 ] }), 21605 /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(PreferencesModal, {}) 21606 ] }); 21607 } 21608 21609 // packages/edit-site/build-module/components/block-editor/use-editor-iframe-props.js 21610 var import_data40 = __toESM(require_data()); 21611 var import_keycodes5 = __toESM(require_keycodes()); 21612 var import_element51 = __toESM(require_element()); 21613 var import_i18n66 = __toESM(require_i18n()); 21614 var import_editor16 = __toESM(require_editor()); 21615 var import_router14 = __toESM(require_router()); 21616 var import_url9 = __toESM(require_url()); 21617 var { useLocation: useLocation13, useHistory: useHistory10 } = unlock(import_router14.privateApis); 21618 function useEditorIframeProps() { 21619 const { query, path } = useLocation13(); 21620 const history = useHistory10(); 21621 const { canvas = "view" } = query; 21622 const currentPostIsTrashed = (0, import_data40.useSelect)((select3) => { 21623 return select3(import_editor16.store).getCurrentPostAttribute("status") === "trash"; 21624 }, []); 21625 const [isFocused, setIsFocused] = (0, import_element51.useState)(false); 21626 (0, import_element51.useEffect)(() => { 21627 if (canvas === "edit") { 21628 setIsFocused(false); 21629 } 21630 }, [canvas]); 21631 const viewModeIframeProps = { 21632 "aria-label": (0, import_i18n66.__)("Edit"), 21633 "aria-disabled": currentPostIsTrashed, 21634 title: null, 21635 role: "button", 21636 tabIndex: 0, 21637 onFocus: () => setIsFocused(true), 21638 onBlur: () => setIsFocused(false), 21639 onKeyDown: (event) => { 21640 const { keyCode } = event; 21641 if ((keyCode === import_keycodes5.ENTER || keyCode === import_keycodes5.SPACE) && !currentPostIsTrashed) { 21642 event.preventDefault(); 21643 history.navigate((0, import_url9.addQueryArgs)(path, { canvas: "edit" }), { 21644 transition: "canvas-mode-edit-transition" 21645 }); 21646 } 21647 }, 21648 onClick: () => history.navigate((0, import_url9.addQueryArgs)(path, { canvas: "edit" }), { 21649 transition: "canvas-mode-edit-transition" 21650 }), 21651 onClickCapture: (event) => { 21652 if (currentPostIsTrashed) { 21653 event.preventDefault(); 21654 event.stopPropagation(); 21655 } 21656 }, 21657 readonly: true 21658 }; 21659 return { 21660 className: clsx_default("edit-site-visual-editor__editor-canvas", { 21661 "is-focused": isFocused && canvas === "view" 21662 }), 21663 ...canvas === "view" ? viewModeIframeProps : {} 21664 }; 21665 } 21666 21667 // packages/edit-site/build-module/components/editor/use-editor-title.js 21668 var import_i18n68 = __toESM(require_i18n()); 21669 var import_data42 = __toESM(require_data()); 21670 var import_core_data30 = __toESM(require_core_data()); 21671 var import_html_entities3 = __toESM(require_html_entities()); 21672 var import_editor17 = __toESM(require_editor()); 21673 21674 // packages/edit-site/build-module/components/routes/use-title.js 21675 var import_element52 = __toESM(require_element()); 21676 var import_data41 = __toESM(require_data()); 21677 var import_core_data29 = __toESM(require_core_data()); 21678 var import_i18n67 = __toESM(require_i18n()); 21679 var import_a11y3 = __toESM(require_a11y()); 21680 var import_html_entities2 = __toESM(require_html_entities()); 21681 var import_router15 = __toESM(require_router()); 21682 var { useLocation: useLocation14 } = unlock(import_router15.privateApis); 21683 function useTitle(title) { 21684 const location = useLocation14(); 21685 const siteTitle = (0, import_data41.useSelect)( 21686 (select3) => select3(import_core_data29.store).getEntityRecord("root", "site")?.title, 21687 [] 21688 ); 21689 const isInitialLocationRef = (0, import_element52.useRef)(true); 21690 (0, import_element52.useEffect)(() => { 21691 isInitialLocationRef.current = false; 21692 }, [location]); 21693 (0, import_element52.useEffect)(() => { 21694 if (isInitialLocationRef.current) { 21695 return; 21696 } 21697 if (title && siteTitle) { 21698 const formattedTitle = (0, import_i18n67.sprintf)( 21699 /* translators: Admin document title. 1: Admin screen name, 2: Network or site name. */ 21700 (0, import_i18n67.__)("%1$s \u2039 %2$s \u2039 Editor \u2014 WordPress"), 21701 (0, import_html_entities2.decodeEntities)(title), 21702 (0, import_html_entities2.decodeEntities)(siteTitle) 21703 ); 21704 document.title = formattedTitle; 21705 (0, import_a11y3.speak)(title, "assertive"); 21706 } 21707 }, [title, siteTitle, location]); 21708 } 21709 21710 // packages/edit-site/build-module/components/editor/use-editor-title.js 21711 var { getTemplateInfo } = unlock(import_editor17.privateApis); 21712 function useEditorTitle(postType2, postId) { 21713 const { title, isLoaded } = (0, import_data42.useSelect)( 21714 (select3) => { 21715 const { 21716 getEditedEntityRecord, 21717 getCurrentTheme, 21718 hasFinishedResolution 21719 } = select3(import_core_data30.store); 21720 if (!postId) { 21721 return { isLoaded: false }; 21722 } 21723 const _record = getEditedEntityRecord( 21724 "postType", 21725 postType2, 21726 postId 21727 ); 21728 const { default_template_types: templateTypes = [] } = getCurrentTheme() ?? {}; 21729 const templateInfo = getTemplateInfo({ 21730 template: _record, 21731 templateTypes 21732 }); 21733 const _isLoaded = hasFinishedResolution("getEditedEntityRecord", [ 21734 "postType", 21735 postType2, 21736 postId 21737 ]); 21738 return { 21739 title: templateInfo.title, 21740 isLoaded: _isLoaded 21741 }; 21742 }, 21743 [postType2, postId] 21744 ); 21745 let editorTitle; 21746 if (isLoaded) { 21747 editorTitle = (0, import_i18n68.sprintf)( 21748 // translators: A breadcrumb trail for the Admin document title. 1: title of template being edited, 2: type of template (Template or Template Part). 21749 (0, import_i18n68._x)("%1$s \u2039 %2$s", "breadcrumb trail"), 21750 (0, import_html_entities3.decodeEntities)(title), 21751 POST_TYPE_LABELS[postType2] ?? POST_TYPE_LABELS[TEMPLATE_POST_TYPE] 21752 ); 21753 } 21754 useTitle(isLoaded && editorTitle); 21755 } 21756 var use_editor_title_default = useEditorTitle; 21757 21758 // packages/edit-site/build-module/components/editor/use-adapt-editor-to-canvas.js 21759 var import_data43 = __toESM(require_data()); 21760 var import_block_editor17 = __toESM(require_block_editor()); 21761 var import_editor18 = __toESM(require_editor()); 21762 var import_element53 = __toESM(require_element()); 21763 var import_preferences10 = __toESM(require_preferences()); 21764 function useAdaptEditorToCanvas(canvas) { 21765 const { clearSelectedBlock } = (0, import_data43.useDispatch)(import_block_editor17.store); 21766 const { 21767 setDeviceType, 21768 closePublishSidebar, 21769 setIsListViewOpened: setIsListViewOpened2, 21770 setIsInserterOpened: setIsInserterOpened2 21771 } = (0, import_data43.useDispatch)(import_editor18.store); 21772 const { get: getPreference } = (0, import_data43.useSelect)(import_preferences10.store); 21773 const registry = (0, import_data43.useRegistry)(); 21774 (0, import_element53.useLayoutEffect)(() => { 21775 const isMediumOrBigger = window.matchMedia("(min-width: 782px)").matches; 21776 registry.batch(() => { 21777 clearSelectedBlock(); 21778 setDeviceType("Desktop"); 21779 closePublishSidebar(); 21780 setIsInserterOpened2(false); 21781 if (isMediumOrBigger && canvas === "edit" && getPreference("core", "showListViewByDefault") && !getPreference("core", "distractionFree")) { 21782 setIsListViewOpened2(true); 21783 } else { 21784 setIsListViewOpened2(false); 21785 } 21786 }); 21787 }, [ 21788 canvas, 21789 registry, 21790 clearSelectedBlock, 21791 setDeviceType, 21792 closePublishSidebar, 21793 setIsInserterOpened2, 21794 setIsListViewOpened2, 21795 getPreference 21796 ]); 21797 } 21798 21799 // packages/edit-site/build-module/components/editor/use-resolve-edited-entity.js 21800 var import_element54 = __toESM(require_element()); 21801 var import_data44 = __toESM(require_data()); 21802 var import_core_data31 = __toESM(require_core_data()); 21803 var import_router16 = __toESM(require_router()); 21804 var { useLocation: useLocation15 } = unlock(import_router16.privateApis); 21805 var postTypesWithoutParentTemplate = [ 21806 TEMPLATE_POST_TYPE, 21807 TEMPLATE_PART_POST_TYPE, 21808 NAVIGATION_POST_TYPE, 21809 PATTERN_TYPES.user 21810 ]; 21811 var authorizedPostTypes = ["page", "post"]; 21812 function getPostType(name2) { 21813 let postType2; 21814 if (name2 === "navigation-item") { 21815 postType2 = NAVIGATION_POST_TYPE; 21816 } else if (name2 === "pattern-item") { 21817 postType2 = PATTERN_TYPES.user; 21818 } else if (name2 === "template-part-item") { 21819 postType2 = TEMPLATE_PART_POST_TYPE; 21820 } else if (name2 === "templates") { 21821 postType2 = TEMPLATE_POST_TYPE; 21822 } else if (name2 === "template-item") { 21823 postType2 = TEMPLATE_POST_TYPE; 21824 } else if (name2 === "page-item" || name2 === "pages") { 21825 postType2 = "page"; 21826 } else if (name2 === "post-item" || name2 === "posts") { 21827 postType2 = "post"; 21828 } 21829 return postType2; 21830 } 21831 function useResolveEditedEntity() { 21832 const { name: name2, params = {}, query } = useLocation15(); 21833 const { postId = query?.postId } = params; 21834 const postType2 = getPostType(name2, postId) ?? query?.postType; 21835 const homePage = (0, import_data44.useSelect)((select3) => { 21836 const { getHomePage } = unlock(select3(import_core_data31.store)); 21837 return getHomePage(); 21838 }, []); 21839 const resolvedTemplateId = (0, import_data44.useSelect)( 21840 (select3) => { 21841 if (postTypesWithoutParentTemplate.includes(postType2) && postId) { 21842 return; 21843 } 21844 if (postId && postId.includes(",")) { 21845 return; 21846 } 21847 const { getTemplateId } = unlock(select3(import_core_data31.store)); 21848 if (postType2 && postId && authorizedPostTypes.includes(postType2)) { 21849 return getTemplateId(postType2, postId); 21850 } 21851 if (homePage?.postType === "page") { 21852 return getTemplateId("page", homePage?.postId); 21853 } 21854 if (homePage?.postType === "wp_template") { 21855 return homePage?.postId; 21856 } 21857 }, 21858 [homePage, postId, postType2] 21859 ); 21860 const context = (0, import_element54.useMemo)(() => { 21861 if (postTypesWithoutParentTemplate.includes(postType2) && postId) { 21862 return {}; 21863 } 21864 if (postType2 && postId && authorizedPostTypes.includes(postType2)) { 21865 return { postType: postType2, postId }; 21866 } 21867 if (homePage?.postType === "page") { 21868 return { postType: "page", postId: homePage?.postId }; 21869 } 21870 return {}; 21871 }, [homePage, postType2, postId]); 21872 if (postTypesWithoutParentTemplate.includes(postType2) && postId) { 21873 return { isReady: true, postType: postType2, postId, context }; 21874 } 21875 if (!!homePage) { 21876 return { 21877 isReady: resolvedTemplateId !== void 0, 21878 postType: TEMPLATE_POST_TYPE, 21879 postId: resolvedTemplateId, 21880 context 21881 }; 21882 } 21883 return { isReady: false }; 21884 } 21885 function useSyncDeprecatedEntityIntoState({ 21886 postType: postType2, 21887 postId, 21888 context, 21889 isReady 21890 }) { 21891 const { setEditedEntity: setEditedEntity2 } = (0, import_data44.useDispatch)(store); 21892 (0, import_element54.useEffect)(() => { 21893 if (isReady) { 21894 setEditedEntity2(postType2, String(postId), context); 21895 } 21896 }, [isReady, postType2, postId, context, setEditedEntity2]); 21897 } 21898 21899 // packages/edit-site/build-module/components/editor/site-preview.js 21900 var import_i18n69 = __toESM(require_i18n()); 21901 var import_data45 = __toESM(require_data()); 21902 var import_core_data32 = __toESM(require_core_data()); 21903 var import_dom2 = __toESM(require_dom()); 21904 var import_url10 = __toESM(require_url()); 21905 var import_jsx_runtime166 = __toESM(require_jsx_runtime()); 21906 function SitePreview() { 21907 const siteUrl = (0, import_data45.useSelect)((select3) => { 21908 const { getEntityRecord } = select3(import_core_data32.store); 21909 const siteData = getEntityRecord("root", "__unstableBase"); 21910 return siteData?.home; 21911 }, []); 21912 return /* @__PURE__ */ (0, import_jsx_runtime166.jsx)( 21913 "iframe", 21914 { 21915 src: (0, import_url10.addQueryArgs)(siteUrl, { 21916 // Parameter for hiding the admin bar. 21917 wp_site_preview: 1 21918 }), 21919 title: (0, import_i18n69.__)("Site Preview"), 21920 style: { 21921 display: "block", 21922 width: "100%", 21923 height: "100%", 21924 backgroundColor: "#fff" 21925 }, 21926 onLoad: (event) => { 21927 const document2 = event.target.contentDocument; 21928 const focusableElements = import_dom2.focus.focusable.find(document2); 21929 focusableElements.forEach((element) => { 21930 element.style.pointerEvents = "none"; 21931 element.tabIndex = -1; 21932 element.setAttribute("aria-hidden", "true"); 21933 }); 21934 } 21935 } 21936 ); 21937 } 21938 21939 // packages/edit-site/build-module/components/editor/index.js 21940 var import_jsx_runtime167 = __toESM(require_jsx_runtime()); 21941 var { Editor, BackButton } = unlock(import_editor19.privateApis); 21942 var { useHistory: useHistory11, useLocation: useLocation16 } = unlock(import_router17.privateApis); 21943 var { BlockKeyboardShortcuts } = unlock(import_block_library.privateApis); 21944 var toggleHomeIconVariants = { 21945 edit: { 21946 opacity: 0, 21947 scale: 0.2 21948 }, 21949 hover: { 21950 opacity: 1, 21951 scale: 1, 21952 clipPath: "inset( 22% round 2px )" 21953 } 21954 }; 21955 var siteIconVariants = { 21956 edit: { 21957 clipPath: "inset(0% round 0px)" 21958 }, 21959 hover: { 21960 clipPath: "inset( 22% round 2px )" 21961 }, 21962 tap: { 21963 clipPath: "inset(0% round 0px)" 21964 } 21965 }; 21966 function getListPathForPostType(postType2) { 21967 switch (postType2) { 21968 case "navigation": 21969 return "/navigation"; 21970 case "wp_block": 21971 return "/pattern?postType=wp_block"; 21972 case "wp_template_part": 21973 return "/pattern?postType=wp_template_part"; 21974 case "wp_template": 21975 return "/template"; 21976 case "page": 21977 return "/page"; 21978 case "post": 21979 return "/"; 21980 } 21981 throw "Unknown post type"; 21982 } 21983 function getNavigationPath(location, postType2) { 21984 const { path, name: name2 } = location; 21985 if ([ 21986 "pattern-item", 21987 "template-part-item", 21988 "page-item", 21989 "template-item", 21990 "static-template-item", 21991 "post-item" 21992 ].includes(name2)) { 21993 return getListPathForPostType(postType2); 21994 } 21995 return (0, import_url11.addQueryArgs)(path, { canvas: void 0 }); 21996 } 21997 function EditSiteEditor({ isHomeRoute = false }) { 21998 const disableMotion = (0, import_compose10.useReducedMotion)(); 21999 const location = useLocation16(); 22000 const { canvas = "view" } = location.query; 22001 const isLoading = useIsSiteEditorLoading(); 22002 useAdaptEditorToCanvas(canvas); 22003 const entity = useResolveEditedEntity(); 22004 useSyncDeprecatedEntityIntoState(entity); 22005 const { postType: postType2, postId, context } = entity; 22006 const { isBlockBasedTheme, hasSiteIcon } = (0, import_data46.useSelect)((select3) => { 22007 const { getCurrentTheme, getEntityRecord } = select3(import_core_data33.store); 22008 const siteData = getEntityRecord("root", "__unstableBase", void 0); 22009 return { 22010 isBlockBasedTheme: getCurrentTheme()?.is_block_theme, 22011 hasSiteIcon: !!siteData?.site_icon_url 22012 }; 22013 }, []); 22014 const postWithTemplate = !!context?.postId; 22015 use_editor_title_default( 22016 postWithTemplate ? context.postType : postType2, 22017 postWithTemplate ? context.postId : postId 22018 ); 22019 const _isPreviewingTheme = isPreviewingTheme(); 22020 const iframeProps = useEditorIframeProps(); 22021 const isEditMode = canvas === "edit"; 22022 const loadingProgressId = (0, import_compose10.useInstanceId)( 22023 CanvasLoader, 22024 "edit-site-editor__loading-progress" 22025 ); 22026 const settings2 = useSpecificEditorSettings(); 22027 const { initialBlockSelection, ...editorSettings } = settings2; 22028 const { resetZoomLevel } = unlock((0, import_data46.useDispatch)(import_block_editor18.store)); 22029 const { createSuccessNotice } = (0, import_data46.useDispatch)(import_notices3.store); 22030 const history = useHistory11(); 22031 const onActionPerformed = (0, import_element55.useCallback)( 22032 (actionId, items) => { 22033 switch (actionId) { 22034 case "move-to-trash": 22035 case "delete-post": 22036 { 22037 history.navigate( 22038 getListPathForPostType( 22039 postWithTemplate ? context.postType : postType2 22040 ) 22041 ); 22042 } 22043 break; 22044 case "duplicate-post": 22045 { 22046 const newItem = items[0]; 22047 const _title = typeof newItem.title === "string" ? newItem.title : newItem.title?.rendered; 22048 createSuccessNotice( 22049 (0, import_i18n70.sprintf)( 22050 // translators: %s: Title of the created post or template, e.g: "Hello world". 22051 (0, import_i18n70.__)('"%s" successfully created.'), 22052 (0, import_html_entities4.decodeEntities)(_title) || (0, import_i18n70.__)("(no title)") 22053 ), 22054 { 22055 type: "snackbar", 22056 id: "duplicate-post-action", 22057 actions: [ 22058 { 22059 label: (0, import_i18n70.__)("Edit"), 22060 onClick: () => { 22061 history.navigate( 22062 `/$newItem.type}/$newItem.id}?canvas=edit` 22063 ); 22064 } 22065 } 22066 ] 22067 } 22068 ); 22069 } 22070 break; 22071 } 22072 }, 22073 [ 22074 postType2, 22075 context?.postType, 22076 postWithTemplate, 22077 history, 22078 createSuccessNotice 22079 ] 22080 ); 22081 const isReady = !isLoading; 22082 const transition = { 22083 duration: disableMotion ? 0 : 0.2 22084 }; 22085 return !isBlockBasedTheme && isHomeRoute ? /* @__PURE__ */ (0, import_jsx_runtime167.jsx)(SitePreview, {}) : /* @__PURE__ */ (0, import_jsx_runtime167.jsxs)(import_jsx_runtime167.Fragment, { children: [ 22086 /* @__PURE__ */ (0, import_jsx_runtime167.jsx)(import_editor19.EditorKeyboardShortcutsRegister, {}), 22087 isEditMode && /* @__PURE__ */ (0, import_jsx_runtime167.jsx)(BlockKeyboardShortcuts, {}), 22088 !isReady ? /* @__PURE__ */ (0, import_jsx_runtime167.jsx)(CanvasLoader, { id: loadingProgressId }) : null, 22089 isEditMode && /* @__PURE__ */ (0, import_jsx_runtime167.jsx)( 22090 WelcomeGuide, 22091 { 22092 postType: postWithTemplate ? context.postType : postType2 22093 } 22094 ), 22095 isReady && /* @__PURE__ */ (0, import_jsx_runtime167.jsxs)( 22096 Editor, 22097 { 22098 postType: postWithTemplate ? context.postType : postType2, 22099 postId: postWithTemplate ? context.postId : postId, 22100 templateId: postWithTemplate ? postId : void 0, 22101 settings: editorSettings, 22102 initialSelection: initialBlockSelection, 22103 className: "edit-site-editor__editor-interface", 22104 customSaveButton: _isPreviewingTheme && /* @__PURE__ */ (0, import_jsx_runtime167.jsx)(SaveButton, { size: "compact" }), 22105 customSavePanel: _isPreviewingTheme && /* @__PURE__ */ (0, import_jsx_runtime167.jsx)(SavePanel, {}), 22106 iframeProps, 22107 onActionPerformed, 22108 extraSidebarPanels: !postWithTemplate && /* @__PURE__ */ (0, import_jsx_runtime167.jsx)(plugin_template_setting_panel_default.Slot, {}), 22109 children: [ 22110 isEditMode && /* @__PURE__ */ (0, import_jsx_runtime167.jsx)(BackButton, { children: ({ length }) => length <= 1 && /* @__PURE__ */ (0, import_jsx_runtime167.jsxs)( 22111 import_components83.__unstableMotion.div, 22112 { 22113 className: "edit-site-editor__view-mode-toggle", 22114 transition, 22115 animate: "edit", 22116 initial: "edit", 22117 whileHover: "hover", 22118 whileTap: "tap", 22119 children: [ 22120 /* @__PURE__ */ (0, import_jsx_runtime167.jsx)( 22121 import_components83.Button, 22122 { 22123 __next40pxDefaultSize: true, 22124 label: (0, import_i18n70.__)("Open Navigation"), 22125 showTooltip: true, 22126 tooltipPosition: "middle right", 22127 onClick: () => { 22128 resetZoomLevel(); 22129 history.navigate( 22130 getNavigationPath( 22131 location, 22132 postWithTemplate ? context.postType : postType2 22133 ), 22134 { 22135 transition: "canvas-mode-view-transition" 22136 } 22137 ); 22138 }, 22139 children: /* @__PURE__ */ (0, import_jsx_runtime167.jsx)( 22140 import_components83.__unstableMotion.div, 22141 { 22142 variants: siteIconVariants, 22143 children: /* @__PURE__ */ (0, import_jsx_runtime167.jsx)(site_icon_default, { className: "edit-site-editor__view-mode-toggle-icon" }) 22144 } 22145 ) 22146 } 22147 ), 22148 /* @__PURE__ */ (0, import_jsx_runtime167.jsx)( 22149 import_components83.__unstableMotion.div, 22150 { 22151 className: clsx_default( 22152 "edit-site-editor__back-icon", 22153 { 22154 "has-site-icon": hasSiteIcon 22155 } 22156 ), 22157 variants: toggleHomeIconVariants, 22158 children: /* @__PURE__ */ (0, import_jsx_runtime167.jsx)(icon_default, { icon: arrow_up_left_default }) 22159 } 22160 ) 22161 ] 22162 } 22163 ) }), 22164 /* @__PURE__ */ (0, import_jsx_runtime167.jsx)(MoreMenu, {}) 22165 ] 22166 } 22167 ) 22168 ] }); 22169 } 22170 22171 // packages/edit-site/build-module/components/site-editor-routes/utils.js 22172 function isClassicThemeWithStyleBookSupport(siteData) { 22173 const isBlockTheme = siteData.currentTheme?.is_block_theme; 22174 const supportsEditorStyles = siteData.currentTheme?.theme_supports["editor-styles"]; 22175 const hasThemeJson = siteData.editorSettings?.supportsLayout; 22176 return !isBlockTheme && (supportsEditorStyles || hasThemeJson); 22177 } 22178 22179 // packages/edit-site/build-module/components/site-editor-routes/home.js 22180 var import_jsx_runtime168 = __toESM(require_jsx_runtime()); 22181 var homeRoute = { 22182 name: "home", 22183 path: "/", 22184 areas: { 22185 sidebar({ siteData }) { 22186 const isBlockTheme = siteData.currentTheme?.is_block_theme; 22187 return isBlockTheme || isClassicThemeWithStyleBookSupport(siteData) ? /* @__PURE__ */ (0, import_jsx_runtime168.jsx)(SidebarNavigationScreenMain, {}) : /* @__PURE__ */ (0, import_jsx_runtime168.jsx)(SidebarNavigationScreenUnsupported, {}); 22188 }, 22189 preview({ siteData }) { 22190 const isBlockTheme = siteData.currentTheme?.is_block_theme; 22191 return isBlockTheme || isClassicThemeWithStyleBookSupport(siteData) ? /* @__PURE__ */ (0, import_jsx_runtime168.jsx)(EditSiteEditor, { isHomeRoute: true }) : void 0; 22192 }, 22193 mobile({ siteData }) { 22194 const isBlockTheme = siteData.currentTheme?.is_block_theme; 22195 return isBlockTheme || isClassicThemeWithStyleBookSupport(siteData) ? /* @__PURE__ */ (0, import_jsx_runtime168.jsx)(SidebarNavigationScreenMain, {}) : /* @__PURE__ */ (0, import_jsx_runtime168.jsx)(SidebarNavigationScreenUnsupported, {}); 22196 } 22197 } 22198 }; 22199 22200 // packages/edit-site/build-module/components/site-editor-routes/styles.js 22201 var import_router19 = __toESM(require_router()); 22202 var import_editor22 = __toESM(require_editor()); 22203 var import_url13 = __toESM(require_url()); 22204 22205 // packages/edit-site/build-module/components/sidebar-global-styles/index.js 22206 var import_i18n71 = __toESM(require_i18n()); 22207 var import_element56 = __toESM(require_element()); 22208 var import_router18 = __toESM(require_router()); 22209 var import_editor21 = __toESM(require_editor()); 22210 var import_compose11 = __toESM(require_compose()); 22211 var import_components84 = __toESM(require_components()); 22212 var import_url12 = __toESM(require_url()); 22213 var import_jsx_runtime169 = __toESM(require_jsx_runtime()); 22214 var { GlobalStylesUIWrapper, GlobalStylesActionMenu } = unlock(import_editor21.privateApis); 22215 var { useLocation: useLocation17, useHistory: useHistory12 } = unlock(import_router18.privateApis); 22216 var GlobalStylesPageActions = ({ 22217 isStyleBookOpened, 22218 setIsStyleBookOpened, 22219 path, 22220 onChangeSection 22221 }) => { 22222 const history = useHistory12(); 22223 return /* @__PURE__ */ (0, import_jsx_runtime169.jsxs)(import_components84.__experimentalHStack, { children: [ 22224 /* @__PURE__ */ (0, import_jsx_runtime169.jsx)( 22225 import_components84.Button, 22226 { 22227 isPressed: isStyleBookOpened, 22228 icon: seen_default, 22229 label: (0, import_i18n71.__)("Style Book"), 22230 onClick: () => { 22231 setIsStyleBookOpened(!isStyleBookOpened); 22232 const updatedPath = !isStyleBookOpened ? (0, import_url12.addQueryArgs)(path, { preview: "stylebook" }) : (0, import_url12.removeQueryArgs)(path, "preview"); 22233 history.navigate(updatedPath); 22234 }, 22235 size: "compact" 22236 } 22237 ), 22238 /* @__PURE__ */ (0, import_jsx_runtime169.jsx)( 22239 GlobalStylesActionMenu, 22240 { 22241 hideWelcomeGuide: true, 22242 onChangePath: onChangeSection 22243 } 22244 ) 22245 ] }); 22246 }; 22247 var useSection = () => { 22248 const { path, query } = useLocation17(); 22249 const history = useHistory12(); 22250 return (0, import_element56.useMemo)(() => { 22251 return [ 22252 query.section ?? "/", 22253 (updatedSection) => { 22254 history.navigate( 22255 (0, import_url12.addQueryArgs)(path, { 22256 section: updatedSection 22257 }) 22258 ); 22259 } 22260 ]; 22261 }, [path, query.section, history]); 22262 }; 22263 function SidebarGlobalStyles() { 22264 const { path } = useLocation17(); 22265 const [isStyleBookOpened, setIsStyleBookOpened] = (0, import_element56.useState)( 22266 path.includes("preview=stylebook") 22267 ); 22268 const isMobileViewport = (0, import_compose11.useViewportMatch)("medium", "<"); 22269 const [section, onChangeSection] = useSection(); 22270 return /* @__PURE__ */ (0, import_jsx_runtime169.jsx)( 22271 page_default, 22272 { 22273 actions: !isMobileViewport ? /* @__PURE__ */ (0, import_jsx_runtime169.jsx)( 22274 GlobalStylesPageActions, 22275 { 22276 isStyleBookOpened, 22277 setIsStyleBookOpened, 22278 path, 22279 onChangeSection 22280 } 22281 ) : null, 22282 className: "edit-site-styles", 22283 title: (0, import_i18n71.__)("Styles"), 22284 children: /* @__PURE__ */ (0, import_jsx_runtime169.jsx)( 22285 GlobalStylesUIWrapper, 22286 { 22287 path: section, 22288 onPathChange: onChangeSection 22289 } 22290 ) 22291 } 22292 ); 22293 } 22294 22295 // packages/edit-site/build-module/components/site-editor-routes/styles.js 22296 var import_jsx_runtime170 = __toESM(require_jsx_runtime()); 22297 var { useLocation: useLocation18, useHistory: useHistory13 } = unlock(import_router19.privateApis); 22298 var { StyleBookPreview } = unlock(import_editor22.privateApis); 22299 function MobileGlobalStylesUI() { 22300 const { query = {} } = useLocation18(); 22301 const { canvas } = query; 22302 if (canvas === "edit") { 22303 return /* @__PURE__ */ (0, import_jsx_runtime170.jsx)(EditSiteEditor, {}); 22304 } 22305 return /* @__PURE__ */ (0, import_jsx_runtime170.jsx)(SidebarGlobalStyles, {}); 22306 } 22307 function StylesPreviewArea() { 22308 const { path, query } = useLocation18(); 22309 const history = useHistory13(); 22310 const isStylebook = query.preview === "stylebook"; 22311 const section = query.section ?? "/"; 22312 const onChangeSection = (updatedSection) => { 22313 history.navigate( 22314 (0, import_url13.addQueryArgs)(path, { 22315 section: updatedSection 22316 }) 22317 ); 22318 }; 22319 if (isStylebook) { 22320 return /* @__PURE__ */ (0, import_jsx_runtime170.jsx)( 22321 StyleBookPreview, 22322 { 22323 path: section, 22324 onPathChange: onChangeSection 22325 } 22326 ); 22327 } 22328 return /* @__PURE__ */ (0, import_jsx_runtime170.jsx)(EditSiteEditor, {}); 22329 } 22330 var stylesRoute = { 22331 name: "styles", 22332 path: "/styles", 22333 areas: { 22334 content: /* @__PURE__ */ (0, import_jsx_runtime170.jsx)(SidebarGlobalStyles, {}), 22335 sidebar: /* @__PURE__ */ (0, import_jsx_runtime170.jsx)(SidebarNavigationScreenGlobalStyles, { backPath: "/" }), 22336 preview: /* @__PURE__ */ (0, import_jsx_runtime170.jsx)(StylesPreviewArea, {}), 22337 mobile: /* @__PURE__ */ (0, import_jsx_runtime170.jsx)(MobileGlobalStylesUI, {}) 22338 }, 22339 widths: { 22340 content: 380 22341 } 22342 }; 22343 22344 // packages/edit-site/build-module/components/site-editor-routes/navigation.js 22345 var import_router24 = __toESM(require_router()); 22346 22347 // packages/edit-site/build-module/components/sidebar-navigation-screen-navigation-menus/index.js 22348 var import_i18n80 = __toESM(require_i18n()); 22349 var import_core_data37 = __toESM(require_core_data()); 22350 var import_data52 = __toESM(require_data()); 22351 var import_html_entities8 = __toESM(require_html_entities()); 22352 var import_components90 = __toESM(require_components()); 22353 22354 // packages/edit-site/build-module/components/sidebar-navigation-screen-navigation-menus/constants.js 22355 var PRELOADED_NAVIGATION_MENUS_QUERY = { 22356 per_page: 100, 22357 status: ["publish", "draft"], 22358 order: "desc", 22359 orderby: "date" 22360 }; 22361 22362 // packages/edit-site/build-module/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js 22363 var import_i18n77 = __toESM(require_i18n()); 22364 var import_html_entities6 = __toESM(require_html_entities()); 22365 22366 // packages/edit-site/build-module/components/sidebar-navigation-screen-navigation-menu/more-menu.js 22367 var import_components87 = __toESM(require_components()); 22368 var import_i18n74 = __toESM(require_i18n()); 22369 var import_element58 = __toESM(require_element()); 22370 var import_router20 = __toESM(require_router()); 22371 22372 // packages/edit-site/build-module/components/sidebar-navigation-screen-navigation-menu/rename-modal.js 22373 var import_components85 = __toESM(require_components()); 22374 var import_i18n72 = __toESM(require_i18n()); 22375 var import_element57 = __toESM(require_element()); 22376 var import_jsx_runtime171 = __toESM(require_jsx_runtime()); 22377 var notEmptyString = (testString) => testString?.trim()?.length > 0; 22378 function RenameModal({ menuTitle, onClose, onSave }) { 22379 const [editedMenuTitle, setEditedMenuTitle] = (0, import_element57.useState)(menuTitle); 22380 const titleHasChanged = editedMenuTitle !== menuTitle; 22381 const isEditedMenuTitleValid = titleHasChanged && notEmptyString(editedMenuTitle); 22382 return /* @__PURE__ */ (0, import_jsx_runtime171.jsx)( 22383 import_components85.Modal, 22384 { 22385 title: (0, import_i18n72.__)("Rename"), 22386 onRequestClose: onClose, 22387 focusOnMount: "firstContentElement", 22388 size: "small", 22389 children: /* @__PURE__ */ (0, import_jsx_runtime171.jsx)("form", { className: "sidebar-navigation__rename-modal-form", children: /* @__PURE__ */ (0, import_jsx_runtime171.jsxs)(import_components85.__experimentalVStack, { spacing: "3", children: [ 22390 /* @__PURE__ */ (0, import_jsx_runtime171.jsx)( 22391 import_components85.TextControl, 22392 { 22393 __next40pxDefaultSize: true, 22394 value: editedMenuTitle, 22395 placeholder: (0, import_i18n72.__)("Navigation title"), 22396 onChange: setEditedMenuTitle, 22397 label: (0, import_i18n72.__)("Name") 22398 } 22399 ), 22400 /* @__PURE__ */ (0, import_jsx_runtime171.jsxs)(import_components85.__experimentalHStack, { justify: "right", children: [ 22401 /* @__PURE__ */ (0, import_jsx_runtime171.jsx)( 22402 import_components85.Button, 22403 { 22404 __next40pxDefaultSize: true, 22405 variant: "tertiary", 22406 onClick: onClose, 22407 children: (0, import_i18n72.__)("Cancel") 22408 } 22409 ), 22410 /* @__PURE__ */ (0, import_jsx_runtime171.jsx)( 22411 import_components85.Button, 22412 { 22413 __next40pxDefaultSize: true, 22414 accessibleWhenDisabled: true, 22415 disabled: !isEditedMenuTitleValid, 22416 variant: "primary", 22417 type: "submit", 22418 onClick: (e2) => { 22419 e2.preventDefault(); 22420 if (!isEditedMenuTitleValid) { 22421 return; 22422 } 22423 onSave({ title: editedMenuTitle }); 22424 onClose(); 22425 }, 22426 children: (0, import_i18n72.__)("Save") 22427 } 22428 ) 22429 ] }) 22430 ] }) }) 22431 } 22432 ); 22433 } 22434 22435 // packages/edit-site/build-module/components/sidebar-navigation-screen-navigation-menu/delete-confirm-dialog.js 22436 var import_components86 = __toESM(require_components()); 22437 var import_i18n73 = __toESM(require_i18n()); 22438 var import_jsx_runtime172 = __toESM(require_jsx_runtime()); 22439 function DeleteConfirmDialog({ onClose, onConfirm }) { 22440 return /* @__PURE__ */ (0, import_jsx_runtime172.jsx)( 22441 import_components86.__experimentalConfirmDialog, 22442 { 22443 isOpen: true, 22444 onConfirm: () => { 22445 onConfirm(); 22446 onClose(); 22447 }, 22448 onCancel: onClose, 22449 confirmButtonText: (0, import_i18n73.__)("Delete"), 22450 size: "medium", 22451 children: (0, import_i18n73.__)("Are you sure you want to delete this Navigation Menu?") 22452 } 22453 ); 22454 } 22455 22456 // packages/edit-site/build-module/components/sidebar-navigation-screen-navigation-menu/more-menu.js 22457 var import_jsx_runtime173 = __toESM(require_jsx_runtime()); 22458 var { useHistory: useHistory14 } = unlock(import_router20.privateApis); 22459 var POPOVER_PROPS = { 22460 position: "bottom right" 22461 }; 22462 function ScreenNavigationMoreMenu(props) { 22463 const { onDelete, onSave, onDuplicate, menuTitle, menuId } = props; 22464 const [renameModalOpen, setRenameModalOpen] = (0, import_element58.useState)(false); 22465 const [deleteConfirmDialogOpen, setDeleteConfirmDialogOpen] = (0, import_element58.useState)(false); 22466 const history = useHistory14(); 22467 const closeModals = () => { 22468 setRenameModalOpen(false); 22469 setDeleteConfirmDialogOpen(false); 22470 }; 22471 const openRenameModal = () => setRenameModalOpen(true); 22472 const openDeleteConfirmDialog = () => setDeleteConfirmDialogOpen(true); 22473 return /* @__PURE__ */ (0, import_jsx_runtime173.jsxs)(import_jsx_runtime173.Fragment, { children: [ 22474 /* @__PURE__ */ (0, import_jsx_runtime173.jsx)( 22475 import_components87.DropdownMenu, 22476 { 22477 className: "sidebar-navigation__more-menu", 22478 label: (0, import_i18n74.__)("Actions"), 22479 icon: more_vertical_default, 22480 popoverProps: POPOVER_PROPS, 22481 children: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime173.jsxs)(import_components87.MenuGroup, { children: [ 22482 /* @__PURE__ */ (0, import_jsx_runtime173.jsx)( 22483 import_components87.MenuItem, 22484 { 22485 onClick: () => { 22486 openRenameModal(); 22487 onClose(); 22488 }, 22489 children: (0, import_i18n74.__)("Rename") 22490 } 22491 ), 22492 /* @__PURE__ */ (0, import_jsx_runtime173.jsx)( 22493 import_components87.MenuItem, 22494 { 22495 onClick: () => { 22496 history.navigate( 22497 `/wp_navigation/$menuId}?canvas=edit` 22498 ); 22499 }, 22500 children: (0, import_i18n74.__)("Edit") 22501 } 22502 ), 22503 /* @__PURE__ */ (0, import_jsx_runtime173.jsx)( 22504 import_components87.MenuItem, 22505 { 22506 onClick: () => { 22507 onDuplicate(); 22508 onClose(); 22509 }, 22510 children: (0, import_i18n74.__)("Duplicate") 22511 } 22512 ), 22513 /* @__PURE__ */ (0, import_jsx_runtime173.jsx)( 22514 import_components87.MenuItem, 22515 { 22516 isDestructive: true, 22517 onClick: () => { 22518 openDeleteConfirmDialog(); 22519 onClose(); 22520 }, 22521 children: (0, import_i18n74.__)("Delete") 22522 } 22523 ) 22524 ] }) 22525 } 22526 ), 22527 deleteConfirmDialogOpen && /* @__PURE__ */ (0, import_jsx_runtime173.jsx)( 22528 DeleteConfirmDialog, 22529 { 22530 onClose: closeModals, 22531 onConfirm: onDelete 22532 } 22533 ), 22534 renameModalOpen && /* @__PURE__ */ (0, import_jsx_runtime173.jsx)( 22535 RenameModal, 22536 { 22537 onClose: closeModals, 22538 menuTitle, 22539 onSave 22540 } 22541 ) 22542 ] }); 22543 } 22544 22545 // packages/edit-site/build-module/components/sidebar-navigation-screen-navigation-menu/navigation-menu-editor.js 22546 var import_element61 = __toESM(require_element()); 22547 var import_data49 = __toESM(require_data()); 22548 var import_block_editor21 = __toESM(require_block_editor()); 22549 var import_blocks10 = __toESM(require_blocks()); 22550 22551 // packages/edit-site/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js 22552 var import_block_editor20 = __toESM(require_block_editor()); 22553 var import_data48 = __toESM(require_data()); 22554 var import_blocks9 = __toESM(require_blocks()); 22555 var import_element60 = __toESM(require_element()); 22556 var import_core_data34 = __toESM(require_core_data()); 22557 22558 // packages/edit-site/build-module/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js 22559 var import_components88 = __toESM(require_components()); 22560 var import_data47 = __toESM(require_data()); 22561 var import_element59 = __toESM(require_element()); 22562 var import_i18n75 = __toESM(require_i18n()); 22563 var import_block_editor19 = __toESM(require_block_editor()); 22564 var import_router21 = __toESM(require_router()); 22565 var import_jsx_runtime174 = __toESM(require_jsx_runtime()); 22566 var POPOVER_PROPS2 = { 22567 className: "block-editor-block-settings-menu__popover", 22568 placement: "bottom-start" 22569 }; 22570 var { useHistory: useHistory15, useLocation: useLocation19 } = unlock(import_router21.privateApis); 22571 function LeafMoreMenu(props) { 22572 const history = useHistory15(); 22573 const { path } = useLocation19(); 22574 const { block } = props; 22575 const { clientId } = block; 22576 const { moveBlocksDown, moveBlocksUp, removeBlocks } = (0, import_data47.useDispatch)(import_block_editor19.store); 22577 const removeLabel = (0, import_i18n75.sprintf)( 22578 /* translators: %s: block name */ 22579 (0, import_i18n75.__)("Remove %s"), 22580 (0, import_block_editor19.BlockTitle)({ clientId, maximumLength: 25 }) 22581 ); 22582 const goToLabel = (0, import_i18n75.sprintf)( 22583 /* translators: %s: block name */ 22584 (0, import_i18n75.__)("Go to %s"), 22585 (0, import_block_editor19.BlockTitle)({ clientId, maximumLength: 25 }) 22586 ); 22587 const rootClientId = (0, import_data47.useSelect)( 22588 (select3) => { 22589 const { getBlockRootClientId } = select3(import_block_editor19.store); 22590 return getBlockRootClientId(clientId); 22591 }, 22592 [clientId] 22593 ); 22594 const onGoToPage = (0, import_element59.useCallback)( 22595 (selectedBlock) => { 22596 const { attributes, name: name2 } = selectedBlock; 22597 if (attributes.kind === "post-type" && attributes.id && attributes.type && history) { 22598 history.navigate( 22599 `/$attributes.type}/$attributes.id}?canvas=edit`, 22600 { 22601 state: { backPath: path } 22602 } 22603 ); 22604 } 22605 if (name2 === "core/page-list-item" && attributes.id && history) { 22606 history.navigate(`/page/$attributes.id}?canvas=edit`, { 22607 state: { backPath: path } 22608 }); 22609 } 22610 }, 22611 [path, history] 22612 ); 22613 return /* @__PURE__ */ (0, import_jsx_runtime174.jsx)( 22614 import_components88.DropdownMenu, 22615 { 22616 icon: more_vertical_default, 22617 label: (0, import_i18n75.__)("Options"), 22618 className: "block-editor-block-settings-menu", 22619 popoverProps: POPOVER_PROPS2, 22620 noIcons: true, 22621 ...props, 22622 children: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime174.jsxs)(import_jsx_runtime174.Fragment, { children: [ 22623 /* @__PURE__ */ (0, import_jsx_runtime174.jsxs)(import_components88.MenuGroup, { children: [ 22624 /* @__PURE__ */ (0, import_jsx_runtime174.jsx)( 22625 import_components88.MenuItem, 22626 { 22627 icon: chevron_up_default, 22628 onClick: () => { 22629 moveBlocksUp([clientId], rootClientId); 22630 onClose(); 22631 }, 22632 children: (0, import_i18n75.__)("Move up") 22633 } 22634 ), 22635 /* @__PURE__ */ (0, import_jsx_runtime174.jsx)( 22636 import_components88.MenuItem, 22637 { 22638 icon: chevron_down_default, 22639 onClick: () => { 22640 moveBlocksDown([clientId], rootClientId); 22641 onClose(); 22642 }, 22643 children: (0, import_i18n75.__)("Move down") 22644 } 22645 ), 22646 block.attributes?.type === "page" && block.attributes?.id && /* @__PURE__ */ (0, import_jsx_runtime174.jsx)( 22647 import_components88.MenuItem, 22648 { 22649 onClick: () => { 22650 onGoToPage(block); 22651 onClose(); 22652 }, 22653 children: goToLabel 22654 } 22655 ) 22656 ] }), 22657 /* @__PURE__ */ (0, import_jsx_runtime174.jsx)(import_components88.MenuGroup, { children: /* @__PURE__ */ (0, import_jsx_runtime174.jsx)( 22658 import_components88.MenuItem, 22659 { 22660 onClick: () => { 22661 removeBlocks([clientId], false); 22662 onClose(); 22663 }, 22664 children: removeLabel 22665 } 22666 ) }) 22667 ] }) 22668 } 22669 ); 22670 } 22671 22672 // packages/edit-site/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js 22673 var import_jsx_runtime175 = __toESM(require_jsx_runtime()); 22674 var { PrivateListView } = unlock(import_block_editor20.privateApis); 22675 var MAX_PAGE_COUNT = 100; 22676 var PAGES_QUERY = [ 22677 "postType", 22678 "page", 22679 { 22680 per_page: MAX_PAGE_COUNT, 22681 _fields: ["id", "link", "menu_order", "parent", "title", "type"], 22682 // TODO: When https://core.trac.wordpress.org/ticket/39037 REST API support for multiple orderby 22683 // values is resolved, update 'orderby' to [ 'menu_order', 'post_title' ] to provide a consistent 22684 // sort. 22685 orderby: "menu_order", 22686 order: "asc" 22687 } 22688 ]; 22689 function NavigationMenuContent({ rootClientId }) { 22690 const { listViewRootClientId, isLoading } = (0, import_data48.useSelect)( 22691 (select3) => { 22692 const { 22693 areInnerBlocksControlled, 22694 getBlockName, 22695 getBlockCount, 22696 getBlockOrder 22697 } = select3(import_block_editor20.store); 22698 const { isResolving } = select3(import_core_data34.store); 22699 const blockClientIds = getBlockOrder(rootClientId); 22700 const hasOnlyPageListBlock = blockClientIds.length === 1 && getBlockName(blockClientIds[0]) === "core/page-list"; 22701 const pageListHasBlocks = hasOnlyPageListBlock && getBlockCount(blockClientIds[0]) > 0; 22702 const isLoadingPages = isResolving( 22703 "getEntityRecords", 22704 PAGES_QUERY 22705 ); 22706 return { 22707 listViewRootClientId: pageListHasBlocks ? blockClientIds[0] : rootClientId, 22708 // This is a small hack to wait for the navigation block 22709 // to actually load its inner blocks. 22710 isLoading: !areInnerBlocksControlled(rootClientId) || isLoadingPages 22711 }; 22712 }, 22713 [rootClientId] 22714 ); 22715 const { replaceBlock, __unstableMarkNextChangeAsNotPersistent } = (0, import_data48.useDispatch)(import_block_editor20.store); 22716 const offCanvasOnselect = (0, import_element60.useCallback)( 22717 (block) => { 22718 if (block.name === "core/navigation-link" && !block.attributes.url) { 22719 __unstableMarkNextChangeAsNotPersistent(); 22720 replaceBlock( 22721 block.clientId, 22722 (0, import_blocks9.createBlock)("core/navigation-link", block.attributes) 22723 ); 22724 } 22725 }, 22726 [__unstableMarkNextChangeAsNotPersistent, replaceBlock] 22727 ); 22728 return /* @__PURE__ */ (0, import_jsx_runtime175.jsxs)(import_jsx_runtime175.Fragment, { children: [ 22729 !isLoading && /* @__PURE__ */ (0, import_jsx_runtime175.jsx)( 22730 PrivateListView, 22731 { 22732 rootClientId: listViewRootClientId, 22733 onSelect: offCanvasOnselect, 22734 blockSettingsMenu: LeafMoreMenu, 22735 showAppender: false, 22736 isExpanded: true 22737 } 22738 ), 22739 /* @__PURE__ */ (0, import_jsx_runtime175.jsx)("div", { className: "edit-site-sidebar-navigation-screen-navigation-menus__helper-block-editor", children: /* @__PURE__ */ (0, import_jsx_runtime175.jsx)(import_block_editor20.BlockList, {}) }) 22740 ] }); 22741 } 22742 22743 // packages/edit-site/build-module/components/sidebar-navigation-screen-navigation-menu/navigation-menu-editor.js 22744 var import_jsx_runtime176 = __toESM(require_jsx_runtime()); 22745 var noop2 = () => { 22746 }; 22747 function NavigationMenuEditor({ navigationMenuId }) { 22748 const { storedSettings } = (0, import_data49.useSelect)((select3) => { 22749 const { getSettings: getSettings7 } = unlock(select3(store)); 22750 return { 22751 storedSettings: getSettings7() 22752 }; 22753 }, []); 22754 const blocks = (0, import_element61.useMemo)(() => { 22755 if (!navigationMenuId) { 22756 return []; 22757 } 22758 return [(0, import_blocks10.createBlock)("core/navigation", { ref: navigationMenuId })]; 22759 }, [navigationMenuId]); 22760 if (!navigationMenuId || !blocks?.length) { 22761 return null; 22762 } 22763 return /* @__PURE__ */ (0, import_jsx_runtime176.jsx)( 22764 import_block_editor21.BlockEditorProvider, 22765 { 22766 settings: storedSettings, 22767 value: blocks, 22768 onChange: noop2, 22769 onInput: noop2, 22770 children: /* @__PURE__ */ (0, import_jsx_runtime176.jsx)("div", { className: "edit-site-sidebar-navigation-screen-navigation-menus__content", children: /* @__PURE__ */ (0, import_jsx_runtime176.jsx)(NavigationMenuContent, { rootClientId: blocks[0].clientId }) }) 22771 } 22772 ); 22773 } 22774 22775 // packages/edit-site/build-module/components/sidebar-navigation-screen-navigation-menus/build-navigation-label.js 22776 var import_i18n76 = __toESM(require_i18n()); 22777 var import_html_entities5 = __toESM(require_html_entities()); 22778 function buildNavigationLabel(title, id, status) { 22779 if (!title?.rendered) { 22780 return (0, import_i18n76.sprintf)((0, import_i18n76.__)("(no title %s)"), id); 22781 } 22782 if (status === "publish") { 22783 return (0, import_html_entities5.decodeEntities)(title?.rendered); 22784 } 22785 return (0, import_i18n76.sprintf)( 22786 // translators: 1: title of the menu. 2: status of the menu (draft, pending, etc.). 22787 (0, import_i18n76._x)("%1$s (%2$s)", "menu label"), 22788 (0, import_html_entities5.decodeEntities)(title?.rendered), 22789 status 22790 ); 22791 } 22792 22793 // packages/edit-site/build-module/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js 22794 var import_jsx_runtime177 = __toESM(require_jsx_runtime()); 22795 function SingleNavigationMenu({ 22796 navigationMenu, 22797 backPath, 22798 handleDelete, 22799 handleDuplicate, 22800 handleSave 22801 }) { 22802 const menuTitle = navigationMenu?.title?.rendered; 22803 return /* @__PURE__ */ (0, import_jsx_runtime177.jsx)( 22804 SidebarNavigationScreenWrapper, 22805 { 22806 actions: /* @__PURE__ */ (0, import_jsx_runtime177.jsx)(import_jsx_runtime177.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime177.jsx)( 22807 ScreenNavigationMoreMenu, 22808 { 22809 menuId: navigationMenu?.id, 22810 menuTitle: (0, import_html_entities6.decodeEntities)(menuTitle), 22811 onDelete: handleDelete, 22812 onSave: handleSave, 22813 onDuplicate: handleDuplicate 22814 } 22815 ) }), 22816 backPath, 22817 title: buildNavigationLabel( 22818 navigationMenu?.title, 22819 navigationMenu?.id, 22820 navigationMenu?.status 22821 ), 22822 description: (0, import_i18n77.__)( 22823 "Navigation Menus are a curated collection of blocks that allow visitors to get around your site." 22824 ), 22825 children: /* @__PURE__ */ (0, import_jsx_runtime177.jsx)(NavigationMenuEditor, { navigationMenuId: navigationMenu?.id }) 22826 } 22827 ); 22828 } 22829 22830 // packages/edit-site/build-module/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js 22831 var import_core_data36 = __toESM(require_core_data()); 22832 var import_i18n79 = __toESM(require_i18n()); 22833 var import_data51 = __toESM(require_data()); 22834 var import_notices4 = __toESM(require_notices()); 22835 var import_router23 = __toESM(require_router()); 22836 22837 // packages/edit-site/build-module/components/sidebar-navigation-screen-navigation-menu/index.js 22838 var import_core_data35 = __toESM(require_core_data()); 22839 var import_components89 = __toESM(require_components()); 22840 var import_i18n78 = __toESM(require_i18n()); 22841 var import_data50 = __toESM(require_data()); 22842 var import_html_entities7 = __toESM(require_html_entities()); 22843 var import_router22 = __toESM(require_router()); 22844 var import_jsx_runtime178 = __toESM(require_jsx_runtime()); 22845 var { useLocation: useLocation20 } = unlock(import_router22.privateApis); 22846 var postType = `wp_navigation`; 22847 function SidebarNavigationScreenNavigationMenu({ backPath }) { 22848 const { 22849 params: { postId } 22850 } = useLocation20(); 22851 const { record: navigationMenu, isResolving } = (0, import_core_data35.useEntityRecord)( 22852 "postType", 22853 postType, 22854 postId 22855 ); 22856 const { isSaving, isDeleting } = (0, import_data50.useSelect)( 22857 (select3) => { 22858 const { isSavingEntityRecord, isDeletingEntityRecord } = select3(import_core_data35.store); 22859 return { 22860 isSaving: isSavingEntityRecord("postType", postType, postId), 22861 isDeleting: isDeletingEntityRecord( 22862 "postType", 22863 postType, 22864 postId 22865 ) 22866 }; 22867 }, 22868 [postId] 22869 ); 22870 const isLoading = isResolving || isSaving || isDeleting; 22871 const menuTitle = navigationMenu?.title?.rendered || navigationMenu?.slug; 22872 const { handleSave, handleDelete, handleDuplicate } = useNavigationMenuHandlers(); 22873 const _handleDelete = () => handleDelete(navigationMenu); 22874 const _handleSave = (edits) => handleSave(navigationMenu, edits); 22875 const _handleDuplicate = () => handleDuplicate(navigationMenu); 22876 if (isLoading) { 22877 return /* @__PURE__ */ (0, import_jsx_runtime178.jsx)( 22878 SidebarNavigationScreenWrapper, 22879 { 22880 description: (0, import_i18n78.__)( 22881 "Navigation Menus are a curated collection of blocks that allow visitors to get around your site." 22882 ), 22883 backPath, 22884 children: /* @__PURE__ */ (0, import_jsx_runtime178.jsx)(import_components89.Spinner, { className: "edit-site-sidebar-navigation-screen-navigation-menus__loading" }) 22885 } 22886 ); 22887 } 22888 if (!isLoading && !navigationMenu) { 22889 return /* @__PURE__ */ (0, import_jsx_runtime178.jsx)( 22890 SidebarNavigationScreenWrapper, 22891 { 22892 description: (0, import_i18n78.__)("Navigation Menu missing."), 22893 backPath 22894 } 22895 ); 22896 } 22897 if (!navigationMenu?.content?.raw) { 22898 return /* @__PURE__ */ (0, import_jsx_runtime178.jsx)( 22899 SidebarNavigationScreenWrapper, 22900 { 22901 actions: /* @__PURE__ */ (0, import_jsx_runtime178.jsx)( 22902 ScreenNavigationMoreMenu, 22903 { 22904 menuId: navigationMenu?.id, 22905 menuTitle: (0, import_html_entities7.decodeEntities)(menuTitle), 22906 onDelete: _handleDelete, 22907 onSave: _handleSave, 22908 onDuplicate: _handleDuplicate 22909 } 22910 ), 22911 backPath, 22912 title: buildNavigationLabel( 22913 navigationMenu?.title, 22914 navigationMenu?.id, 22915 navigationMenu?.status 22916 ), 22917 description: (0, import_i18n78.__)("This Navigation Menu is empty.") 22918 } 22919 ); 22920 } 22921 return /* @__PURE__ */ (0, import_jsx_runtime178.jsx)( 22922 SingleNavigationMenu, 22923 { 22924 navigationMenu, 22925 backPath, 22926 handleDelete: _handleDelete, 22927 handleSave: _handleSave, 22928 handleDuplicate: _handleDuplicate 22929 } 22930 ); 22931 } 22932 22933 // packages/edit-site/build-module/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js 22934 var { useHistory: useHistory16 } = unlock(import_router23.privateApis); 22935 function useDeleteNavigationMenu() { 22936 const { deleteEntityRecord } = (0, import_data51.useDispatch)(import_core_data36.store); 22937 const { createSuccessNotice, createErrorNotice } = (0, import_data51.useDispatch)(import_notices4.store); 22938 const history = useHistory16(); 22939 const handleDelete = async (navigationMenu) => { 22940 const postId = navigationMenu?.id; 22941 try { 22942 await deleteEntityRecord( 22943 "postType", 22944 postType, 22945 postId, 22946 { 22947 force: true 22948 }, 22949 { 22950 throwOnError: true 22951 } 22952 ); 22953 createSuccessNotice( 22954 (0, import_i18n79.__)("Navigation Menu successfully deleted."), 22955 { 22956 type: "snackbar" 22957 } 22958 ); 22959 history.navigate("/navigation"); 22960 } catch (error) { 22961 createErrorNotice( 22962 (0, import_i18n79.sprintf)( 22963 /* translators: %s: error message describing why the navigation menu could not be deleted. */ 22964 (0, import_i18n79.__)(`Unable to delete Navigation Menu (%s).`), 22965 error?.message 22966 ), 22967 { 22968 type: "snackbar" 22969 } 22970 ); 22971 } 22972 }; 22973 return handleDelete; 22974 } 22975 function useSaveNavigationMenu() { 22976 const { getEditedEntityRecord } = (0, import_data51.useSelect)((select3) => { 22977 const { getEditedEntityRecord: getEditedEntityRecordSelector } = select3(import_core_data36.store); 22978 return { 22979 getEditedEntityRecord: getEditedEntityRecordSelector 22980 }; 22981 }, []); 22982 const { 22983 editEntityRecord, 22984 __experimentalSaveSpecifiedEntityEdits: saveSpecifiedEntityEdits 22985 } = (0, import_data51.useDispatch)(import_core_data36.store); 22986 const { createSuccessNotice, createErrorNotice } = (0, import_data51.useDispatch)(import_notices4.store); 22987 const handleSave = async (navigationMenu, edits) => { 22988 if (!edits) { 22989 return; 22990 } 22991 const postId = navigationMenu?.id; 22992 const originalRecord = getEditedEntityRecord( 22993 "postType", 22994 NAVIGATION_POST_TYPE, 22995 postId 22996 ); 22997 editEntityRecord("postType", postType, postId, edits); 22998 const recordPropertiesToSave = Object.keys(edits); 22999 try { 23000 await saveSpecifiedEntityEdits( 23001 "postType", 23002 postType, 23003 postId, 23004 recordPropertiesToSave, 23005 { 23006 throwOnError: true 23007 } 23008 ); 23009 createSuccessNotice((0, import_i18n79.__)("Renamed Navigation Menu"), { 23010 type: "snackbar" 23011 }); 23012 } catch (error) { 23013 editEntityRecord("postType", postType, postId, originalRecord); 23014 createErrorNotice( 23015 (0, import_i18n79.sprintf)( 23016 /* translators: %s: error message describing why the navigation menu could not be renamed. */ 23017 (0, import_i18n79.__)(`Unable to rename Navigation Menu (%s).`), 23018 error?.message 23019 ), 23020 { 23021 type: "snackbar" 23022 } 23023 ); 23024 } 23025 }; 23026 return handleSave; 23027 } 23028 function useDuplicateNavigationMenu() { 23029 const history = useHistory16(); 23030 const { saveEntityRecord } = (0, import_data51.useDispatch)(import_core_data36.store); 23031 const { createSuccessNotice, createErrorNotice } = (0, import_data51.useDispatch)(import_notices4.store); 23032 const handleDuplicate = async (navigationMenu) => { 23033 const menuTitle = navigationMenu?.title?.rendered || navigationMenu?.slug; 23034 try { 23035 const savedRecord = await saveEntityRecord( 23036 "postType", 23037 postType, 23038 { 23039 title: (0, import_i18n79.sprintf)( 23040 /* translators: %s: Navigation menu title */ 23041 (0, import_i18n79._x)("%s (Copy)", "navigation menu"), 23042 menuTitle 23043 ), 23044 content: navigationMenu?.content?.raw, 23045 status: "publish" 23046 }, 23047 { 23048 throwOnError: true 23049 } 23050 ); 23051 if (savedRecord) { 23052 createSuccessNotice((0, import_i18n79.__)("Duplicated Navigation Menu"), { 23053 type: "snackbar" 23054 }); 23055 history.navigate(`/wp_navigation/$savedRecord.id}`); 23056 } 23057 } catch (error) { 23058 createErrorNotice( 23059 (0, import_i18n79.sprintf)( 23060 /* translators: %s: error message describing why the navigation menu could not be deleted. */ 23061 (0, import_i18n79.__)(`Unable to duplicate Navigation Menu (%s).`), 23062 error?.message 23063 ), 23064 { 23065 type: "snackbar" 23066 } 23067 ); 23068 } 23069 }; 23070 return handleDuplicate; 23071 } 23072 function useNavigationMenuHandlers() { 23073 return { 23074 handleDelete: useDeleteNavigationMenu(), 23075 handleSave: useSaveNavigationMenu(), 23076 handleDuplicate: useDuplicateNavigationMenu() 23077 }; 23078 } 23079 23080 // packages/edit-site/build-module/components/sidebar-navigation-screen-navigation-menus/index.js 23081 var import_jsx_runtime179 = __toESM(require_jsx_runtime()); 23082 function buildMenuLabel(title, id, status) { 23083 if (!title) { 23084 return (0, import_i18n80.sprintf)((0, import_i18n80.__)("(no title %s)"), id); 23085 } 23086 if (status === "publish") { 23087 return (0, import_html_entities8.decodeEntities)(title); 23088 } 23089 return (0, import_i18n80.sprintf)( 23090 // translators: 1: title of the menu. 2: status of the menu (draft, pending, etc.). 23091 (0, import_i18n80._x)("%1$s (%2$s)", "menu label"), 23092 (0, import_html_entities8.decodeEntities)(title), 23093 status 23094 ); 23095 } 23096 function SidebarNavigationScreenNavigationMenus({ backPath }) { 23097 const { 23098 records: navigationMenus, 23099 isResolving: isResolvingNavigationMenus, 23100 hasResolved: hasResolvedNavigationMenus 23101 } = (0, import_core_data37.useEntityRecords)( 23102 "postType", 23103 NAVIGATION_POST_TYPE, 23104 PRELOADED_NAVIGATION_MENUS_QUERY 23105 ); 23106 const isLoading = isResolvingNavigationMenus && !hasResolvedNavigationMenus; 23107 const { getNavigationFallbackId } = unlock((0, import_data52.useSelect)(import_core_data37.store)); 23108 const isCreatingNavigationFallback = (0, import_data52.useSelect)( 23109 (select3) => select3(import_core_data37.store).isResolving("getNavigationFallbackId"), 23110 [] 23111 ); 23112 const firstNavigationMenu = navigationMenus?.[0]; 23113 if (!firstNavigationMenu && !isResolvingNavigationMenus && hasResolvedNavigationMenus && // Ensure a fallback navigation is created only once 23114 !isCreatingNavigationFallback) { 23115 getNavigationFallbackId(); 23116 } 23117 const { handleSave, handleDelete, handleDuplicate } = useNavigationMenuHandlers(); 23118 const hasNavigationMenus = !!navigationMenus?.length; 23119 if (isLoading) { 23120 return /* @__PURE__ */ (0, import_jsx_runtime179.jsx)(SidebarNavigationScreenWrapper, { backPath, children: /* @__PURE__ */ (0, import_jsx_runtime179.jsx)(import_components90.Spinner, { className: "edit-site-sidebar-navigation-screen-navigation-menus__loading" }) }); 23121 } 23122 if (!isLoading && !hasNavigationMenus) { 23123 return /* @__PURE__ */ (0, import_jsx_runtime179.jsx)( 23124 SidebarNavigationScreenWrapper, 23125 { 23126 description: (0, import_i18n80.__)("No Navigation Menus found."), 23127 backPath 23128 } 23129 ); 23130 } 23131 if (navigationMenus?.length === 1) { 23132 return /* @__PURE__ */ (0, import_jsx_runtime179.jsx)( 23133 SingleNavigationMenu, 23134 { 23135 navigationMenu: firstNavigationMenu, 23136 backPath, 23137 handleDelete: () => handleDelete(firstNavigationMenu), 23138 handleDuplicate: () => handleDuplicate(firstNavigationMenu), 23139 handleSave: (edits) => handleSave(firstNavigationMenu, edits) 23140 } 23141 ); 23142 } 23143 return /* @__PURE__ */ (0, import_jsx_runtime179.jsx)(SidebarNavigationScreenWrapper, { backPath, children: /* @__PURE__ */ (0, import_jsx_runtime179.jsx)(import_components90.__experimentalItemGroup, { className: "edit-site-sidebar-navigation-screen-navigation-menus", children: navigationMenus?.map(({ id, title, status }, index) => /* @__PURE__ */ (0, import_jsx_runtime179.jsx)( 23144 NavMenuItem, 23145 { 23146 postId: id, 23147 withChevron: true, 23148 icon: navigation_default, 23149 children: buildMenuLabel(title?.rendered, index + 1, status) 23150 }, 23151 id 23152 )) }) }); 23153 } 23154 function SidebarNavigationScreenWrapper({ 23155 children, 23156 actions, 23157 title, 23158 description, 23159 backPath 23160 }) { 23161 return /* @__PURE__ */ (0, import_jsx_runtime179.jsx)( 23162 SidebarNavigationScreen, 23163 { 23164 title: title || (0, import_i18n80.__)("Navigation"), 23165 actions, 23166 description: description || (0, import_i18n80.__)("Manage your Navigation Menus."), 23167 backPath, 23168 content: children 23169 } 23170 ); 23171 } 23172 var NavMenuItem = ({ postId, ...props }) => { 23173 return /* @__PURE__ */ (0, import_jsx_runtime179.jsx)( 23174 SidebarNavigationItem, 23175 { 23176 to: `/wp_navigation/$postId}`, 23177 ...props 23178 } 23179 ); 23180 }; 23181 23182 // packages/edit-site/build-module/components/site-editor-routes/navigation.js 23183 var import_jsx_runtime180 = __toESM(require_jsx_runtime()); 23184 var { useLocation: useLocation21 } = unlock(import_router24.privateApis); 23185 function MobileNavigationView() { 23186 const { query = {} } = useLocation21(); 23187 const { canvas = "view" } = query; 23188 return canvas === "edit" ? /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(EditSiteEditor, {}) : /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(SidebarNavigationScreenNavigationMenus, { backPath: "/" }); 23189 } 23190 var navigationRoute = { 23191 name: "navigation", 23192 path: "/navigation", 23193 areas: { 23194 sidebar({ siteData }) { 23195 const isBlockTheme = siteData.currentTheme?.is_block_theme; 23196 return isBlockTheme ? /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(SidebarNavigationScreenNavigationMenus, { backPath: "/" }) : /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(SidebarNavigationScreenUnsupported, {}); 23197 }, 23198 preview({ siteData }) { 23199 const isBlockTheme = siteData.currentTheme?.is_block_theme; 23200 return isBlockTheme ? /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(EditSiteEditor, {}) : void 0; 23201 }, 23202 mobile({ siteData }) { 23203 const isBlockTheme = siteData.currentTheme?.is_block_theme; 23204 return isBlockTheme ? /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(MobileNavigationView, {}) : /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(SidebarNavigationScreenUnsupported, {}); 23205 } 23206 } 23207 }; 23208 23209 // packages/edit-site/build-module/components/site-editor-routes/navigation-item.js 23210 var import_router25 = __toESM(require_router()); 23211 var import_jsx_runtime181 = __toESM(require_jsx_runtime()); 23212 var { useLocation: useLocation22 } = unlock(import_router25.privateApis); 23213 function MobileNavigationItemView() { 23214 const { query = {} } = useLocation22(); 23215 const { canvas = "view" } = query; 23216 return canvas === "edit" ? /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(EditSiteEditor, {}) : /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(SidebarNavigationScreenNavigationMenu, { backPath: "/navigation" }); 23217 } 23218 var navigationItemRoute = { 23219 name: "navigation-item", 23220 path: "/wp_navigation/:postId", 23221 areas: { 23222 sidebar({ siteData }) { 23223 const isBlockTheme = siteData.currentTheme?.is_block_theme; 23224 return isBlockTheme ? /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(SidebarNavigationScreenNavigationMenu, { backPath: "/navigation" }) : /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(SidebarNavigationScreenUnsupported, {}); 23225 }, 23226 preview({ siteData }) { 23227 const isBlockTheme = siteData.currentTheme?.is_block_theme; 23228 return isBlockTheme ? /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(EditSiteEditor, {}) : /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(SidebarNavigationScreenUnsupported, {}); 23229 }, 23230 mobile({ siteData }) { 23231 const isBlockTheme = siteData.currentTheme?.is_block_theme; 23232 return isBlockTheme ? /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(MobileNavigationItemView, {}) : /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(SidebarNavigationScreenUnsupported, {}); 23233 } 23234 } 23235 }; 23236 23237 // packages/edit-site/build-module/components/sidebar-navigation-screen-patterns/index.js 23238 var import_components91 = __toESM(require_components()); 23239 var import_editor26 = __toESM(require_editor()); 23240 var import_i18n82 = __toESM(require_i18n()); 23241 var import_router26 = __toESM(require_router()); 23242 23243 // packages/edit-site/build-module/components/sidebar-navigation-screen-patterns/category-item.js 23244 var import_jsx_runtime182 = __toESM(require_jsx_runtime()); 23245 function CategoryItem({ 23246 count, 23247 icon, 23248 id, 23249 isActive, 23250 label, 23251 type 23252 }) { 23253 if (!count) { 23254 return; 23255 } 23256 const queryArgs = [`postType=$type}`]; 23257 if (id) { 23258 queryArgs.push(`categoryId=$id}`); 23259 } 23260 return /* @__PURE__ */ (0, import_jsx_runtime182.jsx)( 23261 SidebarNavigationItem, 23262 { 23263 icon, 23264 suffix: /* @__PURE__ */ (0, import_jsx_runtime182.jsx)("span", { children: count }), 23265 "aria-current": isActive ? "true" : void 0, 23266 to: `/pattern?$queryArgs.join("&")}`, 23267 children: label 23268 } 23269 ); 23270 } 23271 23272 // packages/edit-site/build-module/components/sidebar-navigation-screen-patterns/use-pattern-categories.js 23273 var import_element64 = __toESM(require_element()); 23274 var import_i18n81 = __toESM(require_i18n()); 23275 23276 // packages/edit-site/build-module/components/sidebar-navigation-screen-patterns/use-default-pattern-categories.js 23277 var import_core_data38 = __toESM(require_core_data()); 23278 var import_data53 = __toESM(require_data()); 23279 function useDefaultPatternCategories() { 23280 const blockPatternCategories = (0, import_data53.useSelect)((select3) => { 23281 const { getSettings: getSettings7 } = unlock(select3(store)); 23282 const settings2 = getSettings7(); 23283 return settings2.__experimentalAdditionalBlockPatternCategories ?? settings2.__experimentalBlockPatternCategories; 23284 }); 23285 const restBlockPatternCategories = (0, import_data53.useSelect)( 23286 (select3) => select3(import_core_data38.store).getBlockPatternCategories() 23287 ); 23288 return [ 23289 ...blockPatternCategories || [], 23290 ...restBlockPatternCategories || [] 23291 ]; 23292 } 23293 23294 // packages/edit-site/build-module/components/sidebar-navigation-screen-patterns/use-theme-patterns.js 23295 var import_core_data39 = __toESM(require_core_data()); 23296 var import_data54 = __toESM(require_data()); 23297 var import_element62 = __toESM(require_element()); 23298 23299 // packages/edit-site/build-module/components/page-patterns/utils.js 23300 var filterOutDuplicatesByName = (currentItem, index, items) => index === items.findIndex((item) => currentItem.name === item.name); 23301 23302 // packages/edit-site/build-module/components/sidebar-navigation-screen-patterns/use-theme-patterns.js 23303 function useThemePatterns() { 23304 const blockPatterns = (0, import_data54.useSelect)((select3) => { 23305 const { getSettings: getSettings7 } = unlock(select3(store)); 23306 return getSettings7().__experimentalAdditionalBlockPatterns ?? getSettings7().__experimentalBlockPatterns; 23307 }); 23308 const restBlockPatterns = (0, import_data54.useSelect)( 23309 (select3) => select3(import_core_data39.store).getBlockPatterns() 23310 ); 23311 const patterns = (0, import_element62.useMemo)( 23312 () => [...blockPatterns || [], ...restBlockPatterns || []].filter( 23313 (pattern) => !EXCLUDED_PATTERN_SOURCES.includes(pattern.source) 23314 ).filter(filterOutDuplicatesByName).filter((pattern) => pattern.inserter !== false), 23315 [blockPatterns, restBlockPatterns] 23316 ); 23317 return patterns; 23318 } 23319 23320 // packages/edit-site/build-module/components/page-patterns/use-patterns.js 23321 var import_blocks11 = __toESM(require_blocks()); 23322 var import_data55 = __toESM(require_data()); 23323 var import_core_data40 = __toESM(require_core_data()); 23324 var import_element63 = __toESM(require_element()); 23325 23326 // packages/edit-site/build-module/components/page-patterns/search-items.js 23327 var import_block_editor22 = __toESM(require_block_editor()); 23328 var { extractWords, getNormalizedSearchTerms, normalizeString } = unlock( 23329 import_block_editor22.privateApis 23330 ); 23331 var defaultGetName = (item) => { 23332 if (item.type === PATTERN_TYPES.user) { 23333 return item.slug; 23334 } 23335 if (item.type === TEMPLATE_PART_POST_TYPE) { 23336 return ""; 23337 } 23338 return item.name || ""; 23339 }; 23340 var defaultGetTitle = (item) => { 23341 if (typeof item.title === "string") { 23342 return item.title; 23343 } 23344 if (item.title && item.title.rendered) { 23345 return item.title.rendered; 23346 } 23347 if (item.title && item.title.raw) { 23348 return item.title.raw; 23349 } 23350 return ""; 23351 }; 23352 var defaultGetDescription = (item) => { 23353 if (item.type === PATTERN_TYPES.user) { 23354 return item.excerpt.raw; 23355 } 23356 return item.description || ""; 23357 }; 23358 var defaultGetKeywords = (item) => item.keywords || []; 23359 var defaultHasCategory = () => false; 23360 var removeMatchingTerms = (unmatchedTerms, unprocessedTerms) => { 23361 return unmatchedTerms.filter( 23362 (term) => !getNormalizedSearchTerms(unprocessedTerms).some( 23363 (unprocessedTerm) => unprocessedTerm.includes(term) 23364 ) 23365 ); 23366 }; 23367 var searchItems = (items = [], searchInput = "", config2 = {}) => { 23368 const normalizedSearchTerms = getNormalizedSearchTerms(searchInput); 23369 const onlyFilterByCategory = config2.categoryId !== PATTERN_DEFAULT_CATEGORY && !normalizedSearchTerms.length; 23370 const searchRankConfig = { ...config2, onlyFilterByCategory }; 23371 const threshold = onlyFilterByCategory ? 0 : 1; 23372 const rankedItems = items.map((item) => { 23373 return [ 23374 item, 23375 getItemSearchRank(item, searchInput, searchRankConfig) 23376 ]; 23377 }).filter(([, rank]) => rank > threshold); 23378 if (normalizedSearchTerms.length === 0) { 23379 return rankedItems.map(([item]) => item); 23380 } 23381 rankedItems.sort(([, rank1], [, rank2]) => rank2 - rank1); 23382 return rankedItems.map(([item]) => item); 23383 }; 23384 function getItemSearchRank(item, searchTerm, config2) { 23385 const { 23386 categoryId, 23387 getName = defaultGetName, 23388 getTitle = defaultGetTitle, 23389 getDescription = defaultGetDescription, 23390 getKeywords = defaultGetKeywords, 23391 hasCategory = defaultHasCategory, 23392 onlyFilterByCategory 23393 } = config2; 23394 let rank = categoryId === PATTERN_DEFAULT_CATEGORY || categoryId === TEMPLATE_PART_ALL_AREAS_CATEGORY || categoryId === PATTERN_USER_CATEGORY && item.type === PATTERN_TYPES.user || hasCategory(item, categoryId) ? 1 : 0; 23395 if (!rank || onlyFilterByCategory) { 23396 return rank; 23397 } 23398 const name2 = getName(item); 23399 const title = getTitle(item); 23400 const description = getDescription(item); 23401 const keywords = getKeywords(item); 23402 const normalizedSearchInput = normalizeString(searchTerm); 23403 const normalizedTitle = normalizeString(title); 23404 if (normalizedSearchInput === normalizedTitle) { 23405 rank += 30; 23406 } else if (normalizedTitle.startsWith(normalizedSearchInput)) { 23407 rank += 20; 23408 } else { 23409 const terms = [name2, title, description, ...keywords].join(" "); 23410 const normalizedSearchTerms = extractWords(normalizedSearchInput); 23411 const unmatchedTerms = removeMatchingTerms( 23412 normalizedSearchTerms, 23413 terms 23414 ); 23415 if (unmatchedTerms.length === 0) { 23416 rank += 10; 23417 } 23418 } 23419 return rank; 23420 } 23421 23422 // packages/edit-site/build-module/components/page-patterns/use-patterns.js 23423 var EMPTY_PATTERN_LIST = []; 23424 var selectTemplateParts = (0, import_data55.createSelector)( 23425 (select3, categoryId, search = "") => { 23426 const { 23427 getEntityRecords, 23428 getCurrentTheme, 23429 isResolving: isResolvingSelector 23430 } = select3(import_core_data40.store); 23431 const query = { per_page: -1 }; 23432 const templateParts = getEntityRecords("postType", TEMPLATE_PART_POST_TYPE, query) ?? EMPTY_PATTERN_LIST; 23433 const knownAreas = getCurrentTheme()?.default_template_part_areas || []; 23434 const templatePartAreas = knownAreas.map((area) => area.area); 23435 const templatePartHasCategory = (item, category) => { 23436 if (category !== TEMPLATE_PART_AREA_DEFAULT_CATEGORY) { 23437 return item.area === category; 23438 } 23439 return item.area === category || !templatePartAreas.includes(item.area); 23440 }; 23441 const isResolving = isResolvingSelector("getEntityRecords", [ 23442 "postType", 23443 TEMPLATE_PART_POST_TYPE, 23444 query 23445 ]); 23446 const patterns = searchItems(templateParts, search, { 23447 categoryId, 23448 hasCategory: templatePartHasCategory 23449 }); 23450 return { patterns, isResolving }; 23451 }, 23452 (select3) => [ 23453 select3(import_core_data40.store).getEntityRecords( 23454 "postType", 23455 TEMPLATE_PART_POST_TYPE, 23456 { 23457 per_page: -1 23458 } 23459 ), 23460 select3(import_core_data40.store).isResolving("getEntityRecords", [ 23461 "postType", 23462 TEMPLATE_PART_POST_TYPE, 23463 { per_page: -1 } 23464 ]), 23465 select3(import_core_data40.store).getCurrentTheme()?.default_template_part_areas 23466 ] 23467 ); 23468 var selectThemePatterns = (0, import_data55.createSelector)( 23469 (select3) => { 23470 const { getSettings: getSettings7 } = unlock(select3(store)); 23471 const { isResolving: isResolvingSelector } = select3(import_core_data40.store); 23472 const settings2 = getSettings7(); 23473 const blockPatterns = settings2.__experimentalAdditionalBlockPatterns ?? settings2.__experimentalBlockPatterns; 23474 const restBlockPatterns = select3(import_core_data40.store).getBlockPatterns(); 23475 const patterns = [ 23476 ...blockPatterns || [], 23477 ...restBlockPatterns || [] 23478 ].filter( 23479 (pattern) => !EXCLUDED_PATTERN_SOURCES.includes(pattern.source) 23480 ).filter(filterOutDuplicatesByName).filter((pattern) => pattern.inserter !== false).map((pattern) => ({ 23481 ...pattern, 23482 keywords: pattern.keywords || [], 23483 type: PATTERN_TYPES.theme, 23484 blocks: (0, import_blocks11.parse)(pattern.content, { 23485 __unstableSkipMigrationLogs: true 23486 }) 23487 })); 23488 return { 23489 patterns, 23490 isResolving: isResolvingSelector("getBlockPatterns") 23491 }; 23492 }, 23493 (select3) => [ 23494 select3(import_core_data40.store).getBlockPatterns(), 23495 select3(import_core_data40.store).isResolving("getBlockPatterns"), 23496 unlock(select3(store)).getSettings() 23497 ] 23498 ); 23499 var selectPatterns = (0, import_data55.createSelector)( 23500 (select3, categoryId, syncStatus, search = "") => { 23501 const { 23502 patterns: themePatterns, 23503 isResolving: isResolvingThemePatterns 23504 } = selectThemePatterns(select3); 23505 const { 23506 patterns: userPatterns, 23507 isResolving: isResolvingUserPatterns, 23508 categories: userPatternCategories 23509 } = selectUserPatterns(select3); 23510 let patterns = [ 23511 ...themePatterns || [], 23512 ...userPatterns || [] 23513 ]; 23514 if (syncStatus) { 23515 patterns = patterns.filter((pattern) => { 23516 return pattern.type === PATTERN_TYPES.user ? (pattern.wp_pattern_sync_status || PATTERN_SYNC_TYPES.full) === syncStatus : syncStatus === PATTERN_SYNC_TYPES.unsynced; 23517 }); 23518 } 23519 if (categoryId) { 23520 patterns = searchItems(patterns, search, { 23521 categoryId, 23522 hasCategory: (item, currentCategory) => { 23523 if (item.type === PATTERN_TYPES.user) { 23524 return item.wp_pattern_category?.some( 23525 (catId) => userPatternCategories.find( 23526 (cat) => cat.id === catId 23527 )?.slug === currentCategory 23528 ); 23529 } 23530 return item.categories?.includes(currentCategory); 23531 } 23532 }); 23533 } else { 23534 patterns = searchItems(patterns, search, { 23535 hasCategory: (item) => { 23536 if (item.type === PATTERN_TYPES.user) { 23537 return userPatternCategories?.length && (!item.wp_pattern_category?.length || !item.wp_pattern_category?.some( 23538 (catId) => userPatternCategories.find( 23539 (cat) => cat.id === catId 23540 ) 23541 )); 23542 } 23543 return !item.hasOwnProperty("categories"); 23544 } 23545 }); 23546 } 23547 return { 23548 patterns, 23549 isResolving: isResolvingThemePatterns || isResolvingUserPatterns 23550 }; 23551 }, 23552 (select3) => [ 23553 selectThemePatterns(select3), 23554 selectUserPatterns(select3) 23555 ] 23556 ); 23557 var selectUserPatterns = (0, import_data55.createSelector)( 23558 (select3, syncStatus, search = "") => { 23559 const { 23560 getEntityRecords, 23561 isResolving: isResolvingSelector, 23562 getUserPatternCategories 23563 } = select3(import_core_data40.store); 23564 const query = { per_page: -1 }; 23565 const patternPosts = getEntityRecords( 23566 "postType", 23567 PATTERN_TYPES.user, 23568 query 23569 ); 23570 const userPatternCategories = getUserPatternCategories(); 23571 const categories = /* @__PURE__ */ new Map(); 23572 userPatternCategories.forEach( 23573 (userCategory) => categories.set(userCategory.id, userCategory) 23574 ); 23575 let patterns = patternPosts ?? EMPTY_PATTERN_LIST; 23576 const isResolving = isResolvingSelector("getEntityRecords", [ 23577 "postType", 23578 PATTERN_TYPES.user, 23579 query 23580 ]); 23581 if (syncStatus) { 23582 patterns = patterns.filter( 23583 (pattern) => pattern.wp_pattern_sync_status || PATTERN_SYNC_TYPES.full === syncStatus 23584 ); 23585 } 23586 patterns = searchItems(patterns, search, { 23587 // We exit user pattern retrieval early if we aren't in the 23588 // catch-all category for user created patterns, so it has 23589 // to be in the category. 23590 hasCategory: () => true 23591 }); 23592 return { 23593 patterns, 23594 isResolving, 23595 categories: userPatternCategories 23596 }; 23597 }, 23598 (select3) => [ 23599 select3(import_core_data40.store).getEntityRecords("postType", PATTERN_TYPES.user, { 23600 per_page: -1 23601 }), 23602 select3(import_core_data40.store).isResolving("getEntityRecords", [ 23603 "postType", 23604 PATTERN_TYPES.user, 23605 { per_page: -1 } 23606 ]), 23607 select3(import_core_data40.store).getUserPatternCategories() 23608 ] 23609 ); 23610 function useAugmentPatternsWithPermissions(patterns) { 23611 const idsAndTypes = (0, import_element63.useMemo)( 23612 () => patterns?.filter((record) => record.type !== PATTERN_TYPES.theme).map((record) => [record.type, record.id]) ?? [], 23613 [patterns] 23614 ); 23615 const permissions = (0, import_data55.useSelect)( 23616 (select3) => { 23617 const { getEntityRecordPermissions } = unlock( 23618 select3(import_core_data40.store) 23619 ); 23620 return idsAndTypes.reduce((acc, [type, id]) => { 23621 acc[id] = getEntityRecordPermissions("postType", type, id); 23622 return acc; 23623 }, {}); 23624 }, 23625 [idsAndTypes] 23626 ); 23627 return (0, import_element63.useMemo)( 23628 () => patterns?.map((record) => ({ 23629 ...record, 23630 permissions: permissions?.[record.id] ?? {} 23631 })) ?? [], 23632 [patterns, permissions] 23633 ); 23634 } 23635 var usePatterns = (postType2, categoryId, { search = "", syncStatus } = {}) => { 23636 return (0, import_data55.useSelect)( 23637 (select3) => { 23638 if (postType2 === TEMPLATE_PART_POST_TYPE) { 23639 return selectTemplateParts(select3, categoryId, search); 23640 } else if (postType2 === PATTERN_TYPES.user && !!categoryId) { 23641 const appliedCategory = categoryId === "uncategorized" ? "" : categoryId; 23642 return selectPatterns( 23643 select3, 23644 appliedCategory, 23645 syncStatus, 23646 search 23647 ); 23648 } else if (postType2 === PATTERN_TYPES.user) { 23649 return selectUserPatterns(select3, syncStatus, search); 23650 } 23651 return { 23652 patterns: EMPTY_PATTERN_LIST, 23653 isResolving: false 23654 }; 23655 }, 23656 [categoryId, postType2, search, syncStatus] 23657 ); 23658 }; 23659 var use_patterns_default = usePatterns; 23660 23661 // packages/edit-site/build-module/components/sidebar-navigation-screen-patterns/use-pattern-categories.js 23662 function usePatternCategories() { 23663 const defaultCategories = useDefaultPatternCategories(); 23664 defaultCategories.push({ 23665 name: TEMPLATE_PART_AREA_DEFAULT_CATEGORY, 23666 label: (0, import_i18n81.__)("Uncategorized") 23667 }); 23668 const themePatterns = useThemePatterns(); 23669 const { patterns: userPatterns, categories: userPatternCategories } = use_patterns_default(PATTERN_TYPES.user); 23670 const patternCategories = (0, import_element64.useMemo)(() => { 23671 const categoryMap = {}; 23672 const categoriesWithCounts = []; 23673 defaultCategories.forEach((category) => { 23674 if (!categoryMap[category.name]) { 23675 categoryMap[category.name] = { ...category, count: 0 }; 23676 } 23677 }); 23678 userPatternCategories.forEach((category) => { 23679 if (!categoryMap[category.name]) { 23680 categoryMap[category.name] = { ...category, count: 0 }; 23681 } 23682 }); 23683 themePatterns.forEach((pattern) => { 23684 pattern.categories?.forEach((category) => { 23685 if (categoryMap[category]) { 23686 categoryMap[category].count += 1; 23687 } 23688 }); 23689 if (!pattern.categories?.length) { 23690 categoryMap.uncategorized.count += 1; 23691 } 23692 }); 23693 userPatterns.forEach((pattern) => { 23694 pattern.wp_pattern_category?.forEach((catId) => { 23695 const category = userPatternCategories.find( 23696 (cat) => cat.id === catId 23697 )?.name; 23698 if (categoryMap[category]) { 23699 categoryMap[category].count += 1; 23700 } 23701 }); 23702 if (!pattern.wp_pattern_category?.length || !pattern.wp_pattern_category?.some( 23703 (catId) => userPatternCategories.find((cat) => cat.id === catId) 23704 )) { 23705 categoryMap.uncategorized.count += 1; 23706 } 23707 }); 23708 [...defaultCategories, ...userPatternCategories].forEach( 23709 (category) => { 23710 if (categoryMap[category.name].count && !categoriesWithCounts.find( 23711 (cat) => cat.name === category.name 23712 )) { 23713 categoriesWithCounts.push(categoryMap[category.name]); 23714 } 23715 } 23716 ); 23717 const sortedCategories = categoriesWithCounts.sort( 23718 (a2, b2) => a2.label.localeCompare(b2.label) 23719 ); 23720 sortedCategories.unshift({ 23721 name: PATTERN_USER_CATEGORY, 23722 label: (0, import_i18n81.__)("My patterns"), 23723 count: userPatterns.length 23724 }); 23725 sortedCategories.unshift({ 23726 name: PATTERN_DEFAULT_CATEGORY, 23727 label: (0, import_i18n81.__)("All patterns"), 23728 description: (0, import_i18n81.__)("A list of all patterns from all sources."), 23729 count: themePatterns.length + userPatterns.length 23730 }); 23731 return sortedCategories; 23732 }, [ 23733 defaultCategories, 23734 themePatterns, 23735 userPatternCategories, 23736 userPatterns 23737 ]); 23738 return { patternCategories, hasPatterns: !!patternCategories.length }; 23739 } 23740 23741 // packages/edit-site/build-module/components/sidebar-navigation-screen-patterns/use-template-part-areas.js 23742 var import_core_data41 = __toESM(require_core_data()); 23743 var import_data56 = __toESM(require_data()); 23744 var useTemplatePartsGroupedByArea = (items) => { 23745 const allItems = items || []; 23746 const templatePartAreas = (0, import_data56.useSelect)( 23747 (select3) => select3(import_core_data41.store).getCurrentTheme()?.default_template_part_areas || [], 23748 [] 23749 ); 23750 const knownAreas = { 23751 header: {}, 23752 footer: {}, 23753 sidebar: {}, 23754 uncategorized: {}, 23755 overlay: {} 23756 }; 23757 templatePartAreas.forEach( 23758 (templatePartArea) => knownAreas[templatePartArea.area] = { 23759 ...templatePartArea, 23760 templateParts: [] 23761 } 23762 ); 23763 const groupedByArea = allItems.reduce((accumulator, item) => { 23764 const key = accumulator[item.area] ? item.area : TEMPLATE_PART_AREA_DEFAULT_CATEGORY; 23765 accumulator[key]?.templateParts?.push(item); 23766 return accumulator; 23767 }, knownAreas); 23768 return groupedByArea; 23769 }; 23770 function useTemplatePartAreas() { 23771 const { records: templateParts, isResolving: isLoading } = (0, import_core_data41.useEntityRecords)( 23772 "postType", 23773 TEMPLATE_PART_POST_TYPE, 23774 { per_page: -1 } 23775 ); 23776 return { 23777 hasTemplateParts: templateParts ? !!templateParts.length : false, 23778 isLoading, 23779 templatePartAreas: useTemplatePartsGroupedByArea(templateParts) 23780 }; 23781 } 23782 23783 // packages/edit-site/build-module/components/sidebar-navigation-screen-patterns/index.js 23784 var import_jsx_runtime183 = __toESM(require_jsx_runtime()); 23785 var { useLocation: useLocation23 } = unlock(import_router26.privateApis); 23786 function CategoriesGroup({ 23787 templatePartAreas, 23788 patternCategories, 23789 currentCategory, 23790 currentType 23791 }) { 23792 const [allPatterns, ...otherPatterns] = patternCategories; 23793 return /* @__PURE__ */ (0, import_jsx_runtime183.jsxs)(import_components91.__experimentalItemGroup, { className: "edit-site-sidebar-navigation-screen-patterns__group", children: [ 23794 /* @__PURE__ */ (0, import_jsx_runtime183.jsx)( 23795 CategoryItem, 23796 { 23797 count: Object.values(templatePartAreas).map(({ templateParts }) => templateParts?.length || 0).reduce((acc, val) => acc + val, 0), 23798 icon: (0, import_editor26.getTemplatePartIcon)(), 23799 label: (0, import_i18n82.__)("All template parts"), 23800 id: TEMPLATE_PART_ALL_AREAS_CATEGORY, 23801 type: TEMPLATE_PART_POST_TYPE, 23802 isActive: currentCategory === TEMPLATE_PART_ALL_AREAS_CATEGORY && currentType === TEMPLATE_PART_POST_TYPE 23803 }, 23804 "all" 23805 ), 23806 Object.entries(templatePartAreas).map( 23807 ([area, { label, templateParts }]) => /* @__PURE__ */ (0, import_jsx_runtime183.jsx)( 23808 CategoryItem, 23809 { 23810 count: templateParts?.length, 23811 icon: (0, import_editor26.getTemplatePartIcon)(area), 23812 label, 23813 id: area, 23814 type: TEMPLATE_PART_POST_TYPE, 23815 isActive: currentCategory === area && currentType === TEMPLATE_PART_POST_TYPE 23816 }, 23817 area 23818 ) 23819 ), 23820 /* @__PURE__ */ (0, import_jsx_runtime183.jsx)("div", { className: "edit-site-sidebar-navigation-screen-patterns__divider" }), 23821 allPatterns && /* @__PURE__ */ (0, import_jsx_runtime183.jsx)( 23822 CategoryItem, 23823 { 23824 count: allPatterns.count, 23825 label: allPatterns.label, 23826 icon: file_default, 23827 id: allPatterns.name, 23828 type: PATTERN_TYPES.user, 23829 isActive: currentCategory === `$allPatterns.name}` && currentType === PATTERN_TYPES.user 23830 }, 23831 allPatterns.name 23832 ), 23833 otherPatterns.map((category) => /* @__PURE__ */ (0, import_jsx_runtime183.jsx)( 23834 CategoryItem, 23835 { 23836 count: category.count, 23837 label: category.label, 23838 icon: file_default, 23839 id: category.name, 23840 type: PATTERN_TYPES.user, 23841 isActive: currentCategory === `$category.name}` && currentType === PATTERN_TYPES.user 23842 }, 23843 category.name 23844 )) 23845 ] }); 23846 } 23847 function SidebarNavigationScreenPatterns({ backPath }) { 23848 const { 23849 query: { postType: postType2 = "wp_block", categoryId } 23850 } = useLocation23(); 23851 const currentCategory = categoryId || (postType2 === PATTERN_TYPES.user ? PATTERN_DEFAULT_CATEGORY : TEMPLATE_PART_ALL_AREAS_CATEGORY); 23852 const { templatePartAreas, hasTemplateParts, isLoading } = useTemplatePartAreas(); 23853 const { patternCategories, hasPatterns } = usePatternCategories(); 23854 return /* @__PURE__ */ (0, import_jsx_runtime183.jsx)( 23855 SidebarNavigationScreen, 23856 { 23857 title: (0, import_i18n82.__)("Patterns"), 23858 description: (0, import_i18n82.__)( 23859 "Manage what patterns are available when editing the site." 23860 ), 23861 isRoot: !backPath, 23862 backPath, 23863 content: /* @__PURE__ */ (0, import_jsx_runtime183.jsxs)(import_jsx_runtime183.Fragment, { children: [ 23864 isLoading && (0, import_i18n82.__)("Loading items\u2026"), 23865 !isLoading && /* @__PURE__ */ (0, import_jsx_runtime183.jsxs)(import_jsx_runtime183.Fragment, { children: [ 23866 !hasTemplateParts && !hasPatterns && /* @__PURE__ */ (0, import_jsx_runtime183.jsx)(import_components91.__experimentalItemGroup, { className: "edit-site-sidebar-navigation-screen-patterns__group", children: /* @__PURE__ */ (0, import_jsx_runtime183.jsx)(import_components91.__experimentalItem, { children: (0, import_i18n82.__)("No items found") }) }), 23867 /* @__PURE__ */ (0, import_jsx_runtime183.jsx)( 23868 CategoriesGroup, 23869 { 23870 templatePartAreas, 23871 patternCategories, 23872 currentCategory, 23873 currentType: postType2 23874 } 23875 ) 23876 ] }) 23877 ] }) 23878 } 23879 ); 23880 } 23881 23882 // packages/edit-site/build-module/components/page-patterns/index.js 23883 var import_i18n135 = __toESM(require_i18n()); 23884 var import_element133 = __toESM(require_element()); 23885 var import_block_editor24 = __toESM(require_block_editor()); 23886 23887 // packages/dataviews/build-module/components/dataviews/index.js 23888 var import_components140 = __toESM(require_components()); 23889 var import_element115 = __toESM(require_element()); 23890 var import_compose22 = __toESM(require_compose()); 23891 23892 // packages/dataviews/build-module/components/dataviews-context/index.js 23893 var import_element65 = __toESM(require_element()); 23894 23895 // packages/dataviews/build-module/constants.js 23896 var import_i18n83 = __toESM(require_i18n()); 23897 var OPERATOR_IS_ANY2 = "isAny"; 23898 var OPERATOR_IS_NONE2 = "isNone"; 23899 var OPERATOR_IS_ALL = "isAll"; 23900 var OPERATOR_IS_NOT_ALL = "isNotAll"; 23901 var OPERATOR_BETWEEN = "between"; 23902 var OPERATOR_IN_THE_PAST = "inThePast"; 23903 var OPERATOR_OVER = "over"; 23904 var OPERATOR_IS2 = "is"; 23905 var OPERATOR_IS_NOT = "isNot"; 23906 var OPERATOR_LESS_THAN = "lessThan"; 23907 var OPERATOR_GREATER_THAN = "greaterThan"; 23908 var OPERATOR_LESS_THAN_OR_EQUAL = "lessThanOrEqual"; 23909 var OPERATOR_GREATER_THAN_OR_EQUAL = "greaterThanOrEqual"; 23910 var OPERATOR_BEFORE2 = "before"; 23911 var OPERATOR_AFTER2 = "after"; 23912 var OPERATOR_BEFORE_INC = "beforeInc"; 23913 var OPERATOR_AFTER_INC = "afterInc"; 23914 var OPERATOR_CONTAINS = "contains"; 23915 var OPERATOR_NOT_CONTAINS = "notContains"; 23916 var OPERATOR_STARTS_WITH = "startsWith"; 23917 var OPERATOR_ON = "on"; 23918 var OPERATOR_NOT_ON = "notOn"; 23919 var SORTING_DIRECTIONS = ["asc", "desc"]; 23920 var sortArrows = { asc: "\u2191", desc: "\u2193" }; 23921 var sortValues = { asc: "ascending", desc: "descending" }; 23922 var sortLabels = { 23923 asc: (0, import_i18n83.__)("Sort ascending"), 23924 desc: (0, import_i18n83.__)("Sort descending") 23925 }; 23926 var sortIcons = { 23927 asc: arrow_up_default, 23928 desc: arrow_down_default 23929 }; 23930 var LAYOUT_TABLE2 = "table"; 23931 var LAYOUT_GRID2 = "grid"; 23932 var LAYOUT_LIST2 = "list"; 23933 var LAYOUT_ACTIVITY = "activity"; 23934 var LAYOUT_PICKER_GRID = "pickerGrid"; 23935 var LAYOUT_PICKER_TABLE = "pickerTable"; 23936 23937 // packages/dataviews/build-module/components/dataviews-context/index.js 23938 var DataViewsContext = (0, import_element65.createContext)({ 23939 view: { type: LAYOUT_TABLE2 }, 23940 onChangeView: () => { 23941 }, 23942 fields: [], 23943 data: [], 23944 paginationInfo: { 23945 totalItems: 0, 23946 totalPages: 0 23947 }, 23948 selection: [], 23949 onChangeSelection: () => { 23950 }, 23951 setOpenedFilter: () => { 23952 }, 23953 openedFilter: null, 23954 getItemId: (item) => item.id, 23955 isItemClickable: () => true, 23956 renderItemLink: void 0, 23957 containerWidth: 0, 23958 containerRef: (0, import_element65.createRef)(), 23959 resizeObserverRef: () => { 23960 }, 23961 defaultLayouts: { list: {}, grid: {}, table: {} }, 23962 filters: [], 23963 isShowingFilter: false, 23964 setIsShowingFilter: () => { 23965 }, 23966 hasInfiniteScrollHandler: false, 23967 config: { 23968 perPageSizes: [] 23969 } 23970 }); 23971 DataViewsContext.displayName = "DataViewsContext"; 23972 var dataviews_context_default = DataViewsContext; 23973 23974 // packages/dataviews/build-module/dataviews-layouts/index.js 23975 var import_i18n102 = __toESM(require_i18n()); 23976 23977 // packages/dataviews/build-module/dataviews-layouts/table/index.js 23978 var import_i18n90 = __toESM(require_i18n()); 23979 var import_components98 = __toESM(require_components()); 23980 var import_element72 = __toESM(require_element()); 23981 var import_keycodes6 = __toESM(require_keycodes()); 23982 23983 // packages/dataviews/build-module/components/dataviews-selection-checkbox/index.js 23984 var import_components92 = __toESM(require_components()); 23985 var import_i18n84 = __toESM(require_i18n()); 23986 var import_jsx_runtime184 = __toESM(require_jsx_runtime()); 23987 function DataViewsSelectionCheckbox({ 23988 selection, 23989 onChangeSelection, 23990 item, 23991 getItemId: getItemId2, 23992 titleField, 23993 disabled, 23994 ...extraProps 23995 }) { 23996 const id = getItemId2(item); 23997 const checked = !disabled && selection.includes(id); 23998 const selectionLabel = titleField?.getValue?.({ item }) || (0, import_i18n84.__)("(no title)"); 23999 return /* @__PURE__ */ (0, import_jsx_runtime184.jsx)( 24000 import_components92.CheckboxControl, 24001 { 24002 className: "dataviews-selection-checkbox", 24003 "aria-label": selectionLabel, 24004 "aria-disabled": disabled, 24005 checked, 24006 onChange: () => { 24007 if (disabled) { 24008 return; 24009 } 24010 onChangeSelection( 24011 selection.includes(id) ? selection.filter((itemId) => id !== itemId) : [...selection, id] 24012 ); 24013 }, 24014 ...extraProps 24015 } 24016 ); 24017 } 24018 24019 // packages/dataviews/build-module/components/dataviews-item-actions/index.js 24020 var import_components93 = __toESM(require_components()); 24021 var import_i18n85 = __toESM(require_i18n()); 24022 var import_element66 = __toESM(require_element()); 24023 var import_data57 = __toESM(require_data()); 24024 var import_compose12 = __toESM(require_compose()); 24025 24026 // packages/dataviews/build-module/lock-unlock.js 24027 var import_private_apis3 = __toESM(require_private_apis()); 24028 var { lock: lock3, unlock: unlock3 } = (0, import_private_apis3.__dangerousOptInToUnstableAPIsOnlyForCoreModules)( 24029 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.", 24030 "@wordpress/dataviews" 24031 ); 24032 24033 // packages/dataviews/build-module/components/dataviews-item-actions/index.js 24034 var import_jsx_runtime185 = __toESM(require_jsx_runtime()); 24035 var { Menu: Menu5, kebabCase: kebabCase4 } = unlock3(import_components93.privateApis); 24036 function ButtonTrigger({ 24037 action, 24038 onClick, 24039 items, 24040 variant 24041 }) { 24042 const label = typeof action.label === "string" ? action.label : action.label(items); 24043 return /* @__PURE__ */ (0, import_jsx_runtime185.jsx)( 24044 import_components93.Button, 24045 { 24046 disabled: !!action.disabled, 24047 accessibleWhenDisabled: true, 24048 size: "compact", 24049 variant, 24050 onClick, 24051 children: label 24052 } 24053 ); 24054 } 24055 function MenuItemTrigger({ 24056 action, 24057 onClick, 24058 items 24059 }) { 24060 const label = typeof action.label === "string" ? action.label : action.label(items); 24061 return /* @__PURE__ */ (0, import_jsx_runtime185.jsx)(Menu5.Item, { disabled: action.disabled, onClick, children: /* @__PURE__ */ (0, import_jsx_runtime185.jsx)(Menu5.ItemLabel, { children: label }) }); 24062 } 24063 function ActionModal({ 24064 action, 24065 items, 24066 closeModal 24067 }) { 24068 const label = typeof action.label === "string" ? action.label : action.label(items); 24069 const modalHeader = typeof action.modalHeader === "function" ? action.modalHeader(items) : action.modalHeader; 24070 return /* @__PURE__ */ (0, import_jsx_runtime185.jsx)( 24071 import_components93.Modal, 24072 { 24073 title: modalHeader || label, 24074 __experimentalHideHeader: !!action.hideModalHeader, 24075 onRequestClose: closeModal, 24076 focusOnMount: action.modalFocusOnMount ?? true, 24077 size: action.modalSize || "medium", 24078 overlayClassName: `dataviews-action-modal dataviews-action-modal__$kebabCase4( 24079 action.id 24080 )}`, 24081 children: /* @__PURE__ */ (0, import_jsx_runtime185.jsx)(action.RenderModal, { items, closeModal }) 24082 } 24083 ); 24084 } 24085 function ActionsMenuGroup({ 24086 actions, 24087 item, 24088 registry, 24089 setActiveModalAction 24090 }) { 24091 const { primaryActions, regularActions } = (0, import_element66.useMemo)(() => { 24092 return actions.reduce( 24093 (acc, action) => { 24094 (action.isPrimary ? acc.primaryActions : acc.regularActions).push(action); 24095 return acc; 24096 }, 24097 { 24098 primaryActions: [], 24099 regularActions: [] 24100 } 24101 ); 24102 }, [actions]); 24103 const renderActionGroup = (actionList) => actionList.map((action) => /* @__PURE__ */ (0, import_jsx_runtime185.jsx)( 24104 MenuItemTrigger, 24105 { 24106 action, 24107 onClick: () => { 24108 if ("RenderModal" in action) { 24109 setActiveModalAction(action); 24110 return; 24111 } 24112 action.callback([item], { registry }); 24113 }, 24114 items: [item] 24115 }, 24116 action.id 24117 )); 24118 return /* @__PURE__ */ (0, import_jsx_runtime185.jsxs)(Menu5.Group, { children: [ 24119 renderActionGroup(primaryActions), 24120 primaryActions.length > 0 && regularActions.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime185.jsx)(Menu5.Separator, {}), 24121 renderActionGroup(regularActions) 24122 ] }); 24123 } 24124 function ItemActions({ 24125 item, 24126 actions, 24127 isCompact 24128 }) { 24129 const registry = (0, import_data57.useRegistry)(); 24130 const { primaryActions, eligibleActions } = (0, import_element66.useMemo)(() => { 24131 const _eligibleActions = actions.filter( 24132 (action) => !action.isEligible || action.isEligible(item) 24133 ); 24134 const _primaryActions = _eligibleActions.filter( 24135 (action) => action.isPrimary 24136 ); 24137 return { 24138 primaryActions: _primaryActions, 24139 eligibleActions: _eligibleActions 24140 }; 24141 }, [actions, item]); 24142 if (isCompact) { 24143 return /* @__PURE__ */ (0, import_jsx_runtime185.jsx)( 24144 CompactItemActions, 24145 { 24146 item, 24147 actions: eligibleActions, 24148 isSmall: true, 24149 registry 24150 } 24151 ); 24152 } 24153 return /* @__PURE__ */ (0, import_jsx_runtime185.jsxs)( 24154 import_components93.__experimentalHStack, 24155 { 24156 spacing: 0, 24157 justify: "flex-end", 24158 className: "dataviews-item-actions", 24159 style: { 24160 flexShrink: 0, 24161 width: "auto" 24162 }, 24163 children: [ 24164 /* @__PURE__ */ (0, import_jsx_runtime185.jsx)( 24165 PrimaryActions, 24166 { 24167 item, 24168 actions: primaryActions, 24169 registry 24170 } 24171 ), 24172 primaryActions.length < eligibleActions.length && /* @__PURE__ */ (0, import_jsx_runtime185.jsx)( 24173 CompactItemActions, 24174 { 24175 item, 24176 actions: eligibleActions, 24177 registry 24178 } 24179 ) 24180 ] 24181 } 24182 ); 24183 } 24184 function CompactItemActions({ 24185 item, 24186 actions, 24187 isSmall, 24188 registry 24189 }) { 24190 const [activeModalAction, setActiveModalAction] = (0, import_element66.useState)( 24191 null 24192 ); 24193 return /* @__PURE__ */ (0, import_jsx_runtime185.jsxs)(import_jsx_runtime185.Fragment, { children: [ 24194 /* @__PURE__ */ (0, import_jsx_runtime185.jsxs)(Menu5, { placement: "bottom-end", children: [ 24195 /* @__PURE__ */ (0, import_jsx_runtime185.jsx)( 24196 Menu5.TriggerButton, 24197 { 24198 render: /* @__PURE__ */ (0, import_jsx_runtime185.jsx)( 24199 import_components93.Button, 24200 { 24201 size: isSmall ? "small" : "compact", 24202 icon: more_vertical_default, 24203 label: (0, import_i18n85.__)("Actions"), 24204 accessibleWhenDisabled: true, 24205 disabled: !actions.length, 24206 className: "dataviews-all-actions-button" 24207 } 24208 ) 24209 } 24210 ), 24211 /* @__PURE__ */ (0, import_jsx_runtime185.jsx)(Menu5.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime185.jsx)( 24212 ActionsMenuGroup, 24213 { 24214 actions, 24215 item, 24216 registry, 24217 setActiveModalAction 24218 } 24219 ) }) 24220 ] }), 24221 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime185.jsx)( 24222 ActionModal, 24223 { 24224 action: activeModalAction, 24225 items: [item], 24226 closeModal: () => setActiveModalAction(null) 24227 } 24228 ) 24229 ] }); 24230 } 24231 function PrimaryActions({ 24232 item, 24233 actions, 24234 registry, 24235 buttonVariant 24236 }) { 24237 const [activeModalAction, setActiveModalAction] = (0, import_element66.useState)(null); 24238 const isMobileViewport = (0, import_compose12.useViewportMatch)("medium", "<"); 24239 if (isMobileViewport) { 24240 return null; 24241 } 24242 if (!Array.isArray(actions) || actions.length === 0) { 24243 return null; 24244 } 24245 return /* @__PURE__ */ (0, import_jsx_runtime185.jsxs)(import_jsx_runtime185.Fragment, { children: [ 24246 actions.map((action) => /* @__PURE__ */ (0, import_jsx_runtime185.jsx)( 24247 ButtonTrigger, 24248 { 24249 action, 24250 onClick: () => { 24251 if ("RenderModal" in action) { 24252 setActiveModalAction(action); 24253 return; 24254 } 24255 action.callback([item], { registry }); 24256 }, 24257 items: [item], 24258 variant: buttonVariant 24259 }, 24260 action.id 24261 )), 24262 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime185.jsx)( 24263 ActionModal, 24264 { 24265 action: activeModalAction, 24266 items: [item], 24267 closeModal: () => setActiveModalAction(null) 24268 } 24269 ) 24270 ] }); 24271 } 24272 24273 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.js 24274 var import_components94 = __toESM(require_components()); 24275 var import_i18n86 = __toESM(require_i18n()); 24276 var import_element67 = __toESM(require_element()); 24277 var import_data58 = __toESM(require_data()); 24278 var import_compose13 = __toESM(require_compose()); 24279 var import_jsx_runtime186 = __toESM(require_jsx_runtime()); 24280 function ActionWithModal({ 24281 action, 24282 items, 24283 ActionTriggerComponent 24284 }) { 24285 const [isModalOpen, setIsModalOpen] = (0, import_element67.useState)(false); 24286 const actionTriggerProps = { 24287 action, 24288 onClick: () => { 24289 setIsModalOpen(true); 24290 }, 24291 items 24292 }; 24293 return /* @__PURE__ */ (0, import_jsx_runtime186.jsxs)(import_jsx_runtime186.Fragment, { children: [ 24294 /* @__PURE__ */ (0, import_jsx_runtime186.jsx)(ActionTriggerComponent, { ...actionTriggerProps }), 24295 isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime186.jsx)( 24296 ActionModal, 24297 { 24298 action, 24299 items, 24300 closeModal: () => setIsModalOpen(false) 24301 } 24302 ) 24303 ] }); 24304 } 24305 function useHasAPossibleBulkAction(actions, item) { 24306 return (0, import_element67.useMemo)(() => { 24307 return actions.some((action) => { 24308 return action.supportsBulk && (!action.isEligible || action.isEligible(item)); 24309 }); 24310 }, [actions, item]); 24311 } 24312 function useSomeItemHasAPossibleBulkAction(actions, data) { 24313 return (0, import_element67.useMemo)(() => { 24314 return data.some((item) => { 24315 return actions.some((action) => { 24316 return action.supportsBulk && (!action.isEligible || action.isEligible(item)); 24317 }); 24318 }); 24319 }, [actions, data]); 24320 } 24321 function BulkSelectionCheckbox({ 24322 selection, 24323 onChangeSelection, 24324 data, 24325 actions, 24326 getItemId: getItemId2 24327 }) { 24328 const selectableItems = (0, import_element67.useMemo)(() => { 24329 return data.filter((item) => { 24330 return actions.some( 24331 (action) => action.supportsBulk && (!action.isEligible || action.isEligible(item)) 24332 ); 24333 }); 24334 }, [data, actions]); 24335 const selectedItems = data.filter( 24336 (item) => selection.includes(getItemId2(item)) && selectableItems.includes(item) 24337 ); 24338 const areAllSelected = selectedItems.length === selectableItems.length; 24339 return /* @__PURE__ */ (0, import_jsx_runtime186.jsx)( 24340 import_components94.CheckboxControl, 24341 { 24342 className: "dataviews-view-table-selection-checkbox", 24343 checked: areAllSelected, 24344 indeterminate: !areAllSelected && !!selectedItems.length, 24345 onChange: () => { 24346 if (areAllSelected) { 24347 onChangeSelection([]); 24348 } else { 24349 onChangeSelection( 24350 selectableItems.map((item) => getItemId2(item)) 24351 ); 24352 } 24353 }, 24354 "aria-label": areAllSelected ? (0, import_i18n86.__)("Deselect all") : (0, import_i18n86.__)("Select all") 24355 } 24356 ); 24357 } 24358 function ActionTrigger({ 24359 action, 24360 onClick, 24361 isBusy, 24362 items 24363 }) { 24364 const label = typeof action.label === "string" ? action.label : action.label(items); 24365 const isMobile = (0, import_compose13.useViewportMatch)("medium", "<"); 24366 if (isMobile) { 24367 return /* @__PURE__ */ (0, import_jsx_runtime186.jsx)( 24368 import_components94.Button, 24369 { 24370 disabled: isBusy, 24371 accessibleWhenDisabled: true, 24372 label, 24373 icon: action.icon, 24374 size: "compact", 24375 onClick, 24376 isBusy 24377 } 24378 ); 24379 } 24380 return /* @__PURE__ */ (0, import_jsx_runtime186.jsx)( 24381 import_components94.Button, 24382 { 24383 disabled: isBusy, 24384 accessibleWhenDisabled: true, 24385 size: "compact", 24386 onClick, 24387 isBusy, 24388 children: label 24389 } 24390 ); 24391 } 24392 var EMPTY_ARRAY4 = []; 24393 function ActionButton({ 24394 action, 24395 selectedItems, 24396 actionInProgress, 24397 setActionInProgress 24398 }) { 24399 const registry = (0, import_data58.useRegistry)(); 24400 const selectedEligibleItems = (0, import_element67.useMemo)(() => { 24401 return selectedItems.filter((item) => { 24402 return !action.isEligible || action.isEligible(item); 24403 }); 24404 }, [action, selectedItems]); 24405 if ("RenderModal" in action) { 24406 return /* @__PURE__ */ (0, import_jsx_runtime186.jsx)( 24407 ActionWithModal, 24408 { 24409 action, 24410 items: selectedEligibleItems, 24411 ActionTriggerComponent: ActionTrigger 24412 }, 24413 action.id 24414 ); 24415 } 24416 return /* @__PURE__ */ (0, import_jsx_runtime186.jsx)( 24417 ActionTrigger, 24418 { 24419 action, 24420 onClick: async () => { 24421 setActionInProgress(action.id); 24422 await action.callback(selectedItems, { 24423 registry 24424 }); 24425 setActionInProgress(null); 24426 }, 24427 items: selectedEligibleItems, 24428 isBusy: actionInProgress === action.id 24429 }, 24430 action.id 24431 ); 24432 } 24433 function renderFooterContent(data, actions, getItemId2, selection, actionsToShow, selectedItems, actionInProgress, setActionInProgress, onChangeSelection) { 24434 const message2 = selectedItems.length > 0 ? (0, import_i18n86.sprintf)( 24435 /* translators: %d: number of items. */ 24436 (0, import_i18n86._n)( 24437 "%d Item selected", 24438 "%d Items selected", 24439 selectedItems.length 24440 ), 24441 selectedItems.length 24442 ) : (0, import_i18n86.sprintf)( 24443 /* translators: %d: number of items. */ 24444 (0, import_i18n86._n)("%d Item", "%d Items", data.length), 24445 data.length 24446 ); 24447 return /* @__PURE__ */ (0, import_jsx_runtime186.jsxs)( 24448 import_components94.__experimentalHStack, 24449 { 24450 expanded: false, 24451 className: "dataviews-bulk-actions-footer__container", 24452 spacing: 3, 24453 children: [ 24454 /* @__PURE__ */ (0, import_jsx_runtime186.jsx)( 24455 BulkSelectionCheckbox, 24456 { 24457 selection, 24458 onChangeSelection, 24459 data, 24460 actions, 24461 getItemId: getItemId2 24462 } 24463 ), 24464 /* @__PURE__ */ (0, import_jsx_runtime186.jsx)("span", { className: "dataviews-bulk-actions-footer__item-count", children: message2 }), 24465 /* @__PURE__ */ (0, import_jsx_runtime186.jsxs)( 24466 import_components94.__experimentalHStack, 24467 { 24468 className: "dataviews-bulk-actions-footer__action-buttons", 24469 expanded: false, 24470 spacing: 1, 24471 children: [ 24472 actionsToShow.map((action) => { 24473 return /* @__PURE__ */ (0, import_jsx_runtime186.jsx)( 24474 ActionButton, 24475 { 24476 action, 24477 selectedItems, 24478 actionInProgress, 24479 setActionInProgress 24480 }, 24481 action.id 24482 ); 24483 }), 24484 selectedItems.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime186.jsx)( 24485 import_components94.Button, 24486 { 24487 icon: close_small_default, 24488 showTooltip: true, 24489 tooltipPosition: "top", 24490 size: "compact", 24491 label: (0, import_i18n86.__)("Cancel"), 24492 disabled: !!actionInProgress, 24493 accessibleWhenDisabled: false, 24494 onClick: () => { 24495 onChangeSelection(EMPTY_ARRAY4); 24496 } 24497 } 24498 ) 24499 ] 24500 } 24501 ) 24502 ] 24503 } 24504 ); 24505 } 24506 function FooterContent({ 24507 selection, 24508 actions, 24509 onChangeSelection, 24510 data, 24511 getItemId: getItemId2 24512 }) { 24513 const [actionInProgress, setActionInProgress] = (0, import_element67.useState)( 24514 null 24515 ); 24516 const footerContentRef = (0, import_element67.useRef)(null); 24517 const isMobile = (0, import_compose13.useViewportMatch)("medium", "<"); 24518 const bulkActions = (0, import_element67.useMemo)( 24519 () => actions.filter((action) => action.supportsBulk), 24520 [actions] 24521 ); 24522 const selectableItems = (0, import_element67.useMemo)(() => { 24523 return data.filter((item) => { 24524 return bulkActions.some( 24525 (action) => !action.isEligible || action.isEligible(item) 24526 ); 24527 }); 24528 }, [data, bulkActions]); 24529 const selectedItems = (0, import_element67.useMemo)(() => { 24530 return data.filter( 24531 (item) => selection.includes(getItemId2(item)) && selectableItems.includes(item) 24532 ); 24533 }, [selection, data, getItemId2, selectableItems]); 24534 const actionsToShow = (0, import_element67.useMemo)( 24535 () => actions.filter((action) => { 24536 return action.supportsBulk && (!isMobile || action.icon) && selectedItems.some( 24537 (item) => !action.isEligible || action.isEligible(item) 24538 ); 24539 }), 24540 [actions, selectedItems, isMobile] 24541 ); 24542 if (!actionInProgress) { 24543 if (footerContentRef.current) { 24544 footerContentRef.current = null; 24545 } 24546 return renderFooterContent( 24547 data, 24548 actions, 24549 getItemId2, 24550 selection, 24551 actionsToShow, 24552 selectedItems, 24553 actionInProgress, 24554 setActionInProgress, 24555 onChangeSelection 24556 ); 24557 } else if (!footerContentRef.current) { 24558 footerContentRef.current = renderFooterContent( 24559 data, 24560 actions, 24561 getItemId2, 24562 selection, 24563 actionsToShow, 24564 selectedItems, 24565 actionInProgress, 24566 setActionInProgress, 24567 onChangeSelection 24568 ); 24569 } 24570 return footerContentRef.current; 24571 } 24572 function BulkActionsFooter() { 24573 const { 24574 data, 24575 selection, 24576 actions = EMPTY_ARRAY4, 24577 onChangeSelection, 24578 getItemId: getItemId2 24579 } = (0, import_element67.useContext)(dataviews_context_default); 24580 return /* @__PURE__ */ (0, import_jsx_runtime186.jsx)( 24581 FooterContent, 24582 { 24583 selection, 24584 onChangeSelection, 24585 data, 24586 actions, 24587 getItemId: getItemId2 24588 } 24589 ); 24590 } 24591 24592 // packages/dataviews/build-module/dataviews-layouts/table/column-header-menu.js 24593 var import_i18n87 = __toESM(require_i18n()); 24594 var import_components95 = __toESM(require_components()); 24595 var import_element68 = __toESM(require_element()); 24596 24597 // packages/dataviews/build-module/utils/get-hideable-fields.js 24598 function getHideableFields(view, fields) { 24599 const togglableFields = [ 24600 view?.titleField, 24601 view?.mediaField, 24602 view?.descriptionField 24603 ].filter(Boolean); 24604 return fields.filter( 24605 (f2) => !togglableFields.includes(f2.id) && f2.type !== "media" && f2.enableHiding !== false 24606 ); 24607 } 24608 24609 // packages/dataviews/build-module/dataviews-layouts/table/column-header-menu.js 24610 var import_jsx_runtime187 = __toESM(require_jsx_runtime()); 24611 var { Menu: Menu6 } = unlock3(import_components95.privateApis); 24612 function WithMenuSeparators({ children }) { 24613 return import_element68.Children.toArray(children).filter(Boolean).map((child, i2) => /* @__PURE__ */ (0, import_jsx_runtime187.jsxs)(import_element68.Fragment, { children: [ 24614 i2 > 0 && /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(Menu6.Separator, {}), 24615 child 24616 ] }, i2)); 24617 } 24618 var _HeaderMenu = (0, import_element68.forwardRef)(function HeaderMenu({ 24619 fieldId, 24620 view, 24621 fields, 24622 onChangeView, 24623 onHide, 24624 setOpenedFilter, 24625 canMove = true, 24626 canInsertLeft = true, 24627 canInsertRight = true 24628 }, ref) { 24629 const visibleFieldIds = view.fields ?? []; 24630 const index = visibleFieldIds?.indexOf(fieldId); 24631 const isSorted = view.sort?.field === fieldId; 24632 let isHidable = false; 24633 let isSortable = false; 24634 let canAddFilter = false; 24635 let operators = []; 24636 const field = fields.find((f2) => f2.id === fieldId); 24637 const { setIsShowingFilter } = (0, import_element68.useContext)(dataviews_context_default); 24638 if (!field) { 24639 return null; 24640 } 24641 isHidable = field.enableHiding !== false; 24642 isSortable = field.enableSorting !== false; 24643 const header = field.header; 24644 operators = !!field.filterBy && field.filterBy?.operators || []; 24645 canAddFilter = !view.filters?.some((_filter) => fieldId === _filter.field) && !!(field.hasElements || field.Edit) && field.filterBy !== false && !field.filterBy?.isPrimary; 24646 if (!isSortable && !canMove && !isHidable && !canAddFilter) { 24647 return header; 24648 } 24649 const hiddenFields = getHideableFields(view, fields).filter( 24650 (f2) => !visibleFieldIds.includes(f2.id) 24651 ); 24652 const canInsert = (canInsertLeft || canInsertRight) && !!hiddenFields.length; 24653 return /* @__PURE__ */ (0, import_jsx_runtime187.jsxs)(Menu6, { children: [ 24654 /* @__PURE__ */ (0, import_jsx_runtime187.jsxs)( 24655 Menu6.TriggerButton, 24656 { 24657 render: /* @__PURE__ */ (0, import_jsx_runtime187.jsx)( 24658 import_components95.Button, 24659 { 24660 size: "compact", 24661 className: "dataviews-view-table-header-button", 24662 ref, 24663 variant: "tertiary" 24664 } 24665 ), 24666 children: [ 24667 header, 24668 view.sort && isSorted && /* @__PURE__ */ (0, import_jsx_runtime187.jsx)("span", { "aria-hidden": "true", children: sortArrows[view.sort.direction] }) 24669 ] 24670 } 24671 ), 24672 /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(Menu6.Popover, { style: { minWidth: "240px" }, children: /* @__PURE__ */ (0, import_jsx_runtime187.jsxs)(WithMenuSeparators, { children: [ 24673 isSortable && /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(Menu6.Group, { children: SORTING_DIRECTIONS.map( 24674 (direction) => { 24675 const isChecked = view.sort && isSorted && view.sort.direction === direction; 24676 const value = `$fieldId}-$direction}`; 24677 return /* @__PURE__ */ (0, import_jsx_runtime187.jsx)( 24678 Menu6.RadioItem, 24679 { 24680 name: "view-table-sorting", 24681 value, 24682 checked: isChecked, 24683 onChange: () => { 24684 onChangeView({ 24685 ...view, 24686 sort: { 24687 field: fieldId, 24688 direction 24689 }, 24690 showLevels: false 24691 }); 24692 }, 24693 children: /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(Menu6.ItemLabel, { children: sortLabels[direction] }) 24694 }, 24695 value 24696 ); 24697 } 24698 ) }), 24699 canAddFilter && /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(Menu6.Group, { children: /* @__PURE__ */ (0, import_jsx_runtime187.jsx)( 24700 Menu6.Item, 24701 { 24702 prefix: /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(import_components95.Icon, { icon: funnel_default }), 24703 onClick: () => { 24704 setOpenedFilter(fieldId); 24705 setIsShowingFilter(true); 24706 onChangeView({ 24707 ...view, 24708 page: 1, 24709 filters: [ 24710 ...view.filters || [], 24711 { 24712 field: fieldId, 24713 value: void 0, 24714 operator: operators[0] 24715 } 24716 ] 24717 }); 24718 }, 24719 children: /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(Menu6.ItemLabel, { children: (0, import_i18n87.__)("Add filter") }) 24720 } 24721 ) }), 24722 (canMove || isHidable || canInsert) && field && /* @__PURE__ */ (0, import_jsx_runtime187.jsxs)(Menu6.Group, { children: [ 24723 canMove && /* @__PURE__ */ (0, import_jsx_runtime187.jsx)( 24724 Menu6.Item, 24725 { 24726 prefix: /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(import_components95.Icon, { icon: arrow_left_default }), 24727 disabled: index < 1, 24728 onClick: () => { 24729 onChangeView({ 24730 ...view, 24731 fields: [ 24732 ...visibleFieldIds.slice( 24733 0, 24734 index - 1 24735 ) ?? [], 24736 fieldId, 24737 visibleFieldIds[index - 1], 24738 ...visibleFieldIds.slice( 24739 index + 1 24740 ) 24741 ] 24742 }); 24743 }, 24744 children: /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(Menu6.ItemLabel, { children: (0, import_i18n87.__)("Move left") }) 24745 } 24746 ), 24747 canMove && /* @__PURE__ */ (0, import_jsx_runtime187.jsx)( 24748 Menu6.Item, 24749 { 24750 prefix: /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(import_components95.Icon, { icon: arrow_right_default }), 24751 disabled: index >= visibleFieldIds.length - 1, 24752 onClick: () => { 24753 onChangeView({ 24754 ...view, 24755 fields: [ 24756 ...visibleFieldIds.slice( 24757 0, 24758 index 24759 ) ?? [], 24760 visibleFieldIds[index + 1], 24761 fieldId, 24762 ...visibleFieldIds.slice( 24763 index + 2 24764 ) 24765 ] 24766 }); 24767 }, 24768 children: /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(Menu6.ItemLabel, { children: (0, import_i18n87.__)("Move right") }) 24769 } 24770 ), 24771 canInsertLeft && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime187.jsxs)(Menu6, { children: [ 24772 /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(Menu6.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(Menu6.ItemLabel, { children: (0, import_i18n87.__)("Insert left") }) }), 24773 /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(Menu6.Popover, { children: hiddenFields.map((hiddenField) => /* @__PURE__ */ (0, import_jsx_runtime187.jsx)( 24774 Menu6.Item, 24775 { 24776 onClick: () => { 24777 onChangeView({ 24778 ...view, 24779 fields: [ 24780 ...visibleFieldIds.slice( 24781 0, 24782 index 24783 ), 24784 hiddenField.id, 24785 ...visibleFieldIds.slice( 24786 index 24787 ) 24788 ] 24789 }); 24790 }, 24791 children: /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(Menu6.ItemLabel, { children: hiddenField.label }) 24792 }, 24793 hiddenField.id 24794 )) }) 24795 ] }), 24796 canInsertRight && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime187.jsxs)(Menu6, { children: [ 24797 /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(Menu6.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(Menu6.ItemLabel, { children: (0, import_i18n87.__)("Insert right") }) }), 24798 /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(Menu6.Popover, { children: hiddenFields.map((hiddenField) => /* @__PURE__ */ (0, import_jsx_runtime187.jsx)( 24799 Menu6.Item, 24800 { 24801 onClick: () => { 24802 onChangeView({ 24803 ...view, 24804 fields: [ 24805 ...visibleFieldIds.slice( 24806 0, 24807 index + 1 24808 ), 24809 hiddenField.id, 24810 ...visibleFieldIds.slice( 24811 index + 1 24812 ) 24813 ] 24814 }); 24815 }, 24816 children: /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(Menu6.ItemLabel, { children: hiddenField.label }) 24817 }, 24818 hiddenField.id 24819 )) }) 24820 ] }), 24821 isHidable && field && /* @__PURE__ */ (0, import_jsx_runtime187.jsx)( 24822 Menu6.Item, 24823 { 24824 prefix: /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(import_components95.Icon, { icon: unseen_default }), 24825 onClick: () => { 24826 onHide(field); 24827 onChangeView({ 24828 ...view, 24829 fields: visibleFieldIds.filter( 24830 (id) => id !== fieldId 24831 ) 24832 }); 24833 }, 24834 children: /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(Menu6.ItemLabel, { children: (0, import_i18n87.__)("Hide column") }) 24835 } 24836 ) 24837 ] }) 24838 ] }) }) 24839 ] }); 24840 }); 24841 var ColumnHeaderMenu = _HeaderMenu; 24842 var column_header_menu_default = ColumnHeaderMenu; 24843 24844 // packages/dataviews/build-module/dataviews-layouts/table/column-primary.js 24845 var import_components96 = __toESM(require_components()); 24846 24847 // packages/dataviews/build-module/dataviews-layouts/utils/item-click-wrapper.js 24848 var import_element69 = __toESM(require_element()); 24849 var import_jsx_runtime188 = __toESM(require_jsx_runtime()); 24850 function getClickableItemProps({ 24851 item, 24852 isItemClickable, 24853 onClickItem, 24854 className 24855 }) { 24856 if (!isItemClickable(item) || !onClickItem) { 24857 return { className }; 24858 } 24859 return { 24860 className: className ? `$className} $className}--clickable` : void 0, 24861 role: "button", 24862 tabIndex: 0, 24863 onClick: (event) => { 24864 event.stopPropagation(); 24865 onClickItem(item); 24866 }, 24867 onKeyDown: (event) => { 24868 if (event.key === "Enter" || event.key === "" || event.key === " ") { 24869 event.stopPropagation(); 24870 onClickItem(item); 24871 } 24872 } 24873 }; 24874 } 24875 function ItemClickWrapper({ 24876 item, 24877 isItemClickable, 24878 onClickItem, 24879 renderItemLink, 24880 className, 24881 children, 24882 ...extraProps 24883 }) { 24884 if (!isItemClickable(item)) { 24885 return /* @__PURE__ */ (0, import_jsx_runtime188.jsx)("div", { className, ...extraProps, children }); 24886 } 24887 if (renderItemLink) { 24888 const renderedElement = renderItemLink({ 24889 item, 24890 className: `$className} $className}--clickable`, 24891 ...extraProps, 24892 children 24893 }); 24894 return (0, import_element69.cloneElement)(renderedElement, { 24895 onClick: (event) => { 24896 event.stopPropagation(); 24897 if (renderedElement.props.onClick) { 24898 renderedElement.props.onClick(event); 24899 } 24900 }, 24901 onKeyDown: (event) => { 24902 if (event.key === "Enter" || event.key === "" || event.key === " ") { 24903 event.stopPropagation(); 24904 if (renderedElement.props.onKeyDown) { 24905 renderedElement.props.onKeyDown(event); 24906 } 24907 } 24908 } 24909 }); 24910 } 24911 const clickProps = getClickableItemProps({ 24912 item, 24913 isItemClickable, 24914 onClickItem, 24915 className 24916 }); 24917 return /* @__PURE__ */ (0, import_jsx_runtime188.jsx)("div", { ...clickProps, ...extraProps, children }); 24918 } 24919 24920 // packages/dataviews/build-module/dataviews-layouts/table/column-primary.js 24921 var import_jsx_runtime189 = __toESM(require_jsx_runtime()); 24922 function ColumnPrimary({ 24923 item, 24924 level, 24925 titleField, 24926 mediaField, 24927 descriptionField: descriptionField2, 24928 onClickItem, 24929 renderItemLink, 24930 isItemClickable 24931 }) { 24932 return /* @__PURE__ */ (0, import_jsx_runtime189.jsxs)(import_components96.__experimentalHStack, { spacing: 3, alignment: "flex-start", justify: "flex-start", children: [ 24933 mediaField && /* @__PURE__ */ (0, import_jsx_runtime189.jsx)( 24934 ItemClickWrapper, 24935 { 24936 item, 24937 isItemClickable, 24938 onClickItem, 24939 renderItemLink, 24940 className: "dataviews-view-table__cell-content-wrapper dataviews-column-primary__media", 24941 "aria-label": isItemClickable(item) && (!!onClickItem || !!renderItemLink) && !!titleField ? titleField.getValue?.({ item }) : void 0, 24942 children: /* @__PURE__ */ (0, import_jsx_runtime189.jsx)( 24943 mediaField.render, 24944 { 24945 item, 24946 field: mediaField, 24947 config: { sizes: "32px" } 24948 } 24949 ) 24950 } 24951 ), 24952 /* @__PURE__ */ (0, import_jsx_runtime189.jsxs)( 24953 import_components96.__experimentalVStack, 24954 { 24955 spacing: 0, 24956 alignment: "flex-start", 24957 className: "dataviews-view-table__primary-column-content", 24958 children: [ 24959 titleField && /* @__PURE__ */ (0, import_jsx_runtime189.jsxs)( 24960 ItemClickWrapper, 24961 { 24962 item, 24963 isItemClickable, 24964 onClickItem, 24965 renderItemLink, 24966 className: "dataviews-view-table__cell-content-wrapper dataviews-title-field", 24967 children: [ 24968 level !== void 0 && level > 0 && /* @__PURE__ */ (0, import_jsx_runtime189.jsxs)("span", { className: "dataviews-view-table__level", children: [ 24969 "\u2014".repeat(level), 24970 "\xA0" 24971 ] }), 24972 /* @__PURE__ */ (0, import_jsx_runtime189.jsx)(titleField.render, { item, field: titleField }) 24973 ] 24974 } 24975 ), 24976 descriptionField2 && /* @__PURE__ */ (0, import_jsx_runtime189.jsx)( 24977 descriptionField2.render, 24978 { 24979 item, 24980 field: descriptionField2 24981 } 24982 ) 24983 ] 24984 } 24985 ) 24986 ] }); 24987 } 24988 var column_primary_default = ColumnPrimary; 24989 24990 // packages/dataviews/build-module/dataviews-layouts/table/use-is-horizontal-scroll-end.js 24991 var import_compose14 = __toESM(require_compose()); 24992 var import_element70 = __toESM(require_element()); 24993 var import_i18n88 = __toESM(require_i18n()); 24994 var isScrolledToEnd = (element) => { 24995 if ((0, import_i18n88.isRTL)()) { 24996 const scrollLeft = Math.abs(element.scrollLeft); 24997 return scrollLeft <= 1; 24998 } 24999 return element.scrollLeft + element.clientWidth >= element.scrollWidth - 1; 25000 }; 25001 function useIsHorizontalScrollEnd({ 25002 scrollContainerRef, 25003 enabled = false 25004 }) { 25005 const [isHorizontalScrollEnd, setIsHorizontalScrollEnd] = (0, import_element70.useState)(false); 25006 const handleIsHorizontalScrollEnd = (0, import_compose14.useDebounce)( 25007 (0, import_element70.useCallback)(() => { 25008 const scrollContainer = scrollContainerRef.current; 25009 if (scrollContainer) { 25010 setIsHorizontalScrollEnd(isScrolledToEnd(scrollContainer)); 25011 } 25012 }, [scrollContainerRef, setIsHorizontalScrollEnd]), 25013 200 25014 ); 25015 (0, import_element70.useEffect)(() => { 25016 if (typeof window === "undefined" || !enabled || !scrollContainerRef.current) { 25017 return () => { 25018 }; 25019 } 25020 handleIsHorizontalScrollEnd(); 25021 scrollContainerRef.current.addEventListener( 25022 "scroll", 25023 handleIsHorizontalScrollEnd 25024 ); 25025 window.addEventListener("resize", handleIsHorizontalScrollEnd); 25026 return () => { 25027 scrollContainerRef.current?.removeEventListener( 25028 "scroll", 25029 handleIsHorizontalScrollEnd 25030 ); 25031 window.removeEventListener("resize", handleIsHorizontalScrollEnd); 25032 }; 25033 }, [scrollContainerRef, enabled]); 25034 return isHorizontalScrollEnd; 25035 } 25036 25037 // packages/dataviews/build-module/dataviews-layouts/utils/get-data-by-group.js 25038 function getDataByGroup(data, groupByField) { 25039 return data.reduce((groups, item) => { 25040 const groupName = groupByField.getValue({ item }); 25041 if (!groups.has(groupName)) { 25042 groups.set(groupName, []); 25043 } 25044 groups.get(groupName)?.push(item); 25045 return groups; 25046 }, /* @__PURE__ */ new Map()); 25047 } 25048 25049 // packages/dataviews/build-module/components/dataviews-view-config/properties-section.js 25050 var import_components97 = __toESM(require_components()); 25051 var import_i18n89 = __toESM(require_i18n()); 25052 var import_element71 = __toESM(require_element()); 25053 var import_jsx_runtime190 = __toESM(require_jsx_runtime()); 25054 function FieldItem({ 25055 field, 25056 isVisible: isVisible2, 25057 onToggleVisibility 25058 }) { 25059 return /* @__PURE__ */ (0, import_jsx_runtime190.jsx)(import_components97.__experimentalItem, { onClick: field.enableHiding ? onToggleVisibility : void 0, children: /* @__PURE__ */ (0, import_jsx_runtime190.jsxs)(import_components97.__experimentalHStack, { expanded: true, justify: "flex-start", alignment: "center", children: [ 25060 /* @__PURE__ */ (0, import_jsx_runtime190.jsx)("div", { style: { height: 24, width: 24 }, children: isVisible2 && /* @__PURE__ */ (0, import_jsx_runtime190.jsx)(import_components97.Icon, { icon: check_default }) }), 25061 /* @__PURE__ */ (0, import_jsx_runtime190.jsx)("span", { className: "dataviews-view-config__label", children: field.label }) 25062 ] }) }); 25063 } 25064 function isDefined(item) { 25065 return !!item; 25066 } 25067 function PropertiesSection({ 25068 showLabel = true 25069 }) { 25070 const { view, fields, onChangeView } = (0, import_element71.useContext)(dataviews_context_default); 25071 const regularFields = getHideableFields(view, fields); 25072 if (!regularFields?.length) { 25073 return null; 25074 } 25075 const titleField = fields.find((f2) => f2.id === view.titleField); 25076 const previewField3 = fields.find((f2) => f2.id === view.mediaField); 25077 const descriptionField2 = fields.find( 25078 (f2) => f2.id === view.descriptionField 25079 ); 25080 const lockedFields = [ 25081 { 25082 field: titleField, 25083 isVisibleFlag: "showTitle" 25084 }, 25085 { 25086 field: previewField3, 25087 isVisibleFlag: "showMedia" 25088 }, 25089 { 25090 field: descriptionField2, 25091 isVisibleFlag: "showDescription" 25092 } 25093 ].filter(({ field }) => isDefined(field)); 25094 const visibleFieldIds = view.fields ?? []; 25095 const visibleRegularFieldsCount = regularFields.filter( 25096 (f2) => visibleFieldIds.includes(f2.id) 25097 ).length; 25098 let visibleLockedFields = lockedFields.filter( 25099 ({ field, isVisibleFlag }) => ( 25100 // @ts-expect-error 25101 isDefined(field) && (view[isVisibleFlag] ?? true) 25102 ) 25103 ); 25104 const totalVisibleFields = visibleLockedFields.length + visibleRegularFieldsCount; 25105 if (totalVisibleFields === 1) { 25106 if (visibleLockedFields.length === 1) { 25107 visibleLockedFields = visibleLockedFields.map((locked) => ({ 25108 ...locked, 25109 field: { ...locked.field, enableHiding: false } 25110 })); 25111 } 25112 } 25113 const hiddenLockedFields = lockedFields.filter( 25114 ({ field, isVisibleFlag }) => ( 25115 // @ts-expect-error 25116 isDefined(field) && !(view[isVisibleFlag] ?? true) 25117 ) 25118 ); 25119 return /* @__PURE__ */ (0, import_jsx_runtime190.jsxs)(import_components97.__experimentalVStack, { className: "dataviews-field-control", spacing: 0, children: [ 25120 showLabel && /* @__PURE__ */ (0, import_jsx_runtime190.jsx)(import_components97.BaseControl.VisualLabel, { children: (0, import_i18n89.__)("Properties") }), 25121 /* @__PURE__ */ (0, import_jsx_runtime190.jsx)(import_components97.__experimentalVStack, { className: "dataviews-view-config__properties", spacing: 0, children: /* @__PURE__ */ (0, import_jsx_runtime190.jsxs)(import_components97.__experimentalItemGroup, { isBordered: true, isSeparated: true, size: "medium", children: [ 25122 visibleLockedFields.map(({ field, isVisibleFlag }) => { 25123 return /* @__PURE__ */ (0, import_jsx_runtime190.jsx)( 25124 FieldItem, 25125 { 25126 field, 25127 isVisible: true, 25128 onToggleVisibility: () => { 25129 onChangeView({ 25130 ...view, 25131 [isVisibleFlag]: false 25132 }); 25133 } 25134 }, 25135 field.id 25136 ); 25137 }), 25138 hiddenLockedFields.map(({ field, isVisibleFlag }) => { 25139 return /* @__PURE__ */ (0, import_jsx_runtime190.jsx)( 25140 FieldItem, 25141 { 25142 field, 25143 isVisible: false, 25144 onToggleVisibility: () => { 25145 onChangeView({ 25146 ...view, 25147 [isVisibleFlag]: true 25148 }); 25149 } 25150 }, 25151 field.id 25152 ); 25153 }), 25154 regularFields.map((field) => { 25155 const isVisible2 = visibleFieldIds.includes(field.id); 25156 const isLastVisible = totalVisibleFields === 1 && isVisible2; 25157 const fieldToRender = isLastVisible ? { ...field, enableHiding: false } : field; 25158 return /* @__PURE__ */ (0, import_jsx_runtime190.jsx)( 25159 FieldItem, 25160 { 25161 field: fieldToRender, 25162 isVisible: isVisible2, 25163 onToggleVisibility: () => { 25164 onChangeView({ 25165 ...view, 25166 fields: isVisible2 ? visibleFieldIds.filter( 25167 (fieldId) => fieldId !== field.id 25168 ) : [...visibleFieldIds, field.id] 25169 }); 25170 } 25171 }, 25172 field.id 25173 ); 25174 }) 25175 ] }) }) 25176 ] }); 25177 } 25178 25179 // packages/dataviews/build-module/dataviews-layouts/table/index.js 25180 var import_jsx_runtime191 = __toESM(require_jsx_runtime()); 25181 function TableColumnField({ 25182 item, 25183 fields, 25184 column, 25185 align 25186 }) { 25187 const field = fields.find((f2) => f2.id === column); 25188 if (!field) { 25189 return null; 25190 } 25191 const className = clsx_default("dataviews-view-table__cell-content-wrapper", { 25192 "dataviews-view-table__cell-align-end": align === "end", 25193 "dataviews-view-table__cell-align-center": align === "center" 25194 }); 25195 return /* @__PURE__ */ (0, import_jsx_runtime191.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime191.jsx)(field.render, { item, field }) }); 25196 } 25197 function TableRow({ 25198 hasBulkActions, 25199 item, 25200 level, 25201 actions, 25202 fields, 25203 id, 25204 view, 25205 titleField, 25206 mediaField, 25207 descriptionField: descriptionField2, 25208 selection, 25209 getItemId: getItemId2, 25210 isItemClickable, 25211 onClickItem, 25212 renderItemLink, 25213 onChangeSelection, 25214 isActionsColumnSticky, 25215 posinset 25216 }) { 25217 const { paginationInfo } = (0, import_element72.useContext)(dataviews_context_default); 25218 const hasPossibleBulkAction = useHasAPossibleBulkAction(actions, item); 25219 const isSelected2 = hasPossibleBulkAction && selection.includes(id); 25220 const { 25221 showTitle = true, 25222 showMedia = true, 25223 showDescription = true, 25224 infiniteScrollEnabled 25225 } = view; 25226 const isTouchDeviceRef = (0, import_element72.useRef)(false); 25227 const columns = view.fields ?? []; 25228 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField2 && showDescription; 25229 return /* @__PURE__ */ (0, import_jsx_runtime191.jsxs)( 25230 "tr", 25231 { 25232 className: clsx_default("dataviews-view-table__row", { 25233 "is-selected": hasPossibleBulkAction && isSelected2, 25234 "has-bulk-actions": hasPossibleBulkAction 25235 }), 25236 onTouchStart: () => { 25237 isTouchDeviceRef.current = true; 25238 }, 25239 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0, 25240 "aria-posinset": posinset, 25241 role: infiniteScrollEnabled ? "article" : void 0, 25242 onMouseDown: (event) => { 25243 const isMetaClick = (0, import_keycodes6.isAppleOS)() ? event.metaKey : event.ctrlKey; 25244 if (event.button === 0 && isMetaClick && window.navigator.userAgent.toLowerCase().includes("firefox")) { 25245 event?.preventDefault(); 25246 } 25247 }, 25248 onClick: (event) => { 25249 if (!hasPossibleBulkAction) { 25250 return; 25251 } 25252 const isModifierKeyPressed = (0, import_keycodes6.isAppleOS)() ? event.metaKey : event.ctrlKey; 25253 if (isModifierKeyPressed && !isTouchDeviceRef.current && document.getSelection()?.type !== "Range") { 25254 onChangeSelection( 25255 selection.includes(id) ? selection.filter((itemId) => id !== itemId) : [...selection, id] 25256 ); 25257 } 25258 }, 25259 children: [ 25260 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime191.jsx)("td", { className: "dataviews-view-table__checkbox-column", children: /* @__PURE__ */ (0, import_jsx_runtime191.jsx)("div", { className: "dataviews-view-table__cell-content-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime191.jsx)( 25261 DataViewsSelectionCheckbox, 25262 { 25263 item, 25264 selection, 25265 onChangeSelection, 25266 getItemId: getItemId2, 25267 titleField, 25268 disabled: !hasPossibleBulkAction 25269 } 25270 ) }) }), 25271 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime191.jsx)("td", { children: /* @__PURE__ */ (0, import_jsx_runtime191.jsx)( 25272 column_primary_default, 25273 { 25274 item, 25275 level, 25276 titleField: showTitle ? titleField : void 0, 25277 mediaField: showMedia ? mediaField : void 0, 25278 descriptionField: showDescription ? descriptionField2 : void 0, 25279 isItemClickable, 25280 onClickItem, 25281 renderItemLink 25282 } 25283 ) }), 25284 columns.map((column) => { 25285 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {}; 25286 return /* @__PURE__ */ (0, import_jsx_runtime191.jsx)( 25287 "td", 25288 { 25289 style: { 25290 width, 25291 maxWidth, 25292 minWidth 25293 }, 25294 children: /* @__PURE__ */ (0, import_jsx_runtime191.jsx)( 25295 TableColumnField, 25296 { 25297 fields, 25298 item, 25299 column, 25300 align 25301 } 25302 ) 25303 }, 25304 column 25305 ); 25306 }), 25307 !!actions?.length && // Disable reason: we are not making the element interactive, 25308 // but preventing any click events from bubbling up to the 25309 // table row. This allows us to add a click handler to the row 25310 // itself (to toggle row selection) without erroneously 25311 // intercepting click events from ItemActions. 25312 /* eslint-disable jsx-a11y/no-noninteractive-element-interactions, jsx-a11y/click-events-have-key-events */ 25313 /* @__PURE__ */ (0, import_jsx_runtime191.jsx)( 25314 "td", 25315 { 25316 className: clsx_default("dataviews-view-table__actions-column", { 25317 "dataviews-view-table__actions-column--sticky": true, 25318 "dataviews-view-table__actions-column--stuck": isActionsColumnSticky 25319 }), 25320 onClick: (e2) => e2.stopPropagation(), 25321 children: /* @__PURE__ */ (0, import_jsx_runtime191.jsx)(ItemActions, { item, actions }) 25322 } 25323 ) 25324 ] 25325 } 25326 ); 25327 } 25328 function ViewTable({ 25329 actions, 25330 data, 25331 fields, 25332 getItemId: getItemId2, 25333 getItemLevel: getItemLevel2, 25334 isLoading = false, 25335 onChangeView, 25336 onChangeSelection, 25337 selection, 25338 setOpenedFilter, 25339 onClickItem, 25340 isItemClickable, 25341 renderItemLink, 25342 view, 25343 className, 25344 empty 25345 }) { 25346 const { containerRef } = (0, import_element72.useContext)(dataviews_context_default); 25347 const headerMenuRefs = (0, import_element72.useRef)(/* @__PURE__ */ new Map()); 25348 const headerMenuToFocusRef = (0, import_element72.useRef)(); 25349 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element72.useState)(); 25350 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data); 25351 const [contextMenuAnchor, setContextMenuAnchor] = (0, import_element72.useState)(null); 25352 (0, import_element72.useEffect)(() => { 25353 if (headerMenuToFocusRef.current) { 25354 headerMenuToFocusRef.current.focus(); 25355 headerMenuToFocusRef.current = void 0; 25356 } 25357 }); 25358 const tableNoticeId = (0, import_element72.useId)(); 25359 const isHorizontalScrollEnd = useIsHorizontalScrollEnd({ 25360 scrollContainerRef: containerRef, 25361 enabled: !!actions?.length 25362 }); 25363 if (nextHeaderMenuToFocus) { 25364 headerMenuToFocusRef.current = nextHeaderMenuToFocus; 25365 setNextHeaderMenuToFocus(void 0); 25366 return; 25367 } 25368 const onHide = (field) => { 25369 const hidden = headerMenuRefs.current.get(field.id); 25370 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0; 25371 setNextHeaderMenuToFocus(fallback?.node); 25372 }; 25373 const handleHeaderContextMenu = (event) => { 25374 event.preventDefault(); 25375 event.stopPropagation(); 25376 const virtualAnchor = { 25377 getBoundingClientRect: () => ({ 25378 x: event.clientX, 25379 y: event.clientY, 25380 top: event.clientY, 25381 left: event.clientX, 25382 right: event.clientX, 25383 bottom: event.clientY, 25384 width: 0, 25385 height: 0, 25386 toJSON: () => ({}) 25387 }) 25388 }; 25389 window.requestAnimationFrame(() => { 25390 setContextMenuAnchor(virtualAnchor); 25391 }); 25392 }; 25393 const hasData = !!data?.length; 25394 const titleField = fields.find((field) => field.id === view.titleField); 25395 const mediaField = fields.find((field) => field.id === view.mediaField); 25396 const descriptionField2 = fields.find( 25397 (field) => field.id === view.descriptionField 25398 ); 25399 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null; 25400 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null; 25401 const { showTitle = true, showMedia = true, showDescription = true } = view; 25402 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField2 && showDescription; 25403 const columns = view.fields ?? []; 25404 const headerMenuRef = (column, index) => (node) => { 25405 if (node) { 25406 headerMenuRefs.current.set(column, { 25407 node, 25408 fallback: columns[index > 0 ? index - 1 : 1] 25409 }); 25410 } else { 25411 headerMenuRefs.current.delete(column); 25412 } 25413 }; 25414 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup; 25415 return /* @__PURE__ */ (0, import_jsx_runtime191.jsxs)(import_jsx_runtime191.Fragment, { children: [ 25416 /* @__PURE__ */ (0, import_jsx_runtime191.jsxs)( 25417 "table", 25418 { 25419 className: clsx_default("dataviews-view-table", className, { 25420 [`has-$view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes( 25421 view.layout.density 25422 ), 25423 "has-bulk-actions": hasBulkActions 25424 }), 25425 "aria-busy": isLoading, 25426 "aria-describedby": tableNoticeId, 25427 role: isInfiniteScroll ? "feed" : void 0, 25428 children: [ 25429 /* @__PURE__ */ (0, import_jsx_runtime191.jsxs)("colgroup", { children: [ 25430 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime191.jsx)("col", { className: "dataviews-view-table__col-checkbox" }), 25431 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime191.jsx)("col", { className: "dataviews-view-table__col-first-data" }), 25432 columns.map((column, index) => /* @__PURE__ */ (0, import_jsx_runtime191.jsx)( 25433 "col", 25434 { 25435 className: clsx_default( 25436 `dataviews-view-table__col-$column}`, 25437 { 25438 "dataviews-view-table__col-first-data": !hasPrimaryColumn && index === 0 25439 } 25440 ) 25441 }, 25442 `col-$column}` 25443 )), 25444 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime191.jsx)("col", { className: "dataviews-view-table__col-actions" }) 25445 ] }), 25446 contextMenuAnchor && /* @__PURE__ */ (0, import_jsx_runtime191.jsx)( 25447 import_components98.Popover, 25448 { 25449 anchor: contextMenuAnchor, 25450 onClose: () => setContextMenuAnchor(null), 25451 placement: "bottom-start", 25452 children: /* @__PURE__ */ (0, import_jsx_runtime191.jsx)(PropertiesSection, { showLabel: false }) 25453 } 25454 ), 25455 /* @__PURE__ */ (0, import_jsx_runtime191.jsx)("thead", { onContextMenu: handleHeaderContextMenu, children: /* @__PURE__ */ (0, import_jsx_runtime191.jsxs)("tr", { className: "dataviews-view-table__row", children: [ 25456 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime191.jsx)( 25457 "th", 25458 { 25459 className: "dataviews-view-table__checkbox-column", 25460 scope: "col", 25461 onContextMenu: handleHeaderContextMenu, 25462 children: /* @__PURE__ */ (0, import_jsx_runtime191.jsx)( 25463 BulkSelectionCheckbox, 25464 { 25465 selection, 25466 onChangeSelection, 25467 data, 25468 actions, 25469 getItemId: getItemId2 25470 } 25471 ) 25472 } 25473 ), 25474 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime191.jsx)("th", { scope: "col", children: titleField && /* @__PURE__ */ (0, import_jsx_runtime191.jsx)( 25475 column_header_menu_default, 25476 { 25477 ref: headerMenuRef( 25478 titleField.id, 25479 0 25480 ), 25481 fieldId: titleField.id, 25482 view, 25483 fields, 25484 onChangeView, 25485 onHide, 25486 setOpenedFilter, 25487 canMove: false, 25488 canInsertLeft: false, 25489 canInsertRight: view.layout?.enableMoving ?? true 25490 } 25491 ) }), 25492 columns.map((column, index) => { 25493 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {}; 25494 const canInsertOrMove = view.layout?.enableMoving ?? true; 25495 return /* @__PURE__ */ (0, import_jsx_runtime191.jsx)( 25496 "th", 25497 { 25498 style: { 25499 width, 25500 maxWidth, 25501 minWidth, 25502 textAlign: align 25503 }, 25504 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0, 25505 scope: "col", 25506 children: /* @__PURE__ */ (0, import_jsx_runtime191.jsx)( 25507 column_header_menu_default, 25508 { 25509 ref: headerMenuRef(column, index), 25510 fieldId: column, 25511 view, 25512 fields, 25513 onChangeView, 25514 onHide, 25515 setOpenedFilter, 25516 canMove: canInsertOrMove, 25517 canInsertLeft: canInsertOrMove, 25518 canInsertRight: canInsertOrMove 25519 } 25520 ) 25521 }, 25522 column 25523 ); 25524 }), 25525 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime191.jsx)( 25526 "th", 25527 { 25528 className: clsx_default( 25529 "dataviews-view-table__actions-column", 25530 { 25531 "dataviews-view-table__actions-column--sticky": true, 25532 "dataviews-view-table__actions-column--stuck": !isHorizontalScrollEnd 25533 } 25534 ), 25535 children: /* @__PURE__ */ (0, import_jsx_runtime191.jsx)("span", { className: "dataviews-view-table-header", children: (0, import_i18n90.__)("Actions") }) 25536 } 25537 ) 25538 ] }) }), 25539 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map( 25540 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime191.jsxs)("tbody", { children: [ 25541 /* @__PURE__ */ (0, import_jsx_runtime191.jsx)("tr", { className: "dataviews-view-table__group-header-row", children: /* @__PURE__ */ (0, import_jsx_runtime191.jsx)( 25542 "td", 25543 { 25544 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + (hasBulkActions ? 1 : 0) + (actions?.length ? 1 : 0), 25545 className: "dataviews-view-table__group-header-cell", 25546 children: (0, import_i18n90.sprintf)( 25547 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022". 25548 (0, import_i18n90.__)("%1$s: %2$s"), 25549 groupField.label, 25550 groupName 25551 ) 25552 } 25553 ) }), 25554 groupItems.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime191.jsx)( 25555 TableRow, 25556 { 25557 item, 25558 level: view.showLevels && typeof getItemLevel2 === "function" ? getItemLevel2(item) : void 0, 25559 hasBulkActions, 25560 actions, 25561 fields, 25562 id: getItemId2(item) || index.toString(), 25563 view, 25564 titleField, 25565 mediaField, 25566 descriptionField: descriptionField2, 25567 selection, 25568 getItemId: getItemId2, 25569 onChangeSelection, 25570 onClickItem, 25571 renderItemLink, 25572 isItemClickable, 25573 isActionsColumnSticky: !isHorizontalScrollEnd 25574 }, 25575 getItemId2(item) 25576 )) 25577 ] }, `group-$groupName}`) 25578 ) : /* @__PURE__ */ (0, import_jsx_runtime191.jsx)("tbody", { children: hasData && data.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime191.jsx)( 25579 TableRow, 25580 { 25581 item, 25582 level: view.showLevels && typeof getItemLevel2 === "function" ? getItemLevel2(item) : void 0, 25583 hasBulkActions, 25584 actions, 25585 fields, 25586 id: getItemId2(item) || index.toString(), 25587 view, 25588 titleField, 25589 mediaField, 25590 descriptionField: descriptionField2, 25591 selection, 25592 getItemId: getItemId2, 25593 onChangeSelection, 25594 onClickItem, 25595 renderItemLink, 25596 isItemClickable, 25597 isActionsColumnSticky: !isHorizontalScrollEnd, 25598 posinset: isInfiniteScroll ? index + 1 : void 0 25599 }, 25600 getItemId2(item) 25601 )) }) 25602 ] 25603 } 25604 ), 25605 /* @__PURE__ */ (0, import_jsx_runtime191.jsxs)( 25606 "div", 25607 { 25608 className: clsx_default({ 25609 "dataviews-loading": isLoading, 25610 "dataviews-no-results": !hasData && !isLoading 25611 }), 25612 id: tableNoticeId, 25613 children: [ 25614 !hasData && (isLoading ? /* @__PURE__ */ (0, import_jsx_runtime191.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime191.jsx)(import_components98.Spinner, {}) }) : empty), 25615 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime191.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime191.jsx)(import_components98.Spinner, {}) }) 25616 ] 25617 } 25618 ) 25619 ] }); 25620 } 25621 var table_default = ViewTable; 25622 25623 // packages/dataviews/build-module/dataviews-layouts/grid/index.js 25624 var import_components101 = __toESM(require_components()); 25625 var import_i18n93 = __toESM(require_i18n()); 25626 25627 // packages/dataviews/build-module/dataviews-layouts/grid/composite-grid.js 25628 var import_components100 = __toESM(require_components()); 25629 var import_i18n92 = __toESM(require_i18n()); 25630 var import_compose15 = __toESM(require_compose()); 25631 var import_keycodes7 = __toESM(require_keycodes()); 25632 var import_element74 = __toESM(require_element()); 25633 25634 // packages/dataviews/build-module/dataviews-layouts/grid/preview-size-picker.js 25635 var import_components99 = __toESM(require_components()); 25636 var import_i18n91 = __toESM(require_i18n()); 25637 var import_element73 = __toESM(require_element()); 25638 var import_jsx_runtime192 = __toESM(require_jsx_runtime()); 25639 var imageSizes = [ 25640 { 25641 value: 120, 25642 breakpoint: 1 25643 }, 25644 { 25645 value: 170, 25646 breakpoint: 1 25647 }, 25648 { 25649 value: 230, 25650 breakpoint: 1 25651 }, 25652 { 25653 value: 290, 25654 breakpoint: 1112 25655 // at minimum image width, 4 images display at this container size 25656 }, 25657 { 25658 value: 350, 25659 breakpoint: 1636 25660 // at minimum image width, 6 images display at this container size 25661 }, 25662 { 25663 value: 430, 25664 breakpoint: 588 25665 // at minimum image width, 2 images display at this container size 25666 } 25667 ]; 25668 var DEFAULT_PREVIEW_SIZE = imageSizes[2].value; 25669 function useGridColumns() { 25670 const context = (0, import_element73.useContext)(dataviews_context_default); 25671 const view = context.view; 25672 return (0, import_element73.useMemo)(() => { 25673 const containerWidth = context.containerWidth; 25674 const gap = 32; 25675 const previewSize = view.layout?.previewSize ?? DEFAULT_PREVIEW_SIZE; 25676 const columns = Math.floor( 25677 (containerWidth + gap) / (previewSize + gap) 25678 ); 25679 return Math.max(1, columns); 25680 }, [context.containerWidth, view.layout?.previewSize]); 25681 } 25682 25683 // packages/dataviews/build-module/dataviews-layouts/grid/composite-grid.js 25684 var import_jsx_runtime193 = __toESM(require_jsx_runtime()); 25685 var { Badge } = unlock3(import_components100.privateApis); 25686 function chunk(array, size) { 25687 const chunks = []; 25688 for (let i2 = 0, j2 = array.length; i2 < j2; i2 += size) { 25689 chunks.push(array.slice(i2, i2 + size)); 25690 } 25691 return chunks; 25692 } 25693 var GridItem = (0, import_element74.forwardRef)(function GridItem2({ 25694 view, 25695 selection, 25696 onChangeSelection, 25697 onClickItem, 25698 isItemClickable, 25699 renderItemLink, 25700 getItemId: getItemId2, 25701 item, 25702 actions, 25703 mediaField, 25704 titleField, 25705 descriptionField: descriptionField2, 25706 regularFields, 25707 badgeFields, 25708 hasBulkActions, 25709 config: config2, 25710 ...props 25711 }, ref) { 25712 const { showTitle = true, showMedia = true, showDescription = true } = view; 25713 const hasBulkAction = useHasAPossibleBulkAction(actions, item); 25714 const id = getItemId2(item); 25715 const instanceId = (0, import_compose15.useInstanceId)(GridItem2); 25716 const isSelected2 = selection.includes(id); 25717 const renderedMediaField = mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime193.jsx)( 25718 mediaField.render, 25719 { 25720 item, 25721 field: mediaField, 25722 config: config2 25723 } 25724 ) : null; 25725 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime193.jsx)(titleField.render, { item, field: titleField }) : null; 25726 const shouldRenderMedia = showMedia && renderedMediaField; 25727 let mediaA11yProps; 25728 let titleA11yProps; 25729 if (isItemClickable(item) && onClickItem) { 25730 if (renderedTitleField) { 25731 mediaA11yProps = { 25732 "aria-labelledby": `dataviews-view-grid__title-field-$instanceId}` 25733 }; 25734 titleA11yProps = { 25735 id: `dataviews-view-grid__title-field-$instanceId}` 25736 }; 25737 } else { 25738 mediaA11yProps = { 25739 "aria-label": (0, import_i18n92.__)("Navigate to item") 25740 }; 25741 } 25742 } 25743 return /* @__PURE__ */ (0, import_jsx_runtime193.jsxs)( 25744 import_components100.__experimentalVStack, 25745 { 25746 ...props, 25747 ref, 25748 spacing: 0, 25749 className: clsx_default( 25750 props.className, 25751 "dataviews-view-grid__row__gridcell", 25752 "dataviews-view-grid__card", 25753 { 25754 "is-selected": hasBulkAction && isSelected2 25755 } 25756 ), 25757 onClickCapture: (event) => { 25758 props.onClickCapture?.(event); 25759 if ((0, import_keycodes7.isAppleOS)() ? event.metaKey : event.ctrlKey) { 25760 event.stopPropagation(); 25761 event.preventDefault(); 25762 if (!hasBulkAction) { 25763 return; 25764 } 25765 onChangeSelection( 25766 selection.includes(id) ? selection.filter((itemId) => id !== itemId) : [...selection, id] 25767 ); 25768 } 25769 }, 25770 children: [ 25771 shouldRenderMedia && /* @__PURE__ */ (0, import_jsx_runtime193.jsx)( 25772 ItemClickWrapper, 25773 { 25774 item, 25775 isItemClickable, 25776 onClickItem, 25777 renderItemLink, 25778 className: "dataviews-view-grid__media", 25779 ...mediaA11yProps, 25780 children: renderedMediaField 25781 } 25782 ), 25783 hasBulkActions && shouldRenderMedia && /* @__PURE__ */ (0, import_jsx_runtime193.jsx)( 25784 DataViewsSelectionCheckbox, 25785 { 25786 item, 25787 selection, 25788 onChangeSelection, 25789 getItemId: getItemId2, 25790 titleField, 25791 disabled: !hasBulkAction 25792 } 25793 ), 25794 !showTitle && shouldRenderMedia && !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime193.jsx)("div", { className: "dataviews-view-grid__media-actions", children: /* @__PURE__ */ (0, import_jsx_runtime193.jsx)(ItemActions, { item, actions, isCompact: true }) }), 25795 showTitle && /* @__PURE__ */ (0, import_jsx_runtime193.jsxs)( 25796 import_components100.__experimentalHStack, 25797 { 25798 justify: "space-between", 25799 className: "dataviews-view-grid__title-actions", 25800 children: [ 25801 /* @__PURE__ */ (0, import_jsx_runtime193.jsx)( 25802 ItemClickWrapper, 25803 { 25804 item, 25805 isItemClickable, 25806 onClickItem, 25807 renderItemLink, 25808 className: "dataviews-view-grid__title-field dataviews-title-field", 25809 ...titleA11yProps, 25810 children: renderedTitleField 25811 } 25812 ), 25813 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime193.jsx)( 25814 ItemActions, 25815 { 25816 item, 25817 actions, 25818 isCompact: true 25819 } 25820 ) 25821 ] 25822 } 25823 ), 25824 /* @__PURE__ */ (0, import_jsx_runtime193.jsxs)(import_components100.__experimentalVStack, { spacing: 1, children: [ 25825 showDescription && descriptionField2?.render && /* @__PURE__ */ (0, import_jsx_runtime193.jsx)( 25826 descriptionField2.render, 25827 { 25828 item, 25829 field: descriptionField2 25830 } 25831 ), 25832 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime193.jsx)( 25833 import_components100.__experimentalHStack, 25834 { 25835 className: "dataviews-view-grid__badge-fields", 25836 spacing: 2, 25837 wrap: true, 25838 alignment: "top", 25839 justify: "flex-start", 25840 children: badgeFields.map((field) => { 25841 return /* @__PURE__ */ (0, import_jsx_runtime193.jsx)( 25842 Badge, 25843 { 25844 className: "dataviews-view-grid__field-value", 25845 children: /* @__PURE__ */ (0, import_jsx_runtime193.jsx)( 25846 field.render, 25847 { 25848 item, 25849 field 25850 } 25851 ) 25852 }, 25853 field.id 25854 ); 25855 }) 25856 } 25857 ), 25858 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime193.jsx)( 25859 import_components100.__experimentalVStack, 25860 { 25861 className: "dataviews-view-grid__fields", 25862 spacing: 1, 25863 children: regularFields.map((field) => { 25864 return /* @__PURE__ */ (0, import_jsx_runtime193.jsx)( 25865 import_components100.Flex, 25866 { 25867 className: "dataviews-view-grid__field", 25868 gap: 1, 25869 justify: "flex-start", 25870 expanded: true, 25871 style: { height: "auto" }, 25872 direction: "row", 25873 children: /* @__PURE__ */ (0, import_jsx_runtime193.jsxs)(import_jsx_runtime193.Fragment, { children: [ 25874 /* @__PURE__ */ (0, import_jsx_runtime193.jsx)(import_components100.Tooltip, { text: field.label, children: /* @__PURE__ */ (0, import_jsx_runtime193.jsx)(import_components100.FlexItem, { className: "dataviews-view-grid__field-name", children: field.header }) }), 25875 /* @__PURE__ */ (0, import_jsx_runtime193.jsx)( 25876 import_components100.FlexItem, 25877 { 25878 className: "dataviews-view-grid__field-value", 25879 style: { maxHeight: "none" }, 25880 children: /* @__PURE__ */ (0, import_jsx_runtime193.jsx)( 25881 field.render, 25882 { 25883 item, 25884 field 25885 } 25886 ) 25887 } 25888 ) 25889 ] }) 25890 }, 25891 field.id 25892 ); 25893 }) 25894 } 25895 ) 25896 ] }) 25897 ] 25898 } 25899 ); 25900 }); 25901 function CompositeGrid({ 25902 data, 25903 isInfiniteScroll, 25904 className, 25905 isLoading, 25906 view, 25907 fields, 25908 selection, 25909 onChangeSelection, 25910 onClickItem, 25911 isItemClickable, 25912 renderItemLink, 25913 getItemId: getItemId2, 25914 actions 25915 }) { 25916 const { paginationInfo, resizeObserverRef } = (0, import_element74.useContext)(dataviews_context_default); 25917 const gridColumns = useGridColumns(); 25918 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data); 25919 const titleField = fields.find( 25920 (field) => field.id === view?.titleField 25921 ); 25922 const mediaField = fields.find( 25923 (field) => field.id === view?.mediaField 25924 ); 25925 const descriptionField2 = fields.find( 25926 (field) => field.id === view?.descriptionField 25927 ); 25928 const otherFields = view.fields ?? []; 25929 const { regularFields, badgeFields } = otherFields.reduce( 25930 (accumulator, fieldId) => { 25931 const field = fields.find((f2) => f2.id === fieldId); 25932 if (!field) { 25933 return accumulator; 25934 } 25935 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields"; 25936 accumulator[key].push(field); 25937 return accumulator; 25938 }, 25939 { regularFields: [], badgeFields: [] } 25940 ); 25941 const size = "900px"; 25942 const totalRows = Math.ceil(data.length / gridColumns); 25943 return /* @__PURE__ */ (0, import_jsx_runtime193.jsx)( 25944 import_components100.Composite, 25945 { 25946 role: isInfiniteScroll ? "feed" : "grid", 25947 className: clsx_default("dataviews-view-grid", className), 25948 focusWrap: true, 25949 "aria-busy": isLoading, 25950 "aria-rowcount": isInfiniteScroll ? void 0 : totalRows, 25951 ref: resizeObserverRef, 25952 children: chunk(data, gridColumns).map((row, i2) => /* @__PURE__ */ (0, import_jsx_runtime193.jsx)( 25953 import_components100.Composite.Row, 25954 { 25955 render: /* @__PURE__ */ (0, import_jsx_runtime193.jsx)( 25956 "div", 25957 { 25958 role: "row", 25959 "aria-rowindex": i2 + 1, 25960 "aria-label": (0, import_i18n92.sprintf)( 25961 /* translators: %d: The row number in the grid */ 25962 (0, import_i18n92.__)("Row %d"), 25963 i2 + 1 25964 ), 25965 className: "dataviews-view-grid__row", 25966 style: { 25967 gridTemplateColumns: `repeat( $gridColumns}, minmax(0, 1fr) )` 25968 } 25969 } 25970 ), 25971 children: row.map((item, indexInRow) => { 25972 const index = i2 * gridColumns + indexInRow; 25973 return /* @__PURE__ */ (0, import_jsx_runtime193.jsx)( 25974 import_components100.Composite.Item, 25975 { 25976 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime193.jsx)( 25977 GridItem, 25978 { 25979 ...props, 25980 role: isInfiniteScroll ? "article" : "gridcell", 25981 "aria-setsize": isInfiniteScroll ? paginationInfo.totalItems : void 0, 25982 "aria-posinset": isInfiniteScroll ? index + 1 : void 0, 25983 view, 25984 selection, 25985 onChangeSelection, 25986 onClickItem, 25987 isItemClickable, 25988 renderItemLink, 25989 getItemId: getItemId2, 25990 item, 25991 actions, 25992 mediaField, 25993 titleField, 25994 descriptionField: descriptionField2, 25995 regularFields, 25996 badgeFields, 25997 hasBulkActions, 25998 config: { 25999 sizes: size 26000 } 26001 } 26002 ) 26003 }, 26004 getItemId2(item) 26005 ); 26006 }) 26007 }, 26008 i2 26009 )) 26010 } 26011 ); 26012 } 26013 26014 // packages/dataviews/build-module/dataviews-layouts/grid/index.js 26015 var import_jsx_runtime194 = __toESM(require_jsx_runtime()); 26016 function ViewGrid({ 26017 actions, 26018 data, 26019 fields, 26020 getItemId: getItemId2, 26021 isLoading, 26022 onChangeSelection, 26023 onClickItem, 26024 isItemClickable, 26025 renderItemLink, 26026 selection, 26027 view, 26028 className, 26029 empty 26030 }) { 26031 const hasData = !!data?.length; 26032 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null; 26033 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null; 26034 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup; 26035 const gridProps = { 26036 className, 26037 isLoading, 26038 view, 26039 fields, 26040 selection, 26041 onChangeSelection, 26042 onClickItem, 26043 isItemClickable, 26044 renderItemLink, 26045 getItemId: getItemId2, 26046 actions 26047 }; 26048 return /* @__PURE__ */ (0, import_jsx_runtime194.jsxs)(import_jsx_runtime194.Fragment, { 26049 // Render multiple groups. 26050 children: [ 26051 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime194.jsx)(import_components101.__experimentalVStack, { spacing: 4, children: Array.from(dataByGroup.entries()).map( 26052 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime194.jsxs)(import_components101.__experimentalVStack, { spacing: 2, children: [ 26053 /* @__PURE__ */ (0, import_jsx_runtime194.jsx)("h3", { className: "dataviews-view-grid__group-header", children: (0, import_i18n93.sprintf)( 26054 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022". 26055 (0, import_i18n93.__)("%1$s: %2$s"), 26056 groupField.label, 26057 groupName 26058 ) }), 26059 /* @__PURE__ */ (0, import_jsx_runtime194.jsx)( 26060 CompositeGrid, 26061 { 26062 ...gridProps, 26063 data: groupItems, 26064 isInfiniteScroll: false 26065 } 26066 ) 26067 ] }, groupName) 26068 ) }), 26069 // Render a single grid with all data. 26070 hasData && !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime194.jsx)( 26071 CompositeGrid, 26072 { 26073 ...gridProps, 26074 data, 26075 isInfiniteScroll: !!isInfiniteScroll 26076 } 26077 ), 26078 // Render empty state. 26079 !hasData && /* @__PURE__ */ (0, import_jsx_runtime194.jsx)( 26080 "div", 26081 { 26082 className: clsx_default({ 26083 "dataviews-loading": isLoading, 26084 "dataviews-no-results": !isLoading 26085 }), 26086 children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime194.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime194.jsx)(import_components101.Spinner, {}) }) : empty 26087 } 26088 ), 26089 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime194.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime194.jsx)(import_components101.Spinner, {}) }) 26090 ] 26091 }); 26092 } 26093 var grid_default = ViewGrid; 26094 26095 // packages/dataviews/build-module/dataviews-layouts/list/index.js 26096 var import_compose16 = __toESM(require_compose()); 26097 var import_components102 = __toESM(require_components()); 26098 var import_element75 = __toESM(require_element()); 26099 var import_i18n94 = __toESM(require_i18n()); 26100 var import_data59 = __toESM(require_data()); 26101 var import_jsx_runtime195 = __toESM(require_jsx_runtime()); 26102 var { Menu: Menu7 } = unlock3(import_components102.privateApis); 26103 function generateItemWrapperCompositeId(idPrefix) { 26104 return `$idPrefix}-item-wrapper`; 26105 } 26106 function generatePrimaryActionCompositeId(idPrefix, primaryActionId) { 26107 return `$idPrefix}-primary-action-$primaryActionId}`; 26108 } 26109 function generateDropdownTriggerCompositeId(idPrefix) { 26110 return `$idPrefix}-dropdown`; 26111 } 26112 function PrimaryActionGridCell({ 26113 idPrefix, 26114 primaryAction, 26115 item 26116 }) { 26117 const registry = (0, import_data59.useRegistry)(); 26118 const [isModalOpen, setIsModalOpen] = (0, import_element75.useState)(false); 26119 const compositeItemId = generatePrimaryActionCompositeId( 26120 idPrefix, 26121 primaryAction.id 26122 ); 26123 const label = typeof primaryAction.label === "string" ? primaryAction.label : primaryAction.label([item]); 26124 return "RenderModal" in primaryAction ? /* @__PURE__ */ (0, import_jsx_runtime195.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime195.jsx)( 26125 import_components102.Composite.Item, 26126 { 26127 id: compositeItemId, 26128 render: /* @__PURE__ */ (0, import_jsx_runtime195.jsx)( 26129 import_components102.Button, 26130 { 26131 disabled: !!primaryAction.disabled, 26132 accessibleWhenDisabled: true, 26133 text: label, 26134 size: "small", 26135 onClick: () => setIsModalOpen(true) 26136 } 26137 ), 26138 children: isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime195.jsx)( 26139 ActionModal, 26140 { 26141 action: primaryAction, 26142 items: [item], 26143 closeModal: () => setIsModalOpen(false) 26144 } 26145 ) 26146 } 26147 ) }, primaryAction.id) : /* @__PURE__ */ (0, import_jsx_runtime195.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime195.jsx)( 26148 import_components102.Composite.Item, 26149 { 26150 id: compositeItemId, 26151 render: /* @__PURE__ */ (0, import_jsx_runtime195.jsx)( 26152 import_components102.Button, 26153 { 26154 disabled: !!primaryAction.disabled, 26155 accessibleWhenDisabled: true, 26156 size: "small", 26157 onClick: () => { 26158 primaryAction.callback([item], { registry }); 26159 }, 26160 children: label 26161 } 26162 ) 26163 } 26164 ) }, primaryAction.id); 26165 } 26166 function ListItem({ 26167 view, 26168 actions, 26169 idPrefix, 26170 isSelected: isSelected2, 26171 item, 26172 titleField, 26173 mediaField, 26174 descriptionField: descriptionField2, 26175 onSelect, 26176 otherFields, 26177 onDropdownTriggerKeyDown, 26178 posinset 26179 }) { 26180 const { 26181 showTitle = true, 26182 showMedia = true, 26183 showDescription = true, 26184 infiniteScrollEnabled 26185 } = view; 26186 const itemRef = (0, import_element75.useRef)(null); 26187 const labelId = `$idPrefix}-label`; 26188 const descriptionId = `$idPrefix}-description`; 26189 const registry = (0, import_data59.useRegistry)(); 26190 const [isHovered, setIsHovered] = (0, import_element75.useState)(false); 26191 const [activeModalAction, setActiveModalAction] = (0, import_element75.useState)( 26192 null 26193 ); 26194 const handleHover = ({ type }) => { 26195 const isHover = type === "mouseenter"; 26196 setIsHovered(isHover); 26197 }; 26198 const { paginationInfo } = (0, import_element75.useContext)(dataviews_context_default); 26199 (0, import_element75.useEffect)(() => { 26200 if (isSelected2) { 26201 itemRef.current?.scrollIntoView({ 26202 behavior: "auto", 26203 block: "nearest", 26204 inline: "nearest" 26205 }); 26206 } 26207 }, [isSelected2]); 26208 const { primaryAction, eligibleActions } = (0, import_element75.useMemo)(() => { 26209 const _eligibleActions = actions.filter( 26210 (action) => !action.isEligible || action.isEligible(item) 26211 ); 26212 const _primaryActions = _eligibleActions.filter( 26213 (action) => action.isPrimary 26214 ); 26215 return { 26216 primaryAction: _primaryActions[0], 26217 eligibleActions: _eligibleActions 26218 }; 26219 }, [actions, item]); 26220 const hasOnlyOnePrimaryAction = primaryAction && actions.length === 1; 26221 const renderedMediaField = showMedia && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime195.jsx)("div", { className: "dataviews-view-list__media-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime195.jsx)( 26222 mediaField.render, 26223 { 26224 item, 26225 field: mediaField, 26226 config: { sizes: "52px" } 26227 } 26228 ) }) : null; 26229 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime195.jsx)(titleField.render, { item, field: titleField }) : null; 26230 const usedActions = eligibleActions?.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime195.jsxs)(import_components102.__experimentalHStack, { spacing: 3, className: "dataviews-view-list__item-actions", children: [ 26231 primaryAction && /* @__PURE__ */ (0, import_jsx_runtime195.jsx)( 26232 PrimaryActionGridCell, 26233 { 26234 idPrefix, 26235 primaryAction, 26236 item 26237 } 26238 ), 26239 !hasOnlyOnePrimaryAction && /* @__PURE__ */ (0, import_jsx_runtime195.jsxs)("div", { role: "gridcell", children: [ 26240 /* @__PURE__ */ (0, import_jsx_runtime195.jsxs)(Menu7, { placement: "bottom-end", children: [ 26241 /* @__PURE__ */ (0, import_jsx_runtime195.jsx)( 26242 Menu7.TriggerButton, 26243 { 26244 render: /* @__PURE__ */ (0, import_jsx_runtime195.jsx)( 26245 import_components102.Composite.Item, 26246 { 26247 id: generateDropdownTriggerCompositeId( 26248 idPrefix 26249 ), 26250 render: /* @__PURE__ */ (0, import_jsx_runtime195.jsx)( 26251 import_components102.Button, 26252 { 26253 size: "small", 26254 icon: more_vertical_default, 26255 label: (0, import_i18n94.__)("Actions"), 26256 accessibleWhenDisabled: true, 26257 disabled: !actions.length, 26258 onKeyDown: onDropdownTriggerKeyDown 26259 } 26260 ) 26261 } 26262 ) 26263 } 26264 ), 26265 /* @__PURE__ */ (0, import_jsx_runtime195.jsx)(Menu7.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime195.jsx)( 26266 ActionsMenuGroup, 26267 { 26268 actions: eligibleActions, 26269 item, 26270 registry, 26271 setActiveModalAction 26272 } 26273 ) }) 26274 ] }), 26275 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime195.jsx)( 26276 ActionModal, 26277 { 26278 action: activeModalAction, 26279 items: [item], 26280 closeModal: () => setActiveModalAction(null) 26281 } 26282 ) 26283 ] }) 26284 ] }); 26285 return /* @__PURE__ */ (0, import_jsx_runtime195.jsx)( 26286 import_components102.Composite.Row, 26287 { 26288 ref: itemRef, 26289 render: ( 26290 /* aria-posinset breaks Composite.Row if passed to it directly. */ 26291 /* @__PURE__ */ (0, import_jsx_runtime195.jsx)( 26292 "div", 26293 { 26294 "aria-posinset": posinset, 26295 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0 26296 } 26297 ) 26298 ), 26299 role: infiniteScrollEnabled ? "article" : "row", 26300 className: clsx_default({ 26301 "is-selected": isSelected2, 26302 "is-hovered": isHovered 26303 }), 26304 onMouseEnter: handleHover, 26305 onMouseLeave: handleHover, 26306 children: /* @__PURE__ */ (0, import_jsx_runtime195.jsxs)(import_components102.__experimentalHStack, { className: "dataviews-view-list__item-wrapper", spacing: 0, children: [ 26307 /* @__PURE__ */ (0, import_jsx_runtime195.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime195.jsx)( 26308 import_components102.Composite.Item, 26309 { 26310 id: generateItemWrapperCompositeId(idPrefix), 26311 "aria-pressed": isSelected2, 26312 "aria-labelledby": labelId, 26313 "aria-describedby": descriptionId, 26314 className: "dataviews-view-list__item", 26315 onClick: () => onSelect(item) 26316 } 26317 ) }), 26318 /* @__PURE__ */ (0, import_jsx_runtime195.jsxs)(import_components102.__experimentalHStack, { spacing: 3, justify: "start", alignment: "flex-start", children: [ 26319 renderedMediaField, 26320 /* @__PURE__ */ (0, import_jsx_runtime195.jsxs)( 26321 import_components102.__experimentalVStack, 26322 { 26323 spacing: 1, 26324 className: "dataviews-view-list__field-wrapper", 26325 children: [ 26326 /* @__PURE__ */ (0, import_jsx_runtime195.jsxs)(import_components102.__experimentalHStack, { spacing: 0, children: [ 26327 /* @__PURE__ */ (0, import_jsx_runtime195.jsx)( 26328 "div", 26329 { 26330 className: "dataviews-title-field", 26331 id: labelId, 26332 children: renderedTitleField 26333 } 26334 ), 26335 usedActions 26336 ] }), 26337 showDescription && descriptionField2?.render && /* @__PURE__ */ (0, import_jsx_runtime195.jsx)("div", { className: "dataviews-view-list__field", children: /* @__PURE__ */ (0, import_jsx_runtime195.jsx)( 26338 descriptionField2.render, 26339 { 26340 item, 26341 field: descriptionField2 26342 } 26343 ) }), 26344 /* @__PURE__ */ (0, import_jsx_runtime195.jsx)( 26345 "div", 26346 { 26347 className: "dataviews-view-list__fields", 26348 id: descriptionId, 26349 children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime195.jsxs)( 26350 "div", 26351 { 26352 className: "dataviews-view-list__field", 26353 children: [ 26354 /* @__PURE__ */ (0, import_jsx_runtime195.jsx)( 26355 import_components102.VisuallyHidden, 26356 { 26357 as: "span", 26358 className: "dataviews-view-list__field-label", 26359 children: field.label 26360 } 26361 ), 26362 /* @__PURE__ */ (0, import_jsx_runtime195.jsx)("span", { className: "dataviews-view-list__field-value", children: /* @__PURE__ */ (0, import_jsx_runtime195.jsx)( 26363 field.render, 26364 { 26365 item, 26366 field 26367 } 26368 ) }) 26369 ] 26370 }, 26371 field.id 26372 )) 26373 } 26374 ) 26375 ] 26376 } 26377 ) 26378 ] }) 26379 ] }) 26380 } 26381 ); 26382 } 26383 function isDefined2(item) { 26384 return !!item; 26385 } 26386 function ViewList(props) { 26387 const { 26388 actions, 26389 data, 26390 fields, 26391 getItemId: getItemId2, 26392 isLoading, 26393 onChangeSelection, 26394 selection, 26395 view, 26396 className, 26397 empty 26398 } = props; 26399 const baseId = (0, import_compose16.useInstanceId)(ViewList, "view-list"); 26400 const selectedItem = data?.findLast( 26401 (item) => selection.includes(getItemId2(item)) 26402 ); 26403 const titleField = fields.find((field) => field.id === view.titleField); 26404 const mediaField = fields.find((field) => field.id === view.mediaField); 26405 const descriptionField2 = fields.find( 26406 (field) => field.id === view.descriptionField 26407 ); 26408 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined2); 26409 const onSelect = (item) => onChangeSelection([getItemId2(item)]); 26410 const generateCompositeItemIdPrefix = (0, import_element75.useCallback)( 26411 (item) => `$baseId}-$getItemId2(item)}`, 26412 [baseId, getItemId2] 26413 ); 26414 const isActiveCompositeItem = (0, import_element75.useCallback)( 26415 (item, idToCheck) => { 26416 return idToCheck.startsWith( 26417 generateCompositeItemIdPrefix(item) 26418 ); 26419 }, 26420 [generateCompositeItemIdPrefix] 26421 ); 26422 const [activeCompositeId, setActiveCompositeId] = (0, import_element75.useState)(void 0); 26423 (0, import_element75.useEffect)(() => { 26424 if (selectedItem) { 26425 setActiveCompositeId( 26426 generateItemWrapperCompositeId( 26427 generateCompositeItemIdPrefix(selectedItem) 26428 ) 26429 ); 26430 } 26431 }, [selectedItem, generateCompositeItemIdPrefix]); 26432 const activeItemIndex = data.findIndex( 26433 (item) => isActiveCompositeItem(item, activeCompositeId ?? "") 26434 ); 26435 const previousActiveItemIndex = (0, import_compose16.usePrevious)(activeItemIndex); 26436 const isActiveIdInList = activeItemIndex !== -1; 26437 const selectCompositeItem = (0, import_element75.useCallback)( 26438 (targetIndex, generateCompositeId) => { 26439 const clampedIndex = Math.min( 26440 data.length - 1, 26441 Math.max(0, targetIndex) 26442 ); 26443 if (!data[clampedIndex]) { 26444 return; 26445 } 26446 const itemIdPrefix = generateCompositeItemIdPrefix( 26447 data[clampedIndex] 26448 ); 26449 const targetCompositeItemId = generateCompositeId(itemIdPrefix); 26450 setActiveCompositeId(targetCompositeItemId); 26451 document.getElementById(targetCompositeItemId)?.focus(); 26452 }, 26453 [data, generateCompositeItemIdPrefix] 26454 ); 26455 (0, import_element75.useEffect)(() => { 26456 const wasActiveIdInList = previousActiveItemIndex !== void 0 && previousActiveItemIndex !== -1; 26457 if (!isActiveIdInList && wasActiveIdInList) { 26458 selectCompositeItem( 26459 previousActiveItemIndex, 26460 generateItemWrapperCompositeId 26461 ); 26462 } 26463 }, [isActiveIdInList, selectCompositeItem, previousActiveItemIndex]); 26464 const onDropdownTriggerKeyDown = (0, import_element75.useCallback)( 26465 (event) => { 26466 if (event.key === "ArrowDown") { 26467 event.preventDefault(); 26468 selectCompositeItem( 26469 activeItemIndex + 1, 26470 generateDropdownTriggerCompositeId 26471 ); 26472 } 26473 if (event.key === "ArrowUp") { 26474 event.preventDefault(); 26475 selectCompositeItem( 26476 activeItemIndex - 1, 26477 generateDropdownTriggerCompositeId 26478 ); 26479 } 26480 }, 26481 [selectCompositeItem, activeItemIndex] 26482 ); 26483 const hasData = data?.length; 26484 if (!hasData) { 26485 return /* @__PURE__ */ (0, import_jsx_runtime195.jsx)( 26486 "div", 26487 { 26488 className: clsx_default({ 26489 "dataviews-loading": isLoading, 26490 "dataviews-no-results": !hasData && !isLoading 26491 }), 26492 children: !hasData && (isLoading ? /* @__PURE__ */ (0, import_jsx_runtime195.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime195.jsx)(import_components102.Spinner, {}) }) : empty) 26493 } 26494 ); 26495 } 26496 const groupField = view.groupBy?.field ? fields.find((field) => field.id === view.groupBy?.field) : null; 26497 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null; 26498 if (hasData && groupField && dataByGroup) { 26499 return /* @__PURE__ */ (0, import_jsx_runtime195.jsx)( 26500 import_components102.Composite, 26501 { 26502 id: `$baseId}`, 26503 render: /* @__PURE__ */ (0, import_jsx_runtime195.jsx)("div", {}), 26504 className: "dataviews-view-list__group", 26505 role: "grid", 26506 activeId: activeCompositeId, 26507 setActiveId: setActiveCompositeId, 26508 children: /* @__PURE__ */ (0, import_jsx_runtime195.jsx)( 26509 import_components102.__experimentalVStack, 26510 { 26511 spacing: 4, 26512 className: clsx_default("dataviews-view-list", className), 26513 children: Array.from(dataByGroup.entries()).map( 26514 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime195.jsxs)(import_components102.__experimentalVStack, { spacing: 2, children: [ 26515 /* @__PURE__ */ (0, import_jsx_runtime195.jsx)("h3", { className: "dataviews-view-list__group-header", children: (0, import_i18n94.sprintf)( 26516 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022". 26517 (0, import_i18n94.__)("%1$s: %2$s"), 26518 groupField.label, 26519 groupName 26520 ) }), 26521 groupItems.map((item) => { 26522 const id = generateCompositeItemIdPrefix(item); 26523 return /* @__PURE__ */ (0, import_jsx_runtime195.jsx)( 26524 ListItem, 26525 { 26526 view, 26527 idPrefix: id, 26528 actions, 26529 item, 26530 isSelected: item === selectedItem, 26531 onSelect, 26532 mediaField, 26533 titleField, 26534 descriptionField: descriptionField2, 26535 otherFields, 26536 onDropdownTriggerKeyDown 26537 }, 26538 id 26539 ); 26540 }) 26541 ] }, groupName) 26542 ) 26543 } 26544 ) 26545 } 26546 ); 26547 } 26548 return /* @__PURE__ */ (0, import_jsx_runtime195.jsxs)(import_jsx_runtime195.Fragment, { children: [ 26549 /* @__PURE__ */ (0, import_jsx_runtime195.jsx)( 26550 import_components102.Composite, 26551 { 26552 id: baseId, 26553 render: /* @__PURE__ */ (0, import_jsx_runtime195.jsx)("div", {}), 26554 className: clsx_default("dataviews-view-list", className), 26555 role: view.infiniteScrollEnabled ? "feed" : "grid", 26556 activeId: activeCompositeId, 26557 setActiveId: setActiveCompositeId, 26558 children: data.map((item, index) => { 26559 const id = generateCompositeItemIdPrefix(item); 26560 return /* @__PURE__ */ (0, import_jsx_runtime195.jsx)( 26561 ListItem, 26562 { 26563 view, 26564 idPrefix: id, 26565 actions, 26566 item, 26567 isSelected: item === selectedItem, 26568 onSelect, 26569 mediaField, 26570 titleField, 26571 descriptionField: descriptionField2, 26572 otherFields, 26573 onDropdownTriggerKeyDown, 26574 posinset: view.infiniteScrollEnabled ? index + 1 : void 0 26575 }, 26576 id 26577 ); 26578 }) 26579 } 26580 ), 26581 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime195.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime195.jsx)(import_components102.Spinner, {}) }) 26582 ] }); 26583 } 26584 26585 // packages/dataviews/build-module/dataviews-layouts/activity/index.js 26586 var import_components105 = __toESM(require_components()); 26587 26588 // packages/dataviews/build-module/dataviews-layouts/activity/activity-group.js 26589 var import_components103 = __toESM(require_components()); 26590 var import_i18n95 = __toESM(require_i18n()); 26591 var import_element76 = __toESM(require_element()); 26592 var import_jsx_runtime196 = __toESM(require_jsx_runtime()); 26593 function ActivityGroup({ 26594 groupName, 26595 groupData, 26596 groupField, 26597 children 26598 }) { 26599 const groupHeader = (0, import_element76.createInterpolateElement)( 26600 // translators: %s: The label of the field e.g. "Status". 26601 (0, import_i18n95.sprintf)((0, import_i18n95.__)("%s: <groupName />"), groupField.label).trim(), 26602 { 26603 groupName: /* @__PURE__ */ (0, import_jsx_runtime196.jsx)( 26604 groupField.render, 26605 { 26606 item: groupData[0], 26607 field: groupField 26608 } 26609 ) 26610 } 26611 ); 26612 return /* @__PURE__ */ (0, import_jsx_runtime196.jsxs)( 26613 import_components103.__experimentalVStack, 26614 { 26615 spacing: 0, 26616 className: "dataviews-view-activity__group", 26617 children: [ 26618 /* @__PURE__ */ (0, import_jsx_runtime196.jsx)("h3", { className: "dataviews-view-activity__group-header", children: groupHeader }), 26619 children 26620 ] 26621 }, 26622 groupName 26623 ); 26624 } 26625 26626 // packages/dataviews/build-module/dataviews-layouts/activity/activity-item.js 26627 var import_components104 = __toESM(require_components()); 26628 var import_element77 = __toESM(require_element()); 26629 var import_data60 = __toESM(require_data()); 26630 var import_jsx_runtime197 = __toESM(require_jsx_runtime()); 26631 function ActivityItem(props) { 26632 const { 26633 view, 26634 actions, 26635 item, 26636 titleField, 26637 mediaField, 26638 descriptionField: descriptionField2, 26639 otherFields, 26640 posinset, 26641 onClickItem, 26642 renderItemLink, 26643 isItemClickable 26644 } = props; 26645 const { 26646 showTitle = true, 26647 showMedia = true, 26648 showDescription = true, 26649 infiniteScrollEnabled 26650 } = view; 26651 const itemRef = (0, import_element77.useRef)(null); 26652 const registry = (0, import_data60.useRegistry)(); 26653 const { paginationInfo } = (0, import_element77.useContext)(dataviews_context_default); 26654 const { primaryActions, eligibleActions } = (0, import_element77.useMemo)(() => { 26655 const _eligibleActions = actions.filter( 26656 (action) => !action.isEligible || action.isEligible(item) 26657 ); 26658 const _primaryActions = _eligibleActions.filter( 26659 (action) => action.isPrimary 26660 ); 26661 return { 26662 primaryActions: _primaryActions, 26663 eligibleActions: _eligibleActions 26664 }; 26665 }, [actions, item]); 26666 const density = view.layout?.density ?? "balanced"; 26667 const mediaContent = showMedia && density !== "compact" && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime197.jsx)( 26668 mediaField.render, 26669 { 26670 item, 26671 field: mediaField, 26672 config: { 26673 sizes: density === "comfortable" ? "32px" : "24px" 26674 } 26675 } 26676 ) : null; 26677 const renderedMediaField = /* @__PURE__ */ (0, import_jsx_runtime197.jsx)("div", { className: "dataviews-view-activity__item-type-icon", children: mediaContent || /* @__PURE__ */ (0, import_jsx_runtime197.jsx)( 26678 "span", 26679 { 26680 className: "dataviews-view-activity__item-bullet", 26681 "aria-hidden": "true" 26682 } 26683 ) }); 26684 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime197.jsx)(titleField.render, { item, field: titleField }) : null; 26685 const verticalSpacing = (0, import_element77.useMemo)(() => { 26686 switch (density) { 26687 case "comfortable": 26688 return "3"; 26689 default: 26690 return "2"; 26691 } 26692 }, [density]); 26693 return /* @__PURE__ */ (0, import_jsx_runtime197.jsx)( 26694 "div", 26695 { 26696 ref: itemRef, 26697 role: infiniteScrollEnabled ? "article" : void 0, 26698 "aria-posinset": posinset, 26699 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0, 26700 className: clsx_default( 26701 "dataviews-view-activity__item", 26702 density === "compact" && "is-compact", 26703 density === "balanced" && "is-balanced", 26704 density === "comfortable" && "is-comfortable" 26705 ), 26706 children: /* @__PURE__ */ (0, import_jsx_runtime197.jsxs)(import_components104.__experimentalHStack, { spacing: 4, justify: "start", alignment: "flex-start", children: [ 26707 /* @__PURE__ */ (0, import_jsx_runtime197.jsx)( 26708 import_components104.__experimentalVStack, 26709 { 26710 spacing: 1, 26711 alignment: "center", 26712 className: "dataviews-view-activity__item-type", 26713 children: renderedMediaField 26714 } 26715 ), 26716 /* @__PURE__ */ (0, import_jsx_runtime197.jsxs)( 26717 import_components104.__experimentalVStack, 26718 { 26719 spacing: verticalSpacing, 26720 alignment: "flex-start", 26721 className: "dataviews-view-activity__item-content", 26722 children: [ 26723 renderedTitleField && /* @__PURE__ */ (0, import_jsx_runtime197.jsx)( 26724 ItemClickWrapper, 26725 { 26726 item, 26727 isItemClickable, 26728 onClickItem, 26729 renderItemLink, 26730 className: "dataviews-view-activity__item-title", 26731 children: renderedTitleField 26732 } 26733 ), 26734 showDescription && descriptionField2 && /* @__PURE__ */ (0, import_jsx_runtime197.jsx)("div", { className: "dataviews-view-activity__item-description", children: /* @__PURE__ */ (0, import_jsx_runtime197.jsx)( 26735 descriptionField2.render, 26736 { 26737 item, 26738 field: descriptionField2 26739 } 26740 ) }), 26741 /* @__PURE__ */ (0, import_jsx_runtime197.jsx)("div", { className: "dataviews-view-activity__item-fields", children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime197.jsxs)( 26742 "div", 26743 { 26744 className: "dataviews-view-activity__item-field", 26745 children: [ 26746 /* @__PURE__ */ (0, import_jsx_runtime197.jsx)( 26747 import_components104.VisuallyHidden, 26748 { 26749 as: "span", 26750 className: "dataviews-view-activity__item-field-label", 26751 children: field.label 26752 } 26753 ), 26754 /* @__PURE__ */ (0, import_jsx_runtime197.jsx)("span", { className: "dataviews-view-activity__item-field-value", children: /* @__PURE__ */ (0, import_jsx_runtime197.jsx)( 26755 field.render, 26756 { 26757 item, 26758 field 26759 } 26760 ) }) 26761 ] 26762 }, 26763 field.id 26764 )) }), 26765 !!primaryActions?.length && /* @__PURE__ */ (0, import_jsx_runtime197.jsx)( 26766 PrimaryActions, 26767 { 26768 item, 26769 actions: primaryActions, 26770 registry, 26771 buttonVariant: "secondary" 26772 } 26773 ) 26774 ] 26775 } 26776 ), 26777 primaryActions.length < eligibleActions.length && /* @__PURE__ */ (0, import_jsx_runtime197.jsx)("div", { className: "dataviews-view-activity__item-actions", children: /* @__PURE__ */ (0, import_jsx_runtime197.jsx)( 26778 ItemActions, 26779 { 26780 item, 26781 actions: eligibleActions, 26782 isCompact: true 26783 } 26784 ) }) 26785 ] }) 26786 } 26787 ); 26788 } 26789 var activity_item_default = ActivityItem; 26790 26791 // packages/dataviews/build-module/dataviews-layouts/activity/activity-items.js 26792 var import_react4 = __toESM(require_react()); 26793 function isDefined3(item) { 26794 return !!item; 26795 } 26796 function ActivityItems(props) { 26797 const { data, fields, getItemId: getItemId2, view } = props; 26798 const titleField = fields.find((field) => field.id === view.titleField); 26799 const mediaField = fields.find((field) => field.id === view.mediaField); 26800 const descriptionField2 = fields.find( 26801 (field) => field.id === view.descriptionField 26802 ); 26803 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined3); 26804 return data.map((item, index) => { 26805 return /* @__PURE__ */ (0, import_react4.createElement)( 26806 activity_item_default, 26807 { 26808 ...props, 26809 key: getItemId2(item), 26810 item, 26811 mediaField, 26812 titleField, 26813 descriptionField: descriptionField2, 26814 otherFields, 26815 posinset: view.infiniteScrollEnabled ? index + 1 : void 0 26816 } 26817 ); 26818 }); 26819 } 26820 26821 // packages/dataviews/build-module/dataviews-layouts/activity/index.js 26822 var import_jsx_runtime198 = __toESM(require_jsx_runtime()); 26823 function ViewActivity(props) { 26824 const { empty, data, fields, isLoading, view, className } = props; 26825 const hasData = data?.length; 26826 if (!hasData) { 26827 return /* @__PURE__ */ (0, import_jsx_runtime198.jsx)( 26828 "div", 26829 { 26830 className: clsx_default({ 26831 "dataviews-loading": isLoading, 26832 "dataviews-no-results": !hasData && !isLoading 26833 }), 26834 children: !hasData && (isLoading ? /* @__PURE__ */ (0, import_jsx_runtime198.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime198.jsx)(import_components105.Spinner, {}) }) : empty) 26835 } 26836 ); 26837 } 26838 const wrapperClassName = clsx_default("dataviews-view-activity", className); 26839 const groupField = view.groupBy?.field ? fields.find((field) => field.id === view.groupBy?.field) : null; 26840 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null; 26841 const groupedEntries = dataByGroup ? Array.from(dataByGroup.entries()) : []; 26842 if (hasData && groupField && dataByGroup) { 26843 return /* @__PURE__ */ (0, import_jsx_runtime198.jsx)(import_components105.__experimentalVStack, { spacing: 2, className: wrapperClassName, children: groupedEntries.map( 26844 ([groupName, groupData]) => /* @__PURE__ */ (0, import_jsx_runtime198.jsx)( 26845 ActivityGroup, 26846 { 26847 groupName, 26848 groupData, 26849 groupField, 26850 children: /* @__PURE__ */ (0, import_jsx_runtime198.jsx)( 26851 ActivityItems, 26852 { 26853 ...props, 26854 data: groupData 26855 } 26856 ) 26857 }, 26858 groupName 26859 ) 26860 ) }); 26861 } 26862 return /* @__PURE__ */ (0, import_jsx_runtime198.jsxs)(import_jsx_runtime198.Fragment, { children: [ 26863 /* @__PURE__ */ (0, import_jsx_runtime198.jsx)( 26864 "div", 26865 { 26866 className: wrapperClassName, 26867 role: view.infiniteScrollEnabled ? "feed" : void 0, 26868 children: /* @__PURE__ */ (0, import_jsx_runtime198.jsx)(ActivityItems, { ...props }) 26869 } 26870 ), 26871 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime198.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime198.jsx)(import_components105.Spinner, {}) }) 26872 ] }); 26873 } 26874 26875 // packages/dataviews/build-module/dataviews-layouts/picker-grid/index.js 26876 var import_components108 = __toESM(require_components()); 26877 var import_i18n98 = __toESM(require_i18n()); 26878 var import_compose17 = __toESM(require_compose()); 26879 var import_element81 = __toESM(require_element()); 26880 26881 // packages/dataviews/build-module/components/dataviews-picker/footer.js 26882 var import_components107 = __toESM(require_components()); 26883 var import_data61 = __toESM(require_data()); 26884 var import_element79 = __toESM(require_element()); 26885 var import_i18n97 = __toESM(require_i18n()); 26886 26887 // packages/dataviews/build-module/components/dataviews-pagination/index.js 26888 var import_components106 = __toESM(require_components()); 26889 var import_element78 = __toESM(require_element()); 26890 var import_i18n96 = __toESM(require_i18n()); 26891 var import_jsx_runtime199 = __toESM(require_jsx_runtime()); 26892 function DataViewsPagination() { 26893 const { 26894 view, 26895 onChangeView, 26896 paginationInfo: { totalItems = 0, totalPages } 26897 } = (0, import_element78.useContext)(dataviews_context_default); 26898 if (!totalItems || !totalPages || view.infiniteScrollEnabled) { 26899 return null; 26900 } 26901 const currentPage = view.page ?? 1; 26902 const pageSelectOptions = Array.from(Array(totalPages)).map( 26903 (_, i2) => { 26904 const page = i2 + 1; 26905 return { 26906 value: page.toString(), 26907 label: page.toString(), 26908 "aria-label": currentPage === page ? (0, import_i18n96.sprintf)( 26909 // translators: 1: current page number. 2: total number of pages. 26910 (0, import_i18n96.__)("Page %1$d of %2$d"), 26911 currentPage, 26912 totalPages 26913 ) : page.toString() 26914 }; 26915 } 26916 ); 26917 return !!totalItems && totalPages !== 1 && /* @__PURE__ */ (0, import_jsx_runtime199.jsxs)( 26918 import_components106.__experimentalHStack, 26919 { 26920 expanded: false, 26921 className: "dataviews-pagination", 26922 justify: "end", 26923 spacing: 6, 26924 children: [ 26925 /* @__PURE__ */ (0, import_jsx_runtime199.jsx)( 26926 import_components106.__experimentalHStack, 26927 { 26928 justify: "flex-start", 26929 expanded: false, 26930 spacing: 1, 26931 className: "dataviews-pagination__page-select", 26932 children: (0, import_element78.createInterpolateElement)( 26933 (0, import_i18n96.sprintf)( 26934 // translators: 1: Current page number, 2: Total number of pages. 26935 (0, import_i18n96._x)( 26936 "<div>Page</div>%1$s<div>of %2$d</div>", 26937 "paging" 26938 ), 26939 "<CurrentPage />", 26940 totalPages 26941 ), 26942 { 26943 div: /* @__PURE__ */ (0, import_jsx_runtime199.jsx)("div", { "aria-hidden": true }), 26944 CurrentPage: /* @__PURE__ */ (0, import_jsx_runtime199.jsx)( 26945 import_components106.SelectControl, 26946 { 26947 "aria-label": (0, import_i18n96.__)("Current page"), 26948 value: currentPage.toString(), 26949 options: pageSelectOptions, 26950 onChange: (newValue) => { 26951 onChangeView({ 26952 ...view, 26953 page: +newValue 26954 }); 26955 }, 26956 size: "small", 26957 variant: "minimal" 26958 } 26959 ) 26960 } 26961 ) 26962 } 26963 ), 26964 /* @__PURE__ */ (0, import_jsx_runtime199.jsxs)(import_components106.__experimentalHStack, { expanded: false, spacing: 1, children: [ 26965 /* @__PURE__ */ (0, import_jsx_runtime199.jsx)( 26966 import_components106.Button, 26967 { 26968 onClick: () => onChangeView({ 26969 ...view, 26970 page: currentPage - 1 26971 }), 26972 disabled: currentPage === 1, 26973 accessibleWhenDisabled: true, 26974 label: (0, import_i18n96.__)("Previous page"), 26975 icon: (0, import_i18n96.isRTL)() ? next_default : previous_default, 26976 showTooltip: true, 26977 size: "compact", 26978 tooltipPosition: "top" 26979 } 26980 ), 26981 /* @__PURE__ */ (0, import_jsx_runtime199.jsx)( 26982 import_components106.Button, 26983 { 26984 onClick: () => onChangeView({ ...view, page: currentPage + 1 }), 26985 disabled: currentPage >= totalPages, 26986 accessibleWhenDisabled: true, 26987 label: (0, import_i18n96.__)("Next page"), 26988 icon: (0, import_i18n96.isRTL)() ? previous_default : next_default, 26989 showTooltip: true, 26990 size: "compact", 26991 tooltipPosition: "top" 26992 } 26993 ) 26994 ] }) 26995 ] 26996 } 26997 ); 26998 } 26999 var dataviews_pagination_default = (0, import_element78.memo)(DataViewsPagination); 27000 27001 // packages/dataviews/build-module/components/dataviews-picker/footer.js 27002 var import_jsx_runtime200 = __toESM(require_jsx_runtime()); 27003 function useIsMultiselectPicker(actions) { 27004 return (0, import_element79.useMemo)(() => { 27005 return actions?.every((action) => action.supportsBulk); 27006 }, [actions]); 27007 } 27008 27009 // packages/dataviews/build-module/dataviews-layouts/utils/grid-items.js 27010 var import_element80 = __toESM(require_element()); 27011 var import_jsx_runtime201 = __toESM(require_jsx_runtime()); 27012 var GridItems = (0, import_element80.forwardRef)(({ className, previewSize, ...props }, ref) => { 27013 return /* @__PURE__ */ (0, import_jsx_runtime201.jsx)( 27014 "div", 27015 { 27016 ref, 27017 className: clsx_default("dataviews-view-grid-items", className), 27018 style: { 27019 gridTemplateColumns: previewSize && `repeat(auto-fill, minmax($previewSize}px, 1fr))` 27020 }, 27021 ...props 27022 } 27023 ); 27024 }); 27025 27026 // packages/dataviews/build-module/dataviews-layouts/picker-grid/index.js 27027 var import_jsx_runtime202 = __toESM(require_jsx_runtime()); 27028 var { Badge: Badge2 } = unlock3(import_components108.privateApis); 27029 function GridItem3({ 27030 view, 27031 multiselect, 27032 selection, 27033 onChangeSelection, 27034 getItemId: getItemId2, 27035 item, 27036 mediaField, 27037 titleField, 27038 descriptionField: descriptionField2, 27039 regularFields, 27040 badgeFields, 27041 config: config2, 27042 posinset, 27043 setsize 27044 }) { 27045 const { showTitle = true, showMedia = true, showDescription = true } = view; 27046 const id = getItemId2(item); 27047 const isSelected2 = selection.includes(id); 27048 const renderedMediaField = mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime202.jsx)( 27049 mediaField.render, 27050 { 27051 item, 27052 field: mediaField, 27053 config: config2 27054 } 27055 ) : null; 27056 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime202.jsx)(titleField.render, { item, field: titleField }) : null; 27057 return /* @__PURE__ */ (0, import_jsx_runtime202.jsxs)( 27058 import_components108.Composite.Item, 27059 { 27060 "aria-label": titleField ? titleField.getValue({ item }) || (0, import_i18n98.__)("(no title)") : void 0, 27061 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime202.jsx)(import_components108.__experimentalVStack, { spacing: 0, children, ...props }), 27062 role: "option", 27063 "aria-posinset": posinset, 27064 "aria-setsize": setsize, 27065 className: clsx_default("dataviews-view-picker-grid__card", { 27066 "is-selected": isSelected2 27067 }), 27068 "aria-selected": isSelected2, 27069 onClick: () => { 27070 if (isSelected2) { 27071 onChangeSelection( 27072 selection.filter((itemId) => id !== itemId) 27073 ); 27074 } else { 27075 const newSelection = multiselect ? [...selection, id] : [id]; 27076 onChangeSelection(newSelection); 27077 } 27078 }, 27079 children: [ 27080 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime202.jsx)("div", { className: "dataviews-view-picker-grid__media", children: renderedMediaField }), 27081 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime202.jsx)( 27082 DataViewsSelectionCheckbox, 27083 { 27084 item, 27085 selection, 27086 onChangeSelection, 27087 getItemId: getItemId2, 27088 titleField, 27089 disabled: false, 27090 "aria-hidden": true, 27091 tabIndex: -1 27092 } 27093 ), 27094 showTitle && /* @__PURE__ */ (0, import_jsx_runtime202.jsx)( 27095 import_components108.__experimentalHStack, 27096 { 27097 justify: "space-between", 27098 className: "dataviews-view-picker-grid__title-actions", 27099 children: /* @__PURE__ */ (0, import_jsx_runtime202.jsx)("div", { className: "dataviews-view-picker-grid__title-field dataviews-title-field", children: renderedTitleField }) 27100 } 27101 ), 27102 /* @__PURE__ */ (0, import_jsx_runtime202.jsxs)(import_components108.__experimentalVStack, { spacing: 1, children: [ 27103 showDescription && descriptionField2?.render && /* @__PURE__ */ (0, import_jsx_runtime202.jsx)( 27104 descriptionField2.render, 27105 { 27106 item, 27107 field: descriptionField2 27108 } 27109 ), 27110 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime202.jsx)( 27111 import_components108.__experimentalHStack, 27112 { 27113 className: "dataviews-view-picker-grid__badge-fields", 27114 spacing: 2, 27115 wrap: true, 27116 alignment: "top", 27117 justify: "flex-start", 27118 children: badgeFields.map((field) => { 27119 return /* @__PURE__ */ (0, import_jsx_runtime202.jsx)( 27120 Badge2, 27121 { 27122 className: "dataviews-view-picker-grid__field-value", 27123 children: /* @__PURE__ */ (0, import_jsx_runtime202.jsx)( 27124 field.render, 27125 { 27126 item, 27127 field 27128 } 27129 ) 27130 }, 27131 field.id 27132 ); 27133 }) 27134 } 27135 ), 27136 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime202.jsx)( 27137 import_components108.__experimentalVStack, 27138 { 27139 className: "dataviews-view-picker-grid__fields", 27140 spacing: 1, 27141 children: regularFields.map((field) => { 27142 return /* @__PURE__ */ (0, import_jsx_runtime202.jsx)( 27143 import_components108.Flex, 27144 { 27145 className: "dataviews-view-picker-grid__field", 27146 gap: 1, 27147 justify: "flex-start", 27148 expanded: true, 27149 style: { height: "auto" }, 27150 direction: "row", 27151 children: /* @__PURE__ */ (0, import_jsx_runtime202.jsxs)(import_jsx_runtime202.Fragment, { children: [ 27152 /* @__PURE__ */ (0, import_jsx_runtime202.jsx)(import_components108.FlexItem, { className: "dataviews-view-picker-grid__field-name", children: field.header }), 27153 /* @__PURE__ */ (0, import_jsx_runtime202.jsx)( 27154 import_components108.FlexItem, 27155 { 27156 className: "dataviews-view-picker-grid__field-value", 27157 style: { maxHeight: "none" }, 27158 children: /* @__PURE__ */ (0, import_jsx_runtime202.jsx)( 27159 field.render, 27160 { 27161 item, 27162 field 27163 } 27164 ) 27165 } 27166 ) 27167 ] }) 27168 }, 27169 field.id 27170 ); 27171 }) 27172 } 27173 ) 27174 ] }) 27175 ] 27176 }, 27177 id 27178 ); 27179 } 27180 function GridGroup({ 27181 groupName, 27182 groupField, 27183 children 27184 }) { 27185 const headerId = (0, import_compose17.useInstanceId)( 27186 GridGroup, 27187 "dataviews-view-picker-grid-group__header" 27188 ); 27189 return /* @__PURE__ */ (0, import_jsx_runtime202.jsxs)( 27190 import_components108.__experimentalVStack, 27191 { 27192 spacing: 2, 27193 role: "group", 27194 "aria-labelledby": headerId, 27195 children: [ 27196 /* @__PURE__ */ (0, import_jsx_runtime202.jsx)( 27197 "h3", 27198 { 27199 className: "dataviews-view-picker-grid-group__header", 27200 id: headerId, 27201 children: (0, import_i18n98.sprintf)( 27202 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022". 27203 (0, import_i18n98.__)("%1$s: %2$s"), 27204 groupField.label, 27205 groupName 27206 ) 27207 } 27208 ), 27209 children 27210 ] 27211 }, 27212 groupName 27213 ); 27214 } 27215 function ViewPickerGrid({ 27216 actions, 27217 data, 27218 fields, 27219 getItemId: getItemId2, 27220 isLoading, 27221 onChangeSelection, 27222 selection, 27223 view, 27224 className, 27225 empty 27226 }) { 27227 const { resizeObserverRef, paginationInfo, itemListLabel } = (0, import_element81.useContext)(dataviews_context_default); 27228 const titleField = fields.find( 27229 (field) => field.id === view?.titleField 27230 ); 27231 const mediaField = fields.find( 27232 (field) => field.id === view?.mediaField 27233 ); 27234 const descriptionField2 = fields.find( 27235 (field) => field.id === view?.descriptionField 27236 ); 27237 const otherFields = view.fields ?? []; 27238 const { regularFields, badgeFields } = otherFields.reduce( 27239 (accumulator, fieldId) => { 27240 const field = fields.find((f2) => f2.id === fieldId); 27241 if (!field) { 27242 return accumulator; 27243 } 27244 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields"; 27245 accumulator[key].push(field); 27246 return accumulator; 27247 }, 27248 { regularFields: [], badgeFields: [] } 27249 ); 27250 const hasData = !!data?.length; 27251 const usedPreviewSize = view.layout?.previewSize; 27252 const isMultiselect = useIsMultiselectPicker(actions); 27253 const size = "900px"; 27254 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null; 27255 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null; 27256 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup; 27257 const currentPage = view?.page ?? 1; 27258 const perPage = view?.perPage ?? 0; 27259 const setSize = isInfiniteScroll ? paginationInfo?.totalItems : void 0; 27260 return /* @__PURE__ */ (0, import_jsx_runtime202.jsxs)(import_jsx_runtime202.Fragment, { 27261 // Render multiple groups. 27262 children: [ 27263 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime202.jsx)( 27264 import_components108.Composite, 27265 { 27266 virtualFocus: true, 27267 orientation: "horizontal", 27268 role: "listbox", 27269 "aria-multiselectable": isMultiselect, 27270 className: clsx_default( 27271 "dataviews-view-picker-grid", 27272 className 27273 ), 27274 "aria-label": itemListLabel, 27275 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime202.jsx)( 27276 import_components108.__experimentalVStack, 27277 { 27278 spacing: 4, 27279 children, 27280 ...props 27281 } 27282 ), 27283 children: Array.from(dataByGroup.entries()).map( 27284 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime202.jsx)( 27285 GridGroup, 27286 { 27287 groupName, 27288 groupField, 27289 children: /* @__PURE__ */ (0, import_jsx_runtime202.jsx)( 27290 GridItems, 27291 { 27292 previewSize: usedPreviewSize, 27293 style: { 27294 gridTemplateColumns: usedPreviewSize && `repeat(auto-fill, minmax($usedPreviewSize}px, 1fr))` 27295 }, 27296 "aria-busy": isLoading, 27297 ref: resizeObserverRef, 27298 children: groupItems.map((item) => { 27299 const posInSet = (currentPage - 1) * perPage + data.indexOf(item) + 1; 27300 return /* @__PURE__ */ (0, import_jsx_runtime202.jsx)( 27301 GridItem3, 27302 { 27303 view, 27304 multiselect: isMultiselect, 27305 selection, 27306 onChangeSelection, 27307 getItemId: getItemId2, 27308 item, 27309 mediaField, 27310 titleField, 27311 descriptionField: descriptionField2, 27312 regularFields, 27313 badgeFields, 27314 config: { 27315 sizes: size 27316 }, 27317 posinset: posInSet, 27318 setsize: setSize 27319 }, 27320 getItemId2(item) 27321 ); 27322 }) 27323 } 27324 ) 27325 }, 27326 groupName 27327 ) 27328 ) 27329 } 27330 ), 27331 // Render a single grid with all data. 27332 hasData && !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime202.jsx)( 27333 import_components108.Composite, 27334 { 27335 render: /* @__PURE__ */ (0, import_jsx_runtime202.jsx)( 27336 GridItems, 27337 { 27338 className: clsx_default( 27339 "dataviews-view-picker-grid", 27340 className 27341 ), 27342 previewSize: usedPreviewSize, 27343 "aria-busy": isLoading, 27344 ref: resizeObserverRef 27345 } 27346 ), 27347 virtualFocus: true, 27348 orientation: "horizontal", 27349 role: "listbox", 27350 "aria-multiselectable": isMultiselect, 27351 "aria-label": itemListLabel, 27352 children: data.map((item, index) => { 27353 let posinset = isInfiniteScroll ? index + 1 : void 0; 27354 if (!isInfiniteScroll) { 27355 posinset = (currentPage - 1) * perPage + index + 1; 27356 } 27357 return /* @__PURE__ */ (0, import_jsx_runtime202.jsx)( 27358 GridItem3, 27359 { 27360 view, 27361 multiselect: isMultiselect, 27362 selection, 27363 onChangeSelection, 27364 getItemId: getItemId2, 27365 item, 27366 mediaField, 27367 titleField, 27368 descriptionField: descriptionField2, 27369 regularFields, 27370 badgeFields, 27371 config: { 27372 sizes: size 27373 }, 27374 posinset, 27375 setsize: setSize 27376 }, 27377 getItemId2(item) 27378 ); 27379 }) 27380 } 27381 ), 27382 // Render empty state. 27383 !hasData && /* @__PURE__ */ (0, import_jsx_runtime202.jsx)( 27384 "div", 27385 { 27386 className: clsx_default({ 27387 "dataviews-loading": isLoading, 27388 "dataviews-no-results": !isLoading 27389 }), 27390 children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime202.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime202.jsx)(import_components108.Spinner, {}) }) : empty 27391 } 27392 ), 27393 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime202.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime202.jsx)(import_components108.Spinner, {}) }) 27394 ] 27395 }); 27396 } 27397 var picker_grid_default = ViewPickerGrid; 27398 27399 // packages/dataviews/build-module/dataviews-layouts/picker-table/index.js 27400 var import_i18n99 = __toESM(require_i18n()); 27401 var import_components109 = __toESM(require_components()); 27402 var import_element82 = __toESM(require_element()); 27403 var import_jsx_runtime203 = __toESM(require_jsx_runtime()); 27404 function TableColumnField2({ 27405 item, 27406 fields, 27407 column, 27408 align 27409 }) { 27410 const field = fields.find((f2) => f2.id === column); 27411 if (!field) { 27412 return null; 27413 } 27414 const className = clsx_default("dataviews-view-table__cell-content-wrapper", { 27415 "dataviews-view-table__cell-align-end": align === "end", 27416 "dataviews-view-table__cell-align-center": align === "center" 27417 }); 27418 return /* @__PURE__ */ (0, import_jsx_runtime203.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime203.jsx)(field.render, { item, field }) }); 27419 } 27420 function TableRow2({ 27421 item, 27422 fields, 27423 id, 27424 view, 27425 titleField, 27426 mediaField, 27427 descriptionField: descriptionField2, 27428 selection, 27429 getItemId: getItemId2, 27430 onChangeSelection, 27431 multiselect, 27432 posinset 27433 }) { 27434 const { paginationInfo } = (0, import_element82.useContext)(dataviews_context_default); 27435 const isSelected2 = selection.includes(id); 27436 const [isHovered, setIsHovered] = (0, import_element82.useState)(false); 27437 const { 27438 showTitle = true, 27439 showMedia = true, 27440 showDescription = true, 27441 infiniteScrollEnabled 27442 } = view; 27443 const handleMouseEnter = () => { 27444 setIsHovered(true); 27445 }; 27446 const handleMouseLeave = () => { 27447 setIsHovered(false); 27448 }; 27449 const columns = view.fields ?? []; 27450 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField2 && showDescription; 27451 return /* @__PURE__ */ (0, import_jsx_runtime203.jsxs)( 27452 import_components109.Composite.Item, 27453 { 27454 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime203.jsx)( 27455 "tr", 27456 { 27457 className: clsx_default("dataviews-view-table__row", { 27458 "is-selected": isSelected2, 27459 "is-hovered": isHovered 27460 }), 27461 onMouseEnter: handleMouseEnter, 27462 onMouseLeave: handleMouseLeave, 27463 children, 27464 ...props 27465 } 27466 ), 27467 "aria-selected": isSelected2, 27468 "aria-setsize": paginationInfo.totalItems || void 0, 27469 "aria-posinset": posinset, 27470 role: infiniteScrollEnabled ? "article" : "option", 27471 onClick: () => { 27472 if (isSelected2) { 27473 onChangeSelection( 27474 selection.filter((itemId) => id !== itemId) 27475 ); 27476 } else { 27477 const newSelection = multiselect ? [...selection, id] : [id]; 27478 onChangeSelection(newSelection); 27479 } 27480 }, 27481 children: [ 27482 /* @__PURE__ */ (0, import_jsx_runtime203.jsx)( 27483 "td", 27484 { 27485 className: "dataviews-view-table__checkbox-column", 27486 role: "presentation", 27487 children: /* @__PURE__ */ (0, import_jsx_runtime203.jsx)("div", { className: "dataviews-view-table__cell-content-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime203.jsx)( 27488 DataViewsSelectionCheckbox, 27489 { 27490 item, 27491 selection, 27492 onChangeSelection, 27493 getItemId: getItemId2, 27494 titleField, 27495 disabled: false, 27496 "aria-hidden": true, 27497 tabIndex: -1 27498 } 27499 ) }) 27500 } 27501 ), 27502 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime203.jsx)("td", { role: "presentation", children: /* @__PURE__ */ (0, import_jsx_runtime203.jsx)( 27503 column_primary_default, 27504 { 27505 item, 27506 titleField: showTitle ? titleField : void 0, 27507 mediaField: showMedia ? mediaField : void 0, 27508 descriptionField: showDescription ? descriptionField2 : void 0, 27509 isItemClickable: () => false 27510 } 27511 ) }), 27512 columns.map((column) => { 27513 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {}; 27514 return /* @__PURE__ */ (0, import_jsx_runtime203.jsx)( 27515 "td", 27516 { 27517 style: { 27518 width, 27519 maxWidth, 27520 minWidth 27521 }, 27522 role: "presentation", 27523 children: /* @__PURE__ */ (0, import_jsx_runtime203.jsx)( 27524 TableColumnField2, 27525 { 27526 fields, 27527 item, 27528 column, 27529 align 27530 } 27531 ) 27532 }, 27533 column 27534 ); 27535 }) 27536 ] 27537 }, 27538 id 27539 ); 27540 } 27541 function ViewPickerTable({ 27542 actions, 27543 data, 27544 fields, 27545 getItemId: getItemId2, 27546 isLoading = false, 27547 onChangeView, 27548 onChangeSelection, 27549 selection, 27550 setOpenedFilter, 27551 view, 27552 className, 27553 empty 27554 }) { 27555 const headerMenuRefs = (0, import_element82.useRef)(/* @__PURE__ */ new Map()); 27556 const headerMenuToFocusRef = (0, import_element82.useRef)(); 27557 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element82.useState)(); 27558 const isMultiselect = useIsMultiselectPicker(actions) ?? false; 27559 (0, import_element82.useEffect)(() => { 27560 if (headerMenuToFocusRef.current) { 27561 headerMenuToFocusRef.current.focus(); 27562 headerMenuToFocusRef.current = void 0; 27563 } 27564 }); 27565 const tableNoticeId = (0, import_element82.useId)(); 27566 if (nextHeaderMenuToFocus) { 27567 headerMenuToFocusRef.current = nextHeaderMenuToFocus; 27568 setNextHeaderMenuToFocus(void 0); 27569 return; 27570 } 27571 const onHide = (field) => { 27572 const hidden = headerMenuRefs.current.get(field.id); 27573 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0; 27574 setNextHeaderMenuToFocus(fallback?.node); 27575 }; 27576 const hasData = !!data?.length; 27577 const titleField = fields.find((field) => field.id === view.titleField); 27578 const mediaField = fields.find((field) => field.id === view.mediaField); 27579 const descriptionField2 = fields.find( 27580 (field) => field.id === view.descriptionField 27581 ); 27582 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null; 27583 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null; 27584 const { showTitle = true, showMedia = true, showDescription = true } = view; 27585 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField2 && showDescription; 27586 const columns = view.fields ?? []; 27587 const headerMenuRef = (column, index) => (node) => { 27588 if (node) { 27589 headerMenuRefs.current.set(column, { 27590 node, 27591 fallback: columns[index > 0 ? index - 1 : 1] 27592 }); 27593 } else { 27594 headerMenuRefs.current.delete(column); 27595 } 27596 }; 27597 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup; 27598 return /* @__PURE__ */ (0, import_jsx_runtime203.jsxs)(import_jsx_runtime203.Fragment, { children: [ 27599 /* @__PURE__ */ (0, import_jsx_runtime203.jsxs)( 27600 "table", 27601 { 27602 className: clsx_default( 27603 "dataviews-view-table", 27604 "dataviews-view-picker-table", 27605 className, 27606 { 27607 [`has-$view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes( 27608 view.layout.density 27609 ) 27610 } 27611 ), 27612 "aria-busy": isLoading, 27613 "aria-describedby": tableNoticeId, 27614 role: isInfiniteScroll ? "feed" : "listbox", 27615 children: [ 27616 /* @__PURE__ */ (0, import_jsx_runtime203.jsx)("thead", { role: "presentation", children: /* @__PURE__ */ (0, import_jsx_runtime203.jsxs)( 27617 "tr", 27618 { 27619 className: "dataviews-view-table__row", 27620 role: "presentation", 27621 children: [ 27622 /* @__PURE__ */ (0, import_jsx_runtime203.jsx)("th", { className: "dataviews-view-table__checkbox-column", children: isMultiselect && /* @__PURE__ */ (0, import_jsx_runtime203.jsx)( 27623 BulkSelectionCheckbox, 27624 { 27625 selection, 27626 onChangeSelection, 27627 data, 27628 actions, 27629 getItemId: getItemId2 27630 } 27631 ) }), 27632 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime203.jsx)("th", { children: titleField && /* @__PURE__ */ (0, import_jsx_runtime203.jsx)( 27633 column_header_menu_default, 27634 { 27635 ref: headerMenuRef( 27636 titleField.id, 27637 0 27638 ), 27639 fieldId: titleField.id, 27640 view, 27641 fields, 27642 onChangeView, 27643 onHide, 27644 setOpenedFilter, 27645 canMove: false 27646 } 27647 ) }), 27648 columns.map((column, index) => { 27649 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {}; 27650 return /* @__PURE__ */ (0, import_jsx_runtime203.jsx)( 27651 "th", 27652 { 27653 style: { 27654 width, 27655 maxWidth, 27656 minWidth, 27657 textAlign: align 27658 }, 27659 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0, 27660 scope: "col", 27661 children: /* @__PURE__ */ (0, import_jsx_runtime203.jsx)( 27662 column_header_menu_default, 27663 { 27664 ref: headerMenuRef(column, index), 27665 fieldId: column, 27666 view, 27667 fields, 27668 onChangeView, 27669 onHide, 27670 setOpenedFilter, 27671 canMove: view.layout?.enableMoving ?? true 27672 } 27673 ) 27674 }, 27675 column 27676 ); 27677 }) 27678 ] 27679 } 27680 ) }), 27681 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map( 27682 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime203.jsxs)( 27683 import_components109.Composite, 27684 { 27685 virtualFocus: true, 27686 orientation: "vertical", 27687 render: /* @__PURE__ */ (0, import_jsx_runtime203.jsx)("tbody", { role: "group" }), 27688 children: [ 27689 /* @__PURE__ */ (0, import_jsx_runtime203.jsx)( 27690 "tr", 27691 { 27692 className: "dataviews-view-table__group-header-row", 27693 role: "presentation", 27694 children: /* @__PURE__ */ (0, import_jsx_runtime203.jsx)( 27695 "td", 27696 { 27697 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + 1, 27698 className: "dataviews-view-table__group-header-cell", 27699 role: "presentation", 27700 children: (0, import_i18n99.sprintf)( 27701 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022". 27702 (0, import_i18n99.__)("%1$s: %2$s"), 27703 groupField.label, 27704 groupName 27705 ) 27706 } 27707 ) 27708 } 27709 ), 27710 groupItems.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime203.jsx)( 27711 TableRow2, 27712 { 27713 item, 27714 fields, 27715 id: getItemId2(item) || index.toString(), 27716 view, 27717 titleField, 27718 mediaField, 27719 descriptionField: descriptionField2, 27720 selection, 27721 getItemId: getItemId2, 27722 onChangeSelection, 27723 multiselect: isMultiselect 27724 }, 27725 getItemId2(item) 27726 )) 27727 ] 27728 }, 27729 `group-$groupName}` 27730 ) 27731 ) : /* @__PURE__ */ (0, import_jsx_runtime203.jsx)( 27732 import_components109.Composite, 27733 { 27734 render: /* @__PURE__ */ (0, import_jsx_runtime203.jsx)("tbody", { role: "presentation" }), 27735 virtualFocus: true, 27736 orientation: "vertical", 27737 children: hasData && data.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime203.jsx)( 27738 TableRow2, 27739 { 27740 item, 27741 fields, 27742 id: getItemId2(item) || index.toString(), 27743 view, 27744 titleField, 27745 mediaField, 27746 descriptionField: descriptionField2, 27747 selection, 27748 getItemId: getItemId2, 27749 onChangeSelection, 27750 multiselect: isMultiselect, 27751 posinset: index + 1 27752 }, 27753 getItemId2(item) 27754 )) 27755 } 27756 ) 27757 ] 27758 } 27759 ), 27760 /* @__PURE__ */ (0, import_jsx_runtime203.jsxs)( 27761 "div", 27762 { 27763 className: clsx_default({ 27764 "dataviews-loading": isLoading, 27765 "dataviews-no-results": !hasData && !isLoading 27766 }), 27767 id: tableNoticeId, 27768 children: [ 27769 !hasData && (isLoading ? /* @__PURE__ */ (0, import_jsx_runtime203.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime203.jsx)(import_components109.Spinner, {}) }) : empty), 27770 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime203.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime203.jsx)(import_components109.Spinner, {}) }) 27771 ] 27772 } 27773 ) 27774 ] }); 27775 } 27776 var picker_table_default = ViewPickerTable; 27777 27778 // packages/dataviews/build-module/dataviews-layouts/utils/preview-size-picker.js 27779 var import_components110 = __toESM(require_components()); 27780 var import_i18n100 = __toESM(require_i18n()); 27781 var import_element83 = __toESM(require_element()); 27782 var import_jsx_runtime204 = __toESM(require_jsx_runtime()); 27783 var imageSizes2 = [ 27784 { 27785 value: 120, 27786 breakpoint: 1 27787 }, 27788 { 27789 value: 170, 27790 breakpoint: 1 27791 }, 27792 { 27793 value: 230, 27794 breakpoint: 1 27795 }, 27796 { 27797 value: 290, 27798 breakpoint: 1112 27799 // at minimum image width, 4 images display at this container size 27800 }, 27801 { 27802 value: 350, 27803 breakpoint: 1636 27804 // at minimum image width, 6 images display at this container size 27805 }, 27806 { 27807 value: 430, 27808 breakpoint: 588 27809 // at minimum image width, 2 images display at this container size 27810 } 27811 ]; 27812 function PreviewSizePicker() { 27813 const context = (0, import_element83.useContext)(dataviews_context_default); 27814 const view = context.view; 27815 const breakValues = imageSizes2.filter((size) => { 27816 return context.containerWidth >= size.breakpoint; 27817 }); 27818 const layoutPreviewSize = view.layout?.previewSize ?? 230; 27819 const previewSizeToUse = breakValues.map((size, index) => ({ ...size, index })).filter((size) => size.value <= layoutPreviewSize).sort((a2, b2) => b2.value - a2.value)[0]?.index ?? 0; 27820 const marks = breakValues.map((size, index) => { 27821 return { 27822 value: index 27823 }; 27824 }); 27825 return /* @__PURE__ */ (0, import_jsx_runtime204.jsx)( 27826 import_components110.RangeControl, 27827 { 27828 __next40pxDefaultSize: true, 27829 showTooltip: false, 27830 label: (0, import_i18n100.__)("Preview size"), 27831 value: previewSizeToUse, 27832 min: 0, 27833 max: breakValues.length - 1, 27834 withInputField: false, 27835 onChange: (value = 0) => { 27836 context.onChangeView({ 27837 ...view, 27838 layout: { 27839 ...view.layout, 27840 previewSize: breakValues[value].value 27841 } 27842 }); 27843 }, 27844 step: 1, 27845 marks 27846 } 27847 ); 27848 } 27849 27850 // packages/dataviews/build-module/dataviews-layouts/table/density-picker.js 27851 var import_components111 = __toESM(require_components()); 27852 var import_i18n101 = __toESM(require_i18n()); 27853 var import_element84 = __toESM(require_element()); 27854 var import_jsx_runtime205 = __toESM(require_jsx_runtime()); 27855 function DensityPicker() { 27856 const context = (0, import_element84.useContext)(dataviews_context_default); 27857 const view = context.view; 27858 return /* @__PURE__ */ (0, import_jsx_runtime205.jsxs)( 27859 import_components111.__experimentalToggleGroupControl, 27860 { 27861 size: "__unstable-large", 27862 label: (0, import_i18n101.__)("Density"), 27863 value: view.layout?.density || "balanced", 27864 onChange: (value) => { 27865 context.onChangeView({ 27866 ...view, 27867 layout: { 27868 ...view.layout, 27869 density: value 27870 } 27871 }); 27872 }, 27873 isBlock: true, 27874 children: [ 27875 /* @__PURE__ */ (0, import_jsx_runtime205.jsx)( 27876 import_components111.__experimentalToggleGroupControlOption, 27877 { 27878 value: "comfortable", 27879 label: (0, import_i18n101._x)( 27880 "Comfortable", 27881 "Density option for DataView layout" 27882 ) 27883 }, 27884 "comfortable" 27885 ), 27886 /* @__PURE__ */ (0, import_jsx_runtime205.jsx)( 27887 import_components111.__experimentalToggleGroupControlOption, 27888 { 27889 value: "balanced", 27890 label: (0, import_i18n101._x)("Balanced", "Density option for DataView layout") 27891 }, 27892 "balanced" 27893 ), 27894 /* @__PURE__ */ (0, import_jsx_runtime205.jsx)( 27895 import_components111.__experimentalToggleGroupControlOption, 27896 { 27897 value: "compact", 27898 label: (0, import_i18n101._x)("Compact", "Density option for DataView layout") 27899 }, 27900 "compact" 27901 ) 27902 ] 27903 } 27904 ); 27905 } 27906 27907 // packages/dataviews/build-module/dataviews-layouts/index.js 27908 var VIEW_LAYOUTS = [ 27909 { 27910 type: LAYOUT_TABLE2, 27911 label: (0, import_i18n102.__)("Table"), 27912 component: table_default, 27913 icon: block_table_default, 27914 viewConfigOptions: DensityPicker 27915 }, 27916 { 27917 type: LAYOUT_GRID2, 27918 label: (0, import_i18n102.__)("Grid"), 27919 component: grid_default, 27920 icon: category_default, 27921 viewConfigOptions: PreviewSizePicker 27922 }, 27923 { 27924 type: LAYOUT_LIST2, 27925 label: (0, import_i18n102.__)("List"), 27926 component: ViewList, 27927 icon: (0, import_i18n102.isRTL)() ? format_list_bullets_rtl_default : format_list_bullets_default 27928 }, 27929 { 27930 type: LAYOUT_ACTIVITY, 27931 label: (0, import_i18n102.__)("Activity"), 27932 component: ViewActivity, 27933 icon: scheduled_default, 27934 viewConfigOptions: DensityPicker 27935 }, 27936 { 27937 type: LAYOUT_PICKER_GRID, 27938 label: (0, import_i18n102.__)("Grid"), 27939 component: picker_grid_default, 27940 icon: category_default, 27941 viewConfigOptions: PreviewSizePicker, 27942 isPicker: true 27943 }, 27944 { 27945 type: LAYOUT_PICKER_TABLE, 27946 label: (0, import_i18n102.__)("Table"), 27947 component: picker_table_default, 27948 icon: block_table_default, 27949 viewConfigOptions: DensityPicker, 27950 isPicker: true 27951 } 27952 ]; 27953 27954 // packages/dataviews/build-module/components/dataviews-filters/filters.js 27955 var import_element92 = __toESM(require_element()); 27956 var import_components117 = __toESM(require_components()); 27957 27958 // packages/dataviews/build-module/components/dataviews-filters/filter.js 27959 var import_components114 = __toESM(require_components()); 27960 var import_i18n105 = __toESM(require_i18n()); 27961 var import_element89 = __toESM(require_element()); 27962 27963 // node_modules/@ariakit/react-core/esm/__chunks/3YLGPPWQ.js 27964 var __defProp2 = Object.defineProperty; 27965 var __defProps = Object.defineProperties; 27966 var __getOwnPropDescs = Object.getOwnPropertyDescriptors; 27967 var __getOwnPropSymbols = Object.getOwnPropertySymbols; 27968 var __hasOwnProp2 = Object.prototype.hasOwnProperty; 27969 var __propIsEnum = Object.prototype.propertyIsEnumerable; 27970 var __defNormalProp = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; 27971 var __spreadValues = (a2, b2) => { 27972 for (var prop in b2 || (b2 = {})) 27973 if (__hasOwnProp2.call(b2, prop)) 27974 __defNormalProp(a2, prop, b2[prop]); 27975 if (__getOwnPropSymbols) 27976 for (var prop of __getOwnPropSymbols(b2)) { 27977 if (__propIsEnum.call(b2, prop)) 27978 __defNormalProp(a2, prop, b2[prop]); 27979 } 27980 return a2; 27981 }; 27982 var __spreadProps = (a2, b2) => __defProps(a2, __getOwnPropDescs(b2)); 27983 var __objRest = (source, exclude) => { 27984 var target = {}; 27985 for (var prop in source) 27986 if (__hasOwnProp2.call(source, prop) && exclude.indexOf(prop) < 0) 27987 target[prop] = source[prop]; 27988 if (source != null && __getOwnPropSymbols) 27989 for (var prop of __getOwnPropSymbols(source)) { 27990 if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop)) 27991 target[prop] = source[prop]; 27992 } 27993 return target; 27994 }; 27995 27996 // node_modules/@ariakit/core/esm/__chunks/3YLGPPWQ.js 27997 var __defProp3 = Object.defineProperty; 27998 var __defProps2 = Object.defineProperties; 27999 var __getOwnPropDescs2 = Object.getOwnPropertyDescriptors; 28000 var __getOwnPropSymbols2 = Object.getOwnPropertySymbols; 28001 var __hasOwnProp3 = Object.prototype.hasOwnProperty; 28002 var __propIsEnum2 = Object.prototype.propertyIsEnumerable; 28003 var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; 28004 var __spreadValues2 = (a2, b2) => { 28005 for (var prop in b2 || (b2 = {})) 28006 if (__hasOwnProp3.call(b2, prop)) 28007 __defNormalProp2(a2, prop, b2[prop]); 28008 if (__getOwnPropSymbols2) 28009 for (var prop of __getOwnPropSymbols2(b2)) { 28010 if (__propIsEnum2.call(b2, prop)) 28011 __defNormalProp2(a2, prop, b2[prop]); 28012 } 28013 return a2; 28014 }; 28015 var __spreadProps2 = (a2, b2) => __defProps2(a2, __getOwnPropDescs2(b2)); 28016 var __objRest2 = (source, exclude) => { 28017 var target = {}; 28018 for (var prop in source) 28019 if (__hasOwnProp3.call(source, prop) && exclude.indexOf(prop) < 0) 28020 target[prop] = source[prop]; 28021 if (source != null && __getOwnPropSymbols2) 28022 for (var prop of __getOwnPropSymbols2(source)) { 28023 if (exclude.indexOf(prop) < 0 && __propIsEnum2.call(source, prop)) 28024 target[prop] = source[prop]; 28025 } 28026 return target; 28027 }; 28028 28029 // node_modules/@ariakit/core/esm/__chunks/PBFD2E7P.js 28030 function noop3(..._) { 28031 } 28032 function applyState(argument, currentValue) { 28033 if (isUpdater(argument)) { 28034 const value = isLazyValue(currentValue) ? currentValue() : currentValue; 28035 return argument(value); 28036 } 28037 return argument; 28038 } 28039 function isUpdater(argument) { 28040 return typeof argument === "function"; 28041 } 28042 function isLazyValue(value) { 28043 return typeof value === "function"; 28044 } 28045 function hasOwnProperty(object, prop) { 28046 if (typeof Object.hasOwn === "function") { 28047 return Object.hasOwn(object, prop); 28048 } 28049 return Object.prototype.hasOwnProperty.call(object, prop); 28050 } 28051 function chain(...fns) { 28052 return (...args) => { 28053 for (const fn of fns) { 28054 if (typeof fn === "function") { 28055 fn(...args); 28056 } 28057 } 28058 }; 28059 } 28060 function normalizeString2(str) { 28061 return str.normalize("NFD").replace(/[\u0300-\u036f]/g, ""); 28062 } 28063 function omit(object, keys) { 28064 const result = __spreadValues2({}, object); 28065 for (const key of keys) { 28066 if (hasOwnProperty(result, key)) { 28067 delete result[key]; 28068 } 28069 } 28070 return result; 28071 } 28072 function pick(object, paths) { 28073 const result = {}; 28074 for (const key of paths) { 28075 if (hasOwnProperty(object, key)) { 28076 result[key] = object[key]; 28077 } 28078 } 28079 return result; 28080 } 28081 function identity(value) { 28082 return value; 28083 } 28084 function invariant(condition, message2) { 28085 if (condition) return; 28086 if (typeof message2 !== "string") throw new Error("Invariant failed"); 28087 throw new Error(message2); 28088 } 28089 function getKeys(obj) { 28090 return Object.keys(obj); 28091 } 28092 function isFalsyBooleanCallback(booleanOrCallback, ...args) { 28093 const result = typeof booleanOrCallback === "function" ? booleanOrCallback(...args) : booleanOrCallback; 28094 if (result == null) return false; 28095 return !result; 28096 } 28097 function disabledFromProps(props) { 28098 return props.disabled || props["aria-disabled"] === true || props["aria-disabled"] === "true"; 28099 } 28100 function removeUndefinedValues(obj) { 28101 const result = {}; 28102 for (const key in obj) { 28103 if (obj[key] !== void 0) { 28104 result[key] = obj[key]; 28105 } 28106 } 28107 return result; 28108 } 28109 function defaultValue(...values) { 28110 for (const value of values) { 28111 if (value !== void 0) return value; 28112 } 28113 return void 0; 28114 } 28115 28116 // node_modules/@ariakit/react-core/esm/__chunks/SK3NAZA3.js 28117 var import_react5 = __toESM(require_react(), 1); 28118 function setRef(ref, value) { 28119 if (typeof ref === "function") { 28120 ref(value); 28121 } else if (ref) { 28122 ref.current = value; 28123 } 28124 } 28125 function isValidElementWithRef(element) { 28126 if (!element) return false; 28127 if (!(0, import_react5.isValidElement)(element)) return false; 28128 if ("ref" in element.props) return true; 28129 if ("ref" in element) return true; 28130 return false; 28131 } 28132 function getRefProperty(element) { 28133 if (!isValidElementWithRef(element)) return null; 28134 const props = __spreadValues({}, element.props); 28135 return props.ref || element.ref; 28136 } 28137 function mergeProps(base, overrides) { 28138 const props = __spreadValues({}, base); 28139 for (const key in overrides) { 28140 if (!hasOwnProperty(overrides, key)) continue; 28141 if (key === "className") { 28142 const prop = "className"; 28143 props[prop] = base[prop] ? `$base[prop]} $overrides[prop]}` : overrides[prop]; 28144 continue; 28145 } 28146 if (key === "style") { 28147 const prop = "style"; 28148 props[prop] = base[prop] ? __spreadValues(__spreadValues({}, base[prop]), overrides[prop]) : overrides[prop]; 28149 continue; 28150 } 28151 const overrideValue = overrides[key]; 28152 if (typeof overrideValue === "function" && key.startsWith("on")) { 28153 const baseValue = base[key]; 28154 if (typeof baseValue === "function") { 28155 props[key] = (...args) => { 28156 overrideValue(...args); 28157 baseValue(...args); 28158 }; 28159 continue; 28160 } 28161 } 28162 props[key] = overrideValue; 28163 } 28164 return props; 28165 } 28166 28167 // node_modules/@ariakit/core/esm/__chunks/DTR5TSDJ.js 28168 var canUseDOM = checkIsBrowser(); 28169 function checkIsBrowser() { 28170 var _a; 28171 return typeof window !== "undefined" && !!((_a = window.document) == null ? void 0 : _a.createElement); 28172 } 28173 function getDocument(node) { 28174 if (!node) return document; 28175 if ("self" in node) return node.document; 28176 return node.ownerDocument || document; 28177 } 28178 function getActiveElement(node, activeDescendant = false) { 28179 const { activeElement } = getDocument(node); 28180 if (!(activeElement == null ? void 0 : activeElement.nodeName)) { 28181 return null; 28182 } 28183 if (isFrame(activeElement) && activeElement.contentDocument) { 28184 return getActiveElement( 28185 activeElement.contentDocument.body, 28186 activeDescendant 28187 ); 28188 } 28189 if (activeDescendant) { 28190 const id = activeElement.getAttribute("aria-activedescendant"); 28191 if (id) { 28192 const element = getDocument(activeElement).getElementById(id); 28193 if (element) { 28194 return element; 28195 } 28196 } 28197 } 28198 return activeElement; 28199 } 28200 function contains(parent, child) { 28201 return parent === child || parent.contains(child); 28202 } 28203 function isFrame(element) { 28204 return element.tagName === "IFRAME"; 28205 } 28206 function isButton(element) { 28207 const tagName = element.tagName.toLowerCase(); 28208 if (tagName === "button") return true; 28209 if (tagName === "input" && element.type) { 28210 return buttonInputTypes.indexOf(element.type) !== -1; 28211 } 28212 return false; 28213 } 28214 var buttonInputTypes = [ 28215 "button", 28216 "color", 28217 "file", 28218 "image", 28219 "reset", 28220 "submit" 28221 ]; 28222 function isVisible(element) { 28223 if (typeof element.checkVisibility === "function") { 28224 return element.checkVisibility(); 28225 } 28226 const htmlElement = element; 28227 return htmlElement.offsetWidth > 0 || htmlElement.offsetHeight > 0 || element.getClientRects().length > 0; 28228 } 28229 function isTextField(element) { 28230 try { 28231 const isTextInput = element instanceof HTMLInputElement && element.selectionStart !== null; 28232 const isTextArea = element.tagName === "TEXTAREA"; 28233 return isTextInput || isTextArea || false; 28234 } catch (error) { 28235 return false; 28236 } 28237 } 28238 function isTextbox(element) { 28239 return element.isContentEditable || isTextField(element); 28240 } 28241 function getTextboxValue(element) { 28242 if (isTextField(element)) { 28243 return element.value; 28244 } 28245 if (element.isContentEditable) { 28246 const range = getDocument(element).createRange(); 28247 range.selectNodeContents(element); 28248 return range.toString(); 28249 } 28250 return ""; 28251 } 28252 function getTextboxSelection(element) { 28253 let start2 = 0; 28254 let end = 0; 28255 if (isTextField(element)) { 28256 start2 = element.selectionStart || 0; 28257 end = element.selectionEnd || 0; 28258 } else if (element.isContentEditable) { 28259 const selection = getDocument(element).getSelection(); 28260 if ((selection == null ? void 0 : selection.rangeCount) && selection.anchorNode && contains(element, selection.anchorNode) && selection.focusNode && contains(element, selection.focusNode)) { 28261 const range = selection.getRangeAt(0); 28262 const nextRange = range.cloneRange(); 28263 nextRange.selectNodeContents(element); 28264 nextRange.setEnd(range.startContainer, range.startOffset); 28265 start2 = nextRange.toString().length; 28266 nextRange.setEnd(range.endContainer, range.endOffset); 28267 end = nextRange.toString().length; 28268 } 28269 } 28270 return { start: start2, end }; 28271 } 28272 function getPopupRole(element, fallback) { 28273 const allowedPopupRoles = ["dialog", "menu", "listbox", "tree", "grid"]; 28274 const role = element == null ? void 0 : element.getAttribute("role"); 28275 if (role && allowedPopupRoles.indexOf(role) !== -1) { 28276 return role; 28277 } 28278 return fallback; 28279 } 28280 function getScrollingElement(element) { 28281 if (!element) return null; 28282 const isScrollableOverflow = (overflow) => { 28283 if (overflow === "auto") return true; 28284 if (overflow === "scroll") return true; 28285 return false; 28286 }; 28287 if (element.clientHeight && element.scrollHeight > element.clientHeight) { 28288 const { overflowY } = getComputedStyle(element); 28289 if (isScrollableOverflow(overflowY)) return element; 28290 } else if (element.clientWidth && element.scrollWidth > element.clientWidth) { 28291 const { overflowX } = getComputedStyle(element); 28292 if (isScrollableOverflow(overflowX)) return element; 28293 } 28294 return getScrollingElement(element.parentElement) || document.scrollingElement || document.body; 28295 } 28296 function setSelectionRange(element, ...args) { 28297 if (/text|search|password|tel|url/i.test(element.type)) { 28298 element.setSelectionRange(...args); 28299 } 28300 } 28301 function sortBasedOnDOMPosition(items, getElement) { 28302 const pairs = items.map((item, index) => [index, item]); 28303 let isOrderDifferent = false; 28304 pairs.sort(([indexA, a2], [indexB, b2]) => { 28305 const elementA = getElement(a2); 28306 const elementB = getElement(b2); 28307 if (elementA === elementB) return 0; 28308 if (!elementA || !elementB) return 0; 28309 if (isElementPreceding(elementA, elementB)) { 28310 if (indexA > indexB) { 28311 isOrderDifferent = true; 28312 } 28313 return -1; 28314 } 28315 if (indexA < indexB) { 28316 isOrderDifferent = true; 28317 } 28318 return 1; 28319 }); 28320 if (isOrderDifferent) { 28321 return pairs.map(([_, item]) => item); 28322 } 28323 return items; 28324 } 28325 function isElementPreceding(a2, b2) { 28326 return Boolean( 28327 b2.compareDocumentPosition(a2) & Node.DOCUMENT_POSITION_PRECEDING 28328 ); 28329 } 28330 28331 // node_modules/@ariakit/core/esm/__chunks/QAGXQEUG.js 28332 function isTouchDevice() { 28333 return canUseDOM && !!navigator.maxTouchPoints; 28334 } 28335 function isApple() { 28336 if (!canUseDOM) return false; 28337 return /mac|iphone|ipad|ipod/i.test(navigator.platform); 28338 } 28339 function isSafari() { 28340 return canUseDOM && isApple() && /apple/i.test(navigator.vendor); 28341 } 28342 function isFirefox() { 28343 return canUseDOM && /firefox\//i.test(navigator.userAgent); 28344 } 28345 28346 // node_modules/@ariakit/core/esm/utils/events.js 28347 function isPortalEvent(event) { 28348 return Boolean( 28349 event.currentTarget && !contains(event.currentTarget, event.target) 28350 ); 28351 } 28352 function isSelfTarget(event) { 28353 return event.target === event.currentTarget; 28354 } 28355 function isOpeningInNewTab(event) { 28356 const element = event.currentTarget; 28357 if (!element) return false; 28358 const isAppleDevice = isApple(); 28359 if (isAppleDevice && !event.metaKey) return false; 28360 if (!isAppleDevice && !event.ctrlKey) return false; 28361 const tagName = element.tagName.toLowerCase(); 28362 if (tagName === "a") return true; 28363 if (tagName === "button" && element.type === "submit") return true; 28364 if (tagName === "input" && element.type === "submit") return true; 28365 return false; 28366 } 28367 function isDownloading(event) { 28368 const element = event.currentTarget; 28369 if (!element) return false; 28370 const tagName = element.tagName.toLowerCase(); 28371 if (!event.altKey) return false; 28372 if (tagName === "a") return true; 28373 if (tagName === "button" && element.type === "submit") return true; 28374 if (tagName === "input" && element.type === "submit") return true; 28375 return false; 28376 } 28377 function fireBlurEvent(element, eventInit) { 28378 const event = new FocusEvent("blur", eventInit); 28379 const defaultAllowed = element.dispatchEvent(event); 28380 const bubbleInit = __spreadProps2(__spreadValues2({}, eventInit), { bubbles: true }); 28381 element.dispatchEvent(new FocusEvent("focusout", bubbleInit)); 28382 return defaultAllowed; 28383 } 28384 function fireKeyboardEvent(element, type, eventInit) { 28385 const event = new KeyboardEvent(type, eventInit); 28386 return element.dispatchEvent(event); 28387 } 28388 function fireClickEvent(element, eventInit) { 28389 const event = new MouseEvent("click", eventInit); 28390 return element.dispatchEvent(event); 28391 } 28392 function isFocusEventOutside(event, container) { 28393 const containerElement = container || event.currentTarget; 28394 const relatedTarget = event.relatedTarget; 28395 return !relatedTarget || !contains(containerElement, relatedTarget); 28396 } 28397 function queueBeforeEvent(element, type, callback, timeout) { 28398 const createTimer = (callback2) => { 28399 if (timeout) { 28400 const timerId2 = setTimeout(callback2, timeout); 28401 return () => clearTimeout(timerId2); 28402 } 28403 const timerId = requestAnimationFrame(callback2); 28404 return () => cancelAnimationFrame(timerId); 28405 }; 28406 const cancelTimer = createTimer(() => { 28407 element.removeEventListener(type, callSync, true); 28408 callback(); 28409 }); 28410 const callSync = () => { 28411 cancelTimer(); 28412 callback(); 28413 }; 28414 element.addEventListener(type, callSync, { once: true, capture: true }); 28415 return cancelTimer; 28416 } 28417 function addGlobalEventListener(type, listener, options, scope = window) { 28418 const children = []; 28419 try { 28420 scope.document.addEventListener(type, listener, options); 28421 for (const frame of Array.from(scope.frames)) { 28422 children.push(addGlobalEventListener(type, listener, options, frame)); 28423 } 28424 } catch (e2) { 28425 } 28426 const removeEventListener = () => { 28427 try { 28428 scope.document.removeEventListener(type, listener, options); 28429 } catch (e2) { 28430 } 28431 for (const remove of children) { 28432 remove(); 28433 } 28434 }; 28435 return removeEventListener; 28436 } 28437 28438 // node_modules/@ariakit/react-core/esm/__chunks/ABQUS43J.js 28439 var import_react6 = __toESM(require_react(), 1); 28440 var React3 = __toESM(require_react(), 1); 28441 var _React = __spreadValues({}, React3); 28442 var useReactId = _React.useId; 28443 var useReactDeferredValue = _React.useDeferredValue; 28444 var useReactInsertionEffect = _React.useInsertionEffect; 28445 var useSafeLayoutEffect = canUseDOM ? import_react6.useLayoutEffect : import_react6.useEffect; 28446 function useInitialValue(value) { 28447 const [initialValue] = (0, import_react6.useState)(value); 28448 return initialValue; 28449 } 28450 function useLiveRef(value) { 28451 const ref = (0, import_react6.useRef)(value); 28452 useSafeLayoutEffect(() => { 28453 ref.current = value; 28454 }); 28455 return ref; 28456 } 28457 function useEvent(callback) { 28458 const ref = (0, import_react6.useRef)(() => { 28459 throw new Error("Cannot call an event handler while rendering."); 28460 }); 28461 if (useReactInsertionEffect) { 28462 useReactInsertionEffect(() => { 28463 ref.current = callback; 28464 }); 28465 } else { 28466 ref.current = callback; 28467 } 28468 return (0, import_react6.useCallback)((...args) => { 28469 var _a; 28470 return (_a = ref.current) == null ? void 0 : _a.call(ref, ...args); 28471 }, []); 28472 } 28473 function useTransactionState(callback) { 28474 const [state, setState] = (0, import_react6.useState)(null); 28475 useSafeLayoutEffect(() => { 28476 if (state == null) return; 28477 if (!callback) return; 28478 let prevState = null; 28479 callback((prev) => { 28480 prevState = prev; 28481 return state; 28482 }); 28483 return () => { 28484 callback(prevState); 28485 }; 28486 }, [state, callback]); 28487 return [state, setState]; 28488 } 28489 function useMergeRefs(...refs) { 28490 return (0, import_react6.useMemo)(() => { 28491 if (!refs.some(Boolean)) return; 28492 return (value) => { 28493 for (const ref of refs) { 28494 setRef(ref, value); 28495 } 28496 }; 28497 }, refs); 28498 } 28499 function useId5(defaultId) { 28500 if (useReactId) { 28501 const reactId = useReactId(); 28502 if (defaultId) return defaultId; 28503 return reactId; 28504 } 28505 const [id, setId] = (0, import_react6.useState)(defaultId); 28506 useSafeLayoutEffect(() => { 28507 if (defaultId || id) return; 28508 const random = Math.random().toString(36).slice(2, 8); 28509 setId(`id-$random}`); 28510 }, [defaultId, id]); 28511 return defaultId || id; 28512 } 28513 function useTagName(refOrElement, type) { 28514 const stringOrUndefined = (type2) => { 28515 if (typeof type2 !== "string") return; 28516 return type2; 28517 }; 28518 const [tagName, setTagName] = (0, import_react6.useState)(() => stringOrUndefined(type)); 28519 useSafeLayoutEffect(() => { 28520 const element = refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement; 28521 setTagName((element == null ? void 0 : element.tagName.toLowerCase()) || stringOrUndefined(type)); 28522 }, [refOrElement, type]); 28523 return tagName; 28524 } 28525 function useAttribute(refOrElement, attributeName, defaultValue2) { 28526 const initialValue = useInitialValue(defaultValue2); 28527 const [attribute, setAttribute] = (0, import_react6.useState)(initialValue); 28528 (0, import_react6.useEffect)(() => { 28529 const element = refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement; 28530 if (!element) return; 28531 const callback = () => { 28532 const value = element.getAttribute(attributeName); 28533 setAttribute(value == null ? initialValue : value); 28534 }; 28535 const observer = new MutationObserver(callback); 28536 observer.observe(element, { attributeFilter: [attributeName] }); 28537 callback(); 28538 return () => observer.disconnect(); 28539 }, [refOrElement, attributeName, initialValue]); 28540 return attribute; 28541 } 28542 function useUpdateEffect(effect, deps) { 28543 const mounted = (0, import_react6.useRef)(false); 28544 (0, import_react6.useEffect)(() => { 28545 if (mounted.current) { 28546 return effect(); 28547 } 28548 mounted.current = true; 28549 }, deps); 28550 (0, import_react6.useEffect)( 28551 () => () => { 28552 mounted.current = false; 28553 }, 28554 [] 28555 ); 28556 } 28557 function useUpdateLayoutEffect(effect, deps) { 28558 const mounted = (0, import_react6.useRef)(false); 28559 useSafeLayoutEffect(() => { 28560 if (mounted.current) { 28561 return effect(); 28562 } 28563 mounted.current = true; 28564 }, deps); 28565 useSafeLayoutEffect( 28566 () => () => { 28567 mounted.current = false; 28568 }, 28569 [] 28570 ); 28571 } 28572 function useForceUpdate2() { 28573 return (0, import_react6.useReducer)(() => [], []); 28574 } 28575 function useBooleanEvent(booleanOrCallback) { 28576 return useEvent( 28577 typeof booleanOrCallback === "function" ? booleanOrCallback : () => booleanOrCallback 28578 ); 28579 } 28580 function useWrapElement(props, callback, deps = []) { 28581 const wrapElement = (0, import_react6.useCallback)( 28582 (element) => { 28583 if (props.wrapElement) { 28584 element = props.wrapElement(element); 28585 } 28586 return callback(element); 28587 }, 28588 [...deps, props.wrapElement] 28589 ); 28590 return __spreadProps(__spreadValues({}, props), { wrapElement }); 28591 } 28592 function useMetadataProps(props, key, value) { 28593 const parent = props.onLoadedMetadataCapture; 28594 const onLoadedMetadataCapture = (0, import_react6.useMemo)(() => { 28595 return Object.assign(() => { 28596 }, __spreadProps(__spreadValues({}, parent), { [key]: value })); 28597 }, [parent, key, value]); 28598 return [parent == null ? void 0 : parent[key], { onLoadedMetadataCapture }]; 28599 } 28600 function useIsMouseMoving() { 28601 (0, import_react6.useEffect)(() => { 28602 addGlobalEventListener("mousemove", setMouseMoving, true); 28603 addGlobalEventListener("mousedown", resetMouseMoving, true); 28604 addGlobalEventListener("mouseup", resetMouseMoving, true); 28605 addGlobalEventListener("keydown", resetMouseMoving, true); 28606 addGlobalEventListener("scroll", resetMouseMoving, true); 28607 }, []); 28608 const isMouseMoving = useEvent(() => mouseMoving); 28609 return isMouseMoving; 28610 } 28611 var mouseMoving = false; 28612 var previousScreenX = 0; 28613 var previousScreenY = 0; 28614 function hasMouseMovement(event) { 28615 const movementX = event.movementX || event.screenX - previousScreenX; 28616 const movementY = event.movementY || event.screenY - previousScreenY; 28617 previousScreenX = event.screenX; 28618 previousScreenY = event.screenY; 28619 return movementX || movementY || false; 28620 } 28621 function setMouseMoving(event) { 28622 if (!hasMouseMovement(event)) return; 28623 mouseMoving = true; 28624 } 28625 function resetMouseMoving() { 28626 mouseMoving = false; 28627 } 28628 28629 // node_modules/@ariakit/react-core/esm/__chunks/LMDWO4NN.js 28630 var React4 = __toESM(require_react(), 1); 28631 var import_jsx_runtime206 = __toESM(require_jsx_runtime(), 1); 28632 function forwardRef22(render4) { 28633 const Role = React4.forwardRef((props, ref) => render4(__spreadProps(__spreadValues({}, props), { ref }))); 28634 Role.displayName = render4.displayName || render4.name; 28635 return Role; 28636 } 28637 function memo22(Component, propsAreEqual) { 28638 return React4.memo(Component, propsAreEqual); 28639 } 28640 function createElement4(Type, props) { 28641 const _a = props, { wrapElement, render: render4 } = _a, rest = __objRest(_a, ["wrapElement", "render"]); 28642 const mergedRef = useMergeRefs(props.ref, getRefProperty(render4)); 28643 let element; 28644 if (React4.isValidElement(render4)) { 28645 const renderProps = __spreadProps(__spreadValues({}, render4.props), { ref: mergedRef }); 28646 element = React4.cloneElement(render4, mergeProps(rest, renderProps)); 28647 } else if (render4) { 28648 element = render4(rest); 28649 } else { 28650 element = /* @__PURE__ */ (0, import_jsx_runtime206.jsx)(Type, __spreadValues({}, rest)); 28651 } 28652 if (wrapElement) { 28653 return wrapElement(element); 28654 } 28655 return element; 28656 } 28657 function createHook(useProps) { 28658 const useRole = (props = {}) => { 28659 return useProps(props); 28660 }; 28661 useRole.displayName = useProps.name; 28662 return useRole; 28663 } 28664 function createStoreContext(providers = [], scopedProviders = []) { 28665 const context = React4.createContext(void 0); 28666 const scopedContext = React4.createContext(void 0); 28667 const useContext210 = () => React4.useContext(context); 28668 const useScopedContext = (onlyScoped = false) => { 28669 const scoped = React4.useContext(scopedContext); 28670 const store2 = useContext210(); 28671 if (onlyScoped) return scoped; 28672 return scoped || store2; 28673 }; 28674 const useProviderContext = () => { 28675 const scoped = React4.useContext(scopedContext); 28676 const store2 = useContext210(); 28677 if (scoped && scoped === store2) return; 28678 return store2; 28679 }; 28680 const ContextProvider = (props) => { 28681 return providers.reduceRight( 28682 (children, Provider) => /* @__PURE__ */ (0, import_jsx_runtime206.jsx)(Provider, __spreadProps(__spreadValues({}, props), { children })), 28683 /* @__PURE__ */ (0, import_jsx_runtime206.jsx)(context.Provider, __spreadValues({}, props)) 28684 ); 28685 }; 28686 const ScopedContextProvider = (props) => { 28687 return /* @__PURE__ */ (0, import_jsx_runtime206.jsx)(ContextProvider, __spreadProps(__spreadValues({}, props), { children: scopedProviders.reduceRight( 28688 (children, Provider) => /* @__PURE__ */ (0, import_jsx_runtime206.jsx)(Provider, __spreadProps(__spreadValues({}, props), { children })), 28689 /* @__PURE__ */ (0, import_jsx_runtime206.jsx)(scopedContext.Provider, __spreadValues({}, props)) 28690 ) })); 28691 }; 28692 return { 28693 context, 28694 scopedContext, 28695 useContext: useContext210, 28696 useScopedContext, 28697 useProviderContext, 28698 ContextProvider, 28699 ScopedContextProvider 28700 }; 28701 } 28702 28703 // node_modules/@ariakit/react-core/esm/__chunks/VDHZ5F7K.js 28704 var ctx2 = createStoreContext(); 28705 var useCollectionContext = ctx2.useContext; 28706 var useCollectionScopedContext = ctx2.useScopedContext; 28707 var useCollectionProviderContext = ctx2.useProviderContext; 28708 var CollectionContextProvider = ctx2.ContextProvider; 28709 var CollectionScopedContextProvider = ctx2.ScopedContextProvider; 28710 28711 // node_modules/@ariakit/react-core/esm/__chunks/P7GR5CS5.js 28712 var import_react7 = __toESM(require_react(), 1); 28713 var ctx3 = createStoreContext( 28714 [CollectionContextProvider], 28715 [CollectionScopedContextProvider] 28716 ); 28717 var useCompositeContext = ctx3.useContext; 28718 var useCompositeScopedContext = ctx3.useScopedContext; 28719 var useCompositeProviderContext = ctx3.useProviderContext; 28720 var CompositeContextProvider = ctx3.ContextProvider; 28721 var CompositeScopedContextProvider = ctx3.ScopedContextProvider; 28722 var CompositeItemContext = (0, import_react7.createContext)( 28723 void 0 28724 ); 28725 var CompositeRowContext = (0, import_react7.createContext)( 28726 void 0 28727 ); 28728 28729 // node_modules/@ariakit/react-core/esm/__chunks/3XAVFTCA.js 28730 var import_react8 = __toESM(require_react(), 1); 28731 var TagValueContext = (0, import_react8.createContext)(null); 28732 var TagRemoveIdContext = (0, import_react8.createContext)( 28733 null 28734 ); 28735 var ctx4 = createStoreContext( 28736 [CompositeContextProvider], 28737 [CompositeScopedContextProvider] 28738 ); 28739 var useTagContext = ctx4.useContext; 28740 var useTagScopedContext = ctx4.useScopedContext; 28741 var useTagProviderContext = ctx4.useProviderContext; 28742 var TagContextProvider = ctx4.ContextProvider; 28743 var TagScopedContextProvider = ctx4.ScopedContextProvider; 28744 28745 // node_modules/@ariakit/core/esm/__chunks/BCALMBPZ.js 28746 function getInternal(store2, key) { 28747 const internals = store2.__unstableInternals; 28748 invariant(internals, "Invalid store"); 28749 return internals[key]; 28750 } 28751 function createStore(initialState, ...stores) { 28752 let state = initialState; 28753 let prevStateBatch = state; 28754 let lastUpdate = Symbol(); 28755 let destroy = noop3; 28756 const instances = /* @__PURE__ */ new Set(); 28757 const updatedKeys = /* @__PURE__ */ new Set(); 28758 const setups = /* @__PURE__ */ new Set(); 28759 const listeners = /* @__PURE__ */ new Set(); 28760 const batchListeners = /* @__PURE__ */ new Set(); 28761 const disposables = /* @__PURE__ */ new WeakMap(); 28762 const listenerKeys = /* @__PURE__ */ new WeakMap(); 28763 const storeSetup = (callback) => { 28764 setups.add(callback); 28765 return () => setups.delete(callback); 28766 }; 28767 const storeInit = () => { 28768 const initialized = instances.size; 28769 const instance = Symbol(); 28770 instances.add(instance); 28771 const maybeDestroy = () => { 28772 instances.delete(instance); 28773 if (instances.size) return; 28774 destroy(); 28775 }; 28776 if (initialized) return maybeDestroy; 28777 const desyncs = getKeys(state).map( 28778 (key) => chain( 28779 ...stores.map((store2) => { 28780 var _a; 28781 const storeState = (_a = store2 == null ? void 0 : store2.getState) == null ? void 0 : _a.call(store2); 28782 if (!storeState) return; 28783 if (!hasOwnProperty(storeState, key)) return; 28784 return sync2(store2, [key], (state2) => { 28785 setState( 28786 key, 28787 state2[key], 28788 // @ts-expect-error - Not public API. This is just to prevent 28789 // infinite loops. 28790 true 28791 ); 28792 }); 28793 }) 28794 ) 28795 ); 28796 const teardowns = []; 28797 for (const setup2 of setups) { 28798 teardowns.push(setup2()); 28799 } 28800 const cleanups = stores.map(init); 28801 destroy = chain(...desyncs, ...teardowns, ...cleanups); 28802 return maybeDestroy; 28803 }; 28804 const sub = (keys, listener, set = listeners) => { 28805 set.add(listener); 28806 listenerKeys.set(listener, keys); 28807 return () => { 28808 var _a; 28809 (_a = disposables.get(listener)) == null ? void 0 : _a(); 28810 disposables.delete(listener); 28811 listenerKeys.delete(listener); 28812 set.delete(listener); 28813 }; 28814 }; 28815 const storeSubscribe = (keys, listener) => sub(keys, listener); 28816 const storeSync = (keys, listener) => { 28817 disposables.set(listener, listener(state, state)); 28818 return sub(keys, listener); 28819 }; 28820 const storeBatch = (keys, listener) => { 28821 disposables.set(listener, listener(state, prevStateBatch)); 28822 return sub(keys, listener, batchListeners); 28823 }; 28824 const storePick = (keys) => createStore(pick(state, keys), finalStore); 28825 const storeOmit = (keys) => createStore(omit(state, keys), finalStore); 28826 const getState = () => state; 28827 const setState = (key, value, fromStores = false) => { 28828 var _a; 28829 if (!hasOwnProperty(state, key)) return; 28830 const nextValue = applyState(value, state[key]); 28831 if (nextValue === state[key]) return; 28832 if (!fromStores) { 28833 for (const store2 of stores) { 28834 (_a = store2 == null ? void 0 : store2.setState) == null ? void 0 : _a.call(store2, key, nextValue); 28835 } 28836 } 28837 const prevState = state; 28838 state = __spreadProps2(__spreadValues2({}, state), { [key]: nextValue }); 28839 const thisUpdate = Symbol(); 28840 lastUpdate = thisUpdate; 28841 updatedKeys.add(key); 28842 const run = (listener, prev, uKeys) => { 28843 var _a2; 28844 const keys = listenerKeys.get(listener); 28845 const updated = (k2) => uKeys ? uKeys.has(k2) : k2 === key; 28846 if (!keys || keys.some(updated)) { 28847 (_a2 = disposables.get(listener)) == null ? void 0 : _a2(); 28848 disposables.set(listener, listener(state, prev)); 28849 } 28850 }; 28851 for (const listener of listeners) { 28852 run(listener, prevState); 28853 } 28854 queueMicrotask(() => { 28855 if (lastUpdate !== thisUpdate) return; 28856 const snapshot = state; 28857 for (const listener of batchListeners) { 28858 run(listener, prevStateBatch, updatedKeys); 28859 } 28860 prevStateBatch = snapshot; 28861 updatedKeys.clear(); 28862 }); 28863 }; 28864 const finalStore = { 28865 getState, 28866 setState, 28867 __unstableInternals: { 28868 setup: storeSetup, 28869 init: storeInit, 28870 subscribe: storeSubscribe, 28871 sync: storeSync, 28872 batch: storeBatch, 28873 pick: storePick, 28874 omit: storeOmit 28875 } 28876 }; 28877 return finalStore; 28878 } 28879 function setup(store2, ...args) { 28880 if (!store2) return; 28881 return getInternal(store2, "setup")(...args); 28882 } 28883 function init(store2, ...args) { 28884 if (!store2) return; 28885 return getInternal(store2, "init")(...args); 28886 } 28887 function subscribe(store2, ...args) { 28888 if (!store2) return; 28889 return getInternal(store2, "subscribe")(...args); 28890 } 28891 function sync2(store2, ...args) { 28892 if (!store2) return; 28893 return getInternal(store2, "sync")(...args); 28894 } 28895 function batch(store2, ...args) { 28896 if (!store2) return; 28897 return getInternal(store2, "batch")(...args); 28898 } 28899 function omit2(store2, ...args) { 28900 if (!store2) return; 28901 return getInternal(store2, "omit")(...args); 28902 } 28903 function pick2(store2, ...args) { 28904 if (!store2) return; 28905 return getInternal(store2, "pick")(...args); 28906 } 28907 function mergeStore(...stores) { 28908 const initialState = stores.reduce((state, store22) => { 28909 var _a; 28910 const nextState = (_a = store22 == null ? void 0 : store22.getState) == null ? void 0 : _a.call(store22); 28911 if (!nextState) return state; 28912 return Object.assign(state, nextState); 28913 }, {}); 28914 const store2 = createStore(initialState, ...stores); 28915 return Object.assign({}, ...stores, store2); 28916 } 28917 function throwOnConflictingProps(props, store2) { 28918 if (false) return; 28919 if (!store2) return; 28920 const defaultKeys = Object.entries(props).filter(([key, value]) => key.startsWith("default") && value !== void 0).map(([key]) => { 28921 var _a; 28922 const stateKey = key.replace("default", ""); 28923 return `${((_a = stateKey[0]) == null ? void 0 : _a.toLowerCase()) || ""}$stateKey.slice(1)}`; 28924 }); 28925 if (!defaultKeys.length) return; 28926 const storeState = store2.getState(); 28927 const conflictingProps = defaultKeys.filter( 28928 (key) => hasOwnProperty(storeState, key) 28929 ); 28930 if (!conflictingProps.length) return; 28931 throw new Error( 28932 `Passing a store prop in conjunction with a default state is not supported. 28933 28934 const store = useSelectStore(); 28935 <SelectProvider store={store} defaultValue="Apple" /> 28936 ^ ^ 28937 28938 Instead, pass the default state to the topmost store: 28939 28940 const store = useSelectStore({ defaultValue: "Apple" }); 28941 <SelectProvider store={store} /> 28942 28943 See https://github.com/ariakit/ariakit/pull/2745 for more details. 28944 28945 If there's a particular need for this, please submit a feature request at https://github.com/ariakit/ariakit 28946 ` 28947 ); 28948 } 28949 28950 // node_modules/@ariakit/react-core/esm/__chunks/YV4JVR4I.js 28951 var React5 = __toESM(require_react(), 1); 28952 var import_shim = __toESM(require_shim(), 1); 28953 var { useSyncExternalStore } = import_shim.default; 28954 var noopSubscribe = () => () => { 28955 }; 28956 function useStoreState(store2, keyOrSelector = identity) { 28957 const storeSubscribe = React5.useCallback( 28958 (callback) => { 28959 if (!store2) return noopSubscribe(); 28960 return subscribe(store2, null, callback); 28961 }, 28962 [store2] 28963 ); 28964 const getSnapshot = () => { 28965 const key = typeof keyOrSelector === "string" ? keyOrSelector : null; 28966 const selector2 = typeof keyOrSelector === "function" ? keyOrSelector : null; 28967 const state = store2 == null ? void 0 : store2.getState(); 28968 if (selector2) return selector2(state); 28969 if (!state) return; 28970 if (!key) return; 28971 if (!hasOwnProperty(state, key)) return; 28972 return state[key]; 28973 }; 28974 return useSyncExternalStore(storeSubscribe, getSnapshot, getSnapshot); 28975 } 28976 function useStoreStateObject(store2, object) { 28977 const objRef = React5.useRef( 28978 {} 28979 ); 28980 const storeSubscribe = React5.useCallback( 28981 (callback) => { 28982 if (!store2) return noopSubscribe(); 28983 return subscribe(store2, null, callback); 28984 }, 28985 [store2] 28986 ); 28987 const getSnapshot = () => { 28988 const state = store2 == null ? void 0 : store2.getState(); 28989 let updated = false; 28990 const obj = objRef.current; 28991 for (const prop in object) { 28992 const keyOrSelector = object[prop]; 28993 if (typeof keyOrSelector === "function") { 28994 const value = keyOrSelector(state); 28995 if (value !== obj[prop]) { 28996 obj[prop] = value; 28997 updated = true; 28998 } 28999 } 29000 if (typeof keyOrSelector === "string") { 29001 if (!state) continue; 29002 if (!hasOwnProperty(state, keyOrSelector)) continue; 29003 const value = state[keyOrSelector]; 29004 if (value !== obj[prop]) { 29005 obj[prop] = value; 29006 updated = true; 29007 } 29008 } 29009 } 29010 if (updated) { 29011 objRef.current = __spreadValues({}, obj); 29012 } 29013 return objRef.current; 29014 }; 29015 return useSyncExternalStore(storeSubscribe, getSnapshot, getSnapshot); 29016 } 29017 function useStoreProps(store2, props, key, setKey) { 29018 const value = hasOwnProperty(props, key) ? props[key] : void 0; 29019 const setValue = setKey ? props[setKey] : void 0; 29020 const propsRef = useLiveRef({ value, setValue }); 29021 useSafeLayoutEffect(() => { 29022 return sync2(store2, [key], (state, prev) => { 29023 const { value: value2, setValue: setValue2 } = propsRef.current; 29024 if (!setValue2) return; 29025 if (state[key] === prev[key]) return; 29026 if (state[key] === value2) return; 29027 setValue2(state[key]); 29028 }); 29029 }, [store2, key]); 29030 useSafeLayoutEffect(() => { 29031 if (value === void 0) return; 29032 store2.setState(key, value); 29033 return batch(store2, [key], () => { 29034 if (value === void 0) return; 29035 store2.setState(key, value); 29036 }); 29037 }); 29038 } 29039 function useStore(createStore2, props) { 29040 const [store2, setStore] = React5.useState(() => createStore2(props)); 29041 useSafeLayoutEffect(() => init(store2), [store2]); 29042 const useState210 = React5.useCallback( 29043 (keyOrSelector) => useStoreState(store2, keyOrSelector), 29044 [store2] 29045 ); 29046 const memoizedStore = React5.useMemo( 29047 () => __spreadProps(__spreadValues({}, store2), { useState: useState210 }), 29048 [store2, useState210] 29049 ); 29050 const updateStore = useEvent(() => { 29051 setStore((store22) => createStore2(__spreadValues(__spreadValues({}, props), store22.getState()))); 29052 }); 29053 return [memoizedStore, updateStore]; 29054 } 29055 29056 // node_modules/@ariakit/core/esm/__chunks/CYQWQL4J.js 29057 function getCommonParent(items) { 29058 var _a; 29059 const firstItem = items.find((item) => !!item.element); 29060 const lastItem = [...items].reverse().find((item) => !!item.element); 29061 let parentElement = (_a = firstItem == null ? void 0 : firstItem.element) == null ? void 0 : _a.parentElement; 29062 while (parentElement && (lastItem == null ? void 0 : lastItem.element)) { 29063 const parent = parentElement; 29064 if (lastItem && parent.contains(lastItem.element)) { 29065 return parentElement; 29066 } 29067 parentElement = parentElement.parentElement; 29068 } 29069 return getDocument(parentElement).body; 29070 } 29071 function getPrivateStore(store2) { 29072 return store2 == null ? void 0 : store2.__unstablePrivateStore; 29073 } 29074 function createCollectionStore(props = {}) { 29075 var _a; 29076 throwOnConflictingProps(props, props.store); 29077 const syncState = (_a = props.store) == null ? void 0 : _a.getState(); 29078 const items = defaultValue( 29079 props.items, 29080 syncState == null ? void 0 : syncState.items, 29081 props.defaultItems, 29082 [] 29083 ); 29084 const itemsMap = new Map(items.map((item) => [item.id, item])); 29085 const initialState = { 29086 items, 29087 renderedItems: defaultValue(syncState == null ? void 0 : syncState.renderedItems, []) 29088 }; 29089 const syncPrivateStore = getPrivateStore(props.store); 29090 const privateStore = createStore( 29091 { items, renderedItems: initialState.renderedItems }, 29092 syncPrivateStore 29093 ); 29094 const collection = createStore(initialState, props.store); 29095 const sortItems = (renderedItems) => { 29096 const sortedItems = sortBasedOnDOMPosition(renderedItems, (i2) => i2.element); 29097 privateStore.setState("renderedItems", sortedItems); 29098 collection.setState("renderedItems", sortedItems); 29099 }; 29100 setup(collection, () => init(privateStore)); 29101 setup(privateStore, () => { 29102 return batch(privateStore, ["items"], (state) => { 29103 collection.setState("items", state.items); 29104 }); 29105 }); 29106 setup(privateStore, () => { 29107 return batch(privateStore, ["renderedItems"], (state) => { 29108 let firstRun = true; 29109 let raf2 = requestAnimationFrame(() => { 29110 const { renderedItems } = collection.getState(); 29111 if (state.renderedItems === renderedItems) return; 29112 sortItems(state.renderedItems); 29113 }); 29114 if (typeof IntersectionObserver !== "function") { 29115 return () => cancelAnimationFrame(raf2); 29116 } 29117 const ioCallback = () => { 29118 if (firstRun) { 29119 firstRun = false; 29120 return; 29121 } 29122 cancelAnimationFrame(raf2); 29123 raf2 = requestAnimationFrame(() => sortItems(state.renderedItems)); 29124 }; 29125 const root = getCommonParent(state.renderedItems); 29126 const observer = new IntersectionObserver(ioCallback, { root }); 29127 for (const item of state.renderedItems) { 29128 if (!item.element) continue; 29129 observer.observe(item.element); 29130 } 29131 return () => { 29132 cancelAnimationFrame(raf2); 29133 observer.disconnect(); 29134 }; 29135 }); 29136 }); 29137 const mergeItem = (item, setItems, canDeleteFromMap = false) => { 29138 let prevItem; 29139 setItems((items2) => { 29140 const index = items2.findIndex(({ id }) => id === item.id); 29141 const nextItems = items2.slice(); 29142 if (index !== -1) { 29143 prevItem = items2[index]; 29144 const nextItem = __spreadValues2(__spreadValues2({}, prevItem), item); 29145 nextItems[index] = nextItem; 29146 itemsMap.set(item.id, nextItem); 29147 } else { 29148 nextItems.push(item); 29149 itemsMap.set(item.id, item); 29150 } 29151 return nextItems; 29152 }); 29153 const unmergeItem = () => { 29154 setItems((items2) => { 29155 if (!prevItem) { 29156 if (canDeleteFromMap) { 29157 itemsMap.delete(item.id); 29158 } 29159 return items2.filter(({ id }) => id !== item.id); 29160 } 29161 const index = items2.findIndex(({ id }) => id === item.id); 29162 if (index === -1) return items2; 29163 const nextItems = items2.slice(); 29164 nextItems[index] = prevItem; 29165 itemsMap.set(item.id, prevItem); 29166 return nextItems; 29167 }); 29168 }; 29169 return unmergeItem; 29170 }; 29171 const registerItem = (item) => mergeItem( 29172 item, 29173 (getItems) => privateStore.setState("items", getItems), 29174 true 29175 ); 29176 return __spreadProps2(__spreadValues2({}, collection), { 29177 registerItem, 29178 renderItem: (item) => chain( 29179 registerItem(item), 29180 mergeItem( 29181 item, 29182 (getItems) => privateStore.setState("renderedItems", getItems) 29183 ) 29184 ), 29185 item: (id) => { 29186 if (!id) return null; 29187 let item = itemsMap.get(id); 29188 if (!item) { 29189 const { items: items2 } = privateStore.getState(); 29190 item = items2.find((item2) => item2.id === id); 29191 if (item) { 29192 itemsMap.set(id, item); 29193 } 29194 } 29195 return item || null; 29196 }, 29197 // @ts-expect-error Internal 29198 __unstablePrivateStore: privateStore 29199 }); 29200 } 29201 29202 // node_modules/@ariakit/react-core/esm/__chunks/C3IKGW5T.js 29203 function useCollectionStoreProps(store2, update3, props) { 29204 useUpdateEffect(update3, [props.store]); 29205 useStoreProps(store2, props, "items", "setItems"); 29206 return store2; 29207 } 29208 29209 // node_modules/@ariakit/core/esm/__chunks/7PRQYBBV.js 29210 function toArray2(arg) { 29211 if (Array.isArray(arg)) { 29212 return arg; 29213 } 29214 return typeof arg !== "undefined" ? [arg] : []; 29215 } 29216 function flatten2DArray(array) { 29217 const flattened = []; 29218 for (const row of array) { 29219 flattened.push(...row); 29220 } 29221 return flattened; 29222 } 29223 function reverseArray(array) { 29224 return array.slice().reverse(); 29225 } 29226 29227 // node_modules/@ariakit/core/esm/__chunks/AJZ4BYF3.js 29228 var NULL_ITEM = { id: null }; 29229 function findFirstEnabledItem(items, excludeId) { 29230 return items.find((item) => { 29231 if (excludeId) { 29232 return !item.disabled && item.id !== excludeId; 29233 } 29234 return !item.disabled; 29235 }); 29236 } 29237 function getEnabledItems(items, excludeId) { 29238 return items.filter((item) => { 29239 if (excludeId) { 29240 return !item.disabled && item.id !== excludeId; 29241 } 29242 return !item.disabled; 29243 }); 29244 } 29245 function getItemsInRow(items, rowId) { 29246 return items.filter((item) => item.rowId === rowId); 29247 } 29248 function flipItems(items, activeId, shouldInsertNullItem = false) { 29249 const index = items.findIndex((item) => item.id === activeId); 29250 return [ 29251 ...items.slice(index + 1), 29252 ...shouldInsertNullItem ? [NULL_ITEM] : [], 29253 ...items.slice(0, index) 29254 ]; 29255 } 29256 function groupItemsByRows(items) { 29257 const rows = []; 29258 for (const item of items) { 29259 const row = rows.find((currentRow) => { 29260 var _a; 29261 return ((_a = currentRow[0]) == null ? void 0 : _a.rowId) === item.rowId; 29262 }); 29263 if (row) { 29264 row.push(item); 29265 } else { 29266 rows.push([item]); 29267 } 29268 } 29269 return rows; 29270 } 29271 function getMaxRowLength(array) { 29272 let maxLength = 0; 29273 for (const { length } of array) { 29274 if (length > maxLength) { 29275 maxLength = length; 29276 } 29277 } 29278 return maxLength; 29279 } 29280 function createEmptyItem(rowId) { 29281 return { 29282 id: "__EMPTY_ITEM__", 29283 disabled: true, 29284 rowId 29285 }; 29286 } 29287 function normalizeRows(rows, activeId, focusShift) { 29288 const maxLength = getMaxRowLength(rows); 29289 for (const row of rows) { 29290 for (let i2 = 0; i2 < maxLength; i2 += 1) { 29291 const item = row[i2]; 29292 if (!item || focusShift && item.disabled) { 29293 const isFirst = i2 === 0; 29294 const previousItem = isFirst && focusShift ? findFirstEnabledItem(row) : row[i2 - 1]; 29295 row[i2] = previousItem && activeId !== previousItem.id && focusShift ? previousItem : createEmptyItem(previousItem == null ? void 0 : previousItem.rowId); 29296 } 29297 } 29298 } 29299 return rows; 29300 } 29301 function verticalizeItems(items) { 29302 const rows = groupItemsByRows(items); 29303 const maxLength = getMaxRowLength(rows); 29304 const verticalized = []; 29305 for (let i2 = 0; i2 < maxLength; i2 += 1) { 29306 for (const row of rows) { 29307 const item = row[i2]; 29308 if (item) { 29309 verticalized.push(__spreadProps2(__spreadValues2({}, item), { 29310 // If there's no rowId, it means that it's not a grid composite, but 29311 // a single row instead. So, instead of verticalizing it, that is, 29312 // assigning a different rowId based on the column index, we keep it 29313 // undefined so they will be part of the same row. This is useful 29314 // when using up/down on one-dimensional composites. 29315 rowId: item.rowId ? `$i2}` : void 0 29316 })); 29317 } 29318 } 29319 } 29320 return verticalized; 29321 } 29322 function createCompositeStore(props = {}) { 29323 var _a; 29324 const syncState = (_a = props.store) == null ? void 0 : _a.getState(); 29325 const collection = createCollectionStore(props); 29326 const activeId = defaultValue( 29327 props.activeId, 29328 syncState == null ? void 0 : syncState.activeId, 29329 props.defaultActiveId 29330 ); 29331 const initialState = __spreadProps2(__spreadValues2({}, collection.getState()), { 29332 id: defaultValue( 29333 props.id, 29334 syncState == null ? void 0 : syncState.id, 29335 `id-$Math.random().toString(36).slice(2, 8)}` 29336 ), 29337 activeId, 29338 baseElement: defaultValue(syncState == null ? void 0 : syncState.baseElement, null), 29339 includesBaseElement: defaultValue( 29340 props.includesBaseElement, 29341 syncState == null ? void 0 : syncState.includesBaseElement, 29342 activeId === null 29343 ), 29344 moves: defaultValue(syncState == null ? void 0 : syncState.moves, 0), 29345 orientation: defaultValue( 29346 props.orientation, 29347 syncState == null ? void 0 : syncState.orientation, 29348 "both" 29349 ), 29350 rtl: defaultValue(props.rtl, syncState == null ? void 0 : syncState.rtl, false), 29351 virtualFocus: defaultValue( 29352 props.virtualFocus, 29353 syncState == null ? void 0 : syncState.virtualFocus, 29354 false 29355 ), 29356 focusLoop: defaultValue(props.focusLoop, syncState == null ? void 0 : syncState.focusLoop, false), 29357 focusWrap: defaultValue(props.focusWrap, syncState == null ? void 0 : syncState.focusWrap, false), 29358 focusShift: defaultValue(props.focusShift, syncState == null ? void 0 : syncState.focusShift, false) 29359 }); 29360 const composite = createStore(initialState, collection, props.store); 29361 setup( 29362 composite, 29363 () => sync2(composite, ["renderedItems", "activeId"], (state) => { 29364 composite.setState("activeId", (activeId2) => { 29365 var _a2; 29366 if (activeId2 !== void 0) return activeId2; 29367 return (_a2 = findFirstEnabledItem(state.renderedItems)) == null ? void 0 : _a2.id; 29368 }); 29369 }) 29370 ); 29371 const getNextId = (direction = "next", options = {}) => { 29372 var _a2, _b; 29373 const defaultState = composite.getState(); 29374 const { 29375 skip = 0, 29376 activeId: activeId2 = defaultState.activeId, 29377 focusShift = defaultState.focusShift, 29378 focusLoop = defaultState.focusLoop, 29379 focusWrap = defaultState.focusWrap, 29380 includesBaseElement = defaultState.includesBaseElement, 29381 renderedItems = defaultState.renderedItems, 29382 rtl = defaultState.rtl 29383 } = options; 29384 const isVerticalDirection = direction === "up" || direction === "down"; 29385 const isNextDirection = direction === "next" || direction === "down"; 29386 const canReverse = isNextDirection ? rtl && !isVerticalDirection : !rtl || isVerticalDirection; 29387 const canShift = focusShift && !skip; 29388 let items = !isVerticalDirection ? renderedItems : flatten2DArray( 29389 normalizeRows(groupItemsByRows(renderedItems), activeId2, canShift) 29390 ); 29391 items = canReverse ? reverseArray(items) : items; 29392 items = isVerticalDirection ? verticalizeItems(items) : items; 29393 if (activeId2 == null) { 29394 return (_a2 = findFirstEnabledItem(items)) == null ? void 0 : _a2.id; 29395 } 29396 const activeItem = items.find((item) => item.id === activeId2); 29397 if (!activeItem) { 29398 return (_b = findFirstEnabledItem(items)) == null ? void 0 : _b.id; 29399 } 29400 const isGrid2 = items.some((item) => item.rowId); 29401 const activeIndex = items.indexOf(activeItem); 29402 const nextItems = items.slice(activeIndex + 1); 29403 const nextItemsInRow = getItemsInRow(nextItems, activeItem.rowId); 29404 if (skip) { 29405 const nextEnabledItemsInRow = getEnabledItems(nextItemsInRow, activeId2); 29406 const nextItem2 = nextEnabledItemsInRow.slice(skip)[0] || // If we can't find an item, just return the last one. 29407 nextEnabledItemsInRow[nextEnabledItemsInRow.length - 1]; 29408 return nextItem2 == null ? void 0 : nextItem2.id; 29409 } 29410 const canLoop = focusLoop && (isVerticalDirection ? focusLoop !== "horizontal" : focusLoop !== "vertical"); 29411 const canWrap = isGrid2 && focusWrap && (isVerticalDirection ? focusWrap !== "horizontal" : focusWrap !== "vertical"); 29412 const hasNullItem = isNextDirection ? (!isGrid2 || isVerticalDirection) && canLoop && includesBaseElement : isVerticalDirection ? includesBaseElement : false; 29413 if (canLoop) { 29414 const loopItems = canWrap && !hasNullItem ? items : getItemsInRow(items, activeItem.rowId); 29415 const sortedItems = flipItems(loopItems, activeId2, hasNullItem); 29416 const nextItem2 = findFirstEnabledItem(sortedItems, activeId2); 29417 return nextItem2 == null ? void 0 : nextItem2.id; 29418 } 29419 if (canWrap) { 29420 const nextItem2 = findFirstEnabledItem( 29421 // We can use nextItems, which contains all the next items, including 29422 // items from other rows, to wrap between rows. However, if there is a 29423 // null item (the composite container), we'll only use the next items in 29424 // the row. So moving next from the last item will focus on the 29425 // composite container. On grid composites, horizontal navigation never 29426 // focuses on the composite container, only vertical. 29427 hasNullItem ? nextItemsInRow : nextItems, 29428 activeId2 29429 ); 29430 const nextId2 = hasNullItem ? (nextItem2 == null ? void 0 : nextItem2.id) || null : nextItem2 == null ? void 0 : nextItem2.id; 29431 return nextId2; 29432 } 29433 const nextItem = findFirstEnabledItem(nextItemsInRow, activeId2); 29434 if (!nextItem && hasNullItem) { 29435 return null; 29436 } 29437 return nextItem == null ? void 0 : nextItem.id; 29438 }; 29439 return __spreadProps2(__spreadValues2(__spreadValues2({}, collection), composite), { 29440 setBaseElement: (element) => composite.setState("baseElement", element), 29441 setActiveId: (id) => composite.setState("activeId", id), 29442 move: (id) => { 29443 if (id === void 0) return; 29444 composite.setState("activeId", id); 29445 composite.setState("moves", (moves) => moves + 1); 29446 }, 29447 first: () => { 29448 var _a2; 29449 return (_a2 = findFirstEnabledItem(composite.getState().renderedItems)) == null ? void 0 : _a2.id; 29450 }, 29451 last: () => { 29452 var _a2; 29453 return (_a2 = findFirstEnabledItem(reverseArray(composite.getState().renderedItems))) == null ? void 0 : _a2.id; 29454 }, 29455 next: (options) => { 29456 if (options !== void 0 && typeof options === "number") { 29457 options = { skip: options }; 29458 } 29459 return getNextId("next", options); 29460 }, 29461 previous: (options) => { 29462 if (options !== void 0 && typeof options === "number") { 29463 options = { skip: options }; 29464 } 29465 return getNextId("previous", options); 29466 }, 29467 down: (options) => { 29468 if (options !== void 0 && typeof options === "number") { 29469 options = { skip: options }; 29470 } 29471 return getNextId("down", options); 29472 }, 29473 up: (options) => { 29474 if (options !== void 0 && typeof options === "number") { 29475 options = { skip: options }; 29476 } 29477 return getNextId("up", options); 29478 } 29479 }); 29480 } 29481 29482 // node_modules/@ariakit/react-core/esm/__chunks/4CMBR7SL.js 29483 function useCompositeStoreOptions(props) { 29484 const id = useId5(props.id); 29485 return __spreadValues({ id }, props); 29486 } 29487 function useCompositeStoreProps(store2, update3, props) { 29488 store2 = useCollectionStoreProps(store2, update3, props); 29489 useStoreProps(store2, props, "activeId", "setActiveId"); 29490 useStoreProps(store2, props, "includesBaseElement"); 29491 useStoreProps(store2, props, "virtualFocus"); 29492 useStoreProps(store2, props, "orientation"); 29493 useStoreProps(store2, props, "rtl"); 29494 useStoreProps(store2, props, "focusLoop"); 29495 useStoreProps(store2, props, "focusWrap"); 29496 useStoreProps(store2, props, "focusShift"); 29497 return store2; 29498 } 29499 29500 // node_modules/@ariakit/core/esm/__chunks/RCQ5P4YE.js 29501 function createDisclosureStore(props = {}) { 29502 const store2 = mergeStore( 29503 props.store, 29504 omit2(props.disclosure, ["contentElement", "disclosureElement"]) 29505 ); 29506 throwOnConflictingProps(props, store2); 29507 const syncState = store2 == null ? void 0 : store2.getState(); 29508 const open = defaultValue( 29509 props.open, 29510 syncState == null ? void 0 : syncState.open, 29511 props.defaultOpen, 29512 false 29513 ); 29514 const animated2 = defaultValue(props.animated, syncState == null ? void 0 : syncState.animated, false); 29515 const initialState = { 29516 open, 29517 animated: animated2, 29518 animating: !!animated2 && open, 29519 mounted: open, 29520 contentElement: defaultValue(syncState == null ? void 0 : syncState.contentElement, null), 29521 disclosureElement: defaultValue(syncState == null ? void 0 : syncState.disclosureElement, null) 29522 }; 29523 const disclosure = createStore(initialState, store2); 29524 setup( 29525 disclosure, 29526 () => sync2(disclosure, ["animated", "animating"], (state) => { 29527 if (state.animated) return; 29528 disclosure.setState("animating", false); 29529 }) 29530 ); 29531 setup( 29532 disclosure, 29533 () => subscribe(disclosure, ["open"], () => { 29534 if (!disclosure.getState().animated) return; 29535 disclosure.setState("animating", true); 29536 }) 29537 ); 29538 setup( 29539 disclosure, 29540 () => sync2(disclosure, ["open", "animating"], (state) => { 29541 disclosure.setState("mounted", state.open || state.animating); 29542 }) 29543 ); 29544 return __spreadProps2(__spreadValues2({}, disclosure), { 29545 disclosure: props.disclosure, 29546 setOpen: (value) => disclosure.setState("open", value), 29547 show: () => disclosure.setState("open", true), 29548 hide: () => disclosure.setState("open", false), 29549 toggle: () => disclosure.setState("open", (open2) => !open2), 29550 stopAnimation: () => disclosure.setState("animating", false), 29551 setContentElement: (value) => disclosure.setState("contentElement", value), 29552 setDisclosureElement: (value) => disclosure.setState("disclosureElement", value) 29553 }); 29554 } 29555 29556 // node_modules/@ariakit/react-core/esm/__chunks/WYCIER3C.js 29557 function useDisclosureStoreProps(store2, update3, props) { 29558 useUpdateEffect(update3, [props.store, props.disclosure]); 29559 useStoreProps(store2, props, "open", "setOpen"); 29560 useStoreProps(store2, props, "mounted", "setMounted"); 29561 useStoreProps(store2, props, "animated"); 29562 return Object.assign(store2, { disclosure: props.disclosure }); 29563 } 29564 29565 // node_modules/@ariakit/core/esm/__chunks/FZZ2AVHF.js 29566 function createDialogStore(props = {}) { 29567 return createDisclosureStore(props); 29568 } 29569 29570 // node_modules/@ariakit/react-core/esm/__chunks/BM6PGYQY.js 29571 function useDialogStoreProps(store2, update3, props) { 29572 return useDisclosureStoreProps(store2, update3, props); 29573 } 29574 29575 // node_modules/@ariakit/core/esm/__chunks/ME2CUF3F.js 29576 function createPopoverStore(_a = {}) { 29577 var _b = _a, { 29578 popover: otherPopover 29579 } = _b, props = __objRest2(_b, [ 29580 "popover" 29581 ]); 29582 const store2 = mergeStore( 29583 props.store, 29584 omit2(otherPopover, [ 29585 "arrowElement", 29586 "anchorElement", 29587 "contentElement", 29588 "popoverElement", 29589 "disclosureElement" 29590 ]) 29591 ); 29592 throwOnConflictingProps(props, store2); 29593 const syncState = store2 == null ? void 0 : store2.getState(); 29594 const dialog = createDialogStore(__spreadProps2(__spreadValues2({}, props), { store: store2 })); 29595 const placement = defaultValue( 29596 props.placement, 29597 syncState == null ? void 0 : syncState.placement, 29598 "bottom" 29599 ); 29600 const initialState = __spreadProps2(__spreadValues2({}, dialog.getState()), { 29601 placement, 29602 currentPlacement: placement, 29603 anchorElement: defaultValue(syncState == null ? void 0 : syncState.anchorElement, null), 29604 popoverElement: defaultValue(syncState == null ? void 0 : syncState.popoverElement, null), 29605 arrowElement: defaultValue(syncState == null ? void 0 : syncState.arrowElement, null), 29606 rendered: Symbol("rendered") 29607 }); 29608 const popover = createStore(initialState, dialog, store2); 29609 return __spreadProps2(__spreadValues2(__spreadValues2({}, dialog), popover), { 29610 setAnchorElement: (element) => popover.setState("anchorElement", element), 29611 setPopoverElement: (element) => popover.setState("popoverElement", element), 29612 setArrowElement: (element) => popover.setState("arrowElement", element), 29613 render: () => popover.setState("rendered", Symbol("rendered")) 29614 }); 29615 } 29616 29617 // node_modules/@ariakit/react-core/esm/__chunks/O2PQ2652.js 29618 function usePopoverStoreProps(store2, update3, props) { 29619 useUpdateEffect(update3, [props.popover]); 29620 useStoreProps(store2, props, "placement"); 29621 return useDialogStoreProps(store2, update3, props); 29622 } 29623 29624 // node_modules/@ariakit/core/esm/combobox/combobox-store.js 29625 var isTouchSafari = isSafari() && isTouchDevice(); 29626 function createComboboxStore(_a = {}) { 29627 var _b = _a, { 29628 tag 29629 } = _b, props = __objRest2(_b, [ 29630 "tag" 29631 ]); 29632 const store2 = mergeStore(props.store, pick2(tag, ["value", "rtl"])); 29633 throwOnConflictingProps(props, store2); 29634 const tagState = tag == null ? void 0 : tag.getState(); 29635 const syncState = store2 == null ? void 0 : store2.getState(); 29636 const activeId = defaultValue( 29637 props.activeId, 29638 syncState == null ? void 0 : syncState.activeId, 29639 props.defaultActiveId, 29640 null 29641 ); 29642 const composite = createCompositeStore(__spreadProps2(__spreadValues2({}, props), { 29643 activeId, 29644 includesBaseElement: defaultValue( 29645 props.includesBaseElement, 29646 syncState == null ? void 0 : syncState.includesBaseElement, 29647 true 29648 ), 29649 orientation: defaultValue( 29650 props.orientation, 29651 syncState == null ? void 0 : syncState.orientation, 29652 "vertical" 29653 ), 29654 focusLoop: defaultValue(props.focusLoop, syncState == null ? void 0 : syncState.focusLoop, true), 29655 focusWrap: defaultValue(props.focusWrap, syncState == null ? void 0 : syncState.focusWrap, true), 29656 virtualFocus: defaultValue( 29657 props.virtualFocus, 29658 syncState == null ? void 0 : syncState.virtualFocus, 29659 true 29660 ) 29661 })); 29662 const popover = createPopoverStore(__spreadProps2(__spreadValues2({}, props), { 29663 placement: defaultValue( 29664 props.placement, 29665 syncState == null ? void 0 : syncState.placement, 29666 "bottom-start" 29667 ) 29668 })); 29669 const value = defaultValue( 29670 props.value, 29671 syncState == null ? void 0 : syncState.value, 29672 props.defaultValue, 29673 "" 29674 ); 29675 const selectedValue = defaultValue( 29676 props.selectedValue, 29677 syncState == null ? void 0 : syncState.selectedValue, 29678 tagState == null ? void 0 : tagState.values, 29679 props.defaultSelectedValue, 29680 "" 29681 ); 29682 const multiSelectable = Array.isArray(selectedValue); 29683 const initialState = __spreadProps2(__spreadValues2(__spreadValues2({}, composite.getState()), popover.getState()), { 29684 value, 29685 selectedValue, 29686 resetValueOnSelect: defaultValue( 29687 props.resetValueOnSelect, 29688 syncState == null ? void 0 : syncState.resetValueOnSelect, 29689 multiSelectable 29690 ), 29691 resetValueOnHide: defaultValue( 29692 props.resetValueOnHide, 29693 syncState == null ? void 0 : syncState.resetValueOnHide, 29694 multiSelectable && !tag 29695 ), 29696 activeValue: syncState == null ? void 0 : syncState.activeValue 29697 }); 29698 const combobox = createStore(initialState, composite, popover, store2); 29699 if (isTouchSafari) { 29700 setup( 29701 combobox, 29702 () => sync2(combobox, ["virtualFocus"], () => { 29703 combobox.setState("virtualFocus", false); 29704 }) 29705 ); 29706 } 29707 setup(combobox, () => { 29708 if (!tag) return; 29709 return chain( 29710 sync2(combobox, ["selectedValue"], (state) => { 29711 if (!Array.isArray(state.selectedValue)) return; 29712 tag.setValues(state.selectedValue); 29713 }), 29714 sync2(tag, ["values"], (state) => { 29715 combobox.setState("selectedValue", state.values); 29716 }) 29717 ); 29718 }); 29719 setup( 29720 combobox, 29721 () => sync2(combobox, ["resetValueOnHide", "mounted"], (state) => { 29722 if (!state.resetValueOnHide) return; 29723 if (state.mounted) return; 29724 combobox.setState("value", value); 29725 }) 29726 ); 29727 setup( 29728 combobox, 29729 () => sync2(combobox, ["open"], (state) => { 29730 if (state.open) return; 29731 combobox.setState("activeId", activeId); 29732 combobox.setState("moves", 0); 29733 }) 29734 ); 29735 setup( 29736 combobox, 29737 () => sync2(combobox, ["moves", "activeId"], (state, prevState) => { 29738 if (state.moves === prevState.moves) { 29739 combobox.setState("activeValue", void 0); 29740 } 29741 }) 29742 ); 29743 setup( 29744 combobox, 29745 () => batch(combobox, ["moves", "renderedItems"], (state, prev) => { 29746 if (state.moves === prev.moves) return; 29747 const { activeId: activeId2 } = combobox.getState(); 29748 const activeItem = composite.item(activeId2); 29749 combobox.setState("activeValue", activeItem == null ? void 0 : activeItem.value); 29750 }) 29751 ); 29752 return __spreadProps2(__spreadValues2(__spreadValues2(__spreadValues2({}, popover), composite), combobox), { 29753 tag, 29754 setValue: (value2) => combobox.setState("value", value2), 29755 resetValue: () => combobox.setState("value", initialState.value), 29756 setSelectedValue: (selectedValue2) => combobox.setState("selectedValue", selectedValue2) 29757 }); 29758 } 29759 29760 // node_modules/@ariakit/react-core/esm/__chunks/FEOFMWBY.js 29761 function useComboboxStoreOptions(props) { 29762 const tag = useTagContext(); 29763 props = __spreadProps(__spreadValues({}, props), { 29764 tag: props.tag !== void 0 ? props.tag : tag 29765 }); 29766 return useCompositeStoreOptions(props); 29767 } 29768 function useComboboxStoreProps(store2, update3, props) { 29769 useUpdateEffect(update3, [props.tag]); 29770 useStoreProps(store2, props, "value", "setValue"); 29771 useStoreProps(store2, props, "selectedValue", "setSelectedValue"); 29772 useStoreProps(store2, props, "resetValueOnHide"); 29773 useStoreProps(store2, props, "resetValueOnSelect"); 29774 return Object.assign( 29775 useCompositeStoreProps( 29776 usePopoverStoreProps(store2, update3, props), 29777 update3, 29778 props 29779 ), 29780 { tag: props.tag } 29781 ); 29782 } 29783 function useComboboxStore(props = {}) { 29784 props = useComboboxStoreOptions(props); 29785 const [store2, update3] = useStore(createComboboxStore, props); 29786 return useComboboxStoreProps(store2, update3, props); 29787 } 29788 29789 // node_modules/@ariakit/react-core/esm/__chunks/S6EF7IVO.js 29790 var ctx5 = createStoreContext(); 29791 var useDisclosureContext = ctx5.useContext; 29792 var useDisclosureScopedContext = ctx5.useScopedContext; 29793 var useDisclosureProviderContext = ctx5.useProviderContext; 29794 var DisclosureContextProvider = ctx5.ContextProvider; 29795 var DisclosureScopedContextProvider = ctx5.ScopedContextProvider; 29796 29797 // node_modules/@ariakit/react-core/esm/__chunks/RS7LB2H4.js 29798 var import_react9 = __toESM(require_react(), 1); 29799 var ctx6 = createStoreContext( 29800 [DisclosureContextProvider], 29801 [DisclosureScopedContextProvider] 29802 ); 29803 var useDialogContext = ctx6.useContext; 29804 var useDialogScopedContext = ctx6.useScopedContext; 29805 var useDialogProviderContext = ctx6.useProviderContext; 29806 var DialogContextProvider = ctx6.ContextProvider; 29807 var DialogScopedContextProvider = ctx6.ScopedContextProvider; 29808 var DialogHeadingContext = (0, import_react9.createContext)(void 0); 29809 var DialogDescriptionContext = (0, import_react9.createContext)(void 0); 29810 29811 // node_modules/@ariakit/react-core/esm/__chunks/MTZPJQMC.js 29812 var ctx7 = createStoreContext( 29813 [DialogContextProvider], 29814 [DialogScopedContextProvider] 29815 ); 29816 var usePopoverContext = ctx7.useContext; 29817 var usePopoverScopedContext = ctx7.useScopedContext; 29818 var usePopoverProviderContext = ctx7.useProviderContext; 29819 var PopoverContextProvider = ctx7.ContextProvider; 29820 var PopoverScopedContextProvider = ctx7.ScopedContextProvider; 29821 29822 // node_modules/@ariakit/react-core/esm/__chunks/VEVQD5MH.js 29823 var import_react10 = __toESM(require_react(), 1); 29824 var ComboboxListRoleContext = (0, import_react10.createContext)( 29825 void 0 29826 ); 29827 var ctx8 = createStoreContext( 29828 [PopoverContextProvider, CompositeContextProvider], 29829 [PopoverScopedContextProvider, CompositeScopedContextProvider] 29830 ); 29831 var useComboboxContext = ctx8.useContext; 29832 var useComboboxScopedContext = ctx8.useScopedContext; 29833 var useComboboxProviderContext = ctx8.useProviderContext; 29834 var ComboboxContextProvider = ctx8.ContextProvider; 29835 var ComboboxScopedContextProvider = ctx8.ScopedContextProvider; 29836 var ComboboxItemValueContext = (0, import_react10.createContext)( 29837 void 0 29838 ); 29839 var ComboboxItemCheckedContext = (0, import_react10.createContext)(false); 29840 29841 // node_modules/@ariakit/react-core/esm/__chunks/OMU7RWRV.js 29842 var TagName = "div"; 29843 var usePopoverAnchor = createHook( 29844 function usePopoverAnchor2(_a) { 29845 var _b = _a, { store: store2 } = _b, props = __objRest(_b, ["store"]); 29846 const context = usePopoverProviderContext(); 29847 store2 = store2 || context; 29848 props = __spreadProps(__spreadValues({}, props), { 29849 ref: useMergeRefs(store2 == null ? void 0 : store2.setAnchorElement, props.ref) 29850 }); 29851 return props; 29852 } 29853 ); 29854 var PopoverAnchor = forwardRef22(function PopoverAnchor2(props) { 29855 const htmlProps = usePopoverAnchor(props); 29856 return createElement4(TagName, htmlProps); 29857 }); 29858 29859 // node_modules/@ariakit/react-core/esm/__chunks/5VQZOHHZ.js 29860 function findFirstEnabledItem2(items, excludeId) { 29861 return items.find((item) => { 29862 if (excludeId) { 29863 return !item.disabled && item.id !== excludeId; 29864 } 29865 return !item.disabled; 29866 }); 29867 } 29868 function getEnabledItem(store2, id) { 29869 if (!id) return null; 29870 return store2.item(id) || null; 29871 } 29872 function groupItemsByRows2(items) { 29873 const rows = []; 29874 for (const item of items) { 29875 const row = rows.find((currentRow) => { 29876 var _a; 29877 return ((_a = currentRow[0]) == null ? void 0 : _a.rowId) === item.rowId; 29878 }); 29879 if (row) { 29880 row.push(item); 29881 } else { 29882 rows.push([item]); 29883 } 29884 } 29885 return rows; 29886 } 29887 function selectTextField(element, collapseToEnd = false) { 29888 if (isTextField(element)) { 29889 element.setSelectionRange( 29890 collapseToEnd ? element.value.length : 0, 29891 element.value.length 29892 ); 29893 } else if (element.isContentEditable) { 29894 const selection = getDocument(element).getSelection(); 29895 selection == null ? void 0 : selection.selectAllChildren(element); 29896 if (collapseToEnd) { 29897 selection == null ? void 0 : selection.collapseToEnd(); 29898 } 29899 } 29900 } 29901 var FOCUS_SILENTLY = Symbol("FOCUS_SILENTLY"); 29902 function focusSilently(element) { 29903 element[FOCUS_SILENTLY] = true; 29904 element.focus({ preventScroll: true }); 29905 } 29906 function silentlyFocused(element) { 29907 const isSilentlyFocused = element[FOCUS_SILENTLY]; 29908 delete element[FOCUS_SILENTLY]; 29909 return isSilentlyFocused; 29910 } 29911 function isItem(store2, element, exclude) { 29912 if (!element) return false; 29913 if (element === exclude) return false; 29914 const item = store2.item(element.id); 29915 if (!item) return false; 29916 if (exclude && item.element === exclude) return false; 29917 return true; 29918 } 29919 29920 // node_modules/@ariakit/react-core/esm/__chunks/SWN3JYXT.js 29921 var import_react11 = __toESM(require_react(), 1); 29922 var FocusableContext = (0, import_react11.createContext)(true); 29923 29924 // node_modules/@ariakit/core/esm/utils/focus.js 29925 var selector = "input:not([type='hidden']):not([disabled]), select:not([disabled]), textarea:not([disabled]), a[href], button:not([disabled]), [tabindex], summary, iframe, object, embed, area[href], audio[controls], video[controls], [contenteditable]:not([contenteditable='false'])"; 29926 function isFocusable(element) { 29927 if (!element.matches(selector)) return false; 29928 if (!isVisible(element)) return false; 29929 if (element.closest("[inert]")) return false; 29930 return true; 29931 } 29932 function getClosestFocusable(element) { 29933 while (element && !isFocusable(element)) { 29934 element = element.closest(selector); 29935 } 29936 return element || null; 29937 } 29938 function hasFocus(element) { 29939 const activeElement = getActiveElement(element); 29940 if (!activeElement) return false; 29941 if (activeElement === element) return true; 29942 const activeDescendant = activeElement.getAttribute("aria-activedescendant"); 29943 if (!activeDescendant) return false; 29944 return activeDescendant === element.id; 29945 } 29946 function hasFocusWithin(element) { 29947 const activeElement = getActiveElement(element); 29948 if (!activeElement) return false; 29949 if (contains(element, activeElement)) return true; 29950 const activeDescendant = activeElement.getAttribute("aria-activedescendant"); 29951 if (!activeDescendant) return false; 29952 if (!("id" in element)) return false; 29953 if (activeDescendant === element.id) return true; 29954 return !!element.querySelector(`#$CSS.escape(activeDescendant)}`); 29955 } 29956 function focusIfNeeded(element) { 29957 if (!hasFocusWithin(element) && isFocusable(element)) { 29958 element.focus(); 29959 } 29960 } 29961 function focusIntoView(element, options) { 29962 if (!("scrollIntoView" in element)) { 29963 element.focus(); 29964 } else { 29965 element.focus({ preventScroll: true }); 29966 element.scrollIntoView(__spreadValues2({ block: "nearest", inline: "nearest" }, options)); 29967 } 29968 } 29969 29970 // node_modules/@ariakit/react-core/esm/__chunks/LVA2YJMS.js 29971 var import_react12 = __toESM(require_react(), 1); 29972 var TagName2 = "div"; 29973 var isSafariBrowser = isSafari(); 29974 var alwaysFocusVisibleInputTypes = [ 29975 "text", 29976 "search", 29977 "url", 29978 "tel", 29979 "email", 29980 "password", 29981 "number", 29982 "date", 29983 "month", 29984 "week", 29985 "time", 29986 "datetime", 29987 "datetime-local" 29988 ]; 29989 var safariFocusAncestorSymbol = Symbol("safariFocusAncestor"); 29990 function markSafariFocusAncestor(element, value) { 29991 if (!element) return; 29992 element[safariFocusAncestorSymbol] = value; 29993 } 29994 function isAlwaysFocusVisible(element) { 29995 const { tagName, readOnly, type } = element; 29996 if (tagName === "TEXTAREA" && !readOnly) return true; 29997 if (tagName === "SELECT" && !readOnly) return true; 29998 if (tagName === "INPUT" && !readOnly) { 29999 return alwaysFocusVisibleInputTypes.includes(type); 30000 } 30001 if (element.isContentEditable) return true; 30002 const role = element.getAttribute("role"); 30003 if (role === "combobox" && element.dataset.name) { 30004 return true; 30005 } 30006 return false; 30007 } 30008 function getLabels(element) { 30009 if ("labels" in element) { 30010 return element.labels; 30011 } 30012 return null; 30013 } 30014 function isNativeCheckboxOrRadio(element) { 30015 const tagName = element.tagName.toLowerCase(); 30016 if (tagName === "input" && element.type) { 30017 return element.type === "radio" || element.type === "checkbox"; 30018 } 30019 return false; 30020 } 30021 function isNativeTabbable(tagName) { 30022 if (!tagName) return true; 30023 return tagName === "button" || tagName === "summary" || tagName === "input" || tagName === "select" || tagName === "textarea" || tagName === "a"; 30024 } 30025 function supportsDisabledAttribute(tagName) { 30026 if (!tagName) return true; 30027 return tagName === "button" || tagName === "input" || tagName === "select" || tagName === "textarea"; 30028 } 30029 function getTabIndex(focusable, trulyDisabled, nativeTabbable, supportsDisabled, tabIndexProp) { 30030 if (!focusable) { 30031 return tabIndexProp; 30032 } 30033 if (trulyDisabled) { 30034 if (nativeTabbable && !supportsDisabled) { 30035 return -1; 30036 } 30037 return; 30038 } 30039 if (nativeTabbable) { 30040 return tabIndexProp; 30041 } 30042 return tabIndexProp || 0; 30043 } 30044 function useDisableEvent(onEvent, disabled) { 30045 return useEvent((event) => { 30046 onEvent == null ? void 0 : onEvent(event); 30047 if (event.defaultPrevented) return; 30048 if (disabled) { 30049 event.stopPropagation(); 30050 event.preventDefault(); 30051 } 30052 }); 30053 } 30054 var isKeyboardModality = true; 30055 function onGlobalMouseDown(event) { 30056 const target = event.target; 30057 if (target && "hasAttribute" in target) { 30058 if (!target.hasAttribute("data-focus-visible")) { 30059 isKeyboardModality = false; 30060 } 30061 } 30062 } 30063 function onGlobalKeyDown(event) { 30064 if (event.metaKey) return; 30065 if (event.ctrlKey) return; 30066 if (event.altKey) return; 30067 isKeyboardModality = true; 30068 } 30069 var useFocusable = createHook( 30070 function useFocusable2(_a) { 30071 var _b = _a, { 30072 focusable = true, 30073 accessibleWhenDisabled, 30074 autoFocus, 30075 onFocusVisible 30076 } = _b, props = __objRest(_b, [ 30077 "focusable", 30078 "accessibleWhenDisabled", 30079 "autoFocus", 30080 "onFocusVisible" 30081 ]); 30082 const ref = (0, import_react12.useRef)(null); 30083 (0, import_react12.useEffect)(() => { 30084 if (!focusable) return; 30085 addGlobalEventListener("mousedown", onGlobalMouseDown, true); 30086 addGlobalEventListener("keydown", onGlobalKeyDown, true); 30087 }, [focusable]); 30088 if (isSafariBrowser) { 30089 (0, import_react12.useEffect)(() => { 30090 if (!focusable) return; 30091 const element = ref.current; 30092 if (!element) return; 30093 if (!isNativeCheckboxOrRadio(element)) return; 30094 const labels = getLabels(element); 30095 if (!labels) return; 30096 const onMouseUp = () => queueMicrotask(() => element.focus()); 30097 for (const label of labels) { 30098 label.addEventListener("mouseup", onMouseUp); 30099 } 30100 return () => { 30101 for (const label of labels) { 30102 label.removeEventListener("mouseup", onMouseUp); 30103 } 30104 }; 30105 }, [focusable]); 30106 } 30107 const disabled = focusable && disabledFromProps(props); 30108 const trulyDisabled = !!disabled && !accessibleWhenDisabled; 30109 const [focusVisible, setFocusVisible] = (0, import_react12.useState)(false); 30110 (0, import_react12.useEffect)(() => { 30111 if (!focusable) return; 30112 if (trulyDisabled && focusVisible) { 30113 setFocusVisible(false); 30114 } 30115 }, [focusable, trulyDisabled, focusVisible]); 30116 (0, import_react12.useEffect)(() => { 30117 if (!focusable) return; 30118 if (!focusVisible) return; 30119 const element = ref.current; 30120 if (!element) return; 30121 if (typeof IntersectionObserver === "undefined") return; 30122 const observer = new IntersectionObserver(() => { 30123 if (!isFocusable(element)) { 30124 setFocusVisible(false); 30125 } 30126 }); 30127 observer.observe(element); 30128 return () => observer.disconnect(); 30129 }, [focusable, focusVisible]); 30130 const onKeyPressCapture = useDisableEvent( 30131 props.onKeyPressCapture, 30132 disabled 30133 ); 30134 const onMouseDownCapture = useDisableEvent( 30135 props.onMouseDownCapture, 30136 disabled 30137 ); 30138 const onClickCapture = useDisableEvent(props.onClickCapture, disabled); 30139 const onMouseDownProp = props.onMouseDown; 30140 const onMouseDown = useEvent((event) => { 30141 onMouseDownProp == null ? void 0 : onMouseDownProp(event); 30142 if (event.defaultPrevented) return; 30143 if (!focusable) return; 30144 const element = event.currentTarget; 30145 if (!isSafariBrowser) return; 30146 if (isPortalEvent(event)) return; 30147 if (!isButton(element) && !isNativeCheckboxOrRadio(element)) return; 30148 let receivedFocus = false; 30149 const onFocus = () => { 30150 receivedFocus = true; 30151 }; 30152 const options = { capture: true, once: true }; 30153 element.addEventListener("focusin", onFocus, options); 30154 const focusableContainer = getClosestFocusable(element.parentElement); 30155 markSafariFocusAncestor(focusableContainer, true); 30156 queueBeforeEvent(element, "mouseup", () => { 30157 element.removeEventListener("focusin", onFocus, true); 30158 markSafariFocusAncestor(focusableContainer, false); 30159 if (receivedFocus) return; 30160 focusIfNeeded(element); 30161 }); 30162 }); 30163 const handleFocusVisible = (event, currentTarget) => { 30164 if (currentTarget) { 30165 event.currentTarget = currentTarget; 30166 } 30167 if (!focusable) return; 30168 const element = event.currentTarget; 30169 if (!element) return; 30170 if (!hasFocus(element)) return; 30171 onFocusVisible == null ? void 0 : onFocusVisible(event); 30172 if (event.defaultPrevented) return; 30173 element.dataset.focusVisible = "true"; 30174 setFocusVisible(true); 30175 }; 30176 const onKeyDownCaptureProp = props.onKeyDownCapture; 30177 const onKeyDownCapture = useEvent((event) => { 30178 onKeyDownCaptureProp == null ? void 0 : onKeyDownCaptureProp(event); 30179 if (event.defaultPrevented) return; 30180 if (!focusable) return; 30181 if (focusVisible) return; 30182 if (event.metaKey) return; 30183 if (event.altKey) return; 30184 if (event.ctrlKey) return; 30185 if (!isSelfTarget(event)) return; 30186 const element = event.currentTarget; 30187 const applyFocusVisible = () => handleFocusVisible(event, element); 30188 queueBeforeEvent(element, "focusout", applyFocusVisible); 30189 }); 30190 const onFocusCaptureProp = props.onFocusCapture; 30191 const onFocusCapture = useEvent((event) => { 30192 onFocusCaptureProp == null ? void 0 : onFocusCaptureProp(event); 30193 if (event.defaultPrevented) return; 30194 if (!focusable) return; 30195 if (!isSelfTarget(event)) { 30196 setFocusVisible(false); 30197 return; 30198 } 30199 const element = event.currentTarget; 30200 const applyFocusVisible = () => handleFocusVisible(event, element); 30201 if (isKeyboardModality || isAlwaysFocusVisible(event.target)) { 30202 queueBeforeEvent(event.target, "focusout", applyFocusVisible); 30203 } else { 30204 setFocusVisible(false); 30205 } 30206 }); 30207 const onBlurProp = props.onBlur; 30208 const onBlur = useEvent((event) => { 30209 onBlurProp == null ? void 0 : onBlurProp(event); 30210 if (!focusable) return; 30211 if (!isFocusEventOutside(event)) return; 30212 setFocusVisible(false); 30213 }); 30214 const autoFocusOnShow = (0, import_react12.useContext)(FocusableContext); 30215 const autoFocusRef = useEvent((element) => { 30216 if (!focusable) return; 30217 if (!autoFocus) return; 30218 if (!element) return; 30219 if (!autoFocusOnShow) return; 30220 queueMicrotask(() => { 30221 if (hasFocus(element)) return; 30222 if (!isFocusable(element)) return; 30223 element.focus(); 30224 }); 30225 }); 30226 const tagName = useTagName(ref); 30227 const nativeTabbable = focusable && isNativeTabbable(tagName); 30228 const supportsDisabled = focusable && supportsDisabledAttribute(tagName); 30229 const styleProp = props.style; 30230 const style = (0, import_react12.useMemo)(() => { 30231 if (trulyDisabled) { 30232 return __spreadValues({ pointerEvents: "none" }, styleProp); 30233 } 30234 return styleProp; 30235 }, [trulyDisabled, styleProp]); 30236 props = __spreadProps(__spreadValues({ 30237 "data-focus-visible": focusable && focusVisible || void 0, 30238 "data-autofocus": autoFocus || void 0, 30239 "aria-disabled": disabled || void 0 30240 }, props), { 30241 ref: useMergeRefs(ref, autoFocusRef, props.ref), 30242 style, 30243 tabIndex: getTabIndex( 30244 focusable, 30245 trulyDisabled, 30246 nativeTabbable, 30247 supportsDisabled, 30248 props.tabIndex 30249 ), 30250 disabled: supportsDisabled && trulyDisabled ? true : void 0, 30251 // TODO: Test Focusable contentEditable. 30252 contentEditable: disabled ? void 0 : props.contentEditable, 30253 onKeyPressCapture, 30254 onClickCapture, 30255 onMouseDownCapture, 30256 onMouseDown, 30257 onKeyDownCapture, 30258 onFocusCapture, 30259 onBlur 30260 }); 30261 return removeUndefinedValues(props); 30262 } 30263 ); 30264 var Focusable = forwardRef22(function Focusable2(props) { 30265 const htmlProps = useFocusable(props); 30266 return createElement4(TagName2, htmlProps); 30267 }); 30268 30269 // node_modules/@ariakit/react-core/esm/__chunks/ITI7HKP4.js 30270 var import_react13 = __toESM(require_react(), 1); 30271 var import_jsx_runtime207 = __toESM(require_jsx_runtime(), 1); 30272 var TagName3 = "div"; 30273 function isGrid(items) { 30274 return items.some((item) => !!item.rowId); 30275 } 30276 function isPrintableKey(event) { 30277 const target = event.target; 30278 if (target && !isTextField(target)) return false; 30279 return event.key.length === 1 && !event.ctrlKey && !event.metaKey; 30280 } 30281 function isModifierKey(event) { 30282 return event.key === "Shift" || event.key === "Control" || event.key === "Alt" || event.key === "Meta"; 30283 } 30284 function useKeyboardEventProxy(store2, onKeyboardEvent, previousElementRef) { 30285 return useEvent((event) => { 30286 var _a; 30287 onKeyboardEvent == null ? void 0 : onKeyboardEvent(event); 30288 if (event.defaultPrevented) return; 30289 if (event.isPropagationStopped()) return; 30290 if (!isSelfTarget(event)) return; 30291 if (isModifierKey(event)) return; 30292 if (isPrintableKey(event)) return; 30293 const state = store2.getState(); 30294 const activeElement = (_a = getEnabledItem(store2, state.activeId)) == null ? void 0 : _a.element; 30295 if (!activeElement) return; 30296 const _b = event, { view } = _b, eventInit = __objRest(_b, ["view"]); 30297 const previousElement = previousElementRef == null ? void 0 : previousElementRef.current; 30298 if (activeElement !== previousElement) { 30299 activeElement.focus(); 30300 } 30301 if (!fireKeyboardEvent(activeElement, event.type, eventInit)) { 30302 event.preventDefault(); 30303 } 30304 if (event.currentTarget.contains(activeElement)) { 30305 event.stopPropagation(); 30306 } 30307 }); 30308 } 30309 function findFirstEnabledItemInTheLastRow(items) { 30310 return findFirstEnabledItem2( 30311 flatten2DArray(reverseArray(groupItemsByRows2(items))) 30312 ); 30313 } 30314 function useScheduleFocus(store2) { 30315 const [scheduled, setScheduled] = (0, import_react13.useState)(false); 30316 const schedule2 = (0, import_react13.useCallback)(() => setScheduled(true), []); 30317 const activeItem = store2.useState( 30318 (state) => getEnabledItem(store2, state.activeId) 30319 ); 30320 (0, import_react13.useEffect)(() => { 30321 const activeElement = activeItem == null ? void 0 : activeItem.element; 30322 if (!scheduled) return; 30323 if (!activeElement) return; 30324 setScheduled(false); 30325 activeElement.focus({ preventScroll: true }); 30326 }, [activeItem, scheduled]); 30327 return schedule2; 30328 } 30329 var useComposite = createHook( 30330 function useComposite2(_a) { 30331 var _b = _a, { 30332 store: store2, 30333 composite = true, 30334 focusOnMove = composite, 30335 moveOnKeyPress = true 30336 } = _b, props = __objRest(_b, [ 30337 "store", 30338 "composite", 30339 "focusOnMove", 30340 "moveOnKeyPress" 30341 ]); 30342 const context = useCompositeProviderContext(); 30343 store2 = store2 || context; 30344 invariant( 30345 store2, 30346 "Composite must receive a `store` prop or be wrapped in a CompositeProvider component." 30347 ); 30348 const ref = (0, import_react13.useRef)(null); 30349 const previousElementRef = (0, import_react13.useRef)(null); 30350 const scheduleFocus = useScheduleFocus(store2); 30351 const moves = store2.useState("moves"); 30352 const [, setBaseElement] = useTransactionState( 30353 composite ? store2.setBaseElement : null 30354 ); 30355 (0, import_react13.useEffect)(() => { 30356 var _a2; 30357 if (!store2) return; 30358 if (!moves) return; 30359 if (!composite) return; 30360 if (!focusOnMove) return; 30361 const { activeId: activeId2 } = store2.getState(); 30362 const itemElement = (_a2 = getEnabledItem(store2, activeId2)) == null ? void 0 : _a2.element; 30363 if (!itemElement) return; 30364 focusIntoView(itemElement); 30365 }, [store2, moves, composite, focusOnMove]); 30366 useSafeLayoutEffect(() => { 30367 if (!store2) return; 30368 if (!moves) return; 30369 if (!composite) return; 30370 const { baseElement, activeId: activeId2 } = store2.getState(); 30371 const isSelfAcive = activeId2 === null; 30372 if (!isSelfAcive) return; 30373 if (!baseElement) return; 30374 const previousElement = previousElementRef.current; 30375 previousElementRef.current = null; 30376 if (previousElement) { 30377 fireBlurEvent(previousElement, { relatedTarget: baseElement }); 30378 } 30379 if (!hasFocus(baseElement)) { 30380 baseElement.focus(); 30381 } 30382 }, [store2, moves, composite]); 30383 const activeId = store2.useState("activeId"); 30384 const virtualFocus = store2.useState("virtualFocus"); 30385 useSafeLayoutEffect(() => { 30386 var _a2; 30387 if (!store2) return; 30388 if (!composite) return; 30389 if (!virtualFocus) return; 30390 const previousElement = previousElementRef.current; 30391 previousElementRef.current = null; 30392 if (!previousElement) return; 30393 const activeElement = (_a2 = getEnabledItem(store2, activeId)) == null ? void 0 : _a2.element; 30394 const relatedTarget = activeElement || getActiveElement(previousElement); 30395 if (relatedTarget === previousElement) return; 30396 fireBlurEvent(previousElement, { relatedTarget }); 30397 }, [store2, activeId, virtualFocus, composite]); 30398 const onKeyDownCapture = useKeyboardEventProxy( 30399 store2, 30400 props.onKeyDownCapture, 30401 previousElementRef 30402 ); 30403 const onKeyUpCapture = useKeyboardEventProxy( 30404 store2, 30405 props.onKeyUpCapture, 30406 previousElementRef 30407 ); 30408 const onFocusCaptureProp = props.onFocusCapture; 30409 const onFocusCapture = useEvent((event) => { 30410 onFocusCaptureProp == null ? void 0 : onFocusCaptureProp(event); 30411 if (event.defaultPrevented) return; 30412 if (!store2) return; 30413 const { virtualFocus: virtualFocus2 } = store2.getState(); 30414 if (!virtualFocus2) return; 30415 const previousActiveElement = event.relatedTarget; 30416 const isSilentlyFocused = silentlyFocused(event.currentTarget); 30417 if (isSelfTarget(event) && isSilentlyFocused) { 30418 event.stopPropagation(); 30419 previousElementRef.current = previousActiveElement; 30420 } 30421 }); 30422 const onFocusProp = props.onFocus; 30423 const onFocus = useEvent((event) => { 30424 onFocusProp == null ? void 0 : onFocusProp(event); 30425 if (event.defaultPrevented) return; 30426 if (!composite) return; 30427 if (!store2) return; 30428 const { relatedTarget } = event; 30429 const { virtualFocus: virtualFocus2 } = store2.getState(); 30430 if (virtualFocus2) { 30431 if (isSelfTarget(event) && !isItem(store2, relatedTarget)) { 30432 queueMicrotask(scheduleFocus); 30433 } 30434 } else if (isSelfTarget(event)) { 30435 store2.setActiveId(null); 30436 } 30437 }); 30438 const onBlurCaptureProp = props.onBlurCapture; 30439 const onBlurCapture = useEvent((event) => { 30440 var _a2; 30441 onBlurCaptureProp == null ? void 0 : onBlurCaptureProp(event); 30442 if (event.defaultPrevented) return; 30443 if (!store2) return; 30444 const { virtualFocus: virtualFocus2, activeId: activeId2 } = store2.getState(); 30445 if (!virtualFocus2) return; 30446 const activeElement = (_a2 = getEnabledItem(store2, activeId2)) == null ? void 0 : _a2.element; 30447 const nextActiveElement = event.relatedTarget; 30448 const nextActiveElementIsItem = isItem(store2, nextActiveElement); 30449 const previousElement = previousElementRef.current; 30450 previousElementRef.current = null; 30451 if (isSelfTarget(event) && nextActiveElementIsItem) { 30452 if (nextActiveElement === activeElement) { 30453 if (previousElement && previousElement !== nextActiveElement) { 30454 fireBlurEvent(previousElement, event); 30455 } 30456 } else if (activeElement) { 30457 fireBlurEvent(activeElement, event); 30458 } else if (previousElement) { 30459 fireBlurEvent(previousElement, event); 30460 } 30461 event.stopPropagation(); 30462 } else { 30463 const targetIsItem = isItem(store2, event.target); 30464 if (!targetIsItem && activeElement) { 30465 fireBlurEvent(activeElement, event); 30466 } 30467 } 30468 }); 30469 const onKeyDownProp = props.onKeyDown; 30470 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress); 30471 const onKeyDown = useEvent((event) => { 30472 var _a2; 30473 onKeyDownProp == null ? void 0 : onKeyDownProp(event); 30474 if (event.defaultPrevented) return; 30475 if (!store2) return; 30476 if (!isSelfTarget(event)) return; 30477 const { orientation, renderedItems, activeId: activeId2 } = store2.getState(); 30478 const activeItem = getEnabledItem(store2, activeId2); 30479 if ((_a2 = activeItem == null ? void 0 : activeItem.element) == null ? void 0 : _a2.isConnected) return; 30480 const isVertical = orientation !== "horizontal"; 30481 const isHorizontal = orientation !== "vertical"; 30482 const grid = isGrid(renderedItems); 30483 const isHorizontalKey = event.key === "ArrowLeft" || event.key === "ArrowRight" || event.key === "Home" || event.key === "End"; 30484 if (isHorizontalKey && isTextField(event.currentTarget)) return; 30485 const up = () => { 30486 if (grid) { 30487 const item = findFirstEnabledItemInTheLastRow(renderedItems); 30488 return item == null ? void 0 : item.id; 30489 } 30490 return store2 == null ? void 0 : store2.last(); 30491 }; 30492 const keyMap = { 30493 ArrowUp: (grid || isVertical) && up, 30494 ArrowRight: (grid || isHorizontal) && store2.first, 30495 ArrowDown: (grid || isVertical) && store2.first, 30496 ArrowLeft: (grid || isHorizontal) && store2.last, 30497 Home: store2.first, 30498 End: store2.last, 30499 PageUp: store2.first, 30500 PageDown: store2.last 30501 }; 30502 const action = keyMap[event.key]; 30503 if (action) { 30504 const id = action(); 30505 if (id !== void 0) { 30506 if (!moveOnKeyPressProp(event)) return; 30507 event.preventDefault(); 30508 store2.move(id); 30509 } 30510 } 30511 }); 30512 props = useWrapElement( 30513 props, 30514 (element) => /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(CompositeContextProvider, { value: store2, children: element }), 30515 [store2] 30516 ); 30517 const activeDescendant = store2.useState((state) => { 30518 var _a2; 30519 if (!store2) return; 30520 if (!composite) return; 30521 if (!state.virtualFocus) return; 30522 return (_a2 = getEnabledItem(store2, state.activeId)) == null ? void 0 : _a2.id; 30523 }); 30524 props = __spreadProps(__spreadValues({ 30525 "aria-activedescendant": activeDescendant 30526 }, props), { 30527 ref: useMergeRefs(ref, setBaseElement, props.ref), 30528 onKeyDownCapture, 30529 onKeyUpCapture, 30530 onFocusCapture, 30531 onFocus, 30532 onBlurCapture, 30533 onKeyDown 30534 }); 30535 const focusable = store2.useState( 30536 (state) => composite && (state.virtualFocus || state.activeId === null) 30537 ); 30538 props = useFocusable(__spreadValues({ focusable }, props)); 30539 return props; 30540 } 30541 ); 30542 var Composite6 = forwardRef22(function Composite22(props) { 30543 const htmlProps = useComposite(props); 30544 return createElement4(TagName3, htmlProps); 30545 }); 30546 30547 // node_modules/@ariakit/react-core/esm/combobox/combobox.js 30548 var import_react14 = __toESM(require_react(), 1); 30549 var TagName4 = "input"; 30550 function isFirstItemAutoSelected(items, activeValue, autoSelect) { 30551 if (!autoSelect) return false; 30552 const firstItem = items.find((item) => !item.disabled && item.value); 30553 return (firstItem == null ? void 0 : firstItem.value) === activeValue; 30554 } 30555 function hasCompletionString(value, activeValue) { 30556 if (!activeValue) return false; 30557 if (value == null) return false; 30558 value = normalizeString2(value); 30559 return activeValue.length > value.length && activeValue.toLowerCase().indexOf(value.toLowerCase()) === 0; 30560 } 30561 function isInputEvent(event) { 30562 return event.type === "input"; 30563 } 30564 function isAriaAutoCompleteValue(value) { 30565 return value === "inline" || value === "list" || value === "both" || value === "none"; 30566 } 30567 function getDefaultAutoSelectId(items) { 30568 const item = items.find((item2) => { 30569 var _a; 30570 if (item2.disabled) return false; 30571 return ((_a = item2.element) == null ? void 0 : _a.getAttribute("role")) !== "tab"; 30572 }); 30573 return item == null ? void 0 : item.id; 30574 } 30575 var useCombobox = createHook( 30576 function useCombobox2(_a) { 30577 var _b = _a, { 30578 store: store2, 30579 focusable = true, 30580 autoSelect: autoSelectProp = false, 30581 getAutoSelectId, 30582 setValueOnChange, 30583 showMinLength = 0, 30584 showOnChange, 30585 showOnMouseDown, 30586 showOnClick = showOnMouseDown, 30587 showOnKeyDown, 30588 showOnKeyPress = showOnKeyDown, 30589 blurActiveItemOnClick, 30590 setValueOnClick = true, 30591 moveOnKeyPress = true, 30592 autoComplete = "list" 30593 } = _b, props = __objRest(_b, [ 30594 "store", 30595 "focusable", 30596 "autoSelect", 30597 "getAutoSelectId", 30598 "setValueOnChange", 30599 "showMinLength", 30600 "showOnChange", 30601 "showOnMouseDown", 30602 "showOnClick", 30603 "showOnKeyDown", 30604 "showOnKeyPress", 30605 "blurActiveItemOnClick", 30606 "setValueOnClick", 30607 "moveOnKeyPress", 30608 "autoComplete" 30609 ]); 30610 const context = useComboboxProviderContext(); 30611 store2 = store2 || context; 30612 invariant( 30613 store2, 30614 "Combobox must receive a `store` prop or be wrapped in a ComboboxProvider component." 30615 ); 30616 const ref = (0, import_react14.useRef)(null); 30617 const [valueUpdated, forceValueUpdate] = useForceUpdate2(); 30618 const canAutoSelectRef = (0, import_react14.useRef)(false); 30619 const composingRef = (0, import_react14.useRef)(false); 30620 const autoSelect = store2.useState( 30621 (state) => state.virtualFocus && autoSelectProp 30622 ); 30623 const inline = autoComplete === "inline" || autoComplete === "both"; 30624 const [canInline, setCanInline] = (0, import_react14.useState)(inline); 30625 useUpdateLayoutEffect(() => { 30626 if (!inline) return; 30627 setCanInline(true); 30628 }, [inline]); 30629 const storeValue = store2.useState("value"); 30630 const prevSelectedValueRef = (0, import_react14.useRef)(); 30631 (0, import_react14.useEffect)(() => { 30632 return sync2(store2, ["selectedValue", "activeId"], (_, prev) => { 30633 prevSelectedValueRef.current = prev.selectedValue; 30634 }); 30635 }, []); 30636 const inlineActiveValue = store2.useState((state) => { 30637 var _a2; 30638 if (!inline) return; 30639 if (!canInline) return; 30640 if (state.activeValue && Array.isArray(state.selectedValue)) { 30641 if (state.selectedValue.includes(state.activeValue)) return; 30642 if ((_a2 = prevSelectedValueRef.current) == null ? void 0 : _a2.includes(state.activeValue)) return; 30643 } 30644 return state.activeValue; 30645 }); 30646 const items = store2.useState("renderedItems"); 30647 const open = store2.useState("open"); 30648 const contentElement = store2.useState("contentElement"); 30649 const value = (0, import_react14.useMemo)(() => { 30650 if (!inline) return storeValue; 30651 if (!canInline) return storeValue; 30652 const firstItemAutoSelected = isFirstItemAutoSelected( 30653 items, 30654 inlineActiveValue, 30655 autoSelect 30656 ); 30657 if (firstItemAutoSelected) { 30658 if (hasCompletionString(storeValue, inlineActiveValue)) { 30659 const slice = (inlineActiveValue == null ? void 0 : inlineActiveValue.slice(storeValue.length)) || ""; 30660 return storeValue + slice; 30661 } 30662 return storeValue; 30663 } 30664 return inlineActiveValue || storeValue; 30665 }, [inline, canInline, items, inlineActiveValue, autoSelect, storeValue]); 30666 (0, import_react14.useEffect)(() => { 30667 const element = ref.current; 30668 if (!element) return; 30669 const onCompositeItemMove = () => setCanInline(true); 30670 element.addEventListener("combobox-item-move", onCompositeItemMove); 30671 return () => { 30672 element.removeEventListener("combobox-item-move", onCompositeItemMove); 30673 }; 30674 }, []); 30675 (0, import_react14.useEffect)(() => { 30676 if (!inline) return; 30677 if (!canInline) return; 30678 if (!inlineActiveValue) return; 30679 const firstItemAutoSelected = isFirstItemAutoSelected( 30680 items, 30681 inlineActiveValue, 30682 autoSelect 30683 ); 30684 if (!firstItemAutoSelected) return; 30685 if (!hasCompletionString(storeValue, inlineActiveValue)) return; 30686 let cleanup = noop3; 30687 queueMicrotask(() => { 30688 const element = ref.current; 30689 if (!element) return; 30690 const { start: prevStart, end: prevEnd } = getTextboxSelection(element); 30691 const nextStart = storeValue.length; 30692 const nextEnd = inlineActiveValue.length; 30693 setSelectionRange(element, nextStart, nextEnd); 30694 cleanup = () => { 30695 if (!hasFocus(element)) return; 30696 const { start: start2, end } = getTextboxSelection(element); 30697 if (start2 !== nextStart) return; 30698 if (end !== nextEnd) return; 30699 setSelectionRange(element, prevStart, prevEnd); 30700 }; 30701 }); 30702 return () => cleanup(); 30703 }, [ 30704 valueUpdated, 30705 inline, 30706 canInline, 30707 inlineActiveValue, 30708 items, 30709 autoSelect, 30710 storeValue 30711 ]); 30712 const scrollingElementRef = (0, import_react14.useRef)(null); 30713 const getAutoSelectIdProp = useEvent(getAutoSelectId); 30714 const autoSelectIdRef = (0, import_react14.useRef)(null); 30715 (0, import_react14.useEffect)(() => { 30716 if (!open) return; 30717 if (!contentElement) return; 30718 const scrollingElement = getScrollingElement(contentElement); 30719 if (!scrollingElement) return; 30720 scrollingElementRef.current = scrollingElement; 30721 const onUserScroll = () => { 30722 canAutoSelectRef.current = false; 30723 }; 30724 const onScroll = () => { 30725 if (!store2) return; 30726 if (!canAutoSelectRef.current) return; 30727 const { activeId } = store2.getState(); 30728 if (activeId === null) return; 30729 if (activeId === autoSelectIdRef.current) return; 30730 canAutoSelectRef.current = false; 30731 }; 30732 const options = { passive: true, capture: true }; 30733 scrollingElement.addEventListener("wheel", onUserScroll, options); 30734 scrollingElement.addEventListener("touchmove", onUserScroll, options); 30735 scrollingElement.addEventListener("scroll", onScroll, options); 30736 return () => { 30737 scrollingElement.removeEventListener("wheel", onUserScroll, true); 30738 scrollingElement.removeEventListener("touchmove", onUserScroll, true); 30739 scrollingElement.removeEventListener("scroll", onScroll, true); 30740 }; 30741 }, [open, contentElement, store2]); 30742 useSafeLayoutEffect(() => { 30743 if (!storeValue) return; 30744 if (composingRef.current) return; 30745 canAutoSelectRef.current = true; 30746 }, [storeValue]); 30747 useSafeLayoutEffect(() => { 30748 if (autoSelect !== "always" && open) return; 30749 canAutoSelectRef.current = open; 30750 }, [autoSelect, open]); 30751 const resetValueOnSelect = store2.useState("resetValueOnSelect"); 30752 useUpdateEffect(() => { 30753 var _a2, _b2; 30754 const canAutoSelect = canAutoSelectRef.current; 30755 if (!store2) return; 30756 if (!open) return; 30757 if (!canAutoSelect && !resetValueOnSelect) return; 30758 const { baseElement, contentElement: contentElement2, activeId } = store2.getState(); 30759 if (baseElement && !hasFocus(baseElement)) return; 30760 if (contentElement2 == null ? void 0 : contentElement2.hasAttribute("data-placing")) { 30761 const observer = new MutationObserver(forceValueUpdate); 30762 observer.observe(contentElement2, { attributeFilter: ["data-placing"] }); 30763 return () => observer.disconnect(); 30764 } 30765 if (autoSelect && canAutoSelect) { 30766 const userAutoSelectId = getAutoSelectIdProp(items); 30767 const autoSelectId = userAutoSelectId !== void 0 ? userAutoSelectId : (_a2 = getDefaultAutoSelectId(items)) != null ? _a2 : store2.first(); 30768 autoSelectIdRef.current = autoSelectId; 30769 store2.move(autoSelectId != null ? autoSelectId : null); 30770 } else { 30771 const element = (_b2 = store2.item(activeId || store2.first())) == null ? void 0 : _b2.element; 30772 if (element && "scrollIntoView" in element) { 30773 element.scrollIntoView({ block: "nearest", inline: "nearest" }); 30774 } 30775 } 30776 return; 30777 }, [ 30778 store2, 30779 open, 30780 valueUpdated, 30781 storeValue, 30782 autoSelect, 30783 resetValueOnSelect, 30784 getAutoSelectIdProp, 30785 items 30786 ]); 30787 (0, import_react14.useEffect)(() => { 30788 if (!inline) return; 30789 const combobox = ref.current; 30790 if (!combobox) return; 30791 const elements2 = [combobox, contentElement].filter( 30792 (value2) => !!value2 30793 ); 30794 const onBlur2 = (event) => { 30795 if (elements2.every((el) => isFocusEventOutside(event, el))) { 30796 store2 == null ? void 0 : store2.setValue(value); 30797 } 30798 }; 30799 for (const element of elements2) { 30800 element.addEventListener("focusout", onBlur2); 30801 } 30802 return () => { 30803 for (const element of elements2) { 30804 element.removeEventListener("focusout", onBlur2); 30805 } 30806 }; 30807 }, [inline, contentElement, store2, value]); 30808 const canShow = (event) => { 30809 const currentTarget = event.currentTarget; 30810 return currentTarget.value.length >= showMinLength; 30811 }; 30812 const onChangeProp = props.onChange; 30813 const showOnChangeProp = useBooleanEvent(showOnChange != null ? showOnChange : canShow); 30814 const setValueOnChangeProp = useBooleanEvent( 30815 // If the combobox is combined with tags, the value will be set by the tag 30816 // input component. 30817 setValueOnChange != null ? setValueOnChange : !store2.tag 30818 ); 30819 const onChange = useEvent((event) => { 30820 onChangeProp == null ? void 0 : onChangeProp(event); 30821 if (event.defaultPrevented) return; 30822 if (!store2) return; 30823 const currentTarget = event.currentTarget; 30824 const { value: value2, selectionStart, selectionEnd } = currentTarget; 30825 const nativeEvent = event.nativeEvent; 30826 canAutoSelectRef.current = true; 30827 if (isInputEvent(nativeEvent)) { 30828 if (nativeEvent.isComposing) { 30829 canAutoSelectRef.current = false; 30830 composingRef.current = true; 30831 } 30832 if (inline) { 30833 const textInserted = nativeEvent.inputType === "insertText" || nativeEvent.inputType === "insertCompositionText"; 30834 const caretAtEnd = selectionStart === value2.length; 30835 setCanInline(textInserted && caretAtEnd); 30836 } 30837 } 30838 if (setValueOnChangeProp(event)) { 30839 const isSameValue = value2 === store2.getState().value; 30840 store2.setValue(value2); 30841 queueMicrotask(() => { 30842 setSelectionRange(currentTarget, selectionStart, selectionEnd); 30843 }); 30844 if (inline && autoSelect && isSameValue) { 30845 forceValueUpdate(); 30846 } 30847 } 30848 if (showOnChangeProp(event)) { 30849 store2.show(); 30850 } 30851 if (!autoSelect || !canAutoSelectRef.current) { 30852 store2.setActiveId(null); 30853 } 30854 }); 30855 const onCompositionEndProp = props.onCompositionEnd; 30856 const onCompositionEnd = useEvent((event) => { 30857 canAutoSelectRef.current = true; 30858 composingRef.current = false; 30859 onCompositionEndProp == null ? void 0 : onCompositionEndProp(event); 30860 if (event.defaultPrevented) return; 30861 if (!autoSelect) return; 30862 forceValueUpdate(); 30863 }); 30864 const onMouseDownProp = props.onMouseDown; 30865 const blurActiveItemOnClickProp = useBooleanEvent( 30866 blurActiveItemOnClick != null ? blurActiveItemOnClick : () => !!(store2 == null ? void 0 : store2.getState().includesBaseElement) 30867 ); 30868 const setValueOnClickProp = useBooleanEvent(setValueOnClick); 30869 const showOnClickProp = useBooleanEvent(showOnClick != null ? showOnClick : canShow); 30870 const onMouseDown = useEvent((event) => { 30871 onMouseDownProp == null ? void 0 : onMouseDownProp(event); 30872 if (event.defaultPrevented) return; 30873 if (event.button) return; 30874 if (event.ctrlKey) return; 30875 if (!store2) return; 30876 if (blurActiveItemOnClickProp(event)) { 30877 store2.setActiveId(null); 30878 } 30879 if (setValueOnClickProp(event)) { 30880 store2.setValue(value); 30881 } 30882 if (showOnClickProp(event)) { 30883 queueBeforeEvent(event.currentTarget, "mouseup", store2.show); 30884 } 30885 }); 30886 const onKeyDownProp = props.onKeyDown; 30887 const showOnKeyPressProp = useBooleanEvent(showOnKeyPress != null ? showOnKeyPress : canShow); 30888 const onKeyDown = useEvent((event) => { 30889 onKeyDownProp == null ? void 0 : onKeyDownProp(event); 30890 if (!event.repeat) { 30891 canAutoSelectRef.current = false; 30892 } 30893 if (event.defaultPrevented) return; 30894 if (event.ctrlKey) return; 30895 if (event.altKey) return; 30896 if (event.shiftKey) return; 30897 if (event.metaKey) return; 30898 if (!store2) return; 30899 const { open: open2 } = store2.getState(); 30900 if (open2) return; 30901 if (event.key === "ArrowUp" || event.key === "ArrowDown") { 30902 if (showOnKeyPressProp(event)) { 30903 event.preventDefault(); 30904 store2.show(); 30905 } 30906 } 30907 }); 30908 const onBlurProp = props.onBlur; 30909 const onBlur = useEvent((event) => { 30910 canAutoSelectRef.current = false; 30911 onBlurProp == null ? void 0 : onBlurProp(event); 30912 if (event.defaultPrevented) return; 30913 }); 30914 const id = useId5(props.id); 30915 const ariaAutoComplete = isAriaAutoCompleteValue(autoComplete) ? autoComplete : void 0; 30916 const isActiveItem = store2.useState((state) => state.activeId === null); 30917 props = __spreadProps(__spreadValues({ 30918 id, 30919 role: "combobox", 30920 "aria-autocomplete": ariaAutoComplete, 30921 "aria-haspopup": getPopupRole(contentElement, "listbox"), 30922 "aria-expanded": open, 30923 "aria-controls": contentElement == null ? void 0 : contentElement.id, 30924 "data-active-item": isActiveItem || void 0, 30925 value 30926 }, props), { 30927 ref: useMergeRefs(ref, props.ref), 30928 onChange, 30929 onCompositionEnd, 30930 onMouseDown, 30931 onKeyDown, 30932 onBlur 30933 }); 30934 props = useComposite(__spreadProps(__spreadValues({ 30935 store: store2, 30936 focusable 30937 }, props), { 30938 // Enable inline autocomplete when the user moves from the combobox input 30939 // to an item. 30940 moveOnKeyPress: (event) => { 30941 if (isFalsyBooleanCallback(moveOnKeyPress, event)) return false; 30942 if (inline) setCanInline(true); 30943 return true; 30944 } 30945 })); 30946 props = usePopoverAnchor(__spreadValues({ store: store2 }, props)); 30947 return __spreadValues({ autoComplete: "off" }, props); 30948 } 30949 ); 30950 var Combobox = forwardRef22(function Combobox2(props) { 30951 const htmlProps = useCombobox(props); 30952 return createElement4(TagName4, htmlProps); 30953 }); 30954 30955 // node_modules/@ariakit/react-core/esm/combobox/combobox-provider.js 30956 var import_jsx_runtime208 = __toESM(require_jsx_runtime(), 1); 30957 function ComboboxProvider(props = {}) { 30958 const store2 = useComboboxStore(props); 30959 return /* @__PURE__ */ (0, import_jsx_runtime208.jsx)(ComboboxContextProvider, { value: store2, children: props.children }); 30960 } 30961 30962 // node_modules/@ariakit/react-core/esm/__chunks/KUU7WJ55.js 30963 var import_react15 = __toESM(require_react(), 1); 30964 var TagName5 = "button"; 30965 function isNativeClick(event) { 30966 if (!event.isTrusted) return false; 30967 const element = event.currentTarget; 30968 if (event.key === "Enter") { 30969 return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "A"; 30970 } 30971 if (event.key === " ") { 30972 return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "INPUT" || element.tagName === "SELECT"; 30973 } 30974 return false; 30975 } 30976 var symbol = Symbol("command"); 30977 var useCommand = createHook( 30978 function useCommand2(_a) { 30979 var _b = _a, { clickOnEnter = true, clickOnSpace = true } = _b, props = __objRest(_b, ["clickOnEnter", "clickOnSpace"]); 30980 const ref = (0, import_react15.useRef)(null); 30981 const [isNativeButton, setIsNativeButton] = (0, import_react15.useState)(false); 30982 (0, import_react15.useEffect)(() => { 30983 if (!ref.current) return; 30984 setIsNativeButton(isButton(ref.current)); 30985 }, []); 30986 const [active, setActive] = (0, import_react15.useState)(false); 30987 const activeRef = (0, import_react15.useRef)(false); 30988 const disabled = disabledFromProps(props); 30989 const [isDuplicate, metadataProps] = useMetadataProps(props, symbol, true); 30990 const onKeyDownProp = props.onKeyDown; 30991 const onKeyDown = useEvent((event) => { 30992 onKeyDownProp == null ? void 0 : onKeyDownProp(event); 30993 const element = event.currentTarget; 30994 if (event.defaultPrevented) return; 30995 if (isDuplicate) return; 30996 if (disabled) return; 30997 if (!isSelfTarget(event)) return; 30998 if (isTextField(element)) return; 30999 if (element.isContentEditable) return; 31000 const isEnter = clickOnEnter && event.key === "Enter"; 31001 const isSpace = clickOnSpace && event.key === " "; 31002 const shouldPreventEnter = event.key === "Enter" && !clickOnEnter; 31003 const shouldPreventSpace = event.key === " " && !clickOnSpace; 31004 if (shouldPreventEnter || shouldPreventSpace) { 31005 event.preventDefault(); 31006 return; 31007 } 31008 if (isEnter || isSpace) { 31009 const nativeClick = isNativeClick(event); 31010 if (isEnter) { 31011 if (!nativeClick) { 31012 event.preventDefault(); 31013 const _a2 = event, { view } = _a2, eventInit = __objRest(_a2, ["view"]); 31014 const click = () => fireClickEvent(element, eventInit); 31015 if (isFirefox()) { 31016 queueBeforeEvent(element, "keyup", click); 31017 } else { 31018 queueMicrotask(click); 31019 } 31020 } 31021 } else if (isSpace) { 31022 activeRef.current = true; 31023 if (!nativeClick) { 31024 event.preventDefault(); 31025 setActive(true); 31026 } 31027 } 31028 } 31029 }); 31030 const onKeyUpProp = props.onKeyUp; 31031 const onKeyUp = useEvent((event) => { 31032 onKeyUpProp == null ? void 0 : onKeyUpProp(event); 31033 if (event.defaultPrevented) return; 31034 if (isDuplicate) return; 31035 if (disabled) return; 31036 if (event.metaKey) return; 31037 const isSpace = clickOnSpace && event.key === " "; 31038 if (activeRef.current && isSpace) { 31039 activeRef.current = false; 31040 if (!isNativeClick(event)) { 31041 event.preventDefault(); 31042 setActive(false); 31043 const element = event.currentTarget; 31044 const _a2 = event, { view } = _a2, eventInit = __objRest(_a2, ["view"]); 31045 queueMicrotask(() => fireClickEvent(element, eventInit)); 31046 } 31047 } 31048 }); 31049 props = __spreadProps(__spreadValues(__spreadValues({ 31050 "data-active": active || void 0, 31051 type: isNativeButton ? "button" : void 0 31052 }, metadataProps), props), { 31053 ref: useMergeRefs(ref, props.ref), 31054 onKeyDown, 31055 onKeyUp 31056 }); 31057 props = useFocusable(props); 31058 return props; 31059 } 31060 ); 31061 var Command = forwardRef22(function Command2(props) { 31062 const htmlProps = useCommand(props); 31063 return createElement4(TagName5, htmlProps); 31064 }); 31065 31066 // node_modules/@ariakit/react-core/esm/combobox/combobox-item-value.js 31067 var import_react16 = __toESM(require_react(), 1); 31068 var import_jsx_runtime209 = __toESM(require_jsx_runtime(), 1); 31069 var TagName6 = "span"; 31070 function normalizeValue(value) { 31071 return normalizeString2(value).toLowerCase(); 31072 } 31073 function getOffsets(string, values) { 31074 const offsets = []; 31075 for (const value of values) { 31076 let pos = 0; 31077 const length = value.length; 31078 while (string.indexOf(value, pos) !== -1) { 31079 const index = string.indexOf(value, pos); 31080 if (index !== -1) { 31081 offsets.push([index, length]); 31082 } 31083 pos = index + 1; 31084 } 31085 } 31086 return offsets; 31087 } 31088 function filterOverlappingOffsets(offsets) { 31089 return offsets.filter(([offset, length], i2, arr) => { 31090 return !arr.some( 31091 ([o3, l2], j2) => j2 !== i2 && o3 <= offset && o3 + l2 >= offset + length 31092 ); 31093 }); 31094 } 31095 function sortOffsets(offsets) { 31096 return offsets.sort(([a2], [b2]) => a2 - b2); 31097 } 31098 function splitValue(itemValue, userValue) { 31099 if (!itemValue) return itemValue; 31100 if (!userValue) return itemValue; 31101 const userValues = toArray2(userValue).filter(Boolean).map(normalizeValue); 31102 const parts = []; 31103 const span = (value, autocomplete = false) => /* @__PURE__ */ (0, import_jsx_runtime209.jsx)( 31104 "span", 31105 { 31106 "data-autocomplete-value": autocomplete ? "" : void 0, 31107 "data-user-value": autocomplete ? void 0 : "", 31108 children: value 31109 }, 31110 parts.length 31111 ); 31112 const offsets = sortOffsets( 31113 filterOverlappingOffsets( 31114 // Convert userValues into a set to avoid duplicates 31115 getOffsets(normalizeValue(itemValue), new Set(userValues)) 31116 ) 31117 ); 31118 if (!offsets.length) { 31119 parts.push(span(itemValue, true)); 31120 return parts; 31121 } 31122 const [firstOffset] = offsets[0]; 31123 const values = [ 31124 itemValue.slice(0, firstOffset), 31125 ...offsets.flatMap(([offset, length], i2) => { 31126 var _a; 31127 const value = itemValue.slice(offset, offset + length); 31128 const nextOffset = (_a = offsets[i2 + 1]) == null ? void 0 : _a[0]; 31129 const nextValue = itemValue.slice(offset + length, nextOffset); 31130 return [value, nextValue]; 31131 }) 31132 ]; 31133 values.forEach((value, i2) => { 31134 if (!value) return; 31135 parts.push(span(value, i2 % 2 === 0)); 31136 }); 31137 return parts; 31138 } 31139 var useComboboxItemValue = createHook(function useComboboxItemValue2(_a) { 31140 var _b = _a, { store: store2, value, userValue } = _b, props = __objRest(_b, ["store", "value", "userValue"]); 31141 const context = useComboboxScopedContext(); 31142 store2 = store2 || context; 31143 const itemContext = (0, import_react16.useContext)(ComboboxItemValueContext); 31144 const itemValue = value != null ? value : itemContext; 31145 const inputValue = useStoreState(store2, (state) => userValue != null ? userValue : state == null ? void 0 : state.value); 31146 const children = (0, import_react16.useMemo)(() => { 31147 if (!itemValue) return; 31148 if (!inputValue) return itemValue; 31149 return splitValue(itemValue, inputValue); 31150 }, [itemValue, inputValue]); 31151 props = __spreadValues({ 31152 children 31153 }, props); 31154 return removeUndefinedValues(props); 31155 }); 31156 var ComboboxItemValue = forwardRef22(function ComboboxItemValue2(props) { 31157 const htmlProps = useComboboxItemValue(props); 31158 return createElement4(TagName6, htmlProps); 31159 }); 31160 31161 // node_modules/@ariakit/react-core/esm/__chunks/UQQRIHDV.js 31162 var import_react17 = __toESM(require_react(), 1); 31163 var TagName7 = "div"; 31164 function getMouseDestination(event) { 31165 const relatedTarget = event.relatedTarget; 31166 if ((relatedTarget == null ? void 0 : relatedTarget.nodeType) === Node.ELEMENT_NODE) { 31167 return relatedTarget; 31168 } 31169 return null; 31170 } 31171 function hoveringInside(event) { 31172 const nextElement = getMouseDestination(event); 31173 if (!nextElement) return false; 31174 return contains(event.currentTarget, nextElement); 31175 } 31176 var symbol2 = Symbol("composite-hover"); 31177 function movingToAnotherItem(event) { 31178 let dest = getMouseDestination(event); 31179 if (!dest) return false; 31180 do { 31181 if (hasOwnProperty(dest, symbol2) && dest[symbol2]) return true; 31182 dest = dest.parentElement; 31183 } while (dest); 31184 return false; 31185 } 31186 var useCompositeHover = createHook( 31187 function useCompositeHover2(_a) { 31188 var _b = _a, { 31189 store: store2, 31190 focusOnHover = true, 31191 blurOnHoverEnd = !!focusOnHover 31192 } = _b, props = __objRest(_b, [ 31193 "store", 31194 "focusOnHover", 31195 "blurOnHoverEnd" 31196 ]); 31197 const context = useCompositeContext(); 31198 store2 = store2 || context; 31199 invariant( 31200 store2, 31201 "CompositeHover must be wrapped in a Composite component." 31202 ); 31203 const isMouseMoving = useIsMouseMoving(); 31204 const onMouseMoveProp = props.onMouseMove; 31205 const focusOnHoverProp = useBooleanEvent(focusOnHover); 31206 const onMouseMove = useEvent((event) => { 31207 onMouseMoveProp == null ? void 0 : onMouseMoveProp(event); 31208 if (event.defaultPrevented) return; 31209 if (!isMouseMoving()) return; 31210 if (!focusOnHoverProp(event)) return; 31211 if (!hasFocusWithin(event.currentTarget)) { 31212 const baseElement = store2 == null ? void 0 : store2.getState().baseElement; 31213 if (baseElement && !hasFocus(baseElement)) { 31214 baseElement.focus(); 31215 } 31216 } 31217 store2 == null ? void 0 : store2.setActiveId(event.currentTarget.id); 31218 }); 31219 const onMouseLeaveProp = props.onMouseLeave; 31220 const blurOnHoverEndProp = useBooleanEvent(blurOnHoverEnd); 31221 const onMouseLeave = useEvent((event) => { 31222 var _a2; 31223 onMouseLeaveProp == null ? void 0 : onMouseLeaveProp(event); 31224 if (event.defaultPrevented) return; 31225 if (!isMouseMoving()) return; 31226 if (hoveringInside(event)) return; 31227 if (movingToAnotherItem(event)) return; 31228 if (!focusOnHoverProp(event)) return; 31229 if (!blurOnHoverEndProp(event)) return; 31230 store2 == null ? void 0 : store2.setActiveId(null); 31231 (_a2 = store2 == null ? void 0 : store2.getState().baseElement) == null ? void 0 : _a2.focus(); 31232 }); 31233 const ref = (0, import_react17.useCallback)((element) => { 31234 if (!element) return; 31235 element[symbol2] = true; 31236 }, []); 31237 props = __spreadProps(__spreadValues({}, props), { 31238 ref: useMergeRefs(ref, props.ref), 31239 onMouseMove, 31240 onMouseLeave 31241 }); 31242 return removeUndefinedValues(props); 31243 } 31244 ); 31245 var CompositeHover = memo22( 31246 forwardRef22(function CompositeHover2(props) { 31247 const htmlProps = useCompositeHover(props); 31248 return createElement4(TagName7, htmlProps); 31249 }) 31250 ); 31251 31252 // node_modules/@ariakit/react-core/esm/__chunks/RZ4GPYOB.js 31253 var import_react18 = __toESM(require_react(), 1); 31254 var TagName8 = "div"; 31255 var useCollectionItem = createHook( 31256 function useCollectionItem2(_a) { 31257 var _b = _a, { 31258 store: store2, 31259 shouldRegisterItem = true, 31260 getItem = identity, 31261 element 31262 } = _b, props = __objRest(_b, [ 31263 "store", 31264 "shouldRegisterItem", 31265 "getItem", 31266 // @ts-expect-error This prop may come from a collection renderer. 31267 "element" 31268 ]); 31269 const context = useCollectionContext(); 31270 store2 = store2 || context; 31271 const id = useId5(props.id); 31272 const ref = (0, import_react18.useRef)(element); 31273 (0, import_react18.useEffect)(() => { 31274 const element2 = ref.current; 31275 if (!id) return; 31276 if (!element2) return; 31277 if (!shouldRegisterItem) return; 31278 const item = getItem({ id, element: element2 }); 31279 return store2 == null ? void 0 : store2.renderItem(item); 31280 }, [id, shouldRegisterItem, getItem, store2]); 31281 props = __spreadProps(__spreadValues({}, props), { 31282 ref: useMergeRefs(ref, props.ref) 31283 }); 31284 return removeUndefinedValues(props); 31285 } 31286 ); 31287 var CollectionItem = forwardRef22(function CollectionItem2(props) { 31288 const htmlProps = useCollectionItem(props); 31289 return createElement4(TagName8, htmlProps); 31290 }); 31291 31292 // node_modules/@ariakit/react-core/esm/__chunks/P2CTZE2T.js 31293 var import_react19 = __toESM(require_react(), 1); 31294 var import_jsx_runtime210 = __toESM(require_jsx_runtime(), 1); 31295 var TagName9 = "button"; 31296 function isEditableElement(element) { 31297 if (isTextbox(element)) return true; 31298 return element.tagName === "INPUT" && !isButton(element); 31299 } 31300 function getNextPageOffset(scrollingElement, pageUp = false) { 31301 const height = scrollingElement.clientHeight; 31302 const { top } = scrollingElement.getBoundingClientRect(); 31303 const pageSize = Math.max(height * 0.875, height - 40) * 1.5; 31304 const pageOffset = pageUp ? height - pageSize + top : pageSize + top; 31305 if (scrollingElement.tagName === "HTML") { 31306 return pageOffset + scrollingElement.scrollTop; 31307 } 31308 return pageOffset; 31309 } 31310 function getItemOffset(itemElement, pageUp = false) { 31311 const { top } = itemElement.getBoundingClientRect(); 31312 if (pageUp) { 31313 return top + itemElement.clientHeight; 31314 } 31315 return top; 31316 } 31317 function findNextPageItemId(element, store2, next, pageUp = false) { 31318 var _a; 31319 if (!store2) return; 31320 if (!next) return; 31321 const { renderedItems } = store2.getState(); 31322 const scrollingElement = getScrollingElement(element); 31323 if (!scrollingElement) return; 31324 const nextPageOffset = getNextPageOffset(scrollingElement, pageUp); 31325 let id; 31326 let prevDifference; 31327 for (let i2 = 0; i2 < renderedItems.length; i2 += 1) { 31328 const previousId = id; 31329 id = next(i2); 31330 if (!id) break; 31331 if (id === previousId) continue; 31332 const itemElement = (_a = getEnabledItem(store2, id)) == null ? void 0 : _a.element; 31333 if (!itemElement) continue; 31334 const itemOffset = getItemOffset(itemElement, pageUp); 31335 const difference = itemOffset - nextPageOffset; 31336 const absDifference = Math.abs(difference); 31337 if (pageUp && difference <= 0 || !pageUp && difference >= 0) { 31338 if (prevDifference !== void 0 && prevDifference < absDifference) { 31339 id = previousId; 31340 } 31341 break; 31342 } 31343 prevDifference = absDifference; 31344 } 31345 return id; 31346 } 31347 function targetIsAnotherItem(event, store2) { 31348 if (isSelfTarget(event)) return false; 31349 return isItem(store2, event.target); 31350 } 31351 var useCompositeItem = createHook( 31352 function useCompositeItem2(_a) { 31353 var _b = _a, { 31354 store: store2, 31355 rowId: rowIdProp, 31356 preventScrollOnKeyDown = false, 31357 moveOnKeyPress = true, 31358 tabbable = false, 31359 getItem: getItemProp, 31360 "aria-setsize": ariaSetSizeProp, 31361 "aria-posinset": ariaPosInSetProp 31362 } = _b, props = __objRest(_b, [ 31363 "store", 31364 "rowId", 31365 "preventScrollOnKeyDown", 31366 "moveOnKeyPress", 31367 "tabbable", 31368 "getItem", 31369 "aria-setsize", 31370 "aria-posinset" 31371 ]); 31372 const context = useCompositeContext(); 31373 store2 = store2 || context; 31374 const id = useId5(props.id); 31375 const ref = (0, import_react19.useRef)(null); 31376 const row = (0, import_react19.useContext)(CompositeRowContext); 31377 const disabled = disabledFromProps(props); 31378 const trulyDisabled = disabled && !props.accessibleWhenDisabled; 31379 const { 31380 rowId, 31381 baseElement, 31382 isActiveItem, 31383 ariaSetSize, 31384 ariaPosInSet, 31385 isTabbable 31386 } = useStoreStateObject(store2, { 31387 rowId(state) { 31388 if (rowIdProp) return rowIdProp; 31389 if (!state) return; 31390 if (!(row == null ? void 0 : row.baseElement)) return; 31391 if (row.baseElement !== state.baseElement) return; 31392 return row.id; 31393 }, 31394 baseElement(state) { 31395 return (state == null ? void 0 : state.baseElement) || void 0; 31396 }, 31397 isActiveItem(state) { 31398 return !!state && state.activeId === id; 31399 }, 31400 ariaSetSize(state) { 31401 if (ariaSetSizeProp != null) return ariaSetSizeProp; 31402 if (!state) return; 31403 if (!(row == null ? void 0 : row.ariaSetSize)) return; 31404 if (row.baseElement !== state.baseElement) return; 31405 return row.ariaSetSize; 31406 }, 31407 ariaPosInSet(state) { 31408 if (ariaPosInSetProp != null) return ariaPosInSetProp; 31409 if (!state) return; 31410 if (!(row == null ? void 0 : row.ariaPosInSet)) return; 31411 if (row.baseElement !== state.baseElement) return; 31412 const itemsInRow = state.renderedItems.filter( 31413 (item) => item.rowId === rowId 31414 ); 31415 return row.ariaPosInSet + itemsInRow.findIndex((item) => item.id === id); 31416 }, 31417 isTabbable(state) { 31418 if (!(state == null ? void 0 : state.renderedItems.length)) return true; 31419 if (state.virtualFocus) return false; 31420 if (tabbable) return true; 31421 if (state.activeId === null) return false; 31422 const item = store2 == null ? void 0 : store2.item(state.activeId); 31423 if (item == null ? void 0 : item.disabled) return true; 31424 if (!(item == null ? void 0 : item.element)) return true; 31425 return state.activeId === id; 31426 } 31427 }); 31428 const getItem = (0, import_react19.useCallback)( 31429 (item) => { 31430 var _a2; 31431 const nextItem = __spreadProps(__spreadValues({}, item), { 31432 id: id || item.id, 31433 rowId, 31434 disabled: !!trulyDisabled, 31435 children: (_a2 = item.element) == null ? void 0 : _a2.textContent 31436 }); 31437 if (getItemProp) { 31438 return getItemProp(nextItem); 31439 } 31440 return nextItem; 31441 }, 31442 [id, rowId, trulyDisabled, getItemProp] 31443 ); 31444 const onFocusProp = props.onFocus; 31445 const hasFocusedComposite = (0, import_react19.useRef)(false); 31446 const onFocus = useEvent((event) => { 31447 onFocusProp == null ? void 0 : onFocusProp(event); 31448 if (event.defaultPrevented) return; 31449 if (isPortalEvent(event)) return; 31450 if (!id) return; 31451 if (!store2) return; 31452 if (targetIsAnotherItem(event, store2)) return; 31453 const { virtualFocus, baseElement: baseElement2 } = store2.getState(); 31454 store2.setActiveId(id); 31455 if (isTextbox(event.currentTarget)) { 31456 selectTextField(event.currentTarget); 31457 } 31458 if (!virtualFocus) return; 31459 if (!isSelfTarget(event)) return; 31460 if (isEditableElement(event.currentTarget)) return; 31461 if (!(baseElement2 == null ? void 0 : baseElement2.isConnected)) return; 31462 if (isSafari() && event.currentTarget.hasAttribute("data-autofocus")) { 31463 event.currentTarget.scrollIntoView({ 31464 block: "nearest", 31465 inline: "nearest" 31466 }); 31467 } 31468 hasFocusedComposite.current = true; 31469 const fromComposite = event.relatedTarget === baseElement2 || isItem(store2, event.relatedTarget); 31470 if (fromComposite) { 31471 focusSilently(baseElement2); 31472 } else { 31473 baseElement2.focus(); 31474 } 31475 }); 31476 const onBlurCaptureProp = props.onBlurCapture; 31477 const onBlurCapture = useEvent((event) => { 31478 onBlurCaptureProp == null ? void 0 : onBlurCaptureProp(event); 31479 if (event.defaultPrevented) return; 31480 const state = store2 == null ? void 0 : store2.getState(); 31481 if ((state == null ? void 0 : state.virtualFocus) && hasFocusedComposite.current) { 31482 hasFocusedComposite.current = false; 31483 event.preventDefault(); 31484 event.stopPropagation(); 31485 } 31486 }); 31487 const onKeyDownProp = props.onKeyDown; 31488 const preventScrollOnKeyDownProp = useBooleanEvent(preventScrollOnKeyDown); 31489 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress); 31490 const onKeyDown = useEvent((event) => { 31491 onKeyDownProp == null ? void 0 : onKeyDownProp(event); 31492 if (event.defaultPrevented) return; 31493 if (!isSelfTarget(event)) return; 31494 if (!store2) return; 31495 const { currentTarget } = event; 31496 const state = store2.getState(); 31497 const item = store2.item(id); 31498 const isGrid2 = !!(item == null ? void 0 : item.rowId); 31499 const isVertical = state.orientation !== "horizontal"; 31500 const isHorizontal = state.orientation !== "vertical"; 31501 const canHomeEnd = () => { 31502 if (isGrid2) return true; 31503 if (isHorizontal) return true; 31504 if (!state.baseElement) return true; 31505 if (!isTextField(state.baseElement)) return true; 31506 return false; 31507 }; 31508 const keyMap = { 31509 ArrowUp: (isGrid2 || isVertical) && store2.up, 31510 ArrowRight: (isGrid2 || isHorizontal) && store2.next, 31511 ArrowDown: (isGrid2 || isVertical) && store2.down, 31512 ArrowLeft: (isGrid2 || isHorizontal) && store2.previous, 31513 Home: () => { 31514 if (!canHomeEnd()) return; 31515 if (!isGrid2 || event.ctrlKey) { 31516 return store2 == null ? void 0 : store2.first(); 31517 } 31518 return store2 == null ? void 0 : store2.previous(-1); 31519 }, 31520 End: () => { 31521 if (!canHomeEnd()) return; 31522 if (!isGrid2 || event.ctrlKey) { 31523 return store2 == null ? void 0 : store2.last(); 31524 } 31525 return store2 == null ? void 0 : store2.next(-1); 31526 }, 31527 PageUp: () => { 31528 return findNextPageItemId(currentTarget, store2, store2 == null ? void 0 : store2.up, true); 31529 }, 31530 PageDown: () => { 31531 return findNextPageItemId(currentTarget, store2, store2 == null ? void 0 : store2.down); 31532 } 31533 }; 31534 const action = keyMap[event.key]; 31535 if (action) { 31536 if (isTextbox(currentTarget)) { 31537 const selection = getTextboxSelection(currentTarget); 31538 const isLeft = isHorizontal && event.key === "ArrowLeft"; 31539 const isRight = isHorizontal && event.key === "ArrowRight"; 31540 const isUp = isVertical && event.key === "ArrowUp"; 31541 const isDown = isVertical && event.key === "ArrowDown"; 31542 if (isRight || isDown) { 31543 const { length: valueLength } = getTextboxValue(currentTarget); 31544 if (selection.end !== valueLength) return; 31545 } else if ((isLeft || isUp) && selection.start !== 0) return; 31546 } 31547 const nextId2 = action(); 31548 if (preventScrollOnKeyDownProp(event) || nextId2 !== void 0) { 31549 if (!moveOnKeyPressProp(event)) return; 31550 event.preventDefault(); 31551 store2.move(nextId2); 31552 } 31553 } 31554 }); 31555 const providerValue = (0, import_react19.useMemo)( 31556 () => ({ id, baseElement }), 31557 [id, baseElement] 31558 ); 31559 props = useWrapElement( 31560 props, 31561 (element) => /* @__PURE__ */ (0, import_jsx_runtime210.jsx)(CompositeItemContext.Provider, { value: providerValue, children: element }), 31562 [providerValue] 31563 ); 31564 props = __spreadProps(__spreadValues({ 31565 id, 31566 "data-active-item": isActiveItem || void 0 31567 }, props), { 31568 ref: useMergeRefs(ref, props.ref), 31569 tabIndex: isTabbable ? props.tabIndex : -1, 31570 onFocus, 31571 onBlurCapture, 31572 onKeyDown 31573 }); 31574 props = useCommand(props); 31575 props = useCollectionItem(__spreadProps(__spreadValues({ 31576 store: store2 31577 }, props), { 31578 getItem, 31579 shouldRegisterItem: id ? props.shouldRegisterItem : false 31580 })); 31581 return removeUndefinedValues(__spreadProps(__spreadValues({}, props), { 31582 "aria-setsize": ariaSetSize, 31583 "aria-posinset": ariaPosInSet 31584 })); 31585 } 31586 ); 31587 var CompositeItem = memo22( 31588 forwardRef22(function CompositeItem2(props) { 31589 const htmlProps = useCompositeItem(props); 31590 return createElement4(TagName9, htmlProps); 31591 }) 31592 ); 31593 31594 // node_modules/@ariakit/react-core/esm/__chunks/ZTDSJLD6.js 31595 var import_react20 = __toESM(require_react(), 1); 31596 var import_jsx_runtime211 = __toESM(require_jsx_runtime(), 1); 31597 var TagName10 = "div"; 31598 function isSelected(storeValue, itemValue) { 31599 if (itemValue == null) return; 31600 if (storeValue == null) return false; 31601 if (Array.isArray(storeValue)) { 31602 return storeValue.includes(itemValue); 31603 } 31604 return storeValue === itemValue; 31605 } 31606 function getItemRole(popupRole) { 31607 var _a; 31608 const itemRoleByPopupRole = { 31609 menu: "menuitem", 31610 listbox: "option", 31611 tree: "treeitem" 31612 }; 31613 const key = popupRole; 31614 return (_a = itemRoleByPopupRole[key]) != null ? _a : "option"; 31615 } 31616 var useComboboxItem = createHook( 31617 function useComboboxItem2(_a) { 31618 var _b = _a, { 31619 store: store2, 31620 value, 31621 hideOnClick, 31622 setValueOnClick, 31623 selectValueOnClick = true, 31624 resetValueOnSelect, 31625 focusOnHover = false, 31626 moveOnKeyPress = true, 31627 getItem: getItemProp 31628 } = _b, props = __objRest(_b, [ 31629 "store", 31630 "value", 31631 "hideOnClick", 31632 "setValueOnClick", 31633 "selectValueOnClick", 31634 "resetValueOnSelect", 31635 "focusOnHover", 31636 "moveOnKeyPress", 31637 "getItem" 31638 ]); 31639 var _a2; 31640 const context = useComboboxScopedContext(); 31641 store2 = store2 || context; 31642 invariant( 31643 store2, 31644 "ComboboxItem must be wrapped in a ComboboxList or ComboboxPopover component." 31645 ); 31646 const { resetValueOnSelectState, multiSelectable, selected } = useStoreStateObject(store2, { 31647 resetValueOnSelectState: "resetValueOnSelect", 31648 multiSelectable(state) { 31649 return Array.isArray(state.selectedValue); 31650 }, 31651 selected(state) { 31652 return isSelected(state.selectedValue, value); 31653 } 31654 }); 31655 const getItem = (0, import_react20.useCallback)( 31656 (item) => { 31657 const nextItem = __spreadProps(__spreadValues({}, item), { value }); 31658 if (getItemProp) { 31659 return getItemProp(nextItem); 31660 } 31661 return nextItem; 31662 }, 31663 [value, getItemProp] 31664 ); 31665 setValueOnClick = setValueOnClick != null ? setValueOnClick : !multiSelectable; 31666 hideOnClick = hideOnClick != null ? hideOnClick : value != null && !multiSelectable; 31667 const onClickProp = props.onClick; 31668 const setValueOnClickProp = useBooleanEvent(setValueOnClick); 31669 const selectValueOnClickProp = useBooleanEvent(selectValueOnClick); 31670 const resetValueOnSelectProp = useBooleanEvent( 31671 (_a2 = resetValueOnSelect != null ? resetValueOnSelect : resetValueOnSelectState) != null ? _a2 : multiSelectable 31672 ); 31673 const hideOnClickProp = useBooleanEvent(hideOnClick); 31674 const onClick = useEvent((event) => { 31675 onClickProp == null ? void 0 : onClickProp(event); 31676 if (event.defaultPrevented) return; 31677 if (isDownloading(event)) return; 31678 if (isOpeningInNewTab(event)) return; 31679 if (value != null) { 31680 if (selectValueOnClickProp(event)) { 31681 if (resetValueOnSelectProp(event)) { 31682 store2 == null ? void 0 : store2.resetValue(); 31683 } 31684 store2 == null ? void 0 : store2.setSelectedValue((prevValue) => { 31685 if (!Array.isArray(prevValue)) return value; 31686 if (prevValue.includes(value)) { 31687 return prevValue.filter((v2) => v2 !== value); 31688 } 31689 return [...prevValue, value]; 31690 }); 31691 } 31692 if (setValueOnClickProp(event)) { 31693 store2 == null ? void 0 : store2.setValue(value); 31694 } 31695 } 31696 if (hideOnClickProp(event)) { 31697 store2 == null ? void 0 : store2.hide(); 31698 } 31699 }); 31700 const onKeyDownProp = props.onKeyDown; 31701 const onKeyDown = useEvent((event) => { 31702 onKeyDownProp == null ? void 0 : onKeyDownProp(event); 31703 if (event.defaultPrevented) return; 31704 const baseElement = store2 == null ? void 0 : store2.getState().baseElement; 31705 if (!baseElement) return; 31706 if (hasFocus(baseElement)) return; 31707 const printable = event.key.length === 1; 31708 if (printable || event.key === "Backspace" || event.key === "Delete") { 31709 queueMicrotask(() => baseElement.focus()); 31710 if (isTextField(baseElement)) { 31711 store2 == null ? void 0 : store2.setValue(baseElement.value); 31712 } 31713 } 31714 }); 31715 if (multiSelectable && selected != null) { 31716 props = __spreadValues({ 31717 "aria-selected": selected 31718 }, props); 31719 } 31720 props = useWrapElement( 31721 props, 31722 (element) => /* @__PURE__ */ (0, import_jsx_runtime211.jsx)(ComboboxItemValueContext.Provider, { value, children: /* @__PURE__ */ (0, import_jsx_runtime211.jsx)(ComboboxItemCheckedContext.Provider, { value: selected != null ? selected : false, children: element }) }), 31723 [value, selected] 31724 ); 31725 const popupRole = (0, import_react20.useContext)(ComboboxListRoleContext); 31726 props = __spreadProps(__spreadValues({ 31727 role: getItemRole(popupRole), 31728 children: value 31729 }, props), { 31730 onClick, 31731 onKeyDown 31732 }); 31733 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress); 31734 props = useCompositeItem(__spreadProps(__spreadValues({ 31735 store: store2 31736 }, props), { 31737 getItem, 31738 // Dispatch a custom event on the combobox input when moving to an item 31739 // with the keyboard so the Combobox component can enable inline 31740 // autocompletion. 31741 moveOnKeyPress: (event) => { 31742 if (!moveOnKeyPressProp(event)) return false; 31743 const moveEvent = new Event("combobox-item-move"); 31744 const baseElement = store2 == null ? void 0 : store2.getState().baseElement; 31745 baseElement == null ? void 0 : baseElement.dispatchEvent(moveEvent); 31746 return true; 31747 } 31748 })); 31749 props = useCompositeHover(__spreadValues({ store: store2, focusOnHover }, props)); 31750 return props; 31751 } 31752 ); 31753 var ComboboxItem = memo22( 31754 forwardRef22(function ComboboxItem2(props) { 31755 const htmlProps = useComboboxItem(props); 31756 return createElement4(TagName10, htmlProps); 31757 }) 31758 ); 31759 31760 // node_modules/@ariakit/react-core/esm/combobox/combobox-label.js 31761 var TagName11 = "label"; 31762 var useComboboxLabel = createHook( 31763 function useComboboxLabel2(_a) { 31764 var _b = _a, { store: store2 } = _b, props = __objRest(_b, ["store"]); 31765 const context = useComboboxProviderContext(); 31766 store2 = store2 || context; 31767 invariant( 31768 store2, 31769 "ComboboxLabel must receive a `store` prop or be wrapped in a ComboboxProvider component." 31770 ); 31771 const comboboxId = store2.useState((state) => { 31772 var _a2; 31773 return (_a2 = state.baseElement) == null ? void 0 : _a2.id; 31774 }); 31775 props = __spreadValues({ 31776 htmlFor: comboboxId 31777 }, props); 31778 return removeUndefinedValues(props); 31779 } 31780 ); 31781 var ComboboxLabel = memo22( 31782 forwardRef22(function ComboboxLabel2(props) { 31783 const htmlProps = useComboboxLabel(props); 31784 return createElement4(TagName11, htmlProps); 31785 }) 31786 ); 31787 31788 // node_modules/@ariakit/react-core/esm/__chunks/VGCJ63VH.js 31789 var import_react21 = __toESM(require_react(), 1); 31790 var import_react_dom2 = __toESM(require_react_dom(), 1); 31791 var import_jsx_runtime212 = __toESM(require_jsx_runtime(), 1); 31792 var TagName12 = "div"; 31793 function afterTimeout(timeoutMs, cb) { 31794 const timeoutId = setTimeout(cb, timeoutMs); 31795 return () => clearTimeout(timeoutId); 31796 } 31797 function afterPaint2(cb) { 31798 let raf2 = requestAnimationFrame(() => { 31799 raf2 = requestAnimationFrame(cb); 31800 }); 31801 return () => cancelAnimationFrame(raf2); 31802 } 31803 function parseCSSTime(...times) { 31804 return times.join(", ").split(", ").reduce((longestTime, currentTimeString) => { 31805 const multiplier = currentTimeString.endsWith("ms") ? 1 : 1e3; 31806 const currentTime = Number.parseFloat(currentTimeString || "0s") * multiplier; 31807 if (currentTime > longestTime) return currentTime; 31808 return longestTime; 31809 }, 0); 31810 } 31811 function isHidden(mounted, hidden, alwaysVisible) { 31812 return !alwaysVisible && hidden !== false && (!mounted || !!hidden); 31813 } 31814 var useDisclosureContent = createHook(function useDisclosureContent2(_a) { 31815 var _b = _a, { store: store2, alwaysVisible } = _b, props = __objRest(_b, ["store", "alwaysVisible"]); 31816 const context = useDisclosureProviderContext(); 31817 store2 = store2 || context; 31818 invariant( 31819 store2, 31820 "DisclosureContent must receive a `store` prop or be wrapped in a DisclosureProvider component." 31821 ); 31822 const ref = (0, import_react21.useRef)(null); 31823 const id = useId5(props.id); 31824 const [transition, setTransition] = (0, import_react21.useState)(null); 31825 const open = store2.useState("open"); 31826 const mounted = store2.useState("mounted"); 31827 const animated2 = store2.useState("animated"); 31828 const contentElement = store2.useState("contentElement"); 31829 const otherElement = useStoreState(store2.disclosure, "contentElement"); 31830 useSafeLayoutEffect(() => { 31831 if (!ref.current) return; 31832 store2 == null ? void 0 : store2.setContentElement(ref.current); 31833 }, [store2]); 31834 useSafeLayoutEffect(() => { 31835 let previousAnimated; 31836 store2 == null ? void 0 : store2.setState("animated", (animated22) => { 31837 previousAnimated = animated22; 31838 return true; 31839 }); 31840 return () => { 31841 if (previousAnimated === void 0) return; 31842 store2 == null ? void 0 : store2.setState("animated", previousAnimated); 31843 }; 31844 }, [store2]); 31845 useSafeLayoutEffect(() => { 31846 if (!animated2) return; 31847 if (!(contentElement == null ? void 0 : contentElement.isConnected)) { 31848 setTransition(null); 31849 return; 31850 } 31851 return afterPaint2(() => { 31852 setTransition(open ? "enter" : mounted ? "leave" : null); 31853 }); 31854 }, [animated2, contentElement, open, mounted]); 31855 useSafeLayoutEffect(() => { 31856 if (!store2) return; 31857 if (!animated2) return; 31858 if (!transition) return; 31859 if (!contentElement) return; 31860 const stopAnimation = () => store2 == null ? void 0 : store2.setState("animating", false); 31861 const stopAnimationSync = () => (0, import_react_dom2.flushSync)(stopAnimation); 31862 if (transition === "leave" && open) return; 31863 if (transition === "enter" && !open) return; 31864 if (typeof animated2 === "number") { 31865 const timeout2 = animated2; 31866 return afterTimeout(timeout2, stopAnimationSync); 31867 } 31868 const { 31869 transitionDuration, 31870 animationDuration, 31871 transitionDelay, 31872 animationDelay 31873 } = getComputedStyle(contentElement); 31874 const { 31875 transitionDuration: transitionDuration2 = "0", 31876 animationDuration: animationDuration2 = "0", 31877 transitionDelay: transitionDelay2 = "0", 31878 animationDelay: animationDelay2 = "0" 31879 } = otherElement ? getComputedStyle(otherElement) : {}; 31880 const delay = parseCSSTime( 31881 transitionDelay, 31882 animationDelay, 31883 transitionDelay2, 31884 animationDelay2 31885 ); 31886 const duration = parseCSSTime( 31887 transitionDuration, 31888 animationDuration, 31889 transitionDuration2, 31890 animationDuration2 31891 ); 31892 const timeout = delay + duration; 31893 if (!timeout) { 31894 if (transition === "enter") { 31895 store2.setState("animated", false); 31896 } 31897 stopAnimation(); 31898 return; 31899 } 31900 const frameRate = 1e3 / 60; 31901 const maxTimeout = Math.max(timeout - frameRate, 0); 31902 return afterTimeout(maxTimeout, stopAnimationSync); 31903 }, [store2, animated2, contentElement, otherElement, open, transition]); 31904 props = useWrapElement( 31905 props, 31906 (element) => /* @__PURE__ */ (0, import_jsx_runtime212.jsx)(DialogScopedContextProvider, { value: store2, children: element }), 31907 [store2] 31908 ); 31909 const hidden = isHidden(mounted, props.hidden, alwaysVisible); 31910 const styleProp = props.style; 31911 const style = (0, import_react21.useMemo)(() => { 31912 if (hidden) { 31913 return __spreadProps(__spreadValues({}, styleProp), { display: "none" }); 31914 } 31915 return styleProp; 31916 }, [hidden, styleProp]); 31917 props = __spreadProps(__spreadValues({ 31918 id, 31919 "data-open": open || void 0, 31920 "data-enter": transition === "enter" || void 0, 31921 "data-leave": transition === "leave" || void 0, 31922 hidden 31923 }, props), { 31924 ref: useMergeRefs(id ? store2.setContentElement : null, ref, props.ref), 31925 style 31926 }); 31927 return removeUndefinedValues(props); 31928 }); 31929 var DisclosureContentImpl = forwardRef22(function DisclosureContentImpl2(props) { 31930 const htmlProps = useDisclosureContent(props); 31931 return createElement4(TagName12, htmlProps); 31932 }); 31933 var DisclosureContent = forwardRef22(function DisclosureContent2(_a) { 31934 var _b = _a, { 31935 unmountOnHide 31936 } = _b, props = __objRest(_b, [ 31937 "unmountOnHide" 31938 ]); 31939 const context = useDisclosureProviderContext(); 31940 const store2 = props.store || context; 31941 const mounted = useStoreState( 31942 store2, 31943 (state) => !unmountOnHide || (state == null ? void 0 : state.mounted) 31944 ); 31945 if (mounted === false) return null; 31946 return /* @__PURE__ */ (0, import_jsx_runtime212.jsx)(DisclosureContentImpl, __spreadValues({}, props)); 31947 }); 31948 31949 // node_modules/@ariakit/react-core/esm/__chunks/HUWAI7RB.js 31950 var import_react22 = __toESM(require_react(), 1); 31951 var import_jsx_runtime213 = __toESM(require_jsx_runtime(), 1); 31952 var TagName13 = "div"; 31953 var useComboboxList = createHook( 31954 function useComboboxList2(_a) { 31955 var _b = _a, { store: store2, alwaysVisible } = _b, props = __objRest(_b, ["store", "alwaysVisible"]); 31956 const scopedContext = useComboboxScopedContext(true); 31957 const context = useComboboxContext(); 31958 store2 = store2 || context; 31959 const scopedContextSameStore = !!store2 && store2 === scopedContext; 31960 invariant( 31961 store2, 31962 "ComboboxList must receive a `store` prop or be wrapped in a ComboboxProvider component." 31963 ); 31964 const ref = (0, import_react22.useRef)(null); 31965 const id = useId5(props.id); 31966 const mounted = store2.useState("mounted"); 31967 const hidden = isHidden(mounted, props.hidden, alwaysVisible); 31968 const style = hidden ? __spreadProps(__spreadValues({}, props.style), { display: "none" }) : props.style; 31969 const multiSelectable = store2.useState( 31970 (state) => Array.isArray(state.selectedValue) 31971 ); 31972 const role = useAttribute(ref, "role", props.role); 31973 const isCompositeRole = role === "listbox" || role === "tree" || role === "grid"; 31974 const ariaMultiSelectable = isCompositeRole ? multiSelectable || void 0 : void 0; 31975 const [hasListboxInside, setHasListboxInside] = (0, import_react22.useState)(false); 31976 const contentElement = store2.useState("contentElement"); 31977 useSafeLayoutEffect(() => { 31978 if (!mounted) return; 31979 const element = ref.current; 31980 if (!element) return; 31981 if (contentElement !== element) return; 31982 const callback = () => { 31983 setHasListboxInside(!!element.querySelector("[role='listbox']")); 31984 }; 31985 const observer = new MutationObserver(callback); 31986 observer.observe(element, { 31987 subtree: true, 31988 childList: true, 31989 attributeFilter: ["role"] 31990 }); 31991 callback(); 31992 return () => observer.disconnect(); 31993 }, [mounted, contentElement]); 31994 if (!hasListboxInside) { 31995 props = __spreadValues({ 31996 role: "listbox", 31997 "aria-multiselectable": ariaMultiSelectable 31998 }, props); 31999 } 32000 props = useWrapElement( 32001 props, 32002 (element) => /* @__PURE__ */ (0, import_jsx_runtime213.jsx)(ComboboxScopedContextProvider, { value: store2, children: /* @__PURE__ */ (0, import_jsx_runtime213.jsx)(ComboboxListRoleContext.Provider, { value: role, children: element }) }), 32003 [store2, role] 32004 ); 32005 const setContentElement = id && (!scopedContext || !scopedContextSameStore) ? store2.setContentElement : null; 32006 props = __spreadProps(__spreadValues({ 32007 id, 32008 hidden 32009 }, props), { 32010 ref: useMergeRefs(setContentElement, ref, props.ref), 32011 style 32012 }); 32013 return removeUndefinedValues(props); 32014 } 32015 ); 32016 var ComboboxList = forwardRef22(function ComboboxList2(props) { 32017 const htmlProps = useComboboxList(props); 32018 return createElement4(TagName13, htmlProps); 32019 }); 32020 32021 // packages/dataviews/build-module/components/dataviews-filters/search-widget.js 32022 var import_remove_accents = __toESM(require_remove_accents()); 32023 var import_compose18 = __toESM(require_compose()); 32024 var import_i18n103 = __toESM(require_i18n()); 32025 var import_element86 = __toESM(require_element()); 32026 var import_components112 = __toESM(require_components()); 32027 32028 // packages/dataviews/build-module/components/dataviews-filters/utils.js 32029 var EMPTY_ARRAY5 = []; 32030 var getCurrentValue = (filterDefinition, currentFilter) => { 32031 if (filterDefinition.singleSelection) { 32032 return currentFilter?.value; 32033 } 32034 if (Array.isArray(currentFilter?.value)) { 32035 return currentFilter.value; 32036 } 32037 if (!Array.isArray(currentFilter?.value) && !!currentFilter?.value) { 32038 return [currentFilter.value]; 32039 } 32040 return EMPTY_ARRAY5; 32041 }; 32042 32043 // packages/dataviews/build-module/hooks/use-elements.js 32044 var import_element85 = __toESM(require_element()); 32045 var EMPTY_ARRAY6 = []; 32046 function useElements({ 32047 elements: elements2, 32048 getElements 32049 }) { 32050 const staticElements = Array.isArray(elements2) && elements2.length > 0 ? elements2 : EMPTY_ARRAY6; 32051 const [records, setRecords] = (0, import_element85.useState)(staticElements); 32052 const [isLoading, setIsLoading] = (0, import_element85.useState)(false); 32053 (0, import_element85.useEffect)(() => { 32054 if (!getElements) { 32055 setRecords(staticElements); 32056 return; 32057 } 32058 let cancelled = false; 32059 setIsLoading(true); 32060 getElements().then((fetchedElements) => { 32061 if (!cancelled) { 32062 const dynamicElements = Array.isArray(fetchedElements) && fetchedElements.length > 0 ? fetchedElements : staticElements; 32063 setRecords(dynamicElements); 32064 } 32065 }).catch(() => { 32066 if (!cancelled) { 32067 setRecords(staticElements); 32068 } 32069 }).finally(() => { 32070 if (!cancelled) { 32071 setIsLoading(false); 32072 } 32073 }); 32074 return () => { 32075 cancelled = true; 32076 }; 32077 }, [getElements, staticElements]); 32078 return { 32079 elements: records, 32080 isLoading 32081 }; 32082 } 32083 32084 // packages/dataviews/build-module/components/dataviews-filters/search-widget.js 32085 var import_jsx_runtime214 = __toESM(require_jsx_runtime()); 32086 function normalizeSearchInput(input = "") { 32087 return (0, import_remove_accents.default)(input.trim().toLowerCase()); 32088 } 32089 var getNewValue = (filterDefinition, currentFilter, value) => { 32090 if (filterDefinition.singleSelection) { 32091 return value; 32092 } 32093 if (Array.isArray(currentFilter?.value)) { 32094 return currentFilter.value.includes(value) ? currentFilter.value.filter((v2) => v2 !== value) : [...currentFilter.value, value]; 32095 } 32096 return [value]; 32097 }; 32098 function generateFilterElementCompositeItemId(prefix2, filterElementValue) { 32099 return `$prefix2}-$filterElementValue}`; 32100 } 32101 var MultiSelectionOption = ({ selected }) => { 32102 return /* @__PURE__ */ (0, import_jsx_runtime214.jsx)( 32103 "span", 32104 { 32105 className: clsx_default( 32106 "dataviews-filters__search-widget-listitem-multi-selection", 32107 { "is-selected": selected } 32108 ), 32109 children: selected && /* @__PURE__ */ (0, import_jsx_runtime214.jsx)(import_components112.Icon, { icon: check_default }) 32110 } 32111 ); 32112 }; 32113 var SingleSelectionOption = ({ selected }) => { 32114 return /* @__PURE__ */ (0, import_jsx_runtime214.jsx)( 32115 "span", 32116 { 32117 className: clsx_default( 32118 "dataviews-filters__search-widget-listitem-single-selection", 32119 { "is-selected": selected } 32120 ) 32121 } 32122 ); 32123 }; 32124 function ListBox({ view, filter, onChangeView }) { 32125 const baseId = (0, import_compose18.useInstanceId)(ListBox, "dataviews-filter-list-box"); 32126 const [activeCompositeId, setActiveCompositeId] = (0, import_element86.useState)( 32127 // When there are one or less operators, the first item is set as active 32128 // (by setting the initial `activeId` to `undefined`). 32129 // With 2 or more operators, the focus is moved on the operators control 32130 // (by setting the initial `activeId` to `null`), meaning that there won't 32131 // be an active item initially. Focus is then managed via the 32132 // `onFocusVisible` callback. 32133 filter.operators?.length === 1 ? void 0 : null 32134 ); 32135 const currentFilter = view.filters?.find( 32136 (f2) => f2.field === filter.field 32137 ); 32138 const currentValue = getCurrentValue(filter, currentFilter); 32139 return /* @__PURE__ */ (0, import_jsx_runtime214.jsx)( 32140 import_components112.Composite, 32141 { 32142 virtualFocus: true, 32143 focusLoop: true, 32144 activeId: activeCompositeId, 32145 setActiveId: setActiveCompositeId, 32146 role: "listbox", 32147 className: "dataviews-filters__search-widget-listbox", 32148 "aria-label": (0, import_i18n103.sprintf)( 32149 /* translators: List of items for a filter. 1: Filter name. e.g.: "List of: Author". */ 32150 (0, import_i18n103.__)("List of: %1$s"), 32151 filter.name 32152 ), 32153 onFocusVisible: () => { 32154 if (!activeCompositeId && filter.elements.length) { 32155 setActiveCompositeId( 32156 generateFilterElementCompositeItemId( 32157 baseId, 32158 filter.elements[0].value 32159 ) 32160 ); 32161 } 32162 }, 32163 render: /* @__PURE__ */ (0, import_jsx_runtime214.jsx)(import_components112.Composite.Typeahead, {}), 32164 children: filter.elements.map((element) => /* @__PURE__ */ (0, import_jsx_runtime214.jsxs)( 32165 import_components112.Composite.Hover, 32166 { 32167 render: /* @__PURE__ */ (0, import_jsx_runtime214.jsx)( 32168 import_components112.Composite.Item, 32169 { 32170 id: generateFilterElementCompositeItemId( 32171 baseId, 32172 element.value 32173 ), 32174 render: /* @__PURE__ */ (0, import_jsx_runtime214.jsx)( 32175 "div", 32176 { 32177 "aria-label": element.label, 32178 role: "option", 32179 className: "dataviews-filters__search-widget-listitem" 32180 } 32181 ), 32182 onClick: () => { 32183 const newFilters = currentFilter ? [ 32184 ...(view.filters ?? []).map( 32185 (_filter) => { 32186 if (_filter.field === filter.field) { 32187 return { 32188 ..._filter, 32189 operator: currentFilter.operator || filter.operators[0], 32190 value: getNewValue( 32191 filter, 32192 currentFilter, 32193 element.value 32194 ) 32195 }; 32196 } 32197 return _filter; 32198 } 32199 ) 32200 ] : [ 32201 ...view.filters ?? [], 32202 { 32203 field: filter.field, 32204 operator: filter.operators[0], 32205 value: getNewValue( 32206 filter, 32207 currentFilter, 32208 element.value 32209 ) 32210 } 32211 ]; 32212 onChangeView({ 32213 ...view, 32214 page: 1, 32215 filters: newFilters 32216 }); 32217 } 32218 } 32219 ), 32220 children: [ 32221 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime214.jsx)( 32222 SingleSelectionOption, 32223 { 32224 selected: currentValue === element.value 32225 } 32226 ), 32227 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime214.jsx)( 32228 MultiSelectionOption, 32229 { 32230 selected: currentValue.includes(element.value) 32231 } 32232 ), 32233 /* @__PURE__ */ (0, import_jsx_runtime214.jsx)("span", { children: element.label }) 32234 ] 32235 }, 32236 element.value 32237 )) 32238 } 32239 ); 32240 } 32241 function ComboboxList22({ view, filter, onChangeView }) { 32242 const [searchValue, setSearchValue] = (0, import_element86.useState)(""); 32243 const deferredSearchValue = (0, import_element86.useDeferredValue)(searchValue); 32244 const currentFilter = view.filters?.find( 32245 (_filter) => _filter.field === filter.field 32246 ); 32247 const currentValue = getCurrentValue(filter, currentFilter); 32248 const matches = (0, import_element86.useMemo)(() => { 32249 const normalizedSearch = normalizeSearchInput(deferredSearchValue); 32250 return filter.elements.filter( 32251 (item) => normalizeSearchInput(item.label).includes(normalizedSearch) 32252 ); 32253 }, [filter.elements, deferredSearchValue]); 32254 return /* @__PURE__ */ (0, import_jsx_runtime214.jsxs)( 32255 ComboboxProvider, 32256 { 32257 selectedValue: currentValue, 32258 setSelectedValue: (value) => { 32259 const newFilters = currentFilter ? [ 32260 ...(view.filters ?? []).map((_filter) => { 32261 if (_filter.field === filter.field) { 32262 return { 32263 ..._filter, 32264 operator: currentFilter.operator || filter.operators[0], 32265 value 32266 }; 32267 } 32268 return _filter; 32269 }) 32270 ] : [ 32271 ...view.filters ?? [], 32272 { 32273 field: filter.field, 32274 operator: filter.operators[0], 32275 value 32276 } 32277 ]; 32278 onChangeView({ 32279 ...view, 32280 page: 1, 32281 filters: newFilters 32282 }); 32283 }, 32284 setValue: setSearchValue, 32285 children: [ 32286 /* @__PURE__ */ (0, import_jsx_runtime214.jsxs)("div", { className: "dataviews-filters__search-widget-filter-combobox__wrapper", children: [ 32287 /* @__PURE__ */ (0, import_jsx_runtime214.jsx)( 32288 ComboboxLabel, 32289 { 32290 render: /* @__PURE__ */ (0, import_jsx_runtime214.jsx)(import_components112.VisuallyHidden, { children: (0, import_i18n103.__)("Search items") }), 32291 children: (0, import_i18n103.__)("Search items") 32292 } 32293 ), 32294 /* @__PURE__ */ (0, import_jsx_runtime214.jsx)( 32295 Combobox, 32296 { 32297 autoSelect: "always", 32298 placeholder: (0, import_i18n103.__)("Search"), 32299 className: "dataviews-filters__search-widget-filter-combobox__input" 32300 } 32301 ), 32302 /* @__PURE__ */ (0, import_jsx_runtime214.jsx)("div", { className: "dataviews-filters__search-widget-filter-combobox__icon", children: /* @__PURE__ */ (0, import_jsx_runtime214.jsx)(import_components112.Icon, { icon: search_default }) }) 32303 ] }), 32304 /* @__PURE__ */ (0, import_jsx_runtime214.jsxs)( 32305 ComboboxList, 32306 { 32307 className: "dataviews-filters__search-widget-filter-combobox-list", 32308 alwaysVisible: true, 32309 children: [ 32310 matches.map((element) => { 32311 return /* @__PURE__ */ (0, import_jsx_runtime214.jsxs)( 32312 ComboboxItem, 32313 { 32314 resetValueOnSelect: false, 32315 value: element.value, 32316 className: "dataviews-filters__search-widget-listitem", 32317 hideOnClick: false, 32318 setValueOnClick: false, 32319 focusOnHover: true, 32320 children: [ 32321 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime214.jsx)( 32322 SingleSelectionOption, 32323 { 32324 selected: currentValue === element.value 32325 } 32326 ), 32327 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime214.jsx)( 32328 MultiSelectionOption, 32329 { 32330 selected: currentValue.includes( 32331 element.value 32332 ) 32333 } 32334 ), 32335 /* @__PURE__ */ (0, import_jsx_runtime214.jsxs)("span", { children: [ 32336 /* @__PURE__ */ (0, import_jsx_runtime214.jsx)( 32337 ComboboxItemValue, 32338 { 32339 className: "dataviews-filters__search-widget-filter-combobox-item-value", 32340 value: element.label 32341 } 32342 ), 32343 !!element.description && /* @__PURE__ */ (0, import_jsx_runtime214.jsx)("span", { className: "dataviews-filters__search-widget-listitem-description", children: element.description }) 32344 ] }) 32345 ] 32346 }, 32347 element.value 32348 ); 32349 }), 32350 !matches.length && /* @__PURE__ */ (0, import_jsx_runtime214.jsx)("p", { children: (0, import_i18n103.__)("No results found") }) 32351 ] 32352 } 32353 ) 32354 ] 32355 } 32356 ); 32357 } 32358 function SearchWidget(props) { 32359 const { elements: elements2, isLoading } = useElements({ 32360 elements: props.filter.elements, 32361 getElements: props.filter.getElements 32362 }); 32363 if (isLoading) { 32364 return /* @__PURE__ */ (0, import_jsx_runtime214.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: /* @__PURE__ */ (0, import_jsx_runtime214.jsx)(import_components112.Spinner, {}) }); 32365 } 32366 if (elements2.length === 0) { 32367 return /* @__PURE__ */ (0, import_jsx_runtime214.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: (0, import_i18n103.__)("No elements found") }); 32368 } 32369 const Widget = elements2.length > 10 ? ComboboxList22 : ListBox; 32370 return /* @__PURE__ */ (0, import_jsx_runtime214.jsx)(Widget, { ...props, filter: { ...props.filter, elements: elements2 } }); 32371 } 32372 32373 // packages/dataviews/build-module/components/dataviews-filters/input-widget.js 32374 var import_es62 = __toESM(require_es6()); 32375 var import_compose19 = __toESM(require_compose()); 32376 var import_element87 = __toESM(require_element()); 32377 var import_components113 = __toESM(require_components()); 32378 var import_jsx_runtime215 = __toESM(require_jsx_runtime()); 32379 function InputWidget({ 32380 filter, 32381 view, 32382 onChangeView, 32383 fields 32384 }) { 32385 const currentFilter = view.filters?.find( 32386 (f2) => f2.field === filter.field 32387 ); 32388 const currentValue = getCurrentValue(filter, currentFilter); 32389 const field = (0, import_element87.useMemo)(() => { 32390 const currentField = fields.find((f2) => f2.id === filter.field); 32391 if (currentField) { 32392 return { 32393 ...currentField, 32394 // Deactivate validation for filters. 32395 isValid: {}, 32396 // Configure getValue/setValue as if Item was a plain object. 32397 getValue: ({ item }) => item[currentField.id], 32398 setValue: ({ value }) => ({ 32399 [currentField.id]: value 32400 }) 32401 }; 32402 } 32403 return currentField; 32404 }, [fields, filter.field]); 32405 const data = (0, import_element87.useMemo)(() => { 32406 return (view.filters ?? []).reduce( 32407 (acc, activeFilter) => { 32408 acc[activeFilter.field] = activeFilter.value; 32409 return acc; 32410 }, 32411 {} 32412 ); 32413 }, [view.filters]); 32414 const handleChange = (0, import_compose19.useEvent)((updatedData) => { 32415 if (!field || !currentFilter) { 32416 return; 32417 } 32418 const nextValue = field.getValue({ item: updatedData }); 32419 if ((0, import_es62.default)(nextValue, currentValue)) { 32420 return; 32421 } 32422 onChangeView({ 32423 ...view, 32424 filters: (view.filters ?? []).map( 32425 (_filter) => _filter.field === filter.field ? { 32426 ..._filter, 32427 operator: currentFilter.operator || filter.operators[0], 32428 // Consider empty strings as undefined: 32429 // 32430 // - undefined as value means the filter is unset: the filter widget displays no value and the search returns all records 32431 // - empty string as value means "search empty string": returns only the records that have an empty string as value 32432 // 32433 // In practice, this means the filter will not be able to find an empty string as the value. 32434 value: nextValue === "" ? void 0 : nextValue 32435 } : _filter 32436 ) 32437 }); 32438 }); 32439 if (!field || !field.Edit || !currentFilter) { 32440 return null; 32441 } 32442 return /* @__PURE__ */ (0, import_jsx_runtime215.jsx)( 32443 import_components113.Flex, 32444 { 32445 className: "dataviews-filters__user-input-widget", 32446 gap: 2.5, 32447 direction: "column", 32448 children: /* @__PURE__ */ (0, import_jsx_runtime215.jsx)( 32449 field.Edit, 32450 { 32451 hideLabelFromVision: true, 32452 data, 32453 field, 32454 operator: currentFilter.operator, 32455 onChange: handleChange 32456 } 32457 ) 32458 } 32459 ); 32460 } 32461 32462 // packages/dataviews/build-module/utils/operators.js 32463 var import_i18n104 = __toESM(require_i18n()); 32464 var import_element88 = __toESM(require_element()); 32465 var import_jsx_runtime216 = __toESM(require_jsx_runtime()); 32466 var filterTextWrappers = { 32467 Name: /* @__PURE__ */ (0, import_jsx_runtime216.jsx)("span", { className: "dataviews-filters__summary-filter-text-name" }), 32468 Value: /* @__PURE__ */ (0, import_jsx_runtime216.jsx)("span", { className: "dataviews-filters__summary-filter-text-value" }) 32469 }; 32470 var OPERATORS = [ 32471 { 32472 name: OPERATOR_IS_ANY2, 32473 /* translators: DataViews operator name */ 32474 label: (0, import_i18n104.__)("Includes"), 32475 filterText: (filter, activeElements) => (0, import_element88.createInterpolateElement)( 32476 (0, import_i18n104.sprintf)( 32477 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is any: Admin, Editor". */ 32478 (0, import_i18n104.__)("<Name>%1$s includes: </Name><Value>%2$s</Value>"), 32479 filter.name, 32480 activeElements.map((element) => element.label).join(", ") 32481 ), 32482 filterTextWrappers 32483 ), 32484 selection: "multi" 32485 }, 32486 { 32487 name: OPERATOR_IS_NONE2, 32488 /* translators: DataViews operator name */ 32489 label: (0, import_i18n104.__)("Is none of"), 32490 filterText: (filter, activeElements) => (0, import_element88.createInterpolateElement)( 32491 (0, import_i18n104.sprintf)( 32492 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is none of: Admin, Editor". */ 32493 (0, import_i18n104.__)("<Name>%1$s is none of: </Name><Value>%2$s</Value>"), 32494 filter.name, 32495 activeElements.map((element) => element.label).join(", ") 32496 ), 32497 filterTextWrappers 32498 ), 32499 selection: "multi" 32500 }, 32501 { 32502 name: OPERATOR_IS_ALL, 32503 /* translators: DataViews operator name */ 32504 label: (0, import_i18n104.__)("Includes all"), 32505 filterText: (filter, activeElements) => (0, import_element88.createInterpolateElement)( 32506 (0, import_i18n104.sprintf)( 32507 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author includes all: Admin, Editor". */ 32508 (0, import_i18n104.__)("<Name>%1$s includes all: </Name><Value>%2$s</Value>"), 32509 filter.name, 32510 activeElements.map((element) => element.label).join(", ") 32511 ), 32512 filterTextWrappers 32513 ), 32514 selection: "multi" 32515 }, 32516 { 32517 name: OPERATOR_IS_NOT_ALL, 32518 /* translators: DataViews operator name */ 32519 label: (0, import_i18n104.__)("Is none of"), 32520 filterText: (filter, activeElements) => (0, import_element88.createInterpolateElement)( 32521 (0, import_i18n104.sprintf)( 32522 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is none of: Admin, Editor". */ 32523 (0, import_i18n104.__)("<Name>%1$s is none of: </Name><Value>%2$s</Value>"), 32524 filter.name, 32525 activeElements.map((element) => element.label).join(", ") 32526 ), 32527 filterTextWrappers 32528 ), 32529 selection: "multi" 32530 }, 32531 { 32532 name: OPERATOR_BETWEEN, 32533 /* translators: DataViews operator name */ 32534 label: (0, import_i18n104.__)("Between (inc)"), 32535 filterText: (filter, activeElements) => (0, import_element88.createInterpolateElement)( 32536 (0, import_i18n104.sprintf)( 32537 /* translators: 1: Filter name (e.g. "Item count"). 2: Filter value min. 3: Filter value max. e.g.: "Item count between (inc): 10 and 180". */ 32538 (0, import_i18n104.__)( 32539 "<Name>%1$s between (inc): </Name><Value>%2$s and %3$s</Value>" 32540 ), 32541 filter.name, 32542 activeElements[0].label[0], 32543 activeElements[0].label[1] 32544 ), 32545 filterTextWrappers 32546 ), 32547 selection: "custom" 32548 }, 32549 { 32550 name: OPERATOR_IN_THE_PAST, 32551 /* translators: DataViews operator name */ 32552 label: (0, import_i18n104.__)("In the past"), 32553 filterText: (filter, activeElements) => (0, import_element88.createInterpolateElement)( 32554 (0, import_i18n104.sprintf)( 32555 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is in the past: 7 days". */ 32556 (0, import_i18n104.__)( 32557 "<Name>%1$s is in the past: </Name><Value>%2$s</Value>" 32558 ), 32559 filter.name, 32560 `$activeElements[0].value.value} $activeElements[0].value.unit}` 32561 ), 32562 filterTextWrappers 32563 ), 32564 selection: "custom" 32565 }, 32566 { 32567 name: OPERATOR_OVER, 32568 /* translators: DataViews operator name */ 32569 label: (0, import_i18n104.__)("Over"), 32570 filterText: (filter, activeElements) => (0, import_element88.createInterpolateElement)( 32571 (0, import_i18n104.sprintf)( 32572 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is over: 7 days". */ 32573 (0, import_i18n104.__)("<Name>%1$s is over: </Name><Value>%2$s</Value>"), 32574 filter.name, 32575 `$activeElements[0].value.value} $activeElements[0].value.unit}` 32576 ), 32577 filterTextWrappers 32578 ), 32579 selection: "custom" 32580 }, 32581 { 32582 name: OPERATOR_IS2, 32583 /* translators: DataViews operator name */ 32584 label: (0, import_i18n104.__)("Is"), 32585 filterText: (filter, activeElements) => (0, import_element88.createInterpolateElement)( 32586 (0, import_i18n104.sprintf)( 32587 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is: Admin". */ 32588 (0, import_i18n104.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"), 32589 filter.name, 32590 activeElements[0].label 32591 ), 32592 filterTextWrappers 32593 ), 32594 selection: "single" 32595 }, 32596 { 32597 name: OPERATOR_IS_NOT, 32598 /* translators: DataViews operator name */ 32599 label: (0, import_i18n104.__)("Is not"), 32600 filterText: (filter, activeElements) => (0, import_element88.createInterpolateElement)( 32601 (0, import_i18n104.sprintf)( 32602 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is not: Admin". */ 32603 (0, import_i18n104.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"), 32604 filter.name, 32605 activeElements[0].label 32606 ), 32607 filterTextWrappers 32608 ), 32609 selection: "single" 32610 }, 32611 { 32612 name: OPERATOR_LESS_THAN, 32613 /* translators: DataViews operator name */ 32614 label: (0, import_i18n104.__)("Less than"), 32615 filterText: (filter, activeElements) => (0, import_element88.createInterpolateElement)( 32616 (0, import_i18n104.sprintf)( 32617 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than: 10". */ 32618 (0, import_i18n104.__)("<Name>%1$s is less than: </Name><Value>%2$s</Value>"), 32619 filter.name, 32620 activeElements[0].label 32621 ), 32622 filterTextWrappers 32623 ), 32624 selection: "single" 32625 }, 32626 { 32627 name: OPERATOR_GREATER_THAN, 32628 /* translators: DataViews operator name */ 32629 label: (0, import_i18n104.__)("Greater than"), 32630 filterText: (filter, activeElements) => (0, import_element88.createInterpolateElement)( 32631 (0, import_i18n104.sprintf)( 32632 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than: 10". */ 32633 (0, import_i18n104.__)( 32634 "<Name>%1$s is greater than: </Name><Value>%2$s</Value>" 32635 ), 32636 filter.name, 32637 activeElements[0].label 32638 ), 32639 filterTextWrappers 32640 ), 32641 selection: "single" 32642 }, 32643 { 32644 name: OPERATOR_LESS_THAN_OR_EQUAL, 32645 /* translators: DataViews operator name */ 32646 label: (0, import_i18n104.__)("Less than or equal"), 32647 filterText: (filter, activeElements) => (0, import_element88.createInterpolateElement)( 32648 (0, import_i18n104.sprintf)( 32649 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than or equal to: 10". */ 32650 (0, import_i18n104.__)( 32651 "<Name>%1$s is less than or equal to: </Name><Value>%2$s</Value>" 32652 ), 32653 filter.name, 32654 activeElements[0].label 32655 ), 32656 filterTextWrappers 32657 ), 32658 selection: "single" 32659 }, 32660 { 32661 name: OPERATOR_GREATER_THAN_OR_EQUAL, 32662 /* translators: DataViews operator name */ 32663 label: (0, import_i18n104.__)("Greater than or equal"), 32664 filterText: (filter, activeElements) => (0, import_element88.createInterpolateElement)( 32665 (0, import_i18n104.sprintf)( 32666 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than or equal to: 10". */ 32667 (0, import_i18n104.__)( 32668 "<Name>%1$s is greater than or equal to: </Name><Value>%2$s</Value>" 32669 ), 32670 filter.name, 32671 activeElements[0].label 32672 ), 32673 filterTextWrappers 32674 ), 32675 selection: "single" 32676 }, 32677 { 32678 name: OPERATOR_BEFORE2, 32679 /* translators: DataViews operator name */ 32680 label: (0, import_i18n104.__)("Before"), 32681 filterText: (filter, activeElements) => (0, import_element88.createInterpolateElement)( 32682 (0, import_i18n104.sprintf)( 32683 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is before: 2024-01-01". */ 32684 (0, import_i18n104.__)("<Name>%1$s is before: </Name><Value>%2$s</Value>"), 32685 filter.name, 32686 activeElements[0].label 32687 ), 32688 filterTextWrappers 32689 ), 32690 selection: "single" 32691 }, 32692 { 32693 name: OPERATOR_AFTER2, 32694 /* translators: DataViews operator name */ 32695 label: (0, import_i18n104.__)("After"), 32696 filterText: (filter, activeElements) => (0, import_element88.createInterpolateElement)( 32697 (0, import_i18n104.sprintf)( 32698 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is after: 2024-01-01". */ 32699 (0, import_i18n104.__)("<Name>%1$s is after: </Name><Value>%2$s</Value>"), 32700 filter.name, 32701 activeElements[0].label 32702 ), 32703 filterTextWrappers 32704 ), 32705 selection: "single" 32706 }, 32707 { 32708 name: OPERATOR_BEFORE_INC, 32709 /* translators: DataViews operator name */ 32710 label: (0, import_i18n104.__)("Before (inc)"), 32711 filterText: (filter, activeElements) => (0, import_element88.createInterpolateElement)( 32712 (0, import_i18n104.sprintf)( 32713 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or before: 2024-01-01". */ 32714 (0, import_i18n104.__)( 32715 "<Name>%1$s is on or before: </Name><Value>%2$s</Value>" 32716 ), 32717 filter.name, 32718 activeElements[0].label 32719 ), 32720 filterTextWrappers 32721 ), 32722 selection: "single" 32723 }, 32724 { 32725 name: OPERATOR_AFTER_INC, 32726 /* translators: DataViews operator name */ 32727 label: (0, import_i18n104.__)("After (inc)"), 32728 filterText: (filter, activeElements) => (0, import_element88.createInterpolateElement)( 32729 (0, import_i18n104.sprintf)( 32730 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or after: 2024-01-01". */ 32731 (0, import_i18n104.__)( 32732 "<Name>%1$s is on or after: </Name><Value>%2$s</Value>" 32733 ), 32734 filter.name, 32735 activeElements[0].label 32736 ), 32737 filterTextWrappers 32738 ), 32739 selection: "single" 32740 }, 32741 { 32742 name: OPERATOR_CONTAINS, 32743 /* translators: DataViews operator name */ 32744 label: (0, import_i18n104.__)("Contains"), 32745 filterText: (filter, activeElements) => (0, import_element88.createInterpolateElement)( 32746 (0, import_i18n104.sprintf)( 32747 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title contains: Hello". */ 32748 (0, import_i18n104.__)("<Name>%1$s contains: </Name><Value>%2$s</Value>"), 32749 filter.name, 32750 activeElements[0].label 32751 ), 32752 filterTextWrappers 32753 ), 32754 selection: "single" 32755 }, 32756 { 32757 name: OPERATOR_NOT_CONTAINS, 32758 /* translators: DataViews operator name */ 32759 label: (0, import_i18n104.__)("Doesn't contain"), 32760 filterText: (filter, activeElements) => (0, import_element88.createInterpolateElement)( 32761 (0, import_i18n104.sprintf)( 32762 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title doesn't contain: Hello". */ 32763 (0, import_i18n104.__)( 32764 "<Name>%1$s doesn't contain: </Name><Value>%2$s</Value>" 32765 ), 32766 filter.name, 32767 activeElements[0].label 32768 ), 32769 filterTextWrappers 32770 ), 32771 selection: "single" 32772 }, 32773 { 32774 name: OPERATOR_STARTS_WITH, 32775 /* translators: DataViews operator name */ 32776 label: (0, import_i18n104.__)("Starts with"), 32777 filterText: (filter, activeElements) => (0, import_element88.createInterpolateElement)( 32778 (0, import_i18n104.sprintf)( 32779 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title starts with: Hello". */ 32780 (0, import_i18n104.__)("<Name>%1$s starts with: </Name><Value>%2$s</Value>"), 32781 filter.name, 32782 activeElements[0].label 32783 ), 32784 filterTextWrappers 32785 ), 32786 selection: "single" 32787 }, 32788 { 32789 name: OPERATOR_ON, 32790 /* translators: DataViews operator name */ 32791 label: (0, import_i18n104.__)("On"), 32792 filterText: (filter, activeElements) => (0, import_element88.createInterpolateElement)( 32793 (0, import_i18n104.sprintf)( 32794 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is: 2024-01-01". */ 32795 (0, import_i18n104.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"), 32796 filter.name, 32797 activeElements[0].label 32798 ), 32799 filterTextWrappers 32800 ), 32801 selection: "single" 32802 }, 32803 { 32804 name: OPERATOR_NOT_ON, 32805 /* translators: DataViews operator name */ 32806 label: (0, import_i18n104.__)("Not on"), 32807 filterText: (filter, activeElements) => (0, import_element88.createInterpolateElement)( 32808 (0, import_i18n104.sprintf)( 32809 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is not: 2024-01-01". */ 32810 (0, import_i18n104.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"), 32811 filter.name, 32812 activeElements[0].label 32813 ), 32814 filterTextWrappers 32815 ), 32816 selection: "single" 32817 } 32818 ]; 32819 var getOperatorByName = (name2) => OPERATORS.find((op) => op.name === name2); 32820 var getAllOperatorNames = () => OPERATORS.map((op) => op.name); 32821 var isSingleSelectionOperator = (name2) => OPERATORS.filter((op) => op.selection === "single").some( 32822 (op) => op.name === name2 32823 ); 32824 var isRegisteredOperator = (name2) => OPERATORS.some((op) => op.name === name2); 32825 32826 // packages/dataviews/build-module/components/dataviews-filters/filter.js 32827 var import_jsx_runtime217 = __toESM(require_jsx_runtime()); 32828 var ENTER4 = "Enter"; 32829 var SPACE3 = " "; 32830 var FilterText = ({ 32831 activeElements, 32832 filterInView, 32833 filter 32834 }) => { 32835 if (activeElements === void 0 || activeElements.length === 0) { 32836 return filter.name; 32837 } 32838 const operator = getOperatorByName(filterInView?.operator); 32839 if (operator !== void 0) { 32840 return operator.filterText(filter, activeElements); 32841 } 32842 return (0, import_i18n105.sprintf)( 32843 /* translators: 1: Filter name e.g.: "Unknown status for Author". */ 32844 (0, import_i18n105.__)("Unknown status for %1$s"), 32845 filter.name 32846 ); 32847 }; 32848 function OperatorSelector({ 32849 filter, 32850 view, 32851 onChangeView 32852 }) { 32853 const operatorOptions = filter.operators?.map((operator) => ({ 32854 value: operator, 32855 label: getOperatorByName(operator)?.label || operator 32856 })); 32857 const currentFilter = view.filters?.find( 32858 (_filter) => _filter.field === filter.field 32859 ); 32860 const value = currentFilter?.operator || filter.operators[0]; 32861 return operatorOptions.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime217.jsxs)( 32862 import_components114.__experimentalHStack, 32863 { 32864 spacing: 2, 32865 justify: "flex-start", 32866 className: "dataviews-filters__summary-operators-container", 32867 children: [ 32868 /* @__PURE__ */ (0, import_jsx_runtime217.jsx)(import_components114.FlexItem, { className: "dataviews-filters__summary-operators-filter-name", children: filter.name }), 32869 /* @__PURE__ */ (0, import_jsx_runtime217.jsx)( 32870 import_components114.SelectControl, 32871 { 32872 className: "dataviews-filters__summary-operators-filter-select", 32873 label: (0, import_i18n105.__)("Conditions"), 32874 value, 32875 options: operatorOptions, 32876 onChange: (newValue) => { 32877 const newOperator = newValue; 32878 const currentOperator = currentFilter?.operator; 32879 const newFilters = currentFilter ? [ 32880 ...(view.filters ?? []).map( 32881 (_filter) => { 32882 if (_filter.field === filter.field) { 32883 const currentOpSelectionModel = getOperatorByName( 32884 currentOperator 32885 )?.selection; 32886 const newOpSelectionModel = getOperatorByName( 32887 newOperator 32888 )?.selection; 32889 const shouldResetValue = currentOpSelectionModel !== newOpSelectionModel || [ 32890 currentOpSelectionModel, 32891 newOpSelectionModel 32892 ].includes("custom"); 32893 return { 32894 ..._filter, 32895 value: shouldResetValue ? void 0 : _filter.value, 32896 operator: newOperator 32897 }; 32898 } 32899 return _filter; 32900 } 32901 ) 32902 ] : [ 32903 ...view.filters ?? [], 32904 { 32905 field: filter.field, 32906 operator: newOperator, 32907 value: void 0 32908 } 32909 ]; 32910 onChangeView({ 32911 ...view, 32912 page: 1, 32913 filters: newFilters 32914 }); 32915 }, 32916 size: "small", 32917 variant: "minimal", 32918 hideLabelFromVision: true 32919 } 32920 ) 32921 ] 32922 } 32923 ); 32924 } 32925 function Filter({ 32926 addFilterRef, 32927 openedFilter, 32928 fields, 32929 ...commonProps 32930 }) { 32931 const toggleRef = (0, import_element89.useRef)(null); 32932 const { filter, view, onChangeView } = commonProps; 32933 const filterInView = view.filters?.find( 32934 (f2) => f2.field === filter.field 32935 ); 32936 let activeElements = []; 32937 const field = (0, import_element89.useMemo)(() => { 32938 const currentField = fields.find((f2) => f2.id === filter.field); 32939 if (currentField) { 32940 return { 32941 ...currentField, 32942 // Configure getValue as if Item was a plain object. 32943 // See related input-widget.tsx 32944 getValue: ({ item }) => item[currentField.id] 32945 }; 32946 } 32947 return currentField; 32948 }, [fields, filter.field]); 32949 const { elements: elements2 } = useElements({ 32950 elements: filter.elements, 32951 getElements: filter.getElements 32952 }); 32953 if (elements2.length > 0) { 32954 activeElements = elements2.filter((element) => { 32955 if (filter.singleSelection) { 32956 return element.value === filterInView?.value; 32957 } 32958 return filterInView?.value?.includes(element.value); 32959 }); 32960 } else if (Array.isArray(filterInView?.value)) { 32961 const label = filterInView.value.map((v2) => { 32962 const formattedValue = field?.getValueFormatted({ 32963 item: { [field.id]: v2 }, 32964 field 32965 }); 32966 return formattedValue || String(v2); 32967 }); 32968 activeElements = [ 32969 { 32970 value: filterInView.value, 32971 // @ts-ignore 32972 label 32973 } 32974 ]; 32975 } else if (typeof filterInView?.value === "object") { 32976 activeElements = [ 32977 { value: filterInView.value, label: filterInView.value } 32978 ]; 32979 } else if (filterInView?.value !== void 0) { 32980 const label = field !== void 0 ? field.getValueFormatted({ 32981 item: { [field.id]: filterInView.value }, 32982 field 32983 }) : String(filterInView.value); 32984 activeElements = [ 32985 { 32986 value: filterInView.value, 32987 label 32988 } 32989 ]; 32990 } 32991 const isPrimary = filter.isPrimary; 32992 const isLocked = filterInView?.isLocked; 32993 const hasValues = !isLocked && filterInView?.value !== void 0; 32994 const canResetOrRemove = !isLocked && (!isPrimary || hasValues); 32995 return /* @__PURE__ */ (0, import_jsx_runtime217.jsx)( 32996 import_components114.Dropdown, 32997 { 32998 defaultOpen: openedFilter === filter.field, 32999 contentClassName: "dataviews-filters__summary-popover", 33000 popoverProps: { placement: "bottom-start", role: "dialog" }, 33001 onClose: () => { 33002 toggleRef.current?.focus(); 33003 }, 33004 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime217.jsxs)("div", { className: "dataviews-filters__summary-chip-container", children: [ 33005 /* @__PURE__ */ (0, import_jsx_runtime217.jsx)( 33006 import_components114.Tooltip, 33007 { 33008 text: (0, import_i18n105.sprintf)( 33009 /* translators: 1: Filter name. */ 33010 (0, import_i18n105.__)("Filter by: %1$s"), 33011 filter.name.toLowerCase() 33012 ), 33013 placement: "top", 33014 children: /* @__PURE__ */ (0, import_jsx_runtime217.jsx)( 33015 "div", 33016 { 33017 className: clsx_default( 33018 "dataviews-filters__summary-chip", 33019 { 33020 "has-reset": canResetOrRemove, 33021 "has-values": hasValues, 33022 "is-not-clickable": isLocked 33023 } 33024 ), 33025 role: "button", 33026 tabIndex: isLocked ? -1 : 0, 33027 onClick: () => { 33028 if (!isLocked) { 33029 onToggle(); 33030 } 33031 }, 33032 onKeyDown: (event) => { 33033 if (!isLocked && [ENTER4, SPACE3].includes(event.key)) { 33034 onToggle(); 33035 event.preventDefault(); 33036 } 33037 }, 33038 "aria-disabled": isLocked, 33039 "aria-pressed": isOpen, 33040 "aria-expanded": isOpen, 33041 ref: toggleRef, 33042 children: /* @__PURE__ */ (0, import_jsx_runtime217.jsx)( 33043 FilterText, 33044 { 33045 activeElements, 33046 filterInView, 33047 filter 33048 } 33049 ) 33050 } 33051 ) 33052 } 33053 ), 33054 canResetOrRemove && /* @__PURE__ */ (0, import_jsx_runtime217.jsx)( 33055 import_components114.Tooltip, 33056 { 33057 text: isPrimary ? (0, import_i18n105.__)("Reset") : (0, import_i18n105.__)("Remove"), 33058 placement: "top", 33059 children: /* @__PURE__ */ (0, import_jsx_runtime217.jsx)( 33060 "button", 33061 { 33062 className: clsx_default( 33063 "dataviews-filters__summary-chip-remove", 33064 { "has-values": hasValues } 33065 ), 33066 onClick: () => { 33067 onChangeView({ 33068 ...view, 33069 page: 1, 33070 filters: view.filters?.filter( 33071 (_filter) => _filter.field !== filter.field 33072 ) 33073 }); 33074 if (!isPrimary) { 33075 addFilterRef.current?.focus(); 33076 } else { 33077 toggleRef.current?.focus(); 33078 } 33079 }, 33080 children: /* @__PURE__ */ (0, import_jsx_runtime217.jsx)(import_components114.Icon, { icon: close_small_default }) 33081 } 33082 ) 33083 } 33084 ) 33085 ] }), 33086 renderContent: () => { 33087 return /* @__PURE__ */ (0, import_jsx_runtime217.jsxs)(import_components114.__experimentalVStack, { spacing: 0, justify: "flex-start", children: [ 33088 /* @__PURE__ */ (0, import_jsx_runtime217.jsx)(OperatorSelector, { ...commonProps }), 33089 commonProps.filter.hasElements ? /* @__PURE__ */ (0, import_jsx_runtime217.jsx)( 33090 SearchWidget, 33091 { 33092 ...commonProps, 33093 filter: { 33094 ...commonProps.filter, 33095 elements: elements2 33096 } 33097 } 33098 ) : /* @__PURE__ */ (0, import_jsx_runtime217.jsx)(InputWidget, { ...commonProps, fields }) 33099 ] }); 33100 } 33101 } 33102 ); 33103 } 33104 33105 // packages/dataviews/build-module/components/dataviews-filters/add-filter.js 33106 var import_components115 = __toESM(require_components()); 33107 var import_i18n106 = __toESM(require_i18n()); 33108 var import_element90 = __toESM(require_element()); 33109 var import_jsx_runtime218 = __toESM(require_jsx_runtime()); 33110 var { Menu: Menu8 } = unlock3(import_components115.privateApis); 33111 function AddFilterMenu({ 33112 filters, 33113 view, 33114 onChangeView, 33115 setOpenedFilter, 33116 triggerProps 33117 }) { 33118 const inactiveFilters = filters.filter((filter) => !filter.isVisible); 33119 return /* @__PURE__ */ (0, import_jsx_runtime218.jsxs)(Menu8, { children: [ 33120 /* @__PURE__ */ (0, import_jsx_runtime218.jsx)(Menu8.TriggerButton, { ...triggerProps }), 33121 /* @__PURE__ */ (0, import_jsx_runtime218.jsx)(Menu8.Popover, { children: inactiveFilters.map((filter) => { 33122 return /* @__PURE__ */ (0, import_jsx_runtime218.jsx)( 33123 Menu8.Item, 33124 { 33125 onClick: () => { 33126 setOpenedFilter(filter.field); 33127 onChangeView({ 33128 ...view, 33129 page: 1, 33130 filters: [ 33131 ...view.filters || [], 33132 { 33133 field: filter.field, 33134 value: void 0, 33135 operator: filter.operators[0] 33136 } 33137 ] 33138 }); 33139 }, 33140 children: /* @__PURE__ */ (0, import_jsx_runtime218.jsx)(Menu8.ItemLabel, { children: filter.name }) 33141 }, 33142 filter.field 33143 ); 33144 }) }) 33145 ] }); 33146 } 33147 function AddFilter({ filters, view, onChangeView, setOpenedFilter }, ref) { 33148 if (!filters.length || filters.every(({ isPrimary }) => isPrimary)) { 33149 return null; 33150 } 33151 const inactiveFilters = filters.filter((filter) => !filter.isVisible); 33152 return /* @__PURE__ */ (0, import_jsx_runtime218.jsx)( 33153 AddFilterMenu, 33154 { 33155 triggerProps: { 33156 render: /* @__PURE__ */ (0, import_jsx_runtime218.jsx)( 33157 import_components115.Button, 33158 { 33159 accessibleWhenDisabled: true, 33160 size: "compact", 33161 className: "dataviews-filters-button", 33162 variant: "tertiary", 33163 disabled: !inactiveFilters.length, 33164 ref 33165 } 33166 ), 33167 children: (0, import_i18n106.__)("Add filter") 33168 }, 33169 ...{ filters, view, onChangeView, setOpenedFilter } 33170 } 33171 ); 33172 } 33173 var add_filter_default = (0, import_element90.forwardRef)(AddFilter); 33174 33175 // packages/dataviews/build-module/components/dataviews-filters/reset-filters.js 33176 var import_components116 = __toESM(require_components()); 33177 var import_i18n107 = __toESM(require_i18n()); 33178 var import_jsx_runtime219 = __toESM(require_jsx_runtime()); 33179 function ResetFilter({ 33180 filters, 33181 view, 33182 onChangeView 33183 }) { 33184 const isPrimary = (field) => filters.some( 33185 (_filter) => _filter.field === field && _filter.isPrimary 33186 ); 33187 const isDisabled = !view.search && !view.filters?.some( 33188 (_filter) => !_filter.isLocked && (_filter.value !== void 0 || !isPrimary(_filter.field)) 33189 ); 33190 return /* @__PURE__ */ (0, import_jsx_runtime219.jsx)( 33191 import_components116.Button, 33192 { 33193 disabled: isDisabled, 33194 accessibleWhenDisabled: true, 33195 size: "compact", 33196 variant: "tertiary", 33197 className: "dataviews-filters__reset-button", 33198 onClick: () => { 33199 onChangeView({ 33200 ...view, 33201 page: 1, 33202 search: "", 33203 filters: view.filters?.filter((f2) => !!f2.isLocked) || [] 33204 }); 33205 }, 33206 children: (0, import_i18n107.__)("Reset") 33207 } 33208 ); 33209 } 33210 33211 // packages/dataviews/build-module/components/dataviews-filters/use-filters.js 33212 var import_element91 = __toESM(require_element()); 33213 function useFilters(fields, view) { 33214 return (0, import_element91.useMemo)(() => { 33215 const filters = []; 33216 fields.forEach((field) => { 33217 if (field.filterBy === false || !field.hasElements && !field.Edit) { 33218 return; 33219 } 33220 const operators = field.filterBy.operators; 33221 const isPrimary = !!field.filterBy?.isPrimary; 33222 const isLocked = view.filters?.some( 33223 (f2) => f2.field === field.id && !!f2.isLocked 33224 ) ?? false; 33225 filters.push({ 33226 field: field.id, 33227 name: field.label, 33228 elements: field.elements, 33229 getElements: field.getElements, 33230 hasElements: field.hasElements, 33231 singleSelection: operators.some( 33232 (op) => isSingleSelectionOperator(op) 33233 ), 33234 operators, 33235 isVisible: isLocked || isPrimary || !!view.filters?.some( 33236 (f2) => f2.field === field.id && isRegisteredOperator(f2.operator) 33237 ), 33238 isPrimary, 33239 isLocked 33240 }); 33241 }); 33242 filters.sort((a2, b2) => { 33243 if (a2.isLocked && !b2.isLocked) { 33244 return -1; 33245 } 33246 if (!a2.isLocked && b2.isLocked) { 33247 return 1; 33248 } 33249 if (a2.isPrimary && !b2.isPrimary) { 33250 return -1; 33251 } 33252 if (!a2.isPrimary && b2.isPrimary) { 33253 return 1; 33254 } 33255 return a2.name.localeCompare(b2.name); 33256 }); 33257 return filters; 33258 }, [fields, view]); 33259 } 33260 var use_filters_default = useFilters; 33261 33262 // packages/dataviews/build-module/components/dataviews-filters/filters.js 33263 var import_jsx_runtime220 = __toESM(require_jsx_runtime()); 33264 function Filters({ className }) { 33265 const { fields, view, onChangeView, openedFilter, setOpenedFilter } = (0, import_element92.useContext)(dataviews_context_default); 33266 const addFilterRef = (0, import_element92.useRef)(null); 33267 const filters = use_filters_default(fields, view); 33268 const addFilter = /* @__PURE__ */ (0, import_jsx_runtime220.jsx)( 33269 add_filter_default, 33270 { 33271 filters, 33272 view, 33273 onChangeView, 33274 ref: addFilterRef, 33275 setOpenedFilter 33276 }, 33277 "add-filter" 33278 ); 33279 const visibleFilters = filters.filter((filter) => filter.isVisible); 33280 if (visibleFilters.length === 0) { 33281 return null; 33282 } 33283 const filterComponents = [ 33284 ...visibleFilters.map((filter) => { 33285 return /* @__PURE__ */ (0, import_jsx_runtime220.jsx)( 33286 Filter, 33287 { 33288 filter, 33289 view, 33290 fields, 33291 onChangeView, 33292 addFilterRef, 33293 openedFilter 33294 }, 33295 filter.field 33296 ); 33297 }), 33298 addFilter 33299 ]; 33300 filterComponents.push( 33301 /* @__PURE__ */ (0, import_jsx_runtime220.jsx)( 33302 ResetFilter, 33303 { 33304 filters, 33305 view, 33306 onChangeView 33307 }, 33308 "reset-filters" 33309 ) 33310 ); 33311 return /* @__PURE__ */ (0, import_jsx_runtime220.jsx)( 33312 import_components117.__experimentalHStack, 33313 { 33314 justify: "flex-start", 33315 style: { width: "fit-content" }, 33316 wrap: true, 33317 className, 33318 children: filterComponents 33319 } 33320 ); 33321 } 33322 var filters_default = (0, import_element92.memo)(Filters); 33323 33324 // packages/dataviews/build-module/components/dataviews-filters/toggle.js 33325 var import_element93 = __toESM(require_element()); 33326 var import_components118 = __toESM(require_components()); 33327 var import_i18n108 = __toESM(require_i18n()); 33328 var import_jsx_runtime221 = __toESM(require_jsx_runtime()); 33329 function FiltersToggle() { 33330 const { 33331 filters, 33332 view, 33333 onChangeView, 33334 setOpenedFilter, 33335 isShowingFilter, 33336 setIsShowingFilter 33337 } = (0, import_element93.useContext)(dataviews_context_default); 33338 const buttonRef = (0, import_element93.useRef)(null); 33339 const onChangeViewWithFilterVisibility = (0, import_element93.useCallback)( 33340 (_view) => { 33341 onChangeView(_view); 33342 setIsShowingFilter(true); 33343 }, 33344 [onChangeView, setIsShowingFilter] 33345 ); 33346 const visibleFilters = filters.filter((filter) => filter.isVisible); 33347 const hasVisibleFilters = !!visibleFilters.length; 33348 if (filters.length === 0) { 33349 return null; 33350 } 33351 const addFilterButtonProps = { 33352 label: (0, import_i18n108.__)("Add filter"), 33353 "aria-expanded": false, 33354 isPressed: false 33355 }; 33356 const toggleFiltersButtonProps = { 33357 label: (0, import_i18n108._x)("Filter", "verb"), 33358 "aria-expanded": isShowingFilter, 33359 isPressed: isShowingFilter, 33360 onClick: () => { 33361 if (!isShowingFilter) { 33362 setOpenedFilter(null); 33363 } 33364 setIsShowingFilter(!isShowingFilter); 33365 } 33366 }; 33367 const buttonComponent = /* @__PURE__ */ (0, import_jsx_runtime221.jsx)( 33368 import_components118.Button, 33369 { 33370 ref: buttonRef, 33371 className: "dataviews-filters__visibility-toggle", 33372 size: "compact", 33373 icon: funnel_default, 33374 ...hasVisibleFilters ? toggleFiltersButtonProps : addFilterButtonProps 33375 } 33376 ); 33377 return /* @__PURE__ */ (0, import_jsx_runtime221.jsx)("div", { className: "dataviews-filters__container-visibility-toggle", children: !hasVisibleFilters ? /* @__PURE__ */ (0, import_jsx_runtime221.jsx)( 33378 AddFilterMenu, 33379 { 33380 filters, 33381 view, 33382 onChangeView: onChangeViewWithFilterVisibility, 33383 setOpenedFilter, 33384 triggerProps: { render: buttonComponent } 33385 } 33386 ) : /* @__PURE__ */ (0, import_jsx_runtime221.jsx)( 33387 FilterVisibilityToggle, 33388 { 33389 buttonRef, 33390 filtersCount: view.filters?.length, 33391 children: buttonComponent 33392 } 33393 ) }); 33394 } 33395 function FilterVisibilityToggle({ 33396 buttonRef, 33397 filtersCount, 33398 children 33399 }) { 33400 (0, import_element93.useEffect)( 33401 () => () => { 33402 buttonRef.current?.focus(); 33403 }, 33404 [buttonRef] 33405 ); 33406 return /* @__PURE__ */ (0, import_jsx_runtime221.jsxs)(import_jsx_runtime221.Fragment, { children: [ 33407 children, 33408 !!filtersCount && /* @__PURE__ */ (0, import_jsx_runtime221.jsx)("span", { className: "dataviews-filters-toggle__count", children: filtersCount }) 33409 ] }); 33410 } 33411 var toggle_default = FiltersToggle; 33412 33413 // packages/dataviews/build-module/components/dataviews-filters/filters-toggled.js 33414 var import_element94 = __toESM(require_element()); 33415 var import_jsx_runtime222 = __toESM(require_jsx_runtime()); 33416 function FiltersToggled(props) { 33417 const { isShowingFilter } = (0, import_element94.useContext)(dataviews_context_default); 33418 if (!isShowingFilter) { 33419 return null; 33420 } 33421 return /* @__PURE__ */ (0, import_jsx_runtime222.jsx)(filters_default, { ...props }); 33422 } 33423 var filters_toggled_default = FiltersToggled; 33424 33425 // packages/dataviews/build-module/components/dataviews-layout/index.js 33426 var import_element95 = __toESM(require_element()); 33427 var import_i18n109 = __toESM(require_i18n()); 33428 var import_jsx_runtime223 = __toESM(require_jsx_runtime()); 33429 function DataViewsLayout({ className }) { 33430 const { 33431 actions = [], 33432 data, 33433 fields, 33434 getItemId: getItemId2, 33435 getItemLevel: getItemLevel2, 33436 isLoading, 33437 view, 33438 onChangeView, 33439 selection, 33440 onChangeSelection, 33441 setOpenedFilter, 33442 onClickItem, 33443 isItemClickable, 33444 renderItemLink, 33445 defaultLayouts: defaultLayouts4, 33446 empty = /* @__PURE__ */ (0, import_jsx_runtime223.jsx)("p", { children: (0, import_i18n109.__)("No results") }) 33447 } = (0, import_element95.useContext)(dataviews_context_default); 33448 const ViewComponent = VIEW_LAYOUTS.find( 33449 (v2) => v2.type === view.type && defaultLayouts4[v2.type] 33450 )?.component; 33451 return /* @__PURE__ */ (0, import_jsx_runtime223.jsx)( 33452 ViewComponent, 33453 { 33454 className, 33455 actions, 33456 data, 33457 fields, 33458 getItemId: getItemId2, 33459 getItemLevel: getItemLevel2, 33460 isLoading, 33461 onChangeView, 33462 onChangeSelection, 33463 selection, 33464 setOpenedFilter, 33465 onClickItem, 33466 renderItemLink, 33467 isItemClickable, 33468 view, 33469 empty 33470 } 33471 ); 33472 } 33473 33474 // packages/dataviews/build-module/components/dataviews-footer/index.js 33475 var import_components119 = __toESM(require_components()); 33476 var import_element96 = __toESM(require_element()); 33477 var import_jsx_runtime224 = __toESM(require_jsx_runtime()); 33478 var EMPTY_ARRAY7 = []; 33479 function DataViewsFooter() { 33480 const { 33481 view, 33482 paginationInfo: { totalItems = 0, totalPages }, 33483 data, 33484 actions = EMPTY_ARRAY7 33485 } = (0, import_element96.useContext)(dataviews_context_default); 33486 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data) && [LAYOUT_TABLE2, LAYOUT_GRID2].includes(view.type); 33487 if (!totalItems || !totalPages || totalPages <= 1 && !hasBulkActions) { 33488 return null; 33489 } 33490 return !!totalItems && /* @__PURE__ */ (0, import_jsx_runtime224.jsxs)( 33491 import_components119.__experimentalHStack, 33492 { 33493 expanded: false, 33494 justify: "end", 33495 className: "dataviews-footer", 33496 children: [ 33497 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime224.jsx)(BulkActionsFooter, {}), 33498 /* @__PURE__ */ (0, import_jsx_runtime224.jsx)(dataviews_pagination_default, {}) 33499 ] 33500 } 33501 ); 33502 } 33503 33504 // packages/dataviews/build-module/components/dataviews-search/index.js 33505 var import_i18n110 = __toESM(require_i18n()); 33506 var import_element97 = __toESM(require_element()); 33507 var import_components120 = __toESM(require_components()); 33508 var import_compose20 = __toESM(require_compose()); 33509 var import_jsx_runtime225 = __toESM(require_jsx_runtime()); 33510 var DataViewsSearch = (0, import_element97.memo)(function Search({ label }) { 33511 const { view, onChangeView } = (0, import_element97.useContext)(dataviews_context_default); 33512 const [search, setSearch, debouncedSearch] = (0, import_compose20.useDebouncedInput)( 33513 view.search 33514 ); 33515 (0, import_element97.useEffect)(() => { 33516 setSearch(view.search ?? ""); 33517 }, [view.search, setSearch]); 33518 const onChangeViewRef = (0, import_element97.useRef)(onChangeView); 33519 const viewRef = (0, import_element97.useRef)(view); 33520 (0, import_element97.useEffect)(() => { 33521 onChangeViewRef.current = onChangeView; 33522 viewRef.current = view; 33523 }, [onChangeView, view]); 33524 (0, import_element97.useEffect)(() => { 33525 if (debouncedSearch !== viewRef.current?.search) { 33526 onChangeViewRef.current({ 33527 ...viewRef.current, 33528 page: 1, 33529 search: debouncedSearch 33530 }); 33531 } 33532 }, [debouncedSearch]); 33533 const searchLabel = label || (0, import_i18n110.__)("Search"); 33534 return /* @__PURE__ */ (0, import_jsx_runtime225.jsx)( 33535 import_components120.SearchControl, 33536 { 33537 className: "dataviews-search", 33538 onChange: setSearch, 33539 value: search, 33540 label: searchLabel, 33541 placeholder: searchLabel, 33542 size: "compact" 33543 } 33544 ); 33545 }); 33546 var dataviews_search_default = DataViewsSearch; 33547 33548 // packages/dataviews/build-module/components/dataviews-view-config/index.js 33549 var import_components122 = __toESM(require_components()); 33550 var import_i18n112 = __toESM(require_i18n()); 33551 var import_element99 = __toESM(require_element()); 33552 var import_warning = __toESM(require_warning()); 33553 var import_compose21 = __toESM(require_compose()); 33554 33555 // packages/dataviews/build-module/components/dataviews-view-config/infinite-scroll-toggle.js 33556 var import_components121 = __toESM(require_components()); 33557 var import_i18n111 = __toESM(require_i18n()); 33558 var import_element98 = __toESM(require_element()); 33559 var import_jsx_runtime226 = __toESM(require_jsx_runtime()); 33560 function InfiniteScrollToggle() { 33561 const context = (0, import_element98.useContext)(dataviews_context_default); 33562 const { view, onChangeView } = context; 33563 const infiniteScrollEnabled = view.infiniteScrollEnabled ?? false; 33564 if (!context.hasInfiniteScrollHandler) { 33565 return null; 33566 } 33567 return /* @__PURE__ */ (0, import_jsx_runtime226.jsx)( 33568 import_components121.ToggleControl, 33569 { 33570 label: (0, import_i18n111.__)("Enable infinite scroll"), 33571 help: (0, import_i18n111.__)( 33572 "Automatically load more content as you scroll, instead of showing pagination links." 33573 ), 33574 checked: infiniteScrollEnabled, 33575 onChange: (newValue) => { 33576 onChangeView({ 33577 ...view, 33578 infiniteScrollEnabled: newValue 33579 }); 33580 } 33581 } 33582 ); 33583 } 33584 33585 // packages/dataviews/build-module/components/dataviews-view-config/index.js 33586 var import_jsx_runtime227 = __toESM(require_jsx_runtime()); 33587 var { Menu: Menu9 } = unlock3(import_components122.privateApis); 33588 var DATAVIEWS_CONFIG_POPOVER_PROPS = { 33589 className: "dataviews-config__popover", 33590 placement: "bottom-end", 33591 offset: 9 33592 }; 33593 function ViewTypeMenu() { 33594 const { view, onChangeView, defaultLayouts: defaultLayouts4 } = (0, import_element99.useContext)(dataviews_context_default); 33595 const availableLayouts = Object.keys(defaultLayouts4); 33596 if (availableLayouts.length <= 1) { 33597 return null; 33598 } 33599 const activeView = VIEW_LAYOUTS.find((v2) => view.type === v2.type); 33600 return /* @__PURE__ */ (0, import_jsx_runtime227.jsxs)(Menu9, { children: [ 33601 /* @__PURE__ */ (0, import_jsx_runtime227.jsx)( 33602 Menu9.TriggerButton, 33603 { 33604 render: /* @__PURE__ */ (0, import_jsx_runtime227.jsx)( 33605 import_components122.Button, 33606 { 33607 size: "compact", 33608 icon: activeView?.icon, 33609 label: (0, import_i18n112.__)("Layout") 33610 } 33611 ) 33612 } 33613 ), 33614 /* @__PURE__ */ (0, import_jsx_runtime227.jsx)(Menu9.Popover, { children: availableLayouts.map((layout) => { 33615 const config2 = VIEW_LAYOUTS.find( 33616 (v2) => v2.type === layout 33617 ); 33618 if (!config2) { 33619 return null; 33620 } 33621 return /* @__PURE__ */ (0, import_jsx_runtime227.jsx)( 33622 Menu9.RadioItem, 33623 { 33624 value: layout, 33625 name: "view-actions-available-view", 33626 checked: layout === view.type, 33627 hideOnClick: true, 33628 onChange: (e2) => { 33629 switch (e2.target.value) { 33630 case "list": 33631 case "grid": 33632 case "table": 33633 case "pickerGrid": 33634 case "pickerTable": 33635 case "activity": 33636 const viewWithoutLayout = { ...view }; 33637 if ("layout" in viewWithoutLayout) { 33638 delete viewWithoutLayout.layout; 33639 } 33640 return onChangeView({ 33641 ...viewWithoutLayout, 33642 type: e2.target.value, 33643 ...defaultLayouts4[e2.target.value] 33644 }); 33645 } 33646 (0, import_warning.default)("Invalid dataview"); 33647 }, 33648 children: /* @__PURE__ */ (0, import_jsx_runtime227.jsx)(Menu9.ItemLabel, { children: config2.label }) 33649 }, 33650 layout 33651 ); 33652 }) }) 33653 ] }); 33654 } 33655 function SortFieldControl() { 33656 const { view, fields, onChangeView } = (0, import_element99.useContext)(dataviews_context_default); 33657 const orderOptions = (0, import_element99.useMemo)(() => { 33658 const sortableFields = fields.filter( 33659 (field) => field.enableSorting !== false 33660 ); 33661 return sortableFields.map((field) => { 33662 return { 33663 label: field.label, 33664 value: field.id 33665 }; 33666 }); 33667 }, [fields]); 33668 return /* @__PURE__ */ (0, import_jsx_runtime227.jsx)( 33669 import_components122.SelectControl, 33670 { 33671 __next40pxDefaultSize: true, 33672 label: (0, import_i18n112.__)("Sort by"), 33673 value: view.sort?.field, 33674 options: orderOptions, 33675 onChange: (value) => { 33676 onChangeView({ 33677 ...view, 33678 sort: { 33679 direction: view?.sort?.direction || "desc", 33680 field: value 33681 }, 33682 showLevels: false 33683 }); 33684 } 33685 } 33686 ); 33687 } 33688 function SortDirectionControl() { 33689 const { view, fields, onChangeView } = (0, import_element99.useContext)(dataviews_context_default); 33690 const sortableFields = fields.filter( 33691 (field) => field.enableSorting !== false 33692 ); 33693 if (sortableFields.length === 0) { 33694 return null; 33695 } 33696 let value = view.sort?.direction; 33697 if (!value && view.sort?.field) { 33698 value = "desc"; 33699 } 33700 return /* @__PURE__ */ (0, import_jsx_runtime227.jsx)( 33701 import_components122.__experimentalToggleGroupControl, 33702 { 33703 className: "dataviews-view-config__sort-direction", 33704 __next40pxDefaultSize: true, 33705 isBlock: true, 33706 label: (0, import_i18n112.__)("Order"), 33707 value, 33708 onChange: (newDirection) => { 33709 if (newDirection === "asc" || newDirection === "desc") { 33710 onChangeView({ 33711 ...view, 33712 sort: { 33713 direction: newDirection, 33714 field: view.sort?.field || // If there is no field assigned as the sorting field assign the first sortable field. 33715 fields.find( 33716 (field) => field.enableSorting !== false 33717 )?.id || "" 33718 }, 33719 showLevels: false 33720 }); 33721 return; 33722 } 33723 (0, import_warning.default)("Invalid direction"); 33724 }, 33725 children: SORTING_DIRECTIONS.map((direction) => { 33726 return /* @__PURE__ */ (0, import_jsx_runtime227.jsx)( 33727 import_components122.__experimentalToggleGroupControlOptionIcon, 33728 { 33729 value: direction, 33730 icon: sortIcons[direction], 33731 label: sortLabels[direction] 33732 }, 33733 direction 33734 ); 33735 }) 33736 } 33737 ); 33738 } 33739 function ItemsPerPageControl() { 33740 const { view, config: config2, onChangeView } = (0, import_element99.useContext)(dataviews_context_default); 33741 const { infiniteScrollEnabled } = view; 33742 if (!config2 || !config2.perPageSizes || config2.perPageSizes.length < 2 || config2.perPageSizes.length > 6 || infiniteScrollEnabled) { 33743 return null; 33744 } 33745 return /* @__PURE__ */ (0, import_jsx_runtime227.jsx)( 33746 import_components122.__experimentalToggleGroupControl, 33747 { 33748 __next40pxDefaultSize: true, 33749 isBlock: true, 33750 label: (0, import_i18n112.__)("Items per page"), 33751 value: view.perPage || 10, 33752 disabled: !view?.sort?.field, 33753 onChange: (newItemsPerPage) => { 33754 const newItemsPerPageNumber = typeof newItemsPerPage === "number" || newItemsPerPage === void 0 ? newItemsPerPage : parseInt(newItemsPerPage, 10); 33755 onChangeView({ 33756 ...view, 33757 perPage: newItemsPerPageNumber, 33758 page: 1 33759 }); 33760 }, 33761 children: config2.perPageSizes.map((value) => { 33762 return /* @__PURE__ */ (0, import_jsx_runtime227.jsx)( 33763 import_components122.__experimentalToggleGroupControlOption, 33764 { 33765 value, 33766 label: value.toString() 33767 }, 33768 value 33769 ); 33770 }) 33771 } 33772 ); 33773 } 33774 function SettingsSection({ 33775 title, 33776 description, 33777 children 33778 }) { 33779 return /* @__PURE__ */ (0, import_jsx_runtime227.jsxs)(import_components122.__experimentalGrid, { columns: 12, className: "dataviews-settings-section", gap: 4, children: [ 33780 /* @__PURE__ */ (0, import_jsx_runtime227.jsxs)("div", { className: "dataviews-settings-section__sidebar", children: [ 33781 /* @__PURE__ */ (0, import_jsx_runtime227.jsx)( 33782 import_components122.__experimentalHeading, 33783 { 33784 level: 2, 33785 className: "dataviews-settings-section__title", 33786 children: title 33787 } 33788 ), 33789 description && /* @__PURE__ */ (0, import_jsx_runtime227.jsx)( 33790 import_components122.__experimentalText, 33791 { 33792 variant: "muted", 33793 className: "dataviews-settings-section__description", 33794 children: description 33795 } 33796 ) 33797 ] }), 33798 /* @__PURE__ */ (0, import_jsx_runtime227.jsx)( 33799 import_components122.__experimentalGrid, 33800 { 33801 columns: 8, 33802 gap: 4, 33803 className: "dataviews-settings-section__content", 33804 children 33805 } 33806 ) 33807 ] }); 33808 } 33809 function DataviewsViewConfigDropdown() { 33810 const { view } = (0, import_element99.useContext)(dataviews_context_default); 33811 const popoverId = (0, import_compose21.useInstanceId)( 33812 _DataViewsViewConfig, 33813 "dataviews-view-config-dropdown" 33814 ); 33815 const activeLayout = VIEW_LAYOUTS.find( 33816 (layout) => layout.type === view.type 33817 ); 33818 return /* @__PURE__ */ (0, import_jsx_runtime227.jsx)( 33819 import_components122.Dropdown, 33820 { 33821 expandOnMobile: true, 33822 popoverProps: { 33823 ...DATAVIEWS_CONFIG_POPOVER_PROPS, 33824 id: popoverId 33825 }, 33826 renderToggle: ({ onToggle, isOpen }) => { 33827 return /* @__PURE__ */ (0, import_jsx_runtime227.jsx)( 33828 import_components122.Button, 33829 { 33830 size: "compact", 33831 icon: cog_default, 33832 label: (0, import_i18n112._x)("View options", "View is used as a noun"), 33833 onClick: onToggle, 33834 "aria-expanded": isOpen ? "true" : "false", 33835 "aria-controls": popoverId 33836 } 33837 ); 33838 }, 33839 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime227.jsx)( 33840 import_components122.__experimentalDropdownContentWrapper, 33841 { 33842 paddingSize: "medium", 33843 className: "dataviews-config__popover-content-wrapper", 33844 children: /* @__PURE__ */ (0, import_jsx_runtime227.jsx)(import_components122.__experimentalVStack, { className: "dataviews-view-config", spacing: 6, children: /* @__PURE__ */ (0, import_jsx_runtime227.jsxs)(SettingsSection, { title: (0, import_i18n112.__)("Appearance"), children: [ 33845 /* @__PURE__ */ (0, import_jsx_runtime227.jsxs)(import_components122.__experimentalHStack, { expanded: true, className: "is-divided-in-two", children: [ 33846 /* @__PURE__ */ (0, import_jsx_runtime227.jsx)(SortFieldControl, {}), 33847 /* @__PURE__ */ (0, import_jsx_runtime227.jsx)(SortDirectionControl, {}) 33848 ] }), 33849 !!activeLayout?.viewConfigOptions && /* @__PURE__ */ (0, import_jsx_runtime227.jsx)(activeLayout.viewConfigOptions, {}), 33850 /* @__PURE__ */ (0, import_jsx_runtime227.jsx)(InfiniteScrollToggle, {}), 33851 /* @__PURE__ */ (0, import_jsx_runtime227.jsx)(ItemsPerPageControl, {}), 33852 /* @__PURE__ */ (0, import_jsx_runtime227.jsx)(PropertiesSection, {}) 33853 ] }) }) 33854 } 33855 ) 33856 } 33857 ); 33858 } 33859 function _DataViewsViewConfig() { 33860 return /* @__PURE__ */ (0, import_jsx_runtime227.jsxs)(import_jsx_runtime227.Fragment, { children: [ 33861 /* @__PURE__ */ (0, import_jsx_runtime227.jsx)(ViewTypeMenu, {}), 33862 /* @__PURE__ */ (0, import_jsx_runtime227.jsx)(DataviewsViewConfigDropdown, {}) 33863 ] }); 33864 } 33865 var DataViewsViewConfig = (0, import_element99.memo)(_DataViewsViewConfig); 33866 var dataviews_view_config_default = DataViewsViewConfig; 33867 33868 // packages/dataviews/build-module/dataform-controls/checkbox.js 33869 var import_components123 = __toESM(require_components()); 33870 var import_element100 = __toESM(require_element()); 33871 33872 // packages/dataviews/build-module/dataform-controls/utils/get-custom-validity.js 33873 function getCustomValidity(isValid2, validity) { 33874 let customValidity; 33875 if (isValid2?.required && validity?.required) { 33876 customValidity = validity?.required?.message ? validity.required : void 0; 33877 } else if (isValid2?.pattern && validity?.pattern) { 33878 customValidity = validity.pattern; 33879 } else if (isValid2?.min && validity?.min) { 33880 customValidity = validity.min; 33881 } else if (isValid2?.max && validity?.max) { 33882 customValidity = validity.max; 33883 } else if (isValid2?.minLength && validity?.minLength) { 33884 customValidity = validity.minLength; 33885 } else if (isValid2?.maxLength && validity?.maxLength) { 33886 customValidity = validity.maxLength; 33887 } else if (isValid2?.elements && validity?.elements) { 33888 customValidity = validity.elements; 33889 } else if (validity?.custom) { 33890 customValidity = validity.custom; 33891 } 33892 return customValidity; 33893 } 33894 33895 // packages/dataviews/build-module/dataform-controls/checkbox.js 33896 var import_jsx_runtime228 = __toESM(require_jsx_runtime()); 33897 var { ValidatedCheckboxControl } = unlock3(import_components123.privateApis); 33898 function Checkbox({ 33899 field, 33900 onChange, 33901 data, 33902 hideLabelFromVision, 33903 validity 33904 }) { 33905 const { getValue, setValue, label, description, isValid: isValid2 } = field; 33906 const onChangeControl = (0, import_element100.useCallback)(() => { 33907 onChange( 33908 setValue({ item: data, value: !getValue({ item: data }) }) 33909 ); 33910 }, [data, getValue, onChange, setValue]); 33911 return /* @__PURE__ */ (0, import_jsx_runtime228.jsx)( 33912 ValidatedCheckboxControl, 33913 { 33914 required: !!field.isValid?.required, 33915 customValidity: getCustomValidity(isValid2, validity), 33916 hidden: hideLabelFromVision, 33917 label, 33918 help: description, 33919 checked: getValue({ item: data }), 33920 onChange: onChangeControl 33921 } 33922 ); 33923 } 33924 33925 // packages/dataviews/node_modules/date-fns/constants.js 33926 var daysInYear = 365.2425; 33927 var maxTime = Math.pow(10, 8) * 24 * 60 * 60 * 1e3; 33928 var minTime = -maxTime; 33929 var millisecondsInWeek = 6048e5; 33930 var millisecondsInDay = 864e5; 33931 var secondsInHour = 3600; 33932 var secondsInDay = secondsInHour * 24; 33933 var secondsInWeek = secondsInDay * 7; 33934 var secondsInYear = secondsInDay * daysInYear; 33935 var secondsInMonth = secondsInYear / 12; 33936 var secondsInQuarter = secondsInMonth * 3; 33937 var constructFromSymbol = Symbol.for("constructDateFrom"); 33938 33939 // packages/dataviews/node_modules/date-fns/constructFrom.js 33940 function constructFrom(date, value) { 33941 if (typeof date === "function") return date(value); 33942 if (date && typeof date === "object" && constructFromSymbol in date) 33943 return date[constructFromSymbol](value); 33944 if (date instanceof Date) return new date.constructor(value); 33945 return new Date(value); 33946 } 33947 33948 // packages/dataviews/node_modules/date-fns/toDate.js 33949 function toDate(argument, context) { 33950 return constructFrom(context || argument, argument); 33951 } 33952 33953 // packages/dataviews/node_modules/date-fns/addDays.js 33954 function addDays(date, amount, options) { 33955 const _date = toDate(date, options?.in); 33956 if (isNaN(amount)) return constructFrom(options?.in || date, NaN); 33957 if (!amount) return _date; 33958 _date.setDate(_date.getDate() + amount); 33959 return _date; 33960 } 33961 33962 // packages/dataviews/node_modules/date-fns/addMonths.js 33963 function addMonths(date, amount, options) { 33964 const _date = toDate(date, options?.in); 33965 if (isNaN(amount)) return constructFrom(options?.in || date, NaN); 33966 if (!amount) { 33967 return _date; 33968 } 33969 const dayOfMonth = _date.getDate(); 33970 const endOfDesiredMonth = constructFrom(options?.in || date, _date.getTime()); 33971 endOfDesiredMonth.setMonth(_date.getMonth() + amount + 1, 0); 33972 const daysInMonth = endOfDesiredMonth.getDate(); 33973 if (dayOfMonth >= daysInMonth) { 33974 return endOfDesiredMonth; 33975 } else { 33976 _date.setFullYear( 33977 endOfDesiredMonth.getFullYear(), 33978 endOfDesiredMonth.getMonth(), 33979 dayOfMonth 33980 ); 33981 return _date; 33982 } 33983 } 33984 33985 // packages/dataviews/node_modules/date-fns/_lib/defaultOptions.js 33986 var defaultOptions = {}; 33987 function getDefaultOptions() { 33988 return defaultOptions; 33989 } 33990 33991 // packages/dataviews/node_modules/date-fns/startOfWeek.js 33992 function startOfWeek(date, options) { 33993 const defaultOptions2 = getDefaultOptions(); 33994 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0; 33995 const _date = toDate(date, options?.in); 33996 const day = _date.getDay(); 33997 const diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn; 33998 _date.setDate(_date.getDate() - diff); 33999 _date.setHours(0, 0, 0, 0); 34000 return _date; 34001 } 34002 34003 // packages/dataviews/node_modules/date-fns/startOfISOWeek.js 34004 function startOfISOWeek(date, options) { 34005 return startOfWeek(date, { ...options, weekStartsOn: 1 }); 34006 } 34007 34008 // packages/dataviews/node_modules/date-fns/getISOWeekYear.js 34009 function getISOWeekYear(date, options) { 34010 const _date = toDate(date, options?.in); 34011 const year = _date.getFullYear(); 34012 const fourthOfJanuaryOfNextYear = constructFrom(_date, 0); 34013 fourthOfJanuaryOfNextYear.setFullYear(year + 1, 0, 4); 34014 fourthOfJanuaryOfNextYear.setHours(0, 0, 0, 0); 34015 const startOfNextYear = startOfISOWeek(fourthOfJanuaryOfNextYear); 34016 const fourthOfJanuaryOfThisYear = constructFrom(_date, 0); 34017 fourthOfJanuaryOfThisYear.setFullYear(year, 0, 4); 34018 fourthOfJanuaryOfThisYear.setHours(0, 0, 0, 0); 34019 const startOfThisYear = startOfISOWeek(fourthOfJanuaryOfThisYear); 34020 if (_date.getTime() >= startOfNextYear.getTime()) { 34021 return year + 1; 34022 } else if (_date.getTime() >= startOfThisYear.getTime()) { 34023 return year; 34024 } else { 34025 return year - 1; 34026 } 34027 } 34028 34029 // packages/dataviews/node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.js 34030 function getTimezoneOffsetInMilliseconds(date) { 34031 const _date = toDate(date); 34032 const utcDate = new Date( 34033 Date.UTC( 34034 _date.getFullYear(), 34035 _date.getMonth(), 34036 _date.getDate(), 34037 _date.getHours(), 34038 _date.getMinutes(), 34039 _date.getSeconds(), 34040 _date.getMilliseconds() 34041 ) 34042 ); 34043 utcDate.setUTCFullYear(_date.getFullYear()); 34044 return +date - +utcDate; 34045 } 34046 34047 // packages/dataviews/node_modules/date-fns/_lib/normalizeDates.js 34048 function normalizeDates(context, ...dates) { 34049 const normalize = constructFrom.bind( 34050 null, 34051 context || dates.find((date) => typeof date === "object") 34052 ); 34053 return dates.map(normalize); 34054 } 34055 34056 // packages/dataviews/node_modules/date-fns/startOfDay.js 34057 function startOfDay(date, options) { 34058 const _date = toDate(date, options?.in); 34059 _date.setHours(0, 0, 0, 0); 34060 return _date; 34061 } 34062 34063 // packages/dataviews/node_modules/date-fns/differenceInCalendarDays.js 34064 function differenceInCalendarDays(laterDate, earlierDate, options) { 34065 const [laterDate_, earlierDate_] = normalizeDates( 34066 options?.in, 34067 laterDate, 34068 earlierDate 34069 ); 34070 const laterStartOfDay = startOfDay(laterDate_); 34071 const earlierStartOfDay = startOfDay(earlierDate_); 34072 const laterTimestamp = +laterStartOfDay - getTimezoneOffsetInMilliseconds(laterStartOfDay); 34073 const earlierTimestamp = +earlierStartOfDay - getTimezoneOffsetInMilliseconds(earlierStartOfDay); 34074 return Math.round((laterTimestamp - earlierTimestamp) / millisecondsInDay); 34075 } 34076 34077 // packages/dataviews/node_modules/date-fns/startOfISOWeekYear.js 34078 function startOfISOWeekYear(date, options) { 34079 const year = getISOWeekYear(date, options); 34080 const fourthOfJanuary = constructFrom(options?.in || date, 0); 34081 fourthOfJanuary.setFullYear(year, 0, 4); 34082 fourthOfJanuary.setHours(0, 0, 0, 0); 34083 return startOfISOWeek(fourthOfJanuary); 34084 } 34085 34086 // packages/dataviews/node_modules/date-fns/addWeeks.js 34087 function addWeeks(date, amount, options) { 34088 return addDays(date, amount * 7, options); 34089 } 34090 34091 // packages/dataviews/node_modules/date-fns/addYears.js 34092 function addYears(date, amount, options) { 34093 return addMonths(date, amount * 12, options); 34094 } 34095 34096 // packages/dataviews/node_modules/date-fns/isDate.js 34097 function isDate(value) { 34098 return value instanceof Date || typeof value === "object" && Object.prototype.toString.call(value) === "[object Date]"; 34099 } 34100 34101 // packages/dataviews/node_modules/date-fns/isValid.js 34102 function isValid(date) { 34103 return !(!isDate(date) && typeof date !== "number" || isNaN(+toDate(date))); 34104 } 34105 34106 // packages/dataviews/node_modules/date-fns/startOfMonth.js 34107 function startOfMonth(date, options) { 34108 const _date = toDate(date, options?.in); 34109 _date.setDate(1); 34110 _date.setHours(0, 0, 0, 0); 34111 return _date; 34112 } 34113 34114 // packages/dataviews/node_modules/date-fns/startOfYear.js 34115 function startOfYear(date, options) { 34116 const date_ = toDate(date, options?.in); 34117 date_.setFullYear(date_.getFullYear(), 0, 1); 34118 date_.setHours(0, 0, 0, 0); 34119 return date_; 34120 } 34121 34122 // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/formatDistance.js 34123 var formatDistanceLocale = { 34124 lessThanXSeconds: { 34125 one: "less than a second", 34126 other: "less than {{count}} seconds" 34127 }, 34128 xSeconds: { 34129 one: "1 second", 34130 other: "{{count}} seconds" 34131 }, 34132 halfAMinute: "half a minute", 34133 lessThanXMinutes: { 34134 one: "less than a minute", 34135 other: "less than {{count}} minutes" 34136 }, 34137 xMinutes: { 34138 one: "1 minute", 34139 other: "{{count}} minutes" 34140 }, 34141 aboutXHours: { 34142 one: "about 1 hour", 34143 other: "about {{count}} hours" 34144 }, 34145 xHours: { 34146 one: "1 hour", 34147 other: "{{count}} hours" 34148 }, 34149 xDays: { 34150 one: "1 day", 34151 other: "{{count}} days" 34152 }, 34153 aboutXWeeks: { 34154 one: "about 1 week", 34155 other: "about {{count}} weeks" 34156 }, 34157 xWeeks: { 34158 one: "1 week", 34159 other: "{{count}} weeks" 34160 }, 34161 aboutXMonths: { 34162 one: "about 1 month", 34163 other: "about {{count}} months" 34164 }, 34165 xMonths: { 34166 one: "1 month", 34167 other: "{{count}} months" 34168 }, 34169 aboutXYears: { 34170 one: "about 1 year", 34171 other: "about {{count}} years" 34172 }, 34173 xYears: { 34174 one: "1 year", 34175 other: "{{count}} years" 34176 }, 34177 overXYears: { 34178 one: "over 1 year", 34179 other: "over {{count}} years" 34180 }, 34181 almostXYears: { 34182 one: "almost 1 year", 34183 other: "almost {{count}} years" 34184 } 34185 }; 34186 var formatDistance = (token, count, options) => { 34187 let result; 34188 const tokenValue = formatDistanceLocale[token]; 34189 if (typeof tokenValue === "string") { 34190 result = tokenValue; 34191 } else if (count === 1) { 34192 result = tokenValue.one; 34193 } else { 34194 result = tokenValue.other.replace("{{count}}", count.toString()); 34195 } 34196 if (options?.addSuffix) { 34197 if (options.comparison && options.comparison > 0) { 34198 return "in " + result; 34199 } else { 34200 return result + " ago"; 34201 } 34202 } 34203 return result; 34204 }; 34205 34206 // packages/dataviews/node_modules/date-fns/locale/_lib/buildFormatLongFn.js 34207 function buildFormatLongFn(args) { 34208 return (options = {}) => { 34209 const width = options.width ? String(options.width) : args.defaultWidth; 34210 const format6 = args.formats[width] || args.formats[args.defaultWidth]; 34211 return format6; 34212 }; 34213 } 34214 34215 // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/formatLong.js 34216 var dateFormats = { 34217 full: "EEEE, MMMM do, y", 34218 long: "MMMM do, y", 34219 medium: "MMM d, y", 34220 short: "MM/dd/yyyy" 34221 }; 34222 var timeFormats = { 34223 full: "h:mm:ss a zzzz", 34224 long: "h:mm:ss a z", 34225 medium: "h:mm:ss a", 34226 short: "h:mm a" 34227 }; 34228 var dateTimeFormats = { 34229 full: "{{date}} 'at' {{time}}", 34230 long: "{{date}} 'at' {{time}}", 34231 medium: "{{date}}, {{time}}", 34232 short: "{{date}}, {{time}}" 34233 }; 34234 var formatLong = { 34235 date: buildFormatLongFn({ 34236 formats: dateFormats, 34237 defaultWidth: "full" 34238 }), 34239 time: buildFormatLongFn({ 34240 formats: timeFormats, 34241 defaultWidth: "full" 34242 }), 34243 dateTime: buildFormatLongFn({ 34244 formats: dateTimeFormats, 34245 defaultWidth: "full" 34246 }) 34247 }; 34248 34249 // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/formatRelative.js 34250 var formatRelativeLocale = { 34251 lastWeek: "'last' eeee 'at' p", 34252 yesterday: "'yesterday at' p", 34253 today: "'today at' p", 34254 tomorrow: "'tomorrow at' p", 34255 nextWeek: "eeee 'at' p", 34256 other: "P" 34257 }; 34258 var formatRelative = (token, _date, _baseDate, _options) => formatRelativeLocale[token]; 34259 34260 // packages/dataviews/node_modules/date-fns/locale/_lib/buildLocalizeFn.js 34261 function buildLocalizeFn(args) { 34262 return (value, options) => { 34263 const context = options?.context ? String(options.context) : "standalone"; 34264 let valuesArray; 34265 if (context === "formatting" && args.formattingValues) { 34266 const defaultWidth = args.defaultFormattingWidth || args.defaultWidth; 34267 const width = options?.width ? String(options.width) : defaultWidth; 34268 valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth]; 34269 } else { 34270 const defaultWidth = args.defaultWidth; 34271 const width = options?.width ? String(options.width) : args.defaultWidth; 34272 valuesArray = args.values[width] || args.values[defaultWidth]; 34273 } 34274 const index = args.argumentCallback ? args.argumentCallback(value) : value; 34275 return valuesArray[index]; 34276 }; 34277 } 34278 34279 // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/localize.js 34280 var eraValues = { 34281 narrow: ["B", "A"], 34282 abbreviated: ["BC", "AD"], 34283 wide: ["Before Christ", "Anno Domini"] 34284 }; 34285 var quarterValues = { 34286 narrow: ["1", "2", "3", "4"], 34287 abbreviated: ["Q1", "Q2", "Q3", "Q4"], 34288 wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"] 34289 }; 34290 var monthValues = { 34291 narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"], 34292 abbreviated: [ 34293 "Jan", 34294 "Feb", 34295 "Mar", 34296 "Apr", 34297 "May", 34298 "Jun", 34299 "Jul", 34300 "Aug", 34301 "Sep", 34302 "Oct", 34303 "Nov", 34304 "Dec" 34305 ], 34306 wide: [ 34307 "January", 34308 "February", 34309 "March", 34310 "April", 34311 "May", 34312 "June", 34313 "July", 34314 "August", 34315 "September", 34316 "October", 34317 "November", 34318 "December" 34319 ] 34320 }; 34321 var dayValues = { 34322 narrow: ["S", "M", "T", "W", "T", "F", "S"], 34323 short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"], 34324 abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], 34325 wide: [ 34326 "Sunday", 34327 "Monday", 34328 "Tuesday", 34329 "Wednesday", 34330 "Thursday", 34331 "Friday", 34332 "Saturday" 34333 ] 34334 }; 34335 var dayPeriodValues = { 34336 narrow: { 34337 am: "a", 34338 pm: "p", 34339 midnight: "mi", 34340 noon: "n", 34341 morning: "morning", 34342 afternoon: "afternoon", 34343 evening: "evening", 34344 night: "night" 34345 }, 34346 abbreviated: { 34347 am: "AM", 34348 pm: "PM", 34349 midnight: "midnight", 34350 noon: "noon", 34351 morning: "morning", 34352 afternoon: "afternoon", 34353 evening: "evening", 34354 night: "night" 34355 }, 34356 wide: { 34357 am: "a.m.", 34358 pm: "p.m.", 34359 midnight: "midnight", 34360 noon: "noon", 34361 morning: "morning", 34362 afternoon: "afternoon", 34363 evening: "evening", 34364 night: "night" 34365 } 34366 }; 34367 var formattingDayPeriodValues = { 34368 narrow: { 34369 am: "a", 34370 pm: "p", 34371 midnight: "mi", 34372 noon: "n", 34373 morning: "in the morning", 34374 afternoon: "in the afternoon", 34375 evening: "in the evening", 34376 night: "at night" 34377 }, 34378 abbreviated: { 34379 am: "AM", 34380 pm: "PM", 34381 midnight: "midnight", 34382 noon: "noon", 34383 morning: "in the morning", 34384 afternoon: "in the afternoon", 34385 evening: "in the evening", 34386 night: "at night" 34387 }, 34388 wide: { 34389 am: "a.m.", 34390 pm: "p.m.", 34391 midnight: "midnight", 34392 noon: "noon", 34393 morning: "in the morning", 34394 afternoon: "in the afternoon", 34395 evening: "in the evening", 34396 night: "at night" 34397 } 34398 }; 34399 var ordinalNumber = (dirtyNumber, _options) => { 34400 const number = Number(dirtyNumber); 34401 const rem100 = number % 100; 34402 if (rem100 > 20 || rem100 < 10) { 34403 switch (rem100 % 10) { 34404 case 1: 34405 return number + "st"; 34406 case 2: 34407 return number + "nd"; 34408 case 3: 34409 return number + "rd"; 34410 } 34411 } 34412 return number + "th"; 34413 }; 34414 var localize = { 34415 ordinalNumber, 34416 era: buildLocalizeFn({ 34417 values: eraValues, 34418 defaultWidth: "wide" 34419 }), 34420 quarter: buildLocalizeFn({ 34421 values: quarterValues, 34422 defaultWidth: "wide", 34423 argumentCallback: (quarter) => quarter - 1 34424 }), 34425 month: buildLocalizeFn({ 34426 values: monthValues, 34427 defaultWidth: "wide" 34428 }), 34429 day: buildLocalizeFn({ 34430 values: dayValues, 34431 defaultWidth: "wide" 34432 }), 34433 dayPeriod: buildLocalizeFn({ 34434 values: dayPeriodValues, 34435 defaultWidth: "wide", 34436 formattingValues: formattingDayPeriodValues, 34437 defaultFormattingWidth: "wide" 34438 }) 34439 }; 34440 34441 // packages/dataviews/node_modules/date-fns/locale/_lib/buildMatchFn.js 34442 function buildMatchFn(args) { 34443 return (string, options = {}) => { 34444 const width = options.width; 34445 const matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth]; 34446 const matchResult = string.match(matchPattern); 34447 if (!matchResult) { 34448 return null; 34449 } 34450 const matchedString = matchResult[0]; 34451 const parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth]; 34452 const key = Array.isArray(parsePatterns) ? findIndex2(parsePatterns, (pattern) => pattern.test(matchedString)) : ( 34453 // [TODO] -- I challenge you to fix the type 34454 findKey(parsePatterns, (pattern) => pattern.test(matchedString)) 34455 ); 34456 let value; 34457 value = args.valueCallback ? args.valueCallback(key) : key; 34458 value = options.valueCallback ? ( 34459 // [TODO] -- I challenge you to fix the type 34460 options.valueCallback(value) 34461 ) : value; 34462 const rest = string.slice(matchedString.length); 34463 return { value, rest }; 34464 }; 34465 } 34466 function findKey(object, predicate) { 34467 for (const key in object) { 34468 if (Object.prototype.hasOwnProperty.call(object, key) && predicate(object[key])) { 34469 return key; 34470 } 34471 } 34472 return void 0; 34473 } 34474 function findIndex2(array, predicate) { 34475 for (let key = 0; key < array.length; key++) { 34476 if (predicate(array[key])) { 34477 return key; 34478 } 34479 } 34480 return void 0; 34481 } 34482 34483 // packages/dataviews/node_modules/date-fns/locale/_lib/buildMatchPatternFn.js 34484 function buildMatchPatternFn(args) { 34485 return (string, options = {}) => { 34486 const matchResult = string.match(args.matchPattern); 34487 if (!matchResult) return null; 34488 const matchedString = matchResult[0]; 34489 const parseResult = string.match(args.parsePattern); 34490 if (!parseResult) return null; 34491 let value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0]; 34492 value = options.valueCallback ? options.valueCallback(value) : value; 34493 const rest = string.slice(matchedString.length); 34494 return { value, rest }; 34495 }; 34496 } 34497 34498 // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/match.js 34499 var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i; 34500 var parseOrdinalNumberPattern = /\d+/i; 34501 var matchEraPatterns = { 34502 narrow: /^(b|a)/i, 34503 abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i, 34504 wide: /^(before christ|before common era|anno domini|common era)/i 34505 }; 34506 var parseEraPatterns = { 34507 any: [/^b/i, /^(a|c)/i] 34508 }; 34509 var matchQuarterPatterns = { 34510 narrow: /^[1234]/i, 34511 abbreviated: /^q[1234]/i, 34512 wide: /^[1234](th|st|nd|rd)? quarter/i 34513 }; 34514 var parseQuarterPatterns = { 34515 any: [/1/i, /2/i, /3/i, /4/i] 34516 }; 34517 var matchMonthPatterns = { 34518 narrow: /^[jfmasond]/i, 34519 abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i, 34520 wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i 34521 }; 34522 var parseMonthPatterns = { 34523 narrow: [ 34524 /^j/i, 34525 /^f/i, 34526 /^m/i, 34527 /^a/i, 34528 /^m/i, 34529 /^j/i, 34530 /^j/i, 34531 /^a/i, 34532 /^s/i, 34533 /^o/i, 34534 /^n/i, 34535 /^d/i 34536 ], 34537 any: [ 34538 /^ja/i, 34539 /^f/i, 34540 /^mar/i, 34541 /^ap/i, 34542 /^may/i, 34543 /^jun/i, 34544 /^jul/i, 34545 /^au/i, 34546 /^s/i, 34547 /^o/i, 34548 /^n/i, 34549 /^d/i 34550 ] 34551 }; 34552 var matchDayPatterns = { 34553 narrow: /^[smtwf]/i, 34554 short: /^(su|mo|tu|we|th|fr|sa)/i, 34555 abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i, 34556 wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i 34557 }; 34558 var parseDayPatterns = { 34559 narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i], 34560 any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i] 34561 }; 34562 var matchDayPeriodPatterns = { 34563 narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i, 34564 any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i 34565 }; 34566 var parseDayPeriodPatterns = { 34567 any: { 34568 am: /^a/i, 34569 pm: /^p/i, 34570 midnight: /^mi/i, 34571 noon: /^no/i, 34572 morning: /morning/i, 34573 afternoon: /afternoon/i, 34574 evening: /evening/i, 34575 night: /night/i 34576 } 34577 }; 34578 var match2 = { 34579 ordinalNumber: buildMatchPatternFn({ 34580 matchPattern: matchOrdinalNumberPattern, 34581 parsePattern: parseOrdinalNumberPattern, 34582 valueCallback: (value) => parseInt(value, 10) 34583 }), 34584 era: buildMatchFn({ 34585 matchPatterns: matchEraPatterns, 34586 defaultMatchWidth: "wide", 34587 parsePatterns: parseEraPatterns, 34588 defaultParseWidth: "any" 34589 }), 34590 quarter: buildMatchFn({ 34591 matchPatterns: matchQuarterPatterns, 34592 defaultMatchWidth: "wide", 34593 parsePatterns: parseQuarterPatterns, 34594 defaultParseWidth: "any", 34595 valueCallback: (index) => index + 1 34596 }), 34597 month: buildMatchFn({ 34598 matchPatterns: matchMonthPatterns, 34599 defaultMatchWidth: "wide", 34600 parsePatterns: parseMonthPatterns, 34601 defaultParseWidth: "any" 34602 }), 34603 day: buildMatchFn({ 34604 matchPatterns: matchDayPatterns, 34605 defaultMatchWidth: "wide", 34606 parsePatterns: parseDayPatterns, 34607 defaultParseWidth: "any" 34608 }), 34609 dayPeriod: buildMatchFn({ 34610 matchPatterns: matchDayPeriodPatterns, 34611 defaultMatchWidth: "any", 34612 parsePatterns: parseDayPeriodPatterns, 34613 defaultParseWidth: "any" 34614 }) 34615 }; 34616 34617 // packages/dataviews/node_modules/date-fns/locale/en-US.js 34618 var enUS = { 34619 code: "en-US", 34620 formatDistance, 34621 formatLong, 34622 formatRelative, 34623 localize, 34624 match: match2, 34625 options: { 34626 weekStartsOn: 0, 34627 firstWeekContainsDate: 1 34628 } 34629 }; 34630 34631 // packages/dataviews/node_modules/date-fns/getDayOfYear.js 34632 function getDayOfYear(date, options) { 34633 const _date = toDate(date, options?.in); 34634 const diff = differenceInCalendarDays(_date, startOfYear(_date)); 34635 const dayOfYear = diff + 1; 34636 return dayOfYear; 34637 } 34638 34639 // packages/dataviews/node_modules/date-fns/getISOWeek.js 34640 function getISOWeek(date, options) { 34641 const _date = toDate(date, options?.in); 34642 const diff = +startOfISOWeek(_date) - +startOfISOWeekYear(_date); 34643 return Math.round(diff / millisecondsInWeek) + 1; 34644 } 34645 34646 // packages/dataviews/node_modules/date-fns/getWeekYear.js 34647 function getWeekYear(date, options) { 34648 const _date = toDate(date, options?.in); 34649 const year = _date.getFullYear(); 34650 const defaultOptions2 = getDefaultOptions(); 34651 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1; 34652 const firstWeekOfNextYear = constructFrom(options?.in || date, 0); 34653 firstWeekOfNextYear.setFullYear(year + 1, 0, firstWeekContainsDate); 34654 firstWeekOfNextYear.setHours(0, 0, 0, 0); 34655 const startOfNextYear = startOfWeek(firstWeekOfNextYear, options); 34656 const firstWeekOfThisYear = constructFrom(options?.in || date, 0); 34657 firstWeekOfThisYear.setFullYear(year, 0, firstWeekContainsDate); 34658 firstWeekOfThisYear.setHours(0, 0, 0, 0); 34659 const startOfThisYear = startOfWeek(firstWeekOfThisYear, options); 34660 if (+_date >= +startOfNextYear) { 34661 return year + 1; 34662 } else if (+_date >= +startOfThisYear) { 34663 return year; 34664 } else { 34665 return year - 1; 34666 } 34667 } 34668 34669 // packages/dataviews/node_modules/date-fns/startOfWeekYear.js 34670 function startOfWeekYear(date, options) { 34671 const defaultOptions2 = getDefaultOptions(); 34672 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1; 34673 const year = getWeekYear(date, options); 34674 const firstWeek = constructFrom(options?.in || date, 0); 34675 firstWeek.setFullYear(year, 0, firstWeekContainsDate); 34676 firstWeek.setHours(0, 0, 0, 0); 34677 const _date = startOfWeek(firstWeek, options); 34678 return _date; 34679 } 34680 34681 // packages/dataviews/node_modules/date-fns/getWeek.js 34682 function getWeek(date, options) { 34683 const _date = toDate(date, options?.in); 34684 const diff = +startOfWeek(_date, options) - +startOfWeekYear(_date, options); 34685 return Math.round(diff / millisecondsInWeek) + 1; 34686 } 34687 34688 // packages/dataviews/node_modules/date-fns/_lib/addLeadingZeros.js 34689 function addLeadingZeros(number, targetLength) { 34690 const sign = number < 0 ? "-" : ""; 34691 const output = Math.abs(number).toString().padStart(targetLength, "0"); 34692 return sign + output; 34693 } 34694 34695 // packages/dataviews/node_modules/date-fns/_lib/format/lightFormatters.js 34696 var lightFormatters = { 34697 // Year 34698 y(date, token) { 34699 const signedYear = date.getFullYear(); 34700 const year = signedYear > 0 ? signedYear : 1 - signedYear; 34701 return addLeadingZeros(token === "yy" ? year % 100 : year, token.length); 34702 }, 34703 // Month 34704 M(date, token) { 34705 const month = date.getMonth(); 34706 return token === "M" ? String(month + 1) : addLeadingZeros(month + 1, 2); 34707 }, 34708 // Day of the month 34709 d(date, token) { 34710 return addLeadingZeros(date.getDate(), token.length); 34711 }, 34712 // AM or PM 34713 a(date, token) { 34714 const dayPeriodEnumValue = date.getHours() / 12 >= 1 ? "pm" : "am"; 34715 switch (token) { 34716 case "a": 34717 case "aa": 34718 return dayPeriodEnumValue.toUpperCase(); 34719 case "aaa": 34720 return dayPeriodEnumValue; 34721 case "aaaaa": 34722 return dayPeriodEnumValue[0]; 34723 case "aaaa": 34724 default: 34725 return dayPeriodEnumValue === "am" ? "a.m." : "p.m."; 34726 } 34727 }, 34728 // Hour [1-12] 34729 h(date, token) { 34730 return addLeadingZeros(date.getHours() % 12 || 12, token.length); 34731 }, 34732 // Hour [0-23] 34733 H(date, token) { 34734 return addLeadingZeros(date.getHours(), token.length); 34735 }, 34736 // Minute 34737 m(date, token) { 34738 return addLeadingZeros(date.getMinutes(), token.length); 34739 }, 34740 // Second 34741 s(date, token) { 34742 return addLeadingZeros(date.getSeconds(), token.length); 34743 }, 34744 // Fraction of second 34745 S(date, token) { 34746 const numberOfDigits = token.length; 34747 const milliseconds = date.getMilliseconds(); 34748 const fractionalSeconds = Math.trunc( 34749 milliseconds * Math.pow(10, numberOfDigits - 3) 34750 ); 34751 return addLeadingZeros(fractionalSeconds, token.length); 34752 } 34753 }; 34754 34755 // packages/dataviews/node_modules/date-fns/_lib/format/formatters.js 34756 var dayPeriodEnum = { 34757 am: "am", 34758 pm: "pm", 34759 midnight: "midnight", 34760 noon: "noon", 34761 morning: "morning", 34762 afternoon: "afternoon", 34763 evening: "evening", 34764 night: "night" 34765 }; 34766 var formatters = { 34767 // Era 34768 G: function(date, token, localize2) { 34769 const era = date.getFullYear() > 0 ? 1 : 0; 34770 switch (token) { 34771 // AD, BC 34772 case "G": 34773 case "GG": 34774 case "GGG": 34775 return localize2.era(era, { width: "abbreviated" }); 34776 // A, B 34777 case "GGGGG": 34778 return localize2.era(era, { width: "narrow" }); 34779 // Anno Domini, Before Christ 34780 case "GGGG": 34781 default: 34782 return localize2.era(era, { width: "wide" }); 34783 } 34784 }, 34785 // Year 34786 y: function(date, token, localize2) { 34787 if (token === "yo") { 34788 const signedYear = date.getFullYear(); 34789 const year = signedYear > 0 ? signedYear : 1 - signedYear; 34790 return localize2.ordinalNumber(year, { unit: "year" }); 34791 } 34792 return lightFormatters.y(date, token); 34793 }, 34794 // Local week-numbering year 34795 Y: function(date, token, localize2, options) { 34796 const signedWeekYear = getWeekYear(date, options); 34797 const weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear; 34798 if (token === "YY") { 34799 const twoDigitYear = weekYear % 100; 34800 return addLeadingZeros(twoDigitYear, 2); 34801 } 34802 if (token === "Yo") { 34803 return localize2.ordinalNumber(weekYear, { unit: "year" }); 34804 } 34805 return addLeadingZeros(weekYear, token.length); 34806 }, 34807 // ISO week-numbering year 34808 R: function(date, token) { 34809 const isoWeekYear = getISOWeekYear(date); 34810 return addLeadingZeros(isoWeekYear, token.length); 34811 }, 34812 // Extended year. This is a single number designating the year of this calendar system. 34813 // The main difference between `y` and `u` localizers are B.C. years: 34814 // | Year | `y` | `u` | 34815 // |------|-----|-----| 34816 // | AC 1 | 1 | 1 | 34817 // | BC 1 | 1 | 0 | 34818 // | BC 2 | 2 | -1 | 34819 // Also `yy` always returns the last two digits of a year, 34820 // while `uu` pads single digit years to 2 characters and returns other years unchanged. 34821 u: function(date, token) { 34822 const year = date.getFullYear(); 34823 return addLeadingZeros(year, token.length); 34824 }, 34825 // Quarter 34826 Q: function(date, token, localize2) { 34827 const quarter = Math.ceil((date.getMonth() + 1) / 3); 34828 switch (token) { 34829 // 1, 2, 3, 4 34830 case "Q": 34831 return String(quarter); 34832 // 01, 02, 03, 04 34833 case "QQ": 34834 return addLeadingZeros(quarter, 2); 34835 // 1st, 2nd, 3rd, 4th 34836 case "Qo": 34837 return localize2.ordinalNumber(quarter, { unit: "quarter" }); 34838 // Q1, Q2, Q3, Q4 34839 case "QQQ": 34840 return localize2.quarter(quarter, { 34841 width: "abbreviated", 34842 context: "formatting" 34843 }); 34844 // 1, 2, 3, 4 (narrow quarter; could be not numerical) 34845 case "QQQQQ": 34846 return localize2.quarter(quarter, { 34847 width: "narrow", 34848 context: "formatting" 34849 }); 34850 // 1st quarter, 2nd quarter, ... 34851 case "QQQQ": 34852 default: 34853 return localize2.quarter(quarter, { 34854 width: "wide", 34855 context: "formatting" 34856 }); 34857 } 34858 }, 34859 // Stand-alone quarter 34860 q: function(date, token, localize2) { 34861 const quarter = Math.ceil((date.getMonth() + 1) / 3); 34862 switch (token) { 34863 // 1, 2, 3, 4 34864 case "q": 34865 return String(quarter); 34866 // 01, 02, 03, 04 34867 case "qq": 34868 return addLeadingZeros(quarter, 2); 34869 // 1st, 2nd, 3rd, 4th 34870 case "qo": 34871 return localize2.ordinalNumber(quarter, { unit: "quarter" }); 34872 // Q1, Q2, Q3, Q4 34873 case "qqq": 34874 return localize2.quarter(quarter, { 34875 width: "abbreviated", 34876 context: "standalone" 34877 }); 34878 // 1, 2, 3, 4 (narrow quarter; could be not numerical) 34879 case "qqqqq": 34880 return localize2.quarter(quarter, { 34881 width: "narrow", 34882 context: "standalone" 34883 }); 34884 // 1st quarter, 2nd quarter, ... 34885 case "qqqq": 34886 default: 34887 return localize2.quarter(quarter, { 34888 width: "wide", 34889 context: "standalone" 34890 }); 34891 } 34892 }, 34893 // Month 34894 M: function(date, token, localize2) { 34895 const month = date.getMonth(); 34896 switch (token) { 34897 case "M": 34898 case "MM": 34899 return lightFormatters.M(date, token); 34900 // 1st, 2nd, ..., 12th 34901 case "Mo": 34902 return localize2.ordinalNumber(month + 1, { unit: "month" }); 34903 // Jan, Feb, ..., Dec 34904 case "MMM": 34905 return localize2.month(month, { 34906 width: "abbreviated", 34907 context: "formatting" 34908 }); 34909 // J, F, ..., D 34910 case "MMMMM": 34911 return localize2.month(month, { 34912 width: "narrow", 34913 context: "formatting" 34914 }); 34915 // January, February, ..., December 34916 case "MMMM": 34917 default: 34918 return localize2.month(month, { width: "wide", context: "formatting" }); 34919 } 34920 }, 34921 // Stand-alone month 34922 L: function(date, token, localize2) { 34923 const month = date.getMonth(); 34924 switch (token) { 34925 // 1, 2, ..., 12 34926 case "L": 34927 return String(month + 1); 34928 // 01, 02, ..., 12 34929 case "LL": 34930 return addLeadingZeros(month + 1, 2); 34931 // 1st, 2nd, ..., 12th 34932 case "Lo": 34933 return localize2.ordinalNumber(month + 1, { unit: "month" }); 34934 // Jan, Feb, ..., Dec 34935 case "LLL": 34936 return localize2.month(month, { 34937 width: "abbreviated", 34938 context: "standalone" 34939 }); 34940 // J, F, ..., D 34941 case "LLLLL": 34942 return localize2.month(month, { 34943 width: "narrow", 34944 context: "standalone" 34945 }); 34946 // January, February, ..., December 34947 case "LLLL": 34948 default: 34949 return localize2.month(month, { width: "wide", context: "standalone" }); 34950 } 34951 }, 34952 // Local week of year 34953 w: function(date, token, localize2, options) { 34954 const week = getWeek(date, options); 34955 if (token === "wo") { 34956 return localize2.ordinalNumber(week, { unit: "week" }); 34957 } 34958 return addLeadingZeros(week, token.length); 34959 }, 34960 // ISO week of year 34961 I: function(date, token, localize2) { 34962 const isoWeek = getISOWeek(date); 34963 if (token === "Io") { 34964 return localize2.ordinalNumber(isoWeek, { unit: "week" }); 34965 } 34966 return addLeadingZeros(isoWeek, token.length); 34967 }, 34968 // Day of the month 34969 d: function(date, token, localize2) { 34970 if (token === "do") { 34971 return localize2.ordinalNumber(date.getDate(), { unit: "date" }); 34972 } 34973 return lightFormatters.d(date, token); 34974 }, 34975 // Day of year 34976 D: function(date, token, localize2) { 34977 const dayOfYear = getDayOfYear(date); 34978 if (token === "Do") { 34979 return localize2.ordinalNumber(dayOfYear, { unit: "dayOfYear" }); 34980 } 34981 return addLeadingZeros(dayOfYear, token.length); 34982 }, 34983 // Day of week 34984 E: function(date, token, localize2) { 34985 const dayOfWeek = date.getDay(); 34986 switch (token) { 34987 // Tue 34988 case "E": 34989 case "EE": 34990 case "EEE": 34991 return localize2.day(dayOfWeek, { 34992 width: "abbreviated", 34993 context: "formatting" 34994 }); 34995 // T 34996 case "EEEEE": 34997 return localize2.day(dayOfWeek, { 34998 width: "narrow", 34999 context: "formatting" 35000 }); 35001 // Tu 35002 case "EEEEEE": 35003 return localize2.day(dayOfWeek, { 35004 width: "short", 35005 context: "formatting" 35006 }); 35007 // Tuesday 35008 case "EEEE": 35009 default: 35010 return localize2.day(dayOfWeek, { 35011 width: "wide", 35012 context: "formatting" 35013 }); 35014 } 35015 }, 35016 // Local day of week 35017 e: function(date, token, localize2, options) { 35018 const dayOfWeek = date.getDay(); 35019 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7; 35020 switch (token) { 35021 // Numerical value (Nth day of week with current locale or weekStartsOn) 35022 case "e": 35023 return String(localDayOfWeek); 35024 // Padded numerical value 35025 case "ee": 35026 return addLeadingZeros(localDayOfWeek, 2); 35027 // 1st, 2nd, ..., 7th 35028 case "eo": 35029 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" }); 35030 case "eee": 35031 return localize2.day(dayOfWeek, { 35032 width: "abbreviated", 35033 context: "formatting" 35034 }); 35035 // T 35036 case "eeeee": 35037 return localize2.day(dayOfWeek, { 35038 width: "narrow", 35039 context: "formatting" 35040 }); 35041 // Tu 35042 case "eeeeee": 35043 return localize2.day(dayOfWeek, { 35044 width: "short", 35045 context: "formatting" 35046 }); 35047 // Tuesday 35048 case "eeee": 35049 default: 35050 return localize2.day(dayOfWeek, { 35051 width: "wide", 35052 context: "formatting" 35053 }); 35054 } 35055 }, 35056 // Stand-alone local day of week 35057 c: function(date, token, localize2, options) { 35058 const dayOfWeek = date.getDay(); 35059 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7; 35060 switch (token) { 35061 // Numerical value (same as in `e`) 35062 case "c": 35063 return String(localDayOfWeek); 35064 // Padded numerical value 35065 case "cc": 35066 return addLeadingZeros(localDayOfWeek, token.length); 35067 // 1st, 2nd, ..., 7th 35068 case "co": 35069 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" }); 35070 case "ccc": 35071 return localize2.day(dayOfWeek, { 35072 width: "abbreviated", 35073 context: "standalone" 35074 }); 35075 // T 35076 case "ccccc": 35077 return localize2.day(dayOfWeek, { 35078 width: "narrow", 35079 context: "standalone" 35080 }); 35081 // Tu 35082 case "cccccc": 35083 return localize2.day(dayOfWeek, { 35084 width: "short", 35085 context: "standalone" 35086 }); 35087 // Tuesday 35088 case "cccc": 35089 default: 35090 return localize2.day(dayOfWeek, { 35091 width: "wide", 35092 context: "standalone" 35093 }); 35094 } 35095 }, 35096 // ISO day of week 35097 i: function(date, token, localize2) { 35098 const dayOfWeek = date.getDay(); 35099 const isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek; 35100 switch (token) { 35101 // 2 35102 case "i": 35103 return String(isoDayOfWeek); 35104 // 02 35105 case "ii": 35106 return addLeadingZeros(isoDayOfWeek, token.length); 35107 // 2nd 35108 case "io": 35109 return localize2.ordinalNumber(isoDayOfWeek, { unit: "day" }); 35110 // Tue 35111 case "iii": 35112 return localize2.day(dayOfWeek, { 35113 width: "abbreviated", 35114 context: "formatting" 35115 }); 35116 // T 35117 case "iiiii": 35118 return localize2.day(dayOfWeek, { 35119 width: "narrow", 35120 context: "formatting" 35121 }); 35122 // Tu 35123 case "iiiiii": 35124 return localize2.day(dayOfWeek, { 35125 width: "short", 35126 context: "formatting" 35127 }); 35128 // Tuesday 35129 case "iiii": 35130 default: 35131 return localize2.day(dayOfWeek, { 35132 width: "wide", 35133 context: "formatting" 35134 }); 35135 } 35136 }, 35137 // AM or PM 35138 a: function(date, token, localize2) { 35139 const hours = date.getHours(); 35140 const dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am"; 35141 switch (token) { 35142 case "a": 35143 case "aa": 35144 return localize2.dayPeriod(dayPeriodEnumValue, { 35145 width: "abbreviated", 35146 context: "formatting" 35147 }); 35148 case "aaa": 35149 return localize2.dayPeriod(dayPeriodEnumValue, { 35150 width: "abbreviated", 35151 context: "formatting" 35152 }).toLowerCase(); 35153 case "aaaaa": 35154 return localize2.dayPeriod(dayPeriodEnumValue, { 35155 width: "narrow", 35156 context: "formatting" 35157 }); 35158 case "aaaa": 35159 default: 35160 return localize2.dayPeriod(dayPeriodEnumValue, { 35161 width: "wide", 35162 context: "formatting" 35163 }); 35164 } 35165 }, 35166 // AM, PM, midnight, noon 35167 b: function(date, token, localize2) { 35168 const hours = date.getHours(); 35169 let dayPeriodEnumValue; 35170 if (hours === 12) { 35171 dayPeriodEnumValue = dayPeriodEnum.noon; 35172 } else if (hours === 0) { 35173 dayPeriodEnumValue = dayPeriodEnum.midnight; 35174 } else { 35175 dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am"; 35176 } 35177 switch (token) { 35178 case "b": 35179 case "bb": 35180 return localize2.dayPeriod(dayPeriodEnumValue, { 35181 width: "abbreviated", 35182 context: "formatting" 35183 }); 35184 case "bbb": 35185 return localize2.dayPeriod(dayPeriodEnumValue, { 35186 width: "abbreviated", 35187 context: "formatting" 35188 }).toLowerCase(); 35189 case "bbbbb": 35190 return localize2.dayPeriod(dayPeriodEnumValue, { 35191 width: "narrow", 35192 context: "formatting" 35193 }); 35194 case "bbbb": 35195 default: 35196 return localize2.dayPeriod(dayPeriodEnumValue, { 35197 width: "wide", 35198 context: "formatting" 35199 }); 35200 } 35201 }, 35202 // in the morning, in the afternoon, in the evening, at night 35203 B: function(date, token, localize2) { 35204 const hours = date.getHours(); 35205 let dayPeriodEnumValue; 35206 if (hours >= 17) { 35207 dayPeriodEnumValue = dayPeriodEnum.evening; 35208 } else if (hours >= 12) { 35209 dayPeriodEnumValue = dayPeriodEnum.afternoon; 35210 } else if (hours >= 4) { 35211 dayPeriodEnumValue = dayPeriodEnum.morning; 35212 } else { 35213 dayPeriodEnumValue = dayPeriodEnum.night; 35214 } 35215 switch (token) { 35216 case "B": 35217 case "BB": 35218 case "BBB": 35219 return localize2.dayPeriod(dayPeriodEnumValue, { 35220 width: "abbreviated", 35221 context: "formatting" 35222 }); 35223 case "BBBBB": 35224 return localize2.dayPeriod(dayPeriodEnumValue, { 35225 width: "narrow", 35226 context: "formatting" 35227 }); 35228 case "BBBB": 35229 default: 35230 return localize2.dayPeriod(dayPeriodEnumValue, { 35231 width: "wide", 35232 context: "formatting" 35233 }); 35234 } 35235 }, 35236 // Hour [1-12] 35237 h: function(date, token, localize2) { 35238 if (token === "ho") { 35239 let hours = date.getHours() % 12; 35240 if (hours === 0) hours = 12; 35241 return localize2.ordinalNumber(hours, { unit: "hour" }); 35242 } 35243 return lightFormatters.h(date, token); 35244 }, 35245 // Hour [0-23] 35246 H: function(date, token, localize2) { 35247 if (token === "Ho") { 35248 return localize2.ordinalNumber(date.getHours(), { unit: "hour" }); 35249 } 35250 return lightFormatters.H(date, token); 35251 }, 35252 // Hour [0-11] 35253 K: function(date, token, localize2) { 35254 const hours = date.getHours() % 12; 35255 if (token === "Ko") { 35256 return localize2.ordinalNumber(hours, { unit: "hour" }); 35257 } 35258 return addLeadingZeros(hours, token.length); 35259 }, 35260 // Hour [1-24] 35261 k: function(date, token, localize2) { 35262 let hours = date.getHours(); 35263 if (hours === 0) hours = 24; 35264 if (token === "ko") { 35265 return localize2.ordinalNumber(hours, { unit: "hour" }); 35266 } 35267 return addLeadingZeros(hours, token.length); 35268 }, 35269 // Minute 35270 m: function(date, token, localize2) { 35271 if (token === "mo") { 35272 return localize2.ordinalNumber(date.getMinutes(), { unit: "minute" }); 35273 } 35274 return lightFormatters.m(date, token); 35275 }, 35276 // Second 35277 s: function(date, token, localize2) { 35278 if (token === "so") { 35279 return localize2.ordinalNumber(date.getSeconds(), { unit: "second" }); 35280 } 35281 return lightFormatters.s(date, token); 35282 }, 35283 // Fraction of second 35284 S: function(date, token) { 35285 return lightFormatters.S(date, token); 35286 }, 35287 // Timezone (ISO-8601. If offset is 0, output is always `'Z'`) 35288 X: function(date, token, _localize) { 35289 const timezoneOffset = date.getTimezoneOffset(); 35290 if (timezoneOffset === 0) { 35291 return "Z"; 35292 } 35293 switch (token) { 35294 // Hours and optional minutes 35295 case "X": 35296 return formatTimezoneWithOptionalMinutes(timezoneOffset); 35297 // Hours, minutes and optional seconds without `:` delimiter 35298 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets 35299 // so this token always has the same output as `XX` 35300 case "XXXX": 35301 case "XX": 35302 return formatTimezone(timezoneOffset); 35303 // Hours, minutes and optional seconds with `:` delimiter 35304 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets 35305 // so this token always has the same output as `XXX` 35306 case "XXXXX": 35307 case "XXX": 35308 // Hours and minutes with `:` delimiter 35309 default: 35310 return formatTimezone(timezoneOffset, ":"); 35311 } 35312 }, 35313 // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent) 35314 x: function(date, token, _localize) { 35315 const timezoneOffset = date.getTimezoneOffset(); 35316 switch (token) { 35317 // Hours and optional minutes 35318 case "x": 35319 return formatTimezoneWithOptionalMinutes(timezoneOffset); 35320 // Hours, minutes and optional seconds without `:` delimiter 35321 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets 35322 // so this token always has the same output as `xx` 35323 case "xxxx": 35324 case "xx": 35325 return formatTimezone(timezoneOffset); 35326 // Hours, minutes and optional seconds with `:` delimiter 35327 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets 35328 // so this token always has the same output as `xxx` 35329 case "xxxxx": 35330 case "xxx": 35331 // Hours and minutes with `:` delimiter 35332 default: 35333 return formatTimezone(timezoneOffset, ":"); 35334 } 35335 }, 35336 // Timezone (GMT) 35337 O: function(date, token, _localize) { 35338 const timezoneOffset = date.getTimezoneOffset(); 35339 switch (token) { 35340 // Short 35341 case "O": 35342 case "OO": 35343 case "OOO": 35344 return "GMT" + formatTimezoneShort(timezoneOffset, ":"); 35345 // Long 35346 case "OOOO": 35347 default: 35348 return "GMT" + formatTimezone(timezoneOffset, ":"); 35349 } 35350 }, 35351 // Timezone (specific non-location) 35352 z: function(date, token, _localize) { 35353 const timezoneOffset = date.getTimezoneOffset(); 35354 switch (token) { 35355 // Short 35356 case "z": 35357 case "zz": 35358 case "zzz": 35359 return "GMT" + formatTimezoneShort(timezoneOffset, ":"); 35360 // Long 35361 case "zzzz": 35362 default: 35363 return "GMT" + formatTimezone(timezoneOffset, ":"); 35364 } 35365 }, 35366 // Seconds timestamp 35367 t: function(date, token, _localize) { 35368 const timestamp = Math.trunc(+date / 1e3); 35369 return addLeadingZeros(timestamp, token.length); 35370 }, 35371 // Milliseconds timestamp 35372 T: function(date, token, _localize) { 35373 return addLeadingZeros(+date, token.length); 35374 } 35375 }; 35376 function formatTimezoneShort(offset, delimiter = "") { 35377 const sign = offset > 0 ? "-" : "+"; 35378 const absOffset = Math.abs(offset); 35379 const hours = Math.trunc(absOffset / 60); 35380 const minutes = absOffset % 60; 35381 if (minutes === 0) { 35382 return sign + String(hours); 35383 } 35384 return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2); 35385 } 35386 function formatTimezoneWithOptionalMinutes(offset, delimiter) { 35387 if (offset % 60 === 0) { 35388 const sign = offset > 0 ? "-" : "+"; 35389 return sign + addLeadingZeros(Math.abs(offset) / 60, 2); 35390 } 35391 return formatTimezone(offset, delimiter); 35392 } 35393 function formatTimezone(offset, delimiter = "") { 35394 const sign = offset > 0 ? "-" : "+"; 35395 const absOffset = Math.abs(offset); 35396 const hours = addLeadingZeros(Math.trunc(absOffset / 60), 2); 35397 const minutes = addLeadingZeros(absOffset % 60, 2); 35398 return sign + hours + delimiter + minutes; 35399 } 35400 35401 // packages/dataviews/node_modules/date-fns/_lib/format/longFormatters.js 35402 var dateLongFormatter = (pattern, formatLong2) => { 35403 switch (pattern) { 35404 case "P": 35405 return formatLong2.date({ width: "short" }); 35406 case "PP": 35407 return formatLong2.date({ width: "medium" }); 35408 case "PPP": 35409 return formatLong2.date({ width: "long" }); 35410 case "PPPP": 35411 default: 35412 return formatLong2.date({ width: "full" }); 35413 } 35414 }; 35415 var timeLongFormatter = (pattern, formatLong2) => { 35416 switch (pattern) { 35417 case "p": 35418 return formatLong2.time({ width: "short" }); 35419 case "pp": 35420 return formatLong2.time({ width: "medium" }); 35421 case "ppp": 35422 return formatLong2.time({ width: "long" }); 35423 case "pppp": 35424 default: 35425 return formatLong2.time({ width: "full" }); 35426 } 35427 }; 35428 var dateTimeLongFormatter = (pattern, formatLong2) => { 35429 const matchResult = pattern.match(/(P+)(p+)?/) || []; 35430 const datePattern = matchResult[1]; 35431 const timePattern = matchResult[2]; 35432 if (!timePattern) { 35433 return dateLongFormatter(pattern, formatLong2); 35434 } 35435 let dateTimeFormat; 35436 switch (datePattern) { 35437 case "P": 35438 dateTimeFormat = formatLong2.dateTime({ width: "short" }); 35439 break; 35440 case "PP": 35441 dateTimeFormat = formatLong2.dateTime({ width: "medium" }); 35442 break; 35443 case "PPP": 35444 dateTimeFormat = formatLong2.dateTime({ width: "long" }); 35445 break; 35446 case "PPPP": 35447 default: 35448 dateTimeFormat = formatLong2.dateTime({ width: "full" }); 35449 break; 35450 } 35451 return dateTimeFormat.replace("{{date}}", dateLongFormatter(datePattern, formatLong2)).replace("{{time}}", timeLongFormatter(timePattern, formatLong2)); 35452 }; 35453 var longFormatters = { 35454 p: timeLongFormatter, 35455 P: dateTimeLongFormatter 35456 }; 35457 35458 // packages/dataviews/node_modules/date-fns/_lib/protectedTokens.js 35459 var dayOfYearTokenRE = /^D+$/; 35460 var weekYearTokenRE = /^Y+$/; 35461 var throwTokens = ["D", "DD", "YY", "YYYY"]; 35462 function isProtectedDayOfYearToken(token) { 35463 return dayOfYearTokenRE.test(token); 35464 } 35465 function isProtectedWeekYearToken(token) { 35466 return weekYearTokenRE.test(token); 35467 } 35468 function warnOrThrowProtectedError(token, format6, input) { 35469 const _message = message(token, format6, input); 35470 console.warn(_message); 35471 if (throwTokens.includes(token)) throw new RangeError(_message); 35472 } 35473 function message(token, format6, input) { 35474 const subject = token[0] === "Y" ? "years" : "days of the month"; 35475 return `Use \`$token.toLowerCase()}\` instead of \`$token}\` (in \`$format6}\`) for formatting $subject} to the input \`$input}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`; 35476 } 35477 35478 // packages/dataviews/node_modules/date-fns/format.js 35479 var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g; 35480 var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g; 35481 var escapedStringRegExp = /^'([^]*?)'?$/; 35482 var doubleQuoteRegExp = /''/g; 35483 var unescapedLatinCharacterRegExp = /[a-zA-Z]/; 35484 function format(date, formatStr, options) { 35485 const defaultOptions2 = getDefaultOptions(); 35486 const locale = options?.locale ?? defaultOptions2.locale ?? enUS; 35487 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1; 35488 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0; 35489 const originalDate = toDate(date, options?.in); 35490 if (!isValid(originalDate)) { 35491 throw new RangeError("Invalid time value"); 35492 } 35493 let parts = formatStr.match(longFormattingTokensRegExp).map((substring) => { 35494 const firstCharacter = substring[0]; 35495 if (firstCharacter === "p" || firstCharacter === "P") { 35496 const longFormatter = longFormatters[firstCharacter]; 35497 return longFormatter(substring, locale.formatLong); 35498 } 35499 return substring; 35500 }).join("").match(formattingTokensRegExp).map((substring) => { 35501 if (substring === "''") { 35502 return { isToken: false, value: "'" }; 35503 } 35504 const firstCharacter = substring[0]; 35505 if (firstCharacter === "'") { 35506 return { isToken: false, value: cleanEscapedString(substring) }; 35507 } 35508 if (formatters[firstCharacter]) { 35509 return { isToken: true, value: substring }; 35510 } 35511 if (firstCharacter.match(unescapedLatinCharacterRegExp)) { 35512 throw new RangeError( 35513 "Format string contains an unescaped latin alphabet character `" + firstCharacter + "`" 35514 ); 35515 } 35516 return { isToken: false, value: substring }; 35517 }); 35518 if (locale.localize.preprocessor) { 35519 parts = locale.localize.preprocessor(originalDate, parts); 35520 } 35521 const formatterOptions = { 35522 firstWeekContainsDate, 35523 weekStartsOn, 35524 locale 35525 }; 35526 return parts.map((part) => { 35527 if (!part.isToken) return part.value; 35528 const token = part.value; 35529 if (!options?.useAdditionalWeekYearTokens && isProtectedWeekYearToken(token) || !options?.useAdditionalDayOfYearTokens && isProtectedDayOfYearToken(token)) { 35530 warnOrThrowProtectedError(token, formatStr, String(date)); 35531 } 35532 const formatter = formatters[token[0]]; 35533 return formatter(originalDate, token, locale.localize, formatterOptions); 35534 }).join(""); 35535 } 35536 function cleanEscapedString(input) { 35537 const matched = input.match(escapedStringRegExp); 35538 if (!matched) { 35539 return input; 35540 } 35541 return matched[1].replace(doubleQuoteRegExp, "'"); 35542 } 35543 35544 // packages/dataviews/node_modules/date-fns/subDays.js 35545 function subDays(date, amount, options) { 35546 return addDays(date, -amount, options); 35547 } 35548 35549 // packages/dataviews/node_modules/date-fns/subMonths.js 35550 function subMonths(date, amount, options) { 35551 return addMonths(date, -amount, options); 35552 } 35553 35554 // packages/dataviews/node_modules/date-fns/subWeeks.js 35555 function subWeeks(date, amount, options) { 35556 return addWeeks(date, -amount, options); 35557 } 35558 35559 // packages/dataviews/node_modules/date-fns/subYears.js 35560 function subYears(date, amount, options) { 35561 return addYears(date, -amount, options); 35562 } 35563 35564 // packages/dataviews/build-module/dataform-controls/datetime.js 35565 var import_components125 = __toESM(require_components()); 35566 var import_element102 = __toESM(require_element()); 35567 var import_i18n114 = __toESM(require_i18n()); 35568 var import_date3 = __toESM(require_date()); 35569 35570 // packages/dataviews/build-module/dataform-controls/utils/relative-date-control.js 35571 var import_components124 = __toESM(require_components()); 35572 var import_element101 = __toESM(require_element()); 35573 var import_i18n113 = __toESM(require_i18n()); 35574 var import_jsx_runtime229 = __toESM(require_jsx_runtime()); 35575 var TIME_UNITS_OPTIONS = { 35576 [OPERATOR_IN_THE_PAST]: [ 35577 { value: "days", label: (0, import_i18n113.__)("Days") }, 35578 { value: "weeks", label: (0, import_i18n113.__)("Weeks") }, 35579 { value: "months", label: (0, import_i18n113.__)("Months") }, 35580 { value: "years", label: (0, import_i18n113.__)("Years") } 35581 ], 35582 [OPERATOR_OVER]: [ 35583 { value: "days", label: (0, import_i18n113.__)("Days ago") }, 35584 { value: "weeks", label: (0, import_i18n113.__)("Weeks ago") }, 35585 { value: "months", label: (0, import_i18n113.__)("Months ago") }, 35586 { value: "years", label: (0, import_i18n113.__)("Years ago") } 35587 ] 35588 }; 35589 function RelativeDateControl({ 35590 className, 35591 data, 35592 field, 35593 onChange, 35594 hideLabelFromVision, 35595 operator 35596 }) { 35597 const options = TIME_UNITS_OPTIONS[operator === OPERATOR_IN_THE_PAST ? "inThePast" : "over"]; 35598 const { id, label, getValue, setValue } = field; 35599 const fieldValue = getValue({ item: data }); 35600 const { value: relValue = "", unit = options[0].value } = fieldValue && typeof fieldValue === "object" ? fieldValue : {}; 35601 const onChangeValue = (0, import_element101.useCallback)( 35602 (newValue) => onChange( 35603 setValue({ 35604 item: data, 35605 value: { value: Number(newValue), unit } 35606 }) 35607 ), 35608 [onChange, setValue, data, unit] 35609 ); 35610 const onChangeUnit = (0, import_element101.useCallback)( 35611 (newUnit) => onChange( 35612 setValue({ 35613 item: data, 35614 value: { value: relValue, unit: newUnit } 35615 }) 35616 ), 35617 [onChange, setValue, data, relValue] 35618 ); 35619 return /* @__PURE__ */ (0, import_jsx_runtime229.jsx)( 35620 import_components124.BaseControl, 35621 { 35622 id, 35623 className: clsx_default(className, "dataviews-controls__relative-date"), 35624 label, 35625 hideLabelFromVision, 35626 children: /* @__PURE__ */ (0, import_jsx_runtime229.jsxs)(import_components124.__experimentalHStack, { spacing: 2.5, children: [ 35627 /* @__PURE__ */ (0, import_jsx_runtime229.jsx)( 35628 import_components124.__experimentalNumberControl, 35629 { 35630 __next40pxDefaultSize: true, 35631 className: "dataviews-controls__relative-date-number", 35632 spinControls: "none", 35633 min: 1, 35634 step: 1, 35635 value: relValue, 35636 onChange: onChangeValue 35637 } 35638 ), 35639 /* @__PURE__ */ (0, import_jsx_runtime229.jsx)( 35640 import_components124.SelectControl, 35641 { 35642 className: "dataviews-controls__relative-date-unit", 35643 __next40pxDefaultSize: true, 35644 label: (0, import_i18n113.__)("Unit"), 35645 value: unit, 35646 options, 35647 onChange: onChangeUnit, 35648 hideLabelFromVision: true 35649 } 35650 ) 35651 ] }) 35652 } 35653 ); 35654 } 35655 35656 // packages/dataviews/build-module/field-types/utils/parse-date-time.js 35657 var import_date2 = __toESM(require_date()); 35658 function parseDateTime(dateTimeString) { 35659 if (!dateTimeString) { 35660 return null; 35661 } 35662 const parsed = (0, import_date2.getDate)(dateTimeString); 35663 return parsed && isValid(parsed) ? parsed : null; 35664 } 35665 35666 // packages/dataviews/build-module/dataform-controls/datetime.js 35667 var import_jsx_runtime230 = __toESM(require_jsx_runtime()); 35668 var { DateCalendar, ValidatedInputControl } = unlock3(import_components125.privateApis); 35669 var formatDateTime = (date) => { 35670 if (!date) { 35671 return ""; 35672 } 35673 if (typeof date === "string") { 35674 return date; 35675 } 35676 return format(date, "yyyy-MM-dd'T'HH:mm"); 35677 }; 35678 function CalendarDateTimeControl({ 35679 data, 35680 field, 35681 onChange, 35682 hideLabelFromVision, 35683 validity 35684 }) { 35685 const { id, label, description, setValue, getValue, isValid: isValid2 } = field; 35686 const fieldValue = getValue({ item: data }); 35687 const value = typeof fieldValue === "string" ? fieldValue : void 0; 35688 const [calendarMonth, setCalendarMonth] = (0, import_element102.useState)(() => { 35689 const parsedDate = parseDateTime(value); 35690 return parsedDate || /* @__PURE__ */ new Date(); 35691 }); 35692 const inputControlRef = (0, import_element102.useRef)(null); 35693 const validationTimeoutRef = (0, import_element102.useRef)(); 35694 const previousFocusRef = (0, import_element102.useRef)(null); 35695 const onChangeCallback = (0, import_element102.useCallback)( 35696 (newValue) => onChange(setValue({ item: data, value: newValue })), 35697 [data, onChange, setValue] 35698 ); 35699 (0, import_element102.useEffect)(() => { 35700 return () => { 35701 if (validationTimeoutRef.current) { 35702 clearTimeout(validationTimeoutRef.current); 35703 } 35704 }; 35705 }, []); 35706 const onSelectDate = (0, import_element102.useCallback)( 35707 (newDate) => { 35708 let dateTimeValue; 35709 if (newDate) { 35710 let finalDateTime = newDate; 35711 if (value) { 35712 const currentDateTime = parseDateTime(value); 35713 if (currentDateTime) { 35714 finalDateTime = new Date(newDate); 35715 finalDateTime.setHours(currentDateTime.getHours()); 35716 finalDateTime.setMinutes( 35717 currentDateTime.getMinutes() 35718 ); 35719 } 35720 } 35721 dateTimeValue = finalDateTime.toISOString(); 35722 onChangeCallback(dateTimeValue); 35723 if (validationTimeoutRef.current) { 35724 clearTimeout(validationTimeoutRef.current); 35725 } 35726 } else { 35727 onChangeCallback(void 0); 35728 } 35729 previousFocusRef.current = inputControlRef.current && inputControlRef.current.ownerDocument.activeElement; 35730 validationTimeoutRef.current = setTimeout(() => { 35731 if (inputControlRef.current) { 35732 inputControlRef.current.focus(); 35733 inputControlRef.current.blur(); 35734 onChangeCallback(dateTimeValue); 35735 if (previousFocusRef.current && previousFocusRef.current instanceof HTMLElement) { 35736 previousFocusRef.current.focus(); 35737 } 35738 } 35739 }, 0); 35740 }, 35741 [onChangeCallback, value] 35742 ); 35743 const handleManualDateTimeChange = (0, import_element102.useCallback)( 35744 (newValue) => { 35745 if (newValue) { 35746 const dateTime = new Date(newValue); 35747 onChangeCallback(dateTime.toISOString()); 35748 const parsedDate = parseDateTime(dateTime.toISOString()); 35749 if (parsedDate) { 35750 setCalendarMonth(parsedDate); 35751 } 35752 } else { 35753 onChangeCallback(void 0); 35754 } 35755 }, 35756 [onChangeCallback] 35757 ); 35758 const { format: fieldFormat } = field; 35759 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date3.getSettings)().l10n.startOfWeek; 35760 const { 35761 timezone: { string: timezoneString } 35762 } = (0, import_date3.getSettings)(); 35763 const displayLabel = isValid2?.required && !hideLabelFromVision ? `$label} (${(0, import_i18n114.__)("Required")})` : label; 35764 return /* @__PURE__ */ (0, import_jsx_runtime230.jsx)( 35765 import_components125.BaseControl, 35766 { 35767 id, 35768 label: displayLabel, 35769 help: description, 35770 hideLabelFromVision, 35771 children: /* @__PURE__ */ (0, import_jsx_runtime230.jsxs)(import_components125.__experimentalVStack, { spacing: 4, children: [ 35772 /* @__PURE__ */ (0, import_jsx_runtime230.jsx)( 35773 DateCalendar, 35774 { 35775 style: { width: "100%" }, 35776 selected: value ? parseDateTime(value) || void 0 : void 0, 35777 onSelect: onSelectDate, 35778 month: calendarMonth, 35779 onMonthChange: setCalendarMonth, 35780 timeZone: timezoneString || void 0, 35781 weekStartsOn 35782 } 35783 ), 35784 /* @__PURE__ */ (0, import_jsx_runtime230.jsx)( 35785 ValidatedInputControl, 35786 { 35787 ref: inputControlRef, 35788 __next40pxDefaultSize: true, 35789 required: !!isValid2?.required, 35790 customValidity: getCustomValidity(isValid2, validity), 35791 type: "datetime-local", 35792 label: (0, import_i18n114.__)("Date time"), 35793 hideLabelFromVision: true, 35794 value: value ? formatDateTime( 35795 parseDateTime(value) || void 0 35796 ) : "", 35797 onChange: handleManualDateTimeChange 35798 } 35799 ) 35800 ] }) 35801 } 35802 ); 35803 } 35804 function DateTime({ 35805 data, 35806 field, 35807 onChange, 35808 hideLabelFromVision, 35809 operator, 35810 validity 35811 }) { 35812 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) { 35813 return /* @__PURE__ */ (0, import_jsx_runtime230.jsx)( 35814 RelativeDateControl, 35815 { 35816 className: "dataviews-controls__datetime", 35817 data, 35818 field, 35819 onChange, 35820 hideLabelFromVision, 35821 operator 35822 } 35823 ); 35824 } 35825 return /* @__PURE__ */ (0, import_jsx_runtime230.jsx)( 35826 CalendarDateTimeControl, 35827 { 35828 data, 35829 field, 35830 onChange, 35831 hideLabelFromVision, 35832 validity 35833 } 35834 ); 35835 } 35836 35837 // packages/dataviews/build-module/dataform-controls/date.js 35838 var import_components126 = __toESM(require_components()); 35839 var import_element103 = __toESM(require_element()); 35840 var import_i18n115 = __toESM(require_i18n()); 35841 var import_date4 = __toESM(require_date()); 35842 var import_jsx_runtime231 = __toESM(require_jsx_runtime()); 35843 var { DateCalendar: DateCalendar2, DateRangeCalendar } = unlock3(import_components126.privateApis); 35844 var DATE_PRESETS = [ 35845 { 35846 id: "today", 35847 label: (0, import_i18n115.__)("Today"), 35848 getValue: () => (0, import_date4.getDate)(null) 35849 }, 35850 { 35851 id: "yesterday", 35852 label: (0, import_i18n115.__)("Yesterday"), 35853 getValue: () => { 35854 const today = (0, import_date4.getDate)(null); 35855 return subDays(today, 1); 35856 } 35857 }, 35858 { 35859 id: "past-week", 35860 label: (0, import_i18n115.__)("Past week"), 35861 getValue: () => { 35862 const today = (0, import_date4.getDate)(null); 35863 return subDays(today, 7); 35864 } 35865 }, 35866 { 35867 id: "past-month", 35868 label: (0, import_i18n115.__)("Past month"), 35869 getValue: () => { 35870 const today = (0, import_date4.getDate)(null); 35871 return subMonths(today, 1); 35872 } 35873 } 35874 ]; 35875 var DATE_RANGE_PRESETS = [ 35876 { 35877 id: "last-7-days", 35878 label: (0, import_i18n115.__)("Last 7 days"), 35879 getValue: () => { 35880 const today = (0, import_date4.getDate)(null); 35881 return [subDays(today, 7), today]; 35882 } 35883 }, 35884 { 35885 id: "last-30-days", 35886 label: (0, import_i18n115.__)("Last 30 days"), 35887 getValue: () => { 35888 const today = (0, import_date4.getDate)(null); 35889 return [subDays(today, 30), today]; 35890 } 35891 }, 35892 { 35893 id: "month-to-date", 35894 label: (0, import_i18n115.__)("Month to date"), 35895 getValue: () => { 35896 const today = (0, import_date4.getDate)(null); 35897 return [startOfMonth(today), today]; 35898 } 35899 }, 35900 { 35901 id: "last-year", 35902 label: (0, import_i18n115.__)("Last year"), 35903 getValue: () => { 35904 const today = (0, import_date4.getDate)(null); 35905 return [subYears(today, 1), today]; 35906 } 35907 }, 35908 { 35909 id: "year-to-date", 35910 label: (0, import_i18n115.__)("Year to date"), 35911 getValue: () => { 35912 const today = (0, import_date4.getDate)(null); 35913 return [startOfYear(today), today]; 35914 } 35915 } 35916 ]; 35917 var parseDate = (dateString) => { 35918 if (!dateString) { 35919 return null; 35920 } 35921 const parsed = (0, import_date4.getDate)(dateString); 35922 return parsed && isValid(parsed) ? parsed : null; 35923 }; 35924 var formatDate = (date) => { 35925 if (!date) { 35926 return ""; 35927 } 35928 return typeof date === "string" ? date : format(date, "yyyy-MM-dd"); 35929 }; 35930 function ValidatedDateControl({ 35931 field, 35932 validity, 35933 inputRefs, 35934 isTouched, 35935 setIsTouched, 35936 children 35937 }) { 35938 const { isValid: isValid2 } = field; 35939 const [customValidity, setCustomValidity] = (0, import_element103.useState)(void 0); 35940 const validateRefs = (0, import_element103.useCallback)(() => { 35941 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs]; 35942 for (const ref of refs) { 35943 const input = ref.current; 35944 if (input && !input.validity.valid) { 35945 setCustomValidity({ 35946 type: "invalid", 35947 message: input.validationMessage 35948 }); 35949 return; 35950 } 35951 } 35952 setCustomValidity(void 0); 35953 }, [inputRefs]); 35954 (0, import_element103.useEffect)(() => { 35955 if (isTouched) { 35956 const timeoutId = setTimeout(() => { 35957 if (validity) { 35958 setCustomValidity(getCustomValidity(isValid2, validity)); 35959 } else { 35960 validateRefs(); 35961 } 35962 }, 0); 35963 return () => clearTimeout(timeoutId); 35964 } 35965 return void 0; 35966 }, [isTouched, isValid2, validity, validateRefs]); 35967 const onBlur = (event) => { 35968 if (isTouched) { 35969 return; 35970 } 35971 if (!event.relatedTarget || !event.currentTarget.contains(event.relatedTarget)) { 35972 setIsTouched(true); 35973 } 35974 }; 35975 return /* @__PURE__ */ (0, import_jsx_runtime231.jsxs)("div", { onBlur, children: [ 35976 children, 35977 /* @__PURE__ */ (0, import_jsx_runtime231.jsx)("div", { "aria-live": "polite", children: customValidity && /* @__PURE__ */ (0, import_jsx_runtime231.jsxs)( 35978 "p", 35979 { 35980 className: clsx_default( 35981 "components-validated-control__indicator", 35982 customValidity.type === "invalid" ? "is-invalid" : void 0, 35983 customValidity.type === "valid" ? "is-valid" : void 0 35984 ), 35985 children: [ 35986 /* @__PURE__ */ (0, import_jsx_runtime231.jsx)( 35987 import_components126.Icon, 35988 { 35989 className: "components-validated-control__indicator-icon", 35990 icon: error_default, 35991 size: 16, 35992 fill: "currentColor" 35993 } 35994 ), 35995 customValidity.message 35996 ] 35997 } 35998 ) }) 35999 ] }); 36000 } 36001 function CalendarDateControl({ 36002 data, 36003 field, 36004 onChange, 36005 hideLabelFromVision, 36006 validity 36007 }) { 36008 const { 36009 id, 36010 label, 36011 setValue, 36012 getValue, 36013 isValid: isValid2, 36014 format: fieldFormat 36015 } = field; 36016 const [selectedPresetId, setSelectedPresetId] = (0, import_element103.useState)( 36017 null 36018 ); 36019 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek; 36020 const fieldValue = getValue({ item: data }); 36021 const value = typeof fieldValue === "string" ? fieldValue : void 0; 36022 const [calendarMonth, setCalendarMonth] = (0, import_element103.useState)(() => { 36023 const parsedDate = parseDate(value); 36024 return parsedDate || /* @__PURE__ */ new Date(); 36025 }); 36026 const [isTouched, setIsTouched] = (0, import_element103.useState)(false); 36027 const validityTargetRef = (0, import_element103.useRef)(null); 36028 const onChangeCallback = (0, import_element103.useCallback)( 36029 (newValue) => onChange(setValue({ item: data, value: newValue })), 36030 [data, onChange, setValue] 36031 ); 36032 const onSelectDate = (0, import_element103.useCallback)( 36033 (newDate) => { 36034 const dateValue = newDate ? format(newDate, "yyyy-MM-dd") : void 0; 36035 onChangeCallback(dateValue); 36036 setSelectedPresetId(null); 36037 setIsTouched(true); 36038 }, 36039 [onChangeCallback] 36040 ); 36041 const handlePresetClick = (0, import_element103.useCallback)( 36042 (preset) => { 36043 const presetDate = preset.getValue(); 36044 const dateValue = formatDate(presetDate); 36045 setCalendarMonth(presetDate); 36046 onChangeCallback(dateValue); 36047 setSelectedPresetId(preset.id); 36048 setIsTouched(true); 36049 }, 36050 [onChangeCallback] 36051 ); 36052 const handleManualDateChange = (0, import_element103.useCallback)( 36053 (newValue) => { 36054 onChangeCallback(newValue); 36055 if (newValue) { 36056 const parsedDate = parseDate(newValue); 36057 if (parsedDate) { 36058 setCalendarMonth(parsedDate); 36059 } 36060 } 36061 setSelectedPresetId(null); 36062 setIsTouched(true); 36063 }, 36064 [onChangeCallback] 36065 ); 36066 const { 36067 timezone: { string: timezoneString } 36068 } = (0, import_date4.getSettings)(); 36069 const displayLabel = isValid2?.required ? `$label} (${(0, import_i18n115.__)("Required")})` : label; 36070 return /* @__PURE__ */ (0, import_jsx_runtime231.jsx)( 36071 ValidatedDateControl, 36072 { 36073 field, 36074 validity, 36075 inputRefs: validityTargetRef, 36076 isTouched, 36077 setIsTouched, 36078 children: /* @__PURE__ */ (0, import_jsx_runtime231.jsx)( 36079 import_components126.BaseControl, 36080 { 36081 id, 36082 className: "dataviews-controls__date", 36083 label: displayLabel, 36084 hideLabelFromVision, 36085 children: /* @__PURE__ */ (0, import_jsx_runtime231.jsxs)(import_components126.__experimentalVStack, { spacing: 4, children: [ 36086 /* @__PURE__ */ (0, import_jsx_runtime231.jsxs)(import_components126.__experimentalHStack, { spacing: 2, wrap: true, justify: "flex-start", children: [ 36087 DATE_PRESETS.map((preset) => { 36088 const isSelected2 = selectedPresetId === preset.id; 36089 return /* @__PURE__ */ (0, import_jsx_runtime231.jsx)( 36090 import_components126.Button, 36091 { 36092 className: "dataviews-controls__date-preset", 36093 variant: "tertiary", 36094 isPressed: isSelected2, 36095 size: "small", 36096 onClick: () => handlePresetClick(preset), 36097 children: preset.label 36098 }, 36099 preset.id 36100 ); 36101 }), 36102 /* @__PURE__ */ (0, import_jsx_runtime231.jsx)( 36103 import_components126.Button, 36104 { 36105 className: "dataviews-controls__date-preset", 36106 variant: "tertiary", 36107 isPressed: !selectedPresetId, 36108 size: "small", 36109 disabled: !!selectedPresetId, 36110 accessibleWhenDisabled: false, 36111 children: (0, import_i18n115.__)("Custom") 36112 } 36113 ) 36114 ] }), 36115 /* @__PURE__ */ (0, import_jsx_runtime231.jsx)( 36116 import_components126.__experimentalInputControl, 36117 { 36118 __next40pxDefaultSize: true, 36119 ref: validityTargetRef, 36120 type: "date", 36121 label: (0, import_i18n115.__)("Date"), 36122 hideLabelFromVision: true, 36123 value, 36124 onChange: handleManualDateChange, 36125 required: !!field.isValid?.required 36126 } 36127 ), 36128 /* @__PURE__ */ (0, import_jsx_runtime231.jsx)( 36129 DateCalendar2, 36130 { 36131 style: { width: "100%" }, 36132 selected: value ? parseDate(value) || void 0 : void 0, 36133 onSelect: onSelectDate, 36134 month: calendarMonth, 36135 onMonthChange: setCalendarMonth, 36136 timeZone: timezoneString || void 0, 36137 weekStartsOn 36138 } 36139 ) 36140 ] }) 36141 } 36142 ) 36143 } 36144 ); 36145 } 36146 function CalendarDateRangeControl({ 36147 data, 36148 field, 36149 onChange, 36150 hideLabelFromVision, 36151 validity 36152 }) { 36153 const { id, label, getValue, setValue, format: fieldFormat } = field; 36154 let value; 36155 const fieldValue = getValue({ item: data }); 36156 if (Array.isArray(fieldValue) && fieldValue.length === 2 && fieldValue.every((date) => typeof date === "string")) { 36157 value = fieldValue; 36158 } 36159 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek; 36160 const onChangeCallback = (0, import_element103.useCallback)( 36161 (newValue) => { 36162 onChange( 36163 setValue({ 36164 item: data, 36165 value: newValue 36166 }) 36167 ); 36168 }, 36169 [data, onChange, setValue] 36170 ); 36171 const [selectedPresetId, setSelectedPresetId] = (0, import_element103.useState)( 36172 null 36173 ); 36174 const selectedRange = (0, import_element103.useMemo)(() => { 36175 if (!value) { 36176 return { from: void 0, to: void 0 }; 36177 } 36178 const [from, to2] = value; 36179 return { 36180 from: parseDate(from) || void 0, 36181 to: parseDate(to2) || void 0 36182 }; 36183 }, [value]); 36184 const [calendarMonth, setCalendarMonth] = (0, import_element103.useState)(() => { 36185 return selectedRange.from || /* @__PURE__ */ new Date(); 36186 }); 36187 const [isTouched, setIsTouched] = (0, import_element103.useState)(false); 36188 const fromInputRef = (0, import_element103.useRef)(null); 36189 const toInputRef = (0, import_element103.useRef)(null); 36190 const updateDateRange = (0, import_element103.useCallback)( 36191 (fromDate, toDate2) => { 36192 if (fromDate && toDate2) { 36193 onChangeCallback([ 36194 formatDate(fromDate), 36195 formatDate(toDate2) 36196 ]); 36197 } else if (!fromDate && !toDate2) { 36198 onChangeCallback(void 0); 36199 } 36200 }, 36201 [onChangeCallback] 36202 ); 36203 const onSelectCalendarRange = (0, import_element103.useCallback)( 36204 (newRange) => { 36205 updateDateRange(newRange?.from, newRange?.to); 36206 setSelectedPresetId(null); 36207 setIsTouched(true); 36208 }, 36209 [updateDateRange] 36210 ); 36211 const handlePresetClick = (0, import_element103.useCallback)( 36212 (preset) => { 36213 const [startDate2, endDate] = preset.getValue(); 36214 setCalendarMonth(startDate2); 36215 updateDateRange(startDate2, endDate); 36216 setSelectedPresetId(preset.id); 36217 setIsTouched(true); 36218 }, 36219 [updateDateRange] 36220 ); 36221 const handleManualDateChange = (0, import_element103.useCallback)( 36222 (fromOrTo, newValue) => { 36223 const [currentFrom, currentTo] = value || [ 36224 void 0, 36225 void 0 36226 ]; 36227 const updatedFrom = fromOrTo === "from" ? newValue : currentFrom; 36228 const updatedTo = fromOrTo === "to" ? newValue : currentTo; 36229 updateDateRange(updatedFrom, updatedTo); 36230 if (newValue) { 36231 const parsedDate = parseDate(newValue); 36232 if (parsedDate) { 36233 setCalendarMonth(parsedDate); 36234 } 36235 } 36236 setSelectedPresetId(null); 36237 setIsTouched(true); 36238 }, 36239 [value, updateDateRange] 36240 ); 36241 const { timezone } = (0, import_date4.getSettings)(); 36242 const displayLabel = field.isValid?.required ? `$label} (${(0, import_i18n115.__)("Required")})` : label; 36243 return /* @__PURE__ */ (0, import_jsx_runtime231.jsx)( 36244 ValidatedDateControl, 36245 { 36246 field, 36247 validity, 36248 inputRefs: [fromInputRef, toInputRef], 36249 isTouched, 36250 setIsTouched, 36251 children: /* @__PURE__ */ (0, import_jsx_runtime231.jsx)( 36252 import_components126.BaseControl, 36253 { 36254 id, 36255 className: "dataviews-controls__date", 36256 label: displayLabel, 36257 hideLabelFromVision, 36258 children: /* @__PURE__ */ (0, import_jsx_runtime231.jsxs)(import_components126.__experimentalVStack, { spacing: 4, children: [ 36259 /* @__PURE__ */ (0, import_jsx_runtime231.jsxs)(import_components126.__experimentalHStack, { spacing: 2, wrap: true, justify: "flex-start", children: [ 36260 DATE_RANGE_PRESETS.map((preset) => { 36261 const isSelected2 = selectedPresetId === preset.id; 36262 return /* @__PURE__ */ (0, import_jsx_runtime231.jsx)( 36263 import_components126.Button, 36264 { 36265 className: "dataviews-controls__date-preset", 36266 variant: "tertiary", 36267 isPressed: isSelected2, 36268 size: "small", 36269 onClick: () => handlePresetClick(preset), 36270 children: preset.label 36271 }, 36272 preset.id 36273 ); 36274 }), 36275 /* @__PURE__ */ (0, import_jsx_runtime231.jsx)( 36276 import_components126.Button, 36277 { 36278 className: "dataviews-controls__date-preset", 36279 variant: "tertiary", 36280 isPressed: !selectedPresetId, 36281 size: "small", 36282 accessibleWhenDisabled: false, 36283 disabled: !!selectedPresetId, 36284 children: (0, import_i18n115.__)("Custom") 36285 } 36286 ) 36287 ] }), 36288 /* @__PURE__ */ (0, import_jsx_runtime231.jsxs)(import_components126.__experimentalHStack, { spacing: 2, children: [ 36289 /* @__PURE__ */ (0, import_jsx_runtime231.jsx)( 36290 import_components126.__experimentalInputControl, 36291 { 36292 __next40pxDefaultSize: true, 36293 ref: fromInputRef, 36294 type: "date", 36295 label: (0, import_i18n115.__)("From"), 36296 hideLabelFromVision: true, 36297 value: value?.[0], 36298 onChange: (newValue) => handleManualDateChange("from", newValue), 36299 required: !!field.isValid?.required 36300 } 36301 ), 36302 /* @__PURE__ */ (0, import_jsx_runtime231.jsx)( 36303 import_components126.__experimentalInputControl, 36304 { 36305 __next40pxDefaultSize: true, 36306 ref: toInputRef, 36307 type: "date", 36308 label: (0, import_i18n115.__)("To"), 36309 hideLabelFromVision: true, 36310 value: value?.[1], 36311 onChange: (newValue) => handleManualDateChange("to", newValue), 36312 required: !!field.isValid?.required 36313 } 36314 ) 36315 ] }), 36316 /* @__PURE__ */ (0, import_jsx_runtime231.jsx)( 36317 DateRangeCalendar, 36318 { 36319 style: { width: "100%" }, 36320 selected: selectedRange, 36321 onSelect: onSelectCalendarRange, 36322 month: calendarMonth, 36323 onMonthChange: setCalendarMonth, 36324 timeZone: timezone.string || void 0, 36325 weekStartsOn 36326 } 36327 ) 36328 ] }) 36329 } 36330 ) 36331 } 36332 ); 36333 } 36334 function DateControl({ 36335 data, 36336 field, 36337 onChange, 36338 hideLabelFromVision, 36339 operator, 36340 validity 36341 }) { 36342 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) { 36343 return /* @__PURE__ */ (0, import_jsx_runtime231.jsx)( 36344 RelativeDateControl, 36345 { 36346 className: "dataviews-controls__date", 36347 data, 36348 field, 36349 onChange, 36350 hideLabelFromVision, 36351 operator 36352 } 36353 ); 36354 } 36355 if (operator === OPERATOR_BETWEEN) { 36356 return /* @__PURE__ */ (0, import_jsx_runtime231.jsx)( 36357 CalendarDateRangeControl, 36358 { 36359 data, 36360 field, 36361 onChange, 36362 hideLabelFromVision, 36363 validity 36364 } 36365 ); 36366 } 36367 return /* @__PURE__ */ (0, import_jsx_runtime231.jsx)( 36368 CalendarDateControl, 36369 { 36370 data, 36371 field, 36372 onChange, 36373 hideLabelFromVision, 36374 validity 36375 } 36376 ); 36377 } 36378 36379 // packages/dataviews/build-module/dataform-controls/email.js 36380 var import_components128 = __toESM(require_components()); 36381 36382 // packages/dataviews/build-module/dataform-controls/utils/validated-input.js 36383 var import_components127 = __toESM(require_components()); 36384 var import_element104 = __toESM(require_element()); 36385 var import_jsx_runtime232 = __toESM(require_jsx_runtime()); 36386 var { ValidatedInputControl: ValidatedInputControl2 } = unlock3(import_components127.privateApis); 36387 function ValidatedText({ 36388 data, 36389 field, 36390 onChange, 36391 hideLabelFromVision, 36392 type, 36393 prefix: prefix2, 36394 suffix, 36395 validity 36396 }) { 36397 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field; 36398 const value = getValue({ item: data }); 36399 const onChangeControl = (0, import_element104.useCallback)( 36400 (newValue) => onChange( 36401 setValue({ 36402 item: data, 36403 value: newValue 36404 }) 36405 ), 36406 [data, setValue, onChange] 36407 ); 36408 return /* @__PURE__ */ (0, import_jsx_runtime232.jsx)( 36409 ValidatedInputControl2, 36410 { 36411 required: !!isValid2.required, 36412 customValidity: getCustomValidity(isValid2, validity), 36413 label, 36414 placeholder, 36415 value: value ?? "", 36416 help: description, 36417 onChange: onChangeControl, 36418 hideLabelFromVision, 36419 type, 36420 prefix: prefix2, 36421 suffix, 36422 pattern: isValid2.pattern ? isValid2.pattern.constraint : void 0, 36423 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0, 36424 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0, 36425 __next40pxDefaultSize: true 36426 } 36427 ); 36428 } 36429 36430 // packages/dataviews/build-module/dataform-controls/email.js 36431 var import_jsx_runtime233 = __toESM(require_jsx_runtime()); 36432 function Email({ 36433 data, 36434 field, 36435 onChange, 36436 hideLabelFromVision, 36437 validity 36438 }) { 36439 return /* @__PURE__ */ (0, import_jsx_runtime233.jsx)( 36440 ValidatedText, 36441 { 36442 ...{ 36443 data, 36444 field, 36445 onChange, 36446 hideLabelFromVision, 36447 validity, 36448 type: "email", 36449 prefix: /* @__PURE__ */ (0, import_jsx_runtime233.jsx)(import_components128.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime233.jsx)(import_components128.Icon, { icon: envelope_default }) }) 36450 } 36451 } 36452 ); 36453 } 36454 36455 // packages/dataviews/build-module/dataform-controls/telephone.js 36456 var import_components129 = __toESM(require_components()); 36457 var import_jsx_runtime234 = __toESM(require_jsx_runtime()); 36458 function Telephone({ 36459 data, 36460 field, 36461 onChange, 36462 hideLabelFromVision, 36463 validity 36464 }) { 36465 return /* @__PURE__ */ (0, import_jsx_runtime234.jsx)( 36466 ValidatedText, 36467 { 36468 ...{ 36469 data, 36470 field, 36471 onChange, 36472 hideLabelFromVision, 36473 validity, 36474 type: "tel", 36475 prefix: /* @__PURE__ */ (0, import_jsx_runtime234.jsx)(import_components129.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime234.jsx)(import_components129.Icon, { icon: mobile_default }) }) 36476 } 36477 } 36478 ); 36479 } 36480 36481 // packages/dataviews/build-module/dataform-controls/url.js 36482 var import_components130 = __toESM(require_components()); 36483 var import_jsx_runtime235 = __toESM(require_jsx_runtime()); 36484 function Url({ 36485 data, 36486 field, 36487 onChange, 36488 hideLabelFromVision, 36489 validity 36490 }) { 36491 return /* @__PURE__ */ (0, import_jsx_runtime235.jsx)( 36492 ValidatedText, 36493 { 36494 ...{ 36495 data, 36496 field, 36497 onChange, 36498 hideLabelFromVision, 36499 validity, 36500 type: "url", 36501 prefix: /* @__PURE__ */ (0, import_jsx_runtime235.jsx)(import_components130.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime235.jsx)(import_components130.Icon, { icon: link_default }) }) 36502 } 36503 } 36504 ); 36505 } 36506 36507 // packages/dataviews/build-module/dataform-controls/utils/validated-number.js 36508 var import_components131 = __toESM(require_components()); 36509 var import_element105 = __toESM(require_element()); 36510 var import_i18n116 = __toESM(require_i18n()); 36511 var import_jsx_runtime236 = __toESM(require_jsx_runtime()); 36512 var { ValidatedNumberControl } = unlock3(import_components131.privateApis); 36513 function toNumberOrEmpty(value) { 36514 if (value === "" || value === void 0) { 36515 return ""; 36516 } 36517 const number = Number(value); 36518 return Number.isFinite(number) ? number : ""; 36519 } 36520 function BetweenControls({ 36521 value, 36522 onChange, 36523 hideLabelFromVision, 36524 step 36525 }) { 36526 const [min = "", max = ""] = value; 36527 const onChangeMin = (0, import_element105.useCallback)( 36528 (newValue) => onChange([toNumberOrEmpty(newValue), max]), 36529 [onChange, max] 36530 ); 36531 const onChangeMax = (0, import_element105.useCallback)( 36532 (newValue) => onChange([min, toNumberOrEmpty(newValue)]), 36533 [onChange, min] 36534 ); 36535 return /* @__PURE__ */ (0, import_jsx_runtime236.jsx)( 36536 import_components131.BaseControl, 36537 { 36538 help: (0, import_i18n116.__)("The max. value must be greater than the min. value."), 36539 children: /* @__PURE__ */ (0, import_jsx_runtime236.jsxs)(import_components131.Flex, { direction: "row", gap: 4, children: [ 36540 /* @__PURE__ */ (0, import_jsx_runtime236.jsx)( 36541 import_components131.__experimentalNumberControl, 36542 { 36543 label: (0, import_i18n116.__)("Min."), 36544 value: min, 36545 max: max ? Number(max) - step : void 0, 36546 onChange: onChangeMin, 36547 __next40pxDefaultSize: true, 36548 hideLabelFromVision, 36549 step 36550 } 36551 ), 36552 /* @__PURE__ */ (0, import_jsx_runtime236.jsx)( 36553 import_components131.__experimentalNumberControl, 36554 { 36555 label: (0, import_i18n116.__)("Max."), 36556 value: max, 36557 min: min ? Number(min) + step : void 0, 36558 onChange: onChangeMax, 36559 __next40pxDefaultSize: true, 36560 hideLabelFromVision, 36561 step 36562 } 36563 ) 36564 ] }) 36565 } 36566 ); 36567 } 36568 function ValidatedNumber({ 36569 data, 36570 field, 36571 onChange, 36572 hideLabelFromVision, 36573 operator, 36574 validity 36575 }) { 36576 const decimals = field.format?.decimals ?? 0; 36577 const step = Math.pow(10, Math.abs(decimals) * -1); 36578 const { label, description, getValue, setValue, isValid: isValid2 } = field; 36579 const value = getValue({ item: data }) ?? ""; 36580 const onChangeControl = (0, import_element105.useCallback)( 36581 (newValue) => { 36582 onChange( 36583 setValue({ 36584 item: data, 36585 // Do not convert an empty string or undefined to a number, 36586 // otherwise there's a mismatch between the UI control (empty) 36587 // and the data relied by onChange (0). 36588 value: ["", void 0].includes(newValue) ? void 0 : Number(newValue) 36589 }) 36590 ); 36591 }, 36592 [data, onChange, setValue] 36593 ); 36594 const onChangeBetweenControls = (0, import_element105.useCallback)( 36595 (newValue) => { 36596 onChange( 36597 setValue({ 36598 item: data, 36599 value: newValue 36600 }) 36601 ); 36602 }, 36603 [data, onChange, setValue] 36604 ); 36605 if (operator === OPERATOR_BETWEEN) { 36606 let valueBetween = ["", ""]; 36607 if (Array.isArray(value) && value.length === 2 && value.every( 36608 (element) => typeof element === "number" || element === "" 36609 )) { 36610 valueBetween = value; 36611 } 36612 return /* @__PURE__ */ (0, import_jsx_runtime236.jsx)( 36613 BetweenControls, 36614 { 36615 value: valueBetween, 36616 onChange: onChangeBetweenControls, 36617 hideLabelFromVision, 36618 step 36619 } 36620 ); 36621 } 36622 return /* @__PURE__ */ (0, import_jsx_runtime236.jsx)( 36623 ValidatedNumberControl, 36624 { 36625 required: !!isValid2.required, 36626 customValidity: getCustomValidity(isValid2, validity), 36627 label, 36628 help: description, 36629 value, 36630 onChange: onChangeControl, 36631 __next40pxDefaultSize: true, 36632 hideLabelFromVision, 36633 step, 36634 min: isValid2.min ? isValid2.min.constraint : void 0, 36635 max: isValid2.max ? isValid2.max.constraint : void 0 36636 } 36637 ); 36638 } 36639 36640 // packages/dataviews/build-module/dataform-controls/integer.js 36641 var import_jsx_runtime237 = __toESM(require_jsx_runtime()); 36642 function Integer(props) { 36643 return /* @__PURE__ */ (0, import_jsx_runtime237.jsx)(ValidatedNumber, { ...props }); 36644 } 36645 36646 // packages/dataviews/build-module/dataform-controls/number.js 36647 var import_jsx_runtime238 = __toESM(require_jsx_runtime()); 36648 function Number2(props) { 36649 return /* @__PURE__ */ (0, import_jsx_runtime238.jsx)(ValidatedNumber, { ...props }); 36650 } 36651 36652 // packages/dataviews/build-module/dataform-controls/radio.js 36653 var import_components132 = __toESM(require_components()); 36654 var import_element106 = __toESM(require_element()); 36655 var import_jsx_runtime239 = __toESM(require_jsx_runtime()); 36656 var { ValidatedRadioControl } = unlock3(import_components132.privateApis); 36657 function Radio({ 36658 data, 36659 field, 36660 onChange, 36661 hideLabelFromVision, 36662 validity 36663 }) { 36664 const { label, description, getValue, setValue, isValid: isValid2 } = field; 36665 const { elements: elements2, isLoading } = useElements({ 36666 elements: field.elements, 36667 getElements: field.getElements 36668 }); 36669 const value = getValue({ item: data }); 36670 const onChangeControl = (0, import_element106.useCallback)( 36671 (newValue) => onChange(setValue({ item: data, value: newValue })), 36672 [data, onChange, setValue] 36673 ); 36674 if (isLoading) { 36675 return /* @__PURE__ */ (0, import_jsx_runtime239.jsx)(import_components132.Spinner, {}); 36676 } 36677 return /* @__PURE__ */ (0, import_jsx_runtime239.jsx)( 36678 ValidatedRadioControl, 36679 { 36680 required: !!field.isValid?.required, 36681 customValidity: getCustomValidity(isValid2, validity), 36682 label, 36683 help: description, 36684 onChange: onChangeControl, 36685 options: elements2, 36686 selected: value, 36687 hideLabelFromVision 36688 } 36689 ); 36690 } 36691 36692 // packages/dataviews/build-module/dataform-controls/select.js 36693 var import_components133 = __toESM(require_components()); 36694 var import_element107 = __toESM(require_element()); 36695 var import_jsx_runtime240 = __toESM(require_jsx_runtime()); 36696 var { ValidatedSelectControl } = unlock3(import_components133.privateApis); 36697 function Select({ 36698 data, 36699 field, 36700 onChange, 36701 hideLabelFromVision, 36702 validity 36703 }) { 36704 const { type, label, description, getValue, setValue, isValid: isValid2 } = field; 36705 const isMultiple = type === "array"; 36706 const value = getValue({ item: data }) ?? (isMultiple ? [] : ""); 36707 const onChangeControl = (0, import_element107.useCallback)( 36708 (newValue) => onChange(setValue({ item: data, value: newValue })), 36709 [data, onChange, setValue] 36710 ); 36711 const { elements: elements2, isLoading } = useElements({ 36712 elements: field.elements, 36713 getElements: field.getElements 36714 }); 36715 if (isLoading) { 36716 return /* @__PURE__ */ (0, import_jsx_runtime240.jsx)(import_components133.Spinner, {}); 36717 } 36718 return /* @__PURE__ */ (0, import_jsx_runtime240.jsx)( 36719 ValidatedSelectControl, 36720 { 36721 required: !!field.isValid?.required, 36722 customValidity: getCustomValidity(isValid2, validity), 36723 label, 36724 value, 36725 help: description, 36726 options: elements2, 36727 onChange: onChangeControl, 36728 __next40pxDefaultSize: true, 36729 hideLabelFromVision, 36730 multiple: isMultiple 36731 } 36732 ); 36733 } 36734 36735 // packages/dataviews/build-module/dataform-controls/text.js 36736 var import_element108 = __toESM(require_element()); 36737 var import_jsx_runtime241 = __toESM(require_jsx_runtime()); 36738 function Text13({ 36739 data, 36740 field, 36741 onChange, 36742 hideLabelFromVision, 36743 config: config2, 36744 validity 36745 }) { 36746 const { prefix: prefix2, suffix } = config2 || {}; 36747 return /* @__PURE__ */ (0, import_jsx_runtime241.jsx)( 36748 ValidatedText, 36749 { 36750 ...{ 36751 data, 36752 field, 36753 onChange, 36754 hideLabelFromVision, 36755 validity, 36756 prefix: prefix2 ? (0, import_element108.createElement)(prefix2) : void 0, 36757 suffix: suffix ? (0, import_element108.createElement)(suffix) : void 0 36758 } 36759 } 36760 ); 36761 } 36762 36763 // packages/dataviews/build-module/dataform-controls/toggle.js 36764 var import_components134 = __toESM(require_components()); 36765 var import_element109 = __toESM(require_element()); 36766 var import_jsx_runtime242 = __toESM(require_jsx_runtime()); 36767 var { ValidatedToggleControl } = unlock3(import_components134.privateApis); 36768 function Toggle({ 36769 field, 36770 onChange, 36771 data, 36772 hideLabelFromVision, 36773 validity 36774 }) { 36775 const { label, description, getValue, setValue, isValid: isValid2 } = field; 36776 const onChangeControl = (0, import_element109.useCallback)(() => { 36777 onChange( 36778 setValue({ item: data, value: !getValue({ item: data }) }) 36779 ); 36780 }, [onChange, setValue, data, getValue]); 36781 return /* @__PURE__ */ (0, import_jsx_runtime242.jsx)( 36782 ValidatedToggleControl, 36783 { 36784 required: !!isValid2.required, 36785 customValidity: getCustomValidity(isValid2, validity), 36786 hidden: hideLabelFromVision, 36787 label, 36788 help: description, 36789 checked: getValue({ item: data }), 36790 onChange: onChangeControl 36791 } 36792 ); 36793 } 36794 36795 // packages/dataviews/build-module/dataform-controls/textarea.js 36796 var import_components135 = __toESM(require_components()); 36797 var import_element110 = __toESM(require_element()); 36798 var import_jsx_runtime243 = __toESM(require_jsx_runtime()); 36799 var { ValidatedTextareaControl } = unlock3(import_components135.privateApis); 36800 function Textarea({ 36801 data, 36802 field, 36803 onChange, 36804 hideLabelFromVision, 36805 config: config2, 36806 validity 36807 }) { 36808 const { rows = 4 } = config2 || {}; 36809 const { label, placeholder, description, setValue, isValid: isValid2 } = field; 36810 const value = field.getValue({ item: data }); 36811 const onChangeControl = (0, import_element110.useCallback)( 36812 (newValue) => onChange(setValue({ item: data, value: newValue })), 36813 [data, onChange, setValue] 36814 ); 36815 return /* @__PURE__ */ (0, import_jsx_runtime243.jsx)( 36816 ValidatedTextareaControl, 36817 { 36818 required: !!isValid2.required, 36819 customValidity: getCustomValidity(isValid2, validity), 36820 label, 36821 placeholder, 36822 value: value ?? "", 36823 help: description, 36824 onChange: onChangeControl, 36825 rows, 36826 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0, 36827 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0, 36828 __next40pxDefaultSize: true, 36829 hideLabelFromVision 36830 } 36831 ); 36832 } 36833 36834 // packages/dataviews/build-module/dataform-controls/toggle-group.js 36835 var import_components136 = __toESM(require_components()); 36836 var import_element111 = __toESM(require_element()); 36837 var import_jsx_runtime244 = __toESM(require_jsx_runtime()); 36838 var { ValidatedToggleGroupControl } = unlock3(import_components136.privateApis); 36839 function ToggleGroup({ 36840 data, 36841 field, 36842 onChange, 36843 hideLabelFromVision, 36844 validity 36845 }) { 36846 const { getValue, setValue, isValid: isValid2 } = field; 36847 const value = getValue({ item: data }); 36848 const onChangeControl = (0, import_element111.useCallback)( 36849 (newValue) => onChange(setValue({ item: data, value: newValue })), 36850 [data, onChange, setValue] 36851 ); 36852 const { elements: elements2, isLoading } = useElements({ 36853 elements: field.elements, 36854 getElements: field.getElements 36855 }); 36856 if (isLoading) { 36857 return /* @__PURE__ */ (0, import_jsx_runtime244.jsx)(import_components136.Spinner, {}); 36858 } 36859 if (elements2.length === 0) { 36860 return null; 36861 } 36862 const selectedOption = elements2.find((el) => el.value === value); 36863 return /* @__PURE__ */ (0, import_jsx_runtime244.jsx)( 36864 ValidatedToggleGroupControl, 36865 { 36866 required: !!field.isValid?.required, 36867 customValidity: getCustomValidity(isValid2, validity), 36868 __next40pxDefaultSize: true, 36869 isBlock: true, 36870 label: field.label, 36871 help: selectedOption?.description || field.description, 36872 onChange: onChangeControl, 36873 value, 36874 hideLabelFromVision, 36875 children: elements2.map((el) => /* @__PURE__ */ (0, import_jsx_runtime244.jsx)( 36876 import_components136.__experimentalToggleGroupControlOption, 36877 { 36878 label: el.label, 36879 value: el.value 36880 }, 36881 el.value 36882 )) 36883 } 36884 ); 36885 } 36886 36887 // packages/dataviews/build-module/dataform-controls/array.js 36888 var import_components137 = __toESM(require_components()); 36889 var import_element112 = __toESM(require_element()); 36890 var import_jsx_runtime245 = __toESM(require_jsx_runtime()); 36891 var { ValidatedFormTokenField } = unlock3(import_components137.privateApis); 36892 function ArrayControl({ 36893 data, 36894 field, 36895 onChange, 36896 hideLabelFromVision, 36897 validity 36898 }) { 36899 const { label, placeholder, getValue, setValue, isValid: isValid2 } = field; 36900 const value = getValue({ item: data }); 36901 const { elements: elements2, isLoading } = useElements({ 36902 elements: field.elements, 36903 getElements: field.getElements 36904 }); 36905 const arrayValueAsElements = (0, import_element112.useMemo)( 36906 () => Array.isArray(value) ? value.map((token) => { 36907 const element = elements2?.find( 36908 (suggestion) => suggestion.value === token 36909 ); 36910 return element || { value: token, label: token }; 36911 }) : [], 36912 [value, elements2] 36913 ); 36914 const onChangeControl = (0, import_element112.useCallback)( 36915 (tokens) => { 36916 const valueTokens = tokens.map((token) => { 36917 if (typeof token === "object" && "value" in token) { 36918 return token.value; 36919 } 36920 return token; 36921 }); 36922 onChange(setValue({ item: data, value: valueTokens })); 36923 }, 36924 [onChange, setValue, data] 36925 ); 36926 if (isLoading) { 36927 return /* @__PURE__ */ (0, import_jsx_runtime245.jsx)(import_components137.Spinner, {}); 36928 } 36929 return /* @__PURE__ */ (0, import_jsx_runtime245.jsx)( 36930 ValidatedFormTokenField, 36931 { 36932 required: !!isValid2?.required, 36933 customValidity: getCustomValidity(isValid2, validity), 36934 label: hideLabelFromVision ? void 0 : label, 36935 value: arrayValueAsElements, 36936 onChange: onChangeControl, 36937 placeholder, 36938 suggestions: elements2?.map((element) => element.value), 36939 __experimentalValidateInput: (token) => { 36940 if (field.isValid?.elements && elements2) { 36941 return elements2.some( 36942 (element) => element.value === token || element.label === token 36943 ); 36944 } 36945 return true; 36946 }, 36947 __experimentalExpandOnFocus: elements2 && elements2.length > 0, 36948 __experimentalShowHowTo: !field.isValid?.elements, 36949 displayTransform: (token) => { 36950 if (typeof token === "object" && "label" in token) { 36951 return token.label; 36952 } 36953 if (typeof token === "string" && elements2) { 36954 const element = elements2.find( 36955 (el) => el.value === token 36956 ); 36957 return element?.label || token; 36958 } 36959 return token; 36960 }, 36961 __experimentalRenderItem: ({ item }) => { 36962 if (typeof item === "string" && elements2) { 36963 const element = elements2.find( 36964 (el) => el.value === item 36965 ); 36966 return /* @__PURE__ */ (0, import_jsx_runtime245.jsx)("span", { children: element?.label || item }); 36967 } 36968 return /* @__PURE__ */ (0, import_jsx_runtime245.jsx)("span", { children: item }); 36969 } 36970 } 36971 ); 36972 } 36973 36974 // packages/dataviews/build-module/dataform-controls/color.js 36975 var import_components138 = __toESM(require_components()); 36976 var import_element113 = __toESM(require_element()); 36977 var import_jsx_runtime246 = __toESM(require_jsx_runtime()); 36978 var { ValidatedInputControl: ValidatedInputControl3, Picker } = unlock3(import_components138.privateApis); 36979 var ColorPicker = ({ 36980 color, 36981 onColorChange 36982 }) => { 36983 const validColor = color && w(color).isValid() ? color : "#ffffff"; 36984 return /* @__PURE__ */ (0, import_jsx_runtime246.jsx)( 36985 import_components138.Dropdown, 36986 { 36987 renderToggle: ({ onToggle, isOpen }) => /* @__PURE__ */ (0, import_jsx_runtime246.jsx)(import_components138.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime246.jsx)( 36988 "button", 36989 { 36990 type: "button", 36991 onClick: onToggle, 36992 style: { 36993 width: "24px", 36994 height: "24px", 36995 borderRadius: "50%", 36996 backgroundColor: validColor, 36997 border: "1px solid #ddd", 36998 cursor: "pointer", 36999 outline: isOpen ? "2px solid #007cba" : "none", 37000 outlineOffset: "2px", 37001 display: "flex", 37002 alignItems: "center", 37003 justifyContent: "center", 37004 padding: 0, 37005 margin: 0 37006 }, 37007 "aria-label": "Open color picker" 37008 } 37009 ) }), 37010 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime246.jsx)("div", { style: { padding: "16px" }, children: /* @__PURE__ */ (0, import_jsx_runtime246.jsx)( 37011 Picker, 37012 { 37013 color: w(validColor), 37014 onChange: onColorChange, 37015 enableAlpha: true 37016 } 37017 ) }) 37018 } 37019 ); 37020 }; 37021 function Color({ 37022 data, 37023 field, 37024 onChange, 37025 hideLabelFromVision, 37026 validity 37027 }) { 37028 const { label, placeholder, description, setValue, isValid: isValid2 } = field; 37029 const value = field.getValue({ item: data }) || ""; 37030 const handleColorChange = (0, import_element113.useCallback)( 37031 (colorObject) => { 37032 onChange(setValue({ item: data, value: colorObject.toHex() })); 37033 }, 37034 [data, onChange, setValue] 37035 ); 37036 const handleInputChange = (0, import_element113.useCallback)( 37037 (newValue) => { 37038 onChange(setValue({ item: data, value: newValue || "" })); 37039 }, 37040 [data, onChange, setValue] 37041 ); 37042 return /* @__PURE__ */ (0, import_jsx_runtime246.jsx)( 37043 ValidatedInputControl3, 37044 { 37045 required: !!field.isValid?.required, 37046 customValidity: getCustomValidity(isValid2, validity), 37047 label, 37048 placeholder, 37049 value, 37050 help: description, 37051 onChange: handleInputChange, 37052 hideLabelFromVision, 37053 type: "text", 37054 prefix: /* @__PURE__ */ (0, import_jsx_runtime246.jsx)( 37055 ColorPicker, 37056 { 37057 color: value, 37058 onColorChange: handleColorChange 37059 } 37060 ) 37061 } 37062 ); 37063 } 37064 37065 // packages/dataviews/build-module/dataform-controls/password.js 37066 var import_components139 = __toESM(require_components()); 37067 var import_element114 = __toESM(require_element()); 37068 var import_i18n117 = __toESM(require_i18n()); 37069 var import_jsx_runtime247 = __toESM(require_jsx_runtime()); 37070 function Password({ 37071 data, 37072 field, 37073 onChange, 37074 hideLabelFromVision, 37075 validity 37076 }) { 37077 const [isVisible2, setIsVisible] = (0, import_element114.useState)(false); 37078 const toggleVisibility = (0, import_element114.useCallback)(() => { 37079 setIsVisible((prev) => !prev); 37080 }, []); 37081 return /* @__PURE__ */ (0, import_jsx_runtime247.jsx)( 37082 ValidatedText, 37083 { 37084 ...{ 37085 data, 37086 field, 37087 onChange, 37088 hideLabelFromVision, 37089 validity, 37090 type: isVisible2 ? "text" : "password", 37091 suffix: /* @__PURE__ */ (0, import_jsx_runtime247.jsx)(import_components139.__experimentalInputControlSuffixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime247.jsx)( 37092 import_components139.Button, 37093 { 37094 icon: isVisible2 ? unseen_default : seen_default, 37095 onClick: toggleVisibility, 37096 size: "small", 37097 label: isVisible2 ? (0, import_i18n117.__)("Hide password") : (0, import_i18n117.__)("Show password") 37098 } 37099 ) }) 37100 } 37101 } 37102 ); 37103 } 37104 37105 // packages/dataviews/build-module/field-types/utils/has-elements.js 37106 function hasElements(field) { 37107 return Array.isArray(field.elements) && field.elements.length > 0 || typeof field.getElements === "function"; 37108 } 37109 37110 // packages/dataviews/build-module/dataform-controls/index.js 37111 var import_jsx_runtime248 = __toESM(require_jsx_runtime()); 37112 var FORM_CONTROLS = { 37113 array: ArrayControl, 37114 checkbox: Checkbox, 37115 color: Color, 37116 datetime: DateTime, 37117 date: DateControl, 37118 email: Email, 37119 telephone: Telephone, 37120 url: Url, 37121 integer: Integer, 37122 number: Number2, 37123 password: Password, 37124 radio: Radio, 37125 select: Select, 37126 text: Text13, 37127 toggle: Toggle, 37128 textarea: Textarea, 37129 toggleGroup: ToggleGroup 37130 }; 37131 function isEditConfig(value) { 37132 return value && typeof value === "object" && typeof value.control === "string"; 37133 } 37134 function createConfiguredControl(config2) { 37135 const { control, ...controlConfig } = config2; 37136 const BaseControlType = getControlByType(control); 37137 if (BaseControlType === null) { 37138 return null; 37139 } 37140 return function ConfiguredControl(props) { 37141 return /* @__PURE__ */ (0, import_jsx_runtime248.jsx)(BaseControlType, { ...props, config: controlConfig }); 37142 }; 37143 } 37144 function getControl(field, fallback) { 37145 if (typeof field.Edit === "function") { 37146 return field.Edit; 37147 } 37148 if (typeof field.Edit === "string") { 37149 return getControlByType(field.Edit); 37150 } 37151 if (isEditConfig(field.Edit)) { 37152 return createConfiguredControl(field.Edit); 37153 } 37154 if (hasElements(field) && field.type !== "array") { 37155 return getControlByType("select"); 37156 } 37157 if (fallback === null) { 37158 return null; 37159 } 37160 return getControlByType(fallback); 37161 } 37162 function getControlByType(type) { 37163 if (Object.keys(FORM_CONTROLS).includes(type)) { 37164 return FORM_CONTROLS[type]; 37165 } 37166 return null; 37167 } 37168 37169 // packages/dataviews/build-module/field-types/utils/get-filter-by.js 37170 function getFilterBy(field, defaultOperators, validOperators) { 37171 if (field.filterBy === false) { 37172 return false; 37173 } 37174 const operators = field.filterBy?.operators?.filter( 37175 (op) => validOperators.includes(op) 37176 ) ?? defaultOperators; 37177 if (operators.length === 0) { 37178 return false; 37179 } 37180 return { 37181 isPrimary: !!field.filterBy?.isPrimary, 37182 operators 37183 }; 37184 } 37185 var get_filter_by_default = getFilterBy; 37186 37187 // packages/dataviews/build-module/field-types/utils/get-value-from-id.js 37188 var getValueFromId = (id) => ({ item }) => { 37189 const path = id.split("."); 37190 let value = item; 37191 for (const segment of path) { 37192 if (value.hasOwnProperty(segment)) { 37193 value = value[segment]; 37194 } else { 37195 value = void 0; 37196 } 37197 } 37198 return value; 37199 }; 37200 var get_value_from_id_default = getValueFromId; 37201 37202 // packages/dataviews/build-module/field-types/utils/set-value-from-id.js 37203 var setValueFromId = (id) => ({ value }) => { 37204 const path = id.split("."); 37205 const result = {}; 37206 let current = result; 37207 for (const segment of path.slice(0, -1)) { 37208 current[segment] = {}; 37209 current = current[segment]; 37210 } 37211 current[path.at(-1)] = value; 37212 return result; 37213 }; 37214 var set_value_from_id_default = setValueFromId; 37215 37216 // packages/dataviews/build-module/field-types/email.js 37217 var import_i18n118 = __toESM(require_i18n()); 37218 37219 // packages/dataviews/build-module/field-types/utils/render-from-elements.js 37220 function RenderFromElements({ 37221 item, 37222 field 37223 }) { 37224 const { elements: elements2, isLoading } = useElements({ 37225 elements: field.elements, 37226 getElements: field.getElements 37227 }); 37228 const value = field.getValue({ item }); 37229 if (isLoading) { 37230 return value; 37231 } 37232 if (elements2.length === 0) { 37233 return value; 37234 } 37235 return elements2?.find((element) => element.value === value)?.label || field.getValue({ item }); 37236 } 37237 37238 // packages/dataviews/build-module/field-types/utils/render-default.js 37239 var import_jsx_runtime249 = __toESM(require_jsx_runtime()); 37240 function render({ 37241 item, 37242 field 37243 }) { 37244 if (field.hasElements) { 37245 return /* @__PURE__ */ (0, import_jsx_runtime249.jsx)(RenderFromElements, { item, field }); 37246 } 37247 return field.getValueFormatted({ item, field }); 37248 } 37249 37250 // packages/dataviews/build-module/field-types/utils/sort-text.js 37251 var sort_text_default = (a2, b2, direction) => { 37252 return direction === "asc" ? a2.localeCompare(b2) : b2.localeCompare(a2); 37253 }; 37254 37255 // packages/dataviews/build-module/field-types/utils/is-valid-required.js 37256 function isValidRequired(item, field) { 37257 const value = field.getValue({ item }); 37258 return ![void 0, "", null].includes(value); 37259 } 37260 37261 // packages/dataviews/build-module/field-types/utils/is-valid-min-length.js 37262 function isValidMinLength(item, field) { 37263 if (typeof field.isValid.minLength?.constraint !== "number") { 37264 return false; 37265 } 37266 const value = field.getValue({ item }); 37267 if ([void 0, "", null].includes(value)) { 37268 return true; 37269 } 37270 return String(value).length >= field.isValid.minLength.constraint; 37271 } 37272 37273 // packages/dataviews/build-module/field-types/utils/is-valid-max-length.js 37274 function isValidMaxLength(item, field) { 37275 if (typeof field.isValid.maxLength?.constraint !== "number") { 37276 return false; 37277 } 37278 const value = field.getValue({ item }); 37279 if ([void 0, "", null].includes(value)) { 37280 return true; 37281 } 37282 return String(value).length <= field.isValid.maxLength.constraint; 37283 } 37284 37285 // packages/dataviews/build-module/field-types/utils/is-valid-pattern.js 37286 function isValidPattern(item, field) { 37287 if (field.isValid.pattern?.constraint === void 0) { 37288 return true; 37289 } 37290 try { 37291 const regexp = new RegExp(field.isValid.pattern.constraint); 37292 const value = field.getValue({ item }); 37293 if ([void 0, "", null].includes(value)) { 37294 return true; 37295 } 37296 return regexp.test(String(value)); 37297 } catch { 37298 return false; 37299 } 37300 } 37301 37302 // packages/dataviews/build-module/field-types/utils/is-valid-elements.js 37303 function isValidElements(item, field) { 37304 const elements2 = field.elements ?? []; 37305 const validValues = elements2.map((el) => el.value); 37306 if (validValues.length === 0) { 37307 return true; 37308 } 37309 const value = field.getValue({ item }); 37310 return [].concat(value).every((v2) => validValues.includes(v2)); 37311 } 37312 37313 // packages/dataviews/build-module/field-types/utils/get-value-formatted-default.js 37314 function getValueFormatted({ 37315 item, 37316 field 37317 }) { 37318 return field.getValue({ item }); 37319 } 37320 var get_value_formatted_default_default = getValueFormatted; 37321 37322 // packages/dataviews/build-module/field-types/email.js 37323 var emailRegex = /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/; 37324 function isValidCustom(item, field) { 37325 const value = field.getValue({ item }); 37326 if (![void 0, "", null].includes(value) && !emailRegex.test(value)) { 37327 return (0, import_i18n118.__)("Value must be a valid email address."); 37328 } 37329 return null; 37330 } 37331 var email_default = { 37332 type: "email", 37333 render, 37334 Edit: "email", 37335 sort: sort_text_default, 37336 enableSorting: true, 37337 enableGlobalSearch: false, 37338 defaultOperators: [OPERATOR_IS_ANY2, OPERATOR_IS_NONE2], 37339 validOperators: [ 37340 OPERATOR_IS2, 37341 OPERATOR_IS_NOT, 37342 OPERATOR_CONTAINS, 37343 OPERATOR_NOT_CONTAINS, 37344 OPERATOR_STARTS_WITH, 37345 // Multiple selection 37346 OPERATOR_IS_ANY2, 37347 OPERATOR_IS_NONE2, 37348 OPERATOR_IS_ALL, 37349 OPERATOR_IS_NOT_ALL 37350 ], 37351 format: {}, 37352 getValueFormatted: get_value_formatted_default_default, 37353 validate: { 37354 required: isValidRequired, 37355 pattern: isValidPattern, 37356 minLength: isValidMinLength, 37357 maxLength: isValidMaxLength, 37358 elements: isValidElements, 37359 custom: isValidCustom 37360 } 37361 }; 37362 37363 // packages/dataviews/build-module/field-types/integer.js 37364 var import_i18n119 = __toESM(require_i18n()); 37365 37366 // packages/dataviews/build-module/field-types/utils/sort-number.js 37367 var sort_number_default = (a2, b2, direction) => { 37368 return direction === "asc" ? a2 - b2 : b2 - a2; 37369 }; 37370 37371 // packages/dataviews/build-module/field-types/utils/is-valid-min.js 37372 function isValidMin(item, field) { 37373 if (typeof field.isValid.min?.constraint !== "number") { 37374 return false; 37375 } 37376 const value = field.getValue({ item }); 37377 if ([void 0, "", null].includes(value)) { 37378 return true; 37379 } 37380 return Number(value) >= field.isValid.min.constraint; 37381 } 37382 37383 // packages/dataviews/build-module/field-types/utils/is-valid-max.js 37384 function isValidMax(item, field) { 37385 if (typeof field.isValid.max?.constraint !== "number") { 37386 return false; 37387 } 37388 const value = field.getValue({ item }); 37389 if ([void 0, "", null].includes(value)) { 37390 return true; 37391 } 37392 return Number(value) <= field.isValid.max.constraint; 37393 } 37394 37395 // packages/dataviews/build-module/field-types/integer.js 37396 var format2 = { 37397 separatorThousand: "," 37398 }; 37399 function getValueFormatted2({ 37400 item, 37401 field 37402 }) { 37403 let value = field.getValue({ item }); 37404 if (value === null || value === void 0) { 37405 return ""; 37406 } 37407 value = Number(value); 37408 if (!Number.isFinite(value)) { 37409 return String(value); 37410 } 37411 let formatInteger; 37412 if (field.type !== "integer") { 37413 formatInteger = format2; 37414 } else { 37415 formatInteger = field.format; 37416 } 37417 const { separatorThousand } = formatInteger; 37418 const integerValue = Math.trunc(value); 37419 if (!separatorThousand) { 37420 return String(integerValue); 37421 } 37422 return String(integerValue).replace( 37423 /\B(?=(\d{3})+(?!\d))/g, 37424 separatorThousand 37425 ); 37426 } 37427 function isValidCustom2(item, field) { 37428 const value = field.getValue({ item }); 37429 if (![void 0, "", null].includes(value) && !Number.isInteger(value)) { 37430 return (0, import_i18n119.__)("Value must be an integer."); 37431 } 37432 return null; 37433 } 37434 var integer_default = { 37435 type: "integer", 37436 render, 37437 Edit: "integer", 37438 sort: sort_number_default, 37439 enableSorting: true, 37440 enableGlobalSearch: false, 37441 defaultOperators: [ 37442 OPERATOR_IS2, 37443 OPERATOR_IS_NOT, 37444 OPERATOR_LESS_THAN, 37445 OPERATOR_GREATER_THAN, 37446 OPERATOR_LESS_THAN_OR_EQUAL, 37447 OPERATOR_GREATER_THAN_OR_EQUAL, 37448 OPERATOR_BETWEEN 37449 ], 37450 validOperators: [ 37451 // Single-selection 37452 OPERATOR_IS2, 37453 OPERATOR_IS_NOT, 37454 OPERATOR_LESS_THAN, 37455 OPERATOR_GREATER_THAN, 37456 OPERATOR_LESS_THAN_OR_EQUAL, 37457 OPERATOR_GREATER_THAN_OR_EQUAL, 37458 OPERATOR_BETWEEN, 37459 // Multiple-selection 37460 OPERATOR_IS_ANY2, 37461 OPERATOR_IS_NONE2, 37462 OPERATOR_IS_ALL, 37463 OPERATOR_IS_NOT_ALL 37464 ], 37465 format: format2, 37466 getValueFormatted: getValueFormatted2, 37467 validate: { 37468 required: isValidRequired, 37469 min: isValidMin, 37470 max: isValidMax, 37471 elements: isValidElements, 37472 custom: isValidCustom2 37473 } 37474 }; 37475 37476 // packages/dataviews/build-module/field-types/number.js 37477 var import_i18n120 = __toESM(require_i18n()); 37478 var format3 = { 37479 separatorThousand: ",", 37480 separatorDecimal: ".", 37481 decimals: 2 37482 }; 37483 function getValueFormatted3({ 37484 item, 37485 field 37486 }) { 37487 let value = field.getValue({ item }); 37488 if (value === null || value === void 0) { 37489 return ""; 37490 } 37491 value = Number(value); 37492 if (!Number.isFinite(value)) { 37493 return String(value); 37494 } 37495 let formatNumber; 37496 if (field.type !== "number") { 37497 formatNumber = format3; 37498 } else { 37499 formatNumber = field.format; 37500 } 37501 const { separatorThousand, separatorDecimal, decimals } = formatNumber; 37502 const fixedValue = value.toFixed(decimals); 37503 const [integerPart, decimalPart] = fixedValue.split("."); 37504 const formattedInteger = separatorThousand ? integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, separatorThousand) : integerPart; 37505 return decimals === 0 ? formattedInteger : formattedInteger + separatorDecimal + decimalPart; 37506 } 37507 function isEmpty2(value) { 37508 return value === "" || value === void 0 || value === null; 37509 } 37510 function isValidCustom3(item, field) { 37511 const value = field.getValue({ item }); 37512 if (!isEmpty2(value) && !Number.isFinite(value)) { 37513 return (0, import_i18n120.__)("Value must be a number."); 37514 } 37515 return null; 37516 } 37517 var number_default = { 37518 type: "number", 37519 render, 37520 Edit: "number", 37521 sort: sort_number_default, 37522 enableSorting: true, 37523 enableGlobalSearch: false, 37524 defaultOperators: [ 37525 OPERATOR_IS2, 37526 OPERATOR_IS_NOT, 37527 OPERATOR_LESS_THAN, 37528 OPERATOR_GREATER_THAN, 37529 OPERATOR_LESS_THAN_OR_EQUAL, 37530 OPERATOR_GREATER_THAN_OR_EQUAL, 37531 OPERATOR_BETWEEN 37532 ], 37533 validOperators: [ 37534 // Single-selection 37535 OPERATOR_IS2, 37536 OPERATOR_IS_NOT, 37537 OPERATOR_LESS_THAN, 37538 OPERATOR_GREATER_THAN, 37539 OPERATOR_LESS_THAN_OR_EQUAL, 37540 OPERATOR_GREATER_THAN_OR_EQUAL, 37541 OPERATOR_BETWEEN, 37542 // Multiple-selection 37543 OPERATOR_IS_ANY2, 37544 OPERATOR_IS_NONE2, 37545 OPERATOR_IS_ALL, 37546 OPERATOR_IS_NOT_ALL 37547 ], 37548 format: format3, 37549 getValueFormatted: getValueFormatted3, 37550 validate: { 37551 required: isValidRequired, 37552 min: isValidMin, 37553 max: isValidMax, 37554 elements: isValidElements, 37555 custom: isValidCustom3 37556 } 37557 }; 37558 37559 // packages/dataviews/build-module/field-types/text.js 37560 var text_default = { 37561 type: "text", 37562 render, 37563 Edit: "text", 37564 sort: sort_text_default, 37565 enableSorting: true, 37566 enableGlobalSearch: false, 37567 defaultOperators: [OPERATOR_IS_ANY2, OPERATOR_IS_NONE2], 37568 validOperators: [ 37569 // Single selection 37570 OPERATOR_IS2, 37571 OPERATOR_IS_NOT, 37572 OPERATOR_CONTAINS, 37573 OPERATOR_NOT_CONTAINS, 37574 OPERATOR_STARTS_WITH, 37575 // Multiple selection 37576 OPERATOR_IS_ANY2, 37577 OPERATOR_IS_NONE2, 37578 OPERATOR_IS_ALL, 37579 OPERATOR_IS_NOT_ALL 37580 ], 37581 format: {}, 37582 getValueFormatted: get_value_formatted_default_default, 37583 validate: { 37584 required: isValidRequired, 37585 pattern: isValidPattern, 37586 minLength: isValidMinLength, 37587 maxLength: isValidMaxLength, 37588 elements: isValidElements 37589 } 37590 }; 37591 37592 // packages/dataviews/build-module/field-types/datetime.js 37593 var import_date6 = __toESM(require_date()); 37594 var format4 = { 37595 datetime: (0, import_date6.getSettings)().formats.datetime, 37596 weekStartsOn: (0, import_date6.getSettings)().l10n.startOfWeek 37597 }; 37598 function getValueFormatted4({ 37599 item, 37600 field 37601 }) { 37602 const value = field.getValue({ item }); 37603 if (["", void 0, null].includes(value)) { 37604 return ""; 37605 } 37606 let formatDatetime; 37607 if (field.type !== "datetime") { 37608 formatDatetime = format4; 37609 } else { 37610 formatDatetime = field.format; 37611 } 37612 return (0, import_date6.dateI18n)(formatDatetime.datetime, (0, import_date6.getDate)(value)); 37613 } 37614 var sort = (a2, b2, direction) => { 37615 const timeA = new Date(a2).getTime(); 37616 const timeB = new Date(b2).getTime(); 37617 return direction === "asc" ? timeA - timeB : timeB - timeA; 37618 }; 37619 var datetime_default = { 37620 type: "datetime", 37621 render, 37622 Edit: "datetime", 37623 sort, 37624 enableSorting: true, 37625 enableGlobalSearch: false, 37626 defaultOperators: [ 37627 OPERATOR_ON, 37628 OPERATOR_NOT_ON, 37629 OPERATOR_BEFORE2, 37630 OPERATOR_AFTER2, 37631 OPERATOR_BEFORE_INC, 37632 OPERATOR_AFTER_INC, 37633 OPERATOR_IN_THE_PAST, 37634 OPERATOR_OVER 37635 ], 37636 validOperators: [ 37637 OPERATOR_ON, 37638 OPERATOR_NOT_ON, 37639 OPERATOR_BEFORE2, 37640 OPERATOR_AFTER2, 37641 OPERATOR_BEFORE_INC, 37642 OPERATOR_AFTER_INC, 37643 OPERATOR_IN_THE_PAST, 37644 OPERATOR_OVER 37645 ], 37646 format: format4, 37647 getValueFormatted: getValueFormatted4, 37648 validate: { 37649 required: isValidRequired, 37650 elements: isValidElements 37651 } 37652 }; 37653 37654 // packages/dataviews/build-module/field-types/date.js 37655 var import_date7 = __toESM(require_date()); 37656 var format5 = { 37657 date: (0, import_date7.getSettings)().formats.date, 37658 weekStartsOn: (0, import_date7.getSettings)().l10n.startOfWeek 37659 }; 37660 function getValueFormatted5({ 37661 item, 37662 field 37663 }) { 37664 const value = field.getValue({ item }); 37665 if (["", void 0, null].includes(value)) { 37666 return ""; 37667 } 37668 let formatDate2; 37669 if (field.type !== "date") { 37670 formatDate2 = format5; 37671 } else { 37672 formatDate2 = field.format; 37673 } 37674 return (0, import_date7.dateI18n)(formatDate2.date, (0, import_date7.getDate)(value)); 37675 } 37676 var sort2 = (a2, b2, direction) => { 37677 const timeA = new Date(a2).getTime(); 37678 const timeB = new Date(b2).getTime(); 37679 return direction === "asc" ? timeA - timeB : timeB - timeA; 37680 }; 37681 var date_default = { 37682 type: "date", 37683 render, 37684 Edit: "date", 37685 sort: sort2, 37686 enableSorting: true, 37687 enableGlobalSearch: false, 37688 defaultOperators: [ 37689 OPERATOR_ON, 37690 OPERATOR_NOT_ON, 37691 OPERATOR_BEFORE2, 37692 OPERATOR_AFTER2, 37693 OPERATOR_BEFORE_INC, 37694 OPERATOR_AFTER_INC, 37695 OPERATOR_IN_THE_PAST, 37696 OPERATOR_OVER, 37697 OPERATOR_BETWEEN 37698 ], 37699 validOperators: [ 37700 OPERATOR_ON, 37701 OPERATOR_NOT_ON, 37702 OPERATOR_BEFORE2, 37703 OPERATOR_AFTER2, 37704 OPERATOR_BEFORE_INC, 37705 OPERATOR_AFTER_INC, 37706 OPERATOR_IN_THE_PAST, 37707 OPERATOR_OVER, 37708 OPERATOR_BETWEEN 37709 ], 37710 format: format5, 37711 getValueFormatted: getValueFormatted5, 37712 validate: { 37713 required: isValidRequired, 37714 elements: isValidElements 37715 } 37716 }; 37717 37718 // packages/dataviews/build-module/field-types/boolean.js 37719 var import_i18n121 = __toESM(require_i18n()); 37720 37721 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-bool.js 37722 function isValidRequiredForBool(item, field) { 37723 const value = field.getValue({ item }); 37724 return value === true; 37725 } 37726 37727 // packages/dataviews/build-module/field-types/boolean.js 37728 function getValueFormatted6({ 37729 item, 37730 field 37731 }) { 37732 const value = field.getValue({ item }); 37733 if (value === true) { 37734 return (0, import_i18n121.__)("True"); 37735 } 37736 if (value === false) { 37737 return (0, import_i18n121.__)("False"); 37738 } 37739 return ""; 37740 } 37741 function isValidCustom4(item, field) { 37742 const value = field.getValue({ item }); 37743 if (![void 0, "", null].includes(value) && ![true, false].includes(value)) { 37744 return (0, import_i18n121.__)("Value must be true, false, or undefined"); 37745 } 37746 return null; 37747 } 37748 var sort3 = (a2, b2, direction) => { 37749 const boolA = Boolean(a2); 37750 const boolB = Boolean(b2); 37751 if (boolA === boolB) { 37752 return 0; 37753 } 37754 if (direction === "asc") { 37755 return boolA ? 1 : -1; 37756 } 37757 return boolA ? -1 : 1; 37758 }; 37759 var boolean_default = { 37760 type: "boolean", 37761 render, 37762 Edit: "checkbox", 37763 sort: sort3, 37764 validate: { 37765 required: isValidRequiredForBool, 37766 elements: isValidElements, 37767 custom: isValidCustom4 37768 }, 37769 enableSorting: true, 37770 enableGlobalSearch: false, 37771 defaultOperators: [OPERATOR_IS2, OPERATOR_IS_NOT], 37772 validOperators: [OPERATOR_IS2, OPERATOR_IS_NOT], 37773 format: {}, 37774 getValueFormatted: getValueFormatted6 37775 }; 37776 37777 // packages/dataviews/build-module/field-types/media.js 37778 var media_default2 = { 37779 type: "media", 37780 render: () => null, 37781 Edit: null, 37782 sort: () => 0, 37783 enableSorting: false, 37784 enableGlobalSearch: false, 37785 defaultOperators: [], 37786 validOperators: [], 37787 format: {}, 37788 getValueFormatted: get_value_formatted_default_default, 37789 // cannot validate any constraint, so 37790 // the only available validation for the field author 37791 // would be providing a custom validator. 37792 validate: {} 37793 }; 37794 37795 // packages/dataviews/build-module/field-types/array.js 37796 var import_i18n122 = __toESM(require_i18n()); 37797 37798 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-array.js 37799 function isValidRequiredForArray(item, field) { 37800 const value = field.getValue({ item }); 37801 return Array.isArray(value) && value.length > 0 && value.every( 37802 (element) => ![void 0, "", null].includes(element) 37803 ); 37804 } 37805 37806 // packages/dataviews/build-module/field-types/array.js 37807 function getValueFormatted7({ 37808 item, 37809 field 37810 }) { 37811 const value = field.getValue({ item }); 37812 const arr = Array.isArray(value) ? value : []; 37813 return arr.join(", "); 37814 } 37815 function render2({ item, field }) { 37816 return getValueFormatted7({ item, field }); 37817 } 37818 function isValidCustom5(item, field) { 37819 const value = field.getValue({ item }); 37820 if (![void 0, "", null].includes(value) && !Array.isArray(value)) { 37821 return (0, import_i18n122.__)("Value must be an array."); 37822 } 37823 if (!value.every((v2) => typeof v2 === "string")) { 37824 return (0, import_i18n122.__)("Every value must be a string."); 37825 } 37826 return null; 37827 } 37828 var sort4 = (a2, b2, direction) => { 37829 const arrA = Array.isArray(a2) ? a2 : []; 37830 const arrB = Array.isArray(b2) ? b2 : []; 37831 if (arrA.length !== arrB.length) { 37832 return direction === "asc" ? arrA.length - arrB.length : arrB.length - arrA.length; 37833 } 37834 const joinedA = arrA.join(","); 37835 const joinedB = arrB.join(","); 37836 return direction === "asc" ? joinedA.localeCompare(joinedB) : joinedB.localeCompare(joinedA); 37837 }; 37838 var array_default = { 37839 type: "array", 37840 render: render2, 37841 Edit: "array", 37842 sort: sort4, 37843 enableSorting: true, 37844 enableGlobalSearch: false, 37845 defaultOperators: [OPERATOR_IS_ANY2, OPERATOR_IS_NONE2], 37846 validOperators: [ 37847 OPERATOR_IS_ANY2, 37848 OPERATOR_IS_NONE2, 37849 OPERATOR_IS_ALL, 37850 OPERATOR_IS_NOT_ALL 37851 ], 37852 format: {}, 37853 getValueFormatted: getValueFormatted7, 37854 validate: { 37855 required: isValidRequiredForArray, 37856 elements: isValidElements, 37857 custom: isValidCustom5 37858 } 37859 }; 37860 37861 // packages/dataviews/build-module/field-types/password.js 37862 function getValueFormatted8({ 37863 item, 37864 field 37865 }) { 37866 return field.getValue({ item }) ? "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022" : ""; 37867 } 37868 var password_default = { 37869 type: "password", 37870 render, 37871 Edit: "password", 37872 sort: () => 0, 37873 // Passwords should not be sortable for security reasons 37874 enableSorting: false, 37875 enableGlobalSearch: false, 37876 defaultOperators: [], 37877 validOperators: [], 37878 format: {}, 37879 getValueFormatted: getValueFormatted8, 37880 validate: { 37881 required: isValidRequired, 37882 pattern: isValidPattern, 37883 minLength: isValidMinLength, 37884 maxLength: isValidMaxLength, 37885 elements: isValidElements 37886 } 37887 }; 37888 37889 // packages/dataviews/build-module/field-types/telephone.js 37890 var telephone_default = { 37891 type: "telephone", 37892 render, 37893 Edit: "telephone", 37894 sort: sort_text_default, 37895 enableSorting: true, 37896 enableGlobalSearch: false, 37897 defaultOperators: [OPERATOR_IS_ANY2, OPERATOR_IS_NONE2], 37898 validOperators: [ 37899 OPERATOR_IS2, 37900 OPERATOR_IS_NOT, 37901 OPERATOR_CONTAINS, 37902 OPERATOR_NOT_CONTAINS, 37903 OPERATOR_STARTS_WITH, 37904 // Multiple selection 37905 OPERATOR_IS_ANY2, 37906 OPERATOR_IS_NONE2, 37907 OPERATOR_IS_ALL, 37908 OPERATOR_IS_NOT_ALL 37909 ], 37910 format: {}, 37911 getValueFormatted: get_value_formatted_default_default, 37912 validate: { 37913 required: isValidRequired, 37914 pattern: isValidPattern, 37915 minLength: isValidMinLength, 37916 maxLength: isValidMaxLength, 37917 elements: isValidElements 37918 } 37919 }; 37920 37921 // packages/dataviews/build-module/field-types/color.js 37922 var import_i18n123 = __toESM(require_i18n()); 37923 var import_jsx_runtime250 = __toESM(require_jsx_runtime()); 37924 function render3({ item, field }) { 37925 if (field.hasElements) { 37926 return /* @__PURE__ */ (0, import_jsx_runtime250.jsx)(RenderFromElements, { item, field }); 37927 } 37928 const value = get_value_formatted_default_default({ item, field }); 37929 if (!value || !w(value).isValid()) { 37930 return value; 37931 } 37932 return /* @__PURE__ */ (0, import_jsx_runtime250.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [ 37933 /* @__PURE__ */ (0, import_jsx_runtime250.jsx)( 37934 "div", 37935 { 37936 style: { 37937 width: "16px", 37938 height: "16px", 37939 borderRadius: "50%", 37940 backgroundColor: value, 37941 border: "1px solid #ddd", 37942 flexShrink: 0 37943 } 37944 } 37945 ), 37946 /* @__PURE__ */ (0, import_jsx_runtime250.jsx)("span", { children: value }) 37947 ] }); 37948 } 37949 function isValidCustom6(item, field) { 37950 const value = field.getValue({ item }); 37951 if (![void 0, "", null].includes(value) && !w(value).isValid()) { 37952 return (0, import_i18n123.__)("Value must be a valid color."); 37953 } 37954 return null; 37955 } 37956 var sort5 = (a2, b2, direction) => { 37957 const colorA = w(a2); 37958 const colorB = w(b2); 37959 if (!colorA.isValid() && !colorB.isValid()) { 37960 return 0; 37961 } 37962 if (!colorA.isValid()) { 37963 return direction === "asc" ? 1 : -1; 37964 } 37965 if (!colorB.isValid()) { 37966 return direction === "asc" ? -1 : 1; 37967 } 37968 const hslA = colorA.toHsl(); 37969 const hslB = colorB.toHsl(); 37970 if (hslA.h !== hslB.h) { 37971 return direction === "asc" ? hslA.h - hslB.h : hslB.h - hslA.h; 37972 } 37973 if (hslA.s !== hslB.s) { 37974 return direction === "asc" ? hslA.s - hslB.s : hslB.s - hslA.s; 37975 } 37976 return direction === "asc" ? hslA.l - hslB.l : hslB.l - hslA.l; 37977 }; 37978 var color_default = { 37979 type: "color", 37980 render: render3, 37981 Edit: "color", 37982 sort: sort5, 37983 enableSorting: true, 37984 enableGlobalSearch: false, 37985 defaultOperators: [OPERATOR_IS_ANY2, OPERATOR_IS_NONE2], 37986 validOperators: [ 37987 OPERATOR_IS2, 37988 OPERATOR_IS_NOT, 37989 OPERATOR_IS_ANY2, 37990 OPERATOR_IS_NONE2 37991 ], 37992 format: {}, 37993 getValueFormatted: get_value_formatted_default_default, 37994 validate: { 37995 required: isValidRequired, 37996 elements: isValidElements, 37997 custom: isValidCustom6 37998 } 37999 }; 38000 38001 // packages/dataviews/build-module/field-types/url.js 38002 var url_default = { 38003 type: "url", 38004 render, 38005 Edit: "url", 38006 sort: sort_text_default, 38007 enableSorting: true, 38008 enableGlobalSearch: false, 38009 defaultOperators: [OPERATOR_IS_ANY2, OPERATOR_IS_NONE2], 38010 validOperators: [ 38011 OPERATOR_IS2, 38012 OPERATOR_IS_NOT, 38013 OPERATOR_CONTAINS, 38014 OPERATOR_NOT_CONTAINS, 38015 OPERATOR_STARTS_WITH, 38016 // Multiple selection 38017 OPERATOR_IS_ANY2, 38018 OPERATOR_IS_NONE2, 38019 OPERATOR_IS_ALL, 38020 OPERATOR_IS_NOT_ALL 38021 ], 38022 format: {}, 38023 getValueFormatted: get_value_formatted_default_default, 38024 validate: { 38025 required: isValidRequired, 38026 pattern: isValidPattern, 38027 minLength: isValidMinLength, 38028 maxLength: isValidMaxLength, 38029 elements: isValidElements 38030 } 38031 }; 38032 38033 // packages/dataviews/build-module/field-types/no-type.js 38034 var sort6 = (a2, b2, direction) => { 38035 if (typeof a2 === "number" && typeof b2 === "number") { 38036 return sort_number_default(a2, b2, direction); 38037 } 38038 return sort_text_default(a2, b2, direction); 38039 }; 38040 var no_type_default = { 38041 // type: no type for this one 38042 render, 38043 Edit: null, 38044 sort: sort6, 38045 enableSorting: true, 38046 enableGlobalSearch: false, 38047 defaultOperators: [OPERATOR_IS2, OPERATOR_IS_NOT], 38048 validOperators: getAllOperatorNames(), 38049 format: {}, 38050 getValueFormatted: get_value_formatted_default_default, 38051 validate: { 38052 required: isValidRequired, 38053 elements: isValidElements 38054 } 38055 }; 38056 38057 // packages/dataviews/build-module/field-types/utils/get-is-valid.js 38058 function getIsValid(field, fieldType) { 38059 let required; 38060 if (field.isValid?.required === true && fieldType.validate.required !== void 0) { 38061 required = { 38062 constraint: true, 38063 validate: fieldType.validate.required 38064 }; 38065 } 38066 let elements2; 38067 if ((field.isValid?.elements === true || // elements is enabled unless the field opts-out 38068 field.isValid?.elements === void 0 && (!!field.elements || !!field.getElements)) && fieldType.validate.elements !== void 0) { 38069 elements2 = { 38070 constraint: true, 38071 validate: fieldType.validate.elements 38072 }; 38073 } 38074 let min; 38075 if (typeof field.isValid?.min === "number" && fieldType.validate.min !== void 0) { 38076 min = { 38077 constraint: field.isValid.min, 38078 validate: fieldType.validate.min 38079 }; 38080 } 38081 let max; 38082 if (typeof field.isValid?.max === "number" && fieldType.validate.max !== void 0) { 38083 max = { 38084 constraint: field.isValid.max, 38085 validate: fieldType.validate.max 38086 }; 38087 } 38088 let minLength; 38089 if (typeof field.isValid?.minLength === "number" && fieldType.validate.minLength !== void 0) { 38090 minLength = { 38091 constraint: field.isValid.minLength, 38092 validate: fieldType.validate.minLength 38093 }; 38094 } 38095 let maxLength; 38096 if (typeof field.isValid?.maxLength === "number" && fieldType.validate.maxLength !== void 0) { 38097 maxLength = { 38098 constraint: field.isValid.maxLength, 38099 validate: fieldType.validate.maxLength 38100 }; 38101 } 38102 let pattern; 38103 if (field.isValid?.pattern !== void 0 && fieldType.validate.pattern !== void 0) { 38104 pattern = { 38105 constraint: field.isValid?.pattern, 38106 validate: fieldType.validate.pattern 38107 }; 38108 } 38109 const custom = field.isValid?.custom ?? fieldType.validate.custom; 38110 return { 38111 required, 38112 elements: elements2, 38113 min, 38114 max, 38115 minLength, 38116 maxLength, 38117 pattern, 38118 custom 38119 }; 38120 } 38121 38122 // packages/dataviews/build-module/field-types/utils/get-format.js 38123 function getFormat(field, fieldType) { 38124 return { 38125 ...fieldType.format, 38126 ...field.format 38127 }; 38128 } 38129 var get_format_default = getFormat; 38130 38131 // packages/dataviews/build-module/field-types/index.js 38132 function getFieldTypeByName(type) { 38133 const found = [ 38134 email_default, 38135 integer_default, 38136 number_default, 38137 text_default, 38138 datetime_default, 38139 date_default, 38140 boolean_default, 38141 media_default2, 38142 array_default, 38143 password_default, 38144 telephone_default, 38145 color_default, 38146 url_default 38147 ].find((fieldType) => fieldType?.type === type); 38148 if (!!found) { 38149 return found; 38150 } 38151 return no_type_default; 38152 } 38153 function normalizeFields(fields) { 38154 return fields.map((field) => { 38155 const fieldType = getFieldTypeByName(field.type); 38156 const getValue = field.getValue || get_value_from_id_default(field.id); 38157 const sort7 = function(a2, b2, direction) { 38158 const aValue = getValue({ item: a2 }); 38159 const bValue = getValue({ item: b2 }); 38160 return field.sort ? field.sort(aValue, bValue, direction) : fieldType.sort(aValue, bValue, direction); 38161 }; 38162 return { 38163 id: field.id, 38164 label: field.label || field.id, 38165 header: field.header || field.label || field.id, 38166 description: field.description, 38167 placeholder: field.placeholder, 38168 getValue, 38169 setValue: field.setValue || set_value_from_id_default(field.id), 38170 elements: field.elements, 38171 getElements: field.getElements, 38172 hasElements: hasElements(field), 38173 isVisible: field.isVisible, 38174 enableHiding: field.enableHiding ?? true, 38175 readOnly: field.readOnly ?? false, 38176 // The type provides defaults for the following props 38177 type: fieldType.type, 38178 render: field.render ?? fieldType.render, 38179 Edit: getControl(field, fieldType.Edit), 38180 sort: sort7, 38181 enableSorting: field.enableSorting ?? fieldType.enableSorting, 38182 enableGlobalSearch: field.enableGlobalSearch ?? fieldType.enableGlobalSearch, 38183 isValid: getIsValid(field, fieldType), 38184 filterBy: get_filter_by_default( 38185 field, 38186 fieldType.defaultOperators, 38187 fieldType.validOperators 38188 ), 38189 format: get_format_default(field, fieldType), 38190 getValueFormatted: field.getValueFormatted ?? fieldType.getValueFormatted 38191 }; 38192 }); 38193 } 38194 38195 // packages/dataviews/build-module/components/dataviews/index.js 38196 var import_jsx_runtime251 = __toESM(require_jsx_runtime()); 38197 var defaultGetItemId = (item) => item.id; 38198 var defaultIsItemClickable = () => true; 38199 var EMPTY_ARRAY8 = []; 38200 var dataViewsLayouts = VIEW_LAYOUTS.filter( 38201 (viewLayout) => !viewLayout.isPicker 38202 ); 38203 function DefaultUI({ 38204 header, 38205 search = true, 38206 searchLabel = void 0 38207 }) { 38208 return /* @__PURE__ */ (0, import_jsx_runtime251.jsxs)(import_jsx_runtime251.Fragment, { children: [ 38209 /* @__PURE__ */ (0, import_jsx_runtime251.jsxs)( 38210 import_components140.__experimentalHStack, 38211 { 38212 alignment: "top", 38213 justify: "space-between", 38214 className: "dataviews__view-actions", 38215 spacing: 1, 38216 children: [ 38217 /* @__PURE__ */ (0, import_jsx_runtime251.jsxs)( 38218 import_components140.__experimentalHStack, 38219 { 38220 justify: "start", 38221 expanded: false, 38222 className: "dataviews__search", 38223 children: [ 38224 search && /* @__PURE__ */ (0, import_jsx_runtime251.jsx)(dataviews_search_default, { label: searchLabel }), 38225 /* @__PURE__ */ (0, import_jsx_runtime251.jsx)(toggle_default, {}) 38226 ] 38227 } 38228 ), 38229 /* @__PURE__ */ (0, import_jsx_runtime251.jsxs)( 38230 import_components140.__experimentalHStack, 38231 { 38232 spacing: 1, 38233 expanded: false, 38234 style: { flexShrink: 0 }, 38235 children: [ 38236 /* @__PURE__ */ (0, import_jsx_runtime251.jsx)(dataviews_view_config_default, {}), 38237 header 38238 ] 38239 } 38240 ) 38241 ] 38242 } 38243 ), 38244 /* @__PURE__ */ (0, import_jsx_runtime251.jsx)(filters_toggled_default, { className: "dataviews-filters__container" }), 38245 /* @__PURE__ */ (0, import_jsx_runtime251.jsx)(DataViewsLayout, {}), 38246 /* @__PURE__ */ (0, import_jsx_runtime251.jsx)(DataViewsFooter, {}) 38247 ] }); 38248 } 38249 function DataViews({ 38250 view, 38251 onChangeView, 38252 fields, 38253 search = true, 38254 searchLabel = void 0, 38255 actions = EMPTY_ARRAY8, 38256 data, 38257 getItemId: getItemId2 = defaultGetItemId, 38258 getItemLevel: getItemLevel2, 38259 isLoading = false, 38260 paginationInfo, 38261 defaultLayouts: defaultLayoutsProperty, 38262 selection: selectionProperty, 38263 onChangeSelection, 38264 onClickItem, 38265 renderItemLink, 38266 isItemClickable = defaultIsItemClickable, 38267 header, 38268 children, 38269 config: config2 = { perPageSizes: [10, 20, 50, 100] }, 38270 empty 38271 }) { 38272 const { infiniteScrollHandler } = paginationInfo; 38273 const containerRef = (0, import_element115.useRef)(null); 38274 const [containerWidth, setContainerWidth] = (0, import_element115.useState)(0); 38275 const resizeObserverRef = (0, import_compose22.useResizeObserver)( 38276 (resizeObserverEntries) => { 38277 setContainerWidth( 38278 resizeObserverEntries[0].borderBoxSize[0].inlineSize 38279 ); 38280 }, 38281 { box: "border-box" } 38282 ); 38283 const [selectionState, setSelectionState] = (0, import_element115.useState)([]); 38284 const isUncontrolled = selectionProperty === void 0 || onChangeSelection === void 0; 38285 const selection = isUncontrolled ? selectionState : selectionProperty; 38286 const [openedFilter, setOpenedFilter] = (0, import_element115.useState)(null); 38287 function setSelectionWithChange(value) { 38288 const newValue = typeof value === "function" ? value(selection) : value; 38289 if (isUncontrolled) { 38290 setSelectionState(newValue); 38291 } 38292 if (onChangeSelection) { 38293 onChangeSelection(newValue); 38294 } 38295 } 38296 const _fields = (0, import_element115.useMemo)(() => normalizeFields(fields), [fields]); 38297 const _selection = (0, import_element115.useMemo)(() => { 38298 return selection.filter( 38299 (id) => data.some((item) => getItemId2(item) === id) 38300 ); 38301 }, [selection, data, getItemId2]); 38302 const filters = use_filters_default(_fields, view); 38303 const hasPrimaryOrLockedFilters = (0, import_element115.useMemo)( 38304 () => (filters || []).some( 38305 (filter) => filter.isPrimary || filter.isLocked 38306 ), 38307 [filters] 38308 ); 38309 const [isShowingFilter, setIsShowingFilter] = (0, import_element115.useState)( 38310 hasPrimaryOrLockedFilters 38311 ); 38312 (0, import_element115.useEffect)(() => { 38313 if (hasPrimaryOrLockedFilters && !isShowingFilter) { 38314 setIsShowingFilter(true); 38315 } 38316 }, [hasPrimaryOrLockedFilters, isShowingFilter]); 38317 (0, import_element115.useEffect)(() => { 38318 if (!view.infiniteScrollEnabled || !containerRef.current) { 38319 return; 38320 } 38321 const handleScroll = (0, import_compose22.throttle)((event) => { 38322 const target = event.target; 38323 const scrollTop = target.scrollTop; 38324 const scrollHeight = target.scrollHeight; 38325 const clientHeight = target.clientHeight; 38326 if (scrollTop + clientHeight >= scrollHeight - 100) { 38327 infiniteScrollHandler?.(); 38328 } 38329 }, 100); 38330 const container = containerRef.current; 38331 container.addEventListener("scroll", handleScroll); 38332 return () => { 38333 container.removeEventListener("scroll", handleScroll); 38334 handleScroll.cancel(); 38335 }; 38336 }, [infiniteScrollHandler, view.infiniteScrollEnabled]); 38337 const defaultLayouts4 = (0, import_element115.useMemo)( 38338 () => Object.fromEntries( 38339 Object.entries(defaultLayoutsProperty).filter( 38340 ([layoutType]) => { 38341 return dataViewsLayouts.some( 38342 (viewLayout) => viewLayout.type === layoutType 38343 ); 38344 } 38345 ) 38346 ), 38347 [defaultLayoutsProperty] 38348 ); 38349 if (!defaultLayouts4[view.type]) { 38350 return null; 38351 } 38352 return /* @__PURE__ */ (0, import_jsx_runtime251.jsx)( 38353 dataviews_context_default.Provider, 38354 { 38355 value: { 38356 view, 38357 onChangeView, 38358 fields: _fields, 38359 actions, 38360 data, 38361 isLoading, 38362 paginationInfo, 38363 selection: _selection, 38364 onChangeSelection: setSelectionWithChange, 38365 openedFilter, 38366 setOpenedFilter, 38367 getItemId: getItemId2, 38368 getItemLevel: getItemLevel2, 38369 isItemClickable, 38370 onClickItem, 38371 renderItemLink, 38372 containerWidth, 38373 containerRef, 38374 resizeObserverRef, 38375 defaultLayouts: defaultLayouts4, 38376 filters, 38377 isShowingFilter, 38378 setIsShowingFilter, 38379 config: config2, 38380 empty, 38381 hasInfiniteScrollHandler: !!infiniteScrollHandler 38382 }, 38383 children: /* @__PURE__ */ (0, import_jsx_runtime251.jsx)("div", { className: "dataviews-wrapper", ref: containerRef, children: children ?? /* @__PURE__ */ (0, import_jsx_runtime251.jsx)( 38384 DefaultUI, 38385 { 38386 header, 38387 search, 38388 searchLabel 38389 } 38390 ) }) 38391 } 38392 ); 38393 } 38394 var DataViewsSubComponents = DataViews; 38395 DataViewsSubComponents.BulkActionToolbar = BulkActionsFooter; 38396 DataViewsSubComponents.Filters = filters_default; 38397 DataViewsSubComponents.FiltersToggled = filters_toggled_default; 38398 DataViewsSubComponents.FiltersToggle = toggle_default; 38399 DataViewsSubComponents.Layout = DataViewsLayout; 38400 DataViewsSubComponents.LayoutSwitcher = ViewTypeMenu; 38401 DataViewsSubComponents.Pagination = DataViewsPagination; 38402 DataViewsSubComponents.Search = dataviews_search_default; 38403 DataViewsSubComponents.ViewConfig = DataviewsViewConfigDropdown; 38404 DataViewsSubComponents.Footer = DataViewsFooter; 38405 var dataviews_default = DataViewsSubComponents; 38406 38407 // packages/dataviews/build-module/components/dataform/index.js 38408 var import_element125 = __toESM(require_element()); 38409 38410 // packages/dataviews/build-module/components/dataform-context/index.js 38411 var import_element116 = __toESM(require_element()); 38412 var import_jsx_runtime252 = __toESM(require_jsx_runtime()); 38413 var DataFormContext = (0, import_element116.createContext)({ 38414 fields: [] 38415 }); 38416 DataFormContext.displayName = "DataFormContext"; 38417 function DataFormProvider({ 38418 fields, 38419 children 38420 }) { 38421 return /* @__PURE__ */ (0, import_jsx_runtime252.jsx)(DataFormContext.Provider, { value: { fields }, children }); 38422 } 38423 var dataform_context_default = DataFormContext; 38424 38425 // packages/dataviews/build-module/dataform-layouts/data-form-layout.js 38426 var import_components149 = __toESM(require_components()); 38427 var import_element124 = __toESM(require_element()); 38428 38429 // packages/dataviews/build-module/dataform-layouts/index.js 38430 var import_components148 = __toESM(require_components()); 38431 38432 // packages/dataviews/build-module/dataform-layouts/regular/index.js 38433 var import_element117 = __toESM(require_element()); 38434 var import_components141 = __toESM(require_components()); 38435 38436 // packages/dataviews/build-module/dataform-layouts/normalize-form.js 38437 var DEFAULT_LAYOUT = { 38438 type: "regular", 38439 labelPosition: "top" 38440 }; 38441 var normalizeCardSummaryField = (sum) => { 38442 if (typeof sum === "string") { 38443 return [{ id: sum, visibility: "when-collapsed" }]; 38444 } 38445 return sum.map((item) => { 38446 if (typeof item === "string") { 38447 return { id: item, visibility: "when-collapsed" }; 38448 } 38449 return { id: item.id, visibility: item.visibility }; 38450 }); 38451 }; 38452 function normalizeLayout(layout) { 38453 let normalizedLayout = DEFAULT_LAYOUT; 38454 if (layout?.type === "regular") { 38455 normalizedLayout = { 38456 type: "regular", 38457 labelPosition: layout?.labelPosition ?? "top" 38458 }; 38459 } else if (layout?.type === "panel") { 38460 const summary = layout.summary ?? []; 38461 const normalizedSummary = Array.isArray(summary) ? summary : [summary]; 38462 normalizedLayout = { 38463 type: "panel", 38464 labelPosition: layout?.labelPosition ?? "side", 38465 openAs: layout?.openAs ?? "dropdown", 38466 summary: normalizedSummary 38467 }; 38468 } else if (layout?.type === "card") { 38469 if (layout.withHeader === false) { 38470 normalizedLayout = { 38471 type: "card", 38472 withHeader: false, 38473 isOpened: true, 38474 summary: [], 38475 isCollapsible: false 38476 }; 38477 } else { 38478 const summary = layout.summary ?? []; 38479 normalizedLayout = { 38480 type: "card", 38481 withHeader: true, 38482 isOpened: typeof layout.isOpened === "boolean" ? layout.isOpened : true, 38483 summary: normalizeCardSummaryField(summary), 38484 isCollapsible: layout.isCollapsible === void 0 ? true : layout.isCollapsible 38485 }; 38486 } 38487 } else if (layout?.type === "row") { 38488 normalizedLayout = { 38489 type: "row", 38490 alignment: layout?.alignment ?? "center", 38491 styles: layout?.styles ?? {} 38492 }; 38493 } else if (layout?.type === "details") { 38494 normalizedLayout = { 38495 type: "details", 38496 summary: layout?.summary ?? "" 38497 }; 38498 } 38499 return normalizedLayout; 38500 } 38501 function normalizeForm(form) { 38502 const normalizedFormLayout = normalizeLayout(form?.layout); 38503 const normalizedFields = (form.fields ?? []).map( 38504 (field) => { 38505 if (typeof field === "string") { 38506 return { 38507 id: field, 38508 layout: normalizedFormLayout 38509 }; 38510 } 38511 const fieldLayout = field.layout ? normalizeLayout(field.layout) : normalizedFormLayout; 38512 return { 38513 id: field.id, 38514 layout: fieldLayout, 38515 ...!!field.label && { label: field.label }, 38516 ...!!field.description && { 38517 description: field.description 38518 }, 38519 ..."children" in field && Array.isArray(field.children) && { 38520 children: normalizeForm({ 38521 fields: field.children, 38522 layout: DEFAULT_LAYOUT 38523 }).fields 38524 } 38525 }; 38526 } 38527 ); 38528 return { 38529 layout: normalizedFormLayout, 38530 fields: normalizedFields 38531 }; 38532 } 38533 var normalize_form_default = normalizeForm; 38534 38535 // packages/dataviews/build-module/dataform-layouts/regular/index.js 38536 var import_jsx_runtime253 = __toESM(require_jsx_runtime()); 38537 function Header2({ title }) { 38538 return /* @__PURE__ */ (0, import_jsx_runtime253.jsx)(import_components141.__experimentalVStack, { className: "dataforms-layouts-regular__header", spacing: 4, children: /* @__PURE__ */ (0, import_jsx_runtime253.jsxs)(import_components141.__experimentalHStack, { alignment: "center", children: [ 38539 /* @__PURE__ */ (0, import_jsx_runtime253.jsx)(import_components141.__experimentalHeading, { level: 2, size: 13, children: title }), 38540 /* @__PURE__ */ (0, import_jsx_runtime253.jsx)(import_components141.__experimentalSpacer, {}) 38541 ] }) }); 38542 } 38543 function FormRegularField({ 38544 data, 38545 field, 38546 onChange, 38547 hideLabelFromVision, 38548 validity 38549 }) { 38550 const { fields } = (0, import_element117.useContext)(dataform_context_default); 38551 const layout = field.layout; 38552 const form = (0, import_element117.useMemo)( 38553 () => ({ 38554 layout: DEFAULT_LAYOUT, 38555 fields: !!field.children ? field.children : [] 38556 }), 38557 [field] 38558 ); 38559 if (!!field.children) { 38560 return /* @__PURE__ */ (0, import_jsx_runtime253.jsxs)(import_jsx_runtime253.Fragment, { children: [ 38561 !hideLabelFromVision && field.label && /* @__PURE__ */ (0, import_jsx_runtime253.jsx)(Header2, { title: field.label }), 38562 /* @__PURE__ */ (0, import_jsx_runtime253.jsx)( 38563 DataFormLayout, 38564 { 38565 data, 38566 form, 38567 onChange, 38568 validity: validity?.children 38569 } 38570 ) 38571 ] }); 38572 } 38573 const labelPosition = layout.labelPosition; 38574 const fieldDefinition = fields.find( 38575 (fieldDef) => fieldDef.id === field.id 38576 ); 38577 if (!fieldDefinition || !fieldDefinition.Edit) { 38578 return null; 38579 } 38580 if (labelPosition === "side") { 38581 return /* @__PURE__ */ (0, import_jsx_runtime253.jsxs)(import_components141.__experimentalHStack, { className: "dataforms-layouts-regular__field", children: [ 38582 /* @__PURE__ */ (0, import_jsx_runtime253.jsx)( 38583 "div", 38584 { 38585 className: clsx_default( 38586 "dataforms-layouts-regular__field-label", 38587 `dataforms-layouts-regular__field-label--label-position-$labelPosition}` 38588 ), 38589 children: fieldDefinition.label 38590 } 38591 ), 38592 /* @__PURE__ */ (0, import_jsx_runtime253.jsx)("div", { className: "dataforms-layouts-regular__field-control", children: fieldDefinition.readOnly === true ? /* @__PURE__ */ (0, import_jsx_runtime253.jsx)( 38593 fieldDefinition.render, 38594 { 38595 item: data, 38596 field: fieldDefinition 38597 } 38598 ) : /* @__PURE__ */ (0, import_jsx_runtime253.jsx)( 38599 fieldDefinition.Edit, 38600 { 38601 data, 38602 field: fieldDefinition, 38603 onChange, 38604 hideLabelFromVision: true, 38605 validity 38606 }, 38607 fieldDefinition.id 38608 ) }) 38609 ] }); 38610 } 38611 return /* @__PURE__ */ (0, import_jsx_runtime253.jsx)("div", { className: "dataforms-layouts-regular__field", children: fieldDefinition.readOnly === true ? /* @__PURE__ */ (0, import_jsx_runtime253.jsx)(import_jsx_runtime253.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime253.jsxs)(import_jsx_runtime253.Fragment, { children: [ 38612 !hideLabelFromVision && labelPosition !== "none" && /* @__PURE__ */ (0, import_jsx_runtime253.jsx)(import_components141.BaseControl.VisualLabel, { children: fieldDefinition.label }), 38613 /* @__PURE__ */ (0, import_jsx_runtime253.jsx)( 38614 fieldDefinition.render, 38615 { 38616 item: data, 38617 field: fieldDefinition 38618 } 38619 ) 38620 ] }) }) : /* @__PURE__ */ (0, import_jsx_runtime253.jsx)( 38621 fieldDefinition.Edit, 38622 { 38623 data, 38624 field: fieldDefinition, 38625 onChange, 38626 hideLabelFromVision: labelPosition === "none" ? true : hideLabelFromVision, 38627 validity 38628 } 38629 ) }); 38630 } 38631 38632 // packages/dataviews/build-module/dataform-layouts/panel/index.js 38633 var import_components145 = __toESM(require_components()); 38634 var import_element121 = __toESM(require_element()); 38635 38636 // packages/dataviews/build-module/dataform-layouts/panel/dropdown.js 38637 var import_components143 = __toESM(require_components()); 38638 var import_i18n125 = __toESM(require_i18n()); 38639 var import_element118 = __toESM(require_element()); 38640 var import_compose23 = __toESM(require_compose()); 38641 38642 // packages/dataviews/build-module/dataform-layouts/panel/summary-button.js 38643 var import_components142 = __toESM(require_components()); 38644 var import_i18n124 = __toESM(require_i18n()); 38645 var import_jsx_runtime254 = __toESM(require_jsx_runtime()); 38646 function SummaryButton({ 38647 summaryFields, 38648 data, 38649 labelPosition, 38650 fieldLabel, 38651 disabled, 38652 onClick, 38653 "aria-expanded": ariaExpanded 38654 }) { 38655 return /* @__PURE__ */ (0, import_jsx_runtime254.jsx)( 38656 import_components142.Button, 38657 { 38658 className: "dataforms-layouts-panel__summary-button", 38659 size: "compact", 38660 variant: ["none", "top"].includes(labelPosition) ? "link" : "tertiary", 38661 "aria-expanded": ariaExpanded, 38662 "aria-label": (0, import_i18n124.sprintf)( 38663 // translators: %s: Field name. 38664 (0, import_i18n124._x)("Edit %s", "field"), 38665 fieldLabel || "" 38666 ), 38667 onClick, 38668 disabled, 38669 accessibleWhenDisabled: true, 38670 style: summaryFields.length > 1 ? { 38671 minHeight: "auto", 38672 height: "auto", 38673 alignItems: "flex-start" 38674 } : void 0, 38675 children: summaryFields.length > 1 ? /* @__PURE__ */ (0, import_jsx_runtime254.jsx)( 38676 "div", 38677 { 38678 style: { 38679 display: "flex", 38680 flexDirection: "column", 38681 alignItems: "flex-start", 38682 width: "100%", 38683 gap: "2px" 38684 }, 38685 children: summaryFields.map((summaryField) => /* @__PURE__ */ (0, import_jsx_runtime254.jsx)( 38686 "div", 38687 { 38688 style: { width: "100%" }, 38689 children: /* @__PURE__ */ (0, import_jsx_runtime254.jsx)( 38690 summaryField.render, 38691 { 38692 item: data, 38693 field: summaryField 38694 } 38695 ) 38696 }, 38697 summaryField.id 38698 )) 38699 } 38700 ) : summaryFields.map((summaryField) => /* @__PURE__ */ (0, import_jsx_runtime254.jsx)( 38701 summaryField.render, 38702 { 38703 item: data, 38704 field: summaryField 38705 }, 38706 summaryField.id 38707 )) 38708 } 38709 ); 38710 } 38711 var summary_button_default = SummaryButton; 38712 38713 // packages/dataviews/build-module/dataform-layouts/panel/dropdown.js 38714 var import_jsx_runtime255 = __toESM(require_jsx_runtime()); 38715 function DropdownHeader({ 38716 title, 38717 onClose 38718 }) { 38719 return /* @__PURE__ */ (0, import_jsx_runtime255.jsx)( 38720 import_components143.__experimentalVStack, 38721 { 38722 className: "dataforms-layouts-panel__dropdown-header", 38723 spacing: 4, 38724 children: /* @__PURE__ */ (0, import_jsx_runtime255.jsxs)(import_components143.__experimentalHStack, { alignment: "center", children: [ 38725 title && /* @__PURE__ */ (0, import_jsx_runtime255.jsx)(import_components143.__experimentalHeading, { level: 2, size: 13, children: title }), 38726 /* @__PURE__ */ (0, import_jsx_runtime255.jsx)(import_components143.__experimentalSpacer, {}), 38727 onClose && /* @__PURE__ */ (0, import_jsx_runtime255.jsx)( 38728 import_components143.Button, 38729 { 38730 label: (0, import_i18n125.__)("Close"), 38731 icon: close_small_default, 38732 onClick: onClose, 38733 size: "small" 38734 } 38735 ) 38736 ] }) 38737 } 38738 ); 38739 } 38740 function PanelDropdown({ 38741 data, 38742 field, 38743 onChange, 38744 validity, 38745 labelPosition = "side", 38746 summaryFields, 38747 fieldDefinition, 38748 popoverAnchor, 38749 onOpen 38750 }) { 38751 const fieldLabel = !!field.children ? field.label : fieldDefinition?.label; 38752 const form = (0, import_element118.useMemo)( 38753 () => ({ 38754 layout: DEFAULT_LAYOUT, 38755 fields: !!field.children ? field.children : ( 38756 // If not explicit children return the field id itself. 38757 [{ id: field.id, layout: DEFAULT_LAYOUT }] 38758 ) 38759 }), 38760 [field] 38761 ); 38762 const formValidity = (0, import_element118.useMemo)(() => { 38763 if (validity === void 0) { 38764 return void 0; 38765 } 38766 if (!!field.children) { 38767 return validity?.children; 38768 } 38769 return { [field.id]: validity }; 38770 }, [validity, field]); 38771 const popoverProps = (0, import_element118.useMemo)( 38772 () => ({ 38773 // Anchor the popover to the middle of the entire row so that it doesn't 38774 // move around when the label changes. 38775 anchor: popoverAnchor, 38776 placement: "left-start", 38777 offset: 36, 38778 shift: true 38779 }), 38780 [popoverAnchor] 38781 ); 38782 const focusOnMountRef = (0, import_compose23.useFocusOnMount)("firstInputElement"); 38783 return /* @__PURE__ */ (0, import_jsx_runtime255.jsx)( 38784 import_components143.Dropdown, 38785 { 38786 contentClassName: "dataforms-layouts-panel__field-dropdown", 38787 popoverProps, 38788 focusOnMount: false, 38789 toggleProps: { 38790 size: "compact", 38791 variant: "tertiary", 38792 tooltipPosition: "middle left" 38793 }, 38794 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime255.jsx)( 38795 summary_button_default, 38796 { 38797 summaryFields, 38798 data, 38799 labelPosition, 38800 fieldLabel, 38801 disabled: fieldDefinition.readOnly === true, 38802 onClick: () => { 38803 if (!isOpen && onOpen) { 38804 onOpen(); 38805 } 38806 onToggle(); 38807 }, 38808 "aria-expanded": isOpen 38809 } 38810 ), 38811 renderContent: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime255.jsxs)(import_jsx_runtime255.Fragment, { children: [ 38812 /* @__PURE__ */ (0, import_jsx_runtime255.jsx)(DropdownHeader, { title: fieldLabel, onClose }), 38813 /* @__PURE__ */ (0, import_jsx_runtime255.jsx)("div", { ref: focusOnMountRef, children: /* @__PURE__ */ (0, import_jsx_runtime255.jsx)( 38814 DataFormLayout, 38815 { 38816 data, 38817 form, 38818 onChange, 38819 validity: formValidity, 38820 children: (FieldLayout, childField, childFieldValidity) => /* @__PURE__ */ (0, import_jsx_runtime255.jsx)( 38821 FieldLayout, 38822 { 38823 data, 38824 field: childField, 38825 onChange, 38826 hideLabelFromVision: (form?.fields ?? []).length < 2, 38827 validity: childFieldValidity 38828 }, 38829 childField.id 38830 ) 38831 } 38832 ) }) 38833 ] }) 38834 } 38835 ); 38836 } 38837 var dropdown_default = PanelDropdown; 38838 38839 // packages/dataviews/build-module/dataform-layouts/panel/modal.js 38840 var import_deepmerge3 = __toESM(require_cjs()); 38841 var import_components144 = __toESM(require_components()); 38842 var import_i18n127 = __toESM(require_i18n()); 38843 var import_element120 = __toESM(require_element()); 38844 var import_compose24 = __toESM(require_compose()); 38845 38846 // packages/dataviews/build-module/hooks/use-form-validity.js 38847 var import_deepmerge2 = __toESM(require_cjs()); 38848 var import_es63 = __toESM(require_es6()); 38849 var import_element119 = __toESM(require_element()); 38850 var import_i18n126 = __toESM(require_i18n()); 38851 function isFormValid(formValidity) { 38852 if (!formValidity) { 38853 return true; 38854 } 38855 return Object.values(formValidity).every((fieldValidation) => { 38856 return Object.entries(fieldValidation).every( 38857 ([key, validation]) => { 38858 if (key === "children" && validation && typeof validation === "object") { 38859 return isFormValid(validation); 38860 } 38861 return validation.type === "valid"; 38862 } 38863 ); 38864 }); 38865 } 38866 function getFormFieldsToValidate(form, fields) { 38867 const normalizedForm = normalize_form_default(form); 38868 if (normalizedForm.fields.length === 0) { 38869 return []; 38870 } 38871 const fieldsMap = /* @__PURE__ */ new Map(); 38872 fields.forEach((field) => { 38873 fieldsMap.set(field.id, field); 38874 }); 38875 function processFormField(formField) { 38876 if ("children" in formField && Array.isArray(formField.children)) { 38877 const processedChildren = formField.children.map(processFormField).filter((child) => child !== null); 38878 if (processedChildren.length === 0) { 38879 return null; 38880 } 38881 const fieldDef2 = fieldsMap.get(formField.id); 38882 if (fieldDef2) { 38883 const [normalizedField2] = normalizeFields([ 38884 fieldDef2 38885 ]); 38886 return { 38887 id: formField.id, 38888 children: processedChildren, 38889 field: normalizedField2 38890 }; 38891 } 38892 return { 38893 id: formField.id, 38894 children: processedChildren 38895 }; 38896 } 38897 const fieldDef = fieldsMap.get(formField.id); 38898 if (!fieldDef) { 38899 return null; 38900 } 38901 const [normalizedField] = normalizeFields([fieldDef]); 38902 return { 38903 id: formField.id, 38904 children: [], 38905 field: normalizedField 38906 }; 38907 } 38908 const toValidate = normalizedForm.fields.map(processFormField).filter((field) => field !== null); 38909 return toValidate; 38910 } 38911 function setValidityAtPath(formValidity, fieldValidity, path) { 38912 if (!formValidity) { 38913 formValidity = {}; 38914 } 38915 if (path.length === 0) { 38916 return formValidity; 38917 } 38918 const result = { ...formValidity }; 38919 let current = result; 38920 for (let i2 = 0; i2 < path.length - 1; i2++) { 38921 const segment = path[i2]; 38922 if (!current[segment]) { 38923 current[segment] = {}; 38924 } 38925 current = current[segment]; 38926 } 38927 const finalKey = path[path.length - 1]; 38928 current[finalKey] = { 38929 ...current[finalKey] || {}, 38930 ...fieldValidity 38931 }; 38932 return result; 38933 } 38934 function handleElementsValidationAsync(promise, formField, promiseHandler) { 38935 const { elementsCounterRef, setFormValidity, path, item } = promiseHandler; 38936 const currentToken = (elementsCounterRef.current[formField.id] || 0) + 1; 38937 elementsCounterRef.current[formField.id] = currentToken; 38938 promise.then((result) => { 38939 if (currentToken !== elementsCounterRef.current[formField.id]) { 38940 return; 38941 } 38942 if (!Array.isArray(result)) { 38943 setFormValidity((prev) => { 38944 const newFormValidity = setValidityAtPath( 38945 prev, 38946 { 38947 elements: { 38948 type: "invalid", 38949 message: (0, import_i18n126.__)("Could not validate elements.") 38950 } 38951 }, 38952 [...path, formField.id] 38953 ); 38954 return newFormValidity; 38955 }); 38956 return; 38957 } 38958 if (formField.field?.isValid.elements && !formField.field.isValid.elements.validate(item, { 38959 ...formField.field, 38960 elements: result 38961 })) { 38962 setFormValidity((prev) => { 38963 const newFormValidity = setValidityAtPath( 38964 prev, 38965 { 38966 elements: { 38967 type: "invalid", 38968 message: (0, import_i18n126.__)( 38969 "Value must be one of the elements." 38970 ) 38971 } 38972 }, 38973 [...path, formField.id] 38974 ); 38975 return newFormValidity; 38976 }); 38977 } 38978 }).catch((error) => { 38979 if (currentToken !== elementsCounterRef.current[formField.id]) { 38980 return; 38981 } 38982 let errorMessage; 38983 if (error instanceof Error) { 38984 errorMessage = error.message; 38985 } else { 38986 errorMessage = String(error) || (0, import_i18n126.__)( 38987 "Unknown error when running elements validation asynchronously." 38988 ); 38989 } 38990 setFormValidity((prev) => { 38991 const newFormValidity = setValidityAtPath( 38992 prev, 38993 { 38994 elements: { 38995 type: "invalid", 38996 message: errorMessage 38997 } 38998 }, 38999 [...path, formField.id] 39000 ); 39001 return newFormValidity; 39002 }); 39003 }); 39004 } 39005 function handleCustomValidationAsync(promise, formField, promiseHandler) { 39006 const { customCounterRef, setFormValidity, path } = promiseHandler; 39007 const currentToken = (customCounterRef.current[formField.id] || 0) + 1; 39008 customCounterRef.current[formField.id] = currentToken; 39009 promise.then((result) => { 39010 if (currentToken !== customCounterRef.current[formField.id]) { 39011 return; 39012 } 39013 if (result === null) { 39014 setFormValidity((prev) => { 39015 const newFormValidity = setValidityAtPath( 39016 prev, 39017 { 39018 custom: { 39019 type: "valid", 39020 message: (0, import_i18n126.__)("Valid") 39021 } 39022 }, 39023 [...path, formField.id] 39024 ); 39025 return newFormValidity; 39026 }); 39027 return; 39028 } 39029 if (typeof result === "string") { 39030 setFormValidity((prev) => { 39031 const newFormValidity = setValidityAtPath( 39032 prev, 39033 { 39034 custom: { 39035 type: "invalid", 39036 message: result 39037 } 39038 }, 39039 [...path, formField.id] 39040 ); 39041 return newFormValidity; 39042 }); 39043 return; 39044 } 39045 setFormValidity((prev) => { 39046 const newFormValidity = setValidityAtPath( 39047 prev, 39048 { 39049 custom: { 39050 type: "invalid", 39051 message: (0, import_i18n126.__)("Validation could not be processed.") 39052 } 39053 }, 39054 [...path, formField.id] 39055 ); 39056 return newFormValidity; 39057 }); 39058 }).catch((error) => { 39059 if (currentToken !== customCounterRef.current[formField.id]) { 39060 return; 39061 } 39062 let errorMessage; 39063 if (error instanceof Error) { 39064 errorMessage = error.message; 39065 } else { 39066 errorMessage = String(error) || (0, import_i18n126.__)( 39067 "Unknown error when running custom validation asynchronously." 39068 ); 39069 } 39070 setFormValidity((prev) => { 39071 const newFormValidity = setValidityAtPath( 39072 prev, 39073 { 39074 custom: { 39075 type: "invalid", 39076 message: errorMessage 39077 } 39078 }, 39079 [...path, formField.id] 39080 ); 39081 return newFormValidity; 39082 }); 39083 }); 39084 } 39085 function validateFormField(item, formField, promiseHandler) { 39086 if (formField.field?.isValid.required && !formField.field.isValid.required.validate(item, formField.field)) { 39087 return { 39088 required: { type: "invalid" } 39089 }; 39090 } 39091 if (formField.field?.isValid.pattern && !formField.field.isValid.pattern.validate(item, formField.field)) { 39092 return { 39093 pattern: { 39094 type: "invalid", 39095 message: (0, import_i18n126.__)("Value does not match the required pattern.") 39096 } 39097 }; 39098 } 39099 if (formField.field?.isValid.min && !formField.field.isValid.min.validate(item, formField.field)) { 39100 return { 39101 min: { 39102 type: "invalid", 39103 message: (0, import_i18n126.__)("Value is below the minimum.") 39104 } 39105 }; 39106 } 39107 if (formField.field?.isValid.max && !formField.field.isValid.max.validate(item, formField.field)) { 39108 return { 39109 max: { 39110 type: "invalid", 39111 message: (0, import_i18n126.__)("Value is above the maximum.") 39112 } 39113 }; 39114 } 39115 if (formField.field?.isValid.minLength && !formField.field.isValid.minLength.validate(item, formField.field)) { 39116 return { 39117 minLength: { 39118 type: "invalid", 39119 message: (0, import_i18n126.__)("Value is too short.") 39120 } 39121 }; 39122 } 39123 if (formField.field?.isValid.maxLength && !formField.field.isValid.maxLength.validate(item, formField.field)) { 39124 return { 39125 maxLength: { 39126 type: "invalid", 39127 message: (0, import_i18n126.__)("Value is too long.") 39128 } 39129 }; 39130 } 39131 if (formField.field?.isValid.elements && formField.field.hasElements && !formField.field.getElements && Array.isArray(formField.field.elements) && !formField.field.isValid.elements.validate(item, formField.field)) { 39132 return { 39133 elements: { 39134 type: "invalid", 39135 message: (0, import_i18n126.__)("Value must be one of the elements.") 39136 } 39137 }; 39138 } 39139 if (!!formField.field && formField.field.isValid.elements && formField.field.hasElements && typeof formField.field.getElements === "function") { 39140 handleElementsValidationAsync( 39141 formField.field.getElements(), 39142 formField, 39143 promiseHandler 39144 ); 39145 return { 39146 elements: { 39147 type: "validating", 39148 message: (0, import_i18n126.__)("Validating\u2026") 39149 } 39150 }; 39151 } 39152 let customError; 39153 if (!!formField.field && formField.field.isValid.custom) { 39154 try { 39155 const value = formField.field.getValue({ item }); 39156 customError = formField.field.isValid.custom( 39157 (0, import_deepmerge2.default)( 39158 item, 39159 formField.field.setValue({ 39160 item, 39161 value 39162 }) 39163 ), 39164 formField.field 39165 ); 39166 } catch (error) { 39167 let errorMessage; 39168 if (error instanceof Error) { 39169 errorMessage = error.message; 39170 } else { 39171 errorMessage = String(error) || (0, import_i18n126.__)("Unknown error when running custom validation."); 39172 } 39173 return { 39174 custom: { 39175 type: "invalid", 39176 message: errorMessage 39177 } 39178 }; 39179 } 39180 } 39181 if (typeof customError === "string") { 39182 return { 39183 custom: { 39184 type: "invalid", 39185 message: customError 39186 } 39187 }; 39188 } 39189 if (customError instanceof Promise) { 39190 handleCustomValidationAsync(customError, formField, promiseHandler); 39191 return { 39192 custom: { 39193 type: "validating", 39194 message: (0, import_i18n126.__)("Validating\u2026") 39195 } 39196 }; 39197 } 39198 if (formField.children.length > 0) { 39199 const result = {}; 39200 formField.children.forEach((child) => { 39201 result[child.id] = validateFormField(item, child, { 39202 ...promiseHandler, 39203 path: [...promiseHandler.path, formField.id, "children"] 39204 }); 39205 }); 39206 const filteredResult = {}; 39207 Object.entries(result).forEach(([key, value]) => { 39208 if (value !== void 0) { 39209 filteredResult[key] = value; 39210 } 39211 }); 39212 if (Object.keys(filteredResult).length === 0) { 39213 return void 0; 39214 } 39215 return { 39216 children: filteredResult 39217 }; 39218 } 39219 return void 0; 39220 } 39221 function getFormFieldValue(formField, item) { 39222 const fieldValue = formField?.field?.getValue({ item }); 39223 if (formField.children.length === 0) { 39224 return fieldValue; 39225 } 39226 const childrenValues = formField.children.map( 39227 (child) => getFormFieldValue(child, item) 39228 ); 39229 if (!childrenValues) { 39230 return fieldValue; 39231 } 39232 return { 39233 value: fieldValue, 39234 children: childrenValues 39235 }; 39236 } 39237 function useFormValidity(item, fields, form) { 39238 const [formValidity, setFormValidity] = (0, import_element119.useState)(); 39239 const customCounterRef = (0, import_element119.useRef)({}); 39240 const elementsCounterRef = (0, import_element119.useRef)({}); 39241 const previousValuesRef = (0, import_element119.useRef)({}); 39242 const validate = (0, import_element119.useCallback)(() => { 39243 const promiseHandler = { 39244 customCounterRef, 39245 elementsCounterRef, 39246 setFormValidity, 39247 path: [], 39248 item 39249 }; 39250 const formFieldsToValidate = getFormFieldsToValidate(form, fields); 39251 if (formFieldsToValidate.length === 0) { 39252 setFormValidity(void 0); 39253 return; 39254 } 39255 const newFormValidity = {}; 39256 const untouchedFields = []; 39257 formFieldsToValidate.forEach((formField) => { 39258 const value = getFormFieldValue(formField, item); 39259 if (previousValuesRef.current.hasOwnProperty(formField.id) && (0, import_es63.default)( 39260 previousValuesRef.current[formField.id], 39261 value 39262 )) { 39263 untouchedFields.push(formField.id); 39264 return; 39265 } 39266 previousValuesRef.current[formField.id] = value; 39267 const fieldValidity = validateFormField( 39268 item, 39269 formField, 39270 promiseHandler 39271 ); 39272 if (fieldValidity !== void 0) { 39273 newFormValidity[formField.id] = fieldValidity; 39274 } 39275 }); 39276 setFormValidity((existingFormValidity) => { 39277 let validity = { 39278 ...existingFormValidity, 39279 ...newFormValidity 39280 }; 39281 const fieldsToKeep = [ 39282 ...untouchedFields, 39283 ...Object.keys(newFormValidity) 39284 ]; 39285 Object.keys(validity).forEach((key) => { 39286 if (validity && !fieldsToKeep.includes(key)) { 39287 delete validity[key]; 39288 } 39289 }); 39290 if (Object.keys(validity).length === 0) { 39291 validity = void 0; 39292 } 39293 const areEqual = (0, import_es63.default)(existingFormValidity, validity); 39294 if (areEqual) { 39295 return existingFormValidity; 39296 } 39297 return validity; 39298 }); 39299 }, [item, fields, form]); 39300 (0, import_element119.useEffect)(() => { 39301 validate(); 39302 }, [validate]); 39303 return { 39304 validity: formValidity, 39305 isValid: isFormValid(formValidity) 39306 }; 39307 } 39308 var use_form_validity_default = useFormValidity; 39309 39310 // packages/dataviews/build-module/dataform-layouts/panel/modal.js 39311 var import_jsx_runtime256 = __toESM(require_jsx_runtime()); 39312 function ModalContent({ 39313 data, 39314 field, 39315 onChange, 39316 fieldLabel, 39317 onClose 39318 }) { 39319 const { fields } = (0, import_element120.useContext)(dataform_context_default); 39320 const [changes, setChanges] = (0, import_element120.useState)({}); 39321 const modalData = (0, import_element120.useMemo)(() => { 39322 return (0, import_deepmerge3.default)(data, changes, { 39323 arrayMerge: (target, source) => source 39324 }); 39325 }, [data, changes]); 39326 const form = (0, import_element120.useMemo)( 39327 () => ({ 39328 layout: DEFAULT_LAYOUT, 39329 fields: !!field.children ? field.children : ( 39330 // If not explicit children return the field id itself. 39331 [{ id: field.id, layout: DEFAULT_LAYOUT }] 39332 ) 39333 }), 39334 [field] 39335 ); 39336 const fieldsAsFieldType = fields.map((f2) => ({ 39337 ...f2, 39338 Edit: f2.Edit === null ? void 0 : f2.Edit, 39339 isValid: { 39340 required: f2.isValid.required?.constraint, 39341 elements: f2.isValid.elements?.constraint, 39342 min: f2.isValid.min?.constraint, 39343 max: f2.isValid.max?.constraint, 39344 pattern: f2.isValid.pattern?.constraint, 39345 minLength: f2.isValid.minLength?.constraint, 39346 maxLength: f2.isValid.maxLength?.constraint 39347 } 39348 })); 39349 const { validity } = use_form_validity_default(modalData, fieldsAsFieldType, form); 39350 const onApply = () => { 39351 onChange(changes); 39352 onClose(); 39353 }; 39354 const handleOnChange = (newValue) => { 39355 setChanges( 39356 (prev) => (0, import_deepmerge3.default)(prev, newValue, { 39357 arrayMerge: (target, source) => source 39358 }) 39359 ); 39360 }; 39361 const focusOnMountRef = (0, import_compose24.useFocusOnMount)("firstInputElement"); 39362 return /* @__PURE__ */ (0, import_jsx_runtime256.jsxs)( 39363 import_components144.Modal, 39364 { 39365 className: "dataforms-layouts-panel__modal", 39366 onRequestClose: onClose, 39367 isFullScreen: false, 39368 title: fieldLabel, 39369 size: "medium", 39370 children: [ 39371 /* @__PURE__ */ (0, import_jsx_runtime256.jsx)("div", { ref: focusOnMountRef, children: /* @__PURE__ */ (0, import_jsx_runtime256.jsx)( 39372 DataFormLayout, 39373 { 39374 data: modalData, 39375 form, 39376 onChange: handleOnChange, 39377 validity, 39378 children: (FieldLayout, childField, childFieldValidity) => /* @__PURE__ */ (0, import_jsx_runtime256.jsx)( 39379 FieldLayout, 39380 { 39381 data: modalData, 39382 field: childField, 39383 onChange: handleOnChange, 39384 hideLabelFromVision: form.fields.length < 2, 39385 validity: childFieldValidity 39386 }, 39387 childField.id 39388 ) 39389 } 39390 ) }), 39391 /* @__PURE__ */ (0, import_jsx_runtime256.jsxs)( 39392 import_components144.__experimentalHStack, 39393 { 39394 className: "dataforms-layouts-panel__modal-footer", 39395 spacing: 3, 39396 children: [ 39397 /* @__PURE__ */ (0, import_jsx_runtime256.jsx)(import_components144.__experimentalSpacer, {}), 39398 /* @__PURE__ */ (0, import_jsx_runtime256.jsx)( 39399 import_components144.Button, 39400 { 39401 variant: "tertiary", 39402 onClick: onClose, 39403 __next40pxDefaultSize: true, 39404 children: (0, import_i18n127.__)("Cancel") 39405 } 39406 ), 39407 /* @__PURE__ */ (0, import_jsx_runtime256.jsx)( 39408 import_components144.Button, 39409 { 39410 variant: "primary", 39411 onClick: onApply, 39412 __next40pxDefaultSize: true, 39413 children: (0, import_i18n127.__)("Apply") 39414 } 39415 ) 39416 ] 39417 } 39418 ) 39419 ] 39420 } 39421 ); 39422 } 39423 function PanelModal({ 39424 data, 39425 field, 39426 onChange, 39427 labelPosition, 39428 summaryFields, 39429 fieldDefinition, 39430 onOpen 39431 }) { 39432 const [isOpen, setIsOpen] = (0, import_element120.useState)(false); 39433 const fieldLabel = !!field.children ? field.label : fieldDefinition?.label; 39434 return /* @__PURE__ */ (0, import_jsx_runtime256.jsxs)(import_jsx_runtime256.Fragment, { children: [ 39435 /* @__PURE__ */ (0, import_jsx_runtime256.jsx)( 39436 summary_button_default, 39437 { 39438 summaryFields, 39439 data, 39440 labelPosition, 39441 fieldLabel, 39442 disabled: fieldDefinition.readOnly === true, 39443 onClick: () => { 39444 if (onOpen) { 39445 onOpen(); 39446 } 39447 setIsOpen(true); 39448 }, 39449 "aria-expanded": isOpen 39450 } 39451 ), 39452 isOpen && /* @__PURE__ */ (0, import_jsx_runtime256.jsx)( 39453 ModalContent, 39454 { 39455 data, 39456 field, 39457 onChange, 39458 fieldLabel: fieldLabel ?? "", 39459 onClose: () => setIsOpen(false) 39460 } 39461 ) 39462 ] }); 39463 } 39464 var modal_default2 = PanelModal; 39465 39466 // packages/dataviews/build-module/dataform-layouts/get-summary-fields.js 39467 function extractSummaryIds(summary) { 39468 if (Array.isArray(summary)) { 39469 return summary.map( 39470 (item) => typeof item === "string" ? item : item.id 39471 ); 39472 } 39473 return []; 39474 } 39475 var getSummaryFields = (summaryField, fields) => { 39476 if (Array.isArray(summaryField) && summaryField.length > 0) { 39477 const summaryIds = extractSummaryIds(summaryField); 39478 return summaryIds.map( 39479 (summaryId) => fields.find((_field) => _field.id === summaryId) 39480 ).filter((_field) => _field !== void 0); 39481 } 39482 return []; 39483 }; 39484 39485 // packages/dataviews/build-module/dataform-layouts/panel/index.js 39486 var import_jsx_runtime257 = __toESM(require_jsx_runtime()); 39487 function getFirstValidationError(validity) { 39488 if (!validity) { 39489 return void 0; 39490 } 39491 const validityRules = Object.keys(validity).filter( 39492 (key) => key !== "children" 39493 ); 39494 for (const key of validityRules) { 39495 const rule = validity[key]; 39496 if (rule === void 0) { 39497 continue; 39498 } 39499 if (rule.type === "invalid") { 39500 if (rule.message) { 39501 return rule.message; 39502 } 39503 if (key === "required") { 39504 return "A required field is empty"; 39505 } 39506 return "Unidentified validation error"; 39507 } 39508 } 39509 if (validity.children) { 39510 for (const childValidity of Object.values(validity.children)) { 39511 const childError = getFirstValidationError(childValidity); 39512 if (childError) { 39513 return childError; 39514 } 39515 } 39516 } 39517 return void 0; 39518 } 39519 var getFieldDefinition = (field, fields) => { 39520 const fieldDefinition = fields.find((_field) => _field.id === field.id); 39521 if (!fieldDefinition) { 39522 return fields.find((_field) => { 39523 if (!!field.children) { 39524 const simpleChildren = field.children.filter( 39525 (child) => !child.children 39526 ); 39527 if (simpleChildren.length === 0) { 39528 return false; 39529 } 39530 return _field.id === simpleChildren[0].id; 39531 } 39532 return _field.id === field.id; 39533 }); 39534 } 39535 return fieldDefinition; 39536 }; 39537 var getFieldDefinitionAndSummaryFields = (layout, field, fields) => { 39538 const summaryFields = getSummaryFields(layout.summary, fields); 39539 const fieldDefinition = getFieldDefinition(field, fields); 39540 if (summaryFields.length === 0) { 39541 return { 39542 summaryFields: fieldDefinition ? [fieldDefinition] : [], 39543 fieldDefinition 39544 }; 39545 } 39546 return { 39547 summaryFields, 39548 fieldDefinition 39549 }; 39550 }; 39551 function FormPanelField({ 39552 data, 39553 field, 39554 onChange, 39555 validity 39556 }) { 39557 const { fields } = (0, import_element121.useContext)(dataform_context_default); 39558 const layout = field.layout; 39559 const [popoverAnchor, setPopoverAnchor] = (0, import_element121.useState)( 39560 null 39561 ); 39562 const [touched, setTouched] = (0, import_element121.useState)(false); 39563 const handleOpen = () => setTouched(true); 39564 const { fieldDefinition, summaryFields } = getFieldDefinitionAndSummaryFields(layout, field, fields); 39565 if (!fieldDefinition) { 39566 return null; 39567 } 39568 const labelPosition = layout.labelPosition; 39569 const errorMessage = getFirstValidationError(validity); 39570 const showError = touched && !!errorMessage; 39571 const labelClassName = clsx_default( 39572 "dataforms-layouts-panel__field-label", 39573 `dataforms-layouts-panel__field-label--label-position-$labelPosition}`, 39574 { "has-error": showError } 39575 ); 39576 const fieldLabel = !!field.children ? field.label : fieldDefinition?.label; 39577 const labelContent = showError ? /* @__PURE__ */ (0, import_jsx_runtime257.jsx)(import_components145.Tooltip, { text: errorMessage, placement: "top", children: /* @__PURE__ */ (0, import_jsx_runtime257.jsxs)( 39578 import_components145.__experimentalHStack, 39579 { 39580 className: "dataforms-layouts-panel__field-label-error-content", 39581 justify: "flex-start", 39582 children: [ 39583 /* @__PURE__ */ (0, import_jsx_runtime257.jsx)(import_components145.Icon, { icon: error_default, size: 16 }), 39584 /* @__PURE__ */ (0, import_jsx_runtime257.jsx)(import_jsx_runtime257.Fragment, { children: fieldLabel }) 39585 ] 39586 } 39587 ) }) : fieldLabel; 39588 const renderedControl = layout.openAs === "modal" ? /* @__PURE__ */ (0, import_jsx_runtime257.jsx)( 39589 modal_default2, 39590 { 39591 data, 39592 field, 39593 onChange, 39594 labelPosition, 39595 summaryFields, 39596 fieldDefinition, 39597 onOpen: handleOpen 39598 } 39599 ) : /* @__PURE__ */ (0, import_jsx_runtime257.jsx)( 39600 dropdown_default, 39601 { 39602 data, 39603 field, 39604 onChange, 39605 validity, 39606 labelPosition, 39607 summaryFields, 39608 fieldDefinition, 39609 popoverAnchor, 39610 onOpen: handleOpen 39611 } 39612 ); 39613 if (labelPosition === "top") { 39614 return /* @__PURE__ */ (0, import_jsx_runtime257.jsxs)(import_components145.__experimentalVStack, { className: "dataforms-layouts-panel__field", spacing: 0, children: [ 39615 /* @__PURE__ */ (0, import_jsx_runtime257.jsx)( 39616 "div", 39617 { 39618 className: labelClassName, 39619 style: { paddingBottom: 0 }, 39620 children: labelContent 39621 } 39622 ), 39623 /* @__PURE__ */ (0, import_jsx_runtime257.jsx)("div", { className: "dataforms-layouts-panel__field-control", children: renderedControl }) 39624 ] }); 39625 } 39626 if (labelPosition === "none") { 39627 return /* @__PURE__ */ (0, import_jsx_runtime257.jsxs)(import_components145.__experimentalHStack, { className: "dataforms-layouts-panel__field dataforms-layouts-panel__field--label-position-none", children: [ 39628 showError && /* @__PURE__ */ (0, import_jsx_runtime257.jsx)(import_components145.Tooltip, { text: errorMessage, placement: "top", children: /* @__PURE__ */ (0, import_jsx_runtime257.jsx)( 39629 import_components145.Icon, 39630 { 39631 className: "dataforms-layouts-panel__field-label-error-content", 39632 icon: error_default, 39633 size: 16 39634 } 39635 ) }), 39636 /* @__PURE__ */ (0, import_jsx_runtime257.jsx)("div", { className: "dataforms-layouts-panel__field-control", children: renderedControl }) 39637 ] }); 39638 } 39639 return /* @__PURE__ */ (0, import_jsx_runtime257.jsxs)( 39640 import_components145.__experimentalHStack, 39641 { 39642 ref: setPopoverAnchor, 39643 className: "dataforms-layouts-panel__field", 39644 children: [ 39645 /* @__PURE__ */ (0, import_jsx_runtime257.jsx)("div", { className: labelClassName, children: labelContent }), 39646 /* @__PURE__ */ (0, import_jsx_runtime257.jsx)("div", { className: "dataforms-layouts-panel__field-control", children: renderedControl }) 39647 ] 39648 } 39649 ); 39650 } 39651 39652 // packages/dataviews/build-module/dataform-layouts/card/index.js 39653 var import_components146 = __toESM(require_components()); 39654 var import_element122 = __toESM(require_element()); 39655 var import_jsx_runtime258 = __toESM(require_jsx_runtime()); 39656 var NonCollapsibleCardHeader = ({ 39657 children, 39658 ...props 39659 }) => /* @__PURE__ */ (0, import_jsx_runtime258.jsx)(import_components146.CardHeader, { isBorderless: true, ...props, children: /* @__PURE__ */ (0, import_jsx_runtime258.jsx)( 39660 "div", 39661 { 39662 style: { 39663 height: "40px", 39664 // This is to match the chevron's __next40pxDefaultSize 39665 width: "100%", 39666 display: "flex", 39667 justifyContent: "space-between", 39668 alignItems: "center" 39669 }, 39670 children 39671 } 39672 ) }); 39673 function useCardHeader(layout) { 39674 const { isOpened, isCollapsible } = layout; 39675 const [isOpen, setIsOpen] = (0, import_element122.useState)(isOpened); 39676 const toggle = (0, import_element122.useCallback)(() => { 39677 setIsOpen((prev) => !prev); 39678 }, []); 39679 const CollapsibleCardHeader = (0, import_element122.useCallback)( 39680 ({ 39681 children, 39682 ...props 39683 }) => /* @__PURE__ */ (0, import_jsx_runtime258.jsxs)( 39684 import_components146.CardHeader, 39685 { 39686 ...props, 39687 onClick: toggle, 39688 style: { 39689 cursor: "pointer", 39690 ...props.style 39691 }, 39692 isBorderless: true, 39693 children: [ 39694 /* @__PURE__ */ (0, import_jsx_runtime258.jsx)( 39695 "div", 39696 { 39697 style: { 39698 width: "100%", 39699 display: "flex", 39700 justifyContent: "space-between", 39701 alignItems: "center" 39702 }, 39703 children 39704 } 39705 ), 39706 /* @__PURE__ */ (0, import_jsx_runtime258.jsx)( 39707 import_components146.Button, 39708 { 39709 __next40pxDefaultSize: true, 39710 variant: "tertiary", 39711 icon: isOpen ? chevron_up_default : chevron_down_default, 39712 "aria-expanded": isOpen, 39713 "aria-label": isOpen ? "Collapse" : "Expand" 39714 } 39715 ) 39716 ] 39717 } 39718 ), 39719 [toggle, isOpen] 39720 ); 39721 const effectiveIsOpen = isCollapsible ? isOpen : true; 39722 const CardHeaderComponent = isCollapsible ? CollapsibleCardHeader : NonCollapsibleCardHeader; 39723 return { isOpen: effectiveIsOpen, CardHeader: CardHeaderComponent }; 39724 } 39725 function isSummaryFieldVisible(summaryField, summaryConfig, isOpen) { 39726 if (!summaryConfig || Array.isArray(summaryConfig) && summaryConfig.length === 0) { 39727 return false; 39728 } 39729 const summaryConfigArray = Array.isArray(summaryConfig) ? summaryConfig : [summaryConfig]; 39730 const fieldConfig = summaryConfigArray.find((config2) => { 39731 if (typeof config2 === "string") { 39732 return config2 === summaryField.id; 39733 } 39734 if (typeof config2 === "object" && "id" in config2) { 39735 return config2.id === summaryField.id; 39736 } 39737 return false; 39738 }); 39739 if (!fieldConfig) { 39740 return false; 39741 } 39742 if (typeof fieldConfig === "string") { 39743 return true; 39744 } 39745 if (typeof fieldConfig === "object" && "visibility" in fieldConfig) { 39746 return fieldConfig.visibility === "always" || fieldConfig.visibility === "when-collapsed" && !isOpen; 39747 } 39748 return true; 39749 } 39750 function FormCardField({ 39751 data, 39752 field, 39753 onChange, 39754 hideLabelFromVision, 39755 validity 39756 }) { 39757 const { fields } = (0, import_element122.useContext)(dataform_context_default); 39758 const layout = field.layout; 39759 const form = (0, import_element122.useMemo)( 39760 () => ({ 39761 layout: DEFAULT_LAYOUT, 39762 fields: field.children ?? [] 39763 }), 39764 [field] 39765 ); 39766 const { isOpen, CardHeader } = useCardHeader(layout); 39767 const summaryFields = getSummaryFields(layout.summary, fields); 39768 const visibleSummaryFields = summaryFields.filter( 39769 (summaryField) => isSummaryFieldVisible(summaryField, layout.summary, isOpen) 39770 ); 39771 const sizeCard = { 39772 blockStart: "medium", 39773 blockEnd: "medium", 39774 inlineStart: "medium", 39775 inlineEnd: "medium" 39776 }; 39777 if (!!field.children) { 39778 const withHeader2 = !!field.label && layout.withHeader; 39779 const sizeCardBody2 = { 39780 blockStart: withHeader2 ? "none" : "medium", 39781 blockEnd: "medium", 39782 inlineStart: "medium", 39783 inlineEnd: "medium" 39784 }; 39785 return /* @__PURE__ */ (0, import_jsx_runtime258.jsxs)(import_components146.Card, { className: "dataforms-layouts-card__field", size: sizeCard, children: [ 39786 withHeader2 && /* @__PURE__ */ (0, import_jsx_runtime258.jsxs)(CardHeader, { className: "dataforms-layouts-card__field-header", children: [ 39787 /* @__PURE__ */ (0, import_jsx_runtime258.jsx)("span", { className: "dataforms-layouts-card__field-header-label", children: field.label }), 39788 visibleSummaryFields.length > 0 && layout.withHeader && /* @__PURE__ */ (0, import_jsx_runtime258.jsx)("div", { className: "dataforms-layouts-card__field-summary", children: visibleSummaryFields.map( 39789 (summaryField) => /* @__PURE__ */ (0, import_jsx_runtime258.jsx)( 39790 summaryField.render, 39791 { 39792 item: data, 39793 field: summaryField 39794 }, 39795 summaryField.id 39796 ) 39797 ) }) 39798 ] }), 39799 (isOpen || !withHeader2) && // If it doesn't have a header, keep it open. 39800 // Otherwise, the card will not be visible. 39801 /* @__PURE__ */ (0, import_jsx_runtime258.jsxs)( 39802 import_components146.CardBody, 39803 { 39804 size: sizeCardBody2, 39805 className: "dataforms-layouts-card__field-control", 39806 children: [ 39807 field.description && /* @__PURE__ */ (0, import_jsx_runtime258.jsx)("div", { className: "dataforms-layouts-card__field-description", children: field.description }), 39808 /* @__PURE__ */ (0, import_jsx_runtime258.jsx)( 39809 DataFormLayout, 39810 { 39811 data, 39812 form, 39813 onChange, 39814 validity: validity?.children 39815 } 39816 ) 39817 ] 39818 } 39819 ) 39820 ] }); 39821 } 39822 const fieldDefinition = fields.find( 39823 (fieldDef) => fieldDef.id === field.id 39824 ); 39825 if (!fieldDefinition || !fieldDefinition.Edit) { 39826 return null; 39827 } 39828 const RegularLayout = getFormFieldLayout("regular")?.component; 39829 if (!RegularLayout) { 39830 return null; 39831 } 39832 const withHeader = !!fieldDefinition.label && layout.withHeader; 39833 const sizeCardBody = { 39834 blockStart: withHeader ? "none" : "medium", 39835 blockEnd: "medium", 39836 inlineStart: "medium", 39837 inlineEnd: "medium" 39838 }; 39839 return /* @__PURE__ */ (0, import_jsx_runtime258.jsxs)(import_components146.Card, { className: "dataforms-layouts-card__field", size: sizeCard, children: [ 39840 withHeader && /* @__PURE__ */ (0, import_jsx_runtime258.jsxs)(CardHeader, { className: "dataforms-layouts-card__field-header", children: [ 39841 /* @__PURE__ */ (0, import_jsx_runtime258.jsx)("span", { className: "dataforms-layouts-card__field-header-label", children: fieldDefinition.label }), 39842 visibleSummaryFields.length > 0 && layout.withHeader && /* @__PURE__ */ (0, import_jsx_runtime258.jsx)("div", { className: "dataforms-layouts-card__field-summary", children: visibleSummaryFields.map((summaryField) => /* @__PURE__ */ (0, import_jsx_runtime258.jsx)( 39843 summaryField.render, 39844 { 39845 item: data, 39846 field: summaryField 39847 }, 39848 summaryField.id 39849 )) }) 39850 ] }), 39851 (isOpen || !withHeader) && // If it doesn't have a header, keep it open. 39852 // Otherwise, the card will not be visible. 39853 /* @__PURE__ */ (0, import_jsx_runtime258.jsx)( 39854 import_components146.CardBody, 39855 { 39856 size: sizeCardBody, 39857 className: "dataforms-layouts-card__field-control", 39858 children: /* @__PURE__ */ (0, import_jsx_runtime258.jsx)( 39859 RegularLayout, 39860 { 39861 data, 39862 field, 39863 onChange, 39864 hideLabelFromVision: hideLabelFromVision || withHeader, 39865 validity 39866 } 39867 ) 39868 } 39869 ) 39870 ] }); 39871 } 39872 39873 // packages/dataviews/build-module/dataform-layouts/row/index.js 39874 var import_components147 = __toESM(require_components()); 39875 var import_jsx_runtime259 = __toESM(require_jsx_runtime()); 39876 function Header3({ title }) { 39877 return /* @__PURE__ */ (0, import_jsx_runtime259.jsx)(import_components147.__experimentalVStack, { className: "dataforms-layouts-row__header", spacing: 4, children: /* @__PURE__ */ (0, import_jsx_runtime259.jsxs)(import_components147.__experimentalHStack, { alignment: "center", children: [ 39878 /* @__PURE__ */ (0, import_jsx_runtime259.jsx)(import_components147.__experimentalHeading, { level: 2, size: 13, children: title }), 39879 /* @__PURE__ */ (0, import_jsx_runtime259.jsx)(import_components147.__experimentalSpacer, {}) 39880 ] }) }); 39881 } 39882 var EMPTY_WRAPPER = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime259.jsx)(import_jsx_runtime259.Fragment, { children }); 39883 function FormRowField({ 39884 data, 39885 field, 39886 onChange, 39887 hideLabelFromVision, 39888 validity 39889 }) { 39890 const layout = field.layout; 39891 if (!!field.children) { 39892 const form = { 39893 layout: DEFAULT_LAYOUT, 39894 fields: field.children 39895 }; 39896 return /* @__PURE__ */ (0, import_jsx_runtime259.jsxs)("div", { className: "dataforms-layouts-row__field", children: [ 39897 !hideLabelFromVision && field.label && /* @__PURE__ */ (0, import_jsx_runtime259.jsx)(Header3, { title: field.label }), 39898 /* @__PURE__ */ (0, import_jsx_runtime259.jsx)(import_components147.__experimentalHStack, { alignment: layout.alignment, spacing: 4, children: /* @__PURE__ */ (0, import_jsx_runtime259.jsx)( 39899 DataFormLayout, 39900 { 39901 data, 39902 form, 39903 onChange, 39904 validity: validity?.children, 39905 as: EMPTY_WRAPPER, 39906 children: (FieldLayout, childField, childFieldValidity) => /* @__PURE__ */ (0, import_jsx_runtime259.jsx)( 39907 "div", 39908 { 39909 className: "dataforms-layouts-row__field-control", 39910 style: layout.styles[childField.id], 39911 children: /* @__PURE__ */ (0, import_jsx_runtime259.jsx)( 39912 FieldLayout, 39913 { 39914 data, 39915 field: childField, 39916 onChange, 39917 hideLabelFromVision, 39918 validity: childFieldValidity 39919 } 39920 ) 39921 }, 39922 childField.id 39923 ) 39924 } 39925 ) }) 39926 ] }); 39927 } 39928 const RegularLayout = getFormFieldLayout("regular")?.component; 39929 if (!RegularLayout) { 39930 return null; 39931 } 39932 return /* @__PURE__ */ (0, import_jsx_runtime259.jsx)(import_jsx_runtime259.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime259.jsx)("div", { className: "dataforms-layouts-row__field-control", children: /* @__PURE__ */ (0, import_jsx_runtime259.jsx)( 39933 RegularLayout, 39934 { 39935 data, 39936 field, 39937 onChange, 39938 validity 39939 } 39940 ) }) }); 39941 } 39942 39943 // packages/dataviews/build-module/dataform-layouts/details/index.js 39944 var import_element123 = __toESM(require_element()); 39945 var import_i18n128 = __toESM(require_i18n()); 39946 var import_jsx_runtime260 = __toESM(require_jsx_runtime()); 39947 function FormDetailsField({ 39948 data, 39949 field, 39950 onChange 39951 }) { 39952 const { fields } = (0, import_element123.useContext)(dataform_context_default); 39953 const form = (0, import_element123.useMemo)( 39954 () => ({ 39955 layout: DEFAULT_LAYOUT, 39956 fields: field.children ?? [] 39957 }), 39958 [field] 39959 ); 39960 if (!field.children) { 39961 return null; 39962 } 39963 const summaryFieldId = field.layout.summary ?? ""; 39964 const summaryField = summaryFieldId ? fields.find((fieldDef) => fieldDef.id === summaryFieldId) : void 0; 39965 let summaryContent; 39966 if (summaryField && summaryField.render) { 39967 summaryContent = /* @__PURE__ */ (0, import_jsx_runtime260.jsx)(summaryField.render, { item: data, field: summaryField }); 39968 } else { 39969 summaryContent = field.label || (0, import_i18n128.__)("More details"); 39970 } 39971 return /* @__PURE__ */ (0, import_jsx_runtime260.jsxs)("details", { className: "dataforms-layouts-details__details", children: [ 39972 /* @__PURE__ */ (0, import_jsx_runtime260.jsx)("summary", { className: "dataforms-layouts-details__summary", children: summaryContent }), 39973 /* @__PURE__ */ (0, import_jsx_runtime260.jsx)("div", { className: "dataforms-layouts-details__content", children: /* @__PURE__ */ (0, import_jsx_runtime260.jsx)( 39974 DataFormLayout, 39975 { 39976 data, 39977 form, 39978 onChange 39979 } 39980 ) }) 39981 ] }); 39982 } 39983 39984 // packages/dataviews/build-module/dataform-layouts/index.js 39985 var import_jsx_runtime261 = __toESM(require_jsx_runtime()); 39986 var FORM_FIELD_LAYOUTS = [ 39987 { 39988 type: "regular", 39989 component: FormRegularField, 39990 wrapper: ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime261.jsx)(import_components148.__experimentalVStack, { className: "dataforms-layouts__wrapper", spacing: 4, children }) 39991 }, 39992 { 39993 type: "panel", 39994 component: FormPanelField, 39995 wrapper: ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime261.jsx)(import_components148.__experimentalVStack, { className: "dataforms-layouts__wrapper", spacing: 2, children }) 39996 }, 39997 { 39998 type: "card", 39999 component: FormCardField, 40000 wrapper: ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime261.jsx)(import_components148.__experimentalVStack, { className: "dataforms-layouts__wrapper", spacing: 6, children }) 40001 }, 40002 { 40003 type: "row", 40004 component: FormRowField, 40005 wrapper: ({ 40006 children, 40007 layout 40008 }) => /* @__PURE__ */ (0, import_jsx_runtime261.jsx)(import_components148.__experimentalVStack, { className: "dataforms-layouts__wrapper", spacing: 4, children: /* @__PURE__ */ (0, import_jsx_runtime261.jsx)("div", { className: "dataforms-layouts-row__field", children: /* @__PURE__ */ (0, import_jsx_runtime261.jsx)( 40009 import_components148.__experimentalHStack, 40010 { 40011 spacing: 4, 40012 alignment: layout.alignment, 40013 children 40014 } 40015 ) }) }) 40016 }, 40017 { 40018 type: "details", 40019 component: FormDetailsField 40020 } 40021 ]; 40022 function getFormFieldLayout(type) { 40023 return FORM_FIELD_LAYOUTS.find((layout) => layout.type === type); 40024 } 40025 40026 // packages/dataviews/build-module/dataform-layouts/data-form-layout.js 40027 var import_jsx_runtime262 = __toESM(require_jsx_runtime()); 40028 var DEFAULT_WRAPPER = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime262.jsx)(import_components149.__experimentalVStack, { className: "dataforms-layouts__wrapper", spacing: 4, children }); 40029 function DataFormLayout({ 40030 data, 40031 form, 40032 onChange, 40033 validity, 40034 children, 40035 as 40036 }) { 40037 const { fields: fieldDefinitions } = (0, import_element124.useContext)(dataform_context_default); 40038 function getFieldDefinition2(field) { 40039 return fieldDefinitions.find( 40040 (fieldDefinition) => fieldDefinition.id === field.id 40041 ); 40042 } 40043 const Wrapper = as ?? getFormFieldLayout(form.layout.type)?.wrapper ?? DEFAULT_WRAPPER; 40044 return /* @__PURE__ */ (0, import_jsx_runtime262.jsx)(Wrapper, { layout: form.layout, children: form.fields.map((formField) => { 40045 const FieldLayout = getFormFieldLayout(formField.layout.type)?.component; 40046 if (!FieldLayout) { 40047 return null; 40048 } 40049 const fieldDefinition = !formField.children ? getFieldDefinition2(formField) : void 0; 40050 if (fieldDefinition && fieldDefinition.isVisible && !fieldDefinition.isVisible(data)) { 40051 return null; 40052 } 40053 if (children) { 40054 return children( 40055 FieldLayout, 40056 formField, 40057 validity?.[formField.id] 40058 ); 40059 } 40060 return /* @__PURE__ */ (0, import_jsx_runtime262.jsx)( 40061 FieldLayout, 40062 { 40063 data, 40064 field: formField, 40065 onChange, 40066 validity: validity?.[formField.id] 40067 }, 40068 formField.id 40069 ); 40070 }) }); 40071 } 40072 40073 // packages/dataviews/build-module/components/dataform/index.js 40074 var import_jsx_runtime263 = __toESM(require_jsx_runtime()); 40075 function DataForm({ 40076 data, 40077 form, 40078 fields, 40079 onChange, 40080 validity 40081 }) { 40082 const normalizedForm = (0, import_element125.useMemo)(() => normalize_form_default(form), [form]); 40083 const normalizedFields = (0, import_element125.useMemo)( 40084 () => normalizeFields(fields), 40085 [fields] 40086 ); 40087 if (!form.fields) { 40088 return null; 40089 } 40090 return /* @__PURE__ */ (0, import_jsx_runtime263.jsx)(DataFormProvider, { fields: normalizedFields, children: /* @__PURE__ */ (0, import_jsx_runtime263.jsx)( 40091 DataFormLayout, 40092 { 40093 data, 40094 form: normalizedForm, 40095 onChange, 40096 validity 40097 } 40098 ) }); 40099 } 40100 40101 // packages/dataviews/build-module/utils/filter-sort-and-paginate.js 40102 var import_remove_accents2 = __toESM(require_remove_accents()); 40103 var import_deprecated4 = __toESM(require_deprecated()); 40104 var import_date9 = __toESM(require_date()); 40105 function normalizeSearchInput2(input = "") { 40106 return (0, import_remove_accents2.default)(input.trim().toLowerCase()); 40107 } 40108 var EMPTY_ARRAY9 = []; 40109 function getRelativeDate(value, unit) { 40110 switch (unit) { 40111 case "days": 40112 return subDays(/* @__PURE__ */ new Date(), value); 40113 case "weeks": 40114 return subWeeks(/* @__PURE__ */ new Date(), value); 40115 case "months": 40116 return subMonths(/* @__PURE__ */ new Date(), value); 40117 case "years": 40118 return subYears(/* @__PURE__ */ new Date(), value); 40119 default: 40120 return /* @__PURE__ */ new Date(); 40121 } 40122 } 40123 function filterSortAndPaginate(data, view, fields) { 40124 if (!data) { 40125 return { 40126 data: EMPTY_ARRAY9, 40127 paginationInfo: { totalItems: 0, totalPages: 0 } 40128 }; 40129 } 40130 const _fields = normalizeFields(fields); 40131 let filteredData = [...data]; 40132 if (view.search) { 40133 const normalizedSearch = normalizeSearchInput2(view.search); 40134 filteredData = filteredData.filter((item) => { 40135 return _fields.filter((field) => field.enableGlobalSearch).some((field) => { 40136 const fieldValue = field.getValue({ item }); 40137 const values = Array.isArray(fieldValue) ? fieldValue : [fieldValue]; 40138 return values.some( 40139 (value) => normalizeSearchInput2(String(value)).includes( 40140 normalizedSearch 40141 ) 40142 ); 40143 }); 40144 }); 40145 } 40146 if (view.filters && view.filters?.length > 0) { 40147 view.filters.forEach((filter) => { 40148 const field = _fields.find( 40149 (_field) => _field.id === filter.field 40150 ); 40151 if (field) { 40152 if (filter.operator === OPERATOR_IS_ANY2 && filter?.value?.length > 0) { 40153 filteredData = filteredData.filter((item) => { 40154 const fieldValue = field.getValue({ item }); 40155 if (Array.isArray(fieldValue)) { 40156 return filter.value.some( 40157 (filterValue) => fieldValue.includes(filterValue) 40158 ); 40159 } else if (typeof fieldValue === "string") { 40160 return filter.value.includes(fieldValue); 40161 } 40162 return false; 40163 }); 40164 } else if (filter.operator === OPERATOR_IS_NONE2 && filter?.value?.length > 0) { 40165 filteredData = filteredData.filter((item) => { 40166 const fieldValue = field.getValue({ item }); 40167 if (Array.isArray(fieldValue)) { 40168 return !filter.value.some( 40169 (filterValue) => fieldValue.includes(filterValue) 40170 ); 40171 } else if (typeof fieldValue === "string") { 40172 return !filter.value.includes(fieldValue); 40173 } 40174 return false; 40175 }); 40176 } else if (filter.operator === OPERATOR_IS_ALL && filter?.value?.length > 0) { 40177 filteredData = filteredData.filter((item) => { 40178 return filter.value.every((value) => { 40179 return field.getValue({ item })?.includes(value); 40180 }); 40181 }); 40182 } else if (filter.operator === OPERATOR_IS_NOT_ALL && filter?.value?.length > 0) { 40183 (0, import_deprecated4.default)("The 'isNotAll' filter operator", { 40184 since: "7.0", 40185 alternative: "'isNone'" 40186 }); 40187 filteredData = filteredData.filter((item) => { 40188 return filter.value.every((value) => { 40189 return !field.getValue({ item })?.includes(value); 40190 }); 40191 }); 40192 } else if (filter.operator === OPERATOR_IS2) { 40193 filteredData = filteredData.filter((item) => { 40194 return filter.value === field.getValue({ item }) || filter.value === void 0; 40195 }); 40196 } else if (filter.operator === OPERATOR_IS_NOT) { 40197 filteredData = filteredData.filter((item) => { 40198 return filter.value !== field.getValue({ item }); 40199 }); 40200 } else if (filter.operator === OPERATOR_ON && filter.value !== void 0) { 40201 const filterDate = (0, import_date9.getDate)(filter.value); 40202 filteredData = filteredData.filter((item) => { 40203 const fieldDate = (0, import_date9.getDate)(field.getValue({ item })); 40204 return filterDate.getTime() === fieldDate.getTime(); 40205 }); 40206 } else if (filter.operator === OPERATOR_NOT_ON && filter.value !== void 0) { 40207 const filterDate = (0, import_date9.getDate)(filter.value); 40208 filteredData = filteredData.filter((item) => { 40209 const fieldDate = (0, import_date9.getDate)(field.getValue({ item })); 40210 return filterDate.getTime() !== fieldDate.getTime(); 40211 }); 40212 } else if (filter.operator === OPERATOR_LESS_THAN && filter.value !== void 0) { 40213 filteredData = filteredData.filter((item) => { 40214 const fieldValue = field.getValue({ item }); 40215 return fieldValue < filter.value; 40216 }); 40217 } else if (filter.operator === OPERATOR_GREATER_THAN && filter.value !== void 0) { 40218 filteredData = filteredData.filter((item) => { 40219 const fieldValue = field.getValue({ item }); 40220 return fieldValue > filter.value; 40221 }); 40222 } else if (filter.operator === OPERATOR_LESS_THAN_OR_EQUAL && filter.value !== void 0) { 40223 filteredData = filteredData.filter((item) => { 40224 const fieldValue = field.getValue({ item }); 40225 return fieldValue <= filter.value; 40226 }); 40227 } else if (filter.operator === OPERATOR_GREATER_THAN_OR_EQUAL && filter.value !== void 0) { 40228 filteredData = filteredData.filter((item) => { 40229 const fieldValue = field.getValue({ item }); 40230 return fieldValue >= filter.value; 40231 }); 40232 } else if (filter.operator === OPERATOR_CONTAINS && filter?.value !== void 0) { 40233 filteredData = filteredData.filter((item) => { 40234 const fieldValue = field.getValue({ item }); 40235 return typeof fieldValue === "string" && filter.value && fieldValue.toLowerCase().includes( 40236 String(filter.value).toLowerCase() 40237 ); 40238 }); 40239 } else if (filter.operator === OPERATOR_NOT_CONTAINS && filter?.value !== void 0) { 40240 filteredData = filteredData.filter((item) => { 40241 const fieldValue = field.getValue({ item }); 40242 return typeof fieldValue === "string" && filter.value && !fieldValue.toLowerCase().includes( 40243 String(filter.value).toLowerCase() 40244 ); 40245 }); 40246 } else if (filter.operator === OPERATOR_STARTS_WITH && filter?.value !== void 0) { 40247 filteredData = filteredData.filter((item) => { 40248 const fieldValue = field.getValue({ item }); 40249 return typeof fieldValue === "string" && filter.value && fieldValue.toLowerCase().startsWith( 40250 String(filter.value).toLowerCase() 40251 ); 40252 }); 40253 } else if (filter.operator === OPERATOR_BEFORE2 && filter.value !== void 0) { 40254 const filterValue = (0, import_date9.getDate)(filter.value); 40255 filteredData = filteredData.filter((item) => { 40256 const fieldValue = (0, import_date9.getDate)( 40257 field.getValue({ item }) 40258 ); 40259 return fieldValue < filterValue; 40260 }); 40261 } else if (filter.operator === OPERATOR_AFTER2 && filter.value !== void 0) { 40262 const filterValue = (0, import_date9.getDate)(filter.value); 40263 filteredData = filteredData.filter((item) => { 40264 const fieldValue = (0, import_date9.getDate)( 40265 field.getValue({ item }) 40266 ); 40267 return fieldValue > filterValue; 40268 }); 40269 } else if (filter.operator === OPERATOR_BEFORE_INC && filter.value !== void 0) { 40270 const filterValue = (0, import_date9.getDate)(filter.value); 40271 filteredData = filteredData.filter((item) => { 40272 const fieldValue = (0, import_date9.getDate)( 40273 field.getValue({ item }) 40274 ); 40275 return fieldValue <= filterValue; 40276 }); 40277 } else if (filter.operator === OPERATOR_AFTER_INC && filter.value !== void 0) { 40278 const filterValue = (0, import_date9.getDate)(filter.value); 40279 filteredData = filteredData.filter((item) => { 40280 const fieldValue = (0, import_date9.getDate)( 40281 field.getValue({ item }) 40282 ); 40283 return fieldValue >= filterValue; 40284 }); 40285 } else if (filter.operator === OPERATOR_BETWEEN && Array.isArray(filter.value) && filter.value.length === 2 && filter.value[0] !== void 0 && filter.value[1] !== void 0) { 40286 filteredData = filteredData.filter((item) => { 40287 const fieldValue = field.getValue({ item }); 40288 if (typeof fieldValue === "number" || fieldValue instanceof Date || typeof fieldValue === "string") { 40289 return fieldValue >= filter.value[0] && fieldValue <= filter.value[1]; 40290 } 40291 return false; 40292 }); 40293 } else if (filter.operator === OPERATOR_IN_THE_PAST && filter.value?.value !== void 0 && filter.value?.unit !== void 0) { 40294 const targetDate = getRelativeDate( 40295 filter.value.value, 40296 filter.value.unit 40297 ); 40298 filteredData = filteredData.filter((item) => { 40299 const fieldValue = (0, import_date9.getDate)( 40300 field.getValue({ item }) 40301 ); 40302 return fieldValue >= targetDate && fieldValue <= /* @__PURE__ */ new Date(); 40303 }); 40304 } else if (filter.operator === OPERATOR_OVER && filter.value?.value !== void 0 && filter.value?.unit !== void 0) { 40305 const targetDate = getRelativeDate( 40306 filter.value.value, 40307 filter.value.unit 40308 ); 40309 filteredData = filteredData.filter((item) => { 40310 const fieldValue = (0, import_date9.getDate)( 40311 field.getValue({ item }) 40312 ); 40313 return fieldValue < targetDate; 40314 }); 40315 } 40316 } 40317 }); 40318 } 40319 const sortByField = view.sort?.field ? _fields.find((field) => { 40320 return field.enableSorting !== false && field.id === view.sort?.field; 40321 }) : null; 40322 const groupByField = view.groupBy?.field ? _fields.find((field) => { 40323 return field.enableSorting !== false && field.id === view.groupBy?.field; 40324 }) : null; 40325 if (sortByField || groupByField) { 40326 filteredData.sort((a2, b2) => { 40327 if (groupByField) { 40328 const groupCompare = groupByField.sort( 40329 a2, 40330 b2, 40331 view.groupBy?.direction ?? "asc" 40332 ); 40333 if (groupCompare !== 0) { 40334 return groupCompare; 40335 } 40336 } 40337 if (sortByField) { 40338 return sortByField.sort(a2, b2, view.sort?.direction ?? "desc"); 40339 } 40340 return 0; 40341 }); 40342 } 40343 let totalItems = filteredData.length; 40344 let totalPages = 1; 40345 if (view.page !== void 0 && view.perPage !== void 0) { 40346 const start2 = (view.page - 1) * view.perPage; 40347 totalItems = filteredData?.length || 0; 40348 totalPages = Math.ceil(totalItems / view.perPage); 40349 filteredData = filteredData?.slice(start2, start2 + view.perPage); 40350 } 40351 return { 40352 data: filteredData, 40353 paginationInfo: { 40354 totalItems, 40355 totalPages 40356 } 40357 }; 40358 } 40359 40360 // packages/edit-site/build-module/components/page-patterns/index.js 40361 var import_core_data47 = __toESM(require_core_data()); 40362 var import_editor30 = __toESM(require_editor()); 40363 var import_router30 = __toESM(require_router()); 40364 40365 // node_modules/dequal/dist/index.mjs 40366 var has = Object.prototype.hasOwnProperty; 40367 function find(iter, tar, key) { 40368 for (key of iter.keys()) { 40369 if (dequal(key, tar)) return key; 40370 } 40371 } 40372 function dequal(foo, bar) { 40373 var ctor, len, tmp; 40374 if (foo === bar) return true; 40375 if (foo && bar && (ctor = foo.constructor) === bar.constructor) { 40376 if (ctor === Date) return foo.getTime() === bar.getTime(); 40377 if (ctor === RegExp) return foo.toString() === bar.toString(); 40378 if (ctor === Array) { 40379 if ((len = foo.length) === bar.length) { 40380 while (len-- && dequal(foo[len], bar[len])) ; 40381 } 40382 return len === -1; 40383 } 40384 if (ctor === Set) { 40385 if (foo.size !== bar.size) { 40386 return false; 40387 } 40388 for (len of foo) { 40389 tmp = len; 40390 if (tmp && typeof tmp === "object") { 40391 tmp = find(bar, tmp); 40392 if (!tmp) return false; 40393 } 40394 if (!bar.has(tmp)) return false; 40395 } 40396 return true; 40397 } 40398 if (ctor === Map) { 40399 if (foo.size !== bar.size) { 40400 return false; 40401 } 40402 for (len of foo) { 40403 tmp = len[0]; 40404 if (tmp && typeof tmp === "object") { 40405 tmp = find(bar, tmp); 40406 if (!tmp) return false; 40407 } 40408 if (!dequal(len[1], bar.get(tmp))) { 40409 return false; 40410 } 40411 } 40412 return true; 40413 } 40414 if (ctor === ArrayBuffer) { 40415 foo = new Uint8Array(foo); 40416 bar = new Uint8Array(bar); 40417 } else if (ctor === DataView) { 40418 if ((len = foo.byteLength) === bar.byteLength) { 40419 while (len-- && foo.getInt8(len) === bar.getInt8(len)) ; 40420 } 40421 return len === -1; 40422 } 40423 if (ArrayBuffer.isView(foo)) { 40424 if ((len = foo.byteLength) === bar.byteLength) { 40425 while (len-- && foo[len] === bar[len]) ; 40426 } 40427 return len === -1; 40428 } 40429 if (!ctor || typeof foo === "object") { 40430 len = 0; 40431 for (ctor in foo) { 40432 if (has.call(foo, ctor) && ++len && !has.call(bar, ctor)) return false; 40433 if (!(ctor in bar) || !dequal(foo[ctor], bar[ctor])) return false; 40434 } 40435 return Object.keys(bar).length === len; 40436 } 40437 } 40438 return foo !== foo && bar !== bar; 40439 } 40440 40441 // packages/views/build-module/preference-keys.js 40442 function generatePreferenceKey(kind, name2, slug) { 40443 return `dataviews-$kind}-$name2}-$slug}`; 40444 } 40445 40446 // packages/views/build-module/use-view.js 40447 var import_element126 = __toESM(require_element()); 40448 var import_data62 = __toESM(require_data()); 40449 var import_preferences11 = __toESM(require_preferences()); 40450 function omit3(obj, keys) { 40451 const result = { ...obj }; 40452 for (const key of keys) { 40453 delete result[key]; 40454 } 40455 return result; 40456 } 40457 function useView(config2) { 40458 const { kind, name: name2, slug, defaultView, queryParams, onChangeQueryParams } = config2; 40459 const preferenceKey = generatePreferenceKey(kind, name2, slug); 40460 const persistedView = (0, import_data62.useSelect)( 40461 (select3) => { 40462 return select3(import_preferences11.store).get( 40463 "core/views", 40464 preferenceKey 40465 ); 40466 }, 40467 [preferenceKey] 40468 ); 40469 const { set } = (0, import_data62.useDispatch)(import_preferences11.store); 40470 const baseView = persistedView ?? defaultView; 40471 const page = Number(queryParams?.page ?? baseView.page ?? 1); 40472 const search = queryParams?.search ?? baseView.search ?? ""; 40473 const view = (0, import_element126.useMemo)(() => { 40474 return { 40475 ...baseView, 40476 page, 40477 search 40478 }; 40479 }, [baseView, page, search]); 40480 const isModified = !!persistedView; 40481 const updateView = (0, import_element126.useCallback)( 40482 (newView) => { 40483 const urlParams = { 40484 page: newView?.page, 40485 search: newView?.search 40486 }; 40487 const preferenceView = omit3(newView, ["page", "search"]); 40488 if (onChangeQueryParams && !dequal(urlParams, { page, search })) { 40489 onChangeQueryParams(urlParams); 40490 } 40491 if (!dequal(baseView, preferenceView)) { 40492 if (dequal(preferenceView, defaultView)) { 40493 set("core/views", preferenceKey, void 0); 40494 } else { 40495 set("core/views", preferenceKey, preferenceView); 40496 } 40497 } 40498 }, 40499 [ 40500 onChangeQueryParams, 40501 page, 40502 search, 40503 baseView, 40504 defaultView, 40505 set, 40506 preferenceKey 40507 ] 40508 ); 40509 const resetToDefault = (0, import_element126.useCallback)(() => { 40510 set("core/views", preferenceKey, void 0); 40511 }, [preferenceKey, set]); 40512 return { 40513 view, 40514 isModified, 40515 updateView, 40516 resetToDefault 40517 }; 40518 } 40519 40520 // packages/views/build-module/load-view.js 40521 var import_data63 = __toESM(require_data()); 40522 var import_preferences12 = __toESM(require_preferences()); 40523 async function loadView(config2) { 40524 const { kind, name: name2, slug, defaultView, queryParams } = config2; 40525 const preferenceKey = generatePreferenceKey(kind, name2, slug); 40526 const persistedView = (0, import_data63.select)(import_preferences12.store).get( 40527 "core/views", 40528 preferenceKey 40529 ); 40530 const baseView = persistedView ?? defaultView; 40531 const page = queryParams?.page ?? 1; 40532 const search = queryParams?.search ?? ""; 40533 return { 40534 ...baseView, 40535 page, 40536 search 40537 }; 40538 } 40539 40540 // packages/edit-site/build-module/components/page-patterns/index.js 40541 var import_data69 = __toESM(require_data()); 40542 40543 // packages/edit-site/build-module/components/page-patterns/use-pattern-settings.js 40544 var import_core_data42 = __toESM(require_core_data()); 40545 var import_data64 = __toESM(require_data()); 40546 var import_element127 = __toESM(require_element()); 40547 var import_editor27 = __toESM(require_editor()); 40548 var { useGlobalStyles: useGlobalStyles3 } = unlock(import_editor27.privateApis); 40549 function usePatternSettings() { 40550 const { merged: mergedConfig } = useGlobalStyles3(); 40551 const storedSettings = (0, import_data64.useSelect)((select3) => { 40552 const { getSettings: getSettings7 } = unlock(select3(store)); 40553 return getSettings7(); 40554 }, []); 40555 const settingsBlockPatterns = storedSettings.__experimentalAdditionalBlockPatterns ?? // WP 6.0 40556 storedSettings.__experimentalBlockPatterns; 40557 const restBlockPatterns = (0, import_data64.useSelect)( 40558 (select3) => select3(import_core_data42.store).getBlockPatterns(), 40559 [] 40560 ); 40561 const blockPatterns = (0, import_element127.useMemo)( 40562 () => [ 40563 ...settingsBlockPatterns || [], 40564 ...restBlockPatterns || [] 40565 ].filter(filterOutDuplicatesByName), 40566 [settingsBlockPatterns, restBlockPatterns] 40567 ); 40568 const [globalStyles, globalSettings] = (0, import_element127.useMemo)(() => { 40569 return generateGlobalStyles(mergedConfig, [], { 40570 disableRootPadding: false 40571 }); 40572 }, [mergedConfig]); 40573 const settings2 = (0, import_element127.useMemo)(() => { 40574 const { 40575 __experimentalAdditionalBlockPatterns, 40576 styles, 40577 __experimentalFeatures, 40578 ...restStoredSettings 40579 } = storedSettings; 40580 return { 40581 ...restStoredSettings, 40582 styles: globalStyles, 40583 __experimentalFeatures: globalSettings, 40584 __experimentalBlockPatterns: blockPatterns, 40585 isPreviewMode: true 40586 }; 40587 }, [storedSettings, blockPatterns, globalStyles, globalSettings]); 40588 return settings2; 40589 } 40590 40591 // packages/edit-site/build-module/components/page-patterns/actions.js 40592 var import_components153 = __toESM(require_components()); 40593 var import_i18n132 = __toESM(require_i18n()); 40594 40595 // packages/edit-site/build-module/components/add-new-pattern/index.js 40596 var import_components150 = __toESM(require_components()); 40597 var import_element128 = __toESM(require_element()); 40598 var import_i18n129 = __toESM(require_i18n()); 40599 var import_data65 = __toESM(require_data()); 40600 var import_router27 = __toESM(require_router()); 40601 var import_patterns2 = __toESM(require_patterns()); 40602 var import_notices5 = __toESM(require_notices()); 40603 var import_core_data43 = __toESM(require_core_data()); 40604 var import_editor28 = __toESM(require_editor()); 40605 var import_jsx_runtime264 = __toESM(require_jsx_runtime()); 40606 var { useHistory: useHistory17, useLocation: useLocation24 } = unlock(import_router27.privateApis); 40607 var { CreatePatternModal, useAddPatternCategory } = unlock( 40608 import_patterns2.privateApis 40609 ); 40610 var { CreateTemplatePartModal } = unlock(import_editor28.privateApis); 40611 function AddNewPattern() { 40612 const history = useHistory17(); 40613 const location = useLocation24(); 40614 const [showPatternModal, setShowPatternModal] = (0, import_element128.useState)(false); 40615 const [showTemplatePartModal, setShowTemplatePartModal] = (0, import_element128.useState)(false); 40616 const { createPatternFromFile } = unlock((0, import_data65.useDispatch)(import_patterns2.store)); 40617 const { createSuccessNotice, createErrorNotice } = (0, import_data65.useDispatch)(import_notices5.store); 40618 const patternUploadInputRef = (0, import_element128.useRef)(); 40619 const { 40620 isBlockBasedTheme, 40621 addNewPatternLabel, 40622 addNewTemplatePartLabel, 40623 canCreatePattern, 40624 canCreateTemplatePart 40625 } = (0, import_data65.useSelect)((select3) => { 40626 const { getCurrentTheme, getPostType: getPostType2, canUser } = select3(import_core_data43.store); 40627 return { 40628 isBlockBasedTheme: getCurrentTheme()?.is_block_theme, 40629 addNewPatternLabel: getPostType2(PATTERN_TYPES.user)?.labels?.add_new_item, 40630 addNewTemplatePartLabel: getPostType2(TEMPLATE_PART_POST_TYPE)?.labels?.add_new_item, 40631 // Blocks refers to the wp_block post type, this checks the ability to create a post of that type. 40632 canCreatePattern: canUser("create", { 40633 kind: "postType", 40634 name: PATTERN_TYPES.user 40635 }), 40636 canCreateTemplatePart: canUser("create", { 40637 kind: "postType", 40638 name: TEMPLATE_PART_POST_TYPE 40639 }) 40640 }; 40641 }, []); 40642 function handleCreatePattern({ pattern }) { 40643 setShowPatternModal(false); 40644 history.navigate( 40645 `/$PATTERN_TYPES.user}/$pattern.id}?canvas=edit` 40646 ); 40647 } 40648 function handleCreateTemplatePart(templatePart) { 40649 setShowTemplatePartModal(false); 40650 history.navigate( 40651 `/$TEMPLATE_PART_POST_TYPE}/$templatePart.id}?canvas=edit` 40652 ); 40653 } 40654 function handleError() { 40655 setShowPatternModal(false); 40656 setShowTemplatePartModal(false); 40657 } 40658 const controls = []; 40659 if (canCreatePattern) { 40660 controls.push({ 40661 icon: symbol_default, 40662 onClick: () => setShowPatternModal(true), 40663 title: addNewPatternLabel 40664 }); 40665 } 40666 if (isBlockBasedTheme && canCreateTemplatePart) { 40667 controls.push({ 40668 icon: symbol_filled_default, 40669 onClick: () => setShowTemplatePartModal(true), 40670 title: addNewTemplatePartLabel 40671 }); 40672 } 40673 if (canCreatePattern) { 40674 controls.push({ 40675 icon: upload_default, 40676 onClick: () => { 40677 patternUploadInputRef.current.click(); 40678 }, 40679 title: (0, import_i18n129.__)("Import pattern from JSON") 40680 }); 40681 } 40682 const { categoryMap, findOrCreateTerm } = useAddPatternCategory(); 40683 if (controls.length === 0) { 40684 return null; 40685 } 40686 return /* @__PURE__ */ (0, import_jsx_runtime264.jsxs)(import_jsx_runtime264.Fragment, { children: [ 40687 addNewPatternLabel && /* @__PURE__ */ (0, import_jsx_runtime264.jsx)( 40688 import_components150.DropdownMenu, 40689 { 40690 controls, 40691 icon: null, 40692 toggleProps: { 40693 variant: "primary", 40694 showTooltip: false, 40695 __next40pxDefaultSize: true 40696 }, 40697 text: addNewPatternLabel, 40698 label: addNewPatternLabel 40699 } 40700 ), 40701 showPatternModal && /* @__PURE__ */ (0, import_jsx_runtime264.jsx)( 40702 CreatePatternModal, 40703 { 40704 onClose: () => setShowPatternModal(false), 40705 onSuccess: handleCreatePattern, 40706 onError: handleError 40707 } 40708 ), 40709 showTemplatePartModal && /* @__PURE__ */ (0, import_jsx_runtime264.jsx)( 40710 CreateTemplatePartModal, 40711 { 40712 closeModal: () => setShowTemplatePartModal(false), 40713 blocks: [], 40714 onCreate: handleCreateTemplatePart, 40715 onError: handleError 40716 } 40717 ), 40718 /* @__PURE__ */ (0, import_jsx_runtime264.jsx)( 40719 "input", 40720 { 40721 type: "file", 40722 accept: ".json", 40723 hidden: true, 40724 ref: patternUploadInputRef, 40725 onChange: async (event) => { 40726 const file = event.target.files?.[0]; 40727 if (!file) { 40728 return; 40729 } 40730 try { 40731 let currentCategoryId; 40732 if (location.query.postType !== TEMPLATE_PART_POST_TYPE) { 40733 const currentCategory = Array.from( 40734 categoryMap.values() 40735 ).find( 40736 (term) => term.name === location.query.categoryId 40737 ); 40738 if (currentCategory) { 40739 currentCategoryId = currentCategory.id || await findOrCreateTerm( 40740 currentCategory.label 40741 ); 40742 } 40743 } 40744 const pattern = await createPatternFromFile( 40745 file, 40746 currentCategoryId ? [currentCategoryId] : void 0 40747 ); 40748 if (!currentCategoryId && location.query.categoryId !== "my-patterns") { 40749 history.navigate( 40750 `/pattern?categoryId=$PATTERN_DEFAULT_CATEGORY}` 40751 ); 40752 } 40753 createSuccessNotice( 40754 (0, import_i18n129.sprintf)( 40755 // translators: %s: The imported pattern's title. 40756 (0, import_i18n129.__)('Imported "%s" from JSON.'), 40757 pattern.title.raw 40758 ), 40759 { 40760 type: "snackbar", 40761 id: "import-pattern-success" 40762 } 40763 ); 40764 } catch (err) { 40765 createErrorNotice(err.message, { 40766 type: "snackbar", 40767 id: "import-pattern-error" 40768 }); 40769 } finally { 40770 event.target.value = ""; 40771 } 40772 } 40773 } 40774 ) 40775 ] }); 40776 } 40777 40778 // packages/edit-site/build-module/components/page-patterns/rename-category-menu-item.js 40779 var import_components151 = __toESM(require_components()); 40780 var import_element129 = __toESM(require_element()); 40781 var import_i18n130 = __toESM(require_i18n()); 40782 var import_patterns3 = __toESM(require_patterns()); 40783 var import_jsx_runtime265 = __toESM(require_jsx_runtime()); 40784 var { RenamePatternCategoryModal } = unlock(import_patterns3.privateApis); 40785 function RenameCategoryMenuItem({ category, onClose }) { 40786 const [isModalOpen, setIsModalOpen] = (0, import_element129.useState)(false); 40787 return /* @__PURE__ */ (0, import_jsx_runtime265.jsxs)(import_jsx_runtime265.Fragment, { children: [ 40788 /* @__PURE__ */ (0, import_jsx_runtime265.jsx)(import_components151.MenuItem, { onClick: () => setIsModalOpen(true), children: (0, import_i18n130.__)("Rename") }), 40789 isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime265.jsx)( 40790 RenameModal2, 40791 { 40792 category, 40793 onClose: () => { 40794 setIsModalOpen(false); 40795 onClose(); 40796 } 40797 } 40798 ) 40799 ] }); 40800 } 40801 function RenameModal2({ category, onClose }) { 40802 const normalizedCategory = { 40803 id: category.id, 40804 slug: category.slug, 40805 name: category.label 40806 }; 40807 const existingCategories = usePatternCategories(); 40808 return /* @__PURE__ */ (0, import_jsx_runtime265.jsx)( 40809 RenamePatternCategoryModal, 40810 { 40811 category: normalizedCategory, 40812 existingCategories, 40813 onClose, 40814 overlayClassName: "edit-site-list__rename-modal", 40815 focusOnMount: "firstContentElement", 40816 size: "small" 40817 } 40818 ); 40819 } 40820 40821 // packages/edit-site/build-module/components/page-patterns/delete-category-menu-item.js 40822 var import_components152 = __toESM(require_components()); 40823 var import_core_data44 = __toESM(require_core_data()); 40824 var import_data66 = __toESM(require_data()); 40825 var import_element130 = __toESM(require_element()); 40826 var import_html_entities9 = __toESM(require_html_entities()); 40827 var import_i18n131 = __toESM(require_i18n()); 40828 var import_notices6 = __toESM(require_notices()); 40829 var import_router28 = __toESM(require_router()); 40830 var import_jsx_runtime266 = __toESM(require_jsx_runtime()); 40831 var { useHistory: useHistory18 } = unlock(import_router28.privateApis); 40832 function DeleteCategoryMenuItem({ category, onClose }) { 40833 const [isModalOpen, setIsModalOpen] = (0, import_element130.useState)(false); 40834 const history = useHistory18(); 40835 const { createSuccessNotice, createErrorNotice } = (0, import_data66.useDispatch)(import_notices6.store); 40836 const { deleteEntityRecord, invalidateResolution } = (0, import_data66.useDispatch)(import_core_data44.store); 40837 const onDelete = async () => { 40838 try { 40839 await deleteEntityRecord( 40840 "taxonomy", 40841 "wp_pattern_category", 40842 category.id, 40843 { force: true }, 40844 { throwOnError: true } 40845 ); 40846 invalidateResolution("getUserPatternCategories"); 40847 invalidateResolution("getEntityRecords", [ 40848 "postType", 40849 PATTERN_TYPES.user, 40850 { per_page: -1 } 40851 ]); 40852 createSuccessNotice( 40853 (0, import_i18n131.sprintf)( 40854 /* translators: %s: The pattern category's name */ 40855 (0, import_i18n131._x)('"%s" deleted.', "pattern category"), 40856 category.label 40857 ), 40858 { type: "snackbar", id: "pattern-category-delete" } 40859 ); 40860 onClose?.(); 40861 history.navigate( 40862 `/pattern?categoryId=$PATTERN_DEFAULT_CATEGORY}` 40863 ); 40864 } catch (error) { 40865 const errorMessage = error.message && error.code !== "unknown_error" ? error.message : (0, import_i18n131.__)( 40866 "An error occurred while deleting the pattern category." 40867 ); 40868 createErrorNotice(errorMessage, { 40869 type: "snackbar", 40870 id: "pattern-category-delete" 40871 }); 40872 } 40873 }; 40874 return /* @__PURE__ */ (0, import_jsx_runtime266.jsxs)(import_jsx_runtime266.Fragment, { children: [ 40875 /* @__PURE__ */ (0, import_jsx_runtime266.jsx)(import_components152.MenuItem, { isDestructive: true, onClick: () => setIsModalOpen(true), children: (0, import_i18n131.__)("Delete") }), 40876 /* @__PURE__ */ (0, import_jsx_runtime266.jsx)( 40877 import_components152.__experimentalConfirmDialog, 40878 { 40879 isOpen: isModalOpen, 40880 onConfirm: onDelete, 40881 onCancel: () => setIsModalOpen(false), 40882 confirmButtonText: (0, import_i18n131.__)("Delete"), 40883 className: "edit-site-patterns__delete-modal", 40884 title: (0, import_i18n131.sprintf)( 40885 // translators: %s: The pattern category's name. 40886 (0, import_i18n131._x)('Delete "%s"?', "pattern category"), 40887 (0, import_html_entities9.decodeEntities)(category.label) 40888 ), 40889 size: "medium", 40890 __experimentalHideHeader: false, 40891 children: (0, import_i18n131.sprintf)( 40892 // translators: %s: The pattern category's name. 40893 (0, import_i18n131.__)( 40894 'Are you sure you want to delete the category "%s"? The patterns will not be deleted.' 40895 ), 40896 (0, import_html_entities9.decodeEntities)(category.label) 40897 ) 40898 } 40899 ) 40900 ] }); 40901 } 40902 40903 // packages/edit-site/build-module/components/page-patterns/actions.js 40904 var import_jsx_runtime267 = __toESM(require_jsx_runtime()); 40905 function PatternsActions({ categoryId, type }) { 40906 const { patternCategories } = usePatternCategories(); 40907 let patternCategory; 40908 if (type === PATTERN_TYPES.user && !!categoryId) { 40909 patternCategory = patternCategories.find( 40910 (category) => category.name === categoryId 40911 ); 40912 } 40913 return /* @__PURE__ */ (0, import_jsx_runtime267.jsxs)(import_jsx_runtime267.Fragment, { children: [ 40914 /* @__PURE__ */ (0, import_jsx_runtime267.jsx)(AddNewPattern, {}), 40915 !!patternCategory?.id && /* @__PURE__ */ (0, import_jsx_runtime267.jsx)( 40916 import_components153.DropdownMenu, 40917 { 40918 icon: more_vertical_default, 40919 label: (0, import_i18n132.__)("Actions"), 40920 toggleProps: { 40921 className: "edit-site-patterns__button", 40922 size: "compact" 40923 }, 40924 children: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime267.jsxs)(import_components153.MenuGroup, { children: [ 40925 /* @__PURE__ */ (0, import_jsx_runtime267.jsx)( 40926 RenameCategoryMenuItem, 40927 { 40928 category: patternCategory, 40929 onClose 40930 } 40931 ), 40932 /* @__PURE__ */ (0, import_jsx_runtime267.jsx)( 40933 DeleteCategoryMenuItem, 40934 { 40935 category: patternCategory, 40936 onClose 40937 } 40938 ) 40939 ] }) 40940 } 40941 ) 40942 ] }); 40943 } 40944 40945 // packages/edit-site/build-module/components/dataviews-actions/index.js 40946 var import_i18n133 = __toESM(require_i18n()); 40947 var import_element131 = __toESM(require_element()); 40948 var import_router29 = __toESM(require_router()); 40949 var import_data67 = __toESM(require_data()); 40950 var import_core_data45 = __toESM(require_core_data()); 40951 var { useHistory: useHistory19 } = unlock(import_router29.privateApis); 40952 var useSetActiveTemplateAction = () => { 40953 const activeTheme = (0, import_data67.useSelect)( 40954 (select3) => select3(import_core_data45.store).getCurrentTheme() 40955 ); 40956 const { getEntityRecord } = (0, import_data67.useSelect)(import_core_data45.store); 40957 const { editEntityRecord, saveEditedEntityRecord } = (0, import_data67.useDispatch)(import_core_data45.store); 40958 return (0, import_element131.useMemo)( 40959 () => ({ 40960 id: "set-active-template", 40961 label(items) { 40962 return items.some((item) => item._isActive) ? (0, import_i18n133.__)("Deactivate") : (0, import_i18n133.__)("Activate"); 40963 }, 40964 isPrimary: true, 40965 icon: pencil_default, 40966 isEligible(item) { 40967 if (item.theme !== activeTheme.stylesheet) { 40968 return false; 40969 } 40970 if (typeof item.id !== "number") { 40971 return item._isActive === false; 40972 } 40973 return true; 40974 }, 40975 async callback(items) { 40976 const deactivate = items.some((item) => item._isActive); 40977 const activeTemplates = { 40978 ...await getEntityRecord("root", "site").active_templates ?? {} 40979 }; 40980 for (const item of items) { 40981 if (deactivate) { 40982 delete activeTemplates[item.slug]; 40983 } else { 40984 activeTemplates[item.slug] = item.id; 40985 } 40986 } 40987 await editEntityRecord("root", "site", void 0, { 40988 active_templates: activeTemplates 40989 }); 40990 await saveEditedEntityRecord("root", "site"); 40991 } 40992 }), 40993 [ 40994 editEntityRecord, 40995 saveEditedEntityRecord, 40996 getEntityRecord, 40997 activeTheme 40998 ] 40999 ); 41000 }; 41001 var useEditPostAction = () => { 41002 const history = useHistory19(); 41003 return (0, import_element131.useMemo)( 41004 () => ({ 41005 id: "edit-post", 41006 label: (0, import_i18n133.__)("Edit"), 41007 isPrimary: true, 41008 icon: pencil_default, 41009 isEligible(post2) { 41010 if (post2.status === "trash") { 41011 return false; 41012 } 41013 return post2.type !== PATTERN_TYPES.theme; 41014 }, 41015 callback(items) { 41016 const post2 = items[0]; 41017 history.navigate(`/$post2.type}/$post2.id}?canvas=edit`); 41018 } 41019 }), 41020 [history] 41021 ); 41022 }; 41023 41024 // packages/edit-site/build-module/components/page-patterns/fields.js 41025 var import_components154 = __toESM(require_components()); 41026 var import_i18n134 = __toESM(require_i18n()); 41027 var import_element132 = __toESM(require_element()); 41028 var import_block_editor23 = __toESM(require_block_editor()); 41029 var import_blocks12 = __toESM(require_blocks()); 41030 var import_editor29 = __toESM(require_editor()); 41031 41032 // packages/edit-site/build-module/components/page-templates/hooks.js 41033 var import_core_data46 = __toESM(require_core_data()); 41034 var import_data68 = __toESM(require_data()); 41035 function useAddedBy(postType2, postId) { 41036 return (0, import_data68.useSelect)( 41037 (select3) => { 41038 const { getEntityRecord, getUser, getEditedEntityRecord } = select3(import_core_data46.store); 41039 const template = getEditedEntityRecord( 41040 "postType", 41041 postType2, 41042 postId 41043 ); 41044 const originalSource = template?.original_source; 41045 const authorText = template?.author_text; 41046 switch (originalSource) { 41047 case "theme": { 41048 return { 41049 type: originalSource, 41050 icon: layout_default, 41051 text: authorText, 41052 isCustomized: template.source === TEMPLATE_ORIGINS.custom 41053 }; 41054 } 41055 case "plugin": { 41056 return { 41057 type: originalSource, 41058 icon: plugins_default, 41059 text: authorText, 41060 isCustomized: template.source === TEMPLATE_ORIGINS.custom 41061 }; 41062 } 41063 case "site": { 41064 const siteData = getEntityRecord( 41065 "root", 41066 "__unstableBase" 41067 ); 41068 return { 41069 type: originalSource, 41070 icon: globe_default, 41071 imageUrl: siteData?.site_logo ? getEntityRecord( 41072 "postType", 41073 "attachment", 41074 siteData.site_logo 41075 )?.source_url : void 0, 41076 text: authorText, 41077 isCustomized: false 41078 }; 41079 } 41080 default: { 41081 const user = getUser(template.author); 41082 return { 41083 type: "user", 41084 icon: comment_author_avatar_default, 41085 imageUrl: user?.avatar_urls?.[48], 41086 text: authorText ?? user?.name, 41087 isCustomized: false 41088 }; 41089 } 41090 } 41091 }, 41092 [postType2, postId] 41093 ); 41094 } 41095 41096 // packages/edit-site/build-module/components/page-patterns/fields.js 41097 var import_jsx_runtime268 = __toESM(require_jsx_runtime()); 41098 var { useStyle: useStyle4 } = unlock(import_editor29.privateApis); 41099 function PreviewField({ item }) { 41100 const descriptionId = (0, import_element132.useId)(); 41101 const description = item.description || item?.excerpt?.raw; 41102 const isTemplatePart2 = item.type === TEMPLATE_PART_POST_TYPE; 41103 const backgroundColor = useStyle4("color.background"); 41104 const blocks = (0, import_element132.useMemo)(() => { 41105 return item.blocks ?? (0, import_blocks12.parse)(item.content.raw, { 41106 __unstableSkipMigrationLogs: true 41107 }); 41108 }, [item?.content?.raw, item.blocks]); 41109 const isEmpty3 = !blocks?.length; 41110 return /* @__PURE__ */ (0, import_jsx_runtime268.jsxs)( 41111 "div", 41112 { 41113 className: "page-patterns-preview-field", 41114 style: { backgroundColor }, 41115 "aria-describedby": !!description ? descriptionId : void 0, 41116 children: [ 41117 isEmpty3 && isTemplatePart2 && (0, import_i18n134.__)("Empty template part"), 41118 isEmpty3 && !isTemplatePart2 && (0, import_i18n134.__)("Empty pattern"), 41119 !isEmpty3 && /* @__PURE__ */ (0, import_jsx_runtime268.jsx)(import_block_editor23.BlockPreview.Async, { children: /* @__PURE__ */ (0, import_jsx_runtime268.jsx)( 41120 import_block_editor23.BlockPreview, 41121 { 41122 blocks, 41123 viewportWidth: item.viewportWidth 41124 } 41125 ) }), 41126 !!description && /* @__PURE__ */ (0, import_jsx_runtime268.jsx)("div", { hidden: true, id: descriptionId, children: description }) 41127 ] 41128 } 41129 ); 41130 } 41131 var previewField = { 41132 label: (0, import_i18n134.__)("Preview"), 41133 id: "preview", 41134 render: PreviewField, 41135 enableSorting: false 41136 }; 41137 var SYNC_FILTERS = [ 41138 { 41139 value: PATTERN_SYNC_TYPES.full, 41140 label: (0, import_i18n134._x)("Synced", "pattern (singular)"), 41141 description: (0, import_i18n134.__)("Patterns that are kept in sync across the site.") 41142 }, 41143 { 41144 value: PATTERN_SYNC_TYPES.unsynced, 41145 label: (0, import_i18n134._x)("Not synced", "pattern (singular)"), 41146 description: (0, import_i18n134.__)( 41147 "Patterns that can be changed freely without affecting the site." 41148 ) 41149 } 41150 ]; 41151 var patternStatusField = { 41152 label: (0, import_i18n134.__)("Sync status"), 41153 id: "sync-status", 41154 render: ({ item }) => { 41155 const syncStatus = "wp_pattern_sync_status" in item ? item.wp_pattern_sync_status || PATTERN_SYNC_TYPES.full : PATTERN_SYNC_TYPES.unsynced; 41156 return /* @__PURE__ */ (0, import_jsx_runtime268.jsx)( 41157 "span", 41158 { 41159 className: `edit-site-patterns__field-sync-status-$syncStatus}`, 41160 children: SYNC_FILTERS.find(({ value }) => value === syncStatus).label 41161 } 41162 ); 41163 }, 41164 elements: SYNC_FILTERS, 41165 filterBy: { 41166 operators: [OPERATOR_IS], 41167 isPrimary: true 41168 }, 41169 enableSorting: false 41170 }; 41171 function AuthorField({ item }) { 41172 const [isImageLoaded, setIsImageLoaded] = (0, import_element132.useState)(false); 41173 const { text, icon, imageUrl } = useAddedBy(item.type, item.id); 41174 return /* @__PURE__ */ (0, import_jsx_runtime268.jsxs)(import_components154.__experimentalHStack, { alignment: "left", spacing: 0, children: [ 41175 imageUrl && /* @__PURE__ */ (0, import_jsx_runtime268.jsx)( 41176 "div", 41177 { 41178 className: clsx_default("page-templates-author-field__avatar", { 41179 "is-loaded": isImageLoaded 41180 }), 41181 children: /* @__PURE__ */ (0, import_jsx_runtime268.jsx)( 41182 "img", 41183 { 41184 onLoad: () => setIsImageLoaded(true), 41185 alt: "", 41186 src: imageUrl 41187 } 41188 ) 41189 } 41190 ), 41191 !imageUrl && /* @__PURE__ */ (0, import_jsx_runtime268.jsx)("div", { className: "page-templates-author-field__icon", children: /* @__PURE__ */ (0, import_jsx_runtime268.jsx)(icon_default, { icon }) }), 41192 /* @__PURE__ */ (0, import_jsx_runtime268.jsx)("span", { className: "page-templates-author-field__name", children: text }) 41193 ] }); 41194 } 41195 var templatePartAuthorField = { 41196 label: (0, import_i18n134.__)("Author"), 41197 id: "author", 41198 getValue: ({ item }) => item.author_text, 41199 render: AuthorField, 41200 filterBy: { 41201 isPrimary: true 41202 } 41203 }; 41204 41205 // packages/edit-site/build-module/components/page-patterns/index.js 41206 var import_url16 = __toESM(require_url()); 41207 var import_components155 = __toESM(require_components()); 41208 var import_jsx_runtime269 = __toESM(require_jsx_runtime()); 41209 var { ExperimentalBlockEditorProvider } = unlock(import_block_editor24.privateApis); 41210 var { usePostActions, patternTitleField } = unlock(import_editor30.privateApis); 41211 var { useLocation: useLocation25, useHistory: useHistory20 } = unlock(import_router30.privateApis); 41212 var EMPTY_ARRAY10 = []; 41213 var defaultLayouts = { 41214 [LAYOUT_TABLE]: { 41215 layout: { 41216 styles: { 41217 author: { 41218 width: "1%" 41219 } 41220 } 41221 } 41222 }, 41223 [LAYOUT_GRID]: { 41224 layout: { 41225 badgeFields: ["sync-status"] 41226 } 41227 } 41228 }; 41229 var DEFAULT_VIEW = { 41230 type: LAYOUT_GRID, 41231 perPage: 20, 41232 titleField: "title", 41233 mediaField: "preview", 41234 fields: ["sync-status"], 41235 filters: [], 41236 ...defaultLayouts[LAYOUT_GRID] 41237 }; 41238 function usePagePatternsHeader(type, categoryId) { 41239 const { patternCategories } = usePatternCategories(); 41240 const templatePartAreas = (0, import_data69.useSelect)( 41241 (select3) => select3(import_core_data47.store).getCurrentTheme()?.default_template_part_areas || [], 41242 [] 41243 ); 41244 let title, description, patternCategory; 41245 if (type === TEMPLATE_PART_POST_TYPE) { 41246 const templatePartArea = templatePartAreas.find( 41247 (area) => area.area === categoryId 41248 ); 41249 title = templatePartArea?.label || (0, import_i18n135.__)("All Template Parts"); 41250 description = templatePartArea?.description || (0, import_i18n135.__)("Includes every template part defined for any area."); 41251 } else if (type === PATTERN_TYPES.user && !!categoryId) { 41252 patternCategory = patternCategories.find( 41253 (category) => category.name === categoryId 41254 ); 41255 title = patternCategory?.label; 41256 description = patternCategory?.description; 41257 } 41258 return { title, description }; 41259 } 41260 function DataviewsPatterns() { 41261 const { path, query } = useLocation25(); 41262 const { postType: postType2 = "wp_block", categoryId: categoryIdFromURL } = query; 41263 const history = useHistory20(); 41264 const categoryId = categoryIdFromURL || PATTERN_DEFAULT_CATEGORY; 41265 const { view, updateView, isModified, resetToDefault } = useView({ 41266 kind: "postType", 41267 name: postType2, 41268 slug: categoryId, 41269 defaultView: DEFAULT_VIEW, 41270 queryParams: { 41271 page: query.pageNumber, 41272 search: query.search 41273 }, 41274 onChangeQueryParams: (params) => { 41275 history.navigate( 41276 (0, import_url16.addQueryArgs)(path, { 41277 ...query, 41278 pageNumber: params.page, 41279 search: params.search 41280 }) 41281 ); 41282 } 41283 }); 41284 const viewSyncStatus = view.filters?.find( 41285 ({ field }) => field === "sync-status" 41286 )?.value; 41287 const { patterns, isResolving } = use_patterns_default(postType2, categoryId, { 41288 search: view.search, 41289 syncStatus: viewSyncStatus 41290 }); 41291 const { records } = (0, import_core_data47.useEntityRecords)("postType", TEMPLATE_PART_POST_TYPE, { 41292 per_page: -1 41293 }); 41294 const authors = (0, import_element133.useMemo)(() => { 41295 if (!records) { 41296 return EMPTY_ARRAY10; 41297 } 41298 const authorsSet = /* @__PURE__ */ new Set(); 41299 records.forEach((template) => { 41300 authorsSet.add(template.author_text); 41301 }); 41302 return Array.from(authorsSet).map((author) => ({ 41303 value: author, 41304 label: author 41305 })); 41306 }, [records]); 41307 const fields = (0, import_element133.useMemo)(() => { 41308 const _fields = [previewField, patternTitleField]; 41309 if (postType2 === PATTERN_TYPES.user) { 41310 _fields.push(patternStatusField); 41311 } else if (postType2 === TEMPLATE_PART_POST_TYPE) { 41312 _fields.push({ 41313 ...templatePartAuthorField, 41314 elements: authors 41315 }); 41316 } 41317 return _fields; 41318 }, [postType2, authors]); 41319 const { data, paginationInfo } = (0, import_element133.useMemo)(() => { 41320 const viewWithoutFilters = { ...view }; 41321 delete viewWithoutFilters.search; 41322 if (postType2 !== TEMPLATE_PART_POST_TYPE) { 41323 viewWithoutFilters.filters = []; 41324 } 41325 return filterSortAndPaginate(patterns, viewWithoutFilters, fields); 41326 }, [patterns, view, fields, postType2]); 41327 const dataWithPermissions = useAugmentPatternsWithPermissions(data); 41328 const templatePartActions = usePostActions({ 41329 postType: TEMPLATE_PART_POST_TYPE, 41330 context: "list" 41331 }); 41332 const patternActions = usePostActions({ 41333 postType: PATTERN_TYPES.user, 41334 context: "list" 41335 }); 41336 const editAction = useEditPostAction(); 41337 const actions = (0, import_element133.useMemo)(() => { 41338 if (postType2 === TEMPLATE_PART_POST_TYPE) { 41339 return [editAction, ...templatePartActions].filter(Boolean); 41340 } 41341 return [editAction, ...patternActions].filter(Boolean); 41342 }, [editAction, postType2, templatePartActions, patternActions]); 41343 const settings2 = usePatternSettings(); 41344 const { title, description } = usePagePatternsHeader( 41345 postType2, 41346 categoryId 41347 ); 41348 return /* @__PURE__ */ (0, import_jsx_runtime269.jsx)(ExperimentalBlockEditorProvider, { settings: settings2, children: /* @__PURE__ */ (0, import_jsx_runtime269.jsx)( 41349 page_default, 41350 { 41351 className: "edit-site-page-patterns-dataviews", 41352 title, 41353 subTitle: description, 41354 actions: /* @__PURE__ */ (0, import_jsx_runtime269.jsxs)(import_jsx_runtime269.Fragment, { children: [ 41355 isModified && /* @__PURE__ */ (0, import_jsx_runtime269.jsx)( 41356 import_components155.Button, 41357 { 41358 __next40pxDefaultSize: true, 41359 onClick: resetToDefault, 41360 children: (0, import_i18n135.__)("Reset view") 41361 } 41362 ), 41363 /* @__PURE__ */ (0, import_jsx_runtime269.jsx)(PatternsActions, {}) 41364 ] }), 41365 children: /* @__PURE__ */ (0, import_jsx_runtime269.jsx)( 41366 dataviews_default, 41367 { 41368 paginationInfo, 41369 fields, 41370 actions, 41371 data: dataWithPermissions || EMPTY_ARRAY10, 41372 getItemId: (item) => item.name ?? item.id, 41373 isLoading: isResolving, 41374 isItemClickable: (item) => item.type !== PATTERN_TYPES.theme, 41375 onClickItem: (item) => { 41376 history.navigate( 41377 `/$item.type}/${[ 41378 PATTERN_TYPES.user, 41379 TEMPLATE_PART_POST_TYPE 41380 ].includes(item.type) ? item.id : item.name}?canvas=edit` 41381 ); 41382 }, 41383 view, 41384 onChangeView: updateView, 41385 defaultLayouts 41386 }, 41387 categoryId + postType2 41388 ) 41389 } 41390 ) }); 41391 } 41392 41393 // packages/edit-site/build-module/components/site-editor-routes/patterns.js 41394 var import_jsx_runtime270 = __toESM(require_jsx_runtime()); 41395 var patternsRoute = { 41396 name: "patterns", 41397 path: "/pattern", 41398 areas: { 41399 sidebar({ siteData }) { 41400 const isBlockTheme = siteData.currentTheme?.is_block_theme; 41401 const backPath = isBlockTheme || isClassicThemeWithStyleBookSupport(siteData) ? "/" : void 0; 41402 return /* @__PURE__ */ (0, import_jsx_runtime270.jsx)(SidebarNavigationScreenPatterns, { backPath }); 41403 }, 41404 content: /* @__PURE__ */ (0, import_jsx_runtime270.jsx)(DataviewsPatterns, {}), 41405 mobile({ siteData, query }) { 41406 const { categoryId } = query; 41407 const isBlockTheme = siteData.currentTheme?.is_block_theme; 41408 const backPath = isBlockTheme || isClassicThemeWithStyleBookSupport(siteData) ? "/" : void 0; 41409 return !!categoryId ? /* @__PURE__ */ (0, import_jsx_runtime270.jsx)(DataviewsPatterns, {}) : /* @__PURE__ */ (0, import_jsx_runtime270.jsx)(SidebarNavigationScreenPatterns, { backPath }); 41410 } 41411 } 41412 }; 41413 41414 // packages/edit-site/build-module/components/site-editor-routes/pattern-item.js 41415 var import_jsx_runtime271 = __toESM(require_jsx_runtime()); 41416 var patternItemRoute = { 41417 name: "pattern-item", 41418 path: "/wp_block/:postId", 41419 areas: { 41420 sidebar({ siteData }) { 41421 const isBlockTheme = siteData.currentTheme?.is_block_theme; 41422 const backPath = isBlockTheme || isClassicThemeWithStyleBookSupport(siteData) ? "/" : void 0; 41423 return /* @__PURE__ */ (0, import_jsx_runtime271.jsx)(SidebarNavigationScreenPatterns, { backPath }); 41424 }, 41425 mobile: /* @__PURE__ */ (0, import_jsx_runtime271.jsx)(EditSiteEditor, {}), 41426 preview: /* @__PURE__ */ (0, import_jsx_runtime271.jsx)(EditSiteEditor, {}) 41427 } 41428 }; 41429 41430 // packages/edit-site/build-module/components/site-editor-routes/template-part-item.js 41431 var import_jsx_runtime272 = __toESM(require_jsx_runtime()); 41432 var templatePartItemRoute = { 41433 name: "template-part-item", 41434 path: "/wp_template_part/*postId", 41435 areas: { 41436 sidebar: /* @__PURE__ */ (0, import_jsx_runtime272.jsx)(SidebarNavigationScreenPatterns, { backPath: "/" }), 41437 mobile: /* @__PURE__ */ (0, import_jsx_runtime272.jsx)(EditSiteEditor, {}), 41438 preview: /* @__PURE__ */ (0, import_jsx_runtime272.jsx)(EditSiteEditor, {}) 41439 } 41440 }; 41441 41442 // packages/edit-site/build-module/components/sidebar-navigation-screen-templates-browse/index.js 41443 var import_i18n138 = __toESM(require_i18n()); 41444 41445 // packages/edit-site/build-module/components/sidebar-navigation-screen-templates-browse/content.js 41446 var import_core_data48 = __toESM(require_core_data()); 41447 var import_element134 = __toESM(require_element()); 41448 var import_components156 = __toESM(require_components()); 41449 var import_i18n136 = __toESM(require_i18n()); 41450 var import_router31 = __toESM(require_router()); 41451 var import_url17 = __toESM(require_url()); 41452 var import_jsx_runtime273 = __toESM(require_jsx_runtime()); 41453 var { useLocation: useLocation26 } = unlock(import_router31.privateApis); 41454 var EMPTY_ARRAY11 = []; 41455 function TemplateDataviewItem({ template, isActive }) { 41456 const { text, icon } = useAddedBy(template.type, template.id); 41457 return /* @__PURE__ */ (0, import_jsx_runtime273.jsx)( 41458 SidebarNavigationItem, 41459 { 41460 to: (0, import_url17.addQueryArgs)("/template", { activeView: text }), 41461 icon, 41462 "aria-current": isActive, 41463 children: text 41464 } 41465 ); 41466 } 41467 function DataviewsTemplatesSidebarContent() { 41468 const { 41469 query: { activeView = "active" } 41470 } = useLocation26(); 41471 const { records } = (0, import_core_data48.useEntityRecords)("root", "registeredTemplate", { 41472 // This should not be needed, the endpoint returns all registered 41473 // templates, but it's not possible right now to turn off pagination for 41474 // entity configs. 41475 per_page: -1 41476 }); 41477 const firstItemPerAuthorText = (0, import_element134.useMemo)(() => { 41478 const firstItemPerAuthor = records?.reduce((acc, template) => { 41479 const author = template.author_text; 41480 if (author && !acc[author]) { 41481 acc[author] = template; 41482 } 41483 return acc; 41484 }, {}); 41485 return (firstItemPerAuthor && Object.values(firstItemPerAuthor)) ?? EMPTY_ARRAY11; 41486 }, [records]); 41487 return /* @__PURE__ */ (0, import_jsx_runtime273.jsxs)(import_components156.__experimentalItemGroup, { className: "edit-site-sidebar-navigation-screen-templates-browse", children: [ 41488 /* @__PURE__ */ (0, import_jsx_runtime273.jsx)( 41489 SidebarNavigationItem, 41490 { 41491 to: "/template", 41492 icon: published_default, 41493 "aria-current": activeView === "active", 41494 children: (0, import_i18n136.__)("Active templates") 41495 } 41496 ), 41497 /* @__PURE__ */ (0, import_jsx_runtime273.jsx)( 41498 SidebarNavigationItem, 41499 { 41500 to: (0, import_url17.addQueryArgs)("/template", { activeView: "user" }), 41501 icon: comment_author_avatar_default, 41502 "aria-current": activeView === "user", 41503 // Let's avoid calling them "custom templates" to avoid 41504 // confusion. "Created" is closest to meaning database 41505 // templates, created by users. 41506 // https://developer.wordpress.org/themes/classic-themes/templates/page-template-files/#creating-custom-page-templates-for-global-use 41507 children: (0, import_i18n136.__)("Created templates") 41508 } 41509 ), 41510 firstItemPerAuthorText.map((template) => { 41511 return /* @__PURE__ */ (0, import_jsx_runtime273.jsx)( 41512 TemplateDataviewItem, 41513 { 41514 template, 41515 isActive: activeView === template.author_text 41516 }, 41517 template.author_text 41518 ); 41519 }) 41520 ] }); 41521 } 41522 41523 // packages/edit-site/build-module/components/sidebar-navigation-screen-templates-browse/content-legacy.js 41524 var import_core_data49 = __toESM(require_core_data()); 41525 var import_element135 = __toESM(require_element()); 41526 var import_components157 = __toESM(require_components()); 41527 var import_i18n137 = __toESM(require_i18n()); 41528 var import_router32 = __toESM(require_router()); 41529 var import_url18 = __toESM(require_url()); 41530 var import_jsx_runtime274 = __toESM(require_jsx_runtime()); 41531 var { useLocation: useLocation27 } = unlock(import_router32.privateApis); 41532 var EMPTY_ARRAY12 = []; 41533 function TemplateDataviewItem2({ template, isActive }) { 41534 const { text, icon } = useAddedBy(template.type, template.id); 41535 return /* @__PURE__ */ (0, import_jsx_runtime274.jsx)( 41536 SidebarNavigationItem, 41537 { 41538 to: (0, import_url18.addQueryArgs)("/template", { activeView: text }), 41539 icon, 41540 "aria-current": isActive, 41541 children: text 41542 } 41543 ); 41544 } 41545 function DataviewsTemplatesSidebarContent2() { 41546 const { 41547 query: { activeView = "all" } 41548 } = useLocation27(); 41549 const { records } = (0, import_core_data49.useEntityRecords)("postType", TEMPLATE_POST_TYPE, { 41550 per_page: -1 41551 }); 41552 const firstItemPerAuthorText = (0, import_element135.useMemo)(() => { 41553 const firstItemPerAuthor = records?.reduce((acc, template) => { 41554 const author = template.author_text; 41555 if (author && !acc[author]) { 41556 acc[author] = template; 41557 } 41558 return acc; 41559 }, {}); 41560 return (firstItemPerAuthor && Object.values(firstItemPerAuthor)) ?? EMPTY_ARRAY12; 41561 }, [records]); 41562 return /* @__PURE__ */ (0, import_jsx_runtime274.jsxs)(import_components157.__experimentalItemGroup, { className: "edit-site-sidebar-navigation-screen-templates-browse", children: [ 41563 /* @__PURE__ */ (0, import_jsx_runtime274.jsx)( 41564 SidebarNavigationItem, 41565 { 41566 to: "/template", 41567 icon: layout_default, 41568 "aria-current": activeView === "all", 41569 children: (0, import_i18n137.__)("All templates") 41570 } 41571 ), 41572 firstItemPerAuthorText.map((template) => { 41573 return /* @__PURE__ */ (0, import_jsx_runtime274.jsx)( 41574 TemplateDataviewItem2, 41575 { 41576 template, 41577 isActive: activeView === template.author_text 41578 }, 41579 template.author_text 41580 ); 41581 }) 41582 ] }); 41583 } 41584 41585 // packages/edit-site/build-module/components/sidebar-navigation-screen-templates-browse/index.js 41586 var import_jsx_runtime275 = __toESM(require_jsx_runtime()); 41587 function SidebarNavigationScreenTemplatesBrowse({ backPath }) { 41588 return /* @__PURE__ */ (0, import_jsx_runtime275.jsx)( 41589 SidebarNavigationScreen, 41590 { 41591 title: (0, import_i18n138.__)("Templates"), 41592 description: (0, import_i18n138.__)( 41593 "Create new templates, or reset any customizations made to the templates supplied by your theme." 41594 ), 41595 backPath, 41596 content: window?.__experimentalTemplateActivate ? /* @__PURE__ */ (0, import_jsx_runtime275.jsx)(DataviewsTemplatesSidebarContent, {}) : /* @__PURE__ */ (0, import_jsx_runtime275.jsx)(DataviewsTemplatesSidebarContent2, {}) 41597 } 41598 ); 41599 } 41600 41601 // packages/edit-site/build-module/components/page-templates/index.js 41602 var import_i18n144 = __toESM(require_i18n()); 41603 var import_html_entities14 = __toESM(require_html_entities()); 41604 var import_element141 = __toESM(require_element()); 41605 var import_core_data54 = __toESM(require_core_data()); 41606 var import_router34 = __toESM(require_router()); 41607 var import_editor34 = __toESM(require_editor()); 41608 var import_url21 = __toESM(require_url()); 41609 var import_data73 = __toESM(require_data()); 41610 var import_compose27 = __toESM(require_compose()); 41611 var import_components162 = __toESM(require_components()); 41612 var import_notices8 = __toESM(require_notices()); 41613 41614 // packages/edit-site/build-module/components/add-new-template/index.js 41615 var import_components160 = __toESM(require_components()); 41616 var import_html_entities12 = __toESM(require_html_entities()); 41617 var import_element139 = __toESM(require_element()); 41618 var import_data71 = __toESM(require_data()); 41619 var import_core_data52 = __toESM(require_core_data()); 41620 var import_compose26 = __toESM(require_compose()); 41621 var import_i18n142 = __toESM(require_i18n()); 41622 var import_notices7 = __toESM(require_notices()); 41623 var import_router33 = __toESM(require_router()); 41624 var import_dom13 = __toESM(require_dom()); 41625 41626 // packages/edit-site/build-module/components/add-new-template/add-custom-template-modal-content.js 41627 var import_element137 = __toESM(require_element()); 41628 var import_i18n140 = __toESM(require_i18n()); 41629 var import_components158 = __toESM(require_components()); 41630 var import_core_data51 = __toESM(require_core_data()); 41631 var import_html_entities11 = __toESM(require_html_entities()); 41632 var import_compose25 = __toESM(require_compose()); 41633 var import_dom12 = __toESM(require_dom()); 41634 var import_url20 = __toESM(require_url()); 41635 41636 // packages/edit-site/build-module/components/add-new-template/utils.js 41637 var import_data70 = __toESM(require_data()); 41638 var import_core_data50 = __toESM(require_core_data()); 41639 var import_html_entities10 = __toESM(require_html_entities()); 41640 var import_element136 = __toESM(require_element()); 41641 var import_i18n139 = __toESM(require_i18n()); 41642 var import_url19 = __toESM(require_url()); 41643 var EMPTY_OBJECT = {}; 41644 var getValueFromObjectPath2 = (object, path) => { 41645 let value = object; 41646 path.split(".").forEach((fieldName) => { 41647 value = value?.[fieldName]; 41648 }); 41649 return value; 41650 }; 41651 function prefixSlug(prefix2, slug) { 41652 return `$prefix2}-${(0, import_url19.safeDecodeURI)(slug)}`; 41653 } 41654 var mapToIHasNameAndId = (entities, path) => { 41655 return (entities || []).map((entity) => ({ 41656 ...entity, 41657 name: (0, import_html_entities10.decodeEntities)(getValueFromObjectPath2(entity, path)) 41658 })); 41659 }; 41660 var useExistingTemplates = () => { 41661 return (0, import_data70.useSelect)( 41662 (select3) => select3(import_core_data50.store).getEntityRecords( 41663 "postType", 41664 TEMPLATE_POST_TYPE, 41665 { 41666 per_page: -1 41667 } 41668 ), 41669 [] 41670 ); 41671 }; 41672 var useDefaultTemplateTypes = () => { 41673 return (0, import_data70.useSelect)( 41674 (select3) => select3(import_core_data50.store).getCurrentTheme()?.default_template_types || [], 41675 [] 41676 ); 41677 }; 41678 var usePublicPostTypes = () => { 41679 const postTypes = (0, import_data70.useSelect)( 41680 (select3) => select3(import_core_data50.store).getPostTypes({ per_page: -1 }), 41681 [] 41682 ); 41683 return (0, import_element136.useMemo)(() => { 41684 const excludedPostTypes = ["attachment"]; 41685 return postTypes?.filter( 41686 ({ viewable, slug }) => viewable && !excludedPostTypes.includes(slug) 41687 ).sort((a2, b2) => { 41688 if (a2.slug === "post" || b2.slug === "post") { 41689 return 0; 41690 } 41691 return a2.name.localeCompare(b2.name); 41692 }); 41693 }, [postTypes]); 41694 }; 41695 var usePublicTaxonomies = () => { 41696 const taxonomies = (0, import_data70.useSelect)( 41697 (select3) => select3(import_core_data50.store).getTaxonomies({ per_page: -1 }), 41698 [] 41699 ); 41700 return (0, import_element136.useMemo)(() => { 41701 return taxonomies?.filter( 41702 ({ visibility }) => visibility?.publicly_queryable 41703 ); 41704 }, [taxonomies]); 41705 }; 41706 function usePostTypeArchiveMenuItems() { 41707 const publicPostTypes = usePublicPostTypes(); 41708 const postTypesWithArchives = (0, import_element136.useMemo)( 41709 () => publicPostTypes?.filter((postType2) => postType2.has_archive), 41710 [publicPostTypes] 41711 ); 41712 const existingTemplates = useExistingTemplates(); 41713 const postTypeLabels = (0, import_element136.useMemo)( 41714 () => publicPostTypes?.reduce((accumulator, { labels }) => { 41715 const singularName = labels.singular_name.toLowerCase(); 41716 accumulator[singularName] = (accumulator[singularName] || 0) + 1; 41717 return accumulator; 41718 }, {}), 41719 [publicPostTypes] 41720 ); 41721 const needsUniqueIdentifier = (0, import_element136.useCallback)( 41722 ({ labels, slug }) => { 41723 const singularName = labels.singular_name.toLowerCase(); 41724 return postTypeLabels[singularName] > 1 && singularName !== slug; 41725 }, 41726 [postTypeLabels] 41727 ); 41728 return (0, import_element136.useMemo)( 41729 () => postTypesWithArchives?.filter( 41730 (postType2) => !(existingTemplates || []).some( 41731 (existingTemplate) => existingTemplate.slug === "archive-" + postType2.slug 41732 ) 41733 ).map((postType2) => { 41734 let title; 41735 if (needsUniqueIdentifier(postType2)) { 41736 title = (0, import_i18n139.sprintf)( 41737 // translators: %1s: Name of the post type e.g: "Post"; %2s: Slug of the post type e.g: "book". 41738 (0, import_i18n139.__)("Archive: %1$s (%2$s)"), 41739 postType2.labels.singular_name, 41740 postType2.slug 41741 ); 41742 } else { 41743 title = (0, import_i18n139.sprintf)( 41744 // translators: %s: Name of the post type e.g: "Post". 41745 (0, import_i18n139.__)("Archive: %s"), 41746 postType2.labels.singular_name 41747 ); 41748 } 41749 return { 41750 slug: "archive-" + postType2.slug, 41751 description: (0, import_i18n139.sprintf)( 41752 // translators: %s: Name of the post type e.g: "Post". 41753 (0, import_i18n139.__)( 41754 "Displays an archive with the latest posts of type: %s." 41755 ), 41756 postType2.labels.singular_name 41757 ), 41758 title, 41759 // `icon` is the `menu_icon` property of a post type. We 41760 // only handle `dashicons` for now, even if the `menu_icon` 41761 // also supports urls and svg as values. 41762 icon: typeof postType2.icon === "string" && postType2.icon.startsWith("dashicons-") ? postType2.icon.slice(10) : archive_default, 41763 templatePrefix: "archive" 41764 }; 41765 }) || [], 41766 [postTypesWithArchives, existingTemplates, needsUniqueIdentifier] 41767 ); 41768 } 41769 var usePostTypeMenuItems = (onClickMenuItem) => { 41770 const publicPostTypes = usePublicPostTypes(); 41771 const defaultTemplateTypes = useDefaultTemplateTypes(); 41772 const templateLabels = (0, import_element136.useMemo)( 41773 () => publicPostTypes?.reduce((accumulator, { labels }) => { 41774 const templateName = (labels.template_name || labels.singular_name).toLowerCase(); 41775 accumulator[templateName] = (accumulator[templateName] || 0) + 1; 41776 return accumulator; 41777 }, {}), 41778 [publicPostTypes] 41779 ); 41780 const needsUniqueIdentifier = (0, import_element136.useCallback)( 41781 ({ labels, slug }) => { 41782 const templateName = (labels.template_name || labels.singular_name).toLowerCase(); 41783 return templateLabels[templateName] > 1 && templateName !== slug; 41784 }, 41785 [templateLabels] 41786 ); 41787 const templatePrefixes = (0, import_element136.useMemo)( 41788 () => publicPostTypes?.reduce((accumulator, { slug }) => { 41789 let suffix = slug; 41790 if (slug !== "page") { 41791 suffix = `single-$suffix}`; 41792 } 41793 accumulator[slug] = suffix; 41794 return accumulator; 41795 }, {}), 41796 [publicPostTypes] 41797 ); 41798 const postTypesInfo = useEntitiesInfo("postType", templatePrefixes); 41799 const menuItems = (publicPostTypes || []).reduce( 41800 (accumulator, postType2) => { 41801 const { slug, labels, icon } = postType2; 41802 const generalTemplateSlug = templatePrefixes[slug]; 41803 const defaultTemplateType = defaultTemplateTypes?.find( 41804 ({ slug: _slug }) => _slug === generalTemplateSlug 41805 ); 41806 const _needsUniqueIdentifier = needsUniqueIdentifier(postType2); 41807 let menuItemTitle = labels.template_name || (0, import_i18n139.sprintf)( 41808 // translators: %s: Name of the post type e.g: "Post". 41809 (0, import_i18n139.__)("Single item: %s"), 41810 labels.singular_name 41811 ); 41812 if (_needsUniqueIdentifier) { 41813 menuItemTitle = labels.template_name ? (0, import_i18n139.sprintf)( 41814 // translators: 1: Name of the template e.g: "Single Item: Post". 2: Slug of the post type e.g: "book". 41815 (0, import_i18n139._x)("%1$s (%2$s)", "post type menu label"), 41816 labels.template_name, 41817 slug 41818 ) : (0, import_i18n139.sprintf)( 41819 // translators: 1: Name of the post type e.g: "Post". 2: Slug of the post type e.g: "book". 41820 (0, import_i18n139._x)( 41821 "Single item: %1$s (%2$s)", 41822 "post type menu label" 41823 ), 41824 labels.singular_name, 41825 slug 41826 ); 41827 } 41828 const menuItem = defaultTemplateType ? { 41829 ...defaultTemplateType, 41830 templatePrefix: templatePrefixes[slug] 41831 } : { 41832 slug: generalTemplateSlug, 41833 title: menuItemTitle, 41834 description: (0, import_i18n139.sprintf)( 41835 // translators: %s: Name of the post type e.g: "Post". 41836 (0, import_i18n139.__)("Displays a single item: %s."), 41837 labels.singular_name 41838 ), 41839 // `icon` is the `menu_icon` property of a post type. We 41840 // only handle `dashicons` for now, even if the `menu_icon` 41841 // also supports urls and svg as values. 41842 icon: typeof icon === "string" && icon.startsWith("dashicons-") ? icon.slice(10) : post_default, 41843 templatePrefix: templatePrefixes[slug] 41844 }; 41845 const hasEntities = postTypesInfo?.[slug]?.hasEntities; 41846 if (hasEntities) { 41847 menuItem.onClick = (template) => { 41848 onClickMenuItem({ 41849 type: "postType", 41850 slug, 41851 config: { 41852 recordNamePath: "title.rendered", 41853 queryArgs: ({ search }) => { 41854 return { 41855 _fields: "id,title,slug,link", 41856 orderBy: search ? "relevance" : "modified", 41857 exclude: postTypesInfo[slug].existingEntitiesIds 41858 }; 41859 }, 41860 getSpecificTemplate: (suggestion) => { 41861 const templateSlug = prefixSlug( 41862 templatePrefixes[slug], 41863 suggestion.slug 41864 ); 41865 return { 41866 title: templateSlug, 41867 slug: templateSlug, 41868 templatePrefix: templatePrefixes[slug] 41869 }; 41870 } 41871 }, 41872 labels, 41873 template 41874 }); 41875 }; 41876 } 41877 if (hasEntities) { 41878 accumulator.push(menuItem); 41879 } 41880 return accumulator; 41881 }, 41882 [] 41883 ); 41884 const postTypesMenuItems = (0, import_element136.useMemo)( 41885 () => menuItems.reduce( 41886 (accumulator, postType2) => { 41887 const { slug } = postType2; 41888 let key = "postTypesMenuItems"; 41889 if (slug === "page") { 41890 key = "defaultPostTypesMenuItems"; 41891 } 41892 accumulator[key].push(postType2); 41893 return accumulator; 41894 }, 41895 { defaultPostTypesMenuItems: [], postTypesMenuItems: [] } 41896 ), 41897 [menuItems] 41898 ); 41899 return postTypesMenuItems; 41900 }; 41901 var useTaxonomiesMenuItems = (onClickMenuItem) => { 41902 const publicTaxonomies = usePublicTaxonomies(); 41903 const existingTemplates = useExistingTemplates(); 41904 const defaultTemplateTypes = useDefaultTemplateTypes(); 41905 const templatePrefixes = (0, import_element136.useMemo)( 41906 () => publicTaxonomies?.reduce((accumulator, { slug }) => { 41907 let suffix = slug; 41908 if (!["category", "post_tag"].includes(slug)) { 41909 suffix = `taxonomy-$suffix}`; 41910 } 41911 if (slug === "post_tag") { 41912 suffix = `tag`; 41913 } 41914 accumulator[slug] = suffix; 41915 return accumulator; 41916 }, {}), 41917 [publicTaxonomies] 41918 ); 41919 const taxonomyLabels = publicTaxonomies?.reduce( 41920 (accumulator, { labels }) => { 41921 const templateName = (labels.template_name || labels.singular_name).toLowerCase(); 41922 accumulator[templateName] = (accumulator[templateName] || 0) + 1; 41923 return accumulator; 41924 }, 41925 {} 41926 ); 41927 const needsUniqueIdentifier = (labels, slug) => { 41928 if (["category", "post_tag"].includes(slug)) { 41929 return false; 41930 } 41931 const templateName = (labels.template_name || labels.singular_name).toLowerCase(); 41932 return taxonomyLabels[templateName] > 1 && templateName !== slug; 41933 }; 41934 const taxonomiesInfo = useEntitiesInfo("taxonomy", templatePrefixes); 41935 const existingTemplateSlugs = (existingTemplates || []).map( 41936 ({ slug }) => slug 41937 ); 41938 const menuItems = (publicTaxonomies || []).reduce( 41939 (accumulator, taxonomy) => { 41940 const { slug, labels } = taxonomy; 41941 const generalTemplateSlug = templatePrefixes[slug]; 41942 const defaultTemplateType = defaultTemplateTypes?.find( 41943 ({ slug: _slug }) => _slug === generalTemplateSlug 41944 ); 41945 const hasGeneralTemplate = existingTemplateSlugs?.includes(generalTemplateSlug); 41946 const _needsUniqueIdentifier = needsUniqueIdentifier( 41947 labels, 41948 slug 41949 ); 41950 let menuItemTitle = labels.template_name || labels.singular_name; 41951 if (_needsUniqueIdentifier) { 41952 menuItemTitle = labels.template_name ? (0, import_i18n139.sprintf)( 41953 // translators: 1: Name of the template e.g: "Products by Category". 2: Slug of the taxonomy e.g: "product_cat". 41954 (0, import_i18n139._x)("%1$s (%2$s)", "taxonomy template menu label"), 41955 labels.template_name, 41956 slug 41957 ) : (0, import_i18n139.sprintf)( 41958 // translators: 1: Name of the taxonomy e.g: "Category". 2: Slug of the taxonomy e.g: "product_cat". 41959 (0, import_i18n139._x)("%1$s (%2$s)", "taxonomy menu label"), 41960 labels.singular_name, 41961 slug 41962 ); 41963 } 41964 const menuItem = defaultTemplateType ? { 41965 ...defaultTemplateType, 41966 templatePrefix: templatePrefixes[slug] 41967 } : { 41968 slug: generalTemplateSlug, 41969 title: menuItemTitle, 41970 description: (0, import_i18n139.sprintf)( 41971 // translators: %s: Name of the taxonomy e.g: "Product Categories". 41972 (0, import_i18n139.__)("Displays taxonomy: %s."), 41973 labels.singular_name 41974 ), 41975 icon: block_meta_default, 41976 templatePrefix: templatePrefixes[slug] 41977 }; 41978 const hasEntities = taxonomiesInfo?.[slug]?.hasEntities; 41979 if (hasEntities) { 41980 menuItem.onClick = (template) => { 41981 onClickMenuItem({ 41982 type: "taxonomy", 41983 slug, 41984 config: { 41985 queryArgs: ({ search }) => { 41986 return { 41987 _fields: "id,name,slug,link", 41988 orderBy: search ? "name" : "count", 41989 exclude: taxonomiesInfo[slug].existingEntitiesIds 41990 }; 41991 }, 41992 getSpecificTemplate: (suggestion) => { 41993 const templateSlug = prefixSlug( 41994 templatePrefixes[slug], 41995 suggestion.slug 41996 ); 41997 return { 41998 title: templateSlug, 41999 slug: templateSlug, 42000 templatePrefix: templatePrefixes[slug] 42001 }; 42002 } 42003 }, 42004 labels, 42005 hasGeneralTemplate, 42006 template 42007 }); 42008 }; 42009 } 42010 if (!hasGeneralTemplate || hasEntities) { 42011 accumulator.push(menuItem); 42012 } 42013 return accumulator; 42014 }, 42015 [] 42016 ); 42017 const taxonomiesMenuItems = (0, import_element136.useMemo)( 42018 () => menuItems.reduce( 42019 (accumulator, taxonomy) => { 42020 const { slug } = taxonomy; 42021 let key = "taxonomiesMenuItems"; 42022 if (["category", "tag"].includes(slug)) { 42023 key = "defaultTaxonomiesMenuItems"; 42024 } 42025 accumulator[key].push(taxonomy); 42026 return accumulator; 42027 }, 42028 { defaultTaxonomiesMenuItems: [], taxonomiesMenuItems: [] } 42029 ), 42030 [menuItems] 42031 ); 42032 return taxonomiesMenuItems; 42033 }; 42034 var USE_AUTHOR_MENU_ITEM_TEMPLATE_PREFIX = { user: "author" }; 42035 var USE_AUTHOR_MENU_ITEM_QUERY_PARAMETERS = { user: { who: "authors" } }; 42036 function useAuthorMenuItem(onClickMenuItem) { 42037 const existingTemplates = useExistingTemplates(); 42038 const defaultTemplateTypes = useDefaultTemplateTypes(); 42039 const authorInfo = useEntitiesInfo( 42040 "root", 42041 USE_AUTHOR_MENU_ITEM_TEMPLATE_PREFIX, 42042 USE_AUTHOR_MENU_ITEM_QUERY_PARAMETERS 42043 ); 42044 let authorMenuItem = defaultTemplateTypes?.find( 42045 ({ slug }) => slug === "author" 42046 ); 42047 if (!authorMenuItem) { 42048 authorMenuItem = { 42049 description: (0, import_i18n139.__)( 42050 "Displays latest posts written by a single author." 42051 ), 42052 slug: "author", 42053 title: "Author" 42054 }; 42055 } 42056 const hasGeneralTemplate = !!existingTemplates?.find( 42057 ({ slug }) => slug === "author" 42058 ); 42059 if (authorInfo.user?.hasEntities) { 42060 authorMenuItem = { ...authorMenuItem, templatePrefix: "author" }; 42061 authorMenuItem.onClick = (template) => { 42062 onClickMenuItem({ 42063 type: "root", 42064 slug: "user", 42065 config: { 42066 queryArgs: ({ search }) => { 42067 return { 42068 _fields: "id,name,slug,link", 42069 orderBy: search ? "name" : "registered_date", 42070 exclude: authorInfo.user.existingEntitiesIds, 42071 who: "authors" 42072 }; 42073 }, 42074 getSpecificTemplate: (suggestion) => { 42075 const templateSlug = prefixSlug( 42076 "author", 42077 suggestion.slug 42078 ); 42079 return { 42080 title: (0, import_i18n139.sprintf)( 42081 // translators: %s: Name of the author e.g: "Admin". 42082 (0, import_i18n139.__)("Author: %s"), 42083 suggestion.name 42084 ), 42085 slug: templateSlug, 42086 templatePrefix: "author" 42087 }; 42088 } 42089 }, 42090 labels: { 42091 singular_name: (0, import_i18n139.__)("Author"), 42092 search_items: (0, import_i18n139.__)("Search Authors"), 42093 not_found: (0, import_i18n139.__)("No authors found."), 42094 all_items: (0, import_i18n139.__)("All Authors") 42095 }, 42096 hasGeneralTemplate, 42097 template 42098 }); 42099 }; 42100 } 42101 if (!hasGeneralTemplate || authorInfo.user?.hasEntities) { 42102 return authorMenuItem; 42103 } 42104 } 42105 var useEntitiesInfo = (entityName, templatePrefixes, additionalQueryParameters = EMPTY_OBJECT) => { 42106 const entitiesHasRecords = (0, import_data70.useSelect)( 42107 (select3) => { 42108 return Object.keys(templatePrefixes || {}).reduce( 42109 (accumulator, slug) => { 42110 accumulator[slug] = !!select3( 42111 import_core_data50.store 42112 ).getEntityRecords(entityName, slug, { 42113 per_page: 1, 42114 _fields: "id", 42115 context: "view", 42116 ...additionalQueryParameters[slug] 42117 })?.length; 42118 return accumulator; 42119 }, 42120 {} 42121 ); 42122 }, 42123 [templatePrefixes, entityName, additionalQueryParameters] 42124 ); 42125 const entitiesInfo = (0, import_element136.useMemo)(() => { 42126 return Object.keys(templatePrefixes || {}).reduce( 42127 (accumulator, slug) => { 42128 accumulator[slug] = { 42129 hasEntities: entitiesHasRecords[slug] 42130 }; 42131 return accumulator; 42132 }, 42133 {} 42134 ); 42135 }, [templatePrefixes, entitiesHasRecords]); 42136 return entitiesInfo; 42137 }; 42138 42139 // packages/edit-site/build-module/components/add-new-template/add-custom-template-modal-content.js 42140 var import_jsx_runtime276 = __toESM(require_jsx_runtime()); 42141 var EMPTY_ARRAY13 = []; 42142 function SuggestionListItem({ 42143 suggestion, 42144 search, 42145 onSelect, 42146 entityForSuggestions 42147 }) { 42148 const baseCssClass = "edit-site-custom-template-modal__suggestions_list__list-item"; 42149 return /* @__PURE__ */ (0, import_jsx_runtime276.jsxs)( 42150 import_components158.Composite.Item, 42151 { 42152 render: /* @__PURE__ */ (0, import_jsx_runtime276.jsx)( 42153 import_components158.Button, 42154 { 42155 __next40pxDefaultSize: true, 42156 role: "option", 42157 className: baseCssClass, 42158 onClick: () => onSelect( 42159 entityForSuggestions.config.getSpecificTemplate( 42160 suggestion 42161 ) 42162 ) 42163 } 42164 ), 42165 children: [ 42166 /* @__PURE__ */ (0, import_jsx_runtime276.jsx)( 42167 import_components158.__experimentalText, 42168 { 42169 size: "body", 42170 lineHeight: 1.53846153846, 42171 weight: 500, 42172 className: `$baseCssClass}__title`, 42173 children: /* @__PURE__ */ (0, import_jsx_runtime276.jsx)( 42174 import_components158.TextHighlight, 42175 { 42176 text: (0, import_html_entities11.decodeEntities)(suggestion.name), 42177 highlight: search 42178 } 42179 ) 42180 } 42181 ), 42182 suggestion.link && /* @__PURE__ */ (0, import_jsx_runtime276.jsx)( 42183 import_components158.__experimentalText, 42184 { 42185 size: "body", 42186 lineHeight: 1.53846153846, 42187 className: `$baseCssClass}__info`, 42188 children: (0, import_url20.safeDecodeURI)(suggestion.link) 42189 } 42190 ) 42191 ] 42192 } 42193 ); 42194 } 42195 function useSearchSuggestions(entityForSuggestions, search) { 42196 const { config: config2 } = entityForSuggestions; 42197 const query = (0, import_element137.useMemo)( 42198 () => ({ 42199 order: "asc", 42200 context: "view", 42201 search, 42202 per_page: search ? 20 : 10, 42203 ...config2.queryArgs(search) 42204 }), 42205 [search, config2] 42206 ); 42207 const { records: searchResults, hasResolved: searchHasResolved } = (0, import_core_data51.useEntityRecords)( 42208 entityForSuggestions.type, 42209 entityForSuggestions.slug, 42210 query 42211 ); 42212 const [suggestions, setSuggestions] = (0, import_element137.useState)(EMPTY_ARRAY13); 42213 (0, import_element137.useEffect)(() => { 42214 if (!searchHasResolved) { 42215 return; 42216 } 42217 let newSuggestions = EMPTY_ARRAY13; 42218 if (searchResults?.length) { 42219 newSuggestions = searchResults; 42220 if (config2.recordNamePath) { 42221 newSuggestions = mapToIHasNameAndId( 42222 newSuggestions, 42223 config2.recordNamePath 42224 ); 42225 } 42226 } 42227 setSuggestions(newSuggestions); 42228 }, [searchResults, searchHasResolved]); 42229 return suggestions; 42230 } 42231 function SuggestionList({ entityForSuggestions, onSelect }) { 42232 const [search, setSearch, debouncedSearch] = (0, import_compose25.useDebouncedInput)(); 42233 const suggestions = useSearchSuggestions( 42234 entityForSuggestions, 42235 debouncedSearch 42236 ); 42237 const { labels } = entityForSuggestions; 42238 const [showSearchControl, setShowSearchControl] = (0, import_element137.useState)(false); 42239 if (!showSearchControl && suggestions?.length > 9) { 42240 setShowSearchControl(true); 42241 } 42242 return /* @__PURE__ */ (0, import_jsx_runtime276.jsxs)(import_jsx_runtime276.Fragment, { children: [ 42243 showSearchControl && /* @__PURE__ */ (0, import_jsx_runtime276.jsx)( 42244 import_components158.SearchControl, 42245 { 42246 onChange: setSearch, 42247 value: search, 42248 label: labels.search_items, 42249 placeholder: labels.search_items 42250 } 42251 ), 42252 !!suggestions?.length && /* @__PURE__ */ (0, import_jsx_runtime276.jsx)( 42253 import_components158.Composite, 42254 { 42255 orientation: "vertical", 42256 role: "listbox", 42257 className: "edit-site-custom-template-modal__suggestions_list", 42258 "aria-label": (0, import_i18n140.__)("Suggestions list"), 42259 children: suggestions.map((suggestion) => /* @__PURE__ */ (0, import_jsx_runtime276.jsx)( 42260 SuggestionListItem, 42261 { 42262 suggestion, 42263 search: debouncedSearch, 42264 onSelect, 42265 entityForSuggestions 42266 }, 42267 suggestion.slug 42268 )) 42269 } 42270 ), 42271 debouncedSearch && !suggestions?.length && /* @__PURE__ */ (0, import_jsx_runtime276.jsx)( 42272 import_components158.__experimentalText, 42273 { 42274 as: "p", 42275 className: "edit-site-custom-template-modal__no-results", 42276 children: labels.not_found 42277 } 42278 ) 42279 ] }); 42280 } 42281 function AddCustomTemplateModalContent({ 42282 onSelect, 42283 entityForSuggestions, 42284 onBack, 42285 containerRef 42286 }) { 42287 const [showSearchEntities, setShowSearchEntities] = (0, import_element137.useState)(); 42288 (0, import_element137.useEffect)(() => { 42289 if (containerRef.current) { 42290 const [firstFocusable] = import_dom12.focus.focusable.find( 42291 containerRef.current 42292 ); 42293 firstFocusable?.focus(); 42294 } 42295 }, [showSearchEntities]); 42296 return /* @__PURE__ */ (0, import_jsx_runtime276.jsxs)( 42297 import_components158.__experimentalVStack, 42298 { 42299 spacing: 4, 42300 className: "edit-site-custom-template-modal__contents-wrapper", 42301 alignment: "left", 42302 children: [ 42303 !showSearchEntities && /* @__PURE__ */ (0, import_jsx_runtime276.jsxs)(import_jsx_runtime276.Fragment, { children: [ 42304 /* @__PURE__ */ (0, import_jsx_runtime276.jsx)(import_components158.__experimentalText, { as: "p", children: (0, import_i18n140.__)( 42305 "Select whether to create a single template for all items or a specific one." 42306 ) }), 42307 /* @__PURE__ */ (0, import_jsx_runtime276.jsxs)( 42308 import_components158.Flex, 42309 { 42310 className: "edit-site-custom-template-modal__contents", 42311 gap: "4", 42312 align: "initial", 42313 children: [ 42314 /* @__PURE__ */ (0, import_jsx_runtime276.jsxs)( 42315 import_components158.FlexItem, 42316 { 42317 isBlock: true, 42318 as: import_components158.Button, 42319 onClick: () => { 42320 const { 42321 slug, 42322 title, 42323 description, 42324 templatePrefix 42325 } = entityForSuggestions.template; 42326 onSelect({ 42327 slug, 42328 title, 42329 description, 42330 templatePrefix 42331 }); 42332 }, 42333 children: [ 42334 /* @__PURE__ */ (0, import_jsx_runtime276.jsx)( 42335 import_components158.__experimentalText, 42336 { 42337 as: "span", 42338 weight: 500, 42339 lineHeight: 1.53846153846, 42340 children: entityForSuggestions.labels.all_items 42341 } 42342 ), 42343 /* @__PURE__ */ (0, import_jsx_runtime276.jsx)( 42344 import_components158.__experimentalText, 42345 { 42346 as: "span", 42347 lineHeight: 1.53846153846, 42348 // translators: The user is given the choice to set up a template for all items of a post type or taxonomy, or just a specific one. 42349 children: (0, import_i18n140.__)("For all items") 42350 } 42351 ) 42352 ] 42353 } 42354 ), 42355 /* @__PURE__ */ (0, import_jsx_runtime276.jsxs)( 42356 import_components158.FlexItem, 42357 { 42358 isBlock: true, 42359 as: import_components158.Button, 42360 onClick: () => { 42361 setShowSearchEntities(true); 42362 }, 42363 children: [ 42364 /* @__PURE__ */ (0, import_jsx_runtime276.jsx)( 42365 import_components158.__experimentalText, 42366 { 42367 as: "span", 42368 weight: 500, 42369 lineHeight: 1.53846153846, 42370 children: entityForSuggestions.labels.singular_name 42371 } 42372 ), 42373 /* @__PURE__ */ (0, import_jsx_runtime276.jsx)( 42374 import_components158.__experimentalText, 42375 { 42376 as: "span", 42377 lineHeight: 1.53846153846, 42378 // translators: The user is given the choice to set up a template for all items of a post type or taxonomy, or just a specific one. 42379 children: (0, import_i18n140.__)("For a specific item") 42380 } 42381 ) 42382 ] 42383 } 42384 ) 42385 ] 42386 } 42387 ), 42388 /* @__PURE__ */ (0, import_jsx_runtime276.jsx)(import_components158.Flex, { justify: "right", children: /* @__PURE__ */ (0, import_jsx_runtime276.jsx)( 42389 import_components158.Button, 42390 { 42391 __next40pxDefaultSize: true, 42392 variant: "tertiary", 42393 onClick: onBack, 42394 children: (0, import_i18n140.__)("Back") 42395 } 42396 ) }) 42397 ] }), 42398 showSearchEntities && /* @__PURE__ */ (0, import_jsx_runtime276.jsxs)(import_jsx_runtime276.Fragment, { children: [ 42399 /* @__PURE__ */ (0, import_jsx_runtime276.jsx)(import_components158.__experimentalText, { as: "p", children: (0, import_i18n140.__)( 42400 "This template will be used only for the specific item chosen." 42401 ) }), 42402 /* @__PURE__ */ (0, import_jsx_runtime276.jsx)( 42403 SuggestionList, 42404 { 42405 entityForSuggestions, 42406 onSelect 42407 } 42408 ), 42409 /* @__PURE__ */ (0, import_jsx_runtime276.jsx)(import_components158.Flex, { justify: "right", children: /* @__PURE__ */ (0, import_jsx_runtime276.jsx)( 42410 import_components158.Button, 42411 { 42412 __next40pxDefaultSize: true, 42413 variant: "tertiary", 42414 onClick: () => { 42415 if (entityForSuggestions.hasGeneralTemplate) { 42416 onBack(); 42417 } else { 42418 setShowSearchEntities(false); 42419 } 42420 }, 42421 children: (0, import_i18n140.__)("Back") 42422 } 42423 ) }) 42424 ] }) 42425 ] 42426 } 42427 ); 42428 } 42429 var add_custom_template_modal_content_default = AddCustomTemplateModalContent; 42430 42431 // node_modules/tslib/tslib.es6.mjs 42432 var __assign = function() { 42433 __assign = Object.assign || function __assign2(t3) { 42434 for (var s2, i2 = 1, n2 = arguments.length; i2 < n2; i2++) { 42435 s2 = arguments[i2]; 42436 for (var p3 in s2) if (Object.prototype.hasOwnProperty.call(s2, p3)) t3[p3] = s2[p3]; 42437 } 42438 return t3; 42439 }; 42440 return __assign.apply(this, arguments); 42441 }; 42442 42443 // node_modules/lower-case/dist.es2015/index.js 42444 function lowerCase(str) { 42445 return str.toLowerCase(); 42446 } 42447 42448 // node_modules/no-case/dist.es2015/index.js 42449 var DEFAULT_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g]; 42450 var DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi; 42451 function noCase(input, options) { 42452 if (options === void 0) { 42453 options = {}; 42454 } 42455 var _a = options.splitRegexp, splitRegexp = _a === void 0 ? DEFAULT_SPLIT_REGEXP : _a, _b = options.stripRegexp, stripRegexp = _b === void 0 ? DEFAULT_STRIP_REGEXP : _b, _c = options.transform, transform = _c === void 0 ? lowerCase : _c, _d = options.delimiter, delimiter = _d === void 0 ? " " : _d; 42456 var result = replace(replace(input, splitRegexp, "$1\0$2"), stripRegexp, "\0"); 42457 var start2 = 0; 42458 var end = result.length; 42459 while (result.charAt(start2) === "\0") 42460 start2++; 42461 while (result.charAt(end - 1) === "\0") 42462 end--; 42463 return result.slice(start2, end).split("\0").map(transform).join(delimiter); 42464 } 42465 function replace(input, re, value) { 42466 if (re instanceof RegExp) 42467 return input.replace(re, value); 42468 return re.reduce(function(input2, re2) { 42469 return input2.replace(re2, value); 42470 }, input); 42471 } 42472 42473 // node_modules/dot-case/dist.es2015/index.js 42474 function dotCase(input, options) { 42475 if (options === void 0) { 42476 options = {}; 42477 } 42478 return noCase(input, __assign({ delimiter: "." }, options)); 42479 } 42480 42481 // node_modules/param-case/dist.es2015/index.js 42482 function paramCase(input, options) { 42483 if (options === void 0) { 42484 options = {}; 42485 } 42486 return dotCase(input, __assign({ delimiter: "-" }, options)); 42487 } 42488 42489 // packages/edit-site/build-module/components/add-new-template/add-custom-generic-template-modal-content.js 42490 var import_element138 = __toESM(require_element()); 42491 var import_i18n141 = __toESM(require_i18n()); 42492 var import_components159 = __toESM(require_components()); 42493 var import_jsx_runtime277 = __toESM(require_jsx_runtime()); 42494 function AddCustomGenericTemplateModalContent({ createTemplate, onBack }) { 42495 const [title, setTitle] = (0, import_element138.useState)(""); 42496 const defaultTitle = (0, import_i18n141.__)("Custom Template"); 42497 const [isBusy, setIsBusy] = (0, import_element138.useState)(false); 42498 const inputRef = (0, import_element138.useRef)(); 42499 (0, import_element138.useEffect)(() => { 42500 if (inputRef.current) { 42501 inputRef.current.focus(); 42502 } 42503 }, []); 42504 async function onCreateTemplate(event) { 42505 event.preventDefault(); 42506 if (isBusy) { 42507 return; 42508 } 42509 setIsBusy(true); 42510 try { 42511 await createTemplate( 42512 { 42513 slug: paramCase(title || defaultTitle) || "wp-custom-template", 42514 title: title || defaultTitle 42515 }, 42516 false 42517 ); 42518 } finally { 42519 setIsBusy(false); 42520 } 42521 } 42522 return /* @__PURE__ */ (0, import_jsx_runtime277.jsx)("form", { onSubmit: onCreateTemplate, children: /* @__PURE__ */ (0, import_jsx_runtime277.jsxs)(import_components159.__experimentalVStack, { spacing: 6, children: [ 42523 /* @__PURE__ */ (0, import_jsx_runtime277.jsx)( 42524 import_components159.TextControl, 42525 { 42526 __next40pxDefaultSize: true, 42527 label: (0, import_i18n141.__)("Name"), 42528 value: title, 42529 onChange: setTitle, 42530 placeholder: defaultTitle, 42531 disabled: isBusy, 42532 ref: inputRef, 42533 help: (0, import_i18n141.__)( 42534 // eslint-disable-next-line no-restricted-syntax -- 'sidebar' is a common web design term for layouts 42535 'Describe the template, e.g. "Post with sidebar". A custom template can be manually applied to any post or page.' 42536 ) 42537 } 42538 ), 42539 /* @__PURE__ */ (0, import_jsx_runtime277.jsxs)( 42540 import_components159.__experimentalHStack, 42541 { 42542 className: "edit-site-custom-generic-template__modal-actions", 42543 justify: "right", 42544 children: [ 42545 /* @__PURE__ */ (0, import_jsx_runtime277.jsx)( 42546 import_components159.Button, 42547 { 42548 __next40pxDefaultSize: true, 42549 variant: "tertiary", 42550 onClick: onBack, 42551 children: (0, import_i18n141.__)("Back") 42552 } 42553 ), 42554 /* @__PURE__ */ (0, import_jsx_runtime277.jsx)( 42555 import_components159.Button, 42556 { 42557 __next40pxDefaultSize: true, 42558 variant: "primary", 42559 type: "submit", 42560 isBusy, 42561 "aria-disabled": isBusy, 42562 children: (0, import_i18n141.__)("Create") 42563 } 42564 ) 42565 ] 42566 } 42567 ) 42568 ] }) }); 42569 } 42570 var add_custom_generic_template_modal_content_default = AddCustomGenericTemplateModalContent; 42571 42572 // packages/edit-site/build-module/components/add-new-template/index.js 42573 var import_jsx_runtime278 = __toESM(require_jsx_runtime()); 42574 var { useHistory: useHistory21 } = unlock(import_router33.privateApis); 42575 var DEFAULT_TEMPLATE_SLUGS = [ 42576 "front-page", 42577 "home", 42578 "single", 42579 "page", 42580 "index", 42581 "archive", 42582 "author", 42583 "category", 42584 "date", 42585 "tag", 42586 "search", 42587 "404" 42588 ]; 42589 var TEMPLATE_ICONS = { 42590 "front-page": home_default, 42591 home: verse_default, 42592 single: pin_default, 42593 page: page_default2, 42594 archive: archive_default, 42595 search: search_default, 42596 404: not_found_default, 42597 index: list_default, 42598 category: category_default, 42599 author: comment_author_avatar_default, 42600 taxonomy: block_meta_default, 42601 date: calendar_default, 42602 tag: tag_default, 42603 attachment: media_default 42604 }; 42605 function TemplateListItem({ 42606 title, 42607 direction, 42608 className, 42609 description, 42610 icon, 42611 onClick, 42612 children 42613 }) { 42614 return /* @__PURE__ */ (0, import_jsx_runtime278.jsx)( 42615 import_components160.Button, 42616 { 42617 __next40pxDefaultSize: true, 42618 className, 42619 onClick, 42620 label: description, 42621 showTooltip: !!description, 42622 children: /* @__PURE__ */ (0, import_jsx_runtime278.jsxs)( 42623 import_components160.Flex, 42624 { 42625 as: "span", 42626 spacing: 2, 42627 align: "center", 42628 justify: "center", 42629 style: { width: "100%" }, 42630 direction, 42631 children: [ 42632 /* @__PURE__ */ (0, import_jsx_runtime278.jsx)("div", { className: "edit-site-add-new-template__template-icon", children: /* @__PURE__ */ (0, import_jsx_runtime278.jsx)(import_components160.Icon, { icon }) }), 42633 /* @__PURE__ */ (0, import_jsx_runtime278.jsxs)( 42634 import_components160.__experimentalVStack, 42635 { 42636 className: "edit-site-add-new-template__template-name", 42637 alignment: "center", 42638 spacing: 0, 42639 children: [ 42640 /* @__PURE__ */ (0, import_jsx_runtime278.jsx)( 42641 import_components160.__experimentalText, 42642 { 42643 align: "center", 42644 weight: 500, 42645 lineHeight: 1.53846153846, 42646 children: title 42647 } 42648 ), 42649 children 42650 ] 42651 } 42652 ) 42653 ] 42654 } 42655 ) 42656 } 42657 ); 42658 } 42659 var modalContentMap = { 42660 templatesList: 1, 42661 customTemplate: 2, 42662 customGenericTemplate: 3 42663 }; 42664 function NewTemplateModal({ onClose }) { 42665 const [modalContent, setModalContent] = (0, import_element139.useState)( 42666 modalContentMap.templatesList 42667 ); 42668 const [entityForSuggestions, setEntityForSuggestions] = (0, import_element139.useState)({}); 42669 const [isSubmitting, setIsSubmitting] = (0, import_element139.useState)(false); 42670 const missingTemplates = useMissingTemplates( 42671 setEntityForSuggestions, 42672 () => setModalContent(modalContentMap.customTemplate) 42673 ); 42674 const history = useHistory21(); 42675 const { saveEntityRecord } = (0, import_data71.useDispatch)(import_core_data52.store); 42676 const { createErrorNotice, createSuccessNotice } = (0, import_data71.useDispatch)(import_notices7.store); 42677 const containerRef = (0, import_element139.useRef)(null); 42678 const isMobile = (0, import_compose26.useViewportMatch)("medium", "<"); 42679 const homeUrl = (0, import_data71.useSelect)((select3) => { 42680 return select3(import_core_data52.store).getEntityRecord("root", "__unstableBase")?.home; 42681 }, []); 42682 const TEMPLATE_SHORT_DESCRIPTIONS = { 42683 "front-page": homeUrl, 42684 date: (0, import_i18n142.sprintf)( 42685 // translators: %s: The homepage url. 42686 (0, import_i18n142.__)("E.g. %s"), 42687 homeUrl + "/" + (/* @__PURE__ */ new Date()).getFullYear() 42688 ) 42689 }; 42690 (0, import_element139.useEffect)(() => { 42691 if (containerRef.current && modalContent === modalContentMap.templatesList) { 42692 const [firstFocusable] = import_dom13.focus.focusable.find( 42693 containerRef.current 42694 ); 42695 firstFocusable?.focus(); 42696 } 42697 }, [modalContent]); 42698 async function createTemplate(template, isWPSuggestion = true) { 42699 if (isSubmitting) { 42700 return; 42701 } 42702 setIsSubmitting(true); 42703 try { 42704 const { title, description, slug } = template; 42705 const newTemplate = await saveEntityRecord( 42706 "postType", 42707 TEMPLATE_POST_TYPE, 42708 { 42709 description, 42710 // Slugs need to be strings, so this is for template `404` 42711 slug: slug.toString(), 42712 status: "publish", 42713 title, 42714 // This adds a post meta field in template that is part of `is_custom` value calculation. 42715 meta: { 42716 is_wp_suggestion: isWPSuggestion 42717 } 42718 }, 42719 { throwOnError: true } 42720 ); 42721 history.navigate( 42722 `/$TEMPLATE_POST_TYPE}/$newTemplate.id}?canvas=edit` 42723 ); 42724 createSuccessNotice( 42725 (0, import_i18n142.sprintf)( 42726 // translators: %s: Title of the created post or template, e.g: "Hello world". 42727 (0, import_i18n142.__)('"%s" successfully created.'), 42728 (0, import_html_entities12.decodeEntities)(newTemplate.title?.rendered || title) || (0, import_i18n142.__)("(no title)") 42729 ), 42730 { 42731 type: "snackbar" 42732 } 42733 ); 42734 } catch (error) { 42735 const errorMessage = error.message && error.code !== "unknown_error" ? error.message : (0, import_i18n142.__)("An error occurred while creating the template."); 42736 createErrorNotice(errorMessage, { 42737 type: "snackbar" 42738 }); 42739 } finally { 42740 setIsSubmitting(false); 42741 } 42742 } 42743 const onModalClose = () => { 42744 onClose(); 42745 setModalContent(modalContentMap.templatesList); 42746 }; 42747 let modalTitle = (0, import_i18n142.__)("Add template"); 42748 if (modalContent === modalContentMap.customTemplate) { 42749 modalTitle = (0, import_i18n142.sprintf)( 42750 // translators: %s: Name of the post type e.g: "Post". 42751 (0, import_i18n142.__)("Add template: %s"), 42752 entityForSuggestions.labels.singular_name 42753 ); 42754 } else if (modalContent === modalContentMap.customGenericTemplate) { 42755 modalTitle = (0, import_i18n142.__)("Create custom template"); 42756 } 42757 return /* @__PURE__ */ (0, import_jsx_runtime278.jsxs)( 42758 import_components160.Modal, 42759 { 42760 title: modalTitle, 42761 className: clsx_default("edit-site-add-new-template__modal", { 42762 "edit-site-add-new-template__modal_template_list": modalContent === modalContentMap.templatesList, 42763 "edit-site-custom-template-modal": modalContent === modalContentMap.customTemplate 42764 }), 42765 onRequestClose: onModalClose, 42766 overlayClassName: modalContent === modalContentMap.customGenericTemplate ? "edit-site-custom-generic-template__modal" : void 0, 42767 ref: containerRef, 42768 children: [ 42769 modalContent === modalContentMap.templatesList && /* @__PURE__ */ (0, import_jsx_runtime278.jsxs)( 42770 import_components160.__experimentalGrid, 42771 { 42772 columns: isMobile ? 2 : 3, 42773 gap: 4, 42774 align: "flex-start", 42775 justify: "center", 42776 className: "edit-site-add-new-template__template-list__contents", 42777 children: [ 42778 /* @__PURE__ */ (0, import_jsx_runtime278.jsx)(import_components160.Flex, { className: "edit-site-add-new-template__template-list__prompt", children: (0, import_i18n142.__)( 42779 "Select what the new template should apply to:" 42780 ) }), 42781 missingTemplates.map((template) => { 42782 const { title, slug, onClick } = template; 42783 return /* @__PURE__ */ (0, import_jsx_runtime278.jsx)( 42784 TemplateListItem, 42785 { 42786 title, 42787 direction: "column", 42788 className: "edit-site-add-new-template__template-button", 42789 description: TEMPLATE_SHORT_DESCRIPTIONS[slug], 42790 icon: TEMPLATE_ICONS[slug] || layout_default, 42791 onClick: () => onClick ? onClick(template) : createTemplate(template) 42792 }, 42793 slug 42794 ); 42795 }), 42796 /* @__PURE__ */ (0, import_jsx_runtime278.jsx)( 42797 TemplateListItem, 42798 { 42799 title: (0, import_i18n142.__)("Custom template"), 42800 direction: "row", 42801 className: "edit-site-add-new-template__custom-template-button", 42802 icon: pencil_default, 42803 onClick: () => setModalContent( 42804 modalContentMap.customGenericTemplate 42805 ), 42806 children: /* @__PURE__ */ (0, import_jsx_runtime278.jsx)( 42807 import_components160.__experimentalText, 42808 { 42809 lineHeight: 1.53846153846, 42810 children: (0, import_i18n142.__)( 42811 "A custom template can be manually applied to any post or page." 42812 ) 42813 } 42814 ) 42815 } 42816 ) 42817 ] 42818 } 42819 ), 42820 modalContent === modalContentMap.customTemplate && /* @__PURE__ */ (0, import_jsx_runtime278.jsx)( 42821 add_custom_template_modal_content_default, 42822 { 42823 onSelect: createTemplate, 42824 entityForSuggestions, 42825 onBack: () => setModalContent(modalContentMap.templatesList), 42826 containerRef 42827 } 42828 ), 42829 modalContent === modalContentMap.customGenericTemplate && /* @__PURE__ */ (0, import_jsx_runtime278.jsx)( 42830 add_custom_generic_template_modal_content_default, 42831 { 42832 createTemplate, 42833 onBack: () => setModalContent(modalContentMap.templatesList) 42834 } 42835 ) 42836 ] 42837 } 42838 ); 42839 } 42840 function NewTemplate() { 42841 const [showModal, setShowModal] = (0, import_element139.useState)(false); 42842 const { postType: postType2 } = (0, import_data71.useSelect)((select3) => { 42843 const { getPostType: getPostType2 } = select3(import_core_data52.store); 42844 return { 42845 postType: getPostType2(TEMPLATE_POST_TYPE) 42846 }; 42847 }, []); 42848 if (!postType2) { 42849 return null; 42850 } 42851 return /* @__PURE__ */ (0, import_jsx_runtime278.jsxs)(import_jsx_runtime278.Fragment, { children: [ 42852 /* @__PURE__ */ (0, import_jsx_runtime278.jsx)( 42853 import_components160.Button, 42854 { 42855 variant: "primary", 42856 onClick: () => setShowModal(true), 42857 label: postType2.labels.add_new_item, 42858 __next40pxDefaultSize: true, 42859 children: postType2.labels.add_new_item 42860 } 42861 ), 42862 showModal && /* @__PURE__ */ (0, import_jsx_runtime278.jsx)(NewTemplateModal, { onClose: () => setShowModal(false) }) 42863 ] }); 42864 } 42865 function useMissingTemplates(setEntityForSuggestions, onClick) { 42866 const defaultTemplateTypes = useDefaultTemplateTypes(); 42867 const missingDefaultTemplates = (defaultTemplateTypes || []).filter( 42868 (template) => DEFAULT_TEMPLATE_SLUGS.includes(template.slug) 42869 ); 42870 const onClickMenuItem = (_entityForSuggestions) => { 42871 onClick?.(); 42872 setEntityForSuggestions(_entityForSuggestions); 42873 }; 42874 const enhancedMissingDefaultTemplateTypes = [...missingDefaultTemplates]; 42875 const { defaultTaxonomiesMenuItems, taxonomiesMenuItems } = useTaxonomiesMenuItems(onClickMenuItem); 42876 const { defaultPostTypesMenuItems, postTypesMenuItems } = usePostTypeMenuItems(onClickMenuItem); 42877 const authorMenuItem = useAuthorMenuItem(onClickMenuItem); 42878 [ 42879 ...defaultTaxonomiesMenuItems, 42880 ...defaultPostTypesMenuItems, 42881 authorMenuItem 42882 ].forEach((menuItem) => { 42883 if (!menuItem) { 42884 return; 42885 } 42886 const matchIndex = enhancedMissingDefaultTemplateTypes.findIndex( 42887 (template) => template.slug === menuItem.slug 42888 ); 42889 if (matchIndex > -1) { 42890 enhancedMissingDefaultTemplateTypes[matchIndex] = menuItem; 42891 } else { 42892 enhancedMissingDefaultTemplateTypes.push(menuItem); 42893 } 42894 }); 42895 enhancedMissingDefaultTemplateTypes?.sort((template1, template2) => { 42896 return DEFAULT_TEMPLATE_SLUGS.indexOf(template1.slug) - DEFAULT_TEMPLATE_SLUGS.indexOf(template2.slug); 42897 }); 42898 const missingTemplates = [ 42899 ...enhancedMissingDefaultTemplateTypes, 42900 ...usePostTypeArchiveMenuItems(), 42901 ...postTypesMenuItems, 42902 ...taxonomiesMenuItems 42903 ]; 42904 return missingTemplates; 42905 } 42906 var add_new_template_default = (0, import_element139.memo)(NewTemplate); 42907 42908 // packages/edit-site/build-module/components/page-templates/fields.js 42909 var import_components161 = __toESM(require_components()); 42910 var import_i18n143 = __toESM(require_i18n()); 42911 var import_element140 = __toESM(require_element()); 42912 var import_html_entities13 = __toESM(require_html_entities()); 42913 var import_blocks13 = __toESM(require_blocks()); 42914 var import_block_editor25 = __toESM(require_block_editor()); 42915 var import_editor33 = __toESM(require_editor()); 42916 var import_core_data53 = __toESM(require_core_data()); 42917 var import_data72 = __toESM(require_data()); 42918 var import_jsx_runtime279 = __toESM(require_jsx_runtime()); 42919 var { Badge: Badge3 } = unlock(import_components161.privateApis); 42920 var { useEntityRecordsWithPermissions } = unlock(import_core_data53.privateApis); 42921 var { useStyle: useStyle5 } = unlock(import_editor33.privateApis); 42922 function useAllDefaultTemplateTypes() { 42923 const defaultTemplateTypes = useDefaultTemplateTypes(); 42924 const { records: staticRecords } = useEntityRecordsWithPermissions( 42925 "root", 42926 "registeredTemplate" 42927 ); 42928 return [ 42929 ...defaultTemplateTypes, 42930 ...staticRecords?.filter((record) => !record.is_custom).map((record) => { 42931 return { 42932 slug: record.slug, 42933 title: record.title.rendered, 42934 description: record.description 42935 }; 42936 }) 42937 ]; 42938 } 42939 function PreviewField2({ item }) { 42940 const settings2 = usePatternSettings(); 42941 const backgroundColor = useStyle5("color.background") ?? "white"; 42942 const blocks = (0, import_element140.useMemo)(() => { 42943 return (0, import_blocks13.parse)(item.content.raw); 42944 }, [item.content.raw]); 42945 const isEmpty3 = !blocks?.length; 42946 return /* @__PURE__ */ (0, import_jsx_runtime279.jsx)(import_editor33.EditorProvider, { post: item, settings: settings2, children: /* @__PURE__ */ (0, import_jsx_runtime279.jsxs)( 42947 "div", 42948 { 42949 className: "page-templates-preview-field", 42950 style: { backgroundColor }, 42951 children: [ 42952 isEmpty3 && (0, import_i18n143.__)("Empty template"), 42953 !isEmpty3 && /* @__PURE__ */ (0, import_jsx_runtime279.jsx)(import_block_editor25.BlockPreview.Async, { children: /* @__PURE__ */ (0, import_jsx_runtime279.jsx)(import_block_editor25.BlockPreview, { blocks }) }) 42954 ] 42955 } 42956 ) }); 42957 } 42958 var previewField2 = { 42959 label: (0, import_i18n143.__)("Preview"), 42960 id: "preview", 42961 render: PreviewField2, 42962 enableSorting: false 42963 }; 42964 var descriptionField = { 42965 label: (0, import_i18n143.__)("Description"), 42966 id: "description", 42967 render: window?.__experimentalTemplateActivate ? function RenderDescription({ item }) { 42968 const defaultTemplateTypes = useAllDefaultTemplateTypes(); 42969 const defaultTemplateType = defaultTemplateTypes.find( 42970 (type) => type.slug === item.slug 42971 ); 42972 return item.description ? (0, import_html_entities13.decodeEntities)(item.description) : defaultTemplateType?.description; 42973 } : ({ item }) => { 42974 return item.description && (0, import_html_entities13.decodeEntities)(item.description); 42975 }, 42976 enableSorting: false, 42977 enableGlobalSearch: true 42978 }; 42979 function AuthorField2({ item }) { 42980 const [isImageLoaded, setIsImageLoaded] = (0, import_element140.useState)(false); 42981 const { text, icon, imageUrl } = useAddedBy(item.type, item.id); 42982 return /* @__PURE__ */ (0, import_jsx_runtime279.jsxs)(import_components161.__experimentalHStack, { alignment: "left", spacing: 0, children: [ 42983 imageUrl && /* @__PURE__ */ (0, import_jsx_runtime279.jsx)( 42984 "div", 42985 { 42986 className: clsx_default("page-templates-author-field__avatar", { 42987 "is-loaded": isImageLoaded 42988 }), 42989 children: /* @__PURE__ */ (0, import_jsx_runtime279.jsx)( 42990 "img", 42991 { 42992 onLoad: () => setIsImageLoaded(true), 42993 alt: "", 42994 src: imageUrl 42995 } 42996 ) 42997 } 42998 ), 42999 !imageUrl && /* @__PURE__ */ (0, import_jsx_runtime279.jsx)("div", { className: "page-templates-author-field__icon", children: /* @__PURE__ */ (0, import_jsx_runtime279.jsx)(import_components161.Icon, { icon }) }), 43000 /* @__PURE__ */ (0, import_jsx_runtime279.jsx)("span", { className: "page-templates-author-field__name", children: text }) 43001 ] }); 43002 } 43003 var authorField = { 43004 label: (0, import_i18n143.__)("Author"), 43005 id: "author", 43006 getValue: ({ item }) => item.author_text ?? item.author, 43007 render: AuthorField2 43008 }; 43009 var activeField = { 43010 label: (0, import_i18n143.__)("Status"), 43011 id: "active", 43012 type: "boolean", 43013 getValue: ({ item }) => item._isActive, 43014 render: function Render({ item }) { 43015 const activeLabel = item._isCustom ? (0, import_i18n143._x)("Active when used", "template") : (0, import_i18n143._x)("Active", "template"); 43016 const activeIntent = item._isCustom ? "info" : "success"; 43017 const isActive = item._isActive; 43018 return /* @__PURE__ */ (0, import_jsx_runtime279.jsx)(Badge3, { intent: isActive ? activeIntent : "default", children: isActive ? activeLabel : (0, import_i18n143._x)("Inactive", "template") }); 43019 } 43020 }; 43021 var useThemeField = () => { 43022 const activeTheme = (0, import_data72.useSelect)( 43023 (select3) => select3(import_core_data53.store).getCurrentTheme() 43024 ); 43025 return (0, import_element140.useMemo)( 43026 () => ({ 43027 label: (0, import_i18n143.__)("Compatible Theme"), 43028 id: "theme", 43029 getValue: ({ item }) => item.theme, 43030 render: function Render3({ item }) { 43031 if (item.theme === activeTheme.stylesheet) { 43032 return /* @__PURE__ */ (0, import_jsx_runtime279.jsx)(Badge3, { intent: "success", children: item.theme }); 43033 } 43034 return /* @__PURE__ */ (0, import_jsx_runtime279.jsx)(Badge3, { intent: "error", children: item.theme }); 43035 } 43036 }), 43037 [activeTheme] 43038 ); 43039 }; 43040 var slugField = { 43041 label: (0, import_i18n143.__)("Template Type"), 43042 id: "slug", 43043 getValue: ({ item }) => item.slug, 43044 render: function Render2({ item }) { 43045 const defaultTemplateTypes = useAllDefaultTemplateTypes(); 43046 const defaultTemplateType = defaultTemplateTypes.find( 43047 (type) => type.slug === item.slug 43048 ); 43049 return defaultTemplateType?.title || (0, import_i18n143._x)("Custom", "template type"); 43050 } 43051 }; 43052 43053 // packages/edit-site/build-module/components/page-templates/view-utils.js 43054 var defaultLayouts2 = { 43055 table: { 43056 showMedia: false 43057 }, 43058 grid: { 43059 showMedia: true 43060 }, 43061 list: { 43062 showMedia: false 43063 } 43064 }; 43065 var DEFAULT_VIEW2 = { 43066 type: "grid", 43067 perPage: 20, 43068 sort: { 43069 field: "title", 43070 direction: "asc" 43071 }, 43072 titleField: "title", 43073 descriptionField: "description", 43074 mediaField: "preview", 43075 fields: ["author", "active", "slug", "theme"], 43076 filters: [], 43077 ...defaultLayouts2.grid 43078 }; 43079 function getDefaultView(activeView) { 43080 return { 43081 ...DEFAULT_VIEW2, 43082 sort: activeView === "user" ? { 43083 field: "date", 43084 direction: "desc" 43085 } : DEFAULT_VIEW2.sort, 43086 filters: !["active", "user"].includes(activeView) ? [ 43087 { 43088 field: "author", 43089 operator: "isAny", 43090 value: [activeView] 43091 } 43092 ] : [] 43093 }; 43094 } 43095 43096 // packages/edit-site/build-module/components/page-templates/index.js 43097 var import_jsx_runtime280 = __toESM(require_jsx_runtime()); 43098 var { usePostActions: usePostActions2, usePostFields, templateTitleField } = unlock(import_editor34.privateApis); 43099 var { useHistory: useHistory22, useLocation: useLocation28 } = unlock(import_router34.privateApis); 43100 var { useEntityRecordsWithPermissions: useEntityRecordsWithPermissions2 } = unlock(import_core_data54.privateApis); 43101 function PageTemplates() { 43102 const { path, query } = useLocation28(); 43103 const { activeView = "active", postId } = query; 43104 const [selection, setSelection] = (0, import_element141.useState)([postId]); 43105 const [selectedRegisteredTemplate, setSelectedRegisteredTemplate] = (0, import_element141.useState)(false); 43106 const defaultView = (0, import_element141.useMemo)(() => { 43107 return getDefaultView(activeView); 43108 }, [activeView]); 43109 const { view, updateView, isModified, resetToDefault } = useView({ 43110 kind: "postType", 43111 name: TEMPLATE_POST_TYPE, 43112 slug: activeView, 43113 defaultView, 43114 queryParams: { 43115 page: query.pageNumber, 43116 search: query.search 43117 }, 43118 onChangeQueryParams: (newQueryParams) => { 43119 history.navigate( 43120 (0, import_url21.addQueryArgs)(path, { 43121 ...query, 43122 pageNumber: newQueryParams.page, 43123 search: newQueryParams.search || void 0 43124 }) 43125 ); 43126 } 43127 }); 43128 const { activeTemplatesOption, activeTheme, defaultTemplateTypes } = (0, import_data73.useSelect)((select3) => { 43129 const { getEntityRecord, getCurrentTheme } = select3(import_core_data54.store); 43130 return { 43131 activeTemplatesOption: getEntityRecord("root", "site")?.active_templates, 43132 activeTheme: getCurrentTheme(), 43133 defaultTemplateTypes: select3(import_core_data54.store).getCurrentTheme()?.default_template_types 43134 }; 43135 }); 43136 const { records: userRecords, isResolving: isLoadingUserRecords } = useEntityRecordsWithPermissions2("postType", TEMPLATE_POST_TYPE, { 43137 per_page: -1, 43138 combinedTemplates: false 43139 }); 43140 const { records: staticRecords, isResolving: isLoadingStaticData } = useEntityRecordsWithPermissions2("root", "registeredTemplate", { 43141 // This should not be needed, the endpoint returns all registered 43142 // templates, but it's not possible right now to turn off pagination 43143 // for entity configs. 43144 per_page: -1 43145 }); 43146 const activeTemplates = (0, import_element141.useMemo)(() => { 43147 const _active = [...staticRecords]; 43148 if (activeTemplatesOption) { 43149 for (const activeSlug in activeTemplatesOption) { 43150 const activeId = activeTemplatesOption[activeSlug]; 43151 const template = userRecords.find( 43152 (userRecord) => userRecord.id === activeId && userRecord.theme === activeTheme.stylesheet 43153 ); 43154 if (template) { 43155 const index = _active.findIndex( 43156 ({ slug }) => slug === template.slug 43157 ); 43158 if (index !== -1) { 43159 _active[index] = template; 43160 } else { 43161 _active.push(template); 43162 } 43163 } 43164 } 43165 } 43166 return _active; 43167 }, [userRecords, staticRecords, activeTemplatesOption, activeTheme]); 43168 let isLoadingData; 43169 if (activeView === "active") { 43170 isLoadingData = isLoadingUserRecords || isLoadingStaticData; 43171 } else if (activeView === "user") { 43172 isLoadingData = isLoadingUserRecords; 43173 } else { 43174 isLoadingData = isLoadingStaticData; 43175 } 43176 const records = (0, import_element141.useMemo)(() => { 43177 function isCustom(record) { 43178 return record.is_custom ?? // For user templates it's custom if the is_wp_suggestion meta 43179 // field is not set and the slug is not found in the default 43180 // template types. 43181 (!record.meta?.is_wp_suggestion && !defaultTemplateTypes.some( 43182 (type) => type.slug === record.slug 43183 )); 43184 } 43185 let _records; 43186 if (activeView === "active") { 43187 _records = activeTemplates.filter( 43188 (record) => !isCustom(record) 43189 ); 43190 } else if (activeView === "user") { 43191 _records = userRecords; 43192 } else { 43193 _records = staticRecords; 43194 } 43195 return _records.map((record) => ({ 43196 ...record, 43197 _isActive: activeTemplates.some( 43198 (template) => template.id === record.id 43199 ), 43200 _isCustom: isCustom(record) 43201 })); 43202 }, [ 43203 activeTemplates, 43204 defaultTemplateTypes, 43205 userRecords, 43206 staticRecords, 43207 activeView 43208 ]); 43209 const users = (0, import_data73.useSelect)( 43210 (select3) => { 43211 const { getUser } = select3(import_core_data54.store); 43212 return records.reduce((acc, record) => { 43213 if (record.author_text) { 43214 if (!acc[record.author_text]) { 43215 acc[record.author_text] = record.author_text; 43216 } 43217 } else if (record.author) { 43218 if (!acc[record.author]) { 43219 acc[record.author] = getUser(record.author); 43220 } 43221 } 43222 return acc; 43223 }, {}); 43224 }, 43225 [records] 43226 ); 43227 const history = useHistory22(); 43228 const onChangeSelection = (0, import_element141.useCallback)( 43229 (items) => { 43230 setSelection(items); 43231 if (view?.type === "list") { 43232 history.navigate( 43233 (0, import_url21.addQueryArgs)(path, { 43234 postId: items.length === 1 ? items[0] : void 0 43235 }) 43236 ); 43237 } 43238 }, 43239 [history, path, view?.type] 43240 ); 43241 const postTypeFields = usePostFields({ 43242 postType: TEMPLATE_POST_TYPE 43243 }); 43244 const dateField = postTypeFields.find((field) => field.id === "date"); 43245 const themeField = useThemeField(); 43246 const fields = (0, import_element141.useMemo)(() => { 43247 const _fields = [ 43248 previewField2, 43249 templateTitleField, 43250 descriptionField, 43251 activeField, 43252 slugField 43253 ]; 43254 if (activeView === "user") { 43255 _fields.push(themeField); 43256 if (dateField) { 43257 _fields.push(dateField); 43258 } 43259 } 43260 const elements2 = []; 43261 for (const author in users) { 43262 elements2.push({ 43263 value: users[author]?.id ?? author, 43264 label: users[author]?.name ?? author 43265 }); 43266 } 43267 _fields.push({ 43268 ...authorField, 43269 elements: elements2 43270 }); 43271 return _fields; 43272 }, [users, activeView, themeField, dateField]); 43273 const { data, paginationInfo } = (0, import_element141.useMemo)(() => { 43274 return filterSortAndPaginate(records, view, fields); 43275 }, [records, view, fields]); 43276 const { createSuccessNotice } = (0, import_data73.useDispatch)(import_notices8.store); 43277 const onActionPerformed = (0, import_element141.useCallback)( 43278 (actionId, items) => { 43279 switch (actionId) { 43280 case "duplicate-post": 43281 { 43282 const newItem = items[0]; 43283 const _title = typeof newItem.title === "string" ? newItem.title : newItem.title?.rendered; 43284 history.navigate(`/template?activeView=user`); 43285 createSuccessNotice( 43286 (0, import_i18n144.sprintf)( 43287 // translators: %s: Title of the created post or template, e.g: "Hello world". 43288 (0, import_i18n144.__)('"%s" successfully created.'), 43289 (0, import_html_entities14.decodeEntities)(_title) || (0, import_i18n144.__)("(no title)") 43290 ), 43291 { 43292 type: "snackbar", 43293 id: "duplicate-post-action", 43294 actions: [ 43295 { 43296 label: (0, import_i18n144.__)("Edit"), 43297 onClick: () => { 43298 history.navigate( 43299 `/$newItem.type}/$newItem.id}?canvas=edit` 43300 ); 43301 } 43302 } 43303 ] 43304 } 43305 ); 43306 } 43307 break; 43308 } 43309 }, 43310 [history, createSuccessNotice] 43311 ); 43312 const postTypeActions = usePostActions2({ 43313 postType: TEMPLATE_POST_TYPE, 43314 context: "list", 43315 onActionPerformed 43316 }); 43317 const editAction = useEditPostAction(); 43318 const setActiveTemplateAction = useSetActiveTemplateAction(); 43319 const actions = (0, import_element141.useMemo)( 43320 () => activeView === "user" ? [setActiveTemplateAction, editAction, ...postTypeActions] : [setActiveTemplateAction, ...postTypeActions], 43321 [postTypeActions, setActiveTemplateAction, editAction, activeView] 43322 ); 43323 const onChangeView = (0, import_compose27.useEvent)((newView) => { 43324 if (newView.type !== view.type) { 43325 history.invalidate(); 43326 } 43327 updateView(newView); 43328 }); 43329 const duplicateAction = actions.find( 43330 (action) => action.id === "duplicate-post" 43331 ); 43332 return /* @__PURE__ */ (0, import_jsx_runtime280.jsxs)( 43333 page_default, 43334 { 43335 className: "edit-site-page-templates", 43336 title: (0, import_i18n144.__)("Templates"), 43337 actions: /* @__PURE__ */ (0, import_jsx_runtime280.jsxs)(import_jsx_runtime280.Fragment, { children: [ 43338 isModified && /* @__PURE__ */ (0, import_jsx_runtime280.jsx)( 43339 import_components162.Button, 43340 { 43341 __next40pxDefaultSize: true, 43342 onClick: () => { 43343 resetToDefault(); 43344 history.invalidate(); 43345 }, 43346 children: (0, import_i18n144.__)("Reset view") 43347 } 43348 ), 43349 /* @__PURE__ */ (0, import_jsx_runtime280.jsx)(add_new_template_default, {}) 43350 ] }), 43351 children: [ 43352 /* @__PURE__ */ (0, import_jsx_runtime280.jsx)( 43353 dataviews_default, 43354 { 43355 paginationInfo, 43356 fields, 43357 actions, 43358 data, 43359 isLoading: isLoadingData, 43360 view, 43361 onChangeView, 43362 onChangeSelection, 43363 isItemClickable: () => true, 43364 onClickItem: (item) => { 43365 if (typeof item.id === "string") { 43366 setSelectedRegisteredTemplate(item); 43367 } else { 43368 history.navigate( 43369 `/$item.type}/$item.id}?canvas=edit` 43370 ); 43371 } 43372 }, 43373 selection, 43374 defaultLayouts: defaultLayouts2 43375 }, 43376 activeView 43377 ), 43378 selectedRegisteredTemplate && duplicateAction && /* @__PURE__ */ (0, import_jsx_runtime280.jsx)( 43379 import_components162.Modal, 43380 { 43381 title: (0, import_i18n144.__)("Duplicate"), 43382 onRequestClose: () => setSelectedRegisteredTemplate(), 43383 size: "small", 43384 children: /* @__PURE__ */ (0, import_jsx_runtime280.jsx)( 43385 duplicateAction.RenderModal, 43386 { 43387 items: [selectedRegisteredTemplate], 43388 closeModal: () => setSelectedRegisteredTemplate() 43389 } 43390 ) 43391 } 43392 ) 43393 ] 43394 } 43395 ); 43396 } 43397 43398 // packages/edit-site/build-module/components/page-templates/index-legacy.js 43399 var import_i18n149 = __toESM(require_i18n()); 43400 var import_element146 = __toESM(require_element()); 43401 var import_core_data58 = __toESM(require_core_data()); 43402 var import_router36 = __toESM(require_router()); 43403 var import_editor35 = __toESM(require_editor()); 43404 var import_url24 = __toESM(require_url()); 43405 var import_compose30 = __toESM(require_compose()); 43406 var import_components166 = __toESM(require_components()); 43407 43408 // packages/edit-site/build-module/components/add-new-template-legacy/index.js 43409 var import_components165 = __toESM(require_components()); 43410 var import_html_entities17 = __toESM(require_html_entities()); 43411 var import_element145 = __toESM(require_element()); 43412 var import_data75 = __toESM(require_data()); 43413 var import_core_data57 = __toESM(require_core_data()); 43414 var import_compose29 = __toESM(require_compose()); 43415 var import_i18n148 = __toESM(require_i18n()); 43416 var import_notices9 = __toESM(require_notices()); 43417 var import_router35 = __toESM(require_router()); 43418 var import_dom15 = __toESM(require_dom()); 43419 43420 // packages/edit-site/build-module/components/add-new-template-legacy/add-custom-template-modal-content.js 43421 var import_element143 = __toESM(require_element()); 43422 var import_i18n146 = __toESM(require_i18n()); 43423 var import_components163 = __toESM(require_components()); 43424 var import_core_data56 = __toESM(require_core_data()); 43425 var import_html_entities16 = __toESM(require_html_entities()); 43426 var import_compose28 = __toESM(require_compose()); 43427 var import_dom14 = __toESM(require_dom()); 43428 var import_url23 = __toESM(require_url()); 43429 43430 // packages/edit-site/build-module/components/add-new-template-legacy/utils.js 43431 var import_data74 = __toESM(require_data()); 43432 var import_core_data55 = __toESM(require_core_data()); 43433 var import_html_entities15 = __toESM(require_html_entities()); 43434 var import_element142 = __toESM(require_element()); 43435 var import_i18n145 = __toESM(require_i18n()); 43436 var import_url22 = __toESM(require_url()); 43437 var EMPTY_OBJECT2 = {}; 43438 var getValueFromObjectPath3 = (object, path) => { 43439 let value = object; 43440 path.split(".").forEach((fieldName) => { 43441 value = value?.[fieldName]; 43442 }); 43443 return value; 43444 }; 43445 function prefixSlug2(prefix2, slug) { 43446 return `$prefix2}-${(0, import_url22.safeDecodeURI)(slug)}`; 43447 } 43448 var mapToIHasNameAndId2 = (entities, path) => { 43449 return (entities || []).map((entity) => ({ 43450 ...entity, 43451 name: (0, import_html_entities15.decodeEntities)(getValueFromObjectPath3(entity, path)) 43452 })); 43453 }; 43454 var useExistingTemplates2 = () => { 43455 return (0, import_data74.useSelect)( 43456 (select3) => select3(import_core_data55.store).getEntityRecords( 43457 "postType", 43458 TEMPLATE_POST_TYPE, 43459 { 43460 per_page: -1 43461 } 43462 ), 43463 [] 43464 ); 43465 }; 43466 var useDefaultTemplateTypes2 = () => { 43467 return (0, import_data74.useSelect)( 43468 (select3) => select3(import_core_data55.store).getCurrentTheme()?.default_template_types || [], 43469 [] 43470 ); 43471 }; 43472 var usePublicPostTypes2 = () => { 43473 const postTypes = (0, import_data74.useSelect)( 43474 (select3) => select3(import_core_data55.store).getPostTypes({ per_page: -1 }), 43475 [] 43476 ); 43477 return (0, import_element142.useMemo)(() => { 43478 const excludedPostTypes = ["attachment"]; 43479 return postTypes?.filter( 43480 ({ viewable, slug }) => viewable && !excludedPostTypes.includes(slug) 43481 ).sort((a2, b2) => { 43482 if (a2.slug === "post" || b2.slug === "post") { 43483 return 0; 43484 } 43485 return a2.name.localeCompare(b2.name); 43486 }); 43487 }, [postTypes]); 43488 }; 43489 var usePublicTaxonomies2 = () => { 43490 const taxonomies = (0, import_data74.useSelect)( 43491 (select3) => select3(import_core_data55.store).getTaxonomies({ per_page: -1 }), 43492 [] 43493 ); 43494 return (0, import_element142.useMemo)(() => { 43495 return taxonomies?.filter( 43496 ({ visibility }) => visibility?.publicly_queryable 43497 ); 43498 }, [taxonomies]); 43499 }; 43500 function usePostTypeArchiveMenuItems2() { 43501 const publicPostTypes = usePublicPostTypes2(); 43502 const postTypesWithArchives = (0, import_element142.useMemo)( 43503 () => publicPostTypes?.filter((postType2) => postType2.has_archive), 43504 [publicPostTypes] 43505 ); 43506 const existingTemplates = useExistingTemplates2(); 43507 const postTypeLabels = (0, import_element142.useMemo)( 43508 () => publicPostTypes?.reduce((accumulator, { labels }) => { 43509 const singularName = labels.singular_name.toLowerCase(); 43510 accumulator[singularName] = (accumulator[singularName] || 0) + 1; 43511 return accumulator; 43512 }, {}), 43513 [publicPostTypes] 43514 ); 43515 const needsUniqueIdentifier = (0, import_element142.useCallback)( 43516 ({ labels, slug }) => { 43517 const singularName = labels.singular_name.toLowerCase(); 43518 return postTypeLabels[singularName] > 1 && singularName !== slug; 43519 }, 43520 [postTypeLabels] 43521 ); 43522 return (0, import_element142.useMemo)( 43523 () => postTypesWithArchives?.filter( 43524 (postType2) => !(existingTemplates || []).some( 43525 (existingTemplate) => existingTemplate.slug === "archive-" + postType2.slug 43526 ) 43527 ).map((postType2) => { 43528 let title; 43529 if (needsUniqueIdentifier(postType2)) { 43530 title = (0, import_i18n145.sprintf)( 43531 // translators: %1s: Name of the post type e.g: "Post"; %2s: Slug of the post type e.g: "book". 43532 (0, import_i18n145.__)("Archive: %1$s (%2$s)"), 43533 postType2.labels.singular_name, 43534 postType2.slug 43535 ); 43536 } else { 43537 title = (0, import_i18n145.sprintf)( 43538 // translators: %s: Name of the post type e.g: "Post". 43539 (0, import_i18n145.__)("Archive: %s"), 43540 postType2.labels.singular_name 43541 ); 43542 } 43543 return { 43544 slug: "archive-" + postType2.slug, 43545 description: (0, import_i18n145.sprintf)( 43546 // translators: %s: Name of the post type e.g: "Post". 43547 (0, import_i18n145.__)( 43548 "Displays an archive with the latest posts of type: %s." 43549 ), 43550 postType2.labels.singular_name 43551 ), 43552 title, 43553 // `icon` is the `menu_icon` property of a post type. We 43554 // only handle `dashicons` for now, even if the `menu_icon` 43555 // also supports urls and svg as values. 43556 icon: typeof postType2.icon === "string" && postType2.icon.startsWith("dashicons-") ? postType2.icon.slice(10) : archive_default, 43557 templatePrefix: "archive" 43558 }; 43559 }) || [], 43560 [postTypesWithArchives, existingTemplates, needsUniqueIdentifier] 43561 ); 43562 } 43563 var usePostTypeMenuItems2 = (onClickMenuItem) => { 43564 const publicPostTypes = usePublicPostTypes2(); 43565 const existingTemplates = useExistingTemplates2(); 43566 const defaultTemplateTypes = useDefaultTemplateTypes2(); 43567 const templateLabels = (0, import_element142.useMemo)( 43568 () => publicPostTypes?.reduce((accumulator, { labels }) => { 43569 const templateName = (labels.template_name || labels.singular_name).toLowerCase(); 43570 accumulator[templateName] = (accumulator[templateName] || 0) + 1; 43571 return accumulator; 43572 }, {}), 43573 [publicPostTypes] 43574 ); 43575 const needsUniqueIdentifier = (0, import_element142.useCallback)( 43576 ({ labels, slug }) => { 43577 const templateName = (labels.template_name || labels.singular_name).toLowerCase(); 43578 return templateLabels[templateName] > 1 && templateName !== slug; 43579 }, 43580 [templateLabels] 43581 ); 43582 const templatePrefixes = (0, import_element142.useMemo)( 43583 () => publicPostTypes?.reduce((accumulator, { slug }) => { 43584 let suffix = slug; 43585 if (slug !== "page") { 43586 suffix = `single-$suffix}`; 43587 } 43588 accumulator[slug] = suffix; 43589 return accumulator; 43590 }, {}), 43591 [publicPostTypes] 43592 ); 43593 const postTypesInfo = useEntitiesInfo2("postType", templatePrefixes); 43594 const existingTemplateSlugs = (existingTemplates || []).map( 43595 ({ slug }) => slug 43596 ); 43597 const menuItems = (publicPostTypes || []).reduce( 43598 (accumulator, postType2) => { 43599 const { slug, labels, icon } = postType2; 43600 const generalTemplateSlug = templatePrefixes[slug]; 43601 const defaultTemplateType = defaultTemplateTypes?.find( 43602 ({ slug: _slug }) => _slug === generalTemplateSlug 43603 ); 43604 const hasGeneralTemplate = existingTemplateSlugs?.includes(generalTemplateSlug); 43605 const _needsUniqueIdentifier = needsUniqueIdentifier(postType2); 43606 let menuItemTitle = labels.template_name || (0, import_i18n145.sprintf)( 43607 // translators: %s: Name of the post type e.g: "Post". 43608 (0, import_i18n145.__)("Single item: %s"), 43609 labels.singular_name 43610 ); 43611 if (_needsUniqueIdentifier) { 43612 menuItemTitle = labels.template_name ? (0, import_i18n145.sprintf)( 43613 // translators: 1: Name of the template e.g: "Single Item: Post". 2: Slug of the post type e.g: "book". 43614 (0, import_i18n145._x)("%1$s (%2$s)", "post type menu label"), 43615 labels.template_name, 43616 slug 43617 ) : (0, import_i18n145.sprintf)( 43618 // translators: 1: Name of the post type e.g: "Post". 2: Slug of the post type e.g: "book". 43619 (0, import_i18n145._x)( 43620 "Single item: %1$s (%2$s)", 43621 "post type menu label" 43622 ), 43623 labels.singular_name, 43624 slug 43625 ); 43626 } 43627 const menuItem = defaultTemplateType ? { 43628 ...defaultTemplateType, 43629 templatePrefix: templatePrefixes[slug] 43630 } : { 43631 slug: generalTemplateSlug, 43632 title: menuItemTitle, 43633 description: (0, import_i18n145.sprintf)( 43634 // translators: %s: Name of the post type e.g: "Post". 43635 (0, import_i18n145.__)("Displays a single item: %s."), 43636 labels.singular_name 43637 ), 43638 // `icon` is the `menu_icon` property of a post type. We 43639 // only handle `dashicons` for now, even if the `menu_icon` 43640 // also supports urls and svg as values. 43641 icon: typeof icon === "string" && icon.startsWith("dashicons-") ? icon.slice(10) : post_default, 43642 templatePrefix: templatePrefixes[slug] 43643 }; 43644 const hasEntities = postTypesInfo?.[slug]?.hasEntities; 43645 if (hasEntities) { 43646 menuItem.onClick = (template) => { 43647 onClickMenuItem({ 43648 type: "postType", 43649 slug, 43650 config: { 43651 recordNamePath: "title.rendered", 43652 queryArgs: ({ search }) => { 43653 return { 43654 _fields: "id,title,slug,link", 43655 orderBy: search ? "relevance" : "modified", 43656 exclude: postTypesInfo[slug].existingEntitiesIds 43657 }; 43658 }, 43659 getSpecificTemplate: (suggestion) => { 43660 const templateSlug = prefixSlug2( 43661 templatePrefixes[slug], 43662 suggestion.slug 43663 ); 43664 return { 43665 title: templateSlug, 43666 slug: templateSlug, 43667 templatePrefix: templatePrefixes[slug] 43668 }; 43669 } 43670 }, 43671 labels, 43672 hasGeneralTemplate, 43673 template 43674 }); 43675 }; 43676 } 43677 if (!hasGeneralTemplate || hasEntities) { 43678 accumulator.push(menuItem); 43679 } 43680 return accumulator; 43681 }, 43682 [] 43683 ); 43684 const postTypesMenuItems = (0, import_element142.useMemo)( 43685 () => menuItems.reduce( 43686 (accumulator, postType2) => { 43687 const { slug } = postType2; 43688 let key = "postTypesMenuItems"; 43689 if (slug === "page") { 43690 key = "defaultPostTypesMenuItems"; 43691 } 43692 accumulator[key].push(postType2); 43693 return accumulator; 43694 }, 43695 { defaultPostTypesMenuItems: [], postTypesMenuItems: [] } 43696 ), 43697 [menuItems] 43698 ); 43699 return postTypesMenuItems; 43700 }; 43701 var useTaxonomiesMenuItems2 = (onClickMenuItem) => { 43702 const publicTaxonomies = usePublicTaxonomies2(); 43703 const existingTemplates = useExistingTemplates2(); 43704 const defaultTemplateTypes = useDefaultTemplateTypes2(); 43705 const templatePrefixes = (0, import_element142.useMemo)( 43706 () => publicTaxonomies?.reduce((accumulator, { slug }) => { 43707 let suffix = slug; 43708 if (!["category", "post_tag"].includes(slug)) { 43709 suffix = `taxonomy-$suffix}`; 43710 } 43711 if (slug === "post_tag") { 43712 suffix = `tag`; 43713 } 43714 accumulator[slug] = suffix; 43715 return accumulator; 43716 }, {}), 43717 [publicTaxonomies] 43718 ); 43719 const taxonomyLabels = publicTaxonomies?.reduce( 43720 (accumulator, { labels }) => { 43721 const templateName = (labels.template_name || labels.singular_name).toLowerCase(); 43722 accumulator[templateName] = (accumulator[templateName] || 0) + 1; 43723 return accumulator; 43724 }, 43725 {} 43726 ); 43727 const needsUniqueIdentifier = (labels, slug) => { 43728 if (["category", "post_tag"].includes(slug)) { 43729 return false; 43730 } 43731 const templateName = (labels.template_name || labels.singular_name).toLowerCase(); 43732 return taxonomyLabels[templateName] > 1 && templateName !== slug; 43733 }; 43734 const taxonomiesInfo = useEntitiesInfo2("taxonomy", templatePrefixes); 43735 const existingTemplateSlugs = (existingTemplates || []).map( 43736 ({ slug }) => slug 43737 ); 43738 const menuItems = (publicTaxonomies || []).reduce( 43739 (accumulator, taxonomy) => { 43740 const { slug, labels } = taxonomy; 43741 const generalTemplateSlug = templatePrefixes[slug]; 43742 const defaultTemplateType = defaultTemplateTypes?.find( 43743 ({ slug: _slug }) => _slug === generalTemplateSlug 43744 ); 43745 const hasGeneralTemplate = existingTemplateSlugs?.includes(generalTemplateSlug); 43746 const _needsUniqueIdentifier = needsUniqueIdentifier( 43747 labels, 43748 slug 43749 ); 43750 let menuItemTitle = labels.template_name || labels.singular_name; 43751 if (_needsUniqueIdentifier) { 43752 menuItemTitle = labels.template_name ? (0, import_i18n145.sprintf)( 43753 // translators: 1: Name of the template e.g: "Products by Category". 2: Slug of the taxonomy e.g: "product_cat". 43754 (0, import_i18n145._x)("%1$s (%2$s)", "taxonomy template menu label"), 43755 labels.template_name, 43756 slug 43757 ) : (0, import_i18n145.sprintf)( 43758 // translators: 1: Name of the taxonomy e.g: "Category". 2: Slug of the taxonomy e.g: "product_cat". 43759 (0, import_i18n145._x)("%1$s (%2$s)", "taxonomy menu label"), 43760 labels.singular_name, 43761 slug 43762 ); 43763 } 43764 const menuItem = defaultTemplateType ? { 43765 ...defaultTemplateType, 43766 templatePrefix: templatePrefixes[slug] 43767 } : { 43768 slug: generalTemplateSlug, 43769 title: menuItemTitle, 43770 description: (0, import_i18n145.sprintf)( 43771 // translators: %s: Name of the taxonomy e.g: "Product Categories". 43772 (0, import_i18n145.__)("Displays taxonomy: %s."), 43773 labels.singular_name 43774 ), 43775 icon: block_meta_default, 43776 templatePrefix: templatePrefixes[slug] 43777 }; 43778 const hasEntities = taxonomiesInfo?.[slug]?.hasEntities; 43779 if (hasEntities) { 43780 menuItem.onClick = (template) => { 43781 onClickMenuItem({ 43782 type: "taxonomy", 43783 slug, 43784 config: { 43785 queryArgs: ({ search }) => { 43786 return { 43787 _fields: "id,name,slug,link", 43788 orderBy: search ? "name" : "count", 43789 exclude: taxonomiesInfo[slug].existingEntitiesIds 43790 }; 43791 }, 43792 getSpecificTemplate: (suggestion) => { 43793 const templateSlug = prefixSlug2( 43794 templatePrefixes[slug], 43795 suggestion.slug 43796 ); 43797 return { 43798 title: templateSlug, 43799 slug: templateSlug, 43800 templatePrefix: templatePrefixes[slug] 43801 }; 43802 } 43803 }, 43804 labels, 43805 hasGeneralTemplate, 43806 template 43807 }); 43808 }; 43809 } 43810 if (!hasGeneralTemplate || hasEntities) { 43811 accumulator.push(menuItem); 43812 } 43813 return accumulator; 43814 }, 43815 [] 43816 ); 43817 const taxonomiesMenuItems = (0, import_element142.useMemo)( 43818 () => menuItems.reduce( 43819 (accumulator, taxonomy) => { 43820 const { slug } = taxonomy; 43821 let key = "taxonomiesMenuItems"; 43822 if (["category", "tag"].includes(slug)) { 43823 key = "defaultTaxonomiesMenuItems"; 43824 } 43825 accumulator[key].push(taxonomy); 43826 return accumulator; 43827 }, 43828 { defaultTaxonomiesMenuItems: [], taxonomiesMenuItems: [] } 43829 ), 43830 [menuItems] 43831 ); 43832 return taxonomiesMenuItems; 43833 }; 43834 var USE_AUTHOR_MENU_ITEM_TEMPLATE_PREFIX2 = { user: "author" }; 43835 var USE_AUTHOR_MENU_ITEM_QUERY_PARAMETERS2 = { user: { who: "authors" } }; 43836 function useAuthorMenuItem2(onClickMenuItem) { 43837 const existingTemplates = useExistingTemplates2(); 43838 const defaultTemplateTypes = useDefaultTemplateTypes2(); 43839 const authorInfo = useEntitiesInfo2( 43840 "root", 43841 USE_AUTHOR_MENU_ITEM_TEMPLATE_PREFIX2, 43842 USE_AUTHOR_MENU_ITEM_QUERY_PARAMETERS2 43843 ); 43844 let authorMenuItem = defaultTemplateTypes?.find( 43845 ({ slug }) => slug === "author" 43846 ); 43847 if (!authorMenuItem) { 43848 authorMenuItem = { 43849 description: (0, import_i18n145.__)( 43850 "Displays latest posts written by a single author." 43851 ), 43852 slug: "author", 43853 title: "Author" 43854 }; 43855 } 43856 const hasGeneralTemplate = !!existingTemplates?.find( 43857 ({ slug }) => slug === "author" 43858 ); 43859 if (authorInfo.user?.hasEntities) { 43860 authorMenuItem = { ...authorMenuItem, templatePrefix: "author" }; 43861 authorMenuItem.onClick = (template) => { 43862 onClickMenuItem({ 43863 type: "root", 43864 slug: "user", 43865 config: { 43866 queryArgs: ({ search }) => { 43867 return { 43868 _fields: "id,name,slug,link", 43869 orderBy: search ? "name" : "registered_date", 43870 exclude: authorInfo.user.existingEntitiesIds, 43871 who: "authors" 43872 }; 43873 }, 43874 getSpecificTemplate: (suggestion) => { 43875 const templateSlug = prefixSlug2( 43876 "author", 43877 suggestion.slug 43878 ); 43879 return { 43880 title: templateSlug, 43881 slug: templateSlug, 43882 templatePrefix: "author" 43883 }; 43884 } 43885 }, 43886 labels: { 43887 singular_name: (0, import_i18n145.__)("Author"), 43888 search_items: (0, import_i18n145.__)("Search Authors"), 43889 not_found: (0, import_i18n145.__)("No authors found."), 43890 all_items: (0, import_i18n145.__)("All Authors") 43891 }, 43892 hasGeneralTemplate, 43893 template 43894 }); 43895 }; 43896 } 43897 if (!hasGeneralTemplate || authorInfo.user?.hasEntities) { 43898 return authorMenuItem; 43899 } 43900 } 43901 var useExistingTemplateSlugs = (templatePrefixes) => { 43902 const existingTemplates = useExistingTemplates2(); 43903 const existingSlugs = (0, import_element142.useMemo)(() => { 43904 return Object.entries(templatePrefixes || {}).reduce( 43905 (accumulator, [slug, prefix2]) => { 43906 const slugsWithTemplates = (existingTemplates || []).reduce( 43907 (_accumulator, existingTemplate) => { 43908 const _prefix = `$prefix2}-`; 43909 if (existingTemplate.slug.startsWith(_prefix)) { 43910 _accumulator.push( 43911 existingTemplate.slug.substring( 43912 _prefix.length 43913 ) 43914 ); 43915 } 43916 return _accumulator; 43917 }, 43918 [] 43919 ); 43920 if (slugsWithTemplates.length) { 43921 accumulator[slug] = slugsWithTemplates; 43922 } 43923 return accumulator; 43924 }, 43925 {} 43926 ); 43927 }, [templatePrefixes, existingTemplates]); 43928 return existingSlugs; 43929 }; 43930 var useTemplatesToExclude = (entityName, templatePrefixes, additionalQueryParameters = {}) => { 43931 const slugsToExcludePerEntity = useExistingTemplateSlugs(templatePrefixes); 43932 const recordsToExcludePerEntity = (0, import_data74.useSelect)( 43933 (select3) => { 43934 return Object.entries(slugsToExcludePerEntity || {}).reduce( 43935 (accumulator, [slug, slugsWithTemplates]) => { 43936 const entitiesWithTemplates = select3( 43937 import_core_data55.store 43938 ).getEntityRecords(entityName, slug, { 43939 _fields: "id", 43940 context: "view", 43941 slug: slugsWithTemplates, 43942 ...additionalQueryParameters[slug] 43943 }); 43944 if (entitiesWithTemplates?.length) { 43945 accumulator[slug] = entitiesWithTemplates; 43946 } 43947 return accumulator; 43948 }, 43949 {} 43950 ); 43951 }, 43952 [slugsToExcludePerEntity] 43953 ); 43954 return recordsToExcludePerEntity; 43955 }; 43956 var useEntitiesInfo2 = (entityName, templatePrefixes, additionalQueryParameters = EMPTY_OBJECT2) => { 43957 const recordsToExcludePerEntity = useTemplatesToExclude( 43958 entityName, 43959 templatePrefixes, 43960 additionalQueryParameters 43961 ); 43962 const entitiesHasRecords = (0, import_data74.useSelect)( 43963 (select3) => { 43964 return Object.keys(templatePrefixes || {}).reduce( 43965 (accumulator, slug) => { 43966 const existingEntitiesIds = recordsToExcludePerEntity?.[slug]?.map( 43967 ({ id }) => id 43968 ) || []; 43969 accumulator[slug] = !!select3( 43970 import_core_data55.store 43971 ).getEntityRecords(entityName, slug, { 43972 per_page: 1, 43973 _fields: "id", 43974 context: "view", 43975 exclude: existingEntitiesIds, 43976 ...additionalQueryParameters[slug] 43977 })?.length; 43978 return accumulator; 43979 }, 43980 {} 43981 ); 43982 }, 43983 [ 43984 templatePrefixes, 43985 recordsToExcludePerEntity, 43986 entityName, 43987 additionalQueryParameters 43988 ] 43989 ); 43990 const entitiesInfo = (0, import_element142.useMemo)(() => { 43991 return Object.keys(templatePrefixes || {}).reduce( 43992 (accumulator, slug) => { 43993 const existingEntitiesIds = recordsToExcludePerEntity?.[slug]?.map( 43994 ({ id }) => id 43995 ) || []; 43996 accumulator[slug] = { 43997 hasEntities: entitiesHasRecords[slug], 43998 existingEntitiesIds 43999 }; 44000 return accumulator; 44001 }, 44002 {} 44003 ); 44004 }, [templatePrefixes, recordsToExcludePerEntity, entitiesHasRecords]); 44005 return entitiesInfo; 44006 }; 44007 44008 // packages/edit-site/build-module/components/add-new-template-legacy/add-custom-template-modal-content.js 44009 var import_jsx_runtime281 = __toESM(require_jsx_runtime()); 44010 var EMPTY_ARRAY14 = []; 44011 function SuggestionListItem2({ 44012 suggestion, 44013 search, 44014 onSelect, 44015 entityForSuggestions 44016 }) { 44017 const baseCssClass = "edit-site-custom-template-modal__suggestions_list__list-item"; 44018 return /* @__PURE__ */ (0, import_jsx_runtime281.jsxs)( 44019 import_components163.Composite.Item, 44020 { 44021 render: /* @__PURE__ */ (0, import_jsx_runtime281.jsx)( 44022 import_components163.Button, 44023 { 44024 __next40pxDefaultSize: true, 44025 role: "option", 44026 className: baseCssClass, 44027 onClick: () => onSelect( 44028 entityForSuggestions.config.getSpecificTemplate( 44029 suggestion 44030 ) 44031 ) 44032 } 44033 ), 44034 children: [ 44035 /* @__PURE__ */ (0, import_jsx_runtime281.jsx)( 44036 import_components163.__experimentalText, 44037 { 44038 size: "body", 44039 lineHeight: 1.53846153846, 44040 weight: 500, 44041 className: `$baseCssClass}__title`, 44042 children: /* @__PURE__ */ (0, import_jsx_runtime281.jsx)( 44043 import_components163.TextHighlight, 44044 { 44045 text: (0, import_html_entities16.decodeEntities)(suggestion.name), 44046 highlight: search 44047 } 44048 ) 44049 } 44050 ), 44051 suggestion.link && /* @__PURE__ */ (0, import_jsx_runtime281.jsx)( 44052 import_components163.__experimentalText, 44053 { 44054 size: "body", 44055 lineHeight: 1.53846153846, 44056 className: `$baseCssClass}__info`, 44057 children: (0, import_url23.safeDecodeURI)(suggestion.link) 44058 } 44059 ) 44060 ] 44061 } 44062 ); 44063 } 44064 function useSearchSuggestions2(entityForSuggestions, search) { 44065 const { config: config2 } = entityForSuggestions; 44066 const query = (0, import_element143.useMemo)( 44067 () => ({ 44068 order: "asc", 44069 context: "view", 44070 search, 44071 per_page: search ? 20 : 10, 44072 ...config2.queryArgs(search) 44073 }), 44074 [search, config2] 44075 ); 44076 const { records: searchResults, hasResolved: searchHasResolved } = (0, import_core_data56.useEntityRecords)( 44077 entityForSuggestions.type, 44078 entityForSuggestions.slug, 44079 query 44080 ); 44081 const [suggestions, setSuggestions] = (0, import_element143.useState)(EMPTY_ARRAY14); 44082 (0, import_element143.useEffect)(() => { 44083 if (!searchHasResolved) { 44084 return; 44085 } 44086 let newSuggestions = EMPTY_ARRAY14; 44087 if (searchResults?.length) { 44088 newSuggestions = searchResults; 44089 if (config2.recordNamePath) { 44090 newSuggestions = mapToIHasNameAndId2( 44091 newSuggestions, 44092 config2.recordNamePath 44093 ); 44094 } 44095 } 44096 setSuggestions(newSuggestions); 44097 }, [searchResults, searchHasResolved]); 44098 return suggestions; 44099 } 44100 function SuggestionList2({ entityForSuggestions, onSelect }) { 44101 const [search, setSearch, debouncedSearch] = (0, import_compose28.useDebouncedInput)(); 44102 const suggestions = useSearchSuggestions2( 44103 entityForSuggestions, 44104 debouncedSearch 44105 ); 44106 const { labels } = entityForSuggestions; 44107 const [showSearchControl, setShowSearchControl] = (0, import_element143.useState)(false); 44108 if (!showSearchControl && suggestions?.length > 9) { 44109 setShowSearchControl(true); 44110 } 44111 return /* @__PURE__ */ (0, import_jsx_runtime281.jsxs)(import_jsx_runtime281.Fragment, { children: [ 44112 showSearchControl && /* @__PURE__ */ (0, import_jsx_runtime281.jsx)( 44113 import_components163.SearchControl, 44114 { 44115 onChange: setSearch, 44116 value: search, 44117 label: labels.search_items, 44118 placeholder: labels.search_items 44119 } 44120 ), 44121 !!suggestions?.length && /* @__PURE__ */ (0, import_jsx_runtime281.jsx)( 44122 import_components163.Composite, 44123 { 44124 orientation: "vertical", 44125 role: "listbox", 44126 className: "edit-site-custom-template-modal__suggestions_list", 44127 "aria-label": (0, import_i18n146.__)("Suggestions list"), 44128 children: suggestions.map((suggestion) => /* @__PURE__ */ (0, import_jsx_runtime281.jsx)( 44129 SuggestionListItem2, 44130 { 44131 suggestion, 44132 search: debouncedSearch, 44133 onSelect, 44134 entityForSuggestions 44135 }, 44136 suggestion.slug 44137 )) 44138 } 44139 ), 44140 debouncedSearch && !suggestions?.length && /* @__PURE__ */ (0, import_jsx_runtime281.jsx)( 44141 import_components163.__experimentalText, 44142 { 44143 as: "p", 44144 className: "edit-site-custom-template-modal__no-results", 44145 children: labels.not_found 44146 } 44147 ) 44148 ] }); 44149 } 44150 function AddCustomTemplateModalContent2({ 44151 onSelect, 44152 entityForSuggestions, 44153 onBack, 44154 containerRef 44155 }) { 44156 const [showSearchEntities, setShowSearchEntities] = (0, import_element143.useState)( 44157 entityForSuggestions.hasGeneralTemplate 44158 ); 44159 (0, import_element143.useEffect)(() => { 44160 if (containerRef.current) { 44161 const [firstFocusable] = import_dom14.focus.focusable.find( 44162 containerRef.current 44163 ); 44164 firstFocusable?.focus(); 44165 } 44166 }, [showSearchEntities]); 44167 return /* @__PURE__ */ (0, import_jsx_runtime281.jsxs)( 44168 import_components163.__experimentalVStack, 44169 { 44170 spacing: 4, 44171 className: "edit-site-custom-template-modal__contents-wrapper", 44172 alignment: "left", 44173 children: [ 44174 !showSearchEntities && /* @__PURE__ */ (0, import_jsx_runtime281.jsxs)(import_jsx_runtime281.Fragment, { children: [ 44175 /* @__PURE__ */ (0, import_jsx_runtime281.jsx)(import_components163.__experimentalText, { as: "p", children: (0, import_i18n146.__)( 44176 "Select whether to create a single template for all items or a specific one." 44177 ) }), 44178 /* @__PURE__ */ (0, import_jsx_runtime281.jsxs)( 44179 import_components163.Flex, 44180 { 44181 className: "edit-site-custom-template-modal__contents", 44182 gap: "4", 44183 align: "initial", 44184 children: [ 44185 /* @__PURE__ */ (0, import_jsx_runtime281.jsxs)( 44186 import_components163.FlexItem, 44187 { 44188 isBlock: true, 44189 as: import_components163.Button, 44190 onClick: () => { 44191 const { 44192 slug, 44193 title, 44194 description, 44195 templatePrefix 44196 } = entityForSuggestions.template; 44197 onSelect({ 44198 slug, 44199 title, 44200 description, 44201 templatePrefix 44202 }); 44203 }, 44204 children: [ 44205 /* @__PURE__ */ (0, import_jsx_runtime281.jsx)( 44206 import_components163.__experimentalText, 44207 { 44208 as: "span", 44209 weight: 500, 44210 lineHeight: 1.53846153846, 44211 children: entityForSuggestions.labels.all_items 44212 } 44213 ), 44214 /* @__PURE__ */ (0, import_jsx_runtime281.jsx)( 44215 import_components163.__experimentalText, 44216 { 44217 as: "span", 44218 lineHeight: 1.53846153846, 44219 // translators: The user is given the choice to set up a template for all items of a post type or taxonomy, or just a specific one. 44220 children: (0, import_i18n146.__)("For all items") 44221 } 44222 ) 44223 ] 44224 } 44225 ), 44226 /* @__PURE__ */ (0, import_jsx_runtime281.jsxs)( 44227 import_components163.FlexItem, 44228 { 44229 isBlock: true, 44230 as: import_components163.Button, 44231 onClick: () => { 44232 setShowSearchEntities(true); 44233 }, 44234 children: [ 44235 /* @__PURE__ */ (0, import_jsx_runtime281.jsx)( 44236 import_components163.__experimentalText, 44237 { 44238 as: "span", 44239 weight: 500, 44240 lineHeight: 1.53846153846, 44241 children: entityForSuggestions.labels.singular_name 44242 } 44243 ), 44244 /* @__PURE__ */ (0, import_jsx_runtime281.jsx)( 44245 import_components163.__experimentalText, 44246 { 44247 as: "span", 44248 lineHeight: 1.53846153846, 44249 // translators: The user is given the choice to set up a template for all items of a post type or taxonomy, or just a specific one. 44250 children: (0, import_i18n146.__)("For a specific item") 44251 } 44252 ) 44253 ] 44254 } 44255 ) 44256 ] 44257 } 44258 ), 44259 /* @__PURE__ */ (0, import_jsx_runtime281.jsx)(import_components163.Flex, { justify: "right", children: /* @__PURE__ */ (0, import_jsx_runtime281.jsx)( 44260 import_components163.Button, 44261 { 44262 __next40pxDefaultSize: true, 44263 variant: "tertiary", 44264 onClick: onBack, 44265 children: (0, import_i18n146.__)("Back") 44266 } 44267 ) }) 44268 ] }), 44269 showSearchEntities && /* @__PURE__ */ (0, import_jsx_runtime281.jsxs)(import_jsx_runtime281.Fragment, { children: [ 44270 /* @__PURE__ */ (0, import_jsx_runtime281.jsx)(import_components163.__experimentalText, { as: "p", children: (0, import_i18n146.__)( 44271 "This template will be used only for the specific item chosen." 44272 ) }), 44273 /* @__PURE__ */ (0, import_jsx_runtime281.jsx)( 44274 SuggestionList2, 44275 { 44276 entityForSuggestions, 44277 onSelect 44278 } 44279 ), 44280 /* @__PURE__ */ (0, import_jsx_runtime281.jsx)(import_components163.Flex, { justify: "right", children: /* @__PURE__ */ (0, import_jsx_runtime281.jsx)( 44281 import_components163.Button, 44282 { 44283 __next40pxDefaultSize: true, 44284 variant: "tertiary", 44285 onClick: () => { 44286 if (entityForSuggestions.hasGeneralTemplate) { 44287 onBack(); 44288 } else { 44289 setShowSearchEntities(false); 44290 } 44291 }, 44292 children: (0, import_i18n146.__)("Back") 44293 } 44294 ) }) 44295 ] }) 44296 ] 44297 } 44298 ); 44299 } 44300 var add_custom_template_modal_content_default2 = AddCustomTemplateModalContent2; 44301 44302 // packages/edit-site/build-module/components/add-new-template-legacy/add-custom-generic-template-modal-content.js 44303 var import_element144 = __toESM(require_element()); 44304 var import_i18n147 = __toESM(require_i18n()); 44305 var import_components164 = __toESM(require_components()); 44306 var import_jsx_runtime282 = __toESM(require_jsx_runtime()); 44307 function AddCustomGenericTemplateModalContent2({ createTemplate, onBack }) { 44308 const [title, setTitle] = (0, import_element144.useState)(""); 44309 const defaultTitle = (0, import_i18n147.__)("Custom Template"); 44310 const [isBusy, setIsBusy] = (0, import_element144.useState)(false); 44311 const inputRef = (0, import_element144.useRef)(); 44312 (0, import_element144.useEffect)(() => { 44313 if (inputRef.current) { 44314 inputRef.current.focus(); 44315 } 44316 }, []); 44317 async function onCreateTemplate(event) { 44318 event.preventDefault(); 44319 if (isBusy) { 44320 return; 44321 } 44322 setIsBusy(true); 44323 try { 44324 await createTemplate( 44325 { 44326 slug: paramCase(title || defaultTitle) || "wp-custom-template", 44327 title: title || defaultTitle 44328 }, 44329 false 44330 ); 44331 } finally { 44332 setIsBusy(false); 44333 } 44334 } 44335 return /* @__PURE__ */ (0, import_jsx_runtime282.jsx)("form", { onSubmit: onCreateTemplate, children: /* @__PURE__ */ (0, import_jsx_runtime282.jsxs)(import_components164.__experimentalVStack, { spacing: 6, children: [ 44336 /* @__PURE__ */ (0, import_jsx_runtime282.jsx)( 44337 import_components164.TextControl, 44338 { 44339 __next40pxDefaultSize: true, 44340 label: (0, import_i18n147.__)("Name"), 44341 value: title, 44342 onChange: setTitle, 44343 placeholder: defaultTitle, 44344 disabled: isBusy, 44345 ref: inputRef, 44346 help: (0, import_i18n147.__)( 44347 // eslint-disable-next-line no-restricted-syntax -- 'sidebar' is a common web design term for layouts 44348 'Describe the template, e.g. "Post with sidebar". A custom template can be manually applied to any post or page.' 44349 ) 44350 } 44351 ), 44352 /* @__PURE__ */ (0, import_jsx_runtime282.jsxs)( 44353 import_components164.__experimentalHStack, 44354 { 44355 className: "edit-site-custom-generic-template__modal-actions", 44356 justify: "right", 44357 children: [ 44358 /* @__PURE__ */ (0, import_jsx_runtime282.jsx)( 44359 import_components164.Button, 44360 { 44361 __next40pxDefaultSize: true, 44362 variant: "tertiary", 44363 onClick: onBack, 44364 children: (0, import_i18n147.__)("Back") 44365 } 44366 ), 44367 /* @__PURE__ */ (0, import_jsx_runtime282.jsx)( 44368 import_components164.Button, 44369 { 44370 __next40pxDefaultSize: true, 44371 variant: "primary", 44372 type: "submit", 44373 isBusy, 44374 "aria-disabled": isBusy, 44375 children: (0, import_i18n147.__)("Create") 44376 } 44377 ) 44378 ] 44379 } 44380 ) 44381 ] }) }); 44382 } 44383 var add_custom_generic_template_modal_content_default2 = AddCustomGenericTemplateModalContent2; 44384 44385 // packages/edit-site/build-module/components/add-new-template-legacy/index.js 44386 var import_jsx_runtime283 = __toESM(require_jsx_runtime()); 44387 var { useHistory: useHistory23 } = unlock(import_router35.privateApis); 44388 var DEFAULT_TEMPLATE_SLUGS2 = [ 44389 "front-page", 44390 "home", 44391 "single", 44392 "page", 44393 "index", 44394 "archive", 44395 "author", 44396 "category", 44397 "date", 44398 "tag", 44399 "search", 44400 "404" 44401 ]; 44402 var TEMPLATE_ICONS2 = { 44403 "front-page": home_default, 44404 home: verse_default, 44405 single: pin_default, 44406 page: page_default2, 44407 archive: archive_default, 44408 search: search_default, 44409 404: not_found_default, 44410 index: list_default, 44411 category: category_default, 44412 author: comment_author_avatar_default, 44413 taxonomy: block_meta_default, 44414 date: calendar_default, 44415 tag: tag_default, 44416 attachment: media_default 44417 }; 44418 function TemplateListItem2({ 44419 title, 44420 direction, 44421 className, 44422 description, 44423 icon, 44424 onClick, 44425 children 44426 }) { 44427 return /* @__PURE__ */ (0, import_jsx_runtime283.jsx)( 44428 import_components165.Button, 44429 { 44430 __next40pxDefaultSize: true, 44431 className, 44432 onClick, 44433 label: description, 44434 showTooltip: !!description, 44435 children: /* @__PURE__ */ (0, import_jsx_runtime283.jsxs)( 44436 import_components165.Flex, 44437 { 44438 as: "span", 44439 spacing: 2, 44440 align: "center", 44441 justify: "center", 44442 style: { width: "100%" }, 44443 direction, 44444 children: [ 44445 /* @__PURE__ */ (0, import_jsx_runtime283.jsx)("div", { className: "edit-site-add-new-template__template-icon", children: /* @__PURE__ */ (0, import_jsx_runtime283.jsx)(import_components165.Icon, { icon }) }), 44446 /* @__PURE__ */ (0, import_jsx_runtime283.jsxs)( 44447 import_components165.__experimentalVStack, 44448 { 44449 className: "edit-site-add-new-template__template-name", 44450 alignment: "center", 44451 spacing: 0, 44452 children: [ 44453 /* @__PURE__ */ (0, import_jsx_runtime283.jsx)( 44454 import_components165.__experimentalText, 44455 { 44456 align: "center", 44457 weight: 500, 44458 lineHeight: 1.53846153846, 44459 children: title 44460 } 44461 ), 44462 children 44463 ] 44464 } 44465 ) 44466 ] 44467 } 44468 ) 44469 } 44470 ); 44471 } 44472 var modalContentMap2 = { 44473 templatesList: 1, 44474 customTemplate: 2, 44475 customGenericTemplate: 3 44476 }; 44477 function NewTemplateModal2({ onClose }) { 44478 const [modalContent, setModalContent] = (0, import_element145.useState)( 44479 modalContentMap2.templatesList 44480 ); 44481 const [entityForSuggestions, setEntityForSuggestions] = (0, import_element145.useState)({}); 44482 const [isSubmitting, setIsSubmitting] = (0, import_element145.useState)(false); 44483 const missingTemplates = useMissingTemplates2( 44484 setEntityForSuggestions, 44485 () => setModalContent(modalContentMap2.customTemplate) 44486 ); 44487 const history = useHistory23(); 44488 const { saveEntityRecord } = (0, import_data75.useDispatch)(import_core_data57.store); 44489 const { createErrorNotice, createSuccessNotice } = (0, import_data75.useDispatch)(import_notices9.store); 44490 const containerRef = (0, import_element145.useRef)(null); 44491 const isMobile = (0, import_compose29.useViewportMatch)("medium", "<"); 44492 const homeUrl = (0, import_data75.useSelect)((select3) => { 44493 return select3(import_core_data57.store).getEntityRecord("root", "__unstableBase")?.home; 44494 }, []); 44495 const TEMPLATE_SHORT_DESCRIPTIONS = { 44496 "front-page": homeUrl, 44497 date: (0, import_i18n148.sprintf)( 44498 // translators: %s: The homepage url. 44499 (0, import_i18n148.__)("E.g. %s"), 44500 homeUrl + "/" + (/* @__PURE__ */ new Date()).getFullYear() 44501 ) 44502 }; 44503 (0, import_element145.useEffect)(() => { 44504 if (containerRef.current && modalContent === modalContentMap2.templatesList) { 44505 const [firstFocusable] = import_dom15.focus.focusable.find( 44506 containerRef.current 44507 ); 44508 firstFocusable?.focus(); 44509 } 44510 }, [modalContent]); 44511 async function createTemplate(template, isWPSuggestion = true) { 44512 if (isSubmitting) { 44513 return; 44514 } 44515 setIsSubmitting(true); 44516 try { 44517 const { title, description, slug } = template; 44518 const newTemplate = await saveEntityRecord( 44519 "postType", 44520 TEMPLATE_POST_TYPE, 44521 { 44522 description, 44523 // Slugs need to be strings, so this is for template `404` 44524 slug: slug.toString(), 44525 status: "publish", 44526 title, 44527 // This adds a post meta field in template that is part of `is_custom` value calculation. 44528 is_wp_suggestion: isWPSuggestion 44529 }, 44530 { throwOnError: true } 44531 ); 44532 history.navigate( 44533 `/$TEMPLATE_POST_TYPE}/$newTemplate.id}?canvas=edit` 44534 ); 44535 createSuccessNotice( 44536 (0, import_i18n148.sprintf)( 44537 // translators: %s: Title of the created post or template, e.g: "Hello world". 44538 (0, import_i18n148.__)('"%s" successfully created.'), 44539 (0, import_html_entities17.decodeEntities)(newTemplate.title?.rendered || title) || (0, import_i18n148.__)("(no title)") 44540 ), 44541 { 44542 type: "snackbar" 44543 } 44544 ); 44545 } catch (error) { 44546 const errorMessage = error.message && error.code !== "unknown_error" ? error.message : (0, import_i18n148.__)("An error occurred while creating the template."); 44547 createErrorNotice(errorMessage, { 44548 type: "snackbar" 44549 }); 44550 } finally { 44551 setIsSubmitting(false); 44552 } 44553 } 44554 const onModalClose = () => { 44555 onClose(); 44556 setModalContent(modalContentMap2.templatesList); 44557 }; 44558 let modalTitle = (0, import_i18n148.__)("Add template"); 44559 if (modalContent === modalContentMap2.customTemplate) { 44560 modalTitle = (0, import_i18n148.sprintf)( 44561 // translators: %s: Name of the post type e.g: "Post". 44562 (0, import_i18n148.__)("Add template: %s"), 44563 entityForSuggestions.labels.singular_name 44564 ); 44565 } else if (modalContent === modalContentMap2.customGenericTemplate) { 44566 modalTitle = (0, import_i18n148.__)("Create custom template"); 44567 } 44568 return /* @__PURE__ */ (0, import_jsx_runtime283.jsxs)( 44569 import_components165.Modal, 44570 { 44571 title: modalTitle, 44572 className: clsx_default("edit-site-add-new-template__modal", { 44573 "edit-site-add-new-template__modal_template_list": modalContent === modalContentMap2.templatesList, 44574 "edit-site-custom-template-modal": modalContent === modalContentMap2.customTemplate 44575 }), 44576 onRequestClose: onModalClose, 44577 overlayClassName: modalContent === modalContentMap2.customGenericTemplate ? "edit-site-custom-generic-template__modal" : void 0, 44578 ref: containerRef, 44579 children: [ 44580 modalContent === modalContentMap2.templatesList && /* @__PURE__ */ (0, import_jsx_runtime283.jsxs)( 44581 import_components165.__experimentalGrid, 44582 { 44583 columns: isMobile ? 2 : 3, 44584 gap: 4, 44585 align: "flex-start", 44586 justify: "center", 44587 className: "edit-site-add-new-template__template-list__contents", 44588 children: [ 44589 /* @__PURE__ */ (0, import_jsx_runtime283.jsx)(import_components165.Flex, { className: "edit-site-add-new-template__template-list__prompt", children: (0, import_i18n148.__)( 44590 "Select what the new template should apply to:" 44591 ) }), 44592 missingTemplates.map((template) => { 44593 const { title, slug, onClick } = template; 44594 return /* @__PURE__ */ (0, import_jsx_runtime283.jsx)( 44595 TemplateListItem2, 44596 { 44597 title, 44598 direction: "column", 44599 className: "edit-site-add-new-template__template-button", 44600 description: TEMPLATE_SHORT_DESCRIPTIONS[slug], 44601 icon: TEMPLATE_ICONS2[slug] || layout_default, 44602 onClick: () => onClick ? onClick(template) : createTemplate(template) 44603 }, 44604 slug 44605 ); 44606 }), 44607 /* @__PURE__ */ (0, import_jsx_runtime283.jsx)( 44608 TemplateListItem2, 44609 { 44610 title: (0, import_i18n148.__)("Custom template"), 44611 direction: "row", 44612 className: "edit-site-add-new-template__custom-template-button", 44613 icon: pencil_default, 44614 onClick: () => setModalContent( 44615 modalContentMap2.customGenericTemplate 44616 ), 44617 children: /* @__PURE__ */ (0, import_jsx_runtime283.jsx)( 44618 import_components165.__experimentalText, 44619 { 44620 lineHeight: 1.53846153846, 44621 children: (0, import_i18n148.__)( 44622 "A custom template can be manually applied to any post or page." 44623 ) 44624 } 44625 ) 44626 } 44627 ) 44628 ] 44629 } 44630 ), 44631 modalContent === modalContentMap2.customTemplate && /* @__PURE__ */ (0, import_jsx_runtime283.jsx)( 44632 add_custom_template_modal_content_default2, 44633 { 44634 onSelect: createTemplate, 44635 entityForSuggestions, 44636 onBack: () => setModalContent(modalContentMap2.templatesList), 44637 containerRef 44638 } 44639 ), 44640 modalContent === modalContentMap2.customGenericTemplate && /* @__PURE__ */ (0, import_jsx_runtime283.jsx)( 44641 add_custom_generic_template_modal_content_default2, 44642 { 44643 createTemplate, 44644 onBack: () => setModalContent(modalContentMap2.templatesList) 44645 } 44646 ) 44647 ] 44648 } 44649 ); 44650 } 44651 function NewTemplate2() { 44652 const [showModal, setShowModal] = (0, import_element145.useState)(false); 44653 const { postType: postType2 } = (0, import_data75.useSelect)((select3) => { 44654 const { getPostType: getPostType2 } = select3(import_core_data57.store); 44655 return { 44656 postType: getPostType2(TEMPLATE_POST_TYPE) 44657 }; 44658 }, []); 44659 if (!postType2) { 44660 return null; 44661 } 44662 return /* @__PURE__ */ (0, import_jsx_runtime283.jsxs)(import_jsx_runtime283.Fragment, { children: [ 44663 /* @__PURE__ */ (0, import_jsx_runtime283.jsx)( 44664 import_components165.Button, 44665 { 44666 variant: "primary", 44667 onClick: () => setShowModal(true), 44668 label: postType2.labels.add_new_item, 44669 __next40pxDefaultSize: true, 44670 children: postType2.labels.add_new_item 44671 } 44672 ), 44673 showModal && /* @__PURE__ */ (0, import_jsx_runtime283.jsx)(NewTemplateModal2, { onClose: () => setShowModal(false) }) 44674 ] }); 44675 } 44676 function useMissingTemplates2(setEntityForSuggestions, onClick) { 44677 const existingTemplates = useExistingTemplates2(); 44678 const defaultTemplateTypes = useDefaultTemplateTypes2(); 44679 const existingTemplateSlugs = (existingTemplates || []).map( 44680 ({ slug }) => slug 44681 ); 44682 const missingDefaultTemplates = (defaultTemplateTypes || []).filter( 44683 (template) => DEFAULT_TEMPLATE_SLUGS2.includes(template.slug) && !existingTemplateSlugs.includes(template.slug) 44684 ); 44685 const onClickMenuItem = (_entityForSuggestions) => { 44686 onClick?.(); 44687 setEntityForSuggestions(_entityForSuggestions); 44688 }; 44689 const enhancedMissingDefaultTemplateTypes = [...missingDefaultTemplates]; 44690 const { defaultTaxonomiesMenuItems, taxonomiesMenuItems } = useTaxonomiesMenuItems2(onClickMenuItem); 44691 const { defaultPostTypesMenuItems, postTypesMenuItems } = usePostTypeMenuItems2(onClickMenuItem); 44692 const authorMenuItem = useAuthorMenuItem2(onClickMenuItem); 44693 [ 44694 ...defaultTaxonomiesMenuItems, 44695 ...defaultPostTypesMenuItems, 44696 authorMenuItem 44697 ].forEach((menuItem) => { 44698 if (!menuItem) { 44699 return; 44700 } 44701 const matchIndex = enhancedMissingDefaultTemplateTypes.findIndex( 44702 (template) => template.slug === menuItem.slug 44703 ); 44704 if (matchIndex > -1) { 44705 enhancedMissingDefaultTemplateTypes[matchIndex] = menuItem; 44706 } else { 44707 enhancedMissingDefaultTemplateTypes.push(menuItem); 44708 } 44709 }); 44710 enhancedMissingDefaultTemplateTypes?.sort((template1, template2) => { 44711 return DEFAULT_TEMPLATE_SLUGS2.indexOf(template1.slug) - DEFAULT_TEMPLATE_SLUGS2.indexOf(template2.slug); 44712 }); 44713 const missingTemplates = [ 44714 ...enhancedMissingDefaultTemplateTypes, 44715 ...usePostTypeArchiveMenuItems2(), 44716 ...postTypesMenuItems, 44717 ...taxonomiesMenuItems 44718 ]; 44719 return missingTemplates; 44720 } 44721 var add_new_template_legacy_default = (0, import_element145.memo)(NewTemplate2); 44722 44723 // packages/edit-site/build-module/components/page-templates/index-legacy.js 44724 var import_jsx_runtime284 = __toESM(require_jsx_runtime()); 44725 var { usePostActions: usePostActions3, templateTitleField: templateTitleField2 } = unlock(import_editor35.privateApis); 44726 var { useHistory: useHistory24, useLocation: useLocation29 } = unlock(import_router36.privateApis); 44727 var { useEntityRecordsWithPermissions: useEntityRecordsWithPermissions3 } = unlock(import_core_data58.privateApis); 44728 function PageTemplates2() { 44729 const { path, query } = useLocation29(); 44730 const { activeView = "active", postId } = query; 44731 const [selection, setSelection] = (0, import_element146.useState)([postId]); 44732 const defaultView = (0, import_element146.useMemo)(() => { 44733 return getDefaultView(activeView); 44734 }, [activeView]); 44735 const { view, updateView, isModified, resetToDefault } = useView({ 44736 kind: "postType", 44737 name: TEMPLATE_POST_TYPE, 44738 slug: activeView, 44739 defaultView, 44740 queryParams: { 44741 page: query.pageNumber, 44742 search: query.search 44743 }, 44744 onChangeQueryParams: (newQueryParams) => { 44745 history.navigate( 44746 (0, import_url24.addQueryArgs)(path, { 44747 ...query, 44748 pageNumber: newQueryParams.page, 44749 search: newQueryParams.search || void 0 44750 }) 44751 ); 44752 } 44753 }); 44754 const { records, isResolving: isLoadingData } = useEntityRecordsWithPermissions3("postType", TEMPLATE_POST_TYPE, { 44755 per_page: -1 44756 }); 44757 const history = useHistory24(); 44758 const onChangeSelection = (0, import_element146.useCallback)( 44759 (items) => { 44760 setSelection(items); 44761 if (view?.type === "list") { 44762 history.navigate( 44763 (0, import_url24.addQueryArgs)(path, { 44764 postId: items.length === 1 ? items[0] : void 0 44765 }) 44766 ); 44767 } 44768 }, 44769 [history, path, view?.type] 44770 ); 44771 const authors = (0, import_element146.useMemo)(() => { 44772 if (!records) { 44773 return []; 44774 } 44775 const authorsSet = /* @__PURE__ */ new Set(); 44776 records.forEach((template) => { 44777 authorsSet.add(template.author_text); 44778 }); 44779 return Array.from(authorsSet).map((author) => ({ 44780 value: author, 44781 label: author 44782 })); 44783 }, [records]); 44784 const fields = (0, import_element146.useMemo)( 44785 () => [ 44786 previewField2, 44787 templateTitleField2, 44788 descriptionField, 44789 { 44790 ...authorField, 44791 elements: authors 44792 } 44793 ], 44794 [authors] 44795 ); 44796 const { data, paginationInfo } = (0, import_element146.useMemo)(() => { 44797 return filterSortAndPaginate(records, view, fields); 44798 }, [records, view, fields]); 44799 const postTypeActions = usePostActions3({ 44800 postType: TEMPLATE_POST_TYPE, 44801 context: "list" 44802 }); 44803 const editAction = useEditPostAction(); 44804 const actions = (0, import_element146.useMemo)( 44805 () => [editAction, ...postTypeActions], 44806 [postTypeActions, editAction] 44807 ); 44808 const onChangeView = (0, import_compose30.useEvent)((newView) => { 44809 if (newView.type !== view.type) { 44810 history.invalidate(); 44811 } 44812 updateView(newView); 44813 }); 44814 return /* @__PURE__ */ (0, import_jsx_runtime284.jsx)( 44815 page_default, 44816 { 44817 className: "edit-site-page-templates", 44818 title: (0, import_i18n149.__)("Templates"), 44819 actions: /* @__PURE__ */ (0, import_jsx_runtime284.jsxs)(import_jsx_runtime284.Fragment, { children: [ 44820 isModified && /* @__PURE__ */ (0, import_jsx_runtime284.jsx)( 44821 import_components166.Button, 44822 { 44823 __next40pxDefaultSize: true, 44824 onClick: () => { 44825 resetToDefault(); 44826 history.invalidate(); 44827 }, 44828 children: (0, import_i18n149.__)("Reset view") 44829 } 44830 ), 44831 /* @__PURE__ */ (0, import_jsx_runtime284.jsx)(add_new_template_legacy_default, {}) 44832 ] }), 44833 children: /* @__PURE__ */ (0, import_jsx_runtime284.jsx)( 44834 dataviews_default, 44835 { 44836 paginationInfo, 44837 fields, 44838 actions, 44839 data, 44840 isLoading: isLoadingData, 44841 view, 44842 onChangeView, 44843 onChangeSelection, 44844 isItemClickable: () => true, 44845 onClickItem: ({ id }) => { 44846 history.navigate(`/wp_template/$id}?canvas=edit`); 44847 }, 44848 selection, 44849 defaultLayouts: defaultLayouts2 44850 }, 44851 activeView 44852 ) 44853 } 44854 ); 44855 } 44856 44857 // packages/edit-site/build-module/components/site-editor-routes/templates.js 44858 var import_jsx_runtime285 = __toESM(require_jsx_runtime()); 44859 async function isTemplateListView(query) { 44860 const { activeView = "active" } = query; 44861 const view = await loadView({ 44862 kind: "postType", 44863 name: "wp_template", 44864 slug: activeView, 44865 defaultView: getDefaultView(activeView) 44866 }); 44867 return view.type === "list"; 44868 } 44869 var templatesRoute = { 44870 name: "templates", 44871 path: "/template", 44872 areas: { 44873 sidebar({ siteData }) { 44874 const isBlockTheme = siteData.currentTheme?.is_block_theme; 44875 return isBlockTheme ? /* @__PURE__ */ (0, import_jsx_runtime285.jsx)(SidebarNavigationScreenTemplatesBrowse, { backPath: "/" }) : /* @__PURE__ */ (0, import_jsx_runtime285.jsx)(SidebarNavigationScreenUnsupported, {}); 44876 }, 44877 content({ siteData }) { 44878 const isBlockTheme = siteData.currentTheme?.is_block_theme; 44879 if (!isBlockTheme) { 44880 return void 0; 44881 } 44882 return window?.__experimentalTemplateActivate ? /* @__PURE__ */ (0, import_jsx_runtime285.jsx)(PageTemplates, {}) : /* @__PURE__ */ (0, import_jsx_runtime285.jsx)(PageTemplates2, {}); 44883 }, 44884 async preview({ query, siteData }) { 44885 const isBlockTheme = siteData.currentTheme?.is_block_theme; 44886 if (!isBlockTheme) { 44887 return void 0; 44888 } 44889 const isListView2 = await isTemplateListView(query); 44890 return isListView2 ? /* @__PURE__ */ (0, import_jsx_runtime285.jsx)(EditSiteEditor, {}) : void 0; 44891 }, 44892 mobile({ siteData }) { 44893 const isBlockTheme = siteData.currentTheme?.is_block_theme; 44894 if (!isBlockTheme) { 44895 return /* @__PURE__ */ (0, import_jsx_runtime285.jsx)(SidebarNavigationScreenUnsupported, {}); 44896 } 44897 const isTemplateActivateEnabled = typeof window !== "undefined" && window.__experimentalTemplateActivate; 44898 return isTemplateActivateEnabled ? /* @__PURE__ */ (0, import_jsx_runtime285.jsx)(PageTemplates, {}) : /* @__PURE__ */ (0, import_jsx_runtime285.jsx)(PageTemplates2, {}); 44899 } 44900 }, 44901 widths: { 44902 async content({ query }) { 44903 const isListView2 = await isTemplateListView(query); 44904 return isListView2 ? 380 : void 0; 44905 } 44906 } 44907 }; 44908 44909 // packages/edit-site/build-module/components/site-editor-routes/template-item.js 44910 var import_jsx_runtime286 = __toESM(require_jsx_runtime()); 44911 var areas = { 44912 sidebar({ siteData }) { 44913 const isBlockTheme = siteData.currentTheme?.is_block_theme; 44914 return isBlockTheme ? /* @__PURE__ */ (0, import_jsx_runtime286.jsx)(SidebarNavigationScreenTemplatesBrowse, { backPath: "/" }) : /* @__PURE__ */ (0, import_jsx_runtime286.jsx)(SidebarNavigationScreenUnsupported, {}); 44915 }, 44916 mobile({ siteData }) { 44917 const isBlockTheme = siteData.currentTheme?.is_block_theme; 44918 return isBlockTheme ? /* @__PURE__ */ (0, import_jsx_runtime286.jsx)(EditSiteEditor, {}) : /* @__PURE__ */ (0, import_jsx_runtime286.jsx)(SidebarNavigationScreenUnsupported, {}); 44919 }, 44920 preview({ siteData }) { 44921 const isBlockTheme = siteData.currentTheme?.is_block_theme; 44922 return isBlockTheme ? /* @__PURE__ */ (0, import_jsx_runtime286.jsx)(EditSiteEditor, {}) : /* @__PURE__ */ (0, import_jsx_runtime286.jsx)(SidebarNavigationScreenUnsupported, {}); 44923 } 44924 }; 44925 var templateItemRoute = { 44926 name: "template-item", 44927 path: "/wp_template/*postId", 44928 areas 44929 }; 44930 44931 // packages/edit-site/build-module/components/site-editor-routes/pages.js 44932 var import_router40 = __toESM(require_router()); 44933 var import_i18n154 = __toESM(require_i18n()); 44934 var import_data80 = __toESM(require_data()); 44935 var import_core_data64 = __toESM(require_core_data()); 44936 44937 // packages/edit-site/build-module/components/sidebar-dataviews/index.js 44938 var import_components168 = __toESM(require_components()); 44939 var import_router38 = __toESM(require_router()); 44940 var import_data76 = __toESM(require_data()); 44941 var import_core_data59 = __toESM(require_core_data()); 44942 var import_element147 = __toESM(require_element()); 44943 44944 // packages/edit-site/build-module/components/sidebar-dataviews/dataview-item.js 44945 var import_router37 = __toESM(require_router()); 44946 var import_components167 = __toESM(require_components()); 44947 var import_url25 = __toESM(require_url()); 44948 var import_jsx_runtime287 = __toESM(require_jsx_runtime()); 44949 var { useLocation: useLocation30 } = unlock(import_router37.privateApis); 44950 function DataViewItem({ 44951 title, 44952 slug, 44953 type, 44954 icon, 44955 isActive, 44956 suffix 44957 }) { 44958 const { path } = useLocation30(); 44959 const iconToUse = icon || VIEW_LAYOUTS.find((v2) => v2.type === type).icon; 44960 if (slug === "all") { 44961 slug = void 0; 44962 } 44963 return /* @__PURE__ */ (0, import_jsx_runtime287.jsxs)( 44964 import_components167.__experimentalHStack, 44965 { 44966 justify: "flex-start", 44967 className: clsx_default("edit-site-sidebar-dataviews-dataview-item", { 44968 "is-selected": isActive 44969 }), 44970 children: [ 44971 /* @__PURE__ */ (0, import_jsx_runtime287.jsx)( 44972 SidebarNavigationItem, 44973 { 44974 icon: iconToUse, 44975 to: (0, import_url25.addQueryArgs)(path, { 44976 activeView: slug 44977 }), 44978 "aria-current": isActive ? "true" : void 0, 44979 children: title 44980 } 44981 ), 44982 suffix 44983 ] 44984 } 44985 ); 44986 } 44987 44988 // packages/edit-site/build-module/components/post-list/view-utils.js 44989 var import_i18n150 = __toESM(require_i18n()); 44990 var defaultLayouts3 = { 44991 table: {}, 44992 grid: {}, 44993 list: {} 44994 }; 44995 var DEFAULT_POST_BASE = { 44996 type: "list", 44997 filters: [], 44998 perPage: 20, 44999 sort: { 45000 field: "title", 45001 direction: "asc" 45002 }, 45003 showLevels: true, 45004 titleField: "title", 45005 mediaField: "featured_media", 45006 fields: ["author", "status"], 45007 ...defaultLayouts3.list 45008 }; 45009 function getDefaultViews(postType2) { 45010 return [ 45011 { 45012 title: postType2?.labels?.all_items || (0, import_i18n150.__)("All items"), 45013 slug: "all", 45014 icon: pages_default, 45015 view: DEFAULT_POST_BASE 45016 }, 45017 { 45018 title: (0, import_i18n150.__)("Published"), 45019 slug: "published", 45020 icon: published_default, 45021 view: { 45022 ...DEFAULT_POST_BASE, 45023 filters: [ 45024 { 45025 field: "status", 45026 operator: OPERATOR_IS_ANY, 45027 value: "publish", 45028 isLocked: true 45029 } 45030 ] 45031 } 45032 }, 45033 { 45034 title: (0, import_i18n150.__)("Scheduled"), 45035 slug: "future", 45036 icon: scheduled_default, 45037 view: { 45038 ...DEFAULT_POST_BASE, 45039 filters: [ 45040 { 45041 field: "status", 45042 operator: OPERATOR_IS_ANY, 45043 value: "future", 45044 isLocked: true 45045 } 45046 ] 45047 } 45048 }, 45049 { 45050 title: (0, import_i18n150.__)("Drafts"), 45051 slug: "drafts", 45052 icon: drafts_default, 45053 view: { 45054 ...DEFAULT_POST_BASE, 45055 filters: [ 45056 { 45057 field: "status", 45058 operator: OPERATOR_IS_ANY, 45059 value: "draft", 45060 isLocked: true 45061 } 45062 ] 45063 } 45064 }, 45065 { 45066 title: (0, import_i18n150.__)("Pending"), 45067 slug: "pending", 45068 icon: pending_default, 45069 view: { 45070 ...DEFAULT_POST_BASE, 45071 filters: [ 45072 { 45073 field: "status", 45074 operator: OPERATOR_IS_ANY, 45075 value: "pending", 45076 isLocked: true 45077 } 45078 ] 45079 } 45080 }, 45081 { 45082 title: (0, import_i18n150.__)("Private"), 45083 slug: "private", 45084 icon: not_allowed_default, 45085 view: { 45086 ...DEFAULT_POST_BASE, 45087 filters: [ 45088 { 45089 field: "status", 45090 operator: OPERATOR_IS_ANY, 45091 value: "private", 45092 isLocked: true 45093 } 45094 ] 45095 } 45096 }, 45097 { 45098 title: (0, import_i18n150.__)("Trash"), 45099 slug: "trash", 45100 icon: trash_default, 45101 view: { 45102 ...DEFAULT_POST_BASE, 45103 type: "table", 45104 layout: defaultLayouts3.table.layout, 45105 filters: [ 45106 { 45107 field: "status", 45108 operator: OPERATOR_IS_ANY, 45109 value: "trash", 45110 isLocked: true 45111 } 45112 ] 45113 } 45114 } 45115 ]; 45116 } 45117 var getDefaultView2 = (postType2, activeView) => { 45118 return getDefaultViews(postType2).find( 45119 ({ slug }) => slug === activeView 45120 )?.view; 45121 }; 45122 45123 // packages/edit-site/build-module/components/sidebar-dataviews/index.js 45124 var import_jsx_runtime288 = __toESM(require_jsx_runtime()); 45125 var { useLocation: useLocation31 } = unlock(import_router38.privateApis); 45126 function DataViewsSidebarContent({ postType: postType2 }) { 45127 const { 45128 query: { activeView = "all" } 45129 } = useLocation31(); 45130 const postTypeObject = (0, import_data76.useSelect)( 45131 (select3) => { 45132 const { getPostType: getPostType2 } = select3(import_core_data59.store); 45133 return getPostType2(postType2); 45134 }, 45135 [postType2] 45136 ); 45137 const defaultViews = (0, import_element147.useMemo)( 45138 () => getDefaultViews(postTypeObject), 45139 [postTypeObject] 45140 ); 45141 if (!postType2) { 45142 return null; 45143 } 45144 return /* @__PURE__ */ (0, import_jsx_runtime288.jsx)(import_jsx_runtime288.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime288.jsx)(import_components168.__experimentalItemGroup, { className: "edit-site-sidebar-dataviews", children: defaultViews.map((dataview) => { 45145 return /* @__PURE__ */ (0, import_jsx_runtime288.jsx)( 45146 DataViewItem, 45147 { 45148 slug: dataview.slug, 45149 title: dataview.title, 45150 icon: dataview.icon, 45151 type: dataview.view.type, 45152 isActive: dataview.slug === activeView 45153 }, 45154 dataview.slug 45155 ); 45156 }) }) }); 45157 } 45158 45159 // packages/edit-site/build-module/components/post-list/index.js 45160 var import_components170 = __toESM(require_components()); 45161 var import_core_data62 = __toESM(require_core_data()); 45162 var import_element150 = __toESM(require_element()); 45163 var import_router39 = __toESM(require_router()); 45164 var import_data78 = __toESM(require_data()); 45165 var import_editor38 = __toESM(require_editor()); 45166 var import_i18n152 = __toESM(require_i18n()); 45167 var import_compose31 = __toESM(require_compose()); 45168 var import_url26 = __toESM(require_url()); 45169 45170 // packages/edit-site/build-module/components/add-new-post/index.js 45171 var import_components169 = __toESM(require_components()); 45172 var import_i18n151 = __toESM(require_i18n()); 45173 var import_data77 = __toESM(require_data()); 45174 var import_element148 = __toESM(require_element()); 45175 var import_core_data60 = __toESM(require_core_data()); 45176 var import_notices10 = __toESM(require_notices()); 45177 var import_html_entities18 = __toESM(require_html_entities()); 45178 var import_blocks14 = __toESM(require_blocks()); 45179 var import_jsx_runtime289 = __toESM(require_jsx_runtime()); 45180 function AddNewPostModal({ postType: postType2, onSave, onClose }) { 45181 const labels = (0, import_data77.useSelect)( 45182 (select3) => select3(import_core_data60.store).getPostType(postType2)?.labels, 45183 [postType2] 45184 ); 45185 const [isCreatingPost, setIsCreatingPost] = (0, import_element148.useState)(false); 45186 const [title, setTitle] = (0, import_element148.useState)(""); 45187 const { saveEntityRecord } = (0, import_data77.useDispatch)(import_core_data60.store); 45188 const { createErrorNotice, createSuccessNotice } = (0, import_data77.useDispatch)(import_notices10.store); 45189 const { resolveSelect: resolveSelect3 } = (0, import_data77.useRegistry)(); 45190 async function createPost(event) { 45191 event.preventDefault(); 45192 if (isCreatingPost) { 45193 return; 45194 } 45195 setIsCreatingPost(true); 45196 try { 45197 const postTypeObject = await resolveSelect3(import_core_data60.store).getPostType(postType2); 45198 const newPage = await saveEntityRecord( 45199 "postType", 45200 postType2, 45201 { 45202 status: "draft", 45203 title, 45204 slug: title ?? void 0, 45205 content: !!postTypeObject.template && postTypeObject.template.length ? (0, import_blocks14.serialize)( 45206 (0, import_blocks14.synchronizeBlocksWithTemplate)( 45207 [], 45208 postTypeObject.template 45209 ) 45210 ) : void 0 45211 }, 45212 { throwOnError: true } 45213 ); 45214 onSave(newPage); 45215 createSuccessNotice( 45216 (0, import_i18n151.sprintf)( 45217 // translators: %s: Title of the created post or template, e.g: "Hello world". 45218 (0, import_i18n151.__)('"%s" successfully created.'), 45219 (0, import_html_entities18.decodeEntities)(newPage.title?.rendered || title) || (0, import_i18n151.__)("(no title)") 45220 ), 45221 { type: "snackbar" } 45222 ); 45223 } catch (error) { 45224 const errorMessage = error.message && error.code !== "unknown_error" ? error.message : (0, import_i18n151.__)("An error occurred while creating the item."); 45225 createErrorNotice(errorMessage, { 45226 type: "snackbar" 45227 }); 45228 } finally { 45229 setIsCreatingPost(false); 45230 } 45231 } 45232 return /* @__PURE__ */ (0, import_jsx_runtime289.jsx)( 45233 import_components169.Modal, 45234 { 45235 title: ( 45236 // translators: %s: post type singular_name label e.g: "Page". 45237 (0, import_i18n151.sprintf)((0, import_i18n151.__)("Draft new: %s"), labels?.singular_name) 45238 ), 45239 onRequestClose: onClose, 45240 focusOnMount: "firstContentElement", 45241 size: "small", 45242 children: /* @__PURE__ */ (0, import_jsx_runtime289.jsx)("form", { onSubmit: createPost, children: /* @__PURE__ */ (0, import_jsx_runtime289.jsxs)(import_components169.__experimentalVStack, { spacing: 4, children: [ 45243 /* @__PURE__ */ (0, import_jsx_runtime289.jsx)( 45244 import_components169.TextControl, 45245 { 45246 __next40pxDefaultSize: true, 45247 label: (0, import_i18n151.__)("Title"), 45248 onChange: setTitle, 45249 placeholder: (0, import_i18n151.__)("No title"), 45250 value: title 45251 } 45252 ), 45253 /* @__PURE__ */ (0, import_jsx_runtime289.jsxs)(import_components169.__experimentalHStack, { spacing: 2, justify: "end", children: [ 45254 /* @__PURE__ */ (0, import_jsx_runtime289.jsx)( 45255 import_components169.Button, 45256 { 45257 __next40pxDefaultSize: true, 45258 variant: "tertiary", 45259 onClick: onClose, 45260 children: (0, import_i18n151.__)("Cancel") 45261 } 45262 ), 45263 /* @__PURE__ */ (0, import_jsx_runtime289.jsx)( 45264 import_components169.Button, 45265 { 45266 __next40pxDefaultSize: true, 45267 variant: "primary", 45268 type: "submit", 45269 isBusy: isCreatingPost, 45270 "aria-disabled": isCreatingPost, 45271 children: (0, import_i18n151.__)("Create draft") 45272 } 45273 ) 45274 ] }) 45275 ] }) }) 45276 } 45277 ); 45278 } 45279 45280 // packages/edit-site/build-module/components/post-list/use-notes-count.js 45281 var import_element149 = __toESM(require_element()); 45282 var import_core_data61 = __toESM(require_core_data()); 45283 function useNotesCount(postIds) { 45284 const { records: notes, isResolving } = (0, import_core_data61.useEntityRecords)( 45285 "root", 45286 "comment", 45287 { 45288 post: postIds, 45289 type: "note", 45290 status: "all", 45291 per_page: -1, 45292 _fields: "id,post" 45293 }, 45294 { 45295 enabled: postIds?.length > 0 45296 } 45297 ); 45298 const notesCount = (0, import_element149.useMemo)(() => { 45299 if (!notes || notes.length === 0) { 45300 return {}; 45301 } 45302 const counts = {}; 45303 notes.forEach((note) => { 45304 const postId = note.post; 45305 counts[postId] = (counts[postId] || 0) + 1; 45306 }); 45307 return counts; 45308 }, [notes]); 45309 return { notesCount, isResolving }; 45310 } 45311 45312 // packages/edit-site/build-module/components/post-list/index.js 45313 var import_jsx_runtime290 = __toESM(require_jsx_runtime()); 45314 var { usePostActions: usePostActions4, usePostFields: usePostFields2 } = unlock(import_editor38.privateApis); 45315 var { useLocation: useLocation32, useHistory: useHistory25 } = unlock(import_router39.privateApis); 45316 var { useEntityRecordsWithPermissions: useEntityRecordsWithPermissions4 } = unlock(import_core_data62.privateApis); 45317 var EMPTY_ARRAY15 = []; 45318 var DEFAULT_STATUSES = "draft,future,pending,private,publish"; 45319 function getItemId(item) { 45320 return item.id.toString(); 45321 } 45322 function getItemLevel(item) { 45323 return item.level; 45324 } 45325 function PostList({ postType: postType2 }) { 45326 const { path, query } = useLocation32(); 45327 const { activeView = "all", postId, quickEdit = false } = query; 45328 const history = useHistory25(); 45329 const postTypeObject = (0, import_data78.useSelect)( 45330 (select3) => { 45331 const { getPostType: getPostType2 } = select3(import_core_data62.store); 45332 return getPostType2(postType2); 45333 }, 45334 [postType2] 45335 ); 45336 const { view, updateView, isModified, resetToDefault } = useView({ 45337 kind: "postType", 45338 name: postType2, 45339 slug: activeView, 45340 queryParams: { 45341 page: query.pageNumber, 45342 search: query.search 45343 }, 45344 onChangeQueryParams: (newQueryParams) => { 45345 history.navigate( 45346 (0, import_url26.addQueryArgs)(path, { 45347 ...query, 45348 pageNumber: newQueryParams.page, 45349 search: newQueryParams.search || void 0 45350 }) 45351 ); 45352 }, 45353 defaultView: getDefaultView2(postTypeObject, activeView) 45354 }); 45355 const onChangeView = (0, import_compose31.useEvent)((newView) => { 45356 if (newView.type !== view.type) { 45357 history.invalidate(); 45358 } 45359 updateView(newView); 45360 }); 45361 const [selection, setSelection] = (0, import_element150.useState)(postId?.split(",") ?? []); 45362 const onChangeSelection = (0, import_element150.useCallback)( 45363 (items) => { 45364 setSelection(items); 45365 history.navigate( 45366 (0, import_url26.addQueryArgs)(path, { 45367 postId: items.join(",") 45368 }) 45369 ); 45370 }, 45371 [path, history] 45372 ); 45373 const fields = usePostFields2({ 45374 postType: postType2 45375 }); 45376 const queryArgs = (0, import_element150.useMemo)(() => { 45377 const filters = {}; 45378 view.filters?.forEach((filter) => { 45379 if (filter.field === "status" && filter.operator === OPERATOR_IS_ANY) { 45380 filters.status = filter.value; 45381 } 45382 if (filter.field === "author" && filter.operator === OPERATOR_IS_ANY) { 45383 filters.author = filter.value; 45384 } else if (filter.field === "author" && filter.operator === OPERATOR_IS_NONE) { 45385 filters.author_exclude = filter.value; 45386 } 45387 if (filter.field === "date") { 45388 if (!filter.value) { 45389 return; 45390 } 45391 if (filter.operator === OPERATOR_BEFORE) { 45392 filters.before = filter.value; 45393 } else if (filter.operator === OPERATOR_AFTER) { 45394 filters.after = filter.value; 45395 } 45396 } 45397 }); 45398 if (!filters.status || filters.status === "") { 45399 filters.status = DEFAULT_STATUSES; 45400 } 45401 return { 45402 per_page: view.perPage, 45403 page: view.page, 45404 _embed: "author,wp:featuredmedia", 45405 order: view.sort?.direction, 45406 orderby: view.sort?.field, 45407 orderby_hierarchy: !!view.showLevels, 45408 search: view.search, 45409 ...filters 45410 }; 45411 }, [view]); 45412 const { 45413 records, 45414 isResolving: isLoadingData, 45415 totalItems, 45416 totalPages 45417 } = useEntityRecordsWithPermissions4("postType", postType2, queryArgs); 45418 const postIds = (0, import_element150.useMemo)( 45419 () => records?.map((record) => record.id) ?? [], 45420 [records] 45421 ); 45422 const { notesCount, isLoading: isLoadingNotesCount } = useNotesCount(postIds); 45423 const data = (0, import_element150.useMemo)(() => { 45424 let processedRecords = records; 45425 if (view?.sort?.field === "author") { 45426 processedRecords = filterSortAndPaginate( 45427 records, 45428 { sort: { ...view.sort } }, 45429 fields 45430 ).data; 45431 } 45432 if (processedRecords) { 45433 return processedRecords.map((record) => ({ 45434 ...record, 45435 notesCount: notesCount[record.id] ?? 0 45436 })); 45437 } 45438 return processedRecords; 45439 }, [records, fields, view?.sort, notesCount]); 45440 const ids = data?.map((record) => getItemId(record)) ?? []; 45441 const prevIds = (0, import_compose31.usePrevious)(ids) ?? []; 45442 const deletedIds = prevIds.filter((id) => !ids.includes(id)); 45443 const postIdWasDeleted = deletedIds.includes(postId); 45444 (0, import_element150.useEffect)(() => { 45445 if (postIdWasDeleted) { 45446 history.navigate( 45447 (0, import_url26.addQueryArgs)(path, { 45448 postId: void 0 45449 }) 45450 ); 45451 } 45452 }, [history, postIdWasDeleted, path]); 45453 const paginationInfo = (0, import_element150.useMemo)( 45454 () => ({ 45455 totalItems, 45456 totalPages 45457 }), 45458 [totalItems, totalPages] 45459 ); 45460 const { labels, canCreateRecord } = (0, import_data78.useSelect)( 45461 (select3) => { 45462 const { getPostType: getPostType2, canUser } = select3(import_core_data62.store); 45463 return { 45464 labels: getPostType2(postType2)?.labels, 45465 canCreateRecord: canUser("create", { 45466 kind: "postType", 45467 name: postType2 45468 }) 45469 }; 45470 }, 45471 [postType2] 45472 ); 45473 const postTypeActions = usePostActions4({ 45474 postType: postType2, 45475 context: "list" 45476 }); 45477 const editAction = useEditPostAction(); 45478 const actions = (0, import_element150.useMemo)( 45479 () => [editAction, ...postTypeActions], 45480 [postTypeActions, editAction] 45481 ); 45482 const [showAddPostModal, setShowAddPostModal] = (0, import_element150.useState)(false); 45483 const openModal = () => setShowAddPostModal(true); 45484 const closeModal = () => setShowAddPostModal(false); 45485 const handleNewPage = ({ type, id }) => { 45486 history.navigate(`/$type}/$id}?canvas=edit`); 45487 closeModal(); 45488 }; 45489 return /* @__PURE__ */ (0, import_jsx_runtime290.jsx)( 45490 page_default, 45491 { 45492 title: labels?.name, 45493 actions: /* @__PURE__ */ (0, import_jsx_runtime290.jsxs)(import_jsx_runtime290.Fragment, { children: [ 45494 isModified && /* @__PURE__ */ (0, import_jsx_runtime290.jsx)( 45495 import_components170.Button, 45496 { 45497 __next40pxDefaultSize: true, 45498 onClick: () => { 45499 resetToDefault(); 45500 history.invalidate(); 45501 }, 45502 children: (0, import_i18n152.__)("Reset view") 45503 } 45504 ), 45505 labels?.add_new_item && canCreateRecord && /* @__PURE__ */ (0, import_jsx_runtime290.jsxs)(import_jsx_runtime290.Fragment, { children: [ 45506 /* @__PURE__ */ (0, import_jsx_runtime290.jsx)( 45507 import_components170.Button, 45508 { 45509 variant: "primary", 45510 onClick: openModal, 45511 __next40pxDefaultSize: true, 45512 children: labels.add_new_item 45513 } 45514 ), 45515 showAddPostModal && /* @__PURE__ */ (0, import_jsx_runtime290.jsx)( 45516 AddNewPostModal, 45517 { 45518 postType: postType2, 45519 onSave: handleNewPage, 45520 onClose: closeModal 45521 } 45522 ) 45523 ] }) 45524 ] }), 45525 children: /* @__PURE__ */ (0, import_jsx_runtime290.jsx)( 45526 dataviews_default, 45527 { 45528 paginationInfo, 45529 fields, 45530 actions, 45531 data: data || EMPTY_ARRAY15, 45532 isLoading: isLoadingData || isLoadingNotesCount, 45533 view, 45534 onChangeView, 45535 selection, 45536 onChangeSelection, 45537 isItemClickable: (item) => item.status !== "trash", 45538 onClickItem: ({ id }) => { 45539 history.navigate(`/$postType2}/$id}?canvas=edit`); 45540 }, 45541 getItemId, 45542 getItemLevel, 45543 defaultLayouts: defaultLayouts3, 45544 header: window.__experimentalQuickEditDataViews && view.type !== LAYOUT_LIST && postType2 === "page" && /* @__PURE__ */ (0, import_jsx_runtime290.jsx)( 45545 import_components170.Button, 45546 { 45547 size: "compact", 45548 isPressed: quickEdit, 45549 icon: drawer_right_default, 45550 label: (0, import_i18n152.__)("Details"), 45551 onClick: () => { 45552 history.navigate( 45553 (0, import_url26.addQueryArgs)(path, { 45554 quickEdit: quickEdit ? void 0 : true 45555 }) 45556 ); 45557 } 45558 } 45559 ) 45560 }, 45561 activeView 45562 ) 45563 } 45564 ); 45565 } 45566 45567 // packages/edit-site/build-module/components/post-edit/index.js 45568 var import_i18n153 = __toESM(require_i18n()); 45569 var import_data79 = __toESM(require_data()); 45570 var import_core_data63 = __toESM(require_core_data()); 45571 var import_components171 = __toESM(require_components()); 45572 var import_element151 = __toESM(require_element()); 45573 var import_editor39 = __toESM(require_editor()); 45574 var import_block_editor26 = __toESM(require_block_editor()); 45575 var import_jsx_runtime291 = __toESM(require_jsx_runtime()); 45576 var { usePostFields: usePostFields3, PostCardPanel } = unlock(import_editor39.privateApis); 45577 var fieldsWithBulkEditSupport = [ 45578 "title", 45579 "status", 45580 "date", 45581 "author", 45582 "discussion" 45583 ]; 45584 function PostEditForm({ postType: postType2, postId }) { 45585 const ids = (0, import_element151.useMemo)(() => postId.split(","), [postId]); 45586 const { record, hasFinishedResolution } = (0, import_data79.useSelect)( 45587 (select3) => { 45588 const args = ["postType", postType2, ids[0]]; 45589 const { 45590 getEditedEntityRecord, 45591 hasFinishedResolution: hasFinished 45592 } = select3(import_core_data63.store); 45593 return { 45594 record: ids.length === 1 ? getEditedEntityRecord(...args) : null, 45595 hasFinishedResolution: hasFinished( 45596 "getEditedEntityRecord", 45597 args 45598 ) 45599 }; 45600 }, 45601 [postType2, ids] 45602 ); 45603 const [multiEdits, setMultiEdits] = (0, import_element151.useState)({}); 45604 const { editEntityRecord } = (0, import_data79.useDispatch)(import_core_data63.store); 45605 const _fields = usePostFields3({ postType: postType2 }); 45606 const fields = (0, import_element151.useMemo)( 45607 () => _fields?.map((field) => { 45608 if (field.id === "status") { 45609 return { 45610 ...field, 45611 elements: field.elements.filter( 45612 (element) => element.value !== "trash" 45613 ) 45614 }; 45615 } 45616 return field; 45617 }), 45618 [_fields] 45619 ); 45620 const form = (0, import_element151.useMemo)( 45621 () => ({ 45622 layout: { 45623 type: "panel" 45624 }, 45625 fields: [ 45626 { 45627 id: "featured_media", 45628 layout: { 45629 type: "regular" 45630 } 45631 }, 45632 { 45633 id: "status", 45634 label: (0, import_i18n153.__)("Status & Visibility"), 45635 children: ["status", "password"] 45636 }, 45637 "author", 45638 "date", 45639 "slug", 45640 "parent", 45641 { 45642 id: "discussion", 45643 label: (0, import_i18n153.__)("Discussion"), 45644 children: ["comment_status", "ping_status"] 45645 }, 45646 { 45647 label: (0, import_i18n153.__)("Template"), 45648 id: "template", 45649 layout: { 45650 type: "regular", 45651 labelPosition: "side" 45652 } 45653 } 45654 ].filter( 45655 (field) => ids.length === 1 || fieldsWithBulkEditSupport.includes( 45656 typeof field === "string" ? field : field.id 45657 ) 45658 ) 45659 }), 45660 [ids] 45661 ); 45662 const onChange = (edits) => { 45663 for (const id of ids) { 45664 if (edits.status && edits.status !== "future" && record?.status === "future" && new Date(record.date) > /* @__PURE__ */ new Date()) { 45665 edits.date = null; 45666 } 45667 if (edits.status && edits.status === "private" && record.password) { 45668 edits.password = ""; 45669 } 45670 editEntityRecord("postType", postType2, id, edits); 45671 if (ids.length > 1) { 45672 setMultiEdits((prev) => ({ 45673 ...prev, 45674 ...edits 45675 })); 45676 } 45677 } 45678 }; 45679 (0, import_element151.useEffect)(() => { 45680 setMultiEdits({}); 45681 }, [ids]); 45682 const { ExperimentalBlockEditorProvider: ExperimentalBlockEditorProvider2 } = unlock( 45683 import_block_editor26.privateApis 45684 ); 45685 const settings2 = usePatternSettings(); 45686 const fieldsWithDependency = (0, import_element151.useMemo)(() => { 45687 return fields.map((field) => { 45688 if (field.id === "template") { 45689 return { 45690 ...field, 45691 Edit: (data) => /* @__PURE__ */ (0, import_jsx_runtime291.jsx)(ExperimentalBlockEditorProvider2, { settings: settings2, children: /* @__PURE__ */ (0, import_jsx_runtime291.jsx)(field.Edit, { ...data }) }) 45692 }; 45693 } 45694 return field; 45695 }); 45696 }, [fields, settings2]); 45697 return /* @__PURE__ */ (0, import_jsx_runtime291.jsxs)(import_components171.__experimentalVStack, { spacing: 4, children: [ 45698 /* @__PURE__ */ (0, import_jsx_runtime291.jsx)(PostCardPanel, { postType: postType2, postId: ids }), 45699 hasFinishedResolution && /* @__PURE__ */ (0, import_jsx_runtime291.jsx)( 45700 DataForm, 45701 { 45702 data: ids.length === 1 ? record : multiEdits, 45703 fields: fieldsWithDependency, 45704 form, 45705 onChange 45706 } 45707 ) 45708 ] }); 45709 } 45710 function PostEdit({ postType: postType2, postId }) { 45711 return /* @__PURE__ */ (0, import_jsx_runtime291.jsxs)( 45712 page_default, 45713 { 45714 className: clsx_default("edit-site-post-edit", { 45715 "is-empty": !postId 45716 }), 45717 label: (0, import_i18n153.__)("Post Edit"), 45718 children: [ 45719 postId && /* @__PURE__ */ (0, import_jsx_runtime291.jsx)(PostEditForm, { postType: postType2, postId }), 45720 !postId && /* @__PURE__ */ (0, import_jsx_runtime291.jsx)("p", { children: (0, import_i18n153.__)("Select a page to edit") }) 45721 ] 45722 } 45723 ); 45724 } 45725 45726 // packages/edit-site/build-module/components/site-editor-routes/pages.js 45727 var import_jsx_runtime292 = __toESM(require_jsx_runtime()); 45728 var { useLocation: useLocation33 } = unlock(import_router40.privateApis); 45729 async function isListView(query) { 45730 const { activeView = "all" } = query; 45731 const postTypeObject = await (0, import_data80.resolveSelect)(import_core_data64.store).getPostType("page"); 45732 const view = await loadView({ 45733 kind: "postType", 45734 name: "page", 45735 slug: activeView, 45736 defaultView: getDefaultView2(postTypeObject, activeView) 45737 }); 45738 return view.type === "list"; 45739 } 45740 function MobilePagesView() { 45741 const { query = {} } = useLocation33(); 45742 const { canvas = "view" } = query; 45743 return canvas === "edit" ? /* @__PURE__ */ (0, import_jsx_runtime292.jsx)(EditSiteEditor, {}) : /* @__PURE__ */ (0, import_jsx_runtime292.jsx)(PostList, { postType: "page" }); 45744 } 45745 var pagesRoute = { 45746 name: "pages", 45747 path: "/page", 45748 areas: { 45749 sidebar({ siteData }) { 45750 const isBlockTheme = siteData.currentTheme?.is_block_theme; 45751 return isBlockTheme ? /* @__PURE__ */ (0, import_jsx_runtime292.jsx)( 45752 SidebarNavigationScreen, 45753 { 45754 title: (0, import_i18n154.__)("Pages"), 45755 backPath: "/", 45756 content: /* @__PURE__ */ (0, import_jsx_runtime292.jsx)(DataViewsSidebarContent, { postType: "page" }) 45757 } 45758 ) : /* @__PURE__ */ (0, import_jsx_runtime292.jsx)(SidebarNavigationScreenUnsupported, {}); 45759 }, 45760 content({ siteData }) { 45761 const isBlockTheme = siteData.currentTheme?.is_block_theme; 45762 return isBlockTheme ? /* @__PURE__ */ (0, import_jsx_runtime292.jsx)(PostList, { postType: "page" }) : void 0; 45763 }, 45764 async preview({ query, siteData }) { 45765 const isBlockTheme = siteData.currentTheme?.is_block_theme; 45766 if (!isBlockTheme) { 45767 return void 0; 45768 } 45769 const isList = await isListView(query); 45770 return isList ? /* @__PURE__ */ (0, import_jsx_runtime292.jsx)(EditSiteEditor, {}) : void 0; 45771 }, 45772 mobile({ siteData }) { 45773 const isBlockTheme = siteData.currentTheme?.is_block_theme; 45774 return isBlockTheme ? /* @__PURE__ */ (0, import_jsx_runtime292.jsx)(MobilePagesView, {}) : /* @__PURE__ */ (0, import_jsx_runtime292.jsx)(SidebarNavigationScreenUnsupported, {}); 45775 }, 45776 async edit({ query }) { 45777 const isList = await isListView(query); 45778 const hasQuickEdit = !isList && !!query.quickEdit; 45779 return hasQuickEdit ? /* @__PURE__ */ (0, import_jsx_runtime292.jsx)(PostEdit, { postType: "page", postId: query.postId }) : void 0; 45780 } 45781 }, 45782 widths: { 45783 async content({ query }) { 45784 const isList = await isListView(query); 45785 return isList ? 380 : void 0; 45786 }, 45787 async edit({ query }) { 45788 const isList = await isListView(query); 45789 const hasQuickEdit = !isList && !!query.quickEdit; 45790 return hasQuickEdit ? 380 : void 0; 45791 } 45792 } 45793 }; 45794 45795 // packages/edit-site/build-module/components/site-editor-routes/page-item.js 45796 var import_i18n155 = __toESM(require_i18n()); 45797 var import_jsx_runtime293 = __toESM(require_jsx_runtime()); 45798 var pageItemRoute = { 45799 name: "page-item", 45800 path: "/page/:postId", 45801 areas: { 45802 sidebar({ siteData }) { 45803 const isBlockTheme = siteData.currentTheme?.is_block_theme; 45804 return isBlockTheme ? /* @__PURE__ */ (0, import_jsx_runtime293.jsx)( 45805 SidebarNavigationScreen, 45806 { 45807 title: (0, import_i18n155.__)("Pages"), 45808 backPath: "/", 45809 content: /* @__PURE__ */ (0, import_jsx_runtime293.jsx)(DataViewsSidebarContent, { postType: "page" }) 45810 } 45811 ) : /* @__PURE__ */ (0, import_jsx_runtime293.jsx)(SidebarNavigationScreenUnsupported, {}); 45812 }, 45813 mobile({ siteData }) { 45814 const isBlockTheme = siteData.currentTheme?.is_block_theme; 45815 return isBlockTheme ? /* @__PURE__ */ (0, import_jsx_runtime293.jsx)(EditSiteEditor, {}) : /* @__PURE__ */ (0, import_jsx_runtime293.jsx)(SidebarNavigationScreenUnsupported, {}); 45816 }, 45817 preview({ siteData }) { 45818 const isBlockTheme = siteData.currentTheme?.is_block_theme; 45819 return isBlockTheme ? /* @__PURE__ */ (0, import_jsx_runtime293.jsx)(EditSiteEditor, {}) : /* @__PURE__ */ (0, import_jsx_runtime293.jsx)(SidebarNavigationScreenUnsupported, {}); 45820 } 45821 } 45822 }; 45823 45824 // packages/edit-site/build-module/components/site-editor-routes/stylebook.js 45825 var import_i18n156 = __toESM(require_i18n()); 45826 var import_editor42 = __toESM(require_editor()); 45827 var import_jsx_runtime294 = __toESM(require_jsx_runtime()); 45828 var { StyleBookPreview: StyleBookPreview2 } = unlock(import_editor42.privateApis); 45829 var stylebookRoute = { 45830 name: "stylebook", 45831 path: "/stylebook", 45832 areas: { 45833 sidebar({ siteData }) { 45834 return isClassicThemeWithStyleBookSupport(siteData) ? /* @__PURE__ */ (0, import_jsx_runtime294.jsx)( 45835 SidebarNavigationScreen, 45836 { 45837 title: (0, import_i18n156.__)("Styles"), 45838 backPath: "/", 45839 description: (0, import_i18n156.__)( 45840 `Preview your website's visual identity: colors, typography, and blocks.` 45841 ) 45842 } 45843 ) : /* @__PURE__ */ (0, import_jsx_runtime294.jsx)(SidebarNavigationScreenUnsupported, {}); 45844 }, 45845 preview({ siteData }) { 45846 return isClassicThemeWithStyleBookSupport(siteData) ? /* @__PURE__ */ (0, import_jsx_runtime294.jsx)(StyleBookPreview2, { isStatic: true }) : void 0; 45847 }, 45848 mobile({ siteData }) { 45849 return isClassicThemeWithStyleBookSupport(siteData) ? /* @__PURE__ */ (0, import_jsx_runtime294.jsx)(StyleBookPreview2, { isStatic: true }) : void 0; 45850 } 45851 } 45852 }; 45853 45854 // packages/edit-site/build-module/components/site-editor-routes/notfound.js 45855 var import_i18n157 = __toESM(require_i18n()); 45856 var import_components172 = __toESM(require_components()); 45857 var import_jsx_runtime295 = __toESM(require_jsx_runtime()); 45858 function NotFoundError() { 45859 return /* @__PURE__ */ (0, import_jsx_runtime295.jsx)(import_components172.Notice, { status: "error", isDismissible: false, children: (0, import_i18n157.__)( 45860 "The requested page could not be found. Please check the URL." 45861 ) }); 45862 } 45863 var notFoundRoute = { 45864 name: "notfound", 45865 path: "*", 45866 areas: { 45867 sidebar: /* @__PURE__ */ (0, import_jsx_runtime295.jsx)(SidebarNavigationScreenMain, {}), 45868 mobile: /* @__PURE__ */ (0, import_jsx_runtime295.jsx)( 45869 SidebarNavigationScreenMain, 45870 { 45871 customDescription: /* @__PURE__ */ (0, import_jsx_runtime295.jsx)(NotFoundError, {}) 45872 } 45873 ), 45874 content: /* @__PURE__ */ (0, import_jsx_runtime295.jsx)(import_components172.__experimentalSpacer, { padding: 2, children: /* @__PURE__ */ (0, import_jsx_runtime295.jsx)(NotFoundError, {}) }) 45875 } 45876 }; 45877 45878 // packages/edit-site/build-module/components/site-editor-routes/index.js 45879 var routes2 = [ 45880 pageItemRoute, 45881 pagesRoute, 45882 templateItemRoute, 45883 templatesRoute, 45884 templatePartItemRoute, 45885 patternItemRoute, 45886 patternsRoute, 45887 navigationItemRoute, 45888 navigationRoute, 45889 stylesRoute, 45890 homeRoute, 45891 stylebookRoute, 45892 notFoundRoute 45893 ]; 45894 function useRegisterSiteEditorRoutes() { 45895 const registry = (0, import_data81.useRegistry)(); 45896 const { registerRoute: registerRoute2 } = unlock((0, import_data81.useDispatch)(store)); 45897 (0, import_element152.useEffect)(() => { 45898 registry.batch(() => { 45899 routes2.forEach(registerRoute2); 45900 }); 45901 }, [registry, registerRoute2]); 45902 } 45903 45904 // packages/edit-site/build-module/components/app/index.js 45905 var import_jsx_runtime296 = __toESM(require_jsx_runtime()); 45906 var { RouterProvider } = unlock(import_router41.privateApis); 45907 function AppLayout() { 45908 useCommonCommands(); 45909 useSetCommandContext(); 45910 return /* @__PURE__ */ (0, import_jsx_runtime296.jsx)(LayoutWithGlobalStylesProvider, {}); 45911 } 45912 function App() { 45913 useRegisterSiteEditorRoutes(); 45914 const { routes: routes3, currentTheme, editorSettings } = (0, import_data82.useSelect)((select3) => { 45915 return { 45916 routes: unlock(select3(store)).getRoutes(), 45917 currentTheme: select3(import_core_data65.store).getCurrentTheme(), 45918 // This is a temp solution until the has_theme_json value is available for the current theme. 45919 editorSettings: select3(store).getSettings() 45920 }; 45921 }, []); 45922 const beforeNavigate = (0, import_element153.useCallback)(({ path, query }) => { 45923 if (!isPreviewingTheme()) { 45924 return { path, query }; 45925 } 45926 return { 45927 path, 45928 query: { 45929 ...query, 45930 wp_theme_preview: "wp_theme_preview" in query ? query.wp_theme_preview : currentlyPreviewingTheme() 45931 } 45932 }; 45933 }, []); 45934 const matchResolverArgsValue = (0, import_element153.useMemo)( 45935 () => ({ 45936 siteData: { currentTheme, editorSettings } 45937 }), 45938 [currentTheme, editorSettings] 45939 ); 45940 return /* @__PURE__ */ (0, import_jsx_runtime296.jsx)( 45941 RouterProvider, 45942 { 45943 routes: routes3, 45944 pathArg: "p", 45945 beforeNavigate, 45946 matchResolverArgs: matchResolverArgsValue, 45947 children: /* @__PURE__ */ (0, import_jsx_runtime296.jsx)(AppLayout, {}) 45948 } 45949 ); 45950 } 45951 45952 // packages/edit-site/build-module/deprecated.js 45953 var import_editor43 = __toESM(require_editor()); 45954 var import_url27 = __toESM(require_url()); 45955 var import_deprecated5 = __toESM(require_deprecated()); 45956 var import_jsx_runtime297 = __toESM(require_jsx_runtime()); 45957 var isSiteEditor = (0, import_url27.getPath)(window.location.href)?.includes( 45958 "site-editor.php" 45959 ); 45960 var deprecateSlot = (name2) => { 45961 (0, import_deprecated5.default)(`wp.editPost.$name2}`, { 45962 since: "6.6", 45963 alternative: `wp.editor.$name2}` 45964 }); 45965 }; 45966 function PluginMoreMenuItem(props) { 45967 if (!isSiteEditor) { 45968 return null; 45969 } 45970 deprecateSlot("PluginMoreMenuItem"); 45971 return /* @__PURE__ */ (0, import_jsx_runtime297.jsx)(import_editor43.PluginMoreMenuItem, { ...props }); 45972 } 45973 function PluginSidebar(props) { 45974 if (!isSiteEditor) { 45975 return null; 45976 } 45977 deprecateSlot("PluginSidebar"); 45978 return /* @__PURE__ */ (0, import_jsx_runtime297.jsx)(import_editor43.PluginSidebar, { ...props }); 45979 } 45980 function PluginSidebarMoreMenuItem(props) { 45981 if (!isSiteEditor) { 45982 return null; 45983 } 45984 deprecateSlot("PluginSidebarMoreMenuItem"); 45985 return /* @__PURE__ */ (0, import_jsx_runtime297.jsx)(import_editor43.PluginSidebarMoreMenuItem, { ...props }); 45986 } 45987 45988 // packages/edit-site/build-module/index.js 45989 var import_jsx_runtime298 = __toESM(require_jsx_runtime()); 45990 var { registerCoreBlockBindingsSources } = unlock(import_editor44.privateApis); 45991 function initializeEditor(id, settings2) { 45992 const target = document.getElementById(id); 45993 const root = (0, import_element154.createRoot)(target); 45994 (0, import_data83.dispatch)(import_blocks15.store).reapplyBlockTypeFilters(); 45995 const coreBlocks = (0, import_block_library2.__experimentalGetCoreBlocks)().filter( 45996 ({ name: name2 }) => name2 !== "core/freeform" 45997 ); 45998 (0, import_block_library2.registerCoreBlocks)(coreBlocks); 45999 registerCoreBlockBindingsSources(); 46000 (0, import_data83.dispatch)(import_blocks15.store).setFreeformFallbackBlockName("core/html"); 46001 (0, import_widgets.registerLegacyWidgetBlock)({ inserter: false }); 46002 (0, import_widgets.registerWidgetGroupBlock)({ inserter: false }); 46003 if (false) { 46004 (0, import_block_library2.__experimentalRegisterExperimentalCoreBlocks)({ 46005 enableFSEBlocks: true 46006 }); 46007 } 46008 (0, import_data83.dispatch)(import_preferences13.store).setDefaults("core/edit-site", { 46009 welcomeGuide: true, 46010 welcomeGuideStyles: true, 46011 welcomeGuidePage: true, 46012 welcomeGuideTemplate: true 46013 }); 46014 (0, import_data83.dispatch)(import_preferences13.store).setDefaults("core", { 46015 allowRightClickOverrides: true, 46016 distractionFree: false, 46017 editorMode: "visual", 46018 editorTool: "edit", 46019 fixedToolbar: false, 46020 focusMode: false, 46021 inactivePanels: [], 46022 keepCaretInsideBlock: false, 46023 openPanels: ["post-status"], 46024 showBlockBreadcrumbs: true, 46025 showListViewByDefault: false, 46026 enableChoosePatternModal: true 46027 }); 46028 if (window.__experimentalMediaProcessing) { 46029 (0, import_data83.dispatch)(import_preferences13.store).setDefaults("core/media", { 46030 requireApproval: true, 46031 optimizeOnUpload: true 46032 }); 46033 } 46034 (0, import_data83.dispatch)(store).updateSettings(settings2); 46035 window.addEventListener("dragover", (e2) => e2.preventDefault(), false); 46036 window.addEventListener("drop", (e2) => e2.preventDefault(), false); 46037 root.render( 46038 /* @__PURE__ */ (0, import_jsx_runtime298.jsx)(import_element154.StrictMode, { children: /* @__PURE__ */ (0, import_jsx_runtime298.jsx)(App, {}) }) 46039 ); 46040 return root; 46041 } 46042 function reinitializeEditor() { 46043 (0, import_deprecated6.default)("wp.editSite.reinitializeEditor", { 46044 since: "6.2", 46045 version: "6.3" 46046 }); 46047 } 46048 return __toCommonJS(index_exports); 46049 })(); 46050 /*! Bundled license information: 46051 46052 use-sync-external-store/cjs/use-sync-external-store-shim.development.js: 46053 (** 46054 * @license React 46055 * use-sync-external-store-shim.development.js 46056 * 46057 * Copyright (c) Meta Platforms, Inc. and affiliates. 46058 * 46059 * This source code is licensed under the MIT license found in the 46060 * LICENSE file in the root directory of this source tree. 46061 *) 46062 46063 is-plain-object/dist/is-plain-object.mjs: 46064 (*! 46065 * is-plain-object <https://github.com/jonschlinkert/is-plain-object> 46066 * 46067 * Copyright (c) 2014-2017, Jon Schlinkert. 46068 * Released under the MIT License. 46069 *) 46070 */
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated : Wed Apr 15 08:20:10 2026 | Cross-referenced by PHPXref |