| [ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 (function() { 2 "use strict"; 3 var wp; 4 (wp ||= {}).editSite = (() => { 5 var __create = Object.create; 6 var __defProp = Object.defineProperty; 7 var __getOwnPropDesc = Object.getOwnPropertyDescriptor; 8 var __getOwnPropNames = Object.getOwnPropertyNames; 9 var __getProtoOf = Object.getPrototypeOf; 10 var __hasOwnProp = Object.prototype.hasOwnProperty; 11 var __require = /* @__PURE__ */ ((x2) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x2, { 12 get: (a2, b2) => (typeof require !== "undefined" ? require : a2)[b2] 13 }) : x2)(function(x2) { 14 if (typeof require !== "undefined") return require.apply(this, arguments); 15 throw Error('Dynamic require of "' + x2 + '" is not supported'); 16 }); 17 var __commonJS = (cb, mod) => function __require4() { 18 return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; 19 }; 20 var __export = (target, all) => { 21 for (var name2 in all) 22 __defProp(target, name2, { get: all[name2], enumerable: true }); 23 }; 24 var __copyProps = (to2, from, except, desc) => { 25 if (from && typeof from === "object" || typeof from === "function") { 26 for (let key of __getOwnPropNames(from)) 27 if (!__hasOwnProp.call(to2, key) && key !== except) 28 __defProp(to2, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); 29 } 30 return to2; 31 }; 32 var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( 33 // If the importer is in node compatibility mode or this is not an ESM 34 // file that has been converted to a CommonJS file using a Babel- 35 // compatible transform (i.e. "__esModule" has not been set), then set 36 // "default" to the CommonJS "module.exports" for node compatibility. 37 isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, 38 mod 39 )); 40 var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); 41 42 // package-external:@wordpress/blocks 43 var require_blocks = __commonJS({ 44 "package-external:@wordpress/blocks"(exports, module) { 45 module.exports = window.wp.blocks; 46 } 47 }); 48 49 // package-external:@wordpress/block-library 50 var require_block_library = __commonJS({ 51 "package-external:@wordpress/block-library"(exports, module) { 52 module.exports = window.wp.blockLibrary; 53 } 54 }); 55 56 // package-external:@wordpress/data 57 var require_data = __commonJS({ 58 "package-external:@wordpress/data"(exports, module) { 59 module.exports = window.wp.data; 60 } 61 }); 62 63 // package-external:@wordpress/deprecated 64 var require_deprecated = __commonJS({ 65 "package-external:@wordpress/deprecated"(exports, module) { 66 module.exports = window.wp.deprecated; 67 } 68 }); 69 70 // package-external:@wordpress/element 71 var require_element = __commonJS({ 72 "package-external:@wordpress/element"(exports, module) { 73 module.exports = window.wp.element; 74 } 75 }); 76 77 // package-external:@wordpress/editor 78 var require_editor = __commonJS({ 79 "package-external:@wordpress/editor"(exports, module) { 80 module.exports = window.wp.editor; 81 } 82 }); 83 84 // package-external:@wordpress/preferences 85 var require_preferences = __commonJS({ 86 "package-external:@wordpress/preferences"(exports, module) { 87 module.exports = window.wp.preferences; 88 } 89 }); 90 91 // package-external:@wordpress/widgets 92 var require_widgets = __commonJS({ 93 "package-external:@wordpress/widgets"(exports, module) { 94 module.exports = window.wp.widgets; 95 } 96 }); 97 98 // package-external:@wordpress/core-data 99 var require_core_data = __commonJS({ 100 "package-external:@wordpress/core-data"(exports, module) { 101 module.exports = window.wp.coreData; 102 } 103 }); 104 105 // package-external:@wordpress/block-editor 106 var require_block_editor = __commonJS({ 107 "package-external:@wordpress/block-editor"(exports, module) { 108 module.exports = window.wp.blockEditor; 109 } 110 }); 111 112 // package-external:@wordpress/i18n 113 var require_i18n = __commonJS({ 114 "package-external:@wordpress/i18n"(exports, module) { 115 module.exports = window.wp.i18n; 116 } 117 }); 118 119 // package-external:@wordpress/patterns 120 var require_patterns = __commonJS({ 121 "package-external:@wordpress/patterns"(exports, module) { 122 module.exports = window.wp.patterns; 123 } 124 }); 125 126 // package-external:@wordpress/private-apis 127 var require_private_apis = __commonJS({ 128 "package-external:@wordpress/private-apis"(exports, module) { 129 module.exports = window.wp.privateApis; 130 } 131 }); 132 133 // package-external:@wordpress/router 134 var require_router = __commonJS({ 135 "package-external:@wordpress/router"(exports, module) { 136 module.exports = window.wp.router; 137 } 138 }); 139 140 // vendor-external:react 141 var require_react = __commonJS({ 142 "vendor-external:react"(exports, module) { 143 module.exports = window.React; 144 } 145 }); 146 147 // vendor-external:react/jsx-runtime 148 var require_jsx_runtime = __commonJS({ 149 "vendor-external:react/jsx-runtime"(exports, module) { 150 module.exports = window.ReactJSXRuntime; 151 } 152 }); 153 154 // vendor-external:react-dom 155 var require_react_dom = __commonJS({ 156 "vendor-external:react-dom"(exports, module) { 157 module.exports = window.ReactDOM; 158 } 159 }); 160 161 // node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js 162 var require_use_sync_external_store_shim_development = __commonJS({ 163 "node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js"(exports) { 164 "use strict"; 165 (function() { 166 function is2(x2, y2) { 167 return x2 === y2 && (0 !== x2 || 1 / x2 === 1 / y2) || x2 !== x2 && y2 !== y2; 168 } 169 function useSyncExternalStore$2(subscribe3, getSnapshot) { 170 didWarnOld18Alpha || void 0 === React61.startTransition || (didWarnOld18Alpha = true, console.error( 171 "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." 172 )); 173 var value = getSnapshot(); 174 if (!didWarnUncachedGetSnapshot) { 175 var cachedValue = getSnapshot(); 176 objectIs(value, cachedValue) || (console.error( 177 "The result of getSnapshot should be cached to avoid an infinite loop" 178 ), didWarnUncachedGetSnapshot = true); 179 } 180 cachedValue = useState88({ 181 inst: { value, getSnapshot } 182 }); 183 var inst = cachedValue[0].inst, forceUpdate = cachedValue[1]; 184 useLayoutEffect11( 185 function() { 186 inst.value = value; 187 inst.getSnapshot = getSnapshot; 188 checkIfSnapshotChanged(inst) && forceUpdate({ inst }); 189 }, 190 [subscribe3, value, getSnapshot] 191 ); 192 useEffect71( 193 function() { 194 checkIfSnapshotChanged(inst) && forceUpdate({ inst }); 195 return subscribe3(function() { 196 checkIfSnapshotChanged(inst) && forceUpdate({ inst }); 197 }); 198 }, 199 [subscribe3] 200 ); 201 useDebugValue2(value); 202 return value; 203 } 204 function checkIfSnapshotChanged(inst) { 205 var latestGetSnapshot = inst.getSnapshot; 206 inst = inst.value; 207 try { 208 var nextValue = latestGetSnapshot(); 209 return !objectIs(inst, nextValue); 210 } catch (error2) { 211 return true; 212 } 213 } 214 function useSyncExternalStore$1(subscribe3, getSnapshot) { 215 return getSnapshot(); 216 } 217 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error()); 218 var React61 = require_react(), objectIs = "function" === typeof Object.is ? Object.is : is2, useState88 = React61.useState, useEffect71 = React61.useEffect, useLayoutEffect11 = React61.useLayoutEffect, useDebugValue2 = React61.useDebugValue, didWarnOld18Alpha = false, didWarnUncachedGetSnapshot = false, shim = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? useSyncExternalStore$1 : useSyncExternalStore$2; 219 exports.useSyncExternalStore = void 0 !== React61.useSyncExternalStore ? React61.useSyncExternalStore : shim; 220 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error()); 221 })(); 222 } 223 }); 224 225 // node_modules/use-sync-external-store/shim/index.js 226 var require_shim = __commonJS({ 227 "node_modules/use-sync-external-store/shim/index.js"(exports, module) { 228 "use strict"; 229 if (false) { 230 module.exports = null; 231 } else { 232 module.exports = require_use_sync_external_store_shim_development(); 233 } 234 } 235 }); 236 237 // node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js 238 var require_with_selector_development = __commonJS({ 239 "node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js"(exports) { 240 "use strict"; 241 (function() { 242 function is2(x2, y2) { 243 return x2 === y2 && (0 !== x2 || 1 / x2 === 1 / y2) || x2 !== x2 && y2 !== y2; 244 } 245 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error()); 246 var React61 = require_react(), shim = require_shim(), objectIs = "function" === typeof Object.is ? Object.is : is2, useSyncExternalStore3 = shim.useSyncExternalStore, useRef78 = React61.useRef, useEffect71 = React61.useEffect, useMemo95 = React61.useMemo, useDebugValue2 = React61.useDebugValue; 247 exports.useSyncExternalStoreWithSelector = function(subscribe3, getSnapshot, getServerSnapshot, selector2, isEqual2) { 248 var instRef = useRef78(null); 249 if (null === instRef.current) { 250 var inst = { hasValue: false, value: null }; 251 instRef.current = inst; 252 } else inst = instRef.current; 253 instRef = useMemo95( 254 function() { 255 function memoizedSelector(nextSnapshot) { 256 if (!hasMemo) { 257 hasMemo = true; 258 memoizedSnapshot = nextSnapshot; 259 nextSnapshot = selector2(nextSnapshot); 260 if (void 0 !== isEqual2 && inst.hasValue) { 261 var currentSelection = inst.value; 262 if (isEqual2(currentSelection, nextSnapshot)) 263 return memoizedSelection = currentSelection; 264 } 265 return memoizedSelection = nextSnapshot; 266 } 267 currentSelection = memoizedSelection; 268 if (objectIs(memoizedSnapshot, nextSnapshot)) 269 return currentSelection; 270 var nextSelection = selector2(nextSnapshot); 271 if (void 0 !== isEqual2 && isEqual2(currentSelection, nextSelection)) 272 return memoizedSnapshot = nextSnapshot, currentSelection; 273 memoizedSnapshot = nextSnapshot; 274 return memoizedSelection = nextSelection; 275 } 276 var hasMemo = false, memoizedSnapshot, memoizedSelection, maybeGetServerSnapshot = void 0 === getServerSnapshot ? null : getServerSnapshot; 277 return [ 278 function() { 279 return memoizedSelector(getSnapshot()); 280 }, 281 null === maybeGetServerSnapshot ? void 0 : function() { 282 return memoizedSelector(maybeGetServerSnapshot()); 283 } 284 ]; 285 }, 286 [getSnapshot, getServerSnapshot, selector2, isEqual2] 287 ); 288 var value = useSyncExternalStore3(subscribe3, instRef[0], instRef[1]); 289 useEffect71( 290 function() { 291 inst.hasValue = true; 292 inst.value = value; 293 }, 294 [value] 295 ); 296 useDebugValue2(value); 297 return value; 298 }; 299 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error()); 300 })(); 301 } 302 }); 303 304 // node_modules/use-sync-external-store/shim/with-selector.js 305 var require_with_selector = __commonJS({ 306 "node_modules/use-sync-external-store/shim/with-selector.js"(exports, module) { 307 "use strict"; 308 if (false) { 309 module.exports = null; 310 } else { 311 module.exports = require_with_selector_development(); 312 } 313 } 314 }); 315 316 // package-external:@wordpress/a11y 317 var require_a11y = __commonJS({ 318 "package-external:@wordpress/a11y"(exports, module) { 319 module.exports = window.wp.a11y; 320 } 321 }); 322 323 // package-external:@wordpress/primitives 324 var require_primitives = __commonJS({ 325 "package-external:@wordpress/primitives"(exports, module) { 326 module.exports = window.wp.primitives; 327 } 328 }); 329 330 // package-external:@wordpress/compose 331 var require_compose = __commonJS({ 332 "package-external:@wordpress/compose"(exports, module) { 333 module.exports = window.wp.compose; 334 } 335 }); 336 337 // package-external:@wordpress/theme 338 var require_theme = __commonJS({ 339 "package-external:@wordpress/theme"(exports, module) { 340 module.exports = window.wp.theme; 341 } 342 }); 343 344 // package-external:@wordpress/components 345 var require_components = __commonJS({ 346 "package-external:@wordpress/components"(exports, module) { 347 module.exports = window.wp.components; 348 } 349 }); 350 351 // package-external:@wordpress/dom 352 var require_dom = __commonJS({ 353 "package-external:@wordpress/dom"(exports, module) { 354 module.exports = window.wp.dom; 355 } 356 }); 357 358 // package-external:@wordpress/plugins 359 var require_plugins = __commonJS({ 360 "package-external:@wordpress/plugins"(exports, module) { 361 module.exports = window.wp.plugins; 362 } 363 }); 364 365 // package-external:@wordpress/notices 366 var require_notices = __commonJS({ 367 "package-external:@wordpress/notices"(exports, module) { 368 module.exports = window.wp.notices; 369 } 370 }); 371 372 // package-external:@wordpress/url 373 var require_url = __commonJS({ 374 "package-external:@wordpress/url"(exports, module) { 375 module.exports = window.wp.url; 376 } 377 }); 378 379 // package-external:@wordpress/keyboard-shortcuts 380 var require_keyboard_shortcuts = __commonJS({ 381 "package-external:@wordpress/keyboard-shortcuts"(exports, module) { 382 module.exports = window.wp.keyboardShortcuts; 383 } 384 }); 385 386 // package-external:@wordpress/keycodes 387 var require_keycodes = __commonJS({ 388 "package-external:@wordpress/keycodes"(exports, module) { 389 module.exports = window.wp.keycodes; 390 } 391 }); 392 393 // package-external:@wordpress/api-fetch 394 var require_api_fetch = __commonJS({ 395 "package-external:@wordpress/api-fetch"(exports, module) { 396 module.exports = window.wp.apiFetch; 397 } 398 }); 399 400 // package-external:@wordpress/commands 401 var require_commands = __commonJS({ 402 "package-external:@wordpress/commands"(exports, module) { 403 module.exports = window.wp.commands; 404 } 405 }); 406 407 // package-external:@wordpress/html-entities 408 var require_html_entities = __commonJS({ 409 "package-external:@wordpress/html-entities"(exports, module) { 410 module.exports = window.wp.htmlEntities; 411 } 412 }); 413 414 // package-external:@wordpress/style-engine 415 var require_style_engine = __commonJS({ 416 "package-external:@wordpress/style-engine"(exports, module) { 417 module.exports = window.wp.styleEngine; 418 } 419 }); 420 421 // node_modules/fast-deep-equal/es6/index.js 422 var require_es6 = __commonJS({ 423 "node_modules/fast-deep-equal/es6/index.js"(exports, module) { 424 "use strict"; 425 module.exports = function equal(a2, b2) { 426 if (a2 === b2) return true; 427 if (a2 && b2 && typeof a2 == "object" && typeof b2 == "object") { 428 if (a2.constructor !== b2.constructor) return false; 429 var length, i2, keys; 430 if (Array.isArray(a2)) { 431 length = a2.length; 432 if (length != b2.length) return false; 433 for (i2 = length; i2-- !== 0; ) 434 if (!equal(a2[i2], b2[i2])) return false; 435 return true; 436 } 437 if (a2 instanceof Map && b2 instanceof Map) { 438 if (a2.size !== b2.size) return false; 439 for (i2 of a2.entries()) 440 if (!b2.has(i2[0])) return false; 441 for (i2 of a2.entries()) 442 if (!equal(i2[1], b2.get(i2[0]))) return false; 443 return true; 444 } 445 if (a2 instanceof Set && b2 instanceof Set) { 446 if (a2.size !== b2.size) return false; 447 for (i2 of a2.entries()) 448 if (!b2.has(i2[0])) return false; 449 return true; 450 } 451 if (ArrayBuffer.isView(a2) && ArrayBuffer.isView(b2)) { 452 length = a2.length; 453 if (length != b2.length) return false; 454 for (i2 = length; i2-- !== 0; ) 455 if (a2[i2] !== b2[i2]) return false; 456 return true; 457 } 458 if (a2.constructor === RegExp) return a2.source === b2.source && a2.flags === b2.flags; 459 if (a2.valueOf !== Object.prototype.valueOf) return a2.valueOf() === b2.valueOf(); 460 if (a2.toString !== Object.prototype.toString) return a2.toString() === b2.toString(); 461 keys = Object.keys(a2); 462 length = keys.length; 463 if (length !== Object.keys(b2).length) return false; 464 for (i2 = length; i2-- !== 0; ) 465 if (!Object.prototype.hasOwnProperty.call(b2, keys[i2])) return false; 466 for (i2 = length; i2-- !== 0; ) { 467 var key = keys[i2]; 468 if (!equal(a2[key], b2[key])) return false; 469 } 470 return true; 471 } 472 return a2 !== a2 && b2 !== b2; 473 }; 474 } 475 }); 476 477 // node_modules/deepmerge/dist/cjs.js 478 var require_cjs = __commonJS({ 479 "node_modules/deepmerge/dist/cjs.js"(exports, module) { 480 "use strict"; 481 var isMergeableObject = function isMergeableObject2(value) { 482 return isNonNullObject(value) && !isSpecial(value); 483 }; 484 function isNonNullObject(value) { 485 return !!value && typeof value === "object"; 486 } 487 function isSpecial(value) { 488 var stringValue = Object.prototype.toString.call(value); 489 return stringValue === "[object RegExp]" || stringValue === "[object Date]" || isReactElement(value); 490 } 491 var canUseSymbol = typeof Symbol === "function" && Symbol.for; 492 var REACT_ELEMENT_TYPE = canUseSymbol ? /* @__PURE__ */ Symbol.for("react.element") : 60103; 493 function isReactElement(value) { 494 return value.$$typeof === REACT_ELEMENT_TYPE; 495 } 496 function emptyTarget(val) { 497 return Array.isArray(val) ? [] : {}; 498 } 499 function cloneUnlessOtherwiseSpecified(value, options) { 500 return options.clone !== false && options.isMergeableObject(value) ? deepmerge2(emptyTarget(value), value, options) : value; 501 } 502 function defaultArrayMerge(target, source, options) { 503 return target.concat(source).map(function(element) { 504 return cloneUnlessOtherwiseSpecified(element, options); 505 }); 506 } 507 function getMergeFunction(key, options) { 508 if (!options.customMerge) { 509 return deepmerge2; 510 } 511 var customMerge = options.customMerge(key); 512 return typeof customMerge === "function" ? customMerge : deepmerge2; 513 } 514 function getEnumerableOwnPropertySymbols(target) { 515 return Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(target).filter(function(symbol3) { 516 return Object.propertyIsEnumerable.call(target, symbol3); 517 }) : []; 518 } 519 function getKeys2(target) { 520 return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target)); 521 } 522 function propertyIsOnObject(object, property) { 523 try { 524 return property in object; 525 } catch (_) { 526 return false; 527 } 528 } 529 function propertyIsUnsafe(target, key) { 530 return propertyIsOnObject(target, key) && !(Object.hasOwnProperty.call(target, key) && Object.propertyIsEnumerable.call(target, key)); 531 } 532 function mergeObject(target, source, options) { 533 var destination = {}; 534 if (options.isMergeableObject(target)) { 535 getKeys2(target).forEach(function(key) { 536 destination[key] = cloneUnlessOtherwiseSpecified(target[key], options); 537 }); 538 } 539 getKeys2(source).forEach(function(key) { 540 if (propertyIsUnsafe(target, key)) { 541 return; 542 } 543 if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) { 544 destination[key] = getMergeFunction(key, options)(target[key], source[key], options); 545 } else { 546 destination[key] = cloneUnlessOtherwiseSpecified(source[key], options); 547 } 548 }); 549 return destination; 550 } 551 function deepmerge2(target, source, options) { 552 options = options || {}; 553 options.arrayMerge = options.arrayMerge || defaultArrayMerge; 554 options.isMergeableObject = options.isMergeableObject || isMergeableObject; 555 options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified; 556 var sourceIsArray = Array.isArray(source); 557 var targetIsArray = Array.isArray(target); 558 var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray; 559 if (!sourceAndTargetTypesMatch) { 560 return cloneUnlessOtherwiseSpecified(source, options); 561 } else if (sourceIsArray) { 562 return options.arrayMerge(target, source, options); 563 } else { 564 return mergeObject(target, source, options); 565 } 566 } 567 deepmerge2.all = function deepmergeAll(array, options) { 568 if (!Array.isArray(array)) { 569 throw new Error("first argument should be an array"); 570 } 571 return array.reduce(function(prev, next) { 572 return deepmerge2(prev, next, options); 573 }, {}); 574 }; 575 var deepmerge_1 = deepmerge2; 576 module.exports = deepmerge_1; 577 } 578 }); 579 580 // package-external:@wordpress/blob 581 var require_blob = __commonJS({ 582 "package-external:@wordpress/blob"(exports, module) { 583 module.exports = window.wp.blob; 584 } 585 }); 586 587 // node_modules/remove-accents/index.js 588 var require_remove_accents = __commonJS({ 589 "node_modules/remove-accents/index.js"(exports, module) { 590 var characterMap = { 591 "\xC0": "A", 592 "\xC1": "A", 593 "\xC2": "A", 594 "\xC3": "A", 595 "\xC4": "A", 596 "\xC5": "A", 597 "\u1EA4": "A", 598 "\u1EAE": "A", 599 "\u1EB2": "A", 600 "\u1EB4": "A", 601 "\u1EB6": "A", 602 "\xC6": "AE", 603 "\u1EA6": "A", 604 "\u1EB0": "A", 605 "\u0202": "A", 606 "\u1EA2": "A", 607 "\u1EA0": "A", 608 "\u1EA8": "A", 609 "\u1EAA": "A", 610 "\u1EAC": "A", 611 "\xC7": "C", 612 "\u1E08": "C", 613 "\xC8": "E", 614 "\xC9": "E", 615 "\xCA": "E", 616 "\xCB": "E", 617 "\u1EBE": "E", 618 "\u1E16": "E", 619 "\u1EC0": "E", 620 "\u1E14": "E", 621 "\u1E1C": "E", 622 "\u0206": "E", 623 "\u1EBA": "E", 624 "\u1EBC": "E", 625 "\u1EB8": "E", 626 "\u1EC2": "E", 627 "\u1EC4": "E", 628 "\u1EC6": "E", 629 "\xCC": "I", 630 "\xCD": "I", 631 "\xCE": "I", 632 "\xCF": "I", 633 "\u1E2E": "I", 634 "\u020A": "I", 635 "\u1EC8": "I", 636 "\u1ECA": "I", 637 "\xD0": "D", 638 "\xD1": "N", 639 "\xD2": "O", 640 "\xD3": "O", 641 "\xD4": "O", 642 "\xD5": "O", 643 "\xD6": "O", 644 "\xD8": "O", 645 "\u1ED0": "O", 646 "\u1E4C": "O", 647 "\u1E52": "O", 648 "\u020E": "O", 649 "\u1ECE": "O", 650 "\u1ECC": "O", 651 "\u1ED4": "O", 652 "\u1ED6": "O", 653 "\u1ED8": "O", 654 "\u1EDC": "O", 655 "\u1EDE": "O", 656 "\u1EE0": "O", 657 "\u1EDA": "O", 658 "\u1EE2": "O", 659 "\xD9": "U", 660 "\xDA": "U", 661 "\xDB": "U", 662 "\xDC": "U", 663 "\u1EE6": "U", 664 "\u1EE4": "U", 665 "\u1EEC": "U", 666 "\u1EEE": "U", 667 "\u1EF0": "U", 668 "\xDD": "Y", 669 "\xE0": "a", 670 "\xE1": "a", 671 "\xE2": "a", 672 "\xE3": "a", 673 "\xE4": "a", 674 "\xE5": "a", 675 "\u1EA5": "a", 676 "\u1EAF": "a", 677 "\u1EB3": "a", 678 "\u1EB5": "a", 679 "\u1EB7": "a", 680 "\xE6": "ae", 681 "\u1EA7": "a", 682 "\u1EB1": "a", 683 "\u0203": "a", 684 "\u1EA3": "a", 685 "\u1EA1": "a", 686 "\u1EA9": "a", 687 "\u1EAB": "a", 688 "\u1EAD": "a", 689 "\xE7": "c", 690 "\u1E09": "c", 691 "\xE8": "e", 692 "\xE9": "e", 693 "\xEA": "e", 694 "\xEB": "e", 695 "\u1EBF": "e", 696 "\u1E17": "e", 697 "\u1EC1": "e", 698 "\u1E15": "e", 699 "\u1E1D": "e", 700 "\u0207": "e", 701 "\u1EBB": "e", 702 "\u1EBD": "e", 703 "\u1EB9": "e", 704 "\u1EC3": "e", 705 "\u1EC5": "e", 706 "\u1EC7": "e", 707 "\xEC": "i", 708 "\xED": "i", 709 "\xEE": "i", 710 "\xEF": "i", 711 "\u1E2F": "i", 712 "\u020B": "i", 713 "\u1EC9": "i", 714 "\u1ECB": "i", 715 "\xF0": "d", 716 "\xF1": "n", 717 "\xF2": "o", 718 "\xF3": "o", 719 "\xF4": "o", 720 "\xF5": "o", 721 "\xF6": "o", 722 "\xF8": "o", 723 "\u1ED1": "o", 724 "\u1E4D": "o", 725 "\u1E53": "o", 726 "\u020F": "o", 727 "\u1ECF": "o", 728 "\u1ECD": "o", 729 "\u1ED5": "o", 730 "\u1ED7": "o", 731 "\u1ED9": "o", 732 "\u1EDD": "o", 733 "\u1EDF": "o", 734 "\u1EE1": "o", 735 "\u1EDB": "o", 736 "\u1EE3": "o", 737 "\xF9": "u", 738 "\xFA": "u", 739 "\xFB": "u", 740 "\xFC": "u", 741 "\u1EE7": "u", 742 "\u1EE5": "u", 743 "\u1EED": "u", 744 "\u1EEF": "u", 745 "\u1EF1": "u", 746 "\xFD": "y", 747 "\xFF": "y", 748 "\u0100": "A", 749 "\u0101": "a", 750 "\u0102": "A", 751 "\u0103": "a", 752 "\u0104": "A", 753 "\u0105": "a", 754 "\u0106": "C", 755 "\u0107": "c", 756 "\u0108": "C", 757 "\u0109": "c", 758 "\u010A": "C", 759 "\u010B": "c", 760 "\u010C": "C", 761 "\u010D": "c", 762 "C\u0306": "C", 763 "c\u0306": "c", 764 "\u010E": "D", 765 "\u010F": "d", 766 "\u0110": "D", 767 "\u0111": "d", 768 "\u0112": "E", 769 "\u0113": "e", 770 "\u0114": "E", 771 "\u0115": "e", 772 "\u0116": "E", 773 "\u0117": "e", 774 "\u0118": "E", 775 "\u0119": "e", 776 "\u011A": "E", 777 "\u011B": "e", 778 "\u011C": "G", 779 "\u01F4": "G", 780 "\u011D": "g", 781 "\u01F5": "g", 782 "\u011E": "G", 783 "\u011F": "g", 784 "\u0120": "G", 785 "\u0121": "g", 786 "\u0122": "G", 787 "\u0123": "g", 788 "\u0124": "H", 789 "\u0125": "h", 790 "\u0126": "H", 791 "\u0127": "h", 792 "\u1E2A": "H", 793 "\u1E2B": "h", 794 "\u0128": "I", 795 "\u0129": "i", 796 "\u012A": "I", 797 "\u012B": "i", 798 "\u012C": "I", 799 "\u012D": "i", 800 "\u012E": "I", 801 "\u012F": "i", 802 "\u0130": "I", 803 "\u0131": "i", 804 "\u0132": "IJ", 805 "\u0133": "ij", 806 "\u0134": "J", 807 "\u0135": "j", 808 "\u0136": "K", 809 "\u0137": "k", 810 "\u1E30": "K", 811 "\u1E31": "k", 812 "K\u0306": "K", 813 "k\u0306": "k", 814 "\u0139": "L", 815 "\u013A": "l", 816 "\u013B": "L", 817 "\u013C": "l", 818 "\u013D": "L", 819 "\u013E": "l", 820 "\u013F": "L", 821 "\u0140": "l", 822 "\u0141": "l", 823 "\u0142": "l", 824 "\u1E3E": "M", 825 "\u1E3F": "m", 826 "M\u0306": "M", 827 "m\u0306": "m", 828 "\u0143": "N", 829 "\u0144": "n", 830 "\u0145": "N", 831 "\u0146": "n", 832 "\u0147": "N", 833 "\u0148": "n", 834 "\u0149": "n", 835 "N\u0306": "N", 836 "n\u0306": "n", 837 "\u014C": "O", 838 "\u014D": "o", 839 "\u014E": "O", 840 "\u014F": "o", 841 "\u0150": "O", 842 "\u0151": "o", 843 "\u0152": "OE", 844 "\u0153": "oe", 845 "P\u0306": "P", 846 "p\u0306": "p", 847 "\u0154": "R", 848 "\u0155": "r", 849 "\u0156": "R", 850 "\u0157": "r", 851 "\u0158": "R", 852 "\u0159": "r", 853 "R\u0306": "R", 854 "r\u0306": "r", 855 "\u0212": "R", 856 "\u0213": "r", 857 "\u015A": "S", 858 "\u015B": "s", 859 "\u015C": "S", 860 "\u015D": "s", 861 "\u015E": "S", 862 "\u0218": "S", 863 "\u0219": "s", 864 "\u015F": "s", 865 "\u0160": "S", 866 "\u0161": "s", 867 "\u0162": "T", 868 "\u0163": "t", 869 "\u021B": "t", 870 "\u021A": "T", 871 "\u0164": "T", 872 "\u0165": "t", 873 "\u0166": "T", 874 "\u0167": "t", 875 "T\u0306": "T", 876 "t\u0306": "t", 877 "\u0168": "U", 878 "\u0169": "u", 879 "\u016A": "U", 880 "\u016B": "u", 881 "\u016C": "U", 882 "\u016D": "u", 883 "\u016E": "U", 884 "\u016F": "u", 885 "\u0170": "U", 886 "\u0171": "u", 887 "\u0172": "U", 888 "\u0173": "u", 889 "\u0216": "U", 890 "\u0217": "u", 891 "V\u0306": "V", 892 "v\u0306": "v", 893 "\u0174": "W", 894 "\u0175": "w", 895 "\u1E82": "W", 896 "\u1E83": "w", 897 "X\u0306": "X", 898 "x\u0306": "x", 899 "\u0176": "Y", 900 "\u0177": "y", 901 "\u0178": "Y", 902 "Y\u0306": "Y", 903 "y\u0306": "y", 904 "\u0179": "Z", 905 "\u017A": "z", 906 "\u017B": "Z", 907 "\u017C": "z", 908 "\u017D": "Z", 909 "\u017E": "z", 910 "\u017F": "s", 911 "\u0192": "f", 912 "\u01A0": "O", 913 "\u01A1": "o", 914 "\u01AF": "U", 915 "\u01B0": "u", 916 "\u01CD": "A", 917 "\u01CE": "a", 918 "\u01CF": "I", 919 "\u01D0": "i", 920 "\u01D1": "O", 921 "\u01D2": "o", 922 "\u01D3": "U", 923 "\u01D4": "u", 924 "\u01D5": "U", 925 "\u01D6": "u", 926 "\u01D7": "U", 927 "\u01D8": "u", 928 "\u01D9": "U", 929 "\u01DA": "u", 930 "\u01DB": "U", 931 "\u01DC": "u", 932 "\u1EE8": "U", 933 "\u1EE9": "u", 934 "\u1E78": "U", 935 "\u1E79": "u", 936 "\u01FA": "A", 937 "\u01FB": "a", 938 "\u01FC": "AE", 939 "\u01FD": "ae", 940 "\u01FE": "O", 941 "\u01FF": "o", 942 "\xDE": "TH", 943 "\xFE": "th", 944 "\u1E54": "P", 945 "\u1E55": "p", 946 "\u1E64": "S", 947 "\u1E65": "s", 948 "X\u0301": "X", 949 "x\u0301": "x", 950 "\u0403": "\u0413", 951 "\u0453": "\u0433", 952 "\u040C": "\u041A", 953 "\u045C": "\u043A", 954 "A\u030B": "A", 955 "a\u030B": "a", 956 "E\u030B": "E", 957 "e\u030B": "e", 958 "I\u030B": "I", 959 "i\u030B": "i", 960 "\u01F8": "N", 961 "\u01F9": "n", 962 "\u1ED2": "O", 963 "\u1ED3": "o", 964 "\u1E50": "O", 965 "\u1E51": "o", 966 "\u1EEA": "U", 967 "\u1EEB": "u", 968 "\u1E80": "W", 969 "\u1E81": "w", 970 "\u1EF2": "Y", 971 "\u1EF3": "y", 972 "\u0200": "A", 973 "\u0201": "a", 974 "\u0204": "E", 975 "\u0205": "e", 976 "\u0208": "I", 977 "\u0209": "i", 978 "\u020C": "O", 979 "\u020D": "o", 980 "\u0210": "R", 981 "\u0211": "r", 982 "\u0214": "U", 983 "\u0215": "u", 984 "B\u030C": "B", 985 "b\u030C": "b", 986 "\u010C\u0323": "C", 987 "\u010D\u0323": "c", 988 "\xCA\u030C": "E", 989 "\xEA\u030C": "e", 990 "F\u030C": "F", 991 "f\u030C": "f", 992 "\u01E6": "G", 993 "\u01E7": "g", 994 "\u021E": "H", 995 "\u021F": "h", 996 "J\u030C": "J", 997 "\u01F0": "j", 998 "\u01E8": "K", 999 "\u01E9": "k", 1000 "M\u030C": "M", 1001 "m\u030C": "m", 1002 "P\u030C": "P", 1003 "p\u030C": "p", 1004 "Q\u030C": "Q", 1005 "q\u030C": "q", 1006 "\u0158\u0329": "R", 1007 "\u0159\u0329": "r", 1008 "\u1E66": "S", 1009 "\u1E67": "s", 1010 "V\u030C": "V", 1011 "v\u030C": "v", 1012 "W\u030C": "W", 1013 "w\u030C": "w", 1014 "X\u030C": "X", 1015 "x\u030C": "x", 1016 "Y\u030C": "Y", 1017 "y\u030C": "y", 1018 "A\u0327": "A", 1019 "a\u0327": "a", 1020 "B\u0327": "B", 1021 "b\u0327": "b", 1022 "\u1E10": "D", 1023 "\u1E11": "d", 1024 "\u0228": "E", 1025 "\u0229": "e", 1026 "\u0190\u0327": "E", 1027 "\u025B\u0327": "e", 1028 "\u1E28": "H", 1029 "\u1E29": "h", 1030 "I\u0327": "I", 1031 "i\u0327": "i", 1032 "\u0197\u0327": "I", 1033 "\u0268\u0327": "i", 1034 "M\u0327": "M", 1035 "m\u0327": "m", 1036 "O\u0327": "O", 1037 "o\u0327": "o", 1038 "Q\u0327": "Q", 1039 "q\u0327": "q", 1040 "U\u0327": "U", 1041 "u\u0327": "u", 1042 "X\u0327": "X", 1043 "x\u0327": "x", 1044 "Z\u0327": "Z", 1045 "z\u0327": "z", 1046 "\u0439": "\u0438", 1047 "\u0419": "\u0418", 1048 "\u0451": "\u0435", 1049 "\u0401": "\u0415" 1050 }; 1051 var chars = Object.keys(characterMap).join("|"); 1052 var allAccents = new RegExp(chars, "g"); 1053 var firstAccent = new RegExp(chars, ""); 1054 function matcher(match3) { 1055 return characterMap[match3]; 1056 } 1057 var removeAccents3 = function(string) { 1058 return string.replace(allAccents, matcher); 1059 }; 1060 var hasAccents = function(string) { 1061 return !!string.match(firstAccent); 1062 }; 1063 module.exports = removeAccents3; 1064 module.exports.has = hasAccents; 1065 module.exports.remove = removeAccents3; 1066 } 1067 }); 1068 1069 // package-external:@wordpress/date 1070 var require_date = __commonJS({ 1071 "package-external:@wordpress/date"(exports, module) { 1072 module.exports = window.wp.date; 1073 } 1074 }); 1075 1076 // package-external:@wordpress/warning 1077 var require_warning = __commonJS({ 1078 "package-external:@wordpress/warning"(exports, module) { 1079 module.exports = window.wp.warning; 1080 } 1081 }); 1082 1083 // package-external:@wordpress/rich-text 1084 var require_rich_text = __commonJS({ 1085 "package-external:@wordpress/rich-text"(exports, module) { 1086 module.exports = window.wp.richText; 1087 } 1088 }); 1089 1090 // package-external:@wordpress/media-utils 1091 var require_media_utils = __commonJS({ 1092 "package-external:@wordpress/media-utils"(exports, module) { 1093 module.exports = window.wp.mediaUtils; 1094 } 1095 }); 1096 1097 // packages/edit-site/build-module/index.mjs 1098 var index_exports = {}; 1099 __export(index_exports, { 1100 PluginMoreMenuItem: () => PluginMoreMenuItem, 1101 PluginSidebar: () => PluginSidebar, 1102 PluginSidebarMoreMenuItem: () => PluginSidebarMoreMenuItem, 1103 PluginTemplateSettingPanel: () => plugin_template_setting_panel_default, 1104 initializeEditor: () => initializeEditor, 1105 reinitializeEditor: () => reinitializeEditor, 1106 store: () => store 1107 }); 1108 var import_blocks15 = __toESM(require_blocks(), 1); 1109 var import_block_library4 = __toESM(require_block_library(), 1); 1110 var import_data90 = __toESM(require_data(), 1); 1111 var import_deprecated6 = __toESM(require_deprecated(), 1); 1112 var import_element201 = __toESM(require_element(), 1); 1113 var import_editor47 = __toESM(require_editor(), 1); 1114 var import_preferences13 = __toESM(require_preferences(), 1); 1115 var import_widgets = __toESM(require_widgets(), 1); 1116 1117 // packages/edit-site/build-module/store/index.mjs 1118 var import_data3 = __toESM(require_data(), 1); 1119 1120 // packages/edit-site/build-module/store/reducer.mjs 1121 var import_data = __toESM(require_data(), 1); 1122 function settings(state = {}, action) { 1123 switch (action.type) { 1124 case "UPDATE_SETTINGS": 1125 return { 1126 ...state, 1127 ...action.settings 1128 }; 1129 } 1130 return state; 1131 } 1132 function editedPost(state = {}, action) { 1133 switch (action.type) { 1134 case "SET_EDITED_POST": 1135 return { 1136 postType: action.postType, 1137 id: action.id, 1138 context: action.context 1139 }; 1140 case "SET_EDITED_POST_CONTEXT": 1141 return { 1142 ...state, 1143 context: action.context 1144 }; 1145 } 1146 return state; 1147 } 1148 function saveViewPanel(state = false, action) { 1149 switch (action.type) { 1150 case "SET_IS_SAVE_VIEW_OPENED": 1151 return action.isOpen; 1152 } 1153 return state; 1154 } 1155 function routes(state = [], action) { 1156 switch (action.type) { 1157 case "REGISTER_ROUTE": 1158 return [...state, action.route]; 1159 case "UNREGISTER_ROUTE": 1160 return state.filter((route) => route.name !== action.name); 1161 } 1162 return state; 1163 } 1164 var reducer_default = (0, import_data.combineReducers)({ 1165 settings, 1166 editedPost, 1167 saveViewPanel, 1168 routes 1169 }); 1170 1171 // packages/edit-site/build-module/store/actions.mjs 1172 var actions_exports = {}; 1173 __export(actions_exports, { 1174 __experimentalSetPreviewDeviceType: () => __experimentalSetPreviewDeviceType, 1175 addTemplate: () => addTemplate, 1176 closeGeneralSidebar: () => closeGeneralSidebar, 1177 openGeneralSidebar: () => openGeneralSidebar, 1178 openNavigationPanelToMenu: () => openNavigationPanelToMenu, 1179 removeTemplate: () => removeTemplate, 1180 revertTemplate: () => revertTemplate, 1181 setEditedEntity: () => setEditedEntity, 1182 setEditedPostContext: () => setEditedPostContext, 1183 setHasPageContentFocus: () => setHasPageContentFocus, 1184 setHomeTemplateId: () => setHomeTemplateId, 1185 setIsInserterOpened: () => setIsInserterOpened, 1186 setIsListViewOpened: () => setIsListViewOpened, 1187 setIsNavigationPanelOpened: () => setIsNavigationPanelOpened, 1188 setIsSaveViewOpened: () => setIsSaveViewOpened, 1189 setNavigationMenu: () => setNavigationMenu, 1190 setNavigationPanelActiveMenu: () => setNavigationPanelActiveMenu, 1191 setPage: () => setPage, 1192 setTemplate: () => setTemplate, 1193 setTemplatePart: () => setTemplatePart, 1194 switchEditorMode: () => switchEditorMode, 1195 toggleDistractionFree: () => toggleDistractionFree, 1196 toggleFeature: () => toggleFeature, 1197 updateSettings: () => updateSettings 1198 }); 1199 var import_blocks = __toESM(require_blocks(), 1); 1200 var import_deprecated = __toESM(require_deprecated(), 1); 1201 var import_core_data = __toESM(require_core_data(), 1); 1202 var import_block_editor = __toESM(require_block_editor(), 1); 1203 var import_editor = __toESM(require_editor(), 1); 1204 var import_preferences = __toESM(require_preferences(), 1); 1205 1206 // packages/edit-site/build-module/utils/constants.mjs 1207 var import_i18n = __toESM(require_i18n(), 1); 1208 var import_patterns = __toESM(require_patterns(), 1); 1209 1210 // packages/edit-site/build-module/lock-unlock.mjs 1211 var import_private_apis = __toESM(require_private_apis(), 1); 1212 var { lock, unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)( 1213 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.", 1214 "@wordpress/edit-site" 1215 ); 1216 1217 // packages/edit-site/build-module/utils/constants.mjs 1218 var ATTACHMENT_POST_TYPE = "attachment"; 1219 var NAVIGATION_POST_TYPE = "wp_navigation"; 1220 var TEMPLATE_POST_TYPE = "wp_template"; 1221 var TEMPLATE_PART_POST_TYPE = "wp_template_part"; 1222 var TEMPLATE_ORIGINS = { 1223 custom: "custom", 1224 theme: "theme", 1225 plugin: "plugin" 1226 }; 1227 var TEMPLATE_PART_AREA_DEFAULT_CATEGORY = "uncategorized"; 1228 var TEMPLATE_PART_ALL_AREAS_CATEGORY = "all-parts"; 1229 var { 1230 PATTERN_TYPES, 1231 PATTERN_DEFAULT_CATEGORY, 1232 PATTERN_USER_CATEGORY, 1233 EXCLUDED_PATTERN_SOURCES, 1234 PATTERN_SYNC_TYPES 1235 } = unlock(import_patterns.privateApis); 1236 var FOCUSABLE_ENTITIES = [ 1237 TEMPLATE_PART_POST_TYPE, 1238 NAVIGATION_POST_TYPE, 1239 PATTERN_TYPES.user 1240 ]; 1241 var POST_TYPE_LABELS = { 1242 [TEMPLATE_POST_TYPE]: (0, import_i18n.__)("Template"), 1243 [TEMPLATE_PART_POST_TYPE]: (0, import_i18n.__)("Template part"), 1244 [PATTERN_TYPES.user]: (0, import_i18n.__)("Pattern"), 1245 [NAVIGATION_POST_TYPE]: (0, import_i18n.__)("Navigation") 1246 }; 1247 var LAYOUT_LIST = "list"; 1248 var OPERATOR_IS_ANY = "isAny"; 1249 var OPERATOR_IS_NONE = "isNone"; 1250 var OPERATOR_BEFORE = "before"; 1251 var OPERATOR_AFTER = "after"; 1252 1253 // packages/edit-site/build-module/store/actions.mjs 1254 var { interfaceStore } = unlock(import_editor.privateApis); 1255 function toggleFeature(featureName) { 1256 return function({ registry }) { 1257 (0, import_deprecated.default)( 1258 "dispatch( 'core/edit-site' ).toggleFeature( featureName )", 1259 { 1260 since: "6.0", 1261 alternative: "dispatch( 'core/preferences').toggle( 'core/edit-site', featureName )" 1262 } 1263 ); 1264 registry.dispatch(import_preferences.store).toggle("core/edit-site", featureName); 1265 }; 1266 } 1267 var __experimentalSetPreviewDeviceType = (deviceType) => ({ registry }) => { 1268 (0, import_deprecated.default)( 1269 "dispatch( 'core/edit-site' ).__experimentalSetPreviewDeviceType", 1270 { 1271 since: "6.5", 1272 version: "6.7", 1273 hint: "registry.dispatch( editorStore ).setDeviceType" 1274 } 1275 ); 1276 registry.dispatch(import_editor.store).setDeviceType(deviceType); 1277 }; 1278 function setTemplate() { 1279 (0, import_deprecated.default)("dispatch( 'core/edit-site' ).setTemplate", { 1280 since: "6.5", 1281 version: "6.8", 1282 hint: "The setTemplate is not needed anymore, the correct entity is resolved from the URL automatically." 1283 }); 1284 return { 1285 type: "NOTHING" 1286 }; 1287 } 1288 var addTemplate = (template) => async ({ dispatch: dispatch2, registry }) => { 1289 (0, import_deprecated.default)("dispatch( 'core/edit-site' ).addTemplate", { 1290 since: "6.5", 1291 version: "6.8", 1292 hint: "use saveEntityRecord directly" 1293 }); 1294 const newTemplate = await registry.dispatch(import_core_data.store).saveEntityRecord("postType", TEMPLATE_POST_TYPE, template); 1295 if (template.content) { 1296 registry.dispatch(import_core_data.store).editEntityRecord( 1297 "postType", 1298 TEMPLATE_POST_TYPE, 1299 newTemplate.id, 1300 { blocks: (0, import_blocks.parse)(template.content) }, 1301 { undoIgnore: true } 1302 ); 1303 } 1304 dispatch2({ 1305 type: "SET_EDITED_POST", 1306 postType: TEMPLATE_POST_TYPE, 1307 id: newTemplate.id 1308 }); 1309 }; 1310 var removeTemplate = (template) => ({ registry }) => { 1311 return unlock(registry.dispatch(import_editor.store)).removeTemplates([ 1312 template 1313 ]); 1314 }; 1315 function setTemplatePart(templatePartId) { 1316 (0, import_deprecated.default)("dispatch( 'core/edit-site' ).setTemplatePart", { 1317 since: "6.8" 1318 }); 1319 return { 1320 type: "SET_EDITED_POST", 1321 postType: TEMPLATE_PART_POST_TYPE, 1322 id: templatePartId 1323 }; 1324 } 1325 function setNavigationMenu(navigationMenuId) { 1326 (0, import_deprecated.default)("dispatch( 'core/edit-site' ).setNavigationMenu", { 1327 since: "6.8" 1328 }); 1329 return { 1330 type: "SET_EDITED_POST", 1331 postType: NAVIGATION_POST_TYPE, 1332 id: navigationMenuId 1333 }; 1334 } 1335 function setEditedEntity(postType2, postId, context) { 1336 return { 1337 type: "SET_EDITED_POST", 1338 postType: postType2, 1339 id: postId, 1340 context 1341 }; 1342 } 1343 function setHomeTemplateId() { 1344 (0, import_deprecated.default)("dispatch( 'core/edit-site' ).setHomeTemplateId", { 1345 since: "6.2", 1346 version: "6.4" 1347 }); 1348 return { 1349 type: "NOTHING" 1350 }; 1351 } 1352 function setEditedPostContext(context) { 1353 (0, import_deprecated.default)("dispatch( 'core/edit-site' ).setEditedPostContext", { 1354 since: "6.8" 1355 }); 1356 return { 1357 type: "SET_EDITED_POST_CONTEXT", 1358 context 1359 }; 1360 } 1361 function setPage() { 1362 (0, import_deprecated.default)("dispatch( 'core/edit-site' ).setPage", { 1363 since: "6.5", 1364 version: "6.8", 1365 hint: "The setPage is not needed anymore, the correct entity is resolved from the URL automatically." 1366 }); 1367 return { type: "NOTHING" }; 1368 } 1369 function setNavigationPanelActiveMenu() { 1370 (0, import_deprecated.default)("dispatch( 'core/edit-site' ).setNavigationPanelActiveMenu", { 1371 since: "6.2", 1372 version: "6.4" 1373 }); 1374 return { type: "NOTHING" }; 1375 } 1376 function openNavigationPanelToMenu() { 1377 (0, import_deprecated.default)("dispatch( 'core/edit-site' ).openNavigationPanelToMenu", { 1378 since: "6.2", 1379 version: "6.4" 1380 }); 1381 return { type: "NOTHING" }; 1382 } 1383 function setIsNavigationPanelOpened() { 1384 (0, import_deprecated.default)("dispatch( 'core/edit-site' ).setIsNavigationPanelOpened", { 1385 since: "6.2", 1386 version: "6.4" 1387 }); 1388 return { type: "NOTHING" }; 1389 } 1390 var setIsInserterOpened = (value) => ({ registry }) => { 1391 (0, import_deprecated.default)("dispatch( 'core/edit-site' ).setIsInserterOpened", { 1392 since: "6.5", 1393 alternative: "dispatch( 'core/editor').setIsInserterOpened" 1394 }); 1395 registry.dispatch(import_editor.store).setIsInserterOpened(value); 1396 }; 1397 var setIsListViewOpened = (isOpen) => ({ registry }) => { 1398 (0, import_deprecated.default)("dispatch( 'core/edit-site' ).setIsListViewOpened", { 1399 since: "6.5", 1400 alternative: "dispatch( 'core/editor').setIsListViewOpened" 1401 }); 1402 registry.dispatch(import_editor.store).setIsListViewOpened(isOpen); 1403 }; 1404 function updateSettings(settings2) { 1405 return { 1406 type: "UPDATE_SETTINGS", 1407 settings: settings2 1408 }; 1409 } 1410 function setIsSaveViewOpened(isOpen) { 1411 return { 1412 type: "SET_IS_SAVE_VIEW_OPENED", 1413 isOpen 1414 }; 1415 } 1416 var revertTemplate = (template, options) => ({ registry }) => { 1417 return unlock(registry.dispatch(import_editor.store)).revertTemplate( 1418 template, 1419 options 1420 ); 1421 }; 1422 var openGeneralSidebar = (name2) => ({ registry }) => { 1423 registry.dispatch(interfaceStore).enableComplementaryArea("core", name2); 1424 }; 1425 var closeGeneralSidebar = () => ({ registry }) => { 1426 registry.dispatch(interfaceStore).disableComplementaryArea("core"); 1427 }; 1428 var switchEditorMode = (mode) => ({ registry }) => { 1429 (0, import_deprecated.default)("dispatch( 'core/edit-site' ).switchEditorMode", { 1430 since: "6.6", 1431 alternative: "dispatch( 'core/editor').switchEditorMode" 1432 }); 1433 registry.dispatch(import_editor.store).switchEditorMode(mode); 1434 }; 1435 var setHasPageContentFocus = (hasPageContentFocus2) => ({ dispatch: dispatch2, registry }) => { 1436 (0, import_deprecated.default)(`dispatch( 'core/edit-site' ).setHasPageContentFocus`, { 1437 since: "6.5" 1438 }); 1439 if (hasPageContentFocus2) { 1440 registry.dispatch(import_block_editor.store).clearSelectedBlock(); 1441 } 1442 dispatch2({ 1443 type: "SET_HAS_PAGE_CONTENT_FOCUS", 1444 hasPageContentFocus: hasPageContentFocus2 1445 }); 1446 }; 1447 var toggleDistractionFree = () => ({ registry }) => { 1448 (0, import_deprecated.default)("dispatch( 'core/edit-site' ).toggleDistractionFree", { 1449 since: "6.6", 1450 alternative: "dispatch( 'core/editor').toggleDistractionFree" 1451 }); 1452 registry.dispatch(import_editor.store).toggleDistractionFree(); 1453 }; 1454 1455 // packages/edit-site/build-module/store/private-actions.mjs 1456 var private_actions_exports = {}; 1457 __export(private_actions_exports, { 1458 registerRoute: () => registerRoute, 1459 unregisterRoute: () => unregisterRoute 1460 }); 1461 function registerRoute(route) { 1462 return { 1463 type: "REGISTER_ROUTE", 1464 route 1465 }; 1466 } 1467 function unregisterRoute(name2) { 1468 return { 1469 type: "UNREGISTER_ROUTE", 1470 name: name2 1471 }; 1472 } 1473 1474 // packages/edit-site/build-module/store/selectors.mjs 1475 var selectors_exports = {}; 1476 __export(selectors_exports, { 1477 __experimentalGetInsertionPoint: () => __experimentalGetInsertionPoint, 1478 __experimentalGetPreviewDeviceType: () => __experimentalGetPreviewDeviceType, 1479 getCanUserCreateMedia: () => getCanUserCreateMedia, 1480 getCurrentTemplateNavigationPanelSubMenu: () => getCurrentTemplateNavigationPanelSubMenu, 1481 getCurrentTemplateTemplateParts: () => getCurrentTemplateTemplateParts, 1482 getEditedPostContext: () => getEditedPostContext, 1483 getEditedPostId: () => getEditedPostId, 1484 getEditedPostType: () => getEditedPostType, 1485 getEditorMode: () => getEditorMode, 1486 getHomeTemplateId: () => getHomeTemplateId, 1487 getNavigationPanelActiveMenu: () => getNavigationPanelActiveMenu, 1488 getPage: () => getPage, 1489 getReusableBlocks: () => getReusableBlocks, 1490 getSettings: () => getSettings, 1491 hasPageContentFocus: () => hasPageContentFocus, 1492 isFeatureActive: () => isFeatureActive, 1493 isInserterOpened: () => isInserterOpened, 1494 isListViewOpened: () => isListViewOpened, 1495 isNavigationOpened: () => isNavigationOpened, 1496 isPage: () => isPage, 1497 isSaveViewOpened: () => isSaveViewOpened 1498 }); 1499 var import_core_data2 = __toESM(require_core_data(), 1); 1500 var import_data2 = __toESM(require_data(), 1); 1501 var import_deprecated2 = __toESM(require_deprecated(), 1); 1502 var import_preferences2 = __toESM(require_preferences(), 1); 1503 var import_editor2 = __toESM(require_editor(), 1); 1504 var import_block_editor2 = __toESM(require_block_editor(), 1); 1505 1506 // packages/edit-site/build-module/utils/get-filtered-template-parts.mjs 1507 var import_blocks2 = __toESM(require_blocks(), 1); 1508 var EMPTY_ARRAY = []; 1509 function getFilteredTemplatePartBlocks(blocks = EMPTY_ARRAY, templateParts) { 1510 const templatePartsById = templateParts ? ( 1511 // Key template parts by their ID. 1512 templateParts.reduce( 1513 (newTemplateParts, part) => ({ 1514 ...newTemplateParts, 1515 [part.id]: part 1516 }), 1517 {} 1518 ) 1519 ) : {}; 1520 const result = []; 1521 const stack = [...blocks]; 1522 while (stack.length) { 1523 const { innerBlocks, ...block } = stack.shift(); 1524 stack.unshift(...innerBlocks); 1525 if ((0, import_blocks2.isTemplatePart)(block)) { 1526 const { 1527 attributes: { theme: theme2, slug } 1528 } = block; 1529 const templatePartId = `$theme2}//${slug}`; 1530 const templatePart = templatePartsById[templatePartId]; 1531 if (templatePart) { 1532 result.push({ 1533 templatePart, 1534 block 1535 }); 1536 } 1537 } 1538 } 1539 return result; 1540 } 1541 1542 // packages/edit-site/build-module/store/selectors.mjs 1543 var isFeatureActive = (0, import_data2.createRegistrySelector)( 1544 (select4) => (_, featureName) => { 1545 (0, import_deprecated2.default)(`select( 'core/edit-site' ).isFeatureActive`, { 1546 since: "6.0", 1547 alternative: `select( 'core/preferences' ).get` 1548 }); 1549 return !!select4(import_preferences2.store).get( 1550 "core/edit-site", 1551 featureName 1552 ); 1553 } 1554 ); 1555 var __experimentalGetPreviewDeviceType = (0, import_data2.createRegistrySelector)( 1556 (select4) => () => { 1557 (0, import_deprecated2.default)( 1558 `select( 'core/edit-site' ).__experimentalGetPreviewDeviceType`, 1559 { 1560 since: "6.5", 1561 version: "6.7", 1562 alternative: `select( 'core/editor' ).getDeviceType` 1563 } 1564 ); 1565 return select4(import_editor2.store).getDeviceType(); 1566 } 1567 ); 1568 var getCanUserCreateMedia = (0, import_data2.createRegistrySelector)( 1569 (select4) => () => { 1570 (0, import_deprecated2.default)( 1571 `wp.data.select( 'core/edit-site' ).getCanUserCreateMedia()`, 1572 { 1573 since: "6.7", 1574 alternative: `wp.data.select( 'core' ).canUser( 'create', { kind: 'postType', type: 'attachment' } )` 1575 } 1576 ); 1577 return select4(import_core_data2.store).canUser("create", "media"); 1578 } 1579 ); 1580 var getReusableBlocks = (0, import_data2.createRegistrySelector)((select4) => () => { 1581 (0, import_deprecated2.default)(`select( 'core/edit-site' ).getReusableBlocks()`, { 1582 since: "6.5", 1583 version: "6.8", 1584 alternative: `select( 'core/core' ).getEntityRecords( 'postType', 'wp_block' )` 1585 }); 1586 return select4(import_core_data2.store).getEntityRecords("postType", "wp_block", { 1587 per_page: -1 1588 }); 1589 }); 1590 function getSettings(state) { 1591 return state.settings; 1592 } 1593 function getHomeTemplateId() { 1594 (0, import_deprecated2.default)("select( 'core/edit-site' ).getHomeTemplateId", { 1595 since: "6.2", 1596 version: "6.4" 1597 }); 1598 } 1599 function getEditedPostType(state) { 1600 (0, import_deprecated2.default)("select( 'core/edit-site' ).getEditedPostType", { 1601 since: "6.8", 1602 alternative: "select( 'core/editor' ).getCurrentPostType" 1603 }); 1604 return state.editedPost.postType; 1605 } 1606 function getEditedPostId(state) { 1607 (0, import_deprecated2.default)("select( 'core/edit-site' ).getEditedPostId", { 1608 since: "6.8", 1609 alternative: "select( 'core/editor' ).getCurrentPostId" 1610 }); 1611 return state.editedPost.id; 1612 } 1613 function getEditedPostContext(state) { 1614 (0, import_deprecated2.default)("select( 'core/edit-site' ).getEditedPostContext", { 1615 since: "6.8" 1616 }); 1617 return state.editedPost.context; 1618 } 1619 function getPage(state) { 1620 (0, import_deprecated2.default)("select( 'core/edit-site' ).getPage", { 1621 since: "6.8" 1622 }); 1623 return { context: state.editedPost.context }; 1624 } 1625 var isInserterOpened = (0, import_data2.createRegistrySelector)((select4) => () => { 1626 (0, import_deprecated2.default)(`select( 'core/edit-site' ).isInserterOpened`, { 1627 since: "6.5", 1628 alternative: `select( 'core/editor' ).isInserterOpened` 1629 }); 1630 return select4(import_editor2.store).isInserterOpened(); 1631 }); 1632 var __experimentalGetInsertionPoint = (0, import_data2.createRegistrySelector)( 1633 (select4) => () => { 1634 (0, import_deprecated2.default)( 1635 `select( 'core/edit-site' ).__experimentalGetInsertionPoint`, 1636 { 1637 since: "6.5", 1638 version: "6.7" 1639 } 1640 ); 1641 return unlock(select4(import_editor2.store)).getInserter(); 1642 } 1643 ); 1644 var isListViewOpened = (0, import_data2.createRegistrySelector)((select4) => () => { 1645 (0, import_deprecated2.default)(`select( 'core/edit-site' ).isListViewOpened`, { 1646 since: "6.5", 1647 alternative: `select( 'core/editor' ).isListViewOpened` 1648 }); 1649 return select4(import_editor2.store).isListViewOpened(); 1650 }); 1651 function isSaveViewOpened(state) { 1652 return state.saveViewPanel; 1653 } 1654 function getBlocksAndTemplateParts(select4) { 1655 const templateParts = select4(import_core_data2.store).getEntityRecords( 1656 "postType", 1657 TEMPLATE_PART_POST_TYPE, 1658 { per_page: -1 } 1659 ); 1660 const { getBlocksByName, getBlocksByClientId } = select4(import_block_editor2.store); 1661 const clientIds = getBlocksByName("core/template-part"); 1662 const blocks = getBlocksByClientId(clientIds); 1663 return [blocks, templateParts]; 1664 } 1665 var getCurrentTemplateTemplateParts = (0, import_data2.createRegistrySelector)( 1666 (select4) => (0, import_data2.createSelector)( 1667 () => { 1668 (0, import_deprecated2.default)( 1669 `select( 'core/edit-site' ).getCurrentTemplateTemplateParts()`, 1670 { 1671 since: "6.7", 1672 version: "6.9", 1673 alternative: `select( 'core/block-editor' ).getBlocksByName( 'core/template-part' )` 1674 } 1675 ); 1676 return getFilteredTemplatePartBlocks( 1677 ...getBlocksAndTemplateParts(select4) 1678 ); 1679 }, 1680 () => getBlocksAndTemplateParts(select4) 1681 ) 1682 ); 1683 var getEditorMode = (0, import_data2.createRegistrySelector)((select4) => () => { 1684 return select4(import_preferences2.store).get("core", "editorMode"); 1685 }); 1686 function getCurrentTemplateNavigationPanelSubMenu() { 1687 (0, import_deprecated2.default)( 1688 "dispatch( 'core/edit-site' ).getCurrentTemplateNavigationPanelSubMenu", 1689 { 1690 since: "6.2", 1691 version: "6.4" 1692 } 1693 ); 1694 } 1695 function getNavigationPanelActiveMenu() { 1696 (0, import_deprecated2.default)("dispatch( 'core/edit-site' ).getNavigationPanelActiveMenu", { 1697 since: "6.2", 1698 version: "6.4" 1699 }); 1700 } 1701 function isNavigationOpened() { 1702 (0, import_deprecated2.default)("dispatch( 'core/edit-site' ).isNavigationOpened", { 1703 since: "6.2", 1704 version: "6.4" 1705 }); 1706 } 1707 function isPage(state) { 1708 (0, import_deprecated2.default)("select( 'core/edit-site' ).isPage", { 1709 since: "6.8", 1710 alternative: "select( 'core/editor' ).getCurrentPostType" 1711 }); 1712 return !!state.editedPost.context?.postId; 1713 } 1714 function hasPageContentFocus() { 1715 (0, import_deprecated2.default)(`select( 'core/edit-site' ).hasPageContentFocus`, { 1716 since: "6.5" 1717 }); 1718 return false; 1719 } 1720 1721 // packages/edit-site/build-module/store/private-selectors.mjs 1722 var private_selectors_exports = {}; 1723 __export(private_selectors_exports, { 1724 getRoutes: () => getRoutes 1725 }); 1726 function getRoutes(state) { 1727 return state.routes; 1728 } 1729 1730 // packages/edit-site/build-module/store/constants.mjs 1731 var STORE_NAME = "core/edit-site"; 1732 1733 // packages/edit-site/build-module/store/index.mjs 1734 var storeConfig = { 1735 reducer: reducer_default, 1736 actions: actions_exports, 1737 selectors: selectors_exports 1738 }; 1739 var store = (0, import_data3.createReduxStore)(STORE_NAME, storeConfig); 1740 (0, import_data3.register)(store); 1741 unlock(store).registerPrivateSelectors(private_selectors_exports); 1742 unlock(store).registerPrivateActions(private_actions_exports); 1743 1744 // packages/edit-site/build-module/components/app/index.mjs 1745 var import_data89 = __toESM(require_data(), 1); 1746 var import_router38 = __toESM(require_router(), 1); 1747 var import_element200 = __toESM(require_element(), 1); 1748 var import_core_data69 = __toESM(require_core_data(), 1); 1749 1750 // node_modules/clsx/dist/clsx.mjs 1751 function r(e2) { 1752 var t3, f2, n2 = ""; 1753 if ("string" == typeof e2 || "number" == typeof e2) n2 += e2; 1754 else if ("object" == typeof e2) if (Array.isArray(e2)) { 1755 var o3 = e2.length; 1756 for (t3 = 0; t3 < o3; t3++) e2[t3] && (f2 = r(e2[t3])) && (n2 && (n2 += " "), n2 += f2); 1757 } else for (f2 in e2) e2[f2] && (n2 && (n2 += " "), n2 += f2); 1758 return n2; 1759 } 1760 function clsx() { 1761 for (var e2, t3, f2 = 0, n2 = "", o3 = arguments.length; f2 < o3; f2++) (e2 = arguments[f2]) && (t3 = r(e2)) && (n2 && (n2 += " "), n2 += t3); 1762 return n2; 1763 } 1764 var clsx_default = clsx; 1765 1766 // packages/ui/build-module/badge/badge.mjs 1767 var import_element11 = __toESM(require_element(), 1); 1768 1769 // node_modules/@base-ui/utils/useControlled.mjs 1770 var React = __toESM(require_react(), 1); 1771 1772 // node_modules/@base-ui/utils/error.mjs 1773 var set; 1774 if (true) { 1775 set = /* @__PURE__ */ new Set(); 1776 } 1777 function error(...messages) { 1778 if (true) { 1779 const messageKey = messages.join(" "); 1780 if (!set.has(messageKey)) { 1781 set.add(messageKey); 1782 console.error(`Base UI: $messageKey}`); 1783 } 1784 } 1785 } 1786 1787 // node_modules/@base-ui/utils/useControlled.mjs 1788 function useControlled({ 1789 controlled, 1790 default: defaultProp, 1791 name: name2, 1792 state = "value" 1793 }) { 1794 const { 1795 current: isControlled 1796 } = React.useRef(controlled !== void 0); 1797 const [valueState, setValue] = React.useState(defaultProp); 1798 const value = isControlled ? controlled : valueState; 1799 if (true) { 1800 React.useEffect(() => { 1801 if (isControlled !== (controlled !== void 0)) { 1802 error([`A component is changing the $isControlled ? "" : "un"}controlled $state} state of $name2} to be $isControlled ? "un" : ""}controlled.`, "Elements should not switch from uncontrolled to controlled (or vice versa).", `Decide between using a controlled or uncontrolled $name2} element for the lifetime of the component.`, "The nature of the state is determined during the first render. It's considered controlled if the value is not `undefined`.", "More info: https://fb.me/react-controlled-components"].join("\n")); 1803 } 1804 }, [state, name2, controlled]); 1805 const { 1806 current: defaultValue2 1807 } = React.useRef(defaultProp); 1808 React.useEffect(() => { 1809 if (!isControlled && serializeToDevModeString(defaultValue2) !== serializeToDevModeString(defaultProp)) { 1810 error([`A component is changing the default $state} state of an uncontrolled $name2} after being initialized. To suppress this warning opt to use a controlled $name2}.`].join("\n")); 1811 } 1812 }, [defaultProp]); 1813 } 1814 const setValueIfUncontrolled = React.useCallback((newValue) => { 1815 if (!isControlled) { 1816 setValue(newValue); 1817 } 1818 }, []); 1819 return [value, setValueIfUncontrolled]; 1820 } 1821 function serializeToDevModeString(input) { 1822 let nextId2 = 0; 1823 const seen = /* @__PURE__ */ new WeakMap(); 1824 try { 1825 const result = JSON.stringify(input, function replacer(key, value) { 1826 if (key === "_owner" && this != null && typeof this === "object" && "$$typeof" in this) { 1827 return void 0; 1828 } 1829 if (typeof value === "bigint") { 1830 return `__bigint__:$value}`; 1831 } 1832 if (value !== null && typeof value === "object") { 1833 const id = seen.get(value); 1834 if (id !== void 0) { 1835 return `__object__:$id}`; 1836 } 1837 seen.set(value, nextId2); 1838 nextId2 += 1; 1839 } 1840 return value; 1841 }); 1842 return result ?? `__top__:$typeof input}`; 1843 } catch { 1844 return "__unserializable__"; 1845 } 1846 } 1847 1848 // node_modules/@base-ui/utils/safeReact.mjs 1849 var React2 = __toESM(require_react(), 1); 1850 var SafeReact = { 1851 ...React2 1852 }; 1853 1854 // node_modules/@base-ui/utils/useRefWithInit.mjs 1855 var React3 = __toESM(require_react(), 1); 1856 var UNINITIALIZED = {}; 1857 function useRefWithInit(init2, initArg) { 1858 const ref = React3.useRef(UNINITIALIZED); 1859 if (ref.current === UNINITIALIZED) { 1860 ref.current = init2(initArg); 1861 } 1862 return ref; 1863 } 1864 1865 // node_modules/@base-ui/utils/useStableCallback.mjs 1866 var useInsertionEffect = SafeReact.useInsertionEffect; 1867 var useSafeInsertionEffect = ( 1868 // React 17 doesn't have useInsertionEffect. 1869 useInsertionEffect && // Preact replaces useInsertionEffect with useLayoutEffect and fires too late. 1870 useInsertionEffect !== SafeReact.useLayoutEffect ? useInsertionEffect : (fn) => fn() 1871 ); 1872 function useStableCallback(callback) { 1873 const stable = useRefWithInit(createStableCallback).current; 1874 stable.next = callback; 1875 useSafeInsertionEffect(stable.effect); 1876 return stable.trampoline; 1877 } 1878 function createStableCallback() { 1879 const stable = { 1880 next: void 0, 1881 callback: assertNotCalled, 1882 trampoline: (...args) => stable.callback?.(...args), 1883 effect: () => { 1884 stable.callback = stable.next; 1885 } 1886 }; 1887 return stable; 1888 } 1889 function assertNotCalled() { 1890 if (true) { 1891 throw ( 1892 /* minify-error-disabled */ 1893 new Error("Base UI: Cannot call an event handler while rendering.") 1894 ); 1895 } 1896 } 1897 1898 // node_modules/@base-ui/utils/useIsoLayoutEffect.mjs 1899 var React4 = __toESM(require_react(), 1); 1900 var noop = () => { 1901 }; 1902 var useIsoLayoutEffect = typeof document !== "undefined" ? React4.useLayoutEffect : noop; 1903 1904 // node_modules/@base-ui/utils/warn.mjs 1905 var set2; 1906 if (true) { 1907 set2 = /* @__PURE__ */ new Set(); 1908 } 1909 function warn(...messages) { 1910 if (true) { 1911 const messageKey = messages.join(" "); 1912 if (!set2.has(messageKey)) { 1913 set2.add(messageKey); 1914 console.warn(`Base UI: $messageKey}`); 1915 } 1916 } 1917 } 1918 1919 // node_modules/@base-ui/react/internals/direction-context/DirectionContext.mjs 1920 var React5 = __toESM(require_react(), 1); 1921 var DirectionContext = /* @__PURE__ */ React5.createContext(void 0); 1922 if (true) DirectionContext.displayName = "DirectionContext"; 1923 function useDirection() { 1924 const context = React5.useContext(DirectionContext); 1925 return context?.direction ?? "ltr"; 1926 } 1927 1928 // node_modules/@base-ui/react/internals/useRenderElement.mjs 1929 var React8 = __toESM(require_react(), 1); 1930 1931 // node_modules/@base-ui/utils/useMergedRefs.mjs 1932 function useMergedRefs(a2, b2, c6, d2) { 1933 const forkRef = useRefWithInit(createForkRef).current; 1934 if (didChange(forkRef, a2, b2, c6, d2)) { 1935 update(forkRef, [a2, b2, c6, d2]); 1936 } 1937 return forkRef.callback; 1938 } 1939 function useMergedRefsN(refs) { 1940 const forkRef = useRefWithInit(createForkRef).current; 1941 if (didChangeN(forkRef, refs)) { 1942 update(forkRef, refs); 1943 } 1944 return forkRef.callback; 1945 } 1946 function createForkRef() { 1947 return { 1948 callback: null, 1949 cleanup: null, 1950 refs: [] 1951 }; 1952 } 1953 function didChange(forkRef, a2, b2, c6, d2) { 1954 return forkRef.refs[0] !== a2 || forkRef.refs[1] !== b2 || forkRef.refs[2] !== c6 || forkRef.refs[3] !== d2; 1955 } 1956 function didChangeN(forkRef, newRefs) { 1957 return forkRef.refs.length !== newRefs.length || forkRef.refs.some((ref, index2) => ref !== newRefs[index2]); 1958 } 1959 function update(forkRef, refs) { 1960 forkRef.refs = refs; 1961 if (refs.every((ref) => ref == null)) { 1962 forkRef.callback = null; 1963 return; 1964 } 1965 forkRef.callback = (instance) => { 1966 if (forkRef.cleanup) { 1967 forkRef.cleanup(); 1968 forkRef.cleanup = null; 1969 } 1970 if (instance != null) { 1971 const cleanupCallbacks = Array(refs.length).fill(null); 1972 for (let i2 = 0; i2 < refs.length; i2 += 1) { 1973 const ref = refs[i2]; 1974 if (ref == null) { 1975 continue; 1976 } 1977 switch (typeof ref) { 1978 case "function": { 1979 const refCleanup = ref(instance); 1980 if (typeof refCleanup === "function") { 1981 cleanupCallbacks[i2] = refCleanup; 1982 } 1983 break; 1984 } 1985 case "object": { 1986 ref.current = instance; 1987 break; 1988 } 1989 default: 1990 } 1991 } 1992 forkRef.cleanup = () => { 1993 for (let i2 = 0; i2 < refs.length; i2 += 1) { 1994 const ref = refs[i2]; 1995 if (ref == null) { 1996 continue; 1997 } 1998 switch (typeof ref) { 1999 case "function": { 2000 const cleanupCallback = cleanupCallbacks[i2]; 2001 if (typeof cleanupCallback === "function") { 2002 cleanupCallback(); 2003 } else { 2004 ref(null); 2005 } 2006 break; 2007 } 2008 case "object": { 2009 ref.current = null; 2010 break; 2011 } 2012 default: 2013 } 2014 } 2015 }; 2016 } 2017 }; 2018 } 2019 2020 // node_modules/@base-ui/utils/getReactElementRef.mjs 2021 var React7 = __toESM(require_react(), 1); 2022 2023 // node_modules/@base-ui/utils/reactVersion.mjs 2024 var React6 = __toESM(require_react(), 1); 2025 var majorVersion = parseInt(React6.version, 10); 2026 function isReactVersionAtLeast(reactVersionToCheck) { 2027 return majorVersion >= reactVersionToCheck; 2028 } 2029 2030 // node_modules/@base-ui/utils/getReactElementRef.mjs 2031 function getReactElementRef(element) { 2032 if (!/* @__PURE__ */ React7.isValidElement(element)) { 2033 return null; 2034 } 2035 const reactElement = element; 2036 const propsWithRef = reactElement.props; 2037 return (isReactVersionAtLeast(19) ? propsWithRef?.ref : reactElement.ref) ?? null; 2038 } 2039 2040 // node_modules/@base-ui/utils/mergeObjects.mjs 2041 function mergeObjects(a2, b2) { 2042 if (a2 && !b2) { 2043 return a2; 2044 } 2045 if (!a2 && b2) { 2046 return b2; 2047 } 2048 if (a2 || b2) { 2049 return { 2050 ...a2, 2051 ...b2 2052 }; 2053 } 2054 return void 0; 2055 } 2056 2057 // node_modules/@base-ui/utils/empty.mjs 2058 function NOOP() { 2059 } 2060 var EMPTY_ARRAY2 = Object.freeze([]); 2061 var EMPTY_OBJECT = Object.freeze({}); 2062 2063 // node_modules/@base-ui/react/internals/getStateAttributesProps.mjs 2064 function getStateAttributesProps(state, customMapping) { 2065 const props = {}; 2066 for (const key in state) { 2067 const value = state[key]; 2068 if (customMapping?.hasOwnProperty(key)) { 2069 const customProps = customMapping[key](value); 2070 if (customProps != null) { 2071 Object.assign(props, customProps); 2072 } 2073 continue; 2074 } 2075 if (value === true) { 2076 props[`data-$key.toLowerCase()}`] = ""; 2077 } else if (value) { 2078 props[`data-$key.toLowerCase()}`] = value.toString(); 2079 } 2080 } 2081 return props; 2082 } 2083 2084 // node_modules/@base-ui/react/utils/resolveClassName.mjs 2085 function resolveClassName(className, state) { 2086 return typeof className === "function" ? className(state) : className; 2087 } 2088 2089 // node_modules/@base-ui/react/utils/resolveStyle.mjs 2090 function resolveStyle(style, state) { 2091 return typeof style === "function" ? style(state) : style; 2092 } 2093 2094 // node_modules/@base-ui/react/merge-props/mergeProps.mjs 2095 var EMPTY_PROPS = {}; 2096 function mergeProps(a2, b2, c6, d2, e2) { 2097 if (!c6 && !d2 && !e2 && !a2) { 2098 return createInitialMergedProps(b2); 2099 } 2100 let merged = createInitialMergedProps(a2); 2101 if (b2) { 2102 merged = mergeInto(merged, b2); 2103 } 2104 if (c6) { 2105 merged = mergeInto(merged, c6); 2106 } 2107 if (d2) { 2108 merged = mergeInto(merged, d2); 2109 } 2110 if (e2) { 2111 merged = mergeInto(merged, e2); 2112 } 2113 return merged; 2114 } 2115 function mergePropsN(props) { 2116 if (props.length === 0) { 2117 return EMPTY_PROPS; 2118 } 2119 if (props.length === 1) { 2120 return createInitialMergedProps(props[0]); 2121 } 2122 let merged = createInitialMergedProps(props[0]); 2123 for (let i2 = 1; i2 < props.length; i2 += 1) { 2124 merged = mergeInto(merged, props[i2]); 2125 } 2126 return merged; 2127 } 2128 function createInitialMergedProps(inputProps) { 2129 if (isPropsGetter(inputProps)) { 2130 return { 2131 ...resolvePropsGetter(inputProps, EMPTY_PROPS) 2132 }; 2133 } 2134 return copyInitialProps(inputProps); 2135 } 2136 function mergeInto(merged, inputProps) { 2137 if (isPropsGetter(inputProps)) { 2138 return resolvePropsGetter(inputProps, merged); 2139 } 2140 return mutablyMergeInto(merged, inputProps); 2141 } 2142 function copyInitialProps(inputProps) { 2143 const copiedProps = { 2144 ...inputProps 2145 }; 2146 for (const propName in copiedProps) { 2147 const propValue = copiedProps[propName]; 2148 if (isEventHandler(propName, propValue)) { 2149 copiedProps[propName] = wrapEventHandler(propValue); 2150 } 2151 } 2152 return copiedProps; 2153 } 2154 function mutablyMergeInto(mergedProps, externalProps) { 2155 if (!externalProps) { 2156 return mergedProps; 2157 } 2158 for (const propName in externalProps) { 2159 const externalPropValue = externalProps[propName]; 2160 switch (propName) { 2161 case "style": { 2162 mergedProps[propName] = mergeObjects(mergedProps.style, externalPropValue); 2163 break; 2164 } 2165 case "className": { 2166 mergedProps[propName] = mergeClassNames(mergedProps.className, externalPropValue); 2167 break; 2168 } 2169 default: { 2170 if (isEventHandler(propName, externalPropValue)) { 2171 mergedProps[propName] = mergeEventHandlers(mergedProps[propName], externalPropValue); 2172 } else { 2173 mergedProps[propName] = externalPropValue; 2174 } 2175 } 2176 } 2177 } 2178 return mergedProps; 2179 } 2180 function isEventHandler(key, value) { 2181 const code0 = key.charCodeAt(0); 2182 const code1 = key.charCodeAt(1); 2183 const code2 = key.charCodeAt(2); 2184 return code0 === 111 && code1 === 110 && code2 >= 65 && code2 <= 90 && (typeof value === "function" || typeof value === "undefined"); 2185 } 2186 function isPropsGetter(inputProps) { 2187 return typeof inputProps === "function"; 2188 } 2189 function resolvePropsGetter(inputProps, previousProps) { 2190 if (isPropsGetter(inputProps)) { 2191 return inputProps(previousProps); 2192 } 2193 return inputProps ?? EMPTY_PROPS; 2194 } 2195 function mergeEventHandlers(ourHandler, theirHandler) { 2196 if (!theirHandler) { 2197 return ourHandler; 2198 } 2199 if (!ourHandler) { 2200 return wrapEventHandler(theirHandler); 2201 } 2202 return (...args) => { 2203 const event = args[0]; 2204 if (isSyntheticEvent(event)) { 2205 const baseUIEvent = event; 2206 makeEventPreventable(baseUIEvent); 2207 const result2 = theirHandler(...args); 2208 if (!baseUIEvent.baseUIHandlerPrevented) { 2209 ourHandler?.(...args); 2210 } 2211 return result2; 2212 } 2213 const result = theirHandler(...args); 2214 ourHandler?.(...args); 2215 return result; 2216 }; 2217 } 2218 function wrapEventHandler(handler) { 2219 if (!handler) { 2220 return handler; 2221 } 2222 return (...args) => { 2223 const event = args[0]; 2224 if (isSyntheticEvent(event)) { 2225 makeEventPreventable(event); 2226 } 2227 return handler(...args); 2228 }; 2229 } 2230 function makeEventPreventable(event) { 2231 event.preventBaseUIHandler = () => { 2232 event.baseUIHandlerPrevented = true; 2233 }; 2234 return event; 2235 } 2236 function mergeClassNames(ourClassName, theirClassName) { 2237 if (theirClassName) { 2238 if (ourClassName) { 2239 return theirClassName + " " + ourClassName; 2240 } 2241 return theirClassName; 2242 } 2243 return ourClassName; 2244 } 2245 function isSyntheticEvent(event) { 2246 return event != null && typeof event === "object" && "nativeEvent" in event; 2247 } 2248 2249 // node_modules/@base-ui/react/internals/useRenderElement.mjs 2250 var import_react = __toESM(require_react(), 1); 2251 function useRenderElement(element, componentProps, params = {}) { 2252 const renderProp = componentProps.render; 2253 const outProps = useRenderElementProps(componentProps, params); 2254 if (params.enabled === false) { 2255 return null; 2256 } 2257 const state = params.state ?? EMPTY_OBJECT; 2258 return evaluateRenderProp(element, renderProp, outProps, state); 2259 } 2260 function useRenderElementProps(componentProps, params = {}) { 2261 const { 2262 className: classNameProp, 2263 style: styleProp, 2264 render: renderProp 2265 } = componentProps; 2266 const { 2267 state = EMPTY_OBJECT, 2268 ref, 2269 props, 2270 stateAttributesMapping: stateAttributesMapping4, 2271 enabled = true 2272 } = params; 2273 const className = enabled ? resolveClassName(classNameProp, state) : void 0; 2274 const style = enabled ? resolveStyle(styleProp, state) : void 0; 2275 const stateProps = enabled ? getStateAttributesProps(state, stateAttributesMapping4) : EMPTY_OBJECT; 2276 const resolvedProps = enabled && props ? resolveRenderFunctionProps(props) : void 0; 2277 const outProps = enabled ? mergeObjects(stateProps, resolvedProps) ?? {} : EMPTY_OBJECT; 2278 if (typeof document !== "undefined") { 2279 if (!enabled) { 2280 useMergedRefs(null, null); 2281 } else if (Array.isArray(ref)) { 2282 outProps.ref = useMergedRefsN([outProps.ref, getReactElementRef(renderProp), ...ref]); 2283 } else { 2284 outProps.ref = useMergedRefs(outProps.ref, getReactElementRef(renderProp), ref); 2285 } 2286 } 2287 if (!enabled) { 2288 return EMPTY_OBJECT; 2289 } 2290 if (className !== void 0) { 2291 outProps.className = mergeClassNames(outProps.className, className); 2292 } 2293 if (style !== void 0) { 2294 outProps.style = mergeObjects(outProps.style, style); 2295 } 2296 return outProps; 2297 } 2298 function resolveRenderFunctionProps(props) { 2299 if (Array.isArray(props)) { 2300 return mergePropsN(props); 2301 } 2302 return mergeProps(void 0, props); 2303 } 2304 var REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy"); 2305 var COMPONENT_IDENTIFIER_PATTERN = /^[A-Z][A-Za-z0-9$]*$/; 2306 var LOWERCASE_CHARACTER_PATTERN = /[a-z]/; 2307 function evaluateRenderProp(element, render4, props, state) { 2308 if (render4) { 2309 if (typeof render4 === "function") { 2310 if (true) { 2311 warnIfRenderPropLooksLikeComponent(render4); 2312 } 2313 return render4(props, state); 2314 } 2315 const mergedProps = mergeProps(props, render4.props); 2316 mergedProps.ref = props.ref; 2317 let newElement = render4; 2318 if (newElement?.$$typeof === REACT_LAZY_TYPE) { 2319 const children = React8.Children.toArray(render4); 2320 newElement = children[0]; 2321 } 2322 if (true) { 2323 if (!/* @__PURE__ */ React8.isValidElement(newElement)) { 2324 throw new Error(["Base UI: The `render` prop was provided an invalid React element as `React.isValidElement(render)` is `false`.", "A valid React element must be provided to the `render` prop because it is cloned with props to replace the default element.", "https://base-ui.com/r/invalid-render-prop"].join("\n")); 2325 } 2326 } 2327 return /* @__PURE__ */ React8.cloneElement(newElement, mergedProps); 2328 } 2329 if (element) { 2330 if (typeof element === "string") { 2331 return renderTag(element, props); 2332 } 2333 } 2334 throw new Error(true ? "Base UI: Render element or function are not defined." : formatErrorMessage_default(8)); 2335 } 2336 function warnIfRenderPropLooksLikeComponent(renderFn) { 2337 const functionName = renderFn.name; 2338 if (functionName.length === 0) { 2339 return; 2340 } 2341 if (!COMPONENT_IDENTIFIER_PATTERN.test(functionName)) { 2342 return; 2343 } 2344 if (!LOWERCASE_CHARACTER_PATTERN.test(functionName)) { 2345 return; 2346 } 2347 warn(`The \`render\` prop received a function named \`$functionName}\` that starts with an uppercase letter.`, "This usually means a React component was passed directly as `render={Component}`.", "Base UI calls `render` as a plain function, which can break the Rules of Hooks during reconciliation.", "If this is an intentional render callback, rename it to start with a lowercase letter.", "Use `render={<Component />}` or `render={(props) => <Component {...props} />}` instead.", "https://base-ui.com/r/invalid-render-prop"); 2348 } 2349 function renderTag(Tag, props) { 2350 if (Tag === "button") { 2351 return /* @__PURE__ */ (0, import_react.createElement)("button", { 2352 type: "button", 2353 ...props, 2354 key: props.key 2355 }); 2356 } 2357 if (Tag === "img") { 2358 return /* @__PURE__ */ (0, import_react.createElement)("img", { 2359 alt: "", 2360 ...props, 2361 key: props.key 2362 }); 2363 } 2364 return /* @__PURE__ */ React8.createElement(Tag, props); 2365 } 2366 2367 // node_modules/@base-ui/utils/useId.mjs 2368 var React9 = __toESM(require_react(), 1); 2369 var globalId = 0; 2370 function useGlobalId(idOverride, prefix2 = "mui") { 2371 const [defaultId, setDefaultId] = React9.useState(idOverride); 2372 const id = idOverride || defaultId; 2373 React9.useEffect(() => { 2374 if (defaultId == null) { 2375 globalId += 1; 2376 setDefaultId(`$prefix2}-$globalId}`); 2377 } 2378 }, [defaultId, prefix2]); 2379 return id; 2380 } 2381 var maybeReactUseId = SafeReact.useId; 2382 function useId(idOverride, prefix2) { 2383 if (maybeReactUseId !== void 0) { 2384 const reactId = maybeReactUseId(); 2385 return idOverride ?? (prefix2 ? `$prefix2}-$reactId}` : reactId); 2386 } 2387 return useGlobalId(idOverride, prefix2); 2388 } 2389 2390 // node_modules/@base-ui/react/internals/useBaseUiId.mjs 2391 function useBaseUiId(idOverride) { 2392 return useId(idOverride, "base-ui"); 2393 } 2394 2395 // node_modules/@base-ui/react/collapsible/root/useCollapsibleRoot.mjs 2396 var React12 = __toESM(require_react(), 1); 2397 2398 // node_modules/@base-ui/react/internals/reason-parts.mjs 2399 var reason_parts_exports = {}; 2400 __export(reason_parts_exports, { 2401 cancelOpen: () => cancelOpen, 2402 chipRemovePress: () => chipRemovePress, 2403 clearPress: () => clearPress, 2404 closePress: () => closePress, 2405 closeWatcher: () => closeWatcher, 2406 decrementPress: () => decrementPress, 2407 disabled: () => disabled, 2408 drag: () => drag, 2409 escapeKey: () => escapeKey, 2410 focusOut: () => focusOut, 2411 imperativeAction: () => imperativeAction, 2412 incrementPress: () => incrementPress, 2413 initial: () => initial, 2414 inputBlur: () => inputBlur, 2415 inputChange: () => inputChange, 2416 inputClear: () => inputClear, 2417 inputPaste: () => inputPaste, 2418 inputPress: () => inputPress, 2419 itemPress: () => itemPress, 2420 keyboard: () => keyboard, 2421 linkPress: () => linkPress, 2422 listNavigation: () => listNavigation, 2423 missing: () => missing, 2424 none: () => none, 2425 outsidePress: () => outsidePress, 2426 pointer: () => pointer, 2427 scrub: () => scrub, 2428 siblingOpen: () => siblingOpen, 2429 swipe: () => swipe, 2430 trackPress: () => trackPress, 2431 triggerFocus: () => triggerFocus, 2432 triggerHover: () => triggerHover, 2433 triggerPress: () => triggerPress, 2434 wheel: () => wheel, 2435 windowResize: () => windowResize 2436 }); 2437 var none = "none"; 2438 var triggerPress = "trigger-press"; 2439 var triggerHover = "trigger-hover"; 2440 var triggerFocus = "trigger-focus"; 2441 var outsidePress = "outside-press"; 2442 var itemPress = "item-press"; 2443 var closePress = "close-press"; 2444 var linkPress = "link-press"; 2445 var clearPress = "clear-press"; 2446 var chipRemovePress = "chip-remove-press"; 2447 var trackPress = "track-press"; 2448 var incrementPress = "increment-press"; 2449 var decrementPress = "decrement-press"; 2450 var inputChange = "input-change"; 2451 var inputClear = "input-clear"; 2452 var inputBlur = "input-blur"; 2453 var inputPaste = "input-paste"; 2454 var inputPress = "input-press"; 2455 var focusOut = "focus-out"; 2456 var escapeKey = "escape-key"; 2457 var closeWatcher = "close-watcher"; 2458 var listNavigation = "list-navigation"; 2459 var keyboard = "keyboard"; 2460 var pointer = "pointer"; 2461 var drag = "drag"; 2462 var wheel = "wheel"; 2463 var scrub = "scrub"; 2464 var cancelOpen = "cancel-open"; 2465 var siblingOpen = "sibling-open"; 2466 var disabled = "disabled"; 2467 var missing = "missing"; 2468 var initial = "initial"; 2469 var imperativeAction = "imperative-action"; 2470 var swipe = "swipe"; 2471 var windowResize = "window-resize"; 2472 2473 // node_modules/@base-ui/react/internals/createBaseUIEventDetails.mjs 2474 function createChangeEventDetails(reason, event, trigger, customProperties) { 2475 let canceled = false; 2476 let allowPropagation = false; 2477 const custom = customProperties ?? EMPTY_OBJECT; 2478 const details = { 2479 reason, 2480 event: event ?? new Event("base-ui"), 2481 cancel() { 2482 canceled = true; 2483 }, 2484 allowPropagation() { 2485 allowPropagation = true; 2486 }, 2487 get isCanceled() { 2488 return canceled; 2489 }, 2490 get isPropagationAllowed() { 2491 return allowPropagation; 2492 }, 2493 trigger, 2494 ...custom 2495 }; 2496 return details; 2497 } 2498 2499 // node_modules/@base-ui/react/internals/useTransitionStatus.mjs 2500 var React11 = __toESM(require_react(), 1); 2501 2502 // node_modules/@base-ui/utils/useOnMount.mjs 2503 var React10 = __toESM(require_react(), 1); 2504 var EMPTY = []; 2505 function useOnMount(fn) { 2506 React10.useEffect(fn, EMPTY); 2507 } 2508 2509 // node_modules/@base-ui/utils/useAnimationFrame.mjs 2510 var EMPTY2 = null; 2511 var LAST_RAF = globalThis.requestAnimationFrame; 2512 var Scheduler = class { 2513 /* This implementation uses an array as a backing data-structure for frame callbacks. 2514 * It allows `O(1)` callback cancelling by inserting a `null` in the array, though it 2515 * never calls the native `cancelAnimationFrame` if there are no frames left. This can 2516 * be much more efficient if there is a call pattern that alterns as 2517 * "request-cancel-request-cancel-…". 2518 * But in the case of "request-request-…-cancel-cancel-…", it leaves the final animation 2519 * frame to run anyway. We turn that frame into a `O(1)` no-op via `callbacksCount`. */ 2520 callbacks = []; 2521 callbacksCount = 0; 2522 nextId = 1; 2523 startId = 1; 2524 isScheduled = false; 2525 tick = (timestamp) => { 2526 this.isScheduled = false; 2527 const currentCallbacks = this.callbacks; 2528 const currentCallbacksCount = this.callbacksCount; 2529 this.callbacks = []; 2530 this.callbacksCount = 0; 2531 this.startId = this.nextId; 2532 if (currentCallbacksCount > 0) { 2533 for (let i2 = 0; i2 < currentCallbacks.length; i2 += 1) { 2534 currentCallbacks[i2]?.(timestamp); 2535 } 2536 } 2537 }; 2538 request(fn) { 2539 const id = this.nextId; 2540 this.nextId += 1; 2541 this.callbacks.push(fn); 2542 this.callbacksCount += 1; 2543 const didRAFChange = LAST_RAF !== requestAnimationFrame && (LAST_RAF = requestAnimationFrame, true); 2544 if (!this.isScheduled || didRAFChange) { 2545 requestAnimationFrame(this.tick); 2546 this.isScheduled = true; 2547 } 2548 return id; 2549 } 2550 cancel(id) { 2551 const index2 = id - this.startId; 2552 if (index2 < 0 || index2 >= this.callbacks.length) { 2553 return; 2554 } 2555 this.callbacks[index2] = null; 2556 this.callbacksCount -= 1; 2557 } 2558 }; 2559 var scheduler = new Scheduler(); 2560 var AnimationFrame = class _AnimationFrame { 2561 static create() { 2562 return new _AnimationFrame(); 2563 } 2564 static request(fn) { 2565 return scheduler.request(fn); 2566 } 2567 static cancel(id) { 2568 return scheduler.cancel(id); 2569 } 2570 currentId = EMPTY2; 2571 /** 2572 * Executes `fn` after `delay`, clearing any previously scheduled call. 2573 */ 2574 request(fn) { 2575 this.cancel(); 2576 this.currentId = scheduler.request(() => { 2577 this.currentId = EMPTY2; 2578 fn(); 2579 }); 2580 } 2581 cancel = () => { 2582 if (this.currentId !== EMPTY2) { 2583 scheduler.cancel(this.currentId); 2584 this.currentId = EMPTY2; 2585 } 2586 }; 2587 disposeEffect = () => { 2588 return this.cancel; 2589 }; 2590 }; 2591 function useAnimationFrame() { 2592 const timeout = useRefWithInit(AnimationFrame.create).current; 2593 useOnMount(timeout.disposeEffect); 2594 return timeout; 2595 } 2596 2597 // node_modules/@base-ui/react/internals/useTransitionStatus.mjs 2598 function useTransitionStatus(open, enableIdleState = false, deferEndingState = false) { 2599 const [transitionStatus, setTransitionStatus] = React11.useState(open && enableIdleState ? "idle" : void 0); 2600 const [mounted, setMounted] = React11.useState(open); 2601 if (open && !mounted) { 2602 setMounted(true); 2603 setTransitionStatus("starting"); 2604 } 2605 if (!open && mounted && transitionStatus !== "ending" && !deferEndingState) { 2606 setTransitionStatus("ending"); 2607 } 2608 if (!open && !mounted && transitionStatus === "ending") { 2609 setTransitionStatus(void 0); 2610 } 2611 useIsoLayoutEffect(() => { 2612 if (!open && mounted && transitionStatus !== "ending" && deferEndingState) { 2613 const frame = AnimationFrame.request(() => { 2614 setTransitionStatus("ending"); 2615 }); 2616 return () => { 2617 AnimationFrame.cancel(frame); 2618 }; 2619 } 2620 return void 0; 2621 }, [open, mounted, transitionStatus, deferEndingState]); 2622 useIsoLayoutEffect(() => { 2623 if (!open || enableIdleState) { 2624 return void 0; 2625 } 2626 const frame = AnimationFrame.request(() => { 2627 setTransitionStatus(void 0); 2628 }); 2629 return () => { 2630 AnimationFrame.cancel(frame); 2631 }; 2632 }, [enableIdleState, open]); 2633 useIsoLayoutEffect(() => { 2634 if (!open || !enableIdleState) { 2635 return void 0; 2636 } 2637 if (open && mounted && transitionStatus !== "idle") { 2638 setTransitionStatus("starting"); 2639 } 2640 const frame = AnimationFrame.request(() => { 2641 setTransitionStatus("idle"); 2642 }); 2643 return () => { 2644 AnimationFrame.cancel(frame); 2645 }; 2646 }, [enableIdleState, open, mounted, transitionStatus]); 2647 return { 2648 mounted, 2649 setMounted, 2650 transitionStatus 2651 }; 2652 } 2653 2654 // node_modules/@base-ui/react/collapsible/root/useCollapsibleRoot.mjs 2655 function useCollapsibleRoot(parameters) { 2656 const { 2657 open: openParam, 2658 defaultOpen, 2659 onOpenChange, 2660 disabled: disabled2 2661 } = parameters; 2662 const [open, setOpen] = useControlled({ 2663 controlled: openParam, 2664 default: defaultOpen, 2665 name: "Collapsible", 2666 state: "open" 2667 }); 2668 const { 2669 mounted, 2670 setMounted, 2671 transitionStatus 2672 } = useTransitionStatus(open, true, true); 2673 const defaultPanelId = useBaseUiId(); 2674 const [panelIdState, setPanelIdState] = React12.useState(); 2675 const panelId = panelIdState ?? defaultPanelId; 2676 const handleTrigger = useStableCallback((event) => { 2677 const nextOpen = !open; 2678 const eventDetails = createChangeEventDetails(reason_parts_exports.triggerPress, event.nativeEvent); 2679 onOpenChange(nextOpen, eventDetails); 2680 if (eventDetails.isCanceled) { 2681 return; 2682 } 2683 setOpen(nextOpen); 2684 }); 2685 return React12.useMemo(() => ({ 2686 disabled: disabled2, 2687 handleTrigger, 2688 mounted, 2689 open, 2690 panelId, 2691 setMounted, 2692 setOpen, 2693 setPanelIdState, 2694 transitionStatus 2695 }), [disabled2, handleTrigger, mounted, open, panelId, setMounted, setOpen, setPanelIdState, transitionStatus]); 2696 } 2697 2698 // node_modules/@base-ui/react/collapsible/root/CollapsibleRootContext.mjs 2699 var React13 = __toESM(require_react(), 1); 2700 var CollapsibleRootContext = /* @__PURE__ */ React13.createContext(void 0); 2701 if (true) CollapsibleRootContext.displayName = "CollapsibleRootContext"; 2702 function useCollapsibleRootContext() { 2703 const context = React13.useContext(CollapsibleRootContext); 2704 if (context === void 0) { 2705 throw new Error(true ? "Base UI: CollapsibleRootContext is missing. Collapsible parts must be placed within <Collapsible.Root>." : formatErrorMessage_default(15)); 2706 } 2707 return context; 2708 } 2709 2710 // node_modules/@base-ui/react/internals/stateAttributesMapping.mjs 2711 var TransitionStatusDataAttributes = /* @__PURE__ */ (function(TransitionStatusDataAttributes2) { 2712 TransitionStatusDataAttributes2["startingStyle"] = "data-starting-style"; 2713 TransitionStatusDataAttributes2["endingStyle"] = "data-ending-style"; 2714 return TransitionStatusDataAttributes2; 2715 })({}); 2716 var STARTING_HOOK = { 2717 [TransitionStatusDataAttributes.startingStyle]: "" 2718 }; 2719 var ENDING_HOOK = { 2720 [TransitionStatusDataAttributes.endingStyle]: "" 2721 }; 2722 var transitionStatusMapping = { 2723 transitionStatus(value) { 2724 if (value === "starting") { 2725 return STARTING_HOOK; 2726 } 2727 if (value === "ending") { 2728 return ENDING_HOOK; 2729 } 2730 return null; 2731 } 2732 }; 2733 2734 // node_modules/@base-ui/react/collapsible/panel/CollapsiblePanelDataAttributes.mjs 2735 var CollapsiblePanelDataAttributes = (function(CollapsiblePanelDataAttributes2) { 2736 CollapsiblePanelDataAttributes2["open"] = "data-open"; 2737 CollapsiblePanelDataAttributes2["closed"] = "data-closed"; 2738 CollapsiblePanelDataAttributes2[CollapsiblePanelDataAttributes2["startingStyle"] = TransitionStatusDataAttributes.startingStyle] = "startingStyle"; 2739 CollapsiblePanelDataAttributes2[CollapsiblePanelDataAttributes2["endingStyle"] = TransitionStatusDataAttributes.endingStyle] = "endingStyle"; 2740 return CollapsiblePanelDataAttributes2; 2741 })({}); 2742 2743 // node_modules/@base-ui/react/collapsible/trigger/CollapsibleTriggerDataAttributes.mjs 2744 var CollapsibleTriggerDataAttributes = /* @__PURE__ */ (function(CollapsibleTriggerDataAttributes2) { 2745 CollapsibleTriggerDataAttributes2["panelOpen"] = "data-panel-open"; 2746 return CollapsibleTriggerDataAttributes2; 2747 })({}); 2748 2749 // node_modules/@base-ui/react/utils/collapsibleOpenStateMapping.mjs 2750 var PANEL_OPEN_HOOK = { 2751 [CollapsiblePanelDataAttributes.open]: "" 2752 }; 2753 var PANEL_CLOSED_HOOK = { 2754 [CollapsiblePanelDataAttributes.closed]: "" 2755 }; 2756 var triggerOpenStateMapping = { 2757 open(value) { 2758 if (value) { 2759 return { 2760 [CollapsibleTriggerDataAttributes.panelOpen]: "" 2761 }; 2762 } 2763 return null; 2764 } 2765 }; 2766 var collapsibleOpenStateMapping = { 2767 open(value) { 2768 if (value) { 2769 return PANEL_OPEN_HOOK; 2770 } 2771 return PANEL_CLOSED_HOOK; 2772 } 2773 }; 2774 2775 // node_modules/@base-ui/react/internals/use-button/useButton.mjs 2776 var React16 = __toESM(require_react(), 1); 2777 2778 // node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs 2779 function hasWindow() { 2780 return typeof window !== "undefined"; 2781 } 2782 function getNodeName(node) { 2783 if (isNode(node)) { 2784 return (node.nodeName || "").toLowerCase(); 2785 } 2786 return "#document"; 2787 } 2788 function getWindow(node) { 2789 var _node$ownerDocument; 2790 return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window; 2791 } 2792 function getDocumentElement(node) { 2793 var _ref; 2794 return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement; 2795 } 2796 function isNode(value) { 2797 if (!hasWindow()) { 2798 return false; 2799 } 2800 return value instanceof Node || value instanceof getWindow(value).Node; 2801 } 2802 function isElement(value) { 2803 if (!hasWindow()) { 2804 return false; 2805 } 2806 return value instanceof Element || value instanceof getWindow(value).Element; 2807 } 2808 function isHTMLElement(value) { 2809 if (!hasWindow()) { 2810 return false; 2811 } 2812 return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement; 2813 } 2814 function isShadowRoot(value) { 2815 if (!hasWindow() || typeof ShadowRoot === "undefined") { 2816 return false; 2817 } 2818 return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot; 2819 } 2820 function isOverflowElement(element) { 2821 const { 2822 overflow, 2823 overflowX, 2824 overflowY, 2825 display 2826 } = getComputedStyle2(element); 2827 return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && display !== "inline" && display !== "contents"; 2828 } 2829 function isTableElement(element) { 2830 return /^(table|td|th)$/.test(getNodeName(element)); 2831 } 2832 function isTopLayer(element) { 2833 try { 2834 if (element.matches(":popover-open")) { 2835 return true; 2836 } 2837 } catch (_e) { 2838 } 2839 try { 2840 return element.matches(":modal"); 2841 } catch (_e) { 2842 return false; 2843 } 2844 } 2845 var willChangeRe = /transform|translate|scale|rotate|perspective|filter/; 2846 var containRe = /paint|layout|strict|content/; 2847 var isNotNone = (value) => !!value && value !== "none"; 2848 var isWebKitValue; 2849 function isContainingBlock(elementOrCss) { 2850 const css = isElement(elementOrCss) ? getComputedStyle2(elementOrCss) : elementOrCss; 2851 return isNotNone(css.transform) || isNotNone(css.translate) || isNotNone(css.scale) || isNotNone(css.rotate) || isNotNone(css.perspective) || !isWebKit() && (isNotNone(css.backdropFilter) || isNotNone(css.filter)) || willChangeRe.test(css.willChange || "") || containRe.test(css.contain || ""); 2852 } 2853 function getContainingBlock(element) { 2854 let currentNode = getParentNode(element); 2855 while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) { 2856 if (isContainingBlock(currentNode)) { 2857 return currentNode; 2858 } else if (isTopLayer(currentNode)) { 2859 return null; 2860 } 2861 currentNode = getParentNode(currentNode); 2862 } 2863 return null; 2864 } 2865 function isWebKit() { 2866 if (isWebKitValue == null) { 2867 isWebKitValue = typeof CSS !== "undefined" && CSS.supports && CSS.supports("-webkit-backdrop-filter", "none"); 2868 } 2869 return isWebKitValue; 2870 } 2871 function isLastTraversableNode(node) { 2872 return /^(html|body|#document)$/.test(getNodeName(node)); 2873 } 2874 function getComputedStyle2(element) { 2875 return getWindow(element).getComputedStyle(element); 2876 } 2877 function getNodeScroll(element) { 2878 if (isElement(element)) { 2879 return { 2880 scrollLeft: element.scrollLeft, 2881 scrollTop: element.scrollTop 2882 }; 2883 } 2884 return { 2885 scrollLeft: element.scrollX, 2886 scrollTop: element.scrollY 2887 }; 2888 } 2889 function getParentNode(node) { 2890 if (getNodeName(node) === "html") { 2891 return node; 2892 } 2893 const result = ( 2894 // Step into the shadow DOM of the parent of a slotted node. 2895 node.assignedSlot || // DOM Element detected. 2896 node.parentNode || // ShadowRoot detected. 2897 isShadowRoot(node) && node.host || // Fallback. 2898 getDocumentElement(node) 2899 ); 2900 return isShadowRoot(result) ? result.host : result; 2901 } 2902 function getNearestOverflowAncestor(node) { 2903 const parentNode = getParentNode(node); 2904 if (isLastTraversableNode(parentNode)) { 2905 return node.ownerDocument ? node.ownerDocument.body : node.body; 2906 } 2907 if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) { 2908 return parentNode; 2909 } 2910 return getNearestOverflowAncestor(parentNode); 2911 } 2912 function getOverflowAncestors(node, list, traverseIframes) { 2913 var _node$ownerDocument2; 2914 if (list === void 0) { 2915 list = []; 2916 } 2917 if (traverseIframes === void 0) { 2918 traverseIframes = true; 2919 } 2920 const scrollableAncestor = getNearestOverflowAncestor(node); 2921 const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body); 2922 const win = getWindow(scrollableAncestor); 2923 if (isBody) { 2924 const frameElement = getFrameElement(win); 2925 return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []); 2926 } else { 2927 return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes)); 2928 } 2929 } 2930 function getFrameElement(win) { 2931 return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null; 2932 } 2933 2934 // node_modules/@base-ui/react/internals/composite/root/CompositeRootContext.mjs 2935 var React14 = __toESM(require_react(), 1); 2936 var CompositeRootContext = /* @__PURE__ */ React14.createContext(void 0); 2937 if (true) CompositeRootContext.displayName = "CompositeRootContext"; 2938 function useCompositeRootContext(optional = false) { 2939 const context = React14.useContext(CompositeRootContext); 2940 if (context === void 0 && !optional) { 2941 throw new Error(true ? "Base UI: CompositeRootContext is missing. Composite parts must be placed within <Composite.Root>." : formatErrorMessage_default(16)); 2942 } 2943 return context; 2944 } 2945 2946 // node_modules/@base-ui/react/utils/useFocusableWhenDisabled.mjs 2947 var React15 = __toESM(require_react(), 1); 2948 function useFocusableWhenDisabled(parameters) { 2949 const { 2950 focusableWhenDisabled, 2951 disabled: disabled2, 2952 composite = false, 2953 tabIndex: tabIndexProp = 0, 2954 isNativeButton 2955 } = parameters; 2956 const isFocusableComposite = composite && focusableWhenDisabled !== false; 2957 const isNonFocusableComposite = composite && focusableWhenDisabled === false; 2958 const props = React15.useMemo(() => { 2959 const additionalProps = { 2960 // allow Tabbing away from focusableWhenDisabled elements 2961 onKeyDown(event) { 2962 if (disabled2 && focusableWhenDisabled && event.key !== "Tab") { 2963 event.preventDefault(); 2964 } 2965 } 2966 }; 2967 if (!composite) { 2968 additionalProps.tabIndex = tabIndexProp; 2969 if (!isNativeButton && disabled2) { 2970 additionalProps.tabIndex = focusableWhenDisabled ? tabIndexProp : -1; 2971 } 2972 } 2973 if (isNativeButton && (focusableWhenDisabled || isFocusableComposite) || !isNativeButton && disabled2) { 2974 additionalProps["aria-disabled"] = disabled2; 2975 } 2976 if (isNativeButton && (!focusableWhenDisabled || isNonFocusableComposite)) { 2977 additionalProps.disabled = disabled2; 2978 } 2979 return additionalProps; 2980 }, [composite, disabled2, focusableWhenDisabled, isFocusableComposite, isNonFocusableComposite, isNativeButton, tabIndexProp]); 2981 return { 2982 props 2983 }; 2984 } 2985 2986 // node_modules/@base-ui/react/internals/use-button/useButton.mjs 2987 function useButton(parameters = {}) { 2988 const { 2989 disabled: disabled2 = false, 2990 focusableWhenDisabled, 2991 tabIndex = 0, 2992 native: isNativeButton = true, 2993 composite: compositeProp 2994 } = parameters; 2995 const elementRef = React16.useRef(null); 2996 const compositeRootContext = useCompositeRootContext(true); 2997 const isCompositeItem = compositeProp ?? compositeRootContext !== void 0; 2998 const { 2999 props: focusableWhenDisabledProps 3000 } = useFocusableWhenDisabled({ 3001 focusableWhenDisabled, 3002 disabled: disabled2, 3003 composite: isCompositeItem, 3004 tabIndex, 3005 isNativeButton 3006 }); 3007 if (true) { 3008 React16.useEffect(() => { 3009 if (!elementRef.current) { 3010 return; 3011 } 3012 const isButtonTag = isButtonElement(elementRef.current); 3013 if (isNativeButton) { 3014 if (!isButtonTag) { 3015 const ownerStackMessage = SafeReact.captureOwnerStack?.() || ""; 3016 const message2 = "A component that acts as a button expected a native <button> because the `nativeButton` prop is true. Rendering a non-<button> removes native button semantics, which can impact forms and accessibility. Use a real <button> in the `render` prop, or set `nativeButton` to `false`."; 3017 error(`$message2}$ownerStackMessage}`); 3018 } 3019 } else if (isButtonTag) { 3020 const ownerStackMessage = SafeReact.captureOwnerStack?.() || ""; 3021 const message2 = "A component that acts as a button expected a non-<button> because the `nativeButton` prop is false. Rendering a <button> keeps native behavior while Base UI applies non-native attributes and handlers, which can add unintended extra attributes (such as `role` or `aria-disabled`). Use a non-<button> in the `render` prop, or set `nativeButton` to `true`."; 3022 error(`$message2}$ownerStackMessage}`); 3023 } 3024 }, [isNativeButton]); 3025 } 3026 const updateDisabled = React16.useCallback(() => { 3027 const element = elementRef.current; 3028 if (!isButtonElement(element)) { 3029 return; 3030 } 3031 if (isCompositeItem && disabled2 && focusableWhenDisabledProps.disabled === void 0 && element.disabled) { 3032 element.disabled = false; 3033 } 3034 }, [disabled2, focusableWhenDisabledProps.disabled, isCompositeItem]); 3035 useIsoLayoutEffect(updateDisabled, [updateDisabled]); 3036 const getButtonProps = React16.useCallback((externalProps = {}) => { 3037 const { 3038 onClick: externalOnClick, 3039 onMouseDown: externalOnMouseDown, 3040 onKeyUp: externalOnKeyUp, 3041 onKeyDown: externalOnKeyDown, 3042 onPointerDown: externalOnPointerDown, 3043 ...otherExternalProps 3044 } = externalProps; 3045 return mergeProps({ 3046 onClick(event) { 3047 if (disabled2) { 3048 event.preventDefault(); 3049 return; 3050 } 3051 externalOnClick?.(event); 3052 }, 3053 onMouseDown(event) { 3054 if (!disabled2) { 3055 externalOnMouseDown?.(event); 3056 } 3057 }, 3058 onKeyDown(event) { 3059 if (disabled2) { 3060 return; 3061 } 3062 makeEventPreventable(event); 3063 externalOnKeyDown?.(event); 3064 if (event.baseUIHandlerPrevented) { 3065 return; 3066 } 3067 const isCurrentTarget = event.target === event.currentTarget; 3068 const currentTarget = event.currentTarget; 3069 const isButton2 = isButtonElement(currentTarget); 3070 const isLink = !isNativeButton && isValidLinkElement(currentTarget); 3071 const shouldClick = isCurrentTarget && (isNativeButton ? isButton2 : !isLink); 3072 const isEnterKey = event.key === "Enter"; 3073 const isSpaceKey = event.key === " "; 3074 const role = currentTarget.getAttribute("role"); 3075 const isTextNavigationRole = role?.startsWith("menuitem") || role === "option" || role === "gridcell"; 3076 if (isCurrentTarget && isCompositeItem && isSpaceKey) { 3077 if (event.defaultPrevented && isTextNavigationRole) { 3078 return; 3079 } 3080 event.preventDefault(); 3081 if (isLink || isNativeButton && isButton2) { 3082 currentTarget.click(); 3083 event.preventBaseUIHandler(); 3084 } else if (shouldClick) { 3085 externalOnClick?.(event); 3086 event.preventBaseUIHandler(); 3087 } 3088 return; 3089 } 3090 if (shouldClick) { 3091 if (!isNativeButton && (isSpaceKey || isEnterKey)) { 3092 event.preventDefault(); 3093 } 3094 if (!isNativeButton && isEnterKey) { 3095 externalOnClick?.(event); 3096 } 3097 } 3098 }, 3099 onKeyUp(event) { 3100 if (disabled2) { 3101 return; 3102 } 3103 makeEventPreventable(event); 3104 externalOnKeyUp?.(event); 3105 if (event.target === event.currentTarget && isNativeButton && isCompositeItem && isButtonElement(event.currentTarget) && event.key === " ") { 3106 event.preventDefault(); 3107 return; 3108 } 3109 if (event.baseUIHandlerPrevented) { 3110 return; 3111 } 3112 if (event.target === event.currentTarget && !isNativeButton && !isCompositeItem && event.key === " ") { 3113 externalOnClick?.(event); 3114 } 3115 }, 3116 onPointerDown(event) { 3117 if (disabled2) { 3118 event.preventDefault(); 3119 return; 3120 } 3121 externalOnPointerDown?.(event); 3122 } 3123 }, isNativeButton ? { 3124 type: "button" 3125 } : { 3126 role: "button" 3127 }, focusableWhenDisabledProps, otherExternalProps); 3128 }, [disabled2, focusableWhenDisabledProps, isCompositeItem, isNativeButton]); 3129 const buttonRef = useStableCallback((element) => { 3130 elementRef.current = element; 3131 updateDisabled(); 3132 }); 3133 return { 3134 getButtonProps, 3135 buttonRef 3136 }; 3137 } 3138 function isButtonElement(elem) { 3139 return isHTMLElement(elem) && elem.tagName === "BUTTON"; 3140 } 3141 function isValidLinkElement(elem) { 3142 return Boolean(elem?.tagName === "A" && elem?.href); 3143 } 3144 3145 // node_modules/@base-ui/react/collapsible/panel/useCollapsiblePanel.mjs 3146 var React18 = __toESM(require_react(), 1); 3147 3148 // node_modules/@base-ui/utils/addEventListener.mjs 3149 function addEventListener(target, type, listener, options) { 3150 target.addEventListener(type, listener, options); 3151 return () => { 3152 target.removeEventListener(type, listener, options); 3153 }; 3154 } 3155 3156 // node_modules/@base-ui/utils/useValueAsRef.mjs 3157 function useValueAsRef(value) { 3158 const latest = useRefWithInit(createLatestRef, value).current; 3159 latest.next = value; 3160 useIsoLayoutEffect(latest.effect); 3161 return latest; 3162 } 3163 function createLatestRef(value) { 3164 const latest = { 3165 current: value, 3166 next: value, 3167 effect: () => { 3168 latest.current = latest.next; 3169 } 3170 }; 3171 return latest; 3172 } 3173 3174 // node_modules/@base-ui/utils/owner.mjs 3175 function ownerDocument(node) { 3176 return node?.ownerDocument || document; 3177 } 3178 3179 // node_modules/@base-ui/react/internals/useOpenChangeComplete.mjs 3180 var React17 = __toESM(require_react(), 1); 3181 3182 // node_modules/@base-ui/react/internals/useAnimationsFinished.mjs 3183 var ReactDOM = __toESM(require_react_dom(), 1); 3184 3185 // node_modules/@base-ui/react/utils/resolveRef.mjs 3186 function resolveRef(maybeRef) { 3187 if (maybeRef == null) { 3188 return maybeRef; 3189 } 3190 return "current" in maybeRef ? maybeRef.current : maybeRef; 3191 } 3192 3193 // node_modules/@base-ui/react/internals/useAnimationsFinished.mjs 3194 function useAnimationsFinished(elementOrRef, waitForStartingStyleRemoved = false, treatAbortedAsFinished = true) { 3195 const frame = useAnimationFrame(); 3196 return useStableCallback((fnToExecute, signal = null) => { 3197 frame.cancel(); 3198 const element = resolveRef(elementOrRef); 3199 if (element == null) { 3200 return; 3201 } 3202 const resolvedElement = element; 3203 const done = () => { 3204 ReactDOM.flushSync(fnToExecute); 3205 }; 3206 if (typeof resolvedElement.getAnimations !== "function" || globalThis.BASE_UI_ANIMATIONS_DISABLED) { 3207 fnToExecute(); 3208 return; 3209 } 3210 function exec() { 3211 Promise.all(resolvedElement.getAnimations().map((animation) => animation.finished)).then(() => { 3212 if (!signal?.aborted) { 3213 done(); 3214 } 3215 }).catch(() => { 3216 if (treatAbortedAsFinished) { 3217 if (!signal?.aborted) { 3218 done(); 3219 } 3220 return; 3221 } 3222 const currentAnimations = resolvedElement.getAnimations(); 3223 if (!signal?.aborted && currentAnimations.length > 0 && currentAnimations.some((animation) => animation.pending || animation.playState !== "finished")) { 3224 exec(); 3225 } 3226 }); 3227 } 3228 if (waitForStartingStyleRemoved) { 3229 const startingStyleAttribute = TransitionStatusDataAttributes.startingStyle; 3230 if (!resolvedElement.hasAttribute(startingStyleAttribute)) { 3231 frame.request(exec); 3232 return; 3233 } 3234 const attributeObserver = new MutationObserver(() => { 3235 if (!resolvedElement.hasAttribute(startingStyleAttribute)) { 3236 attributeObserver.disconnect(); 3237 exec(); 3238 } 3239 }); 3240 attributeObserver.observe(resolvedElement, { 3241 attributes: true, 3242 attributeFilter: [startingStyleAttribute] 3243 }); 3244 signal?.addEventListener("abort", () => attributeObserver.disconnect(), { 3245 once: true 3246 }); 3247 return; 3248 } 3249 frame.request(exec); 3250 }); 3251 } 3252 3253 // node_modules/@base-ui/react/internals/useOpenChangeComplete.mjs 3254 function useOpenChangeComplete(parameters) { 3255 const { 3256 enabled = true, 3257 open, 3258 ref, 3259 onComplete: onCompleteParam 3260 } = parameters; 3261 const onComplete = useStableCallback(onCompleteParam); 3262 const runOnceAnimationsFinish = useAnimationsFinished(ref, open, false); 3263 React17.useEffect(() => { 3264 if (!enabled) { 3265 return void 0; 3266 } 3267 const abortController = new AbortController(); 3268 runOnceAnimationsFinish(onComplete, abortController.signal); 3269 return () => { 3270 abortController.abort(); 3271 }; 3272 }, [enabled, open, onComplete, runOnceAnimationsFinish]); 3273 } 3274 3275 // node_modules/@base-ui/react/collapsible/panel/useCollapsiblePanel.mjs 3276 var EMPTY_DIMENSIONS = { 3277 height: void 0, 3278 width: void 0 3279 }; 3280 function useCollapsiblePanel(parameters) { 3281 const { 3282 externalRef, 3283 hiddenUntilFound, 3284 id: idParam, 3285 keepMounted, 3286 mounted, 3287 onOpenChange, 3288 open, 3289 setMounted, 3290 setOpen, 3291 transitionStatus 3292 } = parameters; 3293 const panelRef = React18.useRef(null); 3294 const animationTypeRef = React18.useRef(null); 3295 const [dimensions, setDimensionsUnwrapped] = React18.useState(EMPTY_DIMENSIONS); 3296 const lastMeasuredDimensionsRef = React18.useRef(EMPTY_DIMENSIONS); 3297 const shouldSkipNextOpenRef = React18.useRef(false); 3298 const shouldPreventMountAnimationRef = React18.useRef(open); 3299 const shouldPreventActivityResumeAnimationRef = React18.useRef(false); 3300 const [forcePanelIdle, setForcePanelIdle] = React18.useState(false); 3301 const pendingTemporaryStyleRestoreRef = React18.useRef(null); 3302 const mergedPanelRef = useMergedRefs(externalRef, panelRef); 3303 const latestStateRef = useValueAsRef({ 3304 mounted, 3305 open 3306 }); 3307 const runOnceCloseAnimationsFinish = useAnimationsFinished(panelRef, false, false); 3308 const hidden = !open && !mounted; 3309 const panelTransitionStatus = forcePanelIdle ? "idle" : transitionStatus; 3310 const shouldPreventOpenAnimation = open && // These 2 refs are safe to read in render, they are only written from committed 3311 // layout/effect paths and gate one-shot motion suppression for the next open 3312 // lifecycle. They intentionally expose the last committed motion snapshot. 3313 (shouldPreventMountAnimationRef.current || shouldPreventActivityResumeAnimationRef.current); 3314 const renderedDimensions = !open && mounted && // These 2 refs are also safe to read in render, both hold the last committed 3315 // animation mode and measurement. This fallback only restores a previously 3316 // measured pixel size after the live dimensions state has been reset back to `auto`. 3317 animationTypeRef.current === "css-animation" && dimensions.height === void 0 && dimensions.width === void 0 ? lastMeasuredDimensionsRef.current : dimensions; 3318 const shouldPersistHiddenTransitionStyles = hiddenUntilFound && hidden && animationTypeRef.current !== "css-animation"; 3319 const setDimensions = useStableCallback((nextDimensions, shouldCacheMeasurement = true) => { 3320 if (shouldCacheMeasurement) { 3321 lastMeasuredDimensionsRef.current = nextDimensions; 3322 } 3323 setDimensionsUnwrapped(nextDimensions); 3324 }); 3325 const restorePendingTemporaryStyle = useStableCallback(() => { 3326 pendingTemporaryStyleRestoreRef.current?.(); 3327 pendingTemporaryStyleRestoreRef.current = null; 3328 }); 3329 const setPendingTemporaryStyleRestore = useStableCallback((restore) => { 3330 restorePendingTemporaryStyle(); 3331 pendingTemporaryStyleRestoreRef.current = () => { 3332 pendingTemporaryStyleRestoreRef.current = null; 3333 restore(); 3334 }; 3335 }); 3336 const markActivityResumeAnimationSuppressed = useStableCallback(() => { 3337 if (open && mounted && animationTypeRef.current === "css-animation") { 3338 shouldPreventActivityResumeAnimationRef.current = true; 3339 } 3340 }); 3341 useIsoLayoutEffect(() => { 3342 if (!forcePanelIdle || transitionStatus === "starting") { 3343 return; 3344 } 3345 setForcePanelIdle(false); 3346 }, [forcePanelIdle, transitionStatus]); 3347 React18.useEffect(() => { 3348 return () => { 3349 markActivityResumeAnimationSuppressed(); 3350 restorePendingTemporaryStyle(); 3351 }; 3352 }, [markActivityResumeAnimationSuppressed, restorePendingTemporaryStyle]); 3353 useIsoLayoutEffect(() => { 3354 const panel = panelRef.current; 3355 if (!panel) { 3356 return void 0; 3357 } 3358 if (!open && pendingTemporaryStyleRestoreRef.current) { 3359 restorePendingTemporaryStyle(); 3360 } 3361 const animationType = getAnimationType(panel, shouldPreventOpenAnimation); 3362 animationTypeRef.current = animationType; 3363 if (open && transitionStatus === "idle" && shouldPreventMountAnimationRef.current && animationType === "css-animation") { 3364 lastMeasuredDimensionsRef.current = getDimensions(panel); 3365 return void 0; 3366 } 3367 if (open && transitionStatus === "starting") { 3368 const skipNextOpen = shouldSkipNextOpenRef.current; 3369 shouldSkipNextOpenRef.current = false; 3370 if (animationType === "none") { 3371 setDimensions(getDimensions(panel)); 3372 setForcePanelIdle(true); 3373 return void 0; 3374 } 3375 if (animationType === "css-transition") { 3376 const restoreLayoutStyles = resetLayoutStyles(panel); 3377 setDimensions(getDimensions(panel)); 3378 if (!skipNextOpen) { 3379 return restoreLayoutStyles; 3380 } 3381 const restoreTransitionDuration = setTemporaryStyle(panel, "transition-duration", "0s"); 3382 setPendingTemporaryStyleRestore(restoreTransitionDuration); 3383 setForcePanelIdle(true); 3384 return restoreLayoutStyles; 3385 } 3386 if (animationType === "css-animation") { 3387 setDimensions(getDimensions(panel)); 3388 if (!skipNextOpen) { 3389 const restoreAnimationName2 = setTemporaryStyle(panel, "animation-name", "none"); 3390 restoreAnimationName2(); 3391 return void 0; 3392 } 3393 const restoreAnimationName = setTemporaryStyle(panel, "animation-name", "none"); 3394 const restoreAnimationDuration = setTemporaryStyle(panel, "animation-duration", "0s"); 3395 restoreAnimationName(); 3396 setPendingTemporaryStyleRestore(restoreAnimationDuration); 3397 setForcePanelIdle(true); 3398 return void 0; 3399 } 3400 } 3401 if (!open && mounted && (transitionStatus === "idle" || transitionStatus === "starting")) { 3402 shouldPreventMountAnimationRef.current = false; 3403 shouldPreventActivityResumeAnimationRef.current = false; 3404 if (animationType === "none") { 3405 setDimensions(EMPTY_DIMENSIONS, false); 3406 setMounted(false); 3407 return void 0; 3408 } 3409 setDimensions(getDimensions(panel)); 3410 return void 0; 3411 } 3412 if (transitionStatus !== "ending") { 3413 return void 0; 3414 } 3415 if (animationType === "none") { 3416 setMounted(false); 3417 return void 0; 3418 } 3419 const nextDimensions = getDimensions(panel); 3420 const hasMeasuredSize = (nextDimensions.height ?? 0) > 0 || (nextDimensions.width ?? 0) > 0; 3421 if (!hasMeasuredSize) { 3422 setMounted(false); 3423 return void 0; 3424 } 3425 setDimensions(nextDimensions); 3426 if (animationType === "css-animation") { 3427 const restoreAnimationName = setTemporaryStyle(panel, "animation-name", "none"); 3428 restoreAnimationName(); 3429 } 3430 return void 0; 3431 }, [mounted, open, restorePendingTemporaryStyle, setDimensions, setMounted, setPendingTemporaryStyleRestore, shouldPreventOpenAnimation, transitionStatus]); 3432 useOpenChangeComplete({ 3433 enabled: open && mounted && panelTransitionStatus === "idle", 3434 open: true, 3435 ref: panelRef, 3436 onComplete() { 3437 if (!open) { 3438 return; 3439 } 3440 setDimensions(EMPTY_DIMENSIONS, false); 3441 } 3442 }); 3443 React18.useEffect(() => { 3444 if (open || !mounted || panelTransitionStatus !== "ending") { 3445 return void 0; 3446 } 3447 const panel = panelRef.current; 3448 if (!panel) { 3449 return void 0; 3450 } 3451 const abortController = new AbortController(); 3452 let endingStyleFrame = -1; 3453 function handleComplete() { 3454 if (latestStateRef.current.open) { 3455 return; 3456 } 3457 setMounted(false); 3458 setDimensions(EMPTY_DIMENSIONS, false); 3459 } 3460 endingStyleFrame = AnimationFrame.request(() => { 3461 if (!abortController.signal.aborted) { 3462 runOnceCloseAnimationsFinish(handleComplete, abortController.signal); 3463 } 3464 }); 3465 return () => { 3466 AnimationFrame.cancel(endingStyleFrame); 3467 abortController.abort(); 3468 }; 3469 }, [latestStateRef, mounted, open, panelTransitionStatus, runOnceCloseAnimationsFinish, setDimensions, setMounted]); 3470 useIsoLayoutEffect(() => { 3471 const panel = panelRef.current; 3472 if (!panel || !hiddenUntilFound || !hidden) { 3473 return; 3474 } 3475 panel.setAttribute("hidden", "until-found"); 3476 }, [hidden, hiddenUntilFound]); 3477 React18.useEffect(function registerBeforeMatchListener() { 3478 const panel = panelRef.current; 3479 if (!panel) { 3480 return void 0; 3481 } 3482 function handleBeforeMatch(event) { 3483 const eventDetails = createChangeEventDetails(reason_parts_exports.none, event); 3484 onOpenChange(true, eventDetails); 3485 if (eventDetails.isCanceled) { 3486 return; 3487 } 3488 shouldSkipNextOpenRef.current = true; 3489 setOpen(true); 3490 } 3491 return addEventListener(panel, "beforematch", handleBeforeMatch); 3492 }, [onOpenChange, setOpen]); 3493 const shouldRender = keepMounted || hiddenUntilFound || mounted || open; 3494 return { 3495 height: renderedDimensions.height, 3496 props: { 3497 ...shouldPersistHiddenTransitionStyles ? { 3498 [CollapsiblePanelDataAttributes.startingStyle]: "" 3499 } : void 0, 3500 hidden, 3501 id: idParam 3502 }, 3503 ref: mergedPanelRef, 3504 shouldPreventOpenAnimation, 3505 shouldRender, 3506 transitionStatus: panelTransitionStatus, 3507 width: renderedDimensions.width 3508 }; 3509 } 3510 function getDimensions(element) { 3511 return { 3512 height: element.scrollHeight, 3513 width: element.scrollWidth 3514 }; 3515 } 3516 function getAnimationType(element, hasSuppressedMountAnimation = false) { 3517 const panelStyles = getWindow(element).getComputedStyle(element); 3518 const hasAnimation = (panelStyles.animationName.split(",").map((name2) => name2.trim()).some((name2) => name2 !== "" && name2 !== "none") || hasSuppressedMountAnimation) && hasNonZeroDuration(panelStyles.animationDuration); 3519 const hasTransition = hasNonZeroDuration(panelStyles.transitionDuration); 3520 if (hasAnimation && hasTransition) { 3521 if (true) { 3522 warn("CSS transitions and CSS animations both detected on Collapsible or Accordion panel.", "Only one of either animation type should be used."); 3523 } 3524 return "css-transition"; 3525 } 3526 if (hasTransition) { 3527 return "css-transition"; 3528 } 3529 if (hasAnimation) { 3530 return "css-animation"; 3531 } 3532 return "none"; 3533 } 3534 function hasNonZeroDuration(value) { 3535 return value.split(",").map((part) => part.trim()).some((part) => part !== "" && Number.parseFloat(part) > 0); 3536 } 3537 function setTemporaryStyle(element, property, value) { 3538 const previousValue = element.style.getPropertyValue(property); 3539 const previousPriority = element.style.getPropertyPriority(property); 3540 element.style.setProperty(property, value); 3541 return () => { 3542 if (previousValue === "") { 3543 element.style.removeProperty(property); 3544 return; 3545 } 3546 element.style.setProperty(property, previousValue, previousPriority); 3547 }; 3548 } 3549 function resetLayoutStyles(element) { 3550 const originalLayoutStyles = { 3551 "justify-content": element.style.justifyContent, 3552 "align-items": element.style.alignItems, 3553 "align-content": element.style.alignContent, 3554 "justify-items": element.style.justifyItems 3555 }; 3556 Object.keys(originalLayoutStyles).forEach((key) => { 3557 element.style.setProperty(key, "initial", "important"); 3558 }); 3559 function restoreLayoutStyles() { 3560 Object.entries(originalLayoutStyles).forEach(([key, value]) => { 3561 if (value === "") { 3562 element.style.removeProperty(key); 3563 return; 3564 } 3565 element.style.setProperty(key, value); 3566 }); 3567 } 3568 const frame = AnimationFrame.request(restoreLayoutStyles); 3569 return () => { 3570 AnimationFrame.cancel(frame); 3571 restoreLayoutStyles(); 3572 }; 3573 } 3574 3575 // node_modules/@base-ui/utils/useOnFirstRender.mjs 3576 var React19 = __toESM(require_react(), 1); 3577 function useOnFirstRender(fn) { 3578 const ref = React19.useRef(true); 3579 if (ref.current) { 3580 ref.current = false; 3581 fn(); 3582 } 3583 } 3584 3585 // node_modules/@base-ui/utils/platform/parts.mjs 3586 var parts_exports = {}; 3587 __export(parts_exports, { 3588 engine: () => engine_exports, 3589 env: () => env_exports, 3590 os: () => os_exports, 3591 screenReader: () => screen_reader_exports 3592 }); 3593 3594 // node_modules/@base-ui/utils/platform/os.mjs 3595 var os_exports = {}; 3596 __export(os_exports, { 3597 android: () => android, 3598 apple: () => apple, 3599 ios: () => ios, 3600 linux: () => linux, 3601 mac: () => mac, 3602 windows: () => windows 3603 }); 3604 3605 // node_modules/@base-ui/utils/platform/shared.mjs 3606 function readRawData() { 3607 if (typeof navigator === "undefined") { 3608 return { 3609 userAgent: "", 3610 platform: "", 3611 maxTouchPoints: 0 3612 }; 3613 } 3614 if (true) { 3615 const uaData = navigator.userAgentData; 3616 if (uaData && Array.isArray(uaData.brands)) { 3617 return { 3618 userAgent: uaData.brands.map(({ 3619 brand, 3620 version: version2 3621 }) => `$brand}/$version2}`).join(" "), 3622 platform: uaData.platform ?? navigator.platform ?? "", 3623 maxTouchPoints: navigator.maxTouchPoints ?? 0 3624 }; 3625 } 3626 } 3627 return { 3628 userAgent: navigator.userAgent, 3629 platform: navigator.platform ?? "", 3630 maxTouchPoints: navigator.maxTouchPoints ?? 0 3631 }; 3632 } 3633 var { 3634 userAgent, 3635 platform, 3636 maxTouchPoints 3637 } = readRawData(); 3638 var lowerUserAgent = userAgent.toLowerCase(); 3639 var lowerPlatform = platform.toLowerCase(); 3640 3641 // node_modules/@base-ui/utils/platform/os.mjs 3642 var ios = /^i(os$|p)/.test(lowerPlatform) || lowerPlatform === "macintel" && maxTouchPoints > 1; 3643 var ANDROID_STRING = "android"; 3644 var android = lowerPlatform === ANDROID_STRING || lowerUserAgent.includes(ANDROID_STRING); 3645 var mac = !ios && lowerPlatform.startsWith("mac"); 3646 var windows = lowerPlatform.startsWith("win"); 3647 var linux = !android && /^(linux|chrome os)/.test(lowerPlatform); 3648 var apple = mac || ios; 3649 3650 // node_modules/@base-ui/utils/platform/engine.mjs 3651 var engine_exports = {}; 3652 __export(engine_exports, { 3653 blink: () => blink, 3654 gecko: () => gecko, 3655 webkit: () => webkit 3656 }); 3657 var webkit = typeof CSS !== "undefined" && !!CSS.supports?.("-webkit-backdrop-filter:none"); 3658 var gecko = !webkit && lowerUserAgent.includes("firefox"); 3659 var blink = !webkit && lowerUserAgent.includes("chrom"); 3660 3661 // node_modules/@base-ui/utils/platform/screen-reader.mjs 3662 var screen_reader_exports = {}; 3663 __export(screen_reader_exports, { 3664 voiceOver: () => voiceOver 3665 }); 3666 var voiceOver = apple; 3667 3668 // node_modules/@base-ui/utils/platform/env.mjs 3669 var env_exports = {}; 3670 __export(env_exports, { 3671 jsdom: () => jsdom 3672 }); 3673 var jsdom = /jsdom|happydom/.test(lowerUserAgent); 3674 3675 // node_modules/@base-ui/utils/useTimeout.mjs 3676 var EMPTY3 = 0; 3677 var Timeout = class _Timeout { 3678 static create() { 3679 return new _Timeout(); 3680 } 3681 currentId = EMPTY3; 3682 /** 3683 * Executes `fn` after `delay`, clearing any previously scheduled call. 3684 */ 3685 start(delay, fn) { 3686 this.clear(); 3687 this.currentId = setTimeout(() => { 3688 this.currentId = EMPTY3; 3689 fn(); 3690 }, delay); 3691 } 3692 isStarted() { 3693 return this.currentId !== EMPTY3; 3694 } 3695 clear = () => { 3696 if (this.currentId !== EMPTY3) { 3697 clearTimeout(this.currentId); 3698 this.currentId = EMPTY3; 3699 } 3700 }; 3701 disposeEffect = () => { 3702 return this.clear; 3703 }; 3704 }; 3705 function useTimeout() { 3706 const timeout = useRefWithInit(Timeout.create).current; 3707 useOnMount(timeout.disposeEffect); 3708 return timeout; 3709 } 3710 3711 // node_modules/@base-ui/react/floating-ui-react/components/FloatingDelayGroup.mjs 3712 var React20 = __toESM(require_react(), 1); 3713 3714 // node_modules/@base-ui/react/floating-ui-react/utils/event.mjs 3715 function isReactEvent(event) { 3716 return "nativeEvent" in event; 3717 } 3718 function isMouseLikePointerType(pointerType, strict) { 3719 const values = ["mouse", "pen"]; 3720 if (!strict) { 3721 values.push("", void 0); 3722 } 3723 return values.includes(pointerType); 3724 } 3725 function isClickLikeEvent(event) { 3726 const type = event.type; 3727 return type === "click" || type === "mousedown" || type === "keydown" || type === "keyup"; 3728 } 3729 3730 // node_modules/@base-ui/react/floating-ui-react/utils/constants.mjs 3731 var FOCUSABLE_ATTRIBUTE = "data-base-ui-focusable"; 3732 var TYPEABLE_SELECTOR = "input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])"; 3733 3734 // node_modules/@base-ui/react/internals/shadowDom.mjs 3735 function activeElement(doc) { 3736 let element = doc.activeElement; 3737 while (element?.shadowRoot?.activeElement != null) { 3738 element = element.shadowRoot.activeElement; 3739 } 3740 return element; 3741 } 3742 function contains(parent, child) { 3743 if (!parent || !child) { 3744 return false; 3745 } 3746 const rootNode = child.getRootNode?.(); 3747 if (parent.contains(child)) { 3748 return true; 3749 } 3750 if (rootNode && isShadowRoot(rootNode)) { 3751 let next = child; 3752 while (next) { 3753 if (parent === next) { 3754 return true; 3755 } 3756 next = next.parentNode || next.host; 3757 } 3758 } 3759 return false; 3760 } 3761 function getTarget(event) { 3762 if ("composedPath" in event) { 3763 return event.composedPath()[0]; 3764 } 3765 return event.target; 3766 } 3767 3768 // node_modules/@base-ui/react/floating-ui-react/utils/element.mjs 3769 function isTargetInsideEnabledTrigger(target, triggerElements) { 3770 if (!isElement(target)) { 3771 return false; 3772 } 3773 const targetElement = target; 3774 if (triggerElements.hasElement(targetElement)) { 3775 return !targetElement.hasAttribute("data-trigger-disabled"); 3776 } 3777 for (const [, trigger] of triggerElements.entries()) { 3778 if (contains(trigger, targetElement)) { 3779 return !trigger.hasAttribute("data-trigger-disabled"); 3780 } 3781 } 3782 return false; 3783 } 3784 function isEventTargetWithin(event, node) { 3785 if (node == null) { 3786 return false; 3787 } 3788 if ("composedPath" in event) { 3789 return event.composedPath().includes(node); 3790 } 3791 const eventAgain = event; 3792 return eventAgain.target != null && node.contains(eventAgain.target); 3793 } 3794 function isRootElement(element) { 3795 return element.matches("html,body"); 3796 } 3797 function isTypeableElement(element) { 3798 return isHTMLElement(element) && element.matches(TYPEABLE_SELECTOR); 3799 } 3800 function isInteractiveElement(element) { 3801 return element?.closest(`button,a[href],[role="button"],select,[tabindex]:not([tabindex="-1"]),$TYPEABLE_SELECTOR}`) != null; 3802 } 3803 function matchesFocusVisible(element) { 3804 if (!element || parts_exports.env.jsdom) { 3805 return true; 3806 } 3807 try { 3808 return element.matches(":focus-visible"); 3809 } catch (_e) { 3810 return true; 3811 } 3812 } 3813 3814 // node_modules/@base-ui/react/floating-ui-react/hooks/useHoverShared.mjs 3815 function resolveValue(value, pointerType) { 3816 if (pointerType != null && !isMouseLikePointerType(pointerType)) { 3817 return 0; 3818 } 3819 if (typeof value === "function") { 3820 return value(); 3821 } 3822 return value; 3823 } 3824 function getDelay(value, prop, pointerType) { 3825 const result = resolveValue(value, pointerType); 3826 if (typeof result === "number") { 3827 return result; 3828 } 3829 return result?.[prop]; 3830 } 3831 function getRestMs(value) { 3832 if (typeof value === "function") { 3833 return value(); 3834 } 3835 return value; 3836 } 3837 function isClickLikeOpenEvent(openEventType, interactedInside) { 3838 return interactedInside || openEventType === "click" || openEventType === "mousedown"; 3839 } 3840 function isHoverOpenEvent(openEventType) { 3841 return openEventType?.includes("mouse") && openEventType !== "mousedown"; 3842 } 3843 3844 // node_modules/@base-ui/react/floating-ui-react/components/FloatingDelayGroup.mjs 3845 var import_jsx_runtime = __toESM(require_jsx_runtime(), 1); 3846 var FloatingDelayGroupContext = /* @__PURE__ */ React20.createContext({ 3847 hasProvider: false, 3848 timeoutMs: 0, 3849 delayRef: { 3850 current: 0 3851 }, 3852 initialDelayRef: { 3853 current: 0 3854 }, 3855 timeout: new Timeout(), 3856 currentIdRef: { 3857 current: null 3858 }, 3859 currentContextRef: { 3860 current: null 3861 } 3862 }); 3863 if (true) FloatingDelayGroupContext.displayName = "FloatingDelayGroupContext"; 3864 function resetDelayRef(delayRef, initialDelayRef) { 3865 delayRef.current = initialDelayRef.current; 3866 } 3867 function FloatingDelayGroup(props) { 3868 const { 3869 children, 3870 delay, 3871 timeoutMs = 0 3872 } = props; 3873 const delayRef = React20.useRef(delay); 3874 const initialDelayRef = React20.useRef(delay); 3875 const currentIdRef = React20.useRef(null); 3876 const currentContextRef = React20.useRef(null); 3877 const timeout = useTimeout(); 3878 useIsoLayoutEffect(() => { 3879 initialDelayRef.current = delay; 3880 if (!currentIdRef.current) { 3881 delayRef.current = delay; 3882 return; 3883 } 3884 delayRef.current = { 3885 open: getDelay(delayRef.current, "open"), 3886 close: getDelay(delay, "close") 3887 }; 3888 }, [delay, currentIdRef, delayRef, initialDelayRef]); 3889 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FloatingDelayGroupContext.Provider, { 3890 value: React20.useMemo(() => ({ 3891 hasProvider: true, 3892 delayRef, 3893 initialDelayRef, 3894 currentIdRef, 3895 timeoutMs, 3896 currentContextRef, 3897 timeout 3898 }), [timeoutMs, timeout]), 3899 children 3900 }); 3901 } 3902 function useDelayGroup(context, options = { 3903 open: false 3904 }) { 3905 const { 3906 open 3907 } = options; 3908 const store2 = "rootStore" in context ? context.rootStore : context; 3909 const floatingId = store2.useState("floatingId"); 3910 const groupContext = React20.useContext(FloatingDelayGroupContext); 3911 const { 3912 currentIdRef, 3913 delayRef, 3914 timeoutMs, 3915 initialDelayRef, 3916 currentContextRef, 3917 hasProvider, 3918 timeout 3919 } = groupContext; 3920 const [isInstantPhase, setIsInstantPhase] = React20.useState(false); 3921 const openRef = React20.useRef(open); 3922 const isUnmountedRef = React20.useRef(false); 3923 useIsoLayoutEffect(() => { 3924 openRef.current = open; 3925 }, [open]); 3926 useIsoLayoutEffect(() => { 3927 return () => { 3928 isUnmountedRef.current = true; 3929 }; 3930 }, []); 3931 useIsoLayoutEffect(() => { 3932 function unset() { 3933 if (!isUnmountedRef.current) { 3934 setIsInstantPhase(false); 3935 } 3936 currentContextRef.current?.setIsInstantPhase(false); 3937 currentIdRef.current = null; 3938 currentContextRef.current = null; 3939 delayRef.current = initialDelayRef.current; 3940 timeout.clear(); 3941 } 3942 if (!currentIdRef.current) { 3943 return void 0; 3944 } 3945 if (!open && currentIdRef.current === floatingId) { 3946 setIsInstantPhase(false); 3947 if (timeoutMs) { 3948 const closingId = floatingId; 3949 timeout.start(timeoutMs, () => { 3950 if (store2.select("open") || currentIdRef.current && currentIdRef.current !== closingId) { 3951 return; 3952 } 3953 unset(); 3954 }); 3955 return () => { 3956 if (openRef.current || currentIdRef.current !== closingId) { 3957 timeout.clear(); 3958 } 3959 }; 3960 } 3961 unset(); 3962 } 3963 return void 0; 3964 }, [open, floatingId, currentIdRef, delayRef, timeoutMs, initialDelayRef, currentContextRef, timeout, store2]); 3965 useIsoLayoutEffect(() => { 3966 if (!open) { 3967 return; 3968 } 3969 const prevContext = currentContextRef.current; 3970 const prevId = currentIdRef.current; 3971 timeout.clear(); 3972 currentContextRef.current = { 3973 onOpenChange: store2.setOpen, 3974 setIsInstantPhase 3975 }; 3976 currentIdRef.current = floatingId; 3977 delayRef.current = { 3978 open: 0, 3979 close: getDelay(initialDelayRef.current, "close") 3980 }; 3981 if (prevId !== null && prevId !== floatingId) { 3982 setIsInstantPhase(true); 3983 prevContext?.setIsInstantPhase(true); 3984 prevContext?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.none)); 3985 } else { 3986 setIsInstantPhase(false); 3987 prevContext?.setIsInstantPhase(false); 3988 } 3989 }, [open, floatingId, store2, currentIdRef, delayRef, initialDelayRef, currentContextRef, timeout]); 3990 useIsoLayoutEffect(() => { 3991 return () => { 3992 if (currentIdRef.current === floatingId) { 3993 currentContextRef.current = null; 3994 if (!openRef.current) { 3995 return; 3996 } 3997 currentIdRef.current = null; 3998 resetDelayRef(delayRef, initialDelayRef); 3999 timeout.clear(); 4000 } 4001 }; 4002 }, [currentContextRef, currentIdRef, delayRef, floatingId, initialDelayRef, timeout]); 4003 return React20.useMemo(() => ({ 4004 hasProvider, 4005 delayRef, 4006 isInstantPhase 4007 }), [hasProvider, delayRef, isInstantPhase]); 4008 } 4009 4010 // node_modules/@base-ui/utils/mergeCleanups.mjs 4011 function mergeCleanups(...cleanups) { 4012 return () => { 4013 for (let i2 = 0; i2 < cleanups.length; i2 += 1) { 4014 const cleanup = cleanups[i2]; 4015 if (cleanup) { 4016 cleanup(); 4017 } 4018 } 4019 }; 4020 } 4021 4022 // node_modules/@base-ui/react/utils/FocusGuard.mjs 4023 var React21 = __toESM(require_react(), 1); 4024 4025 // node_modules/@base-ui/utils/visuallyHidden.mjs 4026 var visuallyHiddenBase = { 4027 clipPath: "inset(50%)", 4028 overflow: "hidden", 4029 whiteSpace: "nowrap", 4030 border: 0, 4031 padding: 0, 4032 width: 1, 4033 height: 1, 4034 margin: -1 4035 }; 4036 var visuallyHidden = { 4037 ...visuallyHiddenBase, 4038 position: "fixed", 4039 top: 0, 4040 left: 0 4041 }; 4042 var visuallyHiddenInput = { 4043 ...visuallyHiddenBase, 4044 position: "absolute" 4045 }; 4046 4047 // node_modules/@base-ui/react/utils/FocusGuard.mjs 4048 var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1); 4049 var FocusGuard = /* @__PURE__ */ React21.forwardRef(function FocusGuard2(props, ref) { 4050 const [role, setRole] = React21.useState(); 4051 useIsoLayoutEffect(() => { 4052 if (parts_exports.screenReader.voiceOver && parts_exports.engine.webkit) { 4053 setRole("button"); 4054 } 4055 }, []); 4056 const restProps = { 4057 tabIndex: 0, 4058 // Role is only for VoiceOver 4059 role 4060 }; 4061 return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { 4062 ...props, 4063 ref, 4064 style: visuallyHidden, 4065 "aria-hidden": role ? void 0 : true, 4066 ...restProps, 4067 "data-base-ui-focus-guard": "" 4068 }); 4069 }); 4070 if (true) FocusGuard.displayName = "FocusGuard"; 4071 4072 // node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs 4073 var sides = ["top", "right", "bottom", "left"]; 4074 var min = Math.min; 4075 var max = Math.max; 4076 var round = Math.round; 4077 var floor = Math.floor; 4078 var createCoords = (v2) => ({ 4079 x: v2, 4080 y: v2 4081 }); 4082 var oppositeSideMap = { 4083 left: "right", 4084 right: "left", 4085 bottom: "top", 4086 top: "bottom" 4087 }; 4088 function clamp(start2, value, end) { 4089 return max(start2, min(value, end)); 4090 } 4091 function evaluate(value, param) { 4092 return typeof value === "function" ? value(param) : value; 4093 } 4094 function getSide(placement) { 4095 return placement.split("-")[0]; 4096 } 4097 function getAlignment(placement) { 4098 return placement.split("-")[1]; 4099 } 4100 function getOppositeAxis(axis) { 4101 return axis === "x" ? "y" : "x"; 4102 } 4103 function getAxisLength(axis) { 4104 return axis === "y" ? "height" : "width"; 4105 } 4106 function getSideAxis(placement) { 4107 const firstChar = placement[0]; 4108 return firstChar === "t" || firstChar === "b" ? "y" : "x"; 4109 } 4110 function getAlignmentAxis(placement) { 4111 return getOppositeAxis(getSideAxis(placement)); 4112 } 4113 function getAlignmentSides(placement, rects, rtl) { 4114 if (rtl === void 0) { 4115 rtl = false; 4116 } 4117 const alignment = getAlignment(placement); 4118 const alignmentAxis = getAlignmentAxis(placement); 4119 const length = getAxisLength(alignmentAxis); 4120 let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top"; 4121 if (rects.reference[length] > rects.floating[length]) { 4122 mainAlignmentSide = getOppositePlacement(mainAlignmentSide); 4123 } 4124 return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)]; 4125 } 4126 function getExpandedPlacements(placement) { 4127 const oppositePlacement = getOppositePlacement(placement); 4128 return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)]; 4129 } 4130 function getOppositeAlignmentPlacement(placement) { 4131 return placement.includes("start") ? placement.replace("start", "end") : placement.replace("end", "start"); 4132 } 4133 var lrPlacement = ["left", "right"]; 4134 var rlPlacement = ["right", "left"]; 4135 var tbPlacement = ["top", "bottom"]; 4136 var btPlacement = ["bottom", "top"]; 4137 function getSideList(side, isStart, rtl) { 4138 switch (side) { 4139 case "top": 4140 case "bottom": 4141 if (rtl) return isStart ? rlPlacement : lrPlacement; 4142 return isStart ? lrPlacement : rlPlacement; 4143 case "left": 4144 case "right": 4145 return isStart ? tbPlacement : btPlacement; 4146 default: 4147 return []; 4148 } 4149 } 4150 function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) { 4151 const alignment = getAlignment(placement); 4152 let list = getSideList(getSide(placement), direction === "start", rtl); 4153 if (alignment) { 4154 list = list.map((side) => side + "-" + alignment); 4155 if (flipAlignment) { 4156 list = list.concat(list.map(getOppositeAlignmentPlacement)); 4157 } 4158 } 4159 return list; 4160 } 4161 function getOppositePlacement(placement) { 4162 const side = getSide(placement); 4163 return oppositeSideMap[side] + placement.slice(side.length); 4164 } 4165 function expandPaddingObject(padding) { 4166 return { 4167 top: 0, 4168 right: 0, 4169 bottom: 0, 4170 left: 0, 4171 ...padding 4172 }; 4173 } 4174 function getPaddingObject(padding) { 4175 return typeof padding !== "number" ? expandPaddingObject(padding) : { 4176 top: padding, 4177 right: padding, 4178 bottom: padding, 4179 left: padding 4180 }; 4181 } 4182 function rectToClientRect(rect) { 4183 const { 4184 x: x2, 4185 y: y2, 4186 width, 4187 height 4188 } = rect; 4189 return { 4190 width, 4191 height, 4192 top: y2, 4193 left: x2, 4194 right: x2 + width, 4195 bottom: y2 + height, 4196 x: x2, 4197 y: y2 4198 }; 4199 } 4200 4201 // node_modules/@base-ui/react/floating-ui-react/utils/composite.mjs 4202 function isHiddenByStyles(styles) { 4203 return styles.visibility === "hidden" || styles.visibility === "collapse"; 4204 } 4205 function isElementVisible(element, styles = element ? getComputedStyle2(element) : null) { 4206 if (!element || !element.isConnected || !styles || isHiddenByStyles(styles)) { 4207 return false; 4208 } 4209 if (typeof element.checkVisibility === "function") { 4210 return element.checkVisibility(); 4211 } 4212 return styles.display !== "none" && styles.display !== "contents"; 4213 } 4214 4215 // node_modules/@base-ui/react/floating-ui-react/utils/tabbable.mjs 4216 var CANDIDATE_SELECTOR = 'a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]'; 4217 function getParentElement(element) { 4218 const assignedSlot = element.assignedSlot; 4219 if (assignedSlot) { 4220 return assignedSlot; 4221 } 4222 if (element.parentElement) { 4223 return element.parentElement; 4224 } 4225 const rootNode = element.getRootNode(); 4226 return isShadowRoot(rootNode) ? rootNode.host : null; 4227 } 4228 function getDetailsSummary(details) { 4229 for (const child of Array.from(details.children)) { 4230 if (getNodeName(child) === "summary") { 4231 return child; 4232 } 4233 } 4234 return null; 4235 } 4236 function isWithinOpenDetailsSummary(element, details) { 4237 const summary = getDetailsSummary(details); 4238 return !!summary && (element === summary || contains(summary, element)); 4239 } 4240 function isFocusableCandidate(element) { 4241 const nodeName = element ? getNodeName(element) : ""; 4242 return element != null && element.matches(CANDIDATE_SELECTOR) && (nodeName !== "summary" || element.parentElement != null && getNodeName(element.parentElement) === "details" && getDetailsSummary(element.parentElement) === element) && (nodeName !== "details" || getDetailsSummary(element) == null) && (nodeName !== "input" || element.type !== "hidden"); 4243 } 4244 function isFocusableElement(element) { 4245 if (!isFocusableCandidate(element) || !element.isConnected || element.matches(":disabled")) { 4246 return false; 4247 } 4248 for (let current = element; current; current = getParentElement(current)) { 4249 const isAncestor = current !== element; 4250 const isSlot = getNodeName(current) === "slot"; 4251 if (current.hasAttribute("inert")) { 4252 return false; 4253 } 4254 if (isAncestor && getNodeName(current) === "details" && !current.open && !isWithinOpenDetailsSummary(element, current) || current.hasAttribute("hidden") || !isSlot && !isVisibleInTabbableTree(current, isAncestor)) { 4255 return false; 4256 } 4257 } 4258 return true; 4259 } 4260 function isVisibleInTabbableTree(element, isAncestor) { 4261 const styles = getComputedStyle2(element); 4262 if (!isAncestor) { 4263 return isElementVisible(element, styles); 4264 } 4265 return styles.display !== "none"; 4266 } 4267 function getTabIndex(element) { 4268 const tabIndex = element.tabIndex; 4269 if (tabIndex < 0) { 4270 const nodeName = getNodeName(element); 4271 if (nodeName === "details" || nodeName === "audio" || nodeName === "video" || isHTMLElement(element) && element.isContentEditable) { 4272 return 0; 4273 } 4274 } 4275 return tabIndex; 4276 } 4277 function getNamedRadioInput(element) { 4278 if (getNodeName(element) !== "input") { 4279 return null; 4280 } 4281 const input = element; 4282 return input.type === "radio" && input.name !== "" ? input : null; 4283 } 4284 function isTabbableRadio(element, candidates) { 4285 const input = getNamedRadioInput(element); 4286 if (!input) { 4287 return true; 4288 } 4289 const checkedRadio = candidates.find((candidate) => { 4290 const radio = getNamedRadioInput(candidate); 4291 return radio?.name === input.name && radio.form === input.form && radio.checked; 4292 }); 4293 if (checkedRadio) { 4294 return checkedRadio === input; 4295 } 4296 return candidates.find((candidate) => { 4297 const radio = getNamedRadioInput(candidate); 4298 return radio?.name === input.name && radio.form === input.form; 4299 }) === input; 4300 } 4301 function getComposedChildren(container) { 4302 if (isHTMLElement(container) && getNodeName(container) === "slot") { 4303 const assignedElements = container.assignedElements({ 4304 flatten: true 4305 }); 4306 if (assignedElements.length > 0) { 4307 return assignedElements; 4308 } 4309 } 4310 if (isHTMLElement(container) && container.shadowRoot) { 4311 return Array.from(container.shadowRoot.children); 4312 } 4313 return Array.from(container.children); 4314 } 4315 function appendCandidates(container, list) { 4316 getComposedChildren(container).forEach((child) => { 4317 if (isFocusableCandidate(child)) { 4318 list.push(child); 4319 } 4320 appendCandidates(child, list); 4321 }); 4322 } 4323 function appendMatchingElements(container, selector2, list) { 4324 getComposedChildren(container).forEach((child) => { 4325 if (isHTMLElement(child) && child.matches(selector2)) { 4326 list.push(child); 4327 } 4328 appendMatchingElements(child, selector2, list); 4329 }); 4330 } 4331 function focusable(container) { 4332 const candidates = []; 4333 appendCandidates(container, candidates); 4334 return candidates.filter(isFocusableElement); 4335 } 4336 function tabbable(container) { 4337 const candidates = focusable(container); 4338 return candidates.filter((element) => getTabIndex(element) >= 0 && isTabbableRadio(element, candidates)); 4339 } 4340 function getTabbableIn(container, dir) { 4341 const list = tabbable(container); 4342 const len = list.length; 4343 if (len === 0) { 4344 return void 0; 4345 } 4346 const active = activeElement(ownerDocument(container)); 4347 const index2 = list.indexOf(active); 4348 const nextIndex = index2 === -1 ? dir === 1 ? 0 : len - 1 : index2 + dir; 4349 return list[nextIndex]; 4350 } 4351 function getNextTabbable(referenceElement) { 4352 return getTabbableIn(ownerDocument(referenceElement).body, 1) || referenceElement; 4353 } 4354 function getPreviousTabbable(referenceElement) { 4355 return getTabbableIn(ownerDocument(referenceElement).body, -1) || referenceElement; 4356 } 4357 function isOutsideEvent(event, container) { 4358 const containerElement = container || event.currentTarget; 4359 const relatedTarget = event.relatedTarget; 4360 return !relatedTarget || !contains(containerElement, relatedTarget); 4361 } 4362 function disableFocusInside(container) { 4363 const tabbableElements = tabbable(container); 4364 tabbableElements.forEach((element) => { 4365 element.dataset.tabindex = element.getAttribute("tabindex") || ""; 4366 element.setAttribute("tabindex", "-1"); 4367 }); 4368 } 4369 function enableFocusInside(container) { 4370 const elements2 = []; 4371 appendMatchingElements(container, "[data-tabindex]", elements2); 4372 elements2.forEach((element) => { 4373 const tabindex = element.dataset.tabindex; 4374 delete element.dataset.tabindex; 4375 if (tabindex) { 4376 element.setAttribute("tabindex", tabindex); 4377 } else { 4378 element.removeAttribute("tabindex"); 4379 } 4380 }); 4381 } 4382 4383 // node_modules/@base-ui/react/floating-ui-react/utils/nodes.mjs 4384 function getNodeChildren(nodes, id, onlyOpenChildren = true) { 4385 const directChildren = nodes.filter((node) => node.parentId === id); 4386 return directChildren.flatMap((child) => [...!onlyOpenChildren || child.context?.open ? [child] : [], ...getNodeChildren(nodes, child.id, onlyOpenChildren)]); 4387 } 4388 4389 // node_modules/@base-ui/react/floating-ui-react/utils/createAttribute.mjs 4390 function createAttribute(name2) { 4391 return `data-base-ui-$name2}`; 4392 } 4393 4394 // node_modules/@base-ui/react/floating-ui-react/components/FloatingPortal.mjs 4395 var React22 = __toESM(require_react(), 1); 4396 var ReactDOM2 = __toESM(require_react_dom(), 1); 4397 4398 // node_modules/@base-ui/react/internals/constants.mjs 4399 var DISABLED_TRANSITIONS_STYLE = { 4400 style: { 4401 transition: "none" 4402 } 4403 }; 4404 var BASE_UI_SWIPE_IGNORE_ATTRIBUTE = "data-base-ui-swipe-ignore"; 4405 var LEGACY_SWIPE_IGNORE_ATTRIBUTE = "data-swipe-ignore"; 4406 var BASE_UI_SWIPE_IGNORE_SELECTOR = `[$BASE_UI_SWIPE_IGNORE_ATTRIBUTE}]`; 4407 var LEGACY_SWIPE_IGNORE_SELECTOR = `[$LEGACY_SWIPE_IGNORE_ATTRIBUTE}]`; 4408 var POPUP_COLLISION_AVOIDANCE = { 4409 fallbackAxisSide: "end" 4410 }; 4411 var ownerVisuallyHidden = { 4412 clipPath: "inset(50%)", 4413 position: "fixed", 4414 top: 0, 4415 left: 0 4416 }; 4417 4418 // node_modules/@base-ui/react/floating-ui-react/components/FloatingPortal.mjs 4419 var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1); 4420 var PortalContext = /* @__PURE__ */ React22.createContext(null); 4421 if (true) PortalContext.displayName = "PortalContext"; 4422 var usePortalContext = () => React22.useContext(PortalContext); 4423 var attr = createAttribute("portal"); 4424 function useFloatingPortalNode(props = {}) { 4425 const { 4426 ref, 4427 container: containerProp, 4428 componentProps = EMPTY_OBJECT, 4429 elementProps 4430 } = props; 4431 const uniqueId = useId(); 4432 const portalContext = usePortalContext(); 4433 const parentPortalNode = portalContext?.portalNode; 4434 const [containerElement, setContainerElement] = React22.useState(null); 4435 const [portalNode, setPortalNode] = React22.useState(null); 4436 const setPortalNodeRef = useStableCallback((node) => { 4437 if (node !== null) { 4438 setPortalNode(node); 4439 } 4440 }); 4441 const containerRef = React22.useRef(null); 4442 useIsoLayoutEffect(() => { 4443 if (containerProp === null) { 4444 if (containerRef.current) { 4445 containerRef.current = null; 4446 setPortalNode(null); 4447 setContainerElement(null); 4448 } 4449 return; 4450 } 4451 if (uniqueId == null) { 4452 return; 4453 } 4454 const resolvedContainer = (containerProp && (isNode(containerProp) ? containerProp : containerProp.current)) ?? parentPortalNode ?? document.body; 4455 if (resolvedContainer == null) { 4456 if (containerRef.current) { 4457 containerRef.current = null; 4458 setPortalNode(null); 4459 setContainerElement(null); 4460 } 4461 return; 4462 } 4463 if (containerRef.current !== resolvedContainer) { 4464 containerRef.current = resolvedContainer; 4465 setPortalNode(null); 4466 setContainerElement(resolvedContainer); 4467 } 4468 }, [containerProp, parentPortalNode, uniqueId]); 4469 const portalElement = useRenderElement("div", componentProps, { 4470 ref: [ref, setPortalNodeRef], 4471 props: [{ 4472 id: uniqueId, 4473 [attr]: "" 4474 }, elementProps] 4475 }); 4476 const portalSubtree = containerElement && portalElement ? /* @__PURE__ */ ReactDOM2.createPortal(portalElement, containerElement) : null; 4477 return { 4478 portalNode, 4479 portalSubtree 4480 }; 4481 } 4482 var FloatingPortal = /* @__PURE__ */ React22.forwardRef(function FloatingPortal2(componentProps, forwardedRef) { 4483 const { 4484 render: render4, 4485 className, 4486 style, 4487 children, 4488 container, 4489 renderGuards, 4490 ...elementProps 4491 } = componentProps; 4492 const { 4493 portalNode, 4494 portalSubtree 4495 } = useFloatingPortalNode({ 4496 container, 4497 ref: forwardedRef, 4498 componentProps, 4499 elementProps 4500 }); 4501 const beforeOutsideRef = React22.useRef(null); 4502 const afterOutsideRef = React22.useRef(null); 4503 const beforeInsideRef = React22.useRef(null); 4504 const afterInsideRef = React22.useRef(null); 4505 const [focusManagerState, setFocusManagerState] = React22.useState(null); 4506 const focusInsideDisabledRef = React22.useRef(false); 4507 const modal = focusManagerState?.modal; 4508 const open = focusManagerState?.open; 4509 const shouldRenderGuards = typeof renderGuards === "boolean" ? renderGuards : !!focusManagerState && !focusManagerState.modal && focusManagerState.open && !!portalNode; 4510 React22.useEffect(() => { 4511 if (!portalNode || modal) { 4512 return void 0; 4513 } 4514 function onFocus(event) { 4515 if (portalNode && event.relatedTarget && isOutsideEvent(event)) { 4516 if (event.type === "focusin") { 4517 if (focusInsideDisabledRef.current) { 4518 enableFocusInside(portalNode); 4519 focusInsideDisabledRef.current = false; 4520 } 4521 } else { 4522 disableFocusInside(portalNode); 4523 focusInsideDisabledRef.current = true; 4524 } 4525 } 4526 } 4527 return mergeCleanups(addEventListener(portalNode, "focusin", onFocus, true), addEventListener(portalNode, "focusout", onFocus, true)); 4528 }, [portalNode, modal]); 4529 useIsoLayoutEffect(() => { 4530 if (!portalNode || open !== true || !focusInsideDisabledRef.current) { 4531 return; 4532 } 4533 enableFocusInside(portalNode); 4534 focusInsideDisabledRef.current = false; 4535 }, [open, portalNode]); 4536 const portalContextValue = React22.useMemo(() => ({ 4537 beforeOutsideRef, 4538 afterOutsideRef, 4539 beforeInsideRef, 4540 afterInsideRef, 4541 portalNode, 4542 setFocusManagerState 4543 }), [portalNode]); 4544 return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(React22.Fragment, { 4545 children: [portalSubtree, /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(PortalContext.Provider, { 4546 value: portalContextValue, 4547 children: [shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FocusGuard, { 4548 "data-type": "outside", 4549 ref: beforeOutsideRef, 4550 onFocus: (event) => { 4551 if (isOutsideEvent(event, portalNode)) { 4552 beforeInsideRef.current?.focus(); 4553 } else { 4554 const domReference = focusManagerState ? focusManagerState.domReference : null; 4555 const prevTabbable = getPreviousTabbable(domReference); 4556 prevTabbable?.focus(); 4557 } 4558 } 4559 }), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { 4560 "aria-owns": portalNode.id, 4561 style: ownerVisuallyHidden 4562 }), portalNode && /* @__PURE__ */ ReactDOM2.createPortal(children, portalNode), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FocusGuard, { 4563 "data-type": "outside", 4564 ref: afterOutsideRef, 4565 onFocus: (event) => { 4566 if (isOutsideEvent(event, portalNode)) { 4567 afterInsideRef.current?.focus(); 4568 } else { 4569 const domReference = focusManagerState ? focusManagerState.domReference : null; 4570 const nextTabbable = getNextTabbable(domReference); 4571 nextTabbable?.focus(); 4572 if (focusManagerState?.closeOnFocusOut) { 4573 focusManagerState?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.focusOut, event.nativeEvent)); 4574 } 4575 } 4576 } 4577 })] 4578 })] 4579 }); 4580 }); 4581 if (true) FloatingPortal.displayName = "FloatingPortal"; 4582 4583 // node_modules/@base-ui/react/floating-ui-react/components/FloatingTree.mjs 4584 var React23 = __toESM(require_react(), 1); 4585 4586 // node_modules/@base-ui/react/floating-ui-react/utils/createEventEmitter.mjs 4587 function createEventEmitter() { 4588 const map = /* @__PURE__ */ new Map(); 4589 return { 4590 emit(event, data) { 4591 map.get(event)?.forEach((listener) => listener(data)); 4592 }, 4593 on(event, listener) { 4594 if (!map.has(event)) { 4595 map.set(event, /* @__PURE__ */ new Set()); 4596 } 4597 map.get(event).add(listener); 4598 }, 4599 off(event, listener) { 4600 map.get(event)?.delete(listener); 4601 } 4602 }; 4603 } 4604 4605 // node_modules/@base-ui/react/floating-ui-react/components/FloatingTree.mjs 4606 var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1); 4607 var FloatingNodeContext = /* @__PURE__ */ React23.createContext(null); 4608 if (true) FloatingNodeContext.displayName = "FloatingNodeContext"; 4609 var FloatingTreeContext = /* @__PURE__ */ React23.createContext(null); 4610 if (true) FloatingTreeContext.displayName = "FloatingTreeContext"; 4611 var useFloatingParentNodeId = () => React23.useContext(FloatingNodeContext)?.id || null; 4612 var useFloatingTree = (externalTree) => { 4613 const contextTree = React23.useContext(FloatingTreeContext); 4614 return externalTree ?? contextTree; 4615 }; 4616 4617 // node_modules/@base-ui/react/floating-ui-react/hooks/useClientPoint.mjs 4618 var React24 = __toESM(require_react(), 1); 4619 function createVirtualElement(domElement, data) { 4620 let offsetX = null; 4621 let offsetY = null; 4622 let isAutoUpdateEvent = false; 4623 return { 4624 contextElement: domElement || void 0, 4625 getBoundingClientRect() { 4626 const domRect = domElement?.getBoundingClientRect() || { 4627 width: 0, 4628 height: 0, 4629 x: 0, 4630 y: 0 4631 }; 4632 const isXAxis = data.axis === "x" || data.axis === "both"; 4633 const isYAxis = data.axis === "y" || data.axis === "both"; 4634 const canTrackCursorOnAutoUpdate = ["mouseenter", "mousemove"].includes(data.dataRef.current.openEvent?.type || "") && data.pointerType !== "touch"; 4635 let width = domRect.width; 4636 let height = domRect.height; 4637 let x2 = domRect.x; 4638 let y2 = domRect.y; 4639 if (offsetX == null && data.x && isXAxis) { 4640 offsetX = domRect.x - data.x; 4641 } 4642 if (offsetY == null && data.y && isYAxis) { 4643 offsetY = domRect.y - data.y; 4644 } 4645 x2 -= offsetX || 0; 4646 y2 -= offsetY || 0; 4647 width = 0; 4648 height = 0; 4649 if (!isAutoUpdateEvent || canTrackCursorOnAutoUpdate) { 4650 width = data.axis === "y" ? domRect.width : 0; 4651 height = data.axis === "x" ? domRect.height : 0; 4652 x2 = isXAxis && data.x != null ? data.x : x2; 4653 y2 = isYAxis && data.y != null ? data.y : y2; 4654 } else if (isAutoUpdateEvent && !canTrackCursorOnAutoUpdate) { 4655 height = data.axis === "x" ? domRect.height : height; 4656 width = data.axis === "y" ? domRect.width : width; 4657 } 4658 isAutoUpdateEvent = true; 4659 return { 4660 width, 4661 height, 4662 x: x2, 4663 y: y2, 4664 top: y2, 4665 right: x2 + width, 4666 bottom: y2 + height, 4667 left: x2 4668 }; 4669 } 4670 }; 4671 } 4672 function isMouseBasedEvent(event) { 4673 return event != null && event.clientX != null; 4674 } 4675 function useClientPoint(context, props = {}) { 4676 const { 4677 enabled = true, 4678 axis = "both" 4679 } = props; 4680 const store2 = "rootStore" in context ? context.rootStore : context; 4681 const open = store2.useState("open"); 4682 const floating = store2.useState("floatingElement"); 4683 const domReference = store2.useState("domReferenceElement"); 4684 const dataRef = store2.context.dataRef; 4685 const initialRef = React24.useRef(false); 4686 const cleanupListenerRef = React24.useRef(null); 4687 const [pointerType, setPointerType] = React24.useState(); 4688 const [reactive, setReactive] = React24.useState([]); 4689 const resetReference = useStableCallback((reference2) => { 4690 store2.set("positionReference", reference2); 4691 }); 4692 const setReference = useStableCallback((newX, newY, referenceElement) => { 4693 if (initialRef.current) { 4694 return; 4695 } 4696 if (dataRef.current.openEvent && !isMouseBasedEvent(dataRef.current.openEvent)) { 4697 return; 4698 } 4699 store2.set("positionReference", createVirtualElement(referenceElement ?? domReference, { 4700 x: newX, 4701 y: newY, 4702 axis, 4703 dataRef, 4704 pointerType 4705 })); 4706 }); 4707 const handleReferenceEnterOrMove = useStableCallback((event) => { 4708 if (!open) { 4709 setReference(event.clientX, event.clientY, event.currentTarget); 4710 } else if (!cleanupListenerRef.current) { 4711 setReference(event.clientX, event.clientY, event.currentTarget); 4712 setReactive([]); 4713 } 4714 }); 4715 const openCheck = isMouseLikePointerType(pointerType) ? floating : open; 4716 React24.useEffect(() => { 4717 if (!enabled) { 4718 resetReference(domReference); 4719 return void 0; 4720 } 4721 if (!openCheck) { 4722 return void 0; 4723 } 4724 function cleanupListener() { 4725 cleanupListenerRef.current?.(); 4726 cleanupListenerRef.current = null; 4727 } 4728 const win = getWindow(floating); 4729 function handleMouseMove(event) { 4730 const target = getTarget(event); 4731 if (!contains(floating, target)) { 4732 setReference(event.clientX, event.clientY); 4733 } else { 4734 cleanupListener(); 4735 } 4736 } 4737 if (!dataRef.current.openEvent || isMouseBasedEvent(dataRef.current.openEvent)) { 4738 cleanupListenerRef.current = addEventListener(win, "mousemove", handleMouseMove); 4739 } else { 4740 resetReference(domReference); 4741 } 4742 return cleanupListener; 4743 }, [openCheck, enabled, floating, dataRef, domReference, store2, setReference, resetReference, reactive]); 4744 React24.useEffect(() => () => { 4745 store2.set("positionReference", null); 4746 }, [store2]); 4747 React24.useEffect(() => { 4748 if (enabled && !floating) { 4749 initialRef.current = false; 4750 } 4751 }, [enabled, floating]); 4752 React24.useEffect(() => { 4753 if (!enabled && open) { 4754 initialRef.current = true; 4755 } 4756 }, [enabled, open]); 4757 const reference = React24.useMemo(() => { 4758 function setPointerTypeRef(event) { 4759 setPointerType(event.pointerType); 4760 } 4761 return { 4762 onPointerDown: setPointerTypeRef, 4763 onPointerEnter: setPointerTypeRef, 4764 onMouseMove: handleReferenceEnterOrMove, 4765 onMouseEnter: handleReferenceEnterOrMove 4766 }; 4767 }, [handleReferenceEnterOrMove]); 4768 return React24.useMemo(() => enabled ? { 4769 reference, 4770 trigger: reference 4771 } : {}, [enabled, reference]); 4772 } 4773 4774 // node_modules/@base-ui/react/floating-ui-react/hooks/useDismiss.mjs 4775 var React25 = __toESM(require_react(), 1); 4776 function alwaysFalse() { 4777 return false; 4778 } 4779 function normalizeProp(normalizable) { 4780 return { 4781 escapeKey: typeof normalizable === "boolean" ? normalizable : normalizable?.escapeKey ?? false, 4782 outsidePress: typeof normalizable === "boolean" ? normalizable : normalizable?.outsidePress ?? true 4783 }; 4784 } 4785 function useDismiss(context, props = {}) { 4786 const { 4787 enabled = true, 4788 escapeKey: escapeKey2 = true, 4789 outsidePress: outsidePressProp = true, 4790 outsidePressEvent = "sloppy", 4791 referencePress = alwaysFalse, 4792 bubbles, 4793 externalTree 4794 } = props; 4795 const store2 = "rootStore" in context ? context.rootStore : context; 4796 const open = store2.useState("open"); 4797 const floatingElement = store2.useState("floatingElement"); 4798 const { 4799 dataRef 4800 } = store2.context; 4801 const tree = useFloatingTree(externalTree); 4802 const outsidePressFn = useStableCallback(typeof outsidePressProp === "function" ? outsidePressProp : () => false); 4803 const outsidePress2 = typeof outsidePressProp === "function" ? outsidePressFn : outsidePressProp; 4804 const outsidePressEnabled = outsidePress2 !== false; 4805 const getOutsidePressEventProp = useStableCallback(() => outsidePressEvent); 4806 const { 4807 escapeKey: escapeKeyBubbles, 4808 outsidePress: outsidePressBubbles 4809 } = normalizeProp(bubbles); 4810 const pressStartedInsideRef = React25.useRef(false); 4811 const pressStartPreventedRef = React25.useRef(false); 4812 const suppressNextOutsideClickRef = React25.useRef(false); 4813 const isComposingRef = React25.useRef(false); 4814 const currentPointerTypeRef = React25.useRef(""); 4815 const touchStateRef = React25.useRef(null); 4816 const cancelDismissOnEndTimeout = useTimeout(); 4817 const clearInsideReactTreeTimeout = useTimeout(); 4818 const clearInsideReactTree = useStableCallback(() => { 4819 clearInsideReactTreeTimeout.clear(); 4820 dataRef.current.insideReactTree = false; 4821 }); 4822 const hasBlockingChild = useStableCallback((bubbleKey) => { 4823 const nodeId = dataRef.current.floatingContext?.nodeId; 4824 const children = tree ? getNodeChildren(tree.nodesRef.current, nodeId) : []; 4825 return children.some((child) => child.context?.open && !child.context.dataRef.current[bubbleKey]); 4826 }); 4827 const isEventWithinOwnElements = useStableCallback((event) => { 4828 return isEventTargetWithin(event, store2.select("floatingElement")) || isEventTargetWithin(event, store2.select("domReferenceElement")); 4829 }); 4830 const closeOnReferencePress = useStableCallback((event) => { 4831 if (!referencePress()) { 4832 return; 4833 } 4834 store2.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerPress, event.nativeEvent)); 4835 }); 4836 const closeOnEscapeKeyDown = useStableCallback((event) => { 4837 if (!open || !enabled || !escapeKey2 || event.key !== "Escape") { 4838 return; 4839 } 4840 if (isComposingRef.current) { 4841 return; 4842 } 4843 if (!escapeKeyBubbles && hasBlockingChild("__escapeKeyBubbles")) { 4844 return; 4845 } 4846 const native = isReactEvent(event) ? event.nativeEvent : event; 4847 const eventDetails = createChangeEventDetails(reason_parts_exports.escapeKey, native); 4848 store2.setOpen(false, eventDetails); 4849 if (!eventDetails.isCanceled) { 4850 event.preventDefault(); 4851 } 4852 if (!escapeKeyBubbles && !eventDetails.isPropagationAllowed) { 4853 event.stopPropagation(); 4854 } 4855 }); 4856 const markInsideReactTree = useStableCallback(() => { 4857 dataRef.current.insideReactTree = true; 4858 clearInsideReactTreeTimeout.start(0, clearInsideReactTree); 4859 }); 4860 const markPressStartedInsideReactTree = useStableCallback((event) => { 4861 if (!open || !enabled || event.button !== 0) { 4862 return; 4863 } 4864 const target = getTarget(event.nativeEvent); 4865 if (!contains(store2.select("floatingElement"), target)) { 4866 return; 4867 } 4868 if (!pressStartedInsideRef.current) { 4869 pressStartedInsideRef.current = true; 4870 pressStartPreventedRef.current = false; 4871 } 4872 }); 4873 const markInsidePressStartPrevented = useStableCallback((event) => { 4874 if (!open || !enabled) { 4875 return; 4876 } 4877 if (!(event.defaultPrevented || event.nativeEvent.defaultPrevented)) { 4878 return; 4879 } 4880 if (pressStartedInsideRef.current) { 4881 pressStartPreventedRef.current = true; 4882 } 4883 }); 4884 React25.useEffect(() => { 4885 if (!open || !enabled) { 4886 return void 0; 4887 } 4888 dataRef.current.__escapeKeyBubbles = escapeKeyBubbles; 4889 dataRef.current.__outsidePressBubbles = outsidePressBubbles; 4890 const compositionTimeout = new Timeout(); 4891 const preventedPressSuppressionTimeout = new Timeout(); 4892 function handleCompositionStart() { 4893 compositionTimeout.clear(); 4894 isComposingRef.current = true; 4895 } 4896 function handleCompositionEnd() { 4897 compositionTimeout.start( 4898 // 0ms or 1ms don't work in Safari. 5ms appears to consistently work. 4899 // Only apply to WebKit for the test to remain 0ms. 4900 parts_exports.engine.webkit ? 5 : 0, 4901 () => { 4902 isComposingRef.current = false; 4903 } 4904 ); 4905 } 4906 function suppressImmediateOutsideClickAfterPreventedStart() { 4907 suppressNextOutsideClickRef.current = true; 4908 preventedPressSuppressionTimeout.start(0, () => { 4909 suppressNextOutsideClickRef.current = false; 4910 }); 4911 } 4912 function resetPressStartState() { 4913 pressStartedInsideRef.current = false; 4914 pressStartPreventedRef.current = false; 4915 } 4916 function getOutsidePressEvent() { 4917 const type = currentPointerTypeRef.current; 4918 const computedType = type === "pen" || !type ? "mouse" : type; 4919 const outsidePressEventValue = getOutsidePressEventProp(); 4920 const resolved = typeof outsidePressEventValue === "function" ? outsidePressEventValue() : outsidePressEventValue; 4921 if (typeof resolved === "string") { 4922 return resolved; 4923 } 4924 return resolved[computedType]; 4925 } 4926 function shouldIgnoreEvent(event) { 4927 const computedOutsidePressEvent = getOutsidePressEvent(); 4928 return computedOutsidePressEvent === "intentional" && event.type !== "click" || computedOutsidePressEvent === "sloppy" && event.type === "click"; 4929 } 4930 function isEventWithinFloatingTree(event) { 4931 const nodeId = dataRef.current.floatingContext?.nodeId; 4932 const targetIsInsideChildren = tree && getNodeChildren(tree.nodesRef.current, nodeId).some((node) => isEventTargetWithin(event, node.context?.elements.floating)); 4933 return isEventWithinOwnElements(event) || targetIsInsideChildren; 4934 } 4935 function closeOnPressOutside(event) { 4936 if (shouldIgnoreEvent(event)) { 4937 if (event.type !== "click" && !isEventWithinOwnElements(event)) { 4938 preventedPressSuppressionTimeout.clear(); 4939 suppressNextOutsideClickRef.current = false; 4940 } 4941 clearInsideReactTree(); 4942 return; 4943 } 4944 if (dataRef.current.insideReactTree) { 4945 clearInsideReactTree(); 4946 return; 4947 } 4948 const target = getTarget(event); 4949 const inertSelector = `[$createAttribute("inert")}]`; 4950 const targetRoot = isElement(target) ? target.getRootNode() : null; 4951 const markers = Array.from((isShadowRoot(targetRoot) ? targetRoot : ownerDocument(store2.select("floatingElement"))).querySelectorAll(inertSelector)); 4952 const triggers = store2.context.triggerElements; 4953 if (target && (triggers.hasElement(target) || triggers.hasMatchingElement((trigger) => contains(trigger, target)))) { 4954 return; 4955 } 4956 let targetRootAncestor = isElement(target) ? target : null; 4957 while (targetRootAncestor && !isLastTraversableNode(targetRootAncestor)) { 4958 const nextParent = getParentNode(targetRootAncestor); 4959 if (isLastTraversableNode(nextParent) || !isElement(nextParent)) { 4960 break; 4961 } 4962 targetRootAncestor = nextParent; 4963 } 4964 if (markers.length && isElement(target) && !isRootElement(target) && // Clicked on a direct ancestor (e.g. FloatingOverlay). 4965 !contains(target, store2.select("floatingElement")) && // If the target root element contains none of the markers, then the 4966 // element was injected after the floating element rendered. 4967 markers.every((marker) => !contains(targetRootAncestor, marker))) { 4968 return; 4969 } 4970 if (isHTMLElement(target) && !("touches" in event)) { 4971 const lastTraversableNode = isLastTraversableNode(target); 4972 const style = getComputedStyle2(target); 4973 const scrollRe = /auto|scroll/; 4974 const isScrollableX = lastTraversableNode || scrollRe.test(style.overflowX); 4975 const isScrollableY = lastTraversableNode || scrollRe.test(style.overflowY); 4976 const canScrollX = isScrollableX && target.clientWidth > 0 && target.scrollWidth > target.clientWidth; 4977 const canScrollY = isScrollableY && target.clientHeight > 0 && target.scrollHeight > target.clientHeight; 4978 const isRTL23 = style.direction === "rtl"; 4979 const pressedVerticalScrollbar = canScrollY && (isRTL23 ? event.offsetX <= target.offsetWidth - target.clientWidth : event.offsetX > target.clientWidth); 4980 const pressedHorizontalScrollbar = canScrollX && event.offsetY > target.clientHeight; 4981 if (pressedVerticalScrollbar || pressedHorizontalScrollbar) { 4982 return; 4983 } 4984 } 4985 if (isEventWithinFloatingTree(event)) { 4986 return; 4987 } 4988 if (getOutsidePressEvent() === "intentional" && suppressNextOutsideClickRef.current) { 4989 preventedPressSuppressionTimeout.clear(); 4990 suppressNextOutsideClickRef.current = false; 4991 return; 4992 } 4993 if (typeof outsidePress2 === "function" && !outsidePress2(event)) { 4994 return; 4995 } 4996 if (hasBlockingChild("__outsidePressBubbles")) { 4997 return; 4998 } 4999 store2.setOpen(false, createChangeEventDetails(reason_parts_exports.outsidePress, event)); 5000 clearInsideReactTree(); 5001 } 5002 function handlePointerDown(event) { 5003 if (getOutsidePressEvent() !== "sloppy" || event.pointerType === "touch" || !store2.select("open") || !enabled || isEventWithinOwnElements(event)) { 5004 return; 5005 } 5006 closeOnPressOutside(event); 5007 } 5008 function handleTouchStart(event) { 5009 if (getOutsidePressEvent() !== "sloppy" || !store2.select("open") || !enabled || isEventWithinOwnElements(event)) { 5010 return; 5011 } 5012 const touch = event.touches[0]; 5013 if (touch) { 5014 touchStateRef.current = { 5015 startTime: Date.now(), 5016 startX: touch.clientX, 5017 startY: touch.clientY, 5018 dismissOnTouchEnd: false, 5019 dismissOnMouseDown: true 5020 }; 5021 cancelDismissOnEndTimeout.start(1e3, () => { 5022 if (touchStateRef.current) { 5023 touchStateRef.current.dismissOnTouchEnd = false; 5024 touchStateRef.current.dismissOnMouseDown = false; 5025 } 5026 }); 5027 } 5028 } 5029 function addTargetEventListenerOnce(event, listener) { 5030 const target = getTarget(event); 5031 if (!target) { 5032 return; 5033 } 5034 const unsubscribe2 = addEventListener(target, event.type, () => { 5035 listener(event); 5036 unsubscribe2(); 5037 }); 5038 } 5039 function handleTouchStartCapture(event) { 5040 currentPointerTypeRef.current = "touch"; 5041 addTargetEventListenerOnce(event, handleTouchStart); 5042 } 5043 function closeOnPressOutsideCapture(event) { 5044 cancelDismissOnEndTimeout.clear(); 5045 if (event.type === "pointerdown") { 5046 currentPointerTypeRef.current = event.pointerType; 5047 } 5048 if (event.type === "mousedown" && touchStateRef.current && !touchStateRef.current.dismissOnMouseDown) { 5049 return; 5050 } 5051 addTargetEventListenerOnce(event, (targetEvent) => { 5052 if (targetEvent.type === "pointerdown") { 5053 handlePointerDown(targetEvent); 5054 } else { 5055 closeOnPressOutside(targetEvent); 5056 } 5057 }); 5058 } 5059 function handlePressEndCapture(event) { 5060 if (!pressStartedInsideRef.current) { 5061 return; 5062 } 5063 const pressStartedInsideDefaultPrevented = pressStartPreventedRef.current; 5064 resetPressStartState(); 5065 if (getOutsidePressEvent() !== "intentional") { 5066 return; 5067 } 5068 if (event.type === "pointercancel") { 5069 if (pressStartedInsideDefaultPrevented) { 5070 suppressImmediateOutsideClickAfterPreventedStart(); 5071 } 5072 return; 5073 } 5074 if (isEventWithinFloatingTree(event)) { 5075 return; 5076 } 5077 if (pressStartedInsideDefaultPrevented) { 5078 suppressImmediateOutsideClickAfterPreventedStart(); 5079 return; 5080 } 5081 if (typeof outsidePress2 === "function" && !outsidePress2(event)) { 5082 return; 5083 } 5084 preventedPressSuppressionTimeout.clear(); 5085 suppressNextOutsideClickRef.current = true; 5086 clearInsideReactTree(); 5087 } 5088 function handleTouchMove(event) { 5089 if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventWithinOwnElements(event)) { 5090 return; 5091 } 5092 const touch = event.touches[0]; 5093 if (!touch) { 5094 return; 5095 } 5096 const deltaX = Math.abs(touch.clientX - touchStateRef.current.startX); 5097 const deltaY = Math.abs(touch.clientY - touchStateRef.current.startY); 5098 const distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY); 5099 if (distance > 5) { 5100 touchStateRef.current.dismissOnTouchEnd = true; 5101 } 5102 if (distance > 10) { 5103 closeOnPressOutside(event); 5104 cancelDismissOnEndTimeout.clear(); 5105 touchStateRef.current = null; 5106 } 5107 } 5108 function handleTouchMoveCapture(event) { 5109 addTargetEventListenerOnce(event, handleTouchMove); 5110 } 5111 function handleTouchEnd(event) { 5112 if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventWithinOwnElements(event)) { 5113 return; 5114 } 5115 if (touchStateRef.current.dismissOnTouchEnd) { 5116 closeOnPressOutside(event); 5117 } 5118 cancelDismissOnEndTimeout.clear(); 5119 touchStateRef.current = null; 5120 } 5121 function handleTouchEndCapture(event) { 5122 addTargetEventListenerOnce(event, handleTouchEnd); 5123 } 5124 const doc = ownerDocument(floatingElement); 5125 const unsubscribe = mergeCleanups(escapeKey2 && mergeCleanups(addEventListener(doc, "keydown", closeOnEscapeKeyDown), addEventListener(doc, "compositionstart", handleCompositionStart), addEventListener(doc, "compositionend", handleCompositionEnd)), outsidePressEnabled && mergeCleanups(addEventListener(doc, "click", closeOnPressOutsideCapture, true), addEventListener(doc, "pointerdown", closeOnPressOutsideCapture, true), addEventListener(doc, "pointerup", handlePressEndCapture, true), addEventListener(doc, "pointercancel", handlePressEndCapture, true), addEventListener(doc, "mousedown", closeOnPressOutsideCapture, true), addEventListener(doc, "mouseup", handlePressEndCapture, true), addEventListener(doc, "touchstart", handleTouchStartCapture, true), addEventListener(doc, "touchmove", handleTouchMoveCapture, true), addEventListener(doc, "touchend", handleTouchEndCapture, true))); 5126 return () => { 5127 unsubscribe(); 5128 compositionTimeout.clear(); 5129 preventedPressSuppressionTimeout.clear(); 5130 resetPressStartState(); 5131 suppressNextOutsideClickRef.current = false; 5132 }; 5133 }, [dataRef, floatingElement, escapeKey2, outsidePressEnabled, outsidePress2, open, enabled, escapeKeyBubbles, outsidePressBubbles, closeOnEscapeKeyDown, clearInsideReactTree, getOutsidePressEventProp, hasBlockingChild, isEventWithinOwnElements, tree, store2, cancelDismissOnEndTimeout]); 5134 React25.useEffect(clearInsideReactTree, [outsidePress2, clearInsideReactTree]); 5135 const reference = React25.useMemo(() => ({ 5136 onKeyDown: closeOnEscapeKeyDown, 5137 onPointerDown: closeOnReferencePress, 5138 onClick: closeOnReferencePress 5139 }), [closeOnEscapeKeyDown, closeOnReferencePress]); 5140 const floating = React25.useMemo(() => ({ 5141 onKeyDown: closeOnEscapeKeyDown, 5142 // `onMouseDown` may be blocked if `event.preventDefault()` is called in 5143 // `onPointerDown`, such as with <NumberField.ScrubArea>. 5144 // See https://github.com/mui/base-ui/pull/3379 5145 onPointerDown: markInsidePressStartPrevented, 5146 onMouseDown: markInsidePressStartPrevented, 5147 onClickCapture: markInsideReactTree, 5148 onMouseDownCapture(event) { 5149 markInsideReactTree(); 5150 markPressStartedInsideReactTree(event); 5151 }, 5152 onPointerDownCapture(event) { 5153 markInsideReactTree(); 5154 markPressStartedInsideReactTree(event); 5155 }, 5156 onMouseUpCapture: markInsideReactTree, 5157 onTouchEndCapture: markInsideReactTree, 5158 onTouchMoveCapture: markInsideReactTree 5159 }), [closeOnEscapeKeyDown, markInsideReactTree, markPressStartedInsideReactTree, markInsidePressStartPrevented]); 5160 return React25.useMemo(() => enabled ? { 5161 reference, 5162 floating, 5163 trigger: reference 5164 } : {}, [enabled, reference, floating]); 5165 } 5166 5167 // node_modules/@base-ui/react/floating-ui-react/hooks/useFloating.mjs 5168 var React32 = __toESM(require_react(), 1); 5169 5170 // node_modules/@floating-ui/core/dist/floating-ui.core.mjs 5171 function computeCoordsFromPlacement(_ref, placement, rtl) { 5172 let { 5173 reference, 5174 floating 5175 } = _ref; 5176 const sideAxis = getSideAxis(placement); 5177 const alignmentAxis = getAlignmentAxis(placement); 5178 const alignLength = getAxisLength(alignmentAxis); 5179 const side = getSide(placement); 5180 const isVertical = sideAxis === "y"; 5181 const commonX = reference.x + reference.width / 2 - floating.width / 2; 5182 const commonY = reference.y + reference.height / 2 - floating.height / 2; 5183 const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2; 5184 let coords; 5185 switch (side) { 5186 case "top": 5187 coords = { 5188 x: commonX, 5189 y: reference.y - floating.height 5190 }; 5191 break; 5192 case "bottom": 5193 coords = { 5194 x: commonX, 5195 y: reference.y + reference.height 5196 }; 5197 break; 5198 case "right": 5199 coords = { 5200 x: reference.x + reference.width, 5201 y: commonY 5202 }; 5203 break; 5204 case "left": 5205 coords = { 5206 x: reference.x - floating.width, 5207 y: commonY 5208 }; 5209 break; 5210 default: 5211 coords = { 5212 x: reference.x, 5213 y: reference.y 5214 }; 5215 } 5216 switch (getAlignment(placement)) { 5217 case "start": 5218 coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1); 5219 break; 5220 case "end": 5221 coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1); 5222 break; 5223 } 5224 return coords; 5225 } 5226 async function detectOverflow(state, options) { 5227 var _await$platform$isEle; 5228 if (options === void 0) { 5229 options = {}; 5230 } 5231 const { 5232 x: x2, 5233 y: y2, 5234 platform: platform3, 5235 rects, 5236 elements: elements2, 5237 strategy 5238 } = state; 5239 const { 5240 boundary = "clippingAncestors", 5241 rootBoundary = "viewport", 5242 elementContext = "floating", 5243 altBoundary = false, 5244 padding = 0 5245 } = evaluate(options, state); 5246 const paddingObject = getPaddingObject(padding); 5247 const altContext = elementContext === "floating" ? "reference" : "floating"; 5248 const element = elements2[altBoundary ? altContext : elementContext]; 5249 const clippingClientRect = rectToClientRect(await platform3.getClippingRect({ 5250 element: ((_await$platform$isEle = await (platform3.isElement == null ? void 0 : platform3.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || await (platform3.getDocumentElement == null ? void 0 : platform3.getDocumentElement(elements2.floating)), 5251 boundary, 5252 rootBoundary, 5253 strategy 5254 })); 5255 const rect = elementContext === "floating" ? { 5256 x: x2, 5257 y: y2, 5258 width: rects.floating.width, 5259 height: rects.floating.height 5260 } : rects.reference; 5261 const offsetParent = await (platform3.getOffsetParent == null ? void 0 : platform3.getOffsetParent(elements2.floating)); 5262 const offsetScale = await (platform3.isElement == null ? void 0 : platform3.isElement(offsetParent)) ? await (platform3.getScale == null ? void 0 : platform3.getScale(offsetParent)) || { 5263 x: 1, 5264 y: 1 5265 } : { 5266 x: 1, 5267 y: 1 5268 }; 5269 const elementClientRect = rectToClientRect(platform3.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform3.convertOffsetParentRelativeRectToViewportRelativeRect({ 5270 elements: elements2, 5271 rect, 5272 offsetParent, 5273 strategy 5274 }) : rect); 5275 return { 5276 top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y, 5277 bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y, 5278 left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x, 5279 right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x 5280 }; 5281 } 5282 var MAX_RESET_COUNT = 50; 5283 var computePosition = async (reference, floating, config2) => { 5284 const { 5285 placement = "bottom", 5286 strategy = "absolute", 5287 middleware = [], 5288 platform: platform3 5289 } = config2; 5290 const platformWithDetectOverflow = platform3.detectOverflow ? platform3 : { 5291 ...platform3, 5292 detectOverflow 5293 }; 5294 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(floating)); 5295 let rects = await platform3.getElementRects({ 5296 reference, 5297 floating, 5298 strategy 5299 }); 5300 let { 5301 x: x2, 5302 y: y2 5303 } = computeCoordsFromPlacement(rects, placement, rtl); 5304 let statefulPlacement = placement; 5305 let resetCount = 0; 5306 const middlewareData = {}; 5307 for (let i2 = 0; i2 < middleware.length; i2++) { 5308 const currentMiddleware = middleware[i2]; 5309 if (!currentMiddleware) { 5310 continue; 5311 } 5312 const { 5313 name: name2, 5314 fn 5315 } = currentMiddleware; 5316 const { 5317 x: nextX, 5318 y: nextY, 5319 data, 5320 reset 5321 } = await fn({ 5322 x: x2, 5323 y: y2, 5324 initialPlacement: placement, 5325 placement: statefulPlacement, 5326 strategy, 5327 middlewareData, 5328 rects, 5329 platform: platformWithDetectOverflow, 5330 elements: { 5331 reference, 5332 floating 5333 } 5334 }); 5335 x2 = nextX != null ? nextX : x2; 5336 y2 = nextY != null ? nextY : y2; 5337 middlewareData[name2] = { 5338 ...middlewareData[name2], 5339 ...data 5340 }; 5341 if (reset && resetCount < MAX_RESET_COUNT) { 5342 resetCount++; 5343 if (typeof reset === "object") { 5344 if (reset.placement) { 5345 statefulPlacement = reset.placement; 5346 } 5347 if (reset.rects) { 5348 rects = reset.rects === true ? await platform3.getElementRects({ 5349 reference, 5350 floating, 5351 strategy 5352 }) : reset.rects; 5353 } 5354 ({ 5355 x: x2, 5356 y: y2 5357 } = computeCoordsFromPlacement(rects, statefulPlacement, rtl)); 5358 } 5359 i2 = -1; 5360 } 5361 } 5362 return { 5363 x: x2, 5364 y: y2, 5365 placement: statefulPlacement, 5366 strategy, 5367 middlewareData 5368 }; 5369 }; 5370 var flip = function(options) { 5371 if (options === void 0) { 5372 options = {}; 5373 } 5374 return { 5375 name: "flip", 5376 options, 5377 async fn(state) { 5378 var _middlewareData$arrow, _middlewareData$flip; 5379 const { 5380 placement, 5381 middlewareData, 5382 rects, 5383 initialPlacement, 5384 platform: platform3, 5385 elements: elements2 5386 } = state; 5387 const { 5388 mainAxis: checkMainAxis = true, 5389 crossAxis: checkCrossAxis = true, 5390 fallbackPlacements: specifiedFallbackPlacements, 5391 fallbackStrategy = "bestFit", 5392 fallbackAxisSideDirection = "none", 5393 flipAlignment = true, 5394 ...detectOverflowOptions 5395 } = evaluate(options, state); 5396 if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) { 5397 return {}; 5398 } 5399 const side = getSide(placement); 5400 const initialSideAxis = getSideAxis(initialPlacement); 5401 const isBasePlacement = getSide(initialPlacement) === initialPlacement; 5402 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements2.floating)); 5403 const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement)); 5404 const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none"; 5405 if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) { 5406 fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl)); 5407 } 5408 const placements2 = [initialPlacement, ...fallbackPlacements]; 5409 const overflow = await platform3.detectOverflow(state, detectOverflowOptions); 5410 const overflows = []; 5411 let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || []; 5412 if (checkMainAxis) { 5413 overflows.push(overflow[side]); 5414 } 5415 if (checkCrossAxis) { 5416 const sides2 = getAlignmentSides(placement, rects, rtl); 5417 overflows.push(overflow[sides2[0]], overflow[sides2[1]]); 5418 } 5419 overflowsData = [...overflowsData, { 5420 placement, 5421 overflows 5422 }]; 5423 if (!overflows.every((side2) => side2 <= 0)) { 5424 var _middlewareData$flip2, _overflowsData$filter; 5425 const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1; 5426 const nextPlacement = placements2[nextIndex]; 5427 if (nextPlacement) { 5428 const ignoreCrossAxisOverflow = checkCrossAxis === "alignment" ? initialSideAxis !== getSideAxis(nextPlacement) : false; 5429 if (!ignoreCrossAxisOverflow || // We leave the current main axis only if every placement on that axis 5430 // overflows the main axis. 5431 overflowsData.every((d2) => getSideAxis(d2.placement) === initialSideAxis ? d2.overflows[0] > 0 : true)) { 5432 return { 5433 data: { 5434 index: nextIndex, 5435 overflows: overflowsData 5436 }, 5437 reset: { 5438 placement: nextPlacement 5439 } 5440 }; 5441 } 5442 } 5443 let resetPlacement = (_overflowsData$filter = overflowsData.filter((d2) => d2.overflows[0] <= 0).sort((a2, b2) => a2.overflows[1] - b2.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement; 5444 if (!resetPlacement) { 5445 switch (fallbackStrategy) { 5446 case "bestFit": { 5447 var _overflowsData$filter2; 5448 const placement2 = (_overflowsData$filter2 = overflowsData.filter((d2) => { 5449 if (hasFallbackAxisSideDirection) { 5450 const currentSideAxis = getSideAxis(d2.placement); 5451 return currentSideAxis === initialSideAxis || // Create a bias to the `y` side axis due to horizontal 5452 // reading directions favoring greater width. 5453 currentSideAxis === "y"; 5454 } 5455 return true; 5456 }).map((d2) => [d2.placement, d2.overflows.filter((overflow2) => overflow2 > 0).reduce((acc, overflow2) => acc + overflow2, 0)]).sort((a2, b2) => a2[1] - b2[1])[0]) == null ? void 0 : _overflowsData$filter2[0]; 5457 if (placement2) { 5458 resetPlacement = placement2; 5459 } 5460 break; 5461 } 5462 case "initialPlacement": 5463 resetPlacement = initialPlacement; 5464 break; 5465 } 5466 } 5467 if (placement !== resetPlacement) { 5468 return { 5469 reset: { 5470 placement: resetPlacement 5471 } 5472 }; 5473 } 5474 } 5475 return {}; 5476 } 5477 }; 5478 }; 5479 function getSideOffsets(overflow, rect) { 5480 return { 5481 top: overflow.top - rect.height, 5482 right: overflow.right - rect.width, 5483 bottom: overflow.bottom - rect.height, 5484 left: overflow.left - rect.width 5485 }; 5486 } 5487 function isAnySideFullyClipped(overflow) { 5488 return sides.some((side) => overflow[side] >= 0); 5489 } 5490 var hide = function(options) { 5491 if (options === void 0) { 5492 options = {}; 5493 } 5494 return { 5495 name: "hide", 5496 options, 5497 async fn(state) { 5498 const { 5499 rects, 5500 platform: platform3 5501 } = state; 5502 const { 5503 strategy = "referenceHidden", 5504 ...detectOverflowOptions 5505 } = evaluate(options, state); 5506 switch (strategy) { 5507 case "referenceHidden": { 5508 const overflow = await platform3.detectOverflow(state, { 5509 ...detectOverflowOptions, 5510 elementContext: "reference" 5511 }); 5512 const offsets = getSideOffsets(overflow, rects.reference); 5513 return { 5514 data: { 5515 referenceHiddenOffsets: offsets, 5516 referenceHidden: isAnySideFullyClipped(offsets) 5517 } 5518 }; 5519 } 5520 case "escaped": { 5521 const overflow = await platform3.detectOverflow(state, { 5522 ...detectOverflowOptions, 5523 altBoundary: true 5524 }); 5525 const offsets = getSideOffsets(overflow, rects.floating); 5526 return { 5527 data: { 5528 escapedOffsets: offsets, 5529 escaped: isAnySideFullyClipped(offsets) 5530 } 5531 }; 5532 } 5533 default: { 5534 return {}; 5535 } 5536 } 5537 } 5538 }; 5539 }; 5540 var originSides = /* @__PURE__ */ new Set(["left", "top"]); 5541 async function convertValueToCoords(state, options) { 5542 const { 5543 placement, 5544 platform: platform3, 5545 elements: elements2 5546 } = state; 5547 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements2.floating)); 5548 const side = getSide(placement); 5549 const alignment = getAlignment(placement); 5550 const isVertical = getSideAxis(placement) === "y"; 5551 const mainAxisMulti = originSides.has(side) ? -1 : 1; 5552 const crossAxisMulti = rtl && isVertical ? -1 : 1; 5553 const rawValue = evaluate(options, state); 5554 let { 5555 mainAxis, 5556 crossAxis, 5557 alignmentAxis 5558 } = typeof rawValue === "number" ? { 5559 mainAxis: rawValue, 5560 crossAxis: 0, 5561 alignmentAxis: null 5562 } : { 5563 mainAxis: rawValue.mainAxis || 0, 5564 crossAxis: rawValue.crossAxis || 0, 5565 alignmentAxis: rawValue.alignmentAxis 5566 }; 5567 if (alignment && typeof alignmentAxis === "number") { 5568 crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis; 5569 } 5570 return isVertical ? { 5571 x: crossAxis * crossAxisMulti, 5572 y: mainAxis * mainAxisMulti 5573 } : { 5574 x: mainAxis * mainAxisMulti, 5575 y: crossAxis * crossAxisMulti 5576 }; 5577 } 5578 var offset = function(options) { 5579 if (options === void 0) { 5580 options = 0; 5581 } 5582 return { 5583 name: "offset", 5584 options, 5585 async fn(state) { 5586 var _middlewareData$offse, _middlewareData$arrow; 5587 const { 5588 x: x2, 5589 y: y2, 5590 placement, 5591 middlewareData 5592 } = state; 5593 const diffCoords = await convertValueToCoords(state, options); 5594 if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) { 5595 return {}; 5596 } 5597 return { 5598 x: x2 + diffCoords.x, 5599 y: y2 + diffCoords.y, 5600 data: { 5601 ...diffCoords, 5602 placement 5603 } 5604 }; 5605 } 5606 }; 5607 }; 5608 var shift = function(options) { 5609 if (options === void 0) { 5610 options = {}; 5611 } 5612 return { 5613 name: "shift", 5614 options, 5615 async fn(state) { 5616 const { 5617 x: x2, 5618 y: y2, 5619 placement, 5620 platform: platform3 5621 } = state; 5622 const { 5623 mainAxis: checkMainAxis = true, 5624 crossAxis: checkCrossAxis = false, 5625 limiter = { 5626 fn: (_ref) => { 5627 let { 5628 x: x3, 5629 y: y3 5630 } = _ref; 5631 return { 5632 x: x3, 5633 y: y3 5634 }; 5635 } 5636 }, 5637 ...detectOverflowOptions 5638 } = evaluate(options, state); 5639 const coords = { 5640 x: x2, 5641 y: y2 5642 }; 5643 const overflow = await platform3.detectOverflow(state, detectOverflowOptions); 5644 const crossAxis = getSideAxis(getSide(placement)); 5645 const mainAxis = getOppositeAxis(crossAxis); 5646 let mainAxisCoord = coords[mainAxis]; 5647 let crossAxisCoord = coords[crossAxis]; 5648 if (checkMainAxis) { 5649 const minSide = mainAxis === "y" ? "top" : "left"; 5650 const maxSide = mainAxis === "y" ? "bottom" : "right"; 5651 const min2 = mainAxisCoord + overflow[minSide]; 5652 const max2 = mainAxisCoord - overflow[maxSide]; 5653 mainAxisCoord = clamp(min2, mainAxisCoord, max2); 5654 } 5655 if (checkCrossAxis) { 5656 const minSide = crossAxis === "y" ? "top" : "left"; 5657 const maxSide = crossAxis === "y" ? "bottom" : "right"; 5658 const min2 = crossAxisCoord + overflow[minSide]; 5659 const max2 = crossAxisCoord - overflow[maxSide]; 5660 crossAxisCoord = clamp(min2, crossAxisCoord, max2); 5661 } 5662 const limitedCoords = limiter.fn({ 5663 ...state, 5664 [mainAxis]: mainAxisCoord, 5665 [crossAxis]: crossAxisCoord 5666 }); 5667 return { 5668 ...limitedCoords, 5669 data: { 5670 x: limitedCoords.x - x2, 5671 y: limitedCoords.y - y2, 5672 enabled: { 5673 [mainAxis]: checkMainAxis, 5674 [crossAxis]: checkCrossAxis 5675 } 5676 } 5677 }; 5678 } 5679 }; 5680 }; 5681 var limitShift = function(options) { 5682 if (options === void 0) { 5683 options = {}; 5684 } 5685 return { 5686 options, 5687 fn(state) { 5688 const { 5689 x: x2, 5690 y: y2, 5691 placement, 5692 rects, 5693 middlewareData 5694 } = state; 5695 const { 5696 offset: offset4 = 0, 5697 mainAxis: checkMainAxis = true, 5698 crossAxis: checkCrossAxis = true 5699 } = evaluate(options, state); 5700 const coords = { 5701 x: x2, 5702 y: y2 5703 }; 5704 const crossAxis = getSideAxis(placement); 5705 const mainAxis = getOppositeAxis(crossAxis); 5706 let mainAxisCoord = coords[mainAxis]; 5707 let crossAxisCoord = coords[crossAxis]; 5708 const rawOffset = evaluate(offset4, state); 5709 const computedOffset = typeof rawOffset === "number" ? { 5710 mainAxis: rawOffset, 5711 crossAxis: 0 5712 } : { 5713 mainAxis: 0, 5714 crossAxis: 0, 5715 ...rawOffset 5716 }; 5717 if (checkMainAxis) { 5718 const len = mainAxis === "y" ? "height" : "width"; 5719 const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis; 5720 const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis; 5721 if (mainAxisCoord < limitMin) { 5722 mainAxisCoord = limitMin; 5723 } else if (mainAxisCoord > limitMax) { 5724 mainAxisCoord = limitMax; 5725 } 5726 } 5727 if (checkCrossAxis) { 5728 var _middlewareData$offse, _middlewareData$offse2; 5729 const len = mainAxis === "y" ? "width" : "height"; 5730 const isOriginSide = originSides.has(getSide(placement)); 5731 const limitMin = rects.reference[crossAxis] - rects.floating[len] + (isOriginSide ? ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse[crossAxis]) || 0 : 0) + (isOriginSide ? 0 : computedOffset.crossAxis); 5732 const limitMax = rects.reference[crossAxis] + rects.reference[len] + (isOriginSide ? 0 : ((_middlewareData$offse2 = middlewareData.offset) == null ? void 0 : _middlewareData$offse2[crossAxis]) || 0) - (isOriginSide ? computedOffset.crossAxis : 0); 5733 if (crossAxisCoord < limitMin) { 5734 crossAxisCoord = limitMin; 5735 } else if (crossAxisCoord > limitMax) { 5736 crossAxisCoord = limitMax; 5737 } 5738 } 5739 return { 5740 [mainAxis]: mainAxisCoord, 5741 [crossAxis]: crossAxisCoord 5742 }; 5743 } 5744 }; 5745 }; 5746 var size = function(options) { 5747 if (options === void 0) { 5748 options = {}; 5749 } 5750 return { 5751 name: "size", 5752 options, 5753 async fn(state) { 5754 var _state$middlewareData, _state$middlewareData2; 5755 const { 5756 placement, 5757 rects, 5758 platform: platform3, 5759 elements: elements2 5760 } = state; 5761 const { 5762 apply = () => { 5763 }, 5764 ...detectOverflowOptions 5765 } = evaluate(options, state); 5766 const overflow = await platform3.detectOverflow(state, detectOverflowOptions); 5767 const side = getSide(placement); 5768 const alignment = getAlignment(placement); 5769 const isYAxis = getSideAxis(placement) === "y"; 5770 const { 5771 width, 5772 height 5773 } = rects.floating; 5774 let heightSide; 5775 let widthSide; 5776 if (side === "top" || side === "bottom") { 5777 heightSide = side; 5778 widthSide = alignment === (await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements2.floating)) ? "start" : "end") ? "left" : "right"; 5779 } else { 5780 widthSide = side; 5781 heightSide = alignment === "end" ? "top" : "bottom"; 5782 } 5783 const maximumClippingHeight = height - overflow.top - overflow.bottom; 5784 const maximumClippingWidth = width - overflow.left - overflow.right; 5785 const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight); 5786 const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth); 5787 const noShift = !state.middlewareData.shift; 5788 let availableHeight = overflowAvailableHeight; 5789 let availableWidth = overflowAvailableWidth; 5790 if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) { 5791 availableWidth = maximumClippingWidth; 5792 } 5793 if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) { 5794 availableHeight = maximumClippingHeight; 5795 } 5796 if (noShift && !alignment) { 5797 const xMin = max(overflow.left, 0); 5798 const xMax = max(overflow.right, 0); 5799 const yMin = max(overflow.top, 0); 5800 const yMax = max(overflow.bottom, 0); 5801 if (isYAxis) { 5802 availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right)); 5803 } else { 5804 availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom)); 5805 } 5806 } 5807 await apply({ 5808 ...state, 5809 availableWidth, 5810 availableHeight 5811 }); 5812 const nextDimensions = await platform3.getDimensions(elements2.floating); 5813 if (width !== nextDimensions.width || height !== nextDimensions.height) { 5814 return { 5815 reset: { 5816 rects: true 5817 } 5818 }; 5819 } 5820 return {}; 5821 } 5822 }; 5823 }; 5824 5825 // node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs 5826 function getCssDimensions(element) { 5827 const css = getComputedStyle2(element); 5828 let width = parseFloat(css.width) || 0; 5829 let height = parseFloat(css.height) || 0; 5830 const hasOffset = isHTMLElement(element); 5831 const offsetWidth = hasOffset ? element.offsetWidth : width; 5832 const offsetHeight = hasOffset ? element.offsetHeight : height; 5833 const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight; 5834 if (shouldFallback) { 5835 width = offsetWidth; 5836 height = offsetHeight; 5837 } 5838 return { 5839 width, 5840 height, 5841 $: shouldFallback 5842 }; 5843 } 5844 function unwrapElement(element) { 5845 return !isElement(element) ? element.contextElement : element; 5846 } 5847 function getScale(element) { 5848 const domElement = unwrapElement(element); 5849 if (!isHTMLElement(domElement)) { 5850 return createCoords(1); 5851 } 5852 const rect = domElement.getBoundingClientRect(); 5853 const { 5854 width, 5855 height, 5856 $: $2 5857 } = getCssDimensions(domElement); 5858 let x2 = ($2 ? round(rect.width) : rect.width) / width; 5859 let y2 = ($2 ? round(rect.height) : rect.height) / height; 5860 if (!x2 || !Number.isFinite(x2)) { 5861 x2 = 1; 5862 } 5863 if (!y2 || !Number.isFinite(y2)) { 5864 y2 = 1; 5865 } 5866 return { 5867 x: x2, 5868 y: y2 5869 }; 5870 } 5871 var noOffsets = /* @__PURE__ */ createCoords(0); 5872 function getVisualOffsets(element) { 5873 const win = getWindow(element); 5874 if (!isWebKit() || !win.visualViewport) { 5875 return noOffsets; 5876 } 5877 return { 5878 x: win.visualViewport.offsetLeft, 5879 y: win.visualViewport.offsetTop 5880 }; 5881 } 5882 function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) { 5883 if (isFixed === void 0) { 5884 isFixed = false; 5885 } 5886 if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) { 5887 return false; 5888 } 5889 return isFixed; 5890 } 5891 function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) { 5892 if (includeScale === void 0) { 5893 includeScale = false; 5894 } 5895 if (isFixedStrategy === void 0) { 5896 isFixedStrategy = false; 5897 } 5898 const clientRect = element.getBoundingClientRect(); 5899 const domElement = unwrapElement(element); 5900 let scale = createCoords(1); 5901 if (includeScale) { 5902 if (offsetParent) { 5903 if (isElement(offsetParent)) { 5904 scale = getScale(offsetParent); 5905 } 5906 } else { 5907 scale = getScale(element); 5908 } 5909 } 5910 const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0); 5911 let x2 = (clientRect.left + visualOffsets.x) / scale.x; 5912 let y2 = (clientRect.top + visualOffsets.y) / scale.y; 5913 let width = clientRect.width / scale.x; 5914 let height = clientRect.height / scale.y; 5915 if (domElement) { 5916 const win = getWindow(domElement); 5917 const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent; 5918 let currentWin = win; 5919 let currentIFrame = getFrameElement(currentWin); 5920 while (currentIFrame && offsetParent && offsetWin !== currentWin) { 5921 const iframeScale = getScale(currentIFrame); 5922 const iframeRect = currentIFrame.getBoundingClientRect(); 5923 const css = getComputedStyle2(currentIFrame); 5924 const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x; 5925 const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y; 5926 x2 *= iframeScale.x; 5927 y2 *= iframeScale.y; 5928 width *= iframeScale.x; 5929 height *= iframeScale.y; 5930 x2 += left; 5931 y2 += top; 5932 currentWin = getWindow(currentIFrame); 5933 currentIFrame = getFrameElement(currentWin); 5934 } 5935 } 5936 return rectToClientRect({ 5937 width, 5938 height, 5939 x: x2, 5940 y: y2 5941 }); 5942 } 5943 function getWindowScrollBarX(element, rect) { 5944 const leftScroll = getNodeScroll(element).scrollLeft; 5945 if (!rect) { 5946 return getBoundingClientRect(getDocumentElement(element)).left + leftScroll; 5947 } 5948 return rect.left + leftScroll; 5949 } 5950 function getHTMLOffset(documentElement, scroll) { 5951 const htmlRect = documentElement.getBoundingClientRect(); 5952 const x2 = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect); 5953 const y2 = htmlRect.top + scroll.scrollTop; 5954 return { 5955 x: x2, 5956 y: y2 5957 }; 5958 } 5959 function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) { 5960 let { 5961 elements: elements2, 5962 rect, 5963 offsetParent, 5964 strategy 5965 } = _ref; 5966 const isFixed = strategy === "fixed"; 5967 const documentElement = getDocumentElement(offsetParent); 5968 const topLayer = elements2 ? isTopLayer(elements2.floating) : false; 5969 if (offsetParent === documentElement || topLayer && isFixed) { 5970 return rect; 5971 } 5972 let scroll = { 5973 scrollLeft: 0, 5974 scrollTop: 0 5975 }; 5976 let scale = createCoords(1); 5977 const offsets = createCoords(0); 5978 const isOffsetParentAnElement = isHTMLElement(offsetParent); 5979 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) { 5980 if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) { 5981 scroll = getNodeScroll(offsetParent); 5982 } 5983 if (isOffsetParentAnElement) { 5984 const offsetRect = getBoundingClientRect(offsetParent); 5985 scale = getScale(offsetParent); 5986 offsets.x = offsetRect.x + offsetParent.clientLeft; 5987 offsets.y = offsetRect.y + offsetParent.clientTop; 5988 } 5989 } 5990 const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0); 5991 return { 5992 width: rect.width * scale.x, 5993 height: rect.height * scale.y, 5994 x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x, 5995 y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y 5996 }; 5997 } 5998 function getClientRects(element) { 5999 return Array.from(element.getClientRects()); 6000 } 6001 function getDocumentRect(element) { 6002 const html = getDocumentElement(element); 6003 const scroll = getNodeScroll(element); 6004 const body = element.ownerDocument.body; 6005 const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth); 6006 const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight); 6007 let x2 = -scroll.scrollLeft + getWindowScrollBarX(element); 6008 const y2 = -scroll.scrollTop; 6009 if (getComputedStyle2(body).direction === "rtl") { 6010 x2 += max(html.clientWidth, body.clientWidth) - width; 6011 } 6012 return { 6013 width, 6014 height, 6015 x: x2, 6016 y: y2 6017 }; 6018 } 6019 var SCROLLBAR_MAX = 25; 6020 function getViewportRect(element, strategy) { 6021 const win = getWindow(element); 6022 const html = getDocumentElement(element); 6023 const visualViewport = win.visualViewport; 6024 let width = html.clientWidth; 6025 let height = html.clientHeight; 6026 let x2 = 0; 6027 let y2 = 0; 6028 if (visualViewport) { 6029 width = visualViewport.width; 6030 height = visualViewport.height; 6031 const visualViewportBased = isWebKit(); 6032 if (!visualViewportBased || visualViewportBased && strategy === "fixed") { 6033 x2 = visualViewport.offsetLeft; 6034 y2 = visualViewport.offsetTop; 6035 } 6036 } 6037 const windowScrollbarX = getWindowScrollBarX(html); 6038 if (windowScrollbarX <= 0) { 6039 const doc = html.ownerDocument; 6040 const body = doc.body; 6041 const bodyStyles = getComputedStyle(body); 6042 const bodyMarginInline = doc.compatMode === "CSS1Compat" ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0; 6043 const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline); 6044 if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) { 6045 width -= clippingStableScrollbarWidth; 6046 } 6047 } else if (windowScrollbarX <= SCROLLBAR_MAX) { 6048 width += windowScrollbarX; 6049 } 6050 return { 6051 width, 6052 height, 6053 x: x2, 6054 y: y2 6055 }; 6056 } 6057 function getInnerBoundingClientRect(element, strategy) { 6058 const clientRect = getBoundingClientRect(element, true, strategy === "fixed"); 6059 const top = clientRect.top + element.clientTop; 6060 const left = clientRect.left + element.clientLeft; 6061 const scale = isHTMLElement(element) ? getScale(element) : createCoords(1); 6062 const width = element.clientWidth * scale.x; 6063 const height = element.clientHeight * scale.y; 6064 const x2 = left * scale.x; 6065 const y2 = top * scale.y; 6066 return { 6067 width, 6068 height, 6069 x: x2, 6070 y: y2 6071 }; 6072 } 6073 function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) { 6074 let rect; 6075 if (clippingAncestor === "viewport") { 6076 rect = getViewportRect(element, strategy); 6077 } else if (clippingAncestor === "document") { 6078 rect = getDocumentRect(getDocumentElement(element)); 6079 } else if (isElement(clippingAncestor)) { 6080 rect = getInnerBoundingClientRect(clippingAncestor, strategy); 6081 } else { 6082 const visualOffsets = getVisualOffsets(element); 6083 rect = { 6084 x: clippingAncestor.x - visualOffsets.x, 6085 y: clippingAncestor.y - visualOffsets.y, 6086 width: clippingAncestor.width, 6087 height: clippingAncestor.height 6088 }; 6089 } 6090 return rectToClientRect(rect); 6091 } 6092 function hasFixedPositionAncestor(element, stopNode) { 6093 const parentNode = getParentNode(element); 6094 if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) { 6095 return false; 6096 } 6097 return getComputedStyle2(parentNode).position === "fixed" || hasFixedPositionAncestor(parentNode, stopNode); 6098 } 6099 function getClippingElementAncestors(element, cache) { 6100 const cachedResult = cache.get(element); 6101 if (cachedResult) { 6102 return cachedResult; 6103 } 6104 let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body"); 6105 let currentContainingBlockComputedStyle = null; 6106 const elementIsFixed = getComputedStyle2(element).position === "fixed"; 6107 let currentNode = elementIsFixed ? getParentNode(element) : element; 6108 while (isElement(currentNode) && !isLastTraversableNode(currentNode)) { 6109 const computedStyle = getComputedStyle2(currentNode); 6110 const currentNodeIsContaining = isContainingBlock(currentNode); 6111 if (!currentNodeIsContaining && computedStyle.position === "fixed") { 6112 currentContainingBlockComputedStyle = null; 6113 } 6114 const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && (currentContainingBlockComputedStyle.position === "absolute" || currentContainingBlockComputedStyle.position === "fixed") || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode); 6115 if (shouldDropCurrentNode) { 6116 result = result.filter((ancestor) => ancestor !== currentNode); 6117 } else { 6118 currentContainingBlockComputedStyle = computedStyle; 6119 } 6120 currentNode = getParentNode(currentNode); 6121 } 6122 cache.set(element, result); 6123 return result; 6124 } 6125 function getClippingRect(_ref) { 6126 let { 6127 element, 6128 boundary, 6129 rootBoundary, 6130 strategy 6131 } = _ref; 6132 const elementClippingAncestors = boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary); 6133 const clippingAncestors = [...elementClippingAncestors, rootBoundary]; 6134 const firstRect = getClientRectFromClippingAncestor(element, clippingAncestors[0], strategy); 6135 let top = firstRect.top; 6136 let right = firstRect.right; 6137 let bottom = firstRect.bottom; 6138 let left = firstRect.left; 6139 for (let i2 = 1; i2 < clippingAncestors.length; i2++) { 6140 const rect = getClientRectFromClippingAncestor(element, clippingAncestors[i2], strategy); 6141 top = max(rect.top, top); 6142 right = min(rect.right, right); 6143 bottom = min(rect.bottom, bottom); 6144 left = max(rect.left, left); 6145 } 6146 return { 6147 width: right - left, 6148 height: bottom - top, 6149 x: left, 6150 y: top 6151 }; 6152 } 6153 function getDimensions2(element) { 6154 const { 6155 width, 6156 height 6157 } = getCssDimensions(element); 6158 return { 6159 width, 6160 height 6161 }; 6162 } 6163 function getRectRelativeToOffsetParent(element, offsetParent, strategy) { 6164 const isOffsetParentAnElement = isHTMLElement(offsetParent); 6165 const documentElement = getDocumentElement(offsetParent); 6166 const isFixed = strategy === "fixed"; 6167 const rect = getBoundingClientRect(element, true, isFixed, offsetParent); 6168 let scroll = { 6169 scrollLeft: 0, 6170 scrollTop: 0 6171 }; 6172 const offsets = createCoords(0); 6173 function setLeftRTLScrollbarOffset() { 6174 offsets.x = getWindowScrollBarX(documentElement); 6175 } 6176 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) { 6177 if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) { 6178 scroll = getNodeScroll(offsetParent); 6179 } 6180 if (isOffsetParentAnElement) { 6181 const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent); 6182 offsets.x = offsetRect.x + offsetParent.clientLeft; 6183 offsets.y = offsetRect.y + offsetParent.clientTop; 6184 } else if (documentElement) { 6185 setLeftRTLScrollbarOffset(); 6186 } 6187 } 6188 if (isFixed && !isOffsetParentAnElement && documentElement) { 6189 setLeftRTLScrollbarOffset(); 6190 } 6191 const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0); 6192 const x2 = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x; 6193 const y2 = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y; 6194 return { 6195 x: x2, 6196 y: y2, 6197 width: rect.width, 6198 height: rect.height 6199 }; 6200 } 6201 function isStaticPositioned(element) { 6202 return getComputedStyle2(element).position === "static"; 6203 } 6204 function getTrueOffsetParent(element, polyfill) { 6205 if (!isHTMLElement(element) || getComputedStyle2(element).position === "fixed") { 6206 return null; 6207 } 6208 if (polyfill) { 6209 return polyfill(element); 6210 } 6211 let rawOffsetParent = element.offsetParent; 6212 if (getDocumentElement(element) === rawOffsetParent) { 6213 rawOffsetParent = rawOffsetParent.ownerDocument.body; 6214 } 6215 return rawOffsetParent; 6216 } 6217 function getOffsetParent(element, polyfill) { 6218 const win = getWindow(element); 6219 if (isTopLayer(element)) { 6220 return win; 6221 } 6222 if (!isHTMLElement(element)) { 6223 let svgOffsetParent = getParentNode(element); 6224 while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) { 6225 if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) { 6226 return svgOffsetParent; 6227 } 6228 svgOffsetParent = getParentNode(svgOffsetParent); 6229 } 6230 return win; 6231 } 6232 let offsetParent = getTrueOffsetParent(element, polyfill); 6233 while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) { 6234 offsetParent = getTrueOffsetParent(offsetParent, polyfill); 6235 } 6236 if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) { 6237 return win; 6238 } 6239 return offsetParent || getContainingBlock(element) || win; 6240 } 6241 var getElementRects = async function(data) { 6242 const getOffsetParentFn = this.getOffsetParent || getOffsetParent; 6243 const getDimensionsFn = this.getDimensions; 6244 const floatingDimensions = await getDimensionsFn(data.floating); 6245 return { 6246 reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy), 6247 floating: { 6248 x: 0, 6249 y: 0, 6250 width: floatingDimensions.width, 6251 height: floatingDimensions.height 6252 } 6253 }; 6254 }; 6255 function isRTL(element) { 6256 return getComputedStyle2(element).direction === "rtl"; 6257 } 6258 var platform2 = { 6259 convertOffsetParentRelativeRectToViewportRelativeRect, 6260 getDocumentElement, 6261 getClippingRect, 6262 getOffsetParent, 6263 getElementRects, 6264 getClientRects, 6265 getDimensions: getDimensions2, 6266 getScale, 6267 isElement, 6268 isRTL 6269 }; 6270 function rectsAreEqual(a2, b2) { 6271 return a2.x === b2.x && a2.y === b2.y && a2.width === b2.width && a2.height === b2.height; 6272 } 6273 function observeMove(element, onMove) { 6274 let io = null; 6275 let timeoutId; 6276 const root = getDocumentElement(element); 6277 function cleanup() { 6278 var _io; 6279 clearTimeout(timeoutId); 6280 (_io = io) == null || _io.disconnect(); 6281 io = null; 6282 } 6283 function refresh(skip, threshold) { 6284 if (skip === void 0) { 6285 skip = false; 6286 } 6287 if (threshold === void 0) { 6288 threshold = 1; 6289 } 6290 cleanup(); 6291 const elementRectForRootMargin = element.getBoundingClientRect(); 6292 const { 6293 left, 6294 top, 6295 width, 6296 height 6297 } = elementRectForRootMargin; 6298 if (!skip) { 6299 onMove(); 6300 } 6301 if (!width || !height) { 6302 return; 6303 } 6304 const insetTop = floor(top); 6305 const insetRight = floor(root.clientWidth - (left + width)); 6306 const insetBottom = floor(root.clientHeight - (top + height)); 6307 const insetLeft = floor(left); 6308 const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px"; 6309 const options = { 6310 rootMargin, 6311 threshold: max(0, min(1, threshold)) || 1 6312 }; 6313 let isFirstUpdate = true; 6314 function handleObserve(entries) { 6315 const ratio = entries[0].intersectionRatio; 6316 if (ratio !== threshold) { 6317 if (!isFirstUpdate) { 6318 return refresh(); 6319 } 6320 if (!ratio) { 6321 timeoutId = setTimeout(() => { 6322 refresh(false, 1e-7); 6323 }, 1e3); 6324 } else { 6325 refresh(false, ratio); 6326 } 6327 } 6328 if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) { 6329 refresh(); 6330 } 6331 isFirstUpdate = false; 6332 } 6333 try { 6334 io = new IntersectionObserver(handleObserve, { 6335 ...options, 6336 // Handle <iframe>s 6337 root: root.ownerDocument 6338 }); 6339 } catch (_e) { 6340 io = new IntersectionObserver(handleObserve, options); 6341 } 6342 io.observe(element); 6343 } 6344 refresh(true); 6345 return cleanup; 6346 } 6347 function autoUpdate(reference, floating, update4, options) { 6348 if (options === void 0) { 6349 options = {}; 6350 } 6351 const { 6352 ancestorScroll = true, 6353 ancestorResize = true, 6354 elementResize = typeof ResizeObserver === "function", 6355 layoutShift = typeof IntersectionObserver === "function", 6356 animationFrame = false 6357 } = options; 6358 const referenceEl = unwrapElement(reference); 6359 const ancestors = ancestorScroll || ancestorResize ? [...referenceEl ? getOverflowAncestors(referenceEl) : [], ...floating ? getOverflowAncestors(floating) : []] : []; 6360 ancestors.forEach((ancestor) => { 6361 ancestorScroll && ancestor.addEventListener("scroll", update4, { 6362 passive: true 6363 }); 6364 ancestorResize && ancestor.addEventListener("resize", update4); 6365 }); 6366 const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update4) : null; 6367 let reobserveFrame = -1; 6368 let resizeObserver = null; 6369 if (elementResize) { 6370 resizeObserver = new ResizeObserver((_ref) => { 6371 let [firstEntry] = _ref; 6372 if (firstEntry && firstEntry.target === referenceEl && resizeObserver && floating) { 6373 resizeObserver.unobserve(floating); 6374 cancelAnimationFrame(reobserveFrame); 6375 reobserveFrame = requestAnimationFrame(() => { 6376 var _resizeObserver; 6377 (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating); 6378 }); 6379 } 6380 update4(); 6381 }); 6382 if (referenceEl && !animationFrame) { 6383 resizeObserver.observe(referenceEl); 6384 } 6385 if (floating) { 6386 resizeObserver.observe(floating); 6387 } 6388 } 6389 let frameId; 6390 let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null; 6391 if (animationFrame) { 6392 frameLoop2(); 6393 } 6394 function frameLoop2() { 6395 const nextRefRect = getBoundingClientRect(reference); 6396 if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) { 6397 update4(); 6398 } 6399 prevRefRect = nextRefRect; 6400 frameId = requestAnimationFrame(frameLoop2); 6401 } 6402 update4(); 6403 return () => { 6404 var _resizeObserver2; 6405 ancestors.forEach((ancestor) => { 6406 ancestorScroll && ancestor.removeEventListener("scroll", update4); 6407 ancestorResize && ancestor.removeEventListener("resize", update4); 6408 }); 6409 cleanupIo == null || cleanupIo(); 6410 (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect(); 6411 resizeObserver = null; 6412 if (animationFrame) { 6413 cancelAnimationFrame(frameId); 6414 } 6415 }; 6416 } 6417 var offset2 = offset; 6418 var shift2 = shift; 6419 var flip2 = flip; 6420 var size2 = size; 6421 var hide2 = hide; 6422 var limitShift2 = limitShift; 6423 var computePosition2 = (reference, floating, options) => { 6424 const cache = /* @__PURE__ */ new Map(); 6425 const mergedOptions = { 6426 platform: platform2, 6427 ...options 6428 }; 6429 const platformWithCache = { 6430 ...mergedOptions.platform, 6431 _c: cache 6432 }; 6433 return computePosition(reference, floating, { 6434 ...mergedOptions, 6435 platform: platformWithCache 6436 }); 6437 }; 6438 6439 // node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.mjs 6440 var React26 = __toESM(require_react(), 1); 6441 var import_react2 = __toESM(require_react(), 1); 6442 var ReactDOM3 = __toESM(require_react_dom(), 1); 6443 var isClient = typeof document !== "undefined"; 6444 var noop2 = function noop3() { 6445 }; 6446 var index = isClient ? import_react2.useLayoutEffect : noop2; 6447 function deepEqual(a2, b2) { 6448 if (a2 === b2) { 6449 return true; 6450 } 6451 if (typeof a2 !== typeof b2) { 6452 return false; 6453 } 6454 if (typeof a2 === "function" && a2.toString() === b2.toString()) { 6455 return true; 6456 } 6457 let length; 6458 let i2; 6459 let keys; 6460 if (a2 && b2 && typeof a2 === "object") { 6461 if (Array.isArray(a2)) { 6462 length = a2.length; 6463 if (length !== b2.length) return false; 6464 for (i2 = length; i2-- !== 0; ) { 6465 if (!deepEqual(a2[i2], b2[i2])) { 6466 return false; 6467 } 6468 } 6469 return true; 6470 } 6471 keys = Object.keys(a2); 6472 length = keys.length; 6473 if (length !== Object.keys(b2).length) { 6474 return false; 6475 } 6476 for (i2 = length; i2-- !== 0; ) { 6477 if (!{}.hasOwnProperty.call(b2, keys[i2])) { 6478 return false; 6479 } 6480 } 6481 for (i2 = length; i2-- !== 0; ) { 6482 const key = keys[i2]; 6483 if (key === "_owner" && a2.$$typeof) { 6484 continue; 6485 } 6486 if (!deepEqual(a2[key], b2[key])) { 6487 return false; 6488 } 6489 } 6490 return true; 6491 } 6492 return a2 !== a2 && b2 !== b2; 6493 } 6494 function getDPR(element) { 6495 if (typeof window === "undefined") { 6496 return 1; 6497 } 6498 const win = element.ownerDocument.defaultView || window; 6499 return win.devicePixelRatio || 1; 6500 } 6501 function roundByDPR(element, value) { 6502 const dpr = getDPR(element); 6503 return Math.round(value * dpr) / dpr; 6504 } 6505 function useLatestRef(value) { 6506 const ref = React26.useRef(value); 6507 index(() => { 6508 ref.current = value; 6509 }); 6510 return ref; 6511 } 6512 function useFloating(options) { 6513 if (options === void 0) { 6514 options = {}; 6515 } 6516 const { 6517 placement = "bottom", 6518 strategy = "absolute", 6519 middleware = [], 6520 platform: platform3, 6521 elements: { 6522 reference: externalReference, 6523 floating: externalFloating 6524 } = {}, 6525 transform = true, 6526 whileElementsMounted, 6527 open 6528 } = options; 6529 const [data, setData] = React26.useState({ 6530 x: 0, 6531 y: 0, 6532 strategy, 6533 placement, 6534 middlewareData: {}, 6535 isPositioned: false 6536 }); 6537 const [latestMiddleware, setLatestMiddleware] = React26.useState(middleware); 6538 if (!deepEqual(latestMiddleware, middleware)) { 6539 setLatestMiddleware(middleware); 6540 } 6541 const [_reference, _setReference] = React26.useState(null); 6542 const [_floating, _setFloating] = React26.useState(null); 6543 const setReference = React26.useCallback((node) => { 6544 if (node !== referenceRef.current) { 6545 referenceRef.current = node; 6546 _setReference(node); 6547 } 6548 }, []); 6549 const setFloating = React26.useCallback((node) => { 6550 if (node !== floatingRef.current) { 6551 floatingRef.current = node; 6552 _setFloating(node); 6553 } 6554 }, []); 6555 const referenceEl = externalReference || _reference; 6556 const floatingEl = externalFloating || _floating; 6557 const referenceRef = React26.useRef(null); 6558 const floatingRef = React26.useRef(null); 6559 const dataRef = React26.useRef(data); 6560 const hasWhileElementsMounted = whileElementsMounted != null; 6561 const whileElementsMountedRef = useLatestRef(whileElementsMounted); 6562 const platformRef = useLatestRef(platform3); 6563 const openRef = useLatestRef(open); 6564 const update4 = React26.useCallback(() => { 6565 if (!referenceRef.current || !floatingRef.current) { 6566 return; 6567 } 6568 const config2 = { 6569 placement, 6570 strategy, 6571 middleware: latestMiddleware 6572 }; 6573 if (platformRef.current) { 6574 config2.platform = platformRef.current; 6575 } 6576 computePosition2(referenceRef.current, floatingRef.current, config2).then((data2) => { 6577 const fullData = { 6578 ...data2, 6579 // The floating element's position may be recomputed while it's closed 6580 // but still mounted (such as when transitioning out). To ensure 6581 // `isPositioned` will be `false` initially on the next open, avoid 6582 // setting it to `true` when `open === false` (must be specified). 6583 isPositioned: openRef.current !== false 6584 }; 6585 if (isMountedRef.current && !deepEqual(dataRef.current, fullData)) { 6586 dataRef.current = fullData; 6587 ReactDOM3.flushSync(() => { 6588 setData(fullData); 6589 }); 6590 } 6591 }); 6592 }, [latestMiddleware, placement, strategy, platformRef, openRef]); 6593 index(() => { 6594 if (open === false && dataRef.current.isPositioned) { 6595 dataRef.current.isPositioned = false; 6596 setData((data2) => ({ 6597 ...data2, 6598 isPositioned: false 6599 })); 6600 } 6601 }, [open]); 6602 const isMountedRef = React26.useRef(false); 6603 index(() => { 6604 isMountedRef.current = true; 6605 return () => { 6606 isMountedRef.current = false; 6607 }; 6608 }, []); 6609 index(() => { 6610 if (referenceEl) referenceRef.current = referenceEl; 6611 if (floatingEl) floatingRef.current = floatingEl; 6612 if (referenceEl && floatingEl) { 6613 if (whileElementsMountedRef.current) { 6614 return whileElementsMountedRef.current(referenceEl, floatingEl, update4); 6615 } 6616 update4(); 6617 } 6618 }, [referenceEl, floatingEl, update4, whileElementsMountedRef, hasWhileElementsMounted]); 6619 const refs = React26.useMemo(() => ({ 6620 reference: referenceRef, 6621 floating: floatingRef, 6622 setReference, 6623 setFloating 6624 }), [setReference, setFloating]); 6625 const elements2 = React26.useMemo(() => ({ 6626 reference: referenceEl, 6627 floating: floatingEl 6628 }), [referenceEl, floatingEl]); 6629 const floatingStyles = React26.useMemo(() => { 6630 const initialStyles = { 6631 position: strategy, 6632 left: 0, 6633 top: 0 6634 }; 6635 if (!elements2.floating) { 6636 return initialStyles; 6637 } 6638 const x2 = roundByDPR(elements2.floating, data.x); 6639 const y2 = roundByDPR(elements2.floating, data.y); 6640 if (transform) { 6641 return { 6642 ...initialStyles, 6643 transform: "translate(" + x2 + "px, " + y2 + "px)", 6644 ...getDPR(elements2.floating) >= 1.5 && { 6645 willChange: "transform" 6646 } 6647 }; 6648 } 6649 return { 6650 position: strategy, 6651 left: x2, 6652 top: y2 6653 }; 6654 }, [strategy, transform, elements2.floating, data.x, data.y]); 6655 return React26.useMemo(() => ({ 6656 ...data, 6657 update: update4, 6658 refs, 6659 elements: elements2, 6660 floatingStyles 6661 }), [data, update4, refs, elements2, floatingStyles]); 6662 } 6663 var offset3 = (options, deps) => { 6664 const result = offset2(options); 6665 return { 6666 name: result.name, 6667 fn: result.fn, 6668 options: [options, deps] 6669 }; 6670 }; 6671 var shift3 = (options, deps) => { 6672 const result = shift2(options); 6673 return { 6674 name: result.name, 6675 fn: result.fn, 6676 options: [options, deps] 6677 }; 6678 }; 6679 var limitShift3 = (options, deps) => { 6680 const result = limitShift2(options); 6681 return { 6682 fn: result.fn, 6683 options: [options, deps] 6684 }; 6685 }; 6686 var flip3 = (options, deps) => { 6687 const result = flip2(options); 6688 return { 6689 name: result.name, 6690 fn: result.fn, 6691 options: [options, deps] 6692 }; 6693 }; 6694 var size3 = (options, deps) => { 6695 const result = size2(options); 6696 return { 6697 name: result.name, 6698 fn: result.fn, 6699 options: [options, deps] 6700 }; 6701 }; 6702 var hide3 = (options, deps) => { 6703 const result = hide2(options); 6704 return { 6705 name: result.name, 6706 fn: result.fn, 6707 options: [options, deps] 6708 }; 6709 }; 6710 6711 // node_modules/@base-ui/react/utils/popups/popupStoreUtils.mjs 6712 var React31 = __toESM(require_react(), 1); 6713 var ReactDOM4 = __toESM(require_react_dom(), 1); 6714 6715 // node_modules/@base-ui/react/floating-ui-react/hooks/useSyncedFloatingRootContext.mjs 6716 var React30 = __toESM(require_react(), 1); 6717 6718 // node_modules/@base-ui/utils/store/createSelector.mjs 6719 var createSelector2 = (a2, b2, c6, d2, e2, f2, ...other) => { 6720 if (other.length > 0) { 6721 throw new Error(true ? "Unsupported number of selectors" : formatErrorMessage_default(1)); 6722 } 6723 let selector2; 6724 if (a2 && b2 && c6 && d2 && e2 && f2) { 6725 selector2 = (state, a1, a22, a3) => { 6726 const va = a2(state, a1, a22, a3); 6727 const vb = b2(state, a1, a22, a3); 6728 const vc = c6(state, a1, a22, a3); 6729 const vd = d2(state, a1, a22, a3); 6730 const ve = e2(state, a1, a22, a3); 6731 return f2(va, vb, vc, vd, ve, a1, a22, a3); 6732 }; 6733 } else if (a2 && b2 && c6 && d2 && e2) { 6734 selector2 = (state, a1, a22, a3) => { 6735 const va = a2(state, a1, a22, a3); 6736 const vb = b2(state, a1, a22, a3); 6737 const vc = c6(state, a1, a22, a3); 6738 const vd = d2(state, a1, a22, a3); 6739 return e2(va, vb, vc, vd, a1, a22, a3); 6740 }; 6741 } else if (a2 && b2 && c6 && d2) { 6742 selector2 = (state, a1, a22, a3) => { 6743 const va = a2(state, a1, a22, a3); 6744 const vb = b2(state, a1, a22, a3); 6745 const vc = c6(state, a1, a22, a3); 6746 return d2(va, vb, vc, a1, a22, a3); 6747 }; 6748 } else if (a2 && b2 && c6) { 6749 selector2 = (state, a1, a22, a3) => { 6750 const va = a2(state, a1, a22, a3); 6751 const vb = b2(state, a1, a22, a3); 6752 return c6(va, vb, a1, a22, a3); 6753 }; 6754 } else if (a2 && b2) { 6755 selector2 = (state, a1, a22, a3) => { 6756 const va = a2(state, a1, a22, a3); 6757 return b2(va, a1, a22, a3); 6758 }; 6759 } else if (a2) { 6760 selector2 = a2; 6761 } else { 6762 throw ( 6763 /* minify-error-disabled */ 6764 new Error("Missing arguments") 6765 ); 6766 } 6767 return selector2; 6768 }; 6769 6770 // node_modules/@base-ui/utils/store/useStore.mjs 6771 var React28 = __toESM(require_react(), 1); 6772 var import_shim = __toESM(require_shim(), 1); 6773 var import_with_selector = __toESM(require_with_selector(), 1); 6774 6775 // node_modules/@base-ui/utils/fastHooks.mjs 6776 var React27 = __toESM(require_react(), 1); 6777 var hooks = []; 6778 var currentInstance = void 0; 6779 function getInstance() { 6780 return currentInstance; 6781 } 6782 function register2(hook) { 6783 hooks.push(hook); 6784 } 6785 function fastComponent(fn) { 6786 const FastComponent = (props, forwardedRef) => { 6787 const instance = useRefWithInit(createInstance).current; 6788 let result; 6789 try { 6790 currentInstance = instance; 6791 for (const hook of hooks) { 6792 hook.before(instance); 6793 } 6794 result = fn(props, forwardedRef); 6795 for (const hook of hooks) { 6796 hook.after(instance); 6797 } 6798 instance.didInitialize = true; 6799 } finally { 6800 currentInstance = void 0; 6801 } 6802 return result; 6803 }; 6804 FastComponent.displayName = fn.displayName || fn.name; 6805 return FastComponent; 6806 } 6807 function fastComponentRef(fn) { 6808 return /* @__PURE__ */ React27.forwardRef(fastComponent(fn)); 6809 } 6810 function createInstance() { 6811 return { 6812 didInitialize: false 6813 }; 6814 } 6815 6816 // node_modules/@base-ui/utils/store/useStore.mjs 6817 var canUseRawUseSyncExternalStore = isReactVersionAtLeast(19); 6818 var useStoreImplementation = canUseRawUseSyncExternalStore ? useStoreFast : useStoreLegacy; 6819 function useStore(store2, selector2, a1, a2, a3) { 6820 return useStoreImplementation(store2, selector2, a1, a2, a3); 6821 } 6822 function useStoreR19(store2, selector2, a1, a2, a3) { 6823 const getSelection = React28.useCallback(() => selector2(store2.getSnapshot(), a1, a2, a3), [store2, selector2, a1, a2, a3]); 6824 return (0, import_shim.useSyncExternalStore)(store2.subscribe, getSelection, getSelection); 6825 } 6826 register2({ 6827 before(instance) { 6828 instance.syncIndex = 0; 6829 if (!instance.didInitialize) { 6830 instance.syncTick = 1; 6831 instance.syncHooks = []; 6832 instance.didChangeStore = true; 6833 instance.getSnapshot = () => { 6834 let didChange2 = false; 6835 for (let i2 = 0; i2 < instance.syncHooks.length; i2 += 1) { 6836 const hook = instance.syncHooks[i2]; 6837 const value = hook.selector(hook.store.state, hook.a1, hook.a2, hook.a3); 6838 if (!Object.is(hook.value, value)) { 6839 didChange2 = true; 6840 hook.value = value; 6841 } 6842 } 6843 if (didChange2) { 6844 instance.syncTick += 1; 6845 } 6846 return instance.syncTick; 6847 }; 6848 } 6849 }, 6850 after(instance) { 6851 if (instance.syncHooks.length > 0) { 6852 if (instance.didChangeStore) { 6853 instance.didChangeStore = false; 6854 instance.subscribe = (onStoreChange) => { 6855 const stores = /* @__PURE__ */ new Set(); 6856 for (const hook of instance.syncHooks) { 6857 stores.add(hook.store); 6858 } 6859 const unsubscribes = []; 6860 for (const store2 of stores) { 6861 unsubscribes.push(store2.subscribe(onStoreChange)); 6862 } 6863 return () => { 6864 for (const unsubscribe of unsubscribes) { 6865 unsubscribe(); 6866 } 6867 }; 6868 }; 6869 } 6870 (0, import_shim.useSyncExternalStore)(instance.subscribe, instance.getSnapshot, instance.getSnapshot); 6871 } 6872 } 6873 }); 6874 function useStoreFast(store2, selector2, a1, a2, a3) { 6875 const instance = getInstance(); 6876 if (!instance) { 6877 return useStoreR19(store2, selector2, a1, a2, a3); 6878 } 6879 const index2 = instance.syncIndex; 6880 instance.syncIndex += 1; 6881 let hook; 6882 if (!instance.didInitialize) { 6883 hook = { 6884 store: store2, 6885 selector: selector2, 6886 a1, 6887 a2, 6888 a3, 6889 value: selector2(store2.getSnapshot(), a1, a2, a3) 6890 }; 6891 instance.syncHooks.push(hook); 6892 } else { 6893 hook = instance.syncHooks[index2]; 6894 if (hook.store !== store2 || hook.selector !== selector2 || !Object.is(hook.a1, a1) || !Object.is(hook.a2, a2) || !Object.is(hook.a3, a3)) { 6895 if (hook.store !== store2) { 6896 instance.didChangeStore = true; 6897 } 6898 hook.store = store2; 6899 hook.selector = selector2; 6900 hook.a1 = a1; 6901 hook.a2 = a2; 6902 hook.a3 = a3; 6903 hook.value = selector2(store2.getSnapshot(), a1, a2, a3); 6904 } 6905 } 6906 return hook.value; 6907 } 6908 function useStoreLegacy(store2, selector2, a1, a2, a3) { 6909 return (0, import_with_selector.useSyncExternalStoreWithSelector)(store2.subscribe, store2.getSnapshot, store2.getSnapshot, (state) => selector2(state, a1, a2, a3)); 6910 } 6911 6912 // node_modules/@base-ui/utils/store/Store.mjs 6913 var Store = class { 6914 /** 6915 * The current state of the store. 6916 * This property is updated immediately when the state changes as a result of calling {@link setState}, {@link update}, or {@link set}. 6917 * To subscribe to state changes, use the {@link useState} method. The value returned by {@link useState} is updated after the component renders (similarly to React's useState). 6918 * The values can be used directly (to avoid subscribing to the store) in effects or event handlers. 6919 * 6920 * Do not modify properties in state directly. Instead, use the provided methods to ensure proper state management and listener notification. 6921 */ 6922 // Internal state to handle recursive `setState()` calls 6923 constructor(state) { 6924 this.state = state; 6925 this.listeners = /* @__PURE__ */ new Set(); 6926 this.updateTick = 0; 6927 } 6928 /** 6929 * Registers a listener that will be called whenever the store's state changes. 6930 * 6931 * @param fn The listener function to be called on state changes. 6932 * @returns A function to unsubscribe the listener. 6933 */ 6934 subscribe = (fn) => { 6935 this.listeners.add(fn); 6936 return () => { 6937 this.listeners.delete(fn); 6938 }; 6939 }; 6940 /** 6941 * Returns the current state of the store. 6942 */ 6943 getSnapshot = () => { 6944 return this.state; 6945 }; 6946 /** 6947 * Updates the entire store's state and notifies all registered listeners. 6948 * 6949 * @param newState The new state to set for the store. 6950 */ 6951 setState(newState) { 6952 if (this.state === newState) { 6953 return; 6954 } 6955 this.state = newState; 6956 this.updateTick += 1; 6957 const currentTick = this.updateTick; 6958 for (const listener of this.listeners) { 6959 if (currentTick !== this.updateTick) { 6960 return; 6961 } 6962 listener(newState); 6963 } 6964 } 6965 /** 6966 * Merges the provided changes into the current state and notifies listeners if there are changes. 6967 * 6968 * @param changes An object containing the changes to apply to the current state. 6969 */ 6970 update(changes) { 6971 for (const key in changes) { 6972 if (!Object.is(this.state[key], changes[key])) { 6973 this.setState({ 6974 ...this.state, 6975 ...changes 6976 }); 6977 return; 6978 } 6979 } 6980 } 6981 /** 6982 * Sets a specific key in the store's state to a new value and notifies listeners if the value has changed. 6983 * 6984 * @param key The key in the store's state to update. 6985 * @param value The new value to set for the specified key. 6986 */ 6987 set(key, value) { 6988 if (!Object.is(this.state[key], value)) { 6989 this.setState({ 6990 ...this.state, 6991 [key]: value 6992 }); 6993 } 6994 } 6995 /** 6996 * Gives the state a new reference and updates all registered listeners. 6997 */ 6998 notifyAll() { 6999 const newState = { 7000 ...this.state 7001 }; 7002 this.setState(newState); 7003 } 7004 use(selector2, a1, a2, a3) { 7005 return useStore(this, selector2, a1, a2, a3); 7006 } 7007 }; 7008 7009 // node_modules/@base-ui/utils/store/ReactStore.mjs 7010 var React29 = __toESM(require_react(), 1); 7011 var ReactStore = class extends Store { 7012 /** 7013 * Creates a new ReactStore instance. 7014 * 7015 * @param state Initial state of the store. 7016 * @param context Non-reactive context values. 7017 * @param selectors Optional selectors for use with `useState`. 7018 */ 7019 constructor(state, context = {}, selectors3) { 7020 super(state); 7021 this.context = context; 7022 this.selectors = selectors3; 7023 } 7024 /** 7025 * Non-reactive values such as refs, callbacks, etc. 7026 */ 7027 /** 7028 * Synchronizes a single external value into the store. 7029 * 7030 * Note that the while the value in `state` is updated immediately, the value returned 7031 * by `useState` is updated before the next render (similarly to React's `useState`). 7032 */ 7033 useSyncedValue(key, value) { 7034 React29.useDebugValue(key); 7035 const store2 = this; 7036 useIsoLayoutEffect(() => { 7037 if (store2.state[key] !== value) { 7038 store2.set(key, value); 7039 } 7040 }, [store2, key, value]); 7041 } 7042 /** 7043 * Synchronizes a single external value into the store and 7044 * cleans it up (sets to `undefined`) on unmount. 7045 * 7046 * Note that the while the value in `state` is updated immediately, the value returned 7047 * by `useState` is updated before the next render (similarly to React's `useState`). 7048 */ 7049 useSyncedValueWithCleanup(key, value) { 7050 const store2 = this; 7051 useIsoLayoutEffect(() => { 7052 if (store2.state[key] !== value) { 7053 store2.set(key, value); 7054 } 7055 return () => { 7056 store2.set(key, void 0); 7057 }; 7058 }, [store2, key, value]); 7059 } 7060 /** 7061 * Synchronizes multiple external values into the store. 7062 * 7063 * Note that the while the values in `state` are updated immediately, the values returned 7064 * by `useState` are updated before the next render (similarly to React's `useState`). 7065 */ 7066 useSyncedValues(statePart) { 7067 const store2 = this; 7068 if (true) { 7069 React29.useDebugValue(statePart, (p3) => Object.keys(p3)); 7070 const keys = React29.useRef(Object.keys(statePart)).current; 7071 const nextKeys = Object.keys(statePart); 7072 if (keys.length !== nextKeys.length || keys.some((key, index2) => key !== nextKeys[index2])) { 7073 console.error("ReactStore.useSyncedValues expects the same prop keys on every render. Keys should be stable."); 7074 } 7075 } 7076 const dependencies = Object.values(statePart); 7077 useIsoLayoutEffect(() => { 7078 store2.update(statePart); 7079 }, [store2, ...dependencies]); 7080 } 7081 /** 7082 * Registers a controllable prop pair (`controlled`, `defaultValue`) for a specific key. If `controlled` 7083 * is non-undefined, the store's state at `key` is updated to match `controlled`. 7084 */ 7085 useControlledProp(key, controlled) { 7086 React29.useDebugValue(key); 7087 const store2 = this; 7088 const isControlled = controlled !== void 0; 7089 useIsoLayoutEffect(() => { 7090 if (isControlled && !Object.is(store2.state[key], controlled)) { 7091 store2.setState({ 7092 ...store2.state, 7093 [key]: controlled 7094 }); 7095 } 7096 }, [store2, key, controlled, isControlled]); 7097 if (true) { 7098 const cache = this.controlledValues ??= /* @__PURE__ */ new Map(); 7099 if (!cache.has(key)) { 7100 cache.set(key, isControlled); 7101 } 7102 const previouslyControlled = cache.get(key); 7103 if (previouslyControlled !== void 0 && previouslyControlled !== isControlled) { 7104 console.error(`A component is changing the $isControlled ? "" : "un"}controlled state of $key.toString()} to be $isControlled ? "un" : ""}controlled. Elements should not switch from uncontrolled to controlled (or vice versa).`); 7105 } 7106 } 7107 } 7108 /** Gets the current value from the store using a selector with the provided key. 7109 * 7110 * @param key Key of the selector to use. 7111 */ 7112 select(key, a1, a2, a3) { 7113 const selector2 = this.selectors[key]; 7114 return selector2(this.state, a1, a2, a3); 7115 } 7116 /** 7117 * Returns a value from the store's state using a selector function. 7118 * Used to subscribe to specific parts of the state. 7119 * This methods causes a rerender whenever the selected state changes. 7120 * 7121 * @param key Key of the selector to use. 7122 */ 7123 useState(key, a1, a2, a3) { 7124 React29.useDebugValue(key); 7125 return useStore(this, this.selectors[key], a1, a2, a3); 7126 } 7127 /** 7128 * Wraps a function with `useStableCallback` to ensure it has a stable reference 7129 * and assigns it to the context. 7130 * 7131 * @param key Key of the event callback. Must be a function in the context. 7132 * @param fn Function to assign. 7133 */ 7134 useContextCallback(key, fn) { 7135 React29.useDebugValue(key); 7136 const stableFunction = useStableCallback(fn ?? NOOP); 7137 this.context[key] = stableFunction; 7138 } 7139 /** 7140 * Returns a stable setter function for a specific key in the store's state. 7141 * It's commonly used to pass as a ref callback to React elements. 7142 * 7143 * @param key Key of the state to set. 7144 */ 7145 useStateSetter(key) { 7146 const ref = React29.useRef(void 0); 7147 if (ref.current === void 0) { 7148 ref.current = (value) => { 7149 this.set(key, value); 7150 }; 7151 } 7152 return ref.current; 7153 } 7154 /** 7155 * Observes changes derived from the store's selectors and calls the listener when the selected value changes. 7156 * 7157 * @param key Key of the selector to observe. 7158 * @param listener Listener function called when the selector result changes. 7159 */ 7160 observe(selector2, listener) { 7161 let selectFn; 7162 if (typeof selector2 === "function") { 7163 selectFn = selector2; 7164 } else { 7165 selectFn = this.selectors[selector2]; 7166 } 7167 let prevValue = selectFn(this.state); 7168 listener(prevValue, prevValue, this); 7169 return this.subscribe((nextState) => { 7170 const nextValue = selectFn(nextState); 7171 if (!Object.is(prevValue, nextValue)) { 7172 const oldValue = prevValue; 7173 prevValue = nextValue; 7174 listener(nextValue, oldValue, this); 7175 } 7176 }); 7177 } 7178 }; 7179 7180 // node_modules/@base-ui/react/floating-ui-react/components/FloatingRootStore.mjs 7181 var selectors = { 7182 open: createSelector2((state) => state.open), 7183 transitionStatus: createSelector2((state) => state.transitionStatus), 7184 domReferenceElement: createSelector2((state) => state.domReferenceElement), 7185 referenceElement: createSelector2((state) => state.positionReference ?? state.referenceElement), 7186 floatingElement: createSelector2((state) => state.floatingElement), 7187 floatingId: createSelector2((state) => state.floatingId) 7188 }; 7189 var FloatingRootStore = class extends ReactStore { 7190 constructor(options) { 7191 const { 7192 syncOnly, 7193 nested, 7194 onOpenChange, 7195 triggerElements, 7196 ...initialState 7197 } = options; 7198 super({ 7199 ...initialState, 7200 positionReference: initialState.referenceElement, 7201 domReferenceElement: initialState.referenceElement 7202 }, { 7203 onOpenChange, 7204 dataRef: { 7205 current: {} 7206 }, 7207 events: createEventEmitter(), 7208 nested, 7209 triggerElements 7210 }, selectors); 7211 this.syncOnly = syncOnly; 7212 } 7213 /** 7214 * Syncs the event used by hover logic to distinguish hover-open from click-like interaction. 7215 */ 7216 syncOpenEvent = (newOpen, event) => { 7217 if (!newOpen || !this.state.open || // Prevent a pending hover-open from overwriting a click-open event, while allowing 7218 // click events to upgrade a hover-open. 7219 event != null && isClickLikeEvent(event)) { 7220 this.context.dataRef.current.openEvent = newOpen ? event : void 0; 7221 } 7222 }; 7223 /** 7224 * Runs the root-owned side effects for an open state change. 7225 */ 7226 dispatchOpenChange = (newOpen, eventDetails) => { 7227 this.syncOpenEvent(newOpen, eventDetails.event); 7228 const details = { 7229 open: newOpen, 7230 reason: eventDetails.reason, 7231 nativeEvent: eventDetails.event, 7232 nested: this.context.nested, 7233 triggerElement: eventDetails.trigger 7234 }; 7235 this.context.events.emit("openchange", details); 7236 }; 7237 /** 7238 * Emits the `openchange` event through the internal event emitter and calls the `onOpenChange` handler with the provided arguments. 7239 * 7240 * @param newOpen The new open state. 7241 * @param eventDetails Details about the event that triggered the open state change. 7242 */ 7243 setOpen = (newOpen, eventDetails) => { 7244 if (this.syncOnly) { 7245 this.context.onOpenChange?.(newOpen, eventDetails); 7246 return; 7247 } 7248 this.dispatchOpenChange(newOpen, eventDetails); 7249 this.context.onOpenChange?.(newOpen, eventDetails); 7250 }; 7251 }; 7252 7253 // node_modules/@base-ui/react/floating-ui-react/hooks/useSyncedFloatingRootContext.mjs 7254 function useSyncedFloatingRootContext(options) { 7255 const { 7256 popupStore, 7257 treatPopupAsFloatingElement = false, 7258 floatingRootContext: floatingRootContextProp, 7259 floatingId, 7260 nested, 7261 onOpenChange 7262 } = options; 7263 const open = popupStore.useState("open"); 7264 const referenceElement = popupStore.useState("activeTriggerElement"); 7265 const floatingElement = popupStore.useState(treatPopupAsFloatingElement ? "popupElement" : "positionerElement"); 7266 const triggerElements = popupStore.context.triggerElements; 7267 const handleOpenChange = onOpenChange; 7268 const internalStoreRef = React30.useRef(null); 7269 if (floatingRootContextProp === void 0 && internalStoreRef.current === null) { 7270 internalStoreRef.current = new FloatingRootStore({ 7271 open, 7272 transitionStatus: void 0, 7273 referenceElement, 7274 floatingElement, 7275 triggerElements, 7276 onOpenChange: handleOpenChange, 7277 floatingId, 7278 syncOnly: true, 7279 nested 7280 }); 7281 } 7282 const store2 = floatingRootContextProp ?? internalStoreRef.current; 7283 popupStore.useSyncedValue("floatingId", floatingId); 7284 useIsoLayoutEffect(() => { 7285 const valuesToSync = { 7286 open, 7287 floatingId, 7288 referenceElement, 7289 floatingElement 7290 }; 7291 if (isElement(referenceElement)) { 7292 valuesToSync.domReferenceElement = referenceElement; 7293 } 7294 if (store2.state.positionReference === store2.state.referenceElement) { 7295 valuesToSync.positionReference = referenceElement; 7296 } 7297 store2.update(valuesToSync); 7298 }, [open, floatingId, referenceElement, floatingElement, store2]); 7299 store2.context.onOpenChange = handleOpenChange; 7300 store2.context.nested = nested; 7301 return store2; 7302 } 7303 7304 // node_modules/@base-ui/react/utils/popups/popupStoreUtils.mjs 7305 var FOCUSABLE_POPUP_PROPS = { 7306 tabIndex: -1, 7307 [FOCUSABLE_ATTRIBUTE]: "" 7308 }; 7309 function usePopupStore(externalStore, createStore2, treatPopupAsFloatingElement = false) { 7310 const floatingId = useId(); 7311 const nested = useFloatingParentNodeId() != null; 7312 const internalStoreRef = React31.useRef(null); 7313 if (externalStore === void 0 && internalStoreRef.current === null) { 7314 internalStoreRef.current = createStore2(floatingId, nested); 7315 } 7316 const store2 = externalStore ?? internalStoreRef.current; 7317 useSyncedFloatingRootContext({ 7318 popupStore: store2, 7319 treatPopupAsFloatingElement, 7320 floatingRootContext: store2.state.floatingRootContext, 7321 floatingId, 7322 nested, 7323 onOpenChange: store2.setOpen 7324 }); 7325 return { 7326 store: store2, 7327 internalStore: internalStoreRef.current 7328 }; 7329 } 7330 function useTriggerRegistration(id, store2) { 7331 const registeredElementIdRef = React31.useRef(null); 7332 const registeredElementRef = React31.useRef(null); 7333 return React31.useCallback((element) => { 7334 if (id === void 0) { 7335 return; 7336 } 7337 let shouldSyncTriggerCount = false; 7338 if (registeredElementIdRef.current !== null) { 7339 const registeredId = registeredElementIdRef.current; 7340 const registeredElement = registeredElementRef.current; 7341 const currentElement = store2.context.triggerElements.getById(registeredId); 7342 if (registeredElement && currentElement === registeredElement) { 7343 store2.context.triggerElements.delete(registeredId); 7344 shouldSyncTriggerCount = true; 7345 } 7346 registeredElementIdRef.current = null; 7347 registeredElementRef.current = null; 7348 } 7349 if (element !== null) { 7350 registeredElementIdRef.current = id; 7351 registeredElementRef.current = element; 7352 store2.context.triggerElements.add(id, element); 7353 shouldSyncTriggerCount = true; 7354 } 7355 if (shouldSyncTriggerCount) { 7356 const triggerCount = store2.context.triggerElements.size; 7357 if (store2.select("open") && store2.state.triggerCount !== triggerCount) { 7358 store2.set("triggerCount", triggerCount); 7359 } 7360 } 7361 }, [store2, id]); 7362 } 7363 function setPopupOpenState(state, open, trigger, preventUnmountOnClose = false) { 7364 if (open) { 7365 state.preventUnmountingOnClose = false; 7366 } else if (preventUnmountOnClose) { 7367 state.preventUnmountingOnClose = true; 7368 } 7369 const triggerId = trigger?.id ?? null; 7370 if (triggerId || open) { 7371 state.activeTriggerId = triggerId; 7372 state.activeTriggerElement = trigger ?? null; 7373 } 7374 } 7375 function attachPreventUnmountOnClose(eventDetails) { 7376 let preventUnmountOnClose = false; 7377 eventDetails.preventUnmountOnClose = () => { 7378 preventUnmountOnClose = true; 7379 }; 7380 return () => preventUnmountOnClose; 7381 } 7382 function applyPopupOpenChange(store2, nextOpen, eventDetails, options = {}) { 7383 const reason = eventDetails.reason; 7384 const isHover = reason === reason_parts_exports.triggerHover; 7385 const isFocusOpen = nextOpen && reason === reason_parts_exports.triggerFocus; 7386 const isDismissClose = !nextOpen && (reason === reason_parts_exports.triggerPress || reason === reason_parts_exports.escapeKey); 7387 const shouldPreventUnmountOnClose = attachPreventUnmountOnClose(eventDetails); 7388 store2.context.onOpenChange?.(nextOpen, eventDetails); 7389 if (eventDetails.isCanceled) { 7390 return; 7391 } 7392 options.onBeforeDispatch?.(); 7393 store2.state.floatingRootContext.dispatchOpenChange(nextOpen, eventDetails); 7394 const changeState = () => { 7395 const updatedState = { 7396 ...options.extraState, 7397 open: nextOpen 7398 }; 7399 if (isFocusOpen) { 7400 updatedState.instantType = "focus"; 7401 } else if (isDismissClose) { 7402 updatedState.instantType = "dismiss"; 7403 } else if (isHover) { 7404 updatedState.instantType = void 0; 7405 } 7406 setPopupOpenState(updatedState, nextOpen, eventDetails.trigger, shouldPreventUnmountOnClose()); 7407 store2.update(updatedState); 7408 }; 7409 if (isHover) { 7410 ReactDOM4.flushSync(changeState); 7411 } else { 7412 changeState(); 7413 } 7414 } 7415 function useInitialOpenSync(store2, openProp, defaultOpen, defaultTriggerId) { 7416 useOnFirstRender(() => { 7417 if (openProp === void 0 && store2.state.open === false && defaultOpen) { 7418 store2.state = { 7419 ...store2.state, 7420 open: true, 7421 activeTriggerId: defaultTriggerId, 7422 preventUnmountingOnClose: false 7423 }; 7424 } 7425 }); 7426 } 7427 function useTriggerDataForwarding(triggerId, triggerElementRef, store2, stateUpdates) { 7428 const isMountedByThisTrigger = store2.useState("isMountedByTrigger", triggerId); 7429 const baseRegisterTrigger = useTriggerRegistration(triggerId, store2); 7430 const registerTrigger = useStableCallback((element) => { 7431 baseRegisterTrigger(element); 7432 if (!element) { 7433 return; 7434 } 7435 const open = store2.select("open"); 7436 const activeTriggerId = store2.select("activeTriggerId"); 7437 if (activeTriggerId === triggerId) { 7438 store2.update({ 7439 activeTriggerElement: element, 7440 ...open ? stateUpdates : null 7441 }); 7442 return; 7443 } 7444 if (activeTriggerId == null && open) { 7445 store2.update({ 7446 activeTriggerId: triggerId, 7447 activeTriggerElement: element, 7448 ...stateUpdates 7449 }); 7450 } 7451 }); 7452 useIsoLayoutEffect(() => { 7453 if (isMountedByThisTrigger) { 7454 store2.update({ 7455 activeTriggerElement: triggerElementRef.current, 7456 ...stateUpdates 7457 }); 7458 } 7459 }, [isMountedByThisTrigger, store2, triggerElementRef, ...Object.values(stateUpdates)]); 7460 return { 7461 registerTrigger, 7462 isMountedByThisTrigger 7463 }; 7464 } 7465 function useImplicitActiveTrigger(store2, options = {}) { 7466 const { 7467 closeOnActiveTriggerUnmount = false 7468 } = options; 7469 const open = store2.useState("open"); 7470 const reactiveTriggerCount = store2.useState("triggerCount"); 7471 useIsoLayoutEffect(() => { 7472 if (!open) { 7473 if (store2.state.triggerCount !== 0) { 7474 store2.set("triggerCount", 0); 7475 } 7476 return; 7477 } 7478 const triggerCount = store2.context.triggerElements.size; 7479 const stateUpdates = {}; 7480 if (store2.state.triggerCount !== triggerCount) { 7481 stateUpdates.triggerCount = triggerCount; 7482 } 7483 const activeTriggerId = store2.select("activeTriggerId"); 7484 let lostActiveTriggerId = null; 7485 if (activeTriggerId) { 7486 const activeTriggerElement = store2.context.triggerElements.getById(activeTriggerId); 7487 if (!activeTriggerElement) { 7488 lostActiveTriggerId = activeTriggerId; 7489 } else if (activeTriggerElement !== store2.state.activeTriggerElement) { 7490 stateUpdates.activeTriggerElement = activeTriggerElement; 7491 } 7492 } 7493 if (!lostActiveTriggerId && !activeTriggerId && triggerCount === 1) { 7494 const iteratorResult = store2.context.triggerElements.entries().next(); 7495 if (!iteratorResult.done) { 7496 const [implicitTriggerId, implicitTriggerElement] = iteratorResult.value; 7497 stateUpdates.activeTriggerId = implicitTriggerId; 7498 stateUpdates.activeTriggerElement = implicitTriggerElement; 7499 } 7500 } 7501 if (stateUpdates.triggerCount !== void 0 || stateUpdates.activeTriggerId !== void 0 || stateUpdates.activeTriggerElement !== void 0) { 7502 store2.update(stateUpdates); 7503 } 7504 if (lostActiveTriggerId) { 7505 if (closeOnActiveTriggerUnmount) { 7506 queueMicrotask(() => { 7507 if (store2.select("open") && store2.select("activeTriggerId") === lostActiveTriggerId && !store2.context.triggerElements.getById(lostActiveTriggerId)) { 7508 const eventDetails = createChangeEventDetails(reason_parts_exports.none); 7509 store2.setOpen(false, eventDetails); 7510 if (!eventDetails.isCanceled) { 7511 store2.update({ 7512 activeTriggerId: null, 7513 activeTriggerElement: null 7514 }); 7515 } 7516 } 7517 }); 7518 } 7519 } 7520 }, [open, store2, reactiveTriggerCount, closeOnActiveTriggerUnmount]); 7521 } 7522 function useOpenStateTransitions(open, store2, onUnmount) { 7523 const { 7524 mounted, 7525 setMounted, 7526 transitionStatus 7527 } = useTransitionStatus(open); 7528 const preventUnmountingOnClose = store2.useState("preventUnmountingOnClose"); 7529 const syncedPreventUnmountingOnClose = open ? false : preventUnmountingOnClose; 7530 store2.useSyncedValues({ 7531 mounted, 7532 transitionStatus, 7533 preventUnmountingOnClose: syncedPreventUnmountingOnClose 7534 }); 7535 const forceUnmount = useStableCallback(() => { 7536 setMounted(false); 7537 store2.update({ 7538 activeTriggerId: null, 7539 activeTriggerElement: null, 7540 mounted: false, 7541 preventUnmountingOnClose: false 7542 }); 7543 onUnmount?.(); 7544 store2.context.onOpenChangeComplete?.(false); 7545 }); 7546 useOpenChangeComplete({ 7547 enabled: mounted && !open && !syncedPreventUnmountingOnClose, 7548 open, 7549 ref: store2.context.popupRef, 7550 onComplete() { 7551 if (!open) { 7552 forceUnmount(); 7553 } 7554 } 7555 }); 7556 return { 7557 forceUnmount, 7558 transitionStatus 7559 }; 7560 } 7561 function usePopupInteractionProps(store2, statePart) { 7562 store2.useSyncedValues(statePart); 7563 useIsoLayoutEffect(() => () => { 7564 store2.update({ 7565 activeTriggerProps: EMPTY_OBJECT, 7566 inactiveTriggerProps: EMPTY_OBJECT, 7567 popupProps: EMPTY_OBJECT 7568 }); 7569 }, [store2]); 7570 } 7571 7572 // node_modules/@base-ui/react/utils/popups/popupTriggerMap.mjs 7573 var PopupTriggerMap = class { 7574 constructor() { 7575 this.elementsSet = /* @__PURE__ */ new Set(); 7576 this.idMap = /* @__PURE__ */ new Map(); 7577 } 7578 /** 7579 * Adds a trigger element with the given ID. 7580 * 7581 * Note: The provided element is assumed to not be registered under multiple IDs. 7582 */ 7583 add(id, element) { 7584 const existingElement = this.idMap.get(id); 7585 if (existingElement === element) { 7586 return; 7587 } 7588 if (existingElement !== void 0) { 7589 this.elementsSet.delete(existingElement); 7590 } 7591 this.elementsSet.add(element); 7592 this.idMap.set(id, element); 7593 if (true) { 7594 if (this.elementsSet.size !== this.idMap.size) { 7595 throw new Error("Base UI: A trigger element cannot be registered under multiple IDs in PopupTriggerMap."); 7596 } 7597 } 7598 } 7599 /** 7600 * Removes the trigger element with the given ID. 7601 */ 7602 delete(id) { 7603 const element = this.idMap.get(id); 7604 if (element) { 7605 this.elementsSet.delete(element); 7606 this.idMap.delete(id); 7607 } 7608 } 7609 /** 7610 * Whether the given element is registered as a trigger. 7611 */ 7612 hasElement(element) { 7613 return this.elementsSet.has(element); 7614 } 7615 /** 7616 * Whether there is a registered trigger element matching the given predicate. 7617 */ 7618 hasMatchingElement(predicate) { 7619 for (const element of this.elementsSet) { 7620 if (predicate(element)) { 7621 return true; 7622 } 7623 } 7624 return false; 7625 } 7626 /** 7627 * Returns the trigger element associated with the given ID, or undefined if no such element exists. 7628 */ 7629 getById(id) { 7630 return this.idMap.get(id); 7631 } 7632 /** 7633 * Returns an iterable of all registered trigger entries, where each entry is a tuple of [id, element]. 7634 */ 7635 entries() { 7636 return this.idMap.entries(); 7637 } 7638 /** 7639 * Returns an iterable of all registered trigger elements. 7640 */ 7641 elements() { 7642 return this.elementsSet.values(); 7643 } 7644 /** 7645 * Returns the number of registered trigger elements. 7646 */ 7647 get size() { 7648 return this.idMap.size; 7649 } 7650 }; 7651 7652 // node_modules/@base-ui/react/floating-ui-react/utils/getEmptyRootContext.mjs 7653 function getEmptyRootContext() { 7654 return new FloatingRootStore({ 7655 open: false, 7656 transitionStatus: void 0, 7657 floatingElement: null, 7658 referenceElement: null, 7659 triggerElements: new PopupTriggerMap(), 7660 floatingId: void 0, 7661 syncOnly: false, 7662 nested: false, 7663 onOpenChange: void 0 7664 }); 7665 } 7666 7667 // node_modules/@base-ui/react/utils/popups/store.mjs 7668 function createInitialPopupStoreState() { 7669 return { 7670 open: false, 7671 openProp: void 0, 7672 mounted: false, 7673 transitionStatus: void 0, 7674 floatingRootContext: getEmptyRootContext(), 7675 floatingId: void 0, 7676 triggerCount: 0, 7677 preventUnmountingOnClose: false, 7678 payload: void 0, 7679 activeTriggerId: null, 7680 activeTriggerElement: null, 7681 triggerIdProp: void 0, 7682 popupElement: null, 7683 positionerElement: null, 7684 activeTriggerProps: EMPTY_OBJECT, 7685 inactiveTriggerProps: EMPTY_OBJECT, 7686 popupProps: EMPTY_OBJECT 7687 }; 7688 } 7689 function createPopupFloatingRootContext(triggerElements, floatingId, nested = false) { 7690 return new FloatingRootStore({ 7691 open: false, 7692 transitionStatus: void 0, 7693 floatingElement: null, 7694 referenceElement: null, 7695 triggerElements, 7696 floatingId, 7697 syncOnly: true, 7698 nested, 7699 onOpenChange: void 0 7700 }); 7701 } 7702 var activeTriggerIdSelector = createSelector2((state) => state.triggerIdProp ?? state.activeTriggerId); 7703 var openSelector = createSelector2((state) => state.openProp ?? state.open); 7704 var popupIdSelector = createSelector2((state) => { 7705 const popupId = state.popupElement?.id ?? state.floatingId; 7706 return popupId || void 0; 7707 }); 7708 function triggerOwnsOpenPopup(state, triggerId) { 7709 return triggerId !== void 0 && openSelector(state) && activeTriggerIdSelector(state) === triggerId; 7710 } 7711 function triggerOwnsOpenPopupOrIsOnlyTrigger(state, triggerId) { 7712 if (triggerOwnsOpenPopup(state, triggerId)) { 7713 return true; 7714 } 7715 return triggerId !== void 0 && openSelector(state) && activeTriggerIdSelector(state) == null && state.triggerCount === 1; 7716 } 7717 var popupStoreSelectors = { 7718 open: openSelector, 7719 mounted: createSelector2((state) => state.mounted), 7720 transitionStatus: createSelector2((state) => state.transitionStatus), 7721 floatingRootContext: createSelector2((state) => state.floatingRootContext), 7722 triggerCount: createSelector2((state) => state.triggerCount), 7723 preventUnmountingOnClose: createSelector2((state) => state.preventUnmountingOnClose), 7724 payload: createSelector2((state) => state.payload), 7725 activeTriggerId: activeTriggerIdSelector, 7726 activeTriggerElement: createSelector2((state) => state.mounted ? state.activeTriggerElement : null), 7727 popupId: popupIdSelector, 7728 /** 7729 * Whether the trigger with the given ID was used to open the popup. 7730 */ 7731 isTriggerActive: createSelector2((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId), 7732 /** 7733 * Whether the popup is open and was activated by a trigger with the given ID. 7734 */ 7735 isOpenedByTrigger: createSelector2((state, triggerId) => triggerOwnsOpenPopup(state, triggerId)), 7736 /** 7737 * Whether the popup is mounted and was activated by a trigger with the given ID. 7738 */ 7739 isMountedByTrigger: createSelector2((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId && state.mounted), 7740 triggerProps: createSelector2((state, isActive) => isActive ? state.activeTriggerProps : state.inactiveTriggerProps), 7741 /** 7742 * Popup id for the trigger that currently owns the open popup. 7743 */ 7744 triggerPopupId: createSelector2((state, triggerId) => triggerOwnsOpenPopupOrIsOnlyTrigger(state, triggerId) ? popupIdSelector(state) : void 0), 7745 popupProps: createSelector2((state) => state.popupProps), 7746 popupElement: createSelector2((state) => state.popupElement), 7747 positionerElement: createSelector2((state) => state.positionerElement) 7748 }; 7749 7750 // node_modules/@base-ui/react/floating-ui-react/hooks/useFloatingRootContext.mjs 7751 function useFloatingRootContext(options) { 7752 const { 7753 open = false, 7754 onOpenChange, 7755 elements: elements2 = {} 7756 } = options; 7757 const floatingId = useId(); 7758 const nested = useFloatingParentNodeId() != null; 7759 if (true) { 7760 const optionDomReference = elements2.reference; 7761 if (optionDomReference && !isElement(optionDomReference)) { 7762 console.error("Cannot pass a virtual element to the `elements.reference` option,", "as it must be a real DOM element. Use `context.setPositionReference()`", "instead."); 7763 } 7764 } 7765 const store2 = useRefWithInit(() => new FloatingRootStore({ 7766 open, 7767 transitionStatus: void 0, 7768 onOpenChange, 7769 referenceElement: elements2.reference ?? null, 7770 floatingElement: elements2.floating ?? null, 7771 triggerElements: new PopupTriggerMap(), 7772 floatingId, 7773 syncOnly: false, 7774 nested 7775 })).current; 7776 useIsoLayoutEffect(() => { 7777 const valuesToSync = { 7778 open, 7779 floatingId 7780 }; 7781 if (elements2.reference !== void 0) { 7782 valuesToSync.referenceElement = elements2.reference; 7783 valuesToSync.domReferenceElement = isElement(elements2.reference) ? elements2.reference : null; 7784 } 7785 if (elements2.floating !== void 0) { 7786 valuesToSync.floatingElement = elements2.floating; 7787 } 7788 store2.update(valuesToSync); 7789 }, [open, floatingId, elements2.reference, elements2.floating, store2]); 7790 store2.context.onOpenChange = onOpenChange; 7791 store2.context.nested = nested; 7792 return store2; 7793 } 7794 7795 // node_modules/@base-ui/react/floating-ui-react/hooks/useFloating.mjs 7796 function useFloating2(options = {}) { 7797 const { 7798 nodeId, 7799 externalTree 7800 } = options; 7801 const internalStore = useFloatingRootContext(options); 7802 const store2 = options.rootContext || internalStore; 7803 const referenceElement = store2.useState("referenceElement"); 7804 const floatingElement = store2.useState("floatingElement"); 7805 const domReferenceElement = store2.useState("domReferenceElement"); 7806 const open = store2.useState("open"); 7807 const floatingId = store2.useState("floatingId"); 7808 const [positionReference, setPositionReferenceRaw] = React32.useState(null); 7809 const [localDomReference, setLocalDomReference] = React32.useState(void 0); 7810 const [localFloatingElement, setLocalFloatingElement] = React32.useState(void 0); 7811 const domReferenceRef = React32.useRef(null); 7812 const tree = useFloatingTree(externalTree); 7813 const storeElements = React32.useMemo(() => ({ 7814 reference: referenceElement, 7815 floating: floatingElement, 7816 domReference: domReferenceElement 7817 }), [referenceElement, floatingElement, domReferenceElement]); 7818 const position = useFloating({ 7819 ...options, 7820 elements: { 7821 ...storeElements, 7822 ...positionReference && { 7823 reference: positionReference 7824 } 7825 } 7826 }); 7827 const localDomReferenceElement = isElement(localDomReference) ? localDomReference : null; 7828 const syncedFloatingElement = localFloatingElement === void 0 ? store2.state.floatingElement : localFloatingElement; 7829 store2.useSyncedValue("referenceElement", localDomReference ?? null); 7830 store2.useSyncedValue("domReferenceElement", localDomReference === void 0 ? domReferenceElement : localDomReferenceElement); 7831 store2.useSyncedValue("floatingElement", syncedFloatingElement); 7832 const setPositionReference = React32.useCallback((node) => { 7833 const computedPositionReference = isElement(node) ? { 7834 getBoundingClientRect: () => node.getBoundingClientRect(), 7835 getClientRects: () => node.getClientRects(), 7836 contextElement: node 7837 } : node; 7838 setPositionReferenceRaw(computedPositionReference); 7839 position.refs.setReference(computedPositionReference); 7840 }, [position.refs]); 7841 const setReference = React32.useCallback((node) => { 7842 if (isElement(node) || node === null) { 7843 domReferenceRef.current = node; 7844 setLocalDomReference(node); 7845 } 7846 if (isElement(position.refs.reference.current) || position.refs.reference.current === null || // Don't allow setting virtual elements using the old technique back to 7847 // `null` to support `positionReference` + an unstable `reference` 7848 // callback ref. 7849 node !== null && !isElement(node)) { 7850 position.refs.setReference(node); 7851 } 7852 }, [position.refs, setLocalDomReference]); 7853 const setFloating = React32.useCallback((node) => { 7854 setLocalFloatingElement(node); 7855 position.refs.setFloating(node); 7856 }, [position.refs]); 7857 const refs = React32.useMemo(() => ({ 7858 ...position.refs, 7859 setReference, 7860 setFloating, 7861 setPositionReference, 7862 domReference: domReferenceRef 7863 }), [position.refs, setReference, setFloating, setPositionReference]); 7864 const elements2 = React32.useMemo(() => ({ 7865 ...position.elements, 7866 domReference: domReferenceElement 7867 }), [position.elements, domReferenceElement]); 7868 const context = React32.useMemo(() => ({ 7869 ...position, 7870 dataRef: store2.context.dataRef, 7871 open, 7872 onOpenChange: store2.setOpen, 7873 events: store2.context.events, 7874 floatingId, 7875 refs, 7876 elements: elements2, 7877 nodeId, 7878 rootStore: store2 7879 }), [position, refs, elements2, nodeId, store2, open, floatingId]); 7880 useIsoLayoutEffect(() => { 7881 if (domReferenceElement) { 7882 domReferenceRef.current = domReferenceElement; 7883 } 7884 }, [domReferenceElement]); 7885 useIsoLayoutEffect(() => { 7886 store2.context.dataRef.current.floatingContext = context; 7887 const node = tree?.nodesRef.current.find((n2) => n2.id === nodeId); 7888 if (node) { 7889 node.context = context; 7890 } 7891 }); 7892 return React32.useMemo(() => ({ 7893 ...position, 7894 context, 7895 refs, 7896 elements: elements2, 7897 rootStore: store2 7898 }), [position, refs, elements2, context, store2]); 7899 } 7900 7901 // node_modules/@base-ui/react/floating-ui-react/hooks/useFocus.mjs 7902 var React33 = __toESM(require_react(), 1); 7903 var isMacSafari = parts_exports.os.mac && parts_exports.engine.webkit; 7904 function useFocus(context, props = {}) { 7905 const { 7906 enabled = true, 7907 delay 7908 } = props; 7909 const store2 = "rootStore" in context ? context.rootStore : context; 7910 const { 7911 events, 7912 dataRef 7913 } = store2.context; 7914 const blockFocusRef = React33.useRef(false); 7915 const blockedReferenceRef = React33.useRef(null); 7916 const keyboardModalityRef = React33.useRef(true); 7917 const timeout = useTimeout(); 7918 React33.useEffect(() => { 7919 const domReference = store2.select("domReferenceElement"); 7920 if (!enabled) { 7921 return void 0; 7922 } 7923 const win = getWindow(domReference); 7924 function onBlur() { 7925 const currentDomReference = store2.select("domReferenceElement"); 7926 if (!store2.select("open") && isHTMLElement(currentDomReference) && currentDomReference === activeElement(ownerDocument(currentDomReference))) { 7927 blockFocusRef.current = true; 7928 } 7929 } 7930 function onKeyDown() { 7931 keyboardModalityRef.current = true; 7932 } 7933 function onPointerDown() { 7934 keyboardModalityRef.current = false; 7935 } 7936 return mergeCleanups(addEventListener(win, "blur", onBlur), isMacSafari && addEventListener(win, "keydown", onKeyDown, true), isMacSafari && addEventListener(win, "pointerdown", onPointerDown, true)); 7937 }, [store2, enabled]); 7938 React33.useEffect(() => { 7939 if (!enabled) { 7940 return void 0; 7941 } 7942 function onOpenChangeLocal(details) { 7943 if (details.reason === reason_parts_exports.triggerPress || details.reason === reason_parts_exports.escapeKey) { 7944 const referenceElement = store2.select("domReferenceElement"); 7945 if (isElement(referenceElement)) { 7946 blockedReferenceRef.current = referenceElement; 7947 blockFocusRef.current = true; 7948 } 7949 } 7950 } 7951 events.on("openchange", onOpenChangeLocal); 7952 return () => { 7953 events.off("openchange", onOpenChangeLocal); 7954 }; 7955 }, [events, enabled, store2]); 7956 const reference = React33.useMemo(() => { 7957 function resetBlockedFocus() { 7958 blockFocusRef.current = false; 7959 blockedReferenceRef.current = null; 7960 } 7961 return { 7962 onMouseLeave() { 7963 resetBlockedFocus(); 7964 }, 7965 onFocus(event) { 7966 const focusTarget = event.currentTarget; 7967 if (blockFocusRef.current) { 7968 if (blockedReferenceRef.current === focusTarget) { 7969 return; 7970 } 7971 resetBlockedFocus(); 7972 } 7973 const target = getTarget(event.nativeEvent); 7974 if (isElement(target)) { 7975 if (isMacSafari && !event.relatedTarget) { 7976 if (!keyboardModalityRef.current && !isTypeableElement(target)) { 7977 return; 7978 } 7979 } else if (!matchesFocusVisible(target)) { 7980 return; 7981 } 7982 } 7983 const movedFromOtherEnabledTrigger = isTargetInsideEnabledTrigger(event.relatedTarget, store2.context.triggerElements); 7984 const { 7985 nativeEvent, 7986 currentTarget 7987 } = event; 7988 const delayValue = typeof delay === "function" ? delay() : delay; 7989 if (store2.select("open") && movedFromOtherEnabledTrigger || delayValue === 0 || delayValue === void 0) { 7990 store2.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget)); 7991 return; 7992 } 7993 timeout.start(delayValue, () => { 7994 if (blockFocusRef.current) { 7995 return; 7996 } 7997 store2.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget)); 7998 }); 7999 }, 8000 onBlur(event) { 8001 resetBlockedFocus(); 8002 const relatedTarget = event.relatedTarget; 8003 const nativeEvent = event.nativeEvent; 8004 const movedToFocusGuard = isElement(relatedTarget) && relatedTarget.hasAttribute(createAttribute("focus-guard")) && relatedTarget.getAttribute("data-type") === "outside"; 8005 timeout.start(0, () => { 8006 const domReference = store2.select("domReferenceElement"); 8007 const activeEl = activeElement(ownerDocument(domReference)); 8008 if (!relatedTarget && activeEl === domReference) { 8009 return; 8010 } 8011 if (contains(dataRef.current.floatingContext?.refs.floating.current, activeEl) || contains(domReference, activeEl) || movedToFocusGuard) { 8012 return; 8013 } 8014 const nextFocusedElement = relatedTarget ?? activeEl; 8015 if (isTargetInsideEnabledTrigger(nextFocusedElement, store2.context.triggerElements)) { 8016 return; 8017 } 8018 store2.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent)); 8019 }); 8020 } 8021 }; 8022 }, [dataRef, delay, store2, timeout]); 8023 return React33.useMemo(() => enabled ? { 8024 reference, 8025 trigger: reference 8026 } : {}, [enabled, reference]); 8027 } 8028 8029 // node_modules/@base-ui/react/floating-ui-react/hooks/useHoverFloatingInteraction.mjs 8030 var React34 = __toESM(require_react(), 1); 8031 8032 // node_modules/@base-ui/react/floating-ui-react/hooks/useHoverInteractionSharedState.mjs 8033 var HoverInteraction = class _HoverInteraction { 8034 constructor() { 8035 this.pointerType = void 0; 8036 this.interactedInside = false; 8037 this.handler = void 0; 8038 this.blockMouseMove = true; 8039 this.performedPointerEventsMutation = false; 8040 this.pointerEventsScopeElement = null; 8041 this.pointerEventsReferenceElement = null; 8042 this.pointerEventsFloatingElement = null; 8043 this.restTimeoutPending = false; 8044 this.openChangeTimeout = new Timeout(); 8045 this.restTimeout = new Timeout(); 8046 this.handleCloseOptions = void 0; 8047 } 8048 static create() { 8049 return new _HoverInteraction(); 8050 } 8051 dispose = () => { 8052 this.openChangeTimeout.clear(); 8053 this.restTimeout.clear(); 8054 }; 8055 disposeEffect = () => { 8056 return this.dispose; 8057 }; 8058 }; 8059 var pointerEventsMutationOwnerByScopeElement = /* @__PURE__ */ new WeakMap(); 8060 function clearSafePolygonPointerEventsMutation(instance) { 8061 if (!instance.performedPointerEventsMutation) { 8062 return; 8063 } 8064 const scopeElement = instance.pointerEventsScopeElement; 8065 if (scopeElement && pointerEventsMutationOwnerByScopeElement.get(scopeElement) === instance) { 8066 instance.pointerEventsScopeElement?.style.removeProperty("pointer-events"); 8067 instance.pointerEventsReferenceElement?.style.removeProperty("pointer-events"); 8068 instance.pointerEventsFloatingElement?.style.removeProperty("pointer-events"); 8069 pointerEventsMutationOwnerByScopeElement.delete(scopeElement); 8070 } 8071 instance.performedPointerEventsMutation = false; 8072 instance.pointerEventsScopeElement = null; 8073 instance.pointerEventsReferenceElement = null; 8074 instance.pointerEventsFloatingElement = null; 8075 } 8076 function applySafePolygonPointerEventsMutation(instance, options) { 8077 const { 8078 scopeElement, 8079 referenceElement, 8080 floatingElement 8081 } = options; 8082 const existingOwner = pointerEventsMutationOwnerByScopeElement.get(scopeElement); 8083 if (existingOwner && existingOwner !== instance) { 8084 clearSafePolygonPointerEventsMutation(existingOwner); 8085 } 8086 clearSafePolygonPointerEventsMutation(instance); 8087 instance.performedPointerEventsMutation = true; 8088 instance.pointerEventsScopeElement = scopeElement; 8089 instance.pointerEventsReferenceElement = referenceElement; 8090 instance.pointerEventsFloatingElement = floatingElement; 8091 pointerEventsMutationOwnerByScopeElement.set(scopeElement, instance); 8092 scopeElement.style.pointerEvents = "none"; 8093 referenceElement.style.pointerEvents = "auto"; 8094 floatingElement.style.pointerEvents = "auto"; 8095 } 8096 function useHoverInteractionSharedState(store2) { 8097 const data = store2.context.dataRef.current; 8098 const instance = useRefWithInit(() => data.hoverInteractionState ?? HoverInteraction.create()).current; 8099 if (!data.hoverInteractionState) { 8100 data.hoverInteractionState = instance; 8101 } 8102 useOnMount(data.hoverInteractionState.disposeEffect); 8103 return data.hoverInteractionState; 8104 } 8105 8106 // node_modules/@base-ui/react/floating-ui-react/hooks/useHoverFloatingInteraction.mjs 8107 function useHoverFloatingInteraction(context, parameters = {}) { 8108 const { 8109 enabled = true, 8110 closeDelay: closeDelayProp = 0, 8111 nodeId: nodeIdProp 8112 } = parameters; 8113 const store2 = "rootStore" in context ? context.rootStore : context; 8114 const open = store2.useState("open"); 8115 const floatingElement = store2.useState("floatingElement"); 8116 const domReferenceElement = store2.useState("domReferenceElement"); 8117 const { 8118 dataRef 8119 } = store2.context; 8120 const tree = useFloatingTree(); 8121 const parentId = useFloatingParentNodeId(); 8122 const instance = useHoverInteractionSharedState(store2); 8123 const childClosedTimeout = useTimeout(); 8124 const isClickLikeOpenEvent2 = useStableCallback(() => { 8125 return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside); 8126 }); 8127 const isHoverOpen = useStableCallback(() => { 8128 return isHoverOpenEvent(dataRef.current.openEvent?.type); 8129 }); 8130 const clearPointerEvents = useStableCallback(() => { 8131 clearSafePolygonPointerEventsMutation(instance); 8132 }); 8133 useIsoLayoutEffect(() => { 8134 if (!open) { 8135 instance.pointerType = void 0; 8136 instance.restTimeoutPending = false; 8137 instance.interactedInside = false; 8138 clearPointerEvents(); 8139 } 8140 }, [open, instance, clearPointerEvents]); 8141 React34.useEffect(() => { 8142 return clearPointerEvents; 8143 }, [clearPointerEvents]); 8144 useIsoLayoutEffect(() => { 8145 if (!enabled) { 8146 return void 0; 8147 } 8148 if (open && instance.handleCloseOptions?.blockPointerEvents && isHoverOpen() && isElement(domReferenceElement) && floatingElement) { 8149 const ref = domReferenceElement; 8150 const floatingEl = floatingElement; 8151 const doc = ownerDocument(floatingElement); 8152 const parentFloating = tree?.nodesRef.current.find((node) => node.id === parentId)?.context?.elements.floating; 8153 if (parentFloating) { 8154 parentFloating.style.pointerEvents = ""; 8155 } 8156 const cachedScopeElement = instance.pointerEventsScopeElement !== floatingEl ? instance.pointerEventsScopeElement : null; 8157 const parentScopeElement = parentFloating !== floatingEl ? parentFloating : null; 8158 const scopeElement = instance.handleCloseOptions?.getScope?.() ?? cachedScopeElement ?? parentScopeElement ?? ref.closest("[data-rootownerid]") ?? doc.body; 8159 applySafePolygonPointerEventsMutation(instance, { 8160 scopeElement, 8161 referenceElement: ref, 8162 floatingElement: floatingEl 8163 }); 8164 return () => { 8165 clearPointerEvents(); 8166 }; 8167 } 8168 return void 0; 8169 }, [enabled, open, domReferenceElement, floatingElement, instance, isHoverOpen, tree, parentId, clearPointerEvents]); 8170 React34.useEffect(() => { 8171 if (!enabled) { 8172 return void 0; 8173 } 8174 function hasParentChildren() { 8175 return !!(tree && parentId && getNodeChildren(tree.nodesRef.current, parentId).length > 0); 8176 } 8177 function closeWithDelay(event) { 8178 const closeDelay = getDelay(closeDelayProp, "close", instance.pointerType); 8179 const close = () => { 8180 store2.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event)); 8181 tree?.events.emit("floating.closed", event); 8182 }; 8183 if (closeDelay) { 8184 instance.openChangeTimeout.start(closeDelay, close); 8185 } else { 8186 instance.openChangeTimeout.clear(); 8187 close(); 8188 } 8189 } 8190 function handleInteractInside(event) { 8191 const target = getTarget(event); 8192 if (!isInteractiveElement(target)) { 8193 instance.interactedInside = false; 8194 return; 8195 } 8196 instance.interactedInside = target?.closest("[aria-haspopup]") != null; 8197 } 8198 function onFloatingMouseEnter() { 8199 instance.openChangeTimeout.clear(); 8200 childClosedTimeout.clear(); 8201 tree?.events.off("floating.closed", onNodeClosed); 8202 clearPointerEvents(); 8203 } 8204 function onFloatingMouseLeave(event) { 8205 if (hasParentChildren() && tree) { 8206 tree.events.on("floating.closed", onNodeClosed); 8207 return; 8208 } 8209 if (isTargetInsideEnabledTrigger(event.relatedTarget, store2.context.triggerElements)) { 8210 return; 8211 } 8212 const currentNodeId = dataRef.current.floatingContext?.nodeId ?? nodeIdProp; 8213 const relatedTarget = event.relatedTarget; 8214 const isMovingIntoDescendantFloating = tree && currentNodeId && isElement(relatedTarget) && getNodeChildren(tree.nodesRef.current, currentNodeId, false).some((node) => contains(node.context?.elements.floating, relatedTarget)); 8215 if (isMovingIntoDescendantFloating) { 8216 return; 8217 } 8218 if (instance.handler) { 8219 instance.handler(event); 8220 return; 8221 } 8222 clearPointerEvents(); 8223 if (isHoverOpen() && !isClickLikeOpenEvent2()) { 8224 closeWithDelay(event); 8225 } 8226 } 8227 function onNodeClosed(event) { 8228 if (!tree || !parentId || hasParentChildren()) { 8229 return; 8230 } 8231 childClosedTimeout.start(0, () => { 8232 tree.events.off("floating.closed", onNodeClosed); 8233 store2.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event)); 8234 tree.events.emit("floating.closed", event); 8235 }); 8236 } 8237 const floating = floatingElement; 8238 return mergeCleanups(floating && addEventListener(floating, "mouseenter", onFloatingMouseEnter), floating && addEventListener(floating, "mouseleave", onFloatingMouseLeave), floating && addEventListener(floating, "pointerdown", handleInteractInside, true), () => { 8239 tree?.events.off("floating.closed", onNodeClosed); 8240 }); 8241 }, [enabled, floatingElement, store2, dataRef, closeDelayProp, nodeIdProp, isHoverOpen, isClickLikeOpenEvent2, clearPointerEvents, instance, tree, parentId, childClosedTimeout]); 8242 } 8243 8244 // node_modules/@base-ui/react/floating-ui-react/hooks/useHoverReferenceInteraction.mjs 8245 var React35 = __toESM(require_react(), 1); 8246 var ReactDOM5 = __toESM(require_react_dom(), 1); 8247 var EMPTY_REF = { 8248 current: null 8249 }; 8250 function useHoverReferenceInteraction(context, props = {}) { 8251 const { 8252 enabled = true, 8253 delay = 0, 8254 handleClose = null, 8255 mouseOnly = false, 8256 restMs = 0, 8257 move = true, 8258 triggerElementRef = EMPTY_REF, 8259 externalTree, 8260 isActiveTrigger = true, 8261 getHandleCloseContext, 8262 isClosing, 8263 shouldOpen: shouldOpenProp 8264 } = props; 8265 const store2 = "rootStore" in context ? context.rootStore : context; 8266 const { 8267 dataRef, 8268 events 8269 } = store2.context; 8270 const tree = useFloatingTree(externalTree); 8271 const instance = useHoverInteractionSharedState(store2); 8272 const isHoverCloseActiveRef = React35.useRef(false); 8273 const handleCloseRef = useValueAsRef(handleClose); 8274 const delayRef = useValueAsRef(delay); 8275 const restMsRef = useValueAsRef(restMs); 8276 const enabledRef = useValueAsRef(enabled); 8277 const shouldOpenRef = useValueAsRef(shouldOpenProp); 8278 const isClosingRef = useValueAsRef(isClosing); 8279 const isClickLikeOpenEvent2 = useStableCallback(() => { 8280 return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside); 8281 }); 8282 const checkShouldOpen = useStableCallback(() => { 8283 return shouldOpenRef.current?.() !== false; 8284 }); 8285 const isOverInactiveTrigger = useStableCallback((currentDomReference, currentTarget, target) => { 8286 const allTriggers = store2.context.triggerElements; 8287 if (allTriggers.hasElement(currentTarget)) { 8288 return !currentDomReference || !contains(currentDomReference, currentTarget); 8289 } 8290 if (!isElement(target)) { 8291 return false; 8292 } 8293 const targetElement = target; 8294 return allTriggers.hasMatchingElement((trigger) => contains(trigger, targetElement)) && (!currentDomReference || !contains(currentDomReference, targetElement)); 8295 }); 8296 const cleanupMouseMoveHandler = useStableCallback(() => { 8297 if (!instance.handler) { 8298 return; 8299 } 8300 const doc = ownerDocument(store2.select("domReferenceElement")); 8301 doc.removeEventListener("mousemove", instance.handler); 8302 instance.handler = void 0; 8303 }); 8304 const clearPointerEvents = useStableCallback(() => { 8305 clearSafePolygonPointerEventsMutation(instance); 8306 }); 8307 if (isActiveTrigger) { 8308 instance.handleCloseOptions = handleCloseRef.current?.__options; 8309 } 8310 React35.useEffect(() => cleanupMouseMoveHandler, [cleanupMouseMoveHandler]); 8311 React35.useEffect(() => { 8312 if (!enabled) { 8313 return void 0; 8314 } 8315 function onOpenChangeLocal(details) { 8316 if (!details.open) { 8317 isHoverCloseActiveRef.current = details.reason === reason_parts_exports.triggerHover; 8318 cleanupMouseMoveHandler(); 8319 instance.openChangeTimeout.clear(); 8320 instance.restTimeout.clear(); 8321 instance.blockMouseMove = true; 8322 instance.restTimeoutPending = false; 8323 } else { 8324 isHoverCloseActiveRef.current = false; 8325 } 8326 } 8327 events.on("openchange", onOpenChangeLocal); 8328 return () => { 8329 events.off("openchange", onOpenChangeLocal); 8330 }; 8331 }, [enabled, events, instance, cleanupMouseMoveHandler]); 8332 React35.useEffect(() => { 8333 if (!enabled) { 8334 return void 0; 8335 } 8336 function closeWithDelay(event, runElseBranch = true) { 8337 const closeDelay = getDelay(delayRef.current, "close", instance.pointerType); 8338 if (closeDelay) { 8339 instance.openChangeTimeout.start(closeDelay, () => { 8340 store2.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event)); 8341 tree?.events.emit("floating.closed", event); 8342 }); 8343 } else if (runElseBranch) { 8344 instance.openChangeTimeout.clear(); 8345 store2.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event)); 8346 tree?.events.emit("floating.closed", event); 8347 } 8348 } 8349 const trigger = triggerElementRef.current ?? (isActiveTrigger ? store2.select("domReferenceElement") : null); 8350 if (!isElement(trigger)) { 8351 return void 0; 8352 } 8353 function onMouseEnter(event) { 8354 instance.openChangeTimeout.clear(); 8355 instance.blockMouseMove = false; 8356 if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) { 8357 return; 8358 } 8359 const restMsValue = getRestMs(restMsRef.current); 8360 const openDelay = getDelay(delayRef.current, "open", instance.pointerType); 8361 const eventTarget = getTarget(event); 8362 const currentTarget = event.currentTarget ?? null; 8363 const currentDomReference = store2.select("domReferenceElement"); 8364 let triggerNode = currentTarget; 8365 if (isElement(eventTarget) && !store2.context.triggerElements.hasElement(eventTarget)) { 8366 for (const triggerElement of store2.context.triggerElements.elements()) { 8367 if (contains(triggerElement, eventTarget)) { 8368 triggerNode = triggerElement; 8369 break; 8370 } 8371 } 8372 } 8373 if (isElement(currentTarget) && isElement(currentDomReference) && !store2.context.triggerElements.hasElement(currentTarget) && contains(currentTarget, currentDomReference)) { 8374 triggerNode = currentDomReference; 8375 } 8376 const isOverInactive = triggerNode == null ? false : isOverInactiveTrigger(currentDomReference, triggerNode, eventTarget); 8377 const isOpen = store2.select("open"); 8378 const isInClosingTransition = isClosingRef.current?.() ?? store2.select("transitionStatus") === "ending"; 8379 const isHoverCloseTransition = !isOpen && isInClosingTransition && isHoverCloseActiveRef.current; 8380 const isReenteringSameTriggerDuringCloseTransition = !isOverInactive && isElement(triggerNode) && isElement(currentDomReference) && contains(currentDomReference, triggerNode) && isHoverCloseTransition; 8381 const isRestOnlyDelay = restMsValue > 0 && !openDelay; 8382 const shouldOpenImmediately = isOverInactive && (isOpen || isHoverCloseTransition) || isReenteringSameTriggerDuringCloseTransition; 8383 const shouldOpen = !isOpen || isOverInactive; 8384 if (shouldOpenImmediately) { 8385 if (checkShouldOpen()) { 8386 store2.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode)); 8387 } 8388 return; 8389 } 8390 if (isRestOnlyDelay) { 8391 return; 8392 } 8393 if (openDelay) { 8394 instance.openChangeTimeout.start(openDelay, () => { 8395 if (shouldOpen && checkShouldOpen()) { 8396 store2.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode)); 8397 } 8398 }); 8399 } else if (shouldOpen) { 8400 if (checkShouldOpen()) { 8401 store2.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode)); 8402 } 8403 } 8404 } 8405 function onMouseLeave(event) { 8406 if (isClickLikeOpenEvent2()) { 8407 clearPointerEvents(); 8408 return; 8409 } 8410 cleanupMouseMoveHandler(); 8411 const domReferenceElement = store2.select("domReferenceElement"); 8412 const doc = ownerDocument(domReferenceElement); 8413 instance.restTimeout.clear(); 8414 instance.restTimeoutPending = false; 8415 const handleCloseContextBase = dataRef.current.floatingContext ?? getHandleCloseContext?.(); 8416 if (isTargetInsideEnabledTrigger(event.relatedTarget, store2.context.triggerElements)) { 8417 return; 8418 } 8419 if (handleCloseRef.current && handleCloseContextBase) { 8420 if (!store2.select("open")) { 8421 instance.openChangeTimeout.clear(); 8422 } 8423 const currentTrigger = triggerElementRef.current; 8424 instance.handler = handleCloseRef.current({ 8425 ...handleCloseContextBase, 8426 tree, 8427 x: event.clientX, 8428 y: event.clientY, 8429 onClose() { 8430 clearPointerEvents(); 8431 cleanupMouseMoveHandler(); 8432 if (enabledRef.current && !isClickLikeOpenEvent2() && currentTrigger === store2.select("domReferenceElement")) { 8433 closeWithDelay(event, true); 8434 } 8435 } 8436 }); 8437 doc.addEventListener("mousemove", instance.handler); 8438 instance.handler(event); 8439 return; 8440 } 8441 const shouldClose = instance.pointerType === "touch" ? !contains(store2.select("floatingElement"), event.relatedTarget) : true; 8442 if (shouldClose) { 8443 closeWithDelay(event); 8444 } 8445 } 8446 if (move) { 8447 return mergeCleanups(addEventListener(trigger, "mousemove", onMouseEnter, { 8448 once: true 8449 }), addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave)); 8450 } 8451 return mergeCleanups(addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave)); 8452 }, [cleanupMouseMoveHandler, clearPointerEvents, dataRef, delayRef, store2, enabled, handleCloseRef, instance, isActiveTrigger, isOverInactiveTrigger, isClickLikeOpenEvent2, mouseOnly, move, restMsRef, triggerElementRef, tree, enabledRef, getHandleCloseContext, isClosingRef, checkShouldOpen]); 8453 return React35.useMemo(() => { 8454 if (!enabled) { 8455 return void 0; 8456 } 8457 function setPointerRef(event) { 8458 instance.pointerType = event.pointerType; 8459 } 8460 return { 8461 onPointerDown: setPointerRef, 8462 onPointerEnter: setPointerRef, 8463 onMouseMove(event) { 8464 const { 8465 nativeEvent 8466 } = event; 8467 const trigger = event.currentTarget; 8468 const currentDomReference = store2.select("domReferenceElement"); 8469 const currentOpen = store2.select("open"); 8470 const isOverInactive = isOverInactiveTrigger(currentDomReference, trigger, event.target); 8471 if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) { 8472 return; 8473 } 8474 if (currentOpen && isOverInactive && instance.handleCloseOptions?.blockPointerEvents) { 8475 const floatingElement = store2.select("floatingElement"); 8476 if (floatingElement) { 8477 const scopeElement = instance.handleCloseOptions?.getScope?.() ?? trigger.ownerDocument.body; 8478 applySafePolygonPointerEventsMutation(instance, { 8479 scopeElement, 8480 referenceElement: trigger, 8481 floatingElement 8482 }); 8483 } 8484 } 8485 const restMsValue = getRestMs(restMsRef.current); 8486 if (currentOpen && !isOverInactive || restMsValue === 0) { 8487 return; 8488 } 8489 if (!isOverInactive && instance.restTimeoutPending && event.movementX ** 2 + event.movementY ** 2 < 2) { 8490 return; 8491 } 8492 instance.restTimeout.clear(); 8493 function handleMouseMove() { 8494 instance.restTimeoutPending = false; 8495 if (isClickLikeOpenEvent2()) { 8496 return; 8497 } 8498 const latestOpen = store2.select("open"); 8499 if (!instance.blockMouseMove && (!latestOpen || isOverInactive) && checkShouldOpen()) { 8500 store2.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, nativeEvent, trigger)); 8501 } 8502 } 8503 if (instance.pointerType === "touch") { 8504 ReactDOM5.flushSync(() => { 8505 handleMouseMove(); 8506 }); 8507 } else if (isOverInactive && currentOpen) { 8508 handleMouseMove(); 8509 } else { 8510 instance.restTimeoutPending = true; 8511 instance.restTimeout.start(restMsValue, handleMouseMove); 8512 } 8513 } 8514 }; 8515 }, [enabled, instance, isClickLikeOpenEvent2, isOverInactiveTrigger, mouseOnly, store2, restMsRef, checkShouldOpen]); 8516 } 8517 8518 // node_modules/@base-ui/react/floating-ui-react/safePolygon.mjs 8519 var CURSOR_SPEED_THRESHOLD = 0.1; 8520 var CURSOR_SPEED_THRESHOLD_SQUARED = CURSOR_SPEED_THRESHOLD * CURSOR_SPEED_THRESHOLD; 8521 var POLYGON_BUFFER = 0.5; 8522 function hasIntersectingEdge(pointX, pointY, xi, yi, xj, yj) { 8523 return yi >= pointY !== yj >= pointY && pointX <= (xj - xi) * (pointY - yi) / (yj - yi) + xi; 8524 } 8525 function isPointInQuadrilateral(pointX, pointY, x1, y1, x2, y2, x3, y3, x4, y4) { 8526 let isInsideValue = false; 8527 if (hasIntersectingEdge(pointX, pointY, x1, y1, x2, y2)) { 8528 isInsideValue = !isInsideValue; 8529 } 8530 if (hasIntersectingEdge(pointX, pointY, x2, y2, x3, y3)) { 8531 isInsideValue = !isInsideValue; 8532 } 8533 if (hasIntersectingEdge(pointX, pointY, x3, y3, x4, y4)) { 8534 isInsideValue = !isInsideValue; 8535 } 8536 if (hasIntersectingEdge(pointX, pointY, x4, y4, x1, y1)) { 8537 isInsideValue = !isInsideValue; 8538 } 8539 return isInsideValue; 8540 } 8541 function isInsideRect(pointX, pointY, rect) { 8542 return pointX >= rect.x && pointX <= rect.x + rect.width && pointY >= rect.y && pointY <= rect.y + rect.height; 8543 } 8544 function isInsideAxisAlignedRect(pointX, pointY, x1, y1, x2, y2) { 8545 const minX = Math.min(x1, x2); 8546 const maxX = Math.max(x1, x2); 8547 const minY = Math.min(y1, y2); 8548 const maxY = Math.max(y1, y2); 8549 return pointX >= minX && pointX <= maxX && pointY >= minY && pointY <= maxY; 8550 } 8551 function safePolygon(options = {}) { 8552 const { 8553 blockPointerEvents = false 8554 } = options; 8555 const timeout = new Timeout(); 8556 const fn = ({ 8557 x: x2, 8558 y: y2, 8559 placement, 8560 elements: elements2, 8561 onClose, 8562 nodeId, 8563 tree 8564 }) => { 8565 const side = placement?.split("-")[0]; 8566 let hasLanded = false; 8567 let lastX = null; 8568 let lastY = null; 8569 let lastCursorTime = typeof performance !== "undefined" ? performance.now() : 0; 8570 function isCursorMovingSlowly(nextX, nextY) { 8571 const currentTime = performance.now(); 8572 const elapsedTime = currentTime - lastCursorTime; 8573 if (lastX === null || lastY === null || elapsedTime === 0) { 8574 lastX = nextX; 8575 lastY = nextY; 8576 lastCursorTime = currentTime; 8577 return false; 8578 } 8579 const deltaX = nextX - lastX; 8580 const deltaY = nextY - lastY; 8581 const distanceSquared = deltaX * deltaX + deltaY * deltaY; 8582 const thresholdSquared = elapsedTime * elapsedTime * CURSOR_SPEED_THRESHOLD_SQUARED; 8583 lastX = nextX; 8584 lastY = nextY; 8585 lastCursorTime = currentTime; 8586 return distanceSquared < thresholdSquared; 8587 } 8588 function close() { 8589 timeout.clear(); 8590 onClose(); 8591 } 8592 return function onMouseMove(event) { 8593 timeout.clear(); 8594 const domReference = elements2.domReference; 8595 const floating = elements2.floating; 8596 if (!domReference || !floating || side == null || x2 == null || y2 == null) { 8597 return void 0; 8598 } 8599 const { 8600 clientX, 8601 clientY 8602 } = event; 8603 const target = getTarget(event); 8604 const isLeave = event.type === "mouseleave"; 8605 const isOverFloatingEl = contains(floating, target); 8606 const isOverReferenceEl = contains(domReference, target); 8607 if (isOverFloatingEl) { 8608 hasLanded = true; 8609 if (!isLeave) { 8610 return void 0; 8611 } 8612 } 8613 if (isOverReferenceEl) { 8614 hasLanded = false; 8615 if (!isLeave) { 8616 hasLanded = true; 8617 return void 0; 8618 } 8619 } 8620 if (isLeave && isElement(event.relatedTarget) && contains(floating, event.relatedTarget)) { 8621 return void 0; 8622 } 8623 function hasOpenChildNode() { 8624 return Boolean(tree && getNodeChildren(tree.nodesRef.current, nodeId).length > 0); 8625 } 8626 function closeIfNoOpenChild() { 8627 if (!hasOpenChildNode()) { 8628 close(); 8629 } 8630 } 8631 if (hasOpenChildNode()) { 8632 return void 0; 8633 } 8634 const refRect = domReference.getBoundingClientRect(); 8635 const rect = floating.getBoundingClientRect(); 8636 const cursorLeaveFromRight = x2 > rect.right - rect.width / 2; 8637 const cursorLeaveFromBottom = y2 > rect.bottom - rect.height / 2; 8638 const isFloatingWider = rect.width > refRect.width; 8639 const isFloatingTaller = rect.height > refRect.height; 8640 const left = (isFloatingWider ? refRect : rect).left; 8641 const right = (isFloatingWider ? refRect : rect).right; 8642 const top = (isFloatingTaller ? refRect : rect).top; 8643 const bottom = (isFloatingTaller ? refRect : rect).bottom; 8644 if (side === "top" && y2 >= refRect.bottom - 1 || side === "bottom" && y2 <= refRect.top + 1 || side === "left" && x2 >= refRect.right - 1 || side === "right" && x2 <= refRect.left + 1) { 8645 closeIfNoOpenChild(); 8646 return void 0; 8647 } 8648 let isInsideTroughRect = false; 8649 switch (side) { 8650 case "top": 8651 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, refRect.top + 1, right, rect.bottom - 1); 8652 break; 8653 case "bottom": 8654 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, rect.top + 1, right, refRect.bottom - 1); 8655 break; 8656 case "left": 8657 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, rect.right - 1, bottom, refRect.left + 1, top); 8658 break; 8659 case "right": 8660 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, refRect.right - 1, bottom, rect.left + 1, top); 8661 break; 8662 default: 8663 } 8664 if (isInsideTroughRect) { 8665 return void 0; 8666 } 8667 if (hasLanded && !isInsideRect(clientX, clientY, refRect)) { 8668 closeIfNoOpenChild(); 8669 return void 0; 8670 } 8671 if (!isLeave && isCursorMovingSlowly(clientX, clientY)) { 8672 closeIfNoOpenChild(); 8673 return void 0; 8674 } 8675 let isInsidePolygon = false; 8676 switch (side) { 8677 case "top": { 8678 const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4; 8679 const cursorPointOneX = isFloatingWider ? x2 + cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset; 8680 const cursorPointTwoX = isFloatingWider ? x2 - cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset; 8681 const cursorPointY = y2 + POLYGON_BUFFER + 1; 8682 const commonYLeft = cursorLeaveFromRight ? rect.bottom - POLYGON_BUFFER : isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top; 8683 const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top : rect.bottom - POLYGON_BUFFER; 8684 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight); 8685 break; 8686 } 8687 case "bottom": { 8688 const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4; 8689 const cursorPointOneX = isFloatingWider ? x2 + cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset; 8690 const cursorPointTwoX = isFloatingWider ? x2 - cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset; 8691 const cursorPointY = y2 - POLYGON_BUFFER; 8692 const commonYLeft = cursorLeaveFromRight ? rect.top + POLYGON_BUFFER : isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom; 8693 const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom : rect.top + POLYGON_BUFFER; 8694 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight); 8695 break; 8696 } 8697 case "left": { 8698 const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4; 8699 const cursorPointOneY = isFloatingTaller ? y2 + cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset; 8700 const cursorPointTwoY = isFloatingTaller ? y2 - cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset; 8701 const cursorPointX = x2 + POLYGON_BUFFER + 1; 8702 const commonXTop = cursorLeaveFromBottom ? rect.right - POLYGON_BUFFER : isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left; 8703 const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left : rect.right - POLYGON_BUFFER; 8704 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, commonXTop, rect.top, commonXBottom, rect.bottom, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY); 8705 break; 8706 } 8707 case "right": { 8708 const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4; 8709 const cursorPointOneY = isFloatingTaller ? y2 + cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset; 8710 const cursorPointTwoY = isFloatingTaller ? y2 - cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset; 8711 const cursorPointX = x2 - POLYGON_BUFFER; 8712 const commonXTop = cursorLeaveFromBottom ? rect.left + POLYGON_BUFFER : isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right; 8713 const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right : rect.left + POLYGON_BUFFER; 8714 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY, commonXTop, rect.top, commonXBottom, rect.bottom); 8715 break; 8716 } 8717 default: 8718 } 8719 if (!isInsidePolygon) { 8720 closeIfNoOpenChild(); 8721 } else if (!hasLanded) { 8722 timeout.start(40, closeIfNoOpenChild); 8723 } 8724 return void 0; 8725 }; 8726 }; 8727 fn.__options = { 8728 ...options, 8729 blockPointerEvents 8730 }; 8731 return fn; 8732 } 8733 8734 // node_modules/@base-ui/react/utils/popupStateMapping.mjs 8735 var CommonPopupDataAttributes = (function(CommonPopupDataAttributes2) { 8736 CommonPopupDataAttributes2["open"] = "data-open"; 8737 CommonPopupDataAttributes2["closed"] = "data-closed"; 8738 CommonPopupDataAttributes2[CommonPopupDataAttributes2["startingStyle"] = TransitionStatusDataAttributes.startingStyle] = "startingStyle"; 8739 CommonPopupDataAttributes2[CommonPopupDataAttributes2["endingStyle"] = TransitionStatusDataAttributes.endingStyle] = "endingStyle"; 8740 CommonPopupDataAttributes2["anchorHidden"] = "data-anchor-hidden"; 8741 CommonPopupDataAttributes2["side"] = "data-side"; 8742 CommonPopupDataAttributes2["align"] = "data-align"; 8743 return CommonPopupDataAttributes2; 8744 })({}); 8745 var CommonTriggerDataAttributes = /* @__PURE__ */ (function(CommonTriggerDataAttributes2) { 8746 CommonTriggerDataAttributes2["popupOpen"] = "data-popup-open"; 8747 CommonTriggerDataAttributes2["pressed"] = "data-pressed"; 8748 return CommonTriggerDataAttributes2; 8749 })({}); 8750 var TRIGGER_HOOK = { 8751 [CommonTriggerDataAttributes.popupOpen]: "" 8752 }; 8753 var PRESSABLE_TRIGGER_HOOK = { 8754 [CommonTriggerDataAttributes.popupOpen]: "", 8755 [CommonTriggerDataAttributes.pressed]: "" 8756 }; 8757 var POPUP_OPEN_HOOK = { 8758 [CommonPopupDataAttributes.open]: "" 8759 }; 8760 var POPUP_CLOSED_HOOK = { 8761 [CommonPopupDataAttributes.closed]: "" 8762 }; 8763 var ANCHOR_HIDDEN_HOOK = { 8764 [CommonPopupDataAttributes.anchorHidden]: "" 8765 }; 8766 var triggerOpenStateMapping2 = { 8767 open(value) { 8768 if (value) { 8769 return TRIGGER_HOOK; 8770 } 8771 return null; 8772 } 8773 }; 8774 var popupStateMapping = { 8775 open(value) { 8776 if (value) { 8777 return POPUP_OPEN_HOOK; 8778 } 8779 return POPUP_CLOSED_HOOK; 8780 }, 8781 anchorHidden(value) { 8782 if (value) { 8783 return ANCHOR_HIDDEN_HOOK; 8784 } 8785 return null; 8786 } 8787 }; 8788 8789 // node_modules/@base-ui/utils/inertValue.mjs 8790 function inertValue(value) { 8791 if (isReactVersionAtLeast(19)) { 8792 return value; 8793 } 8794 return value ? "true" : void 0; 8795 } 8796 8797 // node_modules/@base-ui/react/utils/useAnchorPositioning.mjs 8798 var React36 = __toESM(require_react(), 1); 8799 8800 // node_modules/@base-ui/react/floating-ui-react/middleware/arrow.mjs 8801 var baseArrow = (options) => ({ 8802 name: "arrow", 8803 options, 8804 async fn(state) { 8805 const { 8806 x: x2, 8807 y: y2, 8808 placement, 8809 rects, 8810 platform: platform3, 8811 elements: elements2, 8812 middlewareData 8813 } = state; 8814 const { 8815 element, 8816 padding = 0, 8817 offsetParent = "real" 8818 } = evaluate(options, state) || {}; 8819 if (element == null) { 8820 return {}; 8821 } 8822 const paddingObject = getPaddingObject(padding); 8823 const coords = { 8824 x: x2, 8825 y: y2 8826 }; 8827 const axis = getAlignmentAxis(placement); 8828 const length = getAxisLength(axis); 8829 const arrowDimensions = await platform3.getDimensions(element); 8830 const isYAxis = axis === "y"; 8831 const minProp = isYAxis ? "top" : "left"; 8832 const maxProp = isYAxis ? "bottom" : "right"; 8833 const clientProp = isYAxis ? "clientHeight" : "clientWidth"; 8834 const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length]; 8835 const startDiff = coords[axis] - rects.reference[axis]; 8836 const arrowOffsetParent = offsetParent === "real" ? await platform3.getOffsetParent?.(element) : elements2.floating; 8837 let clientSize = elements2.floating[clientProp] || rects.floating[length]; 8838 if (!clientSize || !await platform3.isElement?.(arrowOffsetParent)) { 8839 clientSize = elements2.floating[clientProp] || rects.floating[length]; 8840 } 8841 const centerToReference = endDiff / 2 - startDiff / 2; 8842 const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1; 8843 const minPadding = Math.min(paddingObject[minProp], largestPossiblePadding); 8844 const maxPadding = Math.min(paddingObject[maxProp], largestPossiblePadding); 8845 const min2 = minPadding; 8846 const max2 = clientSize - arrowDimensions[length] - maxPadding; 8847 const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference; 8848 const offset4 = clamp(min2, center, max2); 8849 const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset4 && rects.reference[length] / 2 - (center < min2 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0; 8850 const alignmentOffset = shouldAddOffset ? center < min2 ? center - min2 : center - max2 : 0; 8851 return { 8852 [axis]: coords[axis] + alignmentOffset, 8853 data: { 8854 [axis]: offset4, 8855 centerOffset: center - offset4 - alignmentOffset, 8856 ...shouldAddOffset && { 8857 alignmentOffset 8858 } 8859 }, 8860 reset: shouldAddOffset 8861 }; 8862 } 8863 }); 8864 var arrow4 = (options, deps) => ({ 8865 ...baseArrow(options), 8866 options: [options, deps] 8867 }); 8868 8869 // node_modules/@base-ui/react/utils/hideMiddleware.mjs 8870 var nativeHideFn = hide3().fn; 8871 var hide4 = { 8872 name: "hide", 8873 async fn(state) { 8874 const { 8875 width, 8876 height, 8877 x: x2, 8878 y: y2 8879 } = state.rects.reference; 8880 const anchorHidden = width === 0 && height === 0 && x2 === 0 && y2 === 0; 8881 const nativeHideResult = await nativeHideFn(state); 8882 return { 8883 data: { 8884 referenceHidden: nativeHideResult.data?.referenceHidden || anchorHidden 8885 } 8886 }; 8887 } 8888 }; 8889 8890 // node_modules/@base-ui/react/utils/adaptiveOriginMiddleware.mjs 8891 var DEFAULT_SIDES = { 8892 sideX: "left", 8893 sideY: "top" 8894 }; 8895 var adaptiveOrigin = { 8896 name: "adaptiveOrigin", 8897 async fn(state) { 8898 const { 8899 x: rawX, 8900 y: rawY, 8901 rects: { 8902 floating: floatRect 8903 }, 8904 elements: { 8905 floating 8906 }, 8907 platform: platform3, 8908 strategy, 8909 placement 8910 } = state; 8911 const win = getWindow(floating); 8912 const styles = win.getComputedStyle(floating); 8913 const hasTransition = styles.transitionDuration !== "0s" && styles.transitionDuration !== ""; 8914 if (!hasTransition) { 8915 return { 8916 x: rawX, 8917 y: rawY, 8918 data: DEFAULT_SIDES 8919 }; 8920 } 8921 const offsetParent = await platform3.getOffsetParent?.(floating); 8922 let offsetDimensions = { 8923 width: 0, 8924 height: 0 8925 }; 8926 if (strategy === "fixed" && win?.visualViewport) { 8927 offsetDimensions = { 8928 width: win.visualViewport.width, 8929 height: win.visualViewport.height 8930 }; 8931 } else if (offsetParent === win) { 8932 const doc = ownerDocument(floating); 8933 offsetDimensions = { 8934 width: doc.documentElement.clientWidth, 8935 height: doc.documentElement.clientHeight 8936 }; 8937 } else if (await platform3.isElement?.(offsetParent)) { 8938 offsetDimensions = await platform3.getDimensions(offsetParent); 8939 } 8940 const currentSide = getSide(placement); 8941 let x2 = rawX; 8942 let y2 = rawY; 8943 if (currentSide === "left") { 8944 x2 = offsetDimensions.width - (rawX + floatRect.width); 8945 } 8946 if (currentSide === "top") { 8947 y2 = offsetDimensions.height - (rawY + floatRect.height); 8948 } 8949 const sideX = currentSide === "left" ? "right" : DEFAULT_SIDES.sideX; 8950 const sideY = currentSide === "top" ? "bottom" : DEFAULT_SIDES.sideY; 8951 return { 8952 x: x2, 8953 y: y2, 8954 data: { 8955 sideX, 8956 sideY 8957 } 8958 }; 8959 } 8960 }; 8961 8962 // node_modules/@base-ui/react/utils/useAnchorPositioning.mjs 8963 function getLogicalSide(sideParam, renderedSide, isRtl) { 8964 const isLogicalSideParam = sideParam === "inline-start" || sideParam === "inline-end"; 8965 const logicalRight = isRtl ? "inline-start" : "inline-end"; 8966 const logicalLeft = isRtl ? "inline-end" : "inline-start"; 8967 return { 8968 top: "top", 8969 right: isLogicalSideParam ? logicalRight : "right", 8970 bottom: "bottom", 8971 left: isLogicalSideParam ? logicalLeft : "left" 8972 }[renderedSide]; 8973 } 8974 function getOffsetData(state, sideParam, isRtl) { 8975 const { 8976 rects, 8977 placement 8978 } = state; 8979 const data = { 8980 side: getLogicalSide(sideParam, getSide(placement), isRtl), 8981 align: getAlignment(placement) || "center", 8982 anchor: { 8983 width: rects.reference.width, 8984 height: rects.reference.height 8985 }, 8986 positioner: { 8987 width: rects.floating.width, 8988 height: rects.floating.height 8989 } 8990 }; 8991 return data; 8992 } 8993 function useAnchorPositioning(params) { 8994 const { 8995 // Public parameters 8996 anchor, 8997 positionMethod = "absolute", 8998 side: sideParam = "bottom", 8999 sideOffset = 0, 9000 align = "center", 9001 alignOffset = 0, 9002 collisionBoundary, 9003 collisionPadding: collisionPaddingParam = 5, 9004 sticky = false, 9005 arrowPadding = 5, 9006 disableAnchorTracking = false, 9007 inline: inlineMiddleware, 9008 // Private parameters 9009 keepMounted = false, 9010 floatingRootContext, 9011 mounted, 9012 collisionAvoidance, 9013 shiftCrossAxis = false, 9014 nodeId, 9015 adaptiveOrigin: adaptiveOrigin2, 9016 lazyFlip = false, 9017 externalTree 9018 } = params; 9019 const [mountSide, setMountSide] = React36.useState(null); 9020 if (!mounted && mountSide !== null) { 9021 setMountSide(null); 9022 } 9023 const collisionAvoidanceSide = collisionAvoidance.side || "flip"; 9024 const collisionAvoidanceAlign = collisionAvoidance.align || "flip"; 9025 const collisionAvoidanceFallbackAxisSide = collisionAvoidance.fallbackAxisSide || "end"; 9026 const anchorFn = typeof anchor === "function" ? anchor : void 0; 9027 const anchorFnCallback = useStableCallback(anchorFn); 9028 const anchorDep = anchorFn ? anchorFnCallback : anchor; 9029 const anchorValueRef = useValueAsRef(anchor); 9030 const mountedRef = useValueAsRef(mounted); 9031 const direction = useDirection(); 9032 const isRtl = direction === "rtl"; 9033 const side = mountSide || { 9034 top: "top", 9035 right: "right", 9036 bottom: "bottom", 9037 left: "left", 9038 "inline-end": isRtl ? "left" : "right", 9039 "inline-start": isRtl ? "right" : "left" 9040 }[sideParam]; 9041 const placement = align === "center" ? side : `$side}-$align}`; 9042 let collisionPadding = collisionPaddingParam; 9043 const bias = 1; 9044 const biasTop = sideParam === "bottom" ? bias : 0; 9045 const biasBottom = sideParam === "top" ? bias : 0; 9046 const biasLeft = sideParam === "right" ? bias : 0; 9047 const biasRight = sideParam === "left" ? bias : 0; 9048 if (typeof collisionPadding === "number") { 9049 collisionPadding = { 9050 top: collisionPadding + biasTop, 9051 right: collisionPadding + biasRight, 9052 bottom: collisionPadding + biasBottom, 9053 left: collisionPadding + biasLeft 9054 }; 9055 } else if (collisionPadding) { 9056 collisionPadding = { 9057 top: (collisionPadding.top || 0) + biasTop, 9058 right: (collisionPadding.right || 0) + biasRight, 9059 bottom: (collisionPadding.bottom || 0) + biasBottom, 9060 left: (collisionPadding.left || 0) + biasLeft 9061 }; 9062 } 9063 const commonCollisionProps = { 9064 boundary: collisionBoundary === "clipping-ancestors" ? "clippingAncestors" : collisionBoundary, 9065 padding: collisionPadding 9066 }; 9067 const arrowRef = React36.useRef(null); 9068 const sideOffsetRef = useValueAsRef(sideOffset); 9069 const alignOffsetRef = useValueAsRef(alignOffset); 9070 const sideOffsetDep = typeof sideOffset !== "function" ? sideOffset : 0; 9071 const alignOffsetDep = typeof alignOffset !== "function" ? alignOffset : 0; 9072 const middleware = []; 9073 if (inlineMiddleware) { 9074 middleware.push(inlineMiddleware); 9075 } 9076 middleware.push(offset3((state) => { 9077 const data = getOffsetData(state, sideParam, isRtl); 9078 const sideAxis = typeof sideOffsetRef.current === "function" ? sideOffsetRef.current(data) : sideOffsetRef.current; 9079 const alignAxis = typeof alignOffsetRef.current === "function" ? alignOffsetRef.current(data) : alignOffsetRef.current; 9080 return { 9081 mainAxis: sideAxis, 9082 crossAxis: alignAxis, 9083 alignmentAxis: alignAxis 9084 }; 9085 }, [sideOffsetDep, alignOffsetDep, isRtl, sideParam])); 9086 const shiftDisabled = collisionAvoidanceAlign === "none" && collisionAvoidanceSide !== "shift"; 9087 const crossAxisShiftEnabled = !shiftDisabled && (sticky || shiftCrossAxis || collisionAvoidanceSide === "shift"); 9088 const flipMiddleware = collisionAvoidanceSide === "none" ? null : flip3({ 9089 ...commonCollisionProps, 9090 // Ensure the popup flips if it's been limited by its --available-height and it resizes. 9091 // Since the size() padding is smaller than the flip() padding, flip() will take precedence. 9092 padding: { 9093 top: collisionPadding.top + bias, 9094 right: collisionPadding.right + bias, 9095 bottom: collisionPadding.bottom + bias, 9096 left: collisionPadding.left + bias 9097 }, 9098 mainAxis: !shiftCrossAxis && collisionAvoidanceSide === "flip", 9099 crossAxis: collisionAvoidanceAlign === "flip" ? "alignment" : false, 9100 fallbackAxisSideDirection: collisionAvoidanceFallbackAxisSide 9101 }); 9102 const shiftMiddleware = shiftDisabled ? null : shift3((data) => { 9103 const html = ownerDocument(data.elements.floating).documentElement; 9104 return { 9105 ...commonCollisionProps, 9106 // Use the Layout Viewport to avoid shifting around when pinch-zooming 9107 // for context menus. 9108 rootBoundary: shiftCrossAxis ? { 9109 x: 0, 9110 y: 0, 9111 width: html.clientWidth, 9112 height: html.clientHeight 9113 } : void 0, 9114 mainAxis: collisionAvoidanceAlign !== "none", 9115 crossAxis: crossAxisShiftEnabled, 9116 limiter: sticky || shiftCrossAxis ? void 0 : limitShift3((limitData) => { 9117 if (!arrowRef.current) { 9118 return {}; 9119 } 9120 const { 9121 width, 9122 height 9123 } = arrowRef.current.getBoundingClientRect(); 9124 const sideAxis = getSideAxis(getSide(limitData.placement)); 9125 const arrowSize = sideAxis === "y" ? width : height; 9126 const offsetAmount = sideAxis === "y" ? collisionPadding.left + collisionPadding.right : collisionPadding.top + collisionPadding.bottom; 9127 return { 9128 offset: arrowSize / 2 + offsetAmount / 2 9129 }; 9130 }) 9131 }; 9132 }, [commonCollisionProps, sticky, shiftCrossAxis, collisionPadding, collisionAvoidanceAlign]); 9133 if (collisionAvoidanceSide === "shift" || collisionAvoidanceAlign === "shift" || align === "center") { 9134 middleware.push(shiftMiddleware, flipMiddleware); 9135 } else { 9136 middleware.push(flipMiddleware, shiftMiddleware); 9137 } 9138 middleware.push(size3({ 9139 ...commonCollisionProps, 9140 apply({ 9141 elements: { 9142 floating 9143 }, 9144 availableWidth, 9145 availableHeight, 9146 rects 9147 }) { 9148 if (!mountedRef.current) { 9149 return; 9150 } 9151 const floatingStyle = floating.style; 9152 floatingStyle.setProperty("--available-width", `$availableWidth}px`); 9153 floatingStyle.setProperty("--available-height", `$availableHeight}px`); 9154 const dpr = getWindow(floating).devicePixelRatio || 1; 9155 const { 9156 x: x3, 9157 y: y3, 9158 width, 9159 height 9160 } = rects.reference; 9161 const anchorWidth = (Math.round((x3 + width) * dpr) - Math.round(x3 * dpr)) / dpr; 9162 const anchorHeight = (Math.round((y3 + height) * dpr) - Math.round(y3 * dpr)) / dpr; 9163 floatingStyle.setProperty("--anchor-width", `$anchorWidth}px`); 9164 floatingStyle.setProperty("--anchor-height", `$anchorHeight}px`); 9165 } 9166 }), arrow4((state) => ({ 9167 // `transform-origin` calculations rely on an element existing. If the arrow hasn't been set, 9168 // we'll create a fake element. 9169 element: arrowRef.current || ownerDocument(state.elements.floating).createElement("div"), 9170 padding: arrowPadding, 9171 offsetParent: "floating" 9172 }), [arrowPadding]), { 9173 name: "transformOrigin", 9174 fn(state) { 9175 const { 9176 elements: elements3, 9177 middlewareData: middlewareData2, 9178 placement: renderedPlacement2, 9179 rects, 9180 y: y3 9181 } = state; 9182 const currentRenderedSide = getSide(renderedPlacement2); 9183 const currentRenderedAxis = getSideAxis(currentRenderedSide); 9184 const arrowEl = arrowRef.current; 9185 const arrowX = middlewareData2.arrow?.x || 0; 9186 const arrowY = middlewareData2.arrow?.y || 0; 9187 const arrowWidth = arrowEl?.clientWidth || 0; 9188 const arrowHeight = arrowEl?.clientHeight || 0; 9189 const transformX = arrowX + arrowWidth / 2; 9190 const transformY = arrowY + arrowHeight / 2; 9191 const shiftY = Math.abs(middlewareData2.shift?.y || 0); 9192 const halfAnchorHeight = rects.reference.height / 2; 9193 const sideOffsetValue = typeof sideOffset === "function" ? sideOffset(getOffsetData(state, sideParam, isRtl)) : sideOffset; 9194 const isOverlappingAnchor = shiftY > sideOffsetValue; 9195 const adjacentTransformOrigin = { 9196 top: `$transformX}px calc(100% + $sideOffsetValue}px)`, 9197 bottom: `$transformX}px ${-sideOffsetValue}px`, 9198 left: `calc(100% + $sideOffsetValue}px) $transformY}px`, 9199 right: `${-sideOffsetValue}px $transformY}px` 9200 }[currentRenderedSide]; 9201 const overlapTransformOrigin = `$transformX}px $rects.reference.y + halfAnchorHeight - y3}px`; 9202 elements3.floating.style.setProperty("--transform-origin", crossAxisShiftEnabled && currentRenderedAxis === "y" && isOverlappingAnchor ? overlapTransformOrigin : adjacentTransformOrigin); 9203 return {}; 9204 } 9205 }, hide4, adaptiveOrigin2); 9206 useIsoLayoutEffect(() => { 9207 if (!mounted && floatingRootContext) { 9208 floatingRootContext.update({ 9209 referenceElement: null, 9210 floatingElement: null, 9211 domReferenceElement: null, 9212 positionReference: null 9213 }); 9214 } 9215 }, [mounted, floatingRootContext]); 9216 const autoUpdateOptions = React36.useMemo(() => ({ 9217 elementResize: !disableAnchorTracking && typeof ResizeObserver !== "undefined", 9218 layoutShift: !disableAnchorTracking && typeof IntersectionObserver !== "undefined" 9219 }), [disableAnchorTracking]); 9220 const { 9221 refs, 9222 elements: elements2, 9223 x: x2, 9224 y: y2, 9225 middlewareData, 9226 update: update4, 9227 placement: renderedPlacement, 9228 context, 9229 isPositioned, 9230 floatingStyles: originalFloatingStyles 9231 } = useFloating2({ 9232 rootContext: floatingRootContext, 9233 open: keepMounted ? mounted : void 0, 9234 placement, 9235 middleware, 9236 strategy: positionMethod, 9237 whileElementsMounted: keepMounted ? void 0 : (...args) => autoUpdate(...args, autoUpdateOptions), 9238 nodeId, 9239 externalTree 9240 }); 9241 const { 9242 sideX, 9243 sideY 9244 } = middlewareData.adaptiveOrigin || DEFAULT_SIDES; 9245 const resolvedPosition = isPositioned ? positionMethod : "fixed"; 9246 const floatingStyles = React36.useMemo(() => { 9247 const base = adaptiveOrigin2 ? { 9248 position: resolvedPosition, 9249 [sideX]: x2, 9250 [sideY]: y2 9251 } : { 9252 position: resolvedPosition, 9253 ...originalFloatingStyles 9254 }; 9255 if (!isPositioned) { 9256 base.opacity = 0; 9257 } 9258 return base; 9259 }, [adaptiveOrigin2, resolvedPosition, sideX, x2, sideY, y2, originalFloatingStyles, isPositioned]); 9260 const registeredPositionReferenceRef = React36.useRef(null); 9261 useIsoLayoutEffect(() => { 9262 if (!mounted) { 9263 return; 9264 } 9265 const anchorValue = anchorValueRef.current; 9266 const resolvedAnchor = typeof anchorValue === "function" ? anchorValue() : anchorValue; 9267 const unwrappedElement = (isRef(resolvedAnchor) ? resolvedAnchor.current : resolvedAnchor) || null; 9268 const finalAnchor = unwrappedElement || null; 9269 if (finalAnchor !== registeredPositionReferenceRef.current) { 9270 refs.setPositionReference(finalAnchor); 9271 registeredPositionReferenceRef.current = finalAnchor; 9272 } 9273 }, [mounted, refs, anchorDep, anchorValueRef]); 9274 React36.useEffect(() => { 9275 if (!mounted) { 9276 return; 9277 } 9278 const anchorValue = anchorValueRef.current; 9279 if (typeof anchorValue === "function") { 9280 return; 9281 } 9282 if (isRef(anchorValue) && anchorValue.current !== registeredPositionReferenceRef.current) { 9283 refs.setPositionReference(anchorValue.current); 9284 registeredPositionReferenceRef.current = anchorValue.current; 9285 } 9286 }, [mounted, refs, anchorDep, anchorValueRef]); 9287 React36.useEffect(() => { 9288 if (keepMounted && mounted && elements2.reference && elements2.floating) { 9289 return autoUpdate(elements2.reference, elements2.floating, update4, autoUpdateOptions); 9290 } 9291 return void 0; 9292 }, [keepMounted, mounted, elements2, update4, autoUpdateOptions]); 9293 const renderedSide = getSide(renderedPlacement); 9294 const logicalRenderedSide = getLogicalSide(sideParam, renderedSide, isRtl); 9295 const renderedAlign = getAlignment(renderedPlacement) || "center"; 9296 const anchorHidden = Boolean(middlewareData.hide?.referenceHidden); 9297 useIsoLayoutEffect(() => { 9298 if (lazyFlip && mounted && isPositioned) { 9299 setMountSide(renderedSide); 9300 } 9301 }, [lazyFlip, mounted, isPositioned, renderedSide]); 9302 const arrowStyles = React36.useMemo(() => ({ 9303 position: "absolute", 9304 top: middlewareData.arrow?.y, 9305 left: middlewareData.arrow?.x 9306 }), [middlewareData.arrow]); 9307 const arrowUncentered = middlewareData.arrow?.centerOffset !== 0; 9308 return React36.useMemo(() => ({ 9309 positionerStyles: floatingStyles, 9310 arrowStyles, 9311 arrowRef, 9312 arrowUncentered, 9313 side: logicalRenderedSide, 9314 align: renderedAlign, 9315 physicalSide: renderedSide, 9316 anchorHidden, 9317 refs, 9318 context, 9319 isPositioned, 9320 update: update4 9321 }), [floatingStyles, arrowStyles, arrowRef, arrowUncentered, logicalRenderedSide, renderedAlign, renderedSide, anchorHidden, refs, context, isPositioned, update4]); 9322 } 9323 function isRef(param) { 9324 return param != null && "current" in param; 9325 } 9326 9327 // node_modules/@base-ui/react/utils/getDisabledMountTransitionStyles.mjs 9328 function getDisabledMountTransitionStyles(transitionStatus) { 9329 return transitionStatus === "starting" ? DISABLED_TRANSITIONS_STYLE : EMPTY_OBJECT; 9330 } 9331 9332 // node_modules/@base-ui/react/utils/usePositioner.mjs 9333 function usePositioner(componentProps, state, { 9334 styles, 9335 transitionStatus, 9336 props, 9337 refs, 9338 hidden, 9339 inert = false 9340 }) { 9341 const style = { 9342 ...styles 9343 }; 9344 if (inert) { 9345 style.pointerEvents = "none"; 9346 } 9347 return useRenderElement("div", componentProps, { 9348 state, 9349 ref: refs, 9350 props: [{ 9351 role: "presentation", 9352 hidden, 9353 style 9354 }, getDisabledMountTransitionStyles(transitionStatus), props], 9355 stateAttributesMapping: popupStateMapping 9356 }); 9357 } 9358 9359 // node_modules/@base-ui/react/collapsible/index.parts.mjs 9360 var index_parts_exports = {}; 9361 __export(index_parts_exports, { 9362 Panel: () => CollapsiblePanel, 9363 Root: () => CollapsibleRoot, 9364 Trigger: () => CollapsibleTrigger 9365 }); 9366 9367 // node_modules/@base-ui/react/collapsible/root/CollapsibleRoot.mjs 9368 var React37 = __toESM(require_react(), 1); 9369 9370 // node_modules/@base-ui/react/collapsible/root/stateAttributesMapping.mjs 9371 var collapsibleStateAttributesMapping = { 9372 ...collapsibleOpenStateMapping, 9373 ...transitionStatusMapping 9374 }; 9375 9376 // node_modules/@base-ui/react/collapsible/root/CollapsibleRoot.mjs 9377 var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1); 9378 var CollapsibleRoot = /* @__PURE__ */ React37.forwardRef(function CollapsibleRoot2(componentProps, forwardedRef) { 9379 const { 9380 render: render4, 9381 className, 9382 defaultOpen = false, 9383 disabled: disabled2 = false, 9384 onOpenChange: onOpenChangeProp, 9385 open, 9386 style, 9387 ...elementProps 9388 } = componentProps; 9389 const onOpenChange = useStableCallback(onOpenChangeProp); 9390 const collapsible = useCollapsibleRoot({ 9391 open, 9392 defaultOpen, 9393 onOpenChange, 9394 disabled: disabled2 9395 }); 9396 const state = React37.useMemo(() => ({ 9397 open: collapsible.open, 9398 disabled: collapsible.disabled, 9399 transitionStatus: collapsible.transitionStatus 9400 }), [collapsible.open, collapsible.disabled, collapsible.transitionStatus]); 9401 const contextValue = React37.useMemo(() => ({ 9402 ...collapsible, 9403 onOpenChange, 9404 state 9405 }), [collapsible, onOpenChange, state]); 9406 const element = useRenderElement("div", componentProps, { 9407 state, 9408 ref: forwardedRef, 9409 props: elementProps, 9410 stateAttributesMapping: collapsibleStateAttributesMapping 9411 }); 9412 return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CollapsibleRootContext.Provider, { 9413 value: contextValue, 9414 children: element 9415 }); 9416 }); 9417 if (true) CollapsibleRoot.displayName = "CollapsibleRoot"; 9418 9419 // node_modules/@base-ui/react/collapsible/trigger/CollapsibleTrigger.mjs 9420 var React38 = __toESM(require_react(), 1); 9421 var stateAttributesMapping = { 9422 ...triggerOpenStateMapping, 9423 ...transitionStatusMapping 9424 }; 9425 var CollapsibleTrigger = /* @__PURE__ */ React38.forwardRef(function CollapsibleTrigger2(componentProps, forwardedRef) { 9426 const { 9427 panelId, 9428 open, 9429 handleTrigger, 9430 state, 9431 disabled: contextDisabled 9432 } = useCollapsibleRootContext(); 9433 const { 9434 className, 9435 disabled: disabled2 = contextDisabled, 9436 render: render4, 9437 nativeButton = true, 9438 style, 9439 ...elementProps 9440 } = componentProps; 9441 const { 9442 getButtonProps, 9443 buttonRef 9444 } = useButton({ 9445 disabled: disabled2, 9446 focusableWhenDisabled: true, 9447 native: nativeButton 9448 }); 9449 const element = useRenderElement("button", componentProps, { 9450 state, 9451 ref: [forwardedRef, buttonRef], 9452 props: [{ 9453 "aria-controls": open ? panelId : void 0, 9454 "aria-expanded": open, 9455 onClick: handleTrigger 9456 }, elementProps, getButtonProps], 9457 stateAttributesMapping 9458 }); 9459 return element; 9460 }); 9461 if (true) CollapsibleTrigger.displayName = "CollapsibleTrigger"; 9462 9463 // node_modules/@base-ui/react/collapsible/panel/CollapsiblePanel.mjs 9464 var React39 = __toESM(require_react(), 1); 9465 9466 // node_modules/@base-ui/react/collapsible/panel/CollapsiblePanelCssVars.mjs 9467 var CollapsiblePanelCssVars = /* @__PURE__ */ (function(CollapsiblePanelCssVars2) { 9468 CollapsiblePanelCssVars2["collapsiblePanelHeight"] = "--collapsible-panel-height"; 9469 CollapsiblePanelCssVars2["collapsiblePanelWidth"] = "--collapsible-panel-width"; 9470 return CollapsiblePanelCssVars2; 9471 })({}); 9472 9473 // node_modules/@base-ui/react/collapsible/panel/CollapsiblePanel.mjs 9474 var CollapsiblePanel = /* @__PURE__ */ React39.forwardRef(function CollapsiblePanel2(componentProps, forwardedRef) { 9475 const { 9476 className, 9477 hiddenUntilFound: hiddenUntilFoundProp, 9478 keepMounted: keepMountedProp, 9479 render: render4, 9480 id: idProp, 9481 style, 9482 ...elementProps 9483 } = componentProps; 9484 if (true) { 9485 useIsoLayoutEffect(() => { 9486 if (hiddenUntilFoundProp && keepMountedProp === false) { 9487 warn("The `keepMounted={false}` prop on `Collapsible.Panel` is ignored when `hiddenUntilFound` is enabled, since the panel must remain mounted while closed."); 9488 } 9489 }, [hiddenUntilFoundProp, keepMountedProp]); 9490 } 9491 const { 9492 mounted, 9493 onOpenChange, 9494 open, 9495 panelId, 9496 setMounted, 9497 setPanelIdState, 9498 setOpen, 9499 state, 9500 transitionStatus 9501 } = useCollapsibleRootContext(); 9502 const hiddenUntilFound = hiddenUntilFoundProp ?? false; 9503 const keepMounted = keepMountedProp ?? false; 9504 useIsoLayoutEffect(() => { 9505 if (idProp) { 9506 setPanelIdState(idProp); 9507 return () => { 9508 setPanelIdState(void 0); 9509 }; 9510 } 9511 return void 0; 9512 }, [idProp, setPanelIdState]); 9513 const { 9514 height, 9515 props, 9516 ref, 9517 shouldPreventOpenAnimation, 9518 shouldRender, 9519 transitionStatus: panelTransitionStatus, 9520 width 9521 } = useCollapsiblePanel({ 9522 externalRef: forwardedRef, 9523 hiddenUntilFound, 9524 id: panelId, 9525 keepMounted, 9526 mounted, 9527 onOpenChange, 9528 open, 9529 setMounted, 9530 setOpen, 9531 transitionStatus 9532 }); 9533 const panelState = { 9534 ...state, 9535 transitionStatus: panelTransitionStatus 9536 }; 9537 const resolvedStyle = resolveStyle(style, panelState); 9538 const element = useRenderElement("div", { 9539 ...componentProps, 9540 style: void 0 9541 }, { 9542 state: panelState, 9543 ref, 9544 props: [ 9545 props, 9546 { 9547 style: { 9548 [CollapsiblePanelCssVars.collapsiblePanelHeight]: height === void 0 ? "auto" : `$height}px`, 9549 [CollapsiblePanelCssVars.collapsiblePanelWidth]: width === void 0 ? "auto" : `$width}px` 9550 } 9551 }, 9552 elementProps, 9553 resolvedStyle ? { 9554 style: resolvedStyle 9555 } : void 0, 9556 // Resolve the public `style` prop so temporary `animationName: 'none'` 9557 // can still win after user's inline styles have been merged. 9558 shouldPreventOpenAnimation ? { 9559 style: { 9560 animationName: "none" 9561 } 9562 } : void 0 9563 ], 9564 stateAttributesMapping: collapsibleStateAttributesMapping 9565 }); 9566 if (!shouldRender) { 9567 return null; 9568 } 9569 return element; 9570 }); 9571 if (true) CollapsiblePanel.displayName = "CollapsiblePanel"; 9572 9573 // node_modules/@base-ui/react/utils/usePopupViewport.mjs 9574 var React42 = __toESM(require_react(), 1); 9575 var ReactDOM6 = __toESM(require_react_dom(), 1); 9576 9577 // node_modules/@base-ui/utils/usePreviousValue.mjs 9578 var React40 = __toESM(require_react(), 1); 9579 function usePreviousValue(value) { 9580 const [state, setState] = React40.useState({ 9581 current: value, 9582 previous: null 9583 }); 9584 if (value !== state.current) { 9585 setState({ 9586 current: value, 9587 previous: state.current 9588 }); 9589 } 9590 return state.previous; 9591 } 9592 9593 // node_modules/@base-ui/react/utils/usePopupAutoResize.mjs 9594 var React41 = __toESM(require_react(), 1); 9595 9596 // node_modules/@base-ui/react/utils/getCssDimensions.mjs 9597 function getCssDimensions2(element) { 9598 const css = getComputedStyle2(element); 9599 let width = parseFloat(css.width) || 0; 9600 let height = parseFloat(css.height) || 0; 9601 const hasOffset = isHTMLElement(element); 9602 const offsetWidth = hasOffset ? element.offsetWidth : width; 9603 const offsetHeight = hasOffset ? element.offsetHeight : height; 9604 const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight; 9605 if (shouldFallback) { 9606 width = offsetWidth; 9607 height = offsetHeight; 9608 } 9609 return { 9610 width, 9611 height 9612 }; 9613 } 9614 9615 // node_modules/@base-ui/react/utils/usePopupAutoResize.mjs 9616 function usePopupAutoResize(parameters) { 9617 const { 9618 popupElement, 9619 positionerElement, 9620 content, 9621 mounted, 9622 onMeasureLayout: onMeasureLayoutParam, 9623 onMeasureLayoutComplete: onMeasureLayoutCompleteParam, 9624 side, 9625 direction 9626 } = parameters; 9627 const runOnceAnimationsFinish = useAnimationsFinished(popupElement, true, false); 9628 const animationFrame = useAnimationFrame(); 9629 const committedDimensionsRef = React41.useRef(null); 9630 const isInitialRenderRef = React41.useRef(true); 9631 const restoreAnchoringStylesRef = React41.useRef(NOOP); 9632 const onMeasureLayout = useStableCallback(onMeasureLayoutParam); 9633 const onMeasureLayoutComplete = useStableCallback(onMeasureLayoutCompleteParam); 9634 const anchoringStyles = React41.useMemo(() => { 9635 let isOriginSide = side === "top"; 9636 let isPhysicalLeft = side === "left"; 9637 if (direction === "rtl") { 9638 isOriginSide = isOriginSide || side === "inline-end"; 9639 isPhysicalLeft = isPhysicalLeft || side === "inline-end"; 9640 } else { 9641 isOriginSide = isOriginSide || side === "inline-start"; 9642 isPhysicalLeft = isPhysicalLeft || side === "inline-start"; 9643 } 9644 return isOriginSide ? { 9645 position: "absolute", 9646 [side === "top" ? "bottom" : "top"]: "0", 9647 [isPhysicalLeft ? "right" : "left"]: "0" 9648 } : EMPTY_OBJECT; 9649 }, [side, direction]); 9650 useIsoLayoutEffect(() => { 9651 if (!mounted) { 9652 restoreAnchoringStylesRef.current = NOOP; 9653 isInitialRenderRef.current = true; 9654 committedDimensionsRef.current = null; 9655 return void 0; 9656 } 9657 if (!popupElement || !positionerElement) { 9658 return void 0; 9659 } 9660 restoreAnchoringStylesRef.current = applyElementStyles(popupElement, anchoringStyles); 9661 setPopupCssSize(popupElement, "auto"); 9662 const restorePopupPosition = overrideElementStyle(popupElement, "position", "static"); 9663 const restorePopupTransform = overrideElementStyle(popupElement, "transform", "none"); 9664 const restorePopupScale = overrideElementStyle(popupElement, "scale", "1"); 9665 const restorePositionerAvailableSize = applyElementStyles(positionerElement, { 9666 "--available-width": "max-content", 9667 "--available-height": "max-content" 9668 }); 9669 function restoreMeasurementOverrides() { 9670 restorePopupPosition(); 9671 restorePopupTransform(); 9672 restorePositionerAvailableSize(); 9673 } 9674 function restoreMeasurementOverridesIncludingScale() { 9675 restoreMeasurementOverrides(); 9676 restorePopupScale(); 9677 } 9678 onMeasureLayout?.(); 9679 if (isInitialRenderRef.current || committedDimensionsRef.current === null) { 9680 setPositionerCssSize(positionerElement, "max-content"); 9681 const dimensions = getCssDimensions2(popupElement); 9682 committedDimensionsRef.current = dimensions; 9683 setPositionerCssSize(positionerElement, dimensions); 9684 restoreMeasurementOverridesIncludingScale(); 9685 onMeasureLayoutComplete?.(null, dimensions); 9686 isInitialRenderRef.current = false; 9687 return () => { 9688 restoreAnchoringStylesRef.current(); 9689 restoreAnchoringStylesRef.current = NOOP; 9690 }; 9691 } 9692 setPositionerCssSize(positionerElement, "max-content"); 9693 const previousDimensions = committedDimensionsRef.current; 9694 const newDimensions = getCssDimensions2(popupElement); 9695 committedDimensionsRef.current = newDimensions; 9696 setPopupCssSize(popupElement, previousDimensions); 9697 restoreMeasurementOverridesIncludingScale(); 9698 onMeasureLayoutComplete?.(previousDimensions, newDimensions); 9699 setPositionerCssSize(positionerElement, newDimensions); 9700 const abortController = new AbortController(); 9701 animationFrame.request(() => { 9702 setPopupCssSize(popupElement, newDimensions); 9703 runOnceAnimationsFinish(() => { 9704 popupElement.style.setProperty("--popup-width", "auto"); 9705 popupElement.style.setProperty("--popup-height", "auto"); 9706 }, abortController.signal); 9707 }); 9708 return () => { 9709 abortController.abort(); 9710 animationFrame.cancel(); 9711 restoreAnchoringStylesRef.current(); 9712 restoreAnchoringStylesRef.current = NOOP; 9713 }; 9714 }, [content, popupElement, positionerElement, runOnceAnimationsFinish, animationFrame, mounted, onMeasureLayout, onMeasureLayoutComplete, anchoringStyles]); 9715 } 9716 function overrideElementStyle(element, property, value) { 9717 const originalValue = element.style.getPropertyValue(property); 9718 element.style.setProperty(property, value); 9719 return () => { 9720 element.style.setProperty(property, originalValue); 9721 }; 9722 } 9723 function applyElementStyles(element, styles) { 9724 const restorers = []; 9725 for (const [key, value] of Object.entries(styles)) { 9726 restorers.push(overrideElementStyle(element, key, value)); 9727 } 9728 return restorers.length ? () => { 9729 restorers.forEach((restore) => restore()); 9730 } : NOOP; 9731 } 9732 function setPopupCssSize(popupElement, size4) { 9733 const width = size4 === "auto" ? "auto" : `$size4.width}px`; 9734 const height = size4 === "auto" ? "auto" : `$size4.height}px`; 9735 popupElement.style.setProperty("--popup-width", width); 9736 popupElement.style.setProperty("--popup-height", height); 9737 } 9738 function setPositionerCssSize(positionerElement, size4) { 9739 const width = size4 === "max-content" ? "max-content" : `$size4.width}px`; 9740 const height = size4 === "max-content" ? "max-content" : `$size4.height}px`; 9741 positionerElement.style.setProperty("--positioner-width", width); 9742 positionerElement.style.setProperty("--positioner-height", height); 9743 } 9744 9745 // node_modules/@base-ui/react/utils/usePopupViewport.mjs 9746 var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1); 9747 function usePopupViewport(parameters) { 9748 const { 9749 store: store2, 9750 side, 9751 cssVars, 9752 children 9753 } = parameters; 9754 const direction = useDirection(); 9755 const activeTrigger = store2.useState("activeTriggerElement"); 9756 const activeTriggerId = store2.useState("activeTriggerId"); 9757 const open = store2.useState("open"); 9758 const payload = store2.useState("payload"); 9759 const mounted = store2.useState("mounted"); 9760 const popupElement = store2.useState("popupElement"); 9761 const positionerElement = store2.useState("positionerElement"); 9762 const previousActiveTrigger = usePreviousValue(open ? activeTrigger : null); 9763 const currentContentKey = usePopupContentKey(activeTriggerId, payload); 9764 const capturedNodeRef = React42.useRef(null); 9765 const [previousContentNode, setPreviousContentNode] = React42.useState(null); 9766 const [newTriggerOffset, setNewTriggerOffset] = React42.useState(null); 9767 const currentContainerRef = React42.useRef(null); 9768 const previousContainerRef = React42.useRef(null); 9769 const onAnimationsFinished = useAnimationsFinished(currentContainerRef, true, false); 9770 const cleanupFrame = useAnimationFrame(); 9771 const [previousContentDimensions, setPreviousContentDimensions] = React42.useState(null); 9772 const [showStartingStyleAttribute, setShowStartingStyleAttribute] = React42.useState(false); 9773 useIsoLayoutEffect(() => { 9774 store2.set("hasViewport", true); 9775 return () => { 9776 store2.set("hasViewport", false); 9777 }; 9778 }, [store2]); 9779 const handleMeasureLayout = useStableCallback(() => { 9780 currentContainerRef.current?.style.setProperty("animation", "none"); 9781 currentContainerRef.current?.style.setProperty("transition", "none"); 9782 previousContainerRef.current?.style.setProperty("display", "none"); 9783 }); 9784 const handleMeasureLayoutComplete = useStableCallback((previousDimensions) => { 9785 currentContainerRef.current?.style.removeProperty("animation"); 9786 currentContainerRef.current?.style.removeProperty("transition"); 9787 previousContainerRef.current?.style.removeProperty("display"); 9788 if (previousDimensions) { 9789 setPreviousContentDimensions(previousDimensions); 9790 } 9791 }); 9792 const lastHandledTriggerRef = React42.useRef(null); 9793 useIsoLayoutEffect(() => { 9794 if (!open || !mounted) { 9795 lastHandledTriggerRef.current = null; 9796 } 9797 }, [open, mounted]); 9798 useIsoLayoutEffect(() => { 9799 if (activeTrigger && previousActiveTrigger && activeTrigger !== previousActiveTrigger && lastHandledTriggerRef.current !== activeTrigger && capturedNodeRef.current) { 9800 setPreviousContentNode(capturedNodeRef.current); 9801 setShowStartingStyleAttribute(true); 9802 const offset4 = calculateRelativePosition(previousActiveTrigger, activeTrigger); 9803 setNewTriggerOffset(offset4); 9804 cleanupFrame.request(() => { 9805 ReactDOM6.flushSync(() => { 9806 setShowStartingStyleAttribute(false); 9807 }); 9808 onAnimationsFinished(() => { 9809 setPreviousContentNode(null); 9810 setPreviousContentDimensions(null); 9811 capturedNodeRef.current = null; 9812 }); 9813 }); 9814 lastHandledTriggerRef.current = activeTrigger; 9815 } 9816 }, [activeTrigger, previousActiveTrigger, previousContentNode, onAnimationsFinished, cleanupFrame]); 9817 useIsoLayoutEffect(() => { 9818 const source = currentContainerRef.current; 9819 if (!source) { 9820 return; 9821 } 9822 const wrapper = ownerDocument(source).createElement("div"); 9823 for (const child of Array.from(source.childNodes)) { 9824 wrapper.appendChild(child.cloneNode(true)); 9825 } 9826 capturedNodeRef.current = wrapper; 9827 }); 9828 const isTransitioning = previousContentNode != null; 9829 let childrenToRender; 9830 if (!isTransitioning) { 9831 childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { 9832 "data-current": true, 9833 ref: currentContainerRef, 9834 children 9835 }, currentContentKey); 9836 } else { 9837 childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(React42.Fragment, { 9838 children: [/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { 9839 "data-previous": true, 9840 inert: inertValue(true), 9841 ref: previousContainerRef, 9842 style: { 9843 ...previousContentDimensions ? { 9844 [cssVars.popupWidth]: `$previousContentDimensions.width}px`, 9845 [cssVars.popupHeight]: `$previousContentDimensions.height}px` 9846 } : null, 9847 position: "absolute" 9848 }, 9849 "data-ending-style": showStartingStyleAttribute ? void 0 : "" 9850 }, "previous"), /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { 9851 "data-current": true, 9852 ref: currentContainerRef, 9853 "data-starting-style": showStartingStyleAttribute ? "" : void 0, 9854 children 9855 }, currentContentKey)] 9856 }); 9857 } 9858 useIsoLayoutEffect(() => { 9859 const container = previousContainerRef.current; 9860 if (!container || !previousContentNode) { 9861 return; 9862 } 9863 container.replaceChildren(...Array.from(previousContentNode.childNodes)); 9864 }, [previousContentNode]); 9865 usePopupAutoResize({ 9866 popupElement, 9867 positionerElement, 9868 mounted, 9869 content: payload, 9870 onMeasureLayout: handleMeasureLayout, 9871 onMeasureLayoutComplete: handleMeasureLayoutComplete, 9872 side, 9873 direction 9874 }); 9875 const state = { 9876 activationDirection: getActivationDirection(newTriggerOffset), 9877 transitioning: isTransitioning 9878 }; 9879 return { 9880 children: childrenToRender, 9881 state 9882 }; 9883 } 9884 function getActivationDirection(offset4) { 9885 if (!offset4) { 9886 return void 0; 9887 } 9888 return `$getValueWithTolerance(offset4.horizontal, 5, "right", "left")} $getValueWithTolerance(offset4.vertical, 5, "down", "up")}`; 9889 } 9890 function getValueWithTolerance(value, tolerance, positiveLabel, negativeLabel) { 9891 if (value > tolerance) { 9892 return positiveLabel; 9893 } 9894 if (value < -tolerance) { 9895 return negativeLabel; 9896 } 9897 return ""; 9898 } 9899 function calculateRelativePosition(from, to2) { 9900 const fromRect = from.getBoundingClientRect(); 9901 const toRect = to2.getBoundingClientRect(); 9902 const fromCenter = { 9903 x: fromRect.left + fromRect.width / 2, 9904 y: fromRect.top + fromRect.height / 2 9905 }; 9906 const toCenter = { 9907 x: toRect.left + toRect.width / 2, 9908 y: toRect.top + toRect.height / 2 9909 }; 9910 return { 9911 horizontal: toCenter.x - fromCenter.x, 9912 vertical: toCenter.y - fromCenter.y 9913 }; 9914 } 9915 function usePopupContentKey(activeTriggerId, payload) { 9916 const [contentKey, setContentKey] = React42.useState(0); 9917 const previousActiveTriggerIdRef = React42.useRef(activeTriggerId); 9918 const previousPayloadRef = React42.useRef(payload); 9919 const pendingPayloadUpdateRef = React42.useRef(false); 9920 useIsoLayoutEffect(() => { 9921 const previousActiveTriggerId = previousActiveTriggerIdRef.current; 9922 const previousPayload = previousPayloadRef.current; 9923 const triggerIdChanged = activeTriggerId !== previousActiveTriggerId; 9924 const payloadChanged = payload !== previousPayload; 9925 if (triggerIdChanged) { 9926 setContentKey((value) => value + 1); 9927 pendingPayloadUpdateRef.current = !payloadChanged; 9928 } else if (pendingPayloadUpdateRef.current && payloadChanged) { 9929 setContentKey((value) => value + 1); 9930 pendingPayloadUpdateRef.current = false; 9931 } 9932 previousActiveTriggerIdRef.current = activeTriggerId; 9933 previousPayloadRef.current = payload; 9934 }, [activeTriggerId, payload]); 9935 return `$activeTriggerId ?? "current"}-$contentKey}`; 9936 } 9937 9938 // node_modules/@base-ui/react/utils/FloatingPortalLite.mjs 9939 var React43 = __toESM(require_react(), 1); 9940 var ReactDOM7 = __toESM(require_react_dom(), 1); 9941 var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1); 9942 var FloatingPortalLite = /* @__PURE__ */ React43.forwardRef(function FloatingPortalLite2(componentProps, forwardedRef) { 9943 const { 9944 children, 9945 container, 9946 className, 9947 render: render4, 9948 style, 9949 ...elementProps 9950 } = componentProps; 9951 const { 9952 portalNode, 9953 portalSubtree 9954 } = useFloatingPortalNode({ 9955 container, 9956 ref: forwardedRef, 9957 componentProps, 9958 elementProps 9959 }); 9960 if (!portalSubtree && !portalNode) { 9961 return null; 9962 } 9963 return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(React43.Fragment, { 9964 children: [portalSubtree, portalNode && /* @__PURE__ */ ReactDOM7.createPortal(children, portalNode)] 9965 }); 9966 }); 9967 if (true) FloatingPortalLite.displayName = "FloatingPortalLite"; 9968 9969 // node_modules/@base-ui/react/tooltip/index.parts.mjs 9970 var index_parts_exports2 = {}; 9971 __export(index_parts_exports2, { 9972 Arrow: () => TooltipArrow, 9973 Handle: () => TooltipHandle, 9974 Popup: () => TooltipPopup, 9975 Portal: () => TooltipPortal, 9976 Positioner: () => TooltipPositioner, 9977 Provider: () => TooltipProvider, 9978 Root: () => TooltipRoot, 9979 Trigger: () => TooltipTrigger, 9980 Viewport: () => TooltipViewport, 9981 createHandle: () => createTooltipHandle 9982 }); 9983 9984 // node_modules/@base-ui/react/tooltip/root/TooltipRoot.mjs 9985 var React46 = __toESM(require_react(), 1); 9986 9987 // node_modules/@base-ui/react/tooltip/root/TooltipRootContext.mjs 9988 var React44 = __toESM(require_react(), 1); 9989 var TooltipRootContext = /* @__PURE__ */ React44.createContext(void 0); 9990 if (true) TooltipRootContext.displayName = "TooltipRootContext"; 9991 function useTooltipRootContext(optional) { 9992 const context = React44.useContext(TooltipRootContext); 9993 if (context === void 0 && !optional) { 9994 throw new Error(true ? "Base UI: TooltipRootContext is missing. Tooltip parts must be placed within <Tooltip.Root>." : formatErrorMessage_default(72)); 9995 } 9996 return context; 9997 } 9998 9999 // node_modules/@base-ui/react/tooltip/store/TooltipStore.mjs 10000 var React45 = __toESM(require_react(), 1); 10001 var selectors2 = { 10002 ...popupStoreSelectors, 10003 disabled: createSelector2((state) => state.disabled), 10004 instantType: createSelector2((state) => state.instantType), 10005 isInstantPhase: createSelector2((state) => state.isInstantPhase), 10006 trackCursorAxis: createSelector2((state) => state.trackCursorAxis), 10007 disableHoverablePopup: createSelector2((state) => state.disableHoverablePopup), 10008 lastOpenChangeReason: createSelector2((state) => state.openChangeReason), 10009 closeOnClick: createSelector2((state) => state.closeOnClick), 10010 closeDelay: createSelector2((state) => state.closeDelay), 10011 hasViewport: createSelector2((state) => state.hasViewport) 10012 }; 10013 var TooltipStore = class _TooltipStore extends ReactStore { 10014 constructor(initialState, floatingId, nested = false) { 10015 const triggerElements = new PopupTriggerMap(); 10016 const state = { 10017 ...createInitialState(), 10018 ...initialState 10019 }; 10020 state.floatingRootContext = createPopupFloatingRootContext(triggerElements, floatingId, nested); 10021 super(state, { 10022 popupRef: /* @__PURE__ */ React45.createRef(), 10023 onOpenChange: void 0, 10024 onOpenChangeComplete: void 0, 10025 triggerElements 10026 }, selectors2); 10027 } 10028 setOpen = (nextOpen, eventDetails) => { 10029 applyPopupOpenChange(this, nextOpen, eventDetails, { 10030 extraState: { 10031 openChangeReason: eventDetails.reason 10032 } 10033 }); 10034 }; 10035 // Used by trigger clicks to clear a delayed hover open without reporting a public open-state change. 10036 cancelPendingOpen(event) { 10037 this.state.floatingRootContext.dispatchOpenChange(false, createChangeEventDetails(reason_parts_exports.triggerPress, event)); 10038 } 10039 static useStore(externalStore, initialState) { 10040 const store2 = usePopupStore(externalStore, (floatingId, nested) => new _TooltipStore(initialState, floatingId, nested)).store; 10041 return store2; 10042 } 10043 }; 10044 function createInitialState() { 10045 return { 10046 ...createInitialPopupStoreState(), 10047 disabled: false, 10048 instantType: void 0, 10049 isInstantPhase: false, 10050 trackCursorAxis: "none", 10051 disableHoverablePopup: false, 10052 openChangeReason: null, 10053 closeOnClick: true, 10054 closeDelay: 0, 10055 hasViewport: false 10056 }; 10057 } 10058 10059 // node_modules/@base-ui/react/tooltip/root/TooltipRoot.mjs 10060 var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1); 10061 var TooltipRoot = fastComponent(function TooltipRoot2(props) { 10062 const { 10063 disabled: disabled2 = false, 10064 defaultOpen = false, 10065 open: openProp, 10066 disableHoverablePopup = false, 10067 trackCursorAxis = "none", 10068 actionsRef, 10069 onOpenChange, 10070 onOpenChangeComplete, 10071 handle, 10072 triggerId: triggerIdProp, 10073 defaultTriggerId: defaultTriggerIdProp = null, 10074 children 10075 } = props; 10076 const store2 = TooltipStore.useStore(handle?.store, { 10077 open: defaultOpen, 10078 openProp, 10079 activeTriggerId: defaultTriggerIdProp, 10080 triggerIdProp 10081 }); 10082 useInitialOpenSync(store2, openProp, defaultOpen, defaultTriggerIdProp); 10083 store2.useControlledProp("openProp", openProp); 10084 store2.useControlledProp("triggerIdProp", triggerIdProp); 10085 store2.useContextCallback("onOpenChange", onOpenChange); 10086 store2.useContextCallback("onOpenChangeComplete", onOpenChangeComplete); 10087 const openState = store2.useState("open"); 10088 const open = !disabled2 && openState; 10089 const activeTriggerId = store2.useState("activeTriggerId"); 10090 const mounted = store2.useState("mounted"); 10091 const payload = store2.useState("payload"); 10092 store2.useSyncedValues({ 10093 trackCursorAxis, 10094 disableHoverablePopup 10095 }); 10096 store2.useSyncedValue("disabled", disabled2); 10097 useImplicitActiveTrigger(store2, { 10098 closeOnActiveTriggerUnmount: true 10099 }); 10100 const { 10101 forceUnmount, 10102 transitionStatus 10103 } = useOpenStateTransitions(open, store2); 10104 const isInstantPhase = store2.useState("isInstantPhase"); 10105 const instantType = store2.useState("instantType"); 10106 const lastOpenChangeReason = store2.useState("lastOpenChangeReason"); 10107 const previousInstantTypeRef = React46.useRef(null); 10108 useIsoLayoutEffect(() => { 10109 if (openState && disabled2) { 10110 store2.setOpen(false, createChangeEventDetails(reason_parts_exports.disabled)); 10111 } 10112 }, [openState, disabled2, store2]); 10113 useIsoLayoutEffect(() => { 10114 if (transitionStatus === "ending" && lastOpenChangeReason === reason_parts_exports.none || transitionStatus !== "ending" && isInstantPhase) { 10115 if (instantType !== "delay") { 10116 previousInstantTypeRef.current = instantType; 10117 } 10118 store2.set("instantType", "delay"); 10119 } else if (previousInstantTypeRef.current !== null) { 10120 store2.set("instantType", previousInstantTypeRef.current); 10121 previousInstantTypeRef.current = null; 10122 } 10123 }, [transitionStatus, isInstantPhase, lastOpenChangeReason, instantType, store2]); 10124 useIsoLayoutEffect(() => { 10125 if (open) { 10126 if (activeTriggerId == null) { 10127 store2.set("payload", void 0); 10128 } 10129 } 10130 }, [store2, activeTriggerId, open]); 10131 const handleImperativeClose = React46.useCallback(() => { 10132 store2.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction)); 10133 }, [store2]); 10134 React46.useImperativeHandle(actionsRef, () => ({ 10135 unmount: forceUnmount, 10136 close: handleImperativeClose 10137 }), [forceUnmount, handleImperativeClose]); 10138 const shouldRenderInteractions = open || mounted || !disabled2 && trackCursorAxis !== "none"; 10139 return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(TooltipRootContext.Provider, { 10140 value: store2, 10141 children: [shouldRenderInteractions && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(TooltipInteractions, { 10142 store: store2, 10143 disabled: disabled2, 10144 trackCursorAxis 10145 }), typeof children === "function" ? children({ 10146 payload 10147 }) : children] 10148 }); 10149 }); 10150 if (true) TooltipRoot.displayName = "TooltipRoot"; 10151 function TooltipInteractions({ 10152 store: store2, 10153 disabled: disabled2, 10154 trackCursorAxis 10155 }) { 10156 const floatingRootContext = store2.useState("floatingRootContext"); 10157 const dismiss = useDismiss(floatingRootContext, { 10158 enabled: !disabled2, 10159 referencePress: () => store2.select("closeOnClick") 10160 }); 10161 const clientPoint = useClientPoint(floatingRootContext, { 10162 enabled: !disabled2 && trackCursorAxis !== "none", 10163 axis: trackCursorAxis === "none" ? void 0 : trackCursorAxis 10164 }); 10165 const activeTriggerProps = React46.useMemo(() => mergeProps(clientPoint.reference, dismiss.reference), [clientPoint.reference, dismiss.reference]); 10166 const inactiveTriggerProps = React46.useMemo(() => mergeProps(clientPoint.trigger, dismiss.trigger), [clientPoint.trigger, dismiss.trigger]); 10167 const popupProps = React46.useMemo(() => mergeProps(FOCUSABLE_POPUP_PROPS, clientPoint.floating, dismiss.floating), [clientPoint.floating, dismiss.floating]); 10168 usePopupInteractionProps(store2, { 10169 activeTriggerProps, 10170 inactiveTriggerProps, 10171 popupProps 10172 }); 10173 return null; 10174 } 10175 10176 // node_modules/@base-ui/react/tooltip/trigger/TooltipTrigger.mjs 10177 var React48 = __toESM(require_react(), 1); 10178 10179 // node_modules/@base-ui/react/tooltip/provider/TooltipProviderContext.mjs 10180 var React47 = __toESM(require_react(), 1); 10181 var TooltipProviderContext = /* @__PURE__ */ React47.createContext(void 0); 10182 if (true) TooltipProviderContext.displayName = "TooltipProviderContext"; 10183 function useTooltipProviderContext() { 10184 return React47.useContext(TooltipProviderContext); 10185 } 10186 10187 // node_modules/@base-ui/react/tooltip/trigger/TooltipTriggerDataAttributes.mjs 10188 var TooltipTriggerDataAttributes = (function(TooltipTriggerDataAttributes2) { 10189 TooltipTriggerDataAttributes2[TooltipTriggerDataAttributes2["popupOpen"] = CommonTriggerDataAttributes.popupOpen] = "popupOpen"; 10190 TooltipTriggerDataAttributes2["triggerDisabled"] = "data-trigger-disabled"; 10191 return TooltipTriggerDataAttributes2; 10192 })({}); 10193 10194 // node_modules/@base-ui/react/tooltip/utils/constants.mjs 10195 var OPEN_DELAY = 600; 10196 10197 // node_modules/@base-ui/react/tooltip/trigger/TooltipTrigger.mjs 10198 var TOOLTIP_TRIGGER_IDENTIFIER = "data-base-ui-tooltip-trigger"; 10199 function getTargetElement(event) { 10200 if ("composedPath" in event) { 10201 const path = event.composedPath(); 10202 for (let i2 = 0; i2 < path.length; i2 += 1) { 10203 const element = path[i2]; 10204 if (isElement(element)) { 10205 return element; 10206 } 10207 } 10208 } 10209 const target = event.target; 10210 if (isElement(target)) { 10211 return target; 10212 } 10213 return null; 10214 } 10215 function closestEnabledTooltipTrigger(element) { 10216 let current = element; 10217 while (current) { 10218 if (current.hasAttribute(TOOLTIP_TRIGGER_IDENTIFIER)) { 10219 return current; 10220 } 10221 const parentElement = current.parentElement; 10222 if (parentElement) { 10223 current = parentElement; 10224 continue; 10225 } 10226 const root = current.getRootNode(); 10227 current = "host" in root && isElement(root.host) ? root.host : null; 10228 } 10229 return null; 10230 } 10231 var TooltipTrigger = fastComponentRef(function TooltipTrigger2(componentProps, forwardedRef) { 10232 const { 10233 render: render4, 10234 className, 10235 style, 10236 handle, 10237 payload, 10238 disabled: disabledProp, 10239 delay, 10240 closeOnClick = true, 10241 closeDelay, 10242 id: idProp, 10243 ...elementProps 10244 } = componentProps; 10245 const rootContext = useTooltipRootContext(true); 10246 const store2 = handle?.store ?? rootContext; 10247 if (!store2) { 10248 throw new Error(true ? "Base UI: <Tooltip.Trigger> must be either used within a <Tooltip.Root> component or provided with a handle." : formatErrorMessage_default(82)); 10249 } 10250 const thisTriggerId = useBaseUiId(idProp); 10251 const isTriggerActive = store2.useState("isTriggerActive", thisTriggerId); 10252 const isOpenedByThisTrigger = store2.useState("isOpenedByTrigger", thisTriggerId); 10253 const floatingRootContext = store2.useState("floatingRootContext"); 10254 const triggerElementRef = React48.useRef(null); 10255 const delayWithDefault = delay ?? OPEN_DELAY; 10256 const closeDelayWithDefault = closeDelay ?? 0; 10257 const { 10258 registerTrigger, 10259 isMountedByThisTrigger 10260 } = useTriggerDataForwarding(thisTriggerId, triggerElementRef, store2, { 10261 payload, 10262 closeOnClick, 10263 closeDelay: closeDelayWithDefault 10264 }); 10265 const providerContext = useTooltipProviderContext(); 10266 const { 10267 delayRef, 10268 isInstantPhase, 10269 hasProvider 10270 } = useDelayGroup(floatingRootContext, { 10271 open: isOpenedByThisTrigger 10272 }); 10273 const hoverInteraction = useHoverInteractionSharedState(floatingRootContext); 10274 store2.useSyncedValue("isInstantPhase", isInstantPhase); 10275 const rootDisabled = store2.useState("disabled"); 10276 const disabled2 = disabledProp ?? rootDisabled; 10277 const disabledRef = useValueAsRef(disabled2); 10278 const trackCursorAxis = store2.useState("trackCursorAxis"); 10279 const disableHoverablePopup = store2.useState("disableHoverablePopup"); 10280 const isNestedTriggerHoveredRef = React48.useRef(false); 10281 const nestedTriggerOpenTimeout = useTimeout(); 10282 const pointerTypeRef = React48.useRef(void 0); 10283 function getOpenDelay() { 10284 const providerDelay = providerContext?.delay; 10285 const groupOpenValue = typeof delayRef.current === "object" ? delayRef.current.open : void 0; 10286 let computedOpenDelay = delayWithDefault; 10287 if (hasProvider) { 10288 if (groupOpenValue !== 0) { 10289 computedOpenDelay = delay ?? providerDelay ?? delayWithDefault; 10290 } else { 10291 computedOpenDelay = 0; 10292 } 10293 } 10294 return computedOpenDelay; 10295 } 10296 function isEnabledNestedTriggerTarget(target) { 10297 const triggerEl = triggerElementRef.current; 10298 if (!triggerEl || !target) { 10299 return false; 10300 } 10301 const nearestTrigger = closestEnabledTooltipTrigger(target); 10302 return nearestTrigger !== null && nearestTrigger !== triggerEl && contains(triggerEl, nearestTrigger); 10303 } 10304 function detectNestedTriggerHover(target) { 10305 const nestedTriggerHovered = isEnabledNestedTriggerTarget(target); 10306 isNestedTriggerHoveredRef.current = nestedTriggerHovered; 10307 if (nestedTriggerHovered) { 10308 hoverInteraction.openChangeTimeout.clear(); 10309 hoverInteraction.restTimeout.clear(); 10310 hoverInteraction.restTimeoutPending = false; 10311 nestedTriggerOpenTimeout.clear(); 10312 } 10313 return nestedTriggerHovered; 10314 } 10315 const hoverProps = useHoverReferenceInteraction(floatingRootContext, { 10316 enabled: !disabled2, 10317 mouseOnly: true, 10318 move: false, 10319 handleClose: !disableHoverablePopup && trackCursorAxis !== "both" ? safePolygon() : null, 10320 restMs: getOpenDelay, 10321 delay() { 10322 const closeValue = typeof delayRef.current === "object" ? delayRef.current.close : void 0; 10323 let computedCloseDelay = closeDelayWithDefault; 10324 if (closeDelay == null && hasProvider) { 10325 computedCloseDelay = closeValue; 10326 } 10327 return { 10328 close: computedCloseDelay 10329 }; 10330 }, 10331 triggerElementRef, 10332 isActiveTrigger: isTriggerActive, 10333 isClosing: () => store2.select("transitionStatus") === "ending", 10334 shouldOpen() { 10335 return !isNestedTriggerHoveredRef.current; 10336 } 10337 }); 10338 const focusProps = useFocus(floatingRootContext, { 10339 enabled: !disabled2 10340 }).reference; 10341 const handleNestedTriggerHover = (event) => { 10342 const wasNestedTriggerHovered = isNestedTriggerHoveredRef.current; 10343 const target = getTargetElement(event); 10344 const nestedTriggerHovered = detectNestedTriggerHover(target); 10345 const triggerEl = triggerElementRef.current; 10346 const targetInsideTrigger = triggerEl && target && contains(triggerEl, target); 10347 if (nestedTriggerHovered && store2.select("open") && store2.select("lastOpenChangeReason") === reason_parts_exports.triggerHover) { 10348 store2.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event)); 10349 return; 10350 } 10351 if (wasNestedTriggerHovered && !nestedTriggerHovered && targetInsideTrigger && !disabledRef.current && !store2.select("open") && triggerEl && // Match the hover hook's non-strict mouse fallback for mouse-only event sequences. 10352 isMouseLikePointerType(pointerTypeRef.current)) { 10353 const open = () => { 10354 if (!isNestedTriggerHoveredRef.current && !disabledRef.current && !store2.select("open")) { 10355 store2.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerEl)); 10356 } 10357 }; 10358 const openDelay = getOpenDelay(); 10359 if (openDelay === 0) { 10360 nestedTriggerOpenTimeout.clear(); 10361 open(); 10362 } else { 10363 nestedTriggerOpenTimeout.start(openDelay, open); 10364 } 10365 } 10366 }; 10367 const rootTriggerProps = store2.useState("triggerProps", isMountedByThisTrigger); 10368 const shouldApplyRootTriggerProps = isMountedByThisTrigger || trackCursorAxis !== "none"; 10369 const state = { 10370 open: isOpenedByThisTrigger 10371 }; 10372 const element = useRenderElement("button", componentProps, { 10373 state, 10374 ref: [forwardedRef, registerTrigger, triggerElementRef], 10375 props: [hoverProps, focusProps, shouldApplyRootTriggerProps ? rootTriggerProps : void 0, { 10376 onMouseOver(event) { 10377 handleNestedTriggerHover(event.nativeEvent); 10378 }, 10379 onFocus(event) { 10380 if (isEnabledNestedTriggerTarget(getTargetElement(event.nativeEvent))) { 10381 event.preventBaseUIHandler(); 10382 } 10383 }, 10384 onMouseLeave() { 10385 isNestedTriggerHoveredRef.current = false; 10386 nestedTriggerOpenTimeout.clear(); 10387 pointerTypeRef.current = void 0; 10388 }, 10389 onPointerEnter(event) { 10390 pointerTypeRef.current = event.pointerType; 10391 }, 10392 onPointerDown(event) { 10393 pointerTypeRef.current = event.pointerType; 10394 store2.set("closeOnClick", closeOnClick); 10395 if (closeOnClick && !store2.select("open")) { 10396 store2.cancelPendingOpen(event.nativeEvent); 10397 } 10398 }, 10399 onClick(event) { 10400 if (closeOnClick && !store2.select("open")) { 10401 store2.cancelPendingOpen(event.nativeEvent); 10402 } 10403 }, 10404 id: thisTriggerId, 10405 [TooltipTriggerDataAttributes.triggerDisabled]: disabled2 ? "" : void 0, 10406 [TOOLTIP_TRIGGER_IDENTIFIER]: disabled2 ? void 0 : "" 10407 }, elementProps], 10408 stateAttributesMapping: triggerOpenStateMapping2 10409 }); 10410 return element; 10411 }); 10412 if (true) TooltipTrigger.displayName = "TooltipTrigger"; 10413 10414 // node_modules/@base-ui/react/tooltip/portal/TooltipPortal.mjs 10415 var React50 = __toESM(require_react(), 1); 10416 10417 // node_modules/@base-ui/react/tooltip/portal/TooltipPortalContext.mjs 10418 var React49 = __toESM(require_react(), 1); 10419 var TooltipPortalContext = /* @__PURE__ */ React49.createContext(void 0); 10420 if (true) TooltipPortalContext.displayName = "TooltipPortalContext"; 10421 function useTooltipPortalContext() { 10422 const value = React49.useContext(TooltipPortalContext); 10423 if (value === void 0) { 10424 throw new Error(true ? "Base UI: <Tooltip.Portal> is missing." : formatErrorMessage_default(70)); 10425 } 10426 return value; 10427 } 10428 10429 // node_modules/@base-ui/react/tooltip/portal/TooltipPortal.mjs 10430 var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1); 10431 var TooltipPortal = /* @__PURE__ */ React50.forwardRef(function TooltipPortal2(props, forwardedRef) { 10432 const { 10433 keepMounted = false, 10434 ...portalProps 10435 } = props; 10436 const store2 = useTooltipRootContext(); 10437 const mounted = store2.useState("mounted"); 10438 const shouldRender = mounted || keepMounted; 10439 if (!shouldRender) { 10440 return null; 10441 } 10442 return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(TooltipPortalContext.Provider, { 10443 value: keepMounted, 10444 children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(FloatingPortalLite, { 10445 ref: forwardedRef, 10446 ...portalProps 10447 }) 10448 }); 10449 }); 10450 if (true) TooltipPortal.displayName = "TooltipPortal"; 10451 10452 // node_modules/@base-ui/react/tooltip/positioner/TooltipPositioner.mjs 10453 var React52 = __toESM(require_react(), 1); 10454 10455 // node_modules/@base-ui/react/tooltip/positioner/TooltipPositionerContext.mjs 10456 var React51 = __toESM(require_react(), 1); 10457 var TooltipPositionerContext = /* @__PURE__ */ React51.createContext(void 0); 10458 if (true) TooltipPositionerContext.displayName = "TooltipPositionerContext"; 10459 function useTooltipPositionerContext() { 10460 const context = React51.useContext(TooltipPositionerContext); 10461 if (context === void 0) { 10462 throw new Error(true ? "Base UI: TooltipPositionerContext is missing. TooltipPositioner parts must be placed within <Tooltip.Positioner>." : formatErrorMessage_default(71)); 10463 } 10464 return context; 10465 } 10466 10467 // node_modules/@base-ui/react/tooltip/positioner/TooltipPositioner.mjs 10468 var import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1); 10469 var TooltipPositioner = /* @__PURE__ */ React52.forwardRef(function TooltipPositioner2(componentProps, forwardedRef) { 10470 const { 10471 render: render4, 10472 className, 10473 anchor, 10474 positionMethod = "absolute", 10475 side = "top", 10476 align = "center", 10477 sideOffset = 0, 10478 alignOffset = 0, 10479 collisionBoundary = "clipping-ancestors", 10480 collisionPadding = 5, 10481 arrowPadding = 5, 10482 sticky = false, 10483 disableAnchorTracking = false, 10484 collisionAvoidance = POPUP_COLLISION_AVOIDANCE, 10485 style, 10486 ...elementProps 10487 } = componentProps; 10488 const store2 = useTooltipRootContext(); 10489 const keepMounted = useTooltipPortalContext(); 10490 const open = store2.useState("open"); 10491 const mounted = store2.useState("mounted"); 10492 const trackCursorAxis = store2.useState("trackCursorAxis"); 10493 const disableHoverablePopup = store2.useState("disableHoverablePopup"); 10494 const floatingRootContext = store2.useState("floatingRootContext"); 10495 const instantType = store2.useState("instantType"); 10496 const transitionStatus = store2.useState("transitionStatus"); 10497 const hasViewport = store2.useState("hasViewport"); 10498 const positioning = useAnchorPositioning({ 10499 anchor, 10500 positionMethod, 10501 floatingRootContext, 10502 mounted, 10503 side, 10504 sideOffset, 10505 align, 10506 alignOffset, 10507 collisionBoundary, 10508 collisionPadding, 10509 sticky, 10510 arrowPadding, 10511 disableAnchorTracking, 10512 keepMounted, 10513 collisionAvoidance, 10514 adaptiveOrigin: hasViewport ? adaptiveOrigin : void 0 10515 }); 10516 const state = React52.useMemo(() => ({ 10517 open, 10518 side: positioning.side, 10519 align: positioning.align, 10520 anchorHidden: positioning.anchorHidden, 10521 instant: trackCursorAxis !== "none" ? "tracking-cursor" : instantType 10522 }), [open, positioning.side, positioning.align, positioning.anchorHidden, trackCursorAxis, instantType]); 10523 const element = usePositioner(componentProps, state, { 10524 styles: positioning.positionerStyles, 10525 transitionStatus, 10526 props: elementProps, 10527 refs: [forwardedRef, store2.useStateSetter("positionerElement")], 10528 hidden: !mounted, 10529 inert: !open || trackCursorAxis === "both" || disableHoverablePopup 10530 }); 10531 return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(TooltipPositionerContext.Provider, { 10532 value: positioning, 10533 children: element 10534 }); 10535 }); 10536 if (true) TooltipPositioner.displayName = "TooltipPositioner"; 10537 10538 // node_modules/@base-ui/react/tooltip/popup/TooltipPopup.mjs 10539 var React53 = __toESM(require_react(), 1); 10540 var stateAttributesMapping2 = { 10541 ...popupStateMapping, 10542 ...transitionStatusMapping 10543 }; 10544 var TooltipPopup = /* @__PURE__ */ React53.forwardRef(function TooltipPopup2(componentProps, forwardedRef) { 10545 const { 10546 render: render4, 10547 className, 10548 style, 10549 ...elementProps 10550 } = componentProps; 10551 const store2 = useTooltipRootContext(); 10552 const { 10553 side, 10554 align 10555 } = useTooltipPositionerContext(); 10556 const open = store2.useState("open"); 10557 const instantType = store2.useState("instantType"); 10558 const transitionStatus = store2.useState("transitionStatus"); 10559 const popupProps = store2.useState("popupProps"); 10560 const floatingContext = store2.useState("floatingRootContext"); 10561 const disabled2 = store2.useState("disabled"); 10562 const closeDelay = store2.useState("closeDelay"); 10563 useOpenChangeComplete({ 10564 open, 10565 ref: store2.context.popupRef, 10566 onComplete() { 10567 if (open) { 10568 store2.context.onOpenChangeComplete?.(true); 10569 } 10570 } 10571 }); 10572 useHoverFloatingInteraction(floatingContext, { 10573 enabled: !disabled2, 10574 closeDelay 10575 }); 10576 const setPopupElement = store2.useStateSetter("popupElement"); 10577 const state = { 10578 open, 10579 side, 10580 align, 10581 instant: instantType, 10582 transitionStatus 10583 }; 10584 const element = useRenderElement("div", componentProps, { 10585 state, 10586 ref: [forwardedRef, store2.context.popupRef, setPopupElement], 10587 props: [popupProps, getDisabledMountTransitionStyles(transitionStatus), elementProps], 10588 stateAttributesMapping: stateAttributesMapping2 10589 }); 10590 return element; 10591 }); 10592 if (true) TooltipPopup.displayName = "TooltipPopup"; 10593 10594 // node_modules/@base-ui/react/tooltip/arrow/TooltipArrow.mjs 10595 var React54 = __toESM(require_react(), 1); 10596 var TooltipArrow = /* @__PURE__ */ React54.forwardRef(function TooltipArrow2(componentProps, forwardedRef) { 10597 const { 10598 render: render4, 10599 className, 10600 style, 10601 ...elementProps 10602 } = componentProps; 10603 const store2 = useTooltipRootContext(); 10604 const { 10605 arrowRef, 10606 side, 10607 align, 10608 arrowUncentered, 10609 arrowStyles 10610 } = useTooltipPositionerContext(); 10611 const open = store2.useState("open"); 10612 const instantType = store2.useState("instantType"); 10613 const state = { 10614 open, 10615 side, 10616 align, 10617 uncentered: arrowUncentered, 10618 instant: instantType 10619 }; 10620 const element = useRenderElement("div", componentProps, { 10621 state, 10622 ref: [forwardedRef, arrowRef], 10623 props: [{ 10624 style: arrowStyles, 10625 "aria-hidden": true 10626 }, elementProps], 10627 stateAttributesMapping: popupStateMapping 10628 }); 10629 return element; 10630 }); 10631 if (true) TooltipArrow.displayName = "TooltipArrow"; 10632 10633 // node_modules/@base-ui/react/tooltip/provider/TooltipProvider.mjs 10634 var React55 = __toESM(require_react(), 1); 10635 var import_jsx_runtime11 = __toESM(require_jsx_runtime(), 1); 10636 var TooltipProvider = function TooltipProvider2(props) { 10637 const { 10638 delay, 10639 closeDelay, 10640 timeout = 400 10641 } = props; 10642 const contextValue = React55.useMemo(() => ({ 10643 delay, 10644 closeDelay 10645 }), [delay, closeDelay]); 10646 const delayValue = React55.useMemo(() => ({ 10647 open: delay, 10648 close: closeDelay 10649 }), [delay, closeDelay]); 10650 return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(TooltipProviderContext.Provider, { 10651 value: contextValue, 10652 children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(FloatingDelayGroup, { 10653 delay: delayValue, 10654 timeoutMs: timeout, 10655 children: props.children 10656 }) 10657 }); 10658 }; 10659 if (true) TooltipProvider.displayName = "TooltipProvider"; 10660 10661 // node_modules/@base-ui/react/tooltip/viewport/TooltipViewport.mjs 10662 var React56 = __toESM(require_react(), 1); 10663 10664 // node_modules/@base-ui/react/tooltip/viewport/TooltipViewportCssVars.mjs 10665 var TooltipViewportCssVars = /* @__PURE__ */ (function(TooltipViewportCssVars2) { 10666 TooltipViewportCssVars2["popupWidth"] = "--popup-width"; 10667 TooltipViewportCssVars2["popupHeight"] = "--popup-height"; 10668 return TooltipViewportCssVars2; 10669 })({}); 10670 10671 // node_modules/@base-ui/react/tooltip/viewport/TooltipViewport.mjs 10672 var stateAttributesMapping3 = { 10673 activationDirection: (value) => value ? { 10674 "data-activation-direction": value 10675 } : null 10676 }; 10677 var TooltipViewport = /* @__PURE__ */ React56.forwardRef(function TooltipViewport2(componentProps, forwardedRef) { 10678 const { 10679 render: render4, 10680 className, 10681 style, 10682 children, 10683 ...elementProps 10684 } = componentProps; 10685 const store2 = useTooltipRootContext(); 10686 const positioner = useTooltipPositionerContext(); 10687 const instantType = store2.useState("instantType"); 10688 const { 10689 children: childrenToRender, 10690 state: viewportState 10691 } = usePopupViewport({ 10692 store: store2, 10693 side: positioner.side, 10694 cssVars: TooltipViewportCssVars, 10695 children 10696 }); 10697 const state = { 10698 activationDirection: viewportState.activationDirection, 10699 transitioning: viewportState.transitioning, 10700 instant: instantType 10701 }; 10702 return useRenderElement("div", componentProps, { 10703 state, 10704 ref: forwardedRef, 10705 props: [elementProps, { 10706 children: childrenToRender 10707 }], 10708 stateAttributesMapping: stateAttributesMapping3 10709 }); 10710 }); 10711 if (true) TooltipViewport.displayName = "TooltipViewport"; 10712 10713 // node_modules/@base-ui/react/tooltip/store/TooltipHandle.mjs 10714 var TooltipHandle = class { 10715 /** 10716 * Internal store holding the tooltip state. 10717 * @internal 10718 */ 10719 constructor() { 10720 this.store = new TooltipStore(); 10721 } 10722 /** 10723 * Opens the tooltip and associates it with the trigger with the given ID. 10724 * The trigger must be a Tooltip.Trigger component with this handle passed as a prop. 10725 * 10726 * This method should only be called in an event handler or an effect (not during rendering). 10727 * 10728 * @param triggerId ID of the trigger to associate with the tooltip. 10729 */ 10730 open(triggerId) { 10731 const triggerElement = triggerId ? this.store.context.triggerElements.getById(triggerId) : void 0; 10732 if (triggerId && !triggerElement) { 10733 throw new Error(true ? `Base UI: TooltipHandle.open: No trigger found with id "$triggerId}".` : formatErrorMessage_default(81, triggerId)); 10734 } 10735 this.store.setOpen(true, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, triggerElement)); 10736 } 10737 /** 10738 * Closes the tooltip. 10739 */ 10740 close() { 10741 this.store.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, void 0)); 10742 } 10743 /** 10744 * Indicates whether the tooltip is currently open. 10745 */ 10746 get isOpen() { 10747 return this.store.select("open"); 10748 } 10749 }; 10750 function createTooltipHandle() { 10751 return new TooltipHandle(); 10752 } 10753 10754 // node_modules/@base-ui/react/use-render/useRender.mjs 10755 function useRender(params) { 10756 return useRenderElement(params.defaultTagName ?? "div", params, params); 10757 } 10758 10759 // packages/ui/build-module/text/text.mjs 10760 var import_element10 = __toESM(require_element(), 1); 10761 var STYLE_HASH_ATTRIBUTE = "data-wp-hash"; 10762 function getRuntime() { 10763 const globalScope = globalThis; 10764 if (globalScope.__wpStyleRuntime) { 10765 return globalScope.__wpStyleRuntime; 10766 } 10767 globalScope.__wpStyleRuntime = { 10768 documents: /* @__PURE__ */ new Map(), 10769 styles: /* @__PURE__ */ new Map(), 10770 injectedStyles: /* @__PURE__ */ new WeakMap() 10771 }; 10772 if (typeof document !== "undefined") { 10773 registerDocument(document); 10774 } 10775 return globalScope.__wpStyleRuntime; 10776 } 10777 function documentContainsStyleHash(targetDocument, hash) { 10778 if (!targetDocument.head) { 10779 return false; 10780 } 10781 for (const style of targetDocument.head.querySelectorAll( 10782 `style[$STYLE_HASH_ATTRIBUTE}]` 10783 )) { 10784 if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) { 10785 return true; 10786 } 10787 } 10788 return false; 10789 } 10790 function injectStyle(targetDocument, hash, css) { 10791 if (!targetDocument.head) { 10792 return; 10793 } 10794 const runtime = getRuntime(); 10795 let injectedStyles = runtime.injectedStyles.get(targetDocument); 10796 if (!injectedStyles) { 10797 injectedStyles = /* @__PURE__ */ new Set(); 10798 runtime.injectedStyles.set(targetDocument, injectedStyles); 10799 } 10800 if (injectedStyles.has(hash)) { 10801 return; 10802 } 10803 if (documentContainsStyleHash(targetDocument, hash)) { 10804 injectedStyles.add(hash); 10805 return; 10806 } 10807 const style = targetDocument.createElement("style"); 10808 style.setAttribute(STYLE_HASH_ATTRIBUTE, hash); 10809 style.appendChild(targetDocument.createTextNode(css)); 10810 targetDocument.head.appendChild(style); 10811 injectedStyles.add(hash); 10812 } 10813 function registerDocument(targetDocument) { 10814 const runtime = getRuntime(); 10815 runtime.documents.set( 10816 targetDocument, 10817 (runtime.documents.get(targetDocument) ?? 0) + 1 10818 ); 10819 for (const [hash, css] of runtime.styles) { 10820 injectStyle(targetDocument, hash, css); 10821 } 10822 return () => { 10823 const count = runtime.documents.get(targetDocument); 10824 if (count === void 0) { 10825 return; 10826 } 10827 if (count <= 1) { 10828 runtime.documents.delete(targetDocument); 10829 return; 10830 } 10831 runtime.documents.set(targetDocument, count - 1); 10832 }; 10833 } 10834 function registerStyle(hash, css) { 10835 const runtime = getRuntime(); 10836 runtime.styles.set(hash, css); 10837 for (const targetDocument of runtime.documents.keys()) { 10838 injectStyle(targetDocument, hash, css); 10839 } 10840 } 10841 if (typeof process === "undefined" || true) { 10842 registerStyle("a495f9d138", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._83ed8a8da5dd50ea__text{margin:0}._14437cfb77831647__heading-2xl{--_gcd-heading-font-size:var(--wpds-typography-font-size-2xl,32px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-emphasis,600);--_gcd-p-font-size:var(--wpds-typography-font-size-2xl,32px);--_gcd-p-line-height:var(--wpds-typography-line-height-2xl,40px);font-size:var(--wpds-typography-font-size-2xl,32px);line-height:var(--wpds-typography-line-height-2xl,40px)}._14437cfb77831647__heading-2xl,._3c78b7fa9b4072dd__heading-xl{font-family:var(--wpds-typography-font-family-heading,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-emphasis,600)}._3c78b7fa9b4072dd__heading-xl{--_gcd-heading-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-emphasis,600);--_gcd-p-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-p-line-height:var(--wpds-typography-line-height-md,24px);font-size:var(--wpds-typography-font-size-xl,20px);line-height:var(--wpds-typography-line-height-md,24px)}.aa58f227716bcde2__heading-lg{--_gcd-heading-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-emphasis,600);--_gcd-p-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-p-line-height:var(--wpds-typography-line-height-sm,20px);font-size:var(--wpds-typography-font-size-lg,15px)}.aa58f227716bcde2__heading-lg,.fc4da56d8dfe52c4__heading-md{font-family:var(--wpds-typography-font-family-heading,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-emphasis,600);line-height:var(--wpds-typography-line-height-sm,20px)}.fc4da56d8dfe52c4__heading-md{--_gcd-heading-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-emphasis,600);--_gcd-p-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-p-line-height:var(--wpds-typography-line-height-sm,20px);font-size:var(--wpds-typography-font-size-md,13px)}.a9b78c7c82e8dff7__heading-sm{--_gcd-heading-font-size:var(--wpds-typography-font-size-xs,11px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-emphasis,600);--_gcd-p-font-size:var(--wpds-typography-font-size-xs,11px);--_gcd-p-line-height:var(--wpds-typography-line-height-xs,16px);font-family:var(--wpds-typography-font-family-heading,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-xs,11px);font-weight:var(--wpds-typography-font-weight-emphasis,600);line-height:var(--wpds-typography-line-height-xs,16px);text-transform:uppercase}._305ff559e52180d5__body-xl{--_gcd-heading-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-default,400);--_gcd-p-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-p-line-height:var(--wpds-typography-line-height-xl,32px);font-size:var(--wpds-typography-font-size-xl,20px);line-height:var(--wpds-typography-line-height-xl,32px)}._305ff559e52180d5__body-xl,.ca1aa3fc2029e958__body-lg{font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-default,400)}.ca1aa3fc2029e958__body-lg{--_gcd-heading-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-default,400);--_gcd-p-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-p-line-height:var(--wpds-typography-line-height-md,24px);font-size:var(--wpds-typography-font-size-lg,15px);line-height:var(--wpds-typography-line-height-md,24px)}._131101940be12424__body-md{--_gcd-heading-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-default,400);--_gcd-p-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-p-line-height:var(--wpds-typography-line-height-sm,20px);font-size:var(--wpds-typography-font-size-md,13px);line-height:var(--wpds-typography-line-height-sm,20px)}._0e8d87a42c1f75fa__body-sm,._131101940be12424__body-md{font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-default,400)}._0e8d87a42c1f75fa__body-sm{--_gcd-heading-font-size:var(--wpds-typography-font-size-sm,12px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-default,400);--_gcd-p-font-size:var(--wpds-typography-font-size-sm,12px);--_gcd-p-line-height:var(--wpds-typography-line-height-xs,16px);font-size:var(--wpds-typography-font-size-sm,12px);line-height:var(--wpds-typography-line-height-xs,16px)}}}'); 10843 } 10844 var style_default = { "text": "_83ed8a8da5dd50ea__text", "heading-2xl": "_14437cfb77831647__heading-2xl", "heading-xl": "_3c78b7fa9b4072dd__heading-xl", "heading-lg": "aa58f227716bcde2__heading-lg", "heading-md": "fc4da56d8dfe52c4__heading-md", "heading-sm": "a9b78c7c82e8dff7__heading-sm", "body-xl": "_305ff559e52180d5__body-xl", "body-lg": "ca1aa3fc2029e958__body-lg", "body-md": "_131101940be12424__body-md", "body-sm": "_0e8d87a42c1f75fa__body-sm" }; 10845 if (typeof process === "undefined" || true) { 10846 registerStyle("af6d9984a6", "._6defc79820e382c6__button{box-sizing:var(--_gcd-button-box-sizing,border-box);font-family:var(--_gcd-button-font-family,inherit);font-size:var(--_gcd-button-font-size,inherit);font-weight:var(--_gcd-button-font-weight,inherit)}.d2cff2e5dea83bd1__input{box-sizing:var(--_gcd-input-box-sizing,border-box);font-family:var(--_gcd-input-font-family,inherit);font-size:var(--_gcd-input-font-size,inherit);font-weight:var(--_gcd-input-font-weight,inherit);margin:var(--_gcd-input-margin,0);&:is(textarea,[type=text],[type=password],[type=color],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){background-color:var(--_gcd-input-background-color,transparent);border:var(--_gcd-input-border,none);border-radius:var(--_gcd-input-border-radius,0);box-shadow:var(--_gcd-input-box-shadow,0 0 0 transparent);color:var(--_gcd-input-color,var(--wpds-color-foreground-interactive-neutral,#1e1e1e));&:focus{border-color:var(--_gcd-input-border-color-focus,var(--wp-admin-theme-color));box-shadow:var(--_gcd-input-box-shadow-focus,none);outline:var(--_gcd-input-outline-focus,none)}&:disabled{background:var(--_gcd-input-background-disabled,transparent);border-color:var(--_gcd-input-border-color-disabled,transparent);box-shadow:var(--_gcd-input-box-shadow-disabled,none);color:var(--_gcd-input-color-disabled,var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d))}&::placeholder{color:var(--_gcd-input-placeholder-color,var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d))}}&:is(textarea,[type=text],[type=password],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){line-height:var(--_gcd-input-line-height,inherit);min-height:var(--_gcd-input-min-height,auto);padding:var(--_gcd-input-padding,0)}}._547d86373d02e108__textarea{box-sizing:var(--_gcd-textarea-box-sizing,border-box);overflow:var(--_gcd-textarea-overflow,auto);resize:var(--_gcd-textarea-resize,block)}._8c15fd0ed9f28ba4__div{outline:var(--_gcd-div-outline,0 solid transparent)}p._43cec3e1eec1066d__p{font-size:var(--_gcd-p-font-size,13px);line-height:var(--_gcd-p-line-height,1.5);margin:var(--_gcd-p-margin,0)}:is(h1,h2,h3,h4,h5,h6).e97669c6d9a38497__heading{color:var(--_gcd-heading-color,var(--wpds-color-foreground-content-neutral,#1e1e1e));font-size:var(--_gcd-heading-font-size,inherit);font-weight:var(--_gcd-heading-font-weight,var(--wpds-typography-font-weight-emphasis,600));margin:var(--_gcd-heading-margin,0)}._2c0831b0499dbd6e__a,._2c0831b0499dbd6e__a:is(:hover,:focus,:active){border-radius:var(--_gcd-a-border-radius,0);box-shadow:var(--_gcd-a-box-shadow,none);color:var(--_gcd-a-color,inherit);outline:var(--_gcd-a-outline,0 solid transparent);transition:var(--_gcd-a-transition,none)}"); 10847 } 10848 var global_css_defense_default = { "button": "_6defc79820e382c6__button", "input": "d2cff2e5dea83bd1__input", "textarea": "_547d86373d02e108__textarea", "div": "_8c15fd0ed9f28ba4__div", "p": "_43cec3e1eec1066d__p", "heading": "e97669c6d9a38497__heading", "a": "_2c0831b0499dbd6e__a" }; 10849 var Text = (0, import_element10.forwardRef)(function Text2({ variant = "body-md", render: render4, className, ...props }, ref) { 10850 const element = useRender({ 10851 render: render4, 10852 defaultTagName: "span", 10853 ref, 10854 props: mergeProps(props, { 10855 className: clsx_default( 10856 style_default.text, 10857 global_css_defense_default.heading, 10858 global_css_defense_default.p, 10859 style_default[variant], 10860 className 10861 ) 10862 }) 10863 }); 10864 return element; 10865 }); 10866 10867 // packages/ui/build-module/badge/badge.mjs 10868 var import_jsx_runtime12 = __toESM(require_jsx_runtime(), 1); 10869 var STYLE_HASH_ATTRIBUTE2 = "data-wp-hash"; 10870 function getRuntime2() { 10871 const globalScope = globalThis; 10872 if (globalScope.__wpStyleRuntime) { 10873 return globalScope.__wpStyleRuntime; 10874 } 10875 globalScope.__wpStyleRuntime = { 10876 documents: /* @__PURE__ */ new Map(), 10877 styles: /* @__PURE__ */ new Map(), 10878 injectedStyles: /* @__PURE__ */ new WeakMap() 10879 }; 10880 if (typeof document !== "undefined") { 10881 registerDocument2(document); 10882 } 10883 return globalScope.__wpStyleRuntime; 10884 } 10885 function documentContainsStyleHash2(targetDocument, hash) { 10886 if (!targetDocument.head) { 10887 return false; 10888 } 10889 for (const style of targetDocument.head.querySelectorAll( 10890 `style[$STYLE_HASH_ATTRIBUTE2}]` 10891 )) { 10892 if (style.getAttribute(STYLE_HASH_ATTRIBUTE2) === hash) { 10893 return true; 10894 } 10895 } 10896 return false; 10897 } 10898 function injectStyle2(targetDocument, hash, css) { 10899 if (!targetDocument.head) { 10900 return; 10901 } 10902 const runtime = getRuntime2(); 10903 let injectedStyles = runtime.injectedStyles.get(targetDocument); 10904 if (!injectedStyles) { 10905 injectedStyles = /* @__PURE__ */ new Set(); 10906 runtime.injectedStyles.set(targetDocument, injectedStyles); 10907 } 10908 if (injectedStyles.has(hash)) { 10909 return; 10910 } 10911 if (documentContainsStyleHash2(targetDocument, hash)) { 10912 injectedStyles.add(hash); 10913 return; 10914 } 10915 const style = targetDocument.createElement("style"); 10916 style.setAttribute(STYLE_HASH_ATTRIBUTE2, hash); 10917 style.appendChild(targetDocument.createTextNode(css)); 10918 targetDocument.head.appendChild(style); 10919 injectedStyles.add(hash); 10920 } 10921 function registerDocument2(targetDocument) { 10922 const runtime = getRuntime2(); 10923 runtime.documents.set( 10924 targetDocument, 10925 (runtime.documents.get(targetDocument) ?? 0) + 1 10926 ); 10927 for (const [hash, css] of runtime.styles) { 10928 injectStyle2(targetDocument, hash, css); 10929 } 10930 return () => { 10931 const count = runtime.documents.get(targetDocument); 10932 if (count === void 0) { 10933 return; 10934 } 10935 if (count <= 1) { 10936 runtime.documents.delete(targetDocument); 10937 return; 10938 } 10939 runtime.documents.set(targetDocument, count - 1); 10940 }; 10941 } 10942 function registerStyle2(hash, css) { 10943 const runtime = getRuntime2(); 10944 runtime.styles.set(hash, css); 10945 for (const targetDocument of runtime.documents.keys()) { 10946 injectStyle2(targetDocument, hash, css); 10947 } 10948 } 10949 if (typeof process === "undefined" || true) { 10950 registerStyle2("9db2873e7f", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._96e6251aad1a6136__badge{border-radius:var(--wpds-border-radius-lg,8px);padding-block:var(--wpds-dimension-padding-xs,4px);padding-inline:var(--wpds-dimension-padding-sm,8px)}._99f7158cb520f750__is-high-intent{background-color:var(--wpds-color-background-surface-error,#f6e6e3);color:var(--wpds-color-foreground-content-error,#470000)}.c20ebef2365bc8b7__is-medium-intent{background-color:var(--wpds-color-background-surface-warning,#fde6be);color:var(--wpds-color-foreground-content-warning,#2e1900)}._365e1626c6202e52__is-low-intent{background-color:var(--wpds-color-background-surface-caution,#fee995);color:var(--wpds-color-foreground-content-caution,#281d00)}._33f8198127ddf4ef__is-stable-intent{background-color:var(--wpds-color-background-surface-success,#c6f7cd);color:var(--wpds-color-foreground-content-success,#002900)}._04c1aca8fc449412__is-informational-intent{background-color:var(--wpds-color-background-surface-info,#deebfa);color:var(--wpds-color-foreground-content-info,#001b4f)}._90726e69d495ec19__is-draft-intent{background-color:var(--wpds-color-background-surface-neutral-weak,#f4f4f4);color:var(--wpds-color-foreground-content-neutral,#1e1e1e)}._898f4a544993bd39__is-none-intent{background-color:var(--wpds-color-background-surface-neutral-strong,#fff);border:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral,#dbdbdb);color:var(--wpds-color-foreground-content-neutral,#1e1e1e);padding-block:calc(var(--wpds-dimension-padding-xs, 4px) - var(--wpds-border-width-xs, 1px));padding-inline:calc(var(--wpds-dimension-padding-sm, 8px) - var(--wpds-border-width-xs, 1px))}}}"); 10951 } 10952 var style_default2 = { "badge": "_96e6251aad1a6136__badge", "is-high-intent": "_99f7158cb520f750__is-high-intent", "is-medium-intent": "c20ebef2365bc8b7__is-medium-intent", "is-low-intent": "_365e1626c6202e52__is-low-intent", "is-stable-intent": "_33f8198127ddf4ef__is-stable-intent", "is-informational-intent": "_04c1aca8fc449412__is-informational-intent", "is-draft-intent": "_90726e69d495ec19__is-draft-intent", "is-none-intent": "_898f4a544993bd39__is-none-intent" }; 10953 var Badge = (0, import_element11.forwardRef)(function Badge2({ intent = "none", className, ...props }, ref) { 10954 return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)( 10955 Text, 10956 { 10957 ref, 10958 className: clsx_default( 10959 style_default2.badge, 10960 style_default2[`is-$intent}-intent`], 10961 className 10962 ), 10963 ...props, 10964 variant: "body-sm" 10965 } 10966 ); 10967 }); 10968 10969 // packages/ui/build-module/icon/icon.mjs 10970 var import_element12 = __toESM(require_element(), 1); 10971 var import_primitives = __toESM(require_primitives(), 1); 10972 var import_jsx_runtime13 = __toESM(require_jsx_runtime(), 1); 10973 var Icon = (0, import_element12.forwardRef)(function Icon2({ icon, size: size4 = 24, ...restProps }, ref) { 10974 return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)( 10975 import_primitives.SVG, 10976 { 10977 ref, 10978 ...icon.props, 10979 ...restProps, 10980 width: size4, 10981 height: size4 10982 } 10983 ); 10984 }); 10985 10986 // packages/ui/build-module/card/index.mjs 10987 var card_exports = {}; 10988 __export(card_exports, { 10989 Content: () => Content, 10990 FullBleed: () => FullBleed, 10991 Header: () => Header, 10992 Root: () => Root, 10993 Title: () => Title 10994 }); 10995 10996 // packages/ui/build-module/card/root.mjs 10997 var import_element13 = __toESM(require_element(), 1); 10998 var STYLE_HASH_ATTRIBUTE3 = "data-wp-hash"; 10999 function getRuntime3() { 11000 const globalScope = globalThis; 11001 if (globalScope.__wpStyleRuntime) { 11002 return globalScope.__wpStyleRuntime; 11003 } 11004 globalScope.__wpStyleRuntime = { 11005 documents: /* @__PURE__ */ new Map(), 11006 styles: /* @__PURE__ */ new Map(), 11007 injectedStyles: /* @__PURE__ */ new WeakMap() 11008 }; 11009 if (typeof document !== "undefined") { 11010 registerDocument3(document); 11011 } 11012 return globalScope.__wpStyleRuntime; 11013 } 11014 function documentContainsStyleHash3(targetDocument, hash) { 11015 if (!targetDocument.head) { 11016 return false; 11017 } 11018 for (const style of targetDocument.head.querySelectorAll( 11019 `style[$STYLE_HASH_ATTRIBUTE3}]` 11020 )) { 11021 if (style.getAttribute(STYLE_HASH_ATTRIBUTE3) === hash) { 11022 return true; 11023 } 11024 } 11025 return false; 11026 } 11027 function injectStyle3(targetDocument, hash, css) { 11028 if (!targetDocument.head) { 11029 return; 11030 } 11031 const runtime = getRuntime3(); 11032 let injectedStyles = runtime.injectedStyles.get(targetDocument); 11033 if (!injectedStyles) { 11034 injectedStyles = /* @__PURE__ */ new Set(); 11035 runtime.injectedStyles.set(targetDocument, injectedStyles); 11036 } 11037 if (injectedStyles.has(hash)) { 11038 return; 11039 } 11040 if (documentContainsStyleHash3(targetDocument, hash)) { 11041 injectedStyles.add(hash); 11042 return; 11043 } 11044 const style = targetDocument.createElement("style"); 11045 style.setAttribute(STYLE_HASH_ATTRIBUTE3, hash); 11046 style.appendChild(targetDocument.createTextNode(css)); 11047 targetDocument.head.appendChild(style); 11048 injectedStyles.add(hash); 11049 } 11050 function registerDocument3(targetDocument) { 11051 const runtime = getRuntime3(); 11052 runtime.documents.set( 11053 targetDocument, 11054 (runtime.documents.get(targetDocument) ?? 0) + 1 11055 ); 11056 for (const [hash, css] of runtime.styles) { 11057 injectStyle3(targetDocument, hash, css); 11058 } 11059 return () => { 11060 const count = runtime.documents.get(targetDocument); 11061 if (count === void 0) { 11062 return; 11063 } 11064 if (count <= 1) { 11065 runtime.documents.delete(targetDocument); 11066 return; 11067 } 11068 runtime.documents.set(targetDocument, count - 1); 11069 }; 11070 } 11071 function registerStyle3(hash, css) { 11072 const runtime = getRuntime3(); 11073 runtime.styles.set(hash, css); 11074 for (const targetDocument of runtime.documents.keys()) { 11075 injectStyle3(targetDocument, hash, css); 11076 } 11077 } 11078 if (typeof process === "undefined" || true) { 11079 registerStyle3("10f3806643", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}}"); 11080 } 11081 var resets_default = { "box-sizing": "_336cd3e4e743482f__box-sizing" }; 11082 if (typeof process === "undefined" || true) { 11083 registerStyle3("5d38cbdd27", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._02872bf298eadc43__root{--wp-ui-card-padding:var(--wpds-dimension-padding-2xl,24px);--wp-ui-card-header-content-gap:var(--wpds-dimension-gap-xl,24px);--wp-ui-card-header-content-margin:calc(var(--wp-ui-card-header-content-gap) - var(--wp-ui-card-padding));background-color:var(--wpds-color-background-surface-neutral-strong,#fff);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#f0f0f0);border-radius:var(--wpds-border-radius-lg,8px);color:var(--wpds-color-foreground-content-neutral,#1e1e1e);display:flex;flex-direction:column;overflow:clip}._5dffdaf2a6e669ac__content,.bbccc92e6ba5662d__header{padding:var(--wp-ui-card-padding);&:not(:first-child):not(:last-child){padding-block-end:0}}.bbccc92e6ba5662d__header+._5dffdaf2a6e669ac__content{margin-block-start:var(--wp-ui-card-header-content-margin);padding-block-start:0}.c1fa192587e1b4a6__fullbleed{margin-inline:calc(var(--wp-ui-card-padding)*-1);width:calc(100% + var(--wp-ui-card-padding)*2)}._02872bf298eadc43__root>:is(.bbccc92e6ba5662d__header,._5dffdaf2a6e669ac__content):first-child>.c1fa192587e1b4a6__fullbleed:first-child{margin-block-start:calc(var(--wp-ui-card-padding)*-1)}:is(.bbccc92e6ba5662d__header,._5dffdaf2a6e669ac__content):last-child>.c1fa192587e1b4a6__fullbleed:last-child{margin-block-end:calc(var(--wp-ui-card-padding)*-1)}}}"); 11084 } 11085 var style_default3 = { "root": "_02872bf298eadc43__root", "header": "bbccc92e6ba5662d__header", "content": "_5dffdaf2a6e669ac__content", "fullbleed": "c1fa192587e1b4a6__fullbleed" }; 11086 var Root = (0, import_element13.forwardRef)(function Card({ render: render4, ...restProps }, ref) { 11087 const mergedClassName = clsx_default(style_default3.root, resets_default["box-sizing"]); 11088 const element = useRender({ 11089 defaultTagName: "div", 11090 render: render4, 11091 ref, 11092 props: mergeProps({ className: mergedClassName }, restProps) 11093 }); 11094 return element; 11095 }); 11096 11097 // packages/ui/build-module/card/header.mjs 11098 var import_element14 = __toESM(require_element(), 1); 11099 var STYLE_HASH_ATTRIBUTE4 = "data-wp-hash"; 11100 function getRuntime4() { 11101 const globalScope = globalThis; 11102 if (globalScope.__wpStyleRuntime) { 11103 return globalScope.__wpStyleRuntime; 11104 } 11105 globalScope.__wpStyleRuntime = { 11106 documents: /* @__PURE__ */ new Map(), 11107 styles: /* @__PURE__ */ new Map(), 11108 injectedStyles: /* @__PURE__ */ new WeakMap() 11109 }; 11110 if (typeof document !== "undefined") { 11111 registerDocument4(document); 11112 } 11113 return globalScope.__wpStyleRuntime; 11114 } 11115 function documentContainsStyleHash4(targetDocument, hash) { 11116 if (!targetDocument.head) { 11117 return false; 11118 } 11119 for (const style of targetDocument.head.querySelectorAll( 11120 `style[$STYLE_HASH_ATTRIBUTE4}]` 11121 )) { 11122 if (style.getAttribute(STYLE_HASH_ATTRIBUTE4) === hash) { 11123 return true; 11124 } 11125 } 11126 return false; 11127 } 11128 function injectStyle4(targetDocument, hash, css) { 11129 if (!targetDocument.head) { 11130 return; 11131 } 11132 const runtime = getRuntime4(); 11133 let injectedStyles = runtime.injectedStyles.get(targetDocument); 11134 if (!injectedStyles) { 11135 injectedStyles = /* @__PURE__ */ new Set(); 11136 runtime.injectedStyles.set(targetDocument, injectedStyles); 11137 } 11138 if (injectedStyles.has(hash)) { 11139 return; 11140 } 11141 if (documentContainsStyleHash4(targetDocument, hash)) { 11142 injectedStyles.add(hash); 11143 return; 11144 } 11145 const style = targetDocument.createElement("style"); 11146 style.setAttribute(STYLE_HASH_ATTRIBUTE4, hash); 11147 style.appendChild(targetDocument.createTextNode(css)); 11148 targetDocument.head.appendChild(style); 11149 injectedStyles.add(hash); 11150 } 11151 function registerDocument4(targetDocument) { 11152 const runtime = getRuntime4(); 11153 runtime.documents.set( 11154 targetDocument, 11155 (runtime.documents.get(targetDocument) ?? 0) + 1 11156 ); 11157 for (const [hash, css] of runtime.styles) { 11158 injectStyle4(targetDocument, hash, css); 11159 } 11160 return () => { 11161 const count = runtime.documents.get(targetDocument); 11162 if (count === void 0) { 11163 return; 11164 } 11165 if (count <= 1) { 11166 runtime.documents.delete(targetDocument); 11167 return; 11168 } 11169 runtime.documents.set(targetDocument, count - 1); 11170 }; 11171 } 11172 function registerStyle4(hash, css) { 11173 const runtime = getRuntime4(); 11174 runtime.styles.set(hash, css); 11175 for (const targetDocument of runtime.documents.keys()) { 11176 injectStyle4(targetDocument, hash, css); 11177 } 11178 } 11179 if (typeof process === "undefined" || true) { 11180 registerStyle4("5d38cbdd27", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._02872bf298eadc43__root{--wp-ui-card-padding:var(--wpds-dimension-padding-2xl,24px);--wp-ui-card-header-content-gap:var(--wpds-dimension-gap-xl,24px);--wp-ui-card-header-content-margin:calc(var(--wp-ui-card-header-content-gap) - var(--wp-ui-card-padding));background-color:var(--wpds-color-background-surface-neutral-strong,#fff);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#f0f0f0);border-radius:var(--wpds-border-radius-lg,8px);color:var(--wpds-color-foreground-content-neutral,#1e1e1e);display:flex;flex-direction:column;overflow:clip}._5dffdaf2a6e669ac__content,.bbccc92e6ba5662d__header{padding:var(--wp-ui-card-padding);&:not(:first-child):not(:last-child){padding-block-end:0}}.bbccc92e6ba5662d__header+._5dffdaf2a6e669ac__content{margin-block-start:var(--wp-ui-card-header-content-margin);padding-block-start:0}.c1fa192587e1b4a6__fullbleed{margin-inline:calc(var(--wp-ui-card-padding)*-1);width:calc(100% + var(--wp-ui-card-padding)*2)}._02872bf298eadc43__root>:is(.bbccc92e6ba5662d__header,._5dffdaf2a6e669ac__content):first-child>.c1fa192587e1b4a6__fullbleed:first-child{margin-block-start:calc(var(--wp-ui-card-padding)*-1)}:is(.bbccc92e6ba5662d__header,._5dffdaf2a6e669ac__content):last-child>.c1fa192587e1b4a6__fullbleed:last-child{margin-block-end:calc(var(--wp-ui-card-padding)*-1)}}}"); 11181 } 11182 var style_default4 = { "root": "_02872bf298eadc43__root", "header": "bbccc92e6ba5662d__header", "content": "_5dffdaf2a6e669ac__content", "fullbleed": "c1fa192587e1b4a6__fullbleed" }; 11183 var Header = (0, import_element14.forwardRef)( 11184 function CardHeader({ render: render4, ...props }, ref) { 11185 const element = useRender({ 11186 defaultTagName: "div", 11187 render: render4, 11188 ref, 11189 props: mergeProps({ className: style_default4.header }, props) 11190 }); 11191 return element; 11192 } 11193 ); 11194 11195 // packages/ui/build-module/card/content.mjs 11196 var import_element15 = __toESM(require_element(), 1); 11197 var STYLE_HASH_ATTRIBUTE5 = "data-wp-hash"; 11198 function getRuntime5() { 11199 const globalScope = globalThis; 11200 if (globalScope.__wpStyleRuntime) { 11201 return globalScope.__wpStyleRuntime; 11202 } 11203 globalScope.__wpStyleRuntime = { 11204 documents: /* @__PURE__ */ new Map(), 11205 styles: /* @__PURE__ */ new Map(), 11206 injectedStyles: /* @__PURE__ */ new WeakMap() 11207 }; 11208 if (typeof document !== "undefined") { 11209 registerDocument5(document); 11210 } 11211 return globalScope.__wpStyleRuntime; 11212 } 11213 function documentContainsStyleHash5(targetDocument, hash) { 11214 if (!targetDocument.head) { 11215 return false; 11216 } 11217 for (const style of targetDocument.head.querySelectorAll( 11218 `style[$STYLE_HASH_ATTRIBUTE5}]` 11219 )) { 11220 if (style.getAttribute(STYLE_HASH_ATTRIBUTE5) === hash) { 11221 return true; 11222 } 11223 } 11224 return false; 11225 } 11226 function injectStyle5(targetDocument, hash, css) { 11227 if (!targetDocument.head) { 11228 return; 11229 } 11230 const runtime = getRuntime5(); 11231 let injectedStyles = runtime.injectedStyles.get(targetDocument); 11232 if (!injectedStyles) { 11233 injectedStyles = /* @__PURE__ */ new Set(); 11234 runtime.injectedStyles.set(targetDocument, injectedStyles); 11235 } 11236 if (injectedStyles.has(hash)) { 11237 return; 11238 } 11239 if (documentContainsStyleHash5(targetDocument, hash)) { 11240 injectedStyles.add(hash); 11241 return; 11242 } 11243 const style = targetDocument.createElement("style"); 11244 style.setAttribute(STYLE_HASH_ATTRIBUTE5, hash); 11245 style.appendChild(targetDocument.createTextNode(css)); 11246 targetDocument.head.appendChild(style); 11247 injectedStyles.add(hash); 11248 } 11249 function registerDocument5(targetDocument) { 11250 const runtime = getRuntime5(); 11251 runtime.documents.set( 11252 targetDocument, 11253 (runtime.documents.get(targetDocument) ?? 0) + 1 11254 ); 11255 for (const [hash, css] of runtime.styles) { 11256 injectStyle5(targetDocument, hash, css); 11257 } 11258 return () => { 11259 const count = runtime.documents.get(targetDocument); 11260 if (count === void 0) { 11261 return; 11262 } 11263 if (count <= 1) { 11264 runtime.documents.delete(targetDocument); 11265 return; 11266 } 11267 runtime.documents.set(targetDocument, count - 1); 11268 }; 11269 } 11270 function registerStyle5(hash, css) { 11271 const runtime = getRuntime5(); 11272 runtime.styles.set(hash, css); 11273 for (const targetDocument of runtime.documents.keys()) { 11274 injectStyle5(targetDocument, hash, css); 11275 } 11276 } 11277 if (typeof process === "undefined" || true) { 11278 registerStyle5("5d38cbdd27", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._02872bf298eadc43__root{--wp-ui-card-padding:var(--wpds-dimension-padding-2xl,24px);--wp-ui-card-header-content-gap:var(--wpds-dimension-gap-xl,24px);--wp-ui-card-header-content-margin:calc(var(--wp-ui-card-header-content-gap) - var(--wp-ui-card-padding));background-color:var(--wpds-color-background-surface-neutral-strong,#fff);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#f0f0f0);border-radius:var(--wpds-border-radius-lg,8px);color:var(--wpds-color-foreground-content-neutral,#1e1e1e);display:flex;flex-direction:column;overflow:clip}._5dffdaf2a6e669ac__content,.bbccc92e6ba5662d__header{padding:var(--wp-ui-card-padding);&:not(:first-child):not(:last-child){padding-block-end:0}}.bbccc92e6ba5662d__header+._5dffdaf2a6e669ac__content{margin-block-start:var(--wp-ui-card-header-content-margin);padding-block-start:0}.c1fa192587e1b4a6__fullbleed{margin-inline:calc(var(--wp-ui-card-padding)*-1);width:calc(100% + var(--wp-ui-card-padding)*2)}._02872bf298eadc43__root>:is(.bbccc92e6ba5662d__header,._5dffdaf2a6e669ac__content):first-child>.c1fa192587e1b4a6__fullbleed:first-child{margin-block-start:calc(var(--wp-ui-card-padding)*-1)}:is(.bbccc92e6ba5662d__header,._5dffdaf2a6e669ac__content):last-child>.c1fa192587e1b4a6__fullbleed:last-child{margin-block-end:calc(var(--wp-ui-card-padding)*-1)}}}"); 11279 } 11280 var style_default5 = { "root": "_02872bf298eadc43__root", "header": "bbccc92e6ba5662d__header", "content": "_5dffdaf2a6e669ac__content", "fullbleed": "c1fa192587e1b4a6__fullbleed" }; 11281 var Content = (0, import_element15.forwardRef)( 11282 function CardContent({ render: render4, ...props }, ref) { 11283 const element = useRender({ 11284 defaultTagName: "div", 11285 render: render4, 11286 ref, 11287 props: mergeProps({ className: style_default5.content }, props) 11288 }); 11289 return element; 11290 } 11291 ); 11292 11293 // packages/ui/build-module/card/full-bleed.mjs 11294 var import_element16 = __toESM(require_element(), 1); 11295 var STYLE_HASH_ATTRIBUTE6 = "data-wp-hash"; 11296 function getRuntime6() { 11297 const globalScope = globalThis; 11298 if (globalScope.__wpStyleRuntime) { 11299 return globalScope.__wpStyleRuntime; 11300 } 11301 globalScope.__wpStyleRuntime = { 11302 documents: /* @__PURE__ */ new Map(), 11303 styles: /* @__PURE__ */ new Map(), 11304 injectedStyles: /* @__PURE__ */ new WeakMap() 11305 }; 11306 if (typeof document !== "undefined") { 11307 registerDocument6(document); 11308 } 11309 return globalScope.__wpStyleRuntime; 11310 } 11311 function documentContainsStyleHash6(targetDocument, hash) { 11312 if (!targetDocument.head) { 11313 return false; 11314 } 11315 for (const style of targetDocument.head.querySelectorAll( 11316 `style[$STYLE_HASH_ATTRIBUTE6}]` 11317 )) { 11318 if (style.getAttribute(STYLE_HASH_ATTRIBUTE6) === hash) { 11319 return true; 11320 } 11321 } 11322 return false; 11323 } 11324 function injectStyle6(targetDocument, hash, css) { 11325 if (!targetDocument.head) { 11326 return; 11327 } 11328 const runtime = getRuntime6(); 11329 let injectedStyles = runtime.injectedStyles.get(targetDocument); 11330 if (!injectedStyles) { 11331 injectedStyles = /* @__PURE__ */ new Set(); 11332 runtime.injectedStyles.set(targetDocument, injectedStyles); 11333 } 11334 if (injectedStyles.has(hash)) { 11335 return; 11336 } 11337 if (documentContainsStyleHash6(targetDocument, hash)) { 11338 injectedStyles.add(hash); 11339 return; 11340 } 11341 const style = targetDocument.createElement("style"); 11342 style.setAttribute(STYLE_HASH_ATTRIBUTE6, hash); 11343 style.appendChild(targetDocument.createTextNode(css)); 11344 targetDocument.head.appendChild(style); 11345 injectedStyles.add(hash); 11346 } 11347 function registerDocument6(targetDocument) { 11348 const runtime = getRuntime6(); 11349 runtime.documents.set( 11350 targetDocument, 11351 (runtime.documents.get(targetDocument) ?? 0) + 1 11352 ); 11353 for (const [hash, css] of runtime.styles) { 11354 injectStyle6(targetDocument, hash, css); 11355 } 11356 return () => { 11357 const count = runtime.documents.get(targetDocument); 11358 if (count === void 0) { 11359 return; 11360 } 11361 if (count <= 1) { 11362 runtime.documents.delete(targetDocument); 11363 return; 11364 } 11365 runtime.documents.set(targetDocument, count - 1); 11366 }; 11367 } 11368 function registerStyle6(hash, css) { 11369 const runtime = getRuntime6(); 11370 runtime.styles.set(hash, css); 11371 for (const targetDocument of runtime.documents.keys()) { 11372 injectStyle6(targetDocument, hash, css); 11373 } 11374 } 11375 if (typeof process === "undefined" || true) { 11376 registerStyle6("5d38cbdd27", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._02872bf298eadc43__root{--wp-ui-card-padding:var(--wpds-dimension-padding-2xl,24px);--wp-ui-card-header-content-gap:var(--wpds-dimension-gap-xl,24px);--wp-ui-card-header-content-margin:calc(var(--wp-ui-card-header-content-gap) - var(--wp-ui-card-padding));background-color:var(--wpds-color-background-surface-neutral-strong,#fff);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#f0f0f0);border-radius:var(--wpds-border-radius-lg,8px);color:var(--wpds-color-foreground-content-neutral,#1e1e1e);display:flex;flex-direction:column;overflow:clip}._5dffdaf2a6e669ac__content,.bbccc92e6ba5662d__header{padding:var(--wp-ui-card-padding);&:not(:first-child):not(:last-child){padding-block-end:0}}.bbccc92e6ba5662d__header+._5dffdaf2a6e669ac__content{margin-block-start:var(--wp-ui-card-header-content-margin);padding-block-start:0}.c1fa192587e1b4a6__fullbleed{margin-inline:calc(var(--wp-ui-card-padding)*-1);width:calc(100% + var(--wp-ui-card-padding)*2)}._02872bf298eadc43__root>:is(.bbccc92e6ba5662d__header,._5dffdaf2a6e669ac__content):first-child>.c1fa192587e1b4a6__fullbleed:first-child{margin-block-start:calc(var(--wp-ui-card-padding)*-1)}:is(.bbccc92e6ba5662d__header,._5dffdaf2a6e669ac__content):last-child>.c1fa192587e1b4a6__fullbleed:last-child{margin-block-end:calc(var(--wp-ui-card-padding)*-1)}}}"); 11377 } 11378 var style_default6 = { "root": "_02872bf298eadc43__root", "header": "bbccc92e6ba5662d__header", "content": "_5dffdaf2a6e669ac__content", "fullbleed": "c1fa192587e1b4a6__fullbleed" }; 11379 var FullBleed = (0, import_element16.forwardRef)( 11380 function CardFullBleed({ render: render4, ...props }, ref) { 11381 const element = useRender({ 11382 defaultTagName: "div", 11383 render: render4, 11384 ref, 11385 props: mergeProps( 11386 { className: style_default6.fullbleed }, 11387 props 11388 ) 11389 }); 11390 return element; 11391 } 11392 ); 11393 11394 // packages/ui/build-module/card/title.mjs 11395 var import_element17 = __toESM(require_element(), 1); 11396 var import_jsx_runtime14 = __toESM(require_jsx_runtime(), 1); 11397 var DEFAULT_TAG = /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", {}); 11398 var Title = (0, import_element17.forwardRef)( 11399 function CardTitle({ render: render4 = DEFAULT_TAG, children, ...props }, ref) { 11400 return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)( 11401 Text, 11402 { 11403 ref, 11404 variant: "heading-lg", 11405 render: render4, 11406 ...props, 11407 children 11408 } 11409 ); 11410 } 11411 ); 11412 11413 // packages/ui/build-module/collapsible/panel.mjs 11414 var import_element18 = __toESM(require_element(), 1); 11415 var import_jsx_runtime15 = __toESM(require_jsx_runtime(), 1); 11416 var Panel = (0, import_element18.forwardRef)( 11417 function CollapsiblePanel3(props, forwardedRef) { 11418 return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(index_parts_exports.Panel, { ref: forwardedRef, ...props }); 11419 } 11420 ); 11421 11422 // packages/ui/build-module/collapsible/root.mjs 11423 var import_element19 = __toESM(require_element(), 1); 11424 var import_jsx_runtime16 = __toESM(require_jsx_runtime(), 1); 11425 var Root2 = (0, import_element19.forwardRef)( 11426 function CollapsibleRoot3(props, forwardedRef) { 11427 return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(index_parts_exports.Root, { ref: forwardedRef, ...props }); 11428 } 11429 ); 11430 11431 // packages/ui/build-module/collapsible/trigger.mjs 11432 var import_element20 = __toESM(require_element(), 1); 11433 var import_jsx_runtime17 = __toESM(require_jsx_runtime(), 1); 11434 var Trigger = (0, import_element20.forwardRef)( 11435 function CollapsibleTrigger3(props, forwardedRef) { 11436 return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(index_parts_exports.Trigger, { ref: forwardedRef, ...props }); 11437 } 11438 ); 11439 11440 // packages/ui/build-module/collapsible-card/index.mjs 11441 var collapsible_card_exports = {}; 11442 __export(collapsible_card_exports, { 11443 Content: () => Content2, 11444 Header: () => Header2, 11445 HeaderDescription: () => HeaderDescription, 11446 Root: () => Root3 11447 }); 11448 11449 // packages/ui/build-module/collapsible-card/root.mjs 11450 var import_element21 = __toESM(require_element(), 1); 11451 var import_jsx_runtime18 = __toESM(require_jsx_runtime(), 1); 11452 var Root3 = (0, import_element21.forwardRef)( 11453 function CollapsibleCardRoot({ render: render4, ...restProps }, ref) { 11454 return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)( 11455 Root2, 11456 { 11457 ref, 11458 render: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Root, { render: render4 }), 11459 ...restProps 11460 } 11461 ); 11462 } 11463 ); 11464 11465 // packages/ui/build-module/collapsible-card/header.mjs 11466 var import_element24 = __toESM(require_element(), 1); 11467 11468 // packages/icons/build-module/icon/index.mjs 11469 var import_element22 = __toESM(require_element(), 1); 11470 var icon_default = (0, import_element22.forwardRef)( 11471 ({ icon, size: size4 = 24, ...props }, ref) => { 11472 return (0, import_element22.cloneElement)(icon, { 11473 width: size4, 11474 height: size4, 11475 ...props, 11476 ref 11477 }); 11478 } 11479 ); 11480 11481 // packages/icons/build-module/library/archive.mjs 11482 var import_primitives2 = __toESM(require_primitives(), 1); 11483 var import_jsx_runtime19 = __toESM(require_jsx_runtime(), 1); 11484 var archive_default = /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_primitives2.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_primitives2.Path, { fillRule: "evenodd", clipRule: "evenodd", 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" }) }); 11485 11486 // packages/icons/build-module/library/arrow-down.mjs 11487 var import_primitives3 = __toESM(require_primitives(), 1); 11488 var import_jsx_runtime20 = __toESM(require_jsx_runtime(), 1); 11489 var arrow_down_default = /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_primitives3.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_primitives3.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" }) }); 11490 11491 // packages/icons/build-module/library/arrow-left.mjs 11492 var import_primitives4 = __toESM(require_primitives(), 1); 11493 var import_jsx_runtime21 = __toESM(require_jsx_runtime(), 1); 11494 var arrow_left_default = /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_primitives4.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_primitives4.Path, { d: "M20 11.2H6.8l3.7-3.7-1-1L3.9 12l5.6 5.5 1-1-3.7-3.7H20z" }) }); 11495 11496 // packages/icons/build-module/library/arrow-right.mjs 11497 var import_primitives5 = __toESM(require_primitives(), 1); 11498 var import_jsx_runtime22 = __toESM(require_jsx_runtime(), 1); 11499 var arrow_right_default = /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_primitives5.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_primitives5.Path, { d: "m14.5 6.5-1 1 3.7 3.7H4v1.6h13.2l-3.7 3.7 1 1 5.6-5.5z" }) }); 11500 11501 // packages/icons/build-module/library/arrow-up.mjs 11502 var import_primitives6 = __toESM(require_primitives(), 1); 11503 var import_jsx_runtime23 = __toESM(require_jsx_runtime(), 1); 11504 var arrow_up_default = /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_primitives6.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_primitives6.Path, { d: "M12 3.9 6.5 9.5l1 1 3.8-3.7V20h1.5V6.8l3.7 3.7 1-1z" }) }); 11505 11506 // packages/icons/build-module/library/audio.mjs 11507 var import_primitives7 = __toESM(require_primitives(), 1); 11508 var import_jsx_runtime24 = __toESM(require_jsx_runtime(), 1); 11509 var audio_default = /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_primitives7.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_primitives7.Path, { d: "M17.7 4.3c-1.2 0-2.8 0-3.8 1-.6.6-.9 1.5-.9 2.6V14c-.6-.6-1.5-1-2.5-1C8.6 13 7 14.6 7 16.5S8.6 20 10.5 20c1.5 0 2.8-1 3.3-2.3.5-.8.7-1.8.7-2.5V7.9c0-.7.2-1.2.5-1.6.6-.6 1.8-.6 2.8-.6h.3V4.3h-.4z" }) }); 11510 11511 // packages/icons/build-module/library/backup.mjs 11512 var import_primitives8 = __toESM(require_primitives(), 1); 11513 var import_jsx_runtime25 = __toESM(require_jsx_runtime(), 1); 11514 var backup_default = /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_primitives8.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_primitives8.Path, { d: "M13.75 4.194a8 8 0 0 0-4.812.415l-.301.132a8 8 0 0 0-3.203 2.692L4 6.001v4h4L6.517 8.516q.333-.526.758-.977l.011-.012q.341-.359.733-.662l.025-.02a6.5 6.5 0 0 1 2.469-1.172l.034-.008q.117-.027.236-.05l.015-.002q.32-.06.65-.088.08-.008.16-.013a7 7 0 0 1 .323-.01L12 5.5h.05l.203.005.101.003q.146.008.293.023l.12.014.158.02q.103.015.205.033l.058.011q.107.02.212.043l.068.016a6.5 6.5 0 0 1 1.447.521l.02.01a7 7 0 0 1 .452.25l.02.014a7 7 0 0 1 .468.317l.07.054a7 7 0 0 1 .403.334l.034.03q.091.084.18.172l.047.045q.293.294.548.627l.03.038.07.097.096.135q.037.053.072.107a6 6 0 0 1 .167.265l.042.073q.236.411.413.857l.027.07a6.5 6.5 0 0 1 .418 2.014 6.6 6.6 0 0 1-.034 1.04 6 6 0 0 1-.063.424q-.109.597-.32 1.152-.016.034-.028.07a6.5 6.5 0 0 1-.413.856l-.042.073a6 6 0 0 1-.327.497l-.087.118-.02.028a7 7 0 0 1-.526.604l-.035.035-.035.032q-.089.088-.18.172l-.034.03a7 7 0 0 1-.38.317l-.093.071q-.09.067-.183.13l-.076.053q-.112.076-.227.146-.218.133-.446.247l-.028.015-.192.093-.081.036a6.5 6.5 0 0 1-1.184.396l-.058.012a7 7 0 0 1-.475.087q-.08.012-.157.02l-.122.014q-.145.015-.292.023l-.136.005-.139.003L12 18.5q-.053-.002-.104-.003l-.127-.004-.162-.007q-.08-.005-.159-.013a7 7 0 0 1-.65-.088q-.008 0-.015-.002a7 7 0 0 1-.236-.05l-.034-.008a6.5 6.5 0 0 1-4.14-3.077l-1.3.75a8 8 0 0 0 3.564 3.26l.301.131a8 8 0 0 0 11.055-7.061l.007-.33c0-1.76-.581-3.473-1.653-4.87l-.206-.256a8 8 0 0 0-4.07-2.6zM12 7.75a.75.75 0 0 0-.75.75V12a.75.75 0 0 0 .218.529l1.282-.839-1.28.84 2.5 2.5a.75.75 0 1 0 1.06-1.06l-2.28-2.28V8.5a.75.75 0 0 0-.75-.75" }) }); 11515 11516 // packages/icons/build-module/library/block-meta.mjs 11517 var import_primitives9 = __toESM(require_primitives(), 1); 11518 var import_jsx_runtime26 = __toESM(require_jsx_runtime(), 1); 11519 var block_meta_default = /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_primitives9.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_primitives9.Path, { fillRule: "evenodd", 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", clipRule: "evenodd" }) }); 11520 11521 // packages/icons/build-module/library/block-table.mjs 11522 var import_primitives10 = __toESM(require_primitives(), 1); 11523 var import_jsx_runtime27 = __toESM(require_jsx_runtime(), 1); 11524 var block_table_default = /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_primitives10.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime27.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-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" }) }); 11525 11526 // packages/icons/build-module/library/calendar.mjs 11527 var import_primitives11 = __toESM(require_primitives(), 1); 11528 var import_jsx_runtime28 = __toESM(require_jsx_runtime(), 1); 11529 var calendar_default = /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_primitives11.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_primitives11.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" }) }); 11530 11531 // packages/icons/build-module/library/category.mjs 11532 var import_primitives12 = __toESM(require_primitives(), 1); 11533 var import_jsx_runtime29 = __toESM(require_jsx_runtime(), 1); 11534 var category_default = /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_primitives12.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_primitives12.Path, { fillRule: "evenodd", clipRule: "evenodd", 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" }) }); 11535 11536 // packages/icons/build-module/library/check.mjs 11537 var import_primitives13 = __toESM(require_primitives(), 1); 11538 var import_jsx_runtime30 = __toESM(require_jsx_runtime(), 1); 11539 var check_default = /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_primitives13.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_primitives13.Path, { d: "M16.5 7.5 10 13.9l-2.5-2.4-1 1 3.5 3.6 7.5-7.6z" }) }); 11540 11541 // packages/icons/build-module/library/chevron-down.mjs 11542 var import_primitives14 = __toESM(require_primitives(), 1); 11543 var import_jsx_runtime31 = __toESM(require_jsx_runtime(), 1); 11544 var chevron_down_default = /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_primitives14.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_primitives14.Path, { d: "M17.5 11.6L12 16l-5.5-4.4.9-1.2L12 14l4.5-3.6 1 1.2z" }) }); 11545 11546 // packages/icons/build-module/library/chevron-left-small.mjs 11547 var import_primitives15 = __toESM(require_primitives(), 1); 11548 var import_jsx_runtime32 = __toESM(require_jsx_runtime(), 1); 11549 var chevron_left_small_default = /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_primitives15.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_primitives15.Path, { d: "m13.1 16-3.4-4 3.4-4 1.1 1-2.6 3 2.6 3-1.1 1z" }) }); 11550 11551 // packages/icons/build-module/library/chevron-left.mjs 11552 var import_primitives16 = __toESM(require_primitives(), 1); 11553 var import_jsx_runtime33 = __toESM(require_jsx_runtime(), 1); 11554 var chevron_left_default = /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_primitives16.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_primitives16.Path, { d: "M14.6 7l-1.2-1L8 12l5.4 6 1.2-1-4.6-5z" }) }); 11555 11556 // packages/icons/build-module/library/chevron-right-small.mjs 11557 var import_primitives17 = __toESM(require_primitives(), 1); 11558 var import_jsx_runtime34 = __toESM(require_jsx_runtime(), 1); 11559 var chevron_right_small_default = /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_primitives17.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_primitives17.Path, { d: "M10.8622 8.04053L14.2805 12.0286L10.8622 16.0167L9.72327 15.0405L12.3049 12.0286L9.72327 9.01672L10.8622 8.04053Z" }) }); 11560 11561 // packages/icons/build-module/library/chevron-right.mjs 11562 var import_primitives18 = __toESM(require_primitives(), 1); 11563 var import_jsx_runtime35 = __toESM(require_jsx_runtime(), 1); 11564 var chevron_right_default = /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_primitives18.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_primitives18.Path, { d: "M10.6 6L9.4 7l4.6 5-4.6 5 1.2 1 5.4-6z" }) }); 11565 11566 // packages/icons/build-module/library/chevron-up.mjs 11567 var import_primitives19 = __toESM(require_primitives(), 1); 11568 var import_jsx_runtime36 = __toESM(require_jsx_runtime(), 1); 11569 var chevron_up_default = /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_primitives19.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_primitives19.Path, { d: "M6.5 12.4L12 8l5.5 4.4-.9 1.2L12 10l-4.5 3.6-1-1.2z" }) }); 11570 11571 // packages/icons/build-module/library/close-small.mjs 11572 var import_primitives20 = __toESM(require_primitives(), 1); 11573 var import_jsx_runtime37 = __toESM(require_jsx_runtime(), 1); 11574 var close_small_default = /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_primitives20.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_primitives20.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" }) }); 11575 11576 // packages/icons/build-module/library/cog.mjs 11577 var import_primitives21 = __toESM(require_primitives(), 1); 11578 var import_jsx_runtime38 = __toESM(require_jsx_runtime(), 1); 11579 var cog_default = /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_primitives21.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_primitives21.Path, { fillRule: "evenodd", clipRule: "evenodd", 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" }) }); 11580 11581 // packages/icons/build-module/library/comment-author-avatar.mjs 11582 var import_primitives22 = __toESM(require_primitives(), 1); 11583 var import_jsx_runtime39 = __toESM(require_jsx_runtime(), 1); 11584 var comment_author_avatar_default = /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_primitives22.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_primitives22.Path, { fillRule: "evenodd", clipRule: "evenodd", 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" }) }); 11585 11586 // packages/icons/build-module/library/download.mjs 11587 var import_primitives23 = __toESM(require_primitives(), 1); 11588 var import_jsx_runtime40 = __toESM(require_jsx_runtime(), 1); 11589 var download_default = /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_primitives23.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_primitives23.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" }) }); 11590 11591 // packages/icons/build-module/library/drafts.mjs 11592 var import_primitives24 = __toESM(require_primitives(), 1); 11593 var import_jsx_runtime41 = __toESM(require_jsx_runtime(), 1); 11594 var drafts_default = /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(import_primitives24.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(import_primitives24.Path, { fillRule: "evenodd", clipRule: "evenodd", 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" }) }); 11595 11596 // packages/icons/build-module/library/drawer-right.mjs 11597 var import_primitives25 = __toESM(require_primitives(), 1); 11598 var import_jsx_runtime42 = __toESM(require_jsx_runtime(), 1); 11599 var drawer_right_default = /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_primitives25.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_primitives25.Path, { fillRule: "evenodd", clipRule: "evenodd", 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" }) }); 11600 11601 // packages/icons/build-module/library/envelope.mjs 11602 var import_primitives26 = __toESM(require_primitives(), 1); 11603 var import_jsx_runtime43 = __toESM(require_jsx_runtime(), 1); 11604 var envelope_default = /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_primitives26.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_primitives26.Path, { fillRule: "evenodd", clipRule: "evenodd", 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" }) }); 11605 11606 // packages/icons/build-module/library/error.mjs 11607 var import_primitives27 = __toESM(require_primitives(), 1); 11608 var import_jsx_runtime44 = __toESM(require_jsx_runtime(), 1); 11609 var error_default = /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_primitives27.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_primitives27.Path, { fillRule: "evenodd", clipRule: "evenodd", 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" }) }); 11610 11611 // packages/icons/build-module/library/file.mjs 11612 var import_primitives28 = __toESM(require_primitives(), 1); 11613 var import_jsx_runtime45 = __toESM(require_jsx_runtime(), 1); 11614 var file_default = /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_primitives28.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_primitives28.Path, { fillRule: "evenodd", clipRule: "evenodd", 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" }) }); 11615 11616 // packages/icons/build-module/library/format-list-bullets-rtl.mjs 11617 var import_primitives29 = __toESM(require_primitives(), 1); 11618 var import_jsx_runtime46 = __toESM(require_jsx_runtime(), 1); 11619 var format_list_bullets_rtl_default = /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_primitives29.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_primitives29.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" }) }); 11620 11621 // packages/icons/build-module/library/format-list-bullets.mjs 11622 var import_primitives30 = __toESM(require_primitives(), 1); 11623 var import_jsx_runtime47 = __toESM(require_jsx_runtime(), 1); 11624 var format_list_bullets_default = /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(import_primitives30.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(import_primitives30.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" }) }); 11625 11626 // packages/icons/build-module/library/funnel.mjs 11627 var import_primitives31 = __toESM(require_primitives(), 1); 11628 var import_jsx_runtime48 = __toESM(require_jsx_runtime(), 1); 11629 var funnel_default = /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_primitives31.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_primitives31.Path, { d: "M10 17.5H14V16H10V17.5ZM6 6V7.5H18V6H6ZM8 12.5H16V11H8V12.5Z" }) }); 11630 11631 // packages/icons/build-module/library/globe.mjs 11632 var import_primitives32 = __toESM(require_primitives(), 1); 11633 var import_jsx_runtime49 = __toESM(require_jsx_runtime(), 1); 11634 var globe_default = /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(import_primitives32.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(import_primitives32.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" }) }); 11635 11636 // packages/icons/build-module/library/help.mjs 11637 var import_primitives33 = __toESM(require_primitives(), 1); 11638 var import_jsx_runtime50 = __toESM(require_jsx_runtime(), 1); 11639 var help_default = /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_primitives33.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_primitives33.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" }) }); 11640 11641 // packages/icons/build-module/library/home.mjs 11642 var import_primitives34 = __toESM(require_primitives(), 1); 11643 var import_jsx_runtime51 = __toESM(require_jsx_runtime(), 1); 11644 var home_default = /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_primitives34.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_primitives34.Path, { d: "M12 4L4 7.9V20h16V7.9L12 4zm6.5 14.5H14V13h-4v5.5H5.5V8.8L12 5.7l6.5 3.1v9.7z" }) }); 11645 11646 // packages/icons/build-module/library/layout.mjs 11647 var import_primitives35 = __toESM(require_primitives(), 1); 11648 var import_jsx_runtime52 = __toESM(require_jsx_runtime(), 1); 11649 var layout_default = /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_primitives35.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_primitives35.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" }) }); 11650 11651 // packages/icons/build-module/library/link.mjs 11652 var import_primitives36 = __toESM(require_primitives(), 1); 11653 var import_jsx_runtime53 = __toESM(require_jsx_runtime(), 1); 11654 var link_default = /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_primitives36.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_primitives36.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" }) }); 11655 11656 // packages/icons/build-module/library/list.mjs 11657 var import_primitives37 = __toESM(require_primitives(), 1); 11658 var import_jsx_runtime54 = __toESM(require_jsx_runtime(), 1); 11659 var list_default = /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_primitives37.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_primitives37.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" }) }); 11660 11661 // packages/icons/build-module/library/media.mjs 11662 var import_primitives38 = __toESM(require_primitives(), 1); 11663 var import_jsx_runtime55 = __toESM(require_jsx_runtime(), 1); 11664 var media_default = /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(import_primitives38.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: [ 11665 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(import_primitives38.Path, { d: "m7 6.5 4 2.5-4 2.5z" }), 11666 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(import_primitives38.Path, { fillRule: "evenodd", clipRule: "evenodd", 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" }) 11667 ] }); 11668 11669 // packages/icons/build-module/library/mobile.mjs 11670 var import_primitives39 = __toESM(require_primitives(), 1); 11671 var import_jsx_runtime56 = __toESM(require_jsx_runtime(), 1); 11672 var mobile_default = /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(import_primitives39.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(import_primitives39.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" }) }); 11673 11674 // packages/icons/build-module/library/more-vertical.mjs 11675 var import_primitives40 = __toESM(require_primitives(), 1); 11676 var import_jsx_runtime57 = __toESM(require_jsx_runtime(), 1); 11677 var more_vertical_default = /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(import_primitives40.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(import_primitives40.Path, { d: "M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z" }) }); 11678 11679 // packages/icons/build-module/library/navigation.mjs 11680 var import_primitives41 = __toESM(require_primitives(), 1); 11681 var import_jsx_runtime58 = __toESM(require_jsx_runtime(), 1); 11682 var navigation_default = /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_primitives41.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_primitives41.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" }) }); 11683 11684 // packages/icons/build-module/library/next.mjs 11685 var import_primitives42 = __toESM(require_primitives(), 1); 11686 var import_jsx_runtime59 = __toESM(require_jsx_runtime(), 1); 11687 var next_default = /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_primitives42.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_primitives42.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" }) }); 11688 11689 // packages/icons/build-module/library/not-allowed.mjs 11690 var import_primitives43 = __toESM(require_primitives(), 1); 11691 var import_jsx_runtime60 = __toESM(require_jsx_runtime(), 1); 11692 var not_allowed_default = /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(import_primitives43.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(import_primitives43.Path, { fillRule: "evenodd", clipRule: "evenodd", 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" }) }); 11693 11694 // packages/icons/build-module/library/not-found.mjs 11695 var import_primitives44 = __toESM(require_primitives(), 1); 11696 var import_jsx_runtime61 = __toESM(require_jsx_runtime(), 1); 11697 var not_found_default = /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(import_primitives44.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(import_primitives44.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" }) }); 11698 11699 // packages/icons/build-module/library/page.mjs 11700 var import_primitives45 = __toESM(require_primitives(), 1); 11701 var import_jsx_runtime62 = __toESM(require_jsx_runtime(), 1); 11702 var page_default = /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(import_primitives45.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: [ 11703 /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(import_primitives45.Path, { d: "M15.5 7.5h-7V9h7V7.5Zm-7 3.5h7v1.5h-7V11Zm7 3.5h-7V16h7v-1.5Z" }), 11704 /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(import_primitives45.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" }) 11705 ] }); 11706 11707 // packages/icons/build-module/library/pages.mjs 11708 var import_primitives46 = __toESM(require_primitives(), 1); 11709 var import_jsx_runtime63 = __toESM(require_jsx_runtime(), 1); 11710 var pages_default = /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)(import_primitives46.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: [ 11711 /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(import_primitives46.Path, { d: "M14.5 5.5h-7V7h7V5.5ZM7.5 9h7v1.5h-7V9Zm7 3.5h-7V14h7v-1.5Z" }), 11712 /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(import_primitives46.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" }), 11713 /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(import_primitives46.Path, { d: "M20 8v11c0 .69-.31 1-.999 1H6v1.5h13.001c1.52 0 2.499-.982 2.499-2.5V8H20Z" }) 11714 ] }); 11715 11716 // packages/icons/build-module/library/pencil.mjs 11717 var import_primitives47 = __toESM(require_primitives(), 1); 11718 var import_jsx_runtime64 = __toESM(require_jsx_runtime(), 1); 11719 var pencil_default = /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(import_primitives47.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(import_primitives47.Path, { d: "m19 7-3-3-8.5 8.5-1 4 4-1L19 7Zm-7 11.5H5V20h7v-1.5Z" }) }); 11720 11721 // packages/icons/build-module/library/pending.mjs 11722 var import_primitives48 = __toESM(require_primitives(), 1); 11723 var import_jsx_runtime65 = __toESM(require_jsx_runtime(), 1); 11724 var pending_default = /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(import_primitives48.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(import_primitives48.Path, { fillRule: "evenodd", clipRule: "evenodd", 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" }) }); 11725 11726 // packages/icons/build-module/library/pin.mjs 11727 var import_primitives49 = __toESM(require_primitives(), 1); 11728 var import_jsx_runtime66 = __toESM(require_jsx_runtime(), 1); 11729 var pin_default = /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_primitives49.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_primitives49.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" }) }); 11730 11731 // packages/icons/build-module/library/plugins.mjs 11732 var import_primitives50 = __toESM(require_primitives(), 1); 11733 var import_jsx_runtime67 = __toESM(require_jsx_runtime(), 1); 11734 var plugins_default = /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(import_primitives50.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(import_primitives50.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" }) }); 11735 11736 // packages/icons/build-module/library/post.mjs 11737 var import_primitives51 = __toESM(require_primitives(), 1); 11738 var import_jsx_runtime68 = __toESM(require_jsx_runtime(), 1); 11739 var post_default = /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(import_primitives51.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(import_primitives51.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" }) }); 11740 11741 // packages/icons/build-module/library/previous.mjs 11742 var import_primitives52 = __toESM(require_primitives(), 1); 11743 var import_jsx_runtime69 = __toESM(require_jsx_runtime(), 1); 11744 var previous_default = /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(import_primitives52.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(import_primitives52.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" }) }); 11745 11746 // packages/icons/build-module/library/published.mjs 11747 var import_primitives53 = __toESM(require_primitives(), 1); 11748 var import_jsx_runtime70 = __toESM(require_jsx_runtime(), 1); 11749 var published_default = /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(import_primitives53.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(import_primitives53.Path, { fillRule: "evenodd", clipRule: "evenodd", 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" }) }); 11750 11751 // packages/icons/build-module/library/rotate-left.mjs 11752 var import_primitives54 = __toESM(require_primitives(), 1); 11753 var import_jsx_runtime71 = __toESM(require_jsx_runtime(), 1); 11754 var rotate_left_default = /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(import_primitives54.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(import_primitives54.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" }) }); 11755 11756 // packages/icons/build-module/library/rotate-right.mjs 11757 var import_primitives55 = __toESM(require_primitives(), 1); 11758 var import_jsx_runtime72 = __toESM(require_jsx_runtime(), 1); 11759 var rotate_right_default = /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(import_primitives55.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(import_primitives55.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" }) }); 11760 11761 // packages/icons/build-module/library/scheduled.mjs 11762 var import_primitives56 = __toESM(require_primitives(), 1); 11763 var import_jsx_runtime73 = __toESM(require_jsx_runtime(), 1); 11764 var scheduled_default = /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(import_primitives56.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(import_primitives56.Path, { fillRule: "evenodd", clipRule: "evenodd", 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" }) }); 11765 11766 // packages/icons/build-module/library/search.mjs 11767 var import_primitives57 = __toESM(require_primitives(), 1); 11768 var import_jsx_runtime74 = __toESM(require_jsx_runtime(), 1); 11769 var search_default = /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(import_primitives57.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(import_primitives57.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" }) }); 11770 11771 // packages/icons/build-module/library/seen.mjs 11772 var import_primitives58 = __toESM(require_primitives(), 1); 11773 var import_jsx_runtime75 = __toESM(require_jsx_runtime(), 1); 11774 var seen_default = /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(import_primitives58.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(import_primitives58.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" }) }); 11775 11776 // packages/icons/build-module/library/site-logo.mjs 11777 var import_primitives59 = __toESM(require_primitives(), 1); 11778 var import_jsx_runtime76 = __toESM(require_jsx_runtime(), 1); 11779 var site_logo_default = /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(import_primitives59.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(import_primitives59.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 1.5c3.4 0 6.2 2.7 6.5 6l-1.2-.6-.8-.4c-.1 0-.2 0-.3-.1H16c-.1-.2-.4-.2-.7 0l-2.9 2.1L9 11.3h-.7L5.5 13v-1.1c0-3.6 2.9-6.5 6.5-6.5Zm0 13c-2.7 0-5-1.7-6-4l2.8-1.7 3.5 1.2h.4s.2 0 .4-.2l2.9-2.1.4.2c.6.3 1.4.7 2.1 1.1-.5 3.1-3.2 5.4-6.4 5.4Z" }) }); 11780 11781 // packages/icons/build-module/library/styles.mjs 11782 var import_primitives60 = __toESM(require_primitives(), 1); 11783 var import_jsx_runtime77 = __toESM(require_jsx_runtime(), 1); 11784 var styles_default = /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(import_primitives60.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(import_primitives60.Path, { fillRule: "evenodd", clipRule: "evenodd", 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" }) }); 11785 11786 // packages/icons/build-module/library/symbol-filled.mjs 11787 var import_primitives61 = __toESM(require_primitives(), 1); 11788 var import_jsx_runtime78 = __toESM(require_jsx_runtime(), 1); 11789 var symbol_filled_default = /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(import_primitives61.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(import_primitives61.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" }) }); 11790 11791 // packages/icons/build-module/library/symbol.mjs 11792 var import_primitives62 = __toESM(require_primitives(), 1); 11793 var import_jsx_runtime79 = __toESM(require_jsx_runtime(), 1); 11794 var symbol_default = /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(import_primitives62.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(import_primitives62.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" }) }); 11795 11796 // packages/icons/build-module/library/tag.mjs 11797 var import_primitives63 = __toESM(require_primitives(), 1); 11798 var import_jsx_runtime80 = __toESM(require_jsx_runtime(), 1); 11799 var tag_default = /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(import_primitives63.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(import_primitives63.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" }) }); 11800 11801 // packages/icons/build-module/library/trash.mjs 11802 var import_primitives64 = __toESM(require_primitives(), 1); 11803 var import_jsx_runtime81 = __toESM(require_jsx_runtime(), 1); 11804 var trash_default = /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(import_primitives64.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(import_primitives64.Path, { fillRule: "evenodd", clipRule: "evenodd", 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" }) }); 11805 11806 // packages/icons/build-module/library/unseen.mjs 11807 var import_primitives65 = __toESM(require_primitives(), 1); 11808 var import_jsx_runtime82 = __toESM(require_jsx_runtime(), 1); 11809 var unseen_default = /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(import_primitives65.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(import_primitives65.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" }) }); 11810 11811 // packages/icons/build-module/library/upload.mjs 11812 var import_primitives66 = __toESM(require_primitives(), 1); 11813 var import_jsx_runtime83 = __toESM(require_jsx_runtime(), 1); 11814 var upload_default = /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(import_primitives66.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(import_primitives66.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" }) }); 11815 11816 // packages/icons/build-module/library/verse.mjs 11817 var import_primitives67 = __toESM(require_primitives(), 1); 11818 var import_jsx_runtime84 = __toESM(require_jsx_runtime(), 1); 11819 var verse_default = /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(import_primitives67.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(import_primitives67.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" }) }); 11820 11821 // packages/icons/build-module/library/video.mjs 11822 var import_primitives68 = __toESM(require_primitives(), 1); 11823 var import_jsx_runtime85 = __toESM(require_jsx_runtime(), 1); 11824 var video_default = /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(import_primitives68.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(import_primitives68.Path, { d: "M18.7 3H5.3C4 3 3 4 3 5.3v13.4C3 20 4 21 5.3 21h13.4c1.3 0 2.3-1 2.3-2.3V5.3C21 4 20 3 18.7 3zm.8 15.7c0 .4-.4.8-.8.8H5.3c-.4 0-.8-.4-.8-.8V5.3c0-.4.4-.8.8-.8h13.4c.4 0 .8.4.8.8v13.4zM10 15l5-3-5-3v6z" }) }); 11825 11826 // packages/ui/build-module/collapsible-card/context.mjs 11827 var import_element23 = __toESM(require_element(), 1); 11828 var HeaderDescriptionIdContext = (0, import_element23.createContext)({ 11829 setDescriptionId: () => { 11830 } 11831 }); 11832 11833 // packages/ui/build-module/collapsible-card/header.mjs 11834 var import_jsx_runtime86 = __toESM(require_jsx_runtime(), 1); 11835 var STYLE_HASH_ATTRIBUTE7 = "data-wp-hash"; 11836 function getRuntime7() { 11837 const globalScope = globalThis; 11838 if (globalScope.__wpStyleRuntime) { 11839 return globalScope.__wpStyleRuntime; 11840 } 11841 globalScope.__wpStyleRuntime = { 11842 documents: /* @__PURE__ */ new Map(), 11843 styles: /* @__PURE__ */ new Map(), 11844 injectedStyles: /* @__PURE__ */ new WeakMap() 11845 }; 11846 if (typeof document !== "undefined") { 11847 registerDocument7(document); 11848 } 11849 return globalScope.__wpStyleRuntime; 11850 } 11851 function documentContainsStyleHash7(targetDocument, hash) { 11852 if (!targetDocument.head) { 11853 return false; 11854 } 11855 for (const style of targetDocument.head.querySelectorAll( 11856 `style[$STYLE_HASH_ATTRIBUTE7}]` 11857 )) { 11858 if (style.getAttribute(STYLE_HASH_ATTRIBUTE7) === hash) { 11859 return true; 11860 } 11861 } 11862 return false; 11863 } 11864 function injectStyle7(targetDocument, hash, css) { 11865 if (!targetDocument.head) { 11866 return; 11867 } 11868 const runtime = getRuntime7(); 11869 let injectedStyles = runtime.injectedStyles.get(targetDocument); 11870 if (!injectedStyles) { 11871 injectedStyles = /* @__PURE__ */ new Set(); 11872 runtime.injectedStyles.set(targetDocument, injectedStyles); 11873 } 11874 if (injectedStyles.has(hash)) { 11875 return; 11876 } 11877 if (documentContainsStyleHash7(targetDocument, hash)) { 11878 injectedStyles.add(hash); 11879 return; 11880 } 11881 const style = targetDocument.createElement("style"); 11882 style.setAttribute(STYLE_HASH_ATTRIBUTE7, hash); 11883 style.appendChild(targetDocument.createTextNode(css)); 11884 targetDocument.head.appendChild(style); 11885 injectedStyles.add(hash); 11886 } 11887 function registerDocument7(targetDocument) { 11888 const runtime = getRuntime7(); 11889 runtime.documents.set( 11890 targetDocument, 11891 (runtime.documents.get(targetDocument) ?? 0) + 1 11892 ); 11893 for (const [hash, css] of runtime.styles) { 11894 injectStyle7(targetDocument, hash, css); 11895 } 11896 return () => { 11897 const count = runtime.documents.get(targetDocument); 11898 if (count === void 0) { 11899 return; 11900 } 11901 if (count <= 1) { 11902 runtime.documents.delete(targetDocument); 11903 return; 11904 } 11905 runtime.documents.set(targetDocument, count - 1); 11906 }; 11907 } 11908 function registerStyle7(hash, css) { 11909 const runtime = getRuntime7(); 11910 runtime.styles.set(hash, css); 11911 for (const targetDocument of runtime.documents.keys()) { 11912 injectStyle7(targetDocument, hash, css); 11913 } 11914 } 11915 if (typeof process === "undefined" || true) { 11916 registerStyle7("78199613cf", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._626190151275d6d3__heading-wrapper{--_gcd-heading-color:inherit;--_gcd-heading-font-size:inherit;--_gcd-heading-font-weight:inherit;--_gcd-heading-margin:0;font-family:inherit;line-height:inherit}.cab17c7a373cb60d__header-content{flex:1;min-width:0}.dd89d27c4f15912d__header-trigger-positioner{align-self:center;flex-shrink:0;max-height:0;overflow:visible}.bcfab5f2448bafef__header-trigger-wrapper{border-radius:var(--wpds-border-radius-sm,2px);display:flex;translate:0 -50%}._3106f8d2b0330faa__header-trigger{@media not (prefers-reduced-motion){transition:rotate .15s ease-out}}._5d2dfcb4085c6d0f__header[data-panel-open] ._3106f8d2b0330faa__header-trigger{rotate:180deg}._5d2dfcb4085c6d0f__header[data-disabled] ._3106f8d2b0330faa__header-trigger{color:var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d)}.e34cf37ccd0d81e0__content{height:var(--collapsible-panel-height);margin-block-start:var(--wp-ui-card-header-content-margin);overflow:hidden;&._03cfdbcd710393c9__overflow-visible{overflow:visible}&[hidden]:not([hidden=until-found]){display:none}&[data-ending-style],&[data-starting-style]{height:0}@media not (prefers-reduced-motion){transition:all .15s ease-out}}}@layer compositions{._41bfdbf7b6c087c2__content-inner{padding-block-start:0}._5d2dfcb4085c6d0f__header{align-items:stretch;display:flex;flex-direction:row;gap:var(--wpds-dimension-gap-sm,8px);outline:none;&:not([data-disabled]){cursor:var(--wpds-cursor-control,pointer)}}}}"); 11917 } 11918 var style_default7 = { "heading-wrapper": "_626190151275d6d3__heading-wrapper", "header-content": "cab17c7a373cb60d__header-content", "header-trigger-positioner": "dd89d27c4f15912d__header-trigger-positioner", "header-trigger-wrapper": "bcfab5f2448bafef__header-trigger-wrapper", "header-trigger": "_3106f8d2b0330faa__header-trigger", "header": "_5d2dfcb4085c6d0f__header", "content": "e34cf37ccd0d81e0__content", "overflow-visible": "_03cfdbcd710393c9__overflow-visible", "content-inner": "_41bfdbf7b6c087c2__content-inner" }; 11919 if (typeof process === "undefined" || true) { 11920 registerStyle7("af6d9984a6", "._6defc79820e382c6__button{box-sizing:var(--_gcd-button-box-sizing,border-box);font-family:var(--_gcd-button-font-family,inherit);font-size:var(--_gcd-button-font-size,inherit);font-weight:var(--_gcd-button-font-weight,inherit)}.d2cff2e5dea83bd1__input{box-sizing:var(--_gcd-input-box-sizing,border-box);font-family:var(--_gcd-input-font-family,inherit);font-size:var(--_gcd-input-font-size,inherit);font-weight:var(--_gcd-input-font-weight,inherit);margin:var(--_gcd-input-margin,0);&:is(textarea,[type=text],[type=password],[type=color],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){background-color:var(--_gcd-input-background-color,transparent);border:var(--_gcd-input-border,none);border-radius:var(--_gcd-input-border-radius,0);box-shadow:var(--_gcd-input-box-shadow,0 0 0 transparent);color:var(--_gcd-input-color,var(--wpds-color-foreground-interactive-neutral,#1e1e1e));&:focus{border-color:var(--_gcd-input-border-color-focus,var(--wp-admin-theme-color));box-shadow:var(--_gcd-input-box-shadow-focus,none);outline:var(--_gcd-input-outline-focus,none)}&:disabled{background:var(--_gcd-input-background-disabled,transparent);border-color:var(--_gcd-input-border-color-disabled,transparent);box-shadow:var(--_gcd-input-box-shadow-disabled,none);color:var(--_gcd-input-color-disabled,var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d))}&::placeholder{color:var(--_gcd-input-placeholder-color,var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d))}}&:is(textarea,[type=text],[type=password],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){line-height:var(--_gcd-input-line-height,inherit);min-height:var(--_gcd-input-min-height,auto);padding:var(--_gcd-input-padding,0)}}._547d86373d02e108__textarea{box-sizing:var(--_gcd-textarea-box-sizing,border-box);overflow:var(--_gcd-textarea-overflow,auto);resize:var(--_gcd-textarea-resize,block)}._8c15fd0ed9f28ba4__div{outline:var(--_gcd-div-outline,0 solid transparent)}p._43cec3e1eec1066d__p{font-size:var(--_gcd-p-font-size,13px);line-height:var(--_gcd-p-line-height,1.5);margin:var(--_gcd-p-margin,0)}:is(h1,h2,h3,h4,h5,h6).e97669c6d9a38497__heading{color:var(--_gcd-heading-color,var(--wpds-color-foreground-content-neutral,#1e1e1e));font-size:var(--_gcd-heading-font-size,inherit);font-weight:var(--_gcd-heading-font-weight,var(--wpds-typography-font-weight-emphasis,600));margin:var(--_gcd-heading-margin,0)}._2c0831b0499dbd6e__a,._2c0831b0499dbd6e__a:is(:hover,:focus,:active){border-radius:var(--_gcd-a-border-radius,0);box-shadow:var(--_gcd-a-box-shadow,none);color:var(--_gcd-a-color,inherit);outline:var(--_gcd-a-outline,0 solid transparent);transition:var(--_gcd-a-transition,none)}"); 11921 } 11922 var global_css_defense_default2 = { "button": "_6defc79820e382c6__button", "input": "d2cff2e5dea83bd1__input", "textarea": "_547d86373d02e108__textarea", "div": "_8c15fd0ed9f28ba4__div", "p": "_43cec3e1eec1066d__p", "heading": "e97669c6d9a38497__heading", "a": "_2c0831b0499dbd6e__a" }; 11923 if (typeof process === "undefined" || true) { 11924 registerStyle7("da99a163ac", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._08e8a2e44959f892__outset-ring--focus:focus,.c5cb3ee4bddaa8e4__outset-ring--focus-within-visible:focus-within:has(:focus-visible),.cd83dfc2126a0846__outset-ring--focus-within:focus-within,.d0541bc9dd9dc7b6__outset-ring--focus-visible:focus-visible,:focus-visible .ecadb9e080e2dfa5__outset-ring--focus-parent-visible{--_gcd-a-outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus,var(--wp-admin-theme-color,#3858e9));--_gcd-div-outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus,var(--wp-admin-theme-color,#3858e9));outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus,var(--wp-admin-theme-color,#3858e9));outline-offset:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px))}._970d04df7376df67__outset-ring--focus-within-except-active:focus-within,.e25b2bdd7aa21721__outset-ring--focus-except-active:focus{outline:none}._970d04df7376df67__outset-ring--focus-within-except-active:focus-within:not(:has(:active)),.e25b2bdd7aa21721__outset-ring--focus-except-active:focus:not(:active){@include mixins.focus-ring()}}}"); 11925 } 11926 var focus_default = { "outset-ring--focus": "_08e8a2e44959f892__outset-ring--focus", "outset-ring--focus-visible": "d0541bc9dd9dc7b6__outset-ring--focus-visible", "outset-ring--focus-within": "cd83dfc2126a0846__outset-ring--focus-within", "outset-ring--focus-within-visible": "c5cb3ee4bddaa8e4__outset-ring--focus-within-visible", "outset-ring--focus-parent-visible": "ecadb9e080e2dfa5__outset-ring--focus-parent-visible", "outset-ring--focus-except-active": "e25b2bdd7aa21721__outset-ring--focus-except-active", "outset-ring--focus-within-except-active": "_970d04df7376df67__outset-ring--focus-within-except-active" }; 11927 var Header2 = (0, import_element24.forwardRef)( 11928 function CollapsibleCardHeader({ children, className, render: render4, ...restProps }, ref) { 11929 const [descriptionId, setDescriptionId] = (0, import_element24.useState)(); 11930 const contextValue = (0, import_element24.useMemo)( 11931 () => ({ setDescriptionId }), 11932 [setDescriptionId] 11933 ); 11934 return useRender({ 11935 defaultTagName: "div", 11936 render: render4, 11937 ref, 11938 props: mergeProps(restProps, { 11939 className: clsx_default( 11940 global_css_defense_default2.heading, 11941 style_default7["heading-wrapper"], 11942 className 11943 ), 11944 children: /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(HeaderDescriptionIdContext.Provider, { value: contextValue, children: /* @__PURE__ */ (0, import_jsx_runtime86.jsxs)( 11945 Trigger, 11946 { 11947 className: style_default7.header, 11948 render: /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(Header, {}), 11949 nativeButton: false, 11950 "aria-describedby": descriptionId, 11951 children: [ 11952 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)("div", { className: style_default7["header-content"], children }), 11953 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)( 11954 "div", 11955 { 11956 className: clsx_default( 11957 style_default7["header-trigger-positioner"] 11958 ), 11959 children: /* @__PURE__ */ (0, import_jsx_runtime86.jsx)( 11960 "div", 11961 { 11962 className: clsx_default( 11963 style_default7["header-trigger-wrapper"], 11964 global_css_defense_default2.div, 11965 // While the interactive trigger element is the whole header, 11966 // the focus ring will be displayed only on the icon to visually 11967 // emulate it being the button. 11968 focus_default["outset-ring--focus-parent-visible"] 11969 ), 11970 children: /* @__PURE__ */ (0, import_jsx_runtime86.jsx)( 11971 Icon, 11972 { 11973 icon: chevron_down_default, 11974 className: style_default7["header-trigger"] 11975 } 11976 ) 11977 } 11978 ) 11979 } 11980 ) 11981 ] 11982 } 11983 ) }) 11984 }) 11985 }); 11986 } 11987 ); 11988 11989 // packages/ui/build-module/collapsible-card/header-description.mjs 11990 var import_element25 = __toESM(require_element(), 1); 11991 var import_jsx_runtime87 = __toESM(require_jsx_runtime(), 1); 11992 var HeaderDescription = (0, import_element25.forwardRef)(function CollapsibleCardHeaderDescription({ children, className, ...restProps }, ref) { 11993 const descriptionId = (0, import_element25.useId)(); 11994 const { setDescriptionId } = (0, import_element25.useContext)(HeaderDescriptionIdContext); 11995 (0, import_element25.useEffect)(() => { 11996 setDescriptionId(descriptionId); 11997 return () => setDescriptionId(void 0); 11998 }, [descriptionId, setDescriptionId]); 11999 return /* @__PURE__ */ (0, import_jsx_runtime87.jsx)( 12000 "div", 12001 { 12002 ref, 12003 id: descriptionId, 12004 "aria-hidden": "true", 12005 className, 12006 ...restProps, 12007 children 12008 } 12009 ); 12010 }); 12011 12012 // packages/ui/build-module/collapsible-card/content.mjs 12013 var import_element26 = __toESM(require_element(), 1); 12014 var import_jsx_runtime88 = __toESM(require_jsx_runtime(), 1); 12015 var STYLE_HASH_ATTRIBUTE8 = "data-wp-hash"; 12016 function getRuntime8() { 12017 const globalScope = globalThis; 12018 if (globalScope.__wpStyleRuntime) { 12019 return globalScope.__wpStyleRuntime; 12020 } 12021 globalScope.__wpStyleRuntime = { 12022 documents: /* @__PURE__ */ new Map(), 12023 styles: /* @__PURE__ */ new Map(), 12024 injectedStyles: /* @__PURE__ */ new WeakMap() 12025 }; 12026 if (typeof document !== "undefined") { 12027 registerDocument8(document); 12028 } 12029 return globalScope.__wpStyleRuntime; 12030 } 12031 function documentContainsStyleHash8(targetDocument, hash) { 12032 if (!targetDocument.head) { 12033 return false; 12034 } 12035 for (const style of targetDocument.head.querySelectorAll( 12036 `style[$STYLE_HASH_ATTRIBUTE8}]` 12037 )) { 12038 if (style.getAttribute(STYLE_HASH_ATTRIBUTE8) === hash) { 12039 return true; 12040 } 12041 } 12042 return false; 12043 } 12044 function injectStyle8(targetDocument, hash, css) { 12045 if (!targetDocument.head) { 12046 return; 12047 } 12048 const runtime = getRuntime8(); 12049 let injectedStyles = runtime.injectedStyles.get(targetDocument); 12050 if (!injectedStyles) { 12051 injectedStyles = /* @__PURE__ */ new Set(); 12052 runtime.injectedStyles.set(targetDocument, injectedStyles); 12053 } 12054 if (injectedStyles.has(hash)) { 12055 return; 12056 } 12057 if (documentContainsStyleHash8(targetDocument, hash)) { 12058 injectedStyles.add(hash); 12059 return; 12060 } 12061 const style = targetDocument.createElement("style"); 12062 style.setAttribute(STYLE_HASH_ATTRIBUTE8, hash); 12063 style.appendChild(targetDocument.createTextNode(css)); 12064 targetDocument.head.appendChild(style); 12065 injectedStyles.add(hash); 12066 } 12067 function registerDocument8(targetDocument) { 12068 const runtime = getRuntime8(); 12069 runtime.documents.set( 12070 targetDocument, 12071 (runtime.documents.get(targetDocument) ?? 0) + 1 12072 ); 12073 for (const [hash, css] of runtime.styles) { 12074 injectStyle8(targetDocument, hash, css); 12075 } 12076 return () => { 12077 const count = runtime.documents.get(targetDocument); 12078 if (count === void 0) { 12079 return; 12080 } 12081 if (count <= 1) { 12082 runtime.documents.delete(targetDocument); 12083 return; 12084 } 12085 runtime.documents.set(targetDocument, count - 1); 12086 }; 12087 } 12088 function registerStyle8(hash, css) { 12089 const runtime = getRuntime8(); 12090 runtime.styles.set(hash, css); 12091 for (const targetDocument of runtime.documents.keys()) { 12092 injectStyle8(targetDocument, hash, css); 12093 } 12094 } 12095 if (typeof process === "undefined" || true) { 12096 registerStyle8("78199613cf", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._626190151275d6d3__heading-wrapper{--_gcd-heading-color:inherit;--_gcd-heading-font-size:inherit;--_gcd-heading-font-weight:inherit;--_gcd-heading-margin:0;font-family:inherit;line-height:inherit}.cab17c7a373cb60d__header-content{flex:1;min-width:0}.dd89d27c4f15912d__header-trigger-positioner{align-self:center;flex-shrink:0;max-height:0;overflow:visible}.bcfab5f2448bafef__header-trigger-wrapper{border-radius:var(--wpds-border-radius-sm,2px);display:flex;translate:0 -50%}._3106f8d2b0330faa__header-trigger{@media not (prefers-reduced-motion){transition:rotate .15s ease-out}}._5d2dfcb4085c6d0f__header[data-panel-open] ._3106f8d2b0330faa__header-trigger{rotate:180deg}._5d2dfcb4085c6d0f__header[data-disabled] ._3106f8d2b0330faa__header-trigger{color:var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d)}.e34cf37ccd0d81e0__content{height:var(--collapsible-panel-height);margin-block-start:var(--wp-ui-card-header-content-margin);overflow:hidden;&._03cfdbcd710393c9__overflow-visible{overflow:visible}&[hidden]:not([hidden=until-found]){display:none}&[data-ending-style],&[data-starting-style]{height:0}@media not (prefers-reduced-motion){transition:all .15s ease-out}}}@layer compositions{._41bfdbf7b6c087c2__content-inner{padding-block-start:0}._5d2dfcb4085c6d0f__header{align-items:stretch;display:flex;flex-direction:row;gap:var(--wpds-dimension-gap-sm,8px);outline:none;&:not([data-disabled]){cursor:var(--wpds-cursor-control,pointer)}}}}"); 12097 } 12098 var style_default8 = { "heading-wrapper": "_626190151275d6d3__heading-wrapper", "header-content": "cab17c7a373cb60d__header-content", "header-trigger-positioner": "dd89d27c4f15912d__header-trigger-positioner", "header-trigger-wrapper": "bcfab5f2448bafef__header-trigger-wrapper", "header-trigger": "_3106f8d2b0330faa__header-trigger", "header": "_5d2dfcb4085c6d0f__header", "content": "e34cf37ccd0d81e0__content", "overflow-visible": "_03cfdbcd710393c9__overflow-visible", "content-inner": "_41bfdbf7b6c087c2__content-inner" }; 12099 var Content2 = (0, import_element26.forwardRef)( 12100 function CollapsibleCardContent({ className, render: render4, children, hiddenUntilFound = true, ...restProps }, ref) { 12101 return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)( 12102 Panel, 12103 { 12104 ref, 12105 className: (state) => clsx_default( 12106 style_default8.content, 12107 state.open && state.transitionStatus === "idle" && style_default8["overflow-visible"], 12108 className 12109 ), 12110 hiddenUntilFound, 12111 ...restProps, 12112 children: /* @__PURE__ */ (0, import_jsx_runtime88.jsx)( 12113 Content, 12114 { 12115 className: style_default8["content-inner"], 12116 render: render4, 12117 children 12118 } 12119 ) 12120 } 12121 ); 12122 } 12123 ); 12124 12125 // packages/ui/build-module/utils/render-slot-with-children.mjs 12126 var import_element27 = __toESM(require_element(), 1); 12127 function renderSlotWithChildren(slot, defaultSlot, children) { 12128 return (0, import_element27.cloneElement)(slot ?? defaultSlot, { children }); 12129 } 12130 12131 // packages/ui/build-module/utils/theme-provider.mjs 12132 var theme = __toESM(require_theme(), 1); 12133 12134 // packages/ui/build-module/lock-unlock.mjs 12135 var import_private_apis2 = __toESM(require_private_apis(), 1); 12136 var { lock: lock2, unlock: unlock2 } = (0, import_private_apis2.__dangerousOptInToUnstableAPIsOnlyForCoreModules)( 12137 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.", 12138 "@wordpress/ui" 12139 ); 12140 12141 // packages/ui/build-module/utils/theme-provider.mjs 12142 function getThemeProvider() { 12143 const themePackage = theme; 12144 if (themePackage.ThemeProvider) { 12145 return themePackage.ThemeProvider; 12146 } 12147 if (!themePackage.privateApis) { 12148 throw new Error( 12149 "@wordpress/ui: @wordpress/theme must expose `ThemeProvider` or `privateApis.ThemeProvider`." 12150 ); 12151 } 12152 return unlock2( 12153 themePackage.privateApis 12154 ).ThemeProvider; 12155 } 12156 var ThemeProvider = getThemeProvider(); 12157 12158 // packages/ui/build-module/stack/stack.mjs 12159 var import_element28 = __toESM(require_element(), 1); 12160 var STYLE_HASH_ATTRIBUTE9 = "data-wp-hash"; 12161 function getRuntime9() { 12162 const globalScope = globalThis; 12163 if (globalScope.__wpStyleRuntime) { 12164 return globalScope.__wpStyleRuntime; 12165 } 12166 globalScope.__wpStyleRuntime = { 12167 documents: /* @__PURE__ */ new Map(), 12168 styles: /* @__PURE__ */ new Map(), 12169 injectedStyles: /* @__PURE__ */ new WeakMap() 12170 }; 12171 if (typeof document !== "undefined") { 12172 registerDocument9(document); 12173 } 12174 return globalScope.__wpStyleRuntime; 12175 } 12176 function documentContainsStyleHash9(targetDocument, hash) { 12177 if (!targetDocument.head) { 12178 return false; 12179 } 12180 for (const style of targetDocument.head.querySelectorAll( 12181 `style[$STYLE_HASH_ATTRIBUTE9}]` 12182 )) { 12183 if (style.getAttribute(STYLE_HASH_ATTRIBUTE9) === hash) { 12184 return true; 12185 } 12186 } 12187 return false; 12188 } 12189 function injectStyle9(targetDocument, hash, css) { 12190 if (!targetDocument.head) { 12191 return; 12192 } 12193 const runtime = getRuntime9(); 12194 let injectedStyles = runtime.injectedStyles.get(targetDocument); 12195 if (!injectedStyles) { 12196 injectedStyles = /* @__PURE__ */ new Set(); 12197 runtime.injectedStyles.set(targetDocument, injectedStyles); 12198 } 12199 if (injectedStyles.has(hash)) { 12200 return; 12201 } 12202 if (documentContainsStyleHash9(targetDocument, hash)) { 12203 injectedStyles.add(hash); 12204 return; 12205 } 12206 const style = targetDocument.createElement("style"); 12207 style.setAttribute(STYLE_HASH_ATTRIBUTE9, hash); 12208 style.appendChild(targetDocument.createTextNode(css)); 12209 targetDocument.head.appendChild(style); 12210 injectedStyles.add(hash); 12211 } 12212 function registerDocument9(targetDocument) { 12213 const runtime = getRuntime9(); 12214 runtime.documents.set( 12215 targetDocument, 12216 (runtime.documents.get(targetDocument) ?? 0) + 1 12217 ); 12218 for (const [hash, css] of runtime.styles) { 12219 injectStyle9(targetDocument, hash, css); 12220 } 12221 return () => { 12222 const count = runtime.documents.get(targetDocument); 12223 if (count === void 0) { 12224 return; 12225 } 12226 if (count <= 1) { 12227 runtime.documents.delete(targetDocument); 12228 return; 12229 } 12230 runtime.documents.set(targetDocument, count - 1); 12231 }; 12232 } 12233 function registerStyle9(hash, css) { 12234 const runtime = getRuntime9(); 12235 runtime.styles.set(hash, css); 12236 for (const targetDocument of runtime.documents.keys()) { 12237 injectStyle9(targetDocument, hash, css); 12238 } 12239 } 12240 if (typeof process === "undefined" || true) { 12241 registerStyle9("32aba35fe1", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._19ce0419607e1896__stack{display:flex}}}"); 12242 } 12243 var style_default9 = { "stack": "_19ce0419607e1896__stack" }; 12244 var gapTokens = { 12245 xs: "var(--wpds-dimension-gap-xs, 4px)", 12246 sm: "var(--wpds-dimension-gap-sm, 8px)", 12247 md: "var(--wpds-dimension-gap-md, 12px)", 12248 lg: "var(--wpds-dimension-gap-lg, 16px)", 12249 xl: "var(--wpds-dimension-gap-xl, 24px)", 12250 "2xl": "var(--wpds-dimension-gap-2xl, 32px)", 12251 "3xl": "var(--wpds-dimension-gap-3xl, 40px)" 12252 }; 12253 var Stack = (0, import_element28.forwardRef)(function Stack2({ direction, gap, align, justify, wrap, render: render4, ...props }, ref) { 12254 const style = { 12255 gap: gap && gapTokens[gap], 12256 alignItems: align, 12257 justifyContent: justify, 12258 flexDirection: direction, 12259 flexWrap: wrap 12260 }; 12261 const element = useRender({ 12262 render: render4, 12263 ref, 12264 props: mergeProps(props, { style, className: style_default9.stack }) 12265 }); 12266 return element; 12267 }); 12268 12269 // packages/ui/build-module/tooltip/index.mjs 12270 var tooltip_exports = {}; 12271 __export(tooltip_exports, { 12272 Popup: () => Popup, 12273 Portal: () => Portal, 12274 Positioner: () => Positioner, 12275 Provider: () => Provider, 12276 Root: () => Root4, 12277 Trigger: () => Trigger2 12278 }); 12279 12280 // packages/ui/build-module/tooltip/popup.mjs 12281 var import_element31 = __toESM(require_element(), 1); 12282 12283 // packages/ui/build-module/tooltip/portal.mjs 12284 var import_element29 = __toESM(require_element(), 1); 12285 12286 // packages/ui/build-module/utils/wp-compat-overlay-slot.mjs 12287 var STYLE_HASH_ATTRIBUTE10 = "data-wp-hash"; 12288 function getRuntime10() { 12289 const globalScope = globalThis; 12290 if (globalScope.__wpStyleRuntime) { 12291 return globalScope.__wpStyleRuntime; 12292 } 12293 globalScope.__wpStyleRuntime = { 12294 documents: /* @__PURE__ */ new Map(), 12295 styles: /* @__PURE__ */ new Map(), 12296 injectedStyles: /* @__PURE__ */ new WeakMap() 12297 }; 12298 if (typeof document !== "undefined") { 12299 registerDocument10(document); 12300 } 12301 return globalScope.__wpStyleRuntime; 12302 } 12303 function documentContainsStyleHash10(targetDocument, hash) { 12304 if (!targetDocument.head) { 12305 return false; 12306 } 12307 for (const style of targetDocument.head.querySelectorAll( 12308 `style[$STYLE_HASH_ATTRIBUTE10}]` 12309 )) { 12310 if (style.getAttribute(STYLE_HASH_ATTRIBUTE10) === hash) { 12311 return true; 12312 } 12313 } 12314 return false; 12315 } 12316 function injectStyle10(targetDocument, hash, css) { 12317 if (!targetDocument.head) { 12318 return; 12319 } 12320 const runtime = getRuntime10(); 12321 let injectedStyles = runtime.injectedStyles.get(targetDocument); 12322 if (!injectedStyles) { 12323 injectedStyles = /* @__PURE__ */ new Set(); 12324 runtime.injectedStyles.set(targetDocument, injectedStyles); 12325 } 12326 if (injectedStyles.has(hash)) { 12327 return; 12328 } 12329 if (documentContainsStyleHash10(targetDocument, hash)) { 12330 injectedStyles.add(hash); 12331 return; 12332 } 12333 const style = targetDocument.createElement("style"); 12334 style.setAttribute(STYLE_HASH_ATTRIBUTE10, hash); 12335 style.appendChild(targetDocument.createTextNode(css)); 12336 targetDocument.head.appendChild(style); 12337 injectedStyles.add(hash); 12338 } 12339 function registerDocument10(targetDocument) { 12340 const runtime = getRuntime10(); 12341 runtime.documents.set( 12342 targetDocument, 12343 (runtime.documents.get(targetDocument) ?? 0) + 1 12344 ); 12345 for (const [hash, css] of runtime.styles) { 12346 injectStyle10(targetDocument, hash, css); 12347 } 12348 return () => { 12349 const count = runtime.documents.get(targetDocument); 12350 if (count === void 0) { 12351 return; 12352 } 12353 if (count <= 1) { 12354 runtime.documents.delete(targetDocument); 12355 return; 12356 } 12357 runtime.documents.set(targetDocument, count - 1); 12358 }; 12359 } 12360 function registerStyle10(hash, css) { 12361 const runtime = getRuntime10(); 12362 runtime.styles.set(hash, css); 12363 for (const targetDocument of runtime.documents.keys()) { 12364 injectStyle10(targetDocument, hash, css); 12365 } 12366 } 12367 if (typeof process === "undefined" || true) { 12368 registerStyle10("be37f31c1e", "._11fc52b637ff8a7e__slot{inset:0;isolation:isolate;pointer-events:none;position:fixed;z-index:1000000003}@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._11fc52b637ff8a7e__slot>*{pointer-events:auto}}}"); 12369 } 12370 var wp_compat_overlay_slot_default = { "slot": "_11fc52b637ff8a7e__slot" }; 12371 var WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE = "data-wp-compat-overlay-slot"; 12372 function resolveOwnerDocument() { 12373 return typeof document === "undefined" ? null : document; 12374 } 12375 function isInWordPressEnvironment() { 12376 let topWp; 12377 try { 12378 topWp = window.top?.wp; 12379 } catch { 12380 } 12381 const wp = topWp ?? window.wp; 12382 return typeof wp?.components === "object" && wp.components !== null; 12383 } 12384 var cachedSlot = null; 12385 function ensureSlotIsAccessible(element) { 12386 element.setAttribute("aria-hidden", "false"); 12387 return element; 12388 } 12389 function createSlot(ownerDocument2) { 12390 const element = ownerDocument2.createElement("div"); 12391 element.setAttribute(WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE, ""); 12392 if (wp_compat_overlay_slot_default.slot) { 12393 element.classList.add(wp_compat_overlay_slot_default.slot); 12394 } 12395 ownerDocument2.body.appendChild(element); 12396 return element; 12397 } 12398 function getWpCompatOverlaySlot() { 12399 if (typeof window === "undefined") { 12400 return void 0; 12401 } 12402 if (!isInWordPressEnvironment() && window.__wpUiCompatOverlaySlotEnabled !== true) { 12403 return void 0; 12404 } 12405 const ownerDocument2 = resolveOwnerDocument(); 12406 if (!ownerDocument2 || !ownerDocument2.body) { 12407 return void 0; 12408 } 12409 if (cachedSlot && cachedSlot.ownerDocument === ownerDocument2 && cachedSlot.isConnected) { 12410 return ensureSlotIsAccessible(cachedSlot); 12411 } 12412 const existing = ownerDocument2.querySelector( 12413 `[$WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE}]` 12414 ); 12415 if (existing instanceof HTMLDivElement) { 12416 cachedSlot = ensureSlotIsAccessible(existing); 12417 return cachedSlot; 12418 } 12419 if (cachedSlot?.isConnected) { 12420 cachedSlot.remove(); 12421 } 12422 cachedSlot = ensureSlotIsAccessible(createSlot(ownerDocument2)); 12423 return cachedSlot; 12424 } 12425 12426 // packages/ui/build-module/tooltip/portal.mjs 12427 var import_jsx_runtime89 = __toESM(require_jsx_runtime(), 1); 12428 var Portal = (0, import_element29.forwardRef)( 12429 function TooltipPortal3({ container, ...restProps }, ref) { 12430 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)( 12431 index_parts_exports2.Portal, 12432 { 12433 container: container ?? getWpCompatOverlaySlot(), 12434 ...restProps, 12435 ref 12436 } 12437 ); 12438 } 12439 ); 12440 12441 // packages/ui/build-module/tooltip/positioner.mjs 12442 var import_element30 = __toESM(require_element(), 1); 12443 var import_jsx_runtime90 = __toESM(require_jsx_runtime(), 1); 12444 var STYLE_HASH_ATTRIBUTE11 = "data-wp-hash"; 12445 function getRuntime11() { 12446 const globalScope = globalThis; 12447 if (globalScope.__wpStyleRuntime) { 12448 return globalScope.__wpStyleRuntime; 12449 } 12450 globalScope.__wpStyleRuntime = { 12451 documents: /* @__PURE__ */ new Map(), 12452 styles: /* @__PURE__ */ new Map(), 12453 injectedStyles: /* @__PURE__ */ new WeakMap() 12454 }; 12455 if (typeof document !== "undefined") { 12456 registerDocument11(document); 12457 } 12458 return globalScope.__wpStyleRuntime; 12459 } 12460 function documentContainsStyleHash11(targetDocument, hash) { 12461 if (!targetDocument.head) { 12462 return false; 12463 } 12464 for (const style of targetDocument.head.querySelectorAll( 12465 `style[$STYLE_HASH_ATTRIBUTE11}]` 12466 )) { 12467 if (style.getAttribute(STYLE_HASH_ATTRIBUTE11) === hash) { 12468 return true; 12469 } 12470 } 12471 return false; 12472 } 12473 function injectStyle11(targetDocument, hash, css) { 12474 if (!targetDocument.head) { 12475 return; 12476 } 12477 const runtime = getRuntime11(); 12478 let injectedStyles = runtime.injectedStyles.get(targetDocument); 12479 if (!injectedStyles) { 12480 injectedStyles = /* @__PURE__ */ new Set(); 12481 runtime.injectedStyles.set(targetDocument, injectedStyles); 12482 } 12483 if (injectedStyles.has(hash)) { 12484 return; 12485 } 12486 if (documentContainsStyleHash11(targetDocument, hash)) { 12487 injectedStyles.add(hash); 12488 return; 12489 } 12490 const style = targetDocument.createElement("style"); 12491 style.setAttribute(STYLE_HASH_ATTRIBUTE11, hash); 12492 style.appendChild(targetDocument.createTextNode(css)); 12493 targetDocument.head.appendChild(style); 12494 injectedStyles.add(hash); 12495 } 12496 function registerDocument11(targetDocument) { 12497 const runtime = getRuntime11(); 12498 runtime.documents.set( 12499 targetDocument, 12500 (runtime.documents.get(targetDocument) ?? 0) + 1 12501 ); 12502 for (const [hash, css] of runtime.styles) { 12503 injectStyle11(targetDocument, hash, css); 12504 } 12505 return () => { 12506 const count = runtime.documents.get(targetDocument); 12507 if (count === void 0) { 12508 return; 12509 } 12510 if (count <= 1) { 12511 runtime.documents.delete(targetDocument); 12512 return; 12513 } 12514 runtime.documents.set(targetDocument, count - 1); 12515 }; 12516 } 12517 function registerStyle11(hash, css) { 12518 const runtime = getRuntime11(); 12519 runtime.styles.set(hash, css); 12520 for (const targetDocument of runtime.documents.keys()) { 12521 injectStyle11(targetDocument, hash, css); 12522 } 12523 } 12524 if (typeof process === "undefined" || true) { 12525 registerStyle11("10f3806643", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}}"); 12526 } 12527 var resets_default2 = { "box-sizing": "_336cd3e4e743482f__box-sizing" }; 12528 if (typeof process === "undefined" || true) { 12529 registerStyle11("19fcc06039", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._480b748dd3510e64__positioner{z-index:var(--wp-ui-tooltip-z-index,initial)}._50096b232db7709d__popup{--_wp-ui-elevation-sm:0 1px 2px rgba(0,0,0,.05),0 2px 3px rgba(0,0,0,.04),0 6px 6px rgba(0,0,0,.03),0 8px 8px rgba(0,0,0,.02);background-color:var(--wpds-color-background-surface-neutral-strong,#fff);border-radius:var(--wpds-border-radius-md,4px);box-shadow:var(--_wp-ui-elevation-sm);color:var(--wpds-color-foreground-content-neutral,#1e1e1e);font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-sm,12px);line-height:1.4;padding:var(--wpds-dimension-padding-xs,4px) var(--wpds-dimension-padding-sm,8px);@media (forced-colors:active){border-bottom-color:CanvasText;border-bottom-style:solid;border-bottom-width:1px;border-left-color:CanvasText;border-left-style:solid;border-left-width:1px;border-right-color:CanvasText;border-right-style:solid;border-right-width:1px;border-top-color:CanvasText;border-top-style:solid;border-top-width:1px}}}}'); 12530 } 12531 var style_default10 = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" }; 12532 var Positioner = (0, import_element30.forwardRef)( 12533 function TooltipPositioner3({ align = "center", className, side = "top", sideOffset = 4, ...props }, ref) { 12534 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)( 12535 index_parts_exports2.Positioner, 12536 { 12537 ref, 12538 align, 12539 side, 12540 sideOffset, 12541 ...props, 12542 className: clsx_default( 12543 resets_default2["box-sizing"], 12544 style_default10.positioner, 12545 className 12546 ) 12547 } 12548 ); 12549 } 12550 ); 12551 12552 // packages/ui/build-module/tooltip/popup.mjs 12553 var import_jsx_runtime91 = __toESM(require_jsx_runtime(), 1); 12554 var STYLE_HASH_ATTRIBUTE12 = "data-wp-hash"; 12555 function getRuntime12() { 12556 const globalScope = globalThis; 12557 if (globalScope.__wpStyleRuntime) { 12558 return globalScope.__wpStyleRuntime; 12559 } 12560 globalScope.__wpStyleRuntime = { 12561 documents: /* @__PURE__ */ new Map(), 12562 styles: /* @__PURE__ */ new Map(), 12563 injectedStyles: /* @__PURE__ */ new WeakMap() 12564 }; 12565 if (typeof document !== "undefined") { 12566 registerDocument12(document); 12567 } 12568 return globalScope.__wpStyleRuntime; 12569 } 12570 function documentContainsStyleHash12(targetDocument, hash) { 12571 if (!targetDocument.head) { 12572 return false; 12573 } 12574 for (const style of targetDocument.head.querySelectorAll( 12575 `style[$STYLE_HASH_ATTRIBUTE12}]` 12576 )) { 12577 if (style.getAttribute(STYLE_HASH_ATTRIBUTE12) === hash) { 12578 return true; 12579 } 12580 } 12581 return false; 12582 } 12583 function injectStyle12(targetDocument, hash, css) { 12584 if (!targetDocument.head) { 12585 return; 12586 } 12587 const runtime = getRuntime12(); 12588 let injectedStyles = runtime.injectedStyles.get(targetDocument); 12589 if (!injectedStyles) { 12590 injectedStyles = /* @__PURE__ */ new Set(); 12591 runtime.injectedStyles.set(targetDocument, injectedStyles); 12592 } 12593 if (injectedStyles.has(hash)) { 12594 return; 12595 } 12596 if (documentContainsStyleHash12(targetDocument, hash)) { 12597 injectedStyles.add(hash); 12598 return; 12599 } 12600 const style = targetDocument.createElement("style"); 12601 style.setAttribute(STYLE_HASH_ATTRIBUTE12, hash); 12602 style.appendChild(targetDocument.createTextNode(css)); 12603 targetDocument.head.appendChild(style); 12604 injectedStyles.add(hash); 12605 } 12606 function registerDocument12(targetDocument) { 12607 const runtime = getRuntime12(); 12608 runtime.documents.set( 12609 targetDocument, 12610 (runtime.documents.get(targetDocument) ?? 0) + 1 12611 ); 12612 for (const [hash, css] of runtime.styles) { 12613 injectStyle12(targetDocument, hash, css); 12614 } 12615 return () => { 12616 const count = runtime.documents.get(targetDocument); 12617 if (count === void 0) { 12618 return; 12619 } 12620 if (count <= 1) { 12621 runtime.documents.delete(targetDocument); 12622 return; 12623 } 12624 runtime.documents.set(targetDocument, count - 1); 12625 }; 12626 } 12627 function registerStyle12(hash, css) { 12628 const runtime = getRuntime12(); 12629 runtime.styles.set(hash, css); 12630 for (const targetDocument of runtime.documents.keys()) { 12631 injectStyle12(targetDocument, hash, css); 12632 } 12633 } 12634 if (typeof process === "undefined" || true) { 12635 registerStyle12("19fcc06039", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._480b748dd3510e64__positioner{z-index:var(--wp-ui-tooltip-z-index,initial)}._50096b232db7709d__popup{--_wp-ui-elevation-sm:0 1px 2px rgba(0,0,0,.05),0 2px 3px rgba(0,0,0,.04),0 6px 6px rgba(0,0,0,.03),0 8px 8px rgba(0,0,0,.02);background-color:var(--wpds-color-background-surface-neutral-strong,#fff);border-radius:var(--wpds-border-radius-md,4px);box-shadow:var(--_wp-ui-elevation-sm);color:var(--wpds-color-foreground-content-neutral,#1e1e1e);font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-sm,12px);line-height:1.4;padding:var(--wpds-dimension-padding-xs,4px) var(--wpds-dimension-padding-sm,8px);@media (forced-colors:active){border-bottom-color:CanvasText;border-bottom-style:solid;border-bottom-width:1px;border-left-color:CanvasText;border-left-style:solid;border-left-width:1px;border-right-color:CanvasText;border-right-style:solid;border-right-width:1px;border-top-color:CanvasText;border-top-style:solid;border-top-width:1px}}}}'); 12636 } 12637 var style_default11 = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" }; 12638 var POPUP_COLOR = { background: "#1e1e1e" }; 12639 var Popup = (0, import_element31.forwardRef)(function TooltipPopup3({ portal, positioner, children, className, ...props }, ref) { 12640 const popupContent = /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(ThemeProvider, { color: POPUP_COLOR, children: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)( 12641 index_parts_exports2.Popup, 12642 { 12643 ref, 12644 className: clsx_default(style_default11.popup, className), 12645 ...props, 12646 children 12647 } 12648 ) }); 12649 const positionedPopup = renderSlotWithChildren( 12650 positioner, 12651 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(Positioner, {}), 12652 popupContent 12653 ); 12654 return renderSlotWithChildren(portal, /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(Portal, {}), positionedPopup); 12655 }); 12656 12657 // packages/ui/build-module/tooltip/trigger.mjs 12658 var import_element32 = __toESM(require_element(), 1); 12659 var import_jsx_runtime92 = __toESM(require_jsx_runtime(), 1); 12660 var Trigger2 = (0, import_element32.forwardRef)( 12661 function TooltipTrigger3(props, ref) { 12662 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(index_parts_exports2.Trigger, { ref, ...props }); 12663 } 12664 ); 12665 12666 // packages/ui/build-module/tooltip/root.mjs 12667 var import_jsx_runtime93 = __toESM(require_jsx_runtime(), 1); 12668 function Root4(props) { 12669 return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(index_parts_exports2.Root, { ...props }); 12670 } 12671 12672 // packages/ui/build-module/tooltip/provider.mjs 12673 var import_jsx_runtime94 = __toESM(require_jsx_runtime(), 1); 12674 function Provider({ ...props }) { 12675 return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(index_parts_exports2.Provider, { ...props }); 12676 } 12677 12678 // packages/ui/build-module/visually-hidden/visually-hidden.mjs 12679 var import_element33 = __toESM(require_element(), 1); 12680 var STYLE_HASH_ATTRIBUTE13 = "data-wp-hash"; 12681 function getRuntime13() { 12682 const globalScope = globalThis; 12683 if (globalScope.__wpStyleRuntime) { 12684 return globalScope.__wpStyleRuntime; 12685 } 12686 globalScope.__wpStyleRuntime = { 12687 documents: /* @__PURE__ */ new Map(), 12688 styles: /* @__PURE__ */ new Map(), 12689 injectedStyles: /* @__PURE__ */ new WeakMap() 12690 }; 12691 if (typeof document !== "undefined") { 12692 registerDocument13(document); 12693 } 12694 return globalScope.__wpStyleRuntime; 12695 } 12696 function documentContainsStyleHash13(targetDocument, hash) { 12697 if (!targetDocument.head) { 12698 return false; 12699 } 12700 for (const style of targetDocument.head.querySelectorAll( 12701 `style[$STYLE_HASH_ATTRIBUTE13}]` 12702 )) { 12703 if (style.getAttribute(STYLE_HASH_ATTRIBUTE13) === hash) { 12704 return true; 12705 } 12706 } 12707 return false; 12708 } 12709 function injectStyle13(targetDocument, hash, css) { 12710 if (!targetDocument.head) { 12711 return; 12712 } 12713 const runtime = getRuntime13(); 12714 let injectedStyles = runtime.injectedStyles.get(targetDocument); 12715 if (!injectedStyles) { 12716 injectedStyles = /* @__PURE__ */ new Set(); 12717 runtime.injectedStyles.set(targetDocument, injectedStyles); 12718 } 12719 if (injectedStyles.has(hash)) { 12720 return; 12721 } 12722 if (documentContainsStyleHash13(targetDocument, hash)) { 12723 injectedStyles.add(hash); 12724 return; 12725 } 12726 const style = targetDocument.createElement("style"); 12727 style.setAttribute(STYLE_HASH_ATTRIBUTE13, hash); 12728 style.appendChild(targetDocument.createTextNode(css)); 12729 targetDocument.head.appendChild(style); 12730 injectedStyles.add(hash); 12731 } 12732 function registerDocument13(targetDocument) { 12733 const runtime = getRuntime13(); 12734 runtime.documents.set( 12735 targetDocument, 12736 (runtime.documents.get(targetDocument) ?? 0) + 1 12737 ); 12738 for (const [hash, css] of runtime.styles) { 12739 injectStyle13(targetDocument, hash, css); 12740 } 12741 return () => { 12742 const count = runtime.documents.get(targetDocument); 12743 if (count === void 0) { 12744 return; 12745 } 12746 if (count <= 1) { 12747 runtime.documents.delete(targetDocument); 12748 return; 12749 } 12750 runtime.documents.set(targetDocument, count - 1); 12751 }; 12752 } 12753 function registerStyle13(hash, css) { 12754 const runtime = getRuntime13(); 12755 runtime.styles.set(hash, css); 12756 for (const targetDocument of runtime.documents.keys()) { 12757 injectStyle13(targetDocument, hash, css); 12758 } 12759 } 12760 if (typeof process === "undefined" || true) { 12761 registerStyle13("fa606a57ae", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{.f37b9e2e191ebd66__visually-hidden{word-wrap:normal;border:0;clip-path:inset(50%);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;word-break:normal}}}"); 12762 } 12763 var style_default12 = { "visually-hidden": "f37b9e2e191ebd66__visually-hidden" }; 12764 var VisuallyHidden = (0, import_element33.forwardRef)( 12765 function VisuallyHidden2({ render: render4, ...restProps }, ref) { 12766 const element = useRender({ 12767 render: render4, 12768 ref, 12769 props: mergeProps( 12770 { className: style_default12["visually-hidden"] }, 12771 restProps, 12772 { 12773 // @ts-expect-error Arbitrary data-* attributes aren't indexable on the typed div props. Kept hardcoded so consumers can't change or remove it. 12774 "data-visually-hidden": "" 12775 } 12776 ) 12777 }); 12778 return element; 12779 } 12780 ); 12781 12782 // packages/ui/build-module/skeleton/skeleton.mjs 12783 var import_element34 = __toESM(require_element(), 1); 12784 var STYLE_HASH_ATTRIBUTE14 = "data-wp-hash"; 12785 function getRuntime14() { 12786 const globalScope = globalThis; 12787 if (globalScope.__wpStyleRuntime) { 12788 return globalScope.__wpStyleRuntime; 12789 } 12790 globalScope.__wpStyleRuntime = { 12791 documents: /* @__PURE__ */ new Map(), 12792 styles: /* @__PURE__ */ new Map(), 12793 injectedStyles: /* @__PURE__ */ new WeakMap() 12794 }; 12795 if (typeof document !== "undefined") { 12796 registerDocument14(document); 12797 } 12798 return globalScope.__wpStyleRuntime; 12799 } 12800 function documentContainsStyleHash14(targetDocument, hash) { 12801 if (!targetDocument.head) { 12802 return false; 12803 } 12804 for (const style of targetDocument.head.querySelectorAll( 12805 `style[$STYLE_HASH_ATTRIBUTE14}]` 12806 )) { 12807 if (style.getAttribute(STYLE_HASH_ATTRIBUTE14) === hash) { 12808 return true; 12809 } 12810 } 12811 return false; 12812 } 12813 function injectStyle14(targetDocument, hash, css) { 12814 if (!targetDocument.head) { 12815 return; 12816 } 12817 const runtime = getRuntime14(); 12818 let injectedStyles = runtime.injectedStyles.get(targetDocument); 12819 if (!injectedStyles) { 12820 injectedStyles = /* @__PURE__ */ new Set(); 12821 runtime.injectedStyles.set(targetDocument, injectedStyles); 12822 } 12823 if (injectedStyles.has(hash)) { 12824 return; 12825 } 12826 if (documentContainsStyleHash14(targetDocument, hash)) { 12827 injectedStyles.add(hash); 12828 return; 12829 } 12830 const style = targetDocument.createElement("style"); 12831 style.setAttribute(STYLE_HASH_ATTRIBUTE14, hash); 12832 style.appendChild(targetDocument.createTextNode(css)); 12833 targetDocument.head.appendChild(style); 12834 injectedStyles.add(hash); 12835 } 12836 function registerDocument14(targetDocument) { 12837 const runtime = getRuntime14(); 12838 runtime.documents.set( 12839 targetDocument, 12840 (runtime.documents.get(targetDocument) ?? 0) + 1 12841 ); 12842 for (const [hash, css] of runtime.styles) { 12843 injectStyle14(targetDocument, hash, css); 12844 } 12845 return () => { 12846 const count = runtime.documents.get(targetDocument); 12847 if (count === void 0) { 12848 return; 12849 } 12850 if (count <= 1) { 12851 runtime.documents.delete(targetDocument); 12852 return; 12853 } 12854 runtime.documents.set(targetDocument, count - 1); 12855 }; 12856 } 12857 function registerStyle14(hash, css) { 12858 const runtime = getRuntime14(); 12859 runtime.styles.set(hash, css); 12860 for (const targetDocument of runtime.documents.keys()) { 12861 injectStyle14(targetDocument, hash, css); 12862 } 12863 } 12864 if (typeof process === "undefined" || true) { 12865 registerStyle14("10f3806643", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}}"); 12866 } 12867 var resets_default3 = { "box-sizing": "_336cd3e4e743482f__box-sizing" }; 12868 if (typeof process === "undefined" || true) { 12869 registerStyle14("ed2c39ec90", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{.b20cc1690085c2f0__skeleton{background-color:var(--wpds-color-background-surface-neutral-weak,#f4f4f4);display:block;@media (forced-colors:active){border:var(--wpds-border-width-xs,1px) solid CanvasText}}._9b143194fdb45f93__pulse{@media not (prefers-reduced-motion){animation:e2b9fe0690281bc8__skeleton-pulse 1.5s ease-in-out infinite}}@keyframes e2b9fe0690281bc8__skeleton-pulse{0%,to{opacity:1}50%{opacity:.4}}}}"); 12870 } 12871 var style_default13 = { "skeleton": "b20cc1690085c2f0__skeleton", "pulse": "_9b143194fdb45f93__pulse", "skeleton-pulse": "e2b9fe0690281bc8__skeleton-pulse" }; 12872 var Skeleton = (0, import_element34.forwardRef)( 12873 function Skeleton2({ render: render4, ...props }, ref) { 12874 return useRender({ 12875 render: render4, 12876 ref, 12877 props: mergeProps( 12878 { 12879 className: clsx_default( 12880 style_default13.skeleton, 12881 style_default13.pulse, 12882 resets_default3["box-sizing"] 12883 ), 12884 // Decorative by default; consumers mark the loading 12885 // region with aria-busy / role="status". 12886 "aria-hidden": true 12887 }, 12888 props 12889 ) 12890 }); 12891 } 12892 ); 12893 12894 // packages/admin-ui/build-module/navigable-region/index.mjs 12895 var import_element35 = __toESM(require_element(), 1); 12896 var import_jsx_runtime95 = __toESM(require_jsx_runtime(), 1); 12897 var NavigableRegion = (0, import_element35.forwardRef)( 12898 ({ children, className, ariaLabel, as: Tag = "div", ...props }, ref) => { 12899 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)( 12900 Tag, 12901 { 12902 ref, 12903 className: clsx_default("admin-ui-navigable-region", className), 12904 "aria-label": ariaLabel, 12905 role: "region", 12906 tabIndex: "-1", 12907 ...props, 12908 children 12909 } 12910 ); 12911 } 12912 ); 12913 NavigableRegion.displayName = "NavigableRegion"; 12914 var navigable_region_default = NavigableRegion; 12915 12916 // packages/admin-ui/build-module/page/sidebar-toggle-slot.mjs 12917 var import_components = __toESM(require_components(), 1); 12918 var { Fill: SidebarToggleFill, Slot: SidebarToggleSlot } = (0, import_components.createSlotFill)("SidebarToggle"); 12919 12920 // packages/admin-ui/build-module/page/header.mjs 12921 var import_jsx_runtime96 = __toESM(require_jsx_runtime(), 1); 12922 var STYLE_HASH_ATTRIBUTE15 = "data-wp-hash"; 12923 function getRuntime15() { 12924 const globalScope = globalThis; 12925 if (globalScope.__wpStyleRuntime) { 12926 return globalScope.__wpStyleRuntime; 12927 } 12928 globalScope.__wpStyleRuntime = { 12929 documents: /* @__PURE__ */ new Map(), 12930 styles: /* @__PURE__ */ new Map(), 12931 injectedStyles: /* @__PURE__ */ new WeakMap() 12932 }; 12933 if (typeof document !== "undefined") { 12934 registerDocument15(document); 12935 } 12936 return globalScope.__wpStyleRuntime; 12937 } 12938 function documentContainsStyleHash15(targetDocument, hash) { 12939 if (!targetDocument.head) { 12940 return false; 12941 } 12942 for (const style of targetDocument.head.querySelectorAll( 12943 `style[$STYLE_HASH_ATTRIBUTE15}]` 12944 )) { 12945 if (style.getAttribute(STYLE_HASH_ATTRIBUTE15) === hash) { 12946 return true; 12947 } 12948 } 12949 return false; 12950 } 12951 function injectStyle15(targetDocument, hash, css) { 12952 if (!targetDocument.head) { 12953 return; 12954 } 12955 const runtime = getRuntime15(); 12956 let injectedStyles = runtime.injectedStyles.get(targetDocument); 12957 if (!injectedStyles) { 12958 injectedStyles = /* @__PURE__ */ new Set(); 12959 runtime.injectedStyles.set(targetDocument, injectedStyles); 12960 } 12961 if (injectedStyles.has(hash)) { 12962 return; 12963 } 12964 if (documentContainsStyleHash15(targetDocument, hash)) { 12965 injectedStyles.add(hash); 12966 return; 12967 } 12968 const style = targetDocument.createElement("style"); 12969 style.setAttribute(STYLE_HASH_ATTRIBUTE15, hash); 12970 style.appendChild(targetDocument.createTextNode(css)); 12971 targetDocument.head.appendChild(style); 12972 injectedStyles.add(hash); 12973 } 12974 function registerDocument15(targetDocument) { 12975 const runtime = getRuntime15(); 12976 runtime.documents.set( 12977 targetDocument, 12978 (runtime.documents.get(targetDocument) ?? 0) + 1 12979 ); 12980 for (const [hash, css] of runtime.styles) { 12981 injectStyle15(targetDocument, hash, css); 12982 } 12983 return () => { 12984 const count = runtime.documents.get(targetDocument); 12985 if (count === void 0) { 12986 return; 12987 } 12988 if (count <= 1) { 12989 runtime.documents.delete(targetDocument); 12990 return; 12991 } 12992 runtime.documents.set(targetDocument, count - 1); 12993 }; 12994 } 12995 function registerStyle15(hash, css) { 12996 const runtime = getRuntime15(); 12997 runtime.styles.set(hash, css); 12998 for (const targetDocument of runtime.documents.keys()) { 12999 injectStyle15(targetDocument, hash, css); 13000 } 13001 } 13002 if (typeof process === "undefined" || true) { 13003 registerStyle15("ddd9aab364", "._956b6df0898efed0__page{text-wrap:pretty;background-color:var(--wpds-color-background-surface-neutral,#fcfcfc);color:var(--wpds-color-foreground-content-neutral,#1e1e1e);display:flex;flex-flow:column;height:100%;position:relative;z-index:1}._0625b55e82a0d93d__header{background:var(--wpds-color-background-surface-neutral-strong,#fff);border-block-end:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral-weak,#f0f0f0);inset-block-start:0;padding:var(--wpds-dimension-padding-lg,16px) var(--wpds-dimension-padding-2xl,24px);position:sticky;z-index:1}.a43c44d5ae28b2e8__header-content{min-height:var(--wpds-dimension-size-md,32px)}.b7cb5b9daf3a3b25__header-actions{flex-shrink:0}._8113be94e7caf73c__header-title{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}._9a776c7f70996f61__header-visual{display:grid;flex-shrink:0;grid-template-columns:1fr;grid-template-rows:1fr;height:var(--wpds-dimension-size-sm,24px);width:var(--wpds-dimension-size-sm,24px);>*{grid-column:1/-1;grid-row:1/-1;max-height:100%;max-width:100%}}.d5e0920cd15d35bc__sidebar-toggle-slot:empty{display:none}._60fea2f6bf5319cd__header-subtitle{color:var(--wpds-color-foreground-content-neutral-weak,#707070);padding-block-end:var(--wpds-dimension-padding-xs,4px)}.be5e57d029ec4036__content{display:flex;flex-direction:column;flex-grow:1;overflow:auto;&._128806d0b26e3a50__has-padding{padding:var(--wpds-dimension-padding-lg,16px) var(--wpds-dimension-padding-2xl,24px)}}"); 13004 } 13005 var style_default14 = { "page": "_956b6df0898efed0__page", "header": "_0625b55e82a0d93d__header", "header-content": "a43c44d5ae28b2e8__header-content", "header-actions": "b7cb5b9daf3a3b25__header-actions", "header-title": "_8113be94e7caf73c__header-title", "header-visual": "_9a776c7f70996f61__header-visual", "sidebar-toggle-slot": "d5e0920cd15d35bc__sidebar-toggle-slot", "header-subtitle": "_60fea2f6bf5319cd__header-subtitle", "content": "be5e57d029ec4036__content", "has-padding": "_128806d0b26e3a50__has-padding" }; 13006 function Header3({ 13007 headingLevel = 1, 13008 breadcrumbs, 13009 badges, 13010 visual, 13011 title, 13012 subTitle, 13013 actions, 13014 showSidebarToggle = true 13015 }) { 13016 const HeadingTag = `h$headingLevel}`; 13017 return /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(Stack, { direction: "column", className: style_default14.header, children: [ 13018 /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)( 13019 Stack, 13020 { 13021 className: style_default14["header-content"], 13022 direction: "row", 13023 gap: "sm", 13024 justify: "space-between", 13025 children: [ 13026 /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(Stack, { direction: "row", gap: "sm", align: "center", justify: "start", children: [ 13027 showSidebarToggle && /* @__PURE__ */ (0, import_jsx_runtime96.jsx)( 13028 SidebarToggleSlot, 13029 { 13030 bubblesVirtually: true, 13031 className: style_default14["sidebar-toggle-slot"] 13032 } 13033 ), 13034 visual && /* @__PURE__ */ (0, import_jsx_runtime96.jsx)( 13035 "div", 13036 { 13037 className: style_default14["header-visual"], 13038 "aria-hidden": "true", 13039 children: visual 13040 } 13041 ), 13042 title && /* @__PURE__ */ (0, import_jsx_runtime96.jsx)( 13043 Text, 13044 { 13045 className: style_default14["header-title"], 13046 render: /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(HeadingTag, {}), 13047 variant: "heading-lg", 13048 children: title 13049 } 13050 ), 13051 breadcrumbs, 13052 badges 13053 ] }), 13054 actions && /* @__PURE__ */ (0, import_jsx_runtime96.jsx)( 13055 Stack, 13056 { 13057 align: "center", 13058 className: style_default14["header-actions"], 13059 direction: "row", 13060 gap: "sm", 13061 children: actions 13062 } 13063 ) 13064 ] 13065 } 13066 ), 13067 subTitle && /* @__PURE__ */ (0, import_jsx_runtime96.jsx)( 13068 Text, 13069 { 13070 render: /* @__PURE__ */ (0, import_jsx_runtime96.jsx)("p", {}), 13071 variant: "body-md", 13072 className: style_default14["header-subtitle"], 13073 children: subTitle 13074 } 13075 ) 13076 ] }); 13077 } 13078 13079 // packages/admin-ui/build-module/page/index.mjs 13080 var import_jsx_runtime97 = __toESM(require_jsx_runtime(), 1); 13081 var STYLE_HASH_ATTRIBUTE16 = "data-wp-hash"; 13082 function getRuntime16() { 13083 const globalScope = globalThis; 13084 if (globalScope.__wpStyleRuntime) { 13085 return globalScope.__wpStyleRuntime; 13086 } 13087 globalScope.__wpStyleRuntime = { 13088 documents: /* @__PURE__ */ new Map(), 13089 styles: /* @__PURE__ */ new Map(), 13090 injectedStyles: /* @__PURE__ */ new WeakMap() 13091 }; 13092 if (typeof document !== "undefined") { 13093 registerDocument16(document); 13094 } 13095 return globalScope.__wpStyleRuntime; 13096 } 13097 function documentContainsStyleHash16(targetDocument, hash) { 13098 if (!targetDocument.head) { 13099 return false; 13100 } 13101 for (const style of targetDocument.head.querySelectorAll( 13102 `style[$STYLE_HASH_ATTRIBUTE16}]` 13103 )) { 13104 if (style.getAttribute(STYLE_HASH_ATTRIBUTE16) === hash) { 13105 return true; 13106 } 13107 } 13108 return false; 13109 } 13110 function injectStyle16(targetDocument, hash, css) { 13111 if (!targetDocument.head) { 13112 return; 13113 } 13114 const runtime = getRuntime16(); 13115 let injectedStyles = runtime.injectedStyles.get(targetDocument); 13116 if (!injectedStyles) { 13117 injectedStyles = /* @__PURE__ */ new Set(); 13118 runtime.injectedStyles.set(targetDocument, injectedStyles); 13119 } 13120 if (injectedStyles.has(hash)) { 13121 return; 13122 } 13123 if (documentContainsStyleHash16(targetDocument, hash)) { 13124 injectedStyles.add(hash); 13125 return; 13126 } 13127 const style = targetDocument.createElement("style"); 13128 style.setAttribute(STYLE_HASH_ATTRIBUTE16, hash); 13129 style.appendChild(targetDocument.createTextNode(css)); 13130 targetDocument.head.appendChild(style); 13131 injectedStyles.add(hash); 13132 } 13133 function registerDocument16(targetDocument) { 13134 const runtime = getRuntime16(); 13135 runtime.documents.set( 13136 targetDocument, 13137 (runtime.documents.get(targetDocument) ?? 0) + 1 13138 ); 13139 for (const [hash, css] of runtime.styles) { 13140 injectStyle16(targetDocument, hash, css); 13141 } 13142 return () => { 13143 const count = runtime.documents.get(targetDocument); 13144 if (count === void 0) { 13145 return; 13146 } 13147 if (count <= 1) { 13148 runtime.documents.delete(targetDocument); 13149 return; 13150 } 13151 runtime.documents.set(targetDocument, count - 1); 13152 }; 13153 } 13154 function registerStyle16(hash, css) { 13155 const runtime = getRuntime16(); 13156 runtime.styles.set(hash, css); 13157 for (const targetDocument of runtime.documents.keys()) { 13158 injectStyle16(targetDocument, hash, css); 13159 } 13160 } 13161 if (typeof process === "undefined" || true) { 13162 registerStyle16("ddd9aab364", "._956b6df0898efed0__page{text-wrap:pretty;background-color:var(--wpds-color-background-surface-neutral,#fcfcfc);color:var(--wpds-color-foreground-content-neutral,#1e1e1e);display:flex;flex-flow:column;height:100%;position:relative;z-index:1}._0625b55e82a0d93d__header{background:var(--wpds-color-background-surface-neutral-strong,#fff);border-block-end:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral-weak,#f0f0f0);inset-block-start:0;padding:var(--wpds-dimension-padding-lg,16px) var(--wpds-dimension-padding-2xl,24px);position:sticky;z-index:1}.a43c44d5ae28b2e8__header-content{min-height:var(--wpds-dimension-size-md,32px)}.b7cb5b9daf3a3b25__header-actions{flex-shrink:0}._8113be94e7caf73c__header-title{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}._9a776c7f70996f61__header-visual{display:grid;flex-shrink:0;grid-template-columns:1fr;grid-template-rows:1fr;height:var(--wpds-dimension-size-sm,24px);width:var(--wpds-dimension-size-sm,24px);>*{grid-column:1/-1;grid-row:1/-1;max-height:100%;max-width:100%}}.d5e0920cd15d35bc__sidebar-toggle-slot:empty{display:none}._60fea2f6bf5319cd__header-subtitle{color:var(--wpds-color-foreground-content-neutral-weak,#707070);padding-block-end:var(--wpds-dimension-padding-xs,4px)}.be5e57d029ec4036__content{display:flex;flex-direction:column;flex-grow:1;overflow:auto;&._128806d0b26e3a50__has-padding{padding:var(--wpds-dimension-padding-lg,16px) var(--wpds-dimension-padding-2xl,24px)}}"); 13163 } 13164 var style_default15 = { "page": "_956b6df0898efed0__page", "header": "_0625b55e82a0d93d__header", "header-content": "a43c44d5ae28b2e8__header-content", "header-actions": "b7cb5b9daf3a3b25__header-actions", "header-title": "_8113be94e7caf73c__header-title", "header-visual": "_9a776c7f70996f61__header-visual", "sidebar-toggle-slot": "d5e0920cd15d35bc__sidebar-toggle-slot", "header-subtitle": "_60fea2f6bf5319cd__header-subtitle", "content": "be5e57d029ec4036__content", "has-padding": "_128806d0b26e3a50__has-padding" }; 13165 function Page({ 13166 headingLevel, 13167 breadcrumbs, 13168 badges, 13169 visual, 13170 title, 13171 subTitle, 13172 children, 13173 className, 13174 actions, 13175 ariaLabel, 13176 hasPadding = false, 13177 showSidebarToggle = true 13178 }) { 13179 const classes = clsx_default(style_default15.page, className); 13180 const effectiveAriaLabel = ariaLabel ?? (typeof title === "string" ? title : ""); 13181 return /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)(navigable_region_default, { className: classes, ariaLabel: effectiveAriaLabel, children: [ 13182 (title || breadcrumbs || badges || actions || visual) && /* @__PURE__ */ (0, import_jsx_runtime97.jsx)( 13183 Header3, 13184 { 13185 headingLevel, 13186 breadcrumbs, 13187 badges, 13188 visual, 13189 title, 13190 subTitle, 13191 actions, 13192 showSidebarToggle 13193 } 13194 ), 13195 hasPadding ? /* @__PURE__ */ (0, import_jsx_runtime97.jsx)( 13196 "div", 13197 { 13198 className: clsx_default( 13199 style_default15.content, 13200 style_default15["has-padding"] 13201 ), 13202 children 13203 } 13204 ) : children 13205 ] }); 13206 } 13207 Page.SidebarToggleFill = SidebarToggleFill; 13208 var page_default2 = Page; 13209 13210 // packages/admin-ui/build-module/admin-theme-colors/index.mjs 13211 var DEFAULT_THEME_COLORS = { 13212 primary: "#3858e9", 13213 background: "#222524" 13214 }; 13215 var ADMIN_THEME_COLORS = /* @__PURE__ */ new Map([ 13216 ["modern", DEFAULT_THEME_COLORS], 13217 ["fresh", { primary: "#3858e9", background: "#25292b" }], 13218 ["midnight", { primary: "#cf4339", background: "#3d4042" }], 13219 ["coffee", { primary: "#916745", background: "#5b534d" }], 13220 ["ocean", { primary: "#567958", background: "#5f787f" }], 13221 ["blue", { primary: "#437aa8", background: "#3876a8" }], 13222 ["ectoplasm", { primary: "#646c3e", background: "#4f386e" }], 13223 ["sunrise", { primary: "#ad631e", background: "#cc4541" }], 13224 ["light", { primary: "#007cba", background: "#eaeeed" }] 13225 ]); 13226 function getAdminThemeColors() { 13227 const scheme = document.body.className.match(/admin-color-([\w-]+)/)?.[1] ?? "modern"; 13228 return ADMIN_THEME_COLORS.get(scheme) ?? DEFAULT_THEME_COLORS; 13229 } 13230 13231 // packages/edit-site/build-module/components/layout/index.mjs 13232 var import_components6 = __toESM(require_components(), 1); 13233 var import_compose2 = __toESM(require_compose(), 1); 13234 var import_dom23 = __toESM(require_dom(), 1); 13235 var import_i18n7 = __toESM(require_i18n(), 1); 13236 var import_element44 = __toESM(require_element(), 1); 13237 var import_editor6 = __toESM(require_editor(), 1); 13238 var import_router6 = __toESM(require_router(), 1); 13239 var import_theme = __toESM(require_theme(), 1); 13240 var import_plugins2 = __toESM(require_plugins(), 1); 13241 var import_notices = __toESM(require_notices(), 1); 13242 var import_data12 = __toESM(require_data(), 1); 13243 var import_preferences3 = __toESM(require_preferences(), 1); 13244 13245 // packages/edit-site/build-module/components/site-hub/index.mjs 13246 var import_data4 = __toESM(require_data(), 1); 13247 var import_components2 = __toESM(require_components(), 1); 13248 var import_i18n2 = __toESM(require_i18n(), 1); 13249 var import_core_data3 = __toESM(require_core_data(), 1); 13250 var import_element37 = __toESM(require_element(), 1); 13251 var import_router = __toESM(require_router(), 1); 13252 13253 // packages/edit-site/build-module/components/sidebar/index.mjs 13254 var import_element36 = __toESM(require_element(), 1); 13255 var import_dom22 = __toESM(require_dom(), 1); 13256 var import_jsx_runtime98 = __toESM(require_jsx_runtime(), 1); 13257 var SidebarNavigationContext = (0, import_element36.createContext)(() => { 13258 }); 13259 SidebarNavigationContext.displayName = "SidebarNavigationContext"; 13260 function focusSidebarElement(el, direction, focusSelector) { 13261 let elementToFocus; 13262 if (direction === "back" && focusSelector) { 13263 elementToFocus = el.querySelector(focusSelector); 13264 } 13265 if (direction !== null && !elementToFocus) { 13266 const [firstTabbable] = import_dom22.focus.tabbable.find(el); 13267 elementToFocus = firstTabbable ?? el; 13268 } 13269 elementToFocus?.focus(); 13270 } 13271 function createNavState() { 13272 let state = { 13273 direction: null, 13274 focusSelector: null 13275 }; 13276 return { 13277 get() { 13278 return state; 13279 }, 13280 navigate(direction, focusSelector = null) { 13281 state = { 13282 direction, 13283 focusSelector: direction === "forward" && focusSelector ? focusSelector : state.focusSelector 13284 }; 13285 } 13286 }; 13287 } 13288 function SidebarContentWrapper({ children, shouldAnimate }) { 13289 const navState = (0, import_element36.useContext)(SidebarNavigationContext); 13290 const wrapperRef = (0, import_element36.useRef)(); 13291 const [navAnimation, setNavAnimation] = (0, import_element36.useState)(null); 13292 (0, import_element36.useLayoutEffect)(() => { 13293 const { direction, focusSelector } = navState.get(); 13294 focusSidebarElement(wrapperRef.current, direction, focusSelector); 13295 setNavAnimation(direction); 13296 }, [navState]); 13297 const wrapperCls = clsx_default( 13298 "edit-site-sidebar__screen-wrapper", 13299 /* 13300 * Some panes do not have sub-panes and therefore 13301 * should not animate when clicked on. 13302 */ 13303 shouldAnimate ? { 13304 "slide-from-left": navAnimation === "back", 13305 "slide-from-right": navAnimation === "forward" 13306 } : {} 13307 ); 13308 return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)("div", { ref: wrapperRef, className: wrapperCls, children }); 13309 } 13310 function SidebarNavigationProvider({ children }) { 13311 const [navState] = (0, import_element36.useState)(createNavState); 13312 return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(SidebarNavigationContext.Provider, { value: navState, children }); 13313 } 13314 function SidebarContent({ routeKey, shouldAnimate, children }) { 13315 return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)("div", { className: "edit-site-sidebar__content", children: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)( 13316 SidebarContentWrapper, 13317 { 13318 shouldAnimate, 13319 children 13320 }, 13321 routeKey 13322 ) }); 13323 } 13324 13325 // packages/edit-site/build-module/components/site-hub/index.mjs 13326 var import_jsx_runtime99 = __toESM(require_jsx_runtime(), 1); 13327 var { useLocation, useHistory } = unlock(import_router.privateApis); 13328 var SiteHubMobile = (0, import_element37.memo)( 13329 (0, import_element37.forwardRef)((props, ref) => { 13330 const { path } = useLocation(); 13331 const history = useHistory(); 13332 const { navigate } = (0, import_element37.useContext)(SidebarNavigationContext); 13333 const { 13334 dashboardLink, 13335 isBlockTheme, 13336 isClassicThemeWithStyleBookSupport: isClassicThemeWithStyleBookSupport2 13337 } = (0, import_data4.useSelect)((select4) => { 13338 const { getSettings: getSettings7 } = unlock(select4(store)); 13339 const { getCurrentTheme } = select4(import_core_data3.store); 13340 const currentTheme = getCurrentTheme(); 13341 const settings2 = getSettings7(); 13342 const supportsEditorStyles = currentTheme?.theme_supports["editor-styles"]; 13343 const hasThemeJson = settings2.supportsLayout; 13344 return { 13345 dashboardLink: settings2.__experimentalDashboardLink, 13346 isBlockTheme: currentTheme?.is_block_theme, 13347 isClassicThemeWithStyleBookSupport: !currentTheme?.is_block_theme && (supportsEditorStyles || hasThemeJson) 13348 }; 13349 }, []); 13350 let backPath; 13351 if (path !== "/") { 13352 if (isBlockTheme || isClassicThemeWithStyleBookSupport2) { 13353 backPath = "/"; 13354 } else if (path !== "/pattern") { 13355 backPath = "/pattern"; 13356 } 13357 } 13358 const backButtonProps = { 13359 href: !!backPath ? void 0 : dashboardLink, 13360 label: !!backPath ? (0, import_i18n2.__)("Go to Site Editor") : (0, import_i18n2.__)("Go to the Dashboard"), 13361 onClick: !!backPath ? () => { 13362 history.navigate(backPath); 13363 navigate("back"); 13364 } : void 0 13365 }; 13366 return /* @__PURE__ */ (0, import_jsx_runtime99.jsx)("div", { className: "edit-site-site-hub", children: /* @__PURE__ */ (0, import_jsx_runtime99.jsx)( 13367 import_components2.Button, 13368 { 13369 size: "compact", 13370 ref, 13371 className: "edit-site-site-hub__back-button", 13372 icon: (0, import_i18n2.isRTL)() ? chevron_right_default : chevron_left_default, 13373 ...backButtonProps 13374 } 13375 ) }); 13376 }) 13377 ); 13378 13379 // packages/edit-site/build-module/components/resizable-frame/index.mjs 13380 var import_element38 = __toESM(require_element(), 1); 13381 var import_components3 = __toESM(require_components(), 1); 13382 var import_compose = __toESM(require_compose(), 1); 13383 var import_i18n3 = __toESM(require_i18n(), 1); 13384 var import_router2 = __toESM(require_router(), 1); 13385 var import_data5 = __toESM(require_data(), 1); 13386 var import_core_data4 = __toESM(require_core_data(), 1); 13387 var import_url = __toESM(require_url(), 1); 13388 var import_jsx_runtime100 = __toESM(require_jsx_runtime(), 1); 13389 var { useLocation: useLocation2, useHistory: useHistory2 } = unlock(import_router2.privateApis); 13390 var HANDLE_STYLES_OVERRIDE = { 13391 position: void 0, 13392 userSelect: void 0, 13393 cursor: void 0, 13394 width: void 0, 13395 height: void 0, 13396 top: void 0, 13397 right: void 0, 13398 bottom: void 0, 13399 left: void 0 13400 }; 13401 var FRAME_MIN_WIDTH = 320; 13402 var FRAME_REFERENCE_WIDTH = 1300; 13403 var FRAME_TARGET_ASPECT_RATIO = 9 / 19.5; 13404 var SNAP_TO_EDIT_CANVAS_MODE_THRESHOLD = 200; 13405 var INITIAL_FRAME_SIZE = { width: "100%", height: "100%" }; 13406 function calculateNewHeight(width, initialAspectRatio) { 13407 const lerp = (a2, b2, amount) => { 13408 return a2 + (b2 - a2) * amount; 13409 }; 13410 const lerpFactor = 1 - Math.max( 13411 0, 13412 Math.min( 13413 1, 13414 (width - FRAME_MIN_WIDTH) / (FRAME_REFERENCE_WIDTH - FRAME_MIN_WIDTH) 13415 ) 13416 ); 13417 const intermediateAspectRatio = lerp( 13418 initialAspectRatio, 13419 FRAME_TARGET_ASPECT_RATIO, 13420 lerpFactor 13421 ); 13422 return width / intermediateAspectRatio; 13423 } 13424 function ResizableFrame({ 13425 isFullWidth, 13426 isOversized, 13427 setIsOversized, 13428 isReady, 13429 children, 13430 /** The default (unresized) width/height of the frame, based on the space available in the viewport. */ 13431 defaultSize, 13432 innerContentStyle 13433 }) { 13434 const history = useHistory2(); 13435 const { path, query } = useLocation2(); 13436 const { canvas = "view" } = query; 13437 const disableMotion = (0, import_compose.useReducedMotion)(); 13438 const [frameSize, setFrameSize] = (0, import_element38.useState)(INITIAL_FRAME_SIZE); 13439 const [startingWidth, setStartingWidth] = (0, import_element38.useState)(); 13440 const [isResizing, setIsResizing] = (0, import_element38.useState)(false); 13441 const [shouldShowHandle, setShouldShowHandle] = (0, import_element38.useState)(false); 13442 const [resizeRatio, setResizeRatio] = (0, import_element38.useState)(1); 13443 const FRAME_TRANSITION = { type: "tween", duration: isResizing ? 0 : 0.5 }; 13444 const frameRef = (0, import_element38.useRef)(null); 13445 const resizableHandleHelpId = (0, import_compose.useInstanceId)( 13446 ResizableFrame, 13447 "edit-site-resizable-frame-handle-help" 13448 ); 13449 const defaultAspectRatio = defaultSize.width / defaultSize.height; 13450 const isBlockTheme = (0, import_data5.useSelect)((select4) => { 13451 const { getCurrentTheme } = select4(import_core_data4.store); 13452 return getCurrentTheme()?.is_block_theme; 13453 }, []); 13454 const handleResizeStart = (_event, _direction, ref) => { 13455 setStartingWidth(ref.offsetWidth); 13456 setIsResizing(true); 13457 }; 13458 const handleResize = (_event, _direction, _ref, delta) => { 13459 const normalizedDelta = delta.width / resizeRatio; 13460 const deltaAbs = Math.abs(normalizedDelta); 13461 const maxDoubledDelta = delta.width < 0 ? deltaAbs : (defaultSize.width - startingWidth) / 2; 13462 const deltaToDouble = Math.min(deltaAbs, maxDoubledDelta); 13463 const doubleSegment = deltaAbs === 0 ? 0 : deltaToDouble / deltaAbs; 13464 const singleSegment = 1 - doubleSegment; 13465 setResizeRatio(singleSegment + doubleSegment * 2); 13466 const updatedWidth = startingWidth + delta.width; 13467 setIsOversized(updatedWidth > defaultSize.width); 13468 setFrameSize({ 13469 height: isOversized ? "100%" : calculateNewHeight(updatedWidth, defaultAspectRatio) 13470 }); 13471 }; 13472 const handleResizeStop = (_event, _direction, ref) => { 13473 setIsResizing(false); 13474 if (!isOversized) { 13475 return; 13476 } 13477 setIsOversized(false); 13478 const remainingWidth = ref.ownerDocument.documentElement.offsetWidth - ref.offsetWidth; 13479 if (remainingWidth > SNAP_TO_EDIT_CANVAS_MODE_THRESHOLD || !isBlockTheme) { 13480 setFrameSize(INITIAL_FRAME_SIZE); 13481 } else { 13482 history.navigate( 13483 (0, import_url.addQueryArgs)(path, { 13484 canvas: "edit" 13485 }), 13486 { 13487 transition: "canvas-mode-edit-transition" 13488 } 13489 ); 13490 } 13491 }; 13492 const handleResizableHandleKeyDown = (event) => { 13493 if (!["ArrowLeft", "ArrowRight"].includes(event.key)) { 13494 return; 13495 } 13496 event.preventDefault(); 13497 const step = 20 * (event.shiftKey ? 5 : 1); 13498 const delta = step * (event.key === "ArrowLeft" ? 1 : -1) * ((0, import_i18n3.isRTL)() ? -1 : 1); 13499 const newWidth = Math.min( 13500 Math.max( 13501 FRAME_MIN_WIDTH, 13502 frameRef.current.resizable.offsetWidth + delta 13503 ), 13504 defaultSize.width 13505 ); 13506 setFrameSize({ 13507 width: newWidth, 13508 height: calculateNewHeight(newWidth, defaultAspectRatio) 13509 }); 13510 }; 13511 const frameAnimationVariants = { 13512 default: { 13513 flexGrow: 0, 13514 height: frameSize.height 13515 }, 13516 fullWidth: { 13517 flexGrow: 1, 13518 height: frameSize.height 13519 } 13520 }; 13521 const resizeHandleVariants = { 13522 hidden: { 13523 opacity: 0, 13524 ...(0, import_i18n3.isRTL)() ? { right: 0 } : { left: 0 } 13525 }, 13526 visible: { 13527 opacity: 1, 13528 // Account for the handle's width. 13529 ...(0, import_i18n3.isRTL)() ? { right: -14 } : { left: -14 } 13530 }, 13531 active: { 13532 opacity: 1, 13533 // Account for the handle's width. 13534 ...(0, import_i18n3.isRTL)() ? { right: -14 } : { left: -14 }, 13535 scaleY: 1.3 13536 } 13537 }; 13538 const currentResizeHandleVariant = (() => { 13539 if (isResizing) { 13540 return "active"; 13541 } 13542 return shouldShowHandle ? "visible" : "hidden"; 13543 })(); 13544 return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)( 13545 import_components3.ResizableBox, 13546 { 13547 as: import_components3.__unstableMotion.div, 13548 ref: frameRef, 13549 initial: false, 13550 variants: frameAnimationVariants, 13551 animate: isFullWidth ? "fullWidth" : "default", 13552 onAnimationComplete: (definition) => { 13553 if (definition === "fullWidth") { 13554 setFrameSize({ width: "100%", height: "100%" }); 13555 } 13556 }, 13557 whileHover: canvas === "view" && isBlockTheme ? { 13558 scale: 1.005, 13559 transition: { 13560 duration: disableMotion ? 0 : 0.5, 13561 ease: "easeOut" 13562 } 13563 } : {}, 13564 transition: FRAME_TRANSITION, 13565 size: frameSize, 13566 enable: { 13567 top: false, 13568 bottom: false, 13569 // Resizing will be disabled until the editor content is loaded. 13570 ...(0, import_i18n3.isRTL)() ? { right: isReady, left: false } : { left: isReady, right: false }, 13571 topRight: false, 13572 bottomRight: false, 13573 bottomLeft: false, 13574 topLeft: false 13575 }, 13576 resizeRatio, 13577 handleClasses: void 0, 13578 handleStyles: { 13579 left: HANDLE_STYLES_OVERRIDE, 13580 right: HANDLE_STYLES_OVERRIDE 13581 }, 13582 minWidth: FRAME_MIN_WIDTH, 13583 maxWidth: isFullWidth ? "100%" : "150%", 13584 maxHeight: "100%", 13585 onFocus: () => setShouldShowHandle(true), 13586 onBlur: () => setShouldShowHandle(false), 13587 onMouseOver: () => setShouldShowHandle(true), 13588 onMouseOut: () => setShouldShowHandle(false), 13589 handleComponent: { 13590 [(0, import_i18n3.isRTL)() ? "right" : "left"]: canvas === "view" && /* @__PURE__ */ (0, import_jsx_runtime100.jsxs)(import_jsx_runtime100.Fragment, { children: [ 13591 /* @__PURE__ */ (0, import_jsx_runtime100.jsxs)(tooltip_exports.Root, { children: [ 13592 /* @__PURE__ */ (0, import_jsx_runtime100.jsx)( 13593 tooltip_exports.Trigger, 13594 { 13595 render: /* @__PURE__ */ (0, import_jsx_runtime100.jsx)( 13596 import_components3.__unstableMotion.button, 13597 { 13598 role: "separator", 13599 "aria-orientation": "vertical", 13600 className: clsx_default( 13601 "edit-site-resizable-frame__handle", 13602 { "is-resizing": isResizing } 13603 ), 13604 variants: resizeHandleVariants, 13605 animate: currentResizeHandleVariant, 13606 "aria-label": (0, import_i18n3.__)("Drag to resize"), 13607 "aria-describedby": resizableHandleHelpId, 13608 "aria-valuenow": frameRef.current?.resizable?.offsetWidth || void 0, 13609 "aria-valuemin": FRAME_MIN_WIDTH, 13610 "aria-valuemax": defaultSize.width, 13611 onKeyDown: handleResizableHandleKeyDown, 13612 initial: "hidden", 13613 exit: "hidden", 13614 whileFocus: "active", 13615 whileHover: "active" 13616 }, 13617 "handle" 13618 ) 13619 } 13620 ), 13621 /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(tooltip_exports.Popup, { children: (0, import_i18n3.__)("Drag to resize") }) 13622 ] }), 13623 /* @__PURE__ */ (0, import_jsx_runtime100.jsx)("div", { hidden: true, id: resizableHandleHelpId, children: (0, import_i18n3.__)( 13624 "Use left and right arrow keys to resize the canvas. Hold shift to resize in larger increments." 13625 ) }) 13626 ] }) 13627 }, 13628 onResizeStart: handleResizeStart, 13629 onResize: handleResize, 13630 onResizeStop: handleResizeStop, 13631 className: clsx_default("edit-site-resizable-frame__inner", { 13632 "is-resizing": isResizing 13633 }), 13634 showHandle: false, 13635 children: /* @__PURE__ */ (0, import_jsx_runtime100.jsx)( 13636 "div", 13637 { 13638 className: "edit-site-resizable-frame__inner-content", 13639 style: innerContentStyle, 13640 children 13641 } 13642 ) 13643 } 13644 ); 13645 } 13646 var resizable_frame_default = ResizableFrame; 13647 13648 // packages/edit-site/build-module/components/save-keyboard-shortcut/index.mjs 13649 var import_element39 = __toESM(require_element(), 1); 13650 var import_keyboard_shortcuts = __toESM(require_keyboard_shortcuts(), 1); 13651 var import_i18n4 = __toESM(require_i18n(), 1); 13652 var import_data6 = __toESM(require_data(), 1); 13653 var import_core_data5 = __toESM(require_core_data(), 1); 13654 var import_editor3 = __toESM(require_editor(), 1); 13655 var shortcutName = "core/edit-site/save"; 13656 function SaveKeyboardShortcut() { 13657 const { __experimentalGetDirtyEntityRecords, isSavingEntityRecord } = (0, import_data6.useSelect)(import_core_data5.store); 13658 const { hasNonPostEntityChanges, isPostSavingLocked } = (0, import_data6.useSelect)(import_editor3.store); 13659 const { savePost } = (0, import_data6.useDispatch)(import_editor3.store); 13660 const { setIsSaveViewOpened: setIsSaveViewOpened2 } = (0, import_data6.useDispatch)(store); 13661 const { registerShortcut, unregisterShortcut } = (0, import_data6.useDispatch)( 13662 import_keyboard_shortcuts.store 13663 ); 13664 (0, import_element39.useEffect)(() => { 13665 registerShortcut({ 13666 name: shortcutName, 13667 category: "global", 13668 description: (0, import_i18n4.__)("Save your changes."), 13669 keyCombination: { 13670 modifier: "primary", 13671 character: "s" 13672 } 13673 }); 13674 return () => { 13675 unregisterShortcut(shortcutName); 13676 }; 13677 }, [registerShortcut, unregisterShortcut]); 13678 (0, import_keyboard_shortcuts.useShortcut)("core/edit-site/save", (event) => { 13679 event.preventDefault(); 13680 const dirtyEntityRecords = __experimentalGetDirtyEntityRecords(); 13681 const hasDirtyEntities = !!dirtyEntityRecords.length; 13682 const isSaving = dirtyEntityRecords.some( 13683 (record) => isSavingEntityRecord(record.kind, record.name, record.key) 13684 ); 13685 if (!hasDirtyEntities || isSaving) { 13686 return; 13687 } 13688 if (hasNonPostEntityChanges()) { 13689 setIsSaveViewOpened2(true); 13690 } else if (!isPostSavingLocked()) { 13691 savePost(); 13692 } 13693 }); 13694 return null; 13695 } 13696 13697 // packages/edit-site/build-module/components/layout/hooks.mjs 13698 var import_element40 = __toESM(require_element(), 1); 13699 var import_data7 = __toESM(require_data(), 1); 13700 var import_core_data6 = __toESM(require_core_data(), 1); 13701 var MAX_LOADING_TIME = 1e4; 13702 var MAX_PAUSE_TIME = 100; 13703 function waitWhileSiteEditorLoading() { 13704 let pauseTimeout; 13705 const { promise, resolve } = Promise.withResolvers(); 13706 function finish() { 13707 unsubscribe(); 13708 clearTimeout(pauseTimeout); 13709 clearTimeout(maxTimeout); 13710 resolve(); 13711 } 13712 const maxTimeout = setTimeout(finish, MAX_LOADING_TIME); 13713 function checkResolving() { 13714 const isResolving = (0, import_data7.select)(import_core_data6.store).hasResolvingSelectors(); 13715 if (isResolving) { 13716 clearTimeout(pauseTimeout); 13717 pauseTimeout = void 0; 13718 return; 13719 } 13720 if (!pauseTimeout) { 13721 pauseTimeout = setTimeout(finish, MAX_PAUSE_TIME); 13722 } 13723 } 13724 const unsubscribe = (0, import_data7.subscribe)(checkResolving, import_core_data6.store); 13725 checkResolving(); 13726 function cancel() { 13727 unsubscribe(); 13728 clearTimeout(pauseTimeout); 13729 clearTimeout(maxTimeout); 13730 } 13731 return [promise, cancel]; 13732 } 13733 function useIsSiteEditorLoading() { 13734 const [loaded, setLoaded] = (0, import_element40.useState)(false); 13735 (0, import_element40.useEffect)(() => { 13736 const [promise, cancel] = waitWhileSiteEditorLoading(); 13737 promise.then(() => setLoaded(true)); 13738 return cancel; 13739 }, []); 13740 return !loaded; 13741 } 13742 13743 // node_modules/@react-spring/rafz/dist/react-spring-rafz.esm.js 13744 var updateQueue = makeQueue(); 13745 var raf = (fn) => schedule(fn, updateQueue); 13746 var writeQueue = makeQueue(); 13747 raf.write = (fn) => schedule(fn, writeQueue); 13748 var onStartQueue = makeQueue(); 13749 raf.onStart = (fn) => schedule(fn, onStartQueue); 13750 var onFrameQueue = makeQueue(); 13751 raf.onFrame = (fn) => schedule(fn, onFrameQueue); 13752 var onFinishQueue = makeQueue(); 13753 raf.onFinish = (fn) => schedule(fn, onFinishQueue); 13754 var timeouts = []; 13755 raf.setTimeout = (handler, ms) => { 13756 let time = raf.now() + ms; 13757 let cancel = () => { 13758 let i2 = timeouts.findIndex((t3) => t3.cancel == cancel); 13759 if (~i2) timeouts.splice(i2, 1); 13760 pendingCount -= ~i2 ? 1 : 0; 13761 }; 13762 let timeout = { 13763 time, 13764 handler, 13765 cancel 13766 }; 13767 timeouts.splice(findTimeout(time), 0, timeout); 13768 pendingCount += 1; 13769 start(); 13770 return timeout; 13771 }; 13772 var findTimeout = (time) => ~(~timeouts.findIndex((t3) => t3.time > time) || ~timeouts.length); 13773 raf.cancel = (fn) => { 13774 onStartQueue.delete(fn); 13775 onFrameQueue.delete(fn); 13776 onFinishQueue.delete(fn); 13777 updateQueue.delete(fn); 13778 writeQueue.delete(fn); 13779 }; 13780 raf.sync = (fn) => { 13781 sync = true; 13782 raf.batchedUpdates(fn); 13783 sync = false; 13784 }; 13785 raf.throttle = (fn) => { 13786 let lastArgs; 13787 function queuedFn() { 13788 try { 13789 fn(...lastArgs); 13790 } finally { 13791 lastArgs = null; 13792 } 13793 } 13794 function throttled(...args) { 13795 lastArgs = args; 13796 raf.onStart(queuedFn); 13797 } 13798 throttled.handler = fn; 13799 throttled.cancel = () => { 13800 onStartQueue.delete(queuedFn); 13801 lastArgs = null; 13802 }; 13803 return throttled; 13804 }; 13805 var nativeRaf = typeof window != "undefined" ? window.requestAnimationFrame : () => { 13806 }; 13807 raf.use = (impl) => nativeRaf = impl; 13808 raf.now = typeof performance != "undefined" ? () => performance.now() : Date.now; 13809 raf.batchedUpdates = (fn) => fn(); 13810 raf.catch = console.error; 13811 raf.frameLoop = "always"; 13812 raf.advance = () => { 13813 if (raf.frameLoop !== "demand") { 13814 console.warn("Cannot call the manual advancement of rafz whilst frameLoop is not set as demand"); 13815 } else { 13816 update2(); 13817 } 13818 }; 13819 var ts = -1; 13820 var pendingCount = 0; 13821 var sync = false; 13822 function schedule(fn, queue) { 13823 if (sync) { 13824 queue.delete(fn); 13825 fn(0); 13826 } else { 13827 queue.add(fn); 13828 start(); 13829 } 13830 } 13831 function start() { 13832 if (ts < 0) { 13833 ts = 0; 13834 if (raf.frameLoop !== "demand") { 13835 nativeRaf(loop); 13836 } 13837 } 13838 } 13839 function stop() { 13840 ts = -1; 13841 } 13842 function loop() { 13843 if (~ts) { 13844 nativeRaf(loop); 13845 raf.batchedUpdates(update2); 13846 } 13847 } 13848 function update2() { 13849 let prevTs = ts; 13850 ts = raf.now(); 13851 let count = findTimeout(ts); 13852 if (count) { 13853 eachSafely(timeouts.splice(0, count), (t3) => t3.handler()); 13854 pendingCount -= count; 13855 } 13856 if (!pendingCount) { 13857 stop(); 13858 return; 13859 } 13860 onStartQueue.flush(); 13861 updateQueue.flush(prevTs ? Math.min(64, ts - prevTs) : 16.667); 13862 onFrameQueue.flush(); 13863 writeQueue.flush(); 13864 onFinishQueue.flush(); 13865 } 13866 function makeQueue() { 13867 let next = /* @__PURE__ */ new Set(); 13868 let current = next; 13869 return { 13870 add(fn) { 13871 pendingCount += current == next && !next.has(fn) ? 1 : 0; 13872 next.add(fn); 13873 }, 13874 delete(fn) { 13875 pendingCount -= current == next && next.has(fn) ? 1 : 0; 13876 return next.delete(fn); 13877 }, 13878 flush(arg) { 13879 if (current.size) { 13880 next = /* @__PURE__ */ new Set(); 13881 pendingCount -= current.size; 13882 eachSafely(current, (fn) => fn(arg) && next.add(fn)); 13883 pendingCount += next.size; 13884 current = next; 13885 } 13886 } 13887 }; 13888 } 13889 function eachSafely(values, each2) { 13890 values.forEach((value) => { 13891 try { 13892 each2(value); 13893 } catch (e2) { 13894 raf.catch(e2); 13895 } 13896 }); 13897 } 13898 13899 // node_modules/@react-spring/shared/dist/react-spring-shared.esm.js 13900 var import_react12 = __toESM(require_react()); 13901 function noop4() { 13902 } 13903 var defineHidden = (obj, key, value) => Object.defineProperty(obj, key, { 13904 value, 13905 writable: true, 13906 configurable: true 13907 }); 13908 var is = { 13909 arr: Array.isArray, 13910 obj: (a2) => !!a2 && a2.constructor.name === "Object", 13911 fun: (a2) => typeof a2 === "function", 13912 str: (a2) => typeof a2 === "string", 13913 num: (a2) => typeof a2 === "number", 13914 und: (a2) => a2 === void 0 13915 }; 13916 function isEqual(a2, b2) { 13917 if (is.arr(a2)) { 13918 if (!is.arr(b2) || a2.length !== b2.length) return false; 13919 for (let i2 = 0; i2 < a2.length; i2++) { 13920 if (a2[i2] !== b2[i2]) return false; 13921 } 13922 return true; 13923 } 13924 return a2 === b2; 13925 } 13926 var each = (obj, fn) => obj.forEach(fn); 13927 function eachProp(obj, fn, ctx9) { 13928 if (is.arr(obj)) { 13929 for (let i2 = 0; i2 < obj.length; i2++) { 13930 fn.call(ctx9, obj[i2], `$i2}`); 13931 } 13932 return; 13933 } 13934 for (const key in obj) { 13935 if (obj.hasOwnProperty(key)) { 13936 fn.call(ctx9, obj[key], key); 13937 } 13938 } 13939 } 13940 var toArray = (a2) => is.und(a2) ? [] : is.arr(a2) ? a2 : [a2]; 13941 function flush(queue, iterator) { 13942 if (queue.size) { 13943 const items = Array.from(queue); 13944 queue.clear(); 13945 each(items, iterator); 13946 } 13947 } 13948 var flushCalls = (queue, ...args) => flush(queue, (fn) => fn(...args)); 13949 var isSSR = () => typeof window === "undefined" || !window.navigator || /ServerSideRendering|^Deno\//.test(window.navigator.userAgent); 13950 var createStringInterpolator$1; 13951 var to; 13952 var colors$1 = null; 13953 var skipAnimation = false; 13954 var willAdvance = noop4; 13955 var assign = (globals2) => { 13956 if (globals2.to) to = globals2.to; 13957 if (globals2.now) raf.now = globals2.now; 13958 if (globals2.colors !== void 0) colors$1 = globals2.colors; 13959 if (globals2.skipAnimation != null) skipAnimation = globals2.skipAnimation; 13960 if (globals2.createStringInterpolator) createStringInterpolator$1 = globals2.createStringInterpolator; 13961 if (globals2.requestAnimationFrame) raf.use(globals2.requestAnimationFrame); 13962 if (globals2.batchedUpdates) raf.batchedUpdates = globals2.batchedUpdates; 13963 if (globals2.willAdvance) willAdvance = globals2.willAdvance; 13964 if (globals2.frameLoop) raf.frameLoop = globals2.frameLoop; 13965 }; 13966 var globals = /* @__PURE__ */ Object.freeze({ 13967 __proto__: null, 13968 get createStringInterpolator() { 13969 return createStringInterpolator$1; 13970 }, 13971 get to() { 13972 return to; 13973 }, 13974 get colors() { 13975 return colors$1; 13976 }, 13977 get skipAnimation() { 13978 return skipAnimation; 13979 }, 13980 get willAdvance() { 13981 return willAdvance; 13982 }, 13983 assign 13984 }); 13985 var startQueue = /* @__PURE__ */ new Set(); 13986 var currentFrame = []; 13987 var prevFrame = []; 13988 var priority = 0; 13989 var frameLoop = { 13990 get idle() { 13991 return !startQueue.size && !currentFrame.length; 13992 }, 13993 start(animation) { 13994 if (priority > animation.priority) { 13995 startQueue.add(animation); 13996 raf.onStart(flushStartQueue); 13997 } else { 13998 startSafely(animation); 13999 raf(advance); 14000 } 14001 }, 14002 advance, 14003 sort(animation) { 14004 if (priority) { 14005 raf.onFrame(() => frameLoop.sort(animation)); 14006 } else { 14007 const prevIndex = currentFrame.indexOf(animation); 14008 if (~prevIndex) { 14009 currentFrame.splice(prevIndex, 1); 14010 startUnsafely(animation); 14011 } 14012 } 14013 }, 14014 clear() { 14015 currentFrame = []; 14016 startQueue.clear(); 14017 } 14018 }; 14019 function flushStartQueue() { 14020 startQueue.forEach(startSafely); 14021 startQueue.clear(); 14022 raf(advance); 14023 } 14024 function startSafely(animation) { 14025 if (!currentFrame.includes(animation)) startUnsafely(animation); 14026 } 14027 function startUnsafely(animation) { 14028 currentFrame.splice(findIndex(currentFrame, (other) => other.priority > animation.priority), 0, animation); 14029 } 14030 function advance(dt) { 14031 const nextFrame = prevFrame; 14032 for (let i2 = 0; i2 < currentFrame.length; i2++) { 14033 const animation = currentFrame[i2]; 14034 priority = animation.priority; 14035 if (!animation.idle) { 14036 willAdvance(animation); 14037 animation.advance(dt); 14038 if (!animation.idle) { 14039 nextFrame.push(animation); 14040 } 14041 } 14042 } 14043 priority = 0; 14044 prevFrame = currentFrame; 14045 prevFrame.length = 0; 14046 currentFrame = nextFrame; 14047 return currentFrame.length > 0; 14048 } 14049 function findIndex(arr, test) { 14050 const index2 = arr.findIndex(test); 14051 return index2 < 0 ? arr.length : index2; 14052 } 14053 var colors = { 14054 transparent: 0, 14055 aliceblue: 4042850303, 14056 antiquewhite: 4209760255, 14057 aqua: 16777215, 14058 aquamarine: 2147472639, 14059 azure: 4043309055, 14060 beige: 4126530815, 14061 bisque: 4293182719, 14062 black: 255, 14063 blanchedalmond: 4293643775, 14064 blue: 65535, 14065 blueviolet: 2318131967, 14066 brown: 2771004159, 14067 burlywood: 3736635391, 14068 burntsienna: 3934150143, 14069 cadetblue: 1604231423, 14070 chartreuse: 2147418367, 14071 chocolate: 3530104575, 14072 coral: 4286533887, 14073 cornflowerblue: 1687547391, 14074 cornsilk: 4294499583, 14075 crimson: 3692313855, 14076 cyan: 16777215, 14077 darkblue: 35839, 14078 darkcyan: 9145343, 14079 darkgoldenrod: 3095792639, 14080 darkgray: 2846468607, 14081 darkgreen: 6553855, 14082 darkgrey: 2846468607, 14083 darkkhaki: 3182914559, 14084 darkmagenta: 2332068863, 14085 darkolivegreen: 1433087999, 14086 darkorange: 4287365375, 14087 darkorchid: 2570243327, 14088 darkred: 2332033279, 14089 darksalmon: 3918953215, 14090 darkseagreen: 2411499519, 14091 darkslateblue: 1211993087, 14092 darkslategray: 793726975, 14093 darkslategrey: 793726975, 14094 darkturquoise: 13554175, 14095 darkviolet: 2483082239, 14096 deeppink: 4279538687, 14097 deepskyblue: 12582911, 14098 dimgray: 1768516095, 14099 dimgrey: 1768516095, 14100 dodgerblue: 512819199, 14101 firebrick: 2988581631, 14102 floralwhite: 4294635775, 14103 forestgreen: 579543807, 14104 fuchsia: 4278255615, 14105 gainsboro: 3705462015, 14106 ghostwhite: 4177068031, 14107 gold: 4292280575, 14108 goldenrod: 3668254975, 14109 gray: 2155905279, 14110 green: 8388863, 14111 greenyellow: 2919182335, 14112 grey: 2155905279, 14113 honeydew: 4043305215, 14114 hotpink: 4285117695, 14115 indianred: 3445382399, 14116 indigo: 1258324735, 14117 ivory: 4294963455, 14118 khaki: 4041641215, 14119 lavender: 3873897215, 14120 lavenderblush: 4293981695, 14121 lawngreen: 2096890111, 14122 lemonchiffon: 4294626815, 14123 lightblue: 2916673279, 14124 lightcoral: 4034953471, 14125 lightcyan: 3774873599, 14126 lightgoldenrodyellow: 4210742015, 14127 lightgray: 3553874943, 14128 lightgreen: 2431553791, 14129 lightgrey: 3553874943, 14130 lightpink: 4290167295, 14131 lightsalmon: 4288707327, 14132 lightseagreen: 548580095, 14133 lightskyblue: 2278488831, 14134 lightslategray: 2005441023, 14135 lightslategrey: 2005441023, 14136 lightsteelblue: 2965692159, 14137 lightyellow: 4294959359, 14138 lime: 16711935, 14139 limegreen: 852308735, 14140 linen: 4210091775, 14141 magenta: 4278255615, 14142 maroon: 2147483903, 14143 mediumaquamarine: 1724754687, 14144 mediumblue: 52735, 14145 mediumorchid: 3126187007, 14146 mediumpurple: 2473647103, 14147 mediumseagreen: 1018393087, 14148 mediumslateblue: 2070474495, 14149 mediumspringgreen: 16423679, 14150 mediumturquoise: 1221709055, 14151 mediumvioletred: 3340076543, 14152 midnightblue: 421097727, 14153 mintcream: 4127193855, 14154 mistyrose: 4293190143, 14155 moccasin: 4293178879, 14156 navajowhite: 4292783615, 14157 navy: 33023, 14158 oldlace: 4260751103, 14159 olive: 2155872511, 14160 olivedrab: 1804477439, 14161 orange: 4289003775, 14162 orangered: 4282712319, 14163 orchid: 3664828159, 14164 palegoldenrod: 4008225535, 14165 palegreen: 2566625535, 14166 paleturquoise: 2951671551, 14167 palevioletred: 3681588223, 14168 papayawhip: 4293907967, 14169 peachpuff: 4292524543, 14170 peru: 3448061951, 14171 pink: 4290825215, 14172 plum: 3718307327, 14173 powderblue: 2967529215, 14174 purple: 2147516671, 14175 rebeccapurple: 1714657791, 14176 red: 4278190335, 14177 rosybrown: 3163525119, 14178 royalblue: 1097458175, 14179 saddlebrown: 2336560127, 14180 salmon: 4202722047, 14181 sandybrown: 4104413439, 14182 seagreen: 780883967, 14183 seashell: 4294307583, 14184 sienna: 2689740287, 14185 silver: 3233857791, 14186 skyblue: 2278484991, 14187 slateblue: 1784335871, 14188 slategray: 1887473919, 14189 slategrey: 1887473919, 14190 snow: 4294638335, 14191 springgreen: 16744447, 14192 steelblue: 1182971135, 14193 tan: 3535047935, 14194 teal: 8421631, 14195 thistle: 3636451583, 14196 tomato: 4284696575, 14197 turquoise: 1088475391, 14198 violet: 4001558271, 14199 wheat: 4125012991, 14200 white: 4294967295, 14201 whitesmoke: 4126537215, 14202 yellow: 4294902015, 14203 yellowgreen: 2597139199 14204 }; 14205 var NUMBER = "[-+]?\\d*\\.?\\d+"; 14206 var PERCENTAGE = NUMBER + "%"; 14207 function call(...parts) { 14208 return "\\(\\s*(" + parts.join(")\\s*,\\s*(") + ")\\s*\\)"; 14209 } 14210 var rgb = new RegExp("rgb" + call(NUMBER, NUMBER, NUMBER)); 14211 var rgba = new RegExp("rgba" + call(NUMBER, NUMBER, NUMBER, NUMBER)); 14212 var hsl = new RegExp("hsl" + call(NUMBER, PERCENTAGE, PERCENTAGE)); 14213 var hsla = new RegExp("hsla" + call(NUMBER, PERCENTAGE, PERCENTAGE, NUMBER)); 14214 var hex3 = /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/; 14215 var hex4 = /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/; 14216 var hex6 = /^#([0-9a-fA-F]{6})$/; 14217 var hex8 = /^#([0-9a-fA-F]{8})$/; 14218 function normalizeColor(color) { 14219 let match3; 14220 if (typeof color === "number") { 14221 return color >>> 0 === color && color >= 0 && color <= 4294967295 ? color : null; 14222 } 14223 if (match3 = hex6.exec(color)) return parseInt(match3[1] + "ff", 16) >>> 0; 14224 if (colors$1 && colors$1[color] !== void 0) { 14225 return colors$1[color]; 14226 } 14227 if (match3 = rgb.exec(color)) { 14228 return (parse255(match3[1]) << 24 | parse255(match3[2]) << 16 | parse255(match3[3]) << 8 | 255) >>> 0; 14229 } 14230 if (match3 = rgba.exec(color)) { 14231 return (parse255(match3[1]) << 24 | parse255(match3[2]) << 16 | parse255(match3[3]) << 8 | parse1(match3[4])) >>> 0; 14232 } 14233 if (match3 = hex3.exec(color)) { 14234 return parseInt(match3[1] + match3[1] + match3[2] + match3[2] + match3[3] + match3[3] + "ff", 16) >>> 0; 14235 } 14236 if (match3 = hex8.exec(color)) return parseInt(match3[1], 16) >>> 0; 14237 if (match3 = hex4.exec(color)) { 14238 return parseInt(match3[1] + match3[1] + match3[2] + match3[2] + match3[3] + match3[3] + match3[4] + match3[4], 16) >>> 0; 14239 } 14240 if (match3 = hsl.exec(color)) { 14241 return (hslToRgb(parse360(match3[1]), parsePercentage(match3[2]), parsePercentage(match3[3])) | 255) >>> 0; 14242 } 14243 if (match3 = hsla.exec(color)) { 14244 return (hslToRgb(parse360(match3[1]), parsePercentage(match3[2]), parsePercentage(match3[3])) | parse1(match3[4])) >>> 0; 14245 } 14246 return null; 14247 } 14248 function hue2rgb(p3, q, t3) { 14249 if (t3 < 0) t3 += 1; 14250 if (t3 > 1) t3 -= 1; 14251 if (t3 < 1 / 6) return p3 + (q - p3) * 6 * t3; 14252 if (t3 < 1 / 2) return q; 14253 if (t3 < 2 / 3) return p3 + (q - p3) * (2 / 3 - t3) * 6; 14254 return p3; 14255 } 14256 function hslToRgb(h2, s2, l2) { 14257 const q = l2 < 0.5 ? l2 * (1 + s2) : l2 + s2 - l2 * s2; 14258 const p3 = 2 * l2 - q; 14259 const r3 = hue2rgb(p3, q, h2 + 1 / 3); 14260 const g2 = hue2rgb(p3, q, h2); 14261 const b2 = hue2rgb(p3, q, h2 - 1 / 3); 14262 return Math.round(r3 * 255) << 24 | Math.round(g2 * 255) << 16 | Math.round(b2 * 255) << 8; 14263 } 14264 function parse255(str) { 14265 const int = parseInt(str, 10); 14266 if (int < 0) return 0; 14267 if (int > 255) return 255; 14268 return int; 14269 } 14270 function parse360(str) { 14271 const int = parseFloat(str); 14272 return (int % 360 + 360) % 360 / 360; 14273 } 14274 function parse1(str) { 14275 const num = parseFloat(str); 14276 if (num < 0) return 0; 14277 if (num > 1) return 255; 14278 return Math.round(num * 255); 14279 } 14280 function parsePercentage(str) { 14281 const int = parseFloat(str); 14282 if (int < 0) return 0; 14283 if (int > 100) return 1; 14284 return int / 100; 14285 } 14286 function colorToRgba(input) { 14287 let int32Color = normalizeColor(input); 14288 if (int32Color === null) return input; 14289 int32Color = int32Color || 0; 14290 let r3 = (int32Color & 4278190080) >>> 24; 14291 let g2 = (int32Color & 16711680) >>> 16; 14292 let b2 = (int32Color & 65280) >>> 8; 14293 let a2 = (int32Color & 255) / 255; 14294 return `rgba($r3}, $g2}, $b2}, $a2})`; 14295 } 14296 var createInterpolator = (range, output, extrapolate) => { 14297 if (is.fun(range)) { 14298 return range; 14299 } 14300 if (is.arr(range)) { 14301 return createInterpolator({ 14302 range, 14303 output, 14304 extrapolate 14305 }); 14306 } 14307 if (is.str(range.output[0])) { 14308 return createStringInterpolator$1(range); 14309 } 14310 const config2 = range; 14311 const outputRange = config2.output; 14312 const inputRange = config2.range || [0, 1]; 14313 const extrapolateLeft = config2.extrapolateLeft || config2.extrapolate || "extend"; 14314 const extrapolateRight = config2.extrapolateRight || config2.extrapolate || "extend"; 14315 const easing = config2.easing || ((t3) => t3); 14316 return (input) => { 14317 const range2 = findRange(input, inputRange); 14318 return interpolate(input, inputRange[range2], inputRange[range2 + 1], outputRange[range2], outputRange[range2 + 1], easing, extrapolateLeft, extrapolateRight, config2.map); 14319 }; 14320 }; 14321 function interpolate(input, inputMin, inputMax, outputMin, outputMax, easing, extrapolateLeft, extrapolateRight, map) { 14322 let result = map ? map(input) : input; 14323 if (result < inputMin) { 14324 if (extrapolateLeft === "identity") return result; 14325 else if (extrapolateLeft === "clamp") result = inputMin; 14326 } 14327 if (result > inputMax) { 14328 if (extrapolateRight === "identity") return result; 14329 else if (extrapolateRight === "clamp") result = inputMax; 14330 } 14331 if (outputMin === outputMax) return outputMin; 14332 if (inputMin === inputMax) return input <= inputMin ? outputMin : outputMax; 14333 if (inputMin === -Infinity) result = -result; 14334 else if (inputMax === Infinity) result = result - inputMin; 14335 else result = (result - inputMin) / (inputMax - inputMin); 14336 result = easing(result); 14337 if (outputMin === -Infinity) result = -result; 14338 else if (outputMax === Infinity) result = result + outputMin; 14339 else result = result * (outputMax - outputMin) + outputMin; 14340 return result; 14341 } 14342 function findRange(input, inputRange) { 14343 for (var i2 = 1; i2 < inputRange.length - 1; ++i2) if (inputRange[i2] >= input) break; 14344 return i2 - 1; 14345 } 14346 function _extends() { 14347 _extends = Object.assign ? Object.assign.bind() : function(target) { 14348 for (var i2 = 1; i2 < arguments.length; i2++) { 14349 var source = arguments[i2]; 14350 for (var key in source) { 14351 if (Object.prototype.hasOwnProperty.call(source, key)) { 14352 target[key] = source[key]; 14353 } 14354 } 14355 } 14356 return target; 14357 }; 14358 return _extends.apply(this, arguments); 14359 } 14360 var $get = /* @__PURE__ */ Symbol.for("FluidValue.get"); 14361 var $observers = /* @__PURE__ */ Symbol.for("FluidValue.observers"); 14362 var hasFluidValue = (arg) => Boolean(arg && arg[$get]); 14363 var getFluidValue = (arg) => arg && arg[$get] ? arg[$get]() : arg; 14364 var getFluidObservers = (target) => target[$observers] || null; 14365 function callFluidObserver(observer, event) { 14366 if (observer.eventObserved) { 14367 observer.eventObserved(event); 14368 } else { 14369 observer(event); 14370 } 14371 } 14372 function callFluidObservers(target, event) { 14373 let observers = target[$observers]; 14374 if (observers) { 14375 observers.forEach((observer) => { 14376 callFluidObserver(observer, event); 14377 }); 14378 } 14379 } 14380 var FluidValue = class { 14381 constructor(get) { 14382 this[$get] = void 0; 14383 this[$observers] = void 0; 14384 if (!get && !(get = this.get)) { 14385 throw Error("Unknown getter"); 14386 } 14387 setFluidGetter(this, get); 14388 } 14389 }; 14390 var setFluidGetter = (target, get) => setHidden(target, $get, get); 14391 function addFluidObserver(target, observer) { 14392 if (target[$get]) { 14393 let observers = target[$observers]; 14394 if (!observers) { 14395 setHidden(target, $observers, observers = /* @__PURE__ */ new Set()); 14396 } 14397 if (!observers.has(observer)) { 14398 observers.add(observer); 14399 if (target.observerAdded) { 14400 target.observerAdded(observers.size, observer); 14401 } 14402 } 14403 } 14404 return observer; 14405 } 14406 function removeFluidObserver(target, observer) { 14407 let observers = target[$observers]; 14408 if (observers && observers.has(observer)) { 14409 const count = observers.size - 1; 14410 if (count) { 14411 observers.delete(observer); 14412 } else { 14413 target[$observers] = null; 14414 } 14415 if (target.observerRemoved) { 14416 target.observerRemoved(count, observer); 14417 } 14418 } 14419 } 14420 var setHidden = (target, key, value) => Object.defineProperty(target, key, { 14421 value, 14422 writable: true, 14423 configurable: true 14424 }); 14425 var numberRegex = /[+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?/g; 14426 var colorRegex = /(#(?:[0-9a-f]{2}){2,4}|(#[0-9a-f]{3})|(rgb|hsl)a?\((-?\d+%?[,\s]+){2,3}\s*[\d\.]+%?\))/gi; 14427 var unitRegex = new RegExp(`($numberRegex.source})(%|[a-z]+)`, "i"); 14428 var rgbaRegex = /rgba\(([0-9\.-]+), ([0-9\.-]+), ([0-9\.-]+), ([0-9\.-]+)\)/gi; 14429 var cssVariableRegex = /var\((--[a-zA-Z0-9-_]+),? ?([a-zA-Z0-9 ()%#.,-]+)?\)/; 14430 var variableToRgba = (input) => { 14431 const [token, fallback] = parseCSSVariable(input); 14432 if (!token || isSSR()) { 14433 return input; 14434 } 14435 const value = window.getComputedStyle(document.documentElement).getPropertyValue(token); 14436 if (value) { 14437 return value.trim(); 14438 } else if (fallback && fallback.startsWith("--")) { 14439 const _value = window.getComputedStyle(document.documentElement).getPropertyValue(fallback); 14440 if (_value) { 14441 return _value; 14442 } else { 14443 return input; 14444 } 14445 } else if (fallback && cssVariableRegex.test(fallback)) { 14446 return variableToRgba(fallback); 14447 } else if (fallback) { 14448 return fallback; 14449 } 14450 return input; 14451 }; 14452 var parseCSSVariable = (current) => { 14453 const match3 = cssVariableRegex.exec(current); 14454 if (!match3) return [,]; 14455 const [, token, fallback] = match3; 14456 return [token, fallback]; 14457 }; 14458 var namedColorRegex; 14459 var rgbaRound = (_, p1, p22, p3, p4) => `rgba($Math.round(p1)}, $Math.round(p22)}, $Math.round(p3)}, $p4})`; 14460 var createStringInterpolator = (config2) => { 14461 if (!namedColorRegex) namedColorRegex = colors$1 ? new RegExp(`($Object.keys(colors$1).join("|")})(?!\\w)`, "g") : /^\b$/; 14462 const output = config2.output.map((value) => { 14463 return getFluidValue(value).replace(cssVariableRegex, variableToRgba).replace(colorRegex, colorToRgba).replace(namedColorRegex, colorToRgba); 14464 }); 14465 const keyframes = output.map((value) => value.match(numberRegex).map(Number)); 14466 const outputRanges = keyframes[0].map((_, i2) => keyframes.map((values) => { 14467 if (!(i2 in values)) { 14468 throw Error('The arity of each "output" value must be equal'); 14469 } 14470 return values[i2]; 14471 })); 14472 const interpolators = outputRanges.map((output2) => createInterpolator(_extends({}, config2, { 14473 output: output2 14474 }))); 14475 return (input) => { 14476 var _output$find; 14477 const missingUnit = !unitRegex.test(output[0]) && ((_output$find = output.find((value) => unitRegex.test(value))) == null ? void 0 : _output$find.replace(numberRegex, "")); 14478 let i2 = 0; 14479 return output[0].replace(numberRegex, () => `$interpolators[i2++](input)}$missingUnit || ""}`).replace(rgbaRegex, rgbaRound); 14480 }; 14481 }; 14482 var prefix = "react-spring: "; 14483 var once = (fn) => { 14484 const func = fn; 14485 let called = false; 14486 if (typeof func != "function") { 14487 throw new TypeError(`$prefix}once requires a function parameter`); 14488 } 14489 return (...args) => { 14490 if (!called) { 14491 func(...args); 14492 called = true; 14493 } 14494 }; 14495 }; 14496 var warnInterpolate = once(console.warn); 14497 function deprecateInterpolate() { 14498 warnInterpolate(`$prefix}The "interpolate" function is deprecated in v9 (use "to" instead)`); 14499 } 14500 var warnDirectCall = once(console.warn); 14501 function isAnimatedString(value) { 14502 return is.str(value) && (value[0] == "#" || /\d/.test(value) || !isSSR() && cssVariableRegex.test(value) || value in (colors$1 || {})); 14503 } 14504 var useIsomorphicLayoutEffect = isSSR() ? import_react12.useEffect : import_react12.useLayoutEffect; 14505 var useIsMounted = () => { 14506 const isMounted = (0, import_react12.useRef)(false); 14507 useIsomorphicLayoutEffect(() => { 14508 isMounted.current = true; 14509 return () => { 14510 isMounted.current = false; 14511 }; 14512 }, []); 14513 return isMounted; 14514 }; 14515 function useForceUpdate() { 14516 const update4 = (0, import_react12.useState)()[1]; 14517 const isMounted = useIsMounted(); 14518 return () => { 14519 if (isMounted.current) { 14520 update4(Math.random()); 14521 } 14522 }; 14523 } 14524 function useMemoOne(getResult, inputs) { 14525 const [initial2] = (0, import_react12.useState)(() => ({ 14526 inputs, 14527 result: getResult() 14528 })); 14529 const committed = (0, import_react12.useRef)(); 14530 const prevCache = committed.current; 14531 let cache = prevCache; 14532 if (cache) { 14533 const useCache = Boolean(inputs && cache.inputs && areInputsEqual(inputs, cache.inputs)); 14534 if (!useCache) { 14535 cache = { 14536 inputs, 14537 result: getResult() 14538 }; 14539 } 14540 } else { 14541 cache = initial2; 14542 } 14543 (0, import_react12.useEffect)(() => { 14544 committed.current = cache; 14545 if (prevCache == initial2) { 14546 initial2.inputs = initial2.result = void 0; 14547 } 14548 }, [cache]); 14549 return cache.result; 14550 } 14551 function areInputsEqual(next, prev) { 14552 if (next.length !== prev.length) { 14553 return false; 14554 } 14555 for (let i2 = 0; i2 < next.length; i2++) { 14556 if (next[i2] !== prev[i2]) { 14557 return false; 14558 } 14559 } 14560 return true; 14561 } 14562 var useOnce = (effect) => (0, import_react12.useEffect)(effect, emptyDeps); 14563 var emptyDeps = []; 14564 14565 // node_modules/@react-spring/core/dist/react-spring-core.esm.js 14566 var React58 = __toESM(require_react()); 14567 var import_react14 = __toESM(require_react()); 14568 14569 // node_modules/@react-spring/animated/dist/react-spring-animated.esm.js 14570 var React57 = __toESM(require_react()); 14571 var import_react13 = __toESM(require_react()); 14572 var $node = /* @__PURE__ */ Symbol.for("Animated:node"); 14573 var isAnimated = (value) => !!value && value[$node] === value; 14574 var getAnimated = (owner) => owner && owner[$node]; 14575 var setAnimated = (owner, node) => defineHidden(owner, $node, node); 14576 var getPayload = (owner) => owner && owner[$node] && owner[$node].getPayload(); 14577 var Animated = class { 14578 constructor() { 14579 this.payload = void 0; 14580 setAnimated(this, this); 14581 } 14582 getPayload() { 14583 return this.payload || []; 14584 } 14585 }; 14586 var AnimatedValue = class _AnimatedValue extends Animated { 14587 constructor(_value) { 14588 super(); 14589 this.done = true; 14590 this.elapsedTime = void 0; 14591 this.lastPosition = void 0; 14592 this.lastVelocity = void 0; 14593 this.v0 = void 0; 14594 this.durationProgress = 0; 14595 this._value = _value; 14596 if (is.num(this._value)) { 14597 this.lastPosition = this._value; 14598 } 14599 } 14600 static create(value) { 14601 return new _AnimatedValue(value); 14602 } 14603 getPayload() { 14604 return [this]; 14605 } 14606 getValue() { 14607 return this._value; 14608 } 14609 setValue(value, step) { 14610 if (is.num(value)) { 14611 this.lastPosition = value; 14612 if (step) { 14613 value = Math.round(value / step) * step; 14614 if (this.done) { 14615 this.lastPosition = value; 14616 } 14617 } 14618 } 14619 if (this._value === value) { 14620 return false; 14621 } 14622 this._value = value; 14623 return true; 14624 } 14625 reset() { 14626 const { 14627 done 14628 } = this; 14629 this.done = false; 14630 if (is.num(this._value)) { 14631 this.elapsedTime = 0; 14632 this.durationProgress = 0; 14633 this.lastPosition = this._value; 14634 if (done) this.lastVelocity = null; 14635 this.v0 = null; 14636 } 14637 } 14638 }; 14639 var AnimatedString = class _AnimatedString extends AnimatedValue { 14640 constructor(value) { 14641 super(0); 14642 this._string = null; 14643 this._toString = void 0; 14644 this._toString = createInterpolator({ 14645 output: [value, value] 14646 }); 14647 } 14648 static create(value) { 14649 return new _AnimatedString(value); 14650 } 14651 getValue() { 14652 let value = this._string; 14653 return value == null ? this._string = this._toString(this._value) : value; 14654 } 14655 setValue(value) { 14656 if (is.str(value)) { 14657 if (value == this._string) { 14658 return false; 14659 } 14660 this._string = value; 14661 this._value = 1; 14662 } else if (super.setValue(value)) { 14663 this._string = null; 14664 } else { 14665 return false; 14666 } 14667 return true; 14668 } 14669 reset(goal) { 14670 if (goal) { 14671 this._toString = createInterpolator({ 14672 output: [this.getValue(), goal] 14673 }); 14674 } 14675 this._value = 0; 14676 super.reset(); 14677 } 14678 }; 14679 var TreeContext = { 14680 dependencies: null 14681 }; 14682 var AnimatedObject = class extends Animated { 14683 constructor(source) { 14684 super(); 14685 this.source = source; 14686 this.setValue(source); 14687 } 14688 getValue(animated2) { 14689 const values = {}; 14690 eachProp(this.source, (source, key) => { 14691 if (isAnimated(source)) { 14692 values[key] = source.getValue(animated2); 14693 } else if (hasFluidValue(source)) { 14694 values[key] = getFluidValue(source); 14695 } else if (!animated2) { 14696 values[key] = source; 14697 } 14698 }); 14699 return values; 14700 } 14701 setValue(source) { 14702 this.source = source; 14703 this.payload = this._makePayload(source); 14704 } 14705 reset() { 14706 if (this.payload) { 14707 each(this.payload, (node) => node.reset()); 14708 } 14709 } 14710 _makePayload(source) { 14711 if (source) { 14712 const payload = /* @__PURE__ */ new Set(); 14713 eachProp(source, this._addToPayload, payload); 14714 return Array.from(payload); 14715 } 14716 } 14717 _addToPayload(source) { 14718 if (TreeContext.dependencies && hasFluidValue(source)) { 14719 TreeContext.dependencies.add(source); 14720 } 14721 const payload = getPayload(source); 14722 if (payload) { 14723 each(payload, (node) => this.add(node)); 14724 } 14725 } 14726 }; 14727 var AnimatedArray = class _AnimatedArray extends AnimatedObject { 14728 constructor(source) { 14729 super(source); 14730 } 14731 static create(source) { 14732 return new _AnimatedArray(source); 14733 } 14734 getValue() { 14735 return this.source.map((node) => node.getValue()); 14736 } 14737 setValue(source) { 14738 const payload = this.getPayload(); 14739 if (source.length == payload.length) { 14740 return payload.map((node, i2) => node.setValue(source[i2])).some(Boolean); 14741 } 14742 super.setValue(source.map(makeAnimated)); 14743 return true; 14744 } 14745 }; 14746 function makeAnimated(value) { 14747 const nodeType = isAnimatedString(value) ? AnimatedString : AnimatedValue; 14748 return nodeType.create(value); 14749 } 14750 function getAnimatedType(value) { 14751 const parentNode = getAnimated(value); 14752 return parentNode ? parentNode.constructor : is.arr(value) ? AnimatedArray : isAnimatedString(value) ? AnimatedString : AnimatedValue; 14753 } 14754 function _extends2() { 14755 _extends2 = Object.assign ? Object.assign.bind() : function(target) { 14756 for (var i2 = 1; i2 < arguments.length; i2++) { 14757 var source = arguments[i2]; 14758 for (var key in source) { 14759 if (Object.prototype.hasOwnProperty.call(source, key)) { 14760 target[key] = source[key]; 14761 } 14762 } 14763 } 14764 return target; 14765 }; 14766 return _extends2.apply(this, arguments); 14767 } 14768 var withAnimated = (Component, host2) => { 14769 const hasInstance = !is.fun(Component) || Component.prototype && Component.prototype.isReactComponent; 14770 return (0, import_react13.forwardRef)((givenProps, givenRef) => { 14771 const instanceRef = (0, import_react13.useRef)(null); 14772 const ref = hasInstance && (0, import_react13.useCallback)((value) => { 14773 instanceRef.current = updateRef(givenRef, value); 14774 }, [givenRef]); 14775 const [props, deps] = getAnimatedState(givenProps, host2); 14776 const forceUpdate = useForceUpdate(); 14777 const callback = () => { 14778 const instance = instanceRef.current; 14779 if (hasInstance && !instance) { 14780 return; 14781 } 14782 const didUpdate = instance ? host2.applyAnimatedValues(instance, props.getValue(true)) : false; 14783 if (didUpdate === false) { 14784 forceUpdate(); 14785 } 14786 }; 14787 const observer = new PropsObserver(callback, deps); 14788 const observerRef = (0, import_react13.useRef)(); 14789 useIsomorphicLayoutEffect(() => { 14790 observerRef.current = observer; 14791 each(deps, (dep) => addFluidObserver(dep, observer)); 14792 return () => { 14793 if (observerRef.current) { 14794 each(observerRef.current.deps, (dep) => removeFluidObserver(dep, observerRef.current)); 14795 raf.cancel(observerRef.current.update); 14796 } 14797 }; 14798 }); 14799 (0, import_react13.useEffect)(callback, []); 14800 useOnce(() => () => { 14801 const observer2 = observerRef.current; 14802 each(observer2.deps, (dep) => removeFluidObserver(dep, observer2)); 14803 }); 14804 const usedProps = host2.getComponentProps(props.getValue()); 14805 return React57.createElement(Component, _extends2({}, usedProps, { 14806 ref 14807 })); 14808 }); 14809 }; 14810 var PropsObserver = class { 14811 constructor(update4, deps) { 14812 this.update = update4; 14813 this.deps = deps; 14814 } 14815 eventObserved(event) { 14816 if (event.type == "change") { 14817 raf.write(this.update); 14818 } 14819 } 14820 }; 14821 function getAnimatedState(props, host2) { 14822 const dependencies = /* @__PURE__ */ new Set(); 14823 TreeContext.dependencies = dependencies; 14824 if (props.style) props = _extends2({}, props, { 14825 style: host2.createAnimatedStyle(props.style) 14826 }); 14827 props = new AnimatedObject(props); 14828 TreeContext.dependencies = null; 14829 return [props, dependencies]; 14830 } 14831 function updateRef(ref, value) { 14832 if (ref) { 14833 if (is.fun(ref)) ref(value); 14834 else ref.current = value; 14835 } 14836 return value; 14837 } 14838 var cacheKey = /* @__PURE__ */ Symbol.for("AnimatedComponent"); 14839 var createHost = (components, { 14840 applyAnimatedValues: _applyAnimatedValues = () => false, 14841 createAnimatedStyle: _createAnimatedStyle = (style) => new AnimatedObject(style), 14842 getComponentProps: _getComponentProps = (props) => props 14843 } = {}) => { 14844 const hostConfig = { 14845 applyAnimatedValues: _applyAnimatedValues, 14846 createAnimatedStyle: _createAnimatedStyle, 14847 getComponentProps: _getComponentProps 14848 }; 14849 const animated2 = (Component) => { 14850 const displayName = getDisplayName(Component) || "Anonymous"; 14851 if (is.str(Component)) { 14852 Component = animated2[Component] || (animated2[Component] = withAnimated(Component, hostConfig)); 14853 } else { 14854 Component = Component[cacheKey] || (Component[cacheKey] = withAnimated(Component, hostConfig)); 14855 } 14856 Component.displayName = `Animated($displayName})`; 14857 return Component; 14858 }; 14859 eachProp(components, (Component, key) => { 14860 if (is.arr(components)) { 14861 key = getDisplayName(Component); 14862 } 14863 animated2[key] = animated2(Component); 14864 }); 14865 return { 14866 animated: animated2 14867 }; 14868 }; 14869 var getDisplayName = (arg) => is.str(arg) ? arg : arg && is.str(arg.displayName) ? arg.displayName : is.fun(arg) && arg.name || null; 14870 14871 // node_modules/@react-spring/core/dist/react-spring-core.esm.js 14872 function _extends3() { 14873 _extends3 = Object.assign ? Object.assign.bind() : function(target) { 14874 for (var i2 = 1; i2 < arguments.length; i2++) { 14875 var source = arguments[i2]; 14876 for (var key in source) { 14877 if (Object.prototype.hasOwnProperty.call(source, key)) { 14878 target[key] = source[key]; 14879 } 14880 } 14881 } 14882 return target; 14883 }; 14884 return _extends3.apply(this, arguments); 14885 } 14886 function callProp(value, ...args) { 14887 return is.fun(value) ? value(...args) : value; 14888 } 14889 var matchProp = (value, key) => value === true || !!(key && value && (is.fun(value) ? value(key) : toArray(value).includes(key))); 14890 var resolveProp = (prop, key) => is.obj(prop) ? key && prop[key] : prop; 14891 var getDefaultProp = (props, key) => props.default === true ? props[key] : props.default ? props.default[key] : void 0; 14892 var noopTransform = (value) => value; 14893 var getDefaultProps = (props, transform = noopTransform) => { 14894 let keys = DEFAULT_PROPS; 14895 if (props.default && props.default !== true) { 14896 props = props.default; 14897 keys = Object.keys(props); 14898 } 14899 const defaults2 = {}; 14900 for (const key of keys) { 14901 const value = transform(props[key], key); 14902 if (!is.und(value)) { 14903 defaults2[key] = value; 14904 } 14905 } 14906 return defaults2; 14907 }; 14908 var DEFAULT_PROPS = ["config", "onProps", "onStart", "onChange", "onPause", "onResume", "onRest"]; 14909 var RESERVED_PROPS = { 14910 config: 1, 14911 from: 1, 14912 to: 1, 14913 ref: 1, 14914 loop: 1, 14915 reset: 1, 14916 pause: 1, 14917 cancel: 1, 14918 reverse: 1, 14919 immediate: 1, 14920 default: 1, 14921 delay: 1, 14922 onProps: 1, 14923 onStart: 1, 14924 onChange: 1, 14925 onPause: 1, 14926 onResume: 1, 14927 onRest: 1, 14928 onResolve: 1, 14929 items: 1, 14930 trail: 1, 14931 sort: 1, 14932 expires: 1, 14933 initial: 1, 14934 enter: 1, 14935 update: 1, 14936 leave: 1, 14937 children: 1, 14938 onDestroyed: 1, 14939 keys: 1, 14940 callId: 1, 14941 parentId: 1 14942 }; 14943 function getForwardProps(props) { 14944 const forward = {}; 14945 let count = 0; 14946 eachProp(props, (value, prop) => { 14947 if (!RESERVED_PROPS[prop]) { 14948 forward[prop] = value; 14949 count++; 14950 } 14951 }); 14952 if (count) { 14953 return forward; 14954 } 14955 } 14956 function inferTo(props) { 14957 const to2 = getForwardProps(props); 14958 if (to2) { 14959 const out = { 14960 to: to2 14961 }; 14962 eachProp(props, (val, key) => key in to2 || (out[key] = val)); 14963 return out; 14964 } 14965 return _extends3({}, props); 14966 } 14967 function computeGoal(value) { 14968 value = getFluidValue(value); 14969 return is.arr(value) ? value.map(computeGoal) : isAnimatedString(value) ? globals.createStringInterpolator({ 14970 range: [0, 1], 14971 output: [value, value] 14972 })(1) : value; 14973 } 14974 function isAsyncTo(to2) { 14975 return is.fun(to2) || is.arr(to2) && is.obj(to2[0]); 14976 } 14977 var config = { 14978 default: { 14979 tension: 170, 14980 friction: 26 14981 }, 14982 gentle: { 14983 tension: 120, 14984 friction: 14 14985 }, 14986 wobbly: { 14987 tension: 180, 14988 friction: 12 14989 }, 14990 stiff: { 14991 tension: 210, 14992 friction: 20 14993 }, 14994 slow: { 14995 tension: 280, 14996 friction: 60 14997 }, 14998 molasses: { 14999 tension: 280, 15000 friction: 120 15001 } 15002 }; 15003 var c1 = 1.70158; 15004 var c2 = c1 * 1.525; 15005 var c3 = c1 + 1; 15006 var c4 = 2 * Math.PI / 3; 15007 var c5 = 2 * Math.PI / 4.5; 15008 var bounceOut = (x2) => { 15009 const n1 = 7.5625; 15010 const d1 = 2.75; 15011 if (x2 < 1 / d1) { 15012 return n1 * x2 * x2; 15013 } else if (x2 < 2 / d1) { 15014 return n1 * (x2 -= 1.5 / d1) * x2 + 0.75; 15015 } else if (x2 < 2.5 / d1) { 15016 return n1 * (x2 -= 2.25 / d1) * x2 + 0.9375; 15017 } else { 15018 return n1 * (x2 -= 2.625 / d1) * x2 + 0.984375; 15019 } 15020 }; 15021 var easings = { 15022 linear: (x2) => x2, 15023 easeInQuad: (x2) => x2 * x2, 15024 easeOutQuad: (x2) => 1 - (1 - x2) * (1 - x2), 15025 easeInOutQuad: (x2) => x2 < 0.5 ? 2 * x2 * x2 : 1 - Math.pow(-2 * x2 + 2, 2) / 2, 15026 easeInCubic: (x2) => x2 * x2 * x2, 15027 easeOutCubic: (x2) => 1 - Math.pow(1 - x2, 3), 15028 easeInOutCubic: (x2) => x2 < 0.5 ? 4 * x2 * x2 * x2 : 1 - Math.pow(-2 * x2 + 2, 3) / 2, 15029 easeInQuart: (x2) => x2 * x2 * x2 * x2, 15030 easeOutQuart: (x2) => 1 - Math.pow(1 - x2, 4), 15031 easeInOutQuart: (x2) => x2 < 0.5 ? 8 * x2 * x2 * x2 * x2 : 1 - Math.pow(-2 * x2 + 2, 4) / 2, 15032 easeInQuint: (x2) => x2 * x2 * x2 * x2 * x2, 15033 easeOutQuint: (x2) => 1 - Math.pow(1 - x2, 5), 15034 easeInOutQuint: (x2) => x2 < 0.5 ? 16 * x2 * x2 * x2 * x2 * x2 : 1 - Math.pow(-2 * x2 + 2, 5) / 2, 15035 easeInSine: (x2) => 1 - Math.cos(x2 * Math.PI / 2), 15036 easeOutSine: (x2) => Math.sin(x2 * Math.PI / 2), 15037 easeInOutSine: (x2) => -(Math.cos(Math.PI * x2) - 1) / 2, 15038 easeInExpo: (x2) => x2 === 0 ? 0 : Math.pow(2, 10 * x2 - 10), 15039 easeOutExpo: (x2) => x2 === 1 ? 1 : 1 - Math.pow(2, -10 * x2), 15040 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, 15041 easeInCirc: (x2) => 1 - Math.sqrt(1 - Math.pow(x2, 2)), 15042 easeOutCirc: (x2) => Math.sqrt(1 - Math.pow(x2 - 1, 2)), 15043 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, 15044 easeInBack: (x2) => c3 * x2 * x2 * x2 - c1 * x2 * x2, 15045 easeOutBack: (x2) => 1 + c3 * Math.pow(x2 - 1, 3) + c1 * Math.pow(x2 - 1, 2), 15046 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, 15047 easeInElastic: (x2) => x2 === 0 ? 0 : x2 === 1 ? 1 : -Math.pow(2, 10 * x2 - 10) * Math.sin((x2 * 10 - 10.75) * c4), 15048 easeOutElastic: (x2) => x2 === 0 ? 0 : x2 === 1 ? 1 : Math.pow(2, -10 * x2) * Math.sin((x2 * 10 - 0.75) * c4) + 1, 15049 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, 15050 easeInBounce: (x2) => 1 - bounceOut(1 - x2), 15051 easeOutBounce: bounceOut, 15052 easeInOutBounce: (x2) => x2 < 0.5 ? (1 - bounceOut(1 - 2 * x2)) / 2 : (1 + bounceOut(2 * x2 - 1)) / 2 15053 }; 15054 var defaults = _extends3({}, config.default, { 15055 mass: 1, 15056 damping: 1, 15057 easing: easings.linear, 15058 clamp: false 15059 }); 15060 var AnimationConfig = class { 15061 constructor() { 15062 this.tension = void 0; 15063 this.friction = void 0; 15064 this.frequency = void 0; 15065 this.damping = void 0; 15066 this.mass = void 0; 15067 this.velocity = 0; 15068 this.restVelocity = void 0; 15069 this.precision = void 0; 15070 this.progress = void 0; 15071 this.duration = void 0; 15072 this.easing = void 0; 15073 this.clamp = void 0; 15074 this.bounce = void 0; 15075 this.decay = void 0; 15076 this.round = void 0; 15077 Object.assign(this, defaults); 15078 } 15079 }; 15080 function mergeConfig(config2, newConfig, defaultConfig) { 15081 if (defaultConfig) { 15082 defaultConfig = _extends3({}, defaultConfig); 15083 sanitizeConfig(defaultConfig, newConfig); 15084 newConfig = _extends3({}, defaultConfig, newConfig); 15085 } 15086 sanitizeConfig(config2, newConfig); 15087 Object.assign(config2, newConfig); 15088 for (const key in defaults) { 15089 if (config2[key] == null) { 15090 config2[key] = defaults[key]; 15091 } 15092 } 15093 let { 15094 mass, 15095 frequency, 15096 damping 15097 } = config2; 15098 if (!is.und(frequency)) { 15099 if (frequency < 0.01) frequency = 0.01; 15100 if (damping < 0) damping = 0; 15101 config2.tension = Math.pow(2 * Math.PI / frequency, 2) * mass; 15102 config2.friction = 4 * Math.PI * damping * mass / frequency; 15103 } 15104 return config2; 15105 } 15106 function sanitizeConfig(config2, props) { 15107 if (!is.und(props.decay)) { 15108 config2.duration = void 0; 15109 } else { 15110 const isTensionConfig = !is.und(props.tension) || !is.und(props.friction); 15111 if (isTensionConfig || !is.und(props.frequency) || !is.und(props.damping) || !is.und(props.mass)) { 15112 config2.duration = void 0; 15113 config2.decay = void 0; 15114 } 15115 if (isTensionConfig) { 15116 config2.frequency = void 0; 15117 } 15118 } 15119 } 15120 var emptyArray = []; 15121 var Animation = class { 15122 constructor() { 15123 this.changed = false; 15124 this.values = emptyArray; 15125 this.toValues = null; 15126 this.fromValues = emptyArray; 15127 this.to = void 0; 15128 this.from = void 0; 15129 this.config = new AnimationConfig(); 15130 this.immediate = false; 15131 } 15132 }; 15133 function scheduleProps(callId, { 15134 key, 15135 props, 15136 defaultProps, 15137 state, 15138 actions 15139 }) { 15140 return new Promise((resolve, reject) => { 15141 var _props$cancel; 15142 let delay; 15143 let timeout; 15144 let cancel = matchProp((_props$cancel = props.cancel) != null ? _props$cancel : defaultProps == null ? void 0 : defaultProps.cancel, key); 15145 if (cancel) { 15146 onStart(); 15147 } else { 15148 if (!is.und(props.pause)) { 15149 state.paused = matchProp(props.pause, key); 15150 } 15151 let pause = defaultProps == null ? void 0 : defaultProps.pause; 15152 if (pause !== true) { 15153 pause = state.paused || matchProp(pause, key); 15154 } 15155 delay = callProp(props.delay || 0, key); 15156 if (pause) { 15157 state.resumeQueue.add(onResume); 15158 actions.pause(); 15159 } else { 15160 actions.resume(); 15161 onResume(); 15162 } 15163 } 15164 function onPause() { 15165 state.resumeQueue.add(onResume); 15166 state.timeouts.delete(timeout); 15167 timeout.cancel(); 15168 delay = timeout.time - raf.now(); 15169 } 15170 function onResume() { 15171 if (delay > 0 && !globals.skipAnimation) { 15172 state.delayed = true; 15173 timeout = raf.setTimeout(onStart, delay); 15174 state.pauseQueue.add(onPause); 15175 state.timeouts.add(timeout); 15176 } else { 15177 onStart(); 15178 } 15179 } 15180 function onStart() { 15181 if (state.delayed) { 15182 state.delayed = false; 15183 } 15184 state.pauseQueue.delete(onPause); 15185 state.timeouts.delete(timeout); 15186 if (callId <= (state.cancelId || 0)) { 15187 cancel = true; 15188 } 15189 try { 15190 actions.start(_extends3({}, props, { 15191 callId, 15192 cancel 15193 }), resolve); 15194 } catch (err) { 15195 reject(err); 15196 } 15197 } 15198 }); 15199 } 15200 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)); 15201 var getNoopResult = (value) => ({ 15202 value, 15203 noop: true, 15204 finished: true, 15205 cancelled: false 15206 }); 15207 var getFinishedResult = (value, finished, cancelled = false) => ({ 15208 value, 15209 finished, 15210 cancelled 15211 }); 15212 var getCancelledResult = (value) => ({ 15213 value, 15214 cancelled: true, 15215 finished: false 15216 }); 15217 function runAsync(to2, props, state, target) { 15218 const { 15219 callId, 15220 parentId, 15221 onRest 15222 } = props; 15223 const { 15224 asyncTo: prevTo, 15225 promise: prevPromise 15226 } = state; 15227 if (!parentId && to2 === prevTo && !props.reset) { 15228 return prevPromise; 15229 } 15230 return state.promise = (async () => { 15231 state.asyncId = callId; 15232 state.asyncTo = to2; 15233 const defaultProps = getDefaultProps(props, (value, key) => key === "onRest" ? void 0 : value); 15234 let preventBail; 15235 let bail; 15236 const bailPromise = new Promise((resolve, reject) => (preventBail = resolve, bail = reject)); 15237 const bailIfEnded = (bailSignal) => { 15238 const bailResult = callId <= (state.cancelId || 0) && getCancelledResult(target) || callId !== state.asyncId && getFinishedResult(target, false); 15239 if (bailResult) { 15240 bailSignal.result = bailResult; 15241 bail(bailSignal); 15242 throw bailSignal; 15243 } 15244 }; 15245 const animate = (arg1, arg2) => { 15246 const bailSignal = new BailSignal(); 15247 const skipAnimationSignal = new SkipAniamtionSignal(); 15248 return (async () => { 15249 if (globals.skipAnimation) { 15250 stopAsync(state); 15251 skipAnimationSignal.result = getFinishedResult(target, false); 15252 bail(skipAnimationSignal); 15253 throw skipAnimationSignal; 15254 } 15255 bailIfEnded(bailSignal); 15256 const props2 = is.obj(arg1) ? _extends3({}, arg1) : _extends3({}, arg2, { 15257 to: arg1 15258 }); 15259 props2.parentId = callId; 15260 eachProp(defaultProps, (value, key) => { 15261 if (is.und(props2[key])) { 15262 props2[key] = value; 15263 } 15264 }); 15265 const result2 = await target.start(props2); 15266 bailIfEnded(bailSignal); 15267 if (state.paused) { 15268 await new Promise((resume) => { 15269 state.resumeQueue.add(resume); 15270 }); 15271 } 15272 return result2; 15273 })(); 15274 }; 15275 let result; 15276 if (globals.skipAnimation) { 15277 stopAsync(state); 15278 return getFinishedResult(target, false); 15279 } 15280 try { 15281 let animating; 15282 if (is.arr(to2)) { 15283 animating = (async (queue) => { 15284 for (const props2 of queue) { 15285 await animate(props2); 15286 } 15287 })(to2); 15288 } else { 15289 animating = Promise.resolve(to2(animate, target.stop.bind(target))); 15290 } 15291 await Promise.all([animating.then(preventBail), bailPromise]); 15292 result = getFinishedResult(target.get(), true, false); 15293 } catch (err) { 15294 if (err instanceof BailSignal) { 15295 result = err.result; 15296 } else if (err instanceof SkipAniamtionSignal) { 15297 result = err.result; 15298 } else { 15299 throw err; 15300 } 15301 } finally { 15302 if (callId == state.asyncId) { 15303 state.asyncId = parentId; 15304 state.asyncTo = parentId ? prevTo : void 0; 15305 state.promise = parentId ? prevPromise : void 0; 15306 } 15307 } 15308 if (is.fun(onRest)) { 15309 raf.batchedUpdates(() => { 15310 onRest(result, target, target.item); 15311 }); 15312 } 15313 return result; 15314 })(); 15315 } 15316 function stopAsync(state, cancelId) { 15317 flush(state.timeouts, (t3) => t3.cancel()); 15318 state.pauseQueue.clear(); 15319 state.resumeQueue.clear(); 15320 state.asyncId = state.asyncTo = state.promise = void 0; 15321 if (cancelId) state.cancelId = cancelId; 15322 } 15323 var BailSignal = class extends Error { 15324 constructor() { 15325 super("An async animation has been interrupted. You see this error because you forgot to use `await` or `.catch(...)` on its returned promise."); 15326 this.result = void 0; 15327 } 15328 }; 15329 var SkipAniamtionSignal = class extends Error { 15330 constructor() { 15331 super("SkipAnimationSignal"); 15332 this.result = void 0; 15333 } 15334 }; 15335 var isFrameValue = (value) => value instanceof FrameValue; 15336 var nextId$1 = 1; 15337 var FrameValue = class extends FluidValue { 15338 constructor(...args) { 15339 super(...args); 15340 this.id = nextId$1++; 15341 this.key = void 0; 15342 this._priority = 0; 15343 } 15344 get priority() { 15345 return this._priority; 15346 } 15347 set priority(priority2) { 15348 if (this._priority != priority2) { 15349 this._priority = priority2; 15350 this._onPriorityChange(priority2); 15351 } 15352 } 15353 get() { 15354 const node = getAnimated(this); 15355 return node && node.getValue(); 15356 } 15357 to(...args) { 15358 return globals.to(this, args); 15359 } 15360 interpolate(...args) { 15361 deprecateInterpolate(); 15362 return globals.to(this, args); 15363 } 15364 toJSON() { 15365 return this.get(); 15366 } 15367 observerAdded(count) { 15368 if (count == 1) this._attach(); 15369 } 15370 observerRemoved(count) { 15371 if (count == 0) this._detach(); 15372 } 15373 _attach() { 15374 } 15375 _detach() { 15376 } 15377 _onChange(value, idle = false) { 15378 callFluidObservers(this, { 15379 type: "change", 15380 parent: this, 15381 value, 15382 idle 15383 }); 15384 } 15385 _onPriorityChange(priority2) { 15386 if (!this.idle) { 15387 frameLoop.sort(this); 15388 } 15389 callFluidObservers(this, { 15390 type: "priority", 15391 parent: this, 15392 priority: priority2 15393 }); 15394 } 15395 }; 15396 var $P = /* @__PURE__ */ Symbol.for("SpringPhase"); 15397 var HAS_ANIMATED = 1; 15398 var IS_ANIMATING = 2; 15399 var IS_PAUSED = 4; 15400 var hasAnimated = (target) => (target[$P] & HAS_ANIMATED) > 0; 15401 var isAnimating = (target) => (target[$P] & IS_ANIMATING) > 0; 15402 var isPaused = (target) => (target[$P] & IS_PAUSED) > 0; 15403 var setActiveBit = (target, active) => active ? target[$P] |= IS_ANIMATING | HAS_ANIMATED : target[$P] &= ~IS_ANIMATING; 15404 var setPausedBit = (target, paused) => paused ? target[$P] |= IS_PAUSED : target[$P] &= ~IS_PAUSED; 15405 var SpringValue = class extends FrameValue { 15406 constructor(arg1, arg2) { 15407 super(); 15408 this.key = void 0; 15409 this.animation = new Animation(); 15410 this.queue = void 0; 15411 this.defaultProps = {}; 15412 this._state = { 15413 paused: false, 15414 delayed: false, 15415 pauseQueue: /* @__PURE__ */ new Set(), 15416 resumeQueue: /* @__PURE__ */ new Set(), 15417 timeouts: /* @__PURE__ */ new Set() 15418 }; 15419 this._pendingCalls = /* @__PURE__ */ new Set(); 15420 this._lastCallId = 0; 15421 this._lastToId = 0; 15422 this._memoizedDuration = 0; 15423 if (!is.und(arg1) || !is.und(arg2)) { 15424 const props = is.obj(arg1) ? _extends3({}, arg1) : _extends3({}, arg2, { 15425 from: arg1 15426 }); 15427 if (is.und(props.default)) { 15428 props.default = true; 15429 } 15430 this.start(props); 15431 } 15432 } 15433 get idle() { 15434 return !(isAnimating(this) || this._state.asyncTo) || isPaused(this); 15435 } 15436 get goal() { 15437 return getFluidValue(this.animation.to); 15438 } 15439 get velocity() { 15440 const node = getAnimated(this); 15441 return node instanceof AnimatedValue ? node.lastVelocity || 0 : node.getPayload().map((node2) => node2.lastVelocity || 0); 15442 } 15443 get hasAnimated() { 15444 return hasAnimated(this); 15445 } 15446 get isAnimating() { 15447 return isAnimating(this); 15448 } 15449 get isPaused() { 15450 return isPaused(this); 15451 } 15452 get isDelayed() { 15453 return this._state.delayed; 15454 } 15455 advance(dt) { 15456 let idle = true; 15457 let changed = false; 15458 const anim = this.animation; 15459 let { 15460 config: config2, 15461 toValues 15462 } = anim; 15463 const payload = getPayload(anim.to); 15464 if (!payload && hasFluidValue(anim.to)) { 15465 toValues = toArray(getFluidValue(anim.to)); 15466 } 15467 anim.values.forEach((node2, i2) => { 15468 if (node2.done) return; 15469 const to2 = node2.constructor == AnimatedString ? 1 : payload ? payload[i2].lastPosition : toValues[i2]; 15470 let finished = anim.immediate; 15471 let position = to2; 15472 if (!finished) { 15473 position = node2.lastPosition; 15474 if (config2.tension <= 0) { 15475 node2.done = true; 15476 return; 15477 } 15478 let elapsed = node2.elapsedTime += dt; 15479 const from = anim.fromValues[i2]; 15480 const v0 = node2.v0 != null ? node2.v0 : node2.v0 = is.arr(config2.velocity) ? config2.velocity[i2] : config2.velocity; 15481 let velocity; 15482 const precision = config2.precision || (from == to2 ? 5e-3 : Math.min(1, Math.abs(to2 - from) * 1e-3)); 15483 if (!is.und(config2.duration)) { 15484 let p3 = 1; 15485 if (config2.duration > 0) { 15486 if (this._memoizedDuration !== config2.duration) { 15487 this._memoizedDuration = config2.duration; 15488 if (node2.durationProgress > 0) { 15489 node2.elapsedTime = config2.duration * node2.durationProgress; 15490 elapsed = node2.elapsedTime += dt; 15491 } 15492 } 15493 p3 = (config2.progress || 0) + elapsed / this._memoizedDuration; 15494 p3 = p3 > 1 ? 1 : p3 < 0 ? 0 : p3; 15495 node2.durationProgress = p3; 15496 } 15497 position = from + config2.easing(p3) * (to2 - from); 15498 velocity = (position - node2.lastPosition) / dt; 15499 finished = p3 == 1; 15500 } else if (config2.decay) { 15501 const decay = config2.decay === true ? 0.998 : config2.decay; 15502 const e2 = Math.exp(-(1 - decay) * elapsed); 15503 position = from + v0 / (1 - decay) * (1 - e2); 15504 finished = Math.abs(node2.lastPosition - position) <= precision; 15505 velocity = v0 * e2; 15506 } else { 15507 velocity = node2.lastVelocity == null ? v0 : node2.lastVelocity; 15508 const restVelocity = config2.restVelocity || precision / 10; 15509 const bounceFactor = config2.clamp ? 0 : config2.bounce; 15510 const canBounce = !is.und(bounceFactor); 15511 const isGrowing = from == to2 ? node2.v0 > 0 : from < to2; 15512 let isMoving; 15513 let isBouncing = false; 15514 const step = 1; 15515 const numSteps = Math.ceil(dt / step); 15516 for (let n2 = 0; n2 < numSteps; ++n2) { 15517 isMoving = Math.abs(velocity) > restVelocity; 15518 if (!isMoving) { 15519 finished = Math.abs(to2 - position) <= precision; 15520 if (finished) { 15521 break; 15522 } 15523 } 15524 if (canBounce) { 15525 isBouncing = position == to2 || position > to2 == isGrowing; 15526 if (isBouncing) { 15527 velocity = -velocity * bounceFactor; 15528 position = to2; 15529 } 15530 } 15531 const springForce = -config2.tension * 1e-6 * (position - to2); 15532 const dampingForce = -config2.friction * 1e-3 * velocity; 15533 const acceleration = (springForce + dampingForce) / config2.mass; 15534 velocity = velocity + acceleration * step; 15535 position = position + velocity * step; 15536 } 15537 } 15538 node2.lastVelocity = velocity; 15539 if (Number.isNaN(position)) { 15540 console.warn(`Got NaN while animating:`, this); 15541 finished = true; 15542 } 15543 } 15544 if (payload && !payload[i2].done) { 15545 finished = false; 15546 } 15547 if (finished) { 15548 node2.done = true; 15549 } else { 15550 idle = false; 15551 } 15552 if (node2.setValue(position, config2.round)) { 15553 changed = true; 15554 } 15555 }); 15556 const node = getAnimated(this); 15557 const currVal = node.getValue(); 15558 if (idle) { 15559 const finalVal = getFluidValue(anim.to); 15560 if ((currVal !== finalVal || changed) && !config2.decay) { 15561 node.setValue(finalVal); 15562 this._onChange(finalVal); 15563 } else if (changed && config2.decay) { 15564 this._onChange(currVal); 15565 } 15566 this._stop(); 15567 } else if (changed) { 15568 this._onChange(currVal); 15569 } 15570 } 15571 set(value) { 15572 raf.batchedUpdates(() => { 15573 this._stop(); 15574 this._focus(value); 15575 this._set(value); 15576 }); 15577 return this; 15578 } 15579 pause() { 15580 this._update({ 15581 pause: true 15582 }); 15583 } 15584 resume() { 15585 this._update({ 15586 pause: false 15587 }); 15588 } 15589 finish() { 15590 if (isAnimating(this)) { 15591 const { 15592 to: to2, 15593 config: config2 15594 } = this.animation; 15595 raf.batchedUpdates(() => { 15596 this._onStart(); 15597 if (!config2.decay) { 15598 this._set(to2, false); 15599 } 15600 this._stop(); 15601 }); 15602 } 15603 return this; 15604 } 15605 update(props) { 15606 const queue = this.queue || (this.queue = []); 15607 queue.push(props); 15608 return this; 15609 } 15610 start(to2, arg2) { 15611 let queue; 15612 if (!is.und(to2)) { 15613 queue = [is.obj(to2) ? to2 : _extends3({}, arg2, { 15614 to: to2 15615 })]; 15616 } else { 15617 queue = this.queue || []; 15618 this.queue = []; 15619 } 15620 return Promise.all(queue.map((props) => { 15621 const up = this._update(props); 15622 return up; 15623 })).then((results) => getCombinedResult(this, results)); 15624 } 15625 stop(cancel) { 15626 const { 15627 to: to2 15628 } = this.animation; 15629 this._focus(this.get()); 15630 stopAsync(this._state, cancel && this._lastCallId); 15631 raf.batchedUpdates(() => this._stop(to2, cancel)); 15632 return this; 15633 } 15634 reset() { 15635 this._update({ 15636 reset: true 15637 }); 15638 } 15639 eventObserved(event) { 15640 if (event.type == "change") { 15641 this._start(); 15642 } else if (event.type == "priority") { 15643 this.priority = event.priority + 1; 15644 } 15645 } 15646 _prepareNode(props) { 15647 const key = this.key || ""; 15648 let { 15649 to: to2, 15650 from 15651 } = props; 15652 to2 = is.obj(to2) ? to2[key] : to2; 15653 if (to2 == null || isAsyncTo(to2)) { 15654 to2 = void 0; 15655 } 15656 from = is.obj(from) ? from[key] : from; 15657 if (from == null) { 15658 from = void 0; 15659 } 15660 const range = { 15661 to: to2, 15662 from 15663 }; 15664 if (!hasAnimated(this)) { 15665 if (props.reverse) [to2, from] = [from, to2]; 15666 from = getFluidValue(from); 15667 if (!is.und(from)) { 15668 this._set(from); 15669 } else if (!getAnimated(this)) { 15670 this._set(to2); 15671 } 15672 } 15673 return range; 15674 } 15675 _update(_ref, isLoop) { 15676 let props = _extends3({}, _ref); 15677 const { 15678 key, 15679 defaultProps 15680 } = this; 15681 if (props.default) Object.assign(defaultProps, getDefaultProps(props, (value, prop) => /^on/.test(prop) ? resolveProp(value, key) : value)); 15682 mergeActiveFn(this, props, "onProps"); 15683 sendEvent(this, "onProps", props, this); 15684 const range = this._prepareNode(props); 15685 if (Object.isFrozen(this)) { 15686 throw Error("Cannot animate a `SpringValue` object that is frozen. Did you forget to pass your component to `animated(...)` before animating its props?"); 15687 } 15688 const state = this._state; 15689 return scheduleProps(++this._lastCallId, { 15690 key, 15691 props, 15692 defaultProps, 15693 state, 15694 actions: { 15695 pause: () => { 15696 if (!isPaused(this)) { 15697 setPausedBit(this, true); 15698 flushCalls(state.pauseQueue); 15699 sendEvent(this, "onPause", getFinishedResult(this, checkFinished(this, this.animation.to)), this); 15700 } 15701 }, 15702 resume: () => { 15703 if (isPaused(this)) { 15704 setPausedBit(this, false); 15705 if (isAnimating(this)) { 15706 this._resume(); 15707 } 15708 flushCalls(state.resumeQueue); 15709 sendEvent(this, "onResume", getFinishedResult(this, checkFinished(this, this.animation.to)), this); 15710 } 15711 }, 15712 start: this._merge.bind(this, range) 15713 } 15714 }).then((result) => { 15715 if (props.loop && result.finished && !(isLoop && result.noop)) { 15716 const nextProps = createLoopUpdate(props); 15717 if (nextProps) { 15718 return this._update(nextProps, true); 15719 } 15720 } 15721 return result; 15722 }); 15723 } 15724 _merge(range, props, resolve) { 15725 if (props.cancel) { 15726 this.stop(true); 15727 return resolve(getCancelledResult(this)); 15728 } 15729 const hasToProp = !is.und(range.to); 15730 const hasFromProp = !is.und(range.from); 15731 if (hasToProp || hasFromProp) { 15732 if (props.callId > this._lastToId) { 15733 this._lastToId = props.callId; 15734 } else { 15735 return resolve(getCancelledResult(this)); 15736 } 15737 } 15738 const { 15739 key, 15740 defaultProps, 15741 animation: anim 15742 } = this; 15743 const { 15744 to: prevTo, 15745 from: prevFrom 15746 } = anim; 15747 let { 15748 to: to2 = prevTo, 15749 from = prevFrom 15750 } = range; 15751 if (hasFromProp && !hasToProp && (!props.default || is.und(to2))) { 15752 to2 = from; 15753 } 15754 if (props.reverse) [to2, from] = [from, to2]; 15755 const hasFromChanged = !isEqual(from, prevFrom); 15756 if (hasFromChanged) { 15757 anim.from = from; 15758 } 15759 from = getFluidValue(from); 15760 const hasToChanged = !isEqual(to2, prevTo); 15761 if (hasToChanged) { 15762 this._focus(to2); 15763 } 15764 const hasAsyncTo = isAsyncTo(props.to); 15765 const { 15766 config: config2 15767 } = anim; 15768 const { 15769 decay, 15770 velocity 15771 } = config2; 15772 if (hasToProp || hasFromProp) { 15773 config2.velocity = 0; 15774 } 15775 if (props.config && !hasAsyncTo) { 15776 mergeConfig(config2, callProp(props.config, key), props.config !== defaultProps.config ? callProp(defaultProps.config, key) : void 0); 15777 } 15778 let node = getAnimated(this); 15779 if (!node || is.und(to2)) { 15780 return resolve(getFinishedResult(this, true)); 15781 } 15782 const reset = is.und(props.reset) ? hasFromProp && !props.default : !is.und(from) && matchProp(props.reset, key); 15783 const value = reset ? from : this.get(); 15784 const goal = computeGoal(to2); 15785 const isAnimatable = is.num(goal) || is.arr(goal) || isAnimatedString(goal); 15786 const immediate = !hasAsyncTo && (!isAnimatable || matchProp(defaultProps.immediate || props.immediate, key)); 15787 if (hasToChanged) { 15788 const nodeType = getAnimatedType(to2); 15789 if (nodeType !== node.constructor) { 15790 if (immediate) { 15791 node = this._set(goal); 15792 } else throw Error(`Cannot animate between $node.constructor.name} and $nodeType.name}, as the "to" prop suggests`); 15793 } 15794 } 15795 const goalType = node.constructor; 15796 let started = hasFluidValue(to2); 15797 let finished = false; 15798 if (!started) { 15799 const hasValueChanged = reset || !hasAnimated(this) && hasFromChanged; 15800 if (hasToChanged || hasValueChanged) { 15801 finished = isEqual(computeGoal(value), goal); 15802 started = !finished; 15803 } 15804 if (!isEqual(anim.immediate, immediate) && !immediate || !isEqual(config2.decay, decay) || !isEqual(config2.velocity, velocity)) { 15805 started = true; 15806 } 15807 } 15808 if (finished && isAnimating(this)) { 15809 if (anim.changed && !reset) { 15810 started = true; 15811 } else if (!started) { 15812 this._stop(prevTo); 15813 } 15814 } 15815 if (!hasAsyncTo) { 15816 if (started || hasFluidValue(prevTo)) { 15817 anim.values = node.getPayload(); 15818 anim.toValues = hasFluidValue(to2) ? null : goalType == AnimatedString ? [1] : toArray(goal); 15819 } 15820 if (anim.immediate != immediate) { 15821 anim.immediate = immediate; 15822 if (!immediate && !reset) { 15823 this._set(prevTo); 15824 } 15825 } 15826 if (started) { 15827 const { 15828 onRest 15829 } = anim; 15830 each(ACTIVE_EVENTS, (type) => mergeActiveFn(this, props, type)); 15831 const result = getFinishedResult(this, checkFinished(this, prevTo)); 15832 flushCalls(this._pendingCalls, result); 15833 this._pendingCalls.add(resolve); 15834 if (anim.changed) raf.batchedUpdates(() => { 15835 anim.changed = !reset; 15836 onRest == null ? void 0 : onRest(result, this); 15837 if (reset) { 15838 callProp(defaultProps.onRest, result); 15839 } else { 15840 anim.onStart == null ? void 0 : anim.onStart(result, this); 15841 } 15842 }); 15843 } 15844 } 15845 if (reset) { 15846 this._set(value); 15847 } 15848 if (hasAsyncTo) { 15849 resolve(runAsync(props.to, props, this._state, this)); 15850 } else if (started) { 15851 this._start(); 15852 } else if (isAnimating(this) && !hasToChanged) { 15853 this._pendingCalls.add(resolve); 15854 } else { 15855 resolve(getNoopResult(value)); 15856 } 15857 } 15858 _focus(value) { 15859 const anim = this.animation; 15860 if (value !== anim.to) { 15861 if (getFluidObservers(this)) { 15862 this._detach(); 15863 } 15864 anim.to = value; 15865 if (getFluidObservers(this)) { 15866 this._attach(); 15867 } 15868 } 15869 } 15870 _attach() { 15871 let priority2 = 0; 15872 const { 15873 to: to2 15874 } = this.animation; 15875 if (hasFluidValue(to2)) { 15876 addFluidObserver(to2, this); 15877 if (isFrameValue(to2)) { 15878 priority2 = to2.priority + 1; 15879 } 15880 } 15881 this.priority = priority2; 15882 } 15883 _detach() { 15884 const { 15885 to: to2 15886 } = this.animation; 15887 if (hasFluidValue(to2)) { 15888 removeFluidObserver(to2, this); 15889 } 15890 } 15891 _set(arg, idle = true) { 15892 const value = getFluidValue(arg); 15893 if (!is.und(value)) { 15894 const oldNode = getAnimated(this); 15895 if (!oldNode || !isEqual(value, oldNode.getValue())) { 15896 const nodeType = getAnimatedType(value); 15897 if (!oldNode || oldNode.constructor != nodeType) { 15898 setAnimated(this, nodeType.create(value)); 15899 } else { 15900 oldNode.setValue(value); 15901 } 15902 if (oldNode) { 15903 raf.batchedUpdates(() => { 15904 this._onChange(value, idle); 15905 }); 15906 } 15907 } 15908 } 15909 return getAnimated(this); 15910 } 15911 _onStart() { 15912 const anim = this.animation; 15913 if (!anim.changed) { 15914 anim.changed = true; 15915 sendEvent(this, "onStart", getFinishedResult(this, checkFinished(this, anim.to)), this); 15916 } 15917 } 15918 _onChange(value, idle) { 15919 if (!idle) { 15920 this._onStart(); 15921 callProp(this.animation.onChange, value, this); 15922 } 15923 callProp(this.defaultProps.onChange, value, this); 15924 super._onChange(value, idle); 15925 } 15926 _start() { 15927 const anim = this.animation; 15928 getAnimated(this).reset(getFluidValue(anim.to)); 15929 if (!anim.immediate) { 15930 anim.fromValues = anim.values.map((node) => node.lastPosition); 15931 } 15932 if (!isAnimating(this)) { 15933 setActiveBit(this, true); 15934 if (!isPaused(this)) { 15935 this._resume(); 15936 } 15937 } 15938 } 15939 _resume() { 15940 if (globals.skipAnimation) { 15941 this.finish(); 15942 } else { 15943 frameLoop.start(this); 15944 } 15945 } 15946 _stop(goal, cancel) { 15947 if (isAnimating(this)) { 15948 setActiveBit(this, false); 15949 const anim = this.animation; 15950 each(anim.values, (node) => { 15951 node.done = true; 15952 }); 15953 if (anim.toValues) { 15954 anim.onChange = anim.onPause = anim.onResume = void 0; 15955 } 15956 callFluidObservers(this, { 15957 type: "idle", 15958 parent: this 15959 }); 15960 const result = cancel ? getCancelledResult(this.get()) : getFinishedResult(this.get(), checkFinished(this, goal != null ? goal : anim.to)); 15961 flushCalls(this._pendingCalls, result); 15962 if (anim.changed) { 15963 anim.changed = false; 15964 sendEvent(this, "onRest", result, this); 15965 } 15966 } 15967 } 15968 }; 15969 function checkFinished(target, to2) { 15970 const goal = computeGoal(to2); 15971 const value = computeGoal(target.get()); 15972 return isEqual(value, goal); 15973 } 15974 function createLoopUpdate(props, loop2 = props.loop, to2 = props.to) { 15975 let loopRet = callProp(loop2); 15976 if (loopRet) { 15977 const overrides = loopRet !== true && inferTo(loopRet); 15978 const reverse = (overrides || props).reverse; 15979 const reset = !overrides || overrides.reset; 15980 return createUpdate(_extends3({}, props, { 15981 loop: loop2, 15982 default: false, 15983 pause: void 0, 15984 to: !reverse || isAsyncTo(to2) ? to2 : void 0, 15985 from: reset ? props.from : void 0, 15986 reset 15987 }, overrides)); 15988 } 15989 } 15990 function createUpdate(props) { 15991 const { 15992 to: to2, 15993 from 15994 } = props = inferTo(props); 15995 const keys = /* @__PURE__ */ new Set(); 15996 if (is.obj(to2)) findDefined(to2, keys); 15997 if (is.obj(from)) findDefined(from, keys); 15998 props.keys = keys.size ? Array.from(keys) : null; 15999 return props; 16000 } 16001 function findDefined(values, keys) { 16002 eachProp(values, (value, key) => value != null && keys.add(key)); 16003 } 16004 var ACTIVE_EVENTS = ["onStart", "onRest", "onChange", "onPause", "onResume"]; 16005 function mergeActiveFn(target, props, type) { 16006 target.animation[type] = props[type] !== getDefaultProp(props, type) ? resolveProp(props[type], target.key) : void 0; 16007 } 16008 function sendEvent(target, type, ...args) { 16009 var _target$animation$typ, _target$animation, _target$defaultProps$, _target$defaultProps; 16010 (_target$animation$typ = (_target$animation = target.animation)[type]) == null ? void 0 : _target$animation$typ.call(_target$animation, ...args); 16011 (_target$defaultProps$ = (_target$defaultProps = target.defaultProps)[type]) == null ? void 0 : _target$defaultProps$.call(_target$defaultProps, ...args); 16012 } 16013 var BATCHED_EVENTS = ["onStart", "onChange", "onRest"]; 16014 var nextId = 1; 16015 var Controller = class { 16016 constructor(props, flush2) { 16017 this.id = nextId++; 16018 this.springs = {}; 16019 this.queue = []; 16020 this.ref = void 0; 16021 this._flush = void 0; 16022 this._initialProps = void 0; 16023 this._lastAsyncId = 0; 16024 this._active = /* @__PURE__ */ new Set(); 16025 this._changed = /* @__PURE__ */ new Set(); 16026 this._started = false; 16027 this._item = void 0; 16028 this._state = { 16029 paused: false, 16030 pauseQueue: /* @__PURE__ */ new Set(), 16031 resumeQueue: /* @__PURE__ */ new Set(), 16032 timeouts: /* @__PURE__ */ new Set() 16033 }; 16034 this._events = { 16035 onStart: /* @__PURE__ */ new Map(), 16036 onChange: /* @__PURE__ */ new Map(), 16037 onRest: /* @__PURE__ */ new Map() 16038 }; 16039 this._onFrame = this._onFrame.bind(this); 16040 if (flush2) { 16041 this._flush = flush2; 16042 } 16043 if (props) { 16044 this.start(_extends3({ 16045 default: true 16046 }, props)); 16047 } 16048 } 16049 get idle() { 16050 return !this._state.asyncTo && Object.values(this.springs).every((spring) => { 16051 return spring.idle && !spring.isDelayed && !spring.isPaused; 16052 }); 16053 } 16054 get item() { 16055 return this._item; 16056 } 16057 set item(item) { 16058 this._item = item; 16059 } 16060 get() { 16061 const values = {}; 16062 this.each((spring, key) => values[key] = spring.get()); 16063 return values; 16064 } 16065 set(values) { 16066 for (const key in values) { 16067 const value = values[key]; 16068 if (!is.und(value)) { 16069 this.springs[key].set(value); 16070 } 16071 } 16072 } 16073 update(props) { 16074 if (props) { 16075 this.queue.push(createUpdate(props)); 16076 } 16077 return this; 16078 } 16079 start(props) { 16080 let { 16081 queue 16082 } = this; 16083 if (props) { 16084 queue = toArray(props).map(createUpdate); 16085 } else { 16086 this.queue = []; 16087 } 16088 if (this._flush) { 16089 return this._flush(this, queue); 16090 } 16091 prepareKeys(this, queue); 16092 return flushUpdateQueue(this, queue); 16093 } 16094 stop(arg, keys) { 16095 if (arg !== !!arg) { 16096 keys = arg; 16097 } 16098 if (keys) { 16099 const springs = this.springs; 16100 each(toArray(keys), (key) => springs[key].stop(!!arg)); 16101 } else { 16102 stopAsync(this._state, this._lastAsyncId); 16103 this.each((spring) => spring.stop(!!arg)); 16104 } 16105 return this; 16106 } 16107 pause(keys) { 16108 if (is.und(keys)) { 16109 this.start({ 16110 pause: true 16111 }); 16112 } else { 16113 const springs = this.springs; 16114 each(toArray(keys), (key) => springs[key].pause()); 16115 } 16116 return this; 16117 } 16118 resume(keys) { 16119 if (is.und(keys)) { 16120 this.start({ 16121 pause: false 16122 }); 16123 } else { 16124 const springs = this.springs; 16125 each(toArray(keys), (key) => springs[key].resume()); 16126 } 16127 return this; 16128 } 16129 each(iterator) { 16130 eachProp(this.springs, iterator); 16131 } 16132 _onFrame() { 16133 const { 16134 onStart, 16135 onChange, 16136 onRest 16137 } = this._events; 16138 const active = this._active.size > 0; 16139 const changed = this._changed.size > 0; 16140 if (active && !this._started || changed && !this._started) { 16141 this._started = true; 16142 flush(onStart, ([onStart2, result]) => { 16143 result.value = this.get(); 16144 onStart2(result, this, this._item); 16145 }); 16146 } 16147 const idle = !active && this._started; 16148 const values = changed || idle && onRest.size ? this.get() : null; 16149 if (changed && onChange.size) { 16150 flush(onChange, ([onChange2, result]) => { 16151 result.value = values; 16152 onChange2(result, this, this._item); 16153 }); 16154 } 16155 if (idle) { 16156 this._started = false; 16157 flush(onRest, ([onRest2, result]) => { 16158 result.value = values; 16159 onRest2(result, this, this._item); 16160 }); 16161 } 16162 } 16163 eventObserved(event) { 16164 if (event.type == "change") { 16165 this._changed.add(event.parent); 16166 if (!event.idle) { 16167 this._active.add(event.parent); 16168 } 16169 } else if (event.type == "idle") { 16170 this._active.delete(event.parent); 16171 } else return; 16172 raf.onFrame(this._onFrame); 16173 } 16174 }; 16175 function flushUpdateQueue(ctrl, queue) { 16176 return Promise.all(queue.map((props) => flushUpdate(ctrl, props))).then((results) => getCombinedResult(ctrl, results)); 16177 } 16178 async function flushUpdate(ctrl, props, isLoop) { 16179 const { 16180 keys, 16181 to: to2, 16182 from, 16183 loop: loop2, 16184 onRest, 16185 onResolve 16186 } = props; 16187 const defaults2 = is.obj(props.default) && props.default; 16188 if (loop2) { 16189 props.loop = false; 16190 } 16191 if (to2 === false) props.to = null; 16192 if (from === false) props.from = null; 16193 const asyncTo = is.arr(to2) || is.fun(to2) ? to2 : void 0; 16194 if (asyncTo) { 16195 props.to = void 0; 16196 props.onRest = void 0; 16197 if (defaults2) { 16198 defaults2.onRest = void 0; 16199 } 16200 } else { 16201 each(BATCHED_EVENTS, (key) => { 16202 const handler = props[key]; 16203 if (is.fun(handler)) { 16204 const queue = ctrl["_events"][key]; 16205 props[key] = ({ 16206 finished, 16207 cancelled 16208 }) => { 16209 const result2 = queue.get(handler); 16210 if (result2) { 16211 if (!finished) result2.finished = false; 16212 if (cancelled) result2.cancelled = true; 16213 } else { 16214 queue.set(handler, { 16215 value: null, 16216 finished: finished || false, 16217 cancelled: cancelled || false 16218 }); 16219 } 16220 }; 16221 if (defaults2) { 16222 defaults2[key] = props[key]; 16223 } 16224 } 16225 }); 16226 } 16227 const state = ctrl["_state"]; 16228 if (props.pause === !state.paused) { 16229 state.paused = props.pause; 16230 flushCalls(props.pause ? state.pauseQueue : state.resumeQueue); 16231 } else if (state.paused) { 16232 props.pause = true; 16233 } 16234 const promises = (keys || Object.keys(ctrl.springs)).map((key) => ctrl.springs[key].start(props)); 16235 const cancel = props.cancel === true || getDefaultProp(props, "cancel") === true; 16236 if (asyncTo || cancel && state.asyncId) { 16237 promises.push(scheduleProps(++ctrl["_lastAsyncId"], { 16238 props, 16239 state, 16240 actions: { 16241 pause: noop4, 16242 resume: noop4, 16243 start(props2, resolve) { 16244 if (cancel) { 16245 stopAsync(state, ctrl["_lastAsyncId"]); 16246 resolve(getCancelledResult(ctrl)); 16247 } else { 16248 props2.onRest = onRest; 16249 resolve(runAsync(asyncTo, props2, state, ctrl)); 16250 } 16251 } 16252 } 16253 })); 16254 } 16255 if (state.paused) { 16256 await new Promise((resume) => { 16257 state.resumeQueue.add(resume); 16258 }); 16259 } 16260 const result = getCombinedResult(ctrl, await Promise.all(promises)); 16261 if (loop2 && result.finished && !(isLoop && result.noop)) { 16262 const nextProps = createLoopUpdate(props, loop2, to2); 16263 if (nextProps) { 16264 prepareKeys(ctrl, [nextProps]); 16265 return flushUpdate(ctrl, nextProps, true); 16266 } 16267 } 16268 if (onResolve) { 16269 raf.batchedUpdates(() => onResolve(result, ctrl, ctrl.item)); 16270 } 16271 return result; 16272 } 16273 function createSpring(key, observer) { 16274 const spring = new SpringValue(); 16275 spring.key = key; 16276 if (observer) { 16277 addFluidObserver(spring, observer); 16278 } 16279 return spring; 16280 } 16281 function prepareSprings(springs, props, create) { 16282 if (props.keys) { 16283 each(props.keys, (key) => { 16284 const spring = springs[key] || (springs[key] = create(key)); 16285 spring["_prepareNode"](props); 16286 }); 16287 } 16288 } 16289 function prepareKeys(ctrl, queue) { 16290 each(queue, (props) => { 16291 prepareSprings(ctrl.springs, props, (key) => { 16292 return createSpring(key, ctrl); 16293 }); 16294 }); 16295 } 16296 function _objectWithoutPropertiesLoose(source, excluded) { 16297 if (source == null) return {}; 16298 var target = {}; 16299 var sourceKeys = Object.keys(source); 16300 var key, i2; 16301 for (i2 = 0; i2 < sourceKeys.length; i2++) { 16302 key = sourceKeys[i2]; 16303 if (excluded.indexOf(key) >= 0) continue; 16304 target[key] = source[key]; 16305 } 16306 return target; 16307 } 16308 var _excluded$3 = ["children"]; 16309 var SpringContext = (_ref) => { 16310 let { 16311 children 16312 } = _ref, props = _objectWithoutPropertiesLoose(_ref, _excluded$3); 16313 const inherited = (0, import_react14.useContext)(ctx); 16314 const pause = props.pause || !!inherited.pause, immediate = props.immediate || !!inherited.immediate; 16315 props = useMemoOne(() => ({ 16316 pause, 16317 immediate 16318 }), [pause, immediate]); 16319 const { 16320 Provider: Provider2 16321 } = ctx; 16322 return React58.createElement(Provider2, { 16323 value: props 16324 }, children); 16325 }; 16326 var ctx = makeContext(SpringContext, {}); 16327 SpringContext.Provider = ctx.Provider; 16328 SpringContext.Consumer = ctx.Consumer; 16329 function makeContext(target, init2) { 16330 Object.assign(target, React58.createContext(init2)); 16331 target.Provider._context = target; 16332 target.Consumer._context = target; 16333 return target; 16334 } 16335 var TransitionPhase; 16336 (function(TransitionPhase2) { 16337 TransitionPhase2["MOUNT"] = "mount"; 16338 TransitionPhase2["ENTER"] = "enter"; 16339 TransitionPhase2["UPDATE"] = "update"; 16340 TransitionPhase2["LEAVE"] = "leave"; 16341 })(TransitionPhase || (TransitionPhase = {})); 16342 var Interpolation = class extends FrameValue { 16343 constructor(source, args) { 16344 super(); 16345 this.key = void 0; 16346 this.idle = true; 16347 this.calc = void 0; 16348 this._active = /* @__PURE__ */ new Set(); 16349 this.source = source; 16350 this.calc = createInterpolator(...args); 16351 const value = this._get(); 16352 const nodeType = getAnimatedType(value); 16353 setAnimated(this, nodeType.create(value)); 16354 } 16355 advance(_dt) { 16356 const value = this._get(); 16357 const oldValue = this.get(); 16358 if (!isEqual(value, oldValue)) { 16359 getAnimated(this).setValue(value); 16360 this._onChange(value, this.idle); 16361 } 16362 if (!this.idle && checkIdle(this._active)) { 16363 becomeIdle(this); 16364 } 16365 } 16366 _get() { 16367 const inputs = is.arr(this.source) ? this.source.map(getFluidValue) : toArray(getFluidValue(this.source)); 16368 return this.calc(...inputs); 16369 } 16370 _start() { 16371 if (this.idle && !checkIdle(this._active)) { 16372 this.idle = false; 16373 each(getPayload(this), (node) => { 16374 node.done = false; 16375 }); 16376 if (globals.skipAnimation) { 16377 raf.batchedUpdates(() => this.advance()); 16378 becomeIdle(this); 16379 } else { 16380 frameLoop.start(this); 16381 } 16382 } 16383 } 16384 _attach() { 16385 let priority2 = 1; 16386 each(toArray(this.source), (source) => { 16387 if (hasFluidValue(source)) { 16388 addFluidObserver(source, this); 16389 } 16390 if (isFrameValue(source)) { 16391 if (!source.idle) { 16392 this._active.add(source); 16393 } 16394 priority2 = Math.max(priority2, source.priority + 1); 16395 } 16396 }); 16397 this.priority = priority2; 16398 this._start(); 16399 } 16400 _detach() { 16401 each(toArray(this.source), (source) => { 16402 if (hasFluidValue(source)) { 16403 removeFluidObserver(source, this); 16404 } 16405 }); 16406 this._active.clear(); 16407 becomeIdle(this); 16408 } 16409 eventObserved(event) { 16410 if (event.type == "change") { 16411 if (event.idle) { 16412 this.advance(); 16413 } else { 16414 this._active.add(event.parent); 16415 this._start(); 16416 } 16417 } else if (event.type == "idle") { 16418 this._active.delete(event.parent); 16419 } else if (event.type == "priority") { 16420 this.priority = toArray(this.source).reduce((highest, parent) => Math.max(highest, (isFrameValue(parent) ? parent.priority : 0) + 1), 0); 16421 } 16422 } 16423 }; 16424 function isIdle(source) { 16425 return source.idle !== false; 16426 } 16427 function checkIdle(active) { 16428 return !active.size || Array.from(active).every(isIdle); 16429 } 16430 function becomeIdle(self2) { 16431 if (!self2.idle) { 16432 self2.idle = true; 16433 each(getPayload(self2), (node) => { 16434 node.done = true; 16435 }); 16436 callFluidObservers(self2, { 16437 type: "idle", 16438 parent: self2 16439 }); 16440 } 16441 } 16442 globals.assign({ 16443 createStringInterpolator, 16444 to: (source, args) => new Interpolation(source, args) 16445 }); 16446 var update3 = frameLoop.advance; 16447 16448 // node_modules/@react-spring/web/dist/react-spring-web.esm.js 16449 var import_react_dom4 = __toESM(require_react_dom()); 16450 function _objectWithoutPropertiesLoose2(source, excluded) { 16451 if (source == null) return {}; 16452 var target = {}; 16453 var sourceKeys = Object.keys(source); 16454 var key, i2; 16455 for (i2 = 0; i2 < sourceKeys.length; i2++) { 16456 key = sourceKeys[i2]; 16457 if (excluded.indexOf(key) >= 0) continue; 16458 target[key] = source[key]; 16459 } 16460 return target; 16461 } 16462 var _excluded$2 = ["style", "children", "scrollTop", "scrollLeft"]; 16463 var isCustomPropRE = /^--/; 16464 function dangerousStyleValue(name2, value) { 16465 if (value == null || typeof value === "boolean" || value === "") return ""; 16466 if (typeof value === "number" && value !== 0 && !isCustomPropRE.test(name2) && !(isUnitlessNumber.hasOwnProperty(name2) && isUnitlessNumber[name2])) return value + "px"; 16467 return ("" + value).trim(); 16468 } 16469 var attributeCache = {}; 16470 function applyAnimatedValues(instance, props) { 16471 if (!instance.nodeType || !instance.setAttribute) { 16472 return false; 16473 } 16474 const isFilterElement = instance.nodeName === "filter" || instance.parentNode && instance.parentNode.nodeName === "filter"; 16475 const _ref = props, { 16476 style, 16477 children, 16478 scrollTop, 16479 scrollLeft 16480 } = _ref, attributes = _objectWithoutPropertiesLoose2(_ref, _excluded$2); 16481 const values = Object.values(attributes); 16482 const names = Object.keys(attributes).map((name2) => isFilterElement || instance.hasAttribute(name2) ? name2 : attributeCache[name2] || (attributeCache[name2] = name2.replace(/([A-Z])/g, (n2) => "-" + n2.toLowerCase()))); 16483 if (children !== void 0) { 16484 instance.textContent = children; 16485 } 16486 for (let name2 in style) { 16487 if (style.hasOwnProperty(name2)) { 16488 const value = dangerousStyleValue(name2, style[name2]); 16489 if (isCustomPropRE.test(name2)) { 16490 instance.style.setProperty(name2, value); 16491 } else { 16492 instance.style[name2] = value; 16493 } 16494 } 16495 } 16496 names.forEach((name2, i2) => { 16497 instance.setAttribute(name2, values[i2]); 16498 }); 16499 if (scrollTop !== void 0) { 16500 instance.scrollTop = scrollTop; 16501 } 16502 if (scrollLeft !== void 0) { 16503 instance.scrollLeft = scrollLeft; 16504 } 16505 } 16506 var isUnitlessNumber = { 16507 animationIterationCount: true, 16508 borderImageOutset: true, 16509 borderImageSlice: true, 16510 borderImageWidth: true, 16511 boxFlex: true, 16512 boxFlexGroup: true, 16513 boxOrdinalGroup: true, 16514 columnCount: true, 16515 columns: true, 16516 flex: true, 16517 flexGrow: true, 16518 flexPositive: true, 16519 flexShrink: true, 16520 flexNegative: true, 16521 flexOrder: true, 16522 gridRow: true, 16523 gridRowEnd: true, 16524 gridRowSpan: true, 16525 gridRowStart: true, 16526 gridColumn: true, 16527 gridColumnEnd: true, 16528 gridColumnSpan: true, 16529 gridColumnStart: true, 16530 fontWeight: true, 16531 lineClamp: true, 16532 lineHeight: true, 16533 opacity: true, 16534 order: true, 16535 orphans: true, 16536 tabSize: true, 16537 widows: true, 16538 zIndex: true, 16539 zoom: true, 16540 fillOpacity: true, 16541 floodOpacity: true, 16542 stopOpacity: true, 16543 strokeDasharray: true, 16544 strokeDashoffset: true, 16545 strokeMiterlimit: true, 16546 strokeOpacity: true, 16547 strokeWidth: true 16548 }; 16549 var prefixKey = (prefix2, key) => prefix2 + key.charAt(0).toUpperCase() + key.substring(1); 16550 var prefixes = ["Webkit", "Ms", "Moz", "O"]; 16551 isUnitlessNumber = Object.keys(isUnitlessNumber).reduce((acc, prop) => { 16552 prefixes.forEach((prefix2) => acc[prefixKey(prefix2, prop)] = acc[prop]); 16553 return acc; 16554 }, isUnitlessNumber); 16555 var _excluded$1 = ["x", "y", "z"]; 16556 var domTransforms = /^(matrix|translate|scale|rotate|skew)/; 16557 var pxTransforms = /^(translate)/; 16558 var degTransforms = /^(rotate|skew)/; 16559 var addUnit = (value, unit) => is.num(value) && value !== 0 ? value + unit : value; 16560 var isValueIdentity = (value, id) => is.arr(value) ? value.every((v2) => isValueIdentity(v2, id)) : is.num(value) ? value === id : parseFloat(value) === id; 16561 var AnimatedStyle = class extends AnimatedObject { 16562 constructor(_ref) { 16563 let { 16564 x: x2, 16565 y: y2, 16566 z 16567 } = _ref, style = _objectWithoutPropertiesLoose2(_ref, _excluded$1); 16568 const inputs = []; 16569 const transforms = []; 16570 if (x2 || y2 || z) { 16571 inputs.push([x2 || 0, y2 || 0, z || 0]); 16572 transforms.push((xyz) => [`translate3d($xyz.map((v2) => addUnit(v2, "px")).join(",")})`, isValueIdentity(xyz, 0)]); 16573 } 16574 eachProp(style, (value, key) => { 16575 if (key === "transform") { 16576 inputs.push([value || ""]); 16577 transforms.push((transform) => [transform, transform === ""]); 16578 } else if (domTransforms.test(key)) { 16579 delete style[key]; 16580 if (is.und(value)) return; 16581 const unit = pxTransforms.test(key) ? "px" : degTransforms.test(key) ? "deg" : ""; 16582 inputs.push(toArray(value)); 16583 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)]); 16584 } 16585 }); 16586 if (inputs.length) { 16587 style.transform = new FluidTransform(inputs, transforms); 16588 } 16589 super(style); 16590 } 16591 }; 16592 var FluidTransform = class extends FluidValue { 16593 constructor(inputs, transforms) { 16594 super(); 16595 this._value = null; 16596 this.inputs = inputs; 16597 this.transforms = transforms; 16598 } 16599 get() { 16600 return this._value || (this._value = this._get()); 16601 } 16602 _get() { 16603 let transform = ""; 16604 let identity2 = true; 16605 each(this.inputs, (input, i2) => { 16606 const arg1 = getFluidValue(input[0]); 16607 const [t3, id] = this.transforms[i2](is.arr(arg1) ? arg1 : input.map(getFluidValue)); 16608 transform += " " + t3; 16609 identity2 = identity2 && id; 16610 }); 16611 return identity2 ? "none" : transform; 16612 } 16613 observerAdded(count) { 16614 if (count == 1) each(this.inputs, (input) => each(input, (value) => hasFluidValue(value) && addFluidObserver(value, this))); 16615 } 16616 observerRemoved(count) { 16617 if (count == 0) each(this.inputs, (input) => each(input, (value) => hasFluidValue(value) && removeFluidObserver(value, this))); 16618 } 16619 eventObserved(event) { 16620 if (event.type == "change") { 16621 this._value = null; 16622 } 16623 callFluidObservers(this, event); 16624 } 16625 }; 16626 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"]; 16627 var _excluded = ["scrollTop", "scrollLeft"]; 16628 globals.assign({ 16629 batchedUpdates: import_react_dom4.unstable_batchedUpdates, 16630 createStringInterpolator, 16631 colors 16632 }); 16633 var host = createHost(primitives, { 16634 applyAnimatedValues, 16635 createAnimatedStyle: (style) => new AnimatedStyle(style), 16636 getComponentProps: (_ref) => { 16637 let props = _objectWithoutPropertiesLoose2(_ref, _excluded); 16638 return props; 16639 } 16640 }); 16641 var animated = host.animated; 16642 16643 // packages/edit-site/build-module/components/layout/animation.mjs 16644 var import_element41 = __toESM(require_element(), 1); 16645 function getAbsolutePosition(element) { 16646 return { 16647 top: element.offsetTop, 16648 left: element.offsetLeft 16649 }; 16650 } 16651 var ANIMATION_DURATION = 400; 16652 function useMovingAnimation({ triggerAnimationOnChange }) { 16653 const ref = (0, import_element41.useRef)(); 16654 const { previous, prevRect } = (0, import_element41.useMemo)( 16655 () => ({ 16656 previous: ref.current && getAbsolutePosition(ref.current), 16657 prevRect: ref.current && ref.current.getBoundingClientRect() 16658 }), 16659 [triggerAnimationOnChange] 16660 ); 16661 (0, import_element41.useLayoutEffect)(() => { 16662 if (!previous || !ref.current) { 16663 return; 16664 } 16665 const disableAnimation = window.matchMedia( 16666 "(prefers-reduced-motion: reduce)" 16667 ).matches; 16668 if (disableAnimation) { 16669 return; 16670 } 16671 const controller = new Controller({ 16672 x: 0, 16673 y: 0, 16674 width: prevRect.width, 16675 height: prevRect.height, 16676 config: { 16677 duration: ANIMATION_DURATION, 16678 easing: easings.easeInOutQuint 16679 }, 16680 onChange({ value }) { 16681 if (!ref.current) { 16682 return; 16683 } 16684 let { x: x22, y: y22, width: width2, height: height2 } = value; 16685 x22 = Math.round(x22); 16686 y22 = Math.round(y22); 16687 width2 = Math.round(width2); 16688 height2 = Math.round(height2); 16689 const finishedMoving = x22 === 0 && y22 === 0; 16690 ref.current.style.transformOrigin = "center center"; 16691 ref.current.style.transform = finishedMoving ? null : `translate3d($x22}px,$y22}px,0)`; 16692 ref.current.style.width = finishedMoving ? null : `$width2}px`; 16693 ref.current.style.height = finishedMoving ? null : `$height2}px`; 16694 } 16695 }); 16696 ref.current.style.transform = void 0; 16697 const destination = ref.current.getBoundingClientRect(); 16698 const x2 = Math.round(prevRect.left - destination.left); 16699 const y2 = Math.round(prevRect.top - destination.top); 16700 const width = destination.width; 16701 const height = destination.height; 16702 controller.start({ 16703 x: 0, 16704 y: 0, 16705 width, 16706 height, 16707 from: { x: x2, y: y2, width: prevRect.width, height: prevRect.height } 16708 }); 16709 return () => { 16710 controller.stop(); 16711 controller.set({ 16712 x: 0, 16713 y: 0, 16714 width: prevRect.width, 16715 height: prevRect.height 16716 }); 16717 }; 16718 }, [previous, prevRect]); 16719 return ref; 16720 } 16721 var animation_default = useMovingAnimation; 16722 16723 // packages/edit-site/build-module/components/save-hub/index.mjs 16724 var import_data9 = __toESM(require_data(), 1); 16725 var import_core_data8 = __toESM(require_core_data(), 1); 16726 16727 // packages/edit-site/build-module/components/save-button/index.mjs 16728 var import_data8 = __toESM(require_data(), 1); 16729 var import_components4 = __toESM(require_components(), 1); 16730 var import_i18n5 = __toESM(require_i18n(), 1); 16731 var import_core_data7 = __toESM(require_core_data(), 1); 16732 var import_keycodes = __toESM(require_keycodes(), 1); 16733 var import_router3 = __toESM(require_router(), 1); 16734 var import_editor4 = __toESM(require_editor(), 1); 16735 16736 // packages/edit-site/build-module/utils/is-previewing-theme.mjs 16737 var import_url2 = __toESM(require_url(), 1); 16738 function isPreviewingTheme() { 16739 return !!(0, import_url2.getQueryArg)(window.location.href, "wp_theme_preview"); 16740 } 16741 function currentlyPreviewingTheme() { 16742 if (isPreviewingTheme()) { 16743 return (0, import_url2.getQueryArg)(window.location.href, "wp_theme_preview"); 16744 } 16745 return null; 16746 } 16747 16748 // packages/edit-site/build-module/components/save-button/index.mjs 16749 var import_jsx_runtime101 = __toESM(require_jsx_runtime(), 1); 16750 var { useLocation: useLocation3 } = unlock(import_router3.privateApis); 16751 function SaveButton({ 16752 className = "edit-site-save-button__button", 16753 variant = "primary", 16754 showTooltip = true, 16755 showReviewMessage, 16756 icon, 16757 size: size4, 16758 __next40pxDefaultSize = false 16759 }) { 16760 const { params } = useLocation3(); 16761 const { setIsSaveViewOpened: setIsSaveViewOpened2 } = (0, import_data8.useDispatch)(store); 16762 const { saveDirtyEntities } = unlock((0, import_data8.useDispatch)(import_editor4.store)); 16763 const { dirtyEntityRecords } = (0, import_editor4.useEntitiesSavedStatesIsDirty)(); 16764 const { isSaving, isSaveViewOpen, previewingThemeName } = (0, import_data8.useSelect)( 16765 (select4) => { 16766 const { isSavingEntityRecord, isResolving } = select4(import_core_data7.store); 16767 const { isSaveViewOpened: isSaveViewOpened2 } = select4(store); 16768 const isActivatingTheme = isResolving("activateTheme"); 16769 const currentlyPreviewingThemeId = currentlyPreviewingTheme(); 16770 return { 16771 isSaving: dirtyEntityRecords.some( 16772 (record) => isSavingEntityRecord( 16773 record.kind, 16774 record.name, 16775 record.key 16776 ) 16777 ) || isActivatingTheme, 16778 isSaveViewOpen: isSaveViewOpened2(), 16779 // Do not call `getTheme` with null, it will cause a request to 16780 // the server. 16781 previewingThemeName: currentlyPreviewingThemeId ? select4(import_core_data7.store).getTheme(currentlyPreviewingThemeId)?.name?.rendered : void 0 16782 }; 16783 }, 16784 [dirtyEntityRecords] 16785 ); 16786 const hasDirtyEntities = !!dirtyEntityRecords.length; 16787 let isOnlyCurrentEntityDirty; 16788 if (dirtyEntityRecords.length === 1) { 16789 if (params.postId) { 16790 isOnlyCurrentEntityDirty = `$dirtyEntityRecords[0].key}` === params.postId && dirtyEntityRecords[0].name === params.postType; 16791 } else if (params.path?.includes("wp_global_styles")) { 16792 isOnlyCurrentEntityDirty = dirtyEntityRecords[0].name === "globalStyles"; 16793 } 16794 } 16795 const disabled2 = isSaving || !hasDirtyEntities && !isPreviewingTheme(); 16796 const getLabel = () => { 16797 if (isPreviewingTheme()) { 16798 if (isSaving) { 16799 return (0, import_i18n5.sprintf)( 16800 /* translators: %s: The name of theme to be activated. */ 16801 (0, import_i18n5.__)("Activating %s"), 16802 previewingThemeName 16803 ); 16804 } else if (disabled2) { 16805 return (0, import_i18n5.__)("Saved"); 16806 } else if (hasDirtyEntities) { 16807 return (0, import_i18n5.sprintf)( 16808 /* translators: %s: The name of theme to be activated. */ 16809 (0, import_i18n5.__)("Activate %s & Save"), 16810 previewingThemeName 16811 ); 16812 } 16813 return (0, import_i18n5.sprintf)( 16814 /* translators: %s: The name of theme to be activated. */ 16815 (0, import_i18n5.__)("Activate %s"), 16816 previewingThemeName 16817 ); 16818 } 16819 if (isSaving) { 16820 return (0, import_i18n5.__)("Saving"); 16821 } 16822 if (disabled2) { 16823 return (0, import_i18n5.__)("Saved"); 16824 } 16825 if (!isOnlyCurrentEntityDirty && showReviewMessage) { 16826 return (0, import_i18n5.sprintf)( 16827 // translators: %d: number of unsaved changes (number). 16828 (0, import_i18n5._n)( 16829 "Review %d change\u2026", 16830 "Review %d changes\u2026", 16831 dirtyEntityRecords.length 16832 ), 16833 dirtyEntityRecords.length 16834 ); 16835 } 16836 return (0, import_i18n5.__)("Save"); 16837 }; 16838 const label = getLabel(); 16839 const onClick = isOnlyCurrentEntityDirty ? () => saveDirtyEntities({ dirtyEntityRecords }) : () => setIsSaveViewOpened2(true); 16840 return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)( 16841 import_components4.Button, 16842 { 16843 variant, 16844 className, 16845 "aria-disabled": disabled2, 16846 "aria-expanded": isSaveViewOpen, 16847 isBusy: isSaving, 16848 onClick: disabled2 ? void 0 : onClick, 16849 label, 16850 shortcut: disabled2 ? void 0 : import_keycodes.displayShortcut.primary("s"), 16851 showTooltip, 16852 icon, 16853 __next40pxDefaultSize, 16854 size: size4, 16855 children: label 16856 } 16857 ); 16858 } 16859 16860 // packages/edit-site/build-module/components/save-hub/index.mjs 16861 var import_jsx_runtime102 = __toESM(require_jsx_runtime(), 1); 16862 function SaveHub() { 16863 const { isDisabled, isSaving } = (0, import_data9.useSelect)((select4) => { 16864 const { __experimentalGetDirtyEntityRecords, isSavingEntityRecord } = select4(import_core_data8.store); 16865 const dirtyEntityRecords = __experimentalGetDirtyEntityRecords(); 16866 const _isSaving = dirtyEntityRecords.some( 16867 (record) => isSavingEntityRecord(record.kind, record.name, record.key) 16868 ); 16869 return { 16870 isSaving: _isSaving, 16871 isDisabled: _isSaving || !dirtyEntityRecords.length && !isPreviewingTheme() 16872 }; 16873 }, []); 16874 return /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(Stack, { className: "edit-site-save-hub", gap: "lg", children: /* @__PURE__ */ (0, import_jsx_runtime102.jsx)( 16875 SaveButton, 16876 { 16877 className: "edit-site-save-hub__button", 16878 variant: isDisabled && !isSaving ? null : "primary", 16879 showTooltip: false, 16880 icon: isDisabled && !isSaving ? check_default : null, 16881 showReviewMessage: true, 16882 __next40pxDefaultSize: true 16883 } 16884 ) }); 16885 } 16886 16887 // packages/edit-site/build-module/components/save-panel/index.mjs 16888 var import_components5 = __toESM(require_components(), 1); 16889 var import_editor5 = __toESM(require_editor(), 1); 16890 var import_data11 = __toESM(require_data(), 1); 16891 var import_i18n6 = __toESM(require_i18n(), 1); 16892 var import_core_data10 = __toESM(require_core_data(), 1); 16893 var import_router5 = __toESM(require_router(), 1); 16894 var import_element43 = __toESM(require_element(), 1); 16895 16896 // packages/edit-site/build-module/utils/use-activate-theme.mjs 16897 var import_core_data9 = __toESM(require_core_data(), 1); 16898 var import_data10 = __toESM(require_data(), 1); 16899 var import_router4 = __toESM(require_router(), 1); 16900 var import_url3 = __toESM(require_url(), 1); 16901 var { useHistory: useHistory3, useLocation: useLocation4 } = unlock(import_router4.privateApis); 16902 function useActivateTheme() { 16903 const history = useHistory3(); 16904 const { path } = useLocation4(); 16905 const { startResolution, finishResolution } = (0, import_data10.useDispatch)(import_core_data9.store); 16906 return async () => { 16907 if (isPreviewingTheme()) { 16908 const activationURL = "themes.php?action=activate&stylesheet=" + currentlyPreviewingTheme() + "&_wpnonce=" + window.WP_BLOCK_THEME_ACTIVATE_NONCE; 16909 startResolution("activateTheme"); 16910 await window.fetch(activationURL); 16911 finishResolution("activateTheme"); 16912 history.navigate((0, import_url3.addQueryArgs)(path, { wp_theme_preview: "" })); 16913 } 16914 }; 16915 } 16916 16917 // packages/edit-site/build-module/utils/use-actual-current-theme.mjs 16918 var import_api_fetch = __toESM(require_api_fetch(), 1); 16919 var import_element42 = __toESM(require_element(), 1); 16920 var import_url4 = __toESM(require_url(), 1); 16921 var ACTIVE_THEMES_URL = "/wp/v2/themes?status=active"; 16922 function useActualCurrentTheme() { 16923 const [currentTheme, setCurrentTheme] = (0, import_element42.useState)(); 16924 (0, import_element42.useEffect)(() => { 16925 const path = (0, import_url4.addQueryArgs)(ACTIVE_THEMES_URL, { 16926 context: "edit", 16927 wp_theme_preview: "" 16928 }); 16929 (0, import_api_fetch.default)({ path }).then((activeThemes) => setCurrentTheme(activeThemes[0])).catch(() => { 16930 }); 16931 }, []); 16932 return currentTheme; 16933 } 16934 16935 // packages/edit-site/build-module/components/save-panel/index.mjs 16936 var import_jsx_runtime103 = __toESM(require_jsx_runtime(), 1); 16937 var { EntitiesSavedStatesExtensible } = unlock(import_editor5.privateApis); 16938 var { useLocation: useLocation5 } = unlock(import_router5.privateApis); 16939 var EntitiesSavedStatesForPreview = ({ 16940 onClose, 16941 renderDialog, 16942 variant 16943 }) => { 16944 const isDirtyProps = (0, import_editor5.useEntitiesSavedStatesIsDirty)(); 16945 let activateSaveLabel, successNoticeContent; 16946 if (isDirtyProps.isDirty) { 16947 activateSaveLabel = (0, import_i18n6.__)("Activate & Save"); 16948 successNoticeContent = (0, import_i18n6.__)("Theme activated and site updated."); 16949 } else { 16950 activateSaveLabel = (0, import_i18n6.__)("Activate"); 16951 successNoticeContent = (0, import_i18n6.__)("Theme activated."); 16952 } 16953 const currentTheme = useActualCurrentTheme(); 16954 const previewingTheme = (0, import_data11.useSelect)( 16955 (select4) => select4(import_core_data10.store).getCurrentTheme(), 16956 [] 16957 ); 16958 const additionalPrompt = /* @__PURE__ */ (0, import_jsx_runtime103.jsx)("p", { children: (0, import_i18n6.sprintf)( 16959 /* translators: 1: The name of active theme, 2: The name of theme to be activated. */ 16960 (0, import_i18n6.__)( 16961 "Saving your changes will change your active theme from %1$s to %2$s." 16962 ), 16963 currentTheme?.name?.rendered ?? "...", 16964 previewingTheme?.name?.rendered ?? "..." 16965 ) }); 16966 const activateTheme = useActivateTheme(); 16967 const onSave = async () => { 16968 await activateTheme(); 16969 }; 16970 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)( 16971 EntitiesSavedStatesExtensible, 16972 { 16973 ...{ 16974 ...isDirtyProps, 16975 additionalPrompt, 16976 close: onClose, 16977 onSave, 16978 saveEnabled: true, 16979 saveLabel: activateSaveLabel, 16980 renderDialog, 16981 variant, 16982 successNoticeContent 16983 } 16984 } 16985 ); 16986 }; 16987 var _EntitiesSavedStates = ({ onClose, renderDialog, variant }) => { 16988 if (isPreviewingTheme()) { 16989 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)( 16990 EntitiesSavedStatesForPreview, 16991 { 16992 onClose, 16993 renderDialog, 16994 variant 16995 } 16996 ); 16997 } 16998 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)( 16999 import_editor5.EntitiesSavedStates, 17000 { 17001 close: onClose, 17002 renderDialog, 17003 variant 17004 } 17005 ); 17006 }; 17007 function SavePanel() { 17008 const { query } = useLocation5(); 17009 const { canvas = "view" } = query; 17010 const { isSaveViewOpen, isDirty, isSaving } = (0, import_data11.useSelect)((select4) => { 17011 const { 17012 __experimentalGetDirtyEntityRecords, 17013 isSavingEntityRecord, 17014 isResolving 17015 } = select4(import_core_data10.store); 17016 const dirtyEntityRecords = __experimentalGetDirtyEntityRecords(); 17017 const isActivatingTheme = isResolving("activateTheme"); 17018 const { isSaveViewOpened: isSaveViewOpened2 } = unlock(select4(store)); 17019 return { 17020 isSaveViewOpen: isSaveViewOpened2(), 17021 isDirty: dirtyEntityRecords.length > 0, 17022 isSaving: dirtyEntityRecords.some( 17023 (record) => isSavingEntityRecord(record.kind, record.name, record.key) 17024 ) || isActivatingTheme 17025 }; 17026 }, []); 17027 const { setIsSaveViewOpened: setIsSaveViewOpened2 } = (0, import_data11.useDispatch)(store); 17028 const onClose = () => setIsSaveViewOpened2(false); 17029 (0, import_element43.useEffect)(() => { 17030 setIsSaveViewOpened2(false); 17031 }, [canvas, setIsSaveViewOpened2]); 17032 if (canvas === "view") { 17033 return isSaveViewOpen ? /* @__PURE__ */ (0, import_jsx_runtime103.jsx)( 17034 import_components5.Modal, 17035 { 17036 className: "edit-site-save-panel__modal", 17037 onRequestClose: onClose, 17038 title: (0, import_i18n6.__)("Review changes"), 17039 size: "small", 17040 children: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(_EntitiesSavedStates, { onClose, variant: "inline" }) 17041 } 17042 ) : null; 17043 } 17044 const activateSaveEnabled = isPreviewingTheme() || isDirty; 17045 const disabled2 = isSaving || !activateSaveEnabled; 17046 return /* @__PURE__ */ (0, import_jsx_runtime103.jsxs)( 17047 navigable_region_default, 17048 { 17049 className: clsx_default("edit-site-layout__actions", { 17050 "is-entity-save-view-open": isSaveViewOpen 17051 }), 17052 ariaLabel: (0, import_i18n6.__)("Save panel"), 17053 children: [ 17054 /* @__PURE__ */ (0, import_jsx_runtime103.jsx)( 17055 "div", 17056 { 17057 className: clsx_default("edit-site-editor__toggle-save-panel", { 17058 "screen-reader-text": isSaveViewOpen 17059 }), 17060 children: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)( 17061 import_components5.Button, 17062 { 17063 __next40pxDefaultSize: true, 17064 variant: "secondary", 17065 className: "edit-site-editor__toggle-save-panel-button", 17066 onClick: () => setIsSaveViewOpened2(true), 17067 "aria-haspopup": "dialog", 17068 disabled: disabled2, 17069 accessibleWhenDisabled: true, 17070 children: (0, import_i18n6.__)("Open save panel") 17071 } 17072 ) 17073 } 17074 ), 17075 isSaveViewOpen && /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(_EntitiesSavedStates, { onClose, renderDialog: true }) 17076 ] 17077 } 17078 ); 17079 } 17080 17081 // packages/edit-site/build-module/components/layout/index.mjs 17082 var import_jsx_runtime104 = __toESM(require_jsx_runtime(), 1); 17083 var { useLocation: useLocation6 } = unlock(import_router6.privateApis); 17084 var { useStyle, UploadProgressSnackbar } = unlock(import_editor6.privateApis); 17085 var ANIMATION_DURATION2 = 0.3; 17086 var CONTENT_COLOR = { background: "#ffffff" }; 17087 function Layout() { 17088 const { query, name: routeKey, areas: areas2, widths } = useLocation6(); 17089 const canvas = routeKey === "notfound" ? "view" : query?.canvas ?? "view"; 17090 const showMobileSiteHub = !!areas2.mobileContent; 17091 const hasMobileAreas = areas2.mobileSidebar || areas2.mobileContent || areas2.preview; 17092 const isMobileViewport = (0, import_compose2.useViewportMatch)("medium", "<"); 17093 const mobileToggleRef = (0, import_element44.useRef)(); 17094 const sidebarRegionRef = (0, import_element44.useRef)(); 17095 const navigateRegionsProps = (0, import_components6.__unstableUseNavigateRegions)(); 17096 const disableMotion = (0, import_compose2.useReducedMotion)(); 17097 const [canvasResizer, canvasSize] = (0, import_compose2.useResizeObserver)(); 17098 const isEditorLoading = useIsSiteEditorLoading(); 17099 const [isResizableFrameOversized, setIsResizableFrameOversized] = (0, import_element44.useState)(false); 17100 const animationRef = animation_default({ 17101 triggerAnimationOnChange: routeKey + "-" + canvas 17102 }); 17103 const { showIconLabels } = (0, import_data12.useSelect)((select4) => { 17104 return { 17105 showIconLabels: select4(import_preferences3.store).get( 17106 "core", 17107 "showIconLabels" 17108 ) 17109 }; 17110 }); 17111 const backgroundColor = useStyle("color.background"); 17112 const gradientValue = useStyle("color.gradient"); 17113 const previousCanvaMode = (0, import_compose2.usePrevious)(canvas); 17114 (0, import_element44.useEffect)(() => { 17115 if (previousCanvaMode === "edit") { 17116 const desktopToggle = sidebarRegionRef.current ? ( 17117 // We're typically expecting the `<DashboardBackButton />` component as the first tabbable element. 17118 import_dom23.focus.tabbable.find(sidebarRegionRef.current)[0] 17119 ) : void 0; 17120 (desktopToggle ?? mobileToggleRef.current)?.focus(); 17121 } 17122 }, [canvas]); 17123 return /* @__PURE__ */ (0, import_jsx_runtime104.jsxs)(import_jsx_runtime104.Fragment, { children: [ 17124 /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(import_editor6.UnsavedChangesWarning, {}), 17125 canvas === "view" && /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(SaveKeyboardShortcut, {}), 17126 /* @__PURE__ */ (0, import_jsx_runtime104.jsx)( 17127 "div", 17128 { 17129 ...navigateRegionsProps, 17130 className: clsx_default( 17131 "edit-site-layout", 17132 navigateRegionsProps.className, 17133 { 17134 "is-full-canvas": canvas === "edit", 17135 "show-icon-labels": showIconLabels 17136 } 17137 ), 17138 children: /* @__PURE__ */ (0, import_jsx_runtime104.jsxs)("div", { className: "edit-site-layout__content", children: [ 17139 (!isMobileViewport || !hasMobileAreas) && /* @__PURE__ */ (0, import_jsx_runtime104.jsx)( 17140 navigable_region_default, 17141 { 17142 ref: sidebarRegionRef, 17143 ariaLabel: (0, import_i18n7.__)("Navigation"), 17144 className: "edit-site-layout__sidebar-region", 17145 children: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(import_components6.__unstableAnimatePresence, { children: canvas === "view" && /* @__PURE__ */ (0, import_jsx_runtime104.jsxs)( 17146 import_components6.__unstableMotion.div, 17147 { 17148 initial: { opacity: 0 }, 17149 animate: { opacity: 1 }, 17150 exit: { opacity: 0 }, 17151 transition: { 17152 type: "tween", 17153 duration: ( 17154 // Disable transition in mobile to emulate a full page transition. 17155 disableMotion || isMobileViewport ? 0 : ANIMATION_DURATION2 17156 ), 17157 ease: "easeOut" 17158 }, 17159 className: "edit-site-layout__sidebar", 17160 children: [ 17161 /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(SidebarNavigationProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)( 17162 SidebarContent, 17163 { 17164 shouldAnimate: routeKey !== "styles" && routeKey !== "identity", 17165 routeKey, 17166 children: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(import_editor6.ErrorBoundary, { children: areas2.sidebar }) 17167 } 17168 ) }), 17169 /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(SaveHub, {}), 17170 /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(SavePanel, {}) 17171 ] 17172 } 17173 ) }) 17174 } 17175 ), 17176 /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(import_notices.SnackbarNotices, { className: "edit-site-layout__snackbar" }), 17177 /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(UploadProgressSnackbar, {}), 17178 isMobileViewport && hasMobileAreas && /* @__PURE__ */ (0, import_jsx_runtime104.jsx)("div", { className: "edit-site-layout__mobile", children: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(SidebarNavigationProvider, { children: canvas !== "edit" ? /* @__PURE__ */ (0, import_jsx_runtime104.jsxs)(import_jsx_runtime104.Fragment, { children: [ 17179 showMobileSiteHub && /* @__PURE__ */ (0, import_jsx_runtime104.jsx)( 17180 SiteHubMobile, 17181 { 17182 ref: mobileToggleRef 17183 } 17184 ), 17185 areas2.mobileContent ? ( 17186 /* 17187 * ThemeProvider wraps SidebarContent (rather than 17188 * just the content) so the scroll wrapper it renders 17189 * inherits the content background tokens. See 17190 * `.edit-site-sidebar__screen-wrapper` in style.scss. 17191 */ 17192 /* @__PURE__ */ (0, import_jsx_runtime104.jsx)( 17193 import_theme.ThemeProvider, 17194 { 17195 color: CONTENT_COLOR, 17196 children: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)( 17197 SidebarContent, 17198 { 17199 routeKey, 17200 children: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)("div", { className: "edit-site-layout__mobile-content", children: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(import_editor6.ErrorBoundary, { children: areas2.mobileContent }) }) 17201 } 17202 ) 17203 } 17204 ) 17205 ) : /* @__PURE__ */ (0, import_jsx_runtime104.jsx)( 17206 SidebarContent, 17207 { 17208 routeKey, 17209 children: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(import_editor6.ErrorBoundary, { children: areas2.mobileSidebar }) 17210 } 17211 ), 17212 /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(SaveHub, {}), 17213 /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(SavePanel, {}) 17214 ] }) : /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(import_theme.ThemeProvider, { color: CONTENT_COLOR, children: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(import_editor6.ErrorBoundary, { children: areas2.preview }) }) }) }), 17215 !isMobileViewport && areas2.content && canvas !== "edit" && /* @__PURE__ */ (0, import_jsx_runtime104.jsx)( 17216 "div", 17217 { 17218 className: "edit-site-layout__area", 17219 style: { 17220 maxWidth: widths?.content 17221 }, 17222 children: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(import_theme.ThemeProvider, { color: CONTENT_COLOR, children: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(import_editor6.ErrorBoundary, { children: areas2.content }) }) 17223 } 17224 ), 17225 !isMobileViewport && areas2.edit && canvas !== "edit" && /* @__PURE__ */ (0, import_jsx_runtime104.jsx)( 17226 "div", 17227 { 17228 className: "edit-site-layout__area", 17229 style: { 17230 maxWidth: widths?.edit 17231 }, 17232 children: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(import_theme.ThemeProvider, { color: CONTENT_COLOR, children: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(import_editor6.ErrorBoundary, { children: areas2.edit }) }) 17233 } 17234 ), 17235 !isMobileViewport && areas2.preview && /* @__PURE__ */ (0, import_jsx_runtime104.jsxs)("div", { className: "edit-site-layout__canvas-container", children: [ 17236 canvasResizer, 17237 !!canvasSize.width && /* @__PURE__ */ (0, import_jsx_runtime104.jsx)( 17238 "div", 17239 { 17240 className: clsx_default( 17241 "edit-site-layout__canvas", 17242 { 17243 "is-right-aligned": isResizableFrameOversized 17244 } 17245 ), 17246 ref: animationRef, 17247 children: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(import_editor6.ErrorBoundary, { children: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)( 17248 resizable_frame_default, 17249 { 17250 isReady: !isEditorLoading, 17251 isFullWidth: canvas === "edit", 17252 defaultSize: { 17253 width: canvasSize.width - 24, 17254 height: canvasSize.height 17255 }, 17256 isOversized: isResizableFrameOversized, 17257 setIsOversized: setIsResizableFrameOversized, 17258 innerContentStyle: { 17259 background: gradientValue ?? backgroundColor 17260 }, 17261 children: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)( 17262 import_theme.ThemeProvider, 17263 { 17264 color: CONTENT_COLOR, 17265 children: areas2.preview 17266 } 17267 ) 17268 } 17269 ) }) 17270 } 17271 ) 17272 ] }) 17273 ] }) 17274 } 17275 ) 17276 ] }); 17277 } 17278 function LayoutWithGlobalStylesProvider(props) { 17279 const themeColors = (0, import_element44.useMemo)(getAdminThemeColors, []); 17280 const { createErrorNotice } = (0, import_data12.useDispatch)(import_notices.store); 17281 function onPluginAreaError(name2) { 17282 createErrorNotice( 17283 (0, import_i18n7.sprintf)( 17284 /* translators: %s: plugin name */ 17285 (0, import_i18n7.__)( 17286 'The "%s" plugin has encountered an error and cannot be rendered.' 17287 ), 17288 name2 17289 ) 17290 ); 17291 } 17292 return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(import_components6.SlotFillProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime104.jsxs)(tooltip_exports.Provider, { children: [ 17293 /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(import_plugins2.PluginArea, { onError: onPluginAreaError }), 17294 /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(import_theme.ThemeProvider, { color: themeColors, children: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(Layout, { ...props }) }) 17295 ] }) }); 17296 } 17297 17298 // packages/edit-site/build-module/hooks/commands/use-common-commands.mjs 17299 var import_element45 = __toESM(require_element(), 1); 17300 var import_data13 = __toESM(require_data(), 1); 17301 var import_i18n8 = __toESM(require_i18n(), 1); 17302 var import_commands = __toESM(require_commands(), 1); 17303 var import_router7 = __toESM(require_router(), 1); 17304 var import_preferences4 = __toESM(require_preferences(), 1); 17305 var import_core_data11 = __toESM(require_core_data(), 1); 17306 var import_editor7 = __toESM(require_editor(), 1); 17307 var { useHistory: useHistory4, useLocation: useLocation7 } = unlock(import_router7.privateApis); 17308 var { useGlobalStyles } = unlock(import_editor7.privateApis); 17309 var getGlobalStylesToggleWelcomeGuideCommands = () => function useGlobalStylesToggleWelcomeGuideCommands() { 17310 const { openGeneralSidebar: openGeneralSidebar2 } = unlock((0, import_data13.useDispatch)(store)); 17311 const { params } = useLocation7(); 17312 const { canvas = "view" } = params; 17313 const { set: set3 } = (0, import_data13.useDispatch)(import_preferences4.store); 17314 const history = useHistory4(); 17315 const isBlockBasedTheme = (0, import_data13.useSelect)((select4) => { 17316 return select4(import_core_data11.store).getCurrentTheme().is_block_theme; 17317 }, []); 17318 const commands = (0, import_element45.useMemo)(() => { 17319 if (!isBlockBasedTheme) { 17320 return []; 17321 } 17322 return [ 17323 { 17324 name: "core/edit-site/toggle-styles-welcome-guide", 17325 label: (0, import_i18n8.__)("Learn about styles"), 17326 callback: ({ close }) => { 17327 close(); 17328 if (canvas !== "edit") { 17329 history.navigate("/styles?canvas=edit", { 17330 transition: "canvas-mode-edit-transition" 17331 }); 17332 } 17333 openGeneralSidebar2("edit-site/global-styles"); 17334 set3("core/edit-site", "welcomeGuideStyles", true); 17335 setTimeout(() => { 17336 set3("core/edit-site", "welcomeGuideStyles", true); 17337 }, 500); 17338 }, 17339 icon: help_default 17340 } 17341 ]; 17342 }, [history, openGeneralSidebar2, canvas, isBlockBasedTheme, set3]); 17343 return { 17344 isLoading: false, 17345 commands 17346 }; 17347 }; 17348 var getGlobalStylesResetCommands = () => function useGlobalStylesResetCommands() { 17349 const { user, setUser } = useGlobalStyles(); 17350 const canReset = !!user && (Object.keys(user?.styles ?? {}).length > 0 || Object.keys(user?.settings ?? {}).length > 0); 17351 const commands = (0, import_element45.useMemo)(() => { 17352 if (!canReset) { 17353 return []; 17354 } 17355 return [ 17356 { 17357 name: "core/edit-site/reset-global-styles", 17358 label: (0, import_i18n8.__)("Reset styles"), 17359 icon: (0, import_i18n8.isRTL)() ? rotate_right_default : rotate_left_default, 17360 callback: ({ close }) => { 17361 close(); 17362 setUser({ styles: {}, settings: {} }); 17363 } 17364 } 17365 ]; 17366 }, [canReset, setUser]); 17367 return { 17368 isLoading: false, 17369 commands 17370 }; 17371 }; 17372 var getGlobalStylesOpenRevisionsCommands = () => function useGlobalStylesOpenRevisionsCommands() { 17373 const { openGeneralSidebar: openGeneralSidebar2 } = unlock((0, import_data13.useDispatch)(store)); 17374 const { setStylesPath } = unlock((0, import_data13.useDispatch)(import_editor7.store)); 17375 const { params } = useLocation7(); 17376 const { canvas = "view" } = params; 17377 const history = useHistory4(); 17378 const hasRevisions = (0, import_data13.useSelect)((select4) => { 17379 const { getEntityRecord, __experimentalGetCurrentGlobalStylesId } = select4(import_core_data11.store); 17380 const globalStylesId = __experimentalGetCurrentGlobalStylesId(); 17381 const globalStyles = globalStylesId ? getEntityRecord("root", "globalStyles", globalStylesId) : void 0; 17382 return !!globalStyles?._links?.["version-history"]?.[0]?.count; 17383 }, []); 17384 const commands = (0, import_element45.useMemo)(() => { 17385 if (!hasRevisions) { 17386 return []; 17387 } 17388 return [ 17389 { 17390 name: "core/edit-site/open-styles-revisions", 17391 label: (0, import_i18n8.__)("Open style revisions"), 17392 icon: backup_default, 17393 callback: ({ close }) => { 17394 close(); 17395 if (canvas !== "edit") { 17396 history.navigate("/styles?canvas=edit", { 17397 transition: "canvas-mode-edit-transition" 17398 }); 17399 } 17400 openGeneralSidebar2("edit-site/global-styles"); 17401 setStylesPath("/revisions"); 17402 } 17403 } 17404 ]; 17405 }, [ 17406 history, 17407 openGeneralSidebar2, 17408 setStylesPath, 17409 hasRevisions, 17410 canvas 17411 ]); 17412 return { 17413 isLoading: false, 17414 commands 17415 }; 17416 }; 17417 function useCommonCommands() { 17418 (0, import_commands.useCommandLoader)({ 17419 name: "core/edit-site/toggle-styles-welcome-guide", 17420 hook: getGlobalStylesToggleWelcomeGuideCommands() 17421 }); 17422 (0, import_commands.useCommandLoader)({ 17423 name: "core/edit-site/reset-global-styles", 17424 hook: getGlobalStylesResetCommands() 17425 }); 17426 (0, import_commands.useCommandLoader)({ 17427 name: "core/edit-site/open-styles-revisions", 17428 hook: getGlobalStylesOpenRevisionsCommands() 17429 }); 17430 } 17431 17432 // packages/edit-site/build-module/hooks/commands/use-set-command-context.mjs 17433 var import_data14 = __toESM(require_data(), 1); 17434 var import_commands2 = __toESM(require_commands(), 1); 17435 var import_block_editor3 = __toESM(require_block_editor(), 1); 17436 var import_router8 = __toESM(require_router(), 1); 17437 var { useCommandContext } = unlock(import_commands2.privateApis); 17438 var { useLocation: useLocation8 } = unlock(import_router8.privateApis); 17439 function useSetCommandContext() { 17440 const { query = {} } = useLocation8(); 17441 const { canvas = "view" } = query; 17442 const hasBlockSelected = (0, import_data14.useSelect)((select4) => { 17443 return select4(import_block_editor3.store).getBlockSelectionStart(); 17444 }, []); 17445 let commandContext = "site-editor"; 17446 if (canvas === "edit") { 17447 commandContext = "entity-edit"; 17448 } 17449 if (hasBlockSelected) { 17450 commandContext = "block-selection-edit"; 17451 } 17452 useCommandContext(commandContext); 17453 } 17454 17455 // packages/edit-site/build-module/components/site-editor-routes/index.mjs 17456 var import_data88 = __toESM(require_data(), 1); 17457 var import_element199 = __toESM(require_element(), 1); 17458 17459 // packages/edit-site/build-module/components/sidebar-navigation-screen-main/index.mjs 17460 var import_components10 = __toESM(require_components(), 1); 17461 var import_i18n11 = __toESM(require_i18n(), 1); 17462 var import_data16 = __toESM(require_data(), 1); 17463 var import_core_data13 = __toESM(require_core_data(), 1); 17464 17465 // packages/edit-site/build-module/components/sidebar-navigation-screen/index.mjs 17466 var import_components8 = __toESM(require_components(), 1); 17467 var import_i18n9 = __toESM(require_i18n(), 1); 17468 var import_core_data12 = __toESM(require_core_data(), 1); 17469 var import_data15 = __toESM(require_data(), 1); 17470 var import_router9 = __toESM(require_router(), 1); 17471 var import_element46 = __toESM(require_element(), 1); 17472 17473 // packages/edit-site/build-module/components/sidebar-button/index.mjs 17474 var import_components7 = __toESM(require_components(), 1); 17475 var import_jsx_runtime105 = __toESM(require_jsx_runtime(), 1); 17476 function SidebarButton(props) { 17477 return /* @__PURE__ */ (0, import_jsx_runtime105.jsx)( 17478 import_components7.Button, 17479 { 17480 size: "compact", 17481 ...props, 17482 className: clsx_default("edit-site-sidebar-button", props.className) 17483 } 17484 ); 17485 } 17486 17487 // packages/edit-site/build-module/components/sidebar-navigation-screen/index.mjs 17488 var import_jsx_runtime106 = __toESM(require_jsx_runtime(), 1); 17489 var { useHistory: useHistory5, useLocation: useLocation9 } = unlock(import_router9.privateApis); 17490 function SidebarNavigationScreen({ 17491 isRoot, 17492 title, 17493 actions, 17494 content, 17495 footer, 17496 description, 17497 backPath: backPathProp 17498 }) { 17499 const { dashboardLink, dashboardLinkText, previewingThemeName } = (0, import_data15.useSelect)( 17500 (select4) => { 17501 const { getSettings: getSettings7 } = unlock(select4(store)); 17502 const currentlyPreviewingThemeId = currentlyPreviewingTheme(); 17503 return { 17504 dashboardLink: getSettings7().__experimentalDashboardLink, 17505 dashboardLinkText: getSettings7().__experimentalDashboardLinkText, 17506 // Do not call `getTheme` with null, it will cause a request to 17507 // the server. 17508 previewingThemeName: currentlyPreviewingThemeId ? select4(import_core_data12.store).getTheme(currentlyPreviewingThemeId)?.name?.rendered : void 0 17509 }; 17510 }, 17511 [] 17512 ); 17513 const location = useLocation9(); 17514 const history = useHistory5(); 17515 const { navigate } = (0, import_element46.useContext)(SidebarNavigationContext); 17516 const backPath = backPathProp ?? location.state?.backPath; 17517 const icon = (0, import_i18n9.isRTL)() ? chevron_right_default : chevron_left_default; 17518 return /* @__PURE__ */ (0, import_jsx_runtime106.jsxs)(import_jsx_runtime106.Fragment, { children: [ 17519 /* @__PURE__ */ (0, import_jsx_runtime106.jsxs)( 17520 import_components8.__experimentalVStack, 17521 { 17522 className: clsx_default("edit-site-sidebar-navigation-screen__main", { 17523 "has-footer": !!footer 17524 }), 17525 spacing: 0, 17526 justify: "flex-start", 17527 children: [ 17528 /* @__PURE__ */ (0, import_jsx_runtime106.jsxs)( 17529 import_components8.__experimentalHStack, 17530 { 17531 spacing: 3, 17532 alignment: "flex-start", 17533 className: "edit-site-sidebar-navigation-screen__title-icon", 17534 children: [ 17535 !isRoot && /* @__PURE__ */ (0, import_jsx_runtime106.jsx)( 17536 SidebarButton, 17537 { 17538 onClick: () => { 17539 history.navigate(backPath); 17540 navigate("back"); 17541 }, 17542 icon, 17543 label: (0, import_i18n9.__)("Back"), 17544 showTooltip: false 17545 } 17546 ), 17547 isRoot && /* @__PURE__ */ (0, import_jsx_runtime106.jsx)( 17548 SidebarButton, 17549 { 17550 icon, 17551 label: dashboardLinkText || (0, import_i18n9.__)("Go to the Dashboard"), 17552 href: dashboardLink 17553 } 17554 ), 17555 /* @__PURE__ */ (0, import_jsx_runtime106.jsx)( 17556 import_components8.__experimentalHeading, 17557 { 17558 className: "edit-site-sidebar-navigation-screen__title", 17559 level: 1, 17560 size: 20, 17561 children: !isPreviewingTheme() ? title : (0, import_i18n9.sprintf)( 17562 /* translators: 1: theme name. 2: title */ 17563 (0, import_i18n9.__)("Previewing %1$s: %2$s"), 17564 previewingThemeName, 17565 title 17566 ) 17567 } 17568 ), 17569 actions && /* @__PURE__ */ (0, import_jsx_runtime106.jsx)("div", { className: "edit-site-sidebar-navigation-screen__actions", children: actions }) 17570 ] 17571 } 17572 ), 17573 /* @__PURE__ */ (0, import_jsx_runtime106.jsxs)("div", { className: "edit-site-sidebar-navigation-screen__content", children: [ 17574 description && /* @__PURE__ */ (0, import_jsx_runtime106.jsx)("div", { className: "edit-site-sidebar-navigation-screen__description", children: description }), 17575 content 17576 ] }) 17577 ] 17578 } 17579 ), 17580 footer && /* @__PURE__ */ (0, import_jsx_runtime106.jsx)("footer", { className: "edit-site-sidebar-navigation-screen__footer", children: footer }) 17581 ] }); 17582 } 17583 17584 // packages/edit-site/build-module/components/sidebar-navigation-item/index.mjs 17585 var import_components9 = __toESM(require_components(), 1); 17586 var import_i18n10 = __toESM(require_i18n(), 1); 17587 var import_router10 = __toESM(require_router(), 1); 17588 var import_element47 = __toESM(require_element(), 1); 17589 var import_jsx_runtime107 = __toESM(require_jsx_runtime(), 1); 17590 var { useHistory: useHistory6, useLink, useLocation: useLocation10 } = unlock(import_router10.privateApis); 17591 function SidebarNavigationItem({ 17592 isHidden: isHidden2 = false, 17593 ...props 17594 }) { 17595 if (isHidden2) { 17596 return null; 17597 } 17598 return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(SidebarNavigationItemContent, { ...props }); 17599 } 17600 function SidebarNavigationItemContent({ 17601 className, 17602 icon, 17603 withChevron = false, 17604 suffix, 17605 uid, 17606 to: to2, 17607 onClick, 17608 activeOnRouteName, 17609 children, 17610 ...props 17611 }) { 17612 const history = useHistory6(); 17613 const linkProps = useLink(to2); 17614 const { name: name2 } = useLocation10(); 17615 const { navigate } = (0, import_element47.useContext)(SidebarNavigationContext); 17616 const isActive = activeOnRouteName && name2 === activeOnRouteName; 17617 function handleClick(e2) { 17618 if (onClick) { 17619 onClick(e2); 17620 navigate("forward"); 17621 } else if (to2) { 17622 e2.preventDefault(); 17623 history.navigate(to2); 17624 navigate("forward", `[id="$uid}"]`); 17625 } 17626 } 17627 return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)( 17628 import_components9.__experimentalItem, 17629 { 17630 className: clsx_default( 17631 "edit-site-sidebar-navigation-item", 17632 { "with-suffix": !withChevron && suffix }, 17633 className 17634 ), 17635 id: uid, 17636 onClick: handleClick, 17637 href: to2 ? linkProps.href : void 0, 17638 "aria-current": isActive ? true : void 0, 17639 ...props, 17640 children: /* @__PURE__ */ (0, import_jsx_runtime107.jsxs)(Stack, { direction: "row", align: "center", justify: "start", gap: "sm", children: [ 17641 icon && /* @__PURE__ */ (0, import_jsx_runtime107.jsx)( 17642 icon_default, 17643 { 17644 style: { fill: "currentcolor" }, 17645 icon, 17646 size: 24 17647 } 17648 ), 17649 /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(import_components9.FlexBlock, { children }), 17650 withChevron && /* @__PURE__ */ (0, import_jsx_runtime107.jsx)( 17651 icon_default, 17652 { 17653 icon: (0, import_i18n10.isRTL)() ? chevron_left_small_default : chevron_right_small_default, 17654 className: "edit-site-sidebar-navigation-item__drilldown-indicator", 17655 size: 24 17656 } 17657 ), 17658 !withChevron && suffix 17659 ] }) 17660 } 17661 ); 17662 } 17663 17664 // packages/edit-site/build-module/components/sidebar-navigation-screen-main/index.mjs 17665 var import_jsx_runtime108 = __toESM(require_jsx_runtime(), 1); 17666 function MainSidebarNavigationContent({ isBlockBasedTheme = true }) { 17667 return /* @__PURE__ */ (0, import_jsx_runtime108.jsxs)(import_components10.__experimentalItemGroup, { className: "edit-site-sidebar-navigation-screen-main", children: [ 17668 /* @__PURE__ */ (0, import_jsx_runtime108.jsx)( 17669 SidebarNavigationItem, 17670 { 17671 to: "/identity", 17672 uid: "identity-navigation-item", 17673 icon: site_logo_default, 17674 activeOnRouteName: "identity", 17675 isHidden: !isBlockBasedTheme, 17676 children: (0, import_i18n11._x)("Identity", "site identity") 17677 } 17678 ), 17679 /* @__PURE__ */ (0, import_jsx_runtime108.jsx)( 17680 SidebarNavigationItem, 17681 { 17682 to: isBlockBasedTheme ? "/styles" : "/stylebook", 17683 uid: isBlockBasedTheme ? "global-styles-navigation-item" : "stylebook-navigation-item", 17684 icon: styles_default, 17685 activeOnRouteName: isBlockBasedTheme ? "styles" : void 0, 17686 withChevron: !isBlockBasedTheme, 17687 children: (0, import_i18n11.__)("Styles") 17688 } 17689 ), 17690 /* @__PURE__ */ (0, import_jsx_runtime108.jsx)( 17691 SidebarNavigationItem, 17692 { 17693 uid: "page-navigation-item", 17694 to: "/page", 17695 withChevron: true, 17696 icon: page_default, 17697 isHidden: !isBlockBasedTheme, 17698 children: (0, import_i18n11.__)("Pages") 17699 } 17700 ), 17701 /* @__PURE__ */ (0, import_jsx_runtime108.jsx)( 17702 SidebarNavigationItem, 17703 { 17704 uid: "navigation-navigation-item", 17705 to: "/navigation", 17706 withChevron: true, 17707 icon: navigation_default, 17708 isHidden: !isBlockBasedTheme, 17709 children: (0, import_i18n11.__)("Navigation") 17710 } 17711 ), 17712 /* @__PURE__ */ (0, import_jsx_runtime108.jsx)( 17713 SidebarNavigationItem, 17714 { 17715 uid: "patterns-navigation-item", 17716 to: "/pattern", 17717 withChevron: true, 17718 icon: symbol_default, 17719 children: (0, import_i18n11.__)("Patterns") 17720 } 17721 ), 17722 /* @__PURE__ */ (0, import_jsx_runtime108.jsx)( 17723 SidebarNavigationItem, 17724 { 17725 uid: "template-navigation-item", 17726 to: "/template", 17727 withChevron: true, 17728 icon: layout_default, 17729 isHidden: !isBlockBasedTheme, 17730 children: (0, import_i18n11.__)("Templates") 17731 } 17732 ) 17733 ] }); 17734 } 17735 function SidebarNavigationScreenMain({ customDescription }) { 17736 const isBlockBasedTheme = (0, import_data16.useSelect)( 17737 (select4) => select4(import_core_data13.store).getCurrentTheme()?.is_block_theme, 17738 [] 17739 ); 17740 let description; 17741 if (customDescription) { 17742 description = customDescription; 17743 } else if (isBlockBasedTheme) { 17744 description = (0, import_i18n11.__)( 17745 "Customize the appearance of your website using the block editor." 17746 ); 17747 } else { 17748 description = (0, import_i18n11.__)( 17749 "Explore block styles and patterns to refine your site." 17750 ); 17751 } 17752 return /* @__PURE__ */ (0, import_jsx_runtime108.jsx)( 17753 SidebarNavigationScreen, 17754 { 17755 isRoot: true, 17756 title: (0, import_i18n11.__)("Design"), 17757 description, 17758 content: /* @__PURE__ */ (0, import_jsx_runtime108.jsx)( 17759 MainSidebarNavigationContent, 17760 { 17761 isBlockBasedTheme 17762 } 17763 ) 17764 } 17765 ); 17766 } 17767 17768 // packages/edit-site/build-module/components/sidebar-navigation-screen-unsupported/index.mjs 17769 var import_i18n12 = __toESM(require_i18n(), 1); 17770 var import_components11 = __toESM(require_components(), 1); 17771 var import_jsx_runtime109 = __toESM(require_jsx_runtime(), 1); 17772 function SidebarNavigationScreenUnsupported() { 17773 return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(import_components11.__experimentalSpacer, { padding: 3, children: /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(import_components11.Notice, { status: "warning", isDismissible: false, children: (0, import_i18n12.__)( 17774 "The theme you are currently using does not support this screen." 17775 ) }) }); 17776 } 17777 17778 // packages/edit-site/build-module/components/editor/index.mjs 17779 var import_data35 = __toESM(require_data(), 1); 17780 var import_components19 = __toESM(require_components(), 1); 17781 var import_compose4 = __toESM(require_compose(), 1); 17782 var import_editor20 = __toESM(require_editor(), 1); 17783 var import_i18n22 = __toESM(require_i18n(), 1); 17784 var import_core_data22 = __toESM(require_core_data(), 1); 17785 var import_block_library = __toESM(require_block_library(), 1); 17786 var import_element57 = __toESM(require_element(), 1); 17787 var import_notices3 = __toESM(require_notices(), 1); 17788 var import_router18 = __toESM(require_router(), 1); 17789 var import_html_entities3 = __toESM(require_html_entities(), 1); 17790 var import_block_editor5 = __toESM(require_block_editor(), 1); 17791 var import_url9 = __toESM(require_url(), 1); 17792 17793 // packages/edit-site/build-module/components/welcome-guide/editor.mjs 17794 var import_data17 = __toESM(require_data(), 1); 17795 var import_components12 = __toESM(require_components(), 1); 17796 var import_i18n13 = __toESM(require_i18n(), 1); 17797 var import_element48 = __toESM(require_element(), 1); 17798 var import_preferences5 = __toESM(require_preferences(), 1); 17799 var import_core_data14 = __toESM(require_core_data(), 1); 17800 17801 // packages/edit-site/build-module/components/welcome-guide/image.mjs 17802 var import_jsx_runtime110 = __toESM(require_jsx_runtime(), 1); 17803 function WelcomeGuideImage({ nonAnimatedSrc, animatedSrc }) { 17804 return /* @__PURE__ */ (0, import_jsx_runtime110.jsxs)("picture", { className: "edit-site-welcome-guide__image", children: [ 17805 /* @__PURE__ */ (0, import_jsx_runtime110.jsx)( 17806 "source", 17807 { 17808 srcSet: nonAnimatedSrc, 17809 media: "(prefers-reduced-motion: reduce)" 17810 } 17811 ), 17812 /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("img", { src: animatedSrc, width: "312", height: "240", alt: "" }) 17813 ] }); 17814 } 17815 17816 // packages/edit-site/build-module/components/welcome-guide/editor.mjs 17817 var import_jsx_runtime111 = __toESM(require_jsx_runtime(), 1); 17818 function WelcomeGuideEditor() { 17819 const { toggle } = (0, import_data17.useDispatch)(import_preferences5.store); 17820 const { isActive, isBlockBasedTheme } = (0, import_data17.useSelect)((select4) => { 17821 return { 17822 isActive: !!select4(import_preferences5.store).get( 17823 "core/edit-site", 17824 "welcomeGuide" 17825 ), 17826 isBlockBasedTheme: select4(import_core_data14.store).getCurrentTheme()?.is_block_theme 17827 }; 17828 }, []); 17829 if (!isActive || !isBlockBasedTheme) { 17830 return null; 17831 } 17832 return /* @__PURE__ */ (0, import_jsx_runtime111.jsx)( 17833 import_components12.Guide, 17834 { 17835 className: "edit-site-welcome-guide guide-editor", 17836 contentLabel: (0, import_i18n13.__)("Welcome to the site editor"), 17837 finishButtonText: (0, import_i18n13.__)("Get started"), 17838 onFinish: () => toggle("core/edit-site", "welcomeGuide"), 17839 pages: [ 17840 { 17841 image: /* @__PURE__ */ (0, import_jsx_runtime111.jsx)( 17842 WelcomeGuideImage, 17843 { 17844 nonAnimatedSrc: "https://s.w.org/images/block-editor/edit-your-site.svg?1", 17845 animatedSrc: "https://s.w.org/images/block-editor/edit-your-site.gif?1" 17846 } 17847 ), 17848 content: /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)(import_jsx_runtime111.Fragment, { children: [ 17849 /* @__PURE__ */ (0, import_jsx_runtime111.jsx)("h1", { className: "edit-site-welcome-guide__heading", children: (0, import_i18n13.__)("Edit your site") }), 17850 /* @__PURE__ */ (0, import_jsx_runtime111.jsx)("p", { className: "edit-site-welcome-guide__text", children: (0, import_i18n13.__)( 17851 "Design everything on your site \u2014 from the header right down to the footer \u2014 using blocks." 17852 ) }), 17853 /* @__PURE__ */ (0, import_jsx_runtime111.jsx)("p", { className: "edit-site-welcome-guide__text", children: (0, import_element48.createInterpolateElement)( 17854 (0, import_i18n13.__)( 17855 "Click <StylesIconImage /> to start designing your blocks, and choose your typography, layout, and colors." 17856 ), 17857 { 17858 StylesIconImage: /* @__PURE__ */ (0, import_jsx_runtime111.jsx)( 17859 "img", 17860 { 17861 alt: (0, import_i18n13.__)("styles"), 17862 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" 17863 } 17864 ) 17865 } 17866 ) }) 17867 ] }) 17868 } 17869 ] 17870 } 17871 ); 17872 } 17873 17874 // packages/edit-site/build-module/components/welcome-guide/page.mjs 17875 var import_data18 = __toESM(require_data(), 1); 17876 var import_components13 = __toESM(require_components(), 1); 17877 var import_i18n14 = __toESM(require_i18n(), 1); 17878 var import_preferences6 = __toESM(require_preferences(), 1); 17879 var import_jsx_runtime112 = __toESM(require_jsx_runtime(), 1); 17880 function WelcomeGuidePage() { 17881 const { toggle } = (0, import_data18.useDispatch)(import_preferences6.store); 17882 const isVisible2 = (0, import_data18.useSelect)((select4) => { 17883 const isPageActive = !!select4(import_preferences6.store).get( 17884 "core/edit-site", 17885 "welcomeGuidePage" 17886 ); 17887 const isEditorActive = !!select4(import_preferences6.store).get( 17888 "core/edit-site", 17889 "welcomeGuide" 17890 ); 17891 return isPageActive && !isEditorActive; 17892 }, []); 17893 if (!isVisible2) { 17894 return null; 17895 } 17896 const heading = (0, import_i18n14.__)("Editing a page"); 17897 return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)( 17898 import_components13.Guide, 17899 { 17900 className: "edit-site-welcome-guide guide-page", 17901 contentLabel: heading, 17902 finishButtonText: (0, import_i18n14.__)("Continue"), 17903 onFinish: () => toggle("core/edit-site", "welcomeGuidePage"), 17904 pages: [ 17905 { 17906 image: /* @__PURE__ */ (0, import_jsx_runtime112.jsx)( 17907 "video", 17908 { 17909 className: "edit-site-welcome-guide__video", 17910 autoPlay: true, 17911 loop: true, 17912 muted: true, 17913 width: "312", 17914 height: "240", 17915 children: /* @__PURE__ */ (0, import_jsx_runtime112.jsx)( 17916 "source", 17917 { 17918 src: "https://s.w.org/images/block-editor/editing-your-page.mp4", 17919 type: "video/mp4" 17920 } 17921 ) 17922 } 17923 ), 17924 content: /* @__PURE__ */ (0, import_jsx_runtime112.jsxs)(import_jsx_runtime112.Fragment, { children: [ 17925 /* @__PURE__ */ (0, import_jsx_runtime112.jsx)("h1", { className: "edit-site-welcome-guide__heading", children: heading }), 17926 /* @__PURE__ */ (0, import_jsx_runtime112.jsx)("p", { className: "edit-site-welcome-guide__text", children: (0, import_i18n14.__)( 17927 // eslint-disable-next-line no-restricted-syntax -- 'sidebar' is a common web design term for layouts 17928 "It\u2019s now possible to edit page content in the site editor. To customize other parts of the page like the header and footer switch to editing the template using the settings sidebar." 17929 ) }) 17930 ] }) 17931 } 17932 ] 17933 } 17934 ); 17935 } 17936 17937 // packages/edit-site/build-module/components/welcome-guide/template.mjs 17938 var import_data19 = __toESM(require_data(), 1); 17939 var import_components14 = __toESM(require_components(), 1); 17940 var import_i18n15 = __toESM(require_i18n(), 1); 17941 var import_preferences7 = __toESM(require_preferences(), 1); 17942 var import_editor8 = __toESM(require_editor(), 1); 17943 var import_jsx_runtime113 = __toESM(require_jsx_runtime(), 1); 17944 function WelcomeGuideTemplate() { 17945 const { toggle } = (0, import_data19.useDispatch)(import_preferences7.store); 17946 const { isActive, hasPreviousEntity } = (0, import_data19.useSelect)((select4) => { 17947 const { getEditorSettings } = select4(import_editor8.store); 17948 const { get } = select4(import_preferences7.store); 17949 return { 17950 isActive: get("core/edit-site", "welcomeGuideTemplate"), 17951 hasPreviousEntity: !!getEditorSettings().onNavigateToPreviousEntityRecord 17952 }; 17953 }, []); 17954 const isVisible2 = isActive && hasPreviousEntity; 17955 if (!isVisible2) { 17956 return null; 17957 } 17958 const heading = (0, import_i18n15.__)("Editing a template"); 17959 return /* @__PURE__ */ (0, import_jsx_runtime113.jsx)( 17960 import_components14.Guide, 17961 { 17962 className: "edit-site-welcome-guide guide-template", 17963 contentLabel: heading, 17964 finishButtonText: (0, import_i18n15.__)("Continue"), 17965 onFinish: () => toggle("core/edit-site", "welcomeGuideTemplate"), 17966 pages: [ 17967 { 17968 image: /* @__PURE__ */ (0, import_jsx_runtime113.jsx)( 17969 "video", 17970 { 17971 className: "edit-site-welcome-guide__video", 17972 autoPlay: true, 17973 loop: true, 17974 muted: true, 17975 width: "312", 17976 height: "240", 17977 children: /* @__PURE__ */ (0, import_jsx_runtime113.jsx)( 17978 "source", 17979 { 17980 src: "https://s.w.org/images/block-editor/editing-your-template.mp4", 17981 type: "video/mp4" 17982 } 17983 ) 17984 } 17985 ), 17986 content: /* @__PURE__ */ (0, import_jsx_runtime113.jsxs)(import_jsx_runtime113.Fragment, { children: [ 17987 /* @__PURE__ */ (0, import_jsx_runtime113.jsx)("h1", { className: "edit-site-welcome-guide__heading", children: heading }), 17988 /* @__PURE__ */ (0, import_jsx_runtime113.jsx)("p", { className: "edit-site-welcome-guide__text", children: (0, import_i18n15.__)( 17989 "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." 17990 ) }) 17991 ] }) 17992 } 17993 ] 17994 } 17995 ); 17996 } 17997 17998 // packages/edit-site/build-module/components/welcome-guide/index.mjs 17999 var import_jsx_runtime114 = __toESM(require_jsx_runtime(), 1); 18000 function WelcomeGuide({ postType: postType2 }) { 18001 return /* @__PURE__ */ (0, import_jsx_runtime114.jsxs)(import_jsx_runtime114.Fragment, { children: [ 18002 /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(WelcomeGuideEditor, {}), 18003 postType2 === "page" && /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(WelcomeGuidePage, {}), 18004 postType2 === "wp_template" && /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(WelcomeGuideTemplate, {}) 18005 ] }); 18006 } 18007 18008 // packages/edit-site/build-module/components/canvas-loader/index.mjs 18009 var import_components15 = __toESM(require_components(), 1); 18010 var import_core_data15 = __toESM(require_core_data(), 1); 18011 var import_data20 = __toESM(require_data(), 1); 18012 var import_editor10 = __toESM(require_editor(), 1); 18013 var import_jsx_runtime115 = __toESM(require_jsx_runtime(), 1); 18014 var { Theme } = unlock(import_components15.privateApis); 18015 var { useStyle: useStyle2 } = unlock(import_editor10.privateApis); 18016 function CanvasLoader({ id }) { 18017 const textColor = useStyle2("color.text"); 18018 const backgroundColor = useStyle2("color.background"); 18019 const { elapsed, total } = (0, import_data20.useSelect)((select4) => { 18020 const selectorsByStatus = select4(import_core_data15.store).countSelectorsByStatus(); 18021 const resolving = selectorsByStatus.resolving ?? 0; 18022 const finished = selectorsByStatus.finished ?? 0; 18023 return { 18024 elapsed: finished, 18025 total: finished + resolving 18026 }; 18027 }, []); 18028 return /* @__PURE__ */ (0, import_jsx_runtime115.jsx)("div", { className: "edit-site-canvas-loader", children: /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(Theme, { accent: textColor, background: backgroundColor, children: /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(import_components15.ProgressBar, { id, max: total, value: elapsed }) }) }); 18029 } 18030 18031 // packages/edit-site/build-module/components/block-editor/use-site-editor-settings.mjs 18032 var import_data24 = __toESM(require_data(), 1); 18033 var import_element51 = __toESM(require_element(), 1); 18034 var import_router13 = __toESM(require_router(), 1); 18035 var import_compose3 = __toESM(require_compose(), 1); 18036 var import_editor13 = __toESM(require_editor(), 1); 18037 18038 // packages/global-styles-engine/build-module/utils/object.mjs 18039 function setImmutably(object, path, value) { 18040 path = Array.isArray(path) ? [...path] : [path]; 18041 object = Array.isArray(object) ? [...object] : { ...object }; 18042 const leaf = path.pop(); 18043 let prev = object; 18044 for (const key of path) { 18045 const lvl = prev[key]; 18046 prev = prev[key] = Array.isArray(lvl) ? [...lvl] : { ...lvl }; 18047 } 18048 prev[leaf] = value; 18049 return object; 18050 } 18051 var getValueFromObjectPath = (object, path, defaultValue2) => { 18052 const arrayPath = Array.isArray(path) ? path : path.split("."); 18053 let value = object; 18054 arrayPath.forEach((fieldName) => { 18055 value = value?.[fieldName]; 18056 }); 18057 return value ?? defaultValue2; 18058 }; 18059 18060 // packages/global-styles-engine/build-module/settings/get-setting.mjs 18061 var VALID_SETTINGS = [ 18062 "appearanceTools", 18063 "useRootPaddingAwareAlignments", 18064 "background.backgroundImage", 18065 "background.backgroundRepeat", 18066 "background.backgroundSize", 18067 "background.backgroundPosition", 18068 "background.gradient", 18069 "border.color", 18070 "border.radius", 18071 "border.radiusSizes", 18072 "border.style", 18073 "border.width", 18074 "shadow.presets", 18075 "shadow.defaultPresets", 18076 "color.background", 18077 "color.button", 18078 "color.caption", 18079 "color.custom", 18080 "color.customDuotone", 18081 "color.customGradient", 18082 "color.defaultDuotone", 18083 "color.defaultGradients", 18084 "color.defaultPalette", 18085 "color.duotone", 18086 "color.gradients", 18087 "color.heading", 18088 "color.link", 18089 "color.palette", 18090 "color.text", 18091 "custom", 18092 "dimensions.aspectRatio", 18093 "dimensions.height", 18094 "dimensions.minHeight", 18095 "dimensions.minWidth", 18096 "dimensions.width", 18097 "dimensions.dimensionSizes", 18098 "layout.contentSize", 18099 "layout.definitions", 18100 "layout.wideSize", 18101 "lightbox.enabled", 18102 "lightbox.allowEditing", 18103 "position.fixed", 18104 "position.sticky", 18105 "spacing.customSpacingSize", 18106 "spacing.defaultSpacingSizes", 18107 "spacing.spacingSizes", 18108 "spacing.spacingScale", 18109 "spacing.blockGap", 18110 "spacing.margin", 18111 "spacing.padding", 18112 "spacing.units", 18113 "typography.fluid", 18114 "typography.customFontSize", 18115 "typography.defaultFontSizes", 18116 "typography.dropCap", 18117 "typography.fontFamilies", 18118 "typography.fontSizes", 18119 "typography.fontStyle", 18120 "typography.fontWeight", 18121 "typography.letterSpacing", 18122 "typography.lineHeight", 18123 "typography.textAlign", 18124 "typography.textColumns", 18125 "typography.textDecoration", 18126 "typography.textIndent", 18127 "typography.textTransform", 18128 "typography.writingMode", 18129 "viewport.mobile", 18130 "viewport.tablet" 18131 ]; 18132 function getSetting(globalStyles, path, blockName) { 18133 const appendedBlockPath = blockName ? ".blocks." + blockName : ""; 18134 const appendedPropertyPath = path ? "." + path : ""; 18135 const contextualPath = `settings$appendedBlockPath}$appendedPropertyPath}`; 18136 const globalPath = `settings$appendedPropertyPath}`; 18137 if (path) { 18138 return getValueFromObjectPath(globalStyles, contextualPath) ?? getValueFromObjectPath(globalStyles, globalPath); 18139 } 18140 let result = {}; 18141 VALID_SETTINGS.forEach((setting) => { 18142 const value = getValueFromObjectPath( 18143 globalStyles, 18144 `settings$appendedBlockPath}.$setting}` 18145 ) ?? getValueFromObjectPath(globalStyles, `settings.$setting}`); 18146 if (value !== void 0) { 18147 result = setImmutably(result, setting.split("."), value); 18148 } 18149 }); 18150 return result; 18151 } 18152 18153 // packages/global-styles-engine/build-module/settings/set-setting.mjs 18154 function setSetting(globalStyles, path, newValue, blockName) { 18155 const appendedBlockPath = blockName ? ".blocks." + blockName : ""; 18156 const appendedPropertyPath = path ? "." + path : ""; 18157 const finalPath = `settings$appendedBlockPath}$appendedPropertyPath}`; 18158 return setImmutably( 18159 globalStyles, 18160 finalPath.split("."), 18161 newValue 18162 ); 18163 } 18164 18165 // packages/global-styles-engine/build-module/utils/common.mjs 18166 var import_style_engine = __toESM(require_style_engine(), 1); 18167 18168 // packages/global-styles-engine/build-module/utils/fluid.mjs 18169 var DEFAULT_MAXIMUM_VIEWPORT_WIDTH = "1600px"; 18170 var DEFAULT_MINIMUM_VIEWPORT_WIDTH = "320px"; 18171 var DEFAULT_SCALE_FACTOR = 1; 18172 var DEFAULT_MINIMUM_FONT_SIZE_FACTOR_MIN = 0.25; 18173 var DEFAULT_MINIMUM_FONT_SIZE_FACTOR_MAX = 0.75; 18174 var DEFAULT_MINIMUM_FONT_SIZE_LIMIT = "14px"; 18175 function getComputedFluidTypographyValue({ 18176 minimumFontSize, 18177 maximumFontSize, 18178 fontSize, 18179 minimumViewportWidth = DEFAULT_MINIMUM_VIEWPORT_WIDTH, 18180 maximumViewportWidth = DEFAULT_MAXIMUM_VIEWPORT_WIDTH, 18181 scaleFactor = DEFAULT_SCALE_FACTOR, 18182 minimumFontSizeLimit 18183 }) { 18184 minimumFontSizeLimit = !!getTypographyValueAndUnit(minimumFontSizeLimit) ? minimumFontSizeLimit : DEFAULT_MINIMUM_FONT_SIZE_LIMIT; 18185 if (fontSize) { 18186 const fontSizeParsed = getTypographyValueAndUnit(fontSize); 18187 if (!fontSizeParsed?.unit || !fontSizeParsed?.value) { 18188 return null; 18189 } 18190 const minimumFontSizeLimitParsed = getTypographyValueAndUnit( 18191 minimumFontSizeLimit, 18192 { 18193 coerceTo: fontSizeParsed.unit 18194 } 18195 ); 18196 if (!!minimumFontSizeLimitParsed?.value && !minimumFontSize && !maximumFontSize) { 18197 if (fontSizeParsed?.value <= minimumFontSizeLimitParsed?.value) { 18198 return null; 18199 } 18200 } 18201 if (!maximumFontSize) { 18202 maximumFontSize = `$fontSizeParsed.value}$fontSizeParsed.unit}`; 18203 } 18204 if (!minimumFontSize) { 18205 const fontSizeValueInPx = fontSizeParsed.unit === "px" ? fontSizeParsed.value : fontSizeParsed.value * 16; 18206 const minimumFontSizeFactor = Math.min( 18207 Math.max( 18208 1 - 0.075 * Math.log2(fontSizeValueInPx), 18209 DEFAULT_MINIMUM_FONT_SIZE_FACTOR_MIN 18210 ), 18211 DEFAULT_MINIMUM_FONT_SIZE_FACTOR_MAX 18212 ); 18213 const calculatedMinimumFontSize = roundToPrecision( 18214 fontSizeParsed.value * minimumFontSizeFactor, 18215 3 18216 ); 18217 if (!!minimumFontSizeLimitParsed?.value && calculatedMinimumFontSize < minimumFontSizeLimitParsed?.value) { 18218 minimumFontSize = `$minimumFontSizeLimitParsed.value}$minimumFontSizeLimitParsed.unit}`; 18219 } else { 18220 minimumFontSize = `$calculatedMinimumFontSize}$fontSizeParsed.unit}`; 18221 } 18222 } 18223 } 18224 const minimumFontSizeParsed = getTypographyValueAndUnit(minimumFontSize); 18225 const fontSizeUnit = minimumFontSizeParsed?.unit || "rem"; 18226 const maximumFontSizeParsed = getTypographyValueAndUnit(maximumFontSize, { 18227 coerceTo: fontSizeUnit 18228 }); 18229 if (!minimumFontSizeParsed || !maximumFontSizeParsed) { 18230 return null; 18231 } 18232 const minimumFontSizeRem = getTypographyValueAndUnit(minimumFontSize, { 18233 coerceTo: "rem" 18234 }); 18235 const maximumViewportWidthParsed = getTypographyValueAndUnit( 18236 maximumViewportWidth, 18237 { coerceTo: fontSizeUnit } 18238 ); 18239 const minimumViewportWidthParsed = getTypographyValueAndUnit( 18240 minimumViewportWidth, 18241 { coerceTo: fontSizeUnit } 18242 ); 18243 if (!maximumViewportWidthParsed || !minimumViewportWidthParsed || !minimumFontSizeRem) { 18244 return null; 18245 } 18246 const linearDenominator = maximumViewportWidthParsed.value - minimumViewportWidthParsed.value; 18247 if (!linearDenominator) { 18248 return null; 18249 } 18250 const minViewportWidthOffsetValue = roundToPrecision( 18251 minimumViewportWidthParsed.value / 100, 18252 3 18253 ); 18254 const viewportWidthOffset = roundToPrecision(minViewportWidthOffsetValue, 3) + fontSizeUnit; 18255 const linearFactor = 100 * ((maximumFontSizeParsed.value - minimumFontSizeParsed.value) / linearDenominator); 18256 const linearFactorScaled = roundToPrecision( 18257 (linearFactor || 1) * scaleFactor, 18258 3 18259 ); 18260 const fluidTargetFontSize = `$minimumFontSizeRem.value}$minimumFontSizeRem.unit} + ((1vw - $viewportWidthOffset}) * $linearFactorScaled})`; 18261 return `clamp($minimumFontSize}, $fluidTargetFontSize}, $maximumFontSize})`; 18262 } 18263 function getTypographyValueAndUnit(rawValue, options = {}) { 18264 if (typeof rawValue !== "string" && typeof rawValue !== "number") { 18265 return null; 18266 } 18267 if (isFinite(rawValue)) { 18268 rawValue = `$rawValue}px`; 18269 } 18270 const { coerceTo, rootSizeValue, acceptableUnits } = { 18271 coerceTo: "", 18272 // Default browser font size. Later we could inject some JS to compute this `getComputedStyle( document.querySelector( "html" ) ).fontSize`. 18273 rootSizeValue: 16, 18274 acceptableUnits: ["rem", "px", "em"], 18275 ...options 18276 }; 18277 const acceptableUnitsGroup = acceptableUnits?.join("|"); 18278 const regexUnits = new RegExp( 18279 `^(\\d*\\.?\\d+)($acceptableUnitsGroup}){1,1}$` 18280 ); 18281 const matches = rawValue.toString().match(regexUnits); 18282 if (!matches || matches.length < 3) { 18283 return null; 18284 } 18285 let [, value, unit] = matches; 18286 let returnValue = parseFloat(value); 18287 if ("px" === coerceTo && ("em" === unit || "rem" === unit)) { 18288 returnValue = returnValue * rootSizeValue; 18289 unit = coerceTo; 18290 } 18291 if ("px" === unit && ("em" === coerceTo || "rem" === coerceTo)) { 18292 returnValue = returnValue / rootSizeValue; 18293 unit = coerceTo; 18294 } 18295 if (("em" === coerceTo || "rem" === coerceTo) && ("em" === unit || "rem" === unit)) { 18296 unit = coerceTo; 18297 } 18298 if (!unit) { 18299 return null; 18300 } 18301 return { 18302 value: roundToPrecision(returnValue, 3), 18303 unit 18304 }; 18305 } 18306 function roundToPrecision(value, digits = 3) { 18307 const base = Math.pow(10, digits); 18308 return Math.round(value * base) / base; 18309 } 18310 18311 // packages/global-styles-engine/build-module/utils/typography.mjs 18312 function isFluidTypographyEnabled(typographySettings) { 18313 const fluidSettings = typographySettings?.fluid; 18314 return true === fluidSettings || fluidSettings && typeof fluidSettings === "object" && Object.keys(fluidSettings).length > 0; 18315 } 18316 function getFluidTypographyOptionsFromSettings(settings2) { 18317 const typographySettings = settings2?.typography ?? {}; 18318 const layoutSettings = settings2?.layout; 18319 const defaultMaxViewportWidth = getTypographyValueAndUnit( 18320 layoutSettings?.wideSize 18321 ) ? layoutSettings?.wideSize : null; 18322 return isFluidTypographyEnabled(typographySettings) && defaultMaxViewportWidth ? { 18323 fluid: { 18324 maxViewportWidth: defaultMaxViewportWidth, 18325 ...typeof typographySettings.fluid === "object" ? typographySettings.fluid : {} 18326 } 18327 } : { 18328 fluid: typographySettings?.fluid 18329 }; 18330 } 18331 function getTypographyFontSizeValue(preset, settings2) { 18332 const { size: defaultSize } = preset; 18333 if (!defaultSize || "0" === defaultSize || false === preset?.fluid) { 18334 return defaultSize; 18335 } 18336 if (!isFluidTypographyEnabled(settings2?.typography) && !isFluidTypographyEnabled(preset)) { 18337 return defaultSize; 18338 } 18339 const fluidTypographySettings = getFluidTypographyOptionsFromSettings(settings2)?.fluid ?? {}; 18340 const fluidFontSizeValue = getComputedFluidTypographyValue({ 18341 minimumFontSize: typeof preset?.fluid === "boolean" ? void 0 : preset?.fluid?.min, 18342 maximumFontSize: typeof preset?.fluid === "boolean" ? void 0 : preset?.fluid?.max, 18343 fontSize: defaultSize, 18344 minimumFontSizeLimit: typeof fluidTypographySettings === "object" ? fluidTypographySettings?.minFontSize : void 0, 18345 maximumViewportWidth: typeof fluidTypographySettings === "object" ? fluidTypographySettings?.maxViewportWidth : void 0, 18346 minimumViewportWidth: typeof fluidTypographySettings === "object" ? fluidTypographySettings?.minViewportWidth : void 0 18347 }); 18348 if (!!fluidFontSizeValue) { 18349 return fluidFontSizeValue; 18350 } 18351 return defaultSize; 18352 } 18353 18354 // packages/global-styles-engine/build-module/utils/common.mjs 18355 var ROOT_BLOCK_SELECTOR = "body"; 18356 var ROOT_CSS_PROPERTIES_SELECTOR = ":root"; 18357 function splitSelectorList(selector2) { 18358 if (!selector2.includes(",")) { 18359 return [selector2]; 18360 } 18361 const selectors3 = []; 18362 let currentSelector = ""; 18363 let parenthesesDepth = 0; 18364 for (const char of selector2) { 18365 if (char === "(") { 18366 parenthesesDepth++; 18367 } else if (char === ")" && parenthesesDepth > 0) { 18368 parenthesesDepth--; 18369 } else if (char === "," && parenthesesDepth === 0) { 18370 selectors3.push(currentSelector); 18371 currentSelector = ""; 18372 continue; 18373 } 18374 currentSelector += char; 18375 } 18376 selectors3.push(currentSelector); 18377 return selectors3; 18378 } 18379 var PRESET_METADATA = [ 18380 { 18381 path: ["color", "palette"], 18382 valueKey: "color", 18383 cssVarInfix: "color", 18384 classes: [ 18385 { classSuffix: "color", propertyName: "color" }, 18386 { 18387 classSuffix: "background-color", 18388 propertyName: "background-color" 18389 }, 18390 { 18391 classSuffix: "border-color", 18392 propertyName: "border-color" 18393 } 18394 ] 18395 }, 18396 { 18397 path: ["color", "gradients"], 18398 valueKey: "gradient", 18399 cssVarInfix: "gradient", 18400 classes: [ 18401 { 18402 classSuffix: "gradient-background", 18403 propertyName: "background" 18404 } 18405 ] 18406 }, 18407 { 18408 path: ["color", "duotone"], 18409 valueKey: "colors", 18410 cssVarInfix: "duotone", 18411 valueFunc: ({ slug }) => `url( '#wp-duotone-$slug}' )`, 18412 classes: [] 18413 }, 18414 { 18415 path: ["shadow", "presets"], 18416 valueKey: "shadow", 18417 cssVarInfix: "shadow", 18418 classes: [] 18419 }, 18420 { 18421 path: ["typography", "fontSizes"], 18422 valueFunc: (preset, settings2) => getTypographyFontSizeValue(preset, settings2), 18423 valueKey: "size", 18424 cssVarInfix: "font-size", 18425 classes: [{ classSuffix: "font-size", propertyName: "font-size" }] 18426 }, 18427 { 18428 path: ["typography", "fontFamilies"], 18429 valueKey: "fontFamily", 18430 cssVarInfix: "font-family", 18431 classes: [ 18432 { classSuffix: "font-family", propertyName: "font-family" } 18433 ] 18434 }, 18435 { 18436 path: ["spacing", "spacingSizes"], 18437 valueKey: "size", 18438 cssVarInfix: "spacing", 18439 valueFunc: ({ size: size4 }) => size4, 18440 classes: [] 18441 }, 18442 { 18443 path: ["border", "radiusSizes"], 18444 valueKey: "size", 18445 cssVarInfix: "border-radius", 18446 classes: [] 18447 }, 18448 { 18449 path: ["dimensions", "dimensionSizes"], 18450 valueKey: "size", 18451 cssVarInfix: "dimension", 18452 classes: [] 18453 } 18454 ]; 18455 function scopeSelector(scope, selector2) { 18456 if (!scope || !selector2) { 18457 return selector2; 18458 } 18459 const scopes = splitSelectorList(scope); 18460 const selectors3 = splitSelectorList(selector2); 18461 const selectorsScoped = []; 18462 scopes.forEach((outer) => { 18463 selectors3.forEach((inner) => { 18464 selectorsScoped.push(`$outer.trim()} $inner.trim()}`); 18465 }); 18466 }); 18467 return selectorsScoped.join(", "); 18468 } 18469 function scopeFeatureSelectors(scope, selectors3) { 18470 if (!scope || !selectors3) { 18471 return; 18472 } 18473 const featureSelectors = {}; 18474 Object.entries(selectors3).forEach(([feature, selector2]) => { 18475 if (typeof selector2 === "string") { 18476 featureSelectors[feature] = scopeSelector(scope, selector2); 18477 } 18478 if (typeof selector2 === "object") { 18479 featureSelectors[feature] = {}; 18480 Object.entries(selector2).forEach( 18481 ([subfeature, subfeatureSelector]) => { 18482 featureSelectors[feature][subfeature] = scopeSelector( 18483 scope, 18484 subfeatureSelector 18485 ); 18486 } 18487 ); 18488 } 18489 }); 18490 return featureSelectors; 18491 } 18492 function appendToSelector(selector2, toAppend) { 18493 if (!selector2.includes(",")) { 18494 return selector2 + toAppend; 18495 } 18496 const selectors3 = splitSelectorList(selector2); 18497 const newSelectors = selectors3.map((sel) => sel + toAppend); 18498 return newSelectors.join(","); 18499 } 18500 function getBlockStyleVariationSelector(variation, blockSelector) { 18501 const variationClass = `.is-style-$variation}`; 18502 if (!blockSelector) { 18503 return variationClass; 18504 } 18505 const ancestorRegex = /[^\s:]+/; 18506 const addVariationClass = (match3) => match3 + variationClass; 18507 const result = splitSelectorList(blockSelector).map( 18508 (part) => part.replace(ancestorRegex, addVariationClass) 18509 ); 18510 return result.join(","); 18511 } 18512 function getBlockStyleVariationFeatureSelector(variation, featureSelector) { 18513 const variationClass = `.is-style-$variation}`; 18514 const selectorParts = splitSelectorList(featureSelector).map( 18515 (selector2) => { 18516 const trimmedSelector = selector2.trim(); 18517 const prefix2 = `$variationClass} `; 18518 if (trimmedSelector.startsWith(prefix2)) { 18519 return trimmedSelector.slice(prefix2.length); 18520 } 18521 return trimmedSelector; 18522 } 18523 ); 18524 return getBlockStyleVariationSelector( 18525 variation, 18526 selectorParts.join(",") 18527 ); 18528 } 18529 function getResolvedRefValue(ruleValue, tree) { 18530 if (!ruleValue || !tree) { 18531 return ruleValue; 18532 } 18533 if (typeof ruleValue === "object" && "ref" in ruleValue && ruleValue?.ref) { 18534 const resolvedRuleValue = (0, import_style_engine.getCSSValueFromRawStyle)( 18535 getValueFromObjectPath(tree, ruleValue.ref) 18536 ); 18537 if (typeof resolvedRuleValue === "object" && resolvedRuleValue !== null && "ref" in resolvedRuleValue && resolvedRuleValue?.ref) { 18538 return void 0; 18539 } 18540 if (resolvedRuleValue === void 0) { 18541 return ruleValue; 18542 } 18543 return resolvedRuleValue; 18544 } 18545 return ruleValue; 18546 } 18547 function getResolvedThemeFilePath(file, themeFileURIs) { 18548 if (!file || !themeFileURIs || !Array.isArray(themeFileURIs)) { 18549 return file; 18550 } 18551 const uri = themeFileURIs.find( 18552 (themeFileUri) => themeFileUri?.name === file 18553 ); 18554 if (!uri?.href) { 18555 return file; 18556 } 18557 return uri?.href; 18558 } 18559 function getResolvedValue(ruleValue, tree) { 18560 if (!ruleValue || !tree) { 18561 return ruleValue; 18562 } 18563 const resolvedValue = getResolvedRefValue(ruleValue, tree); 18564 if (typeof resolvedValue === "object" && resolvedValue !== null && "url" in resolvedValue && resolvedValue?.url) { 18565 resolvedValue.url = getResolvedThemeFilePath( 18566 resolvedValue.url, 18567 tree?._links?.["wp:theme-file"] 18568 ); 18569 } 18570 return resolvedValue; 18571 } 18572 function findInPresetsBy(settings2, blockName, presetPath = [], presetProperty = "slug", presetValueValue) { 18573 const orderedPresetsByOrigin = [ 18574 blockName ? getValueFromObjectPath(settings2, [ 18575 "blocks", 18576 blockName, 18577 ...presetPath 18578 ]) : void 0, 18579 getValueFromObjectPath(settings2, presetPath) 18580 ].filter(Boolean); 18581 for (const presetByOrigin of orderedPresetsByOrigin) { 18582 if (presetByOrigin) { 18583 const origins = ["custom", "theme", "default"]; 18584 for (const origin of origins) { 18585 const presets = presetByOrigin[origin]; 18586 if (presets) { 18587 const presetObject = presets.find( 18588 (preset) => preset[presetProperty] === presetValueValue 18589 ); 18590 if (presetObject) { 18591 if (presetProperty === "slug") { 18592 return presetObject; 18593 } 18594 const highestPresetObjectWithSameSlug = findInPresetsBy( 18595 settings2, 18596 blockName, 18597 presetPath, 18598 "slug", 18599 presetObject.slug 18600 ); 18601 if (highestPresetObjectWithSameSlug[presetProperty] === presetObject[presetProperty]) { 18602 return presetObject; 18603 } 18604 return void 0; 18605 } 18606 } 18607 } 18608 } 18609 } 18610 } 18611 function getValueFromPresetVariable(features, blockName, variable, [presetType, slug] = []) { 18612 const metadata = PRESET_METADATA.find( 18613 (data) => data.cssVarInfix === presetType 18614 ); 18615 if (!metadata || !features.settings) { 18616 return variable; 18617 } 18618 const presetObject = findInPresetsBy( 18619 features.settings, 18620 blockName, 18621 metadata.path, 18622 "slug", 18623 slug 18624 ); 18625 if (presetObject) { 18626 const { valueKey } = metadata; 18627 const result = presetObject[valueKey]; 18628 return getValueFromVariable(features, blockName, result); 18629 } 18630 return variable; 18631 } 18632 function getValueFromCustomVariable(features, blockName, variable, path = []) { 18633 const result = (blockName ? getValueFromObjectPath(features?.settings ?? {}, [ 18634 "blocks", 18635 blockName, 18636 "custom", 18637 ...path 18638 ]) : void 0) ?? getValueFromObjectPath(features?.settings ?? {}, [ 18639 "custom", 18640 ...path 18641 ]); 18642 if (!result) { 18643 return variable; 18644 } 18645 return getValueFromVariable(features, blockName, result); 18646 } 18647 function getValueFromVariable(features, blockName, variable) { 18648 if (!variable || typeof variable !== "string") { 18649 if (typeof variable === "object" && variable !== null && "ref" in variable && typeof variable.ref === "string") { 18650 const resolvedVariable = getValueFromObjectPath( 18651 features, 18652 variable.ref 18653 ); 18654 if (!resolvedVariable || typeof resolvedVariable === "object" && "ref" in resolvedVariable) { 18655 return resolvedVariable; 18656 } 18657 variable = resolvedVariable; 18658 } else { 18659 return variable; 18660 } 18661 } 18662 const USER_VALUE_PREFIX = "var:"; 18663 const THEME_VALUE_PREFIX = "var(--wp--"; 18664 const THEME_VALUE_SUFFIX = ")"; 18665 let parsedVar; 18666 if (variable.startsWith(USER_VALUE_PREFIX)) { 18667 parsedVar = variable.slice(USER_VALUE_PREFIX.length).split("|"); 18668 } else if (variable.startsWith(THEME_VALUE_PREFIX) && variable.endsWith(THEME_VALUE_SUFFIX)) { 18669 parsedVar = variable.slice(THEME_VALUE_PREFIX.length, -THEME_VALUE_SUFFIX.length).split("--"); 18670 } else { 18671 return variable; 18672 } 18673 const [type, ...path] = parsedVar; 18674 if (type === "preset") { 18675 return getValueFromPresetVariable( 18676 features, 18677 blockName, 18678 variable, 18679 path 18680 ); 18681 } 18682 if (type === "custom") { 18683 return getValueFromCustomVariable( 18684 features, 18685 blockName, 18686 variable, 18687 path 18688 ); 18689 } 18690 return variable; 18691 } 18692 18693 // packages/global-styles-engine/build-module/style-state-back-compat.mjs 18694 var LEGACY_STYLE_STATE_ALIASES = { 18695 "@mobile": "mobile", 18696 "@tablet": "tablet", 18697 "-current": "@current" 18698 }; 18699 function isObjectRecord(value) { 18700 return !!value && typeof value === "object" && !Array.isArray(value); 18701 } 18702 function normalizeStyleStateNode(node) { 18703 if (!isObjectRecord(node)) { 18704 return node; 18705 } 18706 let normalized = node; 18707 Object.entries(LEGACY_STYLE_STATE_ALIASES).forEach( 18708 ([state, legacyState]) => { 18709 if (Object.hasOwn(node, legacyState)) { 18710 if (normalized === node) { 18711 normalized = { ...node }; 18712 } 18713 if (!Object.hasOwn(node, state)) { 18714 normalized[state] = node[legacyState]; 18715 } 18716 delete normalized[legacyState]; 18717 } 18718 } 18719 ); 18720 Object.entries(normalized).forEach(([key, value]) => { 18721 if (!isObjectRecord(value)) { 18722 return; 18723 } 18724 const normalizedValue = normalizeStyleStateNode(value); 18725 if (normalizedValue !== value) { 18726 if (normalized === node) { 18727 normalized = { ...node }; 18728 } 18729 normalized[key] = normalizedValue; 18730 } 18731 }); 18732 return normalized; 18733 } 18734 function normalizeStyleStateAliases(globalStyles) { 18735 if (true) { 18736 return globalStyles; 18737 } 18738 if (!globalStyles?.styles) { 18739 return globalStyles; 18740 } 18741 const styles = normalizeStyleStateNode(globalStyles.styles); 18742 return styles === globalStyles.styles ? globalStyles : { ...globalStyles, styles }; 18743 } 18744 function getLegacyStyleStatePath(path) { 18745 if (true) { 18746 return void 0; 18747 } 18748 const pathParts = path.split("."); 18749 const legacyPathParts = pathParts.map( 18750 (part) => LEGACY_STYLE_STATE_ALIASES[part] ?? part 18751 ); 18752 return legacyPathParts.some( 18753 (part, index2) => part !== pathParts[index2] 18754 ) ? legacyPathParts.join(".") : void 0; 18755 } 18756 18757 // packages/global-styles-engine/build-module/settings/get-style.mjs 18758 function getStyle(globalStyles, path, blockName, shouldDecodeEncode = true) { 18759 const appendedPath = path ? "." + path : ""; 18760 const finalPath = !blockName ? `styles$appendedPath}` : `styles.blocks.$blockName}$appendedPath}`; 18761 if (!globalStyles) { 18762 return void 0; 18763 } 18764 let rawResult = getValueFromObjectPath(globalStyles, finalPath); 18765 const legacyPath = getLegacyStyleStatePath(finalPath); 18766 if (rawResult === void 0 && legacyPath) { 18767 let hasCanonicalPath = true; 18768 let currentValue = globalStyles; 18769 for (const pathPart of finalPath.split(".")) { 18770 if (!currentValue || typeof currentValue !== "object" || !Object.hasOwn(currentValue, pathPart)) { 18771 hasCanonicalPath = false; 18772 break; 18773 } 18774 currentValue = currentValue[pathPart]; 18775 } 18776 if (!hasCanonicalPath) { 18777 rawResult = getValueFromObjectPath(globalStyles, legacyPath); 18778 } 18779 } 18780 const result = shouldDecodeEncode ? getValueFromVariable(globalStyles, blockName, rawResult) : rawResult; 18781 return result; 18782 } 18783 18784 // packages/global-styles-engine/build-module/settings/set-style.mjs 18785 function setStyle(globalStyles, path, newValue, blockName) { 18786 const appendedPath = path ? "." + path : ""; 18787 const finalPath = !blockName ? `styles$appendedPath}` : `styles.blocks.$blockName}$appendedPath}`; 18788 return setImmutably( 18789 normalizeStyleStateAliases(globalStyles), 18790 finalPath.split("."), 18791 newValue 18792 ); 18793 } 18794 18795 // packages/global-styles-engine/build-module/core/equal.mjs 18796 var import_es6 = __toESM(require_es6(), 1); 18797 function areGlobalStylesEqual(original, variation) { 18798 if (typeof original !== "object" || typeof variation !== "object") { 18799 return original === variation; 18800 } 18801 return (0, import_es6.default)(original?.styles, variation?.styles) && (0, import_es6.default)(original?.settings, variation?.settings); 18802 } 18803 18804 // packages/global-styles-engine/build-module/core/merge.mjs 18805 var import_deepmerge = __toESM(require_cjs(), 1); 18806 18807 // node_modules/is-plain-object/dist/is-plain-object.mjs 18808 function isObject(o3) { 18809 return Object.prototype.toString.call(o3) === "[object Object]"; 18810 } 18811 function isPlainObject(o3) { 18812 var ctor, prot; 18813 if (isObject(o3) === false) return false; 18814 ctor = o3.constructor; 18815 if (ctor === void 0) return true; 18816 prot = ctor.prototype; 18817 if (isObject(prot) === false) return false; 18818 if (prot.hasOwnProperty("isPrototypeOf") === false) { 18819 return false; 18820 } 18821 return true; 18822 } 18823 18824 // packages/global-styles-engine/build-module/core/merge.mjs 18825 function mergeGlobalStyles(base, user) { 18826 return (0, import_deepmerge.default)( 18827 normalizeStyleStateAliases(base), 18828 normalizeStyleStateAliases(user), 18829 { 18830 /* 18831 * We only pass as arrays the presets, 18832 * in which case we want the new array of values 18833 * to override the old array (no merging). 18834 */ 18835 isMergeableObject: isPlainObject, 18836 /* 18837 * Exceptions to the above rule. 18838 * Background images should be replaced, not merged, 18839 * as they themselves are specific object definitions for the style. 18840 */ 18841 customMerge: (key) => { 18842 if (key === "backgroundImage") { 18843 return (baseConfig, userConfig) => userConfig ?? baseConfig; 18844 } 18845 return void 0; 18846 } 18847 } 18848 ); 18849 } 18850 18851 // packages/global-styles-engine/build-module/core/render.mjs 18852 var import_blocks3 = __toESM(require_blocks(), 1); 18853 var import_style_engine2 = __toESM(require_style_engine(), 1); 18854 var import_data21 = __toESM(require_data(), 1); 18855 18856 // packages/global-styles-engine/build-module/core/selectors.mjs 18857 function getBlockSelector(blockType, target = "root", options = {}) { 18858 if (!target) { 18859 return null; 18860 } 18861 const { fallback = false } = options; 18862 const { name: name2, selectors: selectors3, supports } = blockType; 18863 const hasSelectors = selectors3 && Object.keys(selectors3).length > 0; 18864 const path = Array.isArray(target) ? target.join(".") : target; 18865 let rootSelector = null; 18866 if (hasSelectors && selectors3.root) { 18867 rootSelector = selectors3?.root; 18868 } else if (supports?.__experimentalSelector) { 18869 rootSelector = supports.__experimentalSelector; 18870 } else { 18871 rootSelector = ".wp-block-" + name2.replace("core/", "").replace("/", "-"); 18872 } 18873 if (path === "root") { 18874 return rootSelector; 18875 } 18876 const pathArray = Array.isArray(target) ? target : target.split("."); 18877 if (pathArray.length === 1) { 18878 const fallbackSelector = fallback ? rootSelector : null; 18879 if (hasSelectors) { 18880 const featureSelector2 = getValueFromObjectPath( 18881 selectors3, 18882 `$path}.root`, 18883 null 18884 ) || getValueFromObjectPath(selectors3, path, null); 18885 return featureSelector2 || fallbackSelector; 18886 } 18887 const featureSelector = supports ? getValueFromObjectPath( 18888 supports, 18889 `$path}.__experimentalSelector`, 18890 null 18891 ) : void 0; 18892 if (!featureSelector) { 18893 return fallbackSelector; 18894 } 18895 return scopeSelector(rootSelector, featureSelector); 18896 } 18897 let subfeatureSelector; 18898 if (hasSelectors) { 18899 subfeatureSelector = getValueFromObjectPath(selectors3, path, null); 18900 } 18901 if (subfeatureSelector) { 18902 return subfeatureSelector; 18903 } 18904 if (fallback) { 18905 return getBlockSelector(blockType, pathArray[0], options); 18906 } 18907 return null; 18908 } 18909 18910 // node_modules/colord/index.mjs 18911 var r2 = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }; 18912 var t = function(r3) { 18913 return "string" == typeof r3 ? r3.length > 0 : "number" == typeof r3; 18914 }; 18915 var n = function(r3, t3, n2) { 18916 return void 0 === t3 && (t3 = 0), void 0 === n2 && (n2 = Math.pow(10, t3)), Math.round(n2 * r3) / n2 + 0; 18917 }; 18918 var e = function(r3, t3, n2) { 18919 return void 0 === t3 && (t3 = 0), void 0 === n2 && (n2 = 1), r3 > n2 ? n2 : r3 > t3 ? r3 : t3; 18920 }; 18921 var u = function(r3) { 18922 return (r3 = isFinite(r3) ? r3 % 360 : 0) > 0 ? r3 : r3 + 360; 18923 }; 18924 var a = function(r3) { 18925 return { r: e(r3.r, 0, 255), g: e(r3.g, 0, 255), b: e(r3.b, 0, 255), a: e(r3.a) }; 18926 }; 18927 var o = function(r3) { 18928 return { r: n(r3.r), g: n(r3.g), b: n(r3.b), a: n(r3.a, 3) }; 18929 }; 18930 var i = /^#([0-9a-f]{3,8})$/i; 18931 var s = function(r3) { 18932 var t3 = r3.toString(16); 18933 return t3.length < 2 ? "0" + t3 : t3; 18934 }; 18935 var h = function(r3) { 18936 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; 18937 return { h: 60 * (i2 < 0 ? i2 + 6 : i2), s: a2 ? o3 / a2 * 100 : 0, v: a2 / 255 * 100, a: u2 }; 18938 }; 18939 var b = function(r3) { 18940 var t3 = r3.h, n2 = r3.s, e2 = r3.v, u2 = r3.a; 18941 t3 = t3 / 360 * 6, n2 /= 100, e2 /= 100; 18942 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; 18943 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 }; 18944 }; 18945 var g = function(r3) { 18946 return { h: u(r3.h), s: e(r3.s, 0, 100), l: e(r3.l, 0, 100), a: e(r3.a) }; 18947 }; 18948 var d = function(r3) { 18949 return { h: n(r3.h), s: n(r3.s), l: n(r3.l), a: n(r3.a, 3) }; 18950 }; 18951 var f = function(r3) { 18952 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 })); 18953 var t3, n2, e2; 18954 }; 18955 var c = function(r3) { 18956 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 }; 18957 var t3, n2, e2, u2; 18958 }; 18959 var l = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i; 18960 var p2 = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i; 18961 var v = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i; 18962 var m = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i; 18963 var y = { string: [[function(r3) { 18964 var t3 = i.exec(r3); 18965 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; 18966 }, "hex"], [function(r3) { 18967 var t3 = v.exec(r3) || m.exec(r3); 18968 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; 18969 }, "rgb"], [function(t3) { 18970 var n2 = l.exec(t3) || p2.exec(t3); 18971 if (!n2) return null; 18972 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) }); 18973 return f(a2); 18974 }, "hsl"]], object: [[function(r3) { 18975 var n2 = r3.r, e2 = r3.g, u2 = r3.b, o3 = r3.a, i2 = void 0 === o3 ? 1 : o3; 18976 return t(n2) && t(e2) && t(u2) ? a({ r: Number(n2), g: Number(e2), b: Number(u2), a: Number(i2) }) : null; 18977 }, "rgb"], [function(r3) { 18978 var n2 = r3.h, e2 = r3.s, u2 = r3.l, a2 = r3.a, o3 = void 0 === a2 ? 1 : a2; 18979 if (!t(n2) || !t(e2) || !t(u2)) return null; 18980 var i2 = g({ h: Number(n2), s: Number(e2), l: Number(u2), a: Number(o3) }); 18981 return f(i2); 18982 }, "hsl"], [function(r3) { 18983 var n2 = r3.h, a2 = r3.s, o3 = r3.v, i2 = r3.a, s2 = void 0 === i2 ? 1 : i2; 18984 if (!t(n2) || !t(a2) || !t(o3)) return null; 18985 var h2 = (function(r4) { 18986 return { h: u(r4.h), s: e(r4.s, 0, 100), v: e(r4.v, 0, 100), a: e(r4.a) }; 18987 })({ h: Number(n2), s: Number(a2), v: Number(o3), a: Number(s2) }); 18988 return b(h2); 18989 }, "hsv"]] }; 18990 var N = function(r3, t3) { 18991 for (var n2 = 0; n2 < t3.length; n2++) { 18992 var e2 = t3[n2][0](r3); 18993 if (e2) return [e2, t3[n2][1]]; 18994 } 18995 return [null, void 0]; 18996 }; 18997 var x = function(r3) { 18998 return "string" == typeof r3 ? N(r3.trim(), y.string) : "object" == typeof r3 && null !== r3 ? N(r3, y.object) : [null, void 0]; 18999 }; 19000 var M = function(r3, t3) { 19001 var n2 = c(r3); 19002 return { h: n2.h, s: e(n2.s + 100 * t3, 0, 100), l: n2.l, a: n2.a }; 19003 }; 19004 var H = function(r3) { 19005 return (299 * r3.r + 587 * r3.g + 114 * r3.b) / 1e3 / 255; 19006 }; 19007 var $ = function(r3, t3) { 19008 var n2 = c(r3); 19009 return { h: n2.h, s: n2.s, l: e(n2.l + 100 * t3, 0, 100), a: n2.a }; 19010 }; 19011 var j = (function() { 19012 function r3(r4) { 19013 this.parsed = x(r4)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 }; 19014 } 19015 return r3.prototype.isValid = function() { 19016 return null !== this.parsed; 19017 }, r3.prototype.brightness = function() { 19018 return n(H(this.rgba), 2); 19019 }, r3.prototype.isDark = function() { 19020 return H(this.rgba) < 0.5; 19021 }, r3.prototype.isLight = function() { 19022 return H(this.rgba) >= 0.5; 19023 }, r3.prototype.toHex = function() { 19024 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; 19025 var r4, t3, e2, u2, a2, i2; 19026 }, r3.prototype.toRgb = function() { 19027 return o(this.rgba); 19028 }, r3.prototype.toRgbString = function() { 19029 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 + ")"; 19030 var r4, t3, n2, e2, u2; 19031 }, r3.prototype.toHsl = function() { 19032 return d(c(this.rgba)); 19033 }, r3.prototype.toHslString = function() { 19034 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 + "%)"; 19035 var r4, t3, n2, e2, u2; 19036 }, r3.prototype.toHsv = function() { 19037 return r4 = h(this.rgba), { h: n(r4.h), s: n(r4.s), v: n(r4.v), a: n(r4.a, 3) }; 19038 var r4; 19039 }, r3.prototype.invert = function() { 19040 return w({ r: 255 - (r4 = this.rgba).r, g: 255 - r4.g, b: 255 - r4.b, a: r4.a }); 19041 var r4; 19042 }, r3.prototype.saturate = function(r4) { 19043 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, r4)); 19044 }, r3.prototype.desaturate = function(r4) { 19045 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, -r4)); 19046 }, r3.prototype.grayscale = function() { 19047 return w(M(this.rgba, -1)); 19048 }, r3.prototype.lighten = function(r4) { 19049 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, r4)); 19050 }, r3.prototype.darken = function(r4) { 19051 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, -r4)); 19052 }, r3.prototype.rotate = function(r4) { 19053 return void 0 === r4 && (r4 = 15), this.hue(this.hue() + r4); 19054 }, r3.prototype.alpha = function(r4) { 19055 return "number" == typeof r4 ? w({ r: (t3 = this.rgba).r, g: t3.g, b: t3.b, a: r4 }) : n(this.rgba.a, 3); 19056 var t3; 19057 }, r3.prototype.hue = function(r4) { 19058 var t3 = c(this.rgba); 19059 return "number" == typeof r4 ? w({ h: r4, s: t3.s, l: t3.l, a: t3.a }) : n(t3.h); 19060 }, r3.prototype.isEqual = function(r4) { 19061 return this.toHex() === w(r4).toHex(); 19062 }, r3; 19063 })(); 19064 var w = function(r3) { 19065 return r3 instanceof j ? r3 : new j(r3); 19066 }; 19067 var S = []; 19068 var k = function(r3) { 19069 r3.forEach(function(r4) { 19070 S.indexOf(r4) < 0 && (r4(j, y), S.push(r4)); 19071 }); 19072 }; 19073 19074 // packages/global-styles-engine/build-module/utils/duotone.mjs 19075 function getValuesFromColors(colors2 = []) { 19076 const values = { 19077 r: [], 19078 g: [], 19079 b: [], 19080 a: [] 19081 }; 19082 colors2.forEach((color) => { 19083 const rgbColor = w(color).toRgb(); 19084 values.r.push(rgbColor.r / 255); 19085 values.g.push(rgbColor.g / 255); 19086 values.b.push(rgbColor.b / 255); 19087 values.a.push(rgbColor.a); 19088 }); 19089 return values; 19090 } 19091 function getDuotoneFilter(id, colors2) { 19092 const values = getValuesFromColors(colors2); 19093 return ` 19094 <svg 19095 xmlns:xlink="http://www.w3.org/1999/xlink" 19096 viewBox="0 0 0 0" 19097 width="0" 19098 height="0" 19099 focusable="false" 19100 role="none" 19101 aria-hidden="true" 19102 style="visibility: hidden; position: absolute; left: -9999px; overflow: hidden;" 19103 > 19104 <defs> 19105 <filter id="$id}"> 19106 <!-- 19107 Use sRGB instead of linearRGB so transparency looks correct. 19108 Use perceptual brightness to convert to grayscale. 19109 --> 19110 <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> 19111 <!-- Use sRGB instead of linearRGB to be consistent with how CSS gradients work. --> 19112 <feComponentTransfer color-interpolation-filters="sRGB"> 19113 <feFuncR type="table" tableValues="$values.r.join(" ")}"></feFuncR> 19114 <feFuncG type="table" tableValues="$values.g.join(" ")}"></feFuncG> 19115 <feFuncB type="table" tableValues="$values.b.join(" ")}"></feFuncB> 19116 <feFuncA type="table" tableValues="$values.a.join(" ")}"></feFuncA> 19117 </feComponentTransfer> 19118 <!-- Re-mask the image with the original transparency since the feColorMatrix above loses that information. --> 19119 <feComposite in2="SourceGraphic" operator="in"></feComposite> 19120 </filter> 19121 </defs> 19122 </svg>`; 19123 } 19124 19125 // packages/global-styles-engine/build-module/utils/string.mjs 19126 function kebabCase(str) { 19127 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(); 19128 } 19129 19130 // packages/global-styles-engine/build-module/utils/spacing.mjs 19131 function getSpacingPresetCssVar(value) { 19132 if (!value) { 19133 return; 19134 } 19135 const slug = value.match(/var:preset\|spacing\|(.+)/); 19136 if (!slug) { 19137 return value; 19138 } 19139 return `var(--wp--preset--spacing--$slug[1]})`; 19140 } 19141 19142 // packages/global-styles-engine/build-module/utils/gap.mjs 19143 function getGapBoxControlValueFromStyle(blockGapValue) { 19144 if (!blockGapValue) { 19145 return null; 19146 } 19147 const isValueString = typeof blockGapValue === "string"; 19148 return { 19149 top: isValueString ? blockGapValue : blockGapValue?.top, 19150 left: isValueString ? blockGapValue : blockGapValue?.left 19151 }; 19152 } 19153 function getGapCSSValue(blockGapValue, defaultValue2 = "0") { 19154 const blockGapBoxControlValue = getGapBoxControlValueFromStyle(blockGapValue); 19155 if (!blockGapBoxControlValue) { 19156 return null; 19157 } 19158 const row = getSpacingPresetCssVar(blockGapBoxControlValue?.top) || defaultValue2; 19159 const column = getSpacingPresetCssVar(blockGapBoxControlValue?.left) || defaultValue2; 19160 return row === column ? row : `$row} $column}`; 19161 } 19162 19163 // packages/global-styles-engine/build-module/utils/background.mjs 19164 var BACKGROUND_BLOCK_DEFAULT_VALUES = { 19165 backgroundSize: "cover", 19166 backgroundPosition: "50% 50%" 19167 // used only when backgroundSize is 'contain'. 19168 }; 19169 function setBackgroundStyleDefaults(backgroundStyle) { 19170 if (!backgroundStyle || // @ts-expect-error 19171 !backgroundStyle?.backgroundImage?.url) { 19172 return; 19173 } 19174 let backgroundStylesWithDefaults; 19175 if (!backgroundStyle?.backgroundSize) { 19176 backgroundStylesWithDefaults = { 19177 backgroundSize: BACKGROUND_BLOCK_DEFAULT_VALUES.backgroundSize 19178 }; 19179 } 19180 if ("contain" === backgroundStyle?.backgroundSize && !backgroundStyle?.backgroundPosition) { 19181 backgroundStylesWithDefaults = { 19182 backgroundPosition: BACKGROUND_BLOCK_DEFAULT_VALUES.backgroundPosition 19183 }; 19184 } 19185 return backgroundStylesWithDefaults; 19186 } 19187 19188 // packages/global-styles-engine/build-module/utils/layout.mjs 19189 var LAYOUT_DEFINITIONS = { 19190 default: { 19191 name: "default", 19192 slug: "flow", 19193 className: "is-layout-flow", 19194 baseStyles: [ 19195 { 19196 selector: " > .alignleft", 19197 rules: { 19198 float: "left", 19199 "margin-inline-start": "0", 19200 "margin-inline-end": "2em" 19201 } 19202 }, 19203 { 19204 selector: " > .alignright", 19205 rules: { 19206 float: "right", 19207 "margin-inline-start": "2em", 19208 "margin-inline-end": "0" 19209 } 19210 }, 19211 { 19212 selector: " > .aligncenter", 19213 rules: { 19214 "margin-left": "auto !important", 19215 "margin-right": "auto !important" 19216 } 19217 } 19218 ], 19219 spacingStyles: [ 19220 { 19221 selector: " > :first-child", 19222 rules: { 19223 "margin-block-start": "0" 19224 } 19225 }, 19226 { 19227 selector: " > :last-child", 19228 rules: { 19229 "margin-block-end": "0" 19230 } 19231 }, 19232 { 19233 selector: " > *", 19234 rules: { 19235 "margin-block-start": null, 19236 "margin-block-end": "0" 19237 } 19238 } 19239 ] 19240 }, 19241 constrained: { 19242 name: "constrained", 19243 slug: "constrained", 19244 className: "is-layout-constrained", 19245 baseStyles: [ 19246 { 19247 selector: " > .alignleft", 19248 rules: { 19249 float: "left", 19250 "margin-inline-start": "0", 19251 "margin-inline-end": "2em" 19252 } 19253 }, 19254 { 19255 selector: " > .alignright", 19256 rules: { 19257 float: "right", 19258 "margin-inline-start": "2em", 19259 "margin-inline-end": "0" 19260 } 19261 }, 19262 { 19263 selector: " > .aligncenter", 19264 rules: { 19265 "margin-left": "auto !important", 19266 "margin-right": "auto !important" 19267 } 19268 }, 19269 { 19270 selector: " > :where(:not(.alignleft):not(.alignright):not(.alignfull))", 19271 rules: { 19272 "max-width": "var(--wp--style--global--content-size)", 19273 "margin-left": "auto !important", 19274 "margin-right": "auto !important" 19275 } 19276 }, 19277 { 19278 selector: " > .alignwide", 19279 rules: { 19280 "max-width": "var(--wp--style--global--wide-size)" 19281 } 19282 } 19283 ], 19284 spacingStyles: [ 19285 { 19286 selector: " > :first-child", 19287 rules: { 19288 "margin-block-start": "0" 19289 } 19290 }, 19291 { 19292 selector: " > :last-child", 19293 rules: { 19294 "margin-block-end": "0" 19295 } 19296 }, 19297 { 19298 selector: " > *", 19299 rules: { 19300 "margin-block-start": null, 19301 "margin-block-end": "0" 19302 } 19303 } 19304 ] 19305 }, 19306 flex: { 19307 name: "flex", 19308 slug: "flex", 19309 className: "is-layout-flex", 19310 displayMode: "flex", 19311 baseStyles: [ 19312 { 19313 selector: "", 19314 rules: { 19315 "flex-wrap": "wrap", 19316 "align-items": "center" 19317 } 19318 }, 19319 { 19320 selector: " > :is(*, div)", 19321 // :is(*, div) instead of just * increases the specificity by 001. 19322 rules: { 19323 margin: "0" 19324 } 19325 } 19326 ], 19327 spacingStyles: [ 19328 { 19329 selector: "", 19330 rules: { 19331 gap: null 19332 } 19333 } 19334 ] 19335 }, 19336 grid: { 19337 name: "grid", 19338 slug: "grid", 19339 className: "is-layout-grid", 19340 displayMode: "grid", 19341 baseStyles: [ 19342 { 19343 selector: " > :is(*, div)", 19344 // :is(*, div) instead of just * increases the specificity by 001. 19345 rules: { 19346 margin: "0" 19347 } 19348 } 19349 ], 19350 spacingStyles: [ 19351 { 19352 selector: "", 19353 rules: { 19354 gap: null 19355 } 19356 } 19357 ] 19358 } 19359 }; 19360 19361 // packages/global-styles-engine/build-module/utils/viewport.mjs 19362 var DEFAULT_VIEWPORT_BREAKPOINTS = { 19363 mobile: "480px", 19364 tablet: "782px" 19365 }; 19366 var VIEWPORT_SIZE_REGEXP = /^(\d+|\d*\.\d+)(px|em|rem)$/; 19367 var DEFAULT_FONT_SIZE = 16; 19368 function isViewportSettings(configOrSettings) { 19369 return "mobile" in configOrSettings || "tablet" in configOrSettings; 19370 } 19371 function getViewportSettings(configOrSettings) { 19372 if (!configOrSettings || typeof configOrSettings !== "object") { 19373 return {}; 19374 } 19375 if (isViewportSettings(configOrSettings)) { 19376 return configOrSettings; 19377 } 19378 return configOrSettings.settings?.viewport ?? {}; 19379 } 19380 function isValidViewportSize(value) { 19381 return typeof value === "string" && VIEWPORT_SIZE_REGEXP.test(value.trim()); 19382 } 19383 function getViewportBreakpointValueInPixels(value) { 19384 if (typeof value === "number") { 19385 return value; 19386 } 19387 if (typeof value !== "string") { 19388 return void 0; 19389 } 19390 const match3 = value.trim().match(VIEWPORT_SIZE_REGEXP); 19391 if (!match3) { 19392 return void 0; 19393 } 19394 const numericValue = Number.parseFloat(match3[1]); 19395 const unit = match3[2]; 19396 return unit === "px" ? numericValue : numericValue * DEFAULT_FONT_SIZE; 19397 } 19398 function getViewportBreakpoints(configOrSettings) { 19399 const viewportSettings = getViewportSettings(configOrSettings); 19400 const breakpoints = {}; 19401 const breakpointValuesInPixels = {}; 19402 Object.keys(DEFAULT_VIEWPORT_BREAKPOINTS).forEach((breakpoint) => { 19403 const key = breakpoint; 19404 const value = viewportSettings[key]; 19405 const px = getViewportBreakpointValueInPixels(value); 19406 if (px !== void 0 && isValidViewportSize(value)) { 19407 breakpoints[key] = value.trim(); 19408 breakpointValuesInPixels[key] = px; 19409 } 19410 }); 19411 const breakpointNames = Object.keys(breakpoints); 19412 if (!breakpointNames.length) { 19413 return { ...DEFAULT_VIEWPORT_BREAKPOINTS }; 19414 } 19415 if (1 === breakpointNames.length) { 19416 return breakpoints; 19417 } 19418 const mobile = breakpoints.mobile; 19419 const tablet = breakpoints.tablet; 19420 if (breakpointValuesInPixels.mobile >= breakpointValuesInPixels.tablet) { 19421 return { mobile }; 19422 } 19423 return { mobile, tablet }; 19424 } 19425 function getResponsiveMediaQueries(configOrSettings) { 19426 const breakpoints = getViewportBreakpoints(configOrSettings); 19427 const mediaQueries = {}; 19428 if (breakpoints.mobile) { 19429 mediaQueries["@mobile"] = `@media (width <= $breakpoints.mobile})`; 19430 } 19431 if (breakpoints.tablet) { 19432 mediaQueries["@tablet"] = breakpoints.mobile ? `@media ($breakpoints.mobile} < width <= $breakpoints.tablet})` : `@media (width <= $breakpoints.tablet})`; 19433 } 19434 return mediaQueries; 19435 } 19436 19437 // packages/global-styles-engine/build-module/core/render.mjs 19438 var ELEMENT_CLASS_NAMES = { 19439 button: "wp-element-button", 19440 caption: "wp-element-caption" 19441 }; 19442 var BLOCK_SUPPORT_FEATURE_LEVEL_SELECTORS = { 19443 __experimentalBorder: "border", 19444 color: "color", 19445 dimensions: "dimensions", 19446 spacing: "spacing", 19447 typography: "typography" 19448 }; 19449 var VALID_BLOCK_PSEUDO_SELECTORS = { 19450 "core/button": [":hover", ":focus", ":focus-visible", ":active"], 19451 "core/navigation-link": [":hover", ":focus", ":focus-visible", ":active"] 19452 }; 19453 var VALID_ELEMENT_PSEUDO_SELECTORS = { 19454 link: [ 19455 ":link", 19456 ":any-link", 19457 ":visited", 19458 ":hover", 19459 ":focus", 19460 ":focus-visible", 19461 ":active" 19462 ], 19463 button: [ 19464 ":link", 19465 ":any-link", 19466 ":visited", 19467 ":hover", 19468 ":focus", 19469 ":focus-visible", 19470 ":active" 19471 ] 19472 }; 19473 function getPresetsClasses(blockSelector = "*", blockPresets = {}) { 19474 return PRESET_METADATA.reduce( 19475 (declarations, { path, cssVarInfix, classes }) => { 19476 if (!classes) { 19477 return declarations; 19478 } 19479 const presetByOrigin = getValueFromObjectPath( 19480 blockPresets, 19481 path, 19482 [] 19483 ); 19484 ["default", "theme", "custom"].forEach((origin) => { 19485 if (presetByOrigin[origin]) { 19486 presetByOrigin[origin].forEach( 19487 ({ slug }) => { 19488 classes.forEach( 19489 ({ 19490 classSuffix, 19491 propertyName 19492 }) => { 19493 const classSelectorToUse = `.has-$kebabCase( 19494 slug 19495 )}-$classSuffix}`; 19496 const selectorToUse = blockSelector ? `:where($blockSelector})$classSelectorToUse}` : classSelectorToUse; 19497 const value = `var(--wp--preset--$cssVarInfix}--$kebabCase( 19498 slug 19499 )})`; 19500 declarations += `$selectorToUse}{$propertyName}: $value} !important;}`; 19501 } 19502 ); 19503 } 19504 ); 19505 } 19506 }); 19507 return declarations; 19508 }, 19509 "" 19510 ); 19511 } 19512 function getPresetsSvgFilters(blockPresets = {}) { 19513 return PRESET_METADATA.filter( 19514 // Duotone are the only type of filters for now. 19515 (metadata) => metadata.path.at(-1) === "duotone" 19516 ).flatMap((metadata) => { 19517 const presetByOrigin = getValueFromObjectPath( 19518 blockPresets, 19519 metadata.path, 19520 {} 19521 ); 19522 return ["default", "theme"].filter((origin) => presetByOrigin[origin]).flatMap( 19523 (origin) => presetByOrigin[origin].map( 19524 (preset) => getDuotoneFilter( 19525 `wp-duotone-$preset.slug}`, 19526 preset.colors 19527 ) 19528 ) 19529 ).join(""); 19530 }); 19531 } 19532 function flattenTree(input = {}, prefix2, token) { 19533 let result = []; 19534 Object.keys(input).forEach((key) => { 19535 const newKey = prefix2 + kebabCase(key.replace("/", "-")); 19536 const newLeaf = input[key]; 19537 if (newLeaf instanceof Object) { 19538 const newPrefix = newKey + token; 19539 result = [...result, ...flattenTree(newLeaf, newPrefix, token)]; 19540 } else { 19541 result.push(`$newKey}: $newLeaf}`); 19542 } 19543 }); 19544 return result; 19545 } 19546 var updateParagraphTextIndentSelector = (featureDeclarations, settings2, blockName) => { 19547 if (blockName !== "core/paragraph") { 19548 return featureDeclarations; 19549 } 19550 const blockSettings = settings2?.blocks?.["core/paragraph"]; 19551 const textIndentSetting = blockSettings?.typography?.textIndent ?? settings2?.typography?.textIndent ?? "subsequent"; 19552 if (textIndentSetting !== "all") { 19553 return featureDeclarations; 19554 } 19555 const oldSelector = ".wp-block-paragraph + .wp-block-paragraph"; 19556 const newSelector = ".wp-block-paragraph"; 19557 if (oldSelector in featureDeclarations) { 19558 const declarations = featureDeclarations[oldSelector]; 19559 const updated = { ...featureDeclarations }; 19560 delete updated[oldSelector]; 19561 updated[newSelector] = declarations; 19562 return updated; 19563 } 19564 return featureDeclarations; 19565 }; 19566 var updateButtonWidthDeclarations = (featureDeclarations, settings2) => { 19567 const buttonSelector = ".wp-block-button"; 19568 if (!(buttonSelector in featureDeclarations)) { 19569 return featureDeclarations; 19570 } 19571 const updated = { ...featureDeclarations }; 19572 updated[buttonSelector] = updated[buttonSelector].map( 19573 (declaration) => { 19574 const match3 = declaration.match(/^width:\s*(.+)$/); 19575 if (!match3) { 19576 return declaration; 19577 } 19578 const value = match3[1]; 19579 let percentage = null; 19580 if (value.endsWith("%")) { 19581 percentage = parseFloat(value); 19582 } 19583 const presetPrefix = "var(--wp--preset--dimension--"; 19584 if (percentage === null && value.startsWith(presetPrefix) && value.endsWith(")")) { 19585 const slug = value.slice(presetPrefix.length, -1); 19586 const dimensionSizes = { 19587 ...settings2?.dimensions?.dimensionSizes ?? {}, 19588 ...settings2?.blocks?.["core/button"]?.dimensions?.dimensionSizes ?? {} 19589 }; 19590 for (const origin of Object.values(dimensionSizes)) { 19591 if (!Array.isArray(origin)) { 19592 continue; 19593 } 19594 for (const preset of origin) { 19595 if (preset.slug === slug && typeof preset.size === "string" && preset.size.endsWith("%")) { 19596 percentage = parseFloat(preset.size); 19597 break; 19598 } 19599 } 19600 if (percentage !== null) { 19601 break; 19602 } 19603 } 19604 } 19605 if (percentage === null || isNaN(percentage)) { 19606 return declaration; 19607 } 19608 return `width: calc($percentage} * 1% - (var(--wp--style--block-gap, 0.5em) * (1 - $percentage} / 100)))`; 19609 } 19610 ); 19611 return updated; 19612 }; 19613 var getFeatureDeclarations = (selectors3, styles) => { 19614 const declarations = {}; 19615 Object.entries(selectors3).forEach(([feature, selector2]) => { 19616 if (feature === "root" || !styles?.[feature]) { 19617 return; 19618 } 19619 const isShorthand = typeof selector2 === "string"; 19620 if (!isShorthand && typeof selector2 === "object" && selector2 !== null) { 19621 Object.entries(selector2).forEach( 19622 ([subfeature, subfeatureSelector]) => { 19623 if (subfeature === "root" || !styles?.[feature][subfeature]) { 19624 return; 19625 } 19626 const subfeatureStyles = { 19627 [feature]: { 19628 [subfeature]: styles[feature][subfeature] 19629 } 19630 }; 19631 const newDeclarations = getStylesDeclarations(subfeatureStyles); 19632 declarations[subfeatureSelector] = [ 19633 ...declarations[subfeatureSelector] || [], 19634 ...newDeclarations 19635 ]; 19636 delete styles[feature][subfeature]; 19637 } 19638 ); 19639 } 19640 if (isShorthand || typeof selector2 === "object" && selector2 !== null && "root" in selector2) { 19641 const featureSelector = isShorthand ? selector2 : selector2.root; 19642 const featureStyles = { [feature]: styles[feature] }; 19643 const newDeclarations = getStylesDeclarations(featureStyles); 19644 declarations[featureSelector] = [ 19645 ...declarations[featureSelector] || [], 19646 ...newDeclarations 19647 ]; 19648 delete styles[feature]; 19649 } 19650 }); 19651 return declarations; 19652 }; 19653 function getStylesDeclarations(blockStyles = {}, selector2 = "", useRootPaddingAlign, tree = {}, disableRootPadding = false) { 19654 const isRoot = ROOT_BLOCK_SELECTOR === selector2; 19655 const output = Object.entries( 19656 import_blocks3.__EXPERIMENTAL_STYLE_PROPERTY 19657 ).reduce( 19658 (declarations, [key, { value, properties, useEngine, rootOnly }]) => { 19659 if (rootOnly && !isRoot) { 19660 return declarations; 19661 } 19662 const pathToValue = value; 19663 if (pathToValue[0] === "elements" || useEngine) { 19664 return declarations; 19665 } 19666 const styleValue = getValueFromObjectPath( 19667 blockStyles, 19668 pathToValue 19669 ); 19670 if (key === "--wp--style--root--padding" && (typeof styleValue === "string" || !useRootPaddingAlign)) { 19671 return declarations; 19672 } 19673 if (properties && typeof styleValue !== "string") { 19674 Object.entries(properties).forEach((entry) => { 19675 const [name2, prop] = entry; 19676 if (!getValueFromObjectPath(styleValue, [prop], false)) { 19677 return; 19678 } 19679 const cssProperty = name2.startsWith("--") ? name2 : kebabCase(name2); 19680 declarations.push( 19681 `$cssProperty}: ${(0, import_style_engine2.getCSSValueFromRawStyle)( 19682 getValueFromObjectPath(styleValue, [prop]) 19683 )}` 19684 ); 19685 }); 19686 } else if (getValueFromObjectPath(blockStyles, pathToValue, false)) { 19687 const cssProperty = key.startsWith("--") ? key : kebabCase(key); 19688 declarations.push( 19689 `$cssProperty}: ${(0, import_style_engine2.getCSSValueFromRawStyle)( 19690 getValueFromObjectPath(blockStyles, pathToValue) 19691 )}` 19692 ); 19693 } 19694 return declarations; 19695 }, 19696 [] 19697 ); 19698 if (!!blockStyles.background) { 19699 if (blockStyles.background?.backgroundImage) { 19700 blockStyles.background.backgroundImage = getResolvedValue( 19701 blockStyles.background.backgroundImage, 19702 tree 19703 ); 19704 } 19705 if (!isRoot && !!blockStyles.background?.backgroundImage?.id) { 19706 blockStyles = { 19707 ...blockStyles, 19708 background: { 19709 ...blockStyles.background, 19710 ...setBackgroundStyleDefaults(blockStyles.background) 19711 } 19712 }; 19713 } 19714 } 19715 const extraRules = (0, import_style_engine2.getCSSRules)(blockStyles); 19716 extraRules.forEach((rule) => { 19717 if (isRoot && (useRootPaddingAlign || disableRootPadding) && rule.key.startsWith("padding")) { 19718 return; 19719 } 19720 const cssProperty = rule.key.startsWith("--") ? rule.key : kebabCase(rule.key); 19721 let ruleValue = getResolvedValue(rule.value, tree); 19722 if (cssProperty === "font-size") { 19723 ruleValue = getTypographyFontSizeValue( 19724 { name: "", slug: "", size: ruleValue }, 19725 tree?.settings 19726 ); 19727 } 19728 if (cssProperty === "aspect-ratio") { 19729 output.push("min-height: unset"); 19730 } 19731 output.push(`$cssProperty}: $ruleValue}`); 19732 }); 19733 return output; 19734 } 19735 function getLayoutStyles({ 19736 layoutDefinitions = LAYOUT_DEFINITIONS, 19737 style, 19738 selector: selector2, 19739 hasBlockGapSupport, 19740 hasFallbackGapSupport, 19741 fallbackGapValue 19742 }) { 19743 let ruleset = ""; 19744 let gapValue = hasBlockGapSupport ? getGapCSSValue(style?.spacing?.blockGap) : ""; 19745 if (hasFallbackGapSupport) { 19746 if (selector2 === ROOT_BLOCK_SELECTOR) { 19747 gapValue = !gapValue ? "0.5em" : gapValue; 19748 } else if (!hasBlockGapSupport && fallbackGapValue) { 19749 gapValue = fallbackGapValue; 19750 } 19751 } 19752 if (gapValue && layoutDefinitions) { 19753 Object.values(layoutDefinitions).forEach( 19754 ({ className, name: name2, spacingStyles }) => { 19755 if (!hasBlockGapSupport && "flex" !== name2 && "grid" !== name2) { 19756 return; 19757 } 19758 if (spacingStyles?.length) { 19759 spacingStyles.forEach((spacingStyle) => { 19760 const declarations = []; 19761 if (spacingStyle.rules) { 19762 Object.entries(spacingStyle.rules).forEach( 19763 ([cssProperty, cssValue]) => { 19764 declarations.push( 19765 `$cssProperty}: $cssValue ? cssValue : gapValue}` 19766 ); 19767 } 19768 ); 19769 } 19770 if (declarations.length) { 19771 let combinedSelector = ""; 19772 if (!hasBlockGapSupport) { 19773 combinedSelector = selector2 === ROOT_BLOCK_SELECTOR ? `:where(.$className}$spacingStyle?.selector || ""})` : `:where($selector2}.$className}$spacingStyle?.selector || ""})`; 19774 } else { 19775 combinedSelector = selector2 === ROOT_BLOCK_SELECTOR ? `:root :where(.$className})$spacingStyle?.selector || ""}` : `:root :where($selector2}-$className})$spacingStyle?.selector || ""}`; 19776 } 19777 ruleset += `$combinedSelector} { $declarations.join( 19778 "; " 19779 )}; }`; 19780 } 19781 }); 19782 } 19783 } 19784 ); 19785 if (selector2 === ROOT_BLOCK_SELECTOR && hasBlockGapSupport) { 19786 ruleset += `$ROOT_CSS_PROPERTIES_SELECTOR} { --wp--style--block-gap: $gapValue}; }`; 19787 } 19788 } 19789 if (selector2 === ROOT_BLOCK_SELECTOR && layoutDefinitions) { 19790 const validDisplayModes = ["block", "flex", "grid"]; 19791 Object.values(layoutDefinitions).forEach( 19792 ({ className, displayMode, baseStyles }) => { 19793 if (displayMode && validDisplayModes.includes(displayMode)) { 19794 ruleset += `$selector2} .$className} { display:$displayMode}; }`; 19795 } 19796 if (baseStyles?.length) { 19797 baseStyles.forEach((baseStyle) => { 19798 const declarations = []; 19799 if (baseStyle.rules) { 19800 Object.entries(baseStyle.rules).forEach( 19801 ([cssProperty, cssValue]) => { 19802 declarations.push( 19803 `$cssProperty}: $cssValue}` 19804 ); 19805 } 19806 ); 19807 } 19808 if (declarations.length) { 19809 const combinedSelector = `.$className}$baseStyle?.selector || ""}`; 19810 ruleset += `$combinedSelector} { $declarations.join( 19811 "; " 19812 )}; }`; 19813 } 19814 }); 19815 } 19816 } 19817 ); 19818 } 19819 return ruleset; 19820 } 19821 var STYLE_KEYS = [ 19822 "border", 19823 "color", 19824 "dimensions", 19825 "spacing", 19826 "typography", 19827 "filter", 19828 "outline", 19829 "shadow", 19830 "background" 19831 ]; 19832 function pickStyleKeys(treeToPickFrom, responsiveMediaQueries) { 19833 return pickStyleAndPseudoKeys( 19834 treeToPickFrom, 19835 void 0, 19836 responsiveMediaQueries 19837 ); 19838 } 19839 function pickStyleAndPseudoKeys(treeToPickFrom, blockName, responsiveMediaQueries) { 19840 if (!treeToPickFrom) { 19841 return {}; 19842 } 19843 const entries = Object.entries(treeToPickFrom); 19844 const allowedPseudoSelectors = blockName ? VALID_BLOCK_PSEUDO_SELECTORS[blockName] ?? [] : []; 19845 const pickedEntries = entries.filter( 19846 ([key]) => STYLE_KEYS.includes(key) || allowedPseudoSelectors.includes(key) || responsiveMediaQueries[key] 19847 ); 19848 const clonedEntries = pickedEntries.map(([key, style]) => [ 19849 key, 19850 JSON.parse(JSON.stringify(style)) 19851 ]); 19852 return Object.fromEntries(clonedEntries); 19853 } 19854 function getPseudoStyleNodes(node) { 19855 const { 19856 styles, 19857 selector: selector2, 19858 featureSelectors, 19859 name: name2, 19860 elementName, 19861 mediaQuery, 19862 variationName 19863 } = node; 19864 const pseudoSelectors = name2 ? VALID_BLOCK_PSEUDO_SELECTORS[name2] ?? [] : VALID_ELEMENT_PSEUDO_SELECTORS[elementName ?? ""] ?? []; 19865 if (!pseudoSelectors.length) { 19866 return []; 19867 } 19868 return pseudoSelectors.flatMap((pseudoSelector) => { 19869 const pseudoStyles = styles?.[pseudoSelector]; 19870 if (!pseudoStyles || typeof pseudoStyles !== "object") { 19871 return []; 19872 } 19873 return [ 19874 { 19875 styles: JSON.parse(JSON.stringify(pseudoStyles)), 19876 selector: selector2, 19877 selectorSuffix: pseudoSelector, 19878 mediaQuery, 19879 featureSelectors: featureSelectors && typeof featureSelectors !== "string" ? featureSelectors : void 0, 19880 name: name2, 19881 elementName, 19882 variationName 19883 } 19884 ]; 19885 }); 19886 } 19887 function getResponsiveStyleNodes(node, responsiveMediaQueries) { 19888 const { 19889 styles, 19890 selector: selector2, 19891 fallbackGapValue, 19892 featureSelectors, 19893 hasLayoutSupport, 19894 layoutHasBlockGapSupport, 19895 layoutSelector, 19896 name: name2, 19897 elementName, 19898 isStyleVariation, 19899 variationName 19900 } = node; 19901 if (!name2 && !elementName) { 19902 return []; 19903 } 19904 return Object.entries(responsiveMediaQueries).flatMap( 19905 ([breakpointKey, mediaQuery]) => { 19906 const breakpointStyles = styles?.[breakpointKey]; 19907 if (!breakpointStyles || typeof breakpointStyles !== "object") { 19908 return []; 19909 } 19910 return [ 19911 { 19912 styles: JSON.parse(JSON.stringify(breakpointStyles)), 19913 selector: selector2, 19914 mediaQuery, 19915 featureSelectors: featureSelectors && typeof featureSelectors !== "string" ? featureSelectors : void 0, 19916 fallbackGapValue, 19917 hasLayoutSupport, 19918 name: name2, 19919 elementName, 19920 isStyleVariation, 19921 variationName, 19922 layoutSelector, 19923 layoutHasBlockGapSupport 19924 } 19925 ]; 19926 } 19927 ); 19928 } 19929 var getNodesWithStyles = (tree, blockSelectors) => { 19930 const nodes = []; 19931 if (!tree?.styles) { 19932 return nodes; 19933 } 19934 const responsiveMediaQueries = getResponsiveMediaQueries(tree); 19935 const styles = pickStyleKeys(tree.styles, responsiveMediaQueries); 19936 if (styles) { 19937 nodes.push({ 19938 styles, 19939 selector: ROOT_BLOCK_SELECTOR, 19940 // Root selector (body) styles should not be wrapped in `:root where()` to keep 19941 // specificity at (0,0,1) and maintain backwards compatibility. 19942 skipSelectorWrapper: true 19943 }); 19944 } 19945 Object.entries(import_blocks3.__EXPERIMENTAL_ELEMENTS).forEach(([name2, selector2]) => { 19946 if (tree.styles?.elements?.[name2]) { 19947 nodes.push({ 19948 styles: tree.styles?.elements?.[name2] ?? {}, 19949 selector: selector2, 19950 elementName: name2, 19951 // Top level elements that don't use a class name should not receive the 19952 // `:root :where()` wrapper to maintain backwards compatibility. 19953 skipSelectorWrapper: !ELEMENT_CLASS_NAMES[name2] 19954 }); 19955 } 19956 }); 19957 Object.entries(tree.styles?.blocks ?? {}).forEach( 19958 ([blockName, node]) => { 19959 const blockStyles = pickStyleAndPseudoKeys( 19960 node, 19961 blockName, 19962 responsiveMediaQueries 19963 ); 19964 const typedNode = node; 19965 const variationNodesToAdd = []; 19966 const variationStyleNodesToAdd = []; 19967 if (typedNode?.variations) { 19968 Object.entries(typedNode.variations).forEach( 19969 ([variationName, variation]) => { 19970 const typedVariation = variation; 19971 const variationStyles = pickStyleAndPseudoKeys( 19972 typedVariation, 19973 blockName, 19974 responsiveMediaQueries 19975 ); 19976 if (typedVariation?.css) { 19977 variationStyles.css = typedVariation.css; 19978 } 19979 const variationSelector = typeof blockSelectors !== "string" ? blockSelectors[blockName]?.styleVariationSelectors?.[variationName] : void 0; 19980 if (variationSelector && typeof blockSelectors !== "string") { 19981 const blockSelector = blockSelectors[blockName]; 19982 variationStyleNodesToAdd.push({ 19983 styles: variationStyles, 19984 selector: variationSelector, 19985 featureSelectors: blockSelector?.featureSelectors, 19986 fallbackGapValue: blockSelector?.fallbackGapValue, 19987 hasLayoutSupport: blockSelector?.hasLayoutSupport, 19988 isStyleVariation: true, 19989 variationName, 19990 layoutSelector: variationSelector + blockSelector.selector, 19991 layoutHasBlockGapSupport: true, 19992 name: blockName 19993 }); 19994 } 19995 Object.entries( 19996 typedVariation?.elements ?? {} 19997 ).forEach(([element, elementStyles]) => { 19998 if (elementStyles && import_blocks3.__EXPERIMENTAL_ELEMENTS[element]) { 19999 variationNodesToAdd.push({ 20000 styles: elementStyles, 20001 selector: scopeSelector( 20002 variationSelector, 20003 import_blocks3.__EXPERIMENTAL_ELEMENTS[element] 20004 ), 20005 elementName: element, 20006 isStyleVariation: true 20007 }); 20008 } 20009 }); 20010 Object.entries(typedVariation?.blocks ?? {}).forEach( 20011 ([ 20012 variationBlockName, 20013 variationBlockStyles 20014 ]) => { 20015 const variationBlockSelector = typeof blockSelectors !== "string" ? scopeSelector( 20016 variationSelector, 20017 blockSelectors[variationBlockName]?.selector 20018 ) : void 0; 20019 const variationDuotoneSelector = typeof blockSelectors !== "string" ? scopeSelector( 20020 variationSelector, 20021 blockSelectors[variationBlockName]?.duotoneSelector 20022 ) : void 0; 20023 const variationFeatureSelectors = typeof blockSelectors !== "string" ? scopeFeatureSelectors( 20024 variationSelector, 20025 blockSelectors[variationBlockName]?.featureSelectors ?? {} 20026 ) : void 0; 20027 const variationBlockStyleNodes = pickStyleAndPseudoKeys( 20028 variationBlockStyles, 20029 variationBlockName, 20030 responsiveMediaQueries 20031 ); 20032 if (variationBlockStyles?.css) { 20033 variationBlockStyleNodes.css = variationBlockStyles.css; 20034 } 20035 if (!variationBlockSelector || typeof blockSelectors === "string") { 20036 return; 20037 } 20038 variationNodesToAdd.push({ 20039 selector: variationBlockSelector, 20040 name: variationBlockName, 20041 isStyleVariation: true, 20042 duotoneSelector: variationDuotoneSelector, 20043 featureSelectors: variationFeatureSelectors, 20044 fallbackGapValue: blockSelectors[variationBlockName]?.fallbackGapValue, 20045 hasLayoutSupport: blockSelectors[variationBlockName]?.hasLayoutSupport, 20046 styles: variationBlockStyleNodes 20047 }); 20048 Object.entries( 20049 variationBlockStyles.elements ?? {} 20050 ).forEach( 20051 ([ 20052 variationBlockElement, 20053 variationBlockElementStyles 20054 ]) => { 20055 if (variationBlockElementStyles && import_blocks3.__EXPERIMENTAL_ELEMENTS[variationBlockElement]) { 20056 variationNodesToAdd.push({ 20057 styles: variationBlockElementStyles, 20058 selector: scopeSelector( 20059 variationBlockSelector, 20060 import_blocks3.__EXPERIMENTAL_ELEMENTS[variationBlockElement] 20061 ), 20062 elementName: variationBlockElement, 20063 isStyleVariation: true 20064 }); 20065 } 20066 } 20067 ); 20068 } 20069 ); 20070 } 20071 ); 20072 } 20073 if (typeof blockSelectors !== "string" && blockSelectors?.[blockName]?.selector) { 20074 nodes.push({ 20075 duotoneSelector: blockSelectors[blockName].duotoneSelector, 20076 fallbackGapValue: blockSelectors[blockName].fallbackGapValue, 20077 hasLayoutSupport: blockSelectors[blockName].hasLayoutSupport, 20078 selector: blockSelectors[blockName].selector, 20079 styles: blockStyles, 20080 featureSelectors: blockSelectors[blockName].featureSelectors, 20081 name: blockName 20082 }); 20083 } 20084 nodes.push(...variationStyleNodesToAdd); 20085 Object.entries(typedNode?.elements ?? {}).forEach( 20086 ([elementName, value]) => { 20087 if (typeof blockSelectors !== "string" && value && blockSelectors?.[blockName] && import_blocks3.__EXPERIMENTAL_ELEMENTS[elementName]) { 20088 nodes.push({ 20089 styles: value, 20090 selector: blockSelectors[blockName]?.selector.split(",").map((sel) => { 20091 const elementSelectors = import_blocks3.__EXPERIMENTAL_ELEMENTS[elementName].split(","); 20092 return elementSelectors.map( 20093 (elementSelector) => sel + " " + elementSelector 20094 ); 20095 }).join(","), 20096 elementName 20097 }); 20098 } 20099 } 20100 ); 20101 nodes.push(...variationNodesToAdd); 20102 } 20103 ); 20104 return nodes; 20105 }; 20106 var getNodesWithSettings = (tree, blockSelectors) => { 20107 const nodes = []; 20108 if (!tree?.settings) { 20109 return nodes; 20110 } 20111 const pickPresets = (treeToPickFrom) => { 20112 let presets2 = {}; 20113 PRESET_METADATA.forEach(({ path }) => { 20114 const value = getValueFromObjectPath(treeToPickFrom, path, false); 20115 if (value !== false) { 20116 presets2 = setImmutably(presets2, path, value); 20117 } 20118 }); 20119 return presets2; 20120 }; 20121 const presets = pickPresets(tree.settings); 20122 const custom = tree.settings?.custom; 20123 if (Object.keys(presets).length > 0 || custom) { 20124 nodes.push({ 20125 presets, 20126 custom, 20127 selector: ROOT_CSS_PROPERTIES_SELECTOR 20128 }); 20129 } 20130 Object.entries(tree.settings?.blocks ?? {}).forEach( 20131 ([blockName, node]) => { 20132 const blockCustom = node.custom; 20133 if (typeof blockSelectors === "string" || !blockSelectors[blockName]) { 20134 return; 20135 } 20136 const blockPresets = pickPresets(node); 20137 if (Object.keys(blockPresets).length > 0 || blockCustom) { 20138 nodes.push({ 20139 presets: blockPresets, 20140 custom: blockCustom, 20141 selector: blockSelectors[blockName]?.selector, 20142 featureSelectors: blockSelectors[blockName]?.featureSelectors 20143 }); 20144 } 20145 } 20146 ); 20147 return nodes; 20148 }; 20149 function resolveFeatureSelector(featureSelectors, featureKey, fallback) { 20150 if (!featureSelectors || typeof featureSelectors === "string") { 20151 return fallback; 20152 } 20153 const feature = featureSelectors[featureKey]; 20154 if (typeof feature === "string") { 20155 return feature; 20156 } 20157 if (typeof feature === "object" && feature.root) { 20158 return feature.root; 20159 } 20160 return fallback; 20161 } 20162 function getPresetVarDeclarations(presets, mergedSettings, { path, valueKey, valueFunc, cssVarInfix }) { 20163 const presetByOrigin = getValueFromObjectPath( 20164 presets, 20165 path, 20166 [] 20167 ); 20168 const declarations = []; 20169 for (const origin of ["default", "theme", "custom"]) { 20170 if (!presetByOrigin[origin]) { 20171 continue; 20172 } 20173 for (const value of presetByOrigin[origin]) { 20174 const slug = kebabCase(value.slug); 20175 if (valueKey && !valueFunc) { 20176 declarations.push( 20177 `--wp--preset--$cssVarInfix}--$slug}: $value[valueKey]}` 20178 ); 20179 } else if (valueFunc && typeof valueFunc === "function") { 20180 declarations.push( 20181 `--wp--preset--$cssVarInfix}--$slug}: $valueFunc( 20182 value, 20183 mergedSettings 20184 )}` 20185 ); 20186 } 20187 } 20188 } 20189 return declarations; 20190 } 20191 var generateCustomProperties = (tree, blockSelectors) => { 20192 const nodes = getNodesWithSettings(tree, blockSelectors); 20193 let ruleset = ""; 20194 for (const { presets, custom, selector: selector2, featureSelectors } of nodes) { 20195 const defaultSelector = selector2; 20196 const varsBySelector = { 20197 [defaultSelector]: [] 20198 }; 20199 if (tree?.settings) { 20200 for (const metadata of PRESET_METADATA) { 20201 const declarations = getPresetVarDeclarations( 20202 presets, 20203 tree.settings, 20204 metadata 20205 ); 20206 if (declarations.length === 0) { 20207 continue; 20208 } 20209 const target = resolveFeatureSelector( 20210 featureSelectors, 20211 metadata.path[0], 20212 defaultSelector 20213 ); 20214 if (!varsBySelector[target]) { 20215 varsBySelector[target] = []; 20216 } 20217 varsBySelector[target].push(...declarations); 20218 } 20219 } 20220 const customProps = flattenTree(custom, "--wp--custom--", "--"); 20221 if (customProps.length > 0) { 20222 varsBySelector[defaultSelector].push(...customProps); 20223 } 20224 for (const [ruleSelector, declarations] of Object.entries( 20225 varsBySelector 20226 )) { 20227 if (declarations.length > 0) { 20228 ruleset += `$ruleSelector}{$declarations.join(";")};}`; 20229 } 20230 } 20231 } 20232 return ruleset; 20233 }; 20234 function renderStylesNode(node, { 20235 tree, 20236 useRootPaddingAlign, 20237 disableLayoutStyles, 20238 hasBlockGapSupport, 20239 hasFallbackGapSupport, 20240 disableRootPadding 20241 }) { 20242 const { 20243 selector: selector2, 20244 selectorSuffix, 20245 mediaQuery, 20246 duotoneSelector, 20247 styles, 20248 fallbackGapValue, 20249 hasLayoutSupport, 20250 featureSelectors, 20251 layoutSelector, 20252 layoutHasBlockGapSupport, 20253 skipSelectorWrapper, 20254 name: name2, 20255 variationName 20256 } = node; 20257 let ruleset = ""; 20258 const effectiveSelector = selectorSuffix ? appendToSelector(selector2, selectorSuffix) : selector2; 20259 if (featureSelectors && typeof featureSelectors !== "string") { 20260 let featureDeclarations = getFeatureDeclarations( 20261 featureSelectors, 20262 styles 20263 ); 20264 featureDeclarations = updateParagraphTextIndentSelector( 20265 featureDeclarations, 20266 tree.settings, 20267 name2 20268 ); 20269 featureDeclarations = updateButtonWidthDeclarations( 20270 featureDeclarations, 20271 tree.settings 20272 ); 20273 Object.entries(featureDeclarations).forEach( 20274 ([featureSelector, declarations]) => { 20275 if (declarations.length) { 20276 let selectorForRule = variationName ? getBlockStyleVariationFeatureSelector( 20277 variationName, 20278 featureSelector 20279 ) : featureSelector; 20280 selectorForRule = selectorSuffix ? appendToSelector(selectorForRule, selectorSuffix) : selectorForRule; 20281 const rules = declarations.join(";"); 20282 ruleset += `:root :where($selectorForRule}){$rules};}`; 20283 } 20284 } 20285 ); 20286 } 20287 if (duotoneSelector) { 20288 const duotoneStyles = {}; 20289 if (styles?.filter) { 20290 duotoneStyles.filter = styles.filter; 20291 delete styles.filter; 20292 } 20293 const duotoneDeclarations = getStylesDeclarations(duotoneStyles); 20294 if (duotoneDeclarations.length) { 20295 ruleset += `$duotoneSelector}{$duotoneDeclarations.join( 20296 ";" 20297 )};}`; 20298 } 20299 } 20300 const selectorForLayout = layoutSelector ?? effectiveSelector; 20301 const hasBlockGapSupportForLayout = layoutHasBlockGapSupport ?? hasBlockGapSupport; 20302 if (!disableLayoutStyles && (ROOT_BLOCK_SELECTOR === selectorForLayout || hasLayoutSupport)) { 20303 ruleset += getLayoutStyles({ 20304 style: styles, 20305 selector: selectorForLayout, 20306 hasBlockGapSupport: hasBlockGapSupportForLayout, 20307 hasFallbackGapSupport, 20308 fallbackGapValue 20309 }); 20310 } 20311 const styleDeclarations = getStylesDeclarations( 20312 styles, 20313 effectiveSelector, 20314 useRootPaddingAlign, 20315 tree, 20316 disableRootPadding 20317 ); 20318 if (styleDeclarations?.length) { 20319 const generalSelector = skipSelectorWrapper ? effectiveSelector : `:root :where($effectiveSelector})`; 20320 ruleset += `$generalSelector}{$styleDeclarations.join(";")};}`; 20321 } 20322 if (styles?.css) { 20323 ruleset += processCSSNesting( 20324 styles.css, 20325 `:root :where($effectiveSelector})` 20326 ); 20327 } 20328 if (mediaQuery && ruleset) { 20329 return `$mediaQuery}{$ruleset}}`; 20330 } 20331 return ruleset; 20332 } 20333 var transformToStyles = (tree, blockSelectors, hasBlockGapSupport, hasFallbackGapSupport, disableLayoutStyles = false, disableRootPadding = false, styleOptions = {}) => { 20334 const options = { 20335 blockGap: true, 20336 blockStyles: true, 20337 layoutStyles: true, 20338 marginReset: true, 20339 presets: true, 20340 rootPadding: true, 20341 variationStyles: false, 20342 ...styleOptions 20343 }; 20344 const normalizedTree = normalizeStyleStateAliases(tree); 20345 const nodesWithStyles = getNodesWithStyles( 20346 normalizedTree, 20347 blockSelectors 20348 ); 20349 const nodesWithSettings = getNodesWithSettings( 20350 normalizedTree, 20351 blockSelectors 20352 ); 20353 const useRootPaddingAlign = normalizedTree?.settings?.useRootPaddingAwareAlignments; 20354 const { contentSize, wideSize } = normalizedTree?.settings?.layout || {}; 20355 const hasBodyStyles = options.marginReset || options.rootPadding || options.layoutStyles; 20356 let ruleset = ""; 20357 if (options.presets && (contentSize || wideSize)) { 20358 ruleset += `$ROOT_CSS_PROPERTIES_SELECTOR} {`; 20359 ruleset = contentSize ? ruleset + ` --wp--style--global--content-size: $contentSize};` : ruleset; 20360 ruleset = wideSize ? ruleset + ` --wp--style--global--wide-size: $wideSize};` : ruleset; 20361 ruleset += "}"; 20362 } 20363 if (hasBodyStyles) { 20364 ruleset += ":where(body) {margin: 0;"; 20365 if (options.rootPadding && useRootPaddingAlign) { 20366 ruleset += `padding-right: 0; padding-left: 0; padding-top: var(--wp--style--root--padding-top); padding-bottom: var(--wp--style--root--padding-bottom) } 20367 .has-global-padding { padding-right: var(--wp--style--root--padding-right); padding-left: var(--wp--style--root--padding-left); } 20368 .has-global-padding > .alignfull { margin-right: calc(var(--wp--style--root--padding-right) * -1); margin-left: calc(var(--wp--style--root--padding-left) * -1); } 20369 .has-global-padding :where(:not(.alignfull.is-layout-flow) > .has-global-padding:not(.wp-block-block, .alignfull)) { padding-right: 0; padding-left: 0; } 20370 .has-global-padding :where(:not(.alignfull.is-layout-flow) > .has-global-padding:not(.wp-block-block, .alignfull)) > .alignfull { margin-left: 0; margin-right: 0; 20371 `; 20372 } 20373 ruleset += "}"; 20374 } 20375 if (options.blockStyles) { 20376 const responsiveMediaQueries = getResponsiveMediaQueries(tree); 20377 nodesWithStyles.forEach((node) => { 20378 if (node.isStyleVariation && !options.variationStyles) { 20379 return; 20380 } 20381 const responsiveNodes = getResponsiveStyleNodes( 20382 node, 20383 responsiveMediaQueries 20384 ); 20385 [ 20386 node, 20387 ...responsiveNodes, 20388 ...getPseudoStyleNodes(node), 20389 ...responsiveNodes.flatMap(getPseudoStyleNodes) 20390 ].forEach((expandedNode) => { 20391 ruleset += renderStylesNode(expandedNode, { 20392 tree: normalizedTree, 20393 useRootPaddingAlign, 20394 disableLayoutStyles, 20395 hasBlockGapSupport, 20396 hasFallbackGapSupport, 20397 disableRootPadding 20398 }); 20399 }); 20400 }); 20401 } 20402 if (options.layoutStyles) { 20403 ruleset = ruleset + ".wp-site-blocks > .alignleft { float: left; margin-right: 2em; }"; 20404 ruleset = ruleset + ".wp-site-blocks > .alignright { float: right; margin-left: 2em; }"; 20405 ruleset = ruleset + ".wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }"; 20406 } 20407 if (options.blockGap && hasBlockGapSupport) { 20408 const gapValue = getGapCSSValue(normalizedTree?.styles?.spacing?.blockGap) || "0.5em"; 20409 ruleset = ruleset + `:root :where(.wp-site-blocks) > * { margin-block-start: $gapValue}; margin-block-end: 0; }`; 20410 ruleset = ruleset + ":root :where(.wp-site-blocks) > :first-child { margin-block-start: 0; }"; 20411 ruleset = ruleset + ":root :where(.wp-site-blocks) > :last-child { margin-block-end: 0; }"; 20412 } 20413 if (options.presets) { 20414 nodesWithSettings.forEach(({ selector: selector2, presets }) => { 20415 if (ROOT_BLOCK_SELECTOR === selector2 || ROOT_CSS_PROPERTIES_SELECTOR === selector2) { 20416 selector2 = ""; 20417 } 20418 const classes = getPresetsClasses(selector2, presets); 20419 if (classes.length > 0) { 20420 ruleset += classes; 20421 } 20422 }); 20423 } 20424 return ruleset; 20425 }; 20426 function generateSvgFilters(tree, blockSelectors) { 20427 const nodesWithSettings = getNodesWithSettings(tree, blockSelectors); 20428 return nodesWithSettings.flatMap(({ presets }) => { 20429 return getPresetsSvgFilters(presets); 20430 }); 20431 } 20432 var getSelectorsConfig = (blockType, rootSelector) => { 20433 if (blockType?.selectors && Object.keys(blockType.selectors).length > 0) { 20434 return blockType.selectors; 20435 } 20436 const config2 = { 20437 root: rootSelector 20438 }; 20439 Object.entries(BLOCK_SUPPORT_FEATURE_LEVEL_SELECTORS).forEach( 20440 ([featureKey, featureName]) => { 20441 const featureSelector = getBlockSelector(blockType, featureKey); 20442 if (featureSelector) { 20443 config2[featureName] = featureSelector; 20444 } 20445 } 20446 ); 20447 return config2; 20448 }; 20449 var getBlockSelectors = (blockTypes, variationInstanceId) => { 20450 const { getBlockStyles } = (0, import_data21.select)(import_blocks3.store); 20451 const result = {}; 20452 blockTypes.forEach((blockType) => { 20453 const name2 = blockType.name; 20454 const selector2 = getBlockSelector(blockType); 20455 if (!selector2) { 20456 return; 20457 } 20458 let duotoneSelector = getBlockSelector(blockType, "filter.duotone"); 20459 if (!duotoneSelector) { 20460 const rootSelector = getBlockSelector(blockType); 20461 const duotoneSupport = (0, import_blocks3.getBlockSupport)( 20462 blockType, 20463 "color.__experimentalDuotone", 20464 false 20465 ); 20466 if (typeof duotoneSupport === "string" && rootSelector) { 20467 duotoneSelector = scopeSelector(rootSelector, duotoneSupport); 20468 } 20469 } 20470 const hasLayoutSupport = !!blockType?.supports?.layout || !!blockType?.supports?.__experimentalLayout; 20471 const fallbackGapValue = ( 20472 // @ts-expect-error 20473 blockType?.supports?.spacing?.blockGap?.__experimentalDefault 20474 ); 20475 const blockStyleVariations = getBlockStyles(name2); 20476 const styleVariationSelectors = {}; 20477 blockStyleVariations?.forEach((variation) => { 20478 const variationSuffix = variationInstanceId ? `-$variationInstanceId}` : ""; 20479 const variationName = `$variation.name}$variationSuffix}`; 20480 const styleVariationSelector = getBlockStyleVariationSelector( 20481 variationName, 20482 selector2 20483 ); 20484 styleVariationSelectors[variationName] = styleVariationSelector; 20485 }); 20486 const featureSelectors = getSelectorsConfig(blockType, selector2); 20487 result[name2] = { 20488 duotoneSelector: duotoneSelector ?? void 0, 20489 fallbackGapValue, 20490 featureSelectors: Object.keys(featureSelectors).length ? featureSelectors : void 0, 20491 hasLayoutSupport, 20492 name: name2, 20493 selector: selector2, 20494 styleVariationSelectors: blockStyleVariations?.length ? styleVariationSelectors : void 0 20495 }; 20496 }); 20497 return result; 20498 }; 20499 function updateConfigWithSeparator(config2) { 20500 const blocks = config2.styles?.blocks; 20501 const separatorBlock = blocks?.["core/separator"]; 20502 const needsSeparatorStyleUpdate = separatorBlock && separatorBlock.color?.background && !separatorBlock.color?.text && !separatorBlock.border?.color; 20503 if (needsSeparatorStyleUpdate) { 20504 return { 20505 ...config2, 20506 styles: { 20507 ...config2.styles, 20508 blocks: { 20509 ...blocks, 20510 "core/separator": { 20511 ...separatorBlock, 20512 color: { 20513 ...separatorBlock.color, 20514 text: separatorBlock.color?.background 20515 } 20516 } 20517 } 20518 } 20519 }; 20520 } 20521 return config2; 20522 } 20523 function processCSSNesting(css, blockSelector) { 20524 let processedCSS = ""; 20525 if (!css || css.trim() === "") { 20526 return processedCSS; 20527 } 20528 const parts = css.split("&"); 20529 parts.forEach((part) => { 20530 if (!part || part.trim() === "") { 20531 return; 20532 } 20533 const isRootCss = !part.includes("{"); 20534 if (isRootCss) { 20535 processedCSS += `:root :where($blockSelector}){$part.trim()}}`; 20536 } else { 20537 const splitPart = part.replace("}", "").split("{"); 20538 if (splitPart.length !== 2) { 20539 return; 20540 } 20541 const [nestedSelector, cssValue] = splitPart; 20542 const matches = nestedSelector.match(/([>+~\s]*::[a-zA-Z-]+)/); 20543 const pseudoPart = matches ? matches[1] : ""; 20544 const withoutPseudoElement = matches ? nestedSelector.replace(pseudoPart, "").trim() : nestedSelector.trim(); 20545 let combinedSelector; 20546 if (withoutPseudoElement === "") { 20547 combinedSelector = blockSelector; 20548 } else { 20549 combinedSelector = nestedSelector.startsWith(" ") ? scopeSelector(blockSelector, withoutPseudoElement) : appendToSelector(blockSelector, withoutPseudoElement); 20550 } 20551 processedCSS += `:root :where($combinedSelector})$pseudoPart}{$cssValue.trim()}}`; 20552 } 20553 }); 20554 return processedCSS; 20555 } 20556 function generateGlobalStyles(config2 = {}, blockTypes = [], options = {}) { 20557 const { 20558 hasBlockGapSupport: hasBlockGapSupportOption, 20559 hasFallbackGapSupport: hasFallbackGapSupportOption, 20560 disableLayoutStyles = false, 20561 disableRootPadding = false, 20562 styleOptions = {} 20563 } = options; 20564 const blocks = blockTypes.length > 0 ? blockTypes : (0, import_blocks3.getBlockTypes)(); 20565 const blockGap = getSetting(config2, "spacing.blockGap"); 20566 const hasBlockGapSupport = hasBlockGapSupportOption ?? blockGap !== null; 20567 const hasFallbackGapSupport = hasFallbackGapSupportOption ?? !hasBlockGapSupport; 20568 if (!config2?.styles || !config2?.settings) { 20569 return [[], {}]; 20570 } 20571 const updatedConfig = updateConfigWithSeparator(config2); 20572 const blockSelectors = getBlockSelectors(blocks); 20573 const customProperties = generateCustomProperties( 20574 updatedConfig, 20575 blockSelectors 20576 ); 20577 const globalStyles = transformToStyles( 20578 updatedConfig, 20579 blockSelectors, 20580 hasBlockGapSupport, 20581 hasFallbackGapSupport, 20582 disableLayoutStyles, 20583 disableRootPadding, 20584 styleOptions 20585 ); 20586 const svgs = generateSvgFilters(updatedConfig, blockSelectors); 20587 const styles = [ 20588 { 20589 css: customProperties, 20590 isGlobalStyles: true 20591 }, 20592 { 20593 css: globalStyles, 20594 isGlobalStyles: true 20595 }, 20596 // 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. 20597 { 20598 css: updatedConfig?.styles?.css ?? "", 20599 isGlobalStyles: true 20600 }, 20601 { 20602 assets: svgs, 20603 __unstableType: "svgs", 20604 isGlobalStyles: true 20605 } 20606 ]; 20607 blocks.forEach((blockType) => { 20608 const blockStyles = updatedConfig?.styles?.blocks?.[blockType.name]; 20609 if (blockStyles?.css) { 20610 const { featureSelectors } = blockSelectors[blockType.name]; 20611 const cssFeatureSelector = typeof featureSelectors === "object" ? featureSelectors?.css : void 0; 20612 let resolvedCssSelector; 20613 if (typeof cssFeatureSelector === "string") { 20614 resolvedCssSelector = cssFeatureSelector; 20615 } else if (typeof cssFeatureSelector === "object") { 20616 resolvedCssSelector = cssFeatureSelector?.root; 20617 } 20618 const selector2 = resolvedCssSelector ?? blockSelectors[blockType.name].selector; 20619 styles.push({ 20620 css: processCSSNesting(blockStyles.css, selector2), 20621 isGlobalStyles: true 20622 }); 20623 } 20624 }); 20625 return [styles, updatedConfig.settings]; 20626 } 20627 20628 // packages/global-styles-engine/build-module/variation.mjs 20629 function getVariationStyle(globalStyles, name2, variation, { resolveRefs = true } = {}) { 20630 if (!globalStyles?.styles?.blocks?.[name2]?.variations?.[variation]) { 20631 return void 0; 20632 } 20633 const replaceRefs = (variationStyles) => { 20634 Object.keys(variationStyles).forEach((key) => { 20635 const value = variationStyles[key]; 20636 if (typeof value === "object" && value !== null) { 20637 if (value.ref !== void 0) { 20638 if (typeof value.ref !== "string" || value.ref.trim() === "") { 20639 delete variationStyles[key]; 20640 } else { 20641 const refValue = getValueFromObjectPath( 20642 globalStyles, 20643 value.ref 20644 ); 20645 if (refValue !== void 0 && refValue !== null) { 20646 variationStyles[key] = refValue; 20647 } else { 20648 delete variationStyles[key]; 20649 } 20650 } 20651 } else { 20652 replaceRefs(value); 20653 if (Object.keys(value).length === 0) { 20654 delete variationStyles[key]; 20655 } 20656 } 20657 } 20658 }); 20659 }; 20660 const styles = JSON.parse( 20661 JSON.stringify( 20662 globalStyles.styles.blocks[name2].variations[variation] 20663 ) 20664 ); 20665 if (resolveRefs) { 20666 replaceRefs(styles); 20667 } 20668 return styles; 20669 } 20670 20671 // packages/global-styles-engine/build-module/resolve-style.mjs 20672 var DEFAULT_STATE_VALUE = "default"; 20673 function isDefaultBlockStyleState(selectedState) { 20674 const viewport = selectedState?.viewport; 20675 const pseudoState = selectedState?.pseudoState; 20676 return (!viewport || viewport === DEFAULT_STATE_VALUE) && (!pseudoState || pseudoState === DEFAULT_STATE_VALUE); 20677 } 20678 function getStyleStatePath(selectedState) { 20679 if (isDefaultBlockStyleState(selectedState)) { 20680 return []; 20681 } 20682 return [selectedState.viewport, selectedState.pseudoState].filter( 20683 (state) => !!state && state !== DEFAULT_STATE_VALUE 20684 ); 20685 } 20686 function getStyleForState(style, selectedState) { 20687 const path = getStyleStatePath(selectedState); 20688 if (!path.length) { 20689 return style; 20690 } 20691 return getValueFromObjectPath(style, path); 20692 } 20693 var TREE_STRUCTURAL_KEYS = /* @__PURE__ */ new Set(["blocks", "variations", "css"]); 20694 var EMPTY_INHERITANCE = Object.freeze({ 20695 value: {}, 20696 sources: {} 20697 }); 20698 var SOURCE_DESCRIPTORS = { 20699 root: { layer: "root" }, 20700 element: { layer: "element" }, 20701 block: { layer: "block" }, 20702 blockVariation: { layer: "blockVariation" } 20703 }; 20704 function createSourceDescriptor(type) { 20705 const descriptor = SOURCE_DESCRIPTORS[type]; 20706 if (!descriptor) { 20707 return null; 20708 } 20709 return { ...descriptor }; 20710 } 20711 function createContribution(styles, source) { 20712 if (!styles || !source) { 20713 return null; 20714 } 20715 return { styles, source }; 20716 } 20717 function getPathKey(path) { 20718 return path.join("."); 20719 } 20720 function getSourceForPath(source) { 20721 return { ...source }; 20722 } 20723 function isExplicitEmpty(value) { 20724 if (value === "" || value === null) { 20725 return true; 20726 } 20727 if (typeof value === "object" && !Array.isArray(value) && Object.keys(value).length === 0) { 20728 return true; 20729 } 20730 return false; 20731 } 20732 function isRefObject(value) { 20733 return value !== null && typeof value === "object" && !Array.isArray(value) && typeof value.ref === "string"; 20734 } 20735 function pickLayerRootContribution(layer) { 20736 if (!layer || typeof layer !== "object" || Array.isArray(layer)) { 20737 return null; 20738 } 20739 const contribution = {}; 20740 for (const key of Object.keys(layer)) { 20741 if (TREE_STRUCTURAL_KEYS.has(key)) { 20742 continue; 20743 } 20744 if (key === "elements") { 20745 if (layer.elements && typeof layer.elements === "object") { 20746 contribution.elements = layer.elements; 20747 } 20748 continue; 20749 } 20750 if (isExplicitEmpty(layer[key])) { 20751 continue; 20752 } 20753 contribution[key] = layer[key]; 20754 } 20755 return Object.keys(contribution).length === 0 ? null : contribution; 20756 } 20757 var ATOMIC_OBJECT_KEYS = /* @__PURE__ */ new Set(["backgroundImage"]); 20758 function deepMergeDroppingEmpties(target, source, globalStyles, sourceMetadata, sources, path = []) { 20759 if (!source || typeof source !== "object" || Array.isArray(source)) { 20760 return target; 20761 } 20762 for (const key of Object.keys(source)) { 20763 let sourceValue = source[key]; 20764 if (isExplicitEmpty(sourceValue)) { 20765 continue; 20766 } 20767 if (isRefObject(sourceValue)) { 20768 if (sourceValue.ref.trim() === "") { 20769 continue; 20770 } 20771 const resolved = getValueFromObjectPath( 20772 globalStyles, 20773 sourceValue.ref 20774 ); 20775 if (resolved === void 0 || resolved === null || isRefObject(resolved)) { 20776 continue; 20777 } 20778 sourceValue = resolved; 20779 } 20780 const nextPath = [...path, key]; 20781 if (!ATOMIC_OBJECT_KEYS.has(key) && sourceValue !== null && typeof sourceValue === "object" && !Array.isArray(sourceValue) && !isRefObject(sourceValue)) { 20782 const existing = target[key] && typeof target[key] === "object" && !Array.isArray(target[key]) ? target[key] : {}; 20783 target[key] = deepMergeDroppingEmpties( 20784 { ...existing }, 20785 sourceValue, 20786 globalStyles, 20787 sourceMetadata, 20788 sources, 20789 nextPath 20790 ); 20791 } else { 20792 target[key] = ATOMIC_OBJECT_KEYS.has(key) && sourceValue !== null && typeof sourceValue === "object" && !Array.isArray(sourceValue) ? { ...sourceValue } : sourceValue; 20793 if (sourceMetadata && sources) { 20794 sources[getPathKey(nextPath)] = getSourceForPath(sourceMetadata); 20795 } 20796 } 20797 } 20798 return target; 20799 } 20800 function getStateSlice(layerObject, selectedState) { 20801 if (!layerObject) { 20802 return null; 20803 } 20804 const slice = getStyleForState(layerObject, selectedState); 20805 return slice && typeof slice === "object" && !Array.isArray(slice) ? slice : null; 20806 } 20807 var NON_CASCADING_ROOT_PREFIXES = [ 20808 "color.background", 20809 "color.gradient", 20810 "background", 20811 "spacing", 20812 "dimensions", 20813 "border", 20814 "shadow", 20815 "filter" 20816 ]; 20817 function isNonCascadingRootPath(pathKey) { 20818 if (pathKey.startsWith("elements.")) { 20819 return false; 20820 } 20821 return NON_CASCADING_ROOT_PREFIXES.some( 20822 (prefix2) => pathKey === prefix2 || pathKey.startsWith(`$prefix2}.`) 20823 ); 20824 } 20825 function deleteAtPath(target, pathSegments) { 20826 if (!target || typeof target !== "object") { 20827 return; 20828 } 20829 const [head2, ...rest] = pathSegments; 20830 if (rest.length === 0) { 20831 delete target[head2]; 20832 return; 20833 } 20834 const child = target[head2]; 20835 if (child && typeof child === "object") { 20836 deleteAtPath(child, rest); 20837 if (Object.keys(child).length === 0) { 20838 delete target[head2]; 20839 } 20840 } 20841 } 20842 function dropNonCascadingRootLeaves(value, sources) { 20843 for (const pathKey of Object.keys(sources)) { 20844 if (sources[pathKey].layer === "root" && isNonCascadingRootPath(pathKey)) { 20845 deleteAtPath(value, pathKey.split(".")); 20846 delete sources[pathKey]; 20847 } 20848 } 20849 } 20850 function resolveThemeFileBackgroundImage(value, globalStyles, links) { 20851 const image = value?.background?.backgroundImage; 20852 if (!image) { 20853 return; 20854 } 20855 const resolved = getResolvedValue(image, { 20856 ...globalStyles, 20857 _links: links ?? void 0 20858 }); 20859 if (resolved !== void 0) { 20860 value.background.backgroundImage = resolved; 20861 } 20862 } 20863 function computeResolvedStyle(globalStyles, { 20864 blockName, 20865 variationName = null, 20866 elements: elements2 = null, 20867 viewport = null, 20868 pseudoState = null 20869 } = {}) { 20870 if (!globalStyles || !globalStyles.styles) { 20871 return EMPTY_INHERITANCE; 20872 } 20873 if (!blockName) { 20874 return EMPTY_INHERITANCE; 20875 } 20876 const styles = globalStyles.styles; 20877 const selectedState = { viewport, pseudoState }; 20878 const root = styles; 20879 const block = styles.blocks?.[blockName] ?? null; 20880 const elementLayers = (elements2 ?? []).map((elementName) => styles.elements?.[elementName] ?? null).filter((layer) => !!layer); 20881 const variation = variationName ? getVariationStyle(globalStyles, blockName, variationName) ?? null : null; 20882 const contributions = [ 20883 createContribution( 20884 pickLayerRootContribution(root), 20885 createSourceDescriptor("root") 20886 ), 20887 ...elementLayers.map( 20888 (layer) => createContribution( 20889 pickLayerRootContribution(layer), 20890 createSourceDescriptor("element") 20891 ) 20892 ), 20893 block ? createContribution( 20894 pickLayerRootContribution(block), 20895 createSourceDescriptor("block") 20896 ) : null, 20897 variation ? createContribution( 20898 pickLayerRootContribution(variation), 20899 createSourceDescriptor("blockVariation") 20900 ) : null 20901 ]; 20902 if (!isDefaultBlockStyleState(selectedState)) { 20903 contributions.push( 20904 createContribution( 20905 pickLayerRootContribution( 20906 getStateSlice(root, selectedState) 20907 ), 20908 createSourceDescriptor("root") 20909 ), 20910 ...elementLayers.map( 20911 (layer) => createContribution( 20912 pickLayerRootContribution( 20913 getStateSlice(layer, selectedState) 20914 ), 20915 createSourceDescriptor("element") 20916 ) 20917 ), 20918 block ? createContribution( 20919 pickLayerRootContribution( 20920 getStateSlice(block, selectedState) 20921 ), 20922 createSourceDescriptor("block") 20923 ) : null, 20924 variation ? createContribution( 20925 pickLayerRootContribution( 20926 getStateSlice(variation, selectedState) 20927 ), 20928 createSourceDescriptor("blockVariation") 20929 ) : null 20930 ); 20931 } 20932 const filteredContributions = contributions.filter( 20933 Boolean 20934 ); 20935 if (filteredContributions.length === 0) { 20936 return EMPTY_INHERITANCE; 20937 } 20938 const sources = {}; 20939 const value = filteredContributions.reduce( 20940 (mergedValue, contribution) => deepMergeDroppingEmpties( 20941 mergedValue, 20942 contribution.styles, 20943 globalStyles, 20944 contribution.source, 20945 sources 20946 ), 20947 {} 20948 ); 20949 dropNonCascadingRootLeaves(value, sources); 20950 resolveThemeFileBackgroundImage( 20951 value, 20952 globalStyles, 20953 globalStyles._links ?? null 20954 ); 20955 return { value, sources }; 20956 } 20957 var NO_LINKS = {}; 20958 var memo2 = /* @__PURE__ */ new WeakMap(); 20959 function resolveStyle2(globalStyles, context = {}) { 20960 const styleData = globalStyles?.styles; 20961 if (!styleData || typeof styleData !== "object") { 20962 return computeResolvedStyle(globalStyles, context); 20963 } 20964 let byLinks = memo2.get(styleData); 20965 if (!byLinks) { 20966 byLinks = /* @__PURE__ */ new WeakMap(); 20967 memo2.set(styleData, byLinks); 20968 } 20969 const linksKey = globalStyles?._links ?? NO_LINKS; 20970 let inner = byLinks.get(linksKey); 20971 if (!inner) { 20972 inner = /* @__PURE__ */ new Map(); 20973 byLinks.set(linksKey, inner); 20974 } 20975 const sliceKey = `$context.elements?.join(",") ?? ""}:$context.viewport ?? ""}:$context.pseudoState ?? ""}`; 20976 const key = (context.blockName || "") + "" + (context.variationName || "") + "" + sliceKey; 20977 if (inner.has(key)) { 20978 return inner.get(key); 20979 } 20980 const result = computeResolvedStyle(globalStyles, context); 20981 inner.set(key, result); 20982 return result; 20983 } 20984 20985 // packages/global-styles-engine/build-module/lock-unlock.mjs 20986 var import_private_apis3 = __toESM(require_private_apis(), 1); 20987 var { lock: lock3, unlock: unlock3 } = (0, import_private_apis3.__dangerousOptInToUnstableAPIsOnlyForCoreModules)( 20988 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.", 20989 "@wordpress/global-styles-engine" 20990 ); 20991 20992 // packages/global-styles-engine/build-module/private-apis.mjs 20993 var privateApis2 = {}; 20994 lock3(privateApis2, { 20995 getResponsiveMediaQueries, 20996 getViewportBreakpoints, 20997 getViewportBreakpointValueInPixels, 20998 resolveStyle: resolveStyle2, 20999 getVariationStyle 21000 }); 21001 21002 // packages/edit-site/build-module/components/block-editor/use-navigate-to-entity-record.mjs 21003 var import_data23 = __toESM(require_data(), 1); 21004 var import_router12 = __toESM(require_router(), 1); 21005 var import_element50 = __toESM(require_element(), 1); 21006 var import_url5 = __toESM(require_url(), 1); 21007 var import_core_data16 = __toESM(require_core_data(), 1); 21008 var import_editor12 = __toESM(require_editor(), 1); 21009 21010 // packages/edit-site/build-module/components/block-editor/use-viewport-sync.mjs 21011 var import_element49 = __toESM(require_element(), 1); 21012 var import_data22 = __toESM(require_data(), 1); 21013 var import_router11 = __toESM(require_router(), 1); 21014 var import_editor11 = __toESM(require_editor(), 1); 21015 var { useLocation: useLocation11 } = unlock(import_router11.privateApis); 21016 var DEFAULT_DEVICE_TYPE = "Desktop"; 21017 var VALID_DEVICE_TYPES = ["desktop", "tablet", "mobile"]; 21018 var capitalize = (str) => str.charAt(0).toUpperCase() + str.slice(1); 21019 function useViewportSync() { 21020 const { query } = useLocation11(); 21021 const { setDeviceType } = (0, import_data22.useDispatch)(import_editor11.store); 21022 (0, import_element49.useEffect)(() => { 21023 const viewport = query?.viewport?.toLowerCase(); 21024 const isValid2 = VALID_DEVICE_TYPES.includes(viewport); 21025 setDeviceType(isValid2 ? capitalize(viewport) : DEFAULT_DEVICE_TYPE); 21026 }, [query?.viewport, setDeviceType]); 21027 } 21028 function ViewportSync() { 21029 useViewportSync(); 21030 return null; 21031 } 21032 21033 // packages/edit-site/build-module/components/block-editor/use-navigate-to-entity-record.mjs 21034 var { useHistory: useHistory7, useLocation: useLocation12 } = unlock(import_router12.privateApis); 21035 var VALID_VIEWPORTS = ["desktop", "tablet", "mobile"]; 21036 function useNavigateToEntityRecord() { 21037 const history = useHistory7(); 21038 const location = useLocation12(); 21039 const { query, path } = location; 21040 const registry = (0, import_data23.useRegistry)(); 21041 const currentDeviceType = (0, import_data23.useSelect)( 21042 (select4) => select4(import_editor12.store).getDeviceType(), 21043 [] 21044 ); 21045 const onNavigateToEntityRecord = (0, import_element50.useCallback)( 21046 (params) => { 21047 const currentPostType = registry.select(import_editor12.store).getCurrentPostType(); 21048 const currentPostId = registry.select(import_editor12.store).getCurrentPostId(); 21049 const entityEdits = registry.select(import_core_data16.store).getEntityRecordEdits( 21050 "postType", 21051 currentPostType, 21052 currentPostId 21053 ); 21054 const externalClientId = entityEdits?.selection?.selectionStart?.clientId; 21055 const urlUpdates = { ...query }; 21056 if (externalClientId) { 21057 urlUpdates.selectedBlock = externalClientId; 21058 } 21059 const requestedViewport = typeof params.viewport === "string" ? params.viewport.toLowerCase() : void 0; 21060 const isValidRequestedViewport = VALID_VIEWPORTS.includes(requestedViewport); 21061 if (isValidRequestedViewport) { 21062 const currentViewportLower = (currentDeviceType || DEFAULT_DEVICE_TYPE).toLowerCase(); 21063 if (currentViewportLower === DEFAULT_DEVICE_TYPE.toLowerCase()) { 21064 delete urlUpdates.viewport; 21065 } else { 21066 urlUpdates.viewport = currentViewportLower; 21067 } 21068 } 21069 const hasUpdatesToSave = externalClientId || isValidRequestedViewport; 21070 if (hasUpdatesToSave) { 21071 history.navigate((0, import_url5.addQueryArgs)(path, urlUpdates), { 21072 replace: true 21073 }); 21074 } 21075 const queryArgs = { 21076 canvas: "edit", 21077 focusMode: true 21078 }; 21079 if (isValidRequestedViewport) { 21080 queryArgs.viewport = requestedViewport; 21081 } 21082 const url = (0, import_url5.addQueryArgs)( 21083 `/$params.postType}/$params.postId}`, 21084 queryArgs 21085 ); 21086 history.navigate(url); 21087 }, 21088 [history, path, query, registry, currentDeviceType] 21089 ); 21090 return onNavigateToEntityRecord; 21091 } 21092 21093 // packages/edit-site/build-module/components/block-editor/use-site-editor-settings.mjs 21094 var { useLocation: useLocation13, useHistory: useHistory8 } = unlock(import_router13.privateApis); 21095 var { useGlobalStyles: useGlobalStyles2 } = unlock(import_editor13.privateApis); 21096 function useNavigateToPreviousEntityRecord() { 21097 const location = useLocation13(); 21098 const previousCanvas = (0, import_compose3.usePrevious)(location.query.canvas); 21099 const history = useHistory8(); 21100 const goBack = (0, import_element51.useMemo)(() => { 21101 const isFocusMode = location.query.focusMode || location?.params?.postId && FOCUSABLE_ENTITIES.includes(location?.params?.postType); 21102 const didComeFromEditorCanvas = previousCanvas === "edit"; 21103 const showBackButton = isFocusMode && didComeFromEditorCanvas; 21104 return showBackButton ? () => history.back() : void 0; 21105 }, [location, history, previousCanvas]); 21106 return goBack; 21107 } 21108 function useSpecificEditorSettings() { 21109 const { query } = useLocation13(); 21110 const { canvas = "view" } = query; 21111 const onNavigateToEntityRecord = useNavigateToEntityRecord(); 21112 const { merged: mergedConfig } = useGlobalStyles2(); 21113 const { settings: settings2, currentPostIsTrashed } = (0, import_data24.useSelect)((select4) => { 21114 const { getSettings: getSettings7 } = select4(store); 21115 const { getCurrentPostAttribute } = select4(import_editor13.store); 21116 return { 21117 settings: getSettings7(), 21118 currentPostIsTrashed: getCurrentPostAttribute("status") === "trash" 21119 }; 21120 }, []); 21121 const onNavigateToPreviousEntityRecord = useNavigateToPreviousEntityRecord(); 21122 const [globalStyles, globalSettings] = (0, import_element51.useMemo)(() => { 21123 return generateGlobalStyles(mergedConfig, [], { 21124 disableRootPadding: false 21125 }); 21126 }, [mergedConfig]); 21127 const defaultEditorSettings = (0, import_element51.useMemo)(() => { 21128 const nonGlobalStyles = (settings2?.styles ?? []).filter( 21129 (style) => !style.isGlobalStyles 21130 ); 21131 return { 21132 ...settings2, 21133 styles: [ 21134 ...nonGlobalStyles, 21135 ...globalStyles, 21136 { 21137 // Forming a "block formatting context" to prevent margin collapsing. 21138 // @see https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Block_formatting_context 21139 css: canvas === "view" ? `body{min-height: 100vh; $currentPostIsTrashed ? "" : "cursor: pointer;"}}` : void 0 21140 } 21141 ], 21142 __experimentalFeatures: globalSettings, 21143 richEditingEnabled: true, 21144 supportsTemplateMode: true, 21145 focusMode: canvas !== "view", 21146 onNavigateToEntityRecord, 21147 onNavigateToPreviousEntityRecord, 21148 isPreviewMode: canvas === "view" 21149 }; 21150 }, [ 21151 settings2, 21152 globalStyles, 21153 globalSettings, 21154 canvas, 21155 currentPostIsTrashed, 21156 onNavigateToEntityRecord, 21157 onNavigateToPreviousEntityRecord 21158 ]); 21159 return defaultEditorSettings; 21160 } 21161 21162 // packages/edit-site/build-module/components/plugin-template-setting-panel/index.mjs 21163 var import_editor14 = __toESM(require_editor(), 1); 21164 var import_data25 = __toESM(require_data(), 1); 21165 var import_components16 = __toESM(require_components(), 1); 21166 var import_deprecated3 = __toESM(require_deprecated(), 1); 21167 var import_jsx_runtime116 = __toESM(require_jsx_runtime(), 1); 21168 var { Fill, Slot } = (0, import_components16.createSlotFill)("PluginTemplateSettingPanel"); 21169 var PluginTemplateSettingPanel = ({ children }) => { 21170 (0, import_deprecated3.default)("wp.editSite.PluginTemplateSettingPanel", { 21171 since: "6.6", 21172 version: "6.8", 21173 alternative: "wp.editor.PluginDocumentSettingPanel" 21174 }); 21175 const isCurrentEntityTemplate = (0, import_data25.useSelect)( 21176 (select4) => select4(import_editor14.store).getCurrentPostType() === "wp_template", 21177 [] 21178 ); 21179 if (!isCurrentEntityTemplate) { 21180 return null; 21181 } 21182 return /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(Fill, { children }); 21183 }; 21184 PluginTemplateSettingPanel.Slot = Slot; 21185 var plugin_template_setting_panel_default = PluginTemplateSettingPanel; 21186 21187 // packages/edit-site/build-module/components/more-menu/index.mjs 21188 var import_editor15 = __toESM(require_editor(), 1); 21189 21190 // packages/edit-site/build-module/components/more-menu/site-export.mjs 21191 var import_i18n16 = __toESM(require_i18n(), 1); 21192 var import_components17 = __toESM(require_components(), 1); 21193 var import_api_fetch2 = __toESM(require_api_fetch(), 1); 21194 var import_data26 = __toESM(require_data(), 1); 21195 var import_blob = __toESM(require_blob(), 1); 21196 var import_core_data17 = __toESM(require_core_data(), 1); 21197 var import_notices2 = __toESM(require_notices(), 1); 21198 var import_jsx_runtime117 = __toESM(require_jsx_runtime(), 1); 21199 function SiteExport() { 21200 const canExport = (0, import_data26.useSelect)((select4) => { 21201 const targetHints = select4(import_core_data17.store).getCurrentTheme()?._links?.["wp:export-theme"]?.[0]?.targetHints ?? {}; 21202 return !!targetHints.allow?.includes("GET"); 21203 }, []); 21204 const { createErrorNotice } = (0, import_data26.useDispatch)(import_notices2.store); 21205 if (!canExport) { 21206 return null; 21207 } 21208 async function handleExport() { 21209 try { 21210 const response = await (0, import_api_fetch2.default)({ 21211 path: "/wp-block-editor/v1/export", 21212 parse: false, 21213 headers: { 21214 Accept: "application/zip" 21215 } 21216 }); 21217 const blob = await response.blob(); 21218 const contentDisposition = response.headers.get( 21219 "content-disposition" 21220 ); 21221 const contentDispositionMatches = contentDisposition.match(/=(.+)\.zip/); 21222 const fileName = contentDispositionMatches[1] ? contentDispositionMatches[1] : "edit-site-export"; 21223 (0, import_blob.downloadBlob)(fileName + ".zip", blob, "application/zip"); 21224 } catch (errorResponse) { 21225 let error2 = {}; 21226 try { 21227 error2 = await errorResponse.json(); 21228 } catch { 21229 } 21230 const errorMessage = error2.message && error2.code !== "unknown_error" ? error2.message : (0, import_i18n16.__)("An error occurred while creating the site export."); 21231 createErrorNotice(errorMessage, { type: "snackbar" }); 21232 } 21233 } 21234 return /* @__PURE__ */ (0, import_jsx_runtime117.jsx)( 21235 import_components17.MenuItem, 21236 { 21237 role: "menuitem", 21238 icon: download_default, 21239 onClick: handleExport, 21240 info: (0, import_i18n16.__)( 21241 "Download your theme with updated templates and styles." 21242 ), 21243 children: (0, import_i18n16._x)("Export", "site exporter menu item") 21244 } 21245 ); 21246 } 21247 21248 // packages/edit-site/build-module/components/more-menu/welcome-guide-menu-item.mjs 21249 var import_i18n17 = __toESM(require_i18n(), 1); 21250 var import_data27 = __toESM(require_data(), 1); 21251 var import_components18 = __toESM(require_components(), 1); 21252 var import_preferences8 = __toESM(require_preferences(), 1); 21253 var import_jsx_runtime118 = __toESM(require_jsx_runtime(), 1); 21254 function WelcomeGuideMenuItem() { 21255 const { toggle } = (0, import_data27.useDispatch)(import_preferences8.store); 21256 return /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(import_components18.MenuItem, { onClick: () => toggle("core/edit-site", "welcomeGuide"), children: (0, import_i18n17.__)("Welcome Guide") }); 21257 } 21258 21259 // packages/edit-site/build-module/components/more-menu/index.mjs 21260 var import_jsx_runtime119 = __toESM(require_jsx_runtime(), 1); 21261 var { ToolsMoreMenuGroup, PreferencesModal } = unlock(import_editor15.privateApis); 21262 function MoreMenu() { 21263 return /* @__PURE__ */ (0, import_jsx_runtime119.jsxs)(import_jsx_runtime119.Fragment, { children: [ 21264 /* @__PURE__ */ (0, import_jsx_runtime119.jsxs)(ToolsMoreMenuGroup, { children: [ 21265 /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(SiteExport, {}), 21266 /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(WelcomeGuideMenuItem, {}) 21267 ] }), 21268 /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(PreferencesModal, {}) 21269 ] }); 21270 } 21271 21272 // packages/edit-site/build-module/components/block-editor/use-editor-iframe-props.mjs 21273 var import_data28 = __toESM(require_data(), 1); 21274 var import_keycodes2 = __toESM(require_keycodes(), 1); 21275 var import_element52 = __toESM(require_element(), 1); 21276 var import_i18n18 = __toESM(require_i18n(), 1); 21277 var import_editor16 = __toESM(require_editor(), 1); 21278 var import_router14 = __toESM(require_router(), 1); 21279 var import_url6 = __toESM(require_url(), 1); 21280 var { useLocation: useLocation14, useHistory: useHistory9 } = unlock(import_router14.privateApis); 21281 function useEditorIframeProps() { 21282 const { query, path } = useLocation14(); 21283 const history = useHistory9(); 21284 const { canvas = "view" } = query; 21285 const currentPostIsTrashed = (0, import_data28.useSelect)((select4) => { 21286 return select4(import_editor16.store).getCurrentPostAttribute("status") === "trash"; 21287 }, []); 21288 const [isFocused, setIsFocused] = (0, import_element52.useState)(false); 21289 (0, import_element52.useEffect)(() => { 21290 if (canvas === "edit") { 21291 setIsFocused(false); 21292 } 21293 }, [canvas]); 21294 const viewModeIframeProps = { 21295 "aria-label": (0, import_i18n18.__)("Edit"), 21296 "aria-disabled": currentPostIsTrashed, 21297 title: null, 21298 role: "button", 21299 tabIndex: 0, 21300 onFocus: () => setIsFocused(true), 21301 onBlur: () => setIsFocused(false), 21302 onKeyDown: (event) => { 21303 const { keyCode } = event; 21304 if ((keyCode === import_keycodes2.ENTER || keyCode === import_keycodes2.SPACE) && !currentPostIsTrashed) { 21305 event.preventDefault(); 21306 history.navigate((0, import_url6.addQueryArgs)(path, { canvas: "edit" }), { 21307 transition: "canvas-mode-edit-transition" 21308 }); 21309 } 21310 }, 21311 onClick: () => history.navigate((0, import_url6.addQueryArgs)(path, { canvas: "edit" }), { 21312 transition: "canvas-mode-edit-transition" 21313 }), 21314 onClickCapture: (event) => { 21315 if (currentPostIsTrashed) { 21316 event.preventDefault(); 21317 event.stopPropagation(); 21318 } 21319 }, 21320 readonly: true 21321 }; 21322 return { 21323 className: clsx_default("edit-site-visual-editor__editor-canvas", { 21324 "is-focused": isFocused && canvas === "view" 21325 }), 21326 ...canvas === "view" ? viewModeIframeProps : {} 21327 }; 21328 } 21329 21330 // packages/edit-site/build-module/components/editor/use-editor-title.mjs 21331 var import_i18n20 = __toESM(require_i18n(), 1); 21332 var import_data30 = __toESM(require_data(), 1); 21333 var import_core_data19 = __toESM(require_core_data(), 1); 21334 var import_html_entities2 = __toESM(require_html_entities(), 1); 21335 var import_editor17 = __toESM(require_editor(), 1); 21336 21337 // packages/edit-site/build-module/components/routes/use-title.mjs 21338 var import_element53 = __toESM(require_element(), 1); 21339 var import_data29 = __toESM(require_data(), 1); 21340 var import_core_data18 = __toESM(require_core_data(), 1); 21341 var import_i18n19 = __toESM(require_i18n(), 1); 21342 var import_a11y = __toESM(require_a11y(), 1); 21343 var import_html_entities = __toESM(require_html_entities(), 1); 21344 var import_router15 = __toESM(require_router(), 1); 21345 var { useLocation: useLocation15 } = unlock(import_router15.privateApis); 21346 function useTitle(title) { 21347 const location = useLocation15(); 21348 const siteTitle = (0, import_data29.useSelect)( 21349 (select4) => select4(import_core_data18.store).getEntityRecord("root", "site")?.title, 21350 [] 21351 ); 21352 const isInitialLocationRef = (0, import_element53.useRef)(true); 21353 (0, import_element53.useEffect)(() => { 21354 isInitialLocationRef.current = false; 21355 }, [location]); 21356 (0, import_element53.useEffect)(() => { 21357 if (isInitialLocationRef.current) { 21358 return; 21359 } 21360 if (title && siteTitle) { 21361 const formattedTitle = (0, import_i18n19.sprintf)( 21362 /* translators: Admin document title. 1: Admin screen name, 2: Network or site name. */ 21363 (0, import_i18n19.__)("%1$s \u2039 %2$s \u2039 Editor \u2014 WordPress"), 21364 (0, import_html_entities.decodeEntities)(title), 21365 (0, import_html_entities.decodeEntities)(siteTitle) 21366 ); 21367 document.title = formattedTitle; 21368 (0, import_a11y.speak)(title, "assertive"); 21369 } 21370 }, [title, siteTitle, location]); 21371 } 21372 21373 // packages/edit-site/build-module/components/editor/use-editor-title.mjs 21374 var { getTemplateInfo } = unlock(import_editor17.privateApis); 21375 function useEditorTitle(postType2, postId) { 21376 const { title, isLoaded } = (0, import_data30.useSelect)( 21377 (select4) => { 21378 const { 21379 getEditedEntityRecord, 21380 getCurrentTheme, 21381 hasFinishedResolution 21382 } = select4(import_core_data19.store); 21383 if (!postId) { 21384 return { isLoaded: false }; 21385 } 21386 const _record = getEditedEntityRecord( 21387 "postType", 21388 postType2, 21389 postId 21390 ); 21391 const { default_template_types: templateTypes = [] } = getCurrentTheme() ?? {}; 21392 const templateInfo = getTemplateInfo({ 21393 template: _record, 21394 templateTypes 21395 }); 21396 const _isLoaded = hasFinishedResolution("getEditedEntityRecord", [ 21397 "postType", 21398 postType2, 21399 postId 21400 ]); 21401 return { 21402 title: templateInfo.title, 21403 isLoaded: _isLoaded 21404 }; 21405 }, 21406 [postType2, postId] 21407 ); 21408 let editorTitle; 21409 if (isLoaded) { 21410 editorTitle = (0, import_i18n20.sprintf)( 21411 // translators: A breadcrumb trail for the Admin document title. 1: title of template being edited, 2: type of template (Template or Template Part). 21412 (0, import_i18n20._x)("%1$s \u2039 %2$s", "breadcrumb trail"), 21413 (0, import_html_entities2.decodeEntities)(title), 21414 POST_TYPE_LABELS[postType2] ?? POST_TYPE_LABELS[TEMPLATE_POST_TYPE] 21415 ); 21416 } 21417 useTitle(isLoaded && editorTitle); 21418 } 21419 var use_editor_title_default = useEditorTitle; 21420 21421 // packages/edit-site/build-module/components/editor/use-revisions-url-sync.mjs 21422 var import_data31 = __toESM(require_data(), 1); 21423 var import_element54 = __toESM(require_element(), 1); 21424 var import_editor18 = __toESM(require_editor(), 1); 21425 var import_router16 = __toESM(require_router(), 1); 21426 var import_url7 = __toESM(require_url(), 1); 21427 var { useHistory: useHistory10, useLocation: useLocation16 } = unlock(import_router16.privateApis); 21428 var URL_WRITE_DEBOUNCE_MS = 300; 21429 function useRevisionsURLSync(enabled, postType2, postId) { 21430 const location = useLocation16(); 21431 const history = useHistory10(); 21432 const { currentPostType, currentPostId, currentRevisionId } = (0, import_data31.useSelect)( 21433 (select4) => { 21434 const editor = select4(import_editor18.store); 21435 return { 21436 currentPostType: editor.getCurrentPostType(), 21437 currentPostId: editor.getCurrentPostId(), 21438 currentRevisionId: unlock(editor).getCurrentRevisionId() 21439 }; 21440 }, 21441 [] 21442 ); 21443 const { openRevision, setCurrentRevisionId } = unlock( 21444 (0, import_data31.useDispatch)(import_editor18.store) 21445 ); 21446 const entityKey = postType2 && postId ? `$postType2}:$postId}` : null; 21447 const isCurrentEntity = !!entityKey && currentPostType === postType2 && String(currentPostId) === String(postId); 21448 const handledEntityKeyRef = (0, import_element54.useRef)(null); 21449 const lastURLWriteTimeRef = (0, import_element54.useRef)(null); 21450 (0, import_element54.useEffect)(() => { 21451 if (!enabled) { 21452 handledEntityKeyRef.current = null; 21453 return; 21454 } 21455 if (!isCurrentEntity || !entityKey || handledEntityKeyRef.current === entityKey) { 21456 return; 21457 } 21458 lastURLWriteTimeRef.current = null; 21459 handledEntityKeyRef.current = entityKey; 21460 const revision = Number(location.query.revision); 21461 if (Number.isInteger(revision) && revision > 0) { 21462 openRevision(revision); 21463 } else if (currentRevisionId) { 21464 setCurrentRevisionId(null); 21465 } 21466 }, [ 21467 enabled, 21468 isCurrentEntity, 21469 entityKey, 21470 location.query.revision, 21471 currentRevisionId, 21472 openRevision, 21473 setCurrentRevisionId 21474 ]); 21475 (0, import_element54.useEffect)(() => { 21476 if (!enabled || !isCurrentEntity || !entityKey || handledEntityKeyRef.current !== entityKey) { 21477 return; 21478 } 21479 if (lastURLWriteTimeRef.current === null) { 21480 lastURLWriteTimeRef.current = Date.now(); 21481 } 21482 const revisionArg = currentRevisionId ? String(currentRevisionId) : void 0; 21483 if (location.query.revision === revisionArg) { 21484 return; 21485 } 21486 const write = async () => { 21487 const addressBarArg = new URLSearchParams(window.location.search).get( 21488 "revision" 21489 ) ?? void 0; 21490 if (addressBarArg !== location.query.revision) { 21491 return; 21492 } 21493 lastURLWriteTimeRef.current = Date.now(); 21494 try { 21495 await history.navigate( 21496 (0, import_url7.addQueryArgs)(location.path, { revision: revisionArg }), 21497 { replace: true } 21498 ); 21499 } catch { 21500 } 21501 }; 21502 if (Date.now() - lastURLWriteTimeRef.current >= URL_WRITE_DEBOUNCE_MS) { 21503 write(); 21504 return; 21505 } 21506 const timeoutId = setTimeout(write, URL_WRITE_DEBOUNCE_MS); 21507 return () => clearTimeout(timeoutId); 21508 }, [ 21509 enabled, 21510 isCurrentEntity, 21511 entityKey, 21512 currentRevisionId, 21513 location, 21514 history 21515 ]); 21516 } 21517 21518 // packages/edit-site/build-module/components/editor/use-adapt-editor-to-canvas.mjs 21519 var import_data32 = __toESM(require_data(), 1); 21520 var import_block_editor4 = __toESM(require_block_editor(), 1); 21521 var import_editor19 = __toESM(require_editor(), 1); 21522 var import_element55 = __toESM(require_element(), 1); 21523 var import_preferences9 = __toESM(require_preferences(), 1); 21524 function useAdaptEditorToCanvas(canvas) { 21525 const { clearSelectedBlock } = (0, import_data32.useDispatch)(import_block_editor4.store); 21526 const { 21527 editPost, 21528 setDeviceType, 21529 closePublishSidebar, 21530 setIsListViewOpened: setIsListViewOpened2, 21531 setIsInserterOpened: setIsInserterOpened2 21532 } = (0, import_data32.useDispatch)(import_editor19.store); 21533 const { get: getPreference } = (0, import_data32.useSelect)(import_preferences9.store); 21534 const { getCurrentPost } = (0, import_data32.useSelect)(import_editor19.store); 21535 const registry = (0, import_data32.useRegistry)(); 21536 (0, import_element55.useLayoutEffect)(() => { 21537 const isMediumOrBigger = window.matchMedia("(min-width: 782px)").matches; 21538 registry.batch(() => { 21539 clearSelectedBlock(); 21540 if (getCurrentPost()?.type) { 21541 editPost({ selection: void 0 }, { undoIgnore: true }); 21542 } 21543 setDeviceType(DEFAULT_DEVICE_TYPE); 21544 closePublishSidebar(); 21545 setIsInserterOpened2(false); 21546 if (isMediumOrBigger && canvas === "edit" && getPreference("core", "showListViewByDefault") && !getPreference("core", "distractionFree")) { 21547 setIsListViewOpened2(true); 21548 } else { 21549 setIsListViewOpened2(false); 21550 } 21551 }); 21552 }, [ 21553 canvas, 21554 registry, 21555 clearSelectedBlock, 21556 editPost, 21557 setDeviceType, 21558 closePublishSidebar, 21559 setIsInserterOpened2, 21560 setIsListViewOpened2, 21561 getPreference, 21562 getCurrentPost 21563 ]); 21564 } 21565 21566 // packages/edit-site/build-module/components/editor/use-resolve-edited-entity.mjs 21567 var import_element56 = __toESM(require_element(), 1); 21568 var import_data33 = __toESM(require_data(), 1); 21569 var import_core_data20 = __toESM(require_core_data(), 1); 21570 var import_router17 = __toESM(require_router(), 1); 21571 var { useLocation: useLocation17 } = unlock(import_router17.privateApis); 21572 var postTypesWithoutParentTemplate = [ 21573 ATTACHMENT_POST_TYPE, 21574 TEMPLATE_POST_TYPE, 21575 TEMPLATE_PART_POST_TYPE, 21576 NAVIGATION_POST_TYPE, 21577 PATTERN_TYPES.user 21578 ]; 21579 var authorizedPostTypes = ["page", "post"]; 21580 function getPostType(name2) { 21581 let postType2; 21582 if (name2 === "navigation-item") { 21583 postType2 = NAVIGATION_POST_TYPE; 21584 } else if (name2 === "pattern-item") { 21585 postType2 = PATTERN_TYPES.user; 21586 } else if (name2 === "template-part-item") { 21587 postType2 = TEMPLATE_PART_POST_TYPE; 21588 } else if (name2 === "templates") { 21589 postType2 = TEMPLATE_POST_TYPE; 21590 } else if (name2 === "template-item") { 21591 postType2 = TEMPLATE_POST_TYPE; 21592 } else if (name2 === "page-item" || name2 === "pages") { 21593 postType2 = "page"; 21594 } else if (name2 === "post-item" || name2 === "posts") { 21595 postType2 = "post"; 21596 } 21597 return postType2; 21598 } 21599 function useResolveEditedEntity() { 21600 const { editEntityRecord } = (0, import_data33.useDispatch)(import_core_data20.store); 21601 const { hasEntityRecord } = (0, import_data33.useSelect)(import_core_data20.store); 21602 const { name: name2, params = {}, query } = useLocation17(); 21603 const { postId = query?.postId } = params; 21604 const postType2 = getPostType(name2, postId) ?? query?.postType; 21605 const { selectedBlock } = query; 21606 const appliedSelectionRef = (0, import_element56.useRef)(null); 21607 const homePage = (0, import_data33.useSelect)((select4) => { 21608 const { getHomePage } = unlock(select4(import_core_data20.store)); 21609 return getHomePage(); 21610 }, []); 21611 const resolvedTemplateId = (0, import_data33.useSelect)( 21612 (select4) => { 21613 if (postTypesWithoutParentTemplate.includes(postType2) && postId) { 21614 return; 21615 } 21616 if (postId && postId.includes(",")) { 21617 return; 21618 } 21619 const { getTemplateId } = unlock(select4(import_core_data20.store)); 21620 if (postType2 && postId && authorizedPostTypes.includes(postType2)) { 21621 return getTemplateId(postType2, postId); 21622 } 21623 if (homePage?.postType === "page") { 21624 return getTemplateId("page", homePage?.postId); 21625 } 21626 if (homePage?.postType === "wp_template") { 21627 return homePage?.postId; 21628 } 21629 }, 21630 [homePage, postId, postType2] 21631 ); 21632 const context = (0, import_element56.useMemo)(() => { 21633 if (postTypesWithoutParentTemplate.includes(postType2) && postId) { 21634 return {}; 21635 } 21636 if (postType2 && postId && authorizedPostTypes.includes(postType2)) { 21637 return { postType: postType2, postId }; 21638 } 21639 if (homePage?.postType === "page") { 21640 return { postType: "page", postId: homePage?.postId }; 21641 } 21642 return {}; 21643 }, [homePage, postType2, postId]); 21644 let entity; 21645 if (postTypesWithoutParentTemplate.includes(postType2) && postId) { 21646 entity = { isReady: true, postType: postType2, postId, context }; 21647 } else if (!!homePage) { 21648 entity = { 21649 isReady: resolvedTemplateId !== void 0, 21650 postType: TEMPLATE_POST_TYPE, 21651 postId: resolvedTemplateId, 21652 context 21653 }; 21654 } else { 21655 entity = { isReady: false }; 21656 } 21657 if (selectedBlock && entity.isReady && appliedSelectionRef.current !== selectedBlock) { 21658 const selectionPostType = entity.context?.postId ? entity.context.postType : entity.postType; 21659 const selectionPostId = entity.context?.postId ? entity.context.postId : entity.postId; 21660 if (hasEntityRecord("postType", selectionPostType, selectionPostId)) { 21661 editEntityRecord( 21662 "postType", 21663 selectionPostType, 21664 selectionPostId, 21665 { 21666 selection: { 21667 selectionStart: { clientId: selectedBlock }, 21668 selectionEnd: { clientId: selectedBlock } 21669 } 21670 }, 21671 { undoIgnore: true } 21672 ); 21673 appliedSelectionRef.current = selectedBlock; 21674 } 21675 } 21676 return entity; 21677 } 21678 function useSyncDeprecatedEntityIntoState({ 21679 postType: postType2, 21680 postId, 21681 context, 21682 isReady 21683 }) { 21684 const { setEditedEntity: setEditedEntity2 } = (0, import_data33.useDispatch)(store); 21685 (0, import_element56.useEffect)(() => { 21686 if (isReady) { 21687 setEditedEntity2(postType2, String(postId), context); 21688 } 21689 }, [isReady, postType2, postId, context, setEditedEntity2]); 21690 } 21691 21692 // packages/edit-site/build-module/components/editor/site-preview.mjs 21693 var import_i18n21 = __toESM(require_i18n(), 1); 21694 var import_data34 = __toESM(require_data(), 1); 21695 var import_core_data21 = __toESM(require_core_data(), 1); 21696 var import_dom24 = __toESM(require_dom(), 1); 21697 var import_url8 = __toESM(require_url(), 1); 21698 var import_jsx_runtime120 = __toESM(require_jsx_runtime(), 1); 21699 function SitePreview() { 21700 const siteUrl = (0, import_data34.useSelect)((select4) => { 21701 const { getEntityRecord } = select4(import_core_data21.store); 21702 const siteData = getEntityRecord("root", "__unstableBase"); 21703 return siteData?.home; 21704 }, []); 21705 return /* @__PURE__ */ (0, import_jsx_runtime120.jsx)( 21706 "iframe", 21707 { 21708 src: (0, import_url8.addQueryArgs)(siteUrl, { 21709 // Parameter for hiding the admin bar. 21710 wp_site_preview: 1 21711 }), 21712 title: (0, import_i18n21.__)("Site Preview"), 21713 style: { 21714 display: "block", 21715 width: "100%", 21716 height: "100%", 21717 backgroundColor: "#fff" 21718 }, 21719 onLoad: (event) => { 21720 const document2 = event.target.contentDocument; 21721 const focusableElements = import_dom24.focus.focusable.find(document2); 21722 focusableElements.forEach((element) => { 21723 element.style.pointerEvents = "none"; 21724 element.tabIndex = -1; 21725 element.setAttribute("aria-hidden", "true"); 21726 }); 21727 } 21728 } 21729 ); 21730 } 21731 21732 // packages/edit-site/build-module/components/editor/index.mjs 21733 var import_jsx_runtime121 = __toESM(require_jsx_runtime(), 1); 21734 var { Editor, BackButton } = unlock(import_editor20.privateApis); 21735 var { useHistory: useHistory11, useLocation: useLocation18 } = unlock(import_router18.privateApis); 21736 var { BlockKeyboardShortcuts } = unlock(import_block_library.privateApis); 21737 function getListPathForPostType(postType2) { 21738 switch (postType2) { 21739 case "navigation": 21740 return "/navigation"; 21741 case "wp_block": 21742 return "/pattern?postType=wp_block"; 21743 case "wp_template_part": 21744 return "/pattern?postType=wp_template_part"; 21745 case "wp_template": 21746 return "/template"; 21747 case "page": 21748 return "/page"; 21749 case "post": 21750 return "/"; 21751 } 21752 throw "Unknown post type"; 21753 } 21754 function getNavigationPath(location, postType2) { 21755 const { path, name: name2 } = location; 21756 if ([ 21757 "pattern-item", 21758 "template-part-item", 21759 "page-item", 21760 "template-item", 21761 "static-template-item", 21762 "post-item" 21763 ].includes(name2)) { 21764 return getListPathForPostType(postType2); 21765 } 21766 return (0, import_url9.addQueryArgs)(path, { canvas: void 0, revision: void 0 }); 21767 } 21768 function EditSiteEditor({ isHomeRoute = false }) { 21769 const location = useLocation18(); 21770 const history = useHistory11(); 21771 const { canvas = "view" } = location.query; 21772 const isLoading = useIsSiteEditorLoading(); 21773 useAdaptEditorToCanvas(canvas); 21774 const entity = useResolveEditedEntity(); 21775 useSyncDeprecatedEntityIntoState(entity); 21776 const { postType: postType2, postId, context } = entity; 21777 const isBlockBasedTheme = (0, import_data35.useSelect)( 21778 (select4) => select4(import_core_data22.store).getCurrentTheme()?.is_block_theme, 21779 [] 21780 ); 21781 const postWithTemplate = !!context?.postId; 21782 const editorPostType = postWithTemplate ? context.postType : postType2; 21783 const editorPostId = postWithTemplate ? context.postId : postId; 21784 use_editor_title_default(editorPostType, editorPostId); 21785 const _isPreviewingTheme = isPreviewingTheme(); 21786 const iframeProps = useEditorIframeProps(); 21787 const isEditMode = canvas === "edit"; 21788 useRevisionsURLSync(isEditMode, editorPostType, editorPostId); 21789 const loadingProgressId = (0, import_compose4.useInstanceId)( 21790 CanvasLoader, 21791 "edit-site-editor__loading-progress" 21792 ); 21793 const editorSettings = useSpecificEditorSettings(); 21794 const { resetZoomLevel } = unlock((0, import_data35.useDispatch)(import_block_editor5.store)); 21795 const { setCurrentRevisionId } = unlock((0, import_data35.useDispatch)(import_editor20.store)); 21796 const { createSuccessNotice } = (0, import_data35.useDispatch)(import_notices3.store); 21797 const onActionPerformed = (0, import_element57.useCallback)( 21798 (actionId, items) => { 21799 switch (actionId) { 21800 case "move-to-trash": 21801 case "delete-post": 21802 { 21803 history.navigate( 21804 getListPathForPostType( 21805 postWithTemplate ? context.postType : postType2 21806 ) 21807 ); 21808 } 21809 break; 21810 case "duplicate-post": 21811 { 21812 const newItem = items[0]; 21813 const _title = typeof newItem.title === "string" ? newItem.title : newItem.title?.rendered; 21814 createSuccessNotice( 21815 (0, import_i18n22.sprintf)( 21816 // translators: %s: Title of the created post or template, e.g: "Hello world". 21817 (0, import_i18n22.__)('"%s" successfully created.'), 21818 (0, import_html_entities3.decodeEntities)(_title) || (0, import_i18n22.__)("(no title)") 21819 ), 21820 { 21821 type: "snackbar", 21822 id: "duplicate-post-action", 21823 actions: [ 21824 { 21825 label: (0, import_i18n22.__)("Edit"), 21826 onClick: () => { 21827 history.navigate( 21828 `/$newItem.type}/$newItem.id}?canvas=edit` 21829 ); 21830 } 21831 } 21832 ] 21833 } 21834 ); 21835 } 21836 break; 21837 } 21838 }, 21839 [ 21840 postType2, 21841 context?.postType, 21842 postWithTemplate, 21843 history, 21844 createSuccessNotice 21845 ] 21846 ); 21847 const isReady = !isLoading; 21848 return !isBlockBasedTheme && isHomeRoute ? /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(SitePreview, {}) : /* @__PURE__ */ (0, import_jsx_runtime121.jsxs)(import_jsx_runtime121.Fragment, { children: [ 21849 /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(import_editor20.EditorKeyboardShortcutsRegister, {}), 21850 isEditMode && /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(BlockKeyboardShortcuts, {}), 21851 !isReady ? /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(CanvasLoader, { id: loadingProgressId }) : null, 21852 isEditMode && isReady && /* @__PURE__ */ (0, import_jsx_runtime121.jsx)( 21853 WelcomeGuide, 21854 { 21855 postType: postWithTemplate ? context.postType : postType2 21856 } 21857 ), 21858 isReady && /* @__PURE__ */ (0, import_jsx_runtime121.jsxs)( 21859 Editor, 21860 { 21861 postType: postWithTemplate ? context.postType : postType2, 21862 postId: postWithTemplate ? context.postId : postId, 21863 templateId: postWithTemplate ? postId : void 0, 21864 settings: editorSettings, 21865 className: "edit-site-editor__editor-interface", 21866 customSaveButton: _isPreviewingTheme && /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(SaveButton, { size: "compact" }), 21867 customSavePanel: _isPreviewingTheme && /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(SavePanel, {}), 21868 iframeProps, 21869 onActionPerformed, 21870 extraSidebarPanels: !postWithTemplate && /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(plugin_template_setting_panel_default.Slot, {}), 21871 children: [ 21872 isEditMode && /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(ViewportSync, {}), 21873 isEditMode && /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(BackButton, { children: ({ length }) => length <= 1 && /* @__PURE__ */ (0, import_jsx_runtime121.jsx)( 21874 import_components19.Button, 21875 { 21876 size: "compact", 21877 label: (0, import_i18n22.__)("Open Navigation"), 21878 showTooltip: true, 21879 tooltipPosition: "middle right", 21880 onClick: () => { 21881 resetZoomLevel(); 21882 setCurrentRevisionId(null); 21883 history.navigate( 21884 getNavigationPath( 21885 location, 21886 postWithTemplate ? context.postType : postType2 21887 ), 21888 { 21889 transition: "canvas-mode-view-transition" 21890 } 21891 ); 21892 }, 21893 icon: (0, import_i18n22.isRTL)() ? chevron_right_default : chevron_left_default 21894 } 21895 ) }), 21896 /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(MoreMenu, {}) 21897 ] 21898 } 21899 ) 21900 ] }); 21901 } 21902 21903 // packages/edit-site/build-module/components/site-editor-routes/utils.mjs 21904 function isThemeDataLoaded(siteData) { 21905 return siteData.currentTheme !== void 0 && siteData.currentTheme !== null; 21906 } 21907 function isClassicThemeWithStyleBookSupport(siteData) { 21908 const isBlockTheme = siteData.currentTheme?.is_block_theme; 21909 const supportsEditorStyles = siteData.currentTheme?.theme_supports["editor-styles"]; 21910 const hasThemeJson = siteData.editorSettings?.supportsLayout; 21911 return !isBlockTheme && (supportsEditorStyles || hasThemeJson); 21912 } 21913 21914 // packages/edit-site/build-module/components/site-editor-routes/home.mjs 21915 var import_jsx_runtime122 = __toESM(require_jsx_runtime(), 1); 21916 var homeRoute = { 21917 name: "home", 21918 path: "/", 21919 areas: { 21920 sidebar({ siteData }) { 21921 if (!isThemeDataLoaded(siteData)) { 21922 return null; 21923 } 21924 return siteData.currentTheme.is_block_theme || isClassicThemeWithStyleBookSupport(siteData) ? /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(SidebarNavigationScreenMain, {}) : /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(SidebarNavigationScreenUnsupported, {}); 21925 }, 21926 preview({ siteData }) { 21927 const isBlockTheme = siteData.currentTheme?.is_block_theme; 21928 return isBlockTheme || isClassicThemeWithStyleBookSupport(siteData) ? /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(EditSiteEditor, { isHomeRoute: true }) : void 0; 21929 }, 21930 mobileSidebar({ siteData }) { 21931 if (!isThemeDataLoaded(siteData)) { 21932 return /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(import_jsx_runtime122.Fragment, {}); 21933 } 21934 return siteData.currentTheme.is_block_theme || isClassicThemeWithStyleBookSupport(siteData) ? /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(SidebarNavigationScreenMain, {}) : /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(SidebarNavigationScreenUnsupported, {}); 21935 } 21936 } 21937 }; 21938 21939 // packages/edit-site/build-module/components/sidebar-navigation-screen-identity/index.mjs 21940 var import_i18n23 = __toESM(require_i18n(), 1); 21941 var import_jsx_runtime123 = __toESM(require_jsx_runtime(), 1); 21942 function SidebarNavigationScreenIdentity() { 21943 return /* @__PURE__ */ (0, import_jsx_runtime123.jsx)( 21944 SidebarNavigationScreen, 21945 { 21946 isRoot: true, 21947 title: (0, import_i18n23.__)("Design"), 21948 description: (0, import_i18n23.__)( 21949 "Customize the appearance of your website using the block editor." 21950 ), 21951 content: /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(MainSidebarNavigationContent, {}) 21952 } 21953 ); 21954 } 21955 21956 // packages/edit-site/build-module/components/sidebar-identity/index.mjs 21957 var import_i18n74 = __toESM(require_i18n(), 1); 21958 var import_data42 = __toESM(require_data(), 1); 21959 var import_core_data24 = __toESM(require_core_data(), 1); 21960 21961 // packages/dataviews/build-module/dataviews/index.mjs 21962 var import_element117 = __toESM(require_element(), 1); 21963 var import_compose18 = __toESM(require_compose(), 1); 21964 21965 // packages/dataviews/build-module/components/dataviews-context/index.mjs 21966 var import_element58 = __toESM(require_element(), 1); 21967 21968 // packages/dataviews/build-module/constants.mjs 21969 var import_i18n24 = __toESM(require_i18n(), 1); 21970 var OPERATOR_IS_ANY2 = "isAny"; 21971 var OPERATOR_IS_NONE2 = "isNone"; 21972 var OPERATOR_IS_ALL = "isAll"; 21973 var OPERATOR_IS_NOT_ALL = "isNotAll"; 21974 var OPERATOR_BETWEEN = "between"; 21975 var OPERATOR_IN_THE_PAST = "inThePast"; 21976 var OPERATOR_OVER = "over"; 21977 var OPERATOR_IS = "is"; 21978 var OPERATOR_IS_NOT = "isNot"; 21979 var OPERATOR_LESS_THAN = "lessThan"; 21980 var OPERATOR_GREATER_THAN = "greaterThan"; 21981 var OPERATOR_LESS_THAN_OR_EQUAL = "lessThanOrEqual"; 21982 var OPERATOR_GREATER_THAN_OR_EQUAL = "greaterThanOrEqual"; 21983 var OPERATOR_BEFORE2 = "before"; 21984 var OPERATOR_AFTER2 = "after"; 21985 var OPERATOR_BEFORE_INC = "beforeInc"; 21986 var OPERATOR_AFTER_INC = "afterInc"; 21987 var OPERATOR_CONTAINS = "contains"; 21988 var OPERATOR_NOT_CONTAINS = "notContains"; 21989 var OPERATOR_STARTS_WITH = "startsWith"; 21990 var OPERATOR_ON = "on"; 21991 var OPERATOR_NOT_ON = "notOn"; 21992 var SORTING_DIRECTIONS = ["asc", "desc"]; 21993 var sortArrows = { asc: "\u2191", desc: "\u2193" }; 21994 var sortValues = { asc: "ascending", desc: "descending" }; 21995 var sortLabels = { 21996 asc: (0, import_i18n24.__)("Sort ascending"), 21997 desc: (0, import_i18n24.__)("Sort descending") 21998 }; 21999 var sortIcons = { 22000 asc: arrow_up_default, 22001 desc: arrow_down_default 22002 }; 22003 var LAYOUT_TABLE = "table"; 22004 var LAYOUT_GRID = "grid"; 22005 var LAYOUT_LIST2 = "list"; 22006 var LAYOUT_ACTIVITY = "activity"; 22007 var LAYOUT_PICKER_GRID = "pickerGrid"; 22008 var LAYOUT_PICKER_TABLE = "pickerTable"; 22009 var LAYOUT_PICKER_ACTIVITY = "pickerActivity"; 22010 22011 // packages/dataviews/build-module/components/dataviews-context/index.mjs 22012 var DataViewsContext = (0, import_element58.createContext)({ 22013 view: { type: LAYOUT_TABLE }, 22014 onChangeView: () => { 22015 }, 22016 fields: [], 22017 data: [], 22018 paginationInfo: { 22019 totalItems: 0, 22020 totalPages: 0 22021 }, 22022 selection: [], 22023 onChangeSelection: () => { 22024 }, 22025 setOpenedFilter: () => { 22026 }, 22027 openedFilter: null, 22028 getItemId: (item) => item.id, 22029 isItemClickable: () => true, 22030 renderItemLink: void 0, 22031 containerWidth: 0, 22032 containerRef: (0, import_element58.createRef)(), 22033 resizeObserverRef: () => { 22034 }, 22035 defaultLayouts: { list: {}, grid: {}, table: {} }, 22036 filters: [], 22037 isShowingFilter: false, 22038 setIsShowingFilter: () => { 22039 }, 22040 hasInitiallyLoaded: false, 22041 config: { 22042 perPageSizes: [] 22043 }, 22044 intersectionObserver: null 22045 }); 22046 DataViewsContext.displayName = "DataViewsContext"; 22047 var dataviews_context_default = DataViewsContext; 22048 22049 // packages/dataviews/build-module/components/dataviews-layouts/index.mjs 22050 var import_i18n45 = __toESM(require_i18n(), 1); 22051 22052 // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs 22053 var import_i18n32 = __toESM(require_i18n(), 1); 22054 var import_components25 = __toESM(require_components(), 1); 22055 var import_element67 = __toESM(require_element(), 1); 22056 var import_keycodes4 = __toESM(require_keycodes(), 1); 22057 22058 // packages/dataviews/build-module/components/dataviews-selection-checkbox/index.mjs 22059 var import_components20 = __toESM(require_components(), 1); 22060 var import_i18n25 = __toESM(require_i18n(), 1); 22061 var import_jsx_runtime124 = __toESM(require_jsx_runtime(), 1); 22062 var SELECTION_CHECKBOX_CLASS = "dataviews-selection-checkbox"; 22063 function DataViewsSelectionCheckbox({ 22064 selection, 22065 onChangeSelection, 22066 item, 22067 getItemId: getItemId2, 22068 titleField, 22069 disabled: disabled2, 22070 ...extraProps 22071 }) { 22072 const id = getItemId2(item); 22073 const isInSelectionArray = selection.includes(id); 22074 const checked = !disabled2 && isInSelectionArray; 22075 const selectionLabel = titleField?.getValue?.({ item }) || (0, import_i18n25.__)("(no title)"); 22076 return /* @__PURE__ */ (0, import_jsx_runtime124.jsx)( 22077 import_components20.CheckboxControl, 22078 { 22079 className: SELECTION_CHECKBOX_CLASS, 22080 "aria-label": selectionLabel, 22081 "aria-disabled": disabled2, 22082 checked, 22083 onChange: () => { 22084 if (disabled2) { 22085 return; 22086 } 22087 onChangeSelection( 22088 isInSelectionArray ? selection.filter((itemId) => id !== itemId) : [...selection, id] 22089 ); 22090 }, 22091 ...extraProps 22092 } 22093 ); 22094 } 22095 22096 // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs 22097 var import_components21 = __toESM(require_components(), 1); 22098 var import_i18n26 = __toESM(require_i18n(), 1); 22099 var import_element59 = __toESM(require_element(), 1); 22100 var import_data36 = __toESM(require_data(), 1); 22101 var import_compose5 = __toESM(require_compose(), 1); 22102 22103 // packages/dataviews/build-module/lock-unlock.mjs 22104 var import_private_apis5 = __toESM(require_private_apis(), 1); 22105 var { lock: lock4, unlock: unlock4 } = (0, import_private_apis5.__dangerousOptInToUnstableAPIsOnlyForCoreModules)( 22106 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.", 22107 "@wordpress/dataviews" 22108 ); 22109 22110 // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs 22111 var import_jsx_runtime125 = __toESM(require_jsx_runtime(), 1); 22112 var { Menu, kebabCase: kebabCase2 } = unlock4(import_components21.privateApis); 22113 function ButtonTrigger({ 22114 action, 22115 onClick, 22116 items, 22117 variant 22118 }) { 22119 const label = typeof action.label === "string" ? action.label : action.label(items); 22120 return /* @__PURE__ */ (0, import_jsx_runtime125.jsx)( 22121 import_components21.Button, 22122 { 22123 disabled: !!action.disabled, 22124 accessibleWhenDisabled: true, 22125 size: "compact", 22126 variant, 22127 onClick, 22128 children: label 22129 } 22130 ); 22131 } 22132 function MenuItemTrigger({ 22133 action, 22134 onClick, 22135 items 22136 }) { 22137 const label = typeof action.label === "string" ? action.label : action.label(items); 22138 return /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(Menu.Item, { disabled: action.disabled, onClick, children: /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(Menu.ItemLabel, { children: label }) }); 22139 } 22140 function ActionModal({ 22141 action, 22142 items, 22143 closeModal 22144 }) { 22145 const label = typeof action.label === "string" ? action.label : action.label(items); 22146 const modalHeader = typeof action.modalHeader === "function" ? action.modalHeader(items) : action.modalHeader; 22147 return /* @__PURE__ */ (0, import_jsx_runtime125.jsx)( 22148 import_components21.Modal, 22149 { 22150 title: modalHeader || label, 22151 __experimentalHideHeader: !!action.hideModalHeader, 22152 onRequestClose: closeModal, 22153 focusOnMount: action.modalFocusOnMount ?? true, 22154 size: action.modalSize || "medium", 22155 overlayClassName: `dataviews-action-modal dataviews-action-modal__$kebabCase2( 22156 action.id 22157 )}`, 22158 children: /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(action.RenderModal, { items, closeModal }) 22159 } 22160 ); 22161 } 22162 function ActionsMenuGroup({ 22163 actions, 22164 item, 22165 registry, 22166 setActiveModalAction 22167 }) { 22168 const { primaryActions, regularActions } = (0, import_element59.useMemo)(() => { 22169 return actions.reduce( 22170 (acc, action) => { 22171 (action.isPrimary ? acc.primaryActions : acc.regularActions).push(action); 22172 return acc; 22173 }, 22174 { 22175 primaryActions: [], 22176 regularActions: [] 22177 } 22178 ); 22179 }, [actions]); 22180 const renderActionGroup = (actionList) => actionList.map((action) => /* @__PURE__ */ (0, import_jsx_runtime125.jsx)( 22181 MenuItemTrigger, 22182 { 22183 action, 22184 onClick: () => { 22185 if ("RenderModal" in action) { 22186 setActiveModalAction(action); 22187 return; 22188 } 22189 action.callback([item], { registry }); 22190 }, 22191 items: [item] 22192 }, 22193 action.id 22194 )); 22195 return /* @__PURE__ */ (0, import_jsx_runtime125.jsxs)(Menu.Group, { children: [ 22196 renderActionGroup(primaryActions), 22197 renderActionGroup(regularActions) 22198 ] }); 22199 } 22200 function ItemActions({ 22201 item, 22202 actions, 22203 isCompact 22204 }) { 22205 const registry = (0, import_data36.useRegistry)(); 22206 const { primaryActions, eligibleActions } = (0, import_element59.useMemo)(() => { 22207 const _eligibleActions = actions.filter( 22208 (action) => !action.isEligible || action.isEligible(item) 22209 ); 22210 const _primaryActions = _eligibleActions.filter( 22211 (action) => action.isPrimary 22212 ); 22213 return { 22214 primaryActions: _primaryActions, 22215 eligibleActions: _eligibleActions 22216 }; 22217 }, [actions, item]); 22218 const isMobileViewport = (0, import_compose5.useViewportMatch)("medium", "<"); 22219 if (isCompact) { 22220 return /* @__PURE__ */ (0, import_jsx_runtime125.jsx)( 22221 CompactItemActions, 22222 { 22223 item, 22224 actions: eligibleActions, 22225 isSmall: true, 22226 registry 22227 } 22228 ); 22229 } 22230 return /* @__PURE__ */ (0, import_jsx_runtime125.jsxs)( 22231 Stack, 22232 { 22233 direction: "row", 22234 justify: "flex-end", 22235 className: "dataviews-item-actions", 22236 style: { 22237 flexShrink: 0, 22238 width: "auto" 22239 }, 22240 children: [ 22241 /* @__PURE__ */ (0, import_jsx_runtime125.jsx)( 22242 PrimaryActions, 22243 { 22244 item, 22245 actions: primaryActions, 22246 registry 22247 } 22248 ), 22249 (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu 22250 // there if there are any actions at all. 22251 isMobileViewport) && /* @__PURE__ */ (0, import_jsx_runtime125.jsx)( 22252 CompactItemActions, 22253 { 22254 item, 22255 actions: eligibleActions, 22256 registry 22257 } 22258 ) 22259 ] 22260 } 22261 ); 22262 } 22263 function CompactItemActions({ 22264 item, 22265 actions, 22266 isSmall, 22267 registry 22268 }) { 22269 const [activeModalAction, setActiveModalAction] = (0, import_element59.useState)( 22270 null 22271 ); 22272 return /* @__PURE__ */ (0, import_jsx_runtime125.jsxs)(import_jsx_runtime125.Fragment, { children: [ 22273 /* @__PURE__ */ (0, import_jsx_runtime125.jsxs)(Menu, { placement: "bottom-end", children: [ 22274 /* @__PURE__ */ (0, import_jsx_runtime125.jsx)( 22275 Menu.TriggerButton, 22276 { 22277 render: /* @__PURE__ */ (0, import_jsx_runtime125.jsx)( 22278 import_components21.Button, 22279 { 22280 size: isSmall ? "small" : "compact", 22281 icon: more_vertical_default, 22282 label: (0, import_i18n26.__)("Actions"), 22283 accessibleWhenDisabled: true, 22284 disabled: !actions.length, 22285 className: "dataviews-all-actions-button" 22286 } 22287 ) 22288 } 22289 ), 22290 /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(Menu.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime125.jsx)( 22291 ActionsMenuGroup, 22292 { 22293 actions, 22294 item, 22295 registry, 22296 setActiveModalAction 22297 } 22298 ) }) 22299 ] }), 22300 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime125.jsx)( 22301 ActionModal, 22302 { 22303 action: activeModalAction, 22304 items: [item], 22305 closeModal: () => setActiveModalAction(null) 22306 } 22307 ) 22308 ] }); 22309 } 22310 function PrimaryActions({ 22311 item, 22312 actions, 22313 registry, 22314 buttonVariant 22315 }) { 22316 const [activeModalAction, setActiveModalAction] = (0, import_element59.useState)(null); 22317 const isMobileViewport = (0, import_compose5.useViewportMatch)("medium", "<"); 22318 if (isMobileViewport) { 22319 return null; 22320 } 22321 if (!Array.isArray(actions) || actions.length === 0) { 22322 return null; 22323 } 22324 return /* @__PURE__ */ (0, import_jsx_runtime125.jsxs)(import_jsx_runtime125.Fragment, { children: [ 22325 actions.map((action) => /* @__PURE__ */ (0, import_jsx_runtime125.jsx)( 22326 ButtonTrigger, 22327 { 22328 action, 22329 onClick: () => { 22330 if ("RenderModal" in action) { 22331 setActiveModalAction(action); 22332 return; 22333 } 22334 action.callback([item], { registry }); 22335 }, 22336 items: [item], 22337 variant: buttonVariant 22338 }, 22339 action.id 22340 )), 22341 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime125.jsx)( 22342 ActionModal, 22343 { 22344 action: activeModalAction, 22345 items: [item], 22346 closeModal: () => setActiveModalAction(null) 22347 } 22348 ) 22349 ] }); 22350 } 22351 22352 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs 22353 var import_components22 = __toESM(require_components(), 1); 22354 var import_i18n28 = __toESM(require_i18n(), 1); 22355 var import_element60 = __toESM(require_element(), 1); 22356 var import_data37 = __toESM(require_data(), 1); 22357 var import_compose6 = __toESM(require_compose(), 1); 22358 22359 // packages/dataviews/build-module/utils/get-footer-message.mjs 22360 var import_i18n27 = __toESM(require_i18n(), 1); 22361 function getFooterMessage(selectionCount, itemsCount, totalItems, onlyTotalCount = false) { 22362 if (selectionCount > 0) { 22363 return (0, import_i18n27.sprintf)( 22364 /* translators: %d: number of items. */ 22365 (0, import_i18n27._n)("%d Item selected", "%d Items selected", selectionCount), 22366 selectionCount 22367 ); 22368 } 22369 if (onlyTotalCount || totalItems <= itemsCount) { 22370 return (0, import_i18n27.sprintf)( 22371 /* translators: %d: number of items. */ 22372 (0, import_i18n27._n)("%d Item", "%d Items", totalItems), 22373 totalItems 22374 ); 22375 } 22376 return (0, import_i18n27.sprintf)( 22377 /* translators: %1$d: number of items. %2$d: total number of items. */ 22378 (0, import_i18n27._n)("%1$d of %2$d Item", "%1$d of %2$d Items", totalItems), 22379 itemsCount, 22380 totalItems 22381 ); 22382 } 22383 22384 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs 22385 var import_jsx_runtime126 = __toESM(require_jsx_runtime(), 1); 22386 function ActionWithModal({ 22387 action, 22388 items, 22389 ActionTriggerComponent 22390 }) { 22391 const [isModalOpen, setIsModalOpen] = (0, import_element60.useState)(false); 22392 const actionTriggerProps = { 22393 action, 22394 onClick: () => { 22395 setIsModalOpen(true); 22396 }, 22397 items 22398 }; 22399 return /* @__PURE__ */ (0, import_jsx_runtime126.jsxs)(import_jsx_runtime126.Fragment, { children: [ 22400 /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(ActionTriggerComponent, { ...actionTriggerProps }), 22401 isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime126.jsx)( 22402 ActionModal, 22403 { 22404 action, 22405 items, 22406 closeModal: () => setIsModalOpen(false) 22407 } 22408 ) 22409 ] }); 22410 } 22411 function hasAPossibleBulkAction(actions, item) { 22412 return actions.some( 22413 (action) => action.supportsBulk && (!action.isEligible || action.isEligible(item)) 22414 ); 22415 } 22416 function useHasAPossibleBulkAction(actions, item) { 22417 return (0, import_element60.useMemo)( 22418 () => hasAPossibleBulkAction(actions, item), 22419 [actions, item] 22420 ); 22421 } 22422 function useSomeItemHasAPossibleBulkAction(actions, data) { 22423 return (0, import_element60.useMemo)( 22424 () => data.some((item) => hasAPossibleBulkAction(actions, item)), 22425 [actions, data] 22426 ); 22427 } 22428 function BulkSelectionCheckbox({ 22429 selection, 22430 onChangeSelection, 22431 data, 22432 actions, 22433 getItemId: getItemId2, 22434 disableSelectAll = false 22435 }) { 22436 const selectableItems = (0, import_element60.useMemo)(() => { 22437 return data.filter((item) => { 22438 return actions.some( 22439 (action) => action.supportsBulk && (!action.isEligible || action.isEligible(item)) 22440 ); 22441 }); 22442 }, [data, actions]); 22443 const selectedItems = data.filter( 22444 (item) => selection.includes(getItemId2(item)) && selectableItems.includes(item) 22445 ); 22446 const hasSelection = selection.length > 0; 22447 const areAllSelected = selectedItems.length === selectableItems.length; 22448 if (disableSelectAll) { 22449 return /* @__PURE__ */ (0, import_jsx_runtime126.jsx)( 22450 import_components22.CheckboxControl, 22451 { 22452 className: "dataviews-view-table-selection-checkbox", 22453 checked: hasSelection, 22454 disabled: !hasSelection, 22455 onChange: () => { 22456 onChangeSelection([]); 22457 }, 22458 "aria-label": (0, import_i18n28.__)("Deselect all") 22459 } 22460 ); 22461 } 22462 return /* @__PURE__ */ (0, import_jsx_runtime126.jsx)( 22463 import_components22.CheckboxControl, 22464 { 22465 className: "dataviews-view-table-selection-checkbox", 22466 checked: areAllSelected, 22467 indeterminate: !areAllSelected && !!selectedItems.length, 22468 onChange: () => { 22469 if (areAllSelected) { 22470 onChangeSelection([]); 22471 } else { 22472 onChangeSelection( 22473 selectableItems.map((item) => getItemId2(item)) 22474 ); 22475 } 22476 }, 22477 "aria-label": areAllSelected ? (0, import_i18n28.__)("Deselect all") : (0, import_i18n28.__)("Select all") 22478 } 22479 ); 22480 } 22481 function ActionTrigger({ 22482 action, 22483 onClick, 22484 isBusy, 22485 items 22486 }) { 22487 const label = typeof action.label === "string" ? action.label : action.label(items); 22488 const isMobile = (0, import_compose6.useViewportMatch)("medium", "<"); 22489 if (isMobile) { 22490 return /* @__PURE__ */ (0, import_jsx_runtime126.jsx)( 22491 import_components22.Button, 22492 { 22493 disabled: isBusy, 22494 accessibleWhenDisabled: true, 22495 label, 22496 icon: action.icon, 22497 size: "compact", 22498 onClick, 22499 isBusy 22500 } 22501 ); 22502 } 22503 return /* @__PURE__ */ (0, import_jsx_runtime126.jsx)( 22504 import_components22.Button, 22505 { 22506 disabled: isBusy, 22507 accessibleWhenDisabled: true, 22508 size: "compact", 22509 onClick, 22510 isBusy, 22511 children: label 22512 } 22513 ); 22514 } 22515 var EMPTY_ARRAY3 = []; 22516 function ActionButton({ 22517 action, 22518 selectedItems, 22519 actionInProgress, 22520 setActionInProgress 22521 }) { 22522 const registry = (0, import_data37.useRegistry)(); 22523 const selectedEligibleItems = (0, import_element60.useMemo)(() => { 22524 return selectedItems.filter((item) => { 22525 return !action.isEligible || action.isEligible(item); 22526 }); 22527 }, [action, selectedItems]); 22528 if ("RenderModal" in action) { 22529 return /* @__PURE__ */ (0, import_jsx_runtime126.jsx)( 22530 ActionWithModal, 22531 { 22532 action, 22533 items: selectedEligibleItems, 22534 ActionTriggerComponent: ActionTrigger 22535 }, 22536 action.id 22537 ); 22538 } 22539 return /* @__PURE__ */ (0, import_jsx_runtime126.jsx)( 22540 ActionTrigger, 22541 { 22542 action, 22543 onClick: async () => { 22544 setActionInProgress(action.id); 22545 await action.callback(selectedEligibleItems, { 22546 registry 22547 }); 22548 setActionInProgress(null); 22549 }, 22550 items: selectedEligibleItems, 22551 isBusy: actionInProgress === action.id 22552 }, 22553 action.id 22554 ); 22555 } 22556 function renderFooterContent(data, actions, getItemId2, isInfiniteScroll, selection, actionsToShow, selectedItems, actionInProgress, setActionInProgress, onChangeSelection, paginationInfo) { 22557 const message2 = getFooterMessage( 22558 selection.length, 22559 data.length, 22560 paginationInfo.totalItems, 22561 isInfiniteScroll 22562 ); 22563 return /* @__PURE__ */ (0, import_jsx_runtime126.jsxs)( 22564 Stack, 22565 { 22566 direction: "row", 22567 className: "dataviews-bulk-actions-footer__container", 22568 gap: "md", 22569 align: "center", 22570 children: [ 22571 /* @__PURE__ */ (0, import_jsx_runtime126.jsx)( 22572 BulkSelectionCheckbox, 22573 { 22574 selection, 22575 onChangeSelection, 22576 data, 22577 actions, 22578 getItemId: getItemId2, 22579 disableSelectAll: isInfiniteScroll 22580 } 22581 ), 22582 /* @__PURE__ */ (0, import_jsx_runtime126.jsx)("span", { className: "dataviews-bulk-actions-footer__item-count", children: message2 }), 22583 /* @__PURE__ */ (0, import_jsx_runtime126.jsxs)( 22584 Stack, 22585 { 22586 direction: "row", 22587 className: "dataviews-bulk-actions-footer__action-buttons", 22588 gap: "xs", 22589 children: [ 22590 actionsToShow.map((action) => { 22591 return /* @__PURE__ */ (0, import_jsx_runtime126.jsx)( 22592 ActionButton, 22593 { 22594 action, 22595 selectedItems, 22596 actionInProgress, 22597 setActionInProgress 22598 }, 22599 action.id 22600 ); 22601 }), 22602 selectedItems.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime126.jsx)( 22603 import_components22.Button, 22604 { 22605 icon: close_small_default, 22606 showTooltip: true, 22607 tooltipPosition: "top", 22608 size: "compact", 22609 label: (0, import_i18n28.__)("Cancel"), 22610 disabled: !!actionInProgress, 22611 accessibleWhenDisabled: false, 22612 onClick: () => { 22613 onChangeSelection(EMPTY_ARRAY3); 22614 } 22615 } 22616 ) 22617 ] 22618 } 22619 ) 22620 ] 22621 } 22622 ); 22623 } 22624 function FooterContent({ 22625 selection, 22626 actions, 22627 onChangeSelection, 22628 data, 22629 getItemId: getItemId2, 22630 isInfiniteScroll, 22631 paginationInfo 22632 }) { 22633 const [actionInProgress, setActionInProgress] = (0, import_element60.useState)( 22634 null 22635 ); 22636 const footerContentRef = (0, import_element60.useRef)(void 0); 22637 const isMobile = (0, import_compose6.useViewportMatch)("medium", "<"); 22638 const bulkActions = (0, import_element60.useMemo)( 22639 () => actions.filter((action) => action.supportsBulk), 22640 [actions] 22641 ); 22642 const selectableItems = (0, import_element60.useMemo)(() => { 22643 return data.filter((item) => { 22644 return bulkActions.some( 22645 (action) => !action.isEligible || action.isEligible(item) 22646 ); 22647 }); 22648 }, [data, bulkActions]); 22649 const selectedItems = (0, import_element60.useMemo)(() => { 22650 return data.filter( 22651 (item) => selection.includes(getItemId2(item)) && selectableItems.includes(item) 22652 ); 22653 }, [selection, data, getItemId2, selectableItems]); 22654 const actionsToShow = (0, import_element60.useMemo)( 22655 () => actions.filter((action) => { 22656 return action.supportsBulk && (!isMobile || action.icon) && selectedItems.some( 22657 (item) => !action.isEligible || action.isEligible(item) 22658 ); 22659 }), 22660 [actions, selectedItems, isMobile] 22661 ); 22662 if (!actionInProgress) { 22663 if (footerContentRef.current) { 22664 footerContentRef.current = void 0; 22665 } 22666 return renderFooterContent( 22667 data, 22668 actions, 22669 getItemId2, 22670 isInfiniteScroll, 22671 selection, 22672 actionsToShow, 22673 selectedItems, 22674 actionInProgress, 22675 setActionInProgress, 22676 onChangeSelection, 22677 paginationInfo 22678 ); 22679 } else if (!footerContentRef.current) { 22680 footerContentRef.current = renderFooterContent( 22681 data, 22682 actions, 22683 getItemId2, 22684 isInfiniteScroll, 22685 selection, 22686 actionsToShow, 22687 selectedItems, 22688 actionInProgress, 22689 setActionInProgress, 22690 onChangeSelection, 22691 paginationInfo 22692 ); 22693 } 22694 return footerContentRef.current; 22695 } 22696 function BulkActionsFooter() { 22697 const { 22698 data, 22699 selection, 22700 actions = EMPTY_ARRAY3, 22701 onChangeSelection, 22702 getItemId: getItemId2, 22703 paginationInfo, 22704 view 22705 } = (0, import_element60.useContext)(dataviews_context_default); 22706 return /* @__PURE__ */ (0, import_jsx_runtime126.jsx)( 22707 FooterContent, 22708 { 22709 selection, 22710 onChangeSelection, 22711 data, 22712 actions, 22713 getItemId: getItemId2, 22714 isInfiniteScroll: !!view.infiniteScrollEnabled, 22715 paginationInfo 22716 } 22717 ); 22718 } 22719 22720 // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs 22721 var import_i18n29 = __toESM(require_i18n(), 1); 22722 var import_components23 = __toESM(require_components(), 1); 22723 var import_element61 = __toESM(require_element(), 1); 22724 22725 // packages/dataviews/build-module/utils/get-hideable-fields.mjs 22726 function getHideableFields(view, fields2) { 22727 const togglableFields = [ 22728 view?.titleField, 22729 view?.mediaField, 22730 view?.descriptionField 22731 ].filter(Boolean); 22732 return fields2.filter( 22733 (f2) => !togglableFields.includes(f2.id) && f2.type !== "media" && f2.enableHiding !== false 22734 ); 22735 } 22736 22737 // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs 22738 var import_jsx_runtime127 = __toESM(require_jsx_runtime(), 1); 22739 var { Menu: Menu2 } = unlock4(import_components23.privateApis); 22740 function WithMenuSeparators({ children }) { 22741 return import_element61.Children.toArray(children).filter(Boolean).map((child, i2) => /* @__PURE__ */ (0, import_jsx_runtime127.jsxs)(import_element61.Fragment, { children: [ 22742 i2 > 0 && /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(Menu2.Separator, {}), 22743 child 22744 ] }, i2)); 22745 } 22746 var _HeaderMenu = (0, import_element61.forwardRef)(function HeaderMenu({ 22747 fieldId, 22748 view, 22749 fields: fields2, 22750 onChangeView, 22751 onHide, 22752 setOpenedFilter, 22753 canMove = true, 22754 canInsertLeft = true, 22755 canInsertRight = true 22756 }, ref) { 22757 const visibleFieldIds = view.fields ?? []; 22758 const index2 = visibleFieldIds?.indexOf(fieldId); 22759 const isSorted = view.sort?.field === fieldId; 22760 let isHidable = false; 22761 let isSortable = false; 22762 let canAddFilter = false; 22763 let operators = []; 22764 const field = fields2.find((f2) => f2.id === fieldId); 22765 const { setIsShowingFilter } = (0, import_element61.useContext)(dataviews_context_default); 22766 if (!field) { 22767 return null; 22768 } 22769 isHidable = field.enableHiding !== false; 22770 isSortable = field.enableSorting !== false; 22771 const header = field.header; 22772 operators = !!field.filterBy && field.filterBy?.operators || []; 22773 canAddFilter = !view.filters?.some((_filter) => fieldId === _filter.field) && !!(field.hasElements || field.Edit) && field.filterBy !== false && !field.filterBy?.isPrimary; 22774 if (!isSortable && !canMove && !isHidable && !canAddFilter) { 22775 return header; 22776 } 22777 const hiddenFields = getHideableFields(view, fields2).filter( 22778 (f2) => !visibleFieldIds.includes(f2.id) 22779 ); 22780 const canInsert = (canInsertLeft || canInsertRight) && !!hiddenFields.length; 22781 const isRtl = (0, import_i18n29.isRTL)(); 22782 return /* @__PURE__ */ (0, import_jsx_runtime127.jsxs)(Menu2, { children: [ 22783 /* @__PURE__ */ (0, import_jsx_runtime127.jsxs)( 22784 Menu2.TriggerButton, 22785 { 22786 render: /* @__PURE__ */ (0, import_jsx_runtime127.jsx)( 22787 import_components23.Button, 22788 { 22789 size: "compact", 22790 className: "dataviews-view-table-header-button", 22791 ref, 22792 variant: "tertiary" 22793 } 22794 ), 22795 children: [ 22796 header, 22797 view.sort && isSorted && /* @__PURE__ */ (0, import_jsx_runtime127.jsx)("span", { "aria-hidden": "true", children: sortArrows[view.sort.direction] }) 22798 ] 22799 } 22800 ), 22801 /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(Menu2.Popover, { style: { minWidth: "240px" }, children: /* @__PURE__ */ (0, import_jsx_runtime127.jsxs)(WithMenuSeparators, { children: [ 22802 isSortable && /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(Menu2.Group, { children: SORTING_DIRECTIONS.map( 22803 (direction) => { 22804 const isChecked = view.sort && isSorted && view.sort.direction === direction; 22805 const value = `$fieldId}-$direction}`; 22806 return /* @__PURE__ */ (0, import_jsx_runtime127.jsx)( 22807 Menu2.RadioItem, 22808 { 22809 name: "view-table-sorting", 22810 value, 22811 checked: isChecked, 22812 onChange: () => { 22813 onChangeView({ 22814 ...view, 22815 sort: { 22816 field: fieldId, 22817 direction 22818 }, 22819 showLevels: false 22820 }); 22821 }, 22822 children: /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(Menu2.ItemLabel, { children: sortLabels[direction] }) 22823 }, 22824 value 22825 ); 22826 } 22827 ) }), 22828 canAddFilter && /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(Menu2.Group, { children: /* @__PURE__ */ (0, import_jsx_runtime127.jsx)( 22829 Menu2.Item, 22830 { 22831 prefix: /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(import_components23.Icon, { icon: funnel_default }), 22832 onClick: () => { 22833 setOpenedFilter(fieldId); 22834 setIsShowingFilter(true); 22835 onChangeView({ 22836 ...view, 22837 page: 1, 22838 filters: [ 22839 ...view.filters || [], 22840 { 22841 field: fieldId, 22842 value: void 0, 22843 operator: operators[0] 22844 } 22845 ] 22846 }); 22847 }, 22848 children: /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(Menu2.ItemLabel, { children: (0, import_i18n29.__)("Add filter") }) 22849 } 22850 ) }), 22851 (canMove || isHidable || canInsert) && field && /* @__PURE__ */ (0, import_jsx_runtime127.jsxs)(Menu2.Group, { children: [ 22852 canMove && /* @__PURE__ */ (0, import_jsx_runtime127.jsx)( 22853 Menu2.Item, 22854 { 22855 prefix: /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(import_components23.Icon, { icon: arrow_left_default }), 22856 disabled: isRtl ? index2 >= visibleFieldIds.length - 1 : index2 < 1, 22857 onClick: () => { 22858 const targetIndex = isRtl ? index2 + 1 : index2 - 1; 22859 const newFields = [ 22860 ...visibleFieldIds 22861 ]; 22862 newFields.splice(index2, 1); 22863 newFields.splice( 22864 targetIndex, 22865 0, 22866 fieldId 22867 ); 22868 onChangeView({ 22869 ...view, 22870 fields: newFields 22871 }); 22872 }, 22873 children: /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(Menu2.ItemLabel, { children: (0, import_i18n29.__)("Move left") }) 22874 } 22875 ), 22876 canMove && /* @__PURE__ */ (0, import_jsx_runtime127.jsx)( 22877 Menu2.Item, 22878 { 22879 prefix: /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(import_components23.Icon, { icon: arrow_right_default }), 22880 disabled: isRtl ? index2 < 1 : index2 >= visibleFieldIds.length - 1, 22881 onClick: () => { 22882 const targetIndex = isRtl ? index2 - 1 : index2 + 1; 22883 const newFields = [ 22884 ...visibleFieldIds 22885 ]; 22886 newFields.splice(index2, 1); 22887 newFields.splice( 22888 targetIndex, 22889 0, 22890 fieldId 22891 ); 22892 onChangeView({ 22893 ...view, 22894 fields: newFields 22895 }); 22896 }, 22897 children: /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(Menu2.ItemLabel, { children: (0, import_i18n29.__)("Move right") }) 22898 } 22899 ), 22900 canInsertLeft && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime127.jsxs)(Menu2, { children: [ 22901 /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(Menu2.ItemLabel, { children: (0, import_i18n29.__)("Insert left") }) }), 22902 /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => { 22903 const insertIndex = isRtl ? index2 + 1 : index2; 22904 return /* @__PURE__ */ (0, import_jsx_runtime127.jsx)( 22905 Menu2.Item, 22906 { 22907 onClick: () => { 22908 onChangeView({ 22909 ...view, 22910 fields: [ 22911 ...visibleFieldIds.slice( 22912 0, 22913 insertIndex 22914 ), 22915 hiddenField.id, 22916 ...visibleFieldIds.slice( 22917 insertIndex 22918 ) 22919 ] 22920 }); 22921 }, 22922 children: /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(Menu2.ItemLabel, { children: hiddenField.label }) 22923 }, 22924 hiddenField.id 22925 ); 22926 }) }) 22927 ] }), 22928 canInsertRight && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime127.jsxs)(Menu2, { children: [ 22929 /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(Menu2.ItemLabel, { children: (0, import_i18n29.__)("Insert right") }) }), 22930 /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => { 22931 const insertIndex = isRtl ? index2 : index2 + 1; 22932 return /* @__PURE__ */ (0, import_jsx_runtime127.jsx)( 22933 Menu2.Item, 22934 { 22935 onClick: () => { 22936 onChangeView({ 22937 ...view, 22938 fields: [ 22939 ...visibleFieldIds.slice( 22940 0, 22941 insertIndex 22942 ), 22943 hiddenField.id, 22944 ...visibleFieldIds.slice( 22945 insertIndex 22946 ) 22947 ] 22948 }); 22949 }, 22950 children: /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(Menu2.ItemLabel, { children: hiddenField.label }) 22951 }, 22952 hiddenField.id 22953 ); 22954 }) }) 22955 ] }), 22956 isHidable && field && /* @__PURE__ */ (0, import_jsx_runtime127.jsx)( 22957 Menu2.Item, 22958 { 22959 prefix: /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(import_components23.Icon, { icon: unseen_default }), 22960 onClick: () => { 22961 onHide(field); 22962 onChangeView({ 22963 ...view, 22964 fields: visibleFieldIds.filter( 22965 (id) => id !== fieldId 22966 ) 22967 }); 22968 }, 22969 children: /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(Menu2.ItemLabel, { children: (0, import_i18n29.__)("Hide column") }) 22970 } 22971 ) 22972 ] }) 22973 ] }) }) 22974 ] }); 22975 }); 22976 var ColumnHeaderMenu = _HeaderMenu; 22977 var column_header_menu_default = ColumnHeaderMenu; 22978 22979 // packages/dataviews/build-module/components/dataviews-layouts/utils/item-click-wrapper.mjs 22980 var import_element62 = __toESM(require_element(), 1); 22981 var import_jsx_runtime128 = __toESM(require_jsx_runtime(), 1); 22982 function getClickableItemProps({ 22983 item, 22984 isItemClickable, 22985 onClickItem, 22986 className 22987 }) { 22988 if (!isItemClickable(item) || !onClickItem) { 22989 return { className }; 22990 } 22991 return { 22992 className: className ? `$className} $className}--clickable` : void 0, 22993 role: "button", 22994 tabIndex: 0, 22995 onClick: (event) => { 22996 event.stopPropagation(); 22997 onClickItem(item); 22998 }, 22999 onKeyDown: (event) => { 23000 if (event.key === "Enter" || event.key === "" || event.key === " ") { 23001 event.stopPropagation(); 23002 onClickItem(item); 23003 } 23004 } 23005 }; 23006 } 23007 function ItemClickWrapper({ 23008 item, 23009 isItemClickable, 23010 onClickItem, 23011 renderItemLink, 23012 className, 23013 children, 23014 ...extraProps 23015 }) { 23016 if (!isItemClickable(item)) { 23017 return /* @__PURE__ */ (0, import_jsx_runtime128.jsx)("div", { className, ...extraProps, children }); 23018 } 23019 if (renderItemLink) { 23020 const renderedElement = renderItemLink({ 23021 item, 23022 className: `$className} $className}--clickable`, 23023 ...extraProps, 23024 children 23025 }); 23026 return (0, import_element62.cloneElement)(renderedElement, { 23027 onClick: (event) => { 23028 event.stopPropagation(); 23029 if (renderedElement.props.onClick) { 23030 renderedElement.props.onClick(event); 23031 } 23032 }, 23033 onKeyDown: (event) => { 23034 if (event.key === "Enter" || event.key === "" || event.key === " ") { 23035 event.stopPropagation(); 23036 if (renderedElement.props.onKeyDown) { 23037 renderedElement.props.onKeyDown(event); 23038 } 23039 } 23040 } 23041 }); 23042 } 23043 const clickProps = getClickableItemProps({ 23044 item, 23045 isItemClickable, 23046 onClickItem, 23047 className 23048 }); 23049 return /* @__PURE__ */ (0, import_jsx_runtime128.jsx)("div", { ...clickProps, ...extraProps, children }); 23050 } 23051 23052 // packages/dataviews/build-module/components/dataviews-layouts/table/column-primary.mjs 23053 var import_jsx_runtime129 = __toESM(require_jsx_runtime(), 1); 23054 function ColumnPrimary({ 23055 item, 23056 level, 23057 titleField, 23058 mediaField, 23059 descriptionField: descriptionField2, 23060 onClickItem, 23061 renderItemLink, 23062 isItemClickable 23063 }) { 23064 return /* @__PURE__ */ (0, import_jsx_runtime129.jsxs)(Stack, { direction: "row", gap: "md", align: "flex-start", justify: "flex-start", children: [ 23065 mediaField && /* @__PURE__ */ (0, import_jsx_runtime129.jsx)( 23066 ItemClickWrapper, 23067 { 23068 item, 23069 isItemClickable, 23070 onClickItem, 23071 renderItemLink, 23072 className: "dataviews-view-table__cell-content-wrapper dataviews-column-primary__media", 23073 "aria-label": isItemClickable(item) && (!!onClickItem || !!renderItemLink) && !!titleField ? titleField.getValue?.({ item }) : void 0, 23074 children: /* @__PURE__ */ (0, import_jsx_runtime129.jsx)( 23075 mediaField.render, 23076 { 23077 item, 23078 field: mediaField, 23079 config: { sizes: "32px" } 23080 } 23081 ) 23082 } 23083 ), 23084 /* @__PURE__ */ (0, import_jsx_runtime129.jsxs)( 23085 Stack, 23086 { 23087 direction: "column", 23088 align: "flex-start", 23089 className: "dataviews-view-table__primary-column-content", 23090 children: [ 23091 titleField && /* @__PURE__ */ (0, import_jsx_runtime129.jsxs)( 23092 ItemClickWrapper, 23093 { 23094 item, 23095 isItemClickable, 23096 onClickItem, 23097 renderItemLink, 23098 className: "dataviews-view-table__cell-content-wrapper dataviews-title-field", 23099 children: [ 23100 level !== void 0 && level > 0 && /* @__PURE__ */ (0, import_jsx_runtime129.jsxs)("span", { className: "dataviews-view-table__level", children: [ 23101 Array(level).fill("\u2014").join(" "), 23102 "\xA0" 23103 ] }), 23104 /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(titleField.render, { item, field: titleField }) 23105 ] 23106 } 23107 ), 23108 descriptionField2 && /* @__PURE__ */ (0, import_jsx_runtime129.jsx)( 23109 descriptionField2.render, 23110 { 23111 item, 23112 field: descriptionField2 23113 } 23114 ) 23115 ] 23116 } 23117 ) 23118 ] }); 23119 } 23120 var column_primary_default = ColumnPrimary; 23121 23122 // packages/dataviews/build-module/components/dataviews-layouts/table/use-scroll-state.mjs 23123 var import_element63 = __toESM(require_element(), 1); 23124 var import_i18n30 = __toESM(require_i18n(), 1); 23125 var isScrolledToEnd = (element) => { 23126 if ((0, import_i18n30.isRTL)()) { 23127 const scrollLeft = Math.abs(element.scrollLeft); 23128 return scrollLeft <= 1; 23129 } 23130 return element.scrollLeft + element.clientWidth >= element.scrollWidth - 1; 23131 }; 23132 function useScrollState({ 23133 scrollContainerRef, 23134 enabledHorizontal = false 23135 }) { 23136 const [isHorizontalScrollEnd, setIsHorizontalScrollEnd] = (0, import_element63.useState)(false); 23137 const [isVerticallyScrolled, setIsVerticallyScrolled] = (0, import_element63.useState)(false); 23138 const handleScroll = (0, import_element63.useCallback)(() => { 23139 const scrollContainer = scrollContainerRef.current; 23140 if (!scrollContainer) { 23141 return; 23142 } 23143 if (enabledHorizontal) { 23144 setIsHorizontalScrollEnd(isScrolledToEnd(scrollContainer)); 23145 } 23146 setIsVerticallyScrolled(scrollContainer.scrollTop > 0); 23147 }, [scrollContainerRef, enabledHorizontal]); 23148 (0, import_element63.useEffect)(() => { 23149 if (typeof window === "undefined" || !scrollContainerRef.current) { 23150 return () => { 23151 }; 23152 } 23153 const scrollContainer = scrollContainerRef.current; 23154 handleScroll(); 23155 scrollContainer.addEventListener("scroll", handleScroll); 23156 window.addEventListener("resize", handleScroll); 23157 return () => { 23158 scrollContainer.removeEventListener("scroll", handleScroll); 23159 window.removeEventListener("resize", handleScroll); 23160 }; 23161 }, [scrollContainerRef, enabledHorizontal, handleScroll]); 23162 return { isHorizontalScrollEnd, isVerticallyScrolled }; 23163 } 23164 23165 // packages/dataviews/build-module/components/dataviews-layouts/utils/get-data-by-group.mjs 23166 function getDataByGroup(data, groupByField) { 23167 return data.reduce((groups, item) => { 23168 const groupName = groupByField.getValue({ item }); 23169 if (!groups.has(groupName)) { 23170 groups.set(groupName, []); 23171 } 23172 groups.get(groupName)?.push(item); 23173 return groups; 23174 }, /* @__PURE__ */ new Map()); 23175 } 23176 23177 // packages/dataviews/build-module/components/dataviews-layouts/utils/use-selection-props.mjs 23178 var import_element64 = __toESM(require_element(), 1); 23179 var import_keycodes3 = __toESM(require_keycodes(), 1); 23180 function getRange(orderedIds, fromIndex, toIndex) { 23181 return orderedIds.slice( 23182 Math.min(fromIndex, toIndex), 23183 Math.max(fromIndex, toIndex) + 1 23184 ); 23185 } 23186 function getRangeSelection({ 23187 anchorId, 23188 targetId, 23189 lastTargetId, 23190 orderedIds, 23191 selection 23192 }) { 23193 const targetIndex = orderedIds.indexOf(targetId); 23194 if (targetIndex === -1) { 23195 return selection; 23196 } 23197 const anchorIndex = anchorId === null ? -1 : orderedIds.indexOf(anchorId); 23198 const hasAnchor = anchorIndex !== -1; 23199 const rangeStart = hasAnchor ? anchorIndex : targetIndex; 23200 const lastTargetIndex = hasAnchor && lastTargetId !== null ? orderedIds.indexOf(lastTargetId) : -1; 23201 const lastRange = lastTargetIndex === -1 ? [] : getRange(orderedIds, rangeStart, lastTargetIndex); 23202 const base = selection.filter((id) => !lastRange.includes(id)); 23203 return [ 23204 .../* @__PURE__ */ new Set([ 23205 ...base, 23206 ...getRange(orderedIds, rangeStart, targetIndex) 23207 ]) 23208 ]; 23209 } 23210 function getClosestSelectedId({ 23211 targetId, 23212 orderedIds, 23213 selection 23214 }) { 23215 const targetIndex = orderedIds.indexOf(targetId); 23216 if (targetIndex === -1) { 23217 return null; 23218 } 23219 const selectedIds = new Set(selection); 23220 let closestId = null; 23221 let closestDistance = Infinity; 23222 orderedIds.forEach((id, index2) => { 23223 if (!selectedIds.has(id)) { 23224 return; 23225 } 23226 const distance = Math.abs(index2 - targetIndex); 23227 if (distance < closestDistance) { 23228 closestDistance = distance; 23229 closestId = id; 23230 } 23231 }); 23232 return closestId; 23233 } 23234 function useSelectionProps({ 23235 data, 23236 actions, 23237 getItemId: getItemId2, 23238 selection, 23239 onChangeSelection 23240 }) { 23241 const gestureRef = (0, import_element64.useRef)(null); 23242 const isTouchDeviceRef = (0, import_element64.useRef)(false); 23243 (0, import_element64.useEffect)(() => { 23244 const markTouchDevice = () => { 23245 isTouchDeviceRef.current = true; 23246 }; 23247 document.addEventListener("touchstart", markTouchDevice, { 23248 once: true 23249 }); 23250 return () => document.removeEventListener("touchstart", markTouchDevice); 23251 }, []); 23252 const selectableIds = data.filter((item) => hasAPossibleBulkAction(actions, item)).map(getItemId2); 23253 const selectableIdSet = new Set(selectableIds); 23254 const hasSelectableItems = selectableIds.length > 0; 23255 const getSelectionProps = (id) => { 23256 const isSelectable = selectableIdSet.has(id); 23257 return { 23258 onMouseDown: (event) => { 23259 if (event.button === 0 && event.shiftKey && hasSelectableItems) { 23260 event.preventDefault(); 23261 } 23262 }, 23263 onClickCapture: (event) => { 23264 if (!hasSelectableItems) { 23265 return; 23266 } 23267 const isModifierKeyPressed = (0, import_keycodes3.isAppleOS)() ? event.metaKey : event.ctrlKey; 23268 const isSelectionCheckboxClick = event.target instanceof Element && !!event.target.closest(`.$SELECTION_CHECKBOX_CLASS}`); 23269 if (!isModifierKeyPressed && !event.shiftKey) { 23270 if (isSelectable && isSelectionCheckboxClick) { 23271 gestureRef.current = { 23272 anchorId: id, 23273 lastTargetId: null 23274 }; 23275 } 23276 return; 23277 } 23278 if (isTouchDeviceRef.current || document.getSelection()?.type === "Range") { 23279 return; 23280 } 23281 event.stopPropagation(); 23282 if (!isSelectionCheckboxClick) { 23283 event.preventDefault(); 23284 } 23285 if (!isSelectable) { 23286 return; 23287 } 23288 if (event.shiftKey) { 23289 let gesture = gestureRef.current; 23290 if (!gesture || !selectableIdSet.has(gesture.anchorId)) { 23291 gesture = { 23292 anchorId: getClosestSelectedId({ 23293 targetId: id, 23294 orderedIds: selectableIds, 23295 selection 23296 }) ?? id, 23297 lastTargetId: null 23298 }; 23299 } 23300 onChangeSelection( 23301 getRangeSelection({ 23302 anchorId: gesture.anchorId, 23303 targetId: id, 23304 lastTargetId: gesture.lastTargetId, 23305 orderedIds: selectableIds, 23306 selection 23307 }) 23308 ); 23309 gestureRef.current = { 23310 anchorId: gesture.anchorId, 23311 lastTargetId: id 23312 }; 23313 } else { 23314 onChangeSelection( 23315 selection.includes(id) ? selection.filter((itemId) => id !== itemId) : [...selection, id] 23316 ); 23317 gestureRef.current = { anchorId: id, lastTargetId: null }; 23318 } 23319 } 23320 }; 23321 }; 23322 return { getSelectionProps }; 23323 } 23324 23325 // packages/dataviews/build-module/components/dataviews-view-config/properties-section.mjs 23326 var import_components24 = __toESM(require_components(), 1); 23327 var import_i18n31 = __toESM(require_i18n(), 1); 23328 var import_element65 = __toESM(require_element(), 1); 23329 var import_jsx_runtime130 = __toESM(require_jsx_runtime(), 1); 23330 function FieldItem({ 23331 field, 23332 isVisible: isVisible2, 23333 onToggleVisibility 23334 }) { 23335 return /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(import_components24.__experimentalItem, { onClick: field.enableHiding ? onToggleVisibility : void 0, children: /* @__PURE__ */ (0, import_jsx_runtime130.jsxs)(Stack, { direction: "row", gap: "sm", justify: "flex-start", align: "center", children: [ 23336 /* @__PURE__ */ (0, import_jsx_runtime130.jsx)("div", { style: { height: 24, width: 24 }, children: isVisible2 && /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(import_components24.Icon, { icon: check_default }) }), 23337 /* @__PURE__ */ (0, import_jsx_runtime130.jsx)("span", { className: "dataviews-view-config__label", children: field.label }) 23338 ] }) }); 23339 } 23340 function isDefined(item) { 23341 return !!item; 23342 } 23343 function PropertiesSection({ 23344 showLabel = true 23345 }) { 23346 const { view, fields: fields2, onChangeView } = (0, import_element65.useContext)(dataviews_context_default); 23347 const regularFields = getHideableFields(view, fields2); 23348 if (!regularFields?.length) { 23349 return null; 23350 } 23351 const titleField = fields2.find((f2) => f2.id === view.titleField); 23352 const previewField3 = fields2.find((f2) => f2.id === view.mediaField); 23353 const descriptionField2 = fields2.find( 23354 (f2) => f2.id === view.descriptionField 23355 ); 23356 const lockedFields = [ 23357 { 23358 field: titleField, 23359 isVisibleFlag: "showTitle" 23360 }, 23361 { 23362 field: previewField3, 23363 isVisibleFlag: "showMedia" 23364 }, 23365 { 23366 field: descriptionField2, 23367 isVisibleFlag: "showDescription" 23368 } 23369 ].filter(({ field }) => isDefined(field)); 23370 const visibleFieldIds = view.fields ?? []; 23371 const visibleRegularFieldsCount = regularFields.filter( 23372 (f2) => visibleFieldIds.includes(f2.id) 23373 ).length; 23374 const visibleLockedFields = lockedFields.filter( 23375 ({ isVisibleFlag }) => ( 23376 // @ts-expect-error 23377 view[isVisibleFlag] ?? true 23378 ) 23379 ); 23380 const totalVisibleFields = visibleLockedFields.length + visibleRegularFieldsCount; 23381 const isSingleVisibleLockedField = totalVisibleFields === 1 && visibleLockedFields.length === 1; 23382 return /* @__PURE__ */ (0, import_jsx_runtime130.jsxs)(Stack, { direction: "column", className: "dataviews-field-control", children: [ 23383 showLabel && /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(import_components24.BaseControl.VisualLabel, { children: (0, import_i18n31.__)("Properties") }), 23384 /* @__PURE__ */ (0, import_jsx_runtime130.jsx)( 23385 Stack, 23386 { 23387 direction: "column", 23388 className: "dataviews-view-config__properties", 23389 children: /* @__PURE__ */ (0, import_jsx_runtime130.jsxs)(import_components24.__experimentalItemGroup, { isBordered: true, isSeparated: true, size: "medium", children: [ 23390 lockedFields.map(({ field, isVisibleFlag }) => { 23391 const isVisible2 = view[isVisibleFlag] ?? true; 23392 const fieldToRender = isSingleVisibleLockedField && isVisible2 ? { ...field, enableHiding: false } : field; 23393 return /* @__PURE__ */ (0, import_jsx_runtime130.jsx)( 23394 FieldItem, 23395 { 23396 field: fieldToRender, 23397 isVisible: isVisible2, 23398 onToggleVisibility: () => { 23399 onChangeView({ 23400 ...view, 23401 [isVisibleFlag]: !isVisible2 23402 }); 23403 } 23404 }, 23405 field.id 23406 ); 23407 }), 23408 regularFields.map((field) => { 23409 const isVisible2 = visibleFieldIds.includes(field.id); 23410 const fieldToRender = totalVisibleFields === 1 && isVisible2 ? { ...field, enableHiding: false } : field; 23411 return /* @__PURE__ */ (0, import_jsx_runtime130.jsx)( 23412 FieldItem, 23413 { 23414 field: fieldToRender, 23415 isVisible: isVisible2, 23416 onToggleVisibility: () => { 23417 onChangeView({ 23418 ...view, 23419 fields: isVisible2 ? visibleFieldIds.filter( 23420 (fieldId) => fieldId !== field.id 23421 ) : [...visibleFieldIds, field.id] 23422 }); 23423 } 23424 }, 23425 field.id 23426 ); 23427 }) 23428 ] }) 23429 } 23430 ) 23431 ] }); 23432 } 23433 23434 // packages/dataviews/build-module/hooks/use-delayed-loading.mjs 23435 var import_element66 = __toESM(require_element(), 1); 23436 function useDelayedLoading(isLoading, options = { delay: 400 }) { 23437 const [showLoader, setShowLoader] = (0, import_element66.useState)(false); 23438 (0, import_element66.useEffect)(() => { 23439 if (!isLoading) { 23440 return; 23441 } 23442 const timeout = setTimeout(() => { 23443 setShowLoader(true); 23444 }, options.delay); 23445 return () => { 23446 clearTimeout(timeout); 23447 setShowLoader(false); 23448 }; 23449 }, [isLoading, options.delay]); 23450 return showLoader; 23451 } 23452 23453 // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs 23454 var import_jsx_runtime131 = __toESM(require_jsx_runtime(), 1); 23455 function getEffectiveAlign(explicitAlign, fieldType) { 23456 if (explicitAlign) { 23457 return explicitAlign; 23458 } 23459 if (fieldType === "integer" || fieldType === "number") { 23460 return "end"; 23461 } 23462 return void 0; 23463 } 23464 function TableColumnField({ 23465 item, 23466 fields: fields2, 23467 column, 23468 align 23469 }) { 23470 const field = fields2.find((f2) => f2.id === column); 23471 if (!field) { 23472 return null; 23473 } 23474 const className = clsx_default("dataviews-view-table__cell-content-wrapper", { 23475 "dataviews-view-table__cell-align-end": align === "end", 23476 "dataviews-view-table__cell-align-center": align === "center" 23477 }); 23478 return /* @__PURE__ */ (0, import_jsx_runtime131.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(field.render, { item, field }) }); 23479 } 23480 function TableRow({ 23481 hasBulkActions, 23482 item, 23483 level, 23484 actions, 23485 fields: fields2, 23486 id, 23487 view, 23488 titleField, 23489 mediaField, 23490 descriptionField: descriptionField2, 23491 selection, 23492 getItemId: getItemId2, 23493 isItemClickable, 23494 onClickItem, 23495 renderItemLink, 23496 onChangeSelection, 23497 onMouseDown, 23498 onClickCapture, 23499 isActionsColumnSticky, 23500 posinset 23501 }) { 23502 const { paginationInfo } = (0, import_element67.useContext)(dataviews_context_default); 23503 const hasPossibleBulkAction = useHasAPossibleBulkAction(actions, item); 23504 const isSelected2 = hasPossibleBulkAction && selection.includes(id); 23505 const { 23506 showTitle = true, 23507 showMedia = true, 23508 showDescription = true, 23509 infiniteScrollEnabled 23510 } = view; 23511 const columns = view.fields ?? []; 23512 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField2 && showDescription; 23513 return /* @__PURE__ */ (0, import_jsx_runtime131.jsxs)( 23514 "tr", 23515 { 23516 className: clsx_default("dataviews-view-table__row", { 23517 "is-selected": hasPossibleBulkAction && isSelected2, 23518 "has-bulk-actions": hasPossibleBulkAction 23519 }), 23520 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0, 23521 "aria-posinset": posinset, 23522 role: infiniteScrollEnabled ? "article" : void 0, 23523 onClickCapture, 23524 onMouseDown: (event) => { 23525 const isMetaClick = (0, import_keycodes4.isAppleOS)() ? event.metaKey : event.ctrlKey; 23526 if (event.button === 0 && isMetaClick && window.navigator.userAgent.toLowerCase().includes("firefox")) { 23527 event.preventDefault(); 23528 } 23529 onMouseDown(event); 23530 }, 23531 children: [ 23532 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime131.jsx)("td", { className: "dataviews-view-table__checkbox-column", children: /* @__PURE__ */ (0, import_jsx_runtime131.jsx)("div", { className: "dataviews-view-table__cell-content-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime131.jsx)( 23533 DataViewsSelectionCheckbox, 23534 { 23535 item, 23536 selection, 23537 onChangeSelection, 23538 getItemId: getItemId2, 23539 titleField, 23540 disabled: !hasPossibleBulkAction 23541 } 23542 ) }) }), 23543 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime131.jsx)("td", { children: /* @__PURE__ */ (0, import_jsx_runtime131.jsx)( 23544 column_primary_default, 23545 { 23546 item, 23547 level, 23548 titleField: showTitle ? titleField : void 0, 23549 mediaField: showMedia ? mediaField : void 0, 23550 descriptionField: showDescription ? descriptionField2 : void 0, 23551 isItemClickable, 23552 onClickItem, 23553 renderItemLink 23554 } 23555 ) }), 23556 columns.map((column) => { 23557 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {}; 23558 const field = fields2.find((f2) => f2.id === column); 23559 const effectiveAlign = getEffectiveAlign(align, field?.type); 23560 return /* @__PURE__ */ (0, import_jsx_runtime131.jsx)( 23561 "td", 23562 { 23563 style: { 23564 width, 23565 maxWidth, 23566 minWidth 23567 }, 23568 children: /* @__PURE__ */ (0, import_jsx_runtime131.jsx)( 23569 TableColumnField, 23570 { 23571 fields: fields2, 23572 item, 23573 column, 23574 align: effectiveAlign 23575 } 23576 ) 23577 }, 23578 column 23579 ); 23580 }), 23581 !!actions?.length && // Disable reason: we are not making the element interactive, 23582 // but preventing any click events from bubbling up to the 23583 // table row. This allows us to add a click handler to the row 23584 // itself (to toggle row selection) without erroneously 23585 // intercepting click events from ItemActions. 23586 /* @__PURE__ */ (0, import_jsx_runtime131.jsx)( 23587 "td", 23588 { 23589 className: clsx_default("dataviews-view-table__actions-column", { 23590 "dataviews-view-table__actions-column--sticky": true, 23591 "dataviews-view-table__actions-column--stuck": isActionsColumnSticky 23592 }), 23593 onClick: (e2) => e2.stopPropagation(), 23594 children: /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(ItemActions, { item, actions }) 23595 } 23596 ) 23597 ] 23598 } 23599 ); 23600 } 23601 function ViewTable({ 23602 actions, 23603 data, 23604 fields: fields2, 23605 getItemId: getItemId2, 23606 getItemLevel: getItemLevel2, 23607 isLoading = false, 23608 onChangeView, 23609 onChangeSelection, 23610 selection, 23611 setOpenedFilter, 23612 onClickItem, 23613 isItemClickable, 23614 renderItemLink, 23615 view, 23616 className, 23617 empty 23618 }) { 23619 const { containerRef } = (0, import_element67.useContext)(dataviews_context_default); 23620 const isDelayedLoading = useDelayedLoading(isLoading); 23621 const groupField = view.groupBy?.field ? fields2.find((f2) => f2.id === view.groupBy?.field) : null; 23622 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null; 23623 const orderedData = dataByGroup ? Array.from(dataByGroup.values()).flat() : data; 23624 const { getSelectionProps } = useSelectionProps({ 23625 data: orderedData, 23626 actions, 23627 getItemId: getItemId2, 23628 selection, 23629 onChangeSelection 23630 }); 23631 const headerMenuRefs = (0, import_element67.useRef)(/* @__PURE__ */ new Map()); 23632 const headerMenuToFocusRef = (0, import_element67.useRef)(void 0); 23633 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element67.useState)(); 23634 const [contextMenuAnchor, setContextMenuAnchor] = (0, import_element67.useState)(null); 23635 (0, import_element67.useEffect)(() => { 23636 if (headerMenuToFocusRef.current) { 23637 headerMenuToFocusRef.current.focus(); 23638 headerMenuToFocusRef.current = void 0; 23639 } 23640 }); 23641 const tableNoticeId = (0, import_element67.useId)(); 23642 const { isHorizontalScrollEnd, isVerticallyScrolled } = useScrollState({ 23643 scrollContainerRef: containerRef, 23644 enabledHorizontal: !!actions?.length 23645 }); 23646 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data); 23647 if (nextHeaderMenuToFocus) { 23648 headerMenuToFocusRef.current = nextHeaderMenuToFocus; 23649 setNextHeaderMenuToFocus(void 0); 23650 return; 23651 } 23652 const onHide = (field) => { 23653 const hidden = headerMenuRefs.current.get(field.id); 23654 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0; 23655 setNextHeaderMenuToFocus(fallback?.node); 23656 }; 23657 const handleHeaderContextMenu = (event) => { 23658 event.preventDefault(); 23659 event.stopPropagation(); 23660 const virtualAnchor = { 23661 getBoundingClientRect: () => ({ 23662 x: event.clientX, 23663 y: event.clientY, 23664 top: event.clientY, 23665 left: event.clientX, 23666 right: event.clientX, 23667 bottom: event.clientY, 23668 width: 0, 23669 height: 0, 23670 toJSON: () => ({}) 23671 }) 23672 }; 23673 window.requestAnimationFrame(() => { 23674 setContextMenuAnchor(virtualAnchor); 23675 }); 23676 }; 23677 const hasData = !!data?.length; 23678 const titleField = fields2.find((field) => field.id === view.titleField); 23679 const mediaField = fields2.find((field) => field.id === view.mediaField); 23680 const descriptionField2 = fields2.find( 23681 (field) => field.id === view.descriptionField 23682 ); 23683 const { showTitle = true, showMedia = true, showDescription = true } = view; 23684 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField2 && showDescription; 23685 const columns = view.fields ?? []; 23686 const headerMenuRef = (column, index2) => (node) => { 23687 if (node) { 23688 headerMenuRefs.current.set(column, { 23689 node, 23690 fallback: columns[index2 > 0 ? index2 - 1 : 1] 23691 }); 23692 } else { 23693 headerMenuRefs.current.delete(column); 23694 } 23695 }; 23696 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup; 23697 const isRtl = (0, import_i18n32.isRTL)(); 23698 if (!hasData) { 23699 return /* @__PURE__ */ (0, import_jsx_runtime131.jsx)( 23700 "div", 23701 { 23702 className: clsx_default("dataviews-no-results", { 23703 "is-refreshing": isDelayedLoading 23704 }), 23705 id: tableNoticeId, 23706 children: empty 23707 } 23708 ); 23709 } 23710 return /* @__PURE__ */ (0, import_jsx_runtime131.jsxs)(import_jsx_runtime131.Fragment, { children: [ 23711 /* @__PURE__ */ (0, import_jsx_runtime131.jsxs)( 23712 "table", 23713 { 23714 className: clsx_default("dataviews-view-table", className, { 23715 [`has-$view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes( 23716 view.layout.density 23717 ), 23718 "has-bulk-actions": hasBulkActions, 23719 "is-refreshing": !isInfiniteScroll && isDelayedLoading 23720 }), 23721 "aria-busy": isLoading, 23722 "aria-describedby": tableNoticeId, 23723 role: isInfiniteScroll ? "feed" : void 0, 23724 inert: !isInfiniteScroll && isLoading ? "true" : void 0, 23725 children: [ 23726 /* @__PURE__ */ (0, import_jsx_runtime131.jsxs)("colgroup", { children: [ 23727 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime131.jsx)("col", { className: "dataviews-view-table__col-checkbox" }), 23728 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime131.jsx)("col", { className: "dataviews-view-table__col-first-data" }), 23729 columns.map((column, index2) => /* @__PURE__ */ (0, import_jsx_runtime131.jsx)( 23730 "col", 23731 { 23732 className: clsx_default( 23733 `dataviews-view-table__col-$column}`, 23734 { 23735 "dataviews-view-table__col-expand": !hasPrimaryColumn && index2 === columns.length - 1 23736 } 23737 ) 23738 }, 23739 `col-$column}` 23740 )), 23741 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime131.jsx)("col", { className: "dataviews-view-table__col-actions" }) 23742 ] }), 23743 contextMenuAnchor && /* @__PURE__ */ (0, import_jsx_runtime131.jsx)( 23744 import_components25.Popover, 23745 { 23746 anchor: contextMenuAnchor, 23747 onClose: () => setContextMenuAnchor(null), 23748 placement: "bottom-start", 23749 children: /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(PropertiesSection, { showLabel: false }) 23750 } 23751 ), 23752 /* @__PURE__ */ (0, import_jsx_runtime131.jsx)( 23753 "thead", 23754 { 23755 className: clsx_default({ 23756 "dataviews-view-table__thead--stuck": isVerticallyScrolled 23757 }), 23758 onContextMenu: handleHeaderContextMenu, 23759 children: /* @__PURE__ */ (0, import_jsx_runtime131.jsxs)("tr", { className: "dataviews-view-table__row", children: [ 23760 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime131.jsx)( 23761 "th", 23762 { 23763 className: "dataviews-view-table__checkbox-column", 23764 scope: "col", 23765 onContextMenu: handleHeaderContextMenu, 23766 children: /* @__PURE__ */ (0, import_jsx_runtime131.jsx)( 23767 BulkSelectionCheckbox, 23768 { 23769 selection, 23770 onChangeSelection, 23771 data, 23772 actions, 23773 getItemId: getItemId2 23774 } 23775 ) 23776 } 23777 ), 23778 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime131.jsx)("th", { scope: "col", children: titleField && /* @__PURE__ */ (0, import_jsx_runtime131.jsx)( 23779 column_header_menu_default, 23780 { 23781 ref: headerMenuRef( 23782 titleField.id, 23783 0 23784 ), 23785 fieldId: titleField.id, 23786 view, 23787 fields: fields2, 23788 onChangeView, 23789 onHide, 23790 setOpenedFilter, 23791 canMove: false, 23792 canInsertLeft: isRtl ? view.layout?.enableMoving ?? true : false, 23793 canInsertRight: isRtl ? false : view.layout?.enableMoving ?? true 23794 } 23795 ) }), 23796 columns.map((column, index2) => { 23797 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {}; 23798 const field = fields2.find( 23799 (f2) => f2.id === column 23800 ); 23801 const effectiveAlign = getEffectiveAlign( 23802 align, 23803 field?.type 23804 ); 23805 const canInsertOrMove = view.layout?.enableMoving ?? true; 23806 return /* @__PURE__ */ (0, import_jsx_runtime131.jsx)( 23807 "th", 23808 { 23809 style: { 23810 width, 23811 maxWidth, 23812 minWidth, 23813 textAlign: effectiveAlign 23814 }, 23815 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0, 23816 scope: "col", 23817 children: /* @__PURE__ */ (0, import_jsx_runtime131.jsx)( 23818 column_header_menu_default, 23819 { 23820 ref: headerMenuRef(column, index2), 23821 fieldId: column, 23822 view, 23823 fields: fields2, 23824 onChangeView, 23825 onHide, 23826 setOpenedFilter, 23827 canMove: canInsertOrMove, 23828 canInsertLeft: canInsertOrMove, 23829 canInsertRight: canInsertOrMove 23830 } 23831 ) 23832 }, 23833 column 23834 ); 23835 }), 23836 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime131.jsx)( 23837 "th", 23838 { 23839 className: clsx_default( 23840 "dataviews-view-table__actions-column", 23841 { 23842 "dataviews-view-table__actions-column--sticky": true, 23843 "dataviews-view-table__actions-column--stuck": !isHorizontalScrollEnd 23844 } 23845 ), 23846 children: /* @__PURE__ */ (0, import_jsx_runtime131.jsx)("span", { className: "dataviews-view-table-header", children: (0, import_i18n32.__)("Actions") }) 23847 } 23848 ) 23849 ] }) 23850 } 23851 ), 23852 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map( 23853 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime131.jsxs)("tbody", { children: [ 23854 /* @__PURE__ */ (0, import_jsx_runtime131.jsx)("tr", { className: "dataviews-view-table__group-header-row", children: /* @__PURE__ */ (0, import_jsx_runtime131.jsx)( 23855 "td", 23856 { 23857 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + (hasBulkActions ? 1 : 0) + (actions?.length ? 1 : 0), 23858 className: "dataviews-view-table__group-header-cell", 23859 children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n32.sprintf)( 23860 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022". 23861 (0, import_i18n32.__)("%1$s: %2$s"), 23862 groupField.label, 23863 groupName 23864 ) 23865 } 23866 ) }), 23867 groupItems.map((item, index2) => { 23868 const id = getItemId2(item) || index2.toString(); 23869 return /* @__PURE__ */ (0, import_jsx_runtime131.jsx)( 23870 TableRow, 23871 { 23872 item, 23873 level: view.showLevels && typeof getItemLevel2 === "function" ? getItemLevel2(item) : void 0, 23874 hasBulkActions, 23875 actions, 23876 fields: fields2, 23877 id, 23878 view, 23879 titleField, 23880 mediaField, 23881 descriptionField: descriptionField2, 23882 selection, 23883 getItemId: getItemId2, 23884 onChangeSelection, 23885 ...getSelectionProps(id), 23886 onClickItem, 23887 renderItemLink, 23888 isItemClickable, 23889 isActionsColumnSticky: !isHorizontalScrollEnd 23890 }, 23891 getItemId2(item) 23892 ); 23893 }) 23894 ] }, `group-$groupName}`) 23895 ) : /* @__PURE__ */ (0, import_jsx_runtime131.jsx)("tbody", { children: hasData && data.map((item, index2) => { 23896 const id = getItemId2(item) || index2.toString(); 23897 return /* @__PURE__ */ (0, import_jsx_runtime131.jsx)( 23898 TableRow, 23899 { 23900 item, 23901 level: view.showLevels && typeof getItemLevel2 === "function" ? getItemLevel2(item) : void 0, 23902 hasBulkActions, 23903 actions, 23904 fields: fields2, 23905 id, 23906 view, 23907 titleField, 23908 mediaField, 23909 descriptionField: descriptionField2, 23910 selection, 23911 getItemId: getItemId2, 23912 onChangeSelection, 23913 ...getSelectionProps(id), 23914 onClickItem, 23915 renderItemLink, 23916 isItemClickable, 23917 isActionsColumnSticky: !isHorizontalScrollEnd, 23918 posinset: isInfiniteScroll ? index2 + 1 : void 0 23919 }, 23920 getItemId2(item) 23921 ); 23922 }) }) 23923 ] 23924 } 23925 ), 23926 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime131.jsx)("div", { className: "dataviews-loading", id: tableNoticeId, children: /* @__PURE__ */ (0, import_jsx_runtime131.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(import_components25.Spinner, {}) }) }) 23927 ] }); 23928 } 23929 var table_default = ViewTable; 23930 23931 // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs 23932 var import_components28 = __toESM(require_components(), 1); 23933 var import_i18n35 = __toESM(require_i18n(), 1); 23934 23935 // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs 23936 var import_components27 = __toESM(require_components(), 1); 23937 var import_i18n34 = __toESM(require_i18n(), 1); 23938 var import_compose7 = __toESM(require_compose(), 1); 23939 var import_element71 = __toESM(require_element(), 1); 23940 23941 // packages/dataviews/build-module/components/dataviews-layouts/grid/preview-size-picker.mjs 23942 var import_components26 = __toESM(require_components(), 1); 23943 var import_i18n33 = __toESM(require_i18n(), 1); 23944 var import_element68 = __toESM(require_element(), 1); 23945 var import_jsx_runtime132 = __toESM(require_jsx_runtime(), 1); 23946 var imageSizes = [ 23947 { 23948 value: 120, 23949 breakpoint: 1 23950 }, 23951 { 23952 value: 170, 23953 breakpoint: 1 23954 }, 23955 { 23956 value: 230, 23957 breakpoint: 1 23958 }, 23959 { 23960 value: 290, 23961 breakpoint: 1112 23962 // at minimum image width, 4 images display at this container size 23963 }, 23964 { 23965 value: 350, 23966 breakpoint: 1636 23967 // at minimum image width, 6 images display at this container size 23968 }, 23969 { 23970 value: 430, 23971 breakpoint: 588 23972 // at minimum image width, 2 images display at this container size 23973 } 23974 ]; 23975 var DEFAULT_PREVIEW_SIZE = imageSizes[2].value; 23976 function useGridColumns() { 23977 const context = (0, import_element68.useContext)(dataviews_context_default); 23978 const view = context.view; 23979 return (0, import_element68.useMemo)(() => { 23980 const containerWidth = context.containerWidth; 23981 const gap = 32; 23982 const previewSize = view.layout?.previewSize ?? DEFAULT_PREVIEW_SIZE; 23983 const columns = Math.floor( 23984 (containerWidth + gap) / (previewSize + gap) 23985 ); 23986 return Math.max(1, columns); 23987 }, [context.containerWidth, view.layout?.previewSize]); 23988 } 23989 23990 // packages/dataviews/build-module/components/dataviews-layouts/utils/grid-items.mjs 23991 var import_element69 = __toESM(require_element(), 1); 23992 var import_jsx_runtime133 = __toESM(require_jsx_runtime(), 1); 23993 var GridItems = (0, import_element69.forwardRef)(({ className, previewSize, ...props }, ref) => { 23994 return /* @__PURE__ */ (0, import_jsx_runtime133.jsx)( 23995 "div", 23996 { 23997 ref, 23998 className: clsx_default("dataviews-view-grid-items", className), 23999 style: { 24000 gridTemplateColumns: previewSize && `repeat(auto-fill, minmax($previewSize}px, 1fr))` 24001 }, 24002 ...props 24003 } 24004 ); 24005 }); 24006 24007 // packages/dataviews/build-module/components/dataviews-layouts/utils/use-infinite-scroll.mjs 24008 var import_element70 = __toESM(require_element(), 1); 24009 function useIntersectionObserver(elementRef, posinset) { 24010 const { intersectionObserver } = (0, import_element70.useContext)(dataviews_context_default); 24011 (0, import_element70.useEffect)(() => { 24012 const element = elementRef.current; 24013 if (!element || posinset === void 0 || !intersectionObserver) { 24014 return; 24015 } 24016 intersectionObserver.observe(element); 24017 return () => { 24018 intersectionObserver.unobserve(element); 24019 }; 24020 }, [elementRef, intersectionObserver, posinset]); 24021 } 24022 function usePlaceholdersNeeded(data, isInfiniteScroll, gridColumns) { 24023 const hasData = !!data?.length; 24024 const firstItemPosition = hasData && isInfiniteScroll ? data[0].position : void 0; 24025 return firstItemPosition && gridColumns ? (firstItemPosition - 1) % gridColumns : 0; 24026 } 24027 24028 // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs 24029 var import_jsx_runtime134 = __toESM(require_jsx_runtime(), 1); 24030 var { Badge: WCBadge } = unlock4(import_components27.privateApis); 24031 function chunk(array, size4) { 24032 const chunks = []; 24033 for (let i2 = 0, j2 = array.length; i2 < j2; i2 += size4) { 24034 chunks.push(array.slice(i2, i2 + size4)); 24035 } 24036 return chunks; 24037 } 24038 var GridItem = (0, import_element71.forwardRef)( 24039 function GridItem2({ 24040 view, 24041 selection, 24042 onChangeSelection, 24043 onClickItem, 24044 isItemClickable, 24045 renderItemLink, 24046 getItemId: getItemId2, 24047 item, 24048 actions, 24049 mediaField, 24050 titleField, 24051 descriptionField: descriptionField2, 24052 regularFields, 24053 badgeFields, 24054 hasBulkActions, 24055 config: config2, 24056 posinset, 24057 setsize, 24058 ...props 24059 }, forwardedRef) { 24060 const { 24061 showTitle = true, 24062 showMedia = true, 24063 showDescription = true 24064 } = view; 24065 const hasBulkAction = useHasAPossibleBulkAction(actions, item); 24066 const id = getItemId2(item); 24067 const elementRef = (0, import_element71.useRef)(null); 24068 const setRefs = (0, import_element71.useCallback)( 24069 (node) => { 24070 elementRef.current = node; 24071 if (typeof forwardedRef === "function") { 24072 forwardedRef(node); 24073 } else if (forwardedRef) { 24074 forwardedRef.current = node; 24075 } 24076 }, 24077 [forwardedRef] 24078 ); 24079 useIntersectionObserver(elementRef, posinset); 24080 const instanceId = (0, import_compose7.useInstanceId)(GridItem2); 24081 const isSelected2 = selection.includes(id); 24082 const mediaPlaceholder = /* @__PURE__ */ (0, import_jsx_runtime134.jsx)("span", { className: "dataviews-view-grid__media-placeholder" }); 24083 const rendersMediaField = showMedia && mediaField?.render; 24084 const renderedMediaField = rendersMediaField ? /* @__PURE__ */ (0, import_jsx_runtime134.jsx)( 24085 mediaField.render, 24086 { 24087 item, 24088 field: mediaField, 24089 config: config2 24090 } 24091 ) : mediaPlaceholder; 24092 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(titleField.render, { item, field: titleField }) : null; 24093 let mediaA11yProps; 24094 let titleA11yProps; 24095 if (isItemClickable(item) && onClickItem) { 24096 if (renderedTitleField) { 24097 mediaA11yProps = { 24098 "aria-labelledby": `dataviews-view-grid__title-field-$instanceId}` 24099 }; 24100 titleA11yProps = { 24101 id: `dataviews-view-grid__title-field-$instanceId}` 24102 }; 24103 } else { 24104 mediaA11yProps = { 24105 "aria-label": (0, import_i18n34.__)("Navigate to item") 24106 }; 24107 } 24108 } 24109 return /* @__PURE__ */ (0, import_jsx_runtime134.jsxs)( 24110 Stack, 24111 { 24112 direction: "column", 24113 ...props, 24114 ref: setRefs, 24115 "aria-setsize": setsize, 24116 "aria-posinset": posinset, 24117 className: clsx_default( 24118 props.className, 24119 "dataviews-view-grid__row__gridcell", 24120 "dataviews-view-grid__card", 24121 { 24122 "is-selected": hasBulkAction && isSelected2 24123 } 24124 ), 24125 children: [ 24126 /* @__PURE__ */ (0, import_jsx_runtime134.jsx)( 24127 ItemClickWrapper, 24128 { 24129 item, 24130 isItemClickable, 24131 onClickItem, 24132 renderItemLink, 24133 className: clsx_default("dataviews-view-grid__media", { 24134 "dataviews-view-grid__media--placeholder": !rendersMediaField 24135 }), 24136 ...mediaA11yProps, 24137 children: renderedMediaField 24138 } 24139 ), 24140 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime134.jsx)( 24141 DataViewsSelectionCheckbox, 24142 { 24143 item, 24144 selection, 24145 onChangeSelection, 24146 getItemId: getItemId2, 24147 titleField, 24148 disabled: !hasBulkAction 24149 } 24150 ), 24151 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime134.jsx)("div", { className: "dataviews-view-grid__media-actions", children: /* @__PURE__ */ (0, import_jsx_runtime134.jsx)( 24152 ItemActions, 24153 { 24154 item, 24155 actions, 24156 isCompact: true 24157 } 24158 ) }), 24159 showTitle && /* @__PURE__ */ (0, import_jsx_runtime134.jsx)("div", { className: "dataviews-view-grid__title-actions", children: /* @__PURE__ */ (0, import_jsx_runtime134.jsx)( 24160 ItemClickWrapper, 24161 { 24162 item, 24163 isItemClickable, 24164 onClickItem, 24165 renderItemLink, 24166 className: "dataviews-view-grid__title-field dataviews-title-field", 24167 ...titleA11yProps, 24168 title: titleField?.getValueFormatted({ 24169 item, 24170 field: titleField 24171 }) || void 0, 24172 children: renderedTitleField 24173 } 24174 ) }), 24175 /* @__PURE__ */ (0, import_jsx_runtime134.jsxs)(Stack, { direction: "column", gap: "xs", children: [ 24176 showDescription && descriptionField2?.render && /* @__PURE__ */ (0, import_jsx_runtime134.jsx)( 24177 descriptionField2.render, 24178 { 24179 item, 24180 field: descriptionField2 24181 } 24182 ), 24183 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime134.jsx)( 24184 Stack, 24185 { 24186 direction: "row", 24187 className: "dataviews-view-grid__badge-fields", 24188 gap: "sm", 24189 wrap: "wrap", 24190 align: "top", 24191 justify: "flex-start", 24192 children: badgeFields.map((field) => { 24193 return /* @__PURE__ */ (0, import_jsx_runtime134.jsx)( 24194 WCBadge, 24195 { 24196 className: "dataviews-view-grid__field-value", 24197 children: /* @__PURE__ */ (0, import_jsx_runtime134.jsx)( 24198 field.render, 24199 { 24200 item, 24201 field 24202 } 24203 ) 24204 }, 24205 field.id 24206 ); 24207 }) 24208 } 24209 ), 24210 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime134.jsx)( 24211 Stack, 24212 { 24213 direction: "column", 24214 className: "dataviews-view-grid__fields", 24215 gap: "xs", 24216 children: regularFields.map((field) => { 24217 return /* @__PURE__ */ (0, import_jsx_runtime134.jsx)( 24218 import_components27.Flex, 24219 { 24220 className: "dataviews-view-grid__field", 24221 gap: 1, 24222 justify: "flex-start", 24223 expanded: true, 24224 style: { height: "auto" }, 24225 direction: "row", 24226 children: /* @__PURE__ */ (0, import_jsx_runtime134.jsxs)(import_jsx_runtime134.Fragment, { children: [ 24227 /* @__PURE__ */ (0, import_jsx_runtime134.jsxs)(tooltip_exports.Root, { children: [ 24228 /* @__PURE__ */ (0, import_jsx_runtime134.jsx)( 24229 tooltip_exports.Trigger, 24230 { 24231 render: /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(import_components27.FlexItem, { className: "dataviews-view-grid__field-name", children: field.header }) 24232 } 24233 ), 24234 /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(tooltip_exports.Popup, { children: field.label }) 24235 ] }), 24236 /* @__PURE__ */ (0, import_jsx_runtime134.jsx)( 24237 import_components27.FlexItem, 24238 { 24239 className: "dataviews-view-grid__field-value", 24240 style: { maxHeight: "none" }, 24241 children: /* @__PURE__ */ (0, import_jsx_runtime134.jsx)( 24242 field.render, 24243 { 24244 item, 24245 field 24246 } 24247 ) 24248 } 24249 ) 24250 ] }) 24251 }, 24252 field.id 24253 ); 24254 }) 24255 } 24256 ) 24257 ] }) 24258 ] 24259 } 24260 ); 24261 } 24262 ); 24263 function CompositeGrid({ 24264 data, 24265 isInfiniteScroll, 24266 className, 24267 inert, 24268 isLoading, 24269 view, 24270 fields: fields2, 24271 selection, 24272 onChangeSelection, 24273 onClickItem, 24274 isItemClickable, 24275 renderItemLink, 24276 getItemId: getItemId2, 24277 actions, 24278 getSelectionProps 24279 }) { 24280 const { paginationInfo, resizeObserverRef } = (0, import_element71.useContext)(dataviews_context_default); 24281 const gridColumns = useGridColumns(); 24282 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data); 24283 const titleField = fields2.find( 24284 (field) => field.id === view?.titleField 24285 ); 24286 const mediaField = fields2.find( 24287 (field) => field.id === view?.mediaField 24288 ); 24289 const descriptionField2 = fields2.find( 24290 (field) => field.id === view?.descriptionField 24291 ); 24292 const otherFields = view.fields ?? []; 24293 const { regularFields, badgeFields } = otherFields.reduce( 24294 (accumulator, fieldId) => { 24295 const field = fields2.find((f2) => f2.id === fieldId); 24296 if (!field) { 24297 return accumulator; 24298 } 24299 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields"; 24300 accumulator[key].push(field); 24301 return accumulator; 24302 }, 24303 { regularFields: [], badgeFields: [] } 24304 ); 24305 const size4 = "900px"; 24306 const totalRows = Math.ceil(data.length / gridColumns); 24307 const placeholdersNeeded = usePlaceholdersNeeded( 24308 data, 24309 isInfiniteScroll, 24310 gridColumns 24311 ); 24312 return /* @__PURE__ */ (0, import_jsx_runtime134.jsxs)(import_jsx_runtime134.Fragment, { 24313 // Render infinite scroll layout (no rows, feed semantics) 24314 children: [ 24315 isInfiniteScroll && /* @__PURE__ */ (0, import_jsx_runtime134.jsxs)( 24316 import_components27.Composite, 24317 { 24318 render: /* @__PURE__ */ (0, import_jsx_runtime134.jsx)( 24319 GridItems, 24320 { 24321 className: clsx_default( 24322 "dataviews-view-grid-infinite-scroll", 24323 className, 24324 { 24325 [`has-$view.layout?.density}-density`]: view.layout?.density && [ 24326 "compact", 24327 "comfortable" 24328 ].includes(view.layout.density) 24329 } 24330 ), 24331 previewSize: view.layout?.previewSize, 24332 "aria-busy": isLoading, 24333 ref: resizeObserverRef 24334 } 24335 ), 24336 role: "feed", 24337 focusWrap: true, 24338 inert, 24339 children: [ 24340 Array.from({ length: placeholdersNeeded }).map( 24341 (_, index2) => /* @__PURE__ */ (0, import_jsx_runtime134.jsx)( 24342 import_components27.Composite.Item, 24343 { 24344 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime134.jsx)( 24345 Stack, 24346 { 24347 ...props, 24348 direction: "column", 24349 role: "article", 24350 className: "dataviews-view-grid__row__gridcell dataviews-view-grid__card dataviews-view-grid__placeholder" 24351 } 24352 ), 24353 "aria-hidden": true, 24354 tabIndex: -1 24355 }, 24356 `placeholder-$index2}` 24357 ) 24358 ), 24359 data.map((item) => { 24360 const itemId = getItemId2(item); 24361 const selectionProps = getSelectionProps(itemId); 24362 const stablePosition = item.position; 24363 return /* @__PURE__ */ (0, import_jsx_runtime134.jsx)( 24364 import_components27.Composite.Item, 24365 { 24366 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime134.jsx)( 24367 GridItem, 24368 { 24369 ...props, 24370 id: itemId, 24371 role: "article", 24372 view, 24373 selection, 24374 onChangeSelection, 24375 onClickItem, 24376 isItemClickable, 24377 renderItemLink, 24378 getItemId: getItemId2, 24379 item, 24380 actions, 24381 onMouseDown: (event) => { 24382 props.onMouseDown?.(event); 24383 selectionProps.onMouseDown( 24384 event 24385 ); 24386 }, 24387 onClickCapture: (event) => { 24388 props.onClickCapture?.(event); 24389 selectionProps.onClickCapture( 24390 event 24391 ); 24392 }, 24393 mediaField, 24394 titleField, 24395 descriptionField: descriptionField2, 24396 regularFields, 24397 badgeFields, 24398 hasBulkActions, 24399 posinset: stablePosition, 24400 setsize: paginationInfo.totalItems, 24401 config: { 24402 sizes: size4 24403 } 24404 } 24405 ) 24406 }, 24407 itemId 24408 ); 24409 }) 24410 ] 24411 } 24412 ), 24413 // Render standard grid layout (with rows, grid semantics) 24414 !isInfiniteScroll && /* @__PURE__ */ (0, import_jsx_runtime134.jsx)( 24415 import_components27.Composite, 24416 { 24417 role: "grid", 24418 className: clsx_default("dataviews-view-grid", className, { 24419 [`has-$view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes( 24420 view.layout.density 24421 ) 24422 }), 24423 focusWrap: true, 24424 "aria-busy": isLoading, 24425 "aria-rowcount": totalRows, 24426 ref: resizeObserverRef, 24427 inert, 24428 children: chunk(data, gridColumns).map((row, i2) => /* @__PURE__ */ (0, import_jsx_runtime134.jsx)( 24429 import_components27.Composite.Row, 24430 { 24431 render: /* @__PURE__ */ (0, import_jsx_runtime134.jsx)( 24432 "div", 24433 { 24434 role: "row", 24435 "aria-rowindex": i2 + 1, 24436 "aria-label": (0, import_i18n34.sprintf)( 24437 /* translators: %d: The row number in the grid */ 24438 (0, import_i18n34.__)("Row %d"), 24439 i2 + 1 24440 ), 24441 className: "dataviews-view-grid__row", 24442 style: { 24443 gridTemplateColumns: `repeat( $gridColumns}, minmax(0, 1fr) )` 24444 } 24445 } 24446 ), 24447 children: row.map((item) => { 24448 const itemId = getItemId2(item); 24449 const selectionProps = getSelectionProps(itemId); 24450 return /* @__PURE__ */ (0, import_jsx_runtime134.jsx)( 24451 import_components27.Composite.Item, 24452 { 24453 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime134.jsx)( 24454 GridItem, 24455 { 24456 ...props, 24457 id: itemId, 24458 role: "gridcell", 24459 view, 24460 selection, 24461 onChangeSelection, 24462 onClickItem, 24463 isItemClickable, 24464 renderItemLink, 24465 getItemId: getItemId2, 24466 item, 24467 actions, 24468 onMouseDown: (event) => { 24469 props.onMouseDown?.( 24470 event 24471 ); 24472 selectionProps.onMouseDown( 24473 event 24474 ); 24475 }, 24476 onClickCapture: (event) => { 24477 props.onClickCapture?.( 24478 event 24479 ); 24480 selectionProps.onClickCapture( 24481 event 24482 ); 24483 }, 24484 mediaField, 24485 titleField, 24486 descriptionField: descriptionField2, 24487 regularFields, 24488 badgeFields, 24489 hasBulkActions, 24490 config: { 24491 sizes: size4 24492 } 24493 } 24494 ) 24495 }, 24496 itemId 24497 ); 24498 }) 24499 }, 24500 i2 24501 )) 24502 } 24503 ) 24504 ] 24505 }); 24506 } 24507 24508 // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs 24509 var import_jsx_runtime135 = __toESM(require_jsx_runtime(), 1); 24510 function ViewGrid({ 24511 actions, 24512 data, 24513 fields: fields2, 24514 getItemId: getItemId2, 24515 isLoading, 24516 onChangeSelection, 24517 onClickItem, 24518 isItemClickable, 24519 renderItemLink, 24520 selection, 24521 view, 24522 className, 24523 empty 24524 }) { 24525 const isDelayedLoading = useDelayedLoading(!!isLoading); 24526 const hasData = !!data?.length; 24527 const groupField = view.groupBy?.field ? fields2.find((f2) => f2.id === view.groupBy?.field) : null; 24528 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null; 24529 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup; 24530 const orderedData = dataByGroup ? Array.from(dataByGroup.values()).flat() : data; 24531 const { getSelectionProps } = useSelectionProps({ 24532 data: orderedData, 24533 actions, 24534 getItemId: getItemId2, 24535 selection, 24536 onChangeSelection 24537 }); 24538 if (!hasData) { 24539 return /* @__PURE__ */ (0, import_jsx_runtime135.jsx)( 24540 "div", 24541 { 24542 className: clsx_default("dataviews-no-results", { 24543 "is-refreshing": isDelayedLoading 24544 }), 24545 children: empty 24546 } 24547 ); 24548 } 24549 const gridProps = { 24550 className: clsx_default(className, { 24551 "is-refreshing": !isInfiniteScroll && isDelayedLoading 24552 }), 24553 inert: !isInfiniteScroll && !!isLoading ? "true" : void 0, 24554 isLoading, 24555 view, 24556 fields: fields2, 24557 selection, 24558 onChangeSelection, 24559 onClickItem, 24560 isItemClickable, 24561 renderItemLink, 24562 getItemId: getItemId2, 24563 actions, 24564 getSelectionProps 24565 }; 24566 return /* @__PURE__ */ (0, import_jsx_runtime135.jsxs)(import_jsx_runtime135.Fragment, { 24567 // Render multiple groups. 24568 children: [ 24569 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(Stack, { direction: "column", gap: "lg", children: Array.from(dataByGroup.entries()).map( 24570 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime135.jsxs)( 24571 Stack, 24572 { 24573 direction: "column", 24574 gap: "sm", 24575 children: [ 24576 /* @__PURE__ */ (0, import_jsx_runtime135.jsx)("h3", { className: "dataviews-view-grid__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n35.sprintf)( 24577 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022". 24578 (0, import_i18n35.__)("%1$s: %2$s"), 24579 groupField.label, 24580 groupName 24581 ) }), 24582 /* @__PURE__ */ (0, import_jsx_runtime135.jsx)( 24583 CompositeGrid, 24584 { 24585 ...gridProps, 24586 data: groupItems, 24587 isInfiniteScroll: false 24588 } 24589 ) 24590 ] 24591 }, 24592 groupName 24593 ) 24594 ) }), 24595 // Render a single grid with all data. 24596 !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime135.jsx)( 24597 CompositeGrid, 24598 { 24599 ...gridProps, 24600 data, 24601 isInfiniteScroll: !!isInfiniteScroll 24602 } 24603 ), 24604 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime135.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(import_components28.Spinner, {}) }) 24605 ] 24606 }); 24607 } 24608 var grid_default = ViewGrid; 24609 24610 // packages/dataviews/build-module/components/dataviews-layouts/list/index.mjs 24611 var import_compose8 = __toESM(require_compose(), 1); 24612 var import_components29 = __toESM(require_components(), 1); 24613 var import_element72 = __toESM(require_element(), 1); 24614 var import_i18n36 = __toESM(require_i18n(), 1); 24615 var import_data38 = __toESM(require_data(), 1); 24616 var import_jsx_runtime136 = __toESM(require_jsx_runtime(), 1); 24617 var { Menu: Menu3 } = unlock4(import_components29.privateApis); 24618 function generateItemWrapperCompositeId(idPrefix) { 24619 return `$idPrefix}-item-wrapper`; 24620 } 24621 function generatePrimaryActionCompositeId(idPrefix, primaryActionId) { 24622 return `$idPrefix}-primary-action-$primaryActionId}`; 24623 } 24624 function generateDropdownTriggerCompositeId(idPrefix) { 24625 return `$idPrefix}-dropdown`; 24626 } 24627 function PrimaryActionGridCell({ 24628 idPrefix, 24629 primaryAction, 24630 item 24631 }) { 24632 const registry = (0, import_data38.useRegistry)(); 24633 const [isModalOpen, setIsModalOpen] = (0, import_element72.useState)(false); 24634 const compositeItemId = generatePrimaryActionCompositeId( 24635 idPrefix, 24636 primaryAction.id 24637 ); 24638 const label = typeof primaryAction.label === "string" ? primaryAction.label : primaryAction.label([item]); 24639 return "RenderModal" in primaryAction ? /* @__PURE__ */ (0, import_jsx_runtime136.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime136.jsx)( 24640 import_components29.Composite.Item, 24641 { 24642 id: compositeItemId, 24643 render: /* @__PURE__ */ (0, import_jsx_runtime136.jsx)( 24644 import_components29.Button, 24645 { 24646 disabled: !!primaryAction.disabled, 24647 accessibleWhenDisabled: true, 24648 text: label, 24649 size: "small", 24650 onClick: () => setIsModalOpen(true) 24651 } 24652 ), 24653 children: isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime136.jsx)( 24654 ActionModal, 24655 { 24656 action: primaryAction, 24657 items: [item], 24658 closeModal: () => setIsModalOpen(false) 24659 } 24660 ) 24661 } 24662 ) }, primaryAction.id) : /* @__PURE__ */ (0, import_jsx_runtime136.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime136.jsx)( 24663 import_components29.Composite.Item, 24664 { 24665 id: compositeItemId, 24666 render: /* @__PURE__ */ (0, import_jsx_runtime136.jsx)( 24667 import_components29.Button, 24668 { 24669 disabled: !!primaryAction.disabled, 24670 accessibleWhenDisabled: true, 24671 size: "small", 24672 onClick: () => { 24673 primaryAction.callback([item], { registry }); 24674 }, 24675 children: label 24676 } 24677 ) 24678 } 24679 ) }, primaryAction.id); 24680 } 24681 function ListItem({ 24682 view, 24683 actions, 24684 idPrefix, 24685 isSelected: isSelected2, 24686 item, 24687 titleField, 24688 mediaField, 24689 descriptionField: descriptionField2, 24690 onSelect, 24691 otherFields, 24692 onDropdownTriggerKeyDown, 24693 posinset 24694 }) { 24695 const { 24696 showTitle = true, 24697 showMedia = true, 24698 showDescription = true, 24699 infiniteScrollEnabled 24700 } = view; 24701 const itemRef = (0, import_element72.useRef)(null); 24702 const labelId = `$idPrefix}-label`; 24703 const descriptionId = `$idPrefix}-description`; 24704 const registry = (0, import_data38.useRegistry)(); 24705 const [isHovered, setIsHovered] = (0, import_element72.useState)(false); 24706 const [activeModalAction, setActiveModalAction] = (0, import_element72.useState)( 24707 null 24708 ); 24709 const handleHover = ({ type }) => { 24710 const isHover = type === "mouseenter"; 24711 setIsHovered(isHover); 24712 }; 24713 const { paginationInfo } = (0, import_element72.useContext)(dataviews_context_default); 24714 (0, import_element72.useEffect)(() => { 24715 if (isSelected2) { 24716 itemRef.current?.scrollIntoView({ 24717 behavior: "auto", 24718 block: "nearest", 24719 inline: "nearest" 24720 }); 24721 } 24722 }, [isSelected2]); 24723 const { primaryAction, eligibleActions } = (0, import_element72.useMemo)(() => { 24724 const _eligibleActions = actions.filter( 24725 (action) => !action.isEligible || action.isEligible(item) 24726 ); 24727 const _primaryActions = _eligibleActions.filter( 24728 (action) => action.isPrimary 24729 ); 24730 return { 24731 primaryAction: _primaryActions[0], 24732 eligibleActions: _eligibleActions 24733 }; 24734 }, [actions, item]); 24735 const hasOnlyOnePrimaryAction = primaryAction && actions.length === 1; 24736 const renderedMediaField = showMedia && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime136.jsx)("div", { className: "dataviews-view-list__media-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime136.jsx)( 24737 mediaField.render, 24738 { 24739 item, 24740 field: mediaField, 24741 config: { sizes: "52px" } 24742 } 24743 ) }) : null; 24744 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(titleField.render, { item, field: titleField }) : null; 24745 const renderDescription = showDescription && descriptionField2?.render; 24746 const hasOnlyMediaAndTitle = !!renderedMediaField && !renderDescription && !otherFields.length; 24747 const usedActions = eligibleActions?.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime136.jsxs)( 24748 Stack, 24749 { 24750 direction: "row", 24751 gap: "md", 24752 className: "dataviews-view-list__item-actions", 24753 children: [ 24754 primaryAction && /* @__PURE__ */ (0, import_jsx_runtime136.jsx)( 24755 PrimaryActionGridCell, 24756 { 24757 idPrefix, 24758 primaryAction, 24759 item 24760 } 24761 ), 24762 !hasOnlyOnePrimaryAction && /* @__PURE__ */ (0, import_jsx_runtime136.jsxs)("div", { role: "gridcell", children: [ 24763 /* @__PURE__ */ (0, import_jsx_runtime136.jsxs)(Menu3, { placement: "bottom-end", children: [ 24764 /* @__PURE__ */ (0, import_jsx_runtime136.jsx)( 24765 Menu3.TriggerButton, 24766 { 24767 render: /* @__PURE__ */ (0, import_jsx_runtime136.jsx)( 24768 import_components29.Composite.Item, 24769 { 24770 id: generateDropdownTriggerCompositeId( 24771 idPrefix 24772 ), 24773 render: /* @__PURE__ */ (0, import_jsx_runtime136.jsx)( 24774 import_components29.Button, 24775 { 24776 size: "small", 24777 icon: more_vertical_default, 24778 label: (0, import_i18n36.__)("Actions"), 24779 accessibleWhenDisabled: true, 24780 disabled: !actions.length, 24781 onKeyDown: onDropdownTriggerKeyDown 24782 } 24783 ) 24784 } 24785 ) 24786 } 24787 ), 24788 /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(Menu3.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime136.jsx)( 24789 ActionsMenuGroup, 24790 { 24791 actions: eligibleActions, 24792 item, 24793 registry, 24794 setActiveModalAction 24795 } 24796 ) }) 24797 ] }), 24798 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime136.jsx)( 24799 ActionModal, 24800 { 24801 action: activeModalAction, 24802 items: [item], 24803 closeModal: () => setActiveModalAction(null) 24804 } 24805 ) 24806 ] }) 24807 ] 24808 } 24809 ); 24810 return /* @__PURE__ */ (0, import_jsx_runtime136.jsx)( 24811 import_components29.Composite.Row, 24812 { 24813 ref: itemRef, 24814 render: ( 24815 /* aria-posinset breaks Composite.Row if passed to it directly. */ 24816 /* @__PURE__ */ (0, import_jsx_runtime136.jsx)( 24817 "div", 24818 { 24819 "aria-posinset": posinset, 24820 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0 24821 } 24822 ) 24823 ), 24824 role: infiniteScrollEnabled ? "article" : "row", 24825 className: clsx_default({ 24826 "is-selected": isSelected2, 24827 "is-hovered": isHovered 24828 }), 24829 onMouseEnter: handleHover, 24830 onMouseLeave: handleHover, 24831 children: /* @__PURE__ */ (0, import_jsx_runtime136.jsxs)( 24832 Stack, 24833 { 24834 direction: "row", 24835 className: "dataviews-view-list__item-wrapper", 24836 children: [ 24837 /* @__PURE__ */ (0, import_jsx_runtime136.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime136.jsx)( 24838 import_components29.Composite.Item, 24839 { 24840 id: generateItemWrapperCompositeId(idPrefix), 24841 "aria-pressed": isSelected2, 24842 "aria-labelledby": labelId, 24843 "aria-describedby": descriptionId, 24844 className: "dataviews-view-list__item", 24845 onClick: () => onSelect(item) 24846 } 24847 ) }), 24848 /* @__PURE__ */ (0, import_jsx_runtime136.jsxs)( 24849 Stack, 24850 { 24851 direction: "row", 24852 gap: "md", 24853 justify: "start", 24854 align: hasOnlyMediaAndTitle ? "center" : "flex-start", 24855 style: { flex: 1, minWidth: 0 }, 24856 children: [ 24857 renderedMediaField, 24858 /* @__PURE__ */ (0, import_jsx_runtime136.jsxs)( 24859 Stack, 24860 { 24861 direction: "column", 24862 gap: "xs", 24863 className: "dataviews-view-list__field-wrapper", 24864 children: [ 24865 /* @__PURE__ */ (0, import_jsx_runtime136.jsxs)(Stack, { direction: "row", align: "center", children: [ 24866 /* @__PURE__ */ (0, import_jsx_runtime136.jsx)( 24867 "div", 24868 { 24869 className: "dataviews-title-field dataviews-view-list__title-field", 24870 id: labelId, 24871 children: renderedTitleField 24872 } 24873 ), 24874 usedActions 24875 ] }), 24876 renderDescription && /* @__PURE__ */ (0, import_jsx_runtime136.jsx)("div", { className: "dataviews-view-list__field", children: /* @__PURE__ */ (0, import_jsx_runtime136.jsx)( 24877 descriptionField2.render, 24878 { 24879 item, 24880 field: descriptionField2 24881 } 24882 ) }), 24883 /* @__PURE__ */ (0, import_jsx_runtime136.jsx)( 24884 "div", 24885 { 24886 className: "dataviews-view-list__fields", 24887 id: descriptionId, 24888 children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime136.jsxs)( 24889 "div", 24890 { 24891 className: "dataviews-view-list__field", 24892 children: [ 24893 /* @__PURE__ */ (0, import_jsx_runtime136.jsx)( 24894 VisuallyHidden, 24895 { 24896 className: "dataviews-view-list__field-label", 24897 render: /* @__PURE__ */ (0, import_jsx_runtime136.jsx)("span", {}), 24898 children: field.label 24899 } 24900 ), 24901 /* @__PURE__ */ (0, import_jsx_runtime136.jsx)("span", { className: "dataviews-view-list__field-value", children: /* @__PURE__ */ (0, import_jsx_runtime136.jsx)( 24902 field.render, 24903 { 24904 item, 24905 field 24906 } 24907 ) }) 24908 ] 24909 }, 24910 field.id 24911 )) 24912 } 24913 ) 24914 ] 24915 } 24916 ) 24917 ] 24918 } 24919 ) 24920 ] 24921 } 24922 ) 24923 } 24924 ); 24925 } 24926 function isDefined2(item) { 24927 return !!item; 24928 } 24929 function ViewList(props) { 24930 const { 24931 actions, 24932 data, 24933 fields: fields2, 24934 getItemId: getItemId2, 24935 isLoading, 24936 onChangeSelection, 24937 selection, 24938 view, 24939 className, 24940 empty 24941 } = props; 24942 const baseId = (0, import_compose8.useInstanceId)(ViewList, "view-list"); 24943 const isDelayedLoading = useDelayedLoading(!!isLoading); 24944 const { paginationInfo } = (0, import_element72.useContext)(dataviews_context_default); 24945 const selectedItem = data?.findLast( 24946 (item) => selection.includes(getItemId2(item)) 24947 ); 24948 const titleField = fields2.find((field) => field.id === view.titleField); 24949 const mediaField = fields2.find((field) => field.id === view.mediaField); 24950 const descriptionField2 = fields2.find( 24951 (field) => field.id === view.descriptionField 24952 ); 24953 const otherFields = (view?.fields ?? []).map((fieldId) => fields2.find((f2) => fieldId === f2.id)).filter(isDefined2); 24954 const onSelect = (item) => onChangeSelection([getItemId2(item)]); 24955 const generateCompositeItemIdPrefix = (0, import_element72.useCallback)( 24956 (item) => `$baseId}-$getItemId2(item)}`, 24957 [baseId, getItemId2] 24958 ); 24959 const isActiveCompositeItem = (0, import_element72.useCallback)( 24960 (item, idToCheck) => { 24961 return idToCheck.startsWith( 24962 generateCompositeItemIdPrefix(item) 24963 ); 24964 }, 24965 [generateCompositeItemIdPrefix] 24966 ); 24967 const [activeCompositeId, setActiveCompositeId] = (0, import_element72.useState)(void 0); 24968 const compositeRef = (0, import_element72.useRef)(null); 24969 (0, import_element72.useEffect)(() => { 24970 if (selectedItem) { 24971 setActiveCompositeId( 24972 generateItemWrapperCompositeId( 24973 generateCompositeItemIdPrefix(selectedItem) 24974 ) 24975 ); 24976 } 24977 }, [selectedItem, generateCompositeItemIdPrefix]); 24978 const activeItemIndex = data.findIndex( 24979 (item) => isActiveCompositeItem(item, activeCompositeId ?? "") 24980 ); 24981 const previousActiveItemIndex = (0, import_compose8.usePrevious)(activeItemIndex); 24982 const isActiveIdInList = activeItemIndex !== -1; 24983 const selectCompositeItem = (0, import_element72.useCallback)( 24984 (targetIndex, generateCompositeId) => { 24985 const clampedIndex = Math.min( 24986 data.length - 1, 24987 Math.max(0, targetIndex) 24988 ); 24989 if (!data[clampedIndex]) { 24990 return; 24991 } 24992 const itemIdPrefix = generateCompositeItemIdPrefix( 24993 data[clampedIndex] 24994 ); 24995 const targetCompositeItemId = generateCompositeId(itemIdPrefix); 24996 setActiveCompositeId(targetCompositeItemId); 24997 if (compositeRef.current?.contains( 24998 compositeRef.current.ownerDocument.activeElement 24999 )) { 25000 document.getElementById(targetCompositeItemId)?.focus(); 25001 } 25002 }, 25003 [data, generateCompositeItemIdPrefix] 25004 ); 25005 (0, import_element72.useEffect)(() => { 25006 const wasActiveIdInList = previousActiveItemIndex !== void 0 && previousActiveItemIndex !== -1; 25007 if (!isActiveIdInList && wasActiveIdInList) { 25008 selectCompositeItem( 25009 previousActiveItemIndex, 25010 generateItemWrapperCompositeId 25011 ); 25012 } 25013 }, [isActiveIdInList, selectCompositeItem, previousActiveItemIndex]); 25014 const onDropdownTriggerKeyDown = (0, import_element72.useCallback)( 25015 (event) => { 25016 if (event.key === "ArrowDown") { 25017 event.preventDefault(); 25018 selectCompositeItem( 25019 activeItemIndex + 1, 25020 generateDropdownTriggerCompositeId 25021 ); 25022 } 25023 if (event.key === "ArrowUp") { 25024 event.preventDefault(); 25025 selectCompositeItem( 25026 activeItemIndex - 1, 25027 generateDropdownTriggerCompositeId 25028 ); 25029 } 25030 }, 25031 [selectCompositeItem, activeItemIndex] 25032 ); 25033 const hasData = !!data?.length; 25034 const groupField = view.groupBy?.field ? fields2.find((field) => field.id === view.groupBy?.field) : null; 25035 const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null; 25036 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup; 25037 const hasMoreItems = isInfiniteScroll && (view.startPosition ?? 1) + (view.perPage ?? 0) < paginationInfo.totalItems; 25038 const listClassName = clsx_default("dataviews-view-list", className, { 25039 [`has-$view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(view.layout.density), 25040 "is-refreshing": !isInfiniteScroll && isDelayedLoading 25041 }); 25042 const compositeProps = { 25043 ref: compositeRef, 25044 id: baseId, 25045 render: /* @__PURE__ */ (0, import_jsx_runtime136.jsx)("div", {}), 25046 activeId: activeCompositeId, 25047 setActiveId: setActiveCompositeId, 25048 inert: !isInfiniteScroll && !!isLoading ? "true" : void 0 25049 }; 25050 if (!hasData) { 25051 return /* @__PURE__ */ (0, import_jsx_runtime136.jsx)( 25052 "div", 25053 { 25054 className: clsx_default("dataviews-no-results", { 25055 "is-refreshing": isDelayedLoading 25056 }), 25057 children: empty 25058 } 25059 ); 25060 } 25061 if (hasData && groupField && dataByGroup) { 25062 return /* @__PURE__ */ (0, import_jsx_runtime136.jsx)( 25063 import_components29.Composite, 25064 { 25065 ...compositeProps, 25066 className: "dataviews-view-list__group", 25067 role: "grid", 25068 children: /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(Stack, { direction: "column", gap: "lg", className: listClassName, children: Array.from(dataByGroup.entries()).map( 25069 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime136.jsxs)(Stack, { direction: "column", children: [ 25070 /* @__PURE__ */ (0, import_jsx_runtime136.jsx)("h3", { className: "dataviews-view-list__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n36.sprintf)( 25071 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022". 25072 (0, import_i18n36.__)("%1$s: %2$s"), 25073 groupField.label, 25074 groupName 25075 ) }), 25076 groupItems.map((item) => { 25077 const id = generateCompositeItemIdPrefix(item); 25078 return /* @__PURE__ */ (0, import_jsx_runtime136.jsx)( 25079 ListItem, 25080 { 25081 view, 25082 idPrefix: id, 25083 actions, 25084 item, 25085 isSelected: item === selectedItem, 25086 onSelect, 25087 mediaField, 25088 titleField, 25089 descriptionField: descriptionField2, 25090 otherFields, 25091 onDropdownTriggerKeyDown 25092 }, 25093 id 25094 ); 25095 }) 25096 ] }, groupName) 25097 ) }) 25098 } 25099 ); 25100 } 25101 return /* @__PURE__ */ (0, import_jsx_runtime136.jsxs)(import_jsx_runtime136.Fragment, { children: [ 25102 /* @__PURE__ */ (0, import_jsx_runtime136.jsx)( 25103 import_components29.Composite, 25104 { 25105 ...compositeProps, 25106 className: listClassName, 25107 role: view.infiniteScrollEnabled ? "feed" : "grid", 25108 children: data.map((item, index2) => { 25109 const id = generateCompositeItemIdPrefix(item); 25110 return /* @__PURE__ */ (0, import_jsx_runtime136.jsx)( 25111 ListItem, 25112 { 25113 view, 25114 idPrefix: id, 25115 actions, 25116 item, 25117 isSelected: item === selectedItem, 25118 onSelect, 25119 mediaField, 25120 titleField, 25121 descriptionField: descriptionField2, 25122 otherFields, 25123 onDropdownTriggerKeyDown, 25124 posinset: view.infiniteScrollEnabled ? index2 + 1 : void 0 25125 }, 25126 id 25127 ); 25128 }) 25129 } 25130 ), 25131 (hasMoreItems || isInfiniteScroll && isLoading) && // Keep the spinner's height reserved while loading more so the 25132 // scroll position doesn't bounce. Hidden, and silent to a11y, 25133 // while idle. 25134 /* @__PURE__ */ (0, import_jsx_runtime136.jsx)( 25135 "p", 25136 { 25137 className: "dataviews-loading-more", 25138 "aria-hidden": !isLoading, 25139 children: /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(import_components29.Spinner, {}) 25140 } 25141 ) 25142 ] }); 25143 } 25144 25145 // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs 25146 var import_components30 = __toESM(require_components(), 1); 25147 25148 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-group.mjs 25149 var import_i18n37 = __toESM(require_i18n(), 1); 25150 var import_element73 = __toESM(require_element(), 1); 25151 var import_jsx_runtime137 = __toESM(require_jsx_runtime(), 1); 25152 function ActivityGroup({ 25153 groupName, 25154 groupData, 25155 groupField, 25156 showLabel = true, 25157 children 25158 }) { 25159 const groupHeader = showLabel ? (0, import_element73.createInterpolateElement)( 25160 // translators: %s: The label of the field e.g. "Status". 25161 (0, import_i18n37.sprintf)((0, import_i18n37.__)("%s: <groupName />"), groupField.label).trim(), 25162 { 25163 groupName: /* @__PURE__ */ (0, import_jsx_runtime137.jsx)( 25164 groupField.render, 25165 { 25166 item: groupData[0], 25167 field: groupField 25168 } 25169 ) 25170 } 25171 ) : /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(groupField.render, { item: groupData[0], field: groupField }); 25172 return /* @__PURE__ */ (0, import_jsx_runtime137.jsxs)( 25173 Stack, 25174 { 25175 direction: "column", 25176 className: "dataviews-view-activity__group", 25177 children: [ 25178 /* @__PURE__ */ (0, import_jsx_runtime137.jsx)("h3", { className: "dataviews-view-activity__group-header", children: groupHeader }), 25179 children 25180 ] 25181 }, 25182 groupName 25183 ); 25184 } 25185 25186 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-item.mjs 25187 var import_element74 = __toESM(require_element(), 1); 25188 var import_data39 = __toESM(require_data(), 1); 25189 var import_compose9 = __toESM(require_compose(), 1); 25190 var import_jsx_runtime138 = __toESM(require_jsx_runtime(), 1); 25191 function ActivityItem(props) { 25192 const { 25193 view, 25194 actions, 25195 item, 25196 titleField, 25197 mediaField, 25198 descriptionField: descriptionField2, 25199 otherFields, 25200 posinset, 25201 onClickItem, 25202 renderItemLink, 25203 isItemClickable 25204 } = props; 25205 const { 25206 showTitle = true, 25207 showMedia = true, 25208 showDescription = true, 25209 infiniteScrollEnabled 25210 } = view; 25211 const itemRef = (0, import_element74.useRef)(null); 25212 const registry = (0, import_data39.useRegistry)(); 25213 const { paginationInfo } = (0, import_element74.useContext)(dataviews_context_default); 25214 const { primaryActions, eligibleActions } = (0, import_element74.useMemo)(() => { 25215 const _eligibleActions = actions.filter( 25216 (action) => !action.isEligible || action.isEligible(item) 25217 ); 25218 const _primaryActions = _eligibleActions.filter( 25219 (action) => action.isPrimary 25220 ); 25221 return { 25222 primaryActions: _primaryActions, 25223 eligibleActions: _eligibleActions 25224 }; 25225 }, [actions, item]); 25226 const isMobileViewport = (0, import_compose9.useViewportMatch)("medium", "<"); 25227 const density = view.layout?.density ?? "balanced"; 25228 const mediaContent = showMedia && density !== "compact" && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime138.jsx)( 25229 mediaField.render, 25230 { 25231 item, 25232 field: mediaField, 25233 config: { 25234 sizes: density === "comfortable" ? "32px" : "24px" 25235 } 25236 } 25237 ) : null; 25238 const renderedMediaField = /* @__PURE__ */ (0, import_jsx_runtime138.jsx)("div", { className: "dataviews-view-activity__item-type-icon", children: mediaContent || /* @__PURE__ */ (0, import_jsx_runtime138.jsx)( 25239 "span", 25240 { 25241 className: "dataviews-view-activity__item-bullet", 25242 "aria-hidden": "true" 25243 } 25244 ) }); 25245 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime138.jsx)(titleField.render, { item, field: titleField }) : null; 25246 const verticalGap = (0, import_element74.useMemo)(() => { 25247 switch (density) { 25248 case "comfortable": 25249 return "md"; 25250 default: 25251 return "sm"; 25252 } 25253 }, [density]); 25254 return /* @__PURE__ */ (0, import_jsx_runtime138.jsx)( 25255 "div", 25256 { 25257 ref: itemRef, 25258 role: infiniteScrollEnabled ? "article" : void 0, 25259 "aria-posinset": posinset, 25260 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0, 25261 className: clsx_default( 25262 "dataviews-view-activity__item", 25263 density === "compact" && "is-compact", 25264 density === "balanced" && "is-balanced", 25265 density === "comfortable" && "is-comfortable" 25266 ), 25267 children: /* @__PURE__ */ (0, import_jsx_runtime138.jsxs)(Stack, { direction: "row", gap: "lg", justify: "start", align: "flex-start", children: [ 25268 /* @__PURE__ */ (0, import_jsx_runtime138.jsx)( 25269 Stack, 25270 { 25271 direction: "column", 25272 gap: "xs", 25273 align: "center", 25274 className: "dataviews-view-activity__item-type", 25275 children: renderedMediaField 25276 } 25277 ), 25278 /* @__PURE__ */ (0, import_jsx_runtime138.jsxs)( 25279 Stack, 25280 { 25281 direction: "column", 25282 gap: verticalGap, 25283 align: "flex-start", 25284 className: "dataviews-view-activity__item-content", 25285 children: [ 25286 renderedTitleField && /* @__PURE__ */ (0, import_jsx_runtime138.jsx)( 25287 ItemClickWrapper, 25288 { 25289 item, 25290 isItemClickable, 25291 onClickItem, 25292 renderItemLink, 25293 className: "dataviews-view-activity__item-title", 25294 children: renderedTitleField 25295 } 25296 ), 25297 showDescription && descriptionField2 && /* @__PURE__ */ (0, import_jsx_runtime138.jsx)("div", { className: "dataviews-view-activity__item-description", children: /* @__PURE__ */ (0, import_jsx_runtime138.jsx)( 25298 descriptionField2.render, 25299 { 25300 item, 25301 field: descriptionField2 25302 } 25303 ) }), 25304 /* @__PURE__ */ (0, import_jsx_runtime138.jsx)("div", { className: "dataviews-view-activity__item-fields", children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime138.jsxs)( 25305 "div", 25306 { 25307 className: "dataviews-view-activity__item-field", 25308 children: [ 25309 /* @__PURE__ */ (0, import_jsx_runtime138.jsx)( 25310 VisuallyHidden, 25311 { 25312 className: "dataviews-view-activity__item-field-label", 25313 render: /* @__PURE__ */ (0, import_jsx_runtime138.jsx)("span", {}), 25314 children: field.label 25315 } 25316 ), 25317 /* @__PURE__ */ (0, import_jsx_runtime138.jsx)("span", { className: "dataviews-view-activity__item-field-value", children: /* @__PURE__ */ (0, import_jsx_runtime138.jsx)( 25318 field.render, 25319 { 25320 item, 25321 field 25322 } 25323 ) }) 25324 ] 25325 }, 25326 field.id 25327 )) }), 25328 !!primaryActions?.length && /* @__PURE__ */ (0, import_jsx_runtime138.jsx)( 25329 PrimaryActions, 25330 { 25331 item, 25332 actions: primaryActions, 25333 registry, 25334 buttonVariant: "secondary" 25335 } 25336 ) 25337 ] 25338 } 25339 ), 25340 (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu 25341 // there if there are any actions at all. 25342 isMobileViewport && // At the same time, only show the menu if there are actions to show. 25343 eligibleActions.length > 0) && /* @__PURE__ */ (0, import_jsx_runtime138.jsx)("div", { className: "dataviews-view-activity__item-actions", children: /* @__PURE__ */ (0, import_jsx_runtime138.jsx)( 25344 ItemActions, 25345 { 25346 item, 25347 actions: eligibleActions, 25348 isCompact: true 25349 } 25350 ) }) 25351 ] }) 25352 } 25353 ); 25354 } 25355 var activity_item_default = ActivityItem; 25356 25357 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-items.mjs 25358 var import_react15 = __toESM(require_react(), 1); 25359 function isDefined3(item) { 25360 return !!item; 25361 } 25362 function ActivityItems(props) { 25363 const { data, fields: fields2, getItemId: getItemId2, view } = props; 25364 const titleField = fields2.find((field) => field.id === view.titleField); 25365 const mediaField = fields2.find((field) => field.id === view.mediaField); 25366 const descriptionField2 = fields2.find( 25367 (field) => field.id === view.descriptionField 25368 ); 25369 const otherFields = (view?.fields ?? []).map((fieldId) => fields2.find((f2) => fieldId === f2.id)).filter(isDefined3); 25370 return data.map((item, index2) => { 25371 return /* @__PURE__ */ (0, import_react15.createElement)( 25372 activity_item_default, 25373 { 25374 ...props, 25375 key: getItemId2(item), 25376 item, 25377 mediaField, 25378 titleField, 25379 descriptionField: descriptionField2, 25380 otherFields, 25381 posinset: view.infiniteScrollEnabled ? index2 + 1 : void 0 25382 } 25383 ); 25384 }); 25385 } 25386 25387 // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs 25388 var import_jsx_runtime139 = __toESM(require_jsx_runtime(), 1); 25389 function ViewActivity(props) { 25390 const { empty, data, fields: fields2, isLoading, view, className } = props; 25391 const isDelayedLoading = useDelayedLoading(!!isLoading); 25392 const hasData = !!data?.length; 25393 const groupField = view.groupBy?.field ? fields2.find((field) => field.id === view.groupBy?.field) : null; 25394 const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null; 25395 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup; 25396 if (!hasData) { 25397 return /* @__PURE__ */ (0, import_jsx_runtime139.jsx)( 25398 "div", 25399 { 25400 className: clsx_default("dataviews-no-results", { 25401 "is-refreshing": isDelayedLoading 25402 }), 25403 children: empty 25404 } 25405 ); 25406 } 25407 const isInert = !isInfiniteScroll && !!isLoading; 25408 const wrapperClassName = clsx_default("dataviews-view-activity", className, { 25409 "is-refreshing": !isInfiniteScroll && isDelayedLoading 25410 }); 25411 const groupedEntries = dataByGroup ? Array.from(dataByGroup.entries()) : []; 25412 if (hasData && groupField && dataByGroup) { 25413 return /* @__PURE__ */ (0, import_jsx_runtime139.jsx)( 25414 Stack, 25415 { 25416 direction: "column", 25417 gap: "sm", 25418 className: wrapperClassName, 25419 inert: isInert ? "true" : void 0, 25420 children: groupedEntries.map( 25421 ([groupName, groupData]) => /* @__PURE__ */ (0, import_jsx_runtime139.jsx)( 25422 ActivityGroup, 25423 { 25424 groupName, 25425 groupData, 25426 groupField, 25427 showLabel: view.groupBy?.showLabel !== false, 25428 children: /* @__PURE__ */ (0, import_jsx_runtime139.jsx)( 25429 ActivityItems, 25430 { 25431 ...props, 25432 data: groupData 25433 } 25434 ) 25435 }, 25436 groupName 25437 ) 25438 ) 25439 } 25440 ); 25441 } 25442 return /* @__PURE__ */ (0, import_jsx_runtime139.jsxs)(import_jsx_runtime139.Fragment, { children: [ 25443 /* @__PURE__ */ (0, import_jsx_runtime139.jsx)( 25444 "div", 25445 { 25446 className: wrapperClassName, 25447 role: view.infiniteScrollEnabled ? "feed" : void 0, 25448 inert: isInert ? "true" : void 0, 25449 children: /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(ActivityItems, { ...props }) 25450 } 25451 ), 25452 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime139.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(import_components30.Spinner, {}) }) 25453 ] }); 25454 } 25455 25456 // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs 25457 var import_components33 = __toESM(require_components(), 1); 25458 var import_i18n40 = __toESM(require_i18n(), 1); 25459 var import_compose10 = __toESM(require_compose(), 1); 25460 var import_element77 = __toESM(require_element(), 1); 25461 25462 // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs 25463 var import_components32 = __toESM(require_components(), 1); 25464 var import_data40 = __toESM(require_data(), 1); 25465 var import_element76 = __toESM(require_element(), 1); 25466 var import_i18n39 = __toESM(require_i18n(), 1); 25467 25468 // packages/dataviews/build-module/components/dataviews-pagination/index.mjs 25469 var import_components31 = __toESM(require_components(), 1); 25470 var import_element75 = __toESM(require_element(), 1); 25471 var import_i18n38 = __toESM(require_i18n(), 1); 25472 var import_jsx_runtime140 = __toESM(require_jsx_runtime(), 1); 25473 function hasPaginationControls(view, paginationInfo) { 25474 return !view.infiniteScrollEnabled && paginationInfo.totalItems > 0 && paginationInfo.totalPages > 1; 25475 } 25476 function DataViewsPagination() { 25477 const { view, onChangeView, paginationInfo } = (0, import_element75.useContext)(dataviews_context_default); 25478 if (!hasPaginationControls(view, paginationInfo)) { 25479 return null; 25480 } 25481 const { totalPages } = paginationInfo; 25482 const currentPage = view.page ?? 1; 25483 const pageSelectOptions = Array.from(Array(totalPages)).map( 25484 (_, i2) => { 25485 const page = i2 + 1; 25486 return { 25487 value: page.toString(), 25488 label: page.toString(), 25489 "aria-label": currentPage === page ? (0, import_i18n38.sprintf)( 25490 // translators: 1: current page number. 2: total number of pages. 25491 (0, import_i18n38.__)("Page %1$d of %2$d"), 25492 currentPage, 25493 totalPages 25494 ) : page.toString() 25495 }; 25496 } 25497 ); 25498 return /* @__PURE__ */ (0, import_jsx_runtime140.jsxs)( 25499 Stack, 25500 { 25501 direction: "row", 25502 className: "dataviews-pagination", 25503 justify: "end", 25504 align: "center", 25505 gap: "xl", 25506 children: [ 25507 /* @__PURE__ */ (0, import_jsx_runtime140.jsx)( 25508 Stack, 25509 { 25510 direction: "row", 25511 justify: "flex-start", 25512 align: "center", 25513 gap: "xs", 25514 className: "dataviews-pagination__page-select", 25515 children: (0, import_element75.createInterpolateElement)( 25516 (0, import_i18n38.sprintf)( 25517 // translators: 1: Current page number, 2: Total number of pages. 25518 (0, import_i18n38._x)("<div>Page</div>%1$s<div>of %2$d</div>", "paging"), 25519 "<CurrentPage />", 25520 totalPages 25521 ), 25522 { 25523 div: /* @__PURE__ */ (0, import_jsx_runtime140.jsx)("div", { "aria-hidden": true }), 25524 // @ts-expect-error — Tag injected via sprintf argument, not visible in format string. 25525 CurrentPage: /* @__PURE__ */ (0, import_jsx_runtime140.jsx)( 25526 import_components31.SelectControl, 25527 { 25528 "aria-label": (0, import_i18n38.__)("Current page"), 25529 value: currentPage.toString(), 25530 options: pageSelectOptions, 25531 onChange: (newValue) => { 25532 onChangeView({ 25533 ...view, 25534 page: +newValue 25535 }); 25536 }, 25537 size: "small", 25538 variant: "minimal" 25539 } 25540 ) 25541 } 25542 ) 25543 } 25544 ), 25545 /* @__PURE__ */ (0, import_jsx_runtime140.jsxs)(Stack, { direction: "row", gap: "xs", align: "center", children: [ 25546 /* @__PURE__ */ (0, import_jsx_runtime140.jsx)( 25547 import_components31.Button, 25548 { 25549 onClick: () => onChangeView({ 25550 ...view, 25551 page: currentPage - 1 25552 }), 25553 disabled: currentPage === 1, 25554 accessibleWhenDisabled: true, 25555 label: (0, import_i18n38.__)("Previous page"), 25556 icon: (0, import_i18n38.isRTL)() ? next_default : previous_default, 25557 showTooltip: true, 25558 size: "compact", 25559 tooltipPosition: "top" 25560 } 25561 ), 25562 /* @__PURE__ */ (0, import_jsx_runtime140.jsx)( 25563 import_components31.Button, 25564 { 25565 onClick: () => onChangeView({ ...view, page: currentPage + 1 }), 25566 disabled: currentPage >= totalPages, 25567 accessibleWhenDisabled: true, 25568 label: (0, import_i18n38.__)("Next page"), 25569 icon: (0, import_i18n38.isRTL)() ? previous_default : next_default, 25570 showTooltip: true, 25571 size: "compact", 25572 tooltipPosition: "top" 25573 } 25574 ) 25575 ] }) 25576 ] 25577 } 25578 ); 25579 } 25580 var dataviews_pagination_default = (0, import_element75.memo)(DataViewsPagination); 25581 25582 // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs 25583 var import_jsx_runtime141 = __toESM(require_jsx_runtime(), 1); 25584 function useIsMultiselectPicker(actions) { 25585 return (0, import_element76.useMemo)(() => { 25586 return !!actions?.length && actions?.every((action) => action.supportsBulk); 25587 }, [actions]); 25588 } 25589 25590 // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs 25591 var import_jsx_runtime142 = __toESM(require_jsx_runtime(), 1); 25592 var { Badge: WCBadge2 } = unlock4(import_components33.privateApis); 25593 function GridItem3({ 25594 view, 25595 multiselect, 25596 selection, 25597 onChangeSelection, 25598 getItemId: getItemId2, 25599 item, 25600 mediaField, 25601 titleField, 25602 descriptionField: descriptionField2, 25603 regularFields, 25604 badgeFields, 25605 config: config2, 25606 posinset, 25607 setsize 25608 }) { 25609 const { showTitle = true, showMedia = true, showDescription = true } = view; 25610 const id = getItemId2(item); 25611 const elementRef = (0, import_element77.useRef)(null); 25612 const isSelected2 = selection.includes(id); 25613 useIntersectionObserver(elementRef, posinset); 25614 const renderedMediaField = mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime142.jsx)( 25615 mediaField.render, 25616 { 25617 item, 25618 field: mediaField, 25619 config: config2 25620 } 25621 ) : null; 25622 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(titleField.render, { item, field: titleField }) : null; 25623 return /* @__PURE__ */ (0, import_jsx_runtime142.jsxs)( 25624 import_components33.Composite.Item, 25625 { 25626 ref: elementRef, 25627 "aria-label": titleField ? titleField.getValue({ item }) || (0, import_i18n40.__)("(no title)") : void 0, 25628 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(Stack, { direction: "column", children, ...props }), 25629 role: "option", 25630 "aria-posinset": posinset, 25631 "aria-setsize": setsize, 25632 className: clsx_default("dataviews-view-picker-grid__card", { 25633 "is-selected": isSelected2 25634 }), 25635 "aria-selected": isSelected2, 25636 onClick: () => { 25637 if (isSelected2) { 25638 onChangeSelection( 25639 selection.filter((itemId) => id !== itemId) 25640 ); 25641 } else { 25642 const newSelection = multiselect ? [...selection, id] : [id]; 25643 onChangeSelection(newSelection); 25644 } 25645 }, 25646 children: [ 25647 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime142.jsx)("div", { className: "dataviews-view-picker-grid__media", children: renderedMediaField }), 25648 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime142.jsx)( 25649 DataViewsSelectionCheckbox, 25650 { 25651 item, 25652 selection, 25653 onChangeSelection, 25654 getItemId: getItemId2, 25655 titleField, 25656 disabled: false, 25657 "aria-hidden": true, 25658 tabIndex: -1 25659 } 25660 ), 25661 showTitle && /* @__PURE__ */ (0, import_jsx_runtime142.jsx)( 25662 Stack, 25663 { 25664 direction: "row", 25665 justify: "space-between", 25666 className: "dataviews-view-picker-grid__title-actions", 25667 children: /* @__PURE__ */ (0, import_jsx_runtime142.jsx)("div", { className: "dataviews-view-picker-grid__title-field dataviews-title-field", children: renderedTitleField }) 25668 } 25669 ), 25670 /* @__PURE__ */ (0, import_jsx_runtime142.jsxs)(Stack, { direction: "column", gap: "xs", children: [ 25671 showDescription && descriptionField2?.render && /* @__PURE__ */ (0, import_jsx_runtime142.jsx)( 25672 descriptionField2.render, 25673 { 25674 item, 25675 field: descriptionField2 25676 } 25677 ), 25678 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime142.jsx)( 25679 Stack, 25680 { 25681 direction: "row", 25682 className: "dataviews-view-picker-grid__badge-fields", 25683 gap: "sm", 25684 wrap: "wrap", 25685 align: "top", 25686 justify: "flex-start", 25687 children: badgeFields.map((field) => { 25688 return /* @__PURE__ */ (0, import_jsx_runtime142.jsx)( 25689 WCBadge2, 25690 { 25691 className: "dataviews-view-picker-grid__field-value", 25692 children: /* @__PURE__ */ (0, import_jsx_runtime142.jsx)( 25693 field.render, 25694 { 25695 item, 25696 field 25697 } 25698 ) 25699 }, 25700 field.id 25701 ); 25702 }) 25703 } 25704 ), 25705 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime142.jsx)( 25706 Stack, 25707 { 25708 direction: "column", 25709 className: "dataviews-view-picker-grid__fields", 25710 gap: "xs", 25711 children: regularFields.map((field) => { 25712 return /* @__PURE__ */ (0, import_jsx_runtime142.jsx)( 25713 import_components33.Flex, 25714 { 25715 className: "dataviews-view-picker-grid__field", 25716 gap: 1, 25717 justify: "flex-start", 25718 expanded: true, 25719 style: { height: "auto" }, 25720 direction: "row", 25721 children: /* @__PURE__ */ (0, import_jsx_runtime142.jsxs)(import_jsx_runtime142.Fragment, { children: [ 25722 /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(import_components33.FlexItem, { className: "dataviews-view-picker-grid__field-name", children: field.header }), 25723 /* @__PURE__ */ (0, import_jsx_runtime142.jsx)( 25724 import_components33.FlexItem, 25725 { 25726 className: "dataviews-view-picker-grid__field-value", 25727 style: { maxHeight: "none" }, 25728 children: /* @__PURE__ */ (0, import_jsx_runtime142.jsx)( 25729 field.render, 25730 { 25731 item, 25732 field 25733 } 25734 ) 25735 } 25736 ) 25737 ] }) 25738 }, 25739 field.id 25740 ); 25741 }) 25742 } 25743 ) 25744 ] }) 25745 ] 25746 }, 25747 id 25748 ); 25749 } 25750 function GridGroup({ 25751 groupName, 25752 groupField, 25753 showLabel = true, 25754 children 25755 }) { 25756 const headerId = (0, import_compose10.useInstanceId)( 25757 GridGroup, 25758 "dataviews-view-picker-grid-group__header" 25759 ); 25760 return /* @__PURE__ */ (0, import_jsx_runtime142.jsxs)( 25761 Stack, 25762 { 25763 direction: "column", 25764 gap: "sm", 25765 role: "group", 25766 "aria-labelledby": headerId, 25767 children: [ 25768 /* @__PURE__ */ (0, import_jsx_runtime142.jsx)( 25769 "h3", 25770 { 25771 className: "dataviews-view-picker-grid-group__header", 25772 id: headerId, 25773 children: showLabel ? (0, import_i18n40.sprintf)( 25774 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022". 25775 (0, import_i18n40.__)("%1$s: %2$s"), 25776 groupField.label, 25777 groupName 25778 ) : groupName 25779 } 25780 ), 25781 children 25782 ] 25783 }, 25784 groupName 25785 ); 25786 } 25787 function ViewPickerGrid({ 25788 actions, 25789 data, 25790 fields: fields2, 25791 getItemId: getItemId2, 25792 isLoading, 25793 onChangeSelection, 25794 selection, 25795 view, 25796 className, 25797 empty 25798 }) { 25799 const { resizeObserverRef, paginationInfo, itemListLabel } = (0, import_element77.useContext)(dataviews_context_default); 25800 const titleField = fields2.find( 25801 (field) => field.id === view?.titleField 25802 ); 25803 const mediaField = fields2.find( 25804 (field) => field.id === view?.mediaField 25805 ); 25806 const descriptionField2 = fields2.find( 25807 (field) => field.id === view?.descriptionField 25808 ); 25809 const otherFields = view.fields ?? []; 25810 const { regularFields, badgeFields } = otherFields.reduce( 25811 (accumulator, fieldId) => { 25812 const field = fields2.find((f2) => f2.id === fieldId); 25813 if (!field) { 25814 return accumulator; 25815 } 25816 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields"; 25817 accumulator[key].push(field); 25818 return accumulator; 25819 }, 25820 { regularFields: [], badgeFields: [] } 25821 ); 25822 const hasData = !!data?.length; 25823 const usedPreviewSize = view.layout?.previewSize; 25824 const isMultiselect = useIsMultiselectPicker(actions); 25825 const size4 = "900px"; 25826 const groupField = view.groupBy?.field ? fields2.find((f2) => f2.id === view.groupBy?.field) : null; 25827 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null; 25828 const isInfiniteScroll = (view.infiniteScrollEnabled && !dataByGroup) ?? false; 25829 const currentPage = view?.page ?? 1; 25830 const perPage = view?.perPage ?? 0; 25831 const setSize = isInfiniteScroll ? paginationInfo?.totalItems : void 0; 25832 const gridColumns = useGridColumns(); 25833 const placeholdersNeeded = usePlaceholdersNeeded( 25834 data, 25835 isInfiniteScroll, 25836 gridColumns 25837 ); 25838 return /* @__PURE__ */ (0, import_jsx_runtime142.jsxs)(import_jsx_runtime142.Fragment, { 25839 // Render multiple groups. 25840 children: [ 25841 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime142.jsx)( 25842 import_components33.Composite, 25843 { 25844 virtualFocus: true, 25845 orientation: "horizontal", 25846 role: "listbox", 25847 "aria-multiselectable": isMultiselect, 25848 className: clsx_default( 25849 "dataviews-view-picker-grid", 25850 className, 25851 { 25852 [`has-$view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes( 25853 view.layout.density 25854 ) 25855 } 25856 ), 25857 "aria-label": itemListLabel, 25858 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime142.jsx)( 25859 Stack, 25860 { 25861 direction: "column", 25862 gap: "lg", 25863 children, 25864 ...props 25865 } 25866 ), 25867 children: Array.from(dataByGroup.entries()).map( 25868 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime142.jsx)( 25869 GridGroup, 25870 { 25871 groupName, 25872 groupField, 25873 showLabel: view.groupBy?.showLabel !== false, 25874 children: /* @__PURE__ */ (0, import_jsx_runtime142.jsx)( 25875 GridItems, 25876 { 25877 previewSize: usedPreviewSize, 25878 style: { 25879 gridTemplateColumns: usedPreviewSize && `repeat(auto-fill, minmax($usedPreviewSize}px, 1fr))` 25880 }, 25881 "aria-busy": isLoading, 25882 ref: resizeObserverRef, 25883 children: groupItems.map((item) => { 25884 const posInSet = item.position ?? (currentPage - 1) * perPage + data.indexOf(item) + 1; 25885 return /* @__PURE__ */ (0, import_jsx_runtime142.jsx)( 25886 GridItem3, 25887 { 25888 view, 25889 multiselect: isMultiselect, 25890 selection, 25891 onChangeSelection, 25892 getItemId: getItemId2, 25893 item, 25894 mediaField, 25895 titleField, 25896 descriptionField: descriptionField2, 25897 regularFields, 25898 badgeFields, 25899 config: { 25900 sizes: size4 25901 }, 25902 posinset: posInSet, 25903 setsize: setSize 25904 }, 25905 getItemId2(item) 25906 ); 25907 }) 25908 } 25909 ) 25910 }, 25911 groupName 25912 ) 25913 ) 25914 } 25915 ), 25916 // Render a single grid with all data. 25917 hasData && !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime142.jsxs)( 25918 import_components33.Composite, 25919 { 25920 render: /* @__PURE__ */ (0, import_jsx_runtime142.jsx)( 25921 GridItems, 25922 { 25923 className: clsx_default( 25924 "dataviews-view-picker-grid", 25925 className, 25926 { 25927 [`has-$view.layout?.density}-density`]: view.layout?.density && [ 25928 "compact", 25929 "comfortable" 25930 ].includes(view.layout.density) 25931 } 25932 ), 25933 previewSize: usedPreviewSize, 25934 "aria-busy": isLoading, 25935 ref: resizeObserverRef 25936 } 25937 ), 25938 virtualFocus: true, 25939 orientation: "horizontal", 25940 role: "listbox", 25941 "aria-multiselectable": isMultiselect, 25942 "aria-label": itemListLabel, 25943 children: [ 25944 Array.from({ length: placeholdersNeeded }).map( 25945 (_, index2) => /* @__PURE__ */ (0, import_jsx_runtime142.jsx)( 25946 import_components33.Composite.Item, 25947 { 25948 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime142.jsx)( 25949 Stack, 25950 { 25951 direction: "column", 25952 children, 25953 ...props 25954 } 25955 ), 25956 role: "option", 25957 "aria-hidden": true, 25958 tabIndex: -1, 25959 className: "dataviews-view-picker-grid__card dataviews-view-picker-grid__placeholder" 25960 }, 25961 `placeholder-$index2}` 25962 ) 25963 ), 25964 data.map((item) => { 25965 const posinset = item.position; 25966 return /* @__PURE__ */ (0, import_jsx_runtime142.jsx)( 25967 GridItem3, 25968 { 25969 view, 25970 multiselect: isMultiselect, 25971 selection, 25972 onChangeSelection, 25973 getItemId: getItemId2, 25974 item, 25975 mediaField, 25976 titleField, 25977 descriptionField: descriptionField2, 25978 regularFields, 25979 badgeFields, 25980 config: { 25981 sizes: size4 25982 }, 25983 posinset, 25984 setsize: setSize 25985 }, 25986 getItemId2(item) 25987 ); 25988 }) 25989 ] 25990 } 25991 ), 25992 // Render empty state. 25993 !hasData && /* @__PURE__ */ (0, import_jsx_runtime142.jsx)( 25994 "div", 25995 { 25996 className: clsx_default({ 25997 "dataviews-loading": isLoading, 25998 "dataviews-no-results": !isLoading 25999 }), 26000 children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime142.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(import_components33.Spinner, {}) }) : empty 26001 } 26002 ), 26003 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime142.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(import_components33.Spinner, {}) }) 26004 ] 26005 }); 26006 } 26007 var picker_grid_default = ViewPickerGrid; 26008 26009 // packages/dataviews/build-module/components/dataviews-layouts/picker-table/index.mjs 26010 var import_i18n41 = __toESM(require_i18n(), 1); 26011 var import_components34 = __toESM(require_components(), 1); 26012 var import_element78 = __toESM(require_element(), 1); 26013 var import_jsx_runtime143 = __toESM(require_jsx_runtime(), 1); 26014 function TableColumnField2({ 26015 item, 26016 fields: fields2, 26017 column, 26018 align 26019 }) { 26020 const field = fields2.find((f2) => f2.id === column); 26021 if (!field) { 26022 return null; 26023 } 26024 const className = clsx_default("dataviews-view-table__cell-content-wrapper", { 26025 "dataviews-view-table__cell-align-end": align === "end", 26026 "dataviews-view-table__cell-align-center": align === "center" 26027 }); 26028 return /* @__PURE__ */ (0, import_jsx_runtime143.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime143.jsx)(field.render, { item, field }) }); 26029 } 26030 function TableRow2({ 26031 item, 26032 fields: fields2, 26033 id, 26034 view, 26035 titleField, 26036 mediaField, 26037 descriptionField: descriptionField2, 26038 selection, 26039 getItemId: getItemId2, 26040 onChangeSelection, 26041 multiselect, 26042 posinset 26043 }) { 26044 const { paginationInfo } = (0, import_element78.useContext)(dataviews_context_default); 26045 const isSelected2 = selection.includes(id); 26046 const [isHovered, setIsHovered] = (0, import_element78.useState)(false); 26047 const elementRef = (0, import_element78.useRef)(null); 26048 useIntersectionObserver(elementRef, posinset); 26049 const { 26050 showTitle = true, 26051 showMedia = true, 26052 showDescription = true, 26053 infiniteScrollEnabled 26054 } = view; 26055 const handleMouseEnter = () => { 26056 setIsHovered(true); 26057 }; 26058 const handleMouseLeave = () => { 26059 setIsHovered(false); 26060 }; 26061 const columns = view.fields ?? []; 26062 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField2 && showDescription; 26063 return /* @__PURE__ */ (0, import_jsx_runtime143.jsxs)( 26064 import_components34.Composite.Item, 26065 { 26066 ref: elementRef, 26067 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime143.jsx)( 26068 "tr", 26069 { 26070 className: clsx_default("dataviews-view-table__row", { 26071 "is-selected": isSelected2, 26072 "is-hovered": isHovered 26073 }), 26074 onMouseEnter: handleMouseEnter, 26075 onMouseLeave: handleMouseLeave, 26076 children, 26077 ...props 26078 } 26079 ), 26080 "aria-selected": isSelected2, 26081 "aria-setsize": paginationInfo.totalItems || void 0, 26082 "aria-posinset": posinset, 26083 role: infiniteScrollEnabled ? "article" : "option", 26084 onMouseDown: (event) => { 26085 if (event.button !== 0) { 26086 return; 26087 } 26088 event.currentTarget.parentElement?.focus({ 26089 preventScroll: true 26090 }); 26091 }, 26092 onClick: () => { 26093 if (isSelected2) { 26094 onChangeSelection( 26095 selection.filter((itemId) => id !== itemId) 26096 ); 26097 } else { 26098 const newSelection = multiselect ? [...selection, id] : [id]; 26099 onChangeSelection(newSelection); 26100 } 26101 }, 26102 children: [ 26103 /* @__PURE__ */ (0, import_jsx_runtime143.jsx)( 26104 "td", 26105 { 26106 className: "dataviews-view-table__checkbox-column", 26107 role: "presentation", 26108 children: /* @__PURE__ */ (0, import_jsx_runtime143.jsx)("div", { className: "dataviews-view-table__cell-content-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime143.jsx)( 26109 DataViewsSelectionCheckbox, 26110 { 26111 item, 26112 selection, 26113 onChangeSelection, 26114 getItemId: getItemId2, 26115 titleField, 26116 disabled: false, 26117 "aria-hidden": true, 26118 tabIndex: -1 26119 } 26120 ) }) 26121 } 26122 ), 26123 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime143.jsx)( 26124 "td", 26125 { 26126 role: "presentation", 26127 children: /* @__PURE__ */ (0, import_jsx_runtime143.jsx)( 26128 column_primary_default, 26129 { 26130 item, 26131 titleField: showTitle ? titleField : void 0, 26132 mediaField: showMedia ? mediaField : void 0, 26133 descriptionField: showDescription ? descriptionField2 : void 0, 26134 isItemClickable: () => false 26135 } 26136 ) 26137 } 26138 ), 26139 columns.map((column) => { 26140 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {}; 26141 return /* @__PURE__ */ (0, import_jsx_runtime143.jsx)( 26142 "td", 26143 { 26144 style: { 26145 width, 26146 maxWidth, 26147 minWidth 26148 }, 26149 role: "presentation", 26150 children: /* @__PURE__ */ (0, import_jsx_runtime143.jsx)( 26151 TableColumnField2, 26152 { 26153 fields: fields2, 26154 item, 26155 column, 26156 align 26157 } 26158 ) 26159 }, 26160 column 26161 ); 26162 }) 26163 ] 26164 }, 26165 id 26166 ); 26167 } 26168 function ViewPickerTable({ 26169 actions, 26170 data, 26171 fields: fields2, 26172 getItemId: getItemId2, 26173 isLoading = false, 26174 onChangeView, 26175 onChangeSelection, 26176 selection, 26177 setOpenedFilter, 26178 view, 26179 className, 26180 empty 26181 }) { 26182 const headerMenuRefs = (0, import_element78.useRef)(/* @__PURE__ */ new Map()); 26183 const headerMenuToFocusRef = (0, import_element78.useRef)(void 0); 26184 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element78.useState)(); 26185 const isMultiselect = useIsMultiselectPicker(actions) ?? false; 26186 (0, import_element78.useEffect)(() => { 26187 if (headerMenuToFocusRef.current) { 26188 headerMenuToFocusRef.current.focus(); 26189 headerMenuToFocusRef.current = void 0; 26190 } 26191 }); 26192 const groupField = view.groupBy?.field ? fields2.find((f2) => f2.id === view.groupBy?.field) : null; 26193 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null; 26194 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup; 26195 const tableNoticeId = (0, import_element78.useId)(); 26196 if (nextHeaderMenuToFocus) { 26197 headerMenuToFocusRef.current = nextHeaderMenuToFocus; 26198 setNextHeaderMenuToFocus(void 0); 26199 return; 26200 } 26201 const onHide = (field) => { 26202 const hidden = headerMenuRefs.current.get(field.id); 26203 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0; 26204 setNextHeaderMenuToFocus(fallback?.node); 26205 }; 26206 const hasData = !!data?.length; 26207 const titleField = fields2.find((field) => field.id === view.titleField); 26208 const mediaField = fields2.find((field) => field.id === view.mediaField); 26209 const descriptionField2 = fields2.find( 26210 (field) => field.id === view.descriptionField 26211 ); 26212 const { showTitle = true, showMedia = true, showDescription = true } = view; 26213 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField2 && showDescription; 26214 const columns = view.fields ?? []; 26215 const headerMenuRef = (column, index2) => (node) => { 26216 if (node) { 26217 headerMenuRefs.current.set(column, { 26218 node, 26219 fallback: columns[index2 > 0 ? index2 - 1 : 1] 26220 }); 26221 } else { 26222 headerMenuRefs.current.delete(column); 26223 } 26224 }; 26225 return /* @__PURE__ */ (0, import_jsx_runtime143.jsxs)(import_jsx_runtime143.Fragment, { children: [ 26226 /* @__PURE__ */ (0, import_jsx_runtime143.jsxs)( 26227 "table", 26228 { 26229 className: clsx_default( 26230 "dataviews-view-table", 26231 "dataviews-view-picker-table", 26232 className, 26233 { 26234 [`has-$view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes( 26235 view.layout.density 26236 ) 26237 } 26238 ), 26239 "aria-busy": isLoading, 26240 "aria-describedby": tableNoticeId, 26241 role: isInfiniteScroll ? "feed" : "listbox", 26242 children: [ 26243 /* @__PURE__ */ (0, import_jsx_runtime143.jsx)("thead", { role: "presentation", children: /* @__PURE__ */ (0, import_jsx_runtime143.jsxs)( 26244 "tr", 26245 { 26246 className: "dataviews-view-table__row", 26247 role: "presentation", 26248 children: [ 26249 /* @__PURE__ */ (0, import_jsx_runtime143.jsx)("th", { className: "dataviews-view-table__checkbox-column", children: isMultiselect && /* @__PURE__ */ (0, import_jsx_runtime143.jsx)( 26250 BulkSelectionCheckbox, 26251 { 26252 selection, 26253 onChangeSelection, 26254 data, 26255 actions, 26256 getItemId: getItemId2, 26257 disableSelectAll: isInfiniteScroll 26258 } 26259 ) }), 26260 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime143.jsx)("th", { children: titleField && /* @__PURE__ */ (0, import_jsx_runtime143.jsx)( 26261 column_header_menu_default, 26262 { 26263 ref: headerMenuRef( 26264 titleField.id, 26265 0 26266 ), 26267 fieldId: titleField.id, 26268 view, 26269 fields: fields2, 26270 onChangeView, 26271 onHide, 26272 setOpenedFilter, 26273 canMove: false 26274 } 26275 ) }), 26276 columns.map((column, index2) => { 26277 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {}; 26278 return /* @__PURE__ */ (0, import_jsx_runtime143.jsx)( 26279 "th", 26280 { 26281 style: { 26282 width, 26283 maxWidth, 26284 minWidth, 26285 textAlign: align 26286 }, 26287 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0, 26288 scope: "col", 26289 children: /* @__PURE__ */ (0, import_jsx_runtime143.jsx)( 26290 column_header_menu_default, 26291 { 26292 ref: headerMenuRef(column, index2), 26293 fieldId: column, 26294 view, 26295 fields: fields2, 26296 onChangeView, 26297 onHide, 26298 setOpenedFilter, 26299 canMove: view.layout?.enableMoving ?? true 26300 } 26301 ) 26302 }, 26303 column 26304 ); 26305 }) 26306 ] 26307 } 26308 ) }), 26309 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map( 26310 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime143.jsxs)( 26311 import_components34.Composite, 26312 { 26313 virtualFocus: true, 26314 orientation: "vertical", 26315 render: /* @__PURE__ */ (0, import_jsx_runtime143.jsx)("tbody", { role: "group" }), 26316 children: [ 26317 /* @__PURE__ */ (0, import_jsx_runtime143.jsx)( 26318 "tr", 26319 { 26320 className: "dataviews-view-table__group-header-row", 26321 role: "presentation", 26322 children: /* @__PURE__ */ (0, import_jsx_runtime143.jsx)( 26323 "td", 26324 { 26325 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + 1, 26326 className: "dataviews-view-table__group-header-cell", 26327 role: "presentation", 26328 children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n41.sprintf)( 26329 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022". 26330 (0, import_i18n41.__)("%1$s: %2$s"), 26331 groupField.label, 26332 groupName 26333 ) 26334 } 26335 ) 26336 } 26337 ), 26338 groupItems.map((item, index2) => /* @__PURE__ */ (0, import_jsx_runtime143.jsx)( 26339 TableRow2, 26340 { 26341 item, 26342 fields: fields2, 26343 id: getItemId2(item) || index2.toString(), 26344 view, 26345 titleField, 26346 mediaField, 26347 descriptionField: descriptionField2, 26348 selection, 26349 getItemId: getItemId2, 26350 onChangeSelection, 26351 multiselect: isMultiselect 26352 }, 26353 getItemId2(item) 26354 )) 26355 ] 26356 }, 26357 `group-$groupName}` 26358 ) 26359 ) : /* @__PURE__ */ (0, import_jsx_runtime143.jsx)( 26360 import_components34.Composite, 26361 { 26362 render: /* @__PURE__ */ (0, import_jsx_runtime143.jsx)("tbody", { role: "presentation" }), 26363 virtualFocus: true, 26364 orientation: "vertical", 26365 children: hasData && data.map((item, index2) => { 26366 const itemId = getItemId2(item); 26367 const posinset = item.position; 26368 return /* @__PURE__ */ (0, import_jsx_runtime143.jsx)( 26369 TableRow2, 26370 { 26371 item, 26372 fields: fields2, 26373 id: itemId || index2.toString(), 26374 view, 26375 titleField, 26376 mediaField, 26377 descriptionField: descriptionField2, 26378 selection, 26379 getItemId: getItemId2, 26380 onChangeSelection, 26381 multiselect: isMultiselect, 26382 posinset 26383 }, 26384 itemId 26385 ); 26386 }) 26387 } 26388 ) 26389 ] 26390 } 26391 ), 26392 /* @__PURE__ */ (0, import_jsx_runtime143.jsxs)( 26393 "div", 26394 { 26395 className: clsx_default({ 26396 "dataviews-loading": isLoading, 26397 "dataviews-no-results": !hasData && !isLoading 26398 }), 26399 id: tableNoticeId, 26400 children: [ 26401 !hasData && (isLoading ? /* @__PURE__ */ (0, import_jsx_runtime143.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime143.jsx)(import_components34.Spinner, {}) }) : empty), 26402 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime143.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime143.jsx)(import_components34.Spinner, {}) }) 26403 ] 26404 } 26405 ) 26406 ] }); 26407 } 26408 var picker_table_default = ViewPickerTable; 26409 26410 // packages/dataviews/build-module/components/dataviews-layouts/picker-activity/index.mjs 26411 var import_components35 = __toESM(require_components(), 1); 26412 var import_element79 = __toESM(require_element(), 1); 26413 var import_compose11 = __toESM(require_compose(), 1); 26414 var import_i18n42 = __toESM(require_i18n(), 1); 26415 var import_jsx_runtime144 = __toESM(require_jsx_runtime(), 1); 26416 function isDefined4(item) { 26417 return !!item; 26418 } 26419 function PickerActivityItem({ 26420 view, 26421 multiselect, 26422 selection, 26423 onChangeSelection, 26424 getItemId: getItemId2, 26425 item, 26426 titleField, 26427 mediaField, 26428 descriptionField: descriptionField2, 26429 otherFields, 26430 posinset, 26431 setsize 26432 }) { 26433 const elementRef = (0, import_element79.useRef)(null); 26434 useIntersectionObserver(elementRef, posinset); 26435 const { showTitle = true, showMedia = true, showDescription = true } = view; 26436 const id = getItemId2(item); 26437 const isSelected2 = selection.includes(id); 26438 const density = view.layout?.density ?? "balanced"; 26439 const mediaContent = showMedia && density !== "compact" && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime144.jsx)( 26440 mediaField.render, 26441 { 26442 item, 26443 field: mediaField, 26444 config: { 26445 sizes: density === "comfortable" ? "32px" : "24px" 26446 } 26447 } 26448 ) : null; 26449 const renderedMediaField = /* @__PURE__ */ (0, import_jsx_runtime144.jsx)("div", { className: "dataviews-view-picker-activity__item-type-icon", children: mediaContent || /* @__PURE__ */ (0, import_jsx_runtime144.jsx)( 26450 "span", 26451 { 26452 className: "dataviews-view-picker-activity__item-bullet", 26453 "aria-hidden": "true" 26454 } 26455 ) }); 26456 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(titleField.render, { item, field: titleField }) : null; 26457 const renderedDescriptionField = showDescription && descriptionField2?.render ? /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(descriptionField2.render, { item, field: descriptionField2 }) : null; 26458 const verticalGap = (0, import_element79.useMemo)(() => { 26459 switch (density) { 26460 case "comfortable": 26461 return "md"; 26462 default: 26463 return "sm"; 26464 } 26465 }, [density]); 26466 return /* @__PURE__ */ (0, import_jsx_runtime144.jsx)( 26467 import_components35.Composite.Item, 26468 { 26469 ref: elementRef, 26470 role: "option", 26471 "aria-label": titleField ? titleField.getValue({ item }) || void 0 : void 0, 26472 "aria-posinset": posinset, 26473 "aria-setsize": setsize, 26474 "aria-selected": isSelected2, 26475 className: clsx_default( 26476 "dataviews-view-picker-activity__item", 26477 density === "compact" && "is-compact", 26478 density === "balanced" && "is-balanced", 26479 density === "comfortable" && "is-comfortable", 26480 isSelected2 && "is-selected" 26481 ), 26482 onClick: () => { 26483 if (isSelected2) { 26484 onChangeSelection( 26485 selection.filter((itemId) => id !== itemId) 26486 ); 26487 } else { 26488 const newSelection = multiselect ? [...selection, id] : [id]; 26489 onChangeSelection(newSelection); 26490 } 26491 }, 26492 render: /* @__PURE__ */ (0, import_jsx_runtime144.jsx)("div", {}), 26493 children: /* @__PURE__ */ (0, import_jsx_runtime144.jsxs)(Stack, { direction: "row", gap: "lg", justify: "start", align: "flex-start", children: [ 26494 /* @__PURE__ */ (0, import_jsx_runtime144.jsx)( 26495 Stack, 26496 { 26497 direction: "column", 26498 gap: "xs", 26499 align: "center", 26500 className: "dataviews-view-picker-activity__item-type", 26501 children: renderedMediaField 26502 } 26503 ), 26504 /* @__PURE__ */ (0, import_jsx_runtime144.jsxs)( 26505 Stack, 26506 { 26507 direction: "column", 26508 gap: verticalGap, 26509 align: "flex-start", 26510 className: "dataviews-view-picker-activity__item-content", 26511 children: [ 26512 renderedTitleField && /* @__PURE__ */ (0, import_jsx_runtime144.jsx)("div", { className: "dataviews-view-picker-activity__item-title", children: renderedTitleField }), 26513 renderedDescriptionField && /* @__PURE__ */ (0, import_jsx_runtime144.jsx)("div", { className: "dataviews-view-picker-activity__item-description", children: renderedDescriptionField }), 26514 /* @__PURE__ */ (0, import_jsx_runtime144.jsx)("div", { className: "dataviews-view-picker-activity__item-fields", children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime144.jsxs)( 26515 "div", 26516 { 26517 className: "dataviews-view-picker-activity__item-field", 26518 children: [ 26519 /* @__PURE__ */ (0, import_jsx_runtime144.jsx)( 26520 VisuallyHidden, 26521 { 26522 render: /* @__PURE__ */ (0, import_jsx_runtime144.jsx)("span", {}), 26523 className: "dataviews-view-picker-activity__item-field-label", 26524 children: field.label 26525 } 26526 ), 26527 /* @__PURE__ */ (0, import_jsx_runtime144.jsx)("span", { className: "dataviews-view-picker-activity__item-field-value", children: /* @__PURE__ */ (0, import_jsx_runtime144.jsx)( 26528 field.render, 26529 { 26530 item, 26531 field 26532 } 26533 ) }) 26534 ] 26535 }, 26536 field.id 26537 )) }) 26538 ] 26539 } 26540 ) 26541 ] }) 26542 } 26543 ); 26544 } 26545 function PickerActivityGroup({ 26546 groupName, 26547 groupField, 26548 showLabel = true, 26549 children 26550 }) { 26551 const headerId = (0, import_compose11.useInstanceId)( 26552 PickerActivityGroup, 26553 "dataviews-view-picker-activity-group__header" 26554 ); 26555 return /* @__PURE__ */ (0, import_jsx_runtime144.jsxs)( 26556 Stack, 26557 { 26558 direction: "column", 26559 role: "group", 26560 "aria-labelledby": headerId, 26561 className: "dataviews-view-picker-activity-group", 26562 children: [ 26563 /* @__PURE__ */ (0, import_jsx_runtime144.jsx)( 26564 "h3", 26565 { 26566 className: "dataviews-view-picker-activity-group__header", 26567 id: headerId, 26568 children: showLabel ? (0, import_i18n42.sprintf)( 26569 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022". 26570 (0, import_i18n42.__)("%1$s: %2$s"), 26571 groupField.label, 26572 groupName 26573 ) : groupName 26574 } 26575 ), 26576 children 26577 ] 26578 } 26579 ); 26580 } 26581 function ViewPickerActivity({ 26582 data, 26583 fields: fields2, 26584 getItemId: getItemId2, 26585 isLoading, 26586 onChangeSelection, 26587 selection, 26588 view, 26589 actions, 26590 className, 26591 empty 26592 }) { 26593 const { itemListLabel, paginationInfo } = (0, import_element79.useContext)(dataviews_context_default); 26594 const isMultiselect = useIsMultiselectPicker(actions); 26595 const titleField = fields2.find( 26596 (field) => field.id === view?.titleField 26597 ); 26598 const mediaField = fields2.find( 26599 (field) => field.id === view?.mediaField 26600 ); 26601 const descriptionField2 = fields2.find( 26602 (field) => field.id === view?.descriptionField 26603 ); 26604 const otherFields = (view?.fields ?? []).map((fieldId) => fields2.find((f2) => fieldId === f2.id)).filter(isDefined4); 26605 const groupField = view.groupBy?.field ? fields2.find((f2) => f2.id === view.groupBy?.field) : null; 26606 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null; 26607 const isInfiniteScroll = (view.infiniteScrollEnabled && !dataByGroup) ?? false; 26608 const setsize = isInfiniteScroll ? paginationInfo?.totalItems : void 0; 26609 const hasData = !!data?.length; 26610 const isGrouped = !!(groupField && dataByGroup); 26611 const renderItem = (item) => /* @__PURE__ */ (0, import_jsx_runtime144.jsx)( 26612 PickerActivityItem, 26613 { 26614 view, 26615 multiselect: isMultiselect, 26616 selection, 26617 onChangeSelection, 26618 getItemId: getItemId2, 26619 item, 26620 titleField, 26621 mediaField, 26622 descriptionField: descriptionField2, 26623 otherFields, 26624 posinset: item.position, 26625 setsize 26626 }, 26627 getItemId2(item) 26628 ); 26629 if (!hasData) { 26630 return /* @__PURE__ */ (0, import_jsx_runtime144.jsx)( 26631 "div", 26632 { 26633 className: clsx_default({ 26634 "dataviews-loading": isLoading, 26635 "dataviews-no-results": !isLoading 26636 }), 26637 children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime144.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(import_components35.Spinner, {}) }) : empty 26638 } 26639 ); 26640 } 26641 return /* @__PURE__ */ (0, import_jsx_runtime144.jsxs)(import_jsx_runtime144.Fragment, { children: [ 26642 /* @__PURE__ */ (0, import_jsx_runtime144.jsx)( 26643 import_components35.Composite, 26644 { 26645 virtualFocus: true, 26646 orientation: "vertical", 26647 role: "listbox", 26648 "aria-multiselectable": isMultiselect, 26649 "aria-label": itemListLabel, 26650 "aria-busy": isLoading, 26651 render: isGrouped ? /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(Stack, { direction: "column", gap: "sm" }) : void 0, 26652 className: clsx_default( 26653 "dataviews-view-picker-activity", 26654 className 26655 ), 26656 children: isGrouped && dataByGroup ? Array.from(dataByGroup.entries()).map( 26657 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime144.jsx)( 26658 PickerActivityGroup, 26659 { 26660 groupName, 26661 groupField, 26662 showLabel: view.groupBy?.showLabel !== false, 26663 children: groupItems.map(renderItem) 26664 }, 26665 groupName 26666 ) 26667 ) : data.map(renderItem) 26668 } 26669 ), 26670 isLoading && /* @__PURE__ */ (0, import_jsx_runtime144.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(import_components35.Spinner, {}) }) 26671 ] }); 26672 } 26673 26674 // packages/dataviews/build-module/components/dataviews-layouts/utils/density-picker.mjs 26675 var import_components36 = __toESM(require_components(), 1); 26676 var import_i18n43 = __toESM(require_i18n(), 1); 26677 var import_element80 = __toESM(require_element(), 1); 26678 var import_jsx_runtime145 = __toESM(require_jsx_runtime(), 1); 26679 function DensityPicker() { 26680 const context = (0, import_element80.useContext)(dataviews_context_default); 26681 const view = context.view; 26682 return /* @__PURE__ */ (0, import_jsx_runtime145.jsxs)( 26683 import_components36.__experimentalToggleGroupControl, 26684 { 26685 label: (0, import_i18n43.__)("Density"), 26686 value: view.layout?.density || "balanced", 26687 onChange: (value) => { 26688 context.onChangeView({ 26689 ...view, 26690 layout: { 26691 ...view.layout, 26692 density: value 26693 } 26694 }); 26695 }, 26696 isBlock: true, 26697 children: [ 26698 /* @__PURE__ */ (0, import_jsx_runtime145.jsx)( 26699 import_components36.__experimentalToggleGroupControlOption, 26700 { 26701 value: "comfortable", 26702 label: (0, import_i18n43._x)( 26703 "Comfortable", 26704 "Density option for DataView layout" 26705 ) 26706 }, 26707 "comfortable" 26708 ), 26709 /* @__PURE__ */ (0, import_jsx_runtime145.jsx)( 26710 import_components36.__experimentalToggleGroupControlOption, 26711 { 26712 value: "balanced", 26713 label: (0, import_i18n43._x)("Balanced", "Density option for DataView layout") 26714 }, 26715 "balanced" 26716 ), 26717 /* @__PURE__ */ (0, import_jsx_runtime145.jsx)( 26718 import_components36.__experimentalToggleGroupControlOption, 26719 { 26720 value: "compact", 26721 label: (0, import_i18n43._x)("Compact", "Density option for DataView layout") 26722 }, 26723 "compact" 26724 ) 26725 ] 26726 } 26727 ); 26728 } 26729 26730 // packages/dataviews/build-module/components/dataviews-layouts/utils/preview-size-picker.mjs 26731 var import_components37 = __toESM(require_components(), 1); 26732 var import_i18n44 = __toESM(require_i18n(), 1); 26733 var import_element81 = __toESM(require_element(), 1); 26734 var import_jsx_runtime146 = __toESM(require_jsx_runtime(), 1); 26735 var imageSizes2 = [ 26736 { 26737 value: 120, 26738 breakpoint: 1 26739 }, 26740 { 26741 value: 170, 26742 breakpoint: 1 26743 }, 26744 { 26745 value: 230, 26746 breakpoint: 1 26747 }, 26748 { 26749 value: 290, 26750 breakpoint: 1112 26751 // at minimum image width, 4 images display at this container size 26752 }, 26753 { 26754 value: 350, 26755 breakpoint: 1636 26756 // at minimum image width, 6 images display at this container size 26757 }, 26758 { 26759 value: 430, 26760 breakpoint: 588 26761 // at minimum image width, 2 images display at this container size 26762 } 26763 ]; 26764 function PreviewSizePicker() { 26765 const context = (0, import_element81.useContext)(dataviews_context_default); 26766 const view = context.view; 26767 const breakValues = imageSizes2.filter((size4) => { 26768 return context.containerWidth >= size4.breakpoint; 26769 }); 26770 const layoutPreviewSize = view.layout?.previewSize ?? 230; 26771 const previewSizeToUse = breakValues.map((size4, index2) => ({ ...size4, index: index2 })).filter((size4) => size4.value <= layoutPreviewSize).sort((a2, b2) => b2.value - a2.value)[0]?.index ?? 0; 26772 const marks = breakValues.map((size4, index2) => { 26773 return { 26774 value: index2 26775 }; 26776 }); 26777 return /* @__PURE__ */ (0, import_jsx_runtime146.jsx)( 26778 import_components37.RangeControl, 26779 { 26780 showTooltip: false, 26781 label: (0, import_i18n44.__)("Preview size"), 26782 value: previewSizeToUse, 26783 min: 0, 26784 max: breakValues.length - 1, 26785 withInputField: false, 26786 onChange: (value = 0) => { 26787 context.onChangeView({ 26788 ...view, 26789 layout: { 26790 ...view.layout, 26791 previewSize: breakValues[value].value 26792 } 26793 }); 26794 }, 26795 step: 1, 26796 marks 26797 } 26798 ); 26799 } 26800 26801 // packages/dataviews/build-module/components/dataviews-layouts/utils/grid-config-options.mjs 26802 var import_jsx_runtime147 = __toESM(require_jsx_runtime(), 1); 26803 function GridConfigOptions() { 26804 return /* @__PURE__ */ (0, import_jsx_runtime147.jsxs)(import_jsx_runtime147.Fragment, { children: [ 26805 /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(DensityPicker, {}), 26806 /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(PreviewSizePicker, {}) 26807 ] }); 26808 } 26809 26810 // packages/dataviews/build-module/components/dataviews-layouts/index.mjs 26811 var VIEW_LAYOUTS = [ 26812 { 26813 type: LAYOUT_TABLE, 26814 label: (0, import_i18n45.__)("Table"), 26815 component: table_default, 26816 icon: block_table_default, 26817 viewConfigOptions: DensityPicker 26818 }, 26819 { 26820 type: LAYOUT_GRID, 26821 label: (0, import_i18n45.__)("Grid"), 26822 component: grid_default, 26823 icon: category_default, 26824 viewConfigOptions: GridConfigOptions 26825 }, 26826 { 26827 type: LAYOUT_LIST2, 26828 label: (0, import_i18n45.__)("List"), 26829 component: ViewList, 26830 icon: (0, import_i18n45.isRTL)() ? format_list_bullets_rtl_default : format_list_bullets_default, 26831 viewConfigOptions: DensityPicker 26832 }, 26833 { 26834 type: LAYOUT_ACTIVITY, 26835 label: (0, import_i18n45.__)("Activity"), 26836 component: ViewActivity, 26837 icon: scheduled_default, 26838 viewConfigOptions: DensityPicker 26839 }, 26840 { 26841 type: LAYOUT_PICKER_GRID, 26842 label: (0, import_i18n45.__)("Grid"), 26843 component: picker_grid_default, 26844 icon: category_default, 26845 viewConfigOptions: GridConfigOptions, 26846 isPicker: true 26847 }, 26848 { 26849 type: LAYOUT_PICKER_TABLE, 26850 label: (0, import_i18n45.__)("Table"), 26851 component: picker_table_default, 26852 icon: block_table_default, 26853 viewConfigOptions: DensityPicker, 26854 isPicker: true 26855 }, 26856 { 26857 type: LAYOUT_PICKER_ACTIVITY, 26858 label: (0, import_i18n45.__)("Activity"), 26859 component: ViewPickerActivity, 26860 icon: scheduled_default, 26861 viewConfigOptions: DensityPicker, 26862 isPicker: true 26863 } 26864 ]; 26865 26866 // packages/dataviews/build-module/components/dataviews-filters/filters.mjs 26867 var import_element89 = __toESM(require_element(), 1); 26868 26869 // packages/dataviews/build-module/components/dataviews-filters/filter.mjs 26870 var import_components40 = __toESM(require_components(), 1); 26871 var import_i18n48 = __toESM(require_i18n(), 1); 26872 var import_element86 = __toESM(require_element(), 1); 26873 26874 // node_modules/@ariakit/react-components/dist/focusable/focusable-context.js 26875 var import_react16 = __toESM(require_react(), 1); 26876 var FocusableContext = (0, import_react16.createContext)(true); 26877 26878 // node_modules/@ariakit/utils/dist/index.js 26879 function toArray2(arg) { 26880 if (Array.isArray(arg)) return arg; 26881 return typeof arg !== "undefined" ? [arg] : []; 26882 } 26883 function flatten2DArray(array) { 26884 const flattened = []; 26885 for (const row of array) flattened.push(...row); 26886 return flattened; 26887 } 26888 function reverseArray(array) { 26889 return array.slice().reverse(); 26890 } 26891 function noop5(..._) { 26892 } 26893 function hasOwnProperty(object, prop) { 26894 if (typeof Object.hasOwn === "function") return Object.hasOwn(object, prop); 26895 return Object.prototype.hasOwnProperty.call(object, prop); 26896 } 26897 function chain(...fns) { 26898 return (...args) => { 26899 for (const fn of fns) if (typeof fn === "function") fn(...args); 26900 }; 26901 } 26902 function normalizeString(str) { 26903 return str.normalize("NFD").replace(/[\u0300-\u036f]/g, ""); 26904 } 26905 function omit(object, keys) { 26906 const result = { ...object }; 26907 for (const key of keys) if (hasOwnProperty(result, key)) delete result[key]; 26908 return result; 26909 } 26910 function pick(object, paths) { 26911 const result = {}; 26912 for (const key of paths) if (hasOwnProperty(object, key)) result[key] = object[key]; 26913 return result; 26914 } 26915 function identity(value) { 26916 return value; 26917 } 26918 function afterPaint(cb = noop5) { 26919 let raf2 = requestAnimationFrame(() => { 26920 raf2 = requestAnimationFrame(cb); 26921 }); 26922 return () => cancelAnimationFrame(raf2); 26923 } 26924 function invariant(condition, message2) { 26925 if (condition) return; 26926 if (typeof message2 !== "string") throw new Error("Invariant failed"); 26927 throw new Error(message2); 26928 } 26929 function getKeys(obj) { 26930 return Object.keys(obj); 26931 } 26932 function isFalsyBooleanCallback(booleanOrCallback, ...args) { 26933 const result = typeof booleanOrCallback === "function" ? booleanOrCallback(...args) : booleanOrCallback; 26934 if (result == null) return false; 26935 return !result; 26936 } 26937 function disabledFromProps(props) { 26938 return props.disabled || props["aria-disabled"] === true || props["aria-disabled"] === "true"; 26939 } 26940 function removeUndefinedValues(obj) { 26941 const result = {}; 26942 for (const key in obj) if (obj[key] !== void 0) result[key] = obj[key]; 26943 return result; 26944 } 26945 function defaultValue(...values) { 26946 for (const value of values) if (value !== void 0) return value; 26947 } 26948 var canUseDOM = checkIsBrowser(); 26949 function checkIsBrowser() { 26950 return typeof window !== "undefined" && !!window.document?.createElement; 26951 } 26952 function getDocument(node) { 26953 if (!node) return document; 26954 if ("self" in node) return node.document; 26955 return node.ownerDocument || document; 26956 } 26957 function getActiveElement(node, activeDescendant = false) { 26958 const { activeElement: activeElement2 } = getDocument(node); 26959 if (!activeElement2?.nodeName) return null; 26960 if (isFrame(activeElement2) && activeElement2.contentDocument?.body) return getActiveElement(activeElement2.contentDocument.body, activeDescendant); 26961 if (activeDescendant) { 26962 const id = activeElement2.getAttribute("aria-activedescendant"); 26963 if (id) { 26964 const element = getDocument(activeElement2).getElementById(id); 26965 if (element) return element; 26966 } 26967 } 26968 return activeElement2; 26969 } 26970 function contains2(parent, child) { 26971 return parent === child || parent.contains(child); 26972 } 26973 function isElement2(target) { 26974 return target?.nodeType === 1; 26975 } 26976 function isNode2(target) { 26977 return typeof target?.nodeType === "number"; 26978 } 26979 function isFrame(element) { 26980 return element.tagName === "IFRAME"; 26981 } 26982 function isButton(element) { 26983 const tagName = element.tagName.toLowerCase(); 26984 if (tagName === "button") return true; 26985 if (tagName === "input" && element.type) return buttonInputTypes.indexOf(element.type) !== -1; 26986 return false; 26987 } 26988 var buttonInputTypes = [ 26989 "button", 26990 "color", 26991 "file", 26992 "image", 26993 "reset", 26994 "submit" 26995 ]; 26996 function isVisible(element) { 26997 if (typeof element.checkVisibility === "function") return element.checkVisibility(); 26998 const htmlElement = element; 26999 return htmlElement.offsetWidth > 0 || htmlElement.offsetHeight > 0 || element.getClientRects().length > 0; 27000 } 27001 function isTextField(element) { 27002 try { 27003 if (element.tagName === "TEXTAREA") return true; 27004 if (element.tagName !== "INPUT") return false; 27005 return element.selectionStart !== null; 27006 } catch (_error) { 27007 return false; 27008 } 27009 } 27010 function isTextbox(element) { 27011 return element.isContentEditable || isTextField(element); 27012 } 27013 function getTextboxValue(element) { 27014 if (isTextField(element)) return element.value; 27015 if (element.isContentEditable) { 27016 const range = getDocument(element).createRange(); 27017 range.selectNodeContents(element); 27018 return range.toString(); 27019 } 27020 return ""; 27021 } 27022 function getTextboxSelection(element) { 27023 let start2 = 0; 27024 let end = 0; 27025 if (isTextField(element)) { 27026 start2 = element.selectionStart || 0; 27027 end = element.selectionEnd || 0; 27028 } else if (element.isContentEditable) { 27029 const selection = getDocument(element).getSelection(); 27030 if (selection?.rangeCount && selection.anchorNode && contains2(element, selection.anchorNode) && selection.focusNode && contains2(element, selection.focusNode)) { 27031 const range = selection.getRangeAt(0); 27032 const nextRange = range.cloneRange(); 27033 nextRange.selectNodeContents(element); 27034 nextRange.setEnd(range.startContainer, range.startOffset); 27035 start2 = nextRange.toString().length; 27036 nextRange.setEnd(range.endContainer, range.endOffset); 27037 end = nextRange.toString().length; 27038 } 27039 } 27040 return { 27041 start: start2, 27042 end 27043 }; 27044 } 27045 var allowedPopupRoles = [ 27046 "dialog", 27047 "menu", 27048 "listbox", 27049 "tree", 27050 "grid" 27051 ]; 27052 var itemRoleByPopupRole = { 27053 menu: "menuitem", 27054 listbox: "option", 27055 tree: "treeitem" 27056 }; 27057 function getPopupRole(element, fallback) { 27058 const role = element?.getAttribute("role"); 27059 if (role && allowedPopupRoles.indexOf(role) !== -1) return role; 27060 return fallback; 27061 } 27062 function getItemRoleByPopupRole(popupRole) { 27063 if (popupRole == null) return; 27064 if (!hasOwnProperty(itemRoleByPopupRole, popupRole)) return; 27065 return itemRoleByPopupRole[popupRole]; 27066 } 27067 function getScrollingElement(element) { 27068 if (!element) return null; 27069 const isScrollableOverflow = (overflow) => { 27070 if (overflow === "auto") return true; 27071 if (overflow === "scroll") return true; 27072 return false; 27073 }; 27074 if (element.clientHeight && element.scrollHeight > element.clientHeight) { 27075 const { overflowY } = getComputedStyle(element); 27076 if (isScrollableOverflow(overflowY)) return element; 27077 } else if (element.clientWidth && element.scrollWidth > element.clientWidth) { 27078 const { overflowX } = getComputedStyle(element); 27079 if (isScrollableOverflow(overflowX)) return element; 27080 } 27081 const doc = getDocument(element); 27082 return getScrollingElement(element.parentElement) || doc.scrollingElement || doc.body; 27083 } 27084 function setSelectionRange(element, ...args) { 27085 if (/text|search|password|tel|url/i.test(element.type)) element.setSelectionRange(...args); 27086 } 27087 function sortBasedOnDOMPosition(items, getElement) { 27088 const pairs = items.map((item, index2) => [index2, item]); 27089 let isOrderDifferent = false; 27090 pairs.sort(([indexA, a2], [indexB, b2]) => { 27091 const elementA = getElement(a2); 27092 const elementB = getElement(b2); 27093 if (elementA === elementB) return 0; 27094 if (!elementA || !elementB) return 0; 27095 if (isElementPreceding(elementA, elementB)) { 27096 if (indexA > indexB) isOrderDifferent = true; 27097 return -1; 27098 } 27099 if (indexA < indexB) isOrderDifferent = true; 27100 return 1; 27101 }); 27102 if (isOrderDifferent) return pairs.map(([_, item]) => item); 27103 return items; 27104 } 27105 function isElementPreceding(a2, b2) { 27106 return Boolean(b2.compareDocumentPosition(a2) & Node.DOCUMENT_POSITION_PRECEDING); 27107 } 27108 function isTouchDevice() { 27109 return canUseDOM && !!navigator.maxTouchPoints; 27110 } 27111 function isApple() { 27112 if (!canUseDOM) return false; 27113 return /mac|iphone|ipad|ipod/i.test(navigator.platform); 27114 } 27115 function isSafari() { 27116 return canUseDOM && isApple() && /apple/i.test(navigator.vendor); 27117 } 27118 function isFirefox() { 27119 return canUseDOM && /firefox\//i.test(navigator.userAgent); 27120 } 27121 function isPortalEvent(event) { 27122 const { currentTarget, target } = event; 27123 if (!currentTarget) return false; 27124 if (!isNode2(target)) return true; 27125 return !contains2(currentTarget, target); 27126 } 27127 function isSelfTarget(event) { 27128 return event.target === event.currentTarget; 27129 } 27130 function isActivatableNavigationTarget(element) { 27131 if (!isElement2(element)) return false; 27132 const target = element; 27133 const tagName = target.tagName.toLowerCase(); 27134 if (tagName === "a") return true; 27135 if (tagName === "button" && target.type === "submit") return true; 27136 if (tagName === "input" && target.type === "submit") return true; 27137 return false; 27138 } 27139 function isOpeningInNewTab(event) { 27140 const isAppleDevice = isApple(); 27141 if (isAppleDevice && !event.metaKey) return false; 27142 if (!isAppleDevice && !event.ctrlKey) return false; 27143 return isActivatableNavigationTarget(event.currentTarget); 27144 } 27145 function isDownloading(event) { 27146 if (!event.altKey) return false; 27147 return isActivatableNavigationTarget(event.currentTarget); 27148 } 27149 function fireBlurEvent(element, eventInit) { 27150 const event = new FocusEvent("blur", eventInit); 27151 const defaultAllowed = element.dispatchEvent(event); 27152 const bubbleInit = { 27153 ...eventInit, 27154 bubbles: true 27155 }; 27156 element.dispatchEvent(new FocusEvent("focusout", bubbleInit)); 27157 return defaultAllowed; 27158 } 27159 function fireKeyboardEvent(element, type, eventInit) { 27160 const event = new KeyboardEvent(type, eventInit); 27161 return element.dispatchEvent(event); 27162 } 27163 function fireClickEvent(element, eventInit) { 27164 const event = new MouseEvent("click", eventInit); 27165 return element.dispatchEvent(event); 27166 } 27167 function isFocusEventOutside(event, container) { 27168 const containerElement = container || event.currentTarget; 27169 const relatedTarget = event.relatedTarget; 27170 return !isNode2(relatedTarget) || !contains2(containerElement, relatedTarget); 27171 } 27172 function isInputEvent(event) { 27173 return event.type === "input"; 27174 } 27175 function queueBeforeEvent(element, type, callback, timeout) { 27176 const createTimer = (callback2) => { 27177 if (timeout) { 27178 const timerId2 = setTimeout(callback2, timeout); 27179 return () => clearTimeout(timerId2); 27180 } 27181 const timerId = requestAnimationFrame(callback2); 27182 return () => cancelAnimationFrame(timerId); 27183 }; 27184 const cancelTimer = createTimer(() => { 27185 element.removeEventListener(type, callSync, true); 27186 callback(); 27187 }); 27188 const callSync = () => { 27189 cancelTimer(); 27190 callback(); 27191 }; 27192 element.addEventListener(type, callSync, { 27193 once: true, 27194 capture: true 27195 }); 27196 return () => { 27197 cancelTimer(); 27198 element.removeEventListener(type, callSync, true); 27199 }; 27200 } 27201 function addGlobalEventListener(type, listener, options, scope = window) { 27202 const children = []; 27203 try { 27204 scope.document.addEventListener(type, listener, options); 27205 for (const frame of Array.from(scope.frames)) children.push(addGlobalEventListener(type, listener, options, frame)); 27206 } catch { 27207 } 27208 const removeEventListener = () => { 27209 try { 27210 scope.document.removeEventListener(type, listener, options); 27211 } catch { 27212 } 27213 for (const remove of children) remove(); 27214 }; 27215 return removeEventListener; 27216 } 27217 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'])"; 27218 function isFocusable(element) { 27219 if (!element.matches(selector)) return false; 27220 if (!isVisible(element)) return false; 27221 if (element.closest("[inert]")) return false; 27222 return true; 27223 } 27224 function hasFocus(element) { 27225 const activeElement2 = getActiveElement(element); 27226 if (!activeElement2) return false; 27227 if (activeElement2 === element) return true; 27228 const activeDescendant = activeElement2.getAttribute("aria-activedescendant"); 27229 if (!activeDescendant) return false; 27230 return activeDescendant === element.id; 27231 } 27232 function hasFocusWithin(element) { 27233 const activeElement2 = getActiveElement(element); 27234 if (!activeElement2) return false; 27235 if (contains2(element, activeElement2)) return true; 27236 const activeDescendant = activeElement2.getAttribute("aria-activedescendant"); 27237 if (!activeDescendant) return false; 27238 if (!("id" in element)) return false; 27239 if (activeDescendant === element.id) return true; 27240 return !!element.querySelector(`#$CSS.escape(activeDescendant)}`); 27241 } 27242 function focusIntoView(element, options) { 27243 if (!("scrollIntoView" in element)) element.focus(); 27244 else { 27245 element.focus({ preventScroll: true }); 27246 element.scrollIntoView({ 27247 block: "nearest", 27248 inline: "nearest", 27249 ...options 27250 }); 27251 } 27252 } 27253 function createUndoCallback(callback) { 27254 return async () => { 27255 const redo = await callback?.(); 27256 return createUndoCallback(async () => { 27257 await redo?.(); 27258 return callback; 27259 }); 27260 }; 27261 } 27262 var UndoManager = createUndoManager(); 27263 function createUndoManager({ limit = 100 } = {}) { 27264 const undoStack = []; 27265 let redoStack = []; 27266 let currentGroup = null; 27267 const canUndo = () => undoStack.length > 0; 27268 const canRedo = () => redoStack.length > 0; 27269 const undo = async () => { 27270 if (!canUndo()) return; 27271 currentGroup = null; 27272 redoStack.push(await undoStack.pop()?.()); 27273 }; 27274 const redo = async () => { 27275 if (!canRedo()) return; 27276 currentGroup = null; 27277 undoStack.push(await redoStack.pop()?.()); 27278 }; 27279 const execute = async (callback, group) => { 27280 if (!callback) return; 27281 const sameGroup = group === currentGroup; 27282 currentGroup = group ?? null; 27283 const nextIndex = sameGroup ? Math.max(0, undoStack.length - 1) : undoStack.length; 27284 const undoCallback = await callback(); 27285 if (!undoCallback) return; 27286 redoStack = []; 27287 const currentUndo = undoStack[nextIndex]; 27288 undoStack[nextIndex] = createUndoCallback(async () => { 27289 await undoCallback?.(); 27290 const currentRedo = await currentUndo?.(); 27291 return async () => { 27292 await currentRedo?.(); 27293 await callback?.(); 27294 }; 27295 }); 27296 while (undoStack.length > limit) undoStack.shift(); 27297 }; 27298 return { 27299 canUndo, 27300 canRedo, 27301 undo, 27302 redo, 27303 execute 27304 }; 27305 } 27306 27307 // node_modules/@ariakit/react-utils/dist/index.js 27308 var React59 = __toESM(require_react(), 1); 27309 var import_react17 = __toESM(require_react(), 1); 27310 var import_jsx_runtime148 = __toESM(require_jsx_runtime(), 1); 27311 function setRef(ref, value) { 27312 if (typeof ref === "function") { 27313 const cleanup = ref(value); 27314 if (typeof cleanup === "function") return cleanup; 27315 } else if (ref) ref.current = value; 27316 } 27317 function isValidElementWithRef(element) { 27318 if (!element) return false; 27319 if (!(0, import_react17.isValidElement)(element)) return false; 27320 if ("ref" in element.props) return true; 27321 if ("ref" in element) return true; 27322 return false; 27323 } 27324 function getRefProperty(element) { 27325 if (!isValidElementWithRef(element)) return null; 27326 return { ...element.props }.ref || element.ref; 27327 } 27328 function mergeProps2(base, overrides) { 27329 const props = { ...base }; 27330 for (const key in overrides) { 27331 if (!hasOwnProperty(overrides, key)) continue; 27332 if (key === "className") { 27333 const prop = "className"; 27334 const baseClass = base[prop]; 27335 const overrideClass = overrides[prop]; 27336 if (baseClass && overrideClass) props[prop] = `$baseClass} $overrideClass}`; 27337 else props[prop] = overrideClass || baseClass; 27338 continue; 27339 } 27340 if (key === "style") { 27341 const prop = "style"; 27342 props[prop] = base[prop] ? { 27343 ...base[prop], 27344 ...overrides[prop] 27345 } : overrides[prop]; 27346 continue; 27347 } 27348 const overrideValue = overrides[key]; 27349 if (key.startsWith("on")) { 27350 if (typeof overrideValue !== "function") continue; 27351 const baseValue = base[key]; 27352 if (typeof baseValue === "function") { 27353 props[key] = (...args) => { 27354 overrideValue(...args); 27355 baseValue(...args); 27356 }; 27357 continue; 27358 } 27359 } 27360 props[key] = overrideValue; 27361 } 27362 return props; 27363 } 27364 var _React = { ...React59 }; 27365 var useReactId = _React.useId; 27366 var useReactDeferredValue = _React.useDeferredValue; 27367 var useReactInsertionEffect = _React.useInsertionEffect; 27368 var useSafeLayoutEffect = canUseDOM ? import_react17.useLayoutEffect : import_react17.useEffect; 27369 function useInitialValue(value) { 27370 const [initialValue] = (0, import_react17.useState)(value); 27371 return initialValue; 27372 } 27373 function useLiveRef(value) { 27374 const ref = (0, import_react17.useRef)(value); 27375 useSafeLayoutEffect(() => { 27376 ref.current = value; 27377 }); 27378 return ref; 27379 } 27380 function useEvent(callback) { 27381 const ref = (0, import_react17.useRef)(() => { 27382 throw new Error("Cannot call an event handler while rendering."); 27383 }); 27384 if (useReactInsertionEffect) useReactInsertionEffect(() => { 27385 ref.current = callback; 27386 }); 27387 else ref.current = callback; 27388 return (0, import_react17.useCallback)((...args) => ref.current?.(...args), []); 27389 } 27390 function useTransactionState(callback) { 27391 const [state, setState] = (0, import_react17.useState)(null); 27392 useSafeLayoutEffect(() => { 27393 if (state == null) return; 27394 if (!callback) return; 27395 let prevState = null; 27396 callback((prev) => { 27397 prevState = prev; 27398 return state; 27399 }); 27400 return () => { 27401 callback(prevState); 27402 }; 27403 }, [state, callback]); 27404 return [state, setState]; 27405 } 27406 function useMergeRefs(...refs) { 27407 return (0, import_react17.useMemo)(() => { 27408 if (!refs.some(Boolean)) return; 27409 return (value) => { 27410 const refEffects = []; 27411 for (const ref of refs) { 27412 if (!ref) continue; 27413 const cleanup = setRef(ref, value); 27414 refEffects.push({ 27415 ref, 27416 cleanup: typeof cleanup === "function" ? cleanup : void 0 27417 }); 27418 } 27419 if (!refEffects.some((effect) => effect.cleanup)) return; 27420 return () => { 27421 for (const { ref, cleanup } of refEffects) if (cleanup) cleanup(); 27422 else setRef(ref, null); 27423 }; 27424 }; 27425 }, refs); 27426 } 27427 function useId5(defaultId) { 27428 if (useReactId) { 27429 const reactId = useReactId(); 27430 if (defaultId) return defaultId; 27431 return reactId; 27432 } 27433 const [id, setId] = (0, import_react17.useState)(defaultId); 27434 useSafeLayoutEffect(() => { 27435 if (defaultId || id) return; 27436 setId(`id-$Math.random().toString(36).slice(2, 8)}`); 27437 }, [defaultId, id]); 27438 return defaultId || id; 27439 } 27440 function useTagName(refOrElement, type) { 27441 const stringOrUndefined = (type2) => { 27442 if (typeof type2 !== "string") return; 27443 return type2; 27444 }; 27445 const [tagName, setTagName] = (0, import_react17.useState)(() => stringOrUndefined(type)); 27446 useSafeLayoutEffect(() => { 27447 setTagName((refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement)?.tagName.toLowerCase() || stringOrUndefined(type)); 27448 }, [refOrElement, type]); 27449 return tagName; 27450 } 27451 function useAttribute(refOrElement, attributeName, defaultValue2) { 27452 const initialValue = useInitialValue(defaultValue2); 27453 const [attribute, setAttribute] = (0, import_react17.useState)(initialValue); 27454 (0, import_react17.useEffect)(() => { 27455 const element = refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement; 27456 if (!element) return; 27457 const callback = () => { 27458 const value = element.getAttribute(attributeName); 27459 setAttribute(value == null ? initialValue : value); 27460 }; 27461 const observer = new MutationObserver(callback); 27462 observer.observe(element, { attributeFilter: [attributeName] }); 27463 callback(); 27464 return () => observer.disconnect(); 27465 }, [ 27466 refOrElement, 27467 attributeName, 27468 initialValue 27469 ]); 27470 return attribute; 27471 } 27472 function useUpdateEffect(effect, deps) { 27473 const mounted = (0, import_react17.useRef)(false); 27474 (0, import_react17.useEffect)(() => { 27475 if (mounted.current) return effect(); 27476 mounted.current = true; 27477 }, deps); 27478 (0, import_react17.useEffect)(() => () => { 27479 mounted.current = false; 27480 }, []); 27481 } 27482 function useUpdateLayoutEffect(effect, deps) { 27483 const mounted = (0, import_react17.useRef)(false); 27484 useSafeLayoutEffect(() => { 27485 if (mounted.current) return effect(); 27486 mounted.current = true; 27487 }, deps); 27488 useSafeLayoutEffect(() => () => { 27489 mounted.current = false; 27490 }, []); 27491 } 27492 function useForceUpdate2() { 27493 return (0, import_react17.useReducer)(() => [], []); 27494 } 27495 function useBooleanEvent(booleanOrCallback) { 27496 return useEvent(typeof booleanOrCallback === "function" ? booleanOrCallback : () => booleanOrCallback); 27497 } 27498 function useWrapElement(props, callback, deps = []) { 27499 const wrapElement = (0, import_react17.useCallback)((element) => { 27500 if (props.wrapElement) element = props.wrapElement(element); 27501 return callback(element); 27502 }, [...deps, props.wrapElement]); 27503 return { 27504 ...props, 27505 wrapElement 27506 }; 27507 } 27508 function useMetadataProps(props, key, value) { 27509 const parent = props.onLoadedMetadataCapture; 27510 const onLoadedMetadataCapture = (0, import_react17.useMemo)(() => { 27511 return Object.assign(() => { 27512 }, parent, ...value !== void 0 ? [{ [key]: value }] : []); 27513 }, [ 27514 parent, 27515 key, 27516 value 27517 ]); 27518 return [parent?.[key], { onLoadedMetadataCapture }]; 27519 } 27520 var hasInstalledGlobalEventListeners = false; 27521 function useIsMouseMoving() { 27522 (0, import_react17.useEffect)(() => { 27523 if (hasInstalledGlobalEventListeners) return; 27524 addGlobalEventListener("mousemove", setMouseMoving, true); 27525 addGlobalEventListener("mousedown", resetMouseMoving, true); 27526 addGlobalEventListener("mouseup", resetMouseMoving, true); 27527 addGlobalEventListener("keydown", resetMouseMoving, true); 27528 addGlobalEventListener("scroll", resetMouseMoving, true); 27529 hasInstalledGlobalEventListeners = true; 27530 }, []); 27531 return useEvent(() => mouseMoving); 27532 } 27533 var mouseMoving = false; 27534 var previousScreenX = 0; 27535 var previousScreenY = 0; 27536 function hasMouseMovement(event) { 27537 const movementX = event.movementX || event.screenX - previousScreenX; 27538 const movementY = event.movementY || event.screenY - previousScreenY; 27539 previousScreenX = event.screenX; 27540 previousScreenY = event.screenY; 27541 return movementX || movementY || false; 27542 } 27543 function setMouseMoving(event) { 27544 if (!hasMouseMovement(event)) return; 27545 mouseMoving = true; 27546 } 27547 function resetMouseMoving() { 27548 mouseMoving = false; 27549 } 27550 function forwardRef43(render4) { 27551 const Role = React59.forwardRef((props, ref) => render4({ 27552 ...props, 27553 ref 27554 })); 27555 Role.displayName = render4.displayName || render4.name; 27556 return Role; 27557 } 27558 function memo5(Component, propsAreEqual) { 27559 return React59.memo(Component, propsAreEqual); 27560 } 27561 function createElement5(Type, props) { 27562 const { wrapElement, render: render4, ...rest } = props; 27563 const mergedRef = useMergeRefs(props.ref, getRefProperty(render4)); 27564 let element; 27565 if (React59.isValidElement(render4)) { 27566 const renderProps = { 27567 ...render4.props, 27568 ref: mergedRef 27569 }; 27570 element = React59.cloneElement(render4, mergeProps2(rest, renderProps)); 27571 } else if (render4) element = render4(rest); 27572 else element = /* @__PURE__ */ (0, import_jsx_runtime148.jsx)(Type, { ...rest }); 27573 if (wrapElement) return wrapElement(element); 27574 return element; 27575 } 27576 function createHook(useProps) { 27577 const useRole = (props = {}) => { 27578 return useProps(props); 27579 }; 27580 useRole.displayName = useProps.name; 27581 return useRole; 27582 } 27583 function createStoreContext(providers = [], scopedProviders = []) { 27584 const context = React59.createContext(void 0); 27585 const scopedContext = React59.createContext(void 0); 27586 const useContext67 = () => React59.useContext(context); 27587 const useScopedContext = (onlyScoped = false) => { 27588 const scoped = React59.useContext(scopedContext); 27589 const store2 = useContext67(); 27590 if (onlyScoped) return scoped; 27591 return scoped || store2; 27592 }; 27593 const useProviderContext = () => { 27594 const scoped = React59.useContext(scopedContext); 27595 const store2 = useContext67(); 27596 if (scoped && scoped === store2) return; 27597 return store2; 27598 }; 27599 const ContextProvider = (props) => { 27600 return providers.reduceRight((children, Provider2) => /* @__PURE__ */ (0, import_jsx_runtime148.jsx)(Provider2, { 27601 ...props, 27602 children 27603 }), /* @__PURE__ */ (0, import_jsx_runtime148.jsx)(context.Provider, { ...props })); 27604 }; 27605 const ScopedContextProvider = (props) => { 27606 return /* @__PURE__ */ (0, import_jsx_runtime148.jsx)(ContextProvider, { 27607 ...props, 27608 children: scopedProviders.reduceRight((children, Provider2) => /* @__PURE__ */ (0, import_jsx_runtime148.jsx)(Provider2, { 27609 ...props, 27610 children 27611 }), /* @__PURE__ */ (0, import_jsx_runtime148.jsx)(scopedContext.Provider, { ...props })) 27612 }); 27613 }; 27614 return { 27615 context, 27616 scopedContext, 27617 useContext: useContext67, 27618 useScopedContext, 27619 useProviderContext, 27620 ContextProvider, 27621 ScopedContextProvider 27622 }; 27623 } 27624 27625 // node_modules/@ariakit/react-components/dist/focusable/focusable.js 27626 var import_react18 = __toESM(require_react(), 1); 27627 var TagName = "div"; 27628 var accessibleWhenDisabledSymbol = /* @__PURE__ */ Symbol("accessibleWhenDisabled"); 27629 var isSafariBrowser = isSafari(); 27630 var alwaysFocusVisibleInputTypes = [ 27631 "text", 27632 "search", 27633 "url", 27634 "tel", 27635 "email", 27636 "password", 27637 "number", 27638 "date", 27639 "month", 27640 "week", 27641 "time", 27642 "datetime", 27643 "datetime-local" 27644 ]; 27645 function isAlwaysFocusVisible(element) { 27646 const { tagName, readOnly, type } = element; 27647 if (tagName === "TEXTAREA" && !readOnly) return true; 27648 if (tagName === "SELECT" && !readOnly) return true; 27649 if (tagName === "INPUT" && !readOnly) return alwaysFocusVisibleInputTypes.includes(type); 27650 if (element.isContentEditable) return true; 27651 if (element.getAttribute("role") === "combobox" && element.dataset.name) return true; 27652 return false; 27653 } 27654 function isNativeTabbable(tagName) { 27655 if (!tagName) return true; 27656 return tagName === "button" || tagName === "summary" || tagName === "input" || tagName === "select" || tagName === "textarea" || tagName === "a"; 27657 } 27658 function supportsDisabledAttribute(tagName) { 27659 if (!tagName) return true; 27660 return tagName === "button" || tagName === "input" || tagName === "select" || tagName === "textarea"; 27661 } 27662 function isNativeSubmitControl(element) { 27663 if (element.tagName === "BUTTON") { 27664 const { type } = element; 27665 return type === "submit"; 27666 } 27667 if (element.tagName === "INPUT") { 27668 const { type } = element; 27669 return type === "submit" || type === "image"; 27670 } 27671 return false; 27672 } 27673 function getTabIndex2({ focusable: focusable2, trulyDisabled, nativeTabbable, supportsDisabled, safariTabIndex, tabIndexProp }) { 27674 if (!focusable2) return tabIndexProp; 27675 if (trulyDisabled) { 27676 if (nativeTabbable && !supportsDisabled) return -1; 27677 return; 27678 } 27679 if (nativeTabbable) { 27680 if (safariTabIndex && tabIndexProp == null) return 0; 27681 return tabIndexProp; 27682 } 27683 return tabIndexProp ?? 0; 27684 } 27685 function useDisableEvent(onEvent, disabled2) { 27686 return useEvent((event) => { 27687 onEvent?.(event); 27688 if (event.defaultPrevented) return; 27689 if (disabled2) { 27690 event.stopPropagation(); 27691 event.preventDefault(); 27692 } 27693 }); 27694 } 27695 var hasInstalledGlobalEventListeners2 = false; 27696 var isKeyboardModality = true; 27697 function onGlobalMouseDown(event) { 27698 const target = event.target; 27699 if (isElement2(target) && !target.hasAttribute("data-focus-visible")) isKeyboardModality = false; 27700 } 27701 function onGlobalKeyDown(event) { 27702 if (event.metaKey) return; 27703 if (event.ctrlKey) return; 27704 if (event.altKey) return; 27705 isKeyboardModality = true; 27706 } 27707 var useFocusable = createHook(function useFocusable2({ focusable: focusable2 = true, accessibleWhenDisabled, autoFocus, onFocusVisible, ...props }) { 27708 const ref = (0, import_react18.useRef)(null); 27709 const [parentAccessibleWhenDisabled, metadataProps] = useMetadataProps(props, accessibleWhenDisabledSymbol, accessibleWhenDisabled); 27710 accessibleWhenDisabled ??= parentAccessibleWhenDisabled; 27711 (0, import_react18.useEffect)(() => { 27712 if (!focusable2) return; 27713 if (hasInstalledGlobalEventListeners2) return; 27714 addGlobalEventListener("mousedown", onGlobalMouseDown, true); 27715 addGlobalEventListener("keydown", onGlobalKeyDown, true); 27716 hasInstalledGlobalEventListeners2 = true; 27717 }, [focusable2]); 27718 const disabled2 = focusable2 && disabledFromProps(props); 27719 const trulyDisabled = disabled2 && !accessibleWhenDisabled; 27720 const [focusVisible, setFocusVisible] = (0, import_react18.useState)(false); 27721 const focusVisibleRef = (0, import_react18.useRef)(false); 27722 const nativeSubmitObserverCleanupRef = (0, import_react18.useRef)(null); 27723 const cleanupFocusVisible = useEvent((element) => { 27724 nativeSubmitObserverCleanupRef.current?.(); 27725 nativeSubmitObserverCleanupRef.current = null; 27726 focusVisibleRef.current = false; 27727 element?.removeAttribute("data-focus-visible"); 27728 }); 27729 (0, import_react18.useEffect)(() => { 27730 if (!focusable2) return; 27731 if (!trulyDisabled) return; 27732 cleanupFocusVisible(ref.current); 27733 if (focusVisible) setFocusVisible(false); 27734 }, [ 27735 focusable2, 27736 trulyDisabled, 27737 focusVisible, 27738 cleanupFocusVisible 27739 ]); 27740 (0, import_react18.useEffect)(() => { 27741 if (!focusable2) return; 27742 if (!focusVisible) return; 27743 const element = ref.current; 27744 if (!element) return; 27745 if (typeof IntersectionObserver === "undefined") return; 27746 const observer = new IntersectionObserver(() => { 27747 if (!isFocusable(element)) { 27748 focusVisibleRef.current = false; 27749 setFocusVisible(false); 27750 } 27751 }); 27752 observer.observe(element); 27753 return () => observer.disconnect(); 27754 }, [focusable2, focusVisible]); 27755 (0, import_react18.useEffect)(() => { 27756 return () => nativeSubmitObserverCleanupRef.current?.(); 27757 }, []); 27758 const onKeyPressCapture = useDisableEvent(props.onKeyPressCapture, disabled2); 27759 const onMouseDownCapture = useDisableEvent(props.onMouseDownCapture, disabled2); 27760 const onClickCapture = useDisableEvent(props.onClickCapture, disabled2); 27761 const handleFocusVisible = (event, currentTarget) => { 27762 if (currentTarget) event.currentTarget = currentTarget; 27763 if (!focusable2) return; 27764 const element = event.currentTarget; 27765 if (!element) return; 27766 if (!hasFocus(element)) return; 27767 onFocusVisible?.(event); 27768 if (event.defaultPrevented) return; 27769 element.dataset.focusVisible = "true"; 27770 focusVisibleRef.current = true; 27771 if (isNativeSubmitControl(element)) { 27772 nativeSubmitObserverCleanupRef.current?.(); 27773 nativeSubmitObserverCleanupRef.current = null; 27774 if (typeof IntersectionObserver !== "undefined") { 27775 const observer = new IntersectionObserver(() => { 27776 if (isFocusable(element)) return; 27777 cleanupFocusVisible(element); 27778 }); 27779 observer.observe(element); 27780 nativeSubmitObserverCleanupRef.current = () => observer.disconnect(); 27781 } 27782 return; 27783 } 27784 setFocusVisible(true); 27785 }; 27786 const onKeyDownCaptureProp = props.onKeyDownCapture; 27787 const onKeyDownCapture = useEvent((event) => { 27788 onKeyDownCaptureProp?.(event); 27789 if (event.defaultPrevented) return; 27790 if (!focusable2) return; 27791 if (focusVisible) return; 27792 if (focusVisibleRef.current) return; 27793 if (event.metaKey) return; 27794 if (event.altKey) return; 27795 if (event.ctrlKey) return; 27796 if (!isSelfTarget(event)) return; 27797 const element = event.currentTarget; 27798 const applyFocusVisible = () => handleFocusVisible(event, element); 27799 queueBeforeEvent(element, "focusout", applyFocusVisible); 27800 }); 27801 const onFocusCaptureProp = props.onFocusCapture; 27802 const onFocusCapture = useEvent((event) => { 27803 onFocusCaptureProp?.(event); 27804 if (event.defaultPrevented) return; 27805 if (!focusable2) return; 27806 if (!isSelfTarget(event)) { 27807 setFocusVisible(false); 27808 return; 27809 } 27810 const element = event.currentTarget; 27811 const applyFocusVisible = () => handleFocusVisible(event, element); 27812 if (isKeyboardModality || isAlwaysFocusVisible(event.target)) queueBeforeEvent(event.target, "focusout", applyFocusVisible); 27813 else setFocusVisible(false); 27814 }); 27815 const onBlurProp = props.onBlur; 27816 const onBlur = useEvent((event) => { 27817 onBlurProp?.(event); 27818 if (!focusable2) return; 27819 if (!isFocusEventOutside(event)) return; 27820 cleanupFocusVisible(event.currentTarget); 27821 setFocusVisible(false); 27822 }); 27823 const autoFocusOnShow = (0, import_react18.useContext)(FocusableContext); 27824 const autoFocusRef = useEvent((element) => { 27825 if (!focusable2) return; 27826 if (!autoFocus) return; 27827 if (!element) return; 27828 if (!autoFocusOnShow) return; 27829 queueMicrotask(() => { 27830 if (hasFocus(element)) return; 27831 if (!isFocusable(element)) return; 27832 element.focus(); 27833 }); 27834 }); 27835 const tagName = useTagName(ref); 27836 const nativeTabbable = focusable2 && isNativeTabbable(tagName); 27837 const supportsDisabled = focusable2 && supportsDisabledAttribute(tagName); 27838 const [safariTabIndex, setSafariTabIndex] = (0, import_react18.useState)(false); 27839 if (isSafariBrowser) (0, import_react18.useEffect)(() => { 27840 if (!focusable2) return; 27841 const element = ref.current; 27842 if (!element) return; 27843 const { type } = element; 27844 const isNativeCheckboxOrRadio = element.tagName === "INPUT" && (type === "checkbox" || type === "radio"); 27845 setSafariTabIndex(isButton(element) || isNativeCheckboxOrRadio); 27846 }, [focusable2]); 27847 const styleProp = props.style; 27848 const style = (0, import_react18.useMemo)(() => { 27849 if (trulyDisabled) return { 27850 pointerEvents: "none", 27851 ...styleProp 27852 }; 27853 return styleProp; 27854 }, [trulyDisabled, styleProp]); 27855 props = { 27856 "data-focus-visible": focusable2 && focusVisible || void 0, 27857 "data-autofocus": autoFocus || void 0, 27858 "aria-disabled": disabled2 || void 0, 27859 ...props, 27860 ...metadataProps, 27861 ref: useMergeRefs(ref, autoFocusRef, props.ref), 27862 style, 27863 tabIndex: getTabIndex2({ 27864 focusable: focusable2, 27865 trulyDisabled, 27866 nativeTabbable, 27867 supportsDisabled, 27868 safariTabIndex, 27869 tabIndexProp: props.tabIndex 27870 }), 27871 disabled: supportsDisabled && trulyDisabled ? true : void 0, 27872 contentEditable: disabled2 ? void 0 : props.contentEditable, 27873 onKeyPressCapture, 27874 onClickCapture, 27875 onMouseDownCapture, 27876 onKeyDownCapture, 27877 onFocusCapture, 27878 onBlur 27879 }; 27880 return removeUndefinedValues(props); 27881 }); 27882 var Focusable = forwardRef43(function Focusable2(props) { 27883 return createElement5(TagName, useFocusable(props)); 27884 }); 27885 27886 // node_modules/@ariakit/react-components/dist/command/command.js 27887 var import_react19 = __toESM(require_react(), 1); 27888 var TagName2 = "button"; 27889 function isNativeClick(event) { 27890 if (!event.isTrusted) return false; 27891 const element = event.currentTarget; 27892 if (event.key === "Enter") return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "A"; 27893 if (event.key === " ") return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "INPUT" || element.tagName === "SELECT"; 27894 return false; 27895 } 27896 var symbol = /* @__PURE__ */ Symbol("command"); 27897 var useCommand = createHook(function useCommand2({ clickOnEnter = true, clickOnSpace = true, ...props }) { 27898 const ref = (0, import_react19.useRef)(null); 27899 const [isNativeButton, setIsNativeButton] = (0, import_react19.useState)(false); 27900 (0, import_react19.useEffect)(() => { 27901 if (!ref.current) return; 27902 setIsNativeButton(isButton(ref.current)); 27903 }, []); 27904 const [active, setActive] = (0, import_react19.useState)(false); 27905 const activeRef = (0, import_react19.useRef)(false); 27906 const disabled2 = disabledFromProps(props); 27907 const [isDuplicate, metadataProps] = useMetadataProps(props, symbol, true); 27908 useSafeLayoutEffect(() => { 27909 if (!disabled2) return; 27910 activeRef.current = false; 27911 setActive(false); 27912 }, [disabled2]); 27913 const onKeyDownProp = props.onKeyDown; 27914 const onKeyDown = useEvent((event) => { 27915 onKeyDownProp?.(event); 27916 const element = event.currentTarget; 27917 if (event.defaultPrevented) return; 27918 if (isDuplicate) return; 27919 if (disabled2) return; 27920 if (!isSelfTarget(event)) return; 27921 if (isTextField(element)) return; 27922 if (element.isContentEditable) return; 27923 const isEnter = clickOnEnter && event.key === "Enter"; 27924 const isSpace = clickOnSpace && event.key === " "; 27925 const shouldPreventEnter = event.key === "Enter" && !clickOnEnter; 27926 const shouldPreventSpace = event.key === " " && !clickOnSpace; 27927 if (shouldPreventEnter || shouldPreventSpace) { 27928 event.preventDefault(); 27929 return; 27930 } 27931 if (isEnter || isSpace) { 27932 const nativeClick = isNativeClick(event); 27933 if (isEnter) { 27934 if (!nativeClick) { 27935 event.preventDefault(); 27936 const { view, ...eventInit } = event; 27937 const click = () => fireClickEvent(element, eventInit); 27938 if (isFirefox()) queueBeforeEvent(element, "keyup", click); 27939 else queueMicrotask(click); 27940 } 27941 } else if (isSpace) { 27942 activeRef.current = true; 27943 if (!nativeClick) { 27944 event.preventDefault(); 27945 setActive(true); 27946 } 27947 } 27948 } 27949 }); 27950 const onKeyUpProp = props.onKeyUp; 27951 const onKeyUp = useEvent((event) => { 27952 onKeyUpProp?.(event); 27953 if (isDuplicate) return; 27954 const isSpace = clickOnSpace && event.key === " "; 27955 if (!activeRef.current || !isSpace) return; 27956 const nativeClick = isNativeClick(event); 27957 activeRef.current = false; 27958 if (!nativeClick) setActive(false); 27959 if (event.defaultPrevented) return; 27960 if (!isSelfTarget(event)) return; 27961 if (disabled2) return; 27962 if (event.metaKey) return; 27963 if (nativeClick) return; 27964 event.preventDefault(); 27965 const element = event.currentTarget; 27966 const { view, ...eventInit } = event; 27967 queueMicrotask(() => fireClickEvent(element, eventInit)); 27968 }); 27969 const onBlurProp = props.onBlur; 27970 const onBlur = useEvent((event) => { 27971 onBlurProp?.(event); 27972 if (!activeRef.current) return; 27973 activeRef.current = false; 27974 setActive(false); 27975 }); 27976 props = { 27977 "data-active": active || void 0, 27978 type: isNativeButton ? "button" : void 0, 27979 ...metadataProps, 27980 ...props, 27981 ref: useMergeRefs(ref, props.ref), 27982 onKeyDown, 27983 onKeyUp, 27984 onBlur 27985 }; 27986 props = useFocusable(props); 27987 return props; 27988 }); 27989 var Command = forwardRef43(function Command2(props) { 27990 return createElement5(TagName2, useCommand(props)); 27991 }); 27992 27993 // node_modules/@ariakit/react-components/dist/collection/collection-context.js 27994 var ctx2 = createStoreContext(); 27995 var useCollectionContext = ctx2.useContext; 27996 var useCollectionScopedContext = ctx2.useScopedContext; 27997 var useCollectionProviderContext = ctx2.useProviderContext; 27998 var CollectionContextProvider = ctx2.ContextProvider; 27999 var CollectionScopedContextProvider = ctx2.ScopedContextProvider; 28000 28001 // node_modules/@ariakit/react-components/dist/collection/collection-item.js 28002 var import_react20 = __toESM(require_react(), 1); 28003 var TagName3 = "div"; 28004 var useCollectionItem = createHook(function useCollectionItem2({ store: store2, shouldRegisterItem = true, getItem = identity, element, ...props }) { 28005 const context = useCollectionContext(); 28006 store2 = store2 || context; 28007 const id = useId5(props.id); 28008 const ref = (0, import_react20.useRef)(element); 28009 (0, import_react20.useEffect)(() => { 28010 const element2 = ref.current; 28011 if (!id) return; 28012 if (!element2) return; 28013 if (!shouldRegisterItem) return; 28014 const item = getItem({ 28015 id, 28016 element: element2 28017 }); 28018 return store2?.renderItem(item); 28019 }, [ 28020 id, 28021 shouldRegisterItem, 28022 getItem, 28023 store2 28024 ]); 28025 props = { 28026 ...props, 28027 ref: useMergeRefs(ref, props.ref) 28028 }; 28029 return removeUndefinedValues(props); 28030 }); 28031 var CollectionItem = forwardRef43(function CollectionItem2(props) { 28032 return createElement5(TagName3, useCollectionItem(props)); 28033 }); 28034 28035 // node_modules/@ariakit/react-components/dist/composite/composite-context.js 28036 var import_react21 = __toESM(require_react(), 1); 28037 var ctx3 = createStoreContext([CollectionContextProvider], [CollectionScopedContextProvider]); 28038 var useCompositeContext = ctx3.useContext; 28039 var useCompositeScopedContext = ctx3.useScopedContext; 28040 var useCompositeProviderContext = ctx3.useProviderContext; 28041 var CompositeContextProvider = ctx3.ContextProvider; 28042 var CompositeScopedContextProvider = ctx3.ScopedContextProvider; 28043 var CompositeItemContext = (0, import_react21.createContext)(void 0); 28044 var CompositeRowContext = (0, import_react21.createContext)(void 0); 28045 28046 // node_modules/@ariakit/store/dist/index.js 28047 function getInternal(store2, key) { 28048 const internals = store2.__unstableInternals; 28049 invariant(internals, "Invalid store"); 28050 return internals[key]; 28051 } 28052 function hasUpdatedKey(keys, updatedKey) { 28053 if (!keys) return true; 28054 for (const currentKey of keys) if (updatedKey instanceof Set) { 28055 if (updatedKey.has(currentKey)) return true; 28056 } else if (currentKey === updatedKey) return true; 28057 return false; 28058 } 28059 function isSameValue(value, other) { 28060 return value === other || value !== value && other !== other; 28061 } 28062 function getCleanupPrevState(prevState, state, stateBeforeCleanup, updatedKey) { 28063 let cleanupPrevState; 28064 for (const key of getKeys(state)) { 28065 if (isSameValue(state[key], stateBeforeCleanup[key])) continue; 28066 if (updatedKey !== void 0 && hasUpdatedKey([key], updatedKey)) continue; 28067 cleanupPrevState ??= { ...prevState }; 28068 cleanupPrevState[key] = state[key]; 28069 } 28070 return cleanupPrevState; 28071 } 28072 var MAX_REPAIR_PASSES = 100; 28073 function addKeyedListener(map, keys, listener) { 28074 if (!keys) return; 28075 for (const key of keys) { 28076 let listeners = map.get(key); 28077 if (!listeners) { 28078 listeners = /* @__PURE__ */ new Set(); 28079 map.set(key, listeners); 28080 } 28081 listeners.add(listener); 28082 } 28083 } 28084 function deleteKeyedListener(map, keys, listener) { 28085 if (!map) return; 28086 if (!keys) return; 28087 for (const key of keys) { 28088 const listeners = map.get(key); 28089 if (!listeners) continue; 28090 listeners.delete(listener); 28091 if (!listeners.size) map.delete(key); 28092 } 28093 } 28094 function getFastPathNotifiedListeners(frame) { 28095 const notifiedListeners = /* @__PURE__ */ new Set(); 28096 const currentListener = frame.currentListener; 28097 if (!currentListener) return notifiedListeners; 28098 for (const listener of frame.keyedListeners) { 28099 notifiedListeners.add(listener); 28100 if (listener === currentListener) return notifiedListeners; 28101 } 28102 notifiedListeners.clear(); 28103 notifiedListeners.add(currentListener); 28104 return notifiedListeners; 28105 } 28106 function preserveFastPathNotifiedListeners(frame) { 28107 frame.notifiedListeners ??= getFastPathNotifiedListeners(frame); 28108 } 28109 function hasFastPathPassedListener(frame, listener) { 28110 if (!frame.currentListener) return false; 28111 let foundCurrentKeyedListener = false; 28112 for (const currentListener of frame.keyedListeners) { 28113 if (currentListener === frame.currentListener) { 28114 foundCurrentKeyedListener = true; 28115 continue; 28116 } 28117 if (!foundCurrentKeyedListener) continue; 28118 if (currentListener === listener) return false; 28119 } 28120 let foundListener = false; 28121 for (const currentListener of frame.group.listeners) { 28122 if (currentListener === frame.currentListener) return foundListener; 28123 if (currentListener === listener) foundListener = true; 28124 } 28125 return false; 28126 } 28127 function preserveFastPathFrames(fastPathFrames, group, listener) { 28128 for (const frame of fastPathFrames) { 28129 if (frame.group !== group) continue; 28130 if (frame.recovering) continue; 28131 if (listener && !frame.keyedListeners.has(listener)) continue; 28132 preserveFastPathNotifiedListeners(frame); 28133 for (const currentListener of frame.group.listeners) { 28134 if (currentListener === frame.currentListener) break; 28135 if (!hasFastPathPassedListener(frame, currentListener)) continue; 28136 frame.notifiedListeners?.add(currentListener); 28137 } 28138 } 28139 } 28140 function preserveFastPathPassedListeners(fastPathFrames, group, listener) { 28141 for (const frame of fastPathFrames) { 28142 if (frame.group !== group) continue; 28143 if (frame.recovering) continue; 28144 if (!hasFastPathPassedListener(frame, listener)) continue; 28145 preserveFastPathNotifiedListeners(frame); 28146 frame.notifiedListeners?.add(listener); 28147 } 28148 } 28149 function preserveFastPathPassedKeyedListeners({ fastPathFrames, group, keys, listener }) { 28150 const wasRegistered = group.listeners.has(listener); 28151 for (const frame of fastPathFrames) { 28152 if (frame.group !== group) continue; 28153 if (frame.recovering) continue; 28154 if (!keys.includes(frame.updatedKey)) continue; 28155 if (hasFastPathPassedListener(frame, listener)) { 28156 preserveFastPathNotifiedListeners(frame); 28157 frame.notifiedListeners?.add(listener); 28158 } else if (wasRegistered) { 28159 preserveFastPathNotifiedListeners(frame); 28160 frame.recoverToLive = true; 28161 } 28162 } 28163 } 28164 function clearFastPathNotifiedListener(fastPathFrames, group, listener) { 28165 for (const frame of fastPathFrames) { 28166 if (frame.group !== group) continue; 28167 frame.notifiedListeners?.delete(listener); 28168 } 28169 } 28170 function addFastPathKeyedListener({ fastPathFrames, group, keys, listener }) { 28171 for (const frame of fastPathFrames) { 28172 if (frame.group !== group) continue; 28173 if (frame.recovering) continue; 28174 if (!keys.includes(frame.updatedKey)) continue; 28175 frame.keyedListeners.add(listener); 28176 } 28177 } 28178 function runPendingCleanup(group, listener) { 28179 if (!group.disposables.size) return; 28180 const cleanup = group.disposables.get(listener); 28181 if (!cleanup) return; 28182 group.disposables.delete(listener); 28183 cleanup(); 28184 } 28185 function setListenerCleanup(group, listener, cleanup) { 28186 const currentCleanup = group.disposables.get(listener); 28187 if (!currentCleanup) { 28188 group.disposables.set(listener, cleanup); 28189 return; 28190 } 28191 group.disposables.set(listener, () => { 28192 currentCleanup(); 28193 cleanup(); 28194 }); 28195 } 28196 function notifyStoreListener(group, listener, state, prevState, getState, updatedKey) { 28197 if (group.suspendCounts?.has(listener)) return; 28198 const { disposables } = group; 28199 const cleanup = disposables.size ? disposables.get(listener) : void 0; 28200 if (cleanup) { 28201 disposables.delete(listener); 28202 const stateBeforeCleanup = state; 28203 cleanup(); 28204 state = getState?.() ?? state; 28205 if (state !== stateBeforeCleanup) prevState = getCleanupPrevState(prevState, state, stateBeforeCleanup, updatedKey) ?? prevState; 28206 } 28207 const result = listener(state, prevState); 28208 if (result) setListenerCleanup(group, listener, result); 28209 } 28210 function runLiveListeners({ group, getState, prevState, updatedKey, notifiedListeners }) { 28211 const allKeysListeners = group.allKeysListeners; 28212 for (const listener of group.listeners) { 28213 if (notifiedListeners?.has(listener)) continue; 28214 if (!allKeysListeners?.has(listener)) { 28215 if (!hasUpdatedKey(group.listenerKeys.get(listener), updatedKey)) continue; 28216 } 28217 notifiedListeners?.add(listener); 28218 notifyStoreListener(group, listener, getState(), prevState, getState, updatedKey); 28219 } 28220 } 28221 function createStore(initialState, ...stores) { 28222 let state = initialState; 28223 let prevStateBatch = state; 28224 let destroy = noop5; 28225 let batchPending = false; 28226 let inDispatch = false; 28227 let updatedKeys = /* @__PURE__ */ new Set(); 28228 const instances = /* @__PURE__ */ new Set(); 28229 const setups = /* @__PURE__ */ new Set(); 28230 const syncListenerGroup = { 28231 listeners: /* @__PURE__ */ new Set(), 28232 disposables: /* @__PURE__ */ new Map(), 28233 listenerKeys: /* @__PURE__ */ new WeakMap() 28234 }; 28235 const batchListenerGroup = { 28236 listeners: /* @__PURE__ */ new Set(), 28237 disposables: /* @__PURE__ */ new Map(), 28238 listenerKeys: /* @__PURE__ */ new WeakMap() 28239 }; 28240 const storeSetup = (callback) => { 28241 setups.add(callback); 28242 return () => setups.delete(callback); 28243 }; 28244 const storeInit = () => { 28245 const initializedInstances = instances.size; 28246 const instance = /* @__PURE__ */ Symbol(); 28247 instances.add(instance); 28248 const maybeDestroy = () => { 28249 if (!instances.delete(instance)) return; 28250 if (instances.size) return; 28251 destroy(); 28252 }; 28253 if (initializedInstances) return maybeDestroy; 28254 const stateKeys = getKeys(state); 28255 const desyncs = []; 28256 for (const store2 of stores) { 28257 const storeState = store2?.getState?.(); 28258 if (!storeState) continue; 28259 const keys = stateKeys.filter((key) => hasOwnProperty(storeState, key)); 28260 if (!keys.length) continue; 28261 if (stores.length === 1 || keys.length === stateKeys.length) { 28262 for (const key of keys) desyncs.push(sync2(store2, [key], (state2) => { 28263 setState(key, state2[key], true); 28264 })); 28265 continue; 28266 } 28267 desyncs.push(subscribe2(store2, keys, (state2, prevState) => { 28268 for (const key of keys) { 28269 if (state2[key] === prevState[key]) continue; 28270 setState(key, state2[key], true); 28271 } 28272 })); 28273 for (const key of keys) { 28274 const liveState = store2?.getState?.(); 28275 if (!liveState) continue; 28276 setState(key, liveState[key], true); 28277 } 28278 } 28279 const teardowns = []; 28280 for (const setup2 of setups) teardowns.push(setup2()); 28281 const cleanups = stores.map(init); 28282 destroy = chain(...desyncs, ...teardowns, ...cleanups); 28283 return maybeDestroy; 28284 }; 28285 const deleteListenerIndexes = (group, listener, keys) => { 28286 if (keys === void 0) return; 28287 if (keys) deleteKeyedListener(group.listenersByKey, keys, listener); 28288 else group.allKeysListeners?.delete(listener); 28289 }; 28290 const fastPathFrames = []; 28291 const registerListener = (keys, listener, group = syncListenerGroup) => { 28292 const listenerKeysValue = keys ? [...keys] : null; 28293 const wasRegistered = group.listeners.has(listener); 28294 if (!wasRegistered) clearFastPathNotifiedListener(fastPathFrames, group, listener); 28295 if (!listenerKeysValue) { 28296 if (wasRegistered) preserveFastPathFrames(fastPathFrames, group); 28297 preserveFastPathPassedListeners(fastPathFrames, group, listener); 28298 } else preserveFastPathPassedKeyedListeners({ 28299 fastPathFrames, 28300 group, 28301 keys: listenerKeysValue, 28302 listener 28303 }); 28304 if (wasRegistered) { 28305 preserveFastPathFrames(fastPathFrames, group, listener); 28306 deleteListenerIndexes(group, listener, group.listenerKeys.get(listener)); 28307 } 28308 group.listeners.add(listener); 28309 if (listenerKeysValue) { 28310 group.listenersByKey ??= /* @__PURE__ */ new Map(); 28311 addKeyedListener(group.listenersByKey, listenerKeysValue, listener); 28312 addFastPathKeyedListener({ 28313 fastPathFrames, 28314 group, 28315 keys: listenerKeysValue, 28316 listener 28317 }); 28318 } else { 28319 group.allKeysListeners ??= /* @__PURE__ */ new Set(); 28320 group.allKeysListeners.add(listener); 28321 } 28322 group.listenerKeys.set(listener, listenerKeysValue); 28323 return () => { 28324 const cleanup = group.disposables.get(listener); 28325 group.disposables.delete(listener); 28326 preserveFastPathFrames(fastPathFrames, group, listener); 28327 const currentKeys = group.listenerKeys.get(listener); 28328 deleteListenerIndexes(group, listener, listenerKeysValue); 28329 if (currentKeys !== listenerKeysValue) deleteListenerIndexes(group, listener, currentKeys); 28330 group.listenerKeys.delete(listener); 28331 group.listeners.delete(listener); 28332 cleanup?.(); 28333 }; 28334 }; 28335 const storeSubscribe = (keys, listener) => registerListener(keys, listener); 28336 const runInitialListener = (group, listener, prevState) => { 28337 const shouldSuspend = group.listeners.has(listener); 28338 if (shouldSuspend) { 28339 group.suspendCounts ??= /* @__PURE__ */ new Map(); 28340 const count = group.suspendCounts.get(listener) ?? 0; 28341 group.suspendCounts.set(listener, count + 1); 28342 } 28343 let cleanupPrevState; 28344 try { 28345 const stateBeforeCleanups = state; 28346 runPendingCleanup(group, listener); 28347 if (state !== stateBeforeCleanups) cleanupPrevState = getCleanupPrevState(prevState, state, stateBeforeCleanups); 28348 const cleanup = listener(state, cleanupPrevState ?? prevState); 28349 if (cleanup) setListenerCleanup(group, listener, cleanup); 28350 } finally { 28351 if (shouldSuspend) { 28352 const suspendCounts = group.suspendCounts; 28353 const count = suspendCounts?.get(listener); 28354 if (count && count > 1) suspendCounts?.set(listener, count - 1); 28355 else suspendCounts?.delete(listener); 28356 if (!suspendCounts?.size) delete group.suspendCounts; 28357 } 28358 } 28359 }; 28360 const storeSync = (keys, listener) => { 28361 runInitialListener(syncListenerGroup, listener, state); 28362 return registerListener(keys, listener); 28363 }; 28364 const storeBatch = (keys, listener) => { 28365 if (!batchListenerGroup.listeners.size && !inDispatch) prevStateBatch = state; 28366 runInitialListener(batchListenerGroup, listener, prevStateBatch); 28367 return registerListener(keys, listener, batchListenerGroup); 28368 }; 28369 const storePick = (keys) => createStore(pick(state, keys), finalStore); 28370 const storeOmit = (keys) => createStore(omit(state, keys), finalStore); 28371 const getState = () => state; 28372 const runListeners = (group, prevState, updatedKey) => { 28373 if (!(updatedKey instanceof Set) && !group.allKeysListeners?.size) { 28374 const keyedListeners = group.listenersByKey?.get(updatedKey); 28375 if (!keyedListeners) return; 28376 const frame = { 28377 group, 28378 keyedListeners, 28379 updatedKey, 28380 currentListener: null 28381 }; 28382 fastPathFrames.push(frame); 28383 try { 28384 for (const listener of keyedListeners) { 28385 if (frame.notifiedListeners?.has(listener)) continue; 28386 frame.currentListener = listener; 28387 frame.notifiedListeners?.add(listener); 28388 notifyStoreListener(group, listener, state, prevState, getState, updatedKey); 28389 if (!group.allKeysListeners?.size && !frame.recoverToLive) continue; 28390 const notifiedListeners = frame.notifiedListeners ?? getFastPathNotifiedListeners(frame); 28391 frame.notifiedListeners = notifiedListeners; 28392 frame.recovering = true; 28393 runLiveListeners({ 28394 group, 28395 getState, 28396 prevState, 28397 updatedKey, 28398 notifiedListeners 28399 }); 28400 return; 28401 } 28402 } finally { 28403 fastPathFrames.pop(); 28404 } 28405 return; 28406 } 28407 runLiveListeners({ 28408 group, 28409 getState, 28410 prevState, 28411 updatedKey 28412 }); 28413 }; 28414 const setState = (key, value, fromStores = false) => { 28415 if (!hasOwnProperty(state, key)) return; 28416 const currentValue = state[key]; 28417 const nextValue = typeof value === "function" ? value(currentValue) : value; 28418 if (isSameValue(nextValue, currentValue)) return; 28419 const wasInDispatch = inDispatch; 28420 inDispatch = true; 28421 const prevState = state; 28422 const nextState = { 28423 ...state, 28424 [key]: nextValue 28425 }; 28426 state = nextState; 28427 let superseded = false; 28428 try { 28429 if (!fromStores && stores.length) { 28430 for (const store2 of stores) { 28431 store2?.setState?.(key, nextValue); 28432 if (isSameValue(state[key], nextValue)) continue; 28433 superseded = true; 28434 break; 28435 } 28436 if (superseded) { 28437 let pass = 0; 28438 for (; pass < MAX_REPAIR_PASSES; pass += 1) { 28439 let changed = false; 28440 for (const store2 of stores) { 28441 const previousValue = state[key]; 28442 store2?.setState?.(key, previousValue); 28443 if (!isSameValue(state[key], previousValue)) changed = true; 28444 } 28445 if (!changed) break; 28446 } 28447 if (pass === MAX_REPAIR_PASSES) console.warn("Parent stores did not converge after a superseded fan-out; a parent listener may be rewriting this key in a cycle."); 28448 } 28449 } 28450 if (!superseded) runListeners(syncListenerGroup, state === nextState ? prevState : { 28451 ...state, 28452 [key]: prevState[key] 28453 }, key); 28454 } finally { 28455 inDispatch = wasInDispatch; 28456 } 28457 if (!batchListenerGroup.listeners.size) { 28458 if (!inDispatch) prevStateBatch = state; 28459 return; 28460 } 28461 updatedKeys.add(key); 28462 if (batchPending) return; 28463 batchPending = true; 28464 queueMicrotask(() => { 28465 batchPending = false; 28466 const snapshot = state; 28467 const updatedKeysSnapshot = updatedKeys; 28468 updatedKeys = /* @__PURE__ */ new Set(); 28469 const prevStateBatchBefore = prevStateBatch; 28470 runListeners(batchListenerGroup, prevStateBatchBefore, updatedKeysSnapshot); 28471 if (prevStateBatch === prevStateBatchBefore) prevStateBatch = snapshot; 28472 }); 28473 }; 28474 const finalStore = { 28475 getState, 28476 setState, 28477 __unstableInternals: { 28478 setup: storeSetup, 28479 init: storeInit, 28480 subscribe: storeSubscribe, 28481 sync: storeSync, 28482 batch: storeBatch, 28483 pick: storePick, 28484 omit: storeOmit 28485 } 28486 }; 28487 return finalStore; 28488 } 28489 function setup(store2, ...args) { 28490 if (!store2) return; 28491 return getInternal(store2, "setup")(...args); 28492 } 28493 function init(store2, ...args) { 28494 if (!store2) return; 28495 return getInternal(store2, "init")(...args); 28496 } 28497 function subscribe2(store2, ...args) { 28498 if (!store2) return; 28499 return getInternal(store2, "subscribe")(...args); 28500 } 28501 function sync2(store2, ...args) { 28502 if (!store2) return; 28503 return getInternal(store2, "sync")(...args); 28504 } 28505 function batch(store2, ...args) { 28506 if (!store2) return; 28507 return getInternal(store2, "batch")(...args); 28508 } 28509 function omit2(store2, ...args) { 28510 if (!store2) return; 28511 return getInternal(store2, "omit")(...args); 28512 } 28513 function pick2(store2, ...args) { 28514 if (!store2) return; 28515 return getInternal(store2, "pick")(...args); 28516 } 28517 function mergeStore(...stores) { 28518 const initialState = {}; 28519 for (const store3 of stores) { 28520 const nextState = store3?.getState?.(); 28521 if (nextState) Object.assign(initialState, nextState); 28522 } 28523 const store2 = createStore(initialState, ...stores); 28524 return Object.assign({}, ...stores, store2); 28525 } 28526 function throwOnConflictingProps(props, store2) { 28527 if (false) return; 28528 if (!store2) return; 28529 const defaultKeys = Object.entries(props).filter(([key, value]) => key.startsWith("default") && value !== void 0).map(([key]) => { 28530 const stateKey = key.replace("default", ""); 28531 return `$stateKey[0]?.toLowerCase() || ""}$stateKey.slice(1)}`; 28532 }); 28533 if (!defaultKeys.length) return; 28534 const storeState = store2.getState(); 28535 if (!defaultKeys.filter((key) => hasOwnProperty(storeState, key)).length) return; 28536 throw new Error(`Passing a store prop in conjunction with a default state is not supported. 28537 28538 const store = useSelectStore(); 28539 <SelectProvider store={store} defaultValue="Apple" /> 28540 ^ ^ 28541 28542 Instead, pass the default state to the topmost store: 28543 28544 const store = useSelectStore({ defaultValue: "Apple" }); 28545 <SelectProvider store={store} /> 28546 28547 See https://github.com/ariakit/ariakit/pull/2745 for more details. 28548 28549 If there's a particular need for this, please submit a feature request at https://github.com/ariakit/ariakit 28550 `); 28551 } 28552 28553 // node_modules/@ariakit/components/dist/collection/collection-store.js 28554 function getCommonParent(items) { 28555 const firstItem = items.find((item) => !!item.element); 28556 const lastElement = [...items].reverse().find((item) => !!item.element)?.element; 28557 let parentElement = firstItem?.element?.parentElement; 28558 if (!lastElement) return getDocument(parentElement).body; 28559 while (parentElement) { 28560 if (parentElement.contains(lastElement)) return parentElement; 28561 parentElement = parentElement.parentElement; 28562 } 28563 return getDocument(parentElement).body; 28564 } 28565 function getPrivateStore(store2) { 28566 return store2?.__unstablePrivateStore; 28567 } 28568 function createCollectionStore(props = {}) { 28569 throwOnConflictingProps(props, props.store); 28570 const syncState = props.store?.getState(); 28571 const items = defaultValue(props.items, syncState?.items, props.defaultItems, []); 28572 const itemsMap = new Map(items.map((item) => [item.id, item])); 28573 const initialState = { 28574 items, 28575 renderedItems: defaultValue(syncState?.renderedItems, []) 28576 }; 28577 const syncPrivateStore = getPrivateStore(props.store); 28578 const privateStore = createStore({ 28579 items, 28580 renderedItems: initialState.renderedItems 28581 }, syncPrivateStore); 28582 const collection = createStore(initialState, props.store); 28583 const sortItems = (renderedItems) => { 28584 const sortedItems = sortBasedOnDOMPosition(renderedItems, (i2) => i2.element); 28585 privateStore.setState("renderedItems", sortedItems); 28586 collection.setState("renderedItems", sortedItems); 28587 }; 28588 setup(collection, () => init(privateStore)); 28589 setup(privateStore, () => { 28590 return batch(privateStore, ["items"], (state) => { 28591 collection.setState("items", state.items); 28592 }); 28593 }); 28594 setup(privateStore, () => { 28595 return batch(privateStore, ["renderedItems"], (state) => { 28596 let firstRun = true; 28597 let raf2 = requestAnimationFrame(() => { 28598 const { renderedItems } = collection.getState(); 28599 if (state.renderedItems === renderedItems) return; 28600 sortItems(state.renderedItems); 28601 }); 28602 if (typeof IntersectionObserver !== "function") return () => cancelAnimationFrame(raf2); 28603 const ioCallback = () => { 28604 if (firstRun) { 28605 firstRun = false; 28606 return; 28607 } 28608 cancelAnimationFrame(raf2); 28609 raf2 = requestAnimationFrame(() => sortItems(state.renderedItems)); 28610 }; 28611 const root = getCommonParent(state.renderedItems); 28612 const observer = new IntersectionObserver(ioCallback, { root }); 28613 for (const item of state.renderedItems) { 28614 if (!item.element) continue; 28615 observer.observe(item.element); 28616 } 28617 return () => { 28618 cancelAnimationFrame(raf2); 28619 observer.disconnect(); 28620 }; 28621 }); 28622 }); 28623 const mergeItem = (item, setItems, canDeleteFromMap = false) => { 28624 let prevItem; 28625 setItems((items2) => { 28626 const index2 = items2.findIndex(({ id }) => id === item.id); 28627 const nextItems = items2.slice(); 28628 if (index2 !== -1) { 28629 prevItem = items2[index2]; 28630 const nextItem = { 28631 ...prevItem, 28632 ...item 28633 }; 28634 nextItems[index2] = nextItem; 28635 itemsMap.set(item.id, nextItem); 28636 } else { 28637 nextItems.push(item); 28638 itemsMap.set(item.id, item); 28639 } 28640 return nextItems; 28641 }); 28642 const unmergeItem = () => { 28643 setItems((items2) => { 28644 if (!prevItem) { 28645 if (canDeleteFromMap) itemsMap.delete(item.id); 28646 return items2.filter(({ id }) => id !== item.id); 28647 } 28648 const index2 = items2.findIndex(({ id }) => id === item.id); 28649 if (index2 === -1) return items2; 28650 const nextItems = items2.slice(); 28651 nextItems[index2] = prevItem; 28652 itemsMap.set(item.id, prevItem); 28653 return nextItems; 28654 }); 28655 }; 28656 return unmergeItem; 28657 }; 28658 const registerItem = (item) => mergeItem(item, (getItems) => privateStore.setState("items", getItems), true); 28659 return { 28660 ...collection, 28661 registerItem, 28662 renderItem: (item) => chain(registerItem(item), mergeItem(item, (getItems) => privateStore.setState("renderedItems", getItems))), 28663 item: (id) => { 28664 if (!id) return null; 28665 let item = itemsMap.get(id); 28666 if (!item) { 28667 const { items: items2 } = privateStore.getState(); 28668 item = items2.find((item2) => item2.id === id); 28669 if (item) itemsMap.set(id, item); 28670 } 28671 return item || null; 28672 }, 28673 __unstablePrivateStore: privateStore 28674 }; 28675 } 28676 28677 // node_modules/@ariakit/components/dist/composite/composite-store.js 28678 var NULL_ITEM = { id: null }; 28679 function findFirstEnabledItem(items, excludeId) { 28680 return items.find((item) => { 28681 if (excludeId) return !item.disabled && item.id !== excludeId; 28682 return !item.disabled; 28683 }); 28684 } 28685 function getEnabledItems(items, excludeId) { 28686 return items.filter((item) => { 28687 if (excludeId) return !item.disabled && item.id !== excludeId; 28688 return !item.disabled; 28689 }); 28690 } 28691 function getItemsInRow(items, rowId) { 28692 return items.filter((item) => item.rowId === rowId); 28693 } 28694 function findEnabledItemId({ items, fromIndex, step, rowId, excludeId }) { 28695 for (let i2 = fromIndex; i2 >= 0 && i2 < items.length; i2 += step) { 28696 const item = items[i2]; 28697 if (!item) continue; 28698 if (item.rowId !== rowId) continue; 28699 if (item.disabled) continue; 28700 if (excludeId != null && item.id === excludeId) continue; 28701 return item.id; 28702 } 28703 } 28704 function flipItems(items, activeId, shouldInsertNullItem = false) { 28705 const index2 = items.findIndex((item) => item.id === activeId); 28706 return [ 28707 ...items.slice(index2 + 1), 28708 ...shouldInsertNullItem ? [NULL_ITEM] : [], 28709 ...items.slice(0, index2) 28710 ]; 28711 } 28712 function groupItemsByRows(items) { 28713 const rows = []; 28714 for (const item of items) { 28715 const row = rows.find((currentRow) => currentRow[0]?.rowId === item.rowId); 28716 if (row) row.push(item); 28717 else rows.push([item]); 28718 } 28719 return rows; 28720 } 28721 function getMaxRowLength(array) { 28722 let maxLength = 0; 28723 for (const { length } of array) if (length > maxLength) maxLength = length; 28724 return maxLength; 28725 } 28726 function createEmptyItem(rowId) { 28727 return { 28728 id: "__EMPTY_ITEM__", 28729 disabled: true, 28730 rowId 28731 }; 28732 } 28733 function normalizeRows(rows, activeId, focusShift) { 28734 const maxLength = getMaxRowLength(rows); 28735 for (const row of rows) for (let i2 = 0; i2 < maxLength; i2 += 1) { 28736 const item = row[i2]; 28737 if (!item || focusShift && item.disabled) { 28738 const previousItem = i2 === 0 && focusShift ? findFirstEnabledItem(row) : row[i2 - 1]; 28739 row[i2] = previousItem && activeId !== previousItem.id && focusShift ? previousItem : createEmptyItem(previousItem?.rowId); 28740 } 28741 } 28742 return rows; 28743 } 28744 function verticalizeItems(items) { 28745 const rows = groupItemsByRows(items); 28746 const maxLength = getMaxRowLength(rows); 28747 const verticalized = []; 28748 for (let i2 = 0; i2 < maxLength; i2 += 1) for (const row of rows) { 28749 const item = row[i2]; 28750 if (item) verticalized.push({ 28751 ...item, 28752 rowId: item.rowId ? `$i2}` : void 0 28753 }); 28754 } 28755 return verticalized; 28756 } 28757 function createCompositeStore(props = {}) { 28758 const syncState = props.store?.getState(); 28759 const collection = createCollectionStore(props); 28760 const activeId = defaultValue(props.activeId, syncState?.activeId, props.defaultActiveId); 28761 const composite = createStore({ 28762 ...collection.getState(), 28763 id: defaultValue(props.id, syncState?.id) ?? `id-$Math.random().toString(36).slice(2, 8)}`, 28764 activeId, 28765 baseElement: defaultValue(syncState?.baseElement, null), 28766 includesBaseElement: defaultValue(props.includesBaseElement, syncState?.includesBaseElement, activeId === null), 28767 moves: defaultValue(syncState?.moves, 0), 28768 orientation: defaultValue(props.orientation, syncState?.orientation, "both"), 28769 rtl: defaultValue(props.rtl, syncState?.rtl, false), 28770 virtualFocus: defaultValue(props.virtualFocus, syncState?.virtualFocus, false), 28771 focusLoop: defaultValue(props.focusLoop, syncState?.focusLoop, false), 28772 focusWrap: defaultValue(props.focusWrap, syncState?.focusWrap, false), 28773 focusShift: defaultValue(props.focusShift, syncState?.focusShift, false) 28774 }, collection, props.store); 28775 setup(composite, () => sync2(composite, ["renderedItems", "activeId"], (state) => { 28776 composite.setState("activeId", (activeId2) => { 28777 if (activeId2 !== void 0) return activeId2; 28778 return findFirstEnabledItem(state.renderedItems)?.id; 28779 }); 28780 })); 28781 const getNextId = (direction = "next", options = {}) => { 28782 const defaultState = composite.getState(); 28783 const { skip = 0, activeId: activeId2 = defaultState.activeId, focusShift = defaultState.focusShift, focusLoop = defaultState.focusLoop, focusWrap = defaultState.focusWrap, includesBaseElement = defaultState.includesBaseElement, renderedItems = defaultState.renderedItems, rtl = defaultState.rtl } = options; 28784 const isVerticalDirection = direction === "up" || direction === "down"; 28785 const isNextDirection = direction === "next" || direction === "down"; 28786 const canReverse = isNextDirection ? rtl && !isVerticalDirection : !rtl || isVerticalDirection; 28787 const canShift = focusShift && !skip; 28788 if (!skip && !focusWrap && !includesBaseElement && activeId2 != null) { 28789 if (!isVerticalDirection ? true : !canShift && !renderedItems.some((item) => item.rowId != null)) { 28790 const activeIndex2 = renderedItems.findIndex((item) => item.id === activeId2); 28791 const activeItem2 = renderedItems[activeIndex2]; 28792 if (activeItem2) { 28793 const step = canReverse ? -1 : 1; 28794 const nextId2 = findEnabledItemId({ 28795 items: renderedItems, 28796 fromIndex: activeIndex2 + step, 28797 step, 28798 rowId: activeItem2.rowId, 28799 excludeId: activeId2 28800 }); 28801 if (nextId2 !== void 0) return nextId2; 28802 if (!(focusLoop && (isVerticalDirection ? focusLoop !== "horizontal" : focusLoop !== "vertical"))) return void 0; 28803 return findEnabledItemId({ 28804 items: renderedItems, 28805 fromIndex: step === 1 ? 0 : renderedItems.length - 1, 28806 step, 28807 rowId: activeItem2.rowId, 28808 excludeId: activeId2 28809 }); 28810 } 28811 } 28812 } 28813 let items = !isVerticalDirection ? renderedItems : flatten2DArray(normalizeRows(groupItemsByRows(renderedItems), activeId2, canShift)); 28814 items = canReverse ? reverseArray(items) : items; 28815 items = isVerticalDirection ? verticalizeItems(items) : items; 28816 if (activeId2 == null) return findFirstEnabledItem(items)?.id; 28817 const activeItem = items.find((item) => item.id === activeId2); 28818 if (!activeItem) return findFirstEnabledItem(items)?.id; 28819 const isGrid2 = items.some((item) => item.rowId); 28820 const activeIndex = items.indexOf(activeItem); 28821 const nextItems = items.slice(activeIndex + 1); 28822 const nextItemsInRow = getItemsInRow(nextItems, activeItem.rowId); 28823 if (skip) { 28824 const nextEnabledItemsInRow = getEnabledItems(nextItemsInRow, activeId2); 28825 return (nextEnabledItemsInRow.slice(skip)[0] || nextEnabledItemsInRow[nextEnabledItemsInRow.length - 1])?.id; 28826 } 28827 const canLoop = focusLoop && (isVerticalDirection ? focusLoop !== "horizontal" : focusLoop !== "vertical"); 28828 const canWrap = isGrid2 && focusWrap && (isVerticalDirection ? focusWrap !== "horizontal" : focusWrap !== "vertical"); 28829 const hasNullItem = isNextDirection ? (!isGrid2 || isVerticalDirection) && canLoop && includesBaseElement : isVerticalDirection ? includesBaseElement : false; 28830 if (canLoop) return findFirstEnabledItem(flipItems(canWrap && !hasNullItem ? items : getItemsInRow(items, activeItem.rowId), activeId2, hasNullItem), activeId2)?.id; 28831 if (canWrap) { 28832 const nextItem2 = findFirstEnabledItem(hasNullItem ? nextItemsInRow : nextItems, activeId2); 28833 return hasNullItem ? nextItem2?.id || null : nextItem2?.id; 28834 } 28835 const nextItem = findFirstEnabledItem(nextItemsInRow, activeId2); 28836 if (!nextItem && hasNullItem) return null; 28837 return nextItem?.id; 28838 }; 28839 const getNextIdFromOptions = (direction, options) => { 28840 if (typeof options === "number") return getNextId(direction, { skip: options }); 28841 return getNextId(direction, options); 28842 }; 28843 return { 28844 ...collection, 28845 ...composite, 28846 setBaseElement: (element) => composite.setState("baseElement", element), 28847 setActiveId: (id) => composite.setState("activeId", id), 28848 move: (id) => { 28849 if (id === void 0) return; 28850 composite.setState("activeId", id); 28851 composite.setState("moves", (moves) => moves + 1); 28852 }, 28853 first: () => findFirstEnabledItem(composite.getState().renderedItems)?.id, 28854 last: () => findFirstEnabledItem(reverseArray(composite.getState().renderedItems))?.id, 28855 next: (options) => getNextIdFromOptions("next", options), 28856 previous: (options) => getNextIdFromOptions("previous", options), 28857 down: (options) => getNextIdFromOptions("down", options), 28858 up: (options) => getNextIdFromOptions("up", options) 28859 }; 28860 } 28861 28862 // node_modules/@ariakit/react-components/dist/composite/utils.js 28863 var findFirstEnabledItem2 = findFirstEnabledItem; 28864 var groupItemsByRows2 = groupItemsByRows; 28865 function getEnabledItem(store2, id) { 28866 if (!id) return null; 28867 return store2.item(id) || null; 28868 } 28869 function selectTextField(element, collapseToEnd = false) { 28870 if (isTextField(element)) element.setSelectionRange(collapseToEnd ? element.value.length : 0, element.value.length); 28871 else if (element.isContentEditable) { 28872 const selection = getDocument(element).getSelection(); 28873 selection?.selectAllChildren(element); 28874 if (collapseToEnd) selection?.collapseToEnd(); 28875 } 28876 } 28877 var FOCUS_SILENTLY = /* @__PURE__ */ Symbol("FOCUS_SILENTLY"); 28878 function focusSilently(element) { 28879 element[FOCUS_SILENTLY] = true; 28880 element.focus({ preventScroll: true }); 28881 } 28882 function silentlyFocused(element) { 28883 const isSilentlyFocused = element[FOCUS_SILENTLY]; 28884 delete element[FOCUS_SILENTLY]; 28885 return isSilentlyFocused; 28886 } 28887 function isItem(store2, element, exclude) { 28888 if (!element) return false; 28889 if (element === exclude) return false; 28890 const item = store2.item(element.id); 28891 if (!item) return false; 28892 if (exclude && item.element === exclude) return false; 28893 return true; 28894 } 28895 28896 // node_modules/@ariakit/react-components/dist/composite/composite-item.js 28897 var import_react22 = __toESM(require_react(), 1); 28898 var import_jsx_runtime149 = __toESM(require_jsx_runtime(), 1); 28899 28900 // node_modules/@ariakit/react-store/dist/index.js 28901 var React60 = __toESM(require_react(), 1); 28902 var import_shim2 = __toESM(require_shim(), 1); 28903 var noopSubscribe = () => () => { 28904 }; 28905 function useStoreState(store2, keyOrSelector = identity) { 28906 const storeSubscribe = React60.useCallback((callback) => { 28907 if (!store2) return noopSubscribe(); 28908 return subscribe2(store2, null, callback); 28909 }, [store2]); 28910 const getSnapshot = () => { 28911 const key = typeof keyOrSelector === "string" ? keyOrSelector : null; 28912 const selector2 = typeof keyOrSelector === "function" ? keyOrSelector : null; 28913 const state = store2?.getState(); 28914 if (selector2) return selector2(state); 28915 if (!state) return; 28916 if (!key) return; 28917 if (!hasOwnProperty(state, key)) return; 28918 return state[key]; 28919 }; 28920 return (0, import_shim2.useSyncExternalStore)(storeSubscribe, getSnapshot, getSnapshot); 28921 } 28922 function useStoreStateObject(store2, object) { 28923 const objRef = React60.useRef({}); 28924 const storeSubscribe = React60.useCallback((callback) => { 28925 if (!store2) return noopSubscribe(); 28926 return subscribe2(store2, null, callback); 28927 }, [store2]); 28928 const getSnapshot = () => { 28929 const state = store2?.getState(); 28930 let updated = false; 28931 const obj = objRef.current; 28932 for (const prop in object) { 28933 const keyOrSelector = object[prop]; 28934 if (typeof keyOrSelector === "function") { 28935 const value = keyOrSelector(state); 28936 if (!Object.is(value, obj[prop])) { 28937 obj[prop] = value; 28938 updated = true; 28939 } 28940 } 28941 if (typeof keyOrSelector === "string") { 28942 if (!state) continue; 28943 if (!hasOwnProperty(state, keyOrSelector)) continue; 28944 const value = state[keyOrSelector]; 28945 if (!Object.is(value, obj[prop])) { 28946 obj[prop] = value; 28947 updated = true; 28948 } 28949 } 28950 } 28951 if (updated) objRef.current = { ...obj }; 28952 return objRef.current; 28953 }; 28954 return (0, import_shim2.useSyncExternalStore)(storeSubscribe, getSnapshot, getSnapshot); 28955 } 28956 function useStoreProps(store2, props, key, setKey) { 28957 const value = hasOwnProperty(props, key) ? props[key] : void 0; 28958 const propsRef = useLiveRef({ 28959 value, 28960 setValue: setKey ? props[setKey] : void 0 28961 }); 28962 useSafeLayoutEffect(() => { 28963 return sync2(store2, [key], (state, prev) => { 28964 const { value: value2, setValue } = propsRef.current; 28965 if (!setValue) return; 28966 if (state[key] === prev[key]) return; 28967 if (state[key] === value2) return; 28968 setValue(state[key]); 28969 }); 28970 }, [store2, key]); 28971 useSafeLayoutEffect(() => { 28972 if (value === void 0) return; 28973 store2.setState(key, value); 28974 return batch(store2, [key], () => { 28975 if (value === void 0) return; 28976 store2.setState(key, value); 28977 }); 28978 }); 28979 } 28980 function useStore2(createStore2, props) { 28981 const [store2, setStore] = React60.useState(() => createStore2(props)); 28982 useSafeLayoutEffect(() => init(store2), [store2]); 28983 const useState88 = React60.useCallback((keyOrSelector) => useStoreState(store2, keyOrSelector), [store2]); 28984 return [React60.useMemo(() => ({ 28985 ...store2, 28986 useState: useState88 28987 }), [store2, useState88]), useEvent(() => { 28988 setStore((store3) => createStore2({ 28989 ...props, 28990 ...store3.getState() 28991 })); 28992 })]; 28993 } 28994 28995 // node_modules/@ariakit/react-components/dist/composite/composite-item.js 28996 var TagName4 = "button"; 28997 function isEditableElement(element) { 28998 if (isTextbox(element)) return true; 28999 return element.tagName === "INPUT" && !isButton(element); 29000 } 29001 function getNextPageOffset(scrollingElement, pageUp = false) { 29002 const height = scrollingElement.clientHeight; 29003 const { top } = scrollingElement.getBoundingClientRect(); 29004 const pageSize = Math.max(height * 0.875, height - 40) * 1.5; 29005 const pageOffset = pageUp ? height - pageSize + top : pageSize + top; 29006 if (scrollingElement.tagName === "HTML") return pageOffset + scrollingElement.scrollTop; 29007 return pageOffset; 29008 } 29009 function getItemOffset(itemElement, pageUp = false) { 29010 const { top } = itemElement.getBoundingClientRect(); 29011 if (pageUp) return top + itemElement.clientHeight; 29012 return top; 29013 } 29014 function findNextPageItemId(element, store2, next, pageUp = false) { 29015 if (!store2) return; 29016 if (!next) return; 29017 const { renderedItems } = store2.getState(); 29018 const scrollingElement = getScrollingElement(element); 29019 if (!scrollingElement) return; 29020 const nextPageOffset = getNextPageOffset(scrollingElement, pageUp); 29021 let id; 29022 let prevDifference; 29023 for (let i2 = 0; i2 < renderedItems.length; i2 += 1) { 29024 const previousId = id; 29025 id = next(i2); 29026 if (!id) break; 29027 if (id === previousId) continue; 29028 const itemElement = getEnabledItem(store2, id)?.element; 29029 if (!itemElement) continue; 29030 const difference = getItemOffset(itemElement, pageUp) - nextPageOffset; 29031 const absDifference = Math.abs(difference); 29032 if (pageUp && difference <= 0 || !pageUp && difference >= 0) { 29033 if (prevDifference !== void 0 && prevDifference < absDifference) id = previousId; 29034 break; 29035 } 29036 prevDifference = absDifference; 29037 } 29038 return id; 29039 } 29040 function targetIsAnotherItem(event, store2) { 29041 if (isSelfTarget(event)) return false; 29042 return isItem(store2, event.target); 29043 } 29044 var useCompositeItem = createHook(function useCompositeItem2({ store: store2, rowId: rowIdProp, preventScrollOnKeyDown = false, moveOnKeyPress = true, tabbable: tabbable2 = false, getItem: getItemProp, "aria-setsize": ariaSetSizeProp, "aria-posinset": ariaPosInSetProp, ...props }) { 29045 const context = useCompositeScopedContext(); 29046 store2 = store2 || context; 29047 const id = useId5(props.id); 29048 const ref = (0, import_react22.useRef)(null); 29049 const row = (0, import_react22.useContext)(CompositeRowContext); 29050 const trulyDisabled = disabledFromProps(props) && !props.accessibleWhenDisabled; 29051 const shouldRegisterItem = props.shouldRegisterItem; 29052 const getRowId = (state) => { 29053 if (rowIdProp) return rowIdProp; 29054 if (!state) return; 29055 if (!row?.baseElement) return; 29056 if (row.baseElement !== state.baseElement) return; 29057 return row.id; 29058 }; 29059 const { rowId, baseElement, isActiveItem, ariaSetSize, ariaPosInSet, isTabbable } = useStoreStateObject(store2, { 29060 rowId: getRowId, 29061 baseElement(state) { 29062 return state?.baseElement || void 0; 29063 }, 29064 isActiveItem(state) { 29065 return !!state && state.activeId === id; 29066 }, 29067 ariaSetSize(state) { 29068 if (ariaSetSizeProp != null) return ariaSetSizeProp; 29069 if (!state) return; 29070 if (!row?.ariaSetSize) return; 29071 if (row.baseElement !== state.baseElement) return; 29072 return row.ariaSetSize; 29073 }, 29074 ariaPosInSet(state) { 29075 if (ariaPosInSetProp != null) return ariaPosInSetProp; 29076 if (!state) return; 29077 if (!row?.ariaPosInSet) return; 29078 if (row.baseElement !== state.baseElement) return; 29079 const rowId2 = getRowId(state); 29080 const itemsInRow = state.renderedItems.filter((item) => item.rowId === rowId2); 29081 return row.ariaPosInSet + itemsInRow.findIndex((item) => item.id === id); 29082 }, 29083 isTabbable(state) { 29084 if (!state?.renderedItems.length) return true; 29085 if (state.virtualFocus) return false; 29086 if (tabbable2) return true; 29087 if (state.activeId === null) return false; 29088 const item = store2?.item(state.activeId); 29089 if (item?.disabled) return true; 29090 if (!item?.element) return true; 29091 return state.activeId === id; 29092 } 29093 }); 29094 const getItem = (0, import_react22.useCallback)((item) => { 29095 const nextItem = { 29096 ...item, 29097 id: id || item.id, 29098 rowId, 29099 disabled: trulyDisabled, 29100 children: item.element?.textContent 29101 }; 29102 if (getItemProp) return getItemProp(nextItem); 29103 return nextItem; 29104 }, [ 29105 id, 29106 rowId, 29107 trulyDisabled, 29108 getItemProp 29109 ]); 29110 const onFocusProp = props.onFocus; 29111 const hasFocusedComposite = (0, import_react22.useRef)(false); 29112 const cancelScheduledFocusRedirectRef = (0, import_react22.useRef)(null); 29113 const onFocus = useEvent((event) => { 29114 onFocusProp?.(event); 29115 if (event.defaultPrevented) return; 29116 if (isPortalEvent(event)) return; 29117 if (!id) return; 29118 if (!store2) return; 29119 if (targetIsAnotherItem(event, store2)) return; 29120 const { virtualFocus, baseElement: baseElement2 } = store2.getState(); 29121 store2.setActiveId(id); 29122 if (isTextbox(event.currentTarget)) selectTextField(event.currentTarget); 29123 if (!virtualFocus) return; 29124 if (!isSelfTarget(event)) return; 29125 if (isEditableElement(event.currentTarget)) return; 29126 const redirectFocusToBaseElement = (currentTarget2, relatedTarget2, baseElement3) => { 29127 if (isSafari() && currentTarget2.hasAttribute("data-autofocus")) currentTarget2.scrollIntoView({ 29128 block: "nearest", 29129 inline: "nearest" 29130 }); 29131 hasFocusedComposite.current = true; 29132 if (relatedTarget2 === baseElement3 || isItem(store2, relatedTarget2)) focusSilently(baseElement3); 29133 else baseElement3.focus(); 29134 }; 29135 if (baseElement2?.isConnected) { 29136 redirectFocusToBaseElement(event.currentTarget, event.relatedTarget, baseElement2); 29137 return; 29138 } 29139 if (shouldRegisterItem === false) return; 29140 const { currentTarget, relatedTarget } = event; 29141 const cancelScheduledFocusRedirect = () => { 29142 cancelScheduledFocusRedirectRef.current?.(); 29143 cancelScheduledFocusRedirectRef.current = null; 29144 }; 29145 cancelScheduledFocusRedirect(); 29146 cancelScheduledFocusRedirectRef.current = subscribe2(store2, null, () => { 29147 if (getActiveElement(currentTarget) !== currentTarget) { 29148 cancelScheduledFocusRedirect(); 29149 return; 29150 } 29151 const state = store2.getState(); 29152 const nextBaseElement = state.baseElement; 29153 if (!nextBaseElement?.isConnected) return; 29154 cancelScheduledFocusRedirect(); 29155 if (!state.virtualFocus) return; 29156 redirectFocusToBaseElement(currentTarget, relatedTarget, nextBaseElement); 29157 }); 29158 }); 29159 const onBlurCaptureProp = props.onBlurCapture; 29160 const onBlurCapture = useEvent((event) => { 29161 onBlurCaptureProp?.(event); 29162 if (event.defaultPrevented) return; 29163 if (store2?.getState()?.virtualFocus && hasFocusedComposite.current) { 29164 hasFocusedComposite.current = false; 29165 event.preventDefault(); 29166 event.stopPropagation(); 29167 } 29168 }); 29169 const onKeyDownProp = props.onKeyDown; 29170 const preventScrollOnKeyDownProp = useBooleanEvent(preventScrollOnKeyDown); 29171 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress); 29172 const onKeyDown = useEvent((event) => { 29173 onKeyDownProp?.(event); 29174 if (event.defaultPrevented) return; 29175 if (!isSelfTarget(event)) return; 29176 if (!store2) return; 29177 const { currentTarget } = event; 29178 const state = store2.getState(); 29179 const isGrid2 = !!store2.item(id)?.rowId; 29180 const isVertical = state.orientation !== "horizontal"; 29181 const isHorizontal = state.orientation !== "vertical"; 29182 const canHomeEnd = () => { 29183 if (isGrid2) return true; 29184 if (isHorizontal) return true; 29185 if (!state.baseElement) return true; 29186 if (!isTextField(state.baseElement)) return true; 29187 return false; 29188 }; 29189 const action = { 29190 ArrowUp: (isGrid2 || isVertical) && store2.up, 29191 ArrowRight: (isGrid2 || isHorizontal) && store2.next, 29192 ArrowDown: (isGrid2 || isVertical) && store2.down, 29193 ArrowLeft: (isGrid2 || isHorizontal) && store2.previous, 29194 Home: () => { 29195 if (!canHomeEnd()) return; 29196 if (!isGrid2 || event.ctrlKey) return store2?.first(); 29197 return store2?.previous(-1); 29198 }, 29199 End: () => { 29200 if (!canHomeEnd()) return; 29201 if (!isGrid2 || event.ctrlKey) return store2?.last(); 29202 return store2?.next(-1); 29203 }, 29204 PageUp: () => { 29205 return findNextPageItemId(currentTarget, store2, store2?.up, true); 29206 }, 29207 PageDown: () => { 29208 return findNextPageItemId(currentTarget, store2, store2?.down); 29209 } 29210 }[event.key]; 29211 if (action) { 29212 if (isTextbox(currentTarget)) { 29213 const selection = getTextboxSelection(currentTarget); 29214 const isLeft = isHorizontal && event.key === "ArrowLeft"; 29215 const isRight = isHorizontal && event.key === "ArrowRight"; 29216 const isUp = isVertical && event.key === "ArrowUp"; 29217 const isDown = isVertical && event.key === "ArrowDown"; 29218 if (isRight || isDown) { 29219 const { length: valueLength } = getTextboxValue(currentTarget); 29220 if (selection.end !== valueLength) return; 29221 } else if ((isLeft || isUp) && selection.start !== 0) return; 29222 } 29223 const nextId2 = action(); 29224 if (preventScrollOnKeyDownProp(event) || nextId2 !== void 0) { 29225 if (!moveOnKeyPressProp(event)) return; 29226 event.preventDefault(); 29227 store2.move(nextId2); 29228 } 29229 } 29230 }); 29231 const providerValue = (0, import_react22.useMemo)(() => ({ 29232 id, 29233 baseElement 29234 }), [id, baseElement]); 29235 props = useWrapElement(props, (element) => /* @__PURE__ */ (0, import_jsx_runtime149.jsx)(CompositeItemContext.Provider, { 29236 value: providerValue, 29237 children: element 29238 }), [providerValue]); 29239 props = { 29240 "data-active-item": isActiveItem || void 0, 29241 ...props, 29242 id, 29243 ref: useMergeRefs(ref, props.ref), 29244 tabIndex: isTabbable ? props.tabIndex : -1, 29245 onFocus, 29246 onBlurCapture, 29247 onKeyDown 29248 }; 29249 props = useCommand(props); 29250 props = useCollectionItem({ 29251 store: store2, 29252 ...props, 29253 getItem, 29254 shouldRegisterItem: id ? shouldRegisterItem : false 29255 }); 29256 return removeUndefinedValues({ 29257 ...props, 29258 "aria-setsize": ariaSetSize, 29259 "aria-posinset": ariaPosInSet 29260 }); 29261 }); 29262 var CompositeItem = memo5(forwardRef43(function CompositeItem2(props) { 29263 return createElement5(TagName4, useCompositeItem(props)); 29264 })); 29265 29266 // node_modules/@ariakit/react-components/dist/composite/composite.js 29267 var import_react23 = __toESM(require_react(), 1); 29268 var import_jsx_runtime150 = __toESM(require_jsx_runtime(), 1); 29269 var TagName5 = "div"; 29270 function isGrid(items) { 29271 return items.some((item) => !!item.rowId); 29272 } 29273 function isPrintableKey(event) { 29274 const target = event.target; 29275 if (target && !isTextField(target)) return false; 29276 return event.key.length === 1 && !event.ctrlKey && !event.metaKey; 29277 } 29278 function isModifierKey(event) { 29279 return event.key === "Shift" || event.key === "Control" || event.key === "Alt" || event.key === "Meta"; 29280 } 29281 function useKeyboardEventProxy(store2, onKeyboardEvent, previousElementRef) { 29282 return useEvent((event) => { 29283 onKeyboardEvent?.(event); 29284 if (event.defaultPrevented) return; 29285 if (event.isPropagationStopped()) return; 29286 if (!isSelfTarget(event)) return; 29287 if (isModifierKey(event)) return; 29288 if (isPrintableKey(event)) return; 29289 const activeElement2 = getEnabledItem(store2, store2.getState().activeId)?.element; 29290 if (!activeElement2) return; 29291 const { view, ...eventInit } = event; 29292 if (activeElement2 !== previousElementRef?.current) activeElement2.focus(); 29293 if (!fireKeyboardEvent(activeElement2, event.type, eventInit)) event.preventDefault(); 29294 if (event.currentTarget.contains(activeElement2)) event.stopPropagation(); 29295 }); 29296 } 29297 function findFirstEnabledItemInTheLastRow(items) { 29298 return findFirstEnabledItem2(flatten2DArray(reverseArray(groupItemsByRows2(items)))); 29299 } 29300 function withBaseScrollPreserved(store2, callback) { 29301 const { virtualFocus, baseElement } = store2.getState(); 29302 if (!virtualFocus || !baseElement || !isTextField(baseElement)) { 29303 callback(); 29304 return; 29305 } 29306 const savedScrollLeft = baseElement.scrollLeft; 29307 const savedScrollTop = baseElement.scrollTop; 29308 callback(); 29309 baseElement.scrollLeft = savedScrollLeft; 29310 baseElement.scrollTop = savedScrollTop; 29311 } 29312 function useScheduleFocus(store2) { 29313 const [scheduled, setScheduled] = (0, import_react23.useState)(false); 29314 const schedule2 = (0, import_react23.useCallback)(() => setScheduled(true), []); 29315 const activeItem = useStoreState(store2, (state) => scheduled ? getEnabledItem(store2, state.activeId) : null); 29316 (0, import_react23.useEffect)(() => { 29317 const activeElement2 = activeItem?.element; 29318 if (!scheduled) return; 29319 if (!activeElement2) return; 29320 setScheduled(false); 29321 withBaseScrollPreserved(store2, () => { 29322 activeElement2.focus({ preventScroll: true }); 29323 }); 29324 }, [ 29325 store2, 29326 activeItem, 29327 scheduled 29328 ]); 29329 return schedule2; 29330 } 29331 var CompositeFocusOnMove = memo5(function CompositeFocusOnMove2({ store: store2, focusOnMove, previousElementRef }) { 29332 const moves = useStoreState(store2, "moves"); 29333 const baseElement = useStoreState(store2, "baseElement"); 29334 (0, import_react23.useEffect)(() => { 29335 if (!moves) return; 29336 if (!focusOnMove) return; 29337 const { activeId } = store2.getState(); 29338 const itemElement = getEnabledItem(store2, activeId)?.element; 29339 if (!itemElement) return; 29340 withBaseScrollPreserved(store2, () => focusIntoView(itemElement)); 29341 }, [ 29342 store2, 29343 moves, 29344 focusOnMove 29345 ]); 29346 useSafeLayoutEffect(() => { 29347 if (!moves) return; 29348 if (!baseElement) return; 29349 const { activeId } = store2.getState(); 29350 if (!(activeId === null)) return; 29351 const previousElement = previousElementRef.current; 29352 previousElementRef.current = null; 29353 if (previousElement) fireBlurEvent(previousElement, { relatedTarget: baseElement }); 29354 if (!hasFocus(baseElement)) baseElement.focus(); 29355 }, [ 29356 store2, 29357 moves, 29358 baseElement 29359 ]); 29360 return null; 29361 }); 29362 var useComposite = createHook(function useComposite2({ store: store2, composite = true, focusOnMove = composite, moveOnKeyPress = true, ...props }) { 29363 const context = useCompositeProviderContext(); 29364 store2 = store2 || context; 29365 invariant(store2, "Composite must receive a `store` prop or be wrapped in a CompositeProvider component."); 29366 const ref = (0, import_react23.useRef)(null); 29367 const previousElementRef = (0, import_react23.useRef)(null); 29368 const scheduleFocus = useScheduleFocus(store2); 29369 const [, setBaseElement] = useTransactionState(composite ? store2.setBaseElement : null); 29370 const virtualFocus = useStoreState(store2, "virtualFocus"); 29371 const activeId = useStoreState(store2, (state) => state.virtualFocus ? state.activeId : null); 29372 useSafeLayoutEffect(() => { 29373 if (!store2) return; 29374 if (!composite) return; 29375 if (!virtualFocus) return; 29376 const previousElement = previousElementRef.current; 29377 previousElementRef.current = null; 29378 if (!previousElement) return; 29379 const relatedTarget = getEnabledItem(store2, activeId)?.element || getActiveElement(previousElement); 29380 if (relatedTarget === previousElement) return; 29381 fireBlurEvent(previousElement, { relatedTarget }); 29382 }, [ 29383 store2, 29384 activeId, 29385 virtualFocus, 29386 composite 29387 ]); 29388 const onKeyDownCapture = useKeyboardEventProxy(store2, props.onKeyDownCapture, previousElementRef); 29389 const onKeyUpCapture = useKeyboardEventProxy(store2, props.onKeyUpCapture, previousElementRef); 29390 const onFocusCaptureProp = props.onFocusCapture; 29391 const onFocusCapture = useEvent((event) => { 29392 onFocusCaptureProp?.(event); 29393 if (event.defaultPrevented) return; 29394 if (!store2) return; 29395 const { virtualFocus: virtualFocus2 } = store2.getState(); 29396 if (!virtualFocus2) return; 29397 const previousActiveElement = event.relatedTarget; 29398 const isSilentlyFocused = silentlyFocused(event.currentTarget); 29399 if (isSelfTarget(event) && isSilentlyFocused) { 29400 event.stopPropagation(); 29401 previousElementRef.current = previousActiveElement; 29402 } 29403 }); 29404 const onFocusProp = props.onFocus; 29405 const onFocus = useEvent((event) => { 29406 onFocusProp?.(event); 29407 if (event.defaultPrevented) return; 29408 if (!composite) return; 29409 if (!store2) return; 29410 const { relatedTarget } = event; 29411 const { virtualFocus: virtualFocus2 } = store2.getState(); 29412 if (virtualFocus2) { 29413 if (isSelfTarget(event) && !isItem(store2, relatedTarget)) queueMicrotask(scheduleFocus); 29414 } else if (isSelfTarget(event)) store2.setActiveId(null); 29415 }); 29416 const onBlurCaptureProp = props.onBlurCapture; 29417 const onBlurCapture = useEvent((event) => { 29418 onBlurCaptureProp?.(event); 29419 if (event.defaultPrevented) return; 29420 if (!store2) return; 29421 const { virtualFocus: virtualFocus2, activeId: activeId2 } = store2.getState(); 29422 if (!virtualFocus2) return; 29423 const activeElement2 = getEnabledItem(store2, activeId2)?.element; 29424 const nextActiveElement = event.relatedTarget; 29425 const nextActiveElementIsItem = isItem(store2, nextActiveElement); 29426 const previousElement = previousElementRef.current; 29427 previousElementRef.current = null; 29428 if (isSelfTarget(event) && nextActiveElementIsItem) { 29429 if (nextActiveElement === activeElement2) { 29430 if (previousElement && previousElement !== nextActiveElement) fireBlurEvent(previousElement, event); 29431 } else if (activeElement2) fireBlurEvent(activeElement2, event); 29432 else if (previousElement) fireBlurEvent(previousElement, event); 29433 event.stopPropagation(); 29434 } else if (!isItem(store2, event.target) && activeElement2) fireBlurEvent(activeElement2, event); 29435 }); 29436 const onKeyDownProp = props.onKeyDown; 29437 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress); 29438 const onKeyDown = useEvent((event) => { 29439 onKeyDownProp?.(event); 29440 if (event.nativeEvent.isComposing) return; 29441 if (event.defaultPrevented) return; 29442 if (!store2) return; 29443 if (!isSelfTarget(event)) return; 29444 const { orientation, renderedItems, activeId: activeId2, rtl } = store2.getState(); 29445 if (getEnabledItem(store2, activeId2)?.element?.isConnected) return; 29446 const isVertical = orientation !== "horizontal"; 29447 const isHorizontal = orientation !== "vertical"; 29448 const grid = isGrid(renderedItems); 29449 if ((event.key === "ArrowLeft" || event.key === "ArrowRight" || event.key === "Home" || event.key === "End") && isTextField(event.currentTarget)) return; 29450 const up = () => { 29451 if (grid) return findFirstEnabledItemInTheLastRow(renderedItems)?.id; 29452 return store2?.last(); 29453 }; 29454 const action = { 29455 ArrowUp: (grid || isVertical) && up, 29456 ArrowRight: (grid || isHorizontal) && (rtl ? store2.last : store2.first), 29457 ArrowDown: (grid || isVertical) && store2.first, 29458 ArrowLeft: (grid || isHorizontal) && (rtl ? store2.first : store2.last), 29459 Home: store2.first, 29460 End: store2.last, 29461 PageUp: store2.first, 29462 PageDown: store2.last 29463 }[event.key]; 29464 if (action) { 29465 const id = action(); 29466 if (id !== void 0) { 29467 if (!moveOnKeyPressProp(event)) return; 29468 event.preventDefault(); 29469 store2.move(id); 29470 } 29471 } 29472 }); 29473 props = useWrapElement(props, (element) => /* @__PURE__ */ (0, import_jsx_runtime150.jsxs)(CompositeScopedContextProvider, { 29474 value: store2, 29475 children: [element, composite && /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(CompositeFocusOnMove, { 29476 store: store2, 29477 focusOnMove, 29478 previousElementRef 29479 })] 29480 }), [ 29481 store2, 29482 composite, 29483 focusOnMove 29484 ]); 29485 props = { 29486 "aria-activedescendant": useStoreState(store2, (state) => { 29487 if (!store2) return; 29488 if (!composite) return; 29489 if (!state.virtualFocus) return; 29490 return getEnabledItem(store2, state.activeId)?.id; 29491 }), 29492 ...props, 29493 ref: useMergeRefs(ref, setBaseElement, props.ref), 29494 onKeyDownCapture, 29495 onKeyUpCapture, 29496 onFocusCapture, 29497 onFocus, 29498 onBlurCapture, 29499 onKeyDown 29500 }; 29501 props = useFocusable({ 29502 focusable: useStoreState(store2, (state) => composite && (state.virtualFocus || state.activeId === null)), 29503 ...props 29504 }); 29505 return props; 29506 }); 29507 var Composite6 = forwardRef43(function Composite7(props) { 29508 return createElement5(TagName5, useComposite(props)); 29509 }); 29510 29511 // node_modules/@ariakit/react-components/dist/disclosure/disclosure-context.js 29512 var ctx4 = createStoreContext(); 29513 var useDisclosureContext = ctx4.useContext; 29514 var useDisclosureScopedContext = ctx4.useScopedContext; 29515 var useDisclosureProviderContext = ctx4.useProviderContext; 29516 var DisclosureContextProvider = ctx4.ContextProvider; 29517 var DisclosureScopedContextProvider = ctx4.ScopedContextProvider; 29518 29519 // node_modules/@ariakit/react-components/dist/dialog/dialog-context.js 29520 var import_react24 = __toESM(require_react(), 1); 29521 var ctx5 = createStoreContext([DisclosureContextProvider], [DisclosureScopedContextProvider]); 29522 var useDialogContext = ctx5.useContext; 29523 var useDialogScopedContext = ctx5.useScopedContext; 29524 var useDialogProviderContext = ctx5.useProviderContext; 29525 var DialogContextProvider = ctx5.ContextProvider; 29526 var DialogScopedContextProvider = ctx5.ScopedContextProvider; 29527 var DialogHeadingContext = (0, import_react24.createContext)(void 0); 29528 var DialogDescriptionContext = (0, import_react24.createContext)(void 0); 29529 29530 // node_modules/@ariakit/react-components/dist/disclosure/disclosure-content.js 29531 var import_react25 = __toESM(require_react(), 1); 29532 var import_jsx_runtime151 = __toESM(require_jsx_runtime(), 1); 29533 var import_react_dom5 = __toESM(require_react_dom(), 1); 29534 var TagName6 = "div"; 29535 function afterTimeout(timeoutMs, cb) { 29536 const timeoutId = setTimeout(cb, timeoutMs); 29537 return () => clearTimeout(timeoutId); 29538 } 29539 function parseCSSTime(time) { 29540 const value = time?.trim() || "0s"; 29541 const multiplier = value.endsWith("ms") ? 1 : 1e3; 29542 const parsed = Number.parseFloat(value) * multiplier; 29543 return Number.isNaN(parsed) ? 0 : parsed; 29544 } 29545 function getEndTime(names, delays, durations) { 29546 const nameList = names.split(","); 29547 const delayList = delays.split(","); 29548 const durationList = durations.split(","); 29549 let endTime = 0; 29550 for (const [index2, name2] of nameList.entries()) { 29551 if (name2.trim() === "none") continue; 29552 const delay = parseCSSTime(delayList[index2 % delayList.length]); 29553 const duration = parseCSSTime(durationList[index2 % durationList.length]); 29554 endTime = Math.max(endTime, delay + duration); 29555 } 29556 return endTime; 29557 } 29558 function getElementEndTime(element) { 29559 const { transitionProperty, transitionDuration, transitionDelay, animationName, animationDuration, animationDelay } = getComputedStyle(element); 29560 return Math.max(getEndTime(transitionProperty, transitionDelay, transitionDuration), getEndTime(animationName, animationDelay, animationDuration)); 29561 } 29562 function isHidden(mounted, hidden, alwaysVisible) { 29563 return !alwaysVisible && hidden !== false && (!mounted || !!hidden); 29564 } 29565 var useDisclosureContent = createHook(function useDisclosureContent2({ store: store2, alwaysVisible, unstable_otherElementRef: otherElementRef, ...props }) { 29566 const context = useDisclosureProviderContext(); 29567 store2 = store2 || context; 29568 invariant(store2, "DisclosureContent must receive a `store` prop or be wrapped in a DisclosureProvider component."); 29569 const ref = (0, import_react25.useRef)(null); 29570 const id = useId5(props.id); 29571 const [transition, setTransition] = (0, import_react25.useState)(null); 29572 const open = useStoreState(store2, "open"); 29573 const mounted = useStoreState(store2, "mounted"); 29574 const animated2 = useStoreState(store2, "animated"); 29575 const contentElement = useStoreState(store2, "contentElement"); 29576 const otherElement = useStoreState(store2.disclosure, "contentElement"); 29577 const hasClosedRef = (0, import_react25.useRef)(false); 29578 useSafeLayoutEffect(() => { 29579 if (!ref.current) return; 29580 store2?.setContentElement(ref.current); 29581 }, [store2]); 29582 useSafeLayoutEffect(() => { 29583 let previousAnimated; 29584 store2?.setState("animated", (animated3) => { 29585 previousAnimated = animated3; 29586 return true; 29587 }); 29588 return () => { 29589 if (previousAnimated === void 0) return; 29590 store2?.setState("animated", previousAnimated); 29591 }; 29592 }, [store2]); 29593 useSafeLayoutEffect(() => { 29594 if (!animated2) { 29595 if (!open) { 29596 hasClosedRef.current = true; 29597 setTransition(null); 29598 } else if (hasClosedRef.current) { 29599 hasClosedRef.current = false; 29600 setTransition("enter"); 29601 } 29602 return; 29603 } 29604 if (!contentElement?.isConnected) { 29605 setTransition(null); 29606 return; 29607 } 29608 return afterPaint(() => { 29609 setTransition(open ? "enter" : mounted ? "leave" : null); 29610 }); 29611 }, [ 29612 animated2, 29613 contentElement, 29614 open, 29615 mounted 29616 ]); 29617 useSafeLayoutEffect(() => { 29618 if (!store2) return; 29619 if (!animated2) return; 29620 if (!transition) return; 29621 if (!contentElement) return; 29622 const stopAnimation = () => store2?.setState("animating", false); 29623 const stopAnimationSync = () => (0, import_react_dom5.flushSync)(stopAnimation); 29624 if (transition === "leave" && open) return; 29625 if (transition === "enter" && !open) return; 29626 if (typeof animated2 === "number") return afterTimeout(animated2, stopAnimationSync); 29627 const elements2 = [contentElement]; 29628 if (otherElement) elements2.push(otherElement); 29629 const relatedElement = otherElementRef?.current; 29630 if (relatedElement) elements2.push(relatedElement); 29631 const timeout = Math.max(...elements2.map(getElementEndTime)); 29632 if (!timeout) { 29633 if (transition === "enter") store2.setState("animated", false); 29634 stopAnimation(); 29635 return; 29636 } 29637 return afterTimeout(Math.max(timeout - 1e3 / 60, 0), stopAnimationSync); 29638 }, [ 29639 store2, 29640 animated2, 29641 contentElement, 29642 otherElement, 29643 otherElementRef, 29644 open, 29645 transition 29646 ]); 29647 props = useWrapElement(props, (element) => /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(DialogScopedContextProvider, { 29648 value: store2, 29649 children: element 29650 }), [store2]); 29651 const hidden = isHidden(mounted, props.hidden, alwaysVisible); 29652 const styleProp = props.style; 29653 const style = (0, import_react25.useMemo)(() => { 29654 if (hidden) return { 29655 ...styleProp, 29656 display: "none" 29657 }; 29658 return styleProp; 29659 }, [hidden, styleProp]); 29660 props = { 29661 "data-open": open || void 0, 29662 "data-enter": transition === "enter" || void 0, 29663 "data-leave": transition === "leave" || void 0, 29664 hidden, 29665 ...props, 29666 id, 29667 ref: useMergeRefs(id ? store2.setContentElement : null, ref, props.ref), 29668 style 29669 }; 29670 return removeUndefinedValues(props); 29671 }); 29672 var DisclosureContentImpl = forwardRef43(function DisclosureContentImpl2(props) { 29673 return createElement5(TagName6, useDisclosureContent(props)); 29674 }); 29675 var DisclosureContent = forwardRef43(function DisclosureContent2({ unmountOnHide, ...props }) { 29676 const context = useDisclosureProviderContext(); 29677 if (useStoreState(props.store || context, (state) => !unmountOnHide || state?.mounted) === false) return null; 29678 return /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(DisclosureContentImpl, { ...props }); 29679 }); 29680 29681 // node_modules/@ariakit/components/dist/disclosure/disclosure-store.js 29682 function createDisclosureStore(props = {}) { 29683 const store2 = mergeStore(props.store, omit2(props.disclosure, ["contentElement", "disclosureElement"])); 29684 throwOnConflictingProps(props, store2); 29685 const syncState = store2?.getState(); 29686 const open = defaultValue(props.open, syncState?.open, props.defaultOpen, false); 29687 const animated2 = defaultValue(props.animated, syncState?.animated, false); 29688 const disclosure = createStore({ 29689 open, 29690 animated: animated2, 29691 animating: !!animated2 && open, 29692 mounted: open, 29693 contentElement: defaultValue(syncState?.contentElement, null), 29694 disclosureElement: defaultValue(syncState?.disclosureElement, null) 29695 }, store2); 29696 setup(disclosure, () => sync2(disclosure, ["animated", "animating"], (state) => { 29697 if (state.animated) return; 29698 disclosure.setState("animating", false); 29699 })); 29700 setup(disclosure, () => subscribe2(disclosure, ["open"], () => { 29701 if (!disclosure.getState().animated) return; 29702 disclosure.setState("animating", true); 29703 })); 29704 setup(disclosure, () => sync2(disclosure, ["open", "animating"], (state) => { 29705 disclosure.setState("mounted", state.open || state.animating); 29706 })); 29707 return { 29708 ...disclosure, 29709 disclosure: props.disclosure, 29710 setOpen: (value) => disclosure.setState("open", value), 29711 show: () => disclosure.setState("open", true), 29712 hide: () => disclosure.setState("open", false), 29713 toggle: () => disclosure.setState("open", (open2) => !open2), 29714 stopAnimation: () => disclosure.setState("animating", false), 29715 setContentElement: (value) => disclosure.setState("contentElement", value), 29716 setDisclosureElement: (value) => disclosure.setState("disclosureElement", value) 29717 }; 29718 } 29719 29720 // node_modules/@ariakit/react-components/dist/disclosure/disclosure-store.js 29721 function useDisclosureStoreProps(store2, update4, props) { 29722 useUpdateEffect(update4, [props.store, props.disclosure]); 29723 useStoreProps(store2, props, "open", "setOpen"); 29724 useStoreProps(store2, props, "mounted", "setMounted"); 29725 useStoreProps(store2, props, "animated"); 29726 return Object.assign(store2, { disclosure: props.disclosure }); 29727 } 29728 29729 // node_modules/@ariakit/react-components/dist/popover/popover-context.js 29730 var ctx6 = createStoreContext([DialogContextProvider], [DialogScopedContextProvider]); 29731 var usePopoverContext = ctx6.useContext; 29732 var usePopoverScopedContext = ctx6.useScopedContext; 29733 var usePopoverProviderContext = ctx6.useProviderContext; 29734 var PopoverContextProvider = ctx6.ContextProvider; 29735 var PopoverScopedContextProvider = ctx6.ScopedContextProvider; 29736 29737 // node_modules/@ariakit/react-components/dist/combobox/combobox-context.js 29738 var import_react26 = __toESM(require_react(), 1); 29739 var ComboboxListRoleContext = (0, import_react26.createContext)(void 0); 29740 var ctx7 = createStoreContext([PopoverContextProvider, CompositeContextProvider], [PopoverScopedContextProvider, CompositeScopedContextProvider]); 29741 var useComboboxContext = ctx7.useContext; 29742 var useComboboxScopedContext = ctx7.useScopedContext; 29743 var useComboboxProviderContext = ctx7.useProviderContext; 29744 var ComboboxContextProvider = ctx7.ContextProvider; 29745 var ComboboxScopedContextProvider = ctx7.ScopedContextProvider; 29746 var ComboboxItemValueContext = (0, import_react26.createContext)(void 0); 29747 var ComboboxItemCheckedContext = (0, import_react26.createContext)(false); 29748 29749 // node_modules/@ariakit/react-components/dist/collection/collection-store.js 29750 function useCollectionStoreProps(store2, update4, props) { 29751 useUpdateEffect(update4, [props.store]); 29752 useStoreProps(store2, props, "items", "setItems"); 29753 return store2; 29754 } 29755 29756 // node_modules/@ariakit/react-components/dist/composite/composite-store.js 29757 function useCompositeStoreOptions(props) { 29758 return { 29759 id: useId5(props.id), 29760 ...props 29761 }; 29762 } 29763 function useCompositeStoreProps(store2, update4, props) { 29764 store2 = useCollectionStoreProps(store2, update4, props); 29765 useStoreProps(store2, props, "activeId", "setActiveId"); 29766 useStoreProps(store2, props, "includesBaseElement"); 29767 useStoreProps(store2, props, "virtualFocus"); 29768 useStoreProps(store2, props, "orientation"); 29769 useStoreProps(store2, props, "rtl"); 29770 useStoreProps(store2, props, "focusLoop"); 29771 useStoreProps(store2, props, "focusWrap"); 29772 useStoreProps(store2, props, "focusShift"); 29773 return store2; 29774 } 29775 29776 // node_modules/@ariakit/components/dist/dialog/dialog-store.js 29777 function createDialogStore(props = {}) { 29778 return createDisclosureStore(props); 29779 } 29780 29781 // node_modules/@ariakit/react-components/dist/dialog/dialog-store.js 29782 function useDialogStoreProps(store2, update4, props) { 29783 return useDisclosureStoreProps(store2, update4, props); 29784 } 29785 29786 // node_modules/@ariakit/components/dist/popover/popover-store.js 29787 function createPopoverStore({ popover: otherPopover, ...props } = {}) { 29788 const store2 = mergeStore(props.store, omit2(otherPopover, [ 29789 "arrowElement", 29790 "anchorElement", 29791 "contentElement", 29792 "popoverElement", 29793 "disclosureElement" 29794 ])); 29795 throwOnConflictingProps(props, store2); 29796 const syncState = store2?.getState(); 29797 const dialog = createDialogStore({ 29798 ...props, 29799 store: store2 29800 }); 29801 const placement = defaultValue(props.placement, syncState?.placement, "bottom"); 29802 const popover = createStore({ 29803 ...dialog.getState(), 29804 placement, 29805 currentPlacement: placement, 29806 anchorElement: defaultValue(syncState?.anchorElement, null), 29807 popoverElement: defaultValue(syncState?.popoverElement, null), 29808 arrowElement: defaultValue(syncState?.arrowElement, null), 29809 rendered: /* @__PURE__ */ Symbol("rendered") 29810 }, dialog, store2); 29811 return { 29812 ...dialog, 29813 ...popover, 29814 setAnchorElement: (element) => popover.setState("anchorElement", element), 29815 setPopoverElement: (element) => popover.setState("popoverElement", element), 29816 setArrowElement: (element) => popover.setState("arrowElement", element), 29817 render: () => popover.setState("rendered", /* @__PURE__ */ Symbol("rendered")) 29818 }; 29819 } 29820 29821 // node_modules/@ariakit/react-components/dist/popover/popover-store.js 29822 function usePopoverStoreProps(store2, update4, props) { 29823 useUpdateEffect(update4, [props.popover]); 29824 useStoreProps(store2, props, "placement"); 29825 return useDialogStoreProps(store2, update4, props); 29826 } 29827 29828 // node_modules/@ariakit/react-components/dist/popover/popover-anchor.js 29829 var TagName7 = "div"; 29830 var usePopoverAnchor = createHook(function usePopoverAnchor2({ store: store2, ...props }) { 29831 const context = usePopoverProviderContext(); 29832 store2 = store2 || context; 29833 props = { 29834 ...props, 29835 ref: useMergeRefs(store2?.setAnchorElement, props.ref) 29836 }; 29837 return props; 29838 }); 29839 var PopoverAnchor = forwardRef43(function PopoverAnchor2(props) { 29840 return createElement5(TagName7, usePopoverAnchor(props)); 29841 }); 29842 29843 // node_modules/@ariakit/react-components/dist/composite/composite-hover.js 29844 var import_react27 = __toESM(require_react(), 1); 29845 var TagName8 = "div"; 29846 function hoveringInside(event) { 29847 const nextElement = event.relatedTarget; 29848 if (!isElement2(nextElement)) return false; 29849 return contains2(event.currentTarget, nextElement); 29850 } 29851 var symbol2 = /* @__PURE__ */ Symbol("composite-hover"); 29852 function movingToAnotherItem(event) { 29853 const { relatedTarget } = event; 29854 if (!isElement2(relatedTarget)) return false; 29855 let dest = relatedTarget; 29856 do { 29857 if (hasOwnProperty(dest, symbol2) && dest[symbol2]) return true; 29858 dest = dest.parentElement; 29859 } while (dest); 29860 return false; 29861 } 29862 var useCompositeHover = createHook(function useCompositeHover2({ store: store2, focusOnHover = true, blurOnHoverEnd = !!focusOnHover, ...props }) { 29863 const context = useCompositeScopedContext(); 29864 store2 = store2 || context; 29865 invariant(store2, "CompositeHover must be wrapped in a Composite component."); 29866 const isMouseMoving = useIsMouseMoving(); 29867 const onMouseMoveProp = props.onMouseMove; 29868 const focusOnHoverProp = useBooleanEvent(focusOnHover); 29869 const onMouseMove = useEvent((event) => { 29870 onMouseMoveProp?.(event); 29871 if (event.defaultPrevented) return; 29872 if (!isMouseMoving()) return; 29873 if (!focusOnHoverProp(event)) return; 29874 if (!hasFocusWithin(event.currentTarget)) { 29875 const baseElement = store2?.getState().baseElement; 29876 if (baseElement && !hasFocus(baseElement)) baseElement.focus(); 29877 } 29878 store2?.setActiveId(event.currentTarget.id); 29879 }); 29880 const onMouseLeaveProp = props.onMouseLeave; 29881 const blurOnHoverEndProp = useBooleanEvent(blurOnHoverEnd); 29882 const onMouseLeave = useEvent((event) => { 29883 onMouseLeaveProp?.(event); 29884 if (event.defaultPrevented) return; 29885 if (!isMouseMoving()) return; 29886 if (hoveringInside(event)) return; 29887 if (movingToAnotherItem(event)) return; 29888 if (!focusOnHoverProp(event)) return; 29889 if (!blurOnHoverEndProp(event)) return; 29890 store2?.setActiveId(null); 29891 store2?.getState().baseElement?.focus(); 29892 }); 29893 const ref = (0, import_react27.useCallback)((element) => { 29894 if (!element) return; 29895 element[symbol2] = true; 29896 }, []); 29897 props = { 29898 ...props, 29899 ref: useMergeRefs(ref, props.ref), 29900 onMouseMove, 29901 onMouseLeave 29902 }; 29903 return removeUndefinedValues(props); 29904 }); 29905 var CompositeHover = memo5(forwardRef43(function CompositeHover2(props) { 29906 return createElement5(TagName8, useCompositeHover(props)); 29907 })); 29908 29909 // node_modules/@ariakit/react-components/dist/combobox/combobox.js 29910 var import_react28 = __toESM(require_react(), 1); 29911 var TagName9 = "input"; 29912 function isFirstItemAutoSelected(items, activeValue, autoSelect) { 29913 if (!autoSelect) return false; 29914 return items.find((item) => !item.disabled && item.value)?.value === activeValue; 29915 } 29916 function hasCompletionString(value, activeValue) { 29917 if (!activeValue) return false; 29918 if (value == null) return false; 29919 const normalizedValue = normalizeString(value); 29920 const normalizedActiveValue = normalizeString(activeValue); 29921 if (normalizedValue.length !== value.length) return false; 29922 if (normalizedActiveValue.length !== activeValue.length) return false; 29923 return normalizedActiveValue.length > normalizedValue.length && normalizedActiveValue.toLowerCase().startsWith(normalizedValue.toLowerCase()); 29924 } 29925 function isAriaAutoCompleteValue(value) { 29926 return value === "inline" || value === "list" || value === "both" || value === "none"; 29927 } 29928 function getDefaultAutoSelectId(items) { 29929 return items.find((item) => { 29930 if (item.disabled) return false; 29931 return item.element?.getAttribute("role") !== "tab"; 29932 })?.id; 29933 } 29934 var useCombobox = createHook(function useCombobox2({ store: store2, focusable: focusable2 = true, autoSelect: autoSelectProp = false, getAutoSelectId, setValueOnChange, showMinLength = 0, showOnChange, showOnMouseDown, showOnClick = showOnMouseDown, showOnKeyDown, showOnKeyPress = showOnKeyDown, blurActiveItemOnClick, setValueOnClick = true, moveOnKeyPress = true, autoComplete = "list", ...props }) { 29935 const context = useComboboxProviderContext(); 29936 store2 = store2 || context; 29937 invariant(store2, "Combobox must receive a `store` prop or be wrapped in a ComboboxProvider component."); 29938 const ref = (0, import_react28.useRef)(null); 29939 const [valueUpdated, forceValueUpdate] = useForceUpdate2(); 29940 const canAutoSelectRef = (0, import_react28.useRef)(false); 29941 const composingRef = (0, import_react28.useRef)(false); 29942 const autoSelect = useStoreState(store2, (state) => state.virtualFocus && autoSelectProp); 29943 const inline4 = autoComplete === "inline" || autoComplete === "both"; 29944 const [canInline, setCanInline] = (0, import_react28.useState)(inline4); 29945 useUpdateLayoutEffect(() => { 29946 if (!inline4) return; 29947 setCanInline(true); 29948 }, [inline4]); 29949 const storeValue = useStoreState(store2, "value"); 29950 const prevSelectedValueRef = (0, import_react28.useRef)(void 0); 29951 (0, import_react28.useEffect)(() => { 29952 return sync2(store2, ["selectedValue", "activeId"], (_, prev) => { 29953 prevSelectedValueRef.current = prev.selectedValue; 29954 }); 29955 }, [store2]); 29956 const inlineActiveValue = useStoreState(store2, (state) => { 29957 if (!inline4) return; 29958 if (!canInline) return; 29959 if (state.activeValue && Array.isArray(state.selectedValue)) { 29960 if (state.selectedValue.includes(state.activeValue)) return; 29961 if (prevSelectedValueRef.current?.includes(state.activeValue)) return; 29962 } 29963 return state.activeValue; 29964 }); 29965 const items = useStoreState(store2, "renderedItems"); 29966 const open = useStoreState(store2, "open"); 29967 const contentElement = useStoreState(store2, "contentElement"); 29968 const value = (0, import_react28.useMemo)(() => { 29969 if (!inline4) return storeValue; 29970 if (!canInline) return storeValue; 29971 if (isFirstItemAutoSelected(items, inlineActiveValue, autoSelect)) { 29972 if (hasCompletionString(storeValue, inlineActiveValue)) return storeValue + (inlineActiveValue?.slice(storeValue.length) || ""); 29973 return storeValue; 29974 } 29975 return inlineActiveValue || storeValue; 29976 }, [ 29977 inline4, 29978 canInline, 29979 items, 29980 inlineActiveValue, 29981 autoSelect, 29982 storeValue 29983 ]); 29984 (0, import_react28.useEffect)(() => { 29985 const element = ref.current; 29986 if (!element) return; 29987 const onCompositeItemMove = () => setCanInline(true); 29988 element.addEventListener("combobox-item-move", onCompositeItemMove); 29989 return () => { 29990 element.removeEventListener("combobox-item-move", onCompositeItemMove); 29991 }; 29992 }, []); 29993 (0, import_react28.useEffect)(() => { 29994 if (!inline4) return; 29995 if (!canInline) return; 29996 if (!inlineActiveValue) return; 29997 if (!isFirstItemAutoSelected(items, inlineActiveValue, autoSelect)) return; 29998 if (!hasCompletionString(storeValue, inlineActiveValue)) return; 29999 let cleanup = noop5; 30000 queueMicrotask(() => { 30001 const element = ref.current; 30002 if (!element) return; 30003 const { start: prevStart, end: prevEnd } = getTextboxSelection(element); 30004 const nextStart = storeValue.length; 30005 const nextEnd = inlineActiveValue.length; 30006 setSelectionRange(element, nextStart, nextEnd); 30007 cleanup = () => { 30008 if (!hasFocus(element)) return; 30009 const { start: start2, end } = getTextboxSelection(element); 30010 if (start2 !== nextStart) return; 30011 if (end !== nextEnd) return; 30012 setSelectionRange(element, prevStart, prevEnd); 30013 }; 30014 }); 30015 return () => cleanup(); 30016 }, [ 30017 valueUpdated, 30018 inline4, 30019 canInline, 30020 inlineActiveValue, 30021 items, 30022 autoSelect, 30023 storeValue 30024 ]); 30025 const getAutoSelectIdProp = useEvent(getAutoSelectId); 30026 const autoSelectIdRef = (0, import_react28.useRef)(null); 30027 const autoSelectMovedRef = (0, import_react28.useRef)(void 0); 30028 const userScrolledRef = (0, import_react28.useRef)(false); 30029 const isAutoScrollingRef = (0, import_react28.useRef)(false); 30030 (0, import_react28.useEffect)(() => { 30031 if (!open) return; 30032 if (!contentElement) return; 30033 const scrollingElement = getScrollingElement(contentElement); 30034 if (!scrollingElement) return; 30035 const onUserScroll = () => { 30036 canAutoSelectRef.current = false; 30037 userScrolledRef.current = true; 30038 }; 30039 const onScroll = () => { 30040 if (!isAutoScrollingRef.current) userScrolledRef.current = true; 30041 if (!store2) return; 30042 if (!canAutoSelectRef.current) return; 30043 const { activeId } = store2.getState(); 30044 if (activeId === null) return; 30045 if (activeId === autoSelectIdRef.current) return; 30046 canAutoSelectRef.current = false; 30047 }; 30048 const options = { 30049 passive: true, 30050 capture: true 30051 }; 30052 scrollingElement.addEventListener("wheel", onUserScroll, options); 30053 scrollingElement.addEventListener("touchmove", onUserScroll, options); 30054 scrollingElement.addEventListener("scroll", onScroll, options); 30055 return () => { 30056 scrollingElement.removeEventListener("wheel", onUserScroll, true); 30057 scrollingElement.removeEventListener("touchmove", onUserScroll, true); 30058 scrollingElement.removeEventListener("scroll", onScroll, true); 30059 }; 30060 }, [ 30061 open, 30062 contentElement, 30063 store2 30064 ]); 30065 useSafeLayoutEffect(() => { 30066 userScrolledRef.current = false; 30067 if (!storeValue) return; 30068 if (composingRef.current) return; 30069 canAutoSelectRef.current = true; 30070 }, [storeValue]); 30071 useSafeLayoutEffect(() => { 30072 if (autoSelect !== "always" && open) return; 30073 canAutoSelectRef.current = open; 30074 }, [autoSelect, open]); 30075 useSafeLayoutEffect(() => { 30076 if (open) return; 30077 autoSelectMovedRef.current = void 0; 30078 }, [open]); 30079 const resetValueOnSelect = useStoreState(store2, "resetValueOnSelect"); 30080 useUpdateEffect(() => { 30081 const canAutoSelect = canAutoSelectRef.current; 30082 if (!store2) return; 30083 if (!open) return; 30084 if (!canAutoSelect && (!resetValueOnSelect || userScrolledRef.current)) return; 30085 const { baseElement, contentElement: contentElement2, activeId } = store2.getState(); 30086 if (baseElement && !hasFocus(baseElement)) return; 30087 if (contentElement2?.hasAttribute("data-placing")) { 30088 const observer = new MutationObserver(forceValueUpdate); 30089 observer.observe(contentElement2, { attributeFilter: ["data-placing"] }); 30090 return () => observer.disconnect(); 30091 } 30092 if (autoSelect && canAutoSelect) { 30093 const userAutoSelectId = getAutoSelectIdProp(items); 30094 const autoSelectId = userAutoSelectId !== void 0 ? userAutoSelectId : getDefaultAutoSelectId(items) ?? store2.first(); 30095 autoSelectIdRef.current = autoSelectId; 30096 const nextActiveId = autoSelectId ?? null; 30097 const nextActiveValue = store2.item(nextActiveId)?.value; 30098 const moved = autoSelectMovedRef.current; 30099 if (nextActiveId !== activeId || moved?.id !== nextActiveId || moved?.value !== nextActiveValue) { 30100 autoSelectMovedRef.current = { 30101 id: nextActiveId, 30102 value: nextActiveValue 30103 }; 30104 store2.move(nextActiveId); 30105 } else store2.setState("activeValue", nextActiveValue); 30106 } else { 30107 const element = store2.item(activeId || store2.first())?.element; 30108 if (element && "scrollIntoView" in element) { 30109 isAutoScrollingRef.current = true; 30110 element.scrollIntoView({ 30111 block: "nearest", 30112 inline: "nearest" 30113 }); 30114 requestAnimationFrame(() => { 30115 isAutoScrollingRef.current = false; 30116 }); 30117 } 30118 } 30119 }, [ 30120 store2, 30121 open, 30122 valueUpdated, 30123 storeValue, 30124 autoSelect, 30125 resetValueOnSelect, 30126 getAutoSelectIdProp, 30127 items 30128 ]); 30129 (0, import_react28.useEffect)(() => { 30130 if (!inline4) return; 30131 const combobox = ref.current; 30132 if (!combobox) return; 30133 const elements2 = [combobox, contentElement].filter((value2) => !!value2); 30134 const onBlur2 = (event) => { 30135 if (elements2.every((el) => isFocusEventOutside(event, el))) store2?.setValue(value); 30136 }; 30137 for (const element of elements2) element.addEventListener("focusout", onBlur2); 30138 return () => { 30139 for (const element of elements2) element.removeEventListener("focusout", onBlur2); 30140 }; 30141 }, [ 30142 inline4, 30143 contentElement, 30144 store2, 30145 value 30146 ]); 30147 const canShow = (event) => { 30148 return event.currentTarget.value.length >= showMinLength; 30149 }; 30150 const onChangeProp = props.onChange; 30151 const showOnChangeProp = useBooleanEvent(showOnChange ?? canShow); 30152 const setValueOnChangeProp = useBooleanEvent(setValueOnChange ?? !store2.tag); 30153 const onChange = useEvent((event) => { 30154 onChangeProp?.(event); 30155 if (event.defaultPrevented) return; 30156 if (!store2) return; 30157 const currentTarget = event.currentTarget; 30158 const { value: value2, selectionStart, selectionEnd } = currentTarget; 30159 const nativeEvent = event.nativeEvent; 30160 canAutoSelectRef.current = true; 30161 if (isInputEvent(nativeEvent)) { 30162 if (nativeEvent.isComposing) { 30163 canAutoSelectRef.current = false; 30164 composingRef.current = true; 30165 } 30166 if (inline4) { 30167 const textInserted = nativeEvent.inputType === "insertText" || nativeEvent.inputType === "insertCompositionText"; 30168 const caretAtEnd = selectionStart === value2.length; 30169 setCanInline(textInserted && caretAtEnd); 30170 } 30171 } 30172 if (setValueOnChangeProp(event)) { 30173 const isSameValue2 = value2 === store2.getState().value; 30174 store2.setValue(value2); 30175 queueMicrotask(() => { 30176 setSelectionRange(currentTarget, selectionStart, selectionEnd); 30177 }); 30178 if (inline4 && autoSelect && isSameValue2) forceValueUpdate(); 30179 } 30180 if (showOnChangeProp(event)) store2.show(); 30181 if (!autoSelect || !canAutoSelectRef.current) store2.setActiveId(null); 30182 }); 30183 const onCompositionEndProp = props.onCompositionEnd; 30184 const onCompositionEnd = useEvent((event) => { 30185 canAutoSelectRef.current = true; 30186 composingRef.current = false; 30187 onCompositionEndProp?.(event); 30188 if (event.defaultPrevented) return; 30189 if (!autoSelect) return; 30190 forceValueUpdate(); 30191 }); 30192 const onMouseDownProp = props.onMouseDown; 30193 const blurActiveItemOnClickProp = useBooleanEvent(blurActiveItemOnClick ?? (() => store2.getState().includesBaseElement)); 30194 const setValueOnClickProp = useBooleanEvent(setValueOnClick); 30195 const showOnClickProp = useBooleanEvent(showOnClick ?? canShow); 30196 const onMouseDown = useEvent((event) => { 30197 onMouseDownProp?.(event); 30198 if (event.defaultPrevented) return; 30199 if (event.button) return; 30200 if (event.ctrlKey) return; 30201 if (!store2) return; 30202 if (blurActiveItemOnClickProp(event)) store2.setActiveId(null); 30203 if (setValueOnClickProp(event)) store2.setValue(value); 30204 if (showOnClickProp(event)) queueBeforeEvent(event.currentTarget, "mouseup", store2.show); 30205 }); 30206 const onKeyDownProp = props.onKeyDown; 30207 const showOnKeyPressProp = useBooleanEvent(showOnKeyPress ?? canShow); 30208 const onKeyDown = useEvent((event) => { 30209 onKeyDownProp?.(event); 30210 if (!event.repeat) canAutoSelectRef.current = false; 30211 if (event.defaultPrevented) return; 30212 if (!store2) return; 30213 const { open: open2 } = store2.getState(); 30214 if (open2 && event.key === "Enter") { 30215 event.preventDefault(); 30216 return; 30217 } 30218 if (event.ctrlKey) return; 30219 if (event.altKey) return; 30220 if (event.shiftKey) return; 30221 if (event.metaKey) return; 30222 if (open2) return; 30223 if (event.key === "ArrowUp" || event.key === "ArrowDown") { 30224 if (showOnKeyPressProp(event)) { 30225 event.preventDefault(); 30226 store2.show(); 30227 } 30228 } 30229 }); 30230 const onBlurProp = props.onBlur; 30231 const onBlur = useEvent((event) => { 30232 canAutoSelectRef.current = false; 30233 onBlurProp?.(event); 30234 }); 30235 const id = useId5(props.id); 30236 const ariaAutoComplete = isAriaAutoCompleteValue(autoComplete) ? autoComplete : void 0; 30237 const isActiveItem = useStoreState(store2, (state) => state.activeId === null); 30238 props = { 30239 role: "combobox", 30240 "aria-autocomplete": ariaAutoComplete, 30241 "aria-haspopup": getPopupRole(contentElement, "listbox"), 30242 "aria-expanded": open, 30243 "aria-controls": contentElement?.id, 30244 "data-active-item": isActiveItem || void 0, 30245 value, 30246 ...props, 30247 id, 30248 ref: useMergeRefs(ref, props.ref), 30249 onChange, 30250 onCompositionEnd, 30251 onMouseDown, 30252 onKeyDown, 30253 onBlur 30254 }; 30255 props = useComposite({ 30256 store: store2, 30257 focusable: focusable2, 30258 ...props, 30259 moveOnKeyPress: (event) => { 30260 if (isFalsyBooleanCallback(moveOnKeyPress, event)) return false; 30261 if (inline4) setCanInline(true); 30262 return true; 30263 } 30264 }); 30265 props = usePopoverAnchor({ 30266 store: store2, 30267 ...props 30268 }); 30269 return { 30270 autoComplete: "off", 30271 ...props 30272 }; 30273 }); 30274 var Combobox = forwardRef43(function Combobox2(props) { 30275 return createElement5(TagName9, useCombobox(props)); 30276 }); 30277 30278 // node_modules/@ariakit/react-components/dist/combobox/combobox-item.js 30279 var import_react29 = __toESM(require_react(), 1); 30280 var import_jsx_runtime152 = __toESM(require_jsx_runtime(), 1); 30281 var TagName10 = "div"; 30282 function isSelected(storeValue, itemValue) { 30283 if (itemValue == null) return; 30284 if (storeValue == null) return false; 30285 if (Array.isArray(storeValue)) return storeValue.includes(itemValue); 30286 return storeValue === itemValue; 30287 } 30288 function getItemRole(popupRole) { 30289 return getItemRoleByPopupRole(popupRole) ?? "option"; 30290 } 30291 var useComboboxItem = createHook(function useComboboxItem2({ store: store2, value, hideOnClick, setValueOnClick, selectValueOnClick = true, resetValueOnSelect, focusOnHover = false, moveOnKeyPress = true, getItem: getItemProp, ...props }) { 30292 const context = useComboboxScopedContext(); 30293 store2 = store2 || context; 30294 invariant(store2, "ComboboxItem must be wrapped in a ComboboxList or ComboboxPopover component."); 30295 const { resetValueOnSelectState, multiSelectable, selected } = useStoreStateObject(store2, { 30296 resetValueOnSelectState: "resetValueOnSelect", 30297 multiSelectable(state) { 30298 return Array.isArray(state.selectedValue); 30299 }, 30300 selected(state) { 30301 return isSelected(state.selectedValue, value); 30302 } 30303 }); 30304 const getItem = (0, import_react29.useCallback)((item) => { 30305 const nextItem = { 30306 ...item, 30307 value 30308 }; 30309 if (getItemProp) return getItemProp(nextItem); 30310 return nextItem; 30311 }, [value, getItemProp]); 30312 setValueOnClick = setValueOnClick ?? !multiSelectable; 30313 hideOnClick = hideOnClick ?? (value != null && !multiSelectable); 30314 const onClickProp = props.onClick; 30315 const setValueOnClickProp = useBooleanEvent(setValueOnClick); 30316 const selectValueOnClickProp = useBooleanEvent(selectValueOnClick); 30317 const resetValueOnSelectProp = useBooleanEvent(resetValueOnSelect ?? resetValueOnSelectState ?? multiSelectable); 30318 const hideOnClickProp = useBooleanEvent(hideOnClick); 30319 const onClick = useEvent((event) => { 30320 onClickProp?.(event); 30321 if (event.defaultPrevented) return; 30322 if (isDownloading(event)) return; 30323 if (isOpeningInNewTab(event)) return; 30324 if (value != null) { 30325 if (selectValueOnClickProp(event)) { 30326 if (resetValueOnSelectProp(event)) store2?.resetValue(); 30327 store2?.setSelectedValue((prevValue) => { 30328 if (!Array.isArray(prevValue)) return value; 30329 if (prevValue.includes(value)) return prevValue.filter((v2) => v2 !== value); 30330 return [...prevValue, value]; 30331 }); 30332 } 30333 if (setValueOnClickProp(event)) store2?.setValue(value); 30334 } 30335 if (hideOnClickProp(event)) store2?.hide(); 30336 }); 30337 const onKeyDownProp = props.onKeyDown; 30338 const onKeyDown = useEvent((event) => { 30339 onKeyDownProp?.(event); 30340 if (event.defaultPrevented) return; 30341 const baseElement = store2?.getState().baseElement; 30342 if (!baseElement) return; 30343 if (hasFocus(baseElement)) return; 30344 const printable = event.key.length === 1 && !event.ctrlKey && !event.metaKey; 30345 const paste = (!isApple() ? event.ctrlKey : event.metaKey) && event.key.toLowerCase() === "v"; 30346 const deleteKey = event.key === "Backspace" || event.key === "Delete"; 30347 if (printable || paste || deleteKey) { 30348 queueMicrotask(() => baseElement.focus()); 30349 if (isTextField(baseElement)) store2?.setValue(baseElement.value); 30350 } 30351 }); 30352 if (multiSelectable && selected != null) props = { 30353 "aria-selected": selected, 30354 ...props 30355 }; 30356 props = useWrapElement(props, (element) => /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(ComboboxItemValueContext.Provider, { 30357 value, 30358 children: /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(ComboboxItemCheckedContext.Provider, { 30359 value: selected ?? false, 30360 children: element 30361 }) 30362 }), [value, selected]); 30363 props = { 30364 role: getItemRole((0, import_react29.useContext)(ComboboxListRoleContext)), 30365 children: value, 30366 ...props, 30367 onClick, 30368 onKeyDown 30369 }; 30370 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress); 30371 props = useCompositeItem({ 30372 store: store2, 30373 ...props, 30374 getItem, 30375 moveOnKeyPress: (event) => { 30376 if (!moveOnKeyPressProp(event)) return false; 30377 const moveEvent = new Event("combobox-item-move"); 30378 store2?.getState().baseElement?.dispatchEvent(moveEvent); 30379 return true; 30380 } 30381 }); 30382 props = useCompositeHover({ 30383 store: store2, 30384 focusOnHover, 30385 ...props 30386 }); 30387 return props; 30388 }); 30389 var ComboboxItem = memo5(forwardRef43(function ComboboxItem2(props) { 30390 return createElement5(TagName10, useComboboxItem(props)); 30391 })); 30392 30393 // node_modules/@ariakit/react-components/dist/combobox/combobox-item-value.js 30394 var import_react30 = __toESM(require_react(), 1); 30395 var import_jsx_runtime153 = __toESM(require_jsx_runtime(), 1); 30396 var TagName11 = "span"; 30397 function normalizeValue(value) { 30398 return normalizeString(value).toLowerCase(); 30399 } 30400 function getOffsets(string, values) { 30401 const offsets = []; 30402 for (const value of values) { 30403 if (!value) continue; 30404 let pos = 0; 30405 const length = value.length; 30406 let index2 = string.indexOf(value, pos); 30407 while (index2 !== -1) { 30408 offsets.push([index2, length]); 30409 pos = index2 + 1; 30410 index2 = string.indexOf(value, pos); 30411 } 30412 } 30413 return offsets; 30414 } 30415 function mergeOverlappingOffsets(offsets) { 30416 offsets.sort(([a2], [b2]) => a2 - b2); 30417 const merged = []; 30418 for (const [offset4, length] of offsets) { 30419 const last = merged[merged.length - 1]; 30420 if (last && offset4 < last[0] + last[1]) last[1] = Math.max(last[1], offset4 + length - last[0]); 30421 else merged.push([offset4, length]); 30422 } 30423 return merged; 30424 } 30425 function getNormalizedIndexes(itemValue) { 30426 const starts = []; 30427 const ends = []; 30428 let index2 = 0; 30429 for (const char of itemValue) { 30430 const normalizedLength = normalizeValue(char).length; 30431 for (let i2 = 0; i2 < normalizedLength; i2 += 1) { 30432 starts.push(i2 === 0 ? index2 : -1); 30433 ends.push(index2); 30434 } 30435 index2 += char.length; 30436 } 30437 starts.push(itemValue.length); 30438 ends.push(itemValue.length); 30439 let nextBoundary = itemValue.length; 30440 for (let i2 = starts.length - 1; i2 >= 0; i2 -= 1) { 30441 const start2 = starts[i2]; 30442 if (start2 == null) continue; 30443 if (start2 === -1) starts[i2] = nextBoundary; 30444 else nextBoundary = start2; 30445 } 30446 return { 30447 starts, 30448 ends 30449 }; 30450 } 30451 function toOriginalOffsets(itemValue, normalizedOffsets) { 30452 if (!normalizedOffsets.length) return normalizedOffsets; 30453 const { starts, ends } = getNormalizedIndexes(itemValue); 30454 const offsets = []; 30455 for (const [normalizedOffset, normalizedLength] of normalizedOffsets) { 30456 const start2 = starts[normalizedOffset]; 30457 const end = ends[normalizedOffset + normalizedLength]; 30458 if (start2 == null || end == null) continue; 30459 if (end <= start2) continue; 30460 offsets.push([start2, end - start2]); 30461 } 30462 return offsets; 30463 } 30464 function splitValue(itemValue, userValue) { 30465 if (!itemValue) return itemValue; 30466 if (!userValue) return itemValue; 30467 const userValues = toArray2(userValue).map(normalizeValue); 30468 const parts = []; 30469 const span = (value, autocomplete = false) => /* @__PURE__ */ (0, import_jsx_runtime153.jsx)("span", { 30470 "data-autocomplete-value": autocomplete ? "" : void 0, 30471 "data-user-value": autocomplete ? void 0 : "", 30472 children: value 30473 }, parts.length); 30474 const offsets = toOriginalOffsets(itemValue, mergeOverlappingOffsets(getOffsets(normalizeValue(itemValue), new Set(userValues)))); 30475 const firstEntry = offsets[0]; 30476 if (!firstEntry) { 30477 parts.push(span(itemValue, true)); 30478 return parts; 30479 } 30480 const [firstOffset] = firstEntry; 30481 [itemValue.slice(0, firstOffset), ...offsets.flatMap(([offset4, length], i2) => { 30482 const value = itemValue.slice(offset4, offset4 + length); 30483 const nextOffset = offsets[i2 + 1]?.[0]; 30484 return [value, itemValue.slice(offset4 + length, nextOffset)]; 30485 })].forEach((value, i2) => { 30486 if (!value) return; 30487 parts.push(span(value, i2 % 2 === 0)); 30488 }); 30489 return parts; 30490 } 30491 var useComboboxItemValue = createHook(function useComboboxItemValue2({ store: store2, value, userValue, ...props }) { 30492 const context = useComboboxScopedContext(); 30493 store2 = store2 || context; 30494 const itemContext = (0, import_react30.useContext)(ComboboxItemValueContext); 30495 const itemValue = value ?? itemContext; 30496 const inputValue = useStoreState(store2, (state) => userValue ?? state?.value); 30497 props = { 30498 children: (0, import_react30.useMemo)(() => { 30499 if (!itemValue) return; 30500 if (!inputValue) return itemValue; 30501 return splitValue(itemValue, inputValue); 30502 }, [itemValue, inputValue]), 30503 ...props 30504 }; 30505 return removeUndefinedValues(props); 30506 }); 30507 var ComboboxItemValue = forwardRef43(function ComboboxItemValue2(props) { 30508 return createElement5(TagName11, useComboboxItemValue(props)); 30509 }); 30510 30511 // node_modules/@ariakit/react-components/dist/combobox/combobox-label.js 30512 var TagName12 = "label"; 30513 var useComboboxLabel = createHook(function useComboboxLabel2({ store: store2, ...props }) { 30514 const context = useComboboxProviderContext(); 30515 store2 = store2 || context; 30516 invariant(store2, "ComboboxLabel must receive a `store` prop or be wrapped in a ComboboxProvider component."); 30517 props = { 30518 htmlFor: useStoreState(store2, (state) => state.baseElement?.id), 30519 ...props 30520 }; 30521 return removeUndefinedValues(props); 30522 }); 30523 var ComboboxLabel = memo5(forwardRef43(function ComboboxLabel2(props) { 30524 return createElement5(TagName12, useComboboxLabel(props)); 30525 })); 30526 30527 // node_modules/@ariakit/react-components/dist/combobox/combobox-list.js 30528 var import_react31 = __toESM(require_react(), 1); 30529 var import_jsx_runtime154 = __toESM(require_jsx_runtime(), 1); 30530 var TagName13 = "div"; 30531 var useComboboxList = createHook(function useComboboxList2({ store: store2, alwaysVisible, ...props }) { 30532 const scopedContext = useComboboxScopedContext(true); 30533 const context = useComboboxContext(); 30534 store2 = store2 || context; 30535 const scopedContextSameStore = !!store2 && store2 === scopedContext; 30536 invariant(store2, "ComboboxList must receive a `store` prop or be wrapped in a ComboboxProvider component."); 30537 const ref = (0, import_react31.useRef)(null); 30538 const id = useId5(props.id); 30539 const mounted = useStoreState(store2, "mounted"); 30540 const hidden = isHidden(mounted, props.hidden, alwaysVisible); 30541 const style = hidden ? { 30542 ...props.style, 30543 display: "none" 30544 } : props.style; 30545 const multiSelectable = useStoreState(store2, (state) => Array.isArray(state.selectedValue)); 30546 const role = useAttribute(ref, "role", props.role); 30547 const ariaMultiSelectable = role === "listbox" || role === "tree" || role === "grid" ? multiSelectable || void 0 : void 0; 30548 const [hasListboxInside, setHasListboxInside] = (0, import_react31.useState)(false); 30549 const contentElement = useStoreState(store2, "contentElement"); 30550 useSafeLayoutEffect(() => { 30551 if (!mounted) return; 30552 const element = ref.current; 30553 if (!element) return; 30554 if (contentElement !== element) return; 30555 const callback = () => { 30556 setHasListboxInside(!!element.querySelector("[role='listbox']")); 30557 }; 30558 const observer = new MutationObserver(callback); 30559 observer.observe(element, { 30560 subtree: true, 30561 childList: true, 30562 attributeFilter: ["role"] 30563 }); 30564 callback(); 30565 return () => observer.disconnect(); 30566 }, [mounted, contentElement]); 30567 if (!hasListboxInside) props = { 30568 role: "listbox", 30569 "aria-multiselectable": ariaMultiSelectable, 30570 ...props 30571 }; 30572 props = useWrapElement(props, (element) => /* @__PURE__ */ (0, import_jsx_runtime154.jsx)(ComboboxScopedContextProvider, { 30573 value: store2, 30574 children: /* @__PURE__ */ (0, import_jsx_runtime154.jsx)(ComboboxListRoleContext.Provider, { 30575 value: role, 30576 children: element 30577 }) 30578 }), [store2, role]); 30579 const setContentElement = id && (!scopedContext || !scopedContextSameStore) ? store2.setContentElement : null; 30580 props = { 30581 hidden, 30582 ...props, 30583 id, 30584 ref: useMergeRefs(setContentElement, ref, props.ref), 30585 style 30586 }; 30587 return removeUndefinedValues(props); 30588 }); 30589 var ComboboxList = forwardRef43(function ComboboxList2(props) { 30590 return createElement5(TagName13, useComboboxList(props)); 30591 }); 30592 30593 // node_modules/@ariakit/react-components/dist/tag/tag-context.js 30594 var import_react32 = __toESM(require_react(), 1); 30595 var TagValueContext = (0, import_react32.createContext)(null); 30596 var TagRemoveIdContext = (0, import_react32.createContext)(null); 30597 var ctx8 = createStoreContext([CompositeContextProvider], [CompositeScopedContextProvider]); 30598 var useTagContext = ctx8.useContext; 30599 var useTagScopedContext = ctx8.useScopedContext; 30600 var useTagProviderContext = ctx8.useProviderContext; 30601 var TagContextProvider = ctx8.ContextProvider; 30602 var TagScopedContextProvider = ctx8.ScopedContextProvider; 30603 30604 // node_modules/@ariakit/components/dist/combobox/combobox-store.js 30605 var isTouchSafari = isSafari() && isTouchDevice(); 30606 function createComboboxStore({ tag, ...props } = {}) { 30607 const store2 = mergeStore(props.store, pick2(tag, ["value", "rtl"])); 30608 throwOnConflictingProps(props, store2); 30609 const tagState = tag?.getState(); 30610 const syncState = store2?.getState(); 30611 const activeId = defaultValue(props.activeId, syncState?.activeId, props.defaultActiveId, null); 30612 const composite = createCompositeStore({ 30613 ...props, 30614 activeId, 30615 includesBaseElement: defaultValue(props.includesBaseElement, syncState?.includesBaseElement, true), 30616 orientation: defaultValue(props.orientation, syncState?.orientation, "vertical"), 30617 focusLoop: defaultValue(props.focusLoop, syncState?.focusLoop, true), 30618 focusWrap: defaultValue(props.focusWrap, syncState?.focusWrap, true), 30619 virtualFocus: defaultValue(props.virtualFocus, syncState?.virtualFocus, true) 30620 }); 30621 const popover = createPopoverStore({ 30622 ...props, 30623 placement: defaultValue(props.placement, syncState?.placement, "bottom-start") 30624 }); 30625 const value = defaultValue(props.value, syncState?.value, props.defaultValue, ""); 30626 const selectedValue = defaultValue(props.selectedValue, syncState?.selectedValue, tagState?.values, props.defaultSelectedValue, ""); 30627 const multiSelectable = Array.isArray(selectedValue); 30628 const initialState = { 30629 ...composite.getState(), 30630 ...popover.getState(), 30631 value, 30632 selectedValue, 30633 resetValueOnSelect: defaultValue(props.resetValueOnSelect, syncState?.resetValueOnSelect, multiSelectable), 30634 resetValueOnHide: defaultValue(props.resetValueOnHide, syncState?.resetValueOnHide, multiSelectable && !tag), 30635 activeValue: syncState?.activeValue 30636 }; 30637 const combobox = createStore(initialState, composite, popover, store2); 30638 if (isTouchSafari) setup(combobox, () => sync2(combobox, ["virtualFocus"], () => { 30639 combobox.setState("virtualFocus", false); 30640 })); 30641 setup(combobox, () => { 30642 if (!tag) return; 30643 return chain(sync2(combobox, ["selectedValue"], (state) => { 30644 if (!Array.isArray(state.selectedValue)) return; 30645 tag.setValues(state.selectedValue); 30646 }), sync2(tag, ["values"], (state) => { 30647 combobox.setState("selectedValue", state.values); 30648 })); 30649 }); 30650 setup(combobox, () => sync2(combobox, ["resetValueOnHide", "mounted"], (state) => { 30651 if (!state.resetValueOnHide) return; 30652 if (state.mounted) return; 30653 combobox.setState("value", value); 30654 })); 30655 setup(combobox, () => sync2(combobox, ["open"], (state) => { 30656 if (state.open) return; 30657 combobox.setState("activeId", activeId); 30658 combobox.setState("moves", 0); 30659 })); 30660 setup(combobox, () => sync2(combobox, ["moves", "activeId"], (state, prevState) => { 30661 if (state.moves === prevState.moves) combobox.setState("activeValue", void 0); 30662 })); 30663 setup(combobox, () => batch(combobox, ["moves", "renderedItems"], (state, prev) => { 30664 if (state.moves === prev.moves) return; 30665 const { activeId: activeId2 } = combobox.getState(); 30666 const activeItem = composite.item(activeId2); 30667 combobox.setState("activeValue", activeItem?.value); 30668 })); 30669 return { 30670 ...popover, 30671 ...composite, 30672 ...combobox, 30673 tag, 30674 setValue: (value2) => combobox.setState("value", value2), 30675 resetValue: () => combobox.setState("value", initialState.value), 30676 setSelectedValue: (selectedValue2) => combobox.setState("selectedValue", selectedValue2) 30677 }; 30678 } 30679 30680 // node_modules/@ariakit/react-components/dist/combobox/combobox-store.js 30681 function useComboboxStoreOptions(props) { 30682 const tag = useTagContext(); 30683 props = { 30684 ...props, 30685 tag: props.tag !== void 0 ? props.tag : tag 30686 }; 30687 return useCompositeStoreOptions(props); 30688 } 30689 function useComboboxStoreProps(store2, update4, props) { 30690 useUpdateEffect(update4, [props.tag]); 30691 useStoreProps(store2, props, "value", "setValue"); 30692 useStoreProps(store2, props, "selectedValue", "setSelectedValue"); 30693 useStoreProps(store2, props, "resetValueOnHide"); 30694 useStoreProps(store2, props, "resetValueOnSelect"); 30695 return Object.assign(useCompositeStoreProps(usePopoverStoreProps(store2, update4, props), update4, props), { tag: props.tag }); 30696 } 30697 function useComboboxStore(props = {}) { 30698 props = useComboboxStoreOptions(props); 30699 const [store2, update4] = useStore2(createComboboxStore, props); 30700 return useComboboxStoreProps(store2, update4, props); 30701 } 30702 30703 // node_modules/@ariakit/react-components/dist/combobox/combobox-provider.js 30704 var import_jsx_runtime155 = __toESM(require_jsx_runtime(), 1); 30705 function ComboboxProvider(props = {}) { 30706 return /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(ComboboxContextProvider, { 30707 value: useComboboxStore(props), 30708 children: props.children 30709 }); 30710 } 30711 30712 // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs 30713 var import_remove_accents = __toESM(require_remove_accents(), 1); 30714 var import_compose12 = __toESM(require_compose(), 1); 30715 var import_i18n46 = __toESM(require_i18n(), 1); 30716 var import_element83 = __toESM(require_element(), 1); 30717 var import_components38 = __toESM(require_components(), 1); 30718 30719 // packages/dataviews/build-module/components/dataviews-filters/utils.mjs 30720 var EMPTY_ARRAY4 = []; 30721 var getCurrentValue = (filterDefinition, currentFilter) => { 30722 if (filterDefinition.singleSelection) { 30723 return currentFilter?.value; 30724 } 30725 if (Array.isArray(currentFilter?.value)) { 30726 return currentFilter.value; 30727 } 30728 if (!Array.isArray(currentFilter?.value) && !!currentFilter?.value) { 30729 return [currentFilter.value]; 30730 } 30731 return EMPTY_ARRAY4; 30732 }; 30733 30734 // packages/dataviews/build-module/hooks/use-elements.mjs 30735 var import_element82 = __toESM(require_element(), 1); 30736 var EMPTY_ARRAY5 = []; 30737 function useElements({ 30738 elements: elements2, 30739 getElements 30740 }) { 30741 const staticElements = Array.isArray(elements2) && elements2.length > 0 ? elements2 : EMPTY_ARRAY5; 30742 const [records, setRecords] = (0, import_element82.useState)(staticElements); 30743 const [isLoading, setIsLoading] = (0, import_element82.useState)(false); 30744 (0, import_element82.useEffect)(() => { 30745 if (!getElements) { 30746 setRecords(staticElements); 30747 return; 30748 } 30749 let cancelled = false; 30750 setIsLoading(true); 30751 getElements().then((fetchedElements) => { 30752 if (!cancelled) { 30753 const dynamicElements = Array.isArray(fetchedElements) && fetchedElements.length > 0 ? fetchedElements : staticElements; 30754 setRecords(dynamicElements); 30755 } 30756 }).catch(() => { 30757 if (!cancelled) { 30758 setRecords(staticElements); 30759 } 30760 }).finally(() => { 30761 if (!cancelled) { 30762 setIsLoading(false); 30763 } 30764 }); 30765 return () => { 30766 cancelled = true; 30767 }; 30768 }, [getElements, staticElements]); 30769 return { 30770 elements: records, 30771 isLoading 30772 }; 30773 } 30774 30775 // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs 30776 var import_jsx_runtime156 = __toESM(require_jsx_runtime(), 1); 30777 function normalizeSearchInput(input = "") { 30778 return (0, import_remove_accents.default)(input.trim().toLowerCase()); 30779 } 30780 var getNewValue = (filterDefinition, currentFilter, value) => { 30781 if (filterDefinition.singleSelection) { 30782 return value; 30783 } 30784 if (Array.isArray(currentFilter?.value)) { 30785 return currentFilter.value.includes(value) ? currentFilter.value.filter((v2) => v2 !== value) : [...currentFilter.value, value]; 30786 } 30787 return [value]; 30788 }; 30789 function generateFilterElementCompositeItemId(prefix2, filterElementValue) { 30790 return `$prefix2}-$filterElementValue}`; 30791 } 30792 var MultiSelectionOption = ({ selected }) => { 30793 return /* @__PURE__ */ (0, import_jsx_runtime156.jsx)( 30794 "span", 30795 { 30796 className: clsx_default( 30797 "dataviews-filters__search-widget-listitem-multi-selection", 30798 { "is-selected": selected } 30799 ), 30800 children: selected && /* @__PURE__ */ (0, import_jsx_runtime156.jsx)(import_components38.Icon, { icon: check_default }) 30801 } 30802 ); 30803 }; 30804 var SingleSelectionOption = ({ selected }) => { 30805 return /* @__PURE__ */ (0, import_jsx_runtime156.jsx)( 30806 "span", 30807 { 30808 className: clsx_default( 30809 "dataviews-filters__search-widget-listitem-single-selection", 30810 { "is-selected": selected } 30811 ) 30812 } 30813 ); 30814 }; 30815 function ListBox({ view, filter, onChangeView }) { 30816 const baseId = (0, import_compose12.useInstanceId)(ListBox, "dataviews-filter-list-box"); 30817 const [activeCompositeId, setActiveCompositeId] = (0, import_element83.useState)( 30818 // When there are one or less operators, the first item is set as active 30819 // (by setting the initial `activeId` to `undefined`). 30820 // With 2 or more operators, the focus is moved on the operators control 30821 // (by setting the initial `activeId` to `null`), meaning that there won't 30822 // be an active item initially. Focus is then managed via the 30823 // `onFocusVisible` callback. 30824 filter.operators?.length === 1 ? void 0 : null 30825 ); 30826 const currentFilter = view.filters?.find( 30827 (f2) => f2.field === filter.field 30828 ); 30829 const currentValue = getCurrentValue(filter, currentFilter); 30830 return /* @__PURE__ */ (0, import_jsx_runtime156.jsx)( 30831 import_components38.Composite, 30832 { 30833 virtualFocus: true, 30834 focusLoop: true, 30835 activeId: activeCompositeId, 30836 setActiveId: setActiveCompositeId, 30837 role: "listbox", 30838 className: "dataviews-filters__search-widget-listbox", 30839 "aria-label": (0, import_i18n46.sprintf)( 30840 /* translators: List of items for a filter. 1: Filter name. e.g.: "List of: Author". */ 30841 (0, import_i18n46.__)("List of: %1$s"), 30842 filter.name 30843 ), 30844 onFocusVisible: () => { 30845 if (!activeCompositeId && filter.elements.length) { 30846 setActiveCompositeId( 30847 generateFilterElementCompositeItemId( 30848 baseId, 30849 filter.elements[0].value 30850 ) 30851 ); 30852 } 30853 }, 30854 render: /* @__PURE__ */ (0, import_jsx_runtime156.jsx)(import_components38.Composite.Typeahead, {}), 30855 children: filter.elements.map((element) => /* @__PURE__ */ (0, import_jsx_runtime156.jsxs)( 30856 import_components38.Composite.Hover, 30857 { 30858 render: /* @__PURE__ */ (0, import_jsx_runtime156.jsx)( 30859 import_components38.Composite.Item, 30860 { 30861 id: generateFilterElementCompositeItemId( 30862 baseId, 30863 element.value 30864 ), 30865 render: /* @__PURE__ */ (0, import_jsx_runtime156.jsx)( 30866 "div", 30867 { 30868 "aria-label": element.label, 30869 role: "option", 30870 className: "dataviews-filters__search-widget-listitem" 30871 } 30872 ), 30873 onClick: () => { 30874 const newFilters = currentFilter ? [ 30875 ...(view.filters ?? []).map( 30876 (_filter) => { 30877 if (_filter.field === filter.field) { 30878 return { 30879 ..._filter, 30880 operator: currentFilter.operator || filter.operators[0], 30881 value: getNewValue( 30882 filter, 30883 currentFilter, 30884 element.value 30885 ) 30886 }; 30887 } 30888 return _filter; 30889 } 30890 ) 30891 ] : [ 30892 ...view.filters ?? [], 30893 { 30894 field: filter.field, 30895 operator: filter.operators[0], 30896 value: getNewValue( 30897 filter, 30898 currentFilter, 30899 element.value 30900 ) 30901 } 30902 ]; 30903 onChangeView({ 30904 ...view, 30905 page: 1, 30906 filters: newFilters 30907 }); 30908 } 30909 } 30910 ), 30911 children: [ 30912 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime156.jsx)( 30913 SingleSelectionOption, 30914 { 30915 selected: currentValue === element.value 30916 } 30917 ), 30918 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime156.jsx)( 30919 MultiSelectionOption, 30920 { 30921 selected: currentValue.includes(element.value) 30922 } 30923 ), 30924 /* @__PURE__ */ (0, import_jsx_runtime156.jsx)( 30925 "span", 30926 { 30927 className: "dataviews-filters__search-widget-listitem-value", 30928 title: element.label, 30929 children: element.label 30930 } 30931 ) 30932 ] 30933 }, 30934 element.value 30935 )) 30936 } 30937 ); 30938 } 30939 function ComboboxList22({ view, filter, onChangeView }) { 30940 const [searchValue, setSearchValue] = (0, import_element83.useState)(""); 30941 const deferredSearchValue = (0, import_element83.useDeferredValue)(searchValue); 30942 const currentFilter = view.filters?.find( 30943 (_filter) => _filter.field === filter.field 30944 ); 30945 const currentValue = getCurrentValue(filter, currentFilter); 30946 const matches = (0, import_element83.useMemo)(() => { 30947 const normalizedSearch = normalizeSearchInput(deferredSearchValue); 30948 return filter.elements.filter( 30949 (item) => normalizeSearchInput(item.label).includes(normalizedSearch) 30950 ); 30951 }, [filter.elements, deferredSearchValue]); 30952 return /* @__PURE__ */ (0, import_jsx_runtime156.jsxs)( 30953 ComboboxProvider, 30954 { 30955 selectedValue: currentValue, 30956 setSelectedValue: (value) => { 30957 const newFilters = currentFilter ? [ 30958 ...(view.filters ?? []).map((_filter) => { 30959 if (_filter.field === filter.field) { 30960 return { 30961 ..._filter, 30962 operator: currentFilter.operator || filter.operators[0], 30963 value 30964 }; 30965 } 30966 return _filter; 30967 }) 30968 ] : [ 30969 ...view.filters ?? [], 30970 { 30971 field: filter.field, 30972 operator: filter.operators[0], 30973 value 30974 } 30975 ]; 30976 onChangeView({ 30977 ...view, 30978 page: 1, 30979 filters: newFilters 30980 }); 30981 }, 30982 setValue: setSearchValue, 30983 children: [ 30984 /* @__PURE__ */ (0, import_jsx_runtime156.jsxs)("div", { className: "dataviews-filters__search-widget-filter-combobox__wrapper", children: [ 30985 /* @__PURE__ */ (0, import_jsx_runtime156.jsx)(VisuallyHidden, { render: /* @__PURE__ */ (0, import_jsx_runtime156.jsx)(ComboboxLabel, {}), children: (0, import_i18n46.__)("Search items") }), 30986 /* @__PURE__ */ (0, import_jsx_runtime156.jsx)( 30987 Combobox, 30988 { 30989 autoSelect: "always", 30990 placeholder: (0, import_i18n46.__)("Search"), 30991 className: "dataviews-filters__search-widget-filter-combobox__input" 30992 } 30993 ), 30994 /* @__PURE__ */ (0, import_jsx_runtime156.jsx)("div", { className: "dataviews-filters__search-widget-filter-combobox__icon", children: /* @__PURE__ */ (0, import_jsx_runtime156.jsx)(import_components38.Icon, { icon: search_default }) }) 30995 ] }), 30996 /* @__PURE__ */ (0, import_jsx_runtime156.jsxs)( 30997 ComboboxList, 30998 { 30999 className: "dataviews-filters__search-widget-filter-combobox-list", 31000 alwaysVisible: true, 31001 children: [ 31002 matches.map((element) => { 31003 return /* @__PURE__ */ (0, import_jsx_runtime156.jsxs)( 31004 ComboboxItem, 31005 { 31006 resetValueOnSelect: false, 31007 value: element.value, 31008 className: "dataviews-filters__search-widget-listitem", 31009 hideOnClick: false, 31010 setValueOnClick: false, 31011 focusOnHover: true, 31012 children: [ 31013 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime156.jsx)( 31014 SingleSelectionOption, 31015 { 31016 selected: currentValue === element.value 31017 } 31018 ), 31019 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime156.jsx)( 31020 MultiSelectionOption, 31021 { 31022 selected: currentValue.includes( 31023 element.value 31024 ) 31025 } 31026 ), 31027 /* @__PURE__ */ (0, import_jsx_runtime156.jsxs)( 31028 "span", 31029 { 31030 className: "dataviews-filters__search-widget-listitem-value", 31031 title: element.label, 31032 children: [ 31033 /* @__PURE__ */ (0, import_jsx_runtime156.jsx)( 31034 ComboboxItemValue, 31035 { 31036 className: "dataviews-filters__search-widget-filter-combobox-item-value", 31037 value: element.label 31038 } 31039 ), 31040 !!element.description && /* @__PURE__ */ (0, import_jsx_runtime156.jsx)("span", { className: "dataviews-filters__search-widget-listitem-description", children: element.description }) 31041 ] 31042 } 31043 ) 31044 ] 31045 }, 31046 element.value 31047 ); 31048 }), 31049 !matches.length && /* @__PURE__ */ (0, import_jsx_runtime156.jsx)("p", { children: (0, import_i18n46.__)("No results found") }) 31050 ] 31051 } 31052 ) 31053 ] 31054 } 31055 ); 31056 } 31057 function SearchWidget(props) { 31058 const { elements: elements2, isLoading } = useElements({ 31059 elements: props.filter.elements, 31060 getElements: props.filter.getElements 31061 }); 31062 if (isLoading) { 31063 return /* @__PURE__ */ (0, import_jsx_runtime156.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: /* @__PURE__ */ (0, import_jsx_runtime156.jsx)(import_components38.Spinner, {}) }); 31064 } 31065 if (elements2.length === 0) { 31066 return /* @__PURE__ */ (0, import_jsx_runtime156.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: (0, import_i18n46.__)("No elements found") }); 31067 } 31068 const Widget = elements2.length > 10 ? ComboboxList22 : ListBox; 31069 return /* @__PURE__ */ (0, import_jsx_runtime156.jsx)(Widget, { ...props, filter: { ...props.filter, elements: elements2 } }); 31070 } 31071 31072 // packages/dataviews/build-module/components/dataviews-filters/input-widget.mjs 31073 var import_es62 = __toESM(require_es6(), 1); 31074 var import_compose13 = __toESM(require_compose(), 1); 31075 var import_element84 = __toESM(require_element(), 1); 31076 var import_components39 = __toESM(require_components(), 1); 31077 var import_jsx_runtime157 = __toESM(require_jsx_runtime(), 1); 31078 function InputWidget({ 31079 filter, 31080 view, 31081 onChangeView, 31082 fields: fields2 31083 }) { 31084 const currentFilter = view.filters?.find( 31085 (f2) => f2.field === filter.field 31086 ); 31087 const currentValue = getCurrentValue(filter, currentFilter); 31088 const field = (0, import_element84.useMemo)(() => { 31089 const currentField = fields2.find((f2) => f2.id === filter.field); 31090 if (currentField) { 31091 return { 31092 ...currentField, 31093 // Deactivate validation for filters. 31094 isValid: {}, 31095 // Filter controls are always enabled. 31096 isDisabled: () => false, 31097 // Filter controls are always visible. 31098 isVisible: () => true, 31099 // Configure getValue/setValue as if Item was a plain object. 31100 getValue: ({ item }) => item[currentField.id], 31101 setValue: ({ value }) => ({ 31102 [currentField.id]: value 31103 }) 31104 }; 31105 } 31106 return currentField; 31107 }, [fields2, filter.field]); 31108 const data = (0, import_element84.useMemo)(() => { 31109 return (view.filters ?? []).reduce( 31110 (acc, activeFilter) => { 31111 acc[activeFilter.field] = activeFilter.value; 31112 return acc; 31113 }, 31114 {} 31115 ); 31116 }, [view.filters]); 31117 const handleChange = (0, import_compose13.useEvent)((updatedData) => { 31118 if (!field || !currentFilter) { 31119 return; 31120 } 31121 const nextValue = field.getValue({ item: updatedData }); 31122 if ((0, import_es62.default)(nextValue, currentValue)) { 31123 return; 31124 } 31125 onChangeView({ 31126 ...view, 31127 filters: (view.filters ?? []).map( 31128 (_filter) => _filter.field === filter.field ? { 31129 ..._filter, 31130 operator: currentFilter.operator || filter.operators[0], 31131 // Consider empty strings as undefined: 31132 // 31133 // - undefined as value means the filter is unset: the filter widget displays no value and the search returns all records 31134 // - empty string as value means "search empty string": returns only the records that have an empty string as value 31135 // 31136 // In practice, this means the filter will not be able to find an empty string as the value. 31137 value: nextValue === "" ? void 0 : nextValue 31138 } : _filter 31139 ) 31140 }); 31141 }); 31142 if (!field || !field.Edit || !currentFilter) { 31143 return null; 31144 } 31145 return /* @__PURE__ */ (0, import_jsx_runtime157.jsx)( 31146 import_components39.Flex, 31147 { 31148 className: "dataviews-filters__user-input-widget", 31149 gap: 2.5, 31150 direction: "column", 31151 children: /* @__PURE__ */ (0, import_jsx_runtime157.jsx)( 31152 field.Edit, 31153 { 31154 hideLabelFromVision: true, 31155 data, 31156 field, 31157 operator: currentFilter.operator, 31158 onChange: handleChange 31159 } 31160 ) 31161 } 31162 ); 31163 } 31164 31165 // node_modules/date-fns/constants.js 31166 var daysInYear = 365.2425; 31167 var maxTime = Math.pow(10, 8) * 24 * 60 * 60 * 1e3; 31168 var minTime = -maxTime; 31169 var millisecondsInWeek = 6048e5; 31170 var millisecondsInDay = 864e5; 31171 var secondsInHour = 3600; 31172 var secondsInDay = secondsInHour * 24; 31173 var secondsInWeek = secondsInDay * 7; 31174 var secondsInYear = secondsInDay * daysInYear; 31175 var secondsInMonth = secondsInYear / 12; 31176 var secondsInQuarter = secondsInMonth * 3; 31177 var constructFromSymbol = /* @__PURE__ */ Symbol.for("constructDateFrom"); 31178 31179 // node_modules/date-fns/constructFrom.js 31180 function constructFrom(date, value) { 31181 if (typeof date === "function") return date(value); 31182 if (date && typeof date === "object" && constructFromSymbol in date) 31183 return date[constructFromSymbol](value); 31184 if (date instanceof Date) return new date.constructor(value); 31185 return new Date(value); 31186 } 31187 31188 // node_modules/date-fns/toDate.js 31189 function toDate(argument, context) { 31190 return constructFrom(context || argument, argument); 31191 } 31192 31193 // node_modules/date-fns/addDays.js 31194 function addDays(date, amount, options) { 31195 const _date = toDate(date, options?.in); 31196 if (isNaN(amount)) return constructFrom(options?.in || date, NaN); 31197 if (!amount) return _date; 31198 _date.setDate(_date.getDate() + amount); 31199 return _date; 31200 } 31201 31202 // node_modules/date-fns/addMonths.js 31203 function addMonths(date, amount, options) { 31204 const _date = toDate(date, options?.in); 31205 if (isNaN(amount)) return constructFrom(options?.in || date, NaN); 31206 if (!amount) { 31207 return _date; 31208 } 31209 const dayOfMonth = _date.getDate(); 31210 const endOfDesiredMonth = constructFrom(options?.in || date, _date.getTime()); 31211 endOfDesiredMonth.setMonth(_date.getMonth() + amount + 1, 0); 31212 const daysInMonth = endOfDesiredMonth.getDate(); 31213 if (dayOfMonth >= daysInMonth) { 31214 return endOfDesiredMonth; 31215 } else { 31216 _date.setFullYear( 31217 endOfDesiredMonth.getFullYear(), 31218 endOfDesiredMonth.getMonth(), 31219 dayOfMonth 31220 ); 31221 return _date; 31222 } 31223 } 31224 31225 // node_modules/date-fns/_lib/defaultOptions.js 31226 var defaultOptions = {}; 31227 function getDefaultOptions() { 31228 return defaultOptions; 31229 } 31230 31231 // node_modules/date-fns/startOfWeek.js 31232 function startOfWeek(date, options) { 31233 const defaultOptions2 = getDefaultOptions(); 31234 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0; 31235 const _date = toDate(date, options?.in); 31236 const day = _date.getDay(); 31237 const diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn; 31238 _date.setDate(_date.getDate() - diff); 31239 _date.setHours(0, 0, 0, 0); 31240 return _date; 31241 } 31242 31243 // node_modules/date-fns/startOfISOWeek.js 31244 function startOfISOWeek(date, options) { 31245 return startOfWeek(date, { ...options, weekStartsOn: 1 }); 31246 } 31247 31248 // node_modules/date-fns/getISOWeekYear.js 31249 function getISOWeekYear(date, options) { 31250 const _date = toDate(date, options?.in); 31251 const year = _date.getFullYear(); 31252 const fourthOfJanuaryOfNextYear = constructFrom(_date, 0); 31253 fourthOfJanuaryOfNextYear.setFullYear(year + 1, 0, 4); 31254 fourthOfJanuaryOfNextYear.setHours(0, 0, 0, 0); 31255 const startOfNextYear = startOfISOWeek(fourthOfJanuaryOfNextYear); 31256 const fourthOfJanuaryOfThisYear = constructFrom(_date, 0); 31257 fourthOfJanuaryOfThisYear.setFullYear(year, 0, 4); 31258 fourthOfJanuaryOfThisYear.setHours(0, 0, 0, 0); 31259 const startOfThisYear = startOfISOWeek(fourthOfJanuaryOfThisYear); 31260 if (_date.getTime() >= startOfNextYear.getTime()) { 31261 return year + 1; 31262 } else if (_date.getTime() >= startOfThisYear.getTime()) { 31263 return year; 31264 } else { 31265 return year - 1; 31266 } 31267 } 31268 31269 // node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.js 31270 function getTimezoneOffsetInMilliseconds(date) { 31271 const _date = toDate(date); 31272 const utcDate = new Date( 31273 Date.UTC( 31274 _date.getFullYear(), 31275 _date.getMonth(), 31276 _date.getDate(), 31277 _date.getHours(), 31278 _date.getMinutes(), 31279 _date.getSeconds(), 31280 _date.getMilliseconds() 31281 ) 31282 ); 31283 utcDate.setUTCFullYear(_date.getFullYear()); 31284 return +date - +utcDate; 31285 } 31286 31287 // node_modules/date-fns/_lib/normalizeDates.js 31288 function normalizeDates(context, ...dates) { 31289 const normalize = constructFrom.bind( 31290 null, 31291 context || dates.find((date) => typeof date === "object") 31292 ); 31293 return dates.map(normalize); 31294 } 31295 31296 // node_modules/date-fns/startOfDay.js 31297 function startOfDay(date, options) { 31298 const _date = toDate(date, options?.in); 31299 _date.setHours(0, 0, 0, 0); 31300 return _date; 31301 } 31302 31303 // node_modules/date-fns/differenceInCalendarDays.js 31304 function differenceInCalendarDays(laterDate, earlierDate, options) { 31305 const [laterDate_, earlierDate_] = normalizeDates( 31306 options?.in, 31307 laterDate, 31308 earlierDate 31309 ); 31310 const laterStartOfDay = startOfDay(laterDate_); 31311 const earlierStartOfDay = startOfDay(earlierDate_); 31312 const laterTimestamp = +laterStartOfDay - getTimezoneOffsetInMilliseconds(laterStartOfDay); 31313 const earlierTimestamp = +earlierStartOfDay - getTimezoneOffsetInMilliseconds(earlierStartOfDay); 31314 return Math.round((laterTimestamp - earlierTimestamp) / millisecondsInDay); 31315 } 31316 31317 // node_modules/date-fns/startOfISOWeekYear.js 31318 function startOfISOWeekYear(date, options) { 31319 const year = getISOWeekYear(date, options); 31320 const fourthOfJanuary = constructFrom(options?.in || date, 0); 31321 fourthOfJanuary.setFullYear(year, 0, 4); 31322 fourthOfJanuary.setHours(0, 0, 0, 0); 31323 return startOfISOWeek(fourthOfJanuary); 31324 } 31325 31326 // node_modules/date-fns/addWeeks.js 31327 function addWeeks(date, amount, options) { 31328 return addDays(date, amount * 7, options); 31329 } 31330 31331 // node_modules/date-fns/addYears.js 31332 function addYears(date, amount, options) { 31333 return addMonths(date, amount * 12, options); 31334 } 31335 31336 // node_modules/date-fns/isDate.js 31337 function isDate(value) { 31338 return value instanceof Date || typeof value === "object" && Object.prototype.toString.call(value) === "[object Date]"; 31339 } 31340 31341 // node_modules/date-fns/isValid.js 31342 function isValid(date) { 31343 return !(!isDate(date) && typeof date !== "number" || isNaN(+toDate(date))); 31344 } 31345 31346 // node_modules/date-fns/startOfMonth.js 31347 function startOfMonth(date, options) { 31348 const _date = toDate(date, options?.in); 31349 _date.setDate(1); 31350 _date.setHours(0, 0, 0, 0); 31351 return _date; 31352 } 31353 31354 // node_modules/date-fns/startOfYear.js 31355 function startOfYear(date, options) { 31356 const date_ = toDate(date, options?.in); 31357 date_.setFullYear(date_.getFullYear(), 0, 1); 31358 date_.setHours(0, 0, 0, 0); 31359 return date_; 31360 } 31361 31362 // node_modules/date-fns/locale/en-US/_lib/formatDistance.js 31363 var formatDistanceLocale = { 31364 lessThanXSeconds: { 31365 one: "less than a second", 31366 other: "less than {{count}} seconds" 31367 }, 31368 xSeconds: { 31369 one: "1 second", 31370 other: "{{count}} seconds" 31371 }, 31372 halfAMinute: "half a minute", 31373 lessThanXMinutes: { 31374 one: "less than a minute", 31375 other: "less than {{count}} minutes" 31376 }, 31377 xMinutes: { 31378 one: "1 minute", 31379 other: "{{count}} minutes" 31380 }, 31381 aboutXHours: { 31382 one: "about 1 hour", 31383 other: "about {{count}} hours" 31384 }, 31385 xHours: { 31386 one: "1 hour", 31387 other: "{{count}} hours" 31388 }, 31389 xDays: { 31390 one: "1 day", 31391 other: "{{count}} days" 31392 }, 31393 aboutXWeeks: { 31394 one: "about 1 week", 31395 other: "about {{count}} weeks" 31396 }, 31397 xWeeks: { 31398 one: "1 week", 31399 other: "{{count}} weeks" 31400 }, 31401 aboutXMonths: { 31402 one: "about 1 month", 31403 other: "about {{count}} months" 31404 }, 31405 xMonths: { 31406 one: "1 month", 31407 other: "{{count}} months" 31408 }, 31409 aboutXYears: { 31410 one: "about 1 year", 31411 other: "about {{count}} years" 31412 }, 31413 xYears: { 31414 one: "1 year", 31415 other: "{{count}} years" 31416 }, 31417 overXYears: { 31418 one: "over 1 year", 31419 other: "over {{count}} years" 31420 }, 31421 almostXYears: { 31422 one: "almost 1 year", 31423 other: "almost {{count}} years" 31424 } 31425 }; 31426 var formatDistance = (token, count, options) => { 31427 let result; 31428 const tokenValue = formatDistanceLocale[token]; 31429 if (typeof tokenValue === "string") { 31430 result = tokenValue; 31431 } else if (count === 1) { 31432 result = tokenValue.one; 31433 } else { 31434 result = tokenValue.other.replace("{{count}}", count.toString()); 31435 } 31436 if (options?.addSuffix) { 31437 if (options.comparison && options.comparison > 0) { 31438 return "in " + result; 31439 } else { 31440 return result + " ago"; 31441 } 31442 } 31443 return result; 31444 }; 31445 31446 // node_modules/date-fns/locale/_lib/buildFormatLongFn.js 31447 function buildFormatLongFn(args) { 31448 return (options = {}) => { 31449 const width = options.width ? String(options.width) : args.defaultWidth; 31450 const format6 = args.formats[width] || args.formats[args.defaultWidth]; 31451 return format6; 31452 }; 31453 } 31454 31455 // node_modules/date-fns/locale/en-US/_lib/formatLong.js 31456 var dateFormats = { 31457 full: "EEEE, MMMM do, y", 31458 long: "MMMM do, y", 31459 medium: "MMM d, y", 31460 short: "MM/dd/yyyy" 31461 }; 31462 var timeFormats = { 31463 full: "h:mm:ss a zzzz", 31464 long: "h:mm:ss a z", 31465 medium: "h:mm:ss a", 31466 short: "h:mm a" 31467 }; 31468 var dateTimeFormats = { 31469 full: "{{date}} 'at' {{time}}", 31470 long: "{{date}} 'at' {{time}}", 31471 medium: "{{date}}, {{time}}", 31472 short: "{{date}}, {{time}}" 31473 }; 31474 var formatLong = { 31475 date: buildFormatLongFn({ 31476 formats: dateFormats, 31477 defaultWidth: "full" 31478 }), 31479 time: buildFormatLongFn({ 31480 formats: timeFormats, 31481 defaultWidth: "full" 31482 }), 31483 dateTime: buildFormatLongFn({ 31484 formats: dateTimeFormats, 31485 defaultWidth: "full" 31486 }) 31487 }; 31488 31489 // node_modules/date-fns/locale/en-US/_lib/formatRelative.js 31490 var formatRelativeLocale = { 31491 lastWeek: "'last' eeee 'at' p", 31492 yesterday: "'yesterday at' p", 31493 today: "'today at' p", 31494 tomorrow: "'tomorrow at' p", 31495 nextWeek: "eeee 'at' p", 31496 other: "P" 31497 }; 31498 var formatRelative = (token, _date, _baseDate, _options) => formatRelativeLocale[token]; 31499 31500 // node_modules/date-fns/locale/_lib/buildLocalizeFn.js 31501 function buildLocalizeFn(args) { 31502 return (value, options) => { 31503 const context = options?.context ? String(options.context) : "standalone"; 31504 let valuesArray; 31505 if (context === "formatting" && args.formattingValues) { 31506 const defaultWidth = args.defaultFormattingWidth || args.defaultWidth; 31507 const width = options?.width ? String(options.width) : defaultWidth; 31508 valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth]; 31509 } else { 31510 const defaultWidth = args.defaultWidth; 31511 const width = options?.width ? String(options.width) : args.defaultWidth; 31512 valuesArray = args.values[width] || args.values[defaultWidth]; 31513 } 31514 const index2 = args.argumentCallback ? args.argumentCallback(value) : value; 31515 return valuesArray[index2]; 31516 }; 31517 } 31518 31519 // node_modules/date-fns/locale/en-US/_lib/localize.js 31520 var eraValues = { 31521 narrow: ["B", "A"], 31522 abbreviated: ["BC", "AD"], 31523 wide: ["Before Christ", "Anno Domini"] 31524 }; 31525 var quarterValues = { 31526 narrow: ["1", "2", "3", "4"], 31527 abbreviated: ["Q1", "Q2", "Q3", "Q4"], 31528 wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"] 31529 }; 31530 var monthValues = { 31531 narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"], 31532 abbreviated: [ 31533 "Jan", 31534 "Feb", 31535 "Mar", 31536 "Apr", 31537 "May", 31538 "Jun", 31539 "Jul", 31540 "Aug", 31541 "Sep", 31542 "Oct", 31543 "Nov", 31544 "Dec" 31545 ], 31546 wide: [ 31547 "January", 31548 "February", 31549 "March", 31550 "April", 31551 "May", 31552 "June", 31553 "July", 31554 "August", 31555 "September", 31556 "October", 31557 "November", 31558 "December" 31559 ] 31560 }; 31561 var dayValues = { 31562 narrow: ["S", "M", "T", "W", "T", "F", "S"], 31563 short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"], 31564 abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], 31565 wide: [ 31566 "Sunday", 31567 "Monday", 31568 "Tuesday", 31569 "Wednesday", 31570 "Thursday", 31571 "Friday", 31572 "Saturday" 31573 ] 31574 }; 31575 var dayPeriodValues = { 31576 narrow: { 31577 am: "a", 31578 pm: "p", 31579 midnight: "mi", 31580 noon: "n", 31581 morning: "morning", 31582 afternoon: "afternoon", 31583 evening: "evening", 31584 night: "night" 31585 }, 31586 abbreviated: { 31587 am: "AM", 31588 pm: "PM", 31589 midnight: "midnight", 31590 noon: "noon", 31591 morning: "morning", 31592 afternoon: "afternoon", 31593 evening: "evening", 31594 night: "night" 31595 }, 31596 wide: { 31597 am: "a.m.", 31598 pm: "p.m.", 31599 midnight: "midnight", 31600 noon: "noon", 31601 morning: "morning", 31602 afternoon: "afternoon", 31603 evening: "evening", 31604 night: "night" 31605 } 31606 }; 31607 var formattingDayPeriodValues = { 31608 narrow: { 31609 am: "a", 31610 pm: "p", 31611 midnight: "mi", 31612 noon: "n", 31613 morning: "in the morning", 31614 afternoon: "in the afternoon", 31615 evening: "in the evening", 31616 night: "at night" 31617 }, 31618 abbreviated: { 31619 am: "AM", 31620 pm: "PM", 31621 midnight: "midnight", 31622 noon: "noon", 31623 morning: "in the morning", 31624 afternoon: "in the afternoon", 31625 evening: "in the evening", 31626 night: "at night" 31627 }, 31628 wide: { 31629 am: "a.m.", 31630 pm: "p.m.", 31631 midnight: "midnight", 31632 noon: "noon", 31633 morning: "in the morning", 31634 afternoon: "in the afternoon", 31635 evening: "in the evening", 31636 night: "at night" 31637 } 31638 }; 31639 var ordinalNumber = (dirtyNumber, _options) => { 31640 const number = Number(dirtyNumber); 31641 const rem100 = number % 100; 31642 if (rem100 > 20 || rem100 < 10) { 31643 switch (rem100 % 10) { 31644 case 1: 31645 return number + "st"; 31646 case 2: 31647 return number + "nd"; 31648 case 3: 31649 return number + "rd"; 31650 } 31651 } 31652 return number + "th"; 31653 }; 31654 var localize = { 31655 ordinalNumber, 31656 era: buildLocalizeFn({ 31657 values: eraValues, 31658 defaultWidth: "wide" 31659 }), 31660 quarter: buildLocalizeFn({ 31661 values: quarterValues, 31662 defaultWidth: "wide", 31663 argumentCallback: (quarter) => quarter - 1 31664 }), 31665 month: buildLocalizeFn({ 31666 values: monthValues, 31667 defaultWidth: "wide" 31668 }), 31669 day: buildLocalizeFn({ 31670 values: dayValues, 31671 defaultWidth: "wide" 31672 }), 31673 dayPeriod: buildLocalizeFn({ 31674 values: dayPeriodValues, 31675 defaultWidth: "wide", 31676 formattingValues: formattingDayPeriodValues, 31677 defaultFormattingWidth: "wide" 31678 }) 31679 }; 31680 31681 // node_modules/date-fns/locale/_lib/buildMatchFn.js 31682 function buildMatchFn(args) { 31683 return (string, options = {}) => { 31684 const width = options.width; 31685 const matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth]; 31686 const matchResult = string.match(matchPattern); 31687 if (!matchResult) { 31688 return null; 31689 } 31690 const matchedString = matchResult[0]; 31691 const parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth]; 31692 const key = Array.isArray(parsePatterns) ? findIndex2(parsePatterns, (pattern) => pattern.test(matchedString)) : ( 31693 // [TODO] -- I challenge you to fix the type 31694 findKey(parsePatterns, (pattern) => pattern.test(matchedString)) 31695 ); 31696 let value; 31697 value = args.valueCallback ? args.valueCallback(key) : key; 31698 value = options.valueCallback ? ( 31699 // [TODO] -- I challenge you to fix the type 31700 options.valueCallback(value) 31701 ) : value; 31702 const rest = string.slice(matchedString.length); 31703 return { value, rest }; 31704 }; 31705 } 31706 function findKey(object, predicate) { 31707 for (const key in object) { 31708 if (Object.prototype.hasOwnProperty.call(object, key) && predicate(object[key])) { 31709 return key; 31710 } 31711 } 31712 return void 0; 31713 } 31714 function findIndex2(array, predicate) { 31715 for (let key = 0; key < array.length; key++) { 31716 if (predicate(array[key])) { 31717 return key; 31718 } 31719 } 31720 return void 0; 31721 } 31722 31723 // node_modules/date-fns/locale/_lib/buildMatchPatternFn.js 31724 function buildMatchPatternFn(args) { 31725 return (string, options = {}) => { 31726 const matchResult = string.match(args.matchPattern); 31727 if (!matchResult) return null; 31728 const matchedString = matchResult[0]; 31729 const parseResult = string.match(args.parsePattern); 31730 if (!parseResult) return null; 31731 let value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0]; 31732 value = options.valueCallback ? options.valueCallback(value) : value; 31733 const rest = string.slice(matchedString.length); 31734 return { value, rest }; 31735 }; 31736 } 31737 31738 // node_modules/date-fns/locale/en-US/_lib/match.js 31739 var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i; 31740 var parseOrdinalNumberPattern = /\d+/i; 31741 var matchEraPatterns = { 31742 narrow: /^(b|a)/i, 31743 abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i, 31744 wide: /^(before christ|before common era|anno domini|common era)/i 31745 }; 31746 var parseEraPatterns = { 31747 any: [/^b/i, /^(a|c)/i] 31748 }; 31749 var matchQuarterPatterns = { 31750 narrow: /^[1234]/i, 31751 abbreviated: /^q[1234]/i, 31752 wide: /^[1234](th|st|nd|rd)? quarter/i 31753 }; 31754 var parseQuarterPatterns = { 31755 any: [/1/i, /2/i, /3/i, /4/i] 31756 }; 31757 var matchMonthPatterns = { 31758 narrow: /^[jfmasond]/i, 31759 abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i, 31760 wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i 31761 }; 31762 var parseMonthPatterns = { 31763 narrow: [ 31764 /^j/i, 31765 /^f/i, 31766 /^m/i, 31767 /^a/i, 31768 /^m/i, 31769 /^j/i, 31770 /^j/i, 31771 /^a/i, 31772 /^s/i, 31773 /^o/i, 31774 /^n/i, 31775 /^d/i 31776 ], 31777 any: [ 31778 /^ja/i, 31779 /^f/i, 31780 /^mar/i, 31781 /^ap/i, 31782 /^may/i, 31783 /^jun/i, 31784 /^jul/i, 31785 /^au/i, 31786 /^s/i, 31787 /^o/i, 31788 /^n/i, 31789 /^d/i 31790 ] 31791 }; 31792 var matchDayPatterns = { 31793 narrow: /^[smtwf]/i, 31794 short: /^(su|mo|tu|we|th|fr|sa)/i, 31795 abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i, 31796 wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i 31797 }; 31798 var parseDayPatterns = { 31799 narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i], 31800 any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i] 31801 }; 31802 var matchDayPeriodPatterns = { 31803 narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i, 31804 any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i 31805 }; 31806 var parseDayPeriodPatterns = { 31807 any: { 31808 am: /^a/i, 31809 pm: /^p/i, 31810 midnight: /^mi/i, 31811 noon: /^no/i, 31812 morning: /morning/i, 31813 afternoon: /afternoon/i, 31814 evening: /evening/i, 31815 night: /night/i 31816 } 31817 }; 31818 var match = { 31819 ordinalNumber: buildMatchPatternFn({ 31820 matchPattern: matchOrdinalNumberPattern, 31821 parsePattern: parseOrdinalNumberPattern, 31822 valueCallback: (value) => parseInt(value, 10) 31823 }), 31824 era: buildMatchFn({ 31825 matchPatterns: matchEraPatterns, 31826 defaultMatchWidth: "wide", 31827 parsePatterns: parseEraPatterns, 31828 defaultParseWidth: "any" 31829 }), 31830 quarter: buildMatchFn({ 31831 matchPatterns: matchQuarterPatterns, 31832 defaultMatchWidth: "wide", 31833 parsePatterns: parseQuarterPatterns, 31834 defaultParseWidth: "any", 31835 valueCallback: (index2) => index2 + 1 31836 }), 31837 month: buildMatchFn({ 31838 matchPatterns: matchMonthPatterns, 31839 defaultMatchWidth: "wide", 31840 parsePatterns: parseMonthPatterns, 31841 defaultParseWidth: "any" 31842 }), 31843 day: buildMatchFn({ 31844 matchPatterns: matchDayPatterns, 31845 defaultMatchWidth: "wide", 31846 parsePatterns: parseDayPatterns, 31847 defaultParseWidth: "any" 31848 }), 31849 dayPeriod: buildMatchFn({ 31850 matchPatterns: matchDayPeriodPatterns, 31851 defaultMatchWidth: "any", 31852 parsePatterns: parseDayPeriodPatterns, 31853 defaultParseWidth: "any" 31854 }) 31855 }; 31856 31857 // node_modules/date-fns/locale/en-US.js 31858 var enUS = { 31859 code: "en-US", 31860 formatDistance, 31861 formatLong, 31862 formatRelative, 31863 localize, 31864 match, 31865 options: { 31866 weekStartsOn: 0, 31867 firstWeekContainsDate: 1 31868 } 31869 }; 31870 31871 // node_modules/date-fns/getDayOfYear.js 31872 function getDayOfYear(date, options) { 31873 const _date = toDate(date, options?.in); 31874 const diff = differenceInCalendarDays(_date, startOfYear(_date)); 31875 const dayOfYear = diff + 1; 31876 return dayOfYear; 31877 } 31878 31879 // node_modules/date-fns/getISOWeek.js 31880 function getISOWeek(date, options) { 31881 const _date = toDate(date, options?.in); 31882 const diff = +startOfISOWeek(_date) - +startOfISOWeekYear(_date); 31883 return Math.round(diff / millisecondsInWeek) + 1; 31884 } 31885 31886 // node_modules/date-fns/getWeekYear.js 31887 function getWeekYear(date, options) { 31888 const _date = toDate(date, options?.in); 31889 const year = _date.getFullYear(); 31890 const defaultOptions2 = getDefaultOptions(); 31891 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1; 31892 const firstWeekOfNextYear = constructFrom(options?.in || date, 0); 31893 firstWeekOfNextYear.setFullYear(year + 1, 0, firstWeekContainsDate); 31894 firstWeekOfNextYear.setHours(0, 0, 0, 0); 31895 const startOfNextYear = startOfWeek(firstWeekOfNextYear, options); 31896 const firstWeekOfThisYear = constructFrom(options?.in || date, 0); 31897 firstWeekOfThisYear.setFullYear(year, 0, firstWeekContainsDate); 31898 firstWeekOfThisYear.setHours(0, 0, 0, 0); 31899 const startOfThisYear = startOfWeek(firstWeekOfThisYear, options); 31900 if (+_date >= +startOfNextYear) { 31901 return year + 1; 31902 } else if (+_date >= +startOfThisYear) { 31903 return year; 31904 } else { 31905 return year - 1; 31906 } 31907 } 31908 31909 // node_modules/date-fns/startOfWeekYear.js 31910 function startOfWeekYear(date, options) { 31911 const defaultOptions2 = getDefaultOptions(); 31912 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1; 31913 const year = getWeekYear(date, options); 31914 const firstWeek = constructFrom(options?.in || date, 0); 31915 firstWeek.setFullYear(year, 0, firstWeekContainsDate); 31916 firstWeek.setHours(0, 0, 0, 0); 31917 const _date = startOfWeek(firstWeek, options); 31918 return _date; 31919 } 31920 31921 // node_modules/date-fns/getWeek.js 31922 function getWeek(date, options) { 31923 const _date = toDate(date, options?.in); 31924 const diff = +startOfWeek(_date, options) - +startOfWeekYear(_date, options); 31925 return Math.round(diff / millisecondsInWeek) + 1; 31926 } 31927 31928 // node_modules/date-fns/_lib/addLeadingZeros.js 31929 function addLeadingZeros(number, targetLength) { 31930 const sign = number < 0 ? "-" : ""; 31931 const output = Math.abs(number).toString().padStart(targetLength, "0"); 31932 return sign + output; 31933 } 31934 31935 // node_modules/date-fns/_lib/format/lightFormatters.js 31936 var lightFormatters = { 31937 // Year 31938 y(date, token) { 31939 const signedYear = date.getFullYear(); 31940 const year = signedYear > 0 ? signedYear : 1 - signedYear; 31941 return addLeadingZeros(token === "yy" ? year % 100 : year, token.length); 31942 }, 31943 // Month 31944 M(date, token) { 31945 const month = date.getMonth(); 31946 return token === "M" ? String(month + 1) : addLeadingZeros(month + 1, 2); 31947 }, 31948 // Day of the month 31949 d(date, token) { 31950 return addLeadingZeros(date.getDate(), token.length); 31951 }, 31952 // AM or PM 31953 a(date, token) { 31954 const dayPeriodEnumValue = date.getHours() / 12 >= 1 ? "pm" : "am"; 31955 switch (token) { 31956 case "a": 31957 case "aa": 31958 return dayPeriodEnumValue.toUpperCase(); 31959 case "aaa": 31960 return dayPeriodEnumValue; 31961 case "aaaaa": 31962 return dayPeriodEnumValue[0]; 31963 case "aaaa": 31964 default: 31965 return dayPeriodEnumValue === "am" ? "a.m." : "p.m."; 31966 } 31967 }, 31968 // Hour [1-12] 31969 h(date, token) { 31970 return addLeadingZeros(date.getHours() % 12 || 12, token.length); 31971 }, 31972 // Hour [0-23] 31973 H(date, token) { 31974 return addLeadingZeros(date.getHours(), token.length); 31975 }, 31976 // Minute 31977 m(date, token) { 31978 return addLeadingZeros(date.getMinutes(), token.length); 31979 }, 31980 // Second 31981 s(date, token) { 31982 return addLeadingZeros(date.getSeconds(), token.length); 31983 }, 31984 // Fraction of second 31985 S(date, token) { 31986 const numberOfDigits = token.length; 31987 const milliseconds = date.getMilliseconds(); 31988 const fractionalSeconds = Math.trunc( 31989 milliseconds * Math.pow(10, numberOfDigits - 3) 31990 ); 31991 return addLeadingZeros(fractionalSeconds, token.length); 31992 } 31993 }; 31994 31995 // node_modules/date-fns/_lib/format/formatters.js 31996 var dayPeriodEnum = { 31997 am: "am", 31998 pm: "pm", 31999 midnight: "midnight", 32000 noon: "noon", 32001 morning: "morning", 32002 afternoon: "afternoon", 32003 evening: "evening", 32004 night: "night" 32005 }; 32006 var formatters = { 32007 // Era 32008 G: function(date, token, localize2) { 32009 const era = date.getFullYear() > 0 ? 1 : 0; 32010 switch (token) { 32011 // AD, BC 32012 case "G": 32013 case "GG": 32014 case "GGG": 32015 return localize2.era(era, { width: "abbreviated" }); 32016 // A, B 32017 case "GGGGG": 32018 return localize2.era(era, { width: "narrow" }); 32019 // Anno Domini, Before Christ 32020 case "GGGG": 32021 default: 32022 return localize2.era(era, { width: "wide" }); 32023 } 32024 }, 32025 // Year 32026 y: function(date, token, localize2) { 32027 if (token === "yo") { 32028 const signedYear = date.getFullYear(); 32029 const year = signedYear > 0 ? signedYear : 1 - signedYear; 32030 return localize2.ordinalNumber(year, { unit: "year" }); 32031 } 32032 return lightFormatters.y(date, token); 32033 }, 32034 // Local week-numbering year 32035 Y: function(date, token, localize2, options) { 32036 const signedWeekYear = getWeekYear(date, options); 32037 const weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear; 32038 if (token === "YY") { 32039 const twoDigitYear = weekYear % 100; 32040 return addLeadingZeros(twoDigitYear, 2); 32041 } 32042 if (token === "Yo") { 32043 return localize2.ordinalNumber(weekYear, { unit: "year" }); 32044 } 32045 return addLeadingZeros(weekYear, token.length); 32046 }, 32047 // ISO week-numbering year 32048 R: function(date, token) { 32049 const isoWeekYear = getISOWeekYear(date); 32050 return addLeadingZeros(isoWeekYear, token.length); 32051 }, 32052 // Extended year. This is a single number designating the year of this calendar system. 32053 // The main difference between `y` and `u` localizers are B.C. years: 32054 // | Year | `y` | `u` | 32055 // |------|-----|-----| 32056 // | AC 1 | 1 | 1 | 32057 // | BC 1 | 1 | 0 | 32058 // | BC 2 | 2 | -1 | 32059 // Also `yy` always returns the last two digits of a year, 32060 // while `uu` pads single digit years to 2 characters and returns other years unchanged. 32061 u: function(date, token) { 32062 const year = date.getFullYear(); 32063 return addLeadingZeros(year, token.length); 32064 }, 32065 // Quarter 32066 Q: function(date, token, localize2) { 32067 const quarter = Math.ceil((date.getMonth() + 1) / 3); 32068 switch (token) { 32069 // 1, 2, 3, 4 32070 case "Q": 32071 return String(quarter); 32072 // 01, 02, 03, 04 32073 case "QQ": 32074 return addLeadingZeros(quarter, 2); 32075 // 1st, 2nd, 3rd, 4th 32076 case "Qo": 32077 return localize2.ordinalNumber(quarter, { unit: "quarter" }); 32078 // Q1, Q2, Q3, Q4 32079 case "QQQ": 32080 return localize2.quarter(quarter, { 32081 width: "abbreviated", 32082 context: "formatting" 32083 }); 32084 // 1, 2, 3, 4 (narrow quarter; could be not numerical) 32085 case "QQQQQ": 32086 return localize2.quarter(quarter, { 32087 width: "narrow", 32088 context: "formatting" 32089 }); 32090 // 1st quarter, 2nd quarter, ... 32091 case "QQQQ": 32092 default: 32093 return localize2.quarter(quarter, { 32094 width: "wide", 32095 context: "formatting" 32096 }); 32097 } 32098 }, 32099 // Stand-alone quarter 32100 q: function(date, token, localize2) { 32101 const quarter = Math.ceil((date.getMonth() + 1) / 3); 32102 switch (token) { 32103 // 1, 2, 3, 4 32104 case "q": 32105 return String(quarter); 32106 // 01, 02, 03, 04 32107 case "qq": 32108 return addLeadingZeros(quarter, 2); 32109 // 1st, 2nd, 3rd, 4th 32110 case "qo": 32111 return localize2.ordinalNumber(quarter, { unit: "quarter" }); 32112 // Q1, Q2, Q3, Q4 32113 case "qqq": 32114 return localize2.quarter(quarter, { 32115 width: "abbreviated", 32116 context: "standalone" 32117 }); 32118 // 1, 2, 3, 4 (narrow quarter; could be not numerical) 32119 case "qqqqq": 32120 return localize2.quarter(quarter, { 32121 width: "narrow", 32122 context: "standalone" 32123 }); 32124 // 1st quarter, 2nd quarter, ... 32125 case "qqqq": 32126 default: 32127 return localize2.quarter(quarter, { 32128 width: "wide", 32129 context: "standalone" 32130 }); 32131 } 32132 }, 32133 // Month 32134 M: function(date, token, localize2) { 32135 const month = date.getMonth(); 32136 switch (token) { 32137 case "M": 32138 case "MM": 32139 return lightFormatters.M(date, token); 32140 // 1st, 2nd, ..., 12th 32141 case "Mo": 32142 return localize2.ordinalNumber(month + 1, { unit: "month" }); 32143 // Jan, Feb, ..., Dec 32144 case "MMM": 32145 return localize2.month(month, { 32146 width: "abbreviated", 32147 context: "formatting" 32148 }); 32149 // J, F, ..., D 32150 case "MMMMM": 32151 return localize2.month(month, { 32152 width: "narrow", 32153 context: "formatting" 32154 }); 32155 // January, February, ..., December 32156 case "MMMM": 32157 default: 32158 return localize2.month(month, { width: "wide", context: "formatting" }); 32159 } 32160 }, 32161 // Stand-alone month 32162 L: function(date, token, localize2) { 32163 const month = date.getMonth(); 32164 switch (token) { 32165 // 1, 2, ..., 12 32166 case "L": 32167 return String(month + 1); 32168 // 01, 02, ..., 12 32169 case "LL": 32170 return addLeadingZeros(month + 1, 2); 32171 // 1st, 2nd, ..., 12th 32172 case "Lo": 32173 return localize2.ordinalNumber(month + 1, { unit: "month" }); 32174 // Jan, Feb, ..., Dec 32175 case "LLL": 32176 return localize2.month(month, { 32177 width: "abbreviated", 32178 context: "standalone" 32179 }); 32180 // J, F, ..., D 32181 case "LLLLL": 32182 return localize2.month(month, { 32183 width: "narrow", 32184 context: "standalone" 32185 }); 32186 // January, February, ..., December 32187 case "LLLL": 32188 default: 32189 return localize2.month(month, { width: "wide", context: "standalone" }); 32190 } 32191 }, 32192 // Local week of year 32193 w: function(date, token, localize2, options) { 32194 const week = getWeek(date, options); 32195 if (token === "wo") { 32196 return localize2.ordinalNumber(week, { unit: "week" }); 32197 } 32198 return addLeadingZeros(week, token.length); 32199 }, 32200 // ISO week of year 32201 I: function(date, token, localize2) { 32202 const isoWeek = getISOWeek(date); 32203 if (token === "Io") { 32204 return localize2.ordinalNumber(isoWeek, { unit: "week" }); 32205 } 32206 return addLeadingZeros(isoWeek, token.length); 32207 }, 32208 // Day of the month 32209 d: function(date, token, localize2) { 32210 if (token === "do") { 32211 return localize2.ordinalNumber(date.getDate(), { unit: "date" }); 32212 } 32213 return lightFormatters.d(date, token); 32214 }, 32215 // Day of year 32216 D: function(date, token, localize2) { 32217 const dayOfYear = getDayOfYear(date); 32218 if (token === "Do") { 32219 return localize2.ordinalNumber(dayOfYear, { unit: "dayOfYear" }); 32220 } 32221 return addLeadingZeros(dayOfYear, token.length); 32222 }, 32223 // Day of week 32224 E: function(date, token, localize2) { 32225 const dayOfWeek = date.getDay(); 32226 switch (token) { 32227 // Tue 32228 case "E": 32229 case "EE": 32230 case "EEE": 32231 return localize2.day(dayOfWeek, { 32232 width: "abbreviated", 32233 context: "formatting" 32234 }); 32235 // T 32236 case "EEEEE": 32237 return localize2.day(dayOfWeek, { 32238 width: "narrow", 32239 context: "formatting" 32240 }); 32241 // Tu 32242 case "EEEEEE": 32243 return localize2.day(dayOfWeek, { 32244 width: "short", 32245 context: "formatting" 32246 }); 32247 // Tuesday 32248 case "EEEE": 32249 default: 32250 return localize2.day(dayOfWeek, { 32251 width: "wide", 32252 context: "formatting" 32253 }); 32254 } 32255 }, 32256 // Local day of week 32257 e: function(date, token, localize2, options) { 32258 const dayOfWeek = date.getDay(); 32259 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7; 32260 switch (token) { 32261 // Numerical value (Nth day of week with current locale or weekStartsOn) 32262 case "e": 32263 return String(localDayOfWeek); 32264 // Padded numerical value 32265 case "ee": 32266 return addLeadingZeros(localDayOfWeek, 2); 32267 // 1st, 2nd, ..., 7th 32268 case "eo": 32269 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" }); 32270 case "eee": 32271 return localize2.day(dayOfWeek, { 32272 width: "abbreviated", 32273 context: "formatting" 32274 }); 32275 // T 32276 case "eeeee": 32277 return localize2.day(dayOfWeek, { 32278 width: "narrow", 32279 context: "formatting" 32280 }); 32281 // Tu 32282 case "eeeeee": 32283 return localize2.day(dayOfWeek, { 32284 width: "short", 32285 context: "formatting" 32286 }); 32287 // Tuesday 32288 case "eeee": 32289 default: 32290 return localize2.day(dayOfWeek, { 32291 width: "wide", 32292 context: "formatting" 32293 }); 32294 } 32295 }, 32296 // Stand-alone local day of week 32297 c: function(date, token, localize2, options) { 32298 const dayOfWeek = date.getDay(); 32299 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7; 32300 switch (token) { 32301 // Numerical value (same as in `e`) 32302 case "c": 32303 return String(localDayOfWeek); 32304 // Padded numerical value 32305 case "cc": 32306 return addLeadingZeros(localDayOfWeek, token.length); 32307 // 1st, 2nd, ..., 7th 32308 case "co": 32309 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" }); 32310 case "ccc": 32311 return localize2.day(dayOfWeek, { 32312 width: "abbreviated", 32313 context: "standalone" 32314 }); 32315 // T 32316 case "ccccc": 32317 return localize2.day(dayOfWeek, { 32318 width: "narrow", 32319 context: "standalone" 32320 }); 32321 // Tu 32322 case "cccccc": 32323 return localize2.day(dayOfWeek, { 32324 width: "short", 32325 context: "standalone" 32326 }); 32327 // Tuesday 32328 case "cccc": 32329 default: 32330 return localize2.day(dayOfWeek, { 32331 width: "wide", 32332 context: "standalone" 32333 }); 32334 } 32335 }, 32336 // ISO day of week 32337 i: function(date, token, localize2) { 32338 const dayOfWeek = date.getDay(); 32339 const isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek; 32340 switch (token) { 32341 // 2 32342 case "i": 32343 return String(isoDayOfWeek); 32344 // 02 32345 case "ii": 32346 return addLeadingZeros(isoDayOfWeek, token.length); 32347 // 2nd 32348 case "io": 32349 return localize2.ordinalNumber(isoDayOfWeek, { unit: "day" }); 32350 // Tue 32351 case "iii": 32352 return localize2.day(dayOfWeek, { 32353 width: "abbreviated", 32354 context: "formatting" 32355 }); 32356 // T 32357 case "iiiii": 32358 return localize2.day(dayOfWeek, { 32359 width: "narrow", 32360 context: "formatting" 32361 }); 32362 // Tu 32363 case "iiiiii": 32364 return localize2.day(dayOfWeek, { 32365 width: "short", 32366 context: "formatting" 32367 }); 32368 // Tuesday 32369 case "iiii": 32370 default: 32371 return localize2.day(dayOfWeek, { 32372 width: "wide", 32373 context: "formatting" 32374 }); 32375 } 32376 }, 32377 // AM or PM 32378 a: function(date, token, localize2) { 32379 const hours = date.getHours(); 32380 const dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am"; 32381 switch (token) { 32382 case "a": 32383 case "aa": 32384 return localize2.dayPeriod(dayPeriodEnumValue, { 32385 width: "abbreviated", 32386 context: "formatting" 32387 }); 32388 case "aaa": 32389 return localize2.dayPeriod(dayPeriodEnumValue, { 32390 width: "abbreviated", 32391 context: "formatting" 32392 }).toLowerCase(); 32393 case "aaaaa": 32394 return localize2.dayPeriod(dayPeriodEnumValue, { 32395 width: "narrow", 32396 context: "formatting" 32397 }); 32398 case "aaaa": 32399 default: 32400 return localize2.dayPeriod(dayPeriodEnumValue, { 32401 width: "wide", 32402 context: "formatting" 32403 }); 32404 } 32405 }, 32406 // AM, PM, midnight, noon 32407 b: function(date, token, localize2) { 32408 const hours = date.getHours(); 32409 let dayPeriodEnumValue; 32410 if (hours === 12) { 32411 dayPeriodEnumValue = dayPeriodEnum.noon; 32412 } else if (hours === 0) { 32413 dayPeriodEnumValue = dayPeriodEnum.midnight; 32414 } else { 32415 dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am"; 32416 } 32417 switch (token) { 32418 case "b": 32419 case "bb": 32420 return localize2.dayPeriod(dayPeriodEnumValue, { 32421 width: "abbreviated", 32422 context: "formatting" 32423 }); 32424 case "bbb": 32425 return localize2.dayPeriod(dayPeriodEnumValue, { 32426 width: "abbreviated", 32427 context: "formatting" 32428 }).toLowerCase(); 32429 case "bbbbb": 32430 return localize2.dayPeriod(dayPeriodEnumValue, { 32431 width: "narrow", 32432 context: "formatting" 32433 }); 32434 case "bbbb": 32435 default: 32436 return localize2.dayPeriod(dayPeriodEnumValue, { 32437 width: "wide", 32438 context: "formatting" 32439 }); 32440 } 32441 }, 32442 // in the morning, in the afternoon, in the evening, at night 32443 B: function(date, token, localize2) { 32444 const hours = date.getHours(); 32445 let dayPeriodEnumValue; 32446 if (hours >= 17) { 32447 dayPeriodEnumValue = dayPeriodEnum.evening; 32448 } else if (hours >= 12) { 32449 dayPeriodEnumValue = dayPeriodEnum.afternoon; 32450 } else if (hours >= 4) { 32451 dayPeriodEnumValue = dayPeriodEnum.morning; 32452 } else { 32453 dayPeriodEnumValue = dayPeriodEnum.night; 32454 } 32455 switch (token) { 32456 case "B": 32457 case "BB": 32458 case "BBB": 32459 return localize2.dayPeriod(dayPeriodEnumValue, { 32460 width: "abbreviated", 32461 context: "formatting" 32462 }); 32463 case "BBBBB": 32464 return localize2.dayPeriod(dayPeriodEnumValue, { 32465 width: "narrow", 32466 context: "formatting" 32467 }); 32468 case "BBBB": 32469 default: 32470 return localize2.dayPeriod(dayPeriodEnumValue, { 32471 width: "wide", 32472 context: "formatting" 32473 }); 32474 } 32475 }, 32476 // Hour [1-12] 32477 h: function(date, token, localize2) { 32478 if (token === "ho") { 32479 let hours = date.getHours() % 12; 32480 if (hours === 0) hours = 12; 32481 return localize2.ordinalNumber(hours, { unit: "hour" }); 32482 } 32483 return lightFormatters.h(date, token); 32484 }, 32485 // Hour [0-23] 32486 H: function(date, token, localize2) { 32487 if (token === "Ho") { 32488 return localize2.ordinalNumber(date.getHours(), { unit: "hour" }); 32489 } 32490 return lightFormatters.H(date, token); 32491 }, 32492 // Hour [0-11] 32493 K: function(date, token, localize2) { 32494 const hours = date.getHours() % 12; 32495 if (token === "Ko") { 32496 return localize2.ordinalNumber(hours, { unit: "hour" }); 32497 } 32498 return addLeadingZeros(hours, token.length); 32499 }, 32500 // Hour [1-24] 32501 k: function(date, token, localize2) { 32502 let hours = date.getHours(); 32503 if (hours === 0) hours = 24; 32504 if (token === "ko") { 32505 return localize2.ordinalNumber(hours, { unit: "hour" }); 32506 } 32507 return addLeadingZeros(hours, token.length); 32508 }, 32509 // Minute 32510 m: function(date, token, localize2) { 32511 if (token === "mo") { 32512 return localize2.ordinalNumber(date.getMinutes(), { unit: "minute" }); 32513 } 32514 return lightFormatters.m(date, token); 32515 }, 32516 // Second 32517 s: function(date, token, localize2) { 32518 if (token === "so") { 32519 return localize2.ordinalNumber(date.getSeconds(), { unit: "second" }); 32520 } 32521 return lightFormatters.s(date, token); 32522 }, 32523 // Fraction of second 32524 S: function(date, token) { 32525 return lightFormatters.S(date, token); 32526 }, 32527 // Timezone (ISO-8601. If offset is 0, output is always `'Z'`) 32528 X: function(date, token, _localize) { 32529 const timezoneOffset = date.getTimezoneOffset(); 32530 if (timezoneOffset === 0) { 32531 return "Z"; 32532 } 32533 switch (token) { 32534 // Hours and optional minutes 32535 case "X": 32536 return formatTimezoneWithOptionalMinutes(timezoneOffset); 32537 // Hours, minutes and optional seconds without `:` delimiter 32538 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets 32539 // so this token always has the same output as `XX` 32540 case "XXXX": 32541 case "XX": 32542 return formatTimezone(timezoneOffset); 32543 // Hours, minutes and optional seconds with `:` delimiter 32544 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets 32545 // so this token always has the same output as `XXX` 32546 case "XXXXX": 32547 case "XXX": 32548 // Hours and minutes with `:` delimiter 32549 default: 32550 return formatTimezone(timezoneOffset, ":"); 32551 } 32552 }, 32553 // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent) 32554 x: function(date, token, _localize) { 32555 const timezoneOffset = date.getTimezoneOffset(); 32556 switch (token) { 32557 // Hours and optional minutes 32558 case "x": 32559 return formatTimezoneWithOptionalMinutes(timezoneOffset); 32560 // Hours, minutes and optional seconds without `:` delimiter 32561 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets 32562 // so this token always has the same output as `xx` 32563 case "xxxx": 32564 case "xx": 32565 return formatTimezone(timezoneOffset); 32566 // Hours, minutes and optional seconds with `:` delimiter 32567 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets 32568 // so this token always has the same output as `xxx` 32569 case "xxxxx": 32570 case "xxx": 32571 // Hours and minutes with `:` delimiter 32572 default: 32573 return formatTimezone(timezoneOffset, ":"); 32574 } 32575 }, 32576 // Timezone (GMT) 32577 O: function(date, token, _localize) { 32578 const timezoneOffset = date.getTimezoneOffset(); 32579 switch (token) { 32580 // Short 32581 case "O": 32582 case "OO": 32583 case "OOO": 32584 return "GMT" + formatTimezoneShort(timezoneOffset, ":"); 32585 // Long 32586 case "OOOO": 32587 default: 32588 return "GMT" + formatTimezone(timezoneOffset, ":"); 32589 } 32590 }, 32591 // Timezone (specific non-location) 32592 z: function(date, token, _localize) { 32593 const timezoneOffset = date.getTimezoneOffset(); 32594 switch (token) { 32595 // Short 32596 case "z": 32597 case "zz": 32598 case "zzz": 32599 return "GMT" + formatTimezoneShort(timezoneOffset, ":"); 32600 // Long 32601 case "zzzz": 32602 default: 32603 return "GMT" + formatTimezone(timezoneOffset, ":"); 32604 } 32605 }, 32606 // Seconds timestamp 32607 t: function(date, token, _localize) { 32608 const timestamp = Math.trunc(+date / 1e3); 32609 return addLeadingZeros(timestamp, token.length); 32610 }, 32611 // Milliseconds timestamp 32612 T: function(date, token, _localize) { 32613 return addLeadingZeros(+date, token.length); 32614 } 32615 }; 32616 function formatTimezoneShort(offset4, delimiter = "") { 32617 const sign = offset4 > 0 ? "-" : "+"; 32618 const absOffset = Math.abs(offset4); 32619 const hours = Math.trunc(absOffset / 60); 32620 const minutes = absOffset % 60; 32621 if (minutes === 0) { 32622 return sign + String(hours); 32623 } 32624 return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2); 32625 } 32626 function formatTimezoneWithOptionalMinutes(offset4, delimiter) { 32627 if (offset4 % 60 === 0) { 32628 const sign = offset4 > 0 ? "-" : "+"; 32629 return sign + addLeadingZeros(Math.abs(offset4) / 60, 2); 32630 } 32631 return formatTimezone(offset4, delimiter); 32632 } 32633 function formatTimezone(offset4, delimiter = "") { 32634 const sign = offset4 > 0 ? "-" : "+"; 32635 const absOffset = Math.abs(offset4); 32636 const hours = addLeadingZeros(Math.trunc(absOffset / 60), 2); 32637 const minutes = addLeadingZeros(absOffset % 60, 2); 32638 return sign + hours + delimiter + minutes; 32639 } 32640 32641 // node_modules/date-fns/_lib/format/longFormatters.js 32642 var dateLongFormatter = (pattern, formatLong2) => { 32643 switch (pattern) { 32644 case "P": 32645 return formatLong2.date({ width: "short" }); 32646 case "PP": 32647 return formatLong2.date({ width: "medium" }); 32648 case "PPP": 32649 return formatLong2.date({ width: "long" }); 32650 case "PPPP": 32651 default: 32652 return formatLong2.date({ width: "full" }); 32653 } 32654 }; 32655 var timeLongFormatter = (pattern, formatLong2) => { 32656 switch (pattern) { 32657 case "p": 32658 return formatLong2.time({ width: "short" }); 32659 case "pp": 32660 return formatLong2.time({ width: "medium" }); 32661 case "ppp": 32662 return formatLong2.time({ width: "long" }); 32663 case "pppp": 32664 default: 32665 return formatLong2.time({ width: "full" }); 32666 } 32667 }; 32668 var dateTimeLongFormatter = (pattern, formatLong2) => { 32669 const matchResult = pattern.match(/(P+)(p+)?/) || []; 32670 const datePattern = matchResult[1]; 32671 const timePattern = matchResult[2]; 32672 if (!timePattern) { 32673 return dateLongFormatter(pattern, formatLong2); 32674 } 32675 let dateTimeFormat; 32676 switch (datePattern) { 32677 case "P": 32678 dateTimeFormat = formatLong2.dateTime({ width: "short" }); 32679 break; 32680 case "PP": 32681 dateTimeFormat = formatLong2.dateTime({ width: "medium" }); 32682 break; 32683 case "PPP": 32684 dateTimeFormat = formatLong2.dateTime({ width: "long" }); 32685 break; 32686 case "PPPP": 32687 default: 32688 dateTimeFormat = formatLong2.dateTime({ width: "full" }); 32689 break; 32690 } 32691 return dateTimeFormat.replace("{{date}}", dateLongFormatter(datePattern, formatLong2)).replace("{{time}}", timeLongFormatter(timePattern, formatLong2)); 32692 }; 32693 var longFormatters = { 32694 p: timeLongFormatter, 32695 P: dateTimeLongFormatter 32696 }; 32697 32698 // node_modules/date-fns/_lib/protectedTokens.js 32699 var dayOfYearTokenRE = /^D+$/; 32700 var weekYearTokenRE = /^Y+$/; 32701 var throwTokens = ["D", "DD", "YY", "YYYY"]; 32702 function isProtectedDayOfYearToken(token) { 32703 return dayOfYearTokenRE.test(token); 32704 } 32705 function isProtectedWeekYearToken(token) { 32706 return weekYearTokenRE.test(token); 32707 } 32708 function warnOrThrowProtectedError(token, format6, input) { 32709 const _message = message(token, format6, input); 32710 console.warn(_message); 32711 if (throwTokens.includes(token)) throw new RangeError(_message); 32712 } 32713 function message(token, format6, input) { 32714 const subject = token[0] === "Y" ? "years" : "days of the month"; 32715 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`; 32716 } 32717 32718 // node_modules/date-fns/format.js 32719 var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g; 32720 var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g; 32721 var escapedStringRegExp = /^'([^]*?)'?$/; 32722 var doubleQuoteRegExp = /''/g; 32723 var unescapedLatinCharacterRegExp = /[a-zA-Z]/; 32724 function format(date, formatStr, options) { 32725 const defaultOptions2 = getDefaultOptions(); 32726 const locale = options?.locale ?? defaultOptions2.locale ?? enUS; 32727 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1; 32728 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0; 32729 const originalDate = toDate(date, options?.in); 32730 if (!isValid(originalDate)) { 32731 throw new RangeError("Invalid time value"); 32732 } 32733 let parts = formatStr.match(longFormattingTokensRegExp).map((substring) => { 32734 const firstCharacter = substring[0]; 32735 if (firstCharacter === "p" || firstCharacter === "P") { 32736 const longFormatter = longFormatters[firstCharacter]; 32737 return longFormatter(substring, locale.formatLong); 32738 } 32739 return substring; 32740 }).join("").match(formattingTokensRegExp).map((substring) => { 32741 if (substring === "''") { 32742 return { isToken: false, value: "'" }; 32743 } 32744 const firstCharacter = substring[0]; 32745 if (firstCharacter === "'") { 32746 return { isToken: false, value: cleanEscapedString(substring) }; 32747 } 32748 if (formatters[firstCharacter]) { 32749 return { isToken: true, value: substring }; 32750 } 32751 if (firstCharacter.match(unescapedLatinCharacterRegExp)) { 32752 throw new RangeError( 32753 "Format string contains an unescaped latin alphabet character `" + firstCharacter + "`" 32754 ); 32755 } 32756 return { isToken: false, value: substring }; 32757 }); 32758 if (locale.localize.preprocessor) { 32759 parts = locale.localize.preprocessor(originalDate, parts); 32760 } 32761 const formatterOptions = { 32762 firstWeekContainsDate, 32763 weekStartsOn, 32764 locale 32765 }; 32766 return parts.map((part) => { 32767 if (!part.isToken) return part.value; 32768 const token = part.value; 32769 if (!options?.useAdditionalWeekYearTokens && isProtectedWeekYearToken(token) || !options?.useAdditionalDayOfYearTokens && isProtectedDayOfYearToken(token)) { 32770 warnOrThrowProtectedError(token, formatStr, String(date)); 32771 } 32772 const formatter = formatters[token[0]]; 32773 return formatter(originalDate, token, locale.localize, formatterOptions); 32774 }).join(""); 32775 } 32776 function cleanEscapedString(input) { 32777 const matched = input.match(escapedStringRegExp); 32778 if (!matched) { 32779 return input; 32780 } 32781 return matched[1].replace(doubleQuoteRegExp, "'"); 32782 } 32783 32784 // node_modules/date-fns/subDays.js 32785 function subDays(date, amount, options) { 32786 return addDays(date, -amount, options); 32787 } 32788 32789 // node_modules/date-fns/subMonths.js 32790 function subMonths(date, amount, options) { 32791 return addMonths(date, -amount, options); 32792 } 32793 32794 // node_modules/date-fns/subWeeks.js 32795 function subWeeks(date, amount, options) { 32796 return addWeeks(date, -amount, options); 32797 } 32798 32799 // node_modules/date-fns/subYears.js 32800 function subYears(date, amount, options) { 32801 return addYears(date, -amount, options); 32802 } 32803 32804 // packages/dataviews/build-module/utils/operators.mjs 32805 var import_i18n47 = __toESM(require_i18n(), 1); 32806 var import_element85 = __toESM(require_element(), 1); 32807 var import_date = __toESM(require_date(), 1); 32808 var import_jsx_runtime158 = __toESM(require_jsx_runtime(), 1); 32809 var filterTextWrappers = { 32810 Name: /* @__PURE__ */ (0, import_jsx_runtime158.jsx)("span", { className: "dataviews-filters__summary-filter-text-name" }), 32811 Value: /* @__PURE__ */ (0, import_jsx_runtime158.jsx)("span", { className: "dataviews-filters__summary-filter-text-value" }) 32812 }; 32813 function getRelativeDate(value, unit) { 32814 switch (unit) { 32815 case "days": 32816 return subDays(/* @__PURE__ */ new Date(), value); 32817 case "weeks": 32818 return subWeeks(/* @__PURE__ */ new Date(), value); 32819 case "months": 32820 return subMonths(/* @__PURE__ */ new Date(), value); 32821 case "years": 32822 return subYears(/* @__PURE__ */ new Date(), value); 32823 default: 32824 return /* @__PURE__ */ new Date(); 32825 } 32826 } 32827 var isNoneOperatorDefinition = { 32828 /* translators: DataViews operator name */ 32829 label: (0, import_i18n47.__)("Is none of"), 32830 filterText: (filter, activeElements) => (0, import_element85.createInterpolateElement)( 32831 (0, import_i18n47.sprintf)( 32832 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is none of: Admin, Editor". */ 32833 (0, import_i18n47.__)("<Name>%1$s is none of: </Name><Value>%2$s</Value>"), 32834 filter.name, 32835 activeElements.map((element) => element.label).join(", ") 32836 ), 32837 filterTextWrappers 32838 ), 32839 filter: ((item, field, filterValue) => { 32840 if (!filterValue?.length) { 32841 return true; 32842 } 32843 const fieldValue = field.getValue({ item }); 32844 if (Array.isArray(fieldValue)) { 32845 return !filterValue.some( 32846 (fv) => fieldValue.includes(fv) 32847 ); 32848 } else if (typeof fieldValue === "string") { 32849 return !filterValue.includes(fieldValue); 32850 } 32851 return false; 32852 }), 32853 selection: "multi" 32854 }; 32855 var OPERATORS = [ 32856 { 32857 name: OPERATOR_IS_ANY2, 32858 /* translators: DataViews operator name */ 32859 label: (0, import_i18n47.__)("Includes"), 32860 filterText: (filter, activeElements) => (0, import_element85.createInterpolateElement)( 32861 (0, import_i18n47.sprintf)( 32862 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is any: Admin, Editor". */ 32863 (0, import_i18n47.__)("<Name>%1$s includes: </Name><Value>%2$s</Value>"), 32864 filter.name, 32865 activeElements.map((element) => element.label).join(", ") 32866 ), 32867 filterTextWrappers 32868 ), 32869 filter(item, field, filterValue) { 32870 if (!filterValue?.length) { 32871 return true; 32872 } 32873 const fieldValue = field.getValue({ item }); 32874 if (Array.isArray(fieldValue)) { 32875 return filterValue.some( 32876 (fv) => fieldValue.includes(fv) 32877 ); 32878 } else if (typeof fieldValue === "string") { 32879 return filterValue.includes(fieldValue); 32880 } 32881 return false; 32882 }, 32883 selection: "multi" 32884 }, 32885 { 32886 name: OPERATOR_IS_NONE2, 32887 ...isNoneOperatorDefinition 32888 }, 32889 { 32890 name: OPERATOR_IS_ALL, 32891 /* translators: DataViews operator name */ 32892 label: (0, import_i18n47.__)("Includes all"), 32893 filterText: (filter, activeElements) => (0, import_element85.createInterpolateElement)( 32894 (0, import_i18n47.sprintf)( 32895 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author includes all: Admin, Editor". */ 32896 (0, import_i18n47.__)("<Name>%1$s includes all: </Name><Value>%2$s</Value>"), 32897 filter.name, 32898 activeElements.map((element) => element.label).join(", ") 32899 ), 32900 filterTextWrappers 32901 ), 32902 filter(item, field, filterValue) { 32903 if (!filterValue?.length) { 32904 return true; 32905 } 32906 return filterValue.every((value) => { 32907 return field.getValue({ item })?.includes(value); 32908 }); 32909 }, 32910 selection: "multi" 32911 }, 32912 { 32913 name: OPERATOR_IS_NOT_ALL, 32914 ...isNoneOperatorDefinition 32915 }, 32916 { 32917 name: OPERATOR_BETWEEN, 32918 /* translators: DataViews operator name */ 32919 label: (0, import_i18n47.__)("Between (inc)"), 32920 filterText: (filter, activeElements) => (0, import_element85.createInterpolateElement)( 32921 (0, import_i18n47.sprintf)( 32922 /* 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". */ 32923 (0, import_i18n47.__)( 32924 "<Name>%1$s between (inc): </Name><Value>%2$s and %3$s</Value>" 32925 ), 32926 filter.name, 32927 activeElements[0].label[0], 32928 activeElements[0].label[1] 32929 ), 32930 filterTextWrappers 32931 ), 32932 filter(item, field, filterValue) { 32933 if (!Array.isArray(filterValue) || filterValue.length !== 2 || filterValue[0] === void 0 || filterValue[1] === void 0) { 32934 return true; 32935 } 32936 const fieldValue = field.getValue({ item }); 32937 if (typeof fieldValue === "number" || fieldValue instanceof Date || typeof fieldValue === "string") { 32938 return fieldValue >= filterValue[0] && fieldValue <= filterValue[1]; 32939 } 32940 return false; 32941 }, 32942 selection: "custom" 32943 }, 32944 { 32945 name: OPERATOR_IN_THE_PAST, 32946 /* translators: DataViews operator name */ 32947 label: (0, import_i18n47.__)("In the past"), 32948 filterText: (filter, activeElements) => (0, import_element85.createInterpolateElement)( 32949 (0, import_i18n47.sprintf)( 32950 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is in the past: 7 days". */ 32951 (0, import_i18n47.__)( 32952 "<Name>%1$s is in the past: </Name><Value>%2$s</Value>" 32953 ), 32954 filter.name, 32955 `$activeElements[0].value.value} $activeElements[0].value.unit}` 32956 ), 32957 filterTextWrappers 32958 ), 32959 filter(item, field, filterValue) { 32960 if (filterValue?.value === void 0 || filterValue?.unit === void 0) { 32961 return true; 32962 } 32963 const targetDate = getRelativeDate( 32964 filterValue.value, 32965 filterValue.unit 32966 ); 32967 const fieldValue = (0, import_date.getDate)(field.getValue({ item })); 32968 return fieldValue >= targetDate && fieldValue <= /* @__PURE__ */ new Date(); 32969 }, 32970 selection: "custom" 32971 }, 32972 { 32973 name: OPERATOR_OVER, 32974 /* translators: DataViews operator name */ 32975 label: (0, import_i18n47.__)("Over"), 32976 filterText: (filter, activeElements) => (0, import_element85.createInterpolateElement)( 32977 (0, import_i18n47.sprintf)( 32978 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is over: 7 days". */ 32979 (0, import_i18n47.__)("<Name>%1$s is over: </Name><Value>%2$s</Value>"), 32980 filter.name, 32981 `$activeElements[0].value.value} $activeElements[0].value.unit}` 32982 ), 32983 filterTextWrappers 32984 ), 32985 filter(item, field, filterValue) { 32986 if (filterValue?.value === void 0 || filterValue?.unit === void 0) { 32987 return true; 32988 } 32989 const targetDate = getRelativeDate( 32990 filterValue.value, 32991 filterValue.unit 32992 ); 32993 const fieldValue = (0, import_date.getDate)(field.getValue({ item })); 32994 return fieldValue < targetDate; 32995 }, 32996 selection: "custom" 32997 }, 32998 { 32999 name: OPERATOR_IS, 33000 /* translators: DataViews operator name */ 33001 label: (0, import_i18n47.__)("Is"), 33002 filterText: (filter, activeElements) => (0, import_element85.createInterpolateElement)( 33003 (0, import_i18n47.sprintf)( 33004 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is: Admin". */ 33005 (0, import_i18n47.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"), 33006 filter.name, 33007 activeElements[0].label 33008 ), 33009 filterTextWrappers 33010 ), 33011 filter(item, field, filterValue) { 33012 return filterValue === field.getValue({ item }) || filterValue === void 0; 33013 }, 33014 selection: "single" 33015 }, 33016 { 33017 name: OPERATOR_IS_NOT, 33018 /* translators: DataViews operator name */ 33019 label: (0, import_i18n47.__)("Is not"), 33020 filterText: (filter, activeElements) => (0, import_element85.createInterpolateElement)( 33021 (0, import_i18n47.sprintf)( 33022 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is not: Admin". */ 33023 (0, import_i18n47.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"), 33024 filter.name, 33025 activeElements[0].label 33026 ), 33027 filterTextWrappers 33028 ), 33029 filter(item, field, filterValue) { 33030 return filterValue !== field.getValue({ item }); 33031 }, 33032 selection: "single" 33033 }, 33034 { 33035 name: OPERATOR_LESS_THAN, 33036 /* translators: DataViews operator name */ 33037 label: (0, import_i18n47.__)("Less than"), 33038 filterText: (filter, activeElements) => (0, import_element85.createInterpolateElement)( 33039 (0, import_i18n47.sprintf)( 33040 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than: 10". */ 33041 (0, import_i18n47.__)("<Name>%1$s is less than: </Name><Value>%2$s</Value>"), 33042 filter.name, 33043 activeElements[0].label 33044 ), 33045 filterTextWrappers 33046 ), 33047 filter(item, field, filterValue) { 33048 if (filterValue === void 0) { 33049 return true; 33050 } 33051 const fieldValue = field.getValue({ item }); 33052 return fieldValue < filterValue; 33053 }, 33054 selection: "single" 33055 }, 33056 { 33057 name: OPERATOR_GREATER_THAN, 33058 /* translators: DataViews operator name */ 33059 label: (0, import_i18n47.__)("Greater than"), 33060 filterText: (filter, activeElements) => (0, import_element85.createInterpolateElement)( 33061 (0, import_i18n47.sprintf)( 33062 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than: 10". */ 33063 (0, import_i18n47.__)( 33064 "<Name>%1$s is greater than: </Name><Value>%2$s</Value>" 33065 ), 33066 filter.name, 33067 activeElements[0].label 33068 ), 33069 filterTextWrappers 33070 ), 33071 filter(item, field, filterValue) { 33072 if (filterValue === void 0) { 33073 return true; 33074 } 33075 const fieldValue = field.getValue({ item }); 33076 return fieldValue > filterValue; 33077 }, 33078 selection: "single" 33079 }, 33080 { 33081 name: OPERATOR_LESS_THAN_OR_EQUAL, 33082 /* translators: DataViews operator name */ 33083 label: (0, import_i18n47.__)("Less than or equal"), 33084 filterText: (filter, activeElements) => (0, import_element85.createInterpolateElement)( 33085 (0, import_i18n47.sprintf)( 33086 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than or equal to: 10". */ 33087 (0, import_i18n47.__)( 33088 "<Name>%1$s is less than or equal to: </Name><Value>%2$s</Value>" 33089 ), 33090 filter.name, 33091 activeElements[0].label 33092 ), 33093 filterTextWrappers 33094 ), 33095 filter(item, field, filterValue) { 33096 if (filterValue === void 0) { 33097 return true; 33098 } 33099 const fieldValue = field.getValue({ item }); 33100 return fieldValue <= filterValue; 33101 }, 33102 selection: "single" 33103 }, 33104 { 33105 name: OPERATOR_GREATER_THAN_OR_EQUAL, 33106 /* translators: DataViews operator name */ 33107 label: (0, import_i18n47.__)("Greater than or equal"), 33108 filterText: (filter, activeElements) => (0, import_element85.createInterpolateElement)( 33109 (0, import_i18n47.sprintf)( 33110 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than or equal to: 10". */ 33111 (0, import_i18n47.__)( 33112 "<Name>%1$s is greater than or equal to: </Name><Value>%2$s</Value>" 33113 ), 33114 filter.name, 33115 activeElements[0].label 33116 ), 33117 filterTextWrappers 33118 ), 33119 filter(item, field, filterValue) { 33120 if (filterValue === void 0) { 33121 return true; 33122 } 33123 const fieldValue = field.getValue({ item }); 33124 return fieldValue >= filterValue; 33125 }, 33126 selection: "single" 33127 }, 33128 { 33129 name: OPERATOR_BEFORE2, 33130 /* translators: DataViews operator name */ 33131 label: (0, import_i18n47.__)("Before"), 33132 filterText: (filter, activeElements) => (0, import_element85.createInterpolateElement)( 33133 (0, import_i18n47.sprintf)( 33134 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is before: 2024-01-01". */ 33135 (0, import_i18n47.__)("<Name>%1$s is before: </Name><Value>%2$s</Value>"), 33136 filter.name, 33137 activeElements[0].label 33138 ), 33139 filterTextWrappers 33140 ), 33141 filter(item, field, filterValue) { 33142 if (filterValue === void 0) { 33143 return true; 33144 } 33145 const filterDate = (0, import_date.getDate)(filterValue); 33146 const fieldDate = (0, import_date.getDate)(field.getValue({ item })); 33147 return fieldDate < filterDate; 33148 }, 33149 selection: "single" 33150 }, 33151 { 33152 name: OPERATOR_AFTER2, 33153 /* translators: DataViews operator name */ 33154 label: (0, import_i18n47.__)("After"), 33155 filterText: (filter, activeElements) => (0, import_element85.createInterpolateElement)( 33156 (0, import_i18n47.sprintf)( 33157 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is after: 2024-01-01". */ 33158 (0, import_i18n47.__)("<Name>%1$s is after: </Name><Value>%2$s</Value>"), 33159 filter.name, 33160 activeElements[0].label 33161 ), 33162 filterTextWrappers 33163 ), 33164 filter(item, field, filterValue) { 33165 if (filterValue === void 0) { 33166 return true; 33167 } 33168 const filterDate = (0, import_date.getDate)(filterValue); 33169 const fieldDate = (0, import_date.getDate)(field.getValue({ item })); 33170 return fieldDate > filterDate; 33171 }, 33172 selection: "single" 33173 }, 33174 { 33175 name: OPERATOR_BEFORE_INC, 33176 /* translators: DataViews operator name */ 33177 label: (0, import_i18n47.__)("Before (inc)"), 33178 filterText: (filter, activeElements) => (0, import_element85.createInterpolateElement)( 33179 (0, import_i18n47.sprintf)( 33180 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or before: 2024-01-01". */ 33181 (0, import_i18n47.__)( 33182 "<Name>%1$s is on or before: </Name><Value>%2$s</Value>" 33183 ), 33184 filter.name, 33185 activeElements[0].label 33186 ), 33187 filterTextWrappers 33188 ), 33189 filter(item, field, filterValue) { 33190 if (filterValue === void 0) { 33191 return true; 33192 } 33193 const filterDate = (0, import_date.getDate)(filterValue); 33194 const fieldDate = (0, import_date.getDate)(field.getValue({ item })); 33195 return fieldDate <= filterDate; 33196 }, 33197 selection: "single" 33198 }, 33199 { 33200 name: OPERATOR_AFTER_INC, 33201 /* translators: DataViews operator name */ 33202 label: (0, import_i18n47.__)("After (inc)"), 33203 filterText: (filter, activeElements) => (0, import_element85.createInterpolateElement)( 33204 (0, import_i18n47.sprintf)( 33205 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or after: 2024-01-01". */ 33206 (0, import_i18n47.__)( 33207 "<Name>%1$s is on or after: </Name><Value>%2$s</Value>" 33208 ), 33209 filter.name, 33210 activeElements[0].label 33211 ), 33212 filterTextWrappers 33213 ), 33214 filter(item, field, filterValue) { 33215 if (filterValue === void 0) { 33216 return true; 33217 } 33218 const filterDate = (0, import_date.getDate)(filterValue); 33219 const fieldDate = (0, import_date.getDate)(field.getValue({ item })); 33220 return fieldDate >= filterDate; 33221 }, 33222 selection: "single" 33223 }, 33224 { 33225 name: OPERATOR_CONTAINS, 33226 /* translators: DataViews operator name */ 33227 label: (0, import_i18n47.__)("Contains"), 33228 filterText: (filter, activeElements) => (0, import_element85.createInterpolateElement)( 33229 (0, import_i18n47.sprintf)( 33230 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title contains: Hello". */ 33231 (0, import_i18n47.__)("<Name>%1$s contains: </Name><Value>%2$s</Value>"), 33232 filter.name, 33233 activeElements[0].label 33234 ), 33235 filterTextWrappers 33236 ), 33237 filter(item, field, filterValue) { 33238 if (filterValue === void 0) { 33239 return true; 33240 } 33241 const fieldValue = field.getValue({ item }); 33242 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().includes(String(filterValue).toLowerCase()); 33243 }, 33244 selection: "single" 33245 }, 33246 { 33247 name: OPERATOR_NOT_CONTAINS, 33248 /* translators: DataViews operator name */ 33249 label: (0, import_i18n47.__)("Doesn't contain"), 33250 filterText: (filter, activeElements) => (0, import_element85.createInterpolateElement)( 33251 (0, import_i18n47.sprintf)( 33252 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title doesn't contain: Hello". */ 33253 (0, import_i18n47.__)( 33254 "<Name>%1$s doesn't contain: </Name><Value>%2$s</Value>" 33255 ), 33256 filter.name, 33257 activeElements[0].label 33258 ), 33259 filterTextWrappers 33260 ), 33261 filter(item, field, filterValue) { 33262 if (filterValue === void 0) { 33263 return true; 33264 } 33265 const fieldValue = field.getValue({ item }); 33266 return typeof fieldValue === "string" && filterValue && !fieldValue.toLowerCase().includes(String(filterValue).toLowerCase()); 33267 }, 33268 selection: "single" 33269 }, 33270 { 33271 name: OPERATOR_STARTS_WITH, 33272 /* translators: DataViews operator name */ 33273 label: (0, import_i18n47.__)("Starts with"), 33274 filterText: (filter, activeElements) => (0, import_element85.createInterpolateElement)( 33275 (0, import_i18n47.sprintf)( 33276 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title starts with: Hello". */ 33277 (0, import_i18n47.__)("<Name>%1$s starts with: </Name><Value>%2$s</Value>"), 33278 filter.name, 33279 activeElements[0].label 33280 ), 33281 filterTextWrappers 33282 ), 33283 filter(item, field, filterValue) { 33284 if (filterValue === void 0) { 33285 return true; 33286 } 33287 const fieldValue = field.getValue({ item }); 33288 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().startsWith(String(filterValue).toLowerCase()); 33289 }, 33290 selection: "single" 33291 }, 33292 { 33293 name: OPERATOR_ON, 33294 /* translators: DataViews operator name */ 33295 label: (0, import_i18n47.__)("On"), 33296 filterText: (filter, activeElements) => (0, import_element85.createInterpolateElement)( 33297 (0, import_i18n47.sprintf)( 33298 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is: 2024-01-01". */ 33299 (0, import_i18n47.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"), 33300 filter.name, 33301 activeElements[0].label 33302 ), 33303 filterTextWrappers 33304 ), 33305 filter(item, field, filterValue) { 33306 if (filterValue === void 0) { 33307 return true; 33308 } 33309 const filterDate = (0, import_date.getDate)(filterValue); 33310 const fieldDate = (0, import_date.getDate)(field.getValue({ item })); 33311 return filterDate.getTime() === fieldDate.getTime(); 33312 }, 33313 selection: "single" 33314 }, 33315 { 33316 name: OPERATOR_NOT_ON, 33317 /* translators: DataViews operator name */ 33318 label: (0, import_i18n47.__)("Not on"), 33319 filterText: (filter, activeElements) => (0, import_element85.createInterpolateElement)( 33320 (0, import_i18n47.sprintf)( 33321 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is not: 2024-01-01". */ 33322 (0, import_i18n47.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"), 33323 filter.name, 33324 activeElements[0].label 33325 ), 33326 filterTextWrappers 33327 ), 33328 filter(item, field, filterValue) { 33329 if (filterValue === void 0) { 33330 return true; 33331 } 33332 const filterDate = (0, import_date.getDate)(filterValue); 33333 const fieldDate = (0, import_date.getDate)(field.getValue({ item })); 33334 return filterDate.getTime() !== fieldDate.getTime(); 33335 }, 33336 selection: "single" 33337 } 33338 ]; 33339 var getOperatorByName = (name2) => OPERATORS.find((op) => op.name === name2); 33340 var getAllOperatorNames = () => OPERATORS.map((op) => op.name); 33341 var isSingleSelectionOperator = (name2) => OPERATORS.filter((op) => op.selection === "single").some( 33342 (op) => op.name === name2 33343 ); 33344 var isRegisteredOperator = (name2) => OPERATORS.some((op) => op.name === name2); 33345 33346 // packages/dataviews/build-module/components/dataviews-filters/filter.mjs 33347 var import_jsx_runtime159 = __toESM(require_jsx_runtime(), 1); 33348 var ENTER2 = "Enter"; 33349 var SPACE2 = " "; 33350 var FilterText = ({ 33351 activeElements, 33352 filterInView, 33353 filter 33354 }) => { 33355 if (activeElements === void 0 || activeElements.length === 0) { 33356 return filter.name; 33357 } 33358 const operator = getOperatorByName(filterInView?.operator); 33359 if (operator !== void 0) { 33360 return operator.filterText(filter, activeElements); 33361 } 33362 return (0, import_i18n48.sprintf)( 33363 /* translators: 1: Filter name e.g.: "Unknown status for Author". */ 33364 (0, import_i18n48.__)("Unknown status for %1$s"), 33365 filter.name 33366 ); 33367 }; 33368 function OperatorSelector({ 33369 filter, 33370 view, 33371 onChangeView 33372 }) { 33373 const operatorOptions = filter.operators?.map((operator) => ({ 33374 value: operator, 33375 label: getOperatorByName(operator)?.label || operator 33376 })); 33377 const currentFilter = view.filters?.find( 33378 (_filter) => _filter.field === filter.field 33379 ); 33380 const value = currentFilter?.operator || filter.operators[0]; 33381 return operatorOptions.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime159.jsxs)( 33382 Stack, 33383 { 33384 direction: "row", 33385 gap: "sm", 33386 justify: "flex-start", 33387 className: "dataviews-filters__summary-operators-container", 33388 align: "center", 33389 children: [ 33390 /* @__PURE__ */ (0, import_jsx_runtime159.jsx)(import_components40.FlexItem, { className: "dataviews-filters__summary-operators-filter-name", children: filter.name }), 33391 /* @__PURE__ */ (0, import_jsx_runtime159.jsx)( 33392 import_components40.SelectControl, 33393 { 33394 className: "dataviews-filters__summary-operators-filter-select", 33395 label: (0, import_i18n48.__)("Conditions"), 33396 value, 33397 options: operatorOptions, 33398 onChange: (newValue) => { 33399 const newOperator = newValue; 33400 const currentOperator = currentFilter?.operator; 33401 const newFilters = currentFilter ? [ 33402 ...(view.filters ?? []).map( 33403 (_filter) => { 33404 if (_filter.field === filter.field) { 33405 const currentOpSelectionModel = getOperatorByName( 33406 currentOperator 33407 )?.selection; 33408 const newOpSelectionModel = getOperatorByName( 33409 newOperator 33410 )?.selection; 33411 const shouldResetValue = currentOpSelectionModel !== newOpSelectionModel || [ 33412 currentOpSelectionModel, 33413 newOpSelectionModel 33414 ].includes("custom"); 33415 return { 33416 ..._filter, 33417 value: shouldResetValue ? void 0 : _filter.value, 33418 operator: newOperator 33419 }; 33420 } 33421 return _filter; 33422 } 33423 ) 33424 ] : [ 33425 ...view.filters ?? [], 33426 { 33427 field: filter.field, 33428 operator: newOperator, 33429 value: void 0 33430 } 33431 ]; 33432 onChangeView({ 33433 ...view, 33434 page: 1, 33435 filters: newFilters 33436 }); 33437 }, 33438 size: "small", 33439 variant: "minimal", 33440 hideLabelFromVision: true 33441 } 33442 ) 33443 ] 33444 } 33445 ); 33446 } 33447 function Filter({ 33448 addFilterRef, 33449 openedFilter, 33450 fields: fields2, 33451 ...commonProps 33452 }) { 33453 const toggleRef = (0, import_element86.useRef)(null); 33454 const { filter, view, onChangeView } = commonProps; 33455 const filterInView = view.filters?.find( 33456 (f2) => f2.field === filter.field 33457 ); 33458 let activeElements = []; 33459 const field = (0, import_element86.useMemo)(() => { 33460 const currentField = fields2.find((f2) => f2.id === filter.field); 33461 if (currentField) { 33462 return { 33463 ...currentField, 33464 // Configure getValue as if Item was a plain object. 33465 // See related input-widget.tsx 33466 getValue: ({ item }) => item[currentField.id] 33467 }; 33468 } 33469 return currentField; 33470 }, [fields2, filter.field]); 33471 const { elements: elements2 } = useElements({ 33472 elements: filter.elements, 33473 getElements: filter.getElements 33474 }); 33475 if (elements2.length > 0) { 33476 activeElements = elements2.filter((element) => { 33477 if (filter.singleSelection) { 33478 return element.value === filterInView?.value; 33479 } 33480 return filterInView?.value?.includes(element.value); 33481 }); 33482 } else if (Array.isArray(filterInView?.value)) { 33483 const label = filterInView.value.map((v2) => { 33484 const formattedValue = field?.getValueFormatted({ 33485 item: { [field.id]: v2 }, 33486 field 33487 }); 33488 return formattedValue || String(v2); 33489 }); 33490 activeElements = [ 33491 { 33492 value: filterInView.value, 33493 // @ts-ignore 33494 label 33495 } 33496 ]; 33497 } else if (typeof filterInView?.value === "object") { 33498 activeElements = [ 33499 { value: filterInView.value, label: filterInView.value } 33500 ]; 33501 } else if (filterInView?.value !== void 0) { 33502 const label = field !== void 0 ? field.getValueFormatted({ 33503 item: { [field.id]: filterInView.value }, 33504 field 33505 }) : String(filterInView.value); 33506 activeElements = [ 33507 { 33508 value: filterInView.value, 33509 label 33510 } 33511 ]; 33512 } 33513 const isPrimary = filter.isPrimary; 33514 const isLocked = filterInView?.isLocked; 33515 const hasValues = !isLocked && filterInView?.value !== void 0; 33516 const canResetOrRemove = !isLocked && (!isPrimary || hasValues); 33517 const resetOrRemoveLabel = isPrimary ? (0, import_i18n48.__)("Reset") : (0, import_i18n48.__)("Remove"); 33518 return /* @__PURE__ */ (0, import_jsx_runtime159.jsx)( 33519 import_components40.Dropdown, 33520 { 33521 defaultOpen: openedFilter === filter.field, 33522 contentClassName: "dataviews-filters__summary-popover", 33523 popoverProps: { placement: "bottom-start", role: "dialog" }, 33524 onClose: () => { 33525 toggleRef.current?.focus(); 33526 }, 33527 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime159.jsxs)("div", { className: "dataviews-filters__summary-chip-container", children: [ 33528 /* @__PURE__ */ (0, import_jsx_runtime159.jsxs)(tooltip_exports.Root, { children: [ 33529 /* @__PURE__ */ (0, import_jsx_runtime159.jsx)( 33530 tooltip_exports.Trigger, 33531 { 33532 render: /* @__PURE__ */ (0, import_jsx_runtime159.jsx)( 33533 "div", 33534 { 33535 className: clsx_default( 33536 "dataviews-filters__summary-chip", 33537 { 33538 "has-reset": canResetOrRemove, 33539 "has-values": hasValues, 33540 "is-not-clickable": isLocked 33541 } 33542 ), 33543 role: "button", 33544 tabIndex: isLocked ? -1 : 0, 33545 onClick: () => { 33546 if (!isLocked) { 33547 onToggle(); 33548 } 33549 }, 33550 onKeyDown: (event) => { 33551 if (!isLocked && [ENTER2, SPACE2].includes( 33552 event.key 33553 )) { 33554 onToggle(); 33555 event.preventDefault(); 33556 } 33557 }, 33558 "aria-disabled": isLocked, 33559 "aria-pressed": isOpen, 33560 "aria-expanded": isOpen, 33561 ref: toggleRef, 33562 children: /* @__PURE__ */ (0, import_jsx_runtime159.jsx)( 33563 FilterText, 33564 { 33565 activeElements, 33566 filterInView, 33567 filter 33568 } 33569 ) 33570 } 33571 ) 33572 } 33573 ), 33574 /* @__PURE__ */ (0, import_jsx_runtime159.jsx)(tooltip_exports.Popup, { children: (0, import_i18n48.sprintf)( 33575 /* translators: 1: Filter name. */ 33576 (0, import_i18n48.__)("Filter by: %1$s"), 33577 filter.name.toLowerCase() 33578 ) }) 33579 ] }), 33580 canResetOrRemove && /* @__PURE__ */ (0, import_jsx_runtime159.jsxs)(tooltip_exports.Root, { children: [ 33581 /* @__PURE__ */ (0, import_jsx_runtime159.jsx)( 33582 tooltip_exports.Trigger, 33583 { 33584 render: /* @__PURE__ */ (0, import_jsx_runtime159.jsx)( 33585 "button", 33586 { 33587 className: clsx_default( 33588 "dataviews-filters__summary-chip-remove", 33589 { "has-values": hasValues } 33590 ), 33591 "aria-label": resetOrRemoveLabel, 33592 onClick: () => { 33593 onChangeView({ 33594 ...view, 33595 page: 1, 33596 filters: view.filters?.filter( 33597 (_filter) => _filter.field !== filter.field 33598 ) 33599 }); 33600 if (!isPrimary) { 33601 addFilterRef.current?.focus(); 33602 } else { 33603 toggleRef.current?.focus(); 33604 } 33605 }, 33606 children: /* @__PURE__ */ (0, import_jsx_runtime159.jsx)(import_components40.Icon, { icon: close_small_default }) 33607 } 33608 ) 33609 } 33610 ), 33611 /* @__PURE__ */ (0, import_jsx_runtime159.jsx)(tooltip_exports.Popup, { children: resetOrRemoveLabel }) 33612 ] }) 33613 ] }), 33614 renderContent: () => { 33615 return /* @__PURE__ */ (0, import_jsx_runtime159.jsxs)(Stack, { direction: "column", justify: "flex-start", children: [ 33616 /* @__PURE__ */ (0, import_jsx_runtime159.jsx)(OperatorSelector, { ...commonProps }), 33617 commonProps.filter.hasElements ? /* @__PURE__ */ (0, import_jsx_runtime159.jsx)( 33618 SearchWidget, 33619 { 33620 ...commonProps, 33621 filter: { 33622 ...commonProps.filter, 33623 elements: elements2 33624 } 33625 } 33626 ) : /* @__PURE__ */ (0, import_jsx_runtime159.jsx)(InputWidget, { ...commonProps, fields: fields2 }) 33627 ] }); 33628 } 33629 } 33630 ); 33631 } 33632 33633 // packages/dataviews/build-module/components/dataviews-filters/add-filter.mjs 33634 var import_components41 = __toESM(require_components(), 1); 33635 var import_i18n49 = __toESM(require_i18n(), 1); 33636 var import_element87 = __toESM(require_element(), 1); 33637 var import_jsx_runtime160 = __toESM(require_jsx_runtime(), 1); 33638 var { Menu: Menu4 } = unlock4(import_components41.privateApis); 33639 function AddFilterMenu({ 33640 filters, 33641 view, 33642 onChangeView, 33643 setOpenedFilter, 33644 triggerProps 33645 }) { 33646 const inactiveFilters = filters.filter((filter) => !filter.isVisible); 33647 return /* @__PURE__ */ (0, import_jsx_runtime160.jsxs)(Menu4, { children: [ 33648 /* @__PURE__ */ (0, import_jsx_runtime160.jsx)(Menu4.TriggerButton, { ...triggerProps }), 33649 /* @__PURE__ */ (0, import_jsx_runtime160.jsx)(Menu4.Popover, { children: inactiveFilters.map((filter) => { 33650 return /* @__PURE__ */ (0, import_jsx_runtime160.jsx)( 33651 Menu4.Item, 33652 { 33653 onClick: () => { 33654 setOpenedFilter(filter.field); 33655 onChangeView({ 33656 ...view, 33657 page: 1, 33658 filters: [ 33659 ...view.filters || [], 33660 { 33661 field: filter.field, 33662 value: void 0, 33663 operator: filter.operators[0] 33664 } 33665 ] 33666 }); 33667 }, 33668 children: /* @__PURE__ */ (0, import_jsx_runtime160.jsx)(Menu4.ItemLabel, { children: filter.name }) 33669 }, 33670 filter.field 33671 ); 33672 }) }) 33673 ] }); 33674 } 33675 function AddFilter({ filters, view, onChangeView, setOpenedFilter }, ref) { 33676 if (!filters.length || filters.every(({ isPrimary }) => isPrimary)) { 33677 return null; 33678 } 33679 const inactiveFilters = filters.filter((filter) => !filter.isVisible); 33680 return /* @__PURE__ */ (0, import_jsx_runtime160.jsx)( 33681 AddFilterMenu, 33682 { 33683 triggerProps: { 33684 render: /* @__PURE__ */ (0, import_jsx_runtime160.jsx)( 33685 import_components41.Button, 33686 { 33687 accessibleWhenDisabled: true, 33688 size: "compact", 33689 className: "dataviews-filters-button", 33690 variant: "tertiary", 33691 disabled: !inactiveFilters.length, 33692 ref 33693 } 33694 ), 33695 children: (0, import_i18n49.__)("Add filter") 33696 }, 33697 ...{ filters, view, onChangeView, setOpenedFilter } 33698 } 33699 ); 33700 } 33701 var add_filter_default = (0, import_element87.forwardRef)(AddFilter); 33702 33703 // packages/dataviews/build-module/components/dataviews-filters/reset-filters.mjs 33704 var import_components42 = __toESM(require_components(), 1); 33705 var import_i18n50 = __toESM(require_i18n(), 1); 33706 var import_jsx_runtime161 = __toESM(require_jsx_runtime(), 1); 33707 function ResetFilter({ 33708 filters, 33709 view, 33710 onChangeView 33711 }) { 33712 const isPrimary = (field) => filters.some( 33713 (_filter) => _filter.field === field && _filter.isPrimary 33714 ); 33715 const isDisabled = !view.search && !view.filters?.some( 33716 (_filter) => !_filter.isLocked && (_filter.value !== void 0 || !isPrimary(_filter.field)) 33717 ); 33718 return /* @__PURE__ */ (0, import_jsx_runtime161.jsx)( 33719 import_components42.Button, 33720 { 33721 disabled: isDisabled, 33722 accessibleWhenDisabled: true, 33723 size: "compact", 33724 variant: "tertiary", 33725 className: "dataviews-filters__reset-button", 33726 onClick: () => { 33727 onChangeView({ 33728 ...view, 33729 page: 1, 33730 search: "", 33731 filters: view.filters?.filter((f2) => !!f2.isLocked) || [] 33732 }); 33733 }, 33734 children: (0, import_i18n50.__)("Reset") 33735 } 33736 ); 33737 } 33738 33739 // packages/dataviews/build-module/components/dataviews-filters/use-filters.mjs 33740 var import_element88 = __toESM(require_element(), 1); 33741 function useFilters(fields2, view) { 33742 return (0, import_element88.useMemo)(() => { 33743 const filters = []; 33744 fields2.forEach((field) => { 33745 if (field.filterBy === false || !field.hasElements && !field.Edit) { 33746 return; 33747 } 33748 const operators = field.filterBy.operators; 33749 const isPrimary = !!field.filterBy?.isPrimary; 33750 const isLocked = view.filters?.some( 33751 (f2) => f2.field === field.id && !!f2.isLocked 33752 ) ?? false; 33753 filters.push({ 33754 field: field.id, 33755 name: field.label, 33756 elements: field.elements, 33757 getElements: field.getElements, 33758 hasElements: field.hasElements, 33759 singleSelection: operators.some( 33760 (op) => isSingleSelectionOperator(op) 33761 ), 33762 operators, 33763 isVisible: isLocked || isPrimary || !!view.filters?.some( 33764 (f2) => f2.field === field.id && isRegisteredOperator(f2.operator) 33765 ), 33766 isPrimary, 33767 isLocked 33768 }); 33769 }); 33770 filters.sort((a2, b2) => { 33771 if (a2.isLocked && !b2.isLocked) { 33772 return -1; 33773 } 33774 if (!a2.isLocked && b2.isLocked) { 33775 return 1; 33776 } 33777 if (a2.isPrimary && !b2.isPrimary) { 33778 return -1; 33779 } 33780 if (!a2.isPrimary && b2.isPrimary) { 33781 return 1; 33782 } 33783 return a2.name.localeCompare(b2.name); 33784 }); 33785 return filters; 33786 }, [fields2, view]); 33787 } 33788 var use_filters_default = useFilters; 33789 33790 // packages/dataviews/build-module/components/dataviews-filters/filters.mjs 33791 var import_jsx_runtime162 = __toESM(require_jsx_runtime(), 1); 33792 function Filters({ className }) { 33793 const { fields: fields2, view, onChangeView, openedFilter, setOpenedFilter } = (0, import_element89.useContext)(dataviews_context_default); 33794 const addFilterRef = (0, import_element89.useRef)(null); 33795 const filters = use_filters_default(fields2, view); 33796 const addFilter = /* @__PURE__ */ (0, import_jsx_runtime162.jsx)( 33797 add_filter_default, 33798 { 33799 filters, 33800 view, 33801 onChangeView, 33802 ref: addFilterRef, 33803 setOpenedFilter 33804 }, 33805 "add-filter" 33806 ); 33807 const visibleFilters = filters.filter((filter) => filter.isVisible); 33808 if (visibleFilters.length === 0) { 33809 return null; 33810 } 33811 const filterComponents = [ 33812 ...visibleFilters.map((filter) => { 33813 return /* @__PURE__ */ (0, import_jsx_runtime162.jsx)( 33814 Filter, 33815 { 33816 filter, 33817 view, 33818 fields: fields2, 33819 onChangeView, 33820 addFilterRef, 33821 openedFilter 33822 }, 33823 filter.field 33824 ); 33825 }), 33826 addFilter 33827 ]; 33828 filterComponents.push( 33829 /* @__PURE__ */ (0, import_jsx_runtime162.jsx)( 33830 ResetFilter, 33831 { 33832 filters, 33833 view, 33834 onChangeView 33835 }, 33836 "reset-filters" 33837 ) 33838 ); 33839 return /* @__PURE__ */ (0, import_jsx_runtime162.jsx)( 33840 Stack, 33841 { 33842 direction: "row", 33843 justify: "flex-start", 33844 gap: "sm", 33845 style: { width: "fit-content" }, 33846 wrap: "wrap", 33847 className, 33848 children: filterComponents 33849 } 33850 ); 33851 } 33852 var filters_default = (0, import_element89.memo)(Filters); 33853 33854 // packages/dataviews/build-module/components/dataviews-filters/toggle.mjs 33855 var import_element90 = __toESM(require_element(), 1); 33856 var import_components43 = __toESM(require_components(), 1); 33857 var import_i18n51 = __toESM(require_i18n(), 1); 33858 var import_jsx_runtime163 = __toESM(require_jsx_runtime(), 1); 33859 function FiltersToggle() { 33860 const { 33861 filters, 33862 view, 33863 onChangeView, 33864 setOpenedFilter, 33865 isShowingFilter, 33866 setIsShowingFilter 33867 } = (0, import_element90.useContext)(dataviews_context_default); 33868 const buttonRef = (0, import_element90.useRef)(null); 33869 const onChangeViewWithFilterVisibility = (0, import_element90.useCallback)( 33870 (_view) => { 33871 onChangeView(_view); 33872 setIsShowingFilter(true); 33873 }, 33874 [onChangeView, setIsShowingFilter] 33875 ); 33876 if (filters.length === 0) { 33877 return null; 33878 } 33879 const hasVisibleFilters = filters.some((filter) => filter.isVisible); 33880 const addFilterButtonProps = { 33881 label: (0, import_i18n51.__)("Add filter"), 33882 "aria-expanded": false, 33883 isPressed: false 33884 }; 33885 const toggleFiltersButtonProps = { 33886 label: (0, import_i18n51._x)("Filter", "verb"), 33887 "aria-expanded": isShowingFilter, 33888 isPressed: isShowingFilter, 33889 onClick: () => { 33890 if (!isShowingFilter) { 33891 setOpenedFilter(null); 33892 } 33893 setIsShowingFilter(!isShowingFilter); 33894 } 33895 }; 33896 const hasPrimaryOrLockedFilters = filters.some( 33897 (filter) => filter.isPrimary || filter.isLocked 33898 ); 33899 const buttonComponent = /* @__PURE__ */ (0, import_jsx_runtime163.jsx)( 33900 import_components43.Button, 33901 { 33902 ref: buttonRef, 33903 className: "dataviews-filters__visibility-toggle", 33904 size: "compact", 33905 icon: funnel_default, 33906 disabled: hasPrimaryOrLockedFilters, 33907 accessibleWhenDisabled: true, 33908 ...hasVisibleFilters ? toggleFiltersButtonProps : addFilterButtonProps 33909 } 33910 ); 33911 return /* @__PURE__ */ (0, import_jsx_runtime163.jsx)("div", { className: "dataviews-filters__container-visibility-toggle", children: !hasVisibleFilters ? /* @__PURE__ */ (0, import_jsx_runtime163.jsx)( 33912 AddFilterMenu, 33913 { 33914 filters, 33915 view, 33916 onChangeView: onChangeViewWithFilterVisibility, 33917 setOpenedFilter, 33918 triggerProps: { render: buttonComponent } 33919 } 33920 ) : /* @__PURE__ */ (0, import_jsx_runtime163.jsx)( 33921 FilterVisibilityToggle, 33922 { 33923 buttonRef, 33924 filtersCount: view.filters?.length, 33925 children: buttonComponent 33926 } 33927 ) }); 33928 } 33929 function FilterVisibilityToggle({ 33930 buttonRef, 33931 filtersCount, 33932 children 33933 }) { 33934 (0, import_element90.useEffect)( 33935 () => () => { 33936 buttonRef.current?.focus(); 33937 }, 33938 [buttonRef] 33939 ); 33940 return /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)(import_jsx_runtime163.Fragment, { children: [ 33941 children, 33942 !!filtersCount && /* @__PURE__ */ (0, import_jsx_runtime163.jsx)("span", { className: "dataviews-filters-toggle__count", children: filtersCount }) 33943 ] }); 33944 } 33945 var toggle_default = FiltersToggle; 33946 33947 // packages/dataviews/build-module/components/dataviews-filters/filters-toggled.mjs 33948 var import_element91 = __toESM(require_element(), 1); 33949 var import_jsx_runtime164 = __toESM(require_jsx_runtime(), 1); 33950 function FiltersToggled(props) { 33951 const { isShowingFilter } = (0, import_element91.useContext)(dataviews_context_default); 33952 if (!isShowingFilter) { 33953 return null; 33954 } 33955 return /* @__PURE__ */ (0, import_jsx_runtime164.jsx)(filters_default, { ...props }); 33956 } 33957 var filters_toggled_default = FiltersToggled; 33958 33959 // packages/dataviews/build-module/components/dataviews-layout/index.mjs 33960 var import_element92 = __toESM(require_element(), 1); 33961 var import_components44 = __toESM(require_components(), 1); 33962 var import_i18n52 = __toESM(require_i18n(), 1); 33963 var import_jsx_runtime165 = __toESM(require_jsx_runtime(), 1); 33964 function DataViewsLayout({ className }) { 33965 const { 33966 actions = [], 33967 data, 33968 fields: fields2, 33969 getItemId: getItemId2, 33970 getItemLevel: getItemLevel2, 33971 hasInitiallyLoaded, 33972 isLoading, 33973 view, 33974 onChangeView, 33975 selection, 33976 onChangeSelection, 33977 setOpenedFilter, 33978 onClickItem, 33979 isItemClickable, 33980 renderItemLink, 33981 defaultLayouts: defaultLayouts2, 33982 containerRef, 33983 empty = /* @__PURE__ */ (0, import_jsx_runtime165.jsx)("p", { children: (0, import_i18n52.__)("No results") }) 33984 } = (0, import_element92.useContext)(dataviews_context_default); 33985 const isDelayedInitialLoading = useDelayedLoading(!hasInitiallyLoaded, { 33986 delay: 200 33987 }); 33988 if (!hasInitiallyLoaded) { 33989 if (!isDelayedInitialLoading) { 33990 return null; 33991 } 33992 return /* @__PURE__ */ (0, import_jsx_runtime165.jsx)("div", { className: "dataviews-loading", children: /* @__PURE__ */ (0, import_jsx_runtime165.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(import_components44.Spinner, {}) }) }); 33993 } 33994 const ViewComponent = VIEW_LAYOUTS.find( 33995 (v2) => v2.type === view.type && defaultLayouts2[v2.type] 33996 )?.component; 33997 return /* @__PURE__ */ (0, import_jsx_runtime165.jsx)("div", { className: "dataviews-layout__container", ref: containerRef, children: /* @__PURE__ */ (0, import_jsx_runtime165.jsx)( 33998 ViewComponent, 33999 { 34000 className, 34001 actions, 34002 data, 34003 fields: fields2, 34004 getItemId: getItemId2, 34005 getItemLevel: getItemLevel2, 34006 isLoading, 34007 onChangeView, 34008 onChangeSelection, 34009 selection, 34010 setOpenedFilter, 34011 onClickItem, 34012 renderItemLink, 34013 isItemClickable, 34014 view, 34015 empty 34016 } 34017 ) }); 34018 } 34019 34020 // packages/dataviews/build-module/components/dataviews-footer/index.mjs 34021 var import_element93 = __toESM(require_element(), 1); 34022 var import_jsx_runtime166 = __toESM(require_jsx_runtime(), 1); 34023 var EMPTY_ARRAY6 = []; 34024 function DataViewsFooter() { 34025 const { 34026 view, 34027 paginationInfo: { totalItems = 0, totalPages }, 34028 data, 34029 actions = EMPTY_ARRAY6, 34030 isLoading, 34031 hasInitiallyLoaded 34032 } = (0, import_element93.useContext)(dataviews_context_default); 34033 const isRefreshing = !!isLoading && hasInitiallyLoaded && !!data?.length; 34034 const isDelayedRefreshing = useDelayedLoading(!!isRefreshing); 34035 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data) && [LAYOUT_TABLE, LAYOUT_GRID].includes(view.type); 34036 const hasPagination = hasPaginationControls(view, { 34037 totalItems, 34038 totalPages 34039 }); 34040 if (!totalItems || !hasBulkActions && !hasPagination) { 34041 return null; 34042 } 34043 return /* @__PURE__ */ (0, import_jsx_runtime166.jsx)( 34044 "div", 34045 { 34046 className: "dataviews-footer", 34047 inert: isRefreshing ? "true" : void 0, 34048 children: /* @__PURE__ */ (0, import_jsx_runtime166.jsxs)( 34049 Stack, 34050 { 34051 direction: "row", 34052 justify: "end", 34053 align: "center", 34054 className: clsx_default("dataviews-footer__content", { 34055 "is-refreshing": isDelayedRefreshing 34056 }), 34057 gap: "sm", 34058 children: [ 34059 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(BulkActionsFooter, {}), 34060 /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(dataviews_pagination_default, {}) 34061 ] 34062 } 34063 ) 34064 } 34065 ); 34066 } 34067 34068 // packages/dataviews/build-module/components/dataviews-search/index.mjs 34069 var import_i18n53 = __toESM(require_i18n(), 1); 34070 var import_element94 = __toESM(require_element(), 1); 34071 var import_components45 = __toESM(require_components(), 1); 34072 var import_compose14 = __toESM(require_compose(), 1); 34073 var import_jsx_runtime167 = __toESM(require_jsx_runtime(), 1); 34074 var DataViewsSearch = (0, import_element94.memo)(function Search({ label }) { 34075 const { view, onChangeView } = (0, import_element94.useContext)(dataviews_context_default); 34076 const [search, setSearch, debouncedSearch] = (0, import_compose14.useDebouncedInput)( 34077 view.search 34078 ); 34079 (0, import_element94.useEffect)(() => { 34080 if (view.search !== debouncedSearch) { 34081 setSearch(view.search ?? ""); 34082 } 34083 }, [view.search, setSearch]); 34084 const onChangeViewRef = (0, import_element94.useRef)(onChangeView); 34085 const viewRef = (0, import_element94.useRef)(view); 34086 (0, import_element94.useEffect)(() => { 34087 onChangeViewRef.current = onChangeView; 34088 viewRef.current = view; 34089 }, [onChangeView, view]); 34090 (0, import_element94.useEffect)(() => { 34091 if (debouncedSearch !== viewRef.current?.search) { 34092 onChangeViewRef.current({ 34093 ...viewRef.current, 34094 page: view.page ? 1 : void 0, 34095 startPosition: view.startPosition ? 1 : void 0, 34096 search: debouncedSearch 34097 }); 34098 } 34099 }, [debouncedSearch]); 34100 const searchLabel = label || (0, import_i18n53.__)("Search"); 34101 return /* @__PURE__ */ (0, import_jsx_runtime167.jsx)( 34102 import_components45.SearchControl, 34103 { 34104 className: "dataviews-search", 34105 onChange: setSearch, 34106 value: search, 34107 label: searchLabel, 34108 placeholder: searchLabel, 34109 size: "compact" 34110 } 34111 ); 34112 }); 34113 var dataviews_search_default = DataViewsSearch; 34114 34115 // packages/dataviews/build-module/components/dataviews-view-config/index.mjs 34116 var import_components46 = __toESM(require_components(), 1); 34117 var import_i18n54 = __toESM(require_i18n(), 1); 34118 var import_element95 = __toESM(require_element(), 1); 34119 var import_warning = __toESM(require_warning(), 1); 34120 var import_compose15 = __toESM(require_compose(), 1); 34121 var import_jsx_runtime168 = __toESM(require_jsx_runtime(), 1); 34122 var { Menu: Menu5 } = unlock4(import_components46.privateApis); 34123 var DATAVIEWS_CONFIG_POPOVER_PROPS = { 34124 className: "dataviews-config__popover", 34125 placement: "bottom-end", 34126 offset: 9 34127 }; 34128 function ViewTypeMenu() { 34129 const { view, onChangeView, defaultLayouts: defaultLayouts2 } = (0, import_element95.useContext)(dataviews_context_default); 34130 const availableLayouts = Object.keys(defaultLayouts2); 34131 if (availableLayouts.length <= 1) { 34132 return null; 34133 } 34134 const activeView = VIEW_LAYOUTS.find((v2) => view.type === v2.type); 34135 return /* @__PURE__ */ (0, import_jsx_runtime168.jsxs)(Menu5, { children: [ 34136 /* @__PURE__ */ (0, import_jsx_runtime168.jsx)( 34137 Menu5.TriggerButton, 34138 { 34139 render: /* @__PURE__ */ (0, import_jsx_runtime168.jsx)( 34140 import_components46.Button, 34141 { 34142 size: "compact", 34143 icon: activeView?.icon, 34144 label: (0, import_i18n54.__)("Layout") 34145 } 34146 ) 34147 } 34148 ), 34149 /* @__PURE__ */ (0, import_jsx_runtime168.jsx)(Menu5.Popover, { children: availableLayouts.map((layout) => { 34150 const config2 = VIEW_LAYOUTS.find( 34151 (v2) => v2.type === layout 34152 ); 34153 if (!config2) { 34154 return null; 34155 } 34156 return /* @__PURE__ */ (0, import_jsx_runtime168.jsx)( 34157 Menu5.RadioItem, 34158 { 34159 value: layout, 34160 name: "view-actions-available-view", 34161 checked: layout === view.type, 34162 hideOnClick: true, 34163 onChange: (e2) => { 34164 switch (e2.target.value) { 34165 case "list": 34166 case "grid": 34167 case "table": 34168 case "pickerGrid": 34169 case "pickerTable": 34170 case "pickerActivity": 34171 case "activity": 34172 const viewWithoutLayout = { ...view }; 34173 if ("layout" in viewWithoutLayout) { 34174 delete viewWithoutLayout.layout; 34175 } 34176 return onChangeView({ 34177 ...viewWithoutLayout, 34178 type: e2.target.value, 34179 ...defaultLayouts2[e2.target.value] 34180 }); 34181 } 34182 (0, import_warning.default)("Invalid dataview"); 34183 }, 34184 children: /* @__PURE__ */ (0, import_jsx_runtime168.jsx)(Menu5.ItemLabel, { children: config2.label }) 34185 }, 34186 layout 34187 ); 34188 }) }) 34189 ] }); 34190 } 34191 function SortFieldControl() { 34192 const { view, fields: fields2, onChangeView } = (0, import_element95.useContext)(dataviews_context_default); 34193 const orderOptions = (0, import_element95.useMemo)(() => { 34194 const sortableFields = fields2.filter( 34195 (field) => field.enableSorting !== false 34196 ); 34197 return sortableFields.map((field) => { 34198 return { 34199 label: field.label, 34200 value: field.id 34201 }; 34202 }); 34203 }, [fields2]); 34204 return /* @__PURE__ */ (0, import_jsx_runtime168.jsx)( 34205 import_components46.SelectControl, 34206 { 34207 label: (0, import_i18n54.__)("Sort by"), 34208 value: view.sort?.field, 34209 options: orderOptions, 34210 onChange: (value) => { 34211 onChangeView({ 34212 ...view, 34213 sort: { 34214 direction: view?.sort?.direction || "desc", 34215 field: value 34216 }, 34217 showLevels: false 34218 }); 34219 } 34220 } 34221 ); 34222 } 34223 function SortDirectionControl() { 34224 const { view, fields: fields2, onChangeView } = (0, import_element95.useContext)(dataviews_context_default); 34225 const sortableFields = fields2.filter( 34226 (field) => field.enableSorting !== false 34227 ); 34228 if (sortableFields.length === 0) { 34229 return null; 34230 } 34231 let value = view.sort?.direction; 34232 if (!value && view.sort?.field) { 34233 value = "desc"; 34234 } 34235 return /* @__PURE__ */ (0, import_jsx_runtime168.jsx)( 34236 import_components46.__experimentalToggleGroupControl, 34237 { 34238 className: "dataviews-view-config__sort-direction", 34239 isBlock: true, 34240 label: (0, import_i18n54.__)("Order"), 34241 value, 34242 onChange: (newDirection) => { 34243 if (newDirection === "asc" || newDirection === "desc") { 34244 onChangeView({ 34245 ...view, 34246 sort: { 34247 direction: newDirection, 34248 field: view.sort?.field || // If there is no field assigned as the sorting field assign the first sortable field. 34249 fields2.find( 34250 (field) => field.enableSorting !== false 34251 )?.id || "" 34252 }, 34253 showLevels: false 34254 }); 34255 return; 34256 } 34257 (0, import_warning.default)("Invalid direction"); 34258 }, 34259 children: SORTING_DIRECTIONS.map((direction) => { 34260 return /* @__PURE__ */ (0, import_jsx_runtime168.jsx)( 34261 import_components46.__experimentalToggleGroupControlOptionIcon, 34262 { 34263 value: direction, 34264 icon: sortIcons[direction], 34265 label: sortLabels[direction] 34266 }, 34267 direction 34268 ); 34269 }) 34270 } 34271 ); 34272 } 34273 function ItemsPerPageControl() { 34274 const { view, config: config2, onChangeView } = (0, import_element95.useContext)(dataviews_context_default); 34275 const { infiniteScrollEnabled } = view; 34276 if (!config2 || !config2.perPageSizes || config2.perPageSizes.length < 2 || config2.perPageSizes.length > 6 || infiniteScrollEnabled) { 34277 return null; 34278 } 34279 return /* @__PURE__ */ (0, import_jsx_runtime168.jsx)( 34280 import_components46.__experimentalToggleGroupControl, 34281 { 34282 isBlock: true, 34283 label: (0, import_i18n54.__)("Items per page"), 34284 value: view.perPage || 10, 34285 disabled: !view?.sort?.field, 34286 onChange: (newItemsPerPage) => { 34287 const newItemsPerPageNumber = typeof newItemsPerPage === "number" || newItemsPerPage === void 0 ? newItemsPerPage : parseInt(newItemsPerPage, 10); 34288 onChangeView({ 34289 ...view, 34290 perPage: newItemsPerPageNumber, 34291 page: 1 34292 }); 34293 }, 34294 children: config2.perPageSizes.map((value) => { 34295 return /* @__PURE__ */ (0, import_jsx_runtime168.jsx)( 34296 import_components46.__experimentalToggleGroupControlOption, 34297 { 34298 value, 34299 label: value.toString() 34300 }, 34301 value 34302 ); 34303 }) 34304 } 34305 ); 34306 } 34307 function ResetViewButton() { 34308 const { onReset } = (0, import_element95.useContext)(dataviews_context_default); 34309 if (onReset === void 0) { 34310 return null; 34311 } 34312 const isDisabled = onReset === false; 34313 return /* @__PURE__ */ (0, import_jsx_runtime168.jsx)( 34314 import_components46.Button, 34315 { 34316 variant: "tertiary", 34317 size: "compact", 34318 disabled: isDisabled, 34319 accessibleWhenDisabled: true, 34320 className: "dataviews-view-config__reset-button", 34321 onClick: () => { 34322 if (typeof onReset === "function") { 34323 onReset(); 34324 } 34325 }, 34326 children: (0, import_i18n54.__)("Reset view") 34327 } 34328 ); 34329 } 34330 function DataviewsViewConfigDropdown() { 34331 const { view, onReset } = (0, import_element95.useContext)(dataviews_context_default); 34332 const popoverId = (0, import_compose15.useInstanceId)( 34333 _DataViewsViewConfig, 34334 "dataviews-view-config-dropdown" 34335 ); 34336 const activeLayout = VIEW_LAYOUTS.find( 34337 (layout) => layout.type === view.type 34338 ); 34339 const isModified = typeof onReset === "function"; 34340 return /* @__PURE__ */ (0, import_jsx_runtime168.jsx)( 34341 import_components46.Dropdown, 34342 { 34343 expandOnMobile: true, 34344 popoverProps: { 34345 ...DATAVIEWS_CONFIG_POPOVER_PROPS, 34346 id: popoverId 34347 }, 34348 renderToggle: ({ onToggle, isOpen }) => { 34349 return /* @__PURE__ */ (0, import_jsx_runtime168.jsxs)("div", { className: "dataviews-view-config__toggle-wrapper", children: [ 34350 /* @__PURE__ */ (0, import_jsx_runtime168.jsx)( 34351 import_components46.Button, 34352 { 34353 size: "compact", 34354 icon: cog_default, 34355 label: (0, import_i18n54._x)( 34356 "View options", 34357 "View is used as a noun" 34358 ), 34359 onClick: onToggle, 34360 "aria-expanded": isOpen ? "true" : "false", 34361 "aria-controls": popoverId 34362 } 34363 ), 34364 isModified && /* @__PURE__ */ (0, import_jsx_runtime168.jsx)("span", { className: "dataviews-view-config__modified-indicator" }) 34365 ] }); 34366 }, 34367 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime168.jsx)( 34368 import_components46.__experimentalDropdownContentWrapper, 34369 { 34370 paddingSize: "medium", 34371 className: "dataviews-config__popover-content-wrapper", 34372 children: /* @__PURE__ */ (0, import_jsx_runtime168.jsxs)( 34373 Stack, 34374 { 34375 direction: "column", 34376 className: "dataviews-view-config", 34377 gap: "xl", 34378 children: [ 34379 /* @__PURE__ */ (0, import_jsx_runtime168.jsxs)( 34380 Stack, 34381 { 34382 direction: "row", 34383 justify: "space-between", 34384 align: "center", 34385 className: "dataviews-view-config__header", 34386 children: [ 34387 /* @__PURE__ */ (0, import_jsx_runtime168.jsx)( 34388 import_components46.__experimentalHeading, 34389 { 34390 level: 2, 34391 className: "dataviews-settings-section__title", 34392 children: (0, import_i18n54.__)("Appearance") 34393 } 34394 ), 34395 /* @__PURE__ */ (0, import_jsx_runtime168.jsx)(ResetViewButton, {}) 34396 ] 34397 } 34398 ), 34399 /* @__PURE__ */ (0, import_jsx_runtime168.jsxs)(Stack, { direction: "column", gap: "lg", children: [ 34400 /* @__PURE__ */ (0, import_jsx_runtime168.jsxs)( 34401 Stack, 34402 { 34403 direction: "row", 34404 gap: "sm", 34405 className: "dataviews-view-config__sort-controls", 34406 children: [ 34407 /* @__PURE__ */ (0, import_jsx_runtime168.jsx)(SortFieldControl, {}), 34408 /* @__PURE__ */ (0, import_jsx_runtime168.jsx)(SortDirectionControl, {}) 34409 ] 34410 } 34411 ), 34412 !!activeLayout?.viewConfigOptions && /* @__PURE__ */ (0, import_jsx_runtime168.jsx)(activeLayout.viewConfigOptions, {}), 34413 /* @__PURE__ */ (0, import_jsx_runtime168.jsx)(ItemsPerPageControl, {}), 34414 /* @__PURE__ */ (0, import_jsx_runtime168.jsx)(PropertiesSection, {}) 34415 ] }) 34416 ] 34417 } 34418 ) 34419 } 34420 ) 34421 } 34422 ); 34423 } 34424 function _DataViewsViewConfig() { 34425 return /* @__PURE__ */ (0, import_jsx_runtime168.jsxs)(import_jsx_runtime168.Fragment, { children: [ 34426 /* @__PURE__ */ (0, import_jsx_runtime168.jsx)(ViewTypeMenu, {}), 34427 /* @__PURE__ */ (0, import_jsx_runtime168.jsx)(DataviewsViewConfigDropdown, {}) 34428 ] }); 34429 } 34430 var DataViewsViewConfig = (0, import_element95.memo)(_DataViewsViewConfig); 34431 var dataviews_view_config_default = DataViewsViewConfig; 34432 34433 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs 34434 var import_components47 = __toESM(require_components(), 1); 34435 var import_element96 = __toESM(require_element(), 1); 34436 34437 // packages/dataviews/build-module/components/dataform-controls/utils/get-custom-validity.mjs 34438 function getCustomValidity(isValid2, validity) { 34439 let customValidity; 34440 if (isValid2?.required && validity?.required) { 34441 customValidity = validity?.required?.message ? validity.required : void 0; 34442 } else if (isValid2?.pattern && validity?.pattern) { 34443 customValidity = validity.pattern; 34444 } else if (isValid2?.min && validity?.min) { 34445 customValidity = validity.min; 34446 } else if (isValid2?.max && validity?.max) { 34447 customValidity = validity.max; 34448 } else if (isValid2?.minLength && validity?.minLength) { 34449 customValidity = validity.minLength; 34450 } else if (isValid2?.maxLength && validity?.maxLength) { 34451 customValidity = validity.maxLength; 34452 } else if (isValid2?.elements && validity?.elements) { 34453 customValidity = validity.elements; 34454 } else if (validity?.custom) { 34455 customValidity = validity.custom; 34456 } 34457 return customValidity; 34458 } 34459 34460 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs 34461 var import_jsx_runtime169 = __toESM(require_jsx_runtime(), 1); 34462 var { ValidatedCheckboxControl } = unlock4(import_components47.privateApis); 34463 function Checkbox({ 34464 field, 34465 onChange, 34466 data, 34467 hideLabelFromVision, 34468 markWhenOptional, 34469 validity 34470 }) { 34471 const { getValue, setValue, label, description, isValid: isValid2 } = field; 34472 const disabled2 = field.isDisabled({ item: data, field }); 34473 const onChangeControl = (0, import_element96.useCallback)(() => { 34474 onChange( 34475 setValue({ item: data, value: !getValue({ item: data }) }) 34476 ); 34477 }, [data, getValue, onChange, setValue]); 34478 return /* @__PURE__ */ (0, import_jsx_runtime169.jsx)( 34479 ValidatedCheckboxControl, 34480 { 34481 required: !!field.isValid?.required, 34482 markWhenOptional, 34483 customValidity: getCustomValidity(isValid2, validity), 34484 hidden: hideLabelFromVision, 34485 label, 34486 help: description, 34487 checked: getValue({ item: data }), 34488 onChange: onChangeControl, 34489 disabled: disabled2 34490 } 34491 ); 34492 } 34493 34494 // packages/dataviews/build-module/components/dataform-controls/combobox.mjs 34495 var import_components48 = __toESM(require_components(), 1); 34496 var import_element97 = __toESM(require_element(), 1); 34497 var import_jsx_runtime170 = __toESM(require_jsx_runtime(), 1); 34498 var { ValidatedComboboxControl } = unlock4(import_components48.privateApis); 34499 function Combobox3({ 34500 data, 34501 field, 34502 onChange, 34503 hideLabelFromVision, 34504 validity 34505 }) { 34506 const { label, description, placeholder, getValue, setValue, isValid: isValid2 } = field; 34507 const value = getValue({ item: data }) ?? ""; 34508 const onChangeControl = (0, import_element97.useCallback)( 34509 (newValue) => onChange(setValue({ item: data, value: newValue ?? "" })), 34510 [data, onChange, setValue] 34511 ); 34512 const { elements: elements2, isLoading } = useElements({ 34513 elements: field.elements, 34514 getElements: field.getElements 34515 }); 34516 if (isLoading) { 34517 return /* @__PURE__ */ (0, import_jsx_runtime170.jsx)(import_components48.Spinner, {}); 34518 } 34519 return /* @__PURE__ */ (0, import_jsx_runtime170.jsx)( 34520 ValidatedComboboxControl, 34521 { 34522 required: !!field.isValid?.required, 34523 customValidity: getCustomValidity(isValid2, validity), 34524 label, 34525 value, 34526 help: description, 34527 placeholder, 34528 options: elements2, 34529 onChange: onChangeControl, 34530 hideLabelFromVision, 34531 allowReset: true, 34532 expandOnFocus: true 34533 } 34534 ); 34535 } 34536 34537 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs 34538 var import_components50 = __toESM(require_components(), 1); 34539 var import_element100 = __toESM(require_element(), 1); 34540 var import_i18n56 = __toESM(require_i18n(), 1); 34541 var import_date3 = __toESM(require_date(), 1); 34542 34543 // packages/dataviews/build-module/components/dataform-controls/utils/relative-date-control.mjs 34544 var import_components49 = __toESM(require_components(), 1); 34545 var import_element98 = __toESM(require_element(), 1); 34546 var import_i18n55 = __toESM(require_i18n(), 1); 34547 var import_jsx_runtime171 = __toESM(require_jsx_runtime(), 1); 34548 var TIME_UNITS_OPTIONS = { 34549 [OPERATOR_IN_THE_PAST]: [ 34550 { value: "days", label: (0, import_i18n55.__)("Days") }, 34551 { value: "weeks", label: (0, import_i18n55.__)("Weeks") }, 34552 { value: "months", label: (0, import_i18n55.__)("Months") }, 34553 { value: "years", label: (0, import_i18n55.__)("Years") } 34554 ], 34555 [OPERATOR_OVER]: [ 34556 { value: "days", label: (0, import_i18n55.__)("Days ago") }, 34557 { value: "weeks", label: (0, import_i18n55.__)("Weeks ago") }, 34558 { value: "months", label: (0, import_i18n55.__)("Months ago") }, 34559 { value: "years", label: (0, import_i18n55.__)("Years ago") } 34560 ] 34561 }; 34562 function RelativeDateControl({ 34563 className, 34564 data, 34565 field, 34566 onChange, 34567 hideLabelFromVision, 34568 operator 34569 }) { 34570 const options = TIME_UNITS_OPTIONS[operator === OPERATOR_IN_THE_PAST ? "inThePast" : "over"]; 34571 const { id, label, description, getValue, setValue } = field; 34572 const disabled2 = field.isDisabled({ item: data, field }); 34573 const fieldValue = getValue({ item: data }); 34574 const { value: relValue = "", unit = options[0].value } = fieldValue && typeof fieldValue === "object" ? fieldValue : {}; 34575 const onChangeValue = (0, import_element98.useCallback)( 34576 (newValue) => onChange( 34577 setValue({ 34578 item: data, 34579 value: { value: Number(newValue), unit } 34580 }) 34581 ), 34582 [onChange, setValue, data, unit] 34583 ); 34584 const onChangeUnit = (0, import_element98.useCallback)( 34585 (newUnit) => onChange( 34586 setValue({ 34587 item: data, 34588 value: { value: relValue, unit: newUnit } 34589 }) 34590 ), 34591 [onChange, setValue, data, relValue] 34592 ); 34593 return /* @__PURE__ */ (0, import_jsx_runtime171.jsx)( 34594 import_components49.BaseControl, 34595 { 34596 id, 34597 className: clsx_default(className, "dataviews-controls__relative-date"), 34598 label, 34599 hideLabelFromVision, 34600 help: description, 34601 children: /* @__PURE__ */ (0, import_jsx_runtime171.jsxs)(Stack, { direction: "row", gap: "sm", children: [ 34602 /* @__PURE__ */ (0, import_jsx_runtime171.jsx)( 34603 import_components49.__experimentalNumberControl, 34604 { 34605 className: "dataviews-controls__relative-date-number", 34606 spinControls: "none", 34607 min: 1, 34608 step: 1, 34609 value: relValue, 34610 onChange: onChangeValue, 34611 disabled: disabled2 34612 } 34613 ), 34614 /* @__PURE__ */ (0, import_jsx_runtime171.jsx)( 34615 import_components49.SelectControl, 34616 { 34617 className: "dataviews-controls__relative-date-unit", 34618 label: (0, import_i18n55.__)("Unit"), 34619 value: unit, 34620 options, 34621 onChange: onChangeUnit, 34622 hideLabelFromVision: true, 34623 disabled: disabled2 34624 } 34625 ) 34626 ] }) 34627 } 34628 ); 34629 } 34630 34631 // packages/dataviews/build-module/components/dataform-controls/utils/use-disabled-date-matchers.mjs 34632 var import_element99 = __toESM(require_element(), 1); 34633 function useDisabledDateMatchers(isValid2, parseDateFn) { 34634 const minConstraint = typeof isValid2.min?.constraint === "string" ? isValid2.min.constraint : void 0; 34635 const maxConstraint = typeof isValid2.max?.constraint === "string" ? isValid2.max.constraint : void 0; 34636 const disabledMatchers = (0, import_element99.useMemo)(() => { 34637 const matchers = []; 34638 if (minConstraint) { 34639 const minDate = parseDateFn(minConstraint); 34640 if (minDate) { 34641 matchers.push({ before: minDate }); 34642 } 34643 } 34644 if (maxConstraint) { 34645 const maxDate = parseDateFn(maxConstraint); 34646 if (maxDate) { 34647 matchers.push({ after: maxDate }); 34648 } 34649 } 34650 return matchers.length > 0 ? matchers : void 0; 34651 }, [minConstraint, maxConstraint, parseDateFn]); 34652 return { minConstraint, maxConstraint, disabledMatchers }; 34653 } 34654 34655 // packages/dataviews/build-module/field-types/utils/parse-date-time.mjs 34656 var import_date2 = __toESM(require_date(), 1); 34657 function parseDateTime(dateTimeString) { 34658 if (!dateTimeString) { 34659 return null; 34660 } 34661 const parsed = (0, import_date2.getDate)(dateTimeString); 34662 return parsed && isValid(parsed) ? parsed : null; 34663 } 34664 34665 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs 34666 var import_jsx_runtime172 = __toESM(require_jsx_runtime(), 1); 34667 var { DateCalendar, ValidatedInputControl } = unlock4(import_components50.privateApis); 34668 var formatDateTime = (value) => { 34669 if (!value) { 34670 return ""; 34671 } 34672 return (0, import_date3.dateI18n)("Y-m-d\\TH:i", (0, import_date3.getDate)(value)); 34673 }; 34674 function CalendarDateTimeControl({ 34675 data, 34676 field, 34677 onChange, 34678 hideLabelFromVision, 34679 markWhenOptional, 34680 validity, 34681 config: config2 34682 }) { 34683 const { compact } = config2 || {}; 34684 const { id, label, description, setValue, getValue, isValid: isValid2 } = field; 34685 const disabled2 = field.isDisabled({ item: data, field }); 34686 const fieldValue = getValue({ item: data }); 34687 const value = typeof fieldValue === "string" ? fieldValue : void 0; 34688 const [calendarMonth, setCalendarMonth] = (0, import_element100.useState)(() => { 34689 const parsedDate = parseDateTime(value); 34690 return parsedDate || /* @__PURE__ */ new Date(); 34691 }); 34692 const inputControlRef = (0, import_element100.useRef)(null); 34693 const validationTimeoutRef = (0, import_element100.useRef)(void 0); 34694 const previousFocusRef = (0, import_element100.useRef)(null); 34695 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDateTime); 34696 const onChangeCallback = (0, import_element100.useCallback)( 34697 (newValue) => onChange(setValue({ item: data, value: newValue })), 34698 [data, onChange, setValue] 34699 ); 34700 (0, import_element100.useEffect)(() => { 34701 return () => { 34702 if (validationTimeoutRef.current) { 34703 clearTimeout(validationTimeoutRef.current); 34704 } 34705 }; 34706 }, []); 34707 const onSelectDate = (0, import_element100.useCallback)( 34708 (newDate) => { 34709 let dateTimeValue; 34710 if (newDate) { 34711 const wpDate = (0, import_date3.dateI18n)("Y-m-d", newDate); 34712 let wpTime; 34713 if (value) { 34714 wpTime = (0, import_date3.dateI18n)("H:i", (0, import_date3.getDate)(value)); 34715 } else { 34716 wpTime = (0, import_date3.dateI18n)("H:i", newDate); 34717 } 34718 const finalDateTime = (0, import_date3.getDate)(`$wpDate}T$wpTime}`); 34719 dateTimeValue = finalDateTime.toISOString(); 34720 onChangeCallback(dateTimeValue); 34721 if (validationTimeoutRef.current) { 34722 clearTimeout(validationTimeoutRef.current); 34723 } 34724 } else { 34725 onChangeCallback(void 0); 34726 } 34727 previousFocusRef.current = inputControlRef.current && inputControlRef.current.ownerDocument.activeElement; 34728 validationTimeoutRef.current = setTimeout(() => { 34729 if (inputControlRef.current) { 34730 inputControlRef.current.focus(); 34731 inputControlRef.current.blur(); 34732 onChangeCallback(dateTimeValue); 34733 if (previousFocusRef.current && previousFocusRef.current instanceof HTMLElement) { 34734 previousFocusRef.current.focus(); 34735 } 34736 } 34737 }, 0); 34738 }, 34739 [onChangeCallback, value] 34740 ); 34741 const handleManualDateTimeChange = (0, import_element100.useCallback)( 34742 (newValue) => { 34743 if (newValue) { 34744 const dateTime = (0, import_date3.getDate)(newValue); 34745 onChangeCallback(dateTime.toISOString()); 34746 const parsedDate = parseDateTime(dateTime.toISOString()); 34747 if (parsedDate) { 34748 setCalendarMonth(parsedDate); 34749 } 34750 } else { 34751 onChangeCallback(void 0); 34752 } 34753 }, 34754 [onChangeCallback] 34755 ); 34756 const { format: fieldFormat } = field; 34757 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date3.getSettings)().l10n.startOfWeek; 34758 const { 34759 timezone: { string: timezoneString } 34760 } = (0, import_date3.getSettings)(); 34761 let displayLabel = label; 34762 if (isValid2?.required && !markWhenOptional && !hideLabelFromVision) { 34763 displayLabel = `$label} (${(0, import_i18n56.__)("Required")})`; 34764 } else if (!isValid2?.required && markWhenOptional && !hideLabelFromVision) { 34765 displayLabel = `$label} (${(0, import_i18n56.__)("Optional")})`; 34766 } 34767 return /* @__PURE__ */ (0, import_jsx_runtime172.jsx)( 34768 import_components50.BaseControl, 34769 { 34770 id, 34771 label: displayLabel, 34772 help: description, 34773 hideLabelFromVision, 34774 children: /* @__PURE__ */ (0, import_jsx_runtime172.jsxs)(Stack, { direction: "column", gap: "lg", children: [ 34775 /* @__PURE__ */ (0, import_jsx_runtime172.jsx)( 34776 ValidatedInputControl, 34777 { 34778 ref: inputControlRef, 34779 required: !!isValid2?.required, 34780 customValidity: getCustomValidity(isValid2, validity), 34781 type: "datetime-local", 34782 label: (0, import_i18n56.__)("Date time"), 34783 hideLabelFromVision: true, 34784 value: formatDateTime(value), 34785 onChange: handleManualDateTimeChange, 34786 disabled: disabled2, 34787 min: minConstraint ? formatDateTime(minConstraint) : void 0, 34788 max: maxConstraint ? formatDateTime(maxConstraint) : void 0 34789 } 34790 ), 34791 !compact && /* @__PURE__ */ (0, import_jsx_runtime172.jsx)( 34792 DateCalendar, 34793 { 34794 style: { width: "100%" }, 34795 selected: value ? parseDateTime(value) || void 0 : void 0, 34796 onSelect: onSelectDate, 34797 month: calendarMonth, 34798 onMonthChange: setCalendarMonth, 34799 timeZone: timezoneString || void 0, 34800 weekStartsOn, 34801 disabled: disabled2 || disabledMatchers 34802 } 34803 ) 34804 ] }) 34805 } 34806 ); 34807 } 34808 function DateTime({ 34809 data, 34810 field, 34811 onChange, 34812 hideLabelFromVision, 34813 markWhenOptional, 34814 operator, 34815 validity, 34816 config: config2 34817 }) { 34818 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) { 34819 return /* @__PURE__ */ (0, import_jsx_runtime172.jsx)( 34820 RelativeDateControl, 34821 { 34822 className: "dataviews-controls__datetime", 34823 data, 34824 field, 34825 onChange, 34826 hideLabelFromVision, 34827 operator 34828 } 34829 ); 34830 } 34831 return /* @__PURE__ */ (0, import_jsx_runtime172.jsx)( 34832 CalendarDateTimeControl, 34833 { 34834 data, 34835 field, 34836 onChange, 34837 hideLabelFromVision, 34838 markWhenOptional, 34839 validity, 34840 config: config2 34841 } 34842 ); 34843 } 34844 34845 // packages/dataviews/build-module/components/dataform-controls/date.mjs 34846 var import_components51 = __toESM(require_components(), 1); 34847 var import_a11y2 = __toESM(require_a11y(), 1); 34848 var import_element101 = __toESM(require_element(), 1); 34849 var import_i18n57 = __toESM(require_i18n(), 1); 34850 var import_date4 = __toESM(require_date(), 1); 34851 var import_jsx_runtime173 = __toESM(require_jsx_runtime(), 1); 34852 var { DateCalendar: DateCalendar2, DateRangeCalendar } = unlock4(import_components51.privateApis); 34853 var DATE_PRESETS = [ 34854 { 34855 id: "today", 34856 label: (0, import_i18n57.__)("Today"), 34857 getValue: () => (0, import_date4.getDate)(null) 34858 }, 34859 { 34860 id: "yesterday", 34861 label: (0, import_i18n57.__)("Yesterday"), 34862 getValue: () => { 34863 const today = (0, import_date4.getDate)(null); 34864 return subDays(today, 1); 34865 } 34866 }, 34867 { 34868 id: "past-week", 34869 label: (0, import_i18n57.__)("Past week"), 34870 getValue: () => { 34871 const today = (0, import_date4.getDate)(null); 34872 return subDays(today, 7); 34873 } 34874 }, 34875 { 34876 id: "past-month", 34877 label: (0, import_i18n57.__)("Past month"), 34878 getValue: () => { 34879 const today = (0, import_date4.getDate)(null); 34880 return subMonths(today, 1); 34881 } 34882 } 34883 ]; 34884 var DATE_RANGE_PRESETS = [ 34885 { 34886 id: "last-7-days", 34887 label: (0, import_i18n57.__)("Last 7 days"), 34888 getValue: () => { 34889 const today = (0, import_date4.getDate)(null); 34890 return [subDays(today, 7), today]; 34891 } 34892 }, 34893 { 34894 id: "last-30-days", 34895 label: (0, import_i18n57.__)("Last 30 days"), 34896 getValue: () => { 34897 const today = (0, import_date4.getDate)(null); 34898 return [subDays(today, 30), today]; 34899 } 34900 }, 34901 { 34902 id: "month-to-date", 34903 label: (0, import_i18n57.__)("Month to date"), 34904 getValue: () => { 34905 const today = (0, import_date4.getDate)(null); 34906 return [startOfMonth(today), today]; 34907 } 34908 }, 34909 { 34910 id: "last-year", 34911 label: (0, import_i18n57.__)("Last year"), 34912 getValue: () => { 34913 const today = (0, import_date4.getDate)(null); 34914 return [subYears(today, 1), today]; 34915 } 34916 }, 34917 { 34918 id: "year-to-date", 34919 label: (0, import_i18n57.__)("Year to date"), 34920 getValue: () => { 34921 const today = (0, import_date4.getDate)(null); 34922 return [startOfYear(today), today]; 34923 } 34924 } 34925 ]; 34926 var parseDate = (dateString) => { 34927 if (!dateString) { 34928 return null; 34929 } 34930 const parsed = (0, import_date4.getDate)(dateString); 34931 return parsed && isValid(parsed) ? parsed : null; 34932 }; 34933 var formatDate = (date) => { 34934 if (!date) { 34935 return ""; 34936 } 34937 return typeof date === "string" ? date : format(date, "yyyy-MM-dd"); 34938 }; 34939 function ValidatedDateControl({ 34940 field, 34941 validity, 34942 inputRefs, 34943 isTouched, 34944 setIsTouched, 34945 children 34946 }) { 34947 const { isValid: isValid2 } = field; 34948 const [customValidity, setCustomValidity] = (0, import_element101.useState)(void 0); 34949 const validateRefs = (0, import_element101.useCallback)(() => { 34950 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs]; 34951 for (const ref of refs) { 34952 const input = ref.current; 34953 if (input && !input.validity.valid) { 34954 setCustomValidity({ 34955 type: "invalid", 34956 message: input.validationMessage 34957 }); 34958 return; 34959 } 34960 } 34961 setCustomValidity(void 0); 34962 }, [inputRefs]); 34963 (0, import_element101.useEffect)(() => { 34964 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs]; 34965 const result = validity ? getCustomValidity(isValid2, validity) : void 0; 34966 for (const ref of refs) { 34967 const input = ref.current; 34968 if (input) { 34969 input.setCustomValidity( 34970 result?.type === "invalid" && result.message ? result.message : "" 34971 ); 34972 } 34973 } 34974 }, [inputRefs, isValid2, validity]); 34975 (0, import_element101.useEffect)(() => { 34976 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs]; 34977 const handleInvalid = (event) => { 34978 event.preventDefault(); 34979 setIsTouched(true); 34980 }; 34981 for (const ref of refs) { 34982 ref.current?.addEventListener("invalid", handleInvalid); 34983 } 34984 return () => { 34985 for (const ref of refs) { 34986 ref.current?.removeEventListener("invalid", handleInvalid); 34987 } 34988 }; 34989 }, [inputRefs, setIsTouched]); 34990 (0, import_element101.useEffect)(() => { 34991 if (!isTouched) { 34992 return; 34993 } 34994 const result = validity ? getCustomValidity(isValid2, validity) : void 0; 34995 if (result) { 34996 setCustomValidity(result); 34997 } else { 34998 validateRefs(); 34999 } 35000 }, [isTouched, isValid2, validity, validateRefs]); 35001 (0, import_element101.useEffect)(() => { 35002 if (isTouched && customValidity?.message) { 35003 (0, import_a11y2.speak)(customValidity.message); 35004 } 35005 }, [isTouched, customValidity?.message]); 35006 const onBlur = (event) => { 35007 if (isTouched) { 35008 return; 35009 } 35010 if (!event.relatedTarget || !event.currentTarget.contains(event.relatedTarget)) { 35011 setIsTouched(true); 35012 } 35013 }; 35014 return /* @__PURE__ */ (0, import_jsx_runtime173.jsxs)("div", { onBlur, children: [ 35015 children, 35016 customValidity && /* @__PURE__ */ (0, import_jsx_runtime173.jsxs)( 35017 "p", 35018 { 35019 className: clsx_default( 35020 "components-validated-control__indicator", 35021 customValidity.type === "invalid" ? "is-invalid" : void 0 35022 ), 35023 children: [ 35024 /* @__PURE__ */ (0, import_jsx_runtime173.jsx)( 35025 import_components51.Icon, 35026 { 35027 className: "components-validated-control__indicator-icon", 35028 icon: error_default, 35029 size: 16, 35030 fill: "currentColor" 35031 } 35032 ), 35033 customValidity.message 35034 ] 35035 } 35036 ) 35037 ] }); 35038 } 35039 function CalendarDateControl({ 35040 data, 35041 field, 35042 onChange, 35043 hideLabelFromVision, 35044 markWhenOptional, 35045 validity 35046 }) { 35047 const { 35048 id, 35049 label, 35050 description, 35051 setValue, 35052 getValue, 35053 isValid: isValid2, 35054 format: fieldFormat 35055 } = field; 35056 const disabled2 = field.isDisabled({ item: data, field }); 35057 const [selectedPresetId, setSelectedPresetId] = (0, import_element101.useState)( 35058 null 35059 ); 35060 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek; 35061 const fieldValue = getValue({ item: data }); 35062 const value = typeof fieldValue === "string" ? fieldValue : void 0; 35063 const [calendarMonth, setCalendarMonth] = (0, import_element101.useState)(() => { 35064 const parsedDate = parseDate(value); 35065 return parsedDate || /* @__PURE__ */ new Date(); 35066 }); 35067 const [isTouched, setIsTouched] = (0, import_element101.useState)(false); 35068 const validityTargetRef = (0, import_element101.useRef)(null); 35069 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate); 35070 const onChangeCallback = (0, import_element101.useCallback)( 35071 (newValue) => onChange(setValue({ item: data, value: newValue })), 35072 [data, onChange, setValue] 35073 ); 35074 const onSelectDate = (0, import_element101.useCallback)( 35075 (newDate) => { 35076 const dateValue = newDate ? format(newDate, "yyyy-MM-dd") : void 0; 35077 onChangeCallback(dateValue); 35078 setSelectedPresetId(null); 35079 setIsTouched(true); 35080 }, 35081 [onChangeCallback] 35082 ); 35083 const handlePresetClick = (0, import_element101.useCallback)( 35084 (preset) => { 35085 const presetDate = preset.getValue(); 35086 const dateValue = formatDate(presetDate); 35087 setCalendarMonth(presetDate); 35088 onChangeCallback(dateValue); 35089 setSelectedPresetId(preset.id); 35090 setIsTouched(true); 35091 }, 35092 [onChangeCallback] 35093 ); 35094 const handleManualDateChange = (0, import_element101.useCallback)( 35095 (newValue) => { 35096 onChangeCallback(newValue); 35097 if (newValue) { 35098 const parsedDate = parseDate(newValue); 35099 if (parsedDate) { 35100 setCalendarMonth(parsedDate); 35101 } 35102 } 35103 setSelectedPresetId(null); 35104 setIsTouched(true); 35105 }, 35106 [onChangeCallback] 35107 ); 35108 const { 35109 timezone: { string: timezoneString } 35110 } = (0, import_date4.getSettings)(); 35111 let displayLabel = label; 35112 if (isValid2?.required && !markWhenOptional) { 35113 displayLabel = `$label} (${(0, import_i18n57.__)("Required")})`; 35114 } else if (!isValid2?.required && markWhenOptional) { 35115 displayLabel = `$label} (${(0, import_i18n57.__)("Optional")})`; 35116 } 35117 return /* @__PURE__ */ (0, import_jsx_runtime173.jsx)( 35118 ValidatedDateControl, 35119 { 35120 field, 35121 validity, 35122 inputRefs: validityTargetRef, 35123 isTouched, 35124 setIsTouched, 35125 children: /* @__PURE__ */ (0, import_jsx_runtime173.jsx)( 35126 import_components51.BaseControl, 35127 { 35128 id, 35129 className: "dataviews-controls__date", 35130 label: displayLabel, 35131 help: description, 35132 hideLabelFromVision, 35133 children: /* @__PURE__ */ (0, import_jsx_runtime173.jsxs)(Stack, { direction: "column", gap: "lg", children: [ 35134 /* @__PURE__ */ (0, import_jsx_runtime173.jsxs)( 35135 Stack, 35136 { 35137 direction: "row", 35138 gap: "sm", 35139 wrap: "wrap", 35140 justify: "flex-start", 35141 children: [ 35142 DATE_PRESETS.map((preset) => { 35143 const isSelected2 = selectedPresetId === preset.id; 35144 return /* @__PURE__ */ (0, import_jsx_runtime173.jsx)( 35145 import_components51.Button, 35146 { 35147 className: "dataviews-controls__date-preset", 35148 variant: "tertiary", 35149 isPressed: isSelected2, 35150 size: "small", 35151 disabled: disabled2, 35152 accessibleWhenDisabled: true, 35153 onClick: () => handlePresetClick(preset), 35154 children: preset.label 35155 }, 35156 preset.id 35157 ); 35158 }), 35159 /* @__PURE__ */ (0, import_jsx_runtime173.jsx)( 35160 import_components51.Button, 35161 { 35162 className: "dataviews-controls__date-preset", 35163 variant: "tertiary", 35164 isPressed: !selectedPresetId, 35165 size: "small", 35166 disabled: !!selectedPresetId || disabled2, 35167 accessibleWhenDisabled: true, 35168 children: (0, import_i18n57.__)("Custom") 35169 } 35170 ) 35171 ] 35172 } 35173 ), 35174 /* @__PURE__ */ (0, import_jsx_runtime173.jsx)( 35175 import_components51.__experimentalInputControl, 35176 { 35177 ref: validityTargetRef, 35178 type: "date", 35179 label: (0, import_i18n57.__)("Date"), 35180 hideLabelFromVision: true, 35181 value, 35182 onChange: handleManualDateChange, 35183 required: !!field.isValid?.required, 35184 disabled: disabled2, 35185 min: minConstraint, 35186 max: maxConstraint 35187 } 35188 ), 35189 /* @__PURE__ */ (0, import_jsx_runtime173.jsx)( 35190 DateCalendar2, 35191 { 35192 style: { width: "100%" }, 35193 selected: value ? parseDate(value) || void 0 : void 0, 35194 onSelect: onSelectDate, 35195 month: calendarMonth, 35196 onMonthChange: setCalendarMonth, 35197 timeZone: timezoneString || void 0, 35198 weekStartsOn, 35199 disabled: disabled2 || disabledMatchers, 35200 disableNavigation: disabled2 35201 } 35202 ) 35203 ] }) 35204 } 35205 ) 35206 } 35207 ); 35208 } 35209 function CalendarDateRangeControl({ 35210 data, 35211 field, 35212 onChange, 35213 hideLabelFromVision, 35214 markWhenOptional, 35215 validity 35216 }) { 35217 const { 35218 id, 35219 label, 35220 description, 35221 getValue, 35222 setValue, 35223 isValid: isValid2, 35224 format: fieldFormat 35225 } = field; 35226 const disabled2 = field.isDisabled({ item: data, field }); 35227 let value; 35228 const fieldValue = getValue({ item: data }); 35229 if (Array.isArray(fieldValue) && fieldValue.length === 2 && fieldValue.every((date) => typeof date === "string")) { 35230 value = fieldValue; 35231 } 35232 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek; 35233 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate); 35234 const onChangeCallback = (0, import_element101.useCallback)( 35235 (newValue) => { 35236 onChange( 35237 setValue({ 35238 item: data, 35239 value: newValue 35240 }) 35241 ); 35242 }, 35243 [data, onChange, setValue] 35244 ); 35245 const [selectedPresetId, setSelectedPresetId] = (0, import_element101.useState)( 35246 null 35247 ); 35248 const selectedRange = (0, import_element101.useMemo)(() => { 35249 if (!value) { 35250 return { from: void 0, to: void 0 }; 35251 } 35252 const [from, to2] = value; 35253 return { 35254 from: parseDate(from) || void 0, 35255 to: parseDate(to2) || void 0 35256 }; 35257 }, [value]); 35258 const [calendarMonth, setCalendarMonth] = (0, import_element101.useState)(() => { 35259 return selectedRange.from || /* @__PURE__ */ new Date(); 35260 }); 35261 const [isTouched, setIsTouched] = (0, import_element101.useState)(false); 35262 const fromInputRef = (0, import_element101.useRef)(null); 35263 const toInputRef = (0, import_element101.useRef)(null); 35264 const updateDateRange = (0, import_element101.useCallback)( 35265 (fromDate, toDate2) => { 35266 if (fromDate && toDate2) { 35267 onChangeCallback([ 35268 formatDate(fromDate), 35269 formatDate(toDate2) 35270 ]); 35271 } else if (!fromDate && !toDate2) { 35272 onChangeCallback(void 0); 35273 } 35274 }, 35275 [onChangeCallback] 35276 ); 35277 const onSelectCalendarRange = (0, import_element101.useCallback)( 35278 (newRange) => { 35279 updateDateRange(newRange?.from, newRange?.to); 35280 setSelectedPresetId(null); 35281 setIsTouched(true); 35282 }, 35283 [updateDateRange] 35284 ); 35285 const handlePresetClick = (0, import_element101.useCallback)( 35286 (preset) => { 35287 const [startDate2, endDate] = preset.getValue(); 35288 setCalendarMonth(startDate2); 35289 updateDateRange(startDate2, endDate); 35290 setSelectedPresetId(preset.id); 35291 setIsTouched(true); 35292 }, 35293 [updateDateRange] 35294 ); 35295 const handleManualDateChange = (0, import_element101.useCallback)( 35296 (fromOrTo, newValue) => { 35297 const [currentFrom, currentTo] = value || [ 35298 void 0, 35299 void 0 35300 ]; 35301 const updatedFrom = fromOrTo === "from" ? newValue : currentFrom; 35302 const updatedTo = fromOrTo === "to" ? newValue : currentTo; 35303 updateDateRange(updatedFrom, updatedTo); 35304 if (newValue) { 35305 const parsedDate = parseDate(newValue); 35306 if (parsedDate) { 35307 setCalendarMonth(parsedDate); 35308 } 35309 } 35310 setSelectedPresetId(null); 35311 setIsTouched(true); 35312 }, 35313 [value, updateDateRange] 35314 ); 35315 const { timezone } = (0, import_date4.getSettings)(); 35316 let displayLabel = label; 35317 if (field.isValid?.required && !markWhenOptional) { 35318 displayLabel = `$label} (${(0, import_i18n57.__)("Required")})`; 35319 } else if (!field.isValid?.required && markWhenOptional) { 35320 displayLabel = `$label} (${(0, import_i18n57.__)("Optional")})`; 35321 } 35322 return /* @__PURE__ */ (0, import_jsx_runtime173.jsx)( 35323 ValidatedDateControl, 35324 { 35325 field, 35326 validity, 35327 inputRefs: [fromInputRef, toInputRef], 35328 isTouched, 35329 setIsTouched, 35330 children: /* @__PURE__ */ (0, import_jsx_runtime173.jsx)( 35331 import_components51.BaseControl, 35332 { 35333 id, 35334 className: "dataviews-controls__date", 35335 label: displayLabel, 35336 help: description, 35337 hideLabelFromVision, 35338 children: /* @__PURE__ */ (0, import_jsx_runtime173.jsxs)(Stack, { direction: "column", gap: "lg", children: [ 35339 /* @__PURE__ */ (0, import_jsx_runtime173.jsxs)( 35340 Stack, 35341 { 35342 direction: "row", 35343 gap: "sm", 35344 wrap: "wrap", 35345 justify: "flex-start", 35346 children: [ 35347 DATE_RANGE_PRESETS.map((preset) => { 35348 const isSelected2 = selectedPresetId === preset.id; 35349 return /* @__PURE__ */ (0, import_jsx_runtime173.jsx)( 35350 import_components51.Button, 35351 { 35352 className: "dataviews-controls__date-preset", 35353 variant: "tertiary", 35354 isPressed: isSelected2, 35355 size: "small", 35356 disabled: disabled2, 35357 accessibleWhenDisabled: true, 35358 onClick: () => handlePresetClick(preset), 35359 children: preset.label 35360 }, 35361 preset.id 35362 ); 35363 }), 35364 /* @__PURE__ */ (0, import_jsx_runtime173.jsx)( 35365 import_components51.Button, 35366 { 35367 className: "dataviews-controls__date-preset", 35368 variant: "tertiary", 35369 isPressed: !selectedPresetId, 35370 size: "small", 35371 accessibleWhenDisabled: true, 35372 disabled: !!selectedPresetId || disabled2, 35373 children: (0, import_i18n57.__)("Custom") 35374 } 35375 ) 35376 ] 35377 } 35378 ), 35379 /* @__PURE__ */ (0, import_jsx_runtime173.jsxs)( 35380 Stack, 35381 { 35382 direction: "row", 35383 gap: "sm", 35384 justify: "space-between", 35385 className: "dataviews-controls__date-range-inputs", 35386 children: [ 35387 /* @__PURE__ */ (0, import_jsx_runtime173.jsx)( 35388 import_components51.__experimentalInputControl, 35389 { 35390 ref: fromInputRef, 35391 type: "date", 35392 label: (0, import_i18n57.__)("From"), 35393 hideLabelFromVision: true, 35394 value: value?.[0], 35395 onChange: (newValue) => handleManualDateChange("from", newValue), 35396 required: !!field.isValid?.required, 35397 disabled: disabled2, 35398 min: minConstraint, 35399 max: maxConstraint 35400 } 35401 ), 35402 /* @__PURE__ */ (0, import_jsx_runtime173.jsx)( 35403 import_components51.__experimentalInputControl, 35404 { 35405 ref: toInputRef, 35406 type: "date", 35407 label: (0, import_i18n57.__)("To"), 35408 hideLabelFromVision: true, 35409 value: value?.[1], 35410 onChange: (newValue) => handleManualDateChange("to", newValue), 35411 required: !!field.isValid?.required, 35412 disabled: disabled2, 35413 min: minConstraint, 35414 max: maxConstraint 35415 } 35416 ) 35417 ] 35418 } 35419 ), 35420 /* @__PURE__ */ (0, import_jsx_runtime173.jsx)( 35421 DateRangeCalendar, 35422 { 35423 style: { width: "100%" }, 35424 selected: selectedRange, 35425 onSelect: onSelectCalendarRange, 35426 month: calendarMonth, 35427 onMonthChange: setCalendarMonth, 35428 timeZone: timezone.string || void 0, 35429 weekStartsOn, 35430 disabled: disabled2 || disabledMatchers 35431 } 35432 ) 35433 ] }) 35434 } 35435 ) 35436 } 35437 ); 35438 } 35439 function DateControl({ 35440 data, 35441 field, 35442 onChange, 35443 hideLabelFromVision, 35444 markWhenOptional, 35445 operator, 35446 validity 35447 }) { 35448 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) { 35449 return /* @__PURE__ */ (0, import_jsx_runtime173.jsx)( 35450 RelativeDateControl, 35451 { 35452 className: "dataviews-controls__date", 35453 data, 35454 field, 35455 onChange, 35456 hideLabelFromVision, 35457 operator 35458 } 35459 ); 35460 } 35461 if (operator === OPERATOR_BETWEEN) { 35462 return /* @__PURE__ */ (0, import_jsx_runtime173.jsx)( 35463 CalendarDateRangeControl, 35464 { 35465 data, 35466 field, 35467 onChange, 35468 hideLabelFromVision, 35469 markWhenOptional, 35470 validity 35471 } 35472 ); 35473 } 35474 return /* @__PURE__ */ (0, import_jsx_runtime173.jsx)( 35475 CalendarDateControl, 35476 { 35477 data, 35478 field, 35479 onChange, 35480 hideLabelFromVision, 35481 markWhenOptional, 35482 validity 35483 } 35484 ); 35485 } 35486 35487 // packages/dataviews/build-module/components/dataform-controls/select.mjs 35488 var import_components52 = __toESM(require_components(), 1); 35489 var import_element102 = __toESM(require_element(), 1); 35490 var import_jsx_runtime174 = __toESM(require_jsx_runtime(), 1); 35491 var { ValidatedSelectControl } = unlock4(import_components52.privateApis); 35492 function Select({ 35493 data, 35494 field, 35495 onChange, 35496 hideLabelFromVision, 35497 markWhenOptional, 35498 validity 35499 }) { 35500 const { type, label, description, getValue, setValue, isValid: isValid2 } = field; 35501 const disabled2 = field.isDisabled({ item: data, field }); 35502 const isMultiple = type === "array"; 35503 const value = getValue({ item: data }) ?? (isMultiple ? [] : ""); 35504 const onChangeControl = (0, import_element102.useCallback)( 35505 (newValue) => onChange(setValue({ item: data, value: newValue })), 35506 [data, onChange, setValue] 35507 ); 35508 const { elements: elements2, isLoading } = useElements({ 35509 elements: field.elements, 35510 getElements: field.getElements 35511 }); 35512 if (isLoading) { 35513 return /* @__PURE__ */ (0, import_jsx_runtime174.jsx)(import_components52.Spinner, {}); 35514 } 35515 return /* @__PURE__ */ (0, import_jsx_runtime174.jsx)( 35516 ValidatedSelectControl, 35517 { 35518 required: !!field.isValid?.required, 35519 markWhenOptional, 35520 customValidity: getCustomValidity(isValid2, validity), 35521 label, 35522 value, 35523 help: description, 35524 options: elements2, 35525 onChange: onChangeControl, 35526 hideLabelFromVision, 35527 multiple: isMultiple, 35528 disabled: disabled2 35529 } 35530 ); 35531 } 35532 35533 // packages/dataviews/build-module/components/dataform-controls/adaptive-select.mjs 35534 var import_jsx_runtime175 = __toESM(require_jsx_runtime(), 1); 35535 var ELEMENTS_THRESHOLD = 10; 35536 function AdaptiveSelect(props) { 35537 const { field } = props; 35538 const { elements: elements2 } = useElements({ 35539 elements: field.elements, 35540 getElements: field.getElements 35541 }); 35542 if (elements2.length >= ELEMENTS_THRESHOLD) { 35543 return /* @__PURE__ */ (0, import_jsx_runtime175.jsx)(Combobox3, { ...props }); 35544 } 35545 return /* @__PURE__ */ (0, import_jsx_runtime175.jsx)(Select, { ...props }); 35546 } 35547 35548 // packages/dataviews/build-module/components/dataform-controls/email.mjs 35549 var import_components54 = __toESM(require_components(), 1); 35550 35551 // packages/dataviews/build-module/components/dataform-controls/utils/validated-input.mjs 35552 var import_components53 = __toESM(require_components(), 1); 35553 var import_element103 = __toESM(require_element(), 1); 35554 var import_jsx_runtime176 = __toESM(require_jsx_runtime(), 1); 35555 var { ValidatedInputControl: ValidatedInputControl2 } = unlock4(import_components53.privateApis); 35556 function ValidatedText({ 35557 data, 35558 field, 35559 onChange, 35560 hideLabelFromVision, 35561 markWhenOptional, 35562 type, 35563 prefix: prefix2, 35564 suffix, 35565 validity 35566 }) { 35567 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field; 35568 const value = getValue({ item: data }); 35569 const disabled2 = field.isDisabled({ item: data, field }); 35570 const onChangeControl = (0, import_element103.useCallback)( 35571 (newValue) => onChange( 35572 setValue({ 35573 item: data, 35574 value: newValue 35575 }) 35576 ), 35577 [data, setValue, onChange] 35578 ); 35579 return /* @__PURE__ */ (0, import_jsx_runtime176.jsx)( 35580 ValidatedInputControl2, 35581 { 35582 required: !!isValid2.required, 35583 markWhenOptional, 35584 customValidity: getCustomValidity(isValid2, validity), 35585 label, 35586 placeholder, 35587 value: value ?? "", 35588 help: description, 35589 onChange: onChangeControl, 35590 hideLabelFromVision, 35591 type, 35592 prefix: prefix2, 35593 suffix, 35594 disabled: disabled2, 35595 pattern: isValid2.pattern ? isValid2.pattern.constraint : void 0, 35596 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0, 35597 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0 35598 } 35599 ); 35600 } 35601 35602 // packages/dataviews/build-module/components/dataform-controls/email.mjs 35603 var import_jsx_runtime177 = __toESM(require_jsx_runtime(), 1); 35604 function Email({ 35605 data, 35606 field, 35607 onChange, 35608 hideLabelFromVision, 35609 markWhenOptional, 35610 validity 35611 }) { 35612 return /* @__PURE__ */ (0, import_jsx_runtime177.jsx)( 35613 ValidatedText, 35614 { 35615 ...{ 35616 data, 35617 field, 35618 onChange, 35619 hideLabelFromVision, 35620 markWhenOptional, 35621 validity, 35622 type: "email", 35623 prefix: /* @__PURE__ */ (0, import_jsx_runtime177.jsx)(import_components54.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime177.jsx)(import_components54.Icon, { icon: envelope_default }) }) 35624 } 35625 } 35626 ); 35627 } 35628 35629 // packages/dataviews/build-module/components/dataform-controls/telephone.mjs 35630 var import_components55 = __toESM(require_components(), 1); 35631 var import_jsx_runtime178 = __toESM(require_jsx_runtime(), 1); 35632 function Telephone({ 35633 data, 35634 field, 35635 onChange, 35636 hideLabelFromVision, 35637 markWhenOptional, 35638 validity 35639 }) { 35640 return /* @__PURE__ */ (0, import_jsx_runtime178.jsx)( 35641 ValidatedText, 35642 { 35643 ...{ 35644 data, 35645 field, 35646 onChange, 35647 hideLabelFromVision, 35648 markWhenOptional, 35649 validity, 35650 type: "tel", 35651 prefix: /* @__PURE__ */ (0, import_jsx_runtime178.jsx)(import_components55.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime178.jsx)(import_components55.Icon, { icon: mobile_default }) }) 35652 } 35653 } 35654 ); 35655 } 35656 35657 // packages/dataviews/build-module/components/dataform-controls/url.mjs 35658 var import_components56 = __toESM(require_components(), 1); 35659 var import_jsx_runtime179 = __toESM(require_jsx_runtime(), 1); 35660 function Url({ 35661 data, 35662 field, 35663 onChange, 35664 hideLabelFromVision, 35665 markWhenOptional, 35666 validity 35667 }) { 35668 return /* @__PURE__ */ (0, import_jsx_runtime179.jsx)( 35669 ValidatedText, 35670 { 35671 ...{ 35672 data, 35673 field, 35674 onChange, 35675 hideLabelFromVision, 35676 markWhenOptional, 35677 validity, 35678 type: "url", 35679 prefix: /* @__PURE__ */ (0, import_jsx_runtime179.jsx)(import_components56.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime179.jsx)(import_components56.Icon, { icon: link_default }) }) 35680 } 35681 } 35682 ); 35683 } 35684 35685 // packages/dataviews/build-module/components/dataform-controls/utils/validated-number.mjs 35686 var import_components57 = __toESM(require_components(), 1); 35687 var import_element104 = __toESM(require_element(), 1); 35688 var import_i18n58 = __toESM(require_i18n(), 1); 35689 var import_jsx_runtime180 = __toESM(require_jsx_runtime(), 1); 35690 var { ValidatedNumberControl } = unlock4(import_components57.privateApis); 35691 function toNumberOrEmpty(value) { 35692 if (value === "" || value === void 0) { 35693 return ""; 35694 } 35695 const number = Number(value); 35696 return Number.isFinite(number) ? number : ""; 35697 } 35698 function BetweenControls({ 35699 value, 35700 onChange, 35701 hideLabelFromVision, 35702 step 35703 }) { 35704 const [min2 = "", max2 = ""] = value; 35705 const onChangeMin = (0, import_element104.useCallback)( 35706 (newValue) => onChange([toNumberOrEmpty(newValue), max2]), 35707 [onChange, max2] 35708 ); 35709 const onChangeMax = (0, import_element104.useCallback)( 35710 (newValue) => onChange([min2, toNumberOrEmpty(newValue)]), 35711 [onChange, min2] 35712 ); 35713 return /* @__PURE__ */ (0, import_jsx_runtime180.jsx)( 35714 import_components57.BaseControl, 35715 { 35716 help: (0, import_i18n58.__)("The max. value must be greater than the min. value."), 35717 children: /* @__PURE__ */ (0, import_jsx_runtime180.jsxs)(import_components57.Flex, { direction: "row", gap: 4, children: [ 35718 /* @__PURE__ */ (0, import_jsx_runtime180.jsx)( 35719 import_components57.__experimentalNumberControl, 35720 { 35721 label: (0, import_i18n58.__)("Min."), 35722 value: min2, 35723 max: max2 ? Number(max2) - step : void 0, 35724 onChange: onChangeMin, 35725 hideLabelFromVision, 35726 step 35727 } 35728 ), 35729 /* @__PURE__ */ (0, import_jsx_runtime180.jsx)( 35730 import_components57.__experimentalNumberControl, 35731 { 35732 label: (0, import_i18n58.__)("Max."), 35733 value: max2, 35734 min: min2 ? Number(min2) + step : void 0, 35735 onChange: onChangeMax, 35736 hideLabelFromVision, 35737 step 35738 } 35739 ) 35740 ] }) 35741 } 35742 ); 35743 } 35744 function ValidatedNumber({ 35745 data, 35746 field, 35747 onChange, 35748 hideLabelFromVision, 35749 markWhenOptional, 35750 operator, 35751 validity 35752 }) { 35753 const decimals = field.format?.decimals ?? 0; 35754 const step = Math.pow(10, Math.abs(decimals) * -1); 35755 const { label, description, getValue, setValue, isValid: isValid2 } = field; 35756 const value = getValue({ item: data }) ?? ""; 35757 const disabled2 = field.isDisabled({ item: data, field }); 35758 const onChangeControl = (0, import_element104.useCallback)( 35759 (newValue) => { 35760 onChange( 35761 setValue({ 35762 item: data, 35763 // Do not convert an empty string or undefined to a number, 35764 // otherwise there's a mismatch between the UI control (empty) 35765 // and the data relied by onChange (0). 35766 value: ["", void 0].includes(newValue) ? void 0 : Number(newValue) 35767 }) 35768 ); 35769 }, 35770 [data, onChange, setValue] 35771 ); 35772 const onChangeBetweenControls = (0, import_element104.useCallback)( 35773 (newValue) => { 35774 onChange( 35775 setValue({ 35776 item: data, 35777 value: newValue 35778 }) 35779 ); 35780 }, 35781 [data, onChange, setValue] 35782 ); 35783 if (operator === OPERATOR_BETWEEN) { 35784 let valueBetween = ["", ""]; 35785 if (Array.isArray(value) && value.length === 2 && value.every( 35786 (element) => typeof element === "number" || element === "" 35787 )) { 35788 valueBetween = value; 35789 } 35790 return /* @__PURE__ */ (0, import_jsx_runtime180.jsx)( 35791 BetweenControls, 35792 { 35793 value: valueBetween, 35794 onChange: onChangeBetweenControls, 35795 hideLabelFromVision, 35796 step 35797 } 35798 ); 35799 } 35800 return /* @__PURE__ */ (0, import_jsx_runtime180.jsx)( 35801 ValidatedNumberControl, 35802 { 35803 required: !!isValid2.required, 35804 markWhenOptional, 35805 customValidity: getCustomValidity(isValid2, validity), 35806 label, 35807 help: description, 35808 value, 35809 onChange: onChangeControl, 35810 hideLabelFromVision, 35811 step, 35812 min: isValid2.min ? isValid2.min.constraint : void 0, 35813 max: isValid2.max ? isValid2.max.constraint : void 0, 35814 disabled: disabled2 35815 } 35816 ); 35817 } 35818 35819 // packages/dataviews/build-module/components/dataform-controls/integer.mjs 35820 var import_jsx_runtime181 = __toESM(require_jsx_runtime(), 1); 35821 function Integer(props) { 35822 return /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(ValidatedNumber, { ...props }); 35823 } 35824 35825 // packages/dataviews/build-module/components/dataform-controls/number.mjs 35826 var import_jsx_runtime182 = __toESM(require_jsx_runtime(), 1); 35827 function Number2(props) { 35828 return /* @__PURE__ */ (0, import_jsx_runtime182.jsx)(ValidatedNumber, { ...props }); 35829 } 35830 35831 // packages/dataviews/build-module/components/dataform-controls/radio.mjs 35832 var import_components58 = __toESM(require_components(), 1); 35833 var import_element105 = __toESM(require_element(), 1); 35834 var import_jsx_runtime183 = __toESM(require_jsx_runtime(), 1); 35835 var { ValidatedRadioControl } = unlock4(import_components58.privateApis); 35836 function Radio({ 35837 data, 35838 field, 35839 onChange, 35840 hideLabelFromVision, 35841 markWhenOptional, 35842 validity 35843 }) { 35844 const { label, description, getValue, setValue, isValid: isValid2 } = field; 35845 const disabled2 = field.isDisabled({ item: data, field }); 35846 const { elements: elements2, isLoading } = useElements({ 35847 elements: field.elements, 35848 getElements: field.getElements 35849 }); 35850 const value = getValue({ item: data }); 35851 const onChangeControl = (0, import_element105.useCallback)( 35852 (newValue) => onChange(setValue({ item: data, value: newValue })), 35853 [data, onChange, setValue] 35854 ); 35855 if (isLoading) { 35856 return /* @__PURE__ */ (0, import_jsx_runtime183.jsx)(import_components58.Spinner, {}); 35857 } 35858 return /* @__PURE__ */ (0, import_jsx_runtime183.jsx)( 35859 ValidatedRadioControl, 35860 { 35861 required: !!field.isValid?.required, 35862 markWhenOptional, 35863 customValidity: getCustomValidity(isValid2, validity), 35864 label, 35865 help: description, 35866 onChange: onChangeControl, 35867 options: elements2, 35868 selected: value, 35869 hideLabelFromVision, 35870 disabled: disabled2 35871 } 35872 ); 35873 } 35874 35875 // packages/dataviews/build-module/components/dataform-controls/text.mjs 35876 var import_element106 = __toESM(require_element(), 1); 35877 var import_jsx_runtime184 = __toESM(require_jsx_runtime(), 1); 35878 function Text3({ 35879 data, 35880 field, 35881 onChange, 35882 hideLabelFromVision, 35883 markWhenOptional, 35884 config: config2, 35885 validity 35886 }) { 35887 const { prefix: prefix2, suffix } = config2 || {}; 35888 return /* @__PURE__ */ (0, import_jsx_runtime184.jsx)( 35889 ValidatedText, 35890 { 35891 ...{ 35892 data, 35893 field, 35894 onChange, 35895 hideLabelFromVision, 35896 markWhenOptional, 35897 validity, 35898 prefix: prefix2 ? (0, import_element106.createElement)(prefix2) : void 0, 35899 suffix: suffix ? (0, import_element106.createElement)(suffix) : void 0 35900 } 35901 } 35902 ); 35903 } 35904 35905 // packages/dataviews/build-module/components/dataform-controls/toggle.mjs 35906 var import_components59 = __toESM(require_components(), 1); 35907 var import_element107 = __toESM(require_element(), 1); 35908 var import_jsx_runtime185 = __toESM(require_jsx_runtime(), 1); 35909 var { ValidatedToggleControl } = unlock4(import_components59.privateApis); 35910 function Toggle({ 35911 field, 35912 onChange, 35913 data, 35914 hideLabelFromVision, 35915 markWhenOptional, 35916 validity 35917 }) { 35918 const { label, description, getValue, setValue, isValid: isValid2 } = field; 35919 const disabled2 = field.isDisabled({ item: data, field }); 35920 const onChangeControl = (0, import_element107.useCallback)(() => { 35921 onChange( 35922 setValue({ item: data, value: !getValue({ item: data }) }) 35923 ); 35924 }, [onChange, setValue, data, getValue]); 35925 return /* @__PURE__ */ (0, import_jsx_runtime185.jsx)( 35926 ValidatedToggleControl, 35927 { 35928 required: !!isValid2.required, 35929 markWhenOptional, 35930 customValidity: getCustomValidity(isValid2, validity), 35931 hidden: hideLabelFromVision, 35932 label, 35933 help: description, 35934 checked: getValue({ item: data }), 35935 onChange: onChangeControl, 35936 disabled: disabled2 35937 } 35938 ); 35939 } 35940 35941 // packages/dataviews/build-module/components/dataform-controls/textarea.mjs 35942 var import_components60 = __toESM(require_components(), 1); 35943 var import_element108 = __toESM(require_element(), 1); 35944 var import_jsx_runtime186 = __toESM(require_jsx_runtime(), 1); 35945 var { ValidatedTextareaControl } = unlock4(import_components60.privateApis); 35946 function Textarea({ 35947 data, 35948 field, 35949 onChange, 35950 hideLabelFromVision, 35951 markWhenOptional, 35952 config: config2, 35953 validity 35954 }) { 35955 const { rows = 4 } = config2 || {}; 35956 const disabled2 = field.isDisabled({ item: data, field }); 35957 const { label, placeholder, description, setValue, isValid: isValid2 } = field; 35958 const value = field.getValue({ item: data }); 35959 const onChangeControl = (0, import_element108.useCallback)( 35960 (newValue) => onChange(setValue({ item: data, value: newValue })), 35961 [data, onChange, setValue] 35962 ); 35963 return /* @__PURE__ */ (0, import_jsx_runtime186.jsx)( 35964 ValidatedTextareaControl, 35965 { 35966 required: !!isValid2.required, 35967 markWhenOptional, 35968 customValidity: getCustomValidity(isValid2, validity), 35969 label, 35970 placeholder, 35971 value: value ?? "", 35972 help: description, 35973 onChange: onChangeControl, 35974 rows, 35975 disabled: disabled2, 35976 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0, 35977 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0, 35978 __next40pxDefaultSize: true, 35979 hideLabelFromVision 35980 } 35981 ); 35982 } 35983 35984 // packages/dataviews/build-module/components/dataform-controls/richtext/index.mjs 35985 var import_element110 = __toESM(require_element(), 1); 35986 35987 // packages/dataviews/build-module/components/dataform-controls/richtext/control.mjs 35988 var import_components61 = __toESM(require_components(), 1); 35989 var import_compose16 = __toESM(require_compose(), 1); 35990 var import_element109 = __toESM(require_element(), 1); 35991 var import_rich_text2 = __toESM(require_rich_text(), 1); 35992 35993 // packages/dataviews/build-module/components/dataform-controls/richtext/utils.mjs 35994 var EMPTY_ARRAY7 = []; 35995 function getAllowedFormats({ 35996 allowedFormats, 35997 disableFormats 35998 }) { 35999 if (disableFormats) { 36000 return EMPTY_ARRAY7; 36001 } 36002 return allowedFormats; 36003 } 36004 36005 // packages/dataviews/build-module/components/dataform-controls/richtext/format-edit.mjs 36006 var import_rich_text = __toESM(require_rich_text(), 1); 36007 var import_jsx_runtime187 = __toESM(require_jsx_runtime(), 1); 36008 var import_react33 = __toESM(require_react(), 1); 36009 var EMPTY_CONTEXT = {}; 36010 function Edit({ 36011 onChange, 36012 onFocus, 36013 value, 36014 forwardedRef, 36015 settings: settings2, 36016 isVisible: isVisible2 36017 }) { 36018 const { name: name2, edit: EditFunction } = settings2; 36019 if (!EditFunction) { 36020 return null; 36021 } 36022 const activeFormat = (0, import_rich_text.getActiveFormat)(value, name2); 36023 const isActive = activeFormat !== void 0; 36024 const activeObject = (0, import_rich_text.getActiveObject)(value); 36025 const isObjectActive = activeObject !== void 0 && activeObject.type === name2; 36026 return /* @__PURE__ */ (0, import_jsx_runtime187.jsx)( 36027 EditFunction, 36028 { 36029 isActive, 36030 isVisible: isVisible2, 36031 activeAttributes: isActive ? activeFormat.attributes || {} : {}, 36032 isObjectActive, 36033 activeObjectAttributes: isObjectActive ? activeObject.attributes || {} : {}, 36034 value, 36035 onChange, 36036 onFocus, 36037 contentRef: forwardedRef, 36038 context: EMPTY_CONTEXT 36039 }, 36040 name2 36041 ); 36042 } 36043 function FormatEdit({ 36044 formatTypes, 36045 ...props 36046 }) { 36047 return formatTypes.map((settings2) => /* @__PURE__ */ (0, import_react33.createElement)(Edit, { settings: settings2, ...props, key: settings2.name })); 36048 } 36049 36050 // packages/dataviews/build-module/components/dataform-controls/richtext/control.mjs 36051 var import_jsx_runtime188 = __toESM(require_jsx_runtime(), 1); 36052 var { 36053 ValidatedContentEditableControl: RichTextControlShell, 36054 withIgnoreIMEEvents 36055 } = unlock4(import_components61.privateApis); 36056 var { 36057 useRichText, 36058 KeyboardShortcutContext, 36059 InputEventContext, 36060 shortcutsListener, 36061 inputEventsListener 36062 } = unlock4(import_rich_text2.privateApis); 36063 var EMPTY_COMPLETERS = []; 36064 function RichTextControl({ 36065 label, 36066 value: attrValue, 36067 onChange, 36068 placeholder, 36069 id, 36070 clientId, 36071 className, 36072 hideLabelFromVision, 36073 help, 36074 disabled: disabled2, 36075 required, 36076 markWhenOptional, 36077 customValidity, 36078 allowedFormats, 36079 disableFormats, 36080 withoutInteractiveFormatting, 36081 preserveWhiteSpace, 36082 disableLineBreaks, 36083 focusOnMount, 36084 completers = EMPTY_COMPLETERS 36085 }) { 36086 const [selection, setSelection] = (0, import_element109.useState)({ 36087 start: void 0, 36088 end: void 0 36089 }); 36090 const [isSelected2, setIsSelected] = (0, import_element109.useState)(false); 36091 const anchorRef = (0, import_element109.useRef)(void 0); 36092 const inputEvents = (0, import_element109.useRef)(/* @__PURE__ */ new Set()); 36093 const keyboardShortcuts = (0, import_element109.useRef)( 36094 /* @__PURE__ */ new Set() 36095 ); 36096 const focusOutside = (0, import_compose16.__experimentalUseFocusOutside)(() => setIsSelected(false)); 36097 const adjustedAllowedFormats = getAllowedFormats({ 36098 allowedFormats, 36099 disableFormats 36100 }); 36101 const { 36102 value, 36103 onChange: onRichTextChange, 36104 ref: richTextRef, 36105 formatTypes, 36106 getValue 36107 } = useRichText({ 36108 value: attrValue, 36109 onChange, 36110 selectionStart: selection.start, 36111 selectionEnd: selection.end, 36112 onSelectionChange: (start2, end) => setSelection({ start: start2, end }), 36113 __unstableIsSelected: isSelected2, 36114 preserveWhiteSpace: !!preserveWhiteSpace, 36115 placeholder, 36116 __unstableDisableFormats: disableFormats, 36117 allowedFormats: adjustedAllowedFormats, 36118 withoutInteractiveFormatting, 36119 __unstableFormatTypeHandlerContext: (0, import_element109.useMemo)( 36120 () => ({ 36121 richTextIdentifier: id, 36122 blockClientId: clientId 36123 }), 36124 [id, clientId] 36125 ) 36126 }); 36127 function onFocus() { 36128 anchorRef.current?.focus(); 36129 } 36130 const eventListenersPropsRef = (0, import_element109.useRef)({ 36131 keyboardShortcuts, 36132 inputEvents 36133 }); 36134 const inputRulePropsRef = (0, import_element109.useRef)({ 36135 formatTypes, 36136 getValue, 36137 onChange: onRichTextChange 36138 }); 36139 (0, import_element109.useInsertionEffect)(() => { 36140 inputRulePropsRef.current = { 36141 formatTypes, 36142 getValue, 36143 onChange: onRichTextChange 36144 }; 36145 }); 36146 const enterRef = (0, import_compose16.useRefEffect)( 36147 (element) => { 36148 if (disabled2) { 36149 return; 36150 } 36151 const onKeyDown = withIgnoreIMEEvents((event) => { 36152 if (event.key !== "Enter" || event.defaultPrevented || event.metaKey || event.ctrlKey) { 36153 return; 36154 } 36155 event.preventDefault(); 36156 if (disableLineBreaks) { 36157 return; 36158 } 36159 const { getValue: getCurrentValue2, onChange: handleChange } = inputRulePropsRef.current; 36160 const current = getCurrentValue2(); 36161 handleChange( 36162 (0, import_rich_text2.insert)( 36163 current, 36164 "\n", 36165 current.start ?? current.text.length, 36166 current.end ?? current.text.length 36167 ) 36168 ); 36169 }); 36170 element.addEventListener("keydown", onKeyDown); 36171 return () => element.removeEventListener("keydown", onKeyDown); 36172 }, 36173 [disableLineBreaks, disabled2] 36174 ); 36175 const eventListenersRef = (0, import_compose16.useRefEffect)( 36176 (element) => { 36177 if (!isSelected2) { 36178 return; 36179 } 36180 const cleanupShortcuts = shortcutsListener( 36181 eventListenersPropsRef 36182 )(element); 36183 const cleanupInputEvents = inputEventsListener( 36184 eventListenersPropsRef 36185 )(element); 36186 function onFormatInput(event) { 36187 if (event.inputType !== "insertText" && event.type !== "compositionend") { 36188 return; 36189 } 36190 const { 36191 formatTypes: types, 36192 getValue: getCurrentValue2, 36193 onChange: handleChange 36194 } = inputRulePropsRef.current; 36195 const current = getCurrentValue2(); 36196 const transformed = types.reduce( 36197 (accumulator, { 36198 __unstableInputRule 36199 }) => __unstableInputRule ? __unstableInputRule(accumulator) : accumulator, 36200 current 36201 ); 36202 if (transformed !== current) { 36203 handleChange({ 36204 ...transformed, 36205 activeFormats: current.activeFormats 36206 }); 36207 } 36208 } 36209 element.addEventListener("input", onFormatInput); 36210 element.addEventListener("compositionend", onFormatInput); 36211 return () => { 36212 cleanupShortcuts(); 36213 cleanupInputEvents(); 36214 element.removeEventListener("input", onFormatInput); 36215 element.removeEventListener("compositionend", onFormatInput); 36216 }; 36217 }, 36218 [isSelected2] 36219 ); 36220 const { ref: autocompleteRef, ...autocompleteProps } = (0, import_components61.__unstableUseAutocompleteProps)( 36221 { 36222 completers, 36223 record: value, 36224 onChange: onRichTextChange, 36225 // This control's completers insert their completion into the value; 36226 // none replace the whole value, so the required `onReplace` is a 36227 // no-op here. 36228 onReplace: () => { 36229 } 36230 } 36231 ); 36232 const focusOnMountRef = (0, import_compose16.useRefEffect)( 36233 (element) => { 36234 if (focusOnMount && !disabled2) { 36235 element.focus(); 36236 } 36237 }, 36238 [focusOnMount, disabled2] 36239 ); 36240 const editableRef = (0, import_compose16.useMergeRefs)([ 36241 richTextRef, 36242 anchorRef, 36243 eventListenersRef, 36244 enterRef, 36245 focusOnMountRef, 36246 autocompleteRef 36247 ]); 36248 return ( 36249 // Focus boundary for the field's selection: `onFocus` selects on entry; 36250 // the spread `useFocusOutside` handlers deselect once focus leaves. 36251 /* @__PURE__ */ (0, import_jsx_runtime188.jsx)( 36252 "div", 36253 { 36254 ...focusOutside, 36255 onFocus: (event) => { 36256 setIsSelected(true); 36257 focusOutside.onFocus(event); 36258 }, 36259 children: /* @__PURE__ */ (0, import_jsx_runtime188.jsxs)(import_components61.SlotFillProvider, { children: [ 36260 /* @__PURE__ */ (0, import_jsx_runtime188.jsx)( 36261 RichTextControlShell, 36262 { 36263 label, 36264 id, 36265 className: clsx_default( 36266 "dataviews-controls__richtext", 36267 className 36268 ), 36269 placeholder, 36270 hideLabelFromVision, 36271 help, 36272 disabled: disabled2, 36273 required, 36274 markWhenOptional, 36275 customValidity, 36276 value: value.text, 36277 "aria-multiline": !disableLineBreaks, 36278 ...autocompleteProps, 36279 ref: editableRef 36280 } 36281 ), 36282 isSelected2 && !disabled2 && /* @__PURE__ */ (0, import_jsx_runtime188.jsx)( 36283 KeyboardShortcutContext.Provider, 36284 { 36285 value: keyboardShortcuts, 36286 children: /* @__PURE__ */ (0, import_jsx_runtime188.jsx)(InputEventContext.Provider, { value: inputEvents, children: /* @__PURE__ */ (0, import_jsx_runtime188.jsx)( 36287 FormatEdit, 36288 { 36289 value, 36290 onChange: onRichTextChange, 36291 onFocus, 36292 formatTypes, 36293 forwardedRef: anchorRef, 36294 isVisible: true 36295 } 36296 ) }) 36297 } 36298 ) 36299 ] }) 36300 } 36301 ) 36302 ); 36303 } 36304 36305 // packages/dataviews/build-module/components/dataform-controls/richtext/index.mjs 36306 var import_jsx_runtime189 = __toESM(require_jsx_runtime(), 1); 36307 function RichText({ 36308 data, 36309 field, 36310 onChange, 36311 hideLabelFromVision, 36312 markWhenOptional, 36313 config: config2, 36314 validity 36315 }) { 36316 const { 36317 className, 36318 clientId, 36319 allowedFormats, 36320 disableFormats, 36321 withoutInteractiveFormatting, 36322 preserveWhiteSpace, 36323 disableLineBreaks 36324 } = config2 || {}; 36325 const disabled2 = field.isDisabled({ item: data, field }); 36326 const { label, placeholder, description, id, setValue, isValid: isValid2 } = field; 36327 const value = field.getValue({ item: data }) ?? ""; 36328 const onChangeControl = (0, import_element110.useCallback)( 36329 (newValue) => onChange(setValue({ item: data, value: newValue })), 36330 [data, onChange, setValue] 36331 ); 36332 return /* @__PURE__ */ (0, import_jsx_runtime189.jsx)( 36333 RichTextControl, 36334 { 36335 label, 36336 value, 36337 onChange: onChangeControl, 36338 placeholder, 36339 id, 36340 hideLabelFromVision, 36341 help: description, 36342 disabled: disabled2, 36343 required: !!isValid2.required, 36344 markWhenOptional, 36345 customValidity: getCustomValidity(isValid2, validity), 36346 className, 36347 clientId, 36348 allowedFormats, 36349 disableFormats, 36350 withoutInteractiveFormatting, 36351 preserveWhiteSpace, 36352 disableLineBreaks 36353 } 36354 ); 36355 } 36356 36357 // packages/dataviews/build-module/components/dataform-controls/toggle-group.mjs 36358 var import_components62 = __toESM(require_components(), 1); 36359 var import_element111 = __toESM(require_element(), 1); 36360 var import_jsx_runtime190 = __toESM(require_jsx_runtime(), 1); 36361 var { ValidatedToggleGroupControl } = unlock4(import_components62.privateApis); 36362 function ToggleGroup({ 36363 data, 36364 field, 36365 onChange, 36366 hideLabelFromVision, 36367 markWhenOptional, 36368 validity 36369 }) { 36370 const { getValue, setValue, isValid: isValid2 } = field; 36371 const disabled2 = field.isDisabled({ item: data, field }); 36372 const value = getValue({ item: data }); 36373 const onChangeControl = (0, import_element111.useCallback)( 36374 (newValue) => onChange(setValue({ item: data, value: newValue })), 36375 [data, onChange, setValue] 36376 ); 36377 const { elements: elements2, isLoading } = useElements({ 36378 elements: field.elements, 36379 getElements: field.getElements 36380 }); 36381 if (isLoading) { 36382 return /* @__PURE__ */ (0, import_jsx_runtime190.jsx)(import_components62.Spinner, {}); 36383 } 36384 if (elements2.length === 0) { 36385 return null; 36386 } 36387 const selectedOption = elements2.find((el) => el.value === value); 36388 return /* @__PURE__ */ (0, import_jsx_runtime190.jsx)( 36389 ValidatedToggleGroupControl, 36390 { 36391 required: !!field.isValid?.required, 36392 markWhenOptional, 36393 customValidity: getCustomValidity(isValid2, validity), 36394 isBlock: true, 36395 label: field.label, 36396 help: selectedOption?.description || field.description, 36397 onChange: onChangeControl, 36398 value, 36399 hideLabelFromVision, 36400 children: elements2.map((el) => /* @__PURE__ */ (0, import_jsx_runtime190.jsx)( 36401 import_components62.__experimentalToggleGroupControlOption, 36402 { 36403 label: el.label, 36404 value: el.value, 36405 disabled: disabled2 36406 }, 36407 el.value 36408 )) 36409 } 36410 ); 36411 } 36412 36413 // packages/dataviews/build-module/components/dataform-controls/array.mjs 36414 var import_components63 = __toESM(require_components(), 1); 36415 var import_element112 = __toESM(require_element(), 1); 36416 var import_jsx_runtime191 = __toESM(require_jsx_runtime(), 1); 36417 var { ValidatedFormTokenField } = unlock4(import_components63.privateApis); 36418 function ArrayControl({ 36419 data, 36420 field, 36421 onChange, 36422 hideLabelFromVision, 36423 markWhenOptional, 36424 validity 36425 }) { 36426 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field; 36427 const value = getValue({ item: data }); 36428 const disabled2 = field.isDisabled({ item: data, field }); 36429 const { elements: elements2, isLoading } = useElements({ 36430 elements: field.elements, 36431 getElements: field.getElements 36432 }); 36433 const arrayValueAsElements = (0, import_element112.useMemo)( 36434 () => Array.isArray(value) ? value.map((token) => { 36435 const element = elements2?.find( 36436 (suggestion) => suggestion.value === token 36437 ); 36438 return element || { value: token, label: token }; 36439 }) : [], 36440 [value, elements2] 36441 ); 36442 const onChangeControl = (0, import_element112.useCallback)( 36443 (tokens) => { 36444 const valueTokens = tokens.map((token) => { 36445 if (typeof token === "object" && "value" in token) { 36446 return token.value; 36447 } 36448 return token; 36449 }); 36450 onChange(setValue({ item: data, value: valueTokens })); 36451 }, 36452 [onChange, setValue, data] 36453 ); 36454 if (isLoading) { 36455 return /* @__PURE__ */ (0, import_jsx_runtime191.jsx)(import_components63.Spinner, {}); 36456 } 36457 return /* @__PURE__ */ (0, import_jsx_runtime191.jsx)( 36458 ValidatedFormTokenField, 36459 { 36460 required: !!isValid2?.required, 36461 markWhenOptional, 36462 customValidity: getCustomValidity(isValid2, validity), 36463 label: hideLabelFromVision ? void 0 : label, 36464 value: arrayValueAsElements, 36465 onChange: onChangeControl, 36466 placeholder, 36467 suggestions: elements2?.map((element) => element.value), 36468 disabled: disabled2, 36469 __experimentalValidateInput: (token) => { 36470 if (field.isValid?.elements && elements2) { 36471 return elements2.some( 36472 (element) => element.value === token || element.label === token 36473 ); 36474 } 36475 return true; 36476 }, 36477 __experimentalExpandOnFocus: elements2 && elements2.length > 0, 36478 help: description ?? (field.isValid?.elements ? "" : void 0), 36479 displayTransform: (token) => { 36480 if (typeof token === "object" && "label" in token) { 36481 return token.label; 36482 } 36483 if (typeof token === "string" && elements2) { 36484 const element = elements2.find( 36485 (el) => el.value === token 36486 ); 36487 return element?.label || token; 36488 } 36489 return token; 36490 }, 36491 __experimentalRenderItem: ({ item }) => { 36492 if (typeof item === "string" && elements2) { 36493 const element = elements2.find( 36494 (el) => el.value === item 36495 ); 36496 return /* @__PURE__ */ (0, import_jsx_runtime191.jsx)("span", { children: element?.label || item }); 36497 } 36498 return /* @__PURE__ */ (0, import_jsx_runtime191.jsx)("span", { children: item }); 36499 } 36500 } 36501 ); 36502 } 36503 36504 // packages/dataviews/build-module/components/dataform-controls/color.mjs 36505 var import_components64 = __toESM(require_components(), 1); 36506 var import_element113 = __toESM(require_element(), 1); 36507 var import_i18n59 = __toESM(require_i18n(), 1); 36508 var import_jsx_runtime192 = __toESM(require_jsx_runtime(), 1); 36509 var { ValidatedInputControl: ValidatedInputControl3 } = unlock4(import_components64.privateApis); 36510 var ColorPickerDropdown = ({ 36511 color, 36512 onColorChange, 36513 disabled: disabled2 36514 }) => { 36515 const validColor = color && w(color).isValid() ? color : "#ffffff"; 36516 return /* @__PURE__ */ (0, import_jsx_runtime192.jsx)( 36517 import_components64.Dropdown, 36518 { 36519 className: "dataviews-controls__color-picker-dropdown", 36520 popoverProps: { resize: false }, 36521 renderToggle: ({ onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime192.jsx)( 36522 import_components64.Button, 36523 { 36524 onClick: onToggle, 36525 "aria-label": (0, import_i18n59.__)("Open color picker"), 36526 size: "small", 36527 disabled: disabled2, 36528 accessibleWhenDisabled: true, 36529 icon: () => /* @__PURE__ */ (0, import_jsx_runtime192.jsx)(import_components64.ColorIndicator, { colorValue: validColor }) 36530 } 36531 ), 36532 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime192.jsx)(import_components64.__experimentalDropdownContentWrapper, { paddingSize: "none", children: /* @__PURE__ */ (0, import_jsx_runtime192.jsx)( 36533 import_components64.ColorPicker, 36534 { 36535 color: validColor, 36536 onChange: onColorChange, 36537 enableAlpha: true 36538 } 36539 ) }) 36540 } 36541 ); 36542 }; 36543 function Color({ 36544 data, 36545 field, 36546 onChange, 36547 hideLabelFromVision, 36548 markWhenOptional, 36549 validity 36550 }) { 36551 const { label, placeholder, description, setValue, isValid: isValid2 } = field; 36552 const disabled2 = field.isDisabled({ item: data, field }); 36553 const value = field.getValue({ item: data }) || ""; 36554 const handleColorChange = (0, import_element113.useCallback)( 36555 (newColor) => { 36556 onChange(setValue({ item: data, value: newColor })); 36557 }, 36558 [data, onChange, setValue] 36559 ); 36560 const handleInputChange = (0, import_element113.useCallback)( 36561 (newValue) => { 36562 onChange(setValue({ item: data, value: newValue || "" })); 36563 }, 36564 [data, onChange, setValue] 36565 ); 36566 return /* @__PURE__ */ (0, import_jsx_runtime192.jsx)( 36567 ValidatedInputControl3, 36568 { 36569 required: !!field.isValid?.required, 36570 markWhenOptional, 36571 customValidity: getCustomValidity(isValid2, validity), 36572 label, 36573 placeholder, 36574 value, 36575 help: description, 36576 onChange: handleInputChange, 36577 hideLabelFromVision, 36578 type: "text", 36579 disabled: disabled2, 36580 prefix: /* @__PURE__ */ (0, import_jsx_runtime192.jsx)(import_components64.__experimentalInputControlPrefixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime192.jsx)( 36581 ColorPickerDropdown, 36582 { 36583 color: value, 36584 onColorChange: handleColorChange, 36585 disabled: disabled2 36586 } 36587 ) }) 36588 } 36589 ); 36590 } 36591 36592 // packages/dataviews/build-module/components/dataform-controls/password.mjs 36593 var import_components65 = __toESM(require_components(), 1); 36594 var import_element114 = __toESM(require_element(), 1); 36595 var import_i18n60 = __toESM(require_i18n(), 1); 36596 var import_jsx_runtime193 = __toESM(require_jsx_runtime(), 1); 36597 function Password({ 36598 data, 36599 field, 36600 onChange, 36601 hideLabelFromVision, 36602 markWhenOptional, 36603 validity 36604 }) { 36605 const [isVisible2, setIsVisible] = (0, import_element114.useState)(false); 36606 const disabled2 = field.isDisabled({ item: data, field }); 36607 const toggleVisibility = (0, import_element114.useCallback)(() => { 36608 setIsVisible((prev) => !prev); 36609 }, []); 36610 return /* @__PURE__ */ (0, import_jsx_runtime193.jsx)( 36611 ValidatedText, 36612 { 36613 ...{ 36614 data, 36615 field, 36616 onChange, 36617 hideLabelFromVision, 36618 markWhenOptional, 36619 validity, 36620 type: isVisible2 ? "text" : "password", 36621 suffix: /* @__PURE__ */ (0, import_jsx_runtime193.jsx)(import_components65.__experimentalInputControlSuffixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime193.jsx)( 36622 import_components65.Button, 36623 { 36624 icon: isVisible2 ? unseen_default : seen_default, 36625 onClick: toggleVisibility, 36626 size: "small", 36627 label: isVisible2 ? (0, import_i18n60.__)("Hide password") : (0, import_i18n60.__)("Show password"), 36628 disabled: disabled2, 36629 accessibleWhenDisabled: true 36630 } 36631 ) }) 36632 } 36633 } 36634 ); 36635 } 36636 36637 // packages/dataviews/build-module/field-types/utils/has-elements.mjs 36638 function hasElements(field) { 36639 return Array.isArray(field.elements) && field.elements.length > 0 || typeof field.getElements === "function"; 36640 } 36641 36642 // packages/dataviews/build-module/components/dataform-controls/index.mjs 36643 var import_jsx_runtime194 = __toESM(require_jsx_runtime(), 1); 36644 var FORM_CONTROLS = { 36645 adaptiveSelect: AdaptiveSelect, 36646 array: ArrayControl, 36647 checkbox: Checkbox, 36648 color: Color, 36649 combobox: Combobox3, 36650 datetime: DateTime, 36651 date: DateControl, 36652 email: Email, 36653 telephone: Telephone, 36654 url: Url, 36655 integer: Integer, 36656 number: Number2, 36657 password: Password, 36658 radio: Radio, 36659 select: Select, 36660 text: Text3, 36661 toggle: Toggle, 36662 textarea: Textarea, 36663 richtext: RichText, 36664 toggleGroup: ToggleGroup 36665 }; 36666 function isEditConfig(value) { 36667 return value && typeof value === "object" && typeof value.control === "string"; 36668 } 36669 function createConfiguredControl(config2) { 36670 const { control, ...controlConfig } = config2; 36671 const BaseControlType = getControlByType(control); 36672 if (BaseControlType === null) { 36673 return null; 36674 } 36675 return function ConfiguredControl(props) { 36676 return /* @__PURE__ */ (0, import_jsx_runtime194.jsx)(BaseControlType, { ...props, config: controlConfig }); 36677 }; 36678 } 36679 function getControl(field, fallback) { 36680 if (typeof field.Edit === "function") { 36681 return field.Edit; 36682 } 36683 if (typeof field.Edit === "string") { 36684 return getControlByType(field.Edit); 36685 } 36686 if (isEditConfig(field.Edit)) { 36687 return createConfiguredControl(field.Edit); 36688 } 36689 if (hasElements(field) && field.type !== "array") { 36690 return getControlByType("adaptiveSelect"); 36691 } 36692 if (fallback === null) { 36693 return null; 36694 } 36695 return getControlByType(fallback); 36696 } 36697 function getControlByType(type) { 36698 if (Object.keys(FORM_CONTROLS).includes(type)) { 36699 return FORM_CONTROLS[type]; 36700 } 36701 return null; 36702 } 36703 36704 // packages/dataviews/build-module/field-types/utils/get-filter-by.mjs 36705 function getFilterBy(field, defaultOperators, validOperators) { 36706 if (field.filterBy === false) { 36707 return false; 36708 } 36709 const operators = field.filterBy?.operators?.filter( 36710 (op) => validOperators.includes(op) 36711 ) ?? defaultOperators; 36712 if (operators.length === 0) { 36713 return false; 36714 } 36715 return { 36716 isPrimary: !!field.filterBy?.isPrimary, 36717 operators 36718 }; 36719 } 36720 var get_filter_by_default = getFilterBy; 36721 36722 // packages/dataviews/build-module/field-types/utils/get-value-from-id.mjs 36723 var getValueFromId = (id) => ({ item }) => { 36724 const path = id.split("."); 36725 let value = item; 36726 for (const segment of path) { 36727 if (value.hasOwnProperty(segment)) { 36728 value = value[segment]; 36729 } else { 36730 value = void 0; 36731 } 36732 } 36733 return value; 36734 }; 36735 var get_value_from_id_default = getValueFromId; 36736 36737 // packages/dataviews/build-module/field-types/utils/set-value-from-id.mjs 36738 var setValueFromId = (id) => ({ value }) => { 36739 const path = id.split("."); 36740 const result = {}; 36741 let current = result; 36742 for (const segment of path.slice(0, -1)) { 36743 current[segment] = {}; 36744 current = current[segment]; 36745 } 36746 current[path.at(-1)] = value; 36747 return result; 36748 }; 36749 var set_value_from_id_default = setValueFromId; 36750 36751 // packages/dataviews/build-module/field-types/email.mjs 36752 var import_i18n61 = __toESM(require_i18n(), 1); 36753 36754 // packages/dataviews/build-module/field-types/utils/render-from-elements.mjs 36755 function RenderFromElements({ 36756 item, 36757 field 36758 }) { 36759 const { elements: elements2, isLoading } = useElements({ 36760 elements: field.elements, 36761 getElements: field.getElements 36762 }); 36763 const value = field.getValue({ item }); 36764 if (isLoading) { 36765 return value; 36766 } 36767 if (elements2.length === 0) { 36768 return value; 36769 } 36770 return elements2?.find((element) => element.value === value)?.label || field.getValue({ item }); 36771 } 36772 36773 // packages/dataviews/build-module/field-types/utils/render-default.mjs 36774 var import_jsx_runtime195 = __toESM(require_jsx_runtime(), 1); 36775 function render({ 36776 item, 36777 field 36778 }) { 36779 if (field.hasElements) { 36780 return /* @__PURE__ */ (0, import_jsx_runtime195.jsx)(RenderFromElements, { item, field }); 36781 } 36782 return field.getValueFormatted({ item, field }); 36783 } 36784 36785 // packages/dataviews/build-module/field-types/utils/sort-text.mjs 36786 var sort_text_default = (a2, b2, direction) => { 36787 return direction === "asc" ? a2.localeCompare(b2) : b2.localeCompare(a2); 36788 }; 36789 36790 // packages/dataviews/build-module/field-types/utils/is-valid-required.mjs 36791 function isValidRequired(item, field) { 36792 const value = field.getValue({ item }); 36793 return ![void 0, "", null].includes(value); 36794 } 36795 36796 // packages/dataviews/build-module/field-types/utils/is-valid-min-length.mjs 36797 function isValidMinLength(item, field) { 36798 if (typeof field.isValid.minLength?.constraint !== "number") { 36799 return false; 36800 } 36801 const value = field.getValue({ item }); 36802 if ([void 0, "", null].includes(value)) { 36803 return true; 36804 } 36805 return String(value).length >= field.isValid.minLength.constraint; 36806 } 36807 36808 // packages/dataviews/build-module/field-types/utils/is-valid-max-length.mjs 36809 function isValidMaxLength(item, field) { 36810 if (typeof field.isValid.maxLength?.constraint !== "number") { 36811 return false; 36812 } 36813 const value = field.getValue({ item }); 36814 if ([void 0, "", null].includes(value)) { 36815 return true; 36816 } 36817 return String(value).length <= field.isValid.maxLength.constraint; 36818 } 36819 36820 // packages/dataviews/build-module/field-types/utils/is-valid-pattern.mjs 36821 function isValidPattern(item, field) { 36822 if (field.isValid.pattern?.constraint === void 0) { 36823 return true; 36824 } 36825 try { 36826 const regexp = new RegExp(field.isValid.pattern.constraint); 36827 const value = field.getValue({ item }); 36828 if ([void 0, "", null].includes(value)) { 36829 return true; 36830 } 36831 return regexp.test(String(value)); 36832 } catch { 36833 return false; 36834 } 36835 } 36836 36837 // packages/dataviews/build-module/field-types/utils/is-valid-elements.mjs 36838 function isValidElements(item, field) { 36839 const elements2 = field.elements ?? []; 36840 const validValues = elements2.map((el) => el.value); 36841 if (validValues.length === 0) { 36842 return true; 36843 } 36844 const value = field.getValue({ item }); 36845 return [].concat(value).every((v2) => validValues.includes(v2)); 36846 } 36847 36848 // packages/dataviews/build-module/field-types/utils/get-value-formatted-default.mjs 36849 function getValueFormatted({ 36850 item, 36851 field 36852 }) { 36853 return field.getValue({ item }); 36854 } 36855 var get_value_formatted_default_default = getValueFormatted; 36856 36857 // packages/dataviews/build-module/field-types/email.mjs 36858 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])?)*$/; 36859 function isValidCustom(item, field) { 36860 const value = field.getValue({ item }); 36861 if (![void 0, "", null].includes(value) && !emailRegex.test(value)) { 36862 return (0, import_i18n61.__)("Value must be a valid email address."); 36863 } 36864 return null; 36865 } 36866 var email_default = { 36867 type: "email", 36868 render, 36869 Edit: "email", 36870 sort: sort_text_default, 36871 enableSorting: true, 36872 enableGlobalSearch: false, 36873 defaultOperators: [OPERATOR_IS_ANY2, OPERATOR_IS_NONE2], 36874 validOperators: [ 36875 OPERATOR_IS, 36876 OPERATOR_IS_NOT, 36877 OPERATOR_CONTAINS, 36878 OPERATOR_NOT_CONTAINS, 36879 OPERATOR_STARTS_WITH, 36880 // Multiple selection 36881 OPERATOR_IS_ANY2, 36882 OPERATOR_IS_NONE2, 36883 OPERATOR_IS_ALL, 36884 OPERATOR_IS_NOT_ALL 36885 ], 36886 format: {}, 36887 getValueFormatted: get_value_formatted_default_default, 36888 validate: { 36889 required: isValidRequired, 36890 pattern: isValidPattern, 36891 minLength: isValidMinLength, 36892 maxLength: isValidMaxLength, 36893 elements: isValidElements, 36894 custom: isValidCustom 36895 } 36896 }; 36897 36898 // packages/dataviews/build-module/field-types/integer.mjs 36899 var import_i18n62 = __toESM(require_i18n(), 1); 36900 36901 // packages/dataviews/build-module/field-types/utils/sort-number.mjs 36902 var sort_number_default = (a2, b2, direction) => { 36903 return direction === "asc" ? a2 - b2 : b2 - a2; 36904 }; 36905 36906 // packages/dataviews/build-module/field-types/utils/is-valid-min.mjs 36907 function isValidMin(item, field) { 36908 if (typeof field.isValid.min?.constraint !== "number") { 36909 return false; 36910 } 36911 const value = field.getValue({ item }); 36912 if ([void 0, "", null].includes(value)) { 36913 return true; 36914 } 36915 return Number(value) >= field.isValid.min.constraint; 36916 } 36917 36918 // packages/dataviews/build-module/field-types/utils/is-valid-max.mjs 36919 function isValidMax(item, field) { 36920 if (typeof field.isValid.max?.constraint !== "number") { 36921 return false; 36922 } 36923 const value = field.getValue({ item }); 36924 if ([void 0, "", null].includes(value)) { 36925 return true; 36926 } 36927 return Number(value) <= field.isValid.max.constraint; 36928 } 36929 36930 // packages/dataviews/build-module/field-types/integer.mjs 36931 var format2 = { 36932 separatorThousand: "," 36933 }; 36934 function getValueFormatted2({ 36935 item, 36936 field 36937 }) { 36938 let value = field.getValue({ item }); 36939 if (value === null || value === void 0) { 36940 return ""; 36941 } 36942 value = Number(value); 36943 if (!Number.isFinite(value)) { 36944 return String(value); 36945 } 36946 let formatInteger; 36947 if (field.type !== "integer") { 36948 formatInteger = format2; 36949 } else { 36950 formatInteger = field.format; 36951 } 36952 const { separatorThousand } = formatInteger; 36953 const integerValue = Math.trunc(value); 36954 if (!separatorThousand) { 36955 return String(integerValue); 36956 } 36957 return String(integerValue).replace( 36958 /\B(?=(\d{3})+(?!\d))/g, 36959 separatorThousand 36960 ); 36961 } 36962 function isValidCustom2(item, field) { 36963 const value = field.getValue({ item }); 36964 if (![void 0, "", null].includes(value) && !Number.isInteger(value)) { 36965 return (0, import_i18n62.__)("Value must be an integer."); 36966 } 36967 return null; 36968 } 36969 var integer_default = { 36970 type: "integer", 36971 render, 36972 Edit: "integer", 36973 sort: sort_number_default, 36974 enableSorting: true, 36975 enableGlobalSearch: false, 36976 defaultOperators: [ 36977 OPERATOR_IS, 36978 OPERATOR_IS_NOT, 36979 OPERATOR_LESS_THAN, 36980 OPERATOR_GREATER_THAN, 36981 OPERATOR_LESS_THAN_OR_EQUAL, 36982 OPERATOR_GREATER_THAN_OR_EQUAL, 36983 OPERATOR_BETWEEN 36984 ], 36985 validOperators: [ 36986 // Single-selection 36987 OPERATOR_IS, 36988 OPERATOR_IS_NOT, 36989 OPERATOR_LESS_THAN, 36990 OPERATOR_GREATER_THAN, 36991 OPERATOR_LESS_THAN_OR_EQUAL, 36992 OPERATOR_GREATER_THAN_OR_EQUAL, 36993 OPERATOR_BETWEEN, 36994 // Multiple-selection 36995 OPERATOR_IS_ANY2, 36996 OPERATOR_IS_NONE2, 36997 OPERATOR_IS_ALL, 36998 OPERATOR_IS_NOT_ALL 36999 ], 37000 format: format2, 37001 getValueFormatted: getValueFormatted2, 37002 validate: { 37003 required: isValidRequired, 37004 min: isValidMin, 37005 max: isValidMax, 37006 elements: isValidElements, 37007 custom: isValidCustom2 37008 } 37009 }; 37010 37011 // packages/dataviews/build-module/field-types/number.mjs 37012 var import_i18n63 = __toESM(require_i18n(), 1); 37013 var format3 = { 37014 separatorThousand: ",", 37015 separatorDecimal: ".", 37016 decimals: 2 37017 }; 37018 function getValueFormatted3({ 37019 item, 37020 field 37021 }) { 37022 let value = field.getValue({ item }); 37023 if (value === null || value === void 0) { 37024 return ""; 37025 } 37026 value = Number(value); 37027 if (!Number.isFinite(value)) { 37028 return String(value); 37029 } 37030 let formatNumber; 37031 if (field.type !== "number") { 37032 formatNumber = format3; 37033 } else { 37034 formatNumber = field.format; 37035 } 37036 const { separatorThousand, separatorDecimal, decimals } = formatNumber; 37037 const fixedValue = value.toFixed(decimals); 37038 const [integerPart, decimalPart] = fixedValue.split("."); 37039 const formattedInteger = separatorThousand ? integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, separatorThousand) : integerPart; 37040 return decimals === 0 ? formattedInteger : formattedInteger + separatorDecimal + decimalPart; 37041 } 37042 function isEmpty(value) { 37043 return value === "" || value === void 0 || value === null; 37044 } 37045 function isValidCustom3(item, field) { 37046 const value = field.getValue({ item }); 37047 if (!isEmpty(value) && !Number.isFinite(value)) { 37048 return (0, import_i18n63.__)("Value must be a number."); 37049 } 37050 return null; 37051 } 37052 var number_default = { 37053 type: "number", 37054 render, 37055 Edit: "number", 37056 sort: sort_number_default, 37057 enableSorting: true, 37058 enableGlobalSearch: false, 37059 defaultOperators: [ 37060 OPERATOR_IS, 37061 OPERATOR_IS_NOT, 37062 OPERATOR_LESS_THAN, 37063 OPERATOR_GREATER_THAN, 37064 OPERATOR_LESS_THAN_OR_EQUAL, 37065 OPERATOR_GREATER_THAN_OR_EQUAL, 37066 OPERATOR_BETWEEN 37067 ], 37068 validOperators: [ 37069 // Single-selection 37070 OPERATOR_IS, 37071 OPERATOR_IS_NOT, 37072 OPERATOR_LESS_THAN, 37073 OPERATOR_GREATER_THAN, 37074 OPERATOR_LESS_THAN_OR_EQUAL, 37075 OPERATOR_GREATER_THAN_OR_EQUAL, 37076 OPERATOR_BETWEEN, 37077 // Multiple-selection 37078 OPERATOR_IS_ANY2, 37079 OPERATOR_IS_NONE2, 37080 OPERATOR_IS_ALL, 37081 OPERATOR_IS_NOT_ALL 37082 ], 37083 format: format3, 37084 getValueFormatted: getValueFormatted3, 37085 validate: { 37086 required: isValidRequired, 37087 min: isValidMin, 37088 max: isValidMax, 37089 elements: isValidElements, 37090 custom: isValidCustom3 37091 } 37092 }; 37093 37094 // packages/dataviews/build-module/field-types/text.mjs 37095 var text_default = { 37096 type: "text", 37097 render, 37098 Edit: "text", 37099 sort: sort_text_default, 37100 enableSorting: true, 37101 enableGlobalSearch: false, 37102 defaultOperators: [OPERATOR_IS_ANY2, OPERATOR_IS_NONE2], 37103 validOperators: [ 37104 // Single selection 37105 OPERATOR_IS, 37106 OPERATOR_IS_NOT, 37107 OPERATOR_CONTAINS, 37108 OPERATOR_NOT_CONTAINS, 37109 OPERATOR_STARTS_WITH, 37110 // Multiple selection 37111 OPERATOR_IS_ANY2, 37112 OPERATOR_IS_NONE2, 37113 OPERATOR_IS_ALL, 37114 OPERATOR_IS_NOT_ALL 37115 ], 37116 format: {}, 37117 getValueFormatted: get_value_formatted_default_default, 37118 validate: { 37119 required: isValidRequired, 37120 pattern: isValidPattern, 37121 minLength: isValidMinLength, 37122 maxLength: isValidMaxLength, 37123 elements: isValidElements 37124 } 37125 }; 37126 37127 // packages/dataviews/build-module/field-types/datetime.mjs 37128 var import_date7 = __toESM(require_date(), 1); 37129 37130 // packages/dataviews/build-module/field-types/utils/is-valid-date-boundary.mjs 37131 var import_date6 = __toESM(require_date(), 1); 37132 function parseDateLike(value) { 37133 if (!value) { 37134 return null; 37135 } 37136 if (!isValid(new Date(value))) { 37137 return null; 37138 } 37139 const parsed = (0, import_date6.getDate)(value); 37140 return parsed && isValid(parsed) ? parsed : null; 37141 } 37142 function validateDateLikeBoundary(item, field, boundary) { 37143 const constraint = field.isValid[boundary]?.constraint; 37144 if (typeof constraint !== "string") { 37145 return false; 37146 } 37147 const value = field.getValue({ item }); 37148 const boundaryValue = Array.isArray(value) ? value[boundary === "min" ? 0 : value.length - 1] : value; 37149 if (boundaryValue === void 0 || boundaryValue === null || boundaryValue === "") { 37150 return true; 37151 } 37152 const parsedConstraint = parseDateLike(constraint); 37153 const parsedValue = parseDateLike(String(boundaryValue)); 37154 return !!parsedConstraint && !!parsedValue && (boundary === "min" ? parsedValue.getTime() >= parsedConstraint.getTime() : parsedValue.getTime() <= parsedConstraint.getTime()); 37155 } 37156 function isValidMinDate(item, field) { 37157 return validateDateLikeBoundary(item, field, "min"); 37158 } 37159 function isValidMaxDate(item, field) { 37160 return validateDateLikeBoundary(item, field, "max"); 37161 } 37162 37163 // packages/dataviews/build-module/field-types/datetime.mjs 37164 var format4 = { 37165 datetime: (0, import_date7.getSettings)().formats.datetime, 37166 weekStartsOn: (0, import_date7.getSettings)().l10n.startOfWeek 37167 }; 37168 function getValueFormatted4({ 37169 item, 37170 field 37171 }) { 37172 const value = field.getValue({ item }); 37173 if (["", void 0, null].includes(value)) { 37174 return ""; 37175 } 37176 let formatDatetime; 37177 if (field.type !== "datetime") { 37178 formatDatetime = format4; 37179 } else { 37180 formatDatetime = field.format; 37181 } 37182 return (0, import_date7.dateI18n)(formatDatetime.datetime, (0, import_date7.getDate)(value)); 37183 } 37184 var sort = (a2, b2, direction) => { 37185 const timeA = new Date(a2).getTime(); 37186 const timeB = new Date(b2).getTime(); 37187 return direction === "asc" ? timeA - timeB : timeB - timeA; 37188 }; 37189 var datetime_default = { 37190 type: "datetime", 37191 render, 37192 Edit: "datetime", 37193 sort, 37194 enableSorting: true, 37195 enableGlobalSearch: false, 37196 defaultOperators: [ 37197 OPERATOR_ON, 37198 OPERATOR_NOT_ON, 37199 OPERATOR_BEFORE2, 37200 OPERATOR_AFTER2, 37201 OPERATOR_BEFORE_INC, 37202 OPERATOR_AFTER_INC, 37203 OPERATOR_IN_THE_PAST, 37204 OPERATOR_OVER 37205 ], 37206 validOperators: [ 37207 OPERATOR_ON, 37208 OPERATOR_NOT_ON, 37209 OPERATOR_BEFORE2, 37210 OPERATOR_AFTER2, 37211 OPERATOR_BEFORE_INC, 37212 OPERATOR_AFTER_INC, 37213 OPERATOR_IN_THE_PAST, 37214 OPERATOR_OVER 37215 ], 37216 format: format4, 37217 getValueFormatted: getValueFormatted4, 37218 validate: { 37219 required: isValidRequired, 37220 elements: isValidElements, 37221 min: isValidMinDate, 37222 max: isValidMaxDate 37223 } 37224 }; 37225 37226 // packages/dataviews/build-module/field-types/date.mjs 37227 var import_date8 = __toESM(require_date(), 1); 37228 var format5 = { 37229 date: (0, import_date8.getSettings)().formats.date, 37230 weekStartsOn: (0, import_date8.getSettings)().l10n.startOfWeek 37231 }; 37232 function getValueFormatted5({ 37233 item, 37234 field 37235 }) { 37236 const value = field.getValue({ item }); 37237 if (["", void 0, null].includes(value)) { 37238 return ""; 37239 } 37240 let formatDate2; 37241 if (field.type !== "date") { 37242 formatDate2 = format5; 37243 } else { 37244 formatDate2 = field.format; 37245 } 37246 return (0, import_date8.dateI18n)(formatDate2.date, (0, import_date8.getDate)(value)); 37247 } 37248 var sort2 = (a2, b2, direction) => { 37249 const timeA = new Date(a2).getTime(); 37250 const timeB = new Date(b2).getTime(); 37251 return direction === "asc" ? timeA - timeB : timeB - timeA; 37252 }; 37253 var date_default = { 37254 type: "date", 37255 render, 37256 Edit: "date", 37257 sort: sort2, 37258 enableSorting: true, 37259 enableGlobalSearch: false, 37260 defaultOperators: [ 37261 OPERATOR_ON, 37262 OPERATOR_NOT_ON, 37263 OPERATOR_BEFORE2, 37264 OPERATOR_AFTER2, 37265 OPERATOR_BEFORE_INC, 37266 OPERATOR_AFTER_INC, 37267 OPERATOR_IN_THE_PAST, 37268 OPERATOR_OVER, 37269 OPERATOR_BETWEEN 37270 ], 37271 validOperators: [ 37272 OPERATOR_ON, 37273 OPERATOR_NOT_ON, 37274 OPERATOR_BEFORE2, 37275 OPERATOR_AFTER2, 37276 OPERATOR_BEFORE_INC, 37277 OPERATOR_AFTER_INC, 37278 OPERATOR_IN_THE_PAST, 37279 OPERATOR_OVER, 37280 OPERATOR_BETWEEN 37281 ], 37282 format: format5, 37283 getValueFormatted: getValueFormatted5, 37284 validate: { 37285 required: isValidRequired, 37286 elements: isValidElements, 37287 min: isValidMinDate, 37288 max: isValidMaxDate 37289 } 37290 }; 37291 37292 // packages/dataviews/build-module/field-types/boolean.mjs 37293 var import_i18n64 = __toESM(require_i18n(), 1); 37294 37295 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-bool.mjs 37296 function isValidRequiredForBool(item, field) { 37297 const value = field.getValue({ item }); 37298 return value === true; 37299 } 37300 37301 // packages/dataviews/build-module/field-types/boolean.mjs 37302 function getValueFormatted6({ 37303 item, 37304 field 37305 }) { 37306 const value = field.getValue({ item }); 37307 if (value === true) { 37308 return (0, import_i18n64.__)("True"); 37309 } 37310 if (value === false) { 37311 return (0, import_i18n64.__)("False"); 37312 } 37313 return ""; 37314 } 37315 function isValidCustom4(item, field) { 37316 const value = field.getValue({ item }); 37317 if (![void 0, "", null].includes(value) && ![true, false].includes(value)) { 37318 return (0, import_i18n64.__)("Value must be true, false, or undefined"); 37319 } 37320 return null; 37321 } 37322 var sort3 = (a2, b2, direction) => { 37323 const boolA = Boolean(a2); 37324 const boolB = Boolean(b2); 37325 if (boolA === boolB) { 37326 return 0; 37327 } 37328 if (direction === "asc") { 37329 return boolA ? 1 : -1; 37330 } 37331 return boolA ? -1 : 1; 37332 }; 37333 var boolean_default = { 37334 type: "boolean", 37335 render, 37336 Edit: "checkbox", 37337 sort: sort3, 37338 validate: { 37339 required: isValidRequiredForBool, 37340 elements: isValidElements, 37341 custom: isValidCustom4 37342 }, 37343 enableSorting: true, 37344 enableGlobalSearch: false, 37345 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT], 37346 validOperators: [OPERATOR_IS, OPERATOR_IS_NOT], 37347 format: {}, 37348 getValueFormatted: getValueFormatted6 37349 }; 37350 37351 // packages/dataviews/build-module/field-types/media.mjs 37352 var media_default2 = { 37353 type: "media", 37354 render: () => null, 37355 Edit: null, 37356 sort: () => 0, 37357 enableSorting: false, 37358 enableGlobalSearch: false, 37359 defaultOperators: [], 37360 validOperators: [], 37361 format: {}, 37362 getValueFormatted: get_value_formatted_default_default, 37363 // cannot validate any constraint, so 37364 // the only available validation for the field author 37365 // would be providing a custom validator. 37366 validate: {} 37367 }; 37368 37369 // packages/dataviews/build-module/field-types/array.mjs 37370 var import_i18n65 = __toESM(require_i18n(), 1); 37371 37372 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-array.mjs 37373 function isValidRequiredForArray(item, field) { 37374 const value = field.getValue({ item }); 37375 return Array.isArray(value) && value.length > 0 && value.every( 37376 (element) => ![void 0, "", null].includes(element) 37377 ); 37378 } 37379 37380 // packages/dataviews/build-module/field-types/array.mjs 37381 function getValueFormatted7({ 37382 item, 37383 field 37384 }) { 37385 const value = field.getValue({ item }); 37386 const arr = Array.isArray(value) ? value : []; 37387 return arr.join(", "); 37388 } 37389 function render2({ item, field }) { 37390 return getValueFormatted7({ item, field }); 37391 } 37392 function isValidCustom5(item, field) { 37393 const value = field.getValue({ item }); 37394 if (![void 0, "", null].includes(value) && !Array.isArray(value)) { 37395 return (0, import_i18n65.__)("Value must be an array."); 37396 } 37397 if (!value.every((v2) => typeof v2 === "string")) { 37398 return (0, import_i18n65.__)("Every value must be a string."); 37399 } 37400 return null; 37401 } 37402 var sort4 = (a2, b2, direction) => { 37403 const arrA = Array.isArray(a2) ? a2 : []; 37404 const arrB = Array.isArray(b2) ? b2 : []; 37405 if (arrA.length !== arrB.length) { 37406 return direction === "asc" ? arrA.length - arrB.length : arrB.length - arrA.length; 37407 } 37408 const joinedA = arrA.join(","); 37409 const joinedB = arrB.join(","); 37410 return direction === "asc" ? joinedA.localeCompare(joinedB) : joinedB.localeCompare(joinedA); 37411 }; 37412 var array_default = { 37413 type: "array", 37414 render: render2, 37415 Edit: "array", 37416 sort: sort4, 37417 enableSorting: true, 37418 enableGlobalSearch: false, 37419 defaultOperators: [OPERATOR_IS_ANY2, OPERATOR_IS_NONE2], 37420 validOperators: [ 37421 OPERATOR_IS_ANY2, 37422 OPERATOR_IS_NONE2, 37423 OPERATOR_IS_ALL, 37424 OPERATOR_IS_NOT_ALL 37425 ], 37426 format: {}, 37427 getValueFormatted: getValueFormatted7, 37428 validate: { 37429 required: isValidRequiredForArray, 37430 elements: isValidElements, 37431 custom: isValidCustom5 37432 } 37433 }; 37434 37435 // packages/dataviews/build-module/field-types/password.mjs 37436 function getValueFormatted8({ 37437 item, 37438 field 37439 }) { 37440 return field.getValue({ item }) ? "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022" : ""; 37441 } 37442 var password_default = { 37443 type: "password", 37444 render, 37445 Edit: "password", 37446 sort: () => 0, 37447 // Passwords should not be sortable for security reasons 37448 enableSorting: false, 37449 enableGlobalSearch: false, 37450 defaultOperators: [], 37451 validOperators: [], 37452 format: {}, 37453 getValueFormatted: getValueFormatted8, 37454 validate: { 37455 required: isValidRequired, 37456 pattern: isValidPattern, 37457 minLength: isValidMinLength, 37458 maxLength: isValidMaxLength, 37459 elements: isValidElements 37460 } 37461 }; 37462 37463 // packages/dataviews/build-module/field-types/telephone.mjs 37464 var telephone_default = { 37465 type: "telephone", 37466 render, 37467 Edit: "telephone", 37468 sort: sort_text_default, 37469 enableSorting: true, 37470 enableGlobalSearch: false, 37471 defaultOperators: [OPERATOR_IS_ANY2, OPERATOR_IS_NONE2], 37472 validOperators: [ 37473 OPERATOR_IS, 37474 OPERATOR_IS_NOT, 37475 OPERATOR_CONTAINS, 37476 OPERATOR_NOT_CONTAINS, 37477 OPERATOR_STARTS_WITH, 37478 // Multiple selection 37479 OPERATOR_IS_ANY2, 37480 OPERATOR_IS_NONE2, 37481 OPERATOR_IS_ALL, 37482 OPERATOR_IS_NOT_ALL 37483 ], 37484 format: {}, 37485 getValueFormatted: get_value_formatted_default_default, 37486 validate: { 37487 required: isValidRequired, 37488 pattern: isValidPattern, 37489 minLength: isValidMinLength, 37490 maxLength: isValidMaxLength, 37491 elements: isValidElements 37492 } 37493 }; 37494 37495 // packages/dataviews/build-module/field-types/color.mjs 37496 var import_i18n66 = __toESM(require_i18n(), 1); 37497 var import_jsx_runtime196 = __toESM(require_jsx_runtime(), 1); 37498 function render3({ item, field }) { 37499 if (field.hasElements) { 37500 return /* @__PURE__ */ (0, import_jsx_runtime196.jsx)(RenderFromElements, { item, field }); 37501 } 37502 const value = get_value_formatted_default_default({ item, field }); 37503 if (!value || !w(value).isValid()) { 37504 return value; 37505 } 37506 return /* @__PURE__ */ (0, import_jsx_runtime196.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [ 37507 /* @__PURE__ */ (0, import_jsx_runtime196.jsx)( 37508 "div", 37509 { 37510 style: { 37511 width: "16px", 37512 height: "16px", 37513 borderRadius: "50%", 37514 backgroundColor: value, 37515 border: "1px solid #ddd", 37516 flexShrink: 0 37517 } 37518 } 37519 ), 37520 /* @__PURE__ */ (0, import_jsx_runtime196.jsx)("span", { children: value }) 37521 ] }); 37522 } 37523 function isValidCustom6(item, field) { 37524 const value = field.getValue({ item }); 37525 if (![void 0, "", null].includes(value) && !w(value).isValid()) { 37526 return (0, import_i18n66.__)("Value must be a valid color."); 37527 } 37528 return null; 37529 } 37530 var sort5 = (a2, b2, direction) => { 37531 const colorA = w(a2); 37532 const colorB = w(b2); 37533 if (!colorA.isValid() && !colorB.isValid()) { 37534 return 0; 37535 } 37536 if (!colorA.isValid()) { 37537 return direction === "asc" ? 1 : -1; 37538 } 37539 if (!colorB.isValid()) { 37540 return direction === "asc" ? -1 : 1; 37541 } 37542 const hslA = colorA.toHsl(); 37543 const hslB = colorB.toHsl(); 37544 if (hslA.h !== hslB.h) { 37545 return direction === "asc" ? hslA.h - hslB.h : hslB.h - hslA.h; 37546 } 37547 if (hslA.s !== hslB.s) { 37548 return direction === "asc" ? hslA.s - hslB.s : hslB.s - hslA.s; 37549 } 37550 return direction === "asc" ? hslA.l - hslB.l : hslB.l - hslA.l; 37551 }; 37552 var color_default = { 37553 type: "color", 37554 render: render3, 37555 Edit: "color", 37556 sort: sort5, 37557 enableSorting: true, 37558 enableGlobalSearch: false, 37559 defaultOperators: [OPERATOR_IS_ANY2, OPERATOR_IS_NONE2], 37560 validOperators: [ 37561 OPERATOR_IS, 37562 OPERATOR_IS_NOT, 37563 OPERATOR_IS_ANY2, 37564 OPERATOR_IS_NONE2 37565 ], 37566 format: {}, 37567 getValueFormatted: get_value_formatted_default_default, 37568 validate: { 37569 required: isValidRequired, 37570 elements: isValidElements, 37571 custom: isValidCustom6 37572 } 37573 }; 37574 37575 // packages/dataviews/build-module/field-types/url.mjs 37576 var url_default = { 37577 type: "url", 37578 render, 37579 Edit: "url", 37580 sort: sort_text_default, 37581 enableSorting: true, 37582 enableGlobalSearch: false, 37583 defaultOperators: [OPERATOR_IS_ANY2, OPERATOR_IS_NONE2], 37584 validOperators: [ 37585 OPERATOR_IS, 37586 OPERATOR_IS_NOT, 37587 OPERATOR_CONTAINS, 37588 OPERATOR_NOT_CONTAINS, 37589 OPERATOR_STARTS_WITH, 37590 // Multiple selection 37591 OPERATOR_IS_ANY2, 37592 OPERATOR_IS_NONE2, 37593 OPERATOR_IS_ALL, 37594 OPERATOR_IS_NOT_ALL 37595 ], 37596 format: {}, 37597 getValueFormatted: get_value_formatted_default_default, 37598 validate: { 37599 required: isValidRequired, 37600 pattern: isValidPattern, 37601 minLength: isValidMinLength, 37602 maxLength: isValidMaxLength, 37603 elements: isValidElements 37604 } 37605 }; 37606 37607 // packages/dataviews/build-module/field-types/no-type.mjs 37608 var sort6 = (a2, b2, direction) => { 37609 if (typeof a2 === "number" && typeof b2 === "number") { 37610 return sort_number_default(a2, b2, direction); 37611 } 37612 return sort_text_default(a2, b2, direction); 37613 }; 37614 var no_type_default = { 37615 // type: no type for this one 37616 render, 37617 Edit: null, 37618 sort: sort6, 37619 enableSorting: true, 37620 enableGlobalSearch: false, 37621 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT], 37622 validOperators: getAllOperatorNames(), 37623 format: {}, 37624 getValueFormatted: get_value_formatted_default_default, 37625 validate: { 37626 required: isValidRequired, 37627 elements: isValidElements 37628 } 37629 }; 37630 37631 // packages/dataviews/build-module/field-types/utils/get-is-valid.mjs 37632 function supportsNumericRangeConstraint(type) { 37633 return type === "integer" || type === "number"; 37634 } 37635 function supportsDateRangeConstraint(type) { 37636 return type === "date" || type === "datetime"; 37637 } 37638 function normalizeRangeRule(value, fieldType, key) { 37639 const validator = fieldType.validate[key]; 37640 if (validator && (typeof value === "number" && supportsNumericRangeConstraint(fieldType.type) || typeof value === "string" && supportsDateRangeConstraint(fieldType.type))) { 37641 return { constraint: value, validate: validator }; 37642 } 37643 return void 0; 37644 } 37645 function getIsValid(field, fieldType) { 37646 const rules = field.isValid; 37647 let required; 37648 if (rules?.required === true && fieldType.validate.required !== void 0) { 37649 required = { 37650 constraint: true, 37651 validate: fieldType.validate.required 37652 }; 37653 } 37654 let elements2; 37655 if ((rules?.elements === true || // elements is enabled unless the field opts-out 37656 rules?.elements === void 0 && (!!field.elements || !!field.getElements)) && fieldType.validate.elements !== void 0) { 37657 elements2 = { 37658 constraint: true, 37659 validate: fieldType.validate.elements 37660 }; 37661 } 37662 const min2 = normalizeRangeRule(rules?.min, fieldType, "min"); 37663 const max2 = normalizeRangeRule(rules?.max, fieldType, "max"); 37664 const minLengthValue = rules?.minLength; 37665 let minLength; 37666 if (typeof minLengthValue === "number" && fieldType.validate.minLength !== void 0) { 37667 minLength = { 37668 constraint: minLengthValue, 37669 validate: fieldType.validate.minLength 37670 }; 37671 } 37672 const maxLengthValue = rules?.maxLength; 37673 let maxLength; 37674 if (typeof maxLengthValue === "number" && fieldType.validate.maxLength !== void 0) { 37675 maxLength = { 37676 constraint: maxLengthValue, 37677 validate: fieldType.validate.maxLength 37678 }; 37679 } 37680 const patternValue = rules?.pattern; 37681 let pattern; 37682 if (patternValue !== void 0 && fieldType.validate.pattern !== void 0) { 37683 pattern = { 37684 constraint: patternValue, 37685 validate: fieldType.validate.pattern 37686 }; 37687 } 37688 const custom = rules?.custom ?? fieldType.validate.custom; 37689 return { 37690 required, 37691 elements: elements2, 37692 min: min2, 37693 max: max2, 37694 minLength, 37695 maxLength, 37696 pattern, 37697 custom 37698 }; 37699 } 37700 37701 // packages/dataviews/build-module/field-types/utils/get-filter.mjs 37702 function getFilter(fieldType) { 37703 return fieldType.validOperators.reduce((accumulator, operator) => { 37704 const operatorObj = getOperatorByName(operator); 37705 if (operatorObj?.filter) { 37706 accumulator[operator] = operatorObj.filter; 37707 } 37708 return accumulator; 37709 }, {}); 37710 } 37711 37712 // packages/dataviews/build-module/field-types/utils/get-format.mjs 37713 function getFormat(field, fieldType) { 37714 return { 37715 ...fieldType.format, 37716 ...field.format 37717 }; 37718 } 37719 var get_format_default = getFormat; 37720 37721 // packages/dataviews/build-module/field-types/index.mjs 37722 function getFieldTypeByName(type) { 37723 const found = [ 37724 email_default, 37725 integer_default, 37726 number_default, 37727 text_default, 37728 datetime_default, 37729 date_default, 37730 boolean_default, 37731 media_default2, 37732 array_default, 37733 password_default, 37734 telephone_default, 37735 color_default, 37736 url_default 37737 ].find((fieldType) => fieldType?.type === type); 37738 if (!!found) { 37739 return found; 37740 } 37741 return no_type_default; 37742 } 37743 function normalizeFields(fields2) { 37744 return fields2.map((field) => { 37745 const fieldType = getFieldTypeByName(field.type); 37746 const getValue = field.getValue || get_value_from_id_default(field.id); 37747 const sort7 = function(a2, b2, direction) { 37748 const aValue = getValue({ item: a2 }); 37749 const bValue = getValue({ item: b2 }); 37750 return field.sort ? field.sort(aValue, bValue, direction) : fieldType.sort(aValue, bValue, direction); 37751 }; 37752 return { 37753 id: field.id, 37754 label: field.label || field.id, 37755 header: field.header || field.label || field.id, 37756 description: field.description, 37757 placeholder: field.placeholder, 37758 getValue, 37759 setValue: field.setValue || set_value_from_id_default(field.id), 37760 elements: field.elements, 37761 getElements: field.getElements, 37762 hasElements: hasElements(field), 37763 isVisible: field.isVisible, 37764 isDisabled: typeof field.isDisabled === "function" ? field.isDisabled : () => !!field.isDisabled, 37765 enableHiding: field.enableHiding ?? true, 37766 readOnly: field.readOnly ?? false, 37767 // The type provides defaults for the following props 37768 type: fieldType.type, 37769 render: field.render ?? fieldType.render, 37770 Edit: getControl(field, fieldType.Edit), 37771 sort: sort7, 37772 enableSorting: field.enableSorting ?? fieldType.enableSorting, 37773 enableGlobalSearch: field.enableGlobalSearch ?? fieldType.enableGlobalSearch, 37774 isValid: getIsValid(field, fieldType), 37775 filterBy: get_filter_by_default( 37776 field, 37777 fieldType.defaultOperators, 37778 fieldType.validOperators 37779 ), 37780 filter: getFilter(fieldType), 37781 format: get_format_default(field, fieldType), 37782 getValueFormatted: field.getValueFormatted ?? fieldType.getValueFormatted 37783 }; 37784 }); 37785 } 37786 37787 // packages/dataviews/build-module/hooks/use-data.mjs 37788 var import_element115 = __toESM(require_element(), 1); 37789 function useData({ 37790 view, 37791 data: shownData, 37792 getItemId: getItemId2, 37793 isLoading, 37794 paginationInfo, 37795 selection 37796 }) { 37797 const isInfiniteScrollEnabled = view.infiniteScrollEnabled; 37798 const [hasInitiallyLoaded, setHasInitiallyLoaded] = (0, import_element115.useState)( 37799 !isLoading 37800 ); 37801 (0, import_element115.useEffect)(() => { 37802 if (!isLoading) { 37803 setHasInitiallyLoaded(true); 37804 } 37805 }, [isLoading]); 37806 const previousDataRef = (0, import_element115.useRef)(shownData); 37807 const previousPaginationInfoRef = (0, import_element115.useRef)(paginationInfo); 37808 (0, import_element115.useEffect)(() => { 37809 if (!isLoading) { 37810 previousDataRef.current = shownData; 37811 previousPaginationInfoRef.current = paginationInfo; 37812 } 37813 }, [shownData, isLoading, paginationInfo]); 37814 const [visibleEntries, setVisibleEntries] = (0, import_element115.useState)([]); 37815 const positionMapRef = (0, import_element115.useRef)(/* @__PURE__ */ new Map()); 37816 const allLoadedRecordsRef = (0, import_element115.useRef)([]); 37817 const prevViewParamsRef = (0, import_element115.useRef)({ 37818 search: void 0, 37819 filters: void 0, 37820 perPage: void 0 37821 }); 37822 const scrollDirectionRef = (0, import_element115.useRef)(void 0); 37823 const prevStartPositionRef = (0, import_element115.useRef)(void 0); 37824 const hasInitializedRef = (0, import_element115.useRef)(false); 37825 const allLoadedRecords = (0, import_element115.useMemo)(() => { 37826 if (view.startPosition !== void 0 && prevStartPositionRef.current !== void 0) { 37827 if (view.startPosition < prevStartPositionRef.current) { 37828 scrollDirectionRef.current = "up"; 37829 } else if (view.startPosition > prevStartPositionRef.current) { 37830 scrollDirectionRef.current = "down"; 37831 } 37832 } 37833 prevStartPositionRef.current = view.startPosition; 37834 const currentFiltersKey = JSON.stringify(view.filters ?? []); 37835 const prevFiltersKey = prevViewParamsRef.current.filters; 37836 const shouldReset = !hasInitializedRef.current || !view.infiniteScrollEnabled || view.search !== prevViewParamsRef.current.search || currentFiltersKey !== prevFiltersKey || view.perPage !== prevViewParamsRef.current.perPage; 37837 hasInitializedRef.current = true; 37838 prevViewParamsRef.current = { 37839 search: view.search, 37840 filters: currentFiltersKey, 37841 perPage: view.perPage 37842 }; 37843 if (shouldReset) { 37844 positionMapRef.current.clear(); 37845 scrollDirectionRef.current = void 0; 37846 const startPosition = view.search ? 1 : view.startPosition ?? 1; 37847 const records = shownData.map((record, index2) => { 37848 const position = startPosition + index2; 37849 positionMapRef.current.set(getItemId2(record), position); 37850 return { 37851 ...record, 37852 position 37853 }; 37854 }); 37855 allLoadedRecordsRef.current = records; 37856 return records; 37857 } 37858 const prev = allLoadedRecordsRef.current; 37859 const shownDataIds = new Set(shownData.map(getItemId2)); 37860 const scrollDirection = scrollDirectionRef.current; 37861 const basePosition = view.search ? 1 : view.startPosition ?? 1; 37862 const newRecords = shownData.map((record, index2) => { 37863 const itemId = getItemId2(record); 37864 const position = view.infiniteScrollEnabled ? basePosition + index2 : void 0; 37865 if (position !== void 0) { 37866 positionMapRef.current.set(itemId, position); 37867 } 37868 return { 37869 ...record, 37870 position 37871 }; 37872 }); 37873 if (newRecords.length === 0) { 37874 return prev; 37875 } 37876 const prevWithoutDuplicates = prev.filter( 37877 (record) => !shownDataIds.has(getItemId2(record)) 37878 ); 37879 const allRecords = scrollDirection === "up" ? [...newRecords, ...prevWithoutDuplicates] : [...prevWithoutDuplicates, ...newRecords]; 37880 allRecords.sort((a2, b2) => { 37881 const posA = a2.position; 37882 const posB = b2.position; 37883 return posA - posB; 37884 }); 37885 let result = allRecords; 37886 if (visibleEntries.length > 0) { 37887 const visibleMin = Math.min(...visibleEntries); 37888 const visibleMax = Math.max(...visibleEntries); 37889 const buffer = 20; 37890 const recordPositions = allRecords.map( 37891 (r3) => r3.position 37892 ); 37893 const minRecordPos = Math.min(...recordPositions); 37894 const maxRecordPos = Math.max(...recordPositions); 37895 const hasOverlap = !(maxRecordPos < visibleMin - buffer || minRecordPos > visibleMax + buffer); 37896 if (hasOverlap) { 37897 result = allRecords.filter((record) => { 37898 const itemId = getItemId2(record); 37899 const isSelected2 = selection?.includes(itemId); 37900 if (isSelected2) { 37901 return true; 37902 } 37903 const itemPosition = record.position; 37904 if (scrollDirection === "up") { 37905 return itemPosition <= visibleMax + buffer; 37906 } else if (scrollDirection === "down") { 37907 return itemPosition >= visibleMin - buffer; 37908 } 37909 return itemPosition >= visibleMin - buffer && itemPosition <= visibleMax + buffer; 37910 }); 37911 } 37912 } 37913 allLoadedRecordsRef.current = result; 37914 return result; 37915 }, [ 37916 shownData, 37917 view.search, 37918 view.filters, 37919 view.perPage, 37920 view.startPosition, 37921 view.infiniteScrollEnabled, 37922 visibleEntries, 37923 selection, 37924 getItemId2 37925 ]); 37926 if (!isInfiniteScrollEnabled) { 37927 const dataToReturn = isLoading && previousDataRef.current?.length ? previousDataRef.current : shownData; 37928 return { 37929 data: dataToReturn.map((item) => ({ 37930 ...item, 37931 position: void 0 37932 })), 37933 paginationInfo: isLoading && previousDataRef.current?.length ? previousPaginationInfoRef.current : paginationInfo, 37934 hasInitiallyLoaded, 37935 setVisibleEntries: void 0 37936 }; 37937 } 37938 return { 37939 data: allLoadedRecords, 37940 paginationInfo, 37941 hasInitiallyLoaded, 37942 setVisibleEntries 37943 }; 37944 } 37945 37946 // packages/dataviews/build-module/hooks/use-infinite-scroll.mjs 37947 var import_element116 = __toESM(require_element(), 1); 37948 var import_compose17 = __toESM(require_compose(), 1); 37949 function captureAnchorElement(container, anchorElementRef, direction) { 37950 const containerRect = container.getBoundingClientRect(); 37951 const centerY = containerRect.top + containerRect.height / 2; 37952 const items = Array.from(container.querySelectorAll("[aria-posinset]")); 37953 if (items.length === 0) { 37954 return false; 37955 } 37956 const bestAnchor = items.reduce((best, item) => { 37957 const itemRect = item.getBoundingClientRect(); 37958 const itemCenterY = itemRect.top + itemRect.height / 2; 37959 const distance = Math.abs(itemCenterY - centerY); 37960 const bestRect = best.getBoundingClientRect(); 37961 const bestCenterY = bestRect.top + bestRect.height / 2; 37962 const bestDistance = Math.abs(bestCenterY - centerY); 37963 return distance < bestDistance ? item : best; 37964 }); 37965 const posinset = Number(bestAnchor.getAttribute("aria-posinset")); 37966 const anchorRect = bestAnchor.getBoundingClientRect(); 37967 anchorElementRef.current = { 37968 posinset, 37969 viewportOffset: anchorRect.top - containerRect.top, 37970 scrollTop: container.scrollTop, 37971 direction 37972 }; 37973 return true; 37974 } 37975 function useInfiniteScroll({ 37976 view, 37977 onChangeView, 37978 isLoading, 37979 paginationInfo, 37980 containerRef, 37981 setVisibleEntries 37982 }) { 37983 const anchorElementRef = (0, import_element116.useRef)(null); 37984 const viewRef = (0, import_element116.useRef)(view); 37985 const isLoadingRef = (0, import_element116.useRef)(isLoading); 37986 const onChangeViewRef = (0, import_element116.useRef)(onChangeView); 37987 const totalItemsRef = (0, import_element116.useRef)(paginationInfo.totalItems); 37988 (0, import_element116.useLayoutEffect)(() => { 37989 viewRef.current = view; 37990 isLoadingRef.current = isLoading; 37991 onChangeViewRef.current = onChangeView; 37992 totalItemsRef.current = paginationInfo.totalItems; 37993 }, [view, isLoading, onChangeView, paginationInfo.totalItems]); 37994 const intersectionObserverCallback = (0, import_element116.useCallback)( 37995 (entries) => { 37996 if (!setVisibleEntries) { 37997 return; 37998 } 37999 setVisibleEntries((prev) => { 38000 const newVisibleEntries = new Set(prev); 38001 let hasChanged = false; 38002 entries.forEach((entry) => { 38003 const posInSet = Number( 38004 entry.target?.attributes?.getNamedItem( 38005 "aria-posinset" 38006 )?.value 38007 ); 38008 if (isNaN(posInSet)) { 38009 return; 38010 } 38011 if (entry.isIntersecting) { 38012 if (!newVisibleEntries.has(posInSet)) { 38013 newVisibleEntries.add(posInSet); 38014 hasChanged = true; 38015 } 38016 } else if (newVisibleEntries.has(posInSet)) { 38017 newVisibleEntries.delete(posInSet); 38018 hasChanged = true; 38019 } 38020 }); 38021 return hasChanged ? Array.from(newVisibleEntries).sort() : prev; 38022 }); 38023 }, 38024 [setVisibleEntries] 38025 ); 38026 (0, import_element116.useLayoutEffect)(() => { 38027 const container = containerRef.current; 38028 const anchor = anchorElementRef.current; 38029 if (!container || !view.infiniteScrollEnabled || !anchor || isLoading) { 38030 return; 38031 } 38032 const anchorElement = container.querySelector( 38033 `[aria-posinset="$anchor.posinset}"]` 38034 ); 38035 if (anchorElement) { 38036 const containerRect = container.getBoundingClientRect(); 38037 const anchorRect = anchorElement.getBoundingClientRect(); 38038 const currentOffset = anchorRect.top - containerRect.top; 38039 const scrollAdjustment = currentOffset - anchor.viewportOffset + (container.scrollTop - anchor.scrollTop); 38040 if (Math.abs(scrollAdjustment) > 1) { 38041 container.scrollTop += scrollAdjustment; 38042 } 38043 } 38044 anchorElementRef.current = null; 38045 }, [containerRef, isLoading, view.infiniteScrollEnabled]); 38046 const intersectionObserverRef = (0, import_element116.useRef)( 38047 null 38048 ); 38049 (0, import_element116.useEffect)(() => { 38050 if (!view.infiniteScrollEnabled || !intersectionObserverCallback) { 38051 if (intersectionObserverRef.current) { 38052 intersectionObserverRef.current.disconnect(); 38053 intersectionObserverRef.current = null; 38054 } 38055 return; 38056 } 38057 intersectionObserverRef.current = new IntersectionObserver( 38058 intersectionObserverCallback, 38059 { root: null, rootMargin: "0px", threshold: 0.1 } 38060 ); 38061 return () => { 38062 if (intersectionObserverRef.current) { 38063 intersectionObserverRef.current.disconnect(); 38064 intersectionObserverRef.current = null; 38065 } 38066 }; 38067 }, [view.infiniteScrollEnabled, intersectionObserverCallback]); 38068 (0, import_element116.useEffect)(() => { 38069 if (!view.infiniteScrollEnabled || !containerRef.current) { 38070 return; 38071 } 38072 let lastScrollTop = 0; 38073 const BOTTOM_THRESHOLD = 600; 38074 const TOP_THRESHOLD = 800; 38075 const handleScroll = (0, import_compose17.throttle)((event) => { 38076 const currentView = viewRef.current; 38077 const totalItems = totalItemsRef.current; 38078 const target = event.target; 38079 const scrollTop = target.scrollTop; 38080 const scrollHeight = target.scrollHeight; 38081 const clientHeight = target.clientHeight; 38082 const scrollDirection = scrollTop > lastScrollTop ? "down" : "up"; 38083 lastScrollTop = scrollTop; 38084 if (isLoadingRef.current) { 38085 return; 38086 } 38087 const currentStartPosition = currentView.startPosition || 1; 38088 const batchSize = currentView.perPage || 10; 38089 const currentEndPosition = Math.min( 38090 currentStartPosition + batchSize, 38091 totalItems 38092 ); 38093 if (scrollDirection === "down" && scrollTop + clientHeight >= scrollHeight - BOTTOM_THRESHOLD) { 38094 if (currentEndPosition < totalItems) { 38095 const newStartPosition = currentEndPosition; 38096 captureAnchorElement(target, anchorElementRef, "down"); 38097 onChangeViewRef.current({ 38098 ...currentView, 38099 startPosition: newStartPosition 38100 }); 38101 } 38102 } 38103 if (scrollDirection === "up" && scrollTop <= TOP_THRESHOLD) { 38104 if (currentStartPosition > 1) { 38105 const calculatedStartPosition = currentStartPosition - batchSize; 38106 const newStartPosition = calculatedStartPosition < 6 ? 1 : calculatedStartPosition; 38107 captureAnchorElement(target, anchorElementRef, "up"); 38108 onChangeViewRef.current({ 38109 ...currentView, 38110 startPosition: newStartPosition 38111 }); 38112 } 38113 } 38114 }, 50); 38115 const container = containerRef.current; 38116 container.addEventListener("scroll", handleScroll); 38117 return () => { 38118 container.removeEventListener("scroll", handleScroll); 38119 handleScroll.cancel(); 38120 }; 38121 }, [containerRef, view.infiniteScrollEnabled]); 38122 return { 38123 intersectionObserver: intersectionObserverRef.current 38124 }; 38125 } 38126 38127 // packages/dataviews/build-module/dataviews/index.mjs 38128 var import_jsx_runtime197 = __toESM(require_jsx_runtime(), 1); 38129 var defaultGetItemId = (item) => item.id; 38130 var defaultIsItemClickable = () => true; 38131 var EMPTY_ARRAY8 = []; 38132 var DEFAULT_LAYOUTS = { table: {}, grid: {}, list: {} }; 38133 var dataViewsLayouts = VIEW_LAYOUTS.filter( 38134 (viewLayout) => !viewLayout.isPicker 38135 ); 38136 function DefaultUI({ 38137 header, 38138 search = true, 38139 searchLabel = void 0 38140 }) { 38141 const { view } = (0, import_element117.useContext)(dataviews_context_default); 38142 const isInfiniteScroll = view.infiniteScrollEnabled; 38143 return /* @__PURE__ */ (0, import_jsx_runtime197.jsxs)(import_jsx_runtime197.Fragment, { children: [ 38144 /* @__PURE__ */ (0, import_jsx_runtime197.jsxs)( 38145 Stack, 38146 { 38147 direction: "row", 38148 align: "top", 38149 justify: "space-between", 38150 className: clsx_default("dataviews__view-actions", { 38151 "dataviews__view-actions--infinite-scroll": isInfiniteScroll 38152 }), 38153 gap: "xs", 38154 children: [ 38155 /* @__PURE__ */ (0, import_jsx_runtime197.jsxs)( 38156 Stack, 38157 { 38158 direction: "row", 38159 justify: "start", 38160 gap: "sm", 38161 className: "dataviews__search", 38162 children: [ 38163 search && /* @__PURE__ */ (0, import_jsx_runtime197.jsx)(dataviews_search_default, { label: searchLabel }), 38164 /* @__PURE__ */ (0, import_jsx_runtime197.jsx)(toggle_default, {}) 38165 ] 38166 } 38167 ), 38168 /* @__PURE__ */ (0, import_jsx_runtime197.jsxs)(Stack, { direction: "row", gap: "xs", style: { flexShrink: 0 }, children: [ 38169 /* @__PURE__ */ (0, import_jsx_runtime197.jsx)(dataviews_view_config_default, {}), 38170 header 38171 ] }) 38172 ] 38173 } 38174 ), 38175 /* @__PURE__ */ (0, import_jsx_runtime197.jsx)(filters_toggled_default, { className: "dataviews-filters__container" }), 38176 /* @__PURE__ */ (0, import_jsx_runtime197.jsx)(DataViewsLayout, {}), 38177 /* @__PURE__ */ (0, import_jsx_runtime197.jsx)(DataViewsFooter, {}) 38178 ] }); 38179 } 38180 function DataViews({ 38181 view, 38182 onChangeView, 38183 fields: fields2, 38184 search = true, 38185 searchLabel = void 0, 38186 actions = EMPTY_ARRAY8, 38187 data, 38188 getItemId: getItemId2 = defaultGetItemId, 38189 getItemLevel: getItemLevel2, 38190 isLoading = false, 38191 paginationInfo, 38192 defaultLayouts: defaultLayoutsProperty = DEFAULT_LAYOUTS, 38193 selection: selectionProperty, 38194 onChangeSelection, 38195 onClickItem, 38196 renderItemLink, 38197 isItemClickable = defaultIsItemClickable, 38198 header, 38199 children, 38200 config: config2 = { perPageSizes: [10, 20, 50, 100] }, 38201 empty, 38202 onReset 38203 }) { 38204 const [selectionState, setSelectionState] = (0, import_element117.useState)([]); 38205 const isUncontrolled = selectionProperty === void 0 || onChangeSelection === void 0; 38206 const selection = isUncontrolled ? selectionState : selectionProperty; 38207 const { 38208 data: displayData, 38209 paginationInfo: displayPaginationInfo, 38210 hasInitiallyLoaded, 38211 setVisibleEntries 38212 } = useData({ 38213 view, 38214 data, 38215 getItemId: getItemId2, 38216 isLoading, 38217 selection, 38218 paginationInfo 38219 }); 38220 const containerRef = (0, import_element117.useRef)(null); 38221 const [containerWidth, setContainerWidth] = (0, import_element117.useState)(0); 38222 const resizeObserverRef = (0, import_compose18.useResizeObserver)( 38223 (resizeObserverEntries) => { 38224 setContainerWidth( 38225 resizeObserverEntries[0].borderBoxSize[0].inlineSize 38226 ); 38227 }, 38228 { box: "border-box" } 38229 ); 38230 const [openedFilter, setOpenedFilter] = (0, import_element117.useState)(null); 38231 function setSelectionWithChange(value) { 38232 const newValue = typeof value === "function" ? value(selection) : value; 38233 if (isUncontrolled) { 38234 setSelectionState(newValue); 38235 } 38236 if (onChangeSelection) { 38237 onChangeSelection(newValue); 38238 } 38239 } 38240 const _fields = (0, import_element117.useMemo)(() => normalizeFields(fields2), [fields2]); 38241 const _selection = (0, import_element117.useMemo)(() => { 38242 if (view.infiniteScrollEnabled) { 38243 return selection; 38244 } 38245 return selection.filter( 38246 (id) => data.some((item) => getItemId2(item) === id) 38247 ); 38248 }, [selection, data, getItemId2, view.infiniteScrollEnabled]); 38249 const filters = use_filters_default(_fields, view); 38250 const hasPrimaryOrLockedFilters = (0, import_element117.useMemo)( 38251 () => (filters || []).some( 38252 (filter) => filter.isPrimary || filter.isLocked 38253 ), 38254 [filters] 38255 ); 38256 const [isShowingFilter, setIsShowingFilter] = (0, import_element117.useState)( 38257 hasPrimaryOrLockedFilters 38258 ); 38259 const { intersectionObserver } = useInfiniteScroll({ 38260 view, 38261 onChangeView, 38262 isLoading, 38263 paginationInfo, 38264 containerRef, 38265 setVisibleEntries 38266 }); 38267 (0, import_element117.useEffect)(() => { 38268 if (hasPrimaryOrLockedFilters && !isShowingFilter) { 38269 setIsShowingFilter(true); 38270 } 38271 }, [hasPrimaryOrLockedFilters, isShowingFilter]); 38272 const defaultLayouts2 = (0, import_element117.useMemo)( 38273 () => Object.fromEntries( 38274 Object.entries(defaultLayoutsProperty).filter(([layoutType]) => { 38275 return dataViewsLayouts.some( 38276 (viewLayout) => viewLayout.type === layoutType 38277 ); 38278 }).map(([key, value]) => [ 38279 key, 38280 value === true ? {} : value 38281 ]) 38282 ), 38283 [defaultLayoutsProperty] 38284 ); 38285 if (!defaultLayouts2[view.type]) { 38286 return null; 38287 } 38288 return /* @__PURE__ */ (0, import_jsx_runtime197.jsx)( 38289 dataviews_context_default.Provider, 38290 { 38291 value: { 38292 view, 38293 onChangeView, 38294 fields: _fields, 38295 actions, 38296 data: displayData, 38297 isLoading, 38298 paginationInfo: displayPaginationInfo, 38299 selection: _selection, 38300 onChangeSelection: setSelectionWithChange, 38301 openedFilter, 38302 setOpenedFilter, 38303 getItemId: getItemId2, 38304 getItemLevel: getItemLevel2, 38305 isItemClickable, 38306 onClickItem, 38307 renderItemLink, 38308 containerWidth, 38309 containerRef, 38310 resizeObserverRef, 38311 defaultLayouts: defaultLayouts2, 38312 filters, 38313 isShowingFilter, 38314 setIsShowingFilter, 38315 config: config2, 38316 empty, 38317 hasInitiallyLoaded, 38318 onReset, 38319 intersectionObserver 38320 }, 38321 children: /* @__PURE__ */ (0, import_jsx_runtime197.jsx)("div", { className: "dataviews-wrapper", children: children ?? /* @__PURE__ */ (0, import_jsx_runtime197.jsx)( 38322 DefaultUI, 38323 { 38324 header, 38325 search, 38326 searchLabel 38327 } 38328 ) }) 38329 } 38330 ); 38331 } 38332 var DataViewsSubComponents = DataViews; 38333 DataViewsSubComponents.BulkActionToolbar = BulkActionsFooter; 38334 DataViewsSubComponents.Filters = filters_default; 38335 DataViewsSubComponents.FiltersToggled = filters_toggled_default; 38336 DataViewsSubComponents.FiltersToggle = toggle_default; 38337 DataViewsSubComponents.Layout = DataViewsLayout; 38338 DataViewsSubComponents.LayoutSwitcher = ViewTypeMenu; 38339 DataViewsSubComponents.Pagination = DataViewsPagination; 38340 DataViewsSubComponents.Search = dataviews_search_default; 38341 DataViewsSubComponents.ViewConfig = DataviewsViewConfigDropdown; 38342 DataViewsSubComponents.Footer = DataViewsFooter; 38343 var dataviews_default = DataViewsSubComponents; 38344 38345 // packages/dataviews/build-module/dataform/index.mjs 38346 var import_element129 = __toESM(require_element(), 1); 38347 38348 // packages/dataviews/build-module/components/dataform-context/index.mjs 38349 var import_element118 = __toESM(require_element(), 1); 38350 var import_jsx_runtime198 = __toESM(require_jsx_runtime(), 1); 38351 var DataFormContext = (0, import_element118.createContext)({ 38352 fields: [] 38353 }); 38354 DataFormContext.displayName = "DataFormContext"; 38355 function DataFormProvider({ 38356 fields: fields2, 38357 children 38358 }) { 38359 return /* @__PURE__ */ (0, import_jsx_runtime198.jsx)(DataFormContext.Provider, { value: { fields: fields2 }, children }); 38360 } 38361 var dataform_context_default = DataFormContext; 38362 38363 // packages/dataviews/build-module/components/dataform-layouts/data-form-layout.mjs 38364 var import_element128 = __toESM(require_element(), 1); 38365 38366 // packages/dataviews/build-module/components/dataform-layouts/regular/index.mjs 38367 var import_element119 = __toESM(require_element(), 1); 38368 var import_components66 = __toESM(require_components(), 1); 38369 38370 // packages/dataviews/build-module/components/dataform-layouts/normalize-form.mjs 38371 var import_i18n67 = __toESM(require_i18n(), 1); 38372 var DEFAULT_LAYOUT = { 38373 type: "regular", 38374 labelPosition: "top" 38375 }; 38376 var normalizeCardSummaryField = (sum) => { 38377 if (typeof sum === "string") { 38378 return [{ id: sum, visibility: "when-collapsed" }]; 38379 } 38380 return sum.map((item) => { 38381 if (typeof item === "string") { 38382 return { id: item, visibility: "when-collapsed" }; 38383 } 38384 return { id: item.id, visibility: item.visibility }; 38385 }); 38386 }; 38387 function normalizeLayout(layout) { 38388 let normalizedLayout = DEFAULT_LAYOUT; 38389 if (layout?.type === "regular") { 38390 normalizedLayout = { 38391 type: "regular", 38392 labelPosition: layout?.labelPosition ?? "top" 38393 }; 38394 } else if (layout?.type === "panel") { 38395 const summary = layout.summary ?? []; 38396 const normalizedSummary = Array.isArray(summary) ? summary : [summary]; 38397 const openAs = layout?.openAs; 38398 let normalizedOpenAs; 38399 if (typeof openAs === "object" && openAs.type === "modal") { 38400 normalizedOpenAs = { 38401 type: "modal", 38402 applyLabel: openAs.applyLabel?.trim() || (0, import_i18n67.__)("Apply"), 38403 cancelLabel: openAs.cancelLabel?.trim() || (0, import_i18n67.__)("Cancel") 38404 }; 38405 } else if (openAs === "modal") { 38406 normalizedOpenAs = { 38407 type: "modal", 38408 applyLabel: (0, import_i18n67.__)("Apply"), 38409 cancelLabel: (0, import_i18n67.__)("Cancel") 38410 }; 38411 } else { 38412 normalizedOpenAs = { type: "dropdown" }; 38413 } 38414 normalizedLayout = { 38415 type: "panel", 38416 labelPosition: layout?.labelPosition ?? "side", 38417 openAs: normalizedOpenAs, 38418 summary: normalizedSummary, 38419 editVisibility: layout?.editVisibility ?? "on-hover" 38420 }; 38421 } else if (layout?.type === "card") { 38422 if (layout.withHeader === false) { 38423 normalizedLayout = { 38424 type: "card", 38425 withHeader: false, 38426 isOpened: true, 38427 summary: [], 38428 isCollapsible: false 38429 }; 38430 } else { 38431 const summary = layout.summary ?? []; 38432 normalizedLayout = { 38433 type: "card", 38434 withHeader: true, 38435 isOpened: typeof layout.isOpened === "boolean" ? layout.isOpened : true, 38436 summary: normalizeCardSummaryField(summary), 38437 isCollapsible: layout.isCollapsible === void 0 ? true : layout.isCollapsible 38438 }; 38439 } 38440 } else if (layout?.type === "row") { 38441 normalizedLayout = { 38442 type: "row", 38443 alignment: layout?.alignment ?? "center", 38444 styles: layout?.styles ?? {} 38445 }; 38446 } else if (layout?.type === "details") { 38447 normalizedLayout = { 38448 type: "details", 38449 summary: layout?.summary ?? "" 38450 }; 38451 } 38452 return normalizedLayout; 38453 } 38454 function normalizeForm(form2) { 38455 const normalizedFormLayout = normalizeLayout(form2?.layout); 38456 const normalizedFields = (form2.fields ?? []).map( 38457 (field) => { 38458 if (typeof field === "string") { 38459 return { 38460 id: field, 38461 layout: normalizedFormLayout 38462 }; 38463 } 38464 const fieldLayout = field.layout ? normalizeLayout(field.layout) : normalizedFormLayout; 38465 return { 38466 id: field.id, 38467 layout: fieldLayout, 38468 ...!!field.label && { label: field.label }, 38469 ...!!field.description && { 38470 description: field.description 38471 }, 38472 ..."children" in field && Array.isArray(field.children) && { 38473 children: normalizeForm({ 38474 fields: field.children, 38475 layout: DEFAULT_LAYOUT 38476 }).fields 38477 } 38478 }; 38479 } 38480 ); 38481 return { 38482 layout: normalizedFormLayout, 38483 fields: normalizedFields 38484 }; 38485 } 38486 var normalize_form_default = normalizeForm; 38487 38488 // packages/dataviews/build-module/components/dataform-layouts/regular/index.mjs 38489 var import_jsx_runtime199 = __toESM(require_jsx_runtime(), 1); 38490 function Header4({ title }) { 38491 return /* @__PURE__ */ (0, import_jsx_runtime199.jsx)( 38492 Stack, 38493 { 38494 direction: "column", 38495 className: "dataforms-layouts-regular__header", 38496 gap: "lg", 38497 children: /* @__PURE__ */ (0, import_jsx_runtime199.jsx)(Stack, { direction: "row", align: "center", children: /* @__PURE__ */ (0, import_jsx_runtime199.jsx)(import_components66.__experimentalHeading, { level: 2, size: 13, children: title }) }) 38498 } 38499 ); 38500 } 38501 function FormRegularField({ 38502 data, 38503 field, 38504 onChange, 38505 hideLabelFromVision, 38506 markWhenOptional, 38507 validity 38508 }) { 38509 const { fields: fields2 } = (0, import_element119.useContext)(dataform_context_default); 38510 const layout = field.layout; 38511 const form2 = (0, import_element119.useMemo)( 38512 () => ({ 38513 layout: DEFAULT_LAYOUT, 38514 fields: !!field.children ? field.children : [] 38515 }), 38516 [field] 38517 ); 38518 if (!!field.children) { 38519 return /* @__PURE__ */ (0, import_jsx_runtime199.jsxs)(import_jsx_runtime199.Fragment, { children: [ 38520 !hideLabelFromVision && field.label && /* @__PURE__ */ (0, import_jsx_runtime199.jsx)(Header4, { title: field.label }), 38521 /* @__PURE__ */ (0, import_jsx_runtime199.jsx)( 38522 DataFormLayout, 38523 { 38524 data, 38525 form: form2, 38526 onChange, 38527 validity: validity?.children 38528 } 38529 ) 38530 ] }); 38531 } 38532 const labelPosition = layout.labelPosition; 38533 const fieldDefinition = fields2.find( 38534 (fieldDef) => fieldDef.id === field.id 38535 ); 38536 if (!fieldDefinition || !fieldDefinition.Edit) { 38537 return null; 38538 } 38539 if (labelPosition === "side") { 38540 return /* @__PURE__ */ (0, import_jsx_runtime199.jsxs)( 38541 Stack, 38542 { 38543 direction: "row", 38544 className: "dataforms-layouts-regular__field", 38545 gap: "sm", 38546 children: [ 38547 /* @__PURE__ */ (0, import_jsx_runtime199.jsx)( 38548 "div", 38549 { 38550 className: clsx_default( 38551 "dataforms-layouts-regular__field-label", 38552 `dataforms-layouts-regular__field-label--label-position-$labelPosition}` 38553 ), 38554 children: /* @__PURE__ */ (0, import_jsx_runtime199.jsx)(import_components66.BaseControl.VisualLabel, { children: fieldDefinition.label }) 38555 } 38556 ), 38557 /* @__PURE__ */ (0, import_jsx_runtime199.jsx)("div", { className: "dataforms-layouts-regular__field-control", children: fieldDefinition.readOnly === true ? /* @__PURE__ */ (0, import_jsx_runtime199.jsx)( 38558 fieldDefinition.render, 38559 { 38560 item: data, 38561 field: fieldDefinition 38562 } 38563 ) : /* @__PURE__ */ (0, import_jsx_runtime199.jsx)( 38564 fieldDefinition.Edit, 38565 { 38566 data, 38567 field: fieldDefinition, 38568 onChange, 38569 hideLabelFromVision: true, 38570 markWhenOptional, 38571 validity 38572 }, 38573 fieldDefinition.id 38574 ) }) 38575 ] 38576 } 38577 ); 38578 } 38579 return /* @__PURE__ */ (0, import_jsx_runtime199.jsx)("div", { className: "dataforms-layouts-regular__field", children: fieldDefinition.readOnly === true ? /* @__PURE__ */ (0, import_jsx_runtime199.jsx)(import_jsx_runtime199.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime199.jsxs)(import_jsx_runtime199.Fragment, { children: [ 38580 !hideLabelFromVision && labelPosition !== "none" && /* @__PURE__ */ (0, import_jsx_runtime199.jsx)(import_components66.BaseControl.VisualLabel, { children: fieldDefinition.label }), 38581 /* @__PURE__ */ (0, import_jsx_runtime199.jsx)( 38582 fieldDefinition.render, 38583 { 38584 item: data, 38585 field: fieldDefinition 38586 } 38587 ) 38588 ] }) }) : /* @__PURE__ */ (0, import_jsx_runtime199.jsx)( 38589 fieldDefinition.Edit, 38590 { 38591 data, 38592 field: fieldDefinition, 38593 onChange, 38594 hideLabelFromVision: labelPosition === "none" ? true : hideLabelFromVision, 38595 markWhenOptional, 38596 validity 38597 } 38598 ) }); 38599 } 38600 38601 // packages/dataviews/build-module/components/dataform-layouts/panel/modal.mjs 38602 var import_deepmerge3 = __toESM(require_cjs(), 1); 38603 var import_components69 = __toESM(require_components(), 1); 38604 var import_element124 = __toESM(require_element(), 1); 38605 var import_compose20 = __toESM(require_compose(), 1); 38606 38607 // packages/dataviews/build-module/components/dataform-layouts/panel/summary-button.mjs 38608 var import_components68 = __toESM(require_components(), 1); 38609 var import_i18n68 = __toESM(require_i18n(), 1); 38610 var import_compose19 = __toESM(require_compose(), 1); 38611 var import_element120 = __toESM(require_element(), 1); 38612 38613 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/get-label-classname.mjs 38614 function getLabelClassName(labelPosition, showError) { 38615 return clsx_default( 38616 "dataforms-layouts-panel__field-label", 38617 `dataforms-layouts-panel__field-label--label-position-$labelPosition}`, 38618 { "has-error": showError } 38619 ); 38620 } 38621 var get_label_classname_default = getLabelClassName; 38622 38623 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/get-label-content.mjs 38624 var import_components67 = __toESM(require_components(), 1); 38625 var import_jsx_runtime200 = __toESM(require_jsx_runtime(), 1); 38626 function getLabelContent(showError, errorMessage, fieldLabel) { 38627 return showError ? /* @__PURE__ */ (0, import_jsx_runtime200.jsxs)(tooltip_exports.Root, { children: [ 38628 /* @__PURE__ */ (0, import_jsx_runtime200.jsx)( 38629 tooltip_exports.Trigger, 38630 { 38631 render: /* @__PURE__ */ (0, import_jsx_runtime200.jsxs)("span", { className: "dataforms-layouts-panel__field-label-error-content", children: [ 38632 /* @__PURE__ */ (0, import_jsx_runtime200.jsx)(import_components67.Icon, { icon: error_default, size: 16 }), 38633 /* @__PURE__ */ (0, import_jsx_runtime200.jsxs)(VisuallyHidden, { children: [ 38634 errorMessage, 38635 ": " 38636 ] }), 38637 fieldLabel 38638 ] }) 38639 } 38640 ), 38641 /* @__PURE__ */ (0, import_jsx_runtime200.jsx)(tooltip_exports.Popup, { children: errorMessage }) 38642 ] }) : fieldLabel; 38643 } 38644 var get_label_content_default = getLabelContent; 38645 38646 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/get-first-validation-error.mjs 38647 function getFirstValidationError(validity) { 38648 if (!validity) { 38649 return void 0; 38650 } 38651 const validityRules = Object.keys(validity).filter( 38652 (key) => key !== "children" 38653 ); 38654 for (const key of validityRules) { 38655 const rule = validity[key]; 38656 if (rule === void 0) { 38657 continue; 38658 } 38659 if (rule.type === "invalid") { 38660 if (rule.message) { 38661 return rule.message; 38662 } 38663 if (key === "required") { 38664 return "A required field is empty"; 38665 } 38666 return "Unidentified validation error"; 38667 } 38668 } 38669 if (validity.children) { 38670 for (const childValidity of Object.values(validity.children)) { 38671 const childError = getFirstValidationError(childValidity); 38672 if (childError) { 38673 return childError; 38674 } 38675 } 38676 } 38677 return void 0; 38678 } 38679 var get_first_validation_error_default = getFirstValidationError; 38680 38681 // packages/dataviews/build-module/components/dataform-layouts/panel/summary-button.mjs 38682 var import_jsx_runtime201 = __toESM(require_jsx_runtime(), 1); 38683 function SummaryButton({ 38684 data, 38685 field, 38686 fieldLabel, 38687 summaryFields, 38688 validity, 38689 touched, 38690 disabled: disabled2, 38691 isOpen, 38692 onClick 38693 }) { 38694 const { labelPosition, editVisibility } = field.layout; 38695 const errorMessage = get_first_validation_error_default(validity); 38696 const showError = touched && !!errorMessage; 38697 const labelClassName = get_label_classname_default(labelPosition, showError); 38698 const labelContent = get_label_content_default(showError, errorMessage, fieldLabel); 38699 const className = clsx_default( 38700 "dataforms-layouts-panel__field-trigger", 38701 `dataforms-layouts-panel__field-trigger--label-$labelPosition}`, 38702 { 38703 "is-disabled": disabled2, 38704 "dataforms-layouts-panel__field-trigger--edit-always": editVisibility === "always" 38705 } 38706 ); 38707 const controlId = (0, import_compose19.useInstanceId)( 38708 SummaryButton, 38709 "dataforms-layouts-panel__field-control" 38710 ); 38711 const ariaLabel = showError ? (0, import_i18n68.sprintf)( 38712 // translators: %s: Field name. 38713 (0, import_i18n68._x)("Edit %s (has errors)", "field"), 38714 fieldLabel || "" 38715 ) : (0, import_i18n68.sprintf)( 38716 // translators: %s: Field name. 38717 (0, import_i18n68._x)("Edit %s", "field"), 38718 fieldLabel || "" 38719 ); 38720 const rowRef = (0, import_element120.useRef)(null); 38721 const editButtonRef = (0, import_element120.useRef)(null); 38722 const handleRowClick = (event) => { 38723 if (!isOpen && event.detail < 2 && !editButtonRef.current?.contains(event.target) && rowRef.current?.ownerDocument.defaultView?.getSelection()?.toString()) { 38724 return; 38725 } 38726 onClick(); 38727 }; 38728 const handleKeyDown = (event) => { 38729 if (event.target === event.currentTarget && (event.key === "Enter" || event.key === " ")) { 38730 event.preventDefault(); 38731 onClick(); 38732 } 38733 }; 38734 return /* @__PURE__ */ (0, import_jsx_runtime201.jsxs)( 38735 "div", 38736 { 38737 ref: rowRef, 38738 className, 38739 onClick: !disabled2 ? handleRowClick : void 0, 38740 onKeyDown: !disabled2 ? handleKeyDown : void 0, 38741 children: [ 38742 labelPosition !== "none" && /* @__PURE__ */ (0, import_jsx_runtime201.jsx)("span", { className: labelClassName, children: labelContent }), 38743 labelPosition === "none" && showError && /* @__PURE__ */ (0, import_jsx_runtime201.jsxs)(tooltip_exports.Root, { children: [ 38744 /* @__PURE__ */ (0, import_jsx_runtime201.jsx)( 38745 tooltip_exports.Trigger, 38746 { 38747 render: /* @__PURE__ */ (0, import_jsx_runtime201.jsx)( 38748 "span", 38749 { 38750 className: "dataforms-layouts-panel__field-label-error-content", 38751 role: "img", 38752 "aria-label": errorMessage, 38753 children: /* @__PURE__ */ (0, import_jsx_runtime201.jsx)(import_components68.Icon, { icon: error_default, size: 16 }) 38754 } 38755 ) 38756 } 38757 ), 38758 /* @__PURE__ */ (0, import_jsx_runtime201.jsx)(tooltip_exports.Popup, { children: errorMessage }) 38759 ] }), 38760 /* @__PURE__ */ (0, import_jsx_runtime201.jsx)( 38761 "span", 38762 { 38763 id: `$controlId}`, 38764 className: "dataforms-layouts-panel__field-control", 38765 children: summaryFields.length > 1 ? /* @__PURE__ */ (0, import_jsx_runtime201.jsx)( 38766 "span", 38767 { 38768 style: { 38769 display: "flex", 38770 flexDirection: "column", 38771 alignItems: "flex-start", 38772 width: "100%", 38773 gap: "2px" 38774 }, 38775 children: summaryFields.map((summaryField) => /* @__PURE__ */ (0, import_jsx_runtime201.jsx)( 38776 "span", 38777 { 38778 style: { width: "100%" }, 38779 children: /* @__PURE__ */ (0, import_jsx_runtime201.jsx)( 38780 summaryField.render, 38781 { 38782 item: data, 38783 field: summaryField 38784 } 38785 ) 38786 }, 38787 summaryField.id 38788 )) 38789 } 38790 ) : summaryFields.map((summaryField) => /* @__PURE__ */ (0, import_jsx_runtime201.jsx)( 38791 summaryField.render, 38792 { 38793 item: data, 38794 field: summaryField 38795 }, 38796 summaryField.id 38797 )) 38798 } 38799 ), 38800 !disabled2 && /* @__PURE__ */ (0, import_jsx_runtime201.jsx)( 38801 import_components68.Button, 38802 { 38803 ref: editButtonRef, 38804 className: "dataforms-layouts-panel__field-trigger-icon", 38805 label: ariaLabel, 38806 icon: pencil_default, 38807 size: "small", 38808 "aria-expanded": isOpen, 38809 "aria-haspopup": "dialog", 38810 "aria-describedby": `$controlId}` 38811 } 38812 ) 38813 ] 38814 } 38815 ); 38816 } 38817 38818 // packages/dataviews/build-module/hooks/use-form-validity.mjs 38819 var import_deepmerge2 = __toESM(require_cjs(), 1); 38820 var import_es63 = __toESM(require_es6(), 1); 38821 var import_element121 = __toESM(require_element(), 1); 38822 var import_i18n69 = __toESM(require_i18n(), 1); 38823 function isFormValid(formValidity) { 38824 if (!formValidity) { 38825 return true; 38826 } 38827 return Object.values(formValidity).every((fieldValidation) => { 38828 return Object.entries(fieldValidation).every( 38829 ([key, validation]) => { 38830 if (key === "children" && validation && typeof validation === "object") { 38831 return isFormValid(validation); 38832 } 38833 return validation.type !== "invalid" && validation.type !== "validating"; 38834 } 38835 ); 38836 }); 38837 } 38838 function getFormFieldsToValidate(form2, fields2) { 38839 const normalizedForm = normalize_form_default(form2); 38840 if (normalizedForm.fields.length === 0) { 38841 return []; 38842 } 38843 const fieldsMap = /* @__PURE__ */ new Map(); 38844 fields2.forEach((field) => { 38845 fieldsMap.set(field.id, field); 38846 }); 38847 function processFormField(formField) { 38848 if ("children" in formField && Array.isArray(formField.children)) { 38849 const processedChildren = formField.children.map(processFormField).filter((child) => child !== null); 38850 if (processedChildren.length === 0) { 38851 return null; 38852 } 38853 const fieldDef2 = fieldsMap.get(formField.id); 38854 if (fieldDef2) { 38855 const [normalizedField2] = normalizeFields([ 38856 fieldDef2 38857 ]); 38858 return { 38859 id: formField.id, 38860 children: processedChildren, 38861 field: normalizedField2 38862 }; 38863 } 38864 return { 38865 id: formField.id, 38866 children: processedChildren 38867 }; 38868 } 38869 const fieldDef = fieldsMap.get(formField.id); 38870 if (!fieldDef) { 38871 return null; 38872 } 38873 const [normalizedField] = normalizeFields([fieldDef]); 38874 return { 38875 id: formField.id, 38876 children: [], 38877 field: normalizedField 38878 }; 38879 } 38880 const toValidate = normalizedForm.fields.map(processFormField).filter((field) => field !== null); 38881 return toValidate; 38882 } 38883 function setValidityAtPath(formValidity, fieldValidity, path) { 38884 if (!formValidity) { 38885 formValidity = {}; 38886 } 38887 if (path.length === 0) { 38888 return formValidity; 38889 } 38890 const result = { ...formValidity }; 38891 let current = result; 38892 for (let i2 = 0; i2 < path.length - 1; i2++) { 38893 const segment = path[i2]; 38894 if (!current[segment]) { 38895 current[segment] = {}; 38896 } 38897 current[segment] = { ...current[segment] }; 38898 current = current[segment]; 38899 } 38900 const finalKey = path[path.length - 1]; 38901 current[finalKey] = { 38902 ...current[finalKey] || {}, 38903 ...fieldValidity 38904 }; 38905 return result; 38906 } 38907 function removeValidationProperty(formValidity, path, property) { 38908 if (!formValidity || path.length === 0) { 38909 return formValidity; 38910 } 38911 const result = { ...formValidity }; 38912 let current = result; 38913 for (let i2 = 0; i2 < path.length - 1; i2++) { 38914 const segment = path[i2]; 38915 if (!current[segment]) { 38916 return formValidity; 38917 } 38918 current[segment] = { ...current[segment] }; 38919 current = current[segment]; 38920 } 38921 const finalKey = path[path.length - 1]; 38922 if (!current[finalKey]) { 38923 return formValidity; 38924 } 38925 const fieldValidity = { ...current[finalKey] }; 38926 delete fieldValidity[property]; 38927 if (Object.keys(fieldValidity).length === 0) { 38928 delete current[finalKey]; 38929 } else { 38930 current[finalKey] = fieldValidity; 38931 } 38932 if (Object.keys(result).length === 0) { 38933 return void 0; 38934 } 38935 return result; 38936 } 38937 function handleElementsValidationAsync(promise, formField, promiseHandler) { 38938 const { elementsCounterRef, setFormValidity, path, item } = promiseHandler; 38939 const currentToken = (elementsCounterRef.current[formField.id] || 0) + 1; 38940 elementsCounterRef.current[formField.id] = currentToken; 38941 promise.then((result) => { 38942 if (currentToken !== elementsCounterRef.current[formField.id]) { 38943 return; 38944 } 38945 if (!Array.isArray(result)) { 38946 setFormValidity((prev) => { 38947 const newFormValidity = setValidityAtPath( 38948 prev, 38949 { 38950 elements: { 38951 type: "invalid", 38952 message: (0, import_i18n69.__)("Could not validate elements.") 38953 } 38954 }, 38955 [...path, formField.id] 38956 ); 38957 return newFormValidity; 38958 }); 38959 return; 38960 } 38961 if (formField.field?.isValid.elements && !formField.field.isValid.elements.validate(item, { 38962 ...formField.field, 38963 elements: result 38964 })) { 38965 setFormValidity((prev) => { 38966 const newFormValidity = setValidityAtPath( 38967 prev, 38968 { 38969 elements: { 38970 type: "invalid", 38971 message: (0, import_i18n69.__)( 38972 "Value must be one of the elements." 38973 ) 38974 } 38975 }, 38976 [...path, formField.id] 38977 ); 38978 return newFormValidity; 38979 }); 38980 } else { 38981 setFormValidity((prev) => { 38982 return removeValidationProperty( 38983 prev, 38984 [...path, formField.id], 38985 "elements" 38986 ); 38987 }); 38988 } 38989 }).catch((error2) => { 38990 if (currentToken !== elementsCounterRef.current[formField.id]) { 38991 return; 38992 } 38993 let errorMessage; 38994 if (error2 instanceof Error) { 38995 errorMessage = error2.message; 38996 } else { 38997 errorMessage = String(error2) || (0, import_i18n69.__)( 38998 "Unknown error when running elements validation asynchronously." 38999 ); 39000 } 39001 setFormValidity((prev) => { 39002 const newFormValidity = setValidityAtPath( 39003 prev, 39004 { 39005 elements: { 39006 type: "invalid", 39007 message: errorMessage 39008 } 39009 }, 39010 [...path, formField.id] 39011 ); 39012 return newFormValidity; 39013 }); 39014 }); 39015 } 39016 function handleCustomValidationAsync(promise, formField, promiseHandler) { 39017 const { customCounterRef, setFormValidity, path } = promiseHandler; 39018 const currentToken = (customCounterRef.current[formField.id] || 0) + 1; 39019 customCounterRef.current[formField.id] = currentToken; 39020 promise.then((result) => { 39021 if (currentToken !== customCounterRef.current[formField.id]) { 39022 return; 39023 } 39024 if (result === null) { 39025 setFormValidity((prev) => { 39026 return removeValidationProperty( 39027 prev, 39028 [...path, formField.id], 39029 "custom" 39030 ); 39031 }); 39032 return; 39033 } 39034 if (typeof result === "string") { 39035 setFormValidity((prev) => { 39036 const newFormValidity = setValidityAtPath( 39037 prev, 39038 { 39039 custom: { 39040 type: "invalid", 39041 message: result 39042 } 39043 }, 39044 [...path, formField.id] 39045 ); 39046 return newFormValidity; 39047 }); 39048 return; 39049 } 39050 setFormValidity((prev) => { 39051 const newFormValidity = setValidityAtPath( 39052 prev, 39053 { 39054 custom: { 39055 type: "invalid", 39056 message: (0, import_i18n69.__)("Validation could not be processed.") 39057 } 39058 }, 39059 [...path, formField.id] 39060 ); 39061 return newFormValidity; 39062 }); 39063 }).catch((error2) => { 39064 if (currentToken !== customCounterRef.current[formField.id]) { 39065 return; 39066 } 39067 let errorMessage; 39068 if (error2 instanceof Error) { 39069 errorMessage = error2.message; 39070 } else { 39071 errorMessage = String(error2) || (0, import_i18n69.__)( 39072 "Unknown error when running custom validation asynchronously." 39073 ); 39074 } 39075 setFormValidity((prev) => { 39076 const newFormValidity = setValidityAtPath( 39077 prev, 39078 { 39079 custom: { 39080 type: "invalid", 39081 message: errorMessage 39082 } 39083 }, 39084 [...path, formField.id] 39085 ); 39086 return newFormValidity; 39087 }); 39088 }); 39089 } 39090 function validateFormField(item, formField, promiseHandler) { 39091 if (formField.field?.isValid.required && !formField.field.isValid.required.validate(item, formField.field)) { 39092 return { 39093 required: { type: "invalid" } 39094 }; 39095 } 39096 if (formField.field?.isValid.pattern && !formField.field.isValid.pattern.validate(item, formField.field)) { 39097 return { 39098 pattern: { 39099 type: "invalid", 39100 message: (0, import_i18n69.__)("Value does not match the required pattern.") 39101 } 39102 }; 39103 } 39104 if (formField.field?.isValid.min && !formField.field.isValid.min.validate(item, formField.field)) { 39105 return { 39106 min: { 39107 type: "invalid", 39108 message: (0, import_i18n69.__)("Value is below the minimum.") 39109 } 39110 }; 39111 } 39112 if (formField.field?.isValid.max && !formField.field.isValid.max.validate(item, formField.field)) { 39113 return { 39114 max: { 39115 type: "invalid", 39116 message: (0, import_i18n69.__)("Value is above the maximum.") 39117 } 39118 }; 39119 } 39120 if (formField.field?.isValid.minLength && !formField.field.isValid.minLength.validate(item, formField.field)) { 39121 return { 39122 minLength: { 39123 type: "invalid", 39124 message: (0, import_i18n69.__)("Value is too short.") 39125 } 39126 }; 39127 } 39128 if (formField.field?.isValid.maxLength && !formField.field.isValid.maxLength.validate(item, formField.field)) { 39129 return { 39130 maxLength: { 39131 type: "invalid", 39132 message: (0, import_i18n69.__)("Value is too long.") 39133 } 39134 }; 39135 } 39136 if (formField.field?.isValid.elements && formField.field.hasElements && !formField.field.getElements && Array.isArray(formField.field.elements) && !formField.field.isValid.elements.validate(item, formField.field)) { 39137 return { 39138 elements: { 39139 type: "invalid", 39140 message: (0, import_i18n69.__)("Value must be one of the elements.") 39141 } 39142 }; 39143 } 39144 let customError; 39145 if (!!formField.field && formField.field.isValid.custom) { 39146 try { 39147 const value = formField.field.getValue({ item }); 39148 customError = formField.field.isValid.custom( 39149 (0, import_deepmerge2.default)( 39150 item, 39151 formField.field.setValue({ 39152 item, 39153 value 39154 }) 39155 ), 39156 formField.field 39157 ); 39158 } catch (error2) { 39159 let errorMessage; 39160 if (error2 instanceof Error) { 39161 errorMessage = error2.message; 39162 } else { 39163 errorMessage = String(error2) || (0, import_i18n69.__)("Unknown error when running custom validation."); 39164 } 39165 return { 39166 custom: { 39167 type: "invalid", 39168 message: errorMessage 39169 } 39170 }; 39171 } 39172 } 39173 if (typeof customError === "string") { 39174 return { 39175 custom: { 39176 type: "invalid", 39177 message: customError 39178 } 39179 }; 39180 } 39181 const fieldValidity = {}; 39182 if (!!formField.field && formField.field.isValid.elements && formField.field.hasElements && typeof formField.field.getElements === "function") { 39183 handleElementsValidationAsync( 39184 formField.field.getElements(), 39185 formField, 39186 promiseHandler 39187 ); 39188 fieldValidity.elements = { 39189 type: "validating", 39190 message: (0, import_i18n69.__)("Validating\u2026") 39191 }; 39192 } 39193 if (customError instanceof Promise) { 39194 handleCustomValidationAsync(customError, formField, promiseHandler); 39195 fieldValidity.custom = { 39196 type: "validating", 39197 message: (0, import_i18n69.__)("Validating\u2026") 39198 }; 39199 } 39200 if (Object.keys(fieldValidity).length > 0) { 39201 return fieldValidity; 39202 } 39203 if (formField.children.length > 0) { 39204 const result = {}; 39205 formField.children.forEach((child) => { 39206 result[child.id] = validateFormField(item, child, { 39207 ...promiseHandler, 39208 path: [...promiseHandler.path, formField.id, "children"] 39209 }); 39210 }); 39211 const filteredResult = {}; 39212 Object.entries(result).forEach(([key, value]) => { 39213 if (value !== void 0) { 39214 filteredResult[key] = value; 39215 } 39216 }); 39217 if (Object.keys(filteredResult).length === 0) { 39218 return void 0; 39219 } 39220 return { 39221 children: filteredResult 39222 }; 39223 } 39224 return void 0; 39225 } 39226 function getFormFieldValue(formField, item) { 39227 const fieldValue = formField?.field?.getValue({ item }); 39228 if (formField.children.length === 0) { 39229 return fieldValue; 39230 } 39231 const childrenValues = formField.children.map( 39232 (child) => getFormFieldValue(child, item) 39233 ); 39234 if (!childrenValues) { 39235 return fieldValue; 39236 } 39237 return { 39238 value: fieldValue, 39239 children: childrenValues 39240 }; 39241 } 39242 function useFormValidity(item, fields2, form2) { 39243 const [formValidity, setFormValidity] = (0, import_element121.useState)(); 39244 const customCounterRef = (0, import_element121.useRef)({}); 39245 const elementsCounterRef = (0, import_element121.useRef)({}); 39246 const previousValuesRef = (0, import_element121.useRef)({}); 39247 const validate = (0, import_element121.useCallback)(() => { 39248 const promiseHandler = { 39249 customCounterRef, 39250 elementsCounterRef, 39251 setFormValidity, 39252 path: [], 39253 item 39254 }; 39255 const formFieldsToValidate = getFormFieldsToValidate(form2, fields2); 39256 if (formFieldsToValidate.length === 0) { 39257 setFormValidity(void 0); 39258 return; 39259 } 39260 const newFormValidity = {}; 39261 const untouchedFields = []; 39262 formFieldsToValidate.forEach((formField) => { 39263 const value = getFormFieldValue(formField, item); 39264 if (previousValuesRef.current.hasOwnProperty(formField.id) && (0, import_es63.default)( 39265 previousValuesRef.current[formField.id], 39266 value 39267 )) { 39268 untouchedFields.push(formField.id); 39269 return; 39270 } 39271 previousValuesRef.current[formField.id] = value; 39272 const fieldValidity = validateFormField( 39273 item, 39274 formField, 39275 promiseHandler 39276 ); 39277 if (fieldValidity !== void 0) { 39278 newFormValidity[formField.id] = fieldValidity; 39279 } 39280 }); 39281 setFormValidity((existingFormValidity) => { 39282 let validity = { 39283 ...existingFormValidity, 39284 ...newFormValidity 39285 }; 39286 const fieldsToKeep = [ 39287 ...untouchedFields, 39288 ...Object.keys(newFormValidity) 39289 ]; 39290 Object.keys(validity).forEach((key) => { 39291 if (validity && !fieldsToKeep.includes(key)) { 39292 delete validity[key]; 39293 } 39294 }); 39295 if (Object.keys(validity).length === 0) { 39296 validity = void 0; 39297 } 39298 const areEqual = (0, import_es63.default)(existingFormValidity, validity); 39299 if (areEqual) { 39300 return existingFormValidity; 39301 } 39302 return validity; 39303 }); 39304 }, [item, fields2, form2]); 39305 (0, import_element121.useEffect)(() => { 39306 validate(); 39307 }, [validate]); 39308 return { 39309 validity: formValidity, 39310 isValid: isFormValid(formValidity) 39311 }; 39312 } 39313 var use_form_validity_default = useFormValidity; 39314 39315 // packages/dataviews/build-module/hooks/use-report-validity.mjs 39316 var import_element122 = __toESM(require_element(), 1); 39317 function useReportValidity(ref, shouldReport) { 39318 (0, import_element122.useEffect)(() => { 39319 if (shouldReport && ref.current) { 39320 const inputs = ref.current.querySelectorAll( 39321 "input, textarea, select" 39322 ); 39323 inputs.forEach((input) => { 39324 input.reportValidity(); 39325 }); 39326 } 39327 }, [shouldReport, ref]); 39328 } 39329 39330 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/use-field-from-form-field.mjs 39331 var import_element123 = __toESM(require_element(), 1); 39332 39333 // packages/dataviews/build-module/components/dataform-layouts/get-summary-fields.mjs 39334 function extractSummaryIds(summary) { 39335 if (Array.isArray(summary)) { 39336 return summary.map( 39337 (item) => typeof item === "string" ? item : item.id 39338 ); 39339 } 39340 return []; 39341 } 39342 var getSummaryFields = (summaryField, fields2) => { 39343 if (Array.isArray(summaryField) && summaryField.length > 0) { 39344 const summaryIds = extractSummaryIds(summaryField); 39345 return summaryIds.map( 39346 (summaryId) => fields2.find((_field) => _field.id === summaryId) 39347 ).filter((_field) => _field !== void 0); 39348 } 39349 return []; 39350 }; 39351 39352 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/use-field-from-form-field.mjs 39353 var getFieldDefinition = (field, fields2) => { 39354 const fieldDefinition = fields2.find((_field) => _field.id === field.id); 39355 if (!fieldDefinition) { 39356 return fields2.find((_field) => { 39357 if (!!field.children) { 39358 const simpleChildren = field.children.filter( 39359 (child) => !child.children 39360 ); 39361 if (simpleChildren.length === 0) { 39362 return false; 39363 } 39364 return _field.id === simpleChildren[0].id; 39365 } 39366 return _field.id === field.id; 39367 }); 39368 } 39369 return fieldDefinition; 39370 }; 39371 function useFieldFromFormField(field) { 39372 const { fields: fields2 } = (0, import_element123.useContext)(dataform_context_default); 39373 const layout = field.layout; 39374 const summaryFields = getSummaryFields(layout.summary, fields2); 39375 const fieldDefinition = getFieldDefinition(field, fields2); 39376 const fieldLabel = !!field.children ? field.label : fieldDefinition?.label; 39377 if (summaryFields.length === 0) { 39378 return { 39379 summaryFields: fieldDefinition ? [fieldDefinition] : [], 39380 fieldDefinition, 39381 fieldLabel 39382 }; 39383 } 39384 return { 39385 summaryFields, 39386 fieldDefinition, 39387 fieldLabel 39388 }; 39389 } 39390 var use_field_from_form_field_default = useFieldFromFormField; 39391 39392 // packages/dataviews/build-module/components/dataform-layouts/panel/modal.mjs 39393 var import_jsx_runtime202 = __toESM(require_jsx_runtime(), 1); 39394 function ModalContent({ 39395 data, 39396 field, 39397 onChange, 39398 fieldLabel, 39399 onClose, 39400 touched 39401 }) { 39402 const { openAs } = field.layout; 39403 const { applyLabel, cancelLabel } = openAs; 39404 const { fields: fields2 } = (0, import_element124.useContext)(dataform_context_default); 39405 const [changes, setChanges] = (0, import_element124.useState)({}); 39406 const modalData = (0, import_element124.useMemo)(() => { 39407 return (0, import_deepmerge3.default)(data, changes, { 39408 arrayMerge: (target, source) => source 39409 }); 39410 }, [data, changes]); 39411 const form2 = (0, import_element124.useMemo)( 39412 () => ({ 39413 layout: DEFAULT_LAYOUT, 39414 fields: !!field.children ? field.children : ( 39415 // If not explicit children return the field id itself. 39416 [{ id: field.id, layout: DEFAULT_LAYOUT }] 39417 ) 39418 }), 39419 [field] 39420 ); 39421 const fieldsAsFieldType = fields2.map((f2) => ({ 39422 ...f2, 39423 Edit: f2.Edit === null ? void 0 : f2.Edit, 39424 isValid: { 39425 required: f2.isValid.required?.constraint, 39426 elements: f2.isValid.elements?.constraint, 39427 min: f2.isValid.min?.constraint, 39428 max: f2.isValid.max?.constraint, 39429 pattern: f2.isValid.pattern?.constraint, 39430 minLength: f2.isValid.minLength?.constraint, 39431 maxLength: f2.isValid.maxLength?.constraint 39432 } 39433 })); 39434 const { validity } = use_form_validity_default(modalData, fieldsAsFieldType, form2); 39435 const onApply = () => { 39436 onChange(changes); 39437 onClose(); 39438 }; 39439 const handleOnChange = (newValue) => { 39440 setChanges( 39441 (prev) => (0, import_deepmerge3.default)(prev, newValue, { 39442 arrayMerge: (target, source) => source 39443 }) 39444 ); 39445 }; 39446 const focusOnMountRef = (0, import_compose20.useFocusOnMount)("firstInputElement"); 39447 const contentRef = (0, import_element124.useRef)(null); 39448 const mergedRef = (0, import_compose20.useMergeRefs)([focusOnMountRef, contentRef]); 39449 useReportValidity(contentRef, touched); 39450 return /* @__PURE__ */ (0, import_jsx_runtime202.jsxs)( 39451 import_components69.Modal, 39452 { 39453 className: "dataforms-layouts-panel__modal", 39454 onRequestClose: onClose, 39455 isFullScreen: false, 39456 title: fieldLabel, 39457 size: "medium", 39458 children: [ 39459 /* @__PURE__ */ (0, import_jsx_runtime202.jsx)("div", { ref: mergedRef, children: /* @__PURE__ */ (0, import_jsx_runtime202.jsx)( 39460 DataFormLayout, 39461 { 39462 data: modalData, 39463 form: form2, 39464 onChange: handleOnChange, 39465 validity, 39466 children: (FieldLayout, childField, childFieldValidity, markWhenOptional) => /* @__PURE__ */ (0, import_jsx_runtime202.jsx)( 39467 FieldLayout, 39468 { 39469 data: modalData, 39470 field: childField, 39471 onChange: handleOnChange, 39472 hideLabelFromVision: form2.fields.length < 2, 39473 markWhenOptional, 39474 validity: childFieldValidity 39475 }, 39476 childField.id 39477 ) 39478 } 39479 ) }), 39480 /* @__PURE__ */ (0, import_jsx_runtime202.jsxs)( 39481 Stack, 39482 { 39483 direction: "row", 39484 className: "dataforms-layouts-panel__modal-footer", 39485 gap: "md", 39486 children: [ 39487 /* @__PURE__ */ (0, import_jsx_runtime202.jsx)(import_components69.__experimentalSpacer, { style: { flex: 1 } }), 39488 /* @__PURE__ */ (0, import_jsx_runtime202.jsx)( 39489 import_components69.Button, 39490 { 39491 variant: "tertiary", 39492 onClick: onClose, 39493 __next40pxDefaultSize: true, 39494 children: cancelLabel 39495 } 39496 ), 39497 /* @__PURE__ */ (0, import_jsx_runtime202.jsx)( 39498 import_components69.Button, 39499 { 39500 variant: "primary", 39501 onClick: onApply, 39502 __next40pxDefaultSize: true, 39503 children: applyLabel 39504 } 39505 ) 39506 ] 39507 } 39508 ) 39509 ] 39510 } 39511 ); 39512 } 39513 function PanelModal({ 39514 data, 39515 field, 39516 onChange, 39517 validity 39518 }) { 39519 const [touched, setTouched] = (0, import_element124.useState)(false); 39520 const [isOpen, setIsOpen] = (0, import_element124.useState)(false); 39521 const { fieldDefinition, fieldLabel, summaryFields } = use_field_from_form_field_default(field); 39522 if (!fieldDefinition) { 39523 return null; 39524 } 39525 const handleClose = () => { 39526 setIsOpen(false); 39527 setTouched(true); 39528 }; 39529 return /* @__PURE__ */ (0, import_jsx_runtime202.jsxs)(import_jsx_runtime202.Fragment, { children: [ 39530 /* @__PURE__ */ (0, import_jsx_runtime202.jsx)( 39531 SummaryButton, 39532 { 39533 data, 39534 field, 39535 fieldLabel, 39536 summaryFields, 39537 validity, 39538 touched, 39539 disabled: fieldDefinition.readOnly === true, 39540 onClick: () => setIsOpen(true), 39541 isOpen 39542 } 39543 ), 39544 isOpen && /* @__PURE__ */ (0, import_jsx_runtime202.jsx)( 39545 ModalContent, 39546 { 39547 data, 39548 field, 39549 onChange, 39550 fieldLabel: fieldLabel ?? "", 39551 onClose: handleClose, 39552 touched 39553 } 39554 ) 39555 ] }); 39556 } 39557 var modal_default = PanelModal; 39558 39559 // packages/dataviews/build-module/components/dataform-layouts/panel/dropdown.mjs 39560 var import_components70 = __toESM(require_components(), 1); 39561 var import_i18n70 = __toESM(require_i18n(), 1); 39562 var import_element125 = __toESM(require_element(), 1); 39563 var import_compose21 = __toESM(require_compose(), 1); 39564 var import_jsx_runtime203 = __toESM(require_jsx_runtime(), 1); 39565 function DropdownHeader({ 39566 title, 39567 onClose 39568 }) { 39569 return /* @__PURE__ */ (0, import_jsx_runtime203.jsx)( 39570 Stack, 39571 { 39572 direction: "column", 39573 className: "dataforms-layouts-panel__dropdown-header", 39574 gap: "lg", 39575 children: /* @__PURE__ */ (0, import_jsx_runtime203.jsxs)(Stack, { direction: "row", gap: "sm", align: "center", children: [ 39576 title && /* @__PURE__ */ (0, import_jsx_runtime203.jsx)(import_components70.__experimentalHeading, { level: 2, size: 13, children: title }), 39577 /* @__PURE__ */ (0, import_jsx_runtime203.jsx)(import_components70.__experimentalSpacer, { style: { flex: 1 } }), 39578 onClose && /* @__PURE__ */ (0, import_jsx_runtime203.jsx)( 39579 import_components70.Button, 39580 { 39581 label: (0, import_i18n70.__)("Close"), 39582 icon: close_small_default, 39583 onClick: onClose, 39584 size: "small" 39585 } 39586 ) 39587 ] }) 39588 } 39589 ); 39590 } 39591 function DropdownContentWithValidation({ 39592 touched, 39593 children 39594 }) { 39595 const ref = (0, import_element125.useRef)(null); 39596 useReportValidity(ref, touched); 39597 return /* @__PURE__ */ (0, import_jsx_runtime203.jsx)("div", { ref, children }); 39598 } 39599 function PanelDropdown({ 39600 data, 39601 field, 39602 onChange, 39603 validity 39604 }) { 39605 const [touched, setTouched] = (0, import_element125.useState)(false); 39606 const [popoverAnchor, setPopoverAnchor] = (0, import_element125.useState)( 39607 null 39608 ); 39609 const popoverProps = (0, import_element125.useMemo)( 39610 () => ({ 39611 // Anchor the popover to the middle of the entire row so that it doesn't 39612 // move around when the label changes. 39613 anchor: popoverAnchor, 39614 placement: "left-start", 39615 offset: 36, 39616 shift: true 39617 }), 39618 [popoverAnchor] 39619 ); 39620 const [dialogRef, dialogProps] = (0, import_compose21.__experimentalUseDialog)({ 39621 focusOnMount: "firstInputElement" 39622 }); 39623 const form2 = (0, import_element125.useMemo)( 39624 () => ({ 39625 layout: DEFAULT_LAYOUT, 39626 fields: !!field.children ? field.children : ( 39627 // If not explicit children return the field id itself. 39628 [{ id: field.id, layout: DEFAULT_LAYOUT }] 39629 ) 39630 }), 39631 [field] 39632 ); 39633 const formValidity = (0, import_element125.useMemo)(() => { 39634 if (validity === void 0) { 39635 return void 0; 39636 } 39637 if (!!field.children) { 39638 return validity?.children; 39639 } 39640 return { [field.id]: validity }; 39641 }, [validity, field]); 39642 const { fieldDefinition, fieldLabel, summaryFields } = use_field_from_form_field_default(field); 39643 if (!fieldDefinition) { 39644 return null; 39645 } 39646 return /* @__PURE__ */ (0, import_jsx_runtime203.jsx)( 39647 "div", 39648 { 39649 ref: setPopoverAnchor, 39650 className: "dataforms-layouts-panel__field-dropdown-anchor", 39651 children: /* @__PURE__ */ (0, import_jsx_runtime203.jsx)( 39652 import_components70.Dropdown, 39653 { 39654 contentClassName: "dataforms-layouts-panel__field-dropdown", 39655 popoverProps, 39656 focusOnMount: false, 39657 onToggle: (willOpen) => { 39658 if (!willOpen) { 39659 setTouched(true); 39660 } 39661 }, 39662 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime203.jsx)( 39663 SummaryButton, 39664 { 39665 data, 39666 field, 39667 fieldLabel, 39668 summaryFields, 39669 validity, 39670 touched, 39671 disabled: fieldDefinition.readOnly === true, 39672 isOpen, 39673 onClick: onToggle 39674 } 39675 ), 39676 renderContent: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime203.jsx)(DropdownContentWithValidation, { touched, children: /* @__PURE__ */ (0, import_jsx_runtime203.jsxs)("div", { ref: dialogRef, ...dialogProps, children: [ 39677 /* @__PURE__ */ (0, import_jsx_runtime203.jsx)( 39678 DropdownHeader, 39679 { 39680 title: fieldLabel, 39681 onClose 39682 } 39683 ), 39684 /* @__PURE__ */ (0, import_jsx_runtime203.jsx)( 39685 DataFormLayout, 39686 { 39687 data, 39688 form: form2, 39689 onChange, 39690 validity: formValidity, 39691 children: (FieldLayout, childField, childFieldValidity, markWhenOptional) => /* @__PURE__ */ (0, import_jsx_runtime203.jsx)( 39692 FieldLayout, 39693 { 39694 data, 39695 field: childField, 39696 onChange, 39697 hideLabelFromVision: (form2?.fields ?? []).length < 2, 39698 markWhenOptional, 39699 validity: childFieldValidity 39700 }, 39701 childField.id 39702 ) 39703 } 39704 ) 39705 ] }) }) 39706 } 39707 ) 39708 } 39709 ); 39710 } 39711 var dropdown_default = PanelDropdown; 39712 39713 // packages/dataviews/build-module/components/dataform-layouts/panel/index.mjs 39714 var import_jsx_runtime204 = __toESM(require_jsx_runtime(), 1); 39715 function FormPanelField({ 39716 data, 39717 field, 39718 onChange, 39719 validity 39720 }) { 39721 const layout = field.layout; 39722 if (layout.openAs.type === "modal") { 39723 return /* @__PURE__ */ (0, import_jsx_runtime204.jsx)( 39724 modal_default, 39725 { 39726 data, 39727 field, 39728 onChange, 39729 validity 39730 } 39731 ); 39732 } 39733 return /* @__PURE__ */ (0, import_jsx_runtime204.jsx)( 39734 dropdown_default, 39735 { 39736 data, 39737 field, 39738 onChange, 39739 validity 39740 } 39741 ); 39742 } 39743 39744 // packages/dataviews/build-module/components/dataform-layouts/card/index.mjs 39745 var import_element126 = __toESM(require_element(), 1); 39746 39747 // packages/dataviews/build-module/components/dataform-layouts/validation-badge.mjs 39748 var import_i18n71 = __toESM(require_i18n(), 1); 39749 var import_jsx_runtime205 = __toESM(require_jsx_runtime(), 1); 39750 function countInvalidFields(validity) { 39751 if (!validity) { 39752 return 0; 39753 } 39754 let count = 0; 39755 const validityRules = Object.keys(validity).filter( 39756 (key) => key !== "children" 39757 ); 39758 for (const key of validityRules) { 39759 const rule = validity[key]; 39760 if (rule?.type === "invalid") { 39761 count++; 39762 } 39763 } 39764 if (validity.children) { 39765 for (const childValidity of Object.values(validity.children)) { 39766 count += countInvalidFields(childValidity); 39767 } 39768 } 39769 return count; 39770 } 39771 function ValidationBadge({ 39772 validity 39773 }) { 39774 const invalidCount = countInvalidFields(validity); 39775 if (invalidCount === 0) { 39776 return null; 39777 } 39778 return /* @__PURE__ */ (0, import_jsx_runtime205.jsx)(Badge, { intent: "high", children: (0, import_i18n71.sprintf)( 39779 /* translators: %d: Number of fields that need attention */ 39780 (0, import_i18n71._n)( 39781 "%d field needs attention", 39782 "%d fields need attention", 39783 invalidCount 39784 ), 39785 invalidCount 39786 ) }); 39787 } 39788 39789 // packages/dataviews/build-module/components/dataform-layouts/card/index.mjs 39790 var import_jsx_runtime206 = __toESM(require_jsx_runtime(), 1); 39791 function isSummaryFieldVisible(summaryField, summaryConfig, isOpen) { 39792 if (!summaryConfig || Array.isArray(summaryConfig) && summaryConfig.length === 0) { 39793 return false; 39794 } 39795 const summaryConfigArray = Array.isArray(summaryConfig) ? summaryConfig : [summaryConfig]; 39796 const fieldConfig = summaryConfigArray.find((config2) => { 39797 if (typeof config2 === "string") { 39798 return config2 === summaryField.id; 39799 } 39800 if (typeof config2 === "object" && "id" in config2) { 39801 return config2.id === summaryField.id; 39802 } 39803 return false; 39804 }); 39805 if (!fieldConfig) { 39806 return false; 39807 } 39808 if (typeof fieldConfig === "string") { 39809 return true; 39810 } 39811 if (typeof fieldConfig === "object" && "visibility" in fieldConfig) { 39812 return fieldConfig.visibility === "always" || fieldConfig.visibility === "when-collapsed" && !isOpen; 39813 } 39814 return true; 39815 } 39816 function HeaderContent({ 39817 data, 39818 fields: fields2, 39819 label, 39820 layout, 39821 isOpen, 39822 touched, 39823 validity 39824 }) { 39825 const summaryFields = getSummaryFields(layout.summary, fields2); 39826 const visibleSummaryFields = summaryFields.filter( 39827 (summaryField) => isSummaryFieldVisible(summaryField, layout.summary, isOpen) 39828 ); 39829 const hasBadge = touched && layout.isCollapsible; 39830 const hasSummary = visibleSummaryFields.length > 0 && layout.withHeader; 39831 return /* @__PURE__ */ (0, import_jsx_runtime206.jsxs)( 39832 Stack, 39833 { 39834 align: "center", 39835 justify: "space-between", 39836 className: "dataforms-layouts-card__field-header-content", 39837 children: [ 39838 /* @__PURE__ */ (0, import_jsx_runtime206.jsx)(card_exports.Title, { children: label }), 39839 (hasBadge || hasSummary) && /* @__PURE__ */ (0, import_jsx_runtime206.jsxs)(collapsible_card_exports.HeaderDescription, { className: "dataforms-layouts-card__field-header-content-description", children: [ 39840 hasBadge && /* @__PURE__ */ (0, import_jsx_runtime206.jsx)(ValidationBadge, { validity }), 39841 hasSummary && /* @__PURE__ */ (0, import_jsx_runtime206.jsx)("div", { className: "dataforms-layouts-card__field-summary", children: visibleSummaryFields.map((summaryField) => /* @__PURE__ */ (0, import_jsx_runtime206.jsx)( 39842 summaryField.render, 39843 { 39844 item: data, 39845 field: summaryField 39846 }, 39847 summaryField.id 39848 )) }) 39849 ] }) 39850 ] 39851 } 39852 ); 39853 } 39854 function BodyContent({ 39855 data, 39856 field, 39857 form: form2, 39858 onChange, 39859 hideLabelFromVision, 39860 markWhenOptional, 39861 validity, 39862 withHeader 39863 }) { 39864 if (field.children) { 39865 return /* @__PURE__ */ (0, import_jsx_runtime206.jsxs)(import_jsx_runtime206.Fragment, { children: [ 39866 field.description && /* @__PURE__ */ (0, import_jsx_runtime206.jsx)("div", { className: "dataforms-layouts-card__field-description", children: field.description }), 39867 /* @__PURE__ */ (0, import_jsx_runtime206.jsx)( 39868 DataFormLayout, 39869 { 39870 data, 39871 form: form2, 39872 onChange, 39873 validity: validity?.children 39874 } 39875 ) 39876 ] }); 39877 } 39878 const SingleFieldLayout = getFormFieldLayout("regular")?.component; 39879 if (!SingleFieldLayout) { 39880 return null; 39881 } 39882 return /* @__PURE__ */ (0, import_jsx_runtime206.jsx)( 39883 SingleFieldLayout, 39884 { 39885 data, 39886 field, 39887 onChange, 39888 hideLabelFromVision: hideLabelFromVision || withHeader, 39889 markWhenOptional, 39890 validity 39891 } 39892 ); 39893 } 39894 function FormCardField({ 39895 data, 39896 field, 39897 onChange, 39898 hideLabelFromVision, 39899 markWhenOptional, 39900 validity 39901 }) { 39902 const { fields: fields2 } = (0, import_element126.useContext)(dataform_context_default); 39903 const layout = field.layout; 39904 const contentRef = (0, import_element126.useRef)(null); 39905 const form2 = (0, import_element126.useMemo)( 39906 () => ({ 39907 layout: DEFAULT_LAYOUT, 39908 fields: field.children ?? [] 39909 }), 39910 [field] 39911 ); 39912 const { isOpened, isCollapsible } = layout; 39913 const [isOpen, setIsOpen] = (0, import_element126.useState)(isOpened); 39914 const [touched, setTouched] = (0, import_element126.useState)(false); 39915 (0, import_element126.useEffect)(() => { 39916 setIsOpen(isOpened); 39917 }, [isOpened]); 39918 const handleOpenChange = (0, import_element126.useCallback)((open) => { 39919 if (!open) { 39920 setTouched(true); 39921 } 39922 setIsOpen(open); 39923 }, []); 39924 const handleBlur = (0, import_element126.useCallback)(() => { 39925 setTouched(true); 39926 }, []); 39927 useReportValidity( 39928 contentRef, 39929 (isCollapsible ? isOpen : true) && touched 39930 ); 39931 let label = field.label; 39932 let withHeader; 39933 if (field.children) { 39934 withHeader = !!label && layout.withHeader; 39935 } else { 39936 const fieldDefinition = fields2.find( 39937 (fieldDef) => fieldDef.id === field.id 39938 ); 39939 if (!fieldDefinition || !fieldDefinition.Edit) { 39940 return null; 39941 } 39942 label = fieldDefinition.label; 39943 withHeader = !!label && layout.withHeader; 39944 } 39945 const bodyContent = /* @__PURE__ */ (0, import_jsx_runtime206.jsx)( 39946 BodyContent, 39947 { 39948 data, 39949 field, 39950 form: form2, 39951 onChange, 39952 hideLabelFromVision, 39953 markWhenOptional, 39954 validity, 39955 withHeader 39956 } 39957 ); 39958 const headerContent = /* @__PURE__ */ (0, import_jsx_runtime206.jsx)( 39959 HeaderContent, 39960 { 39961 data, 39962 fields: fields2, 39963 label, 39964 layout, 39965 isOpen: isCollapsible ? !!isOpen : true, 39966 touched, 39967 validity 39968 } 39969 ); 39970 if (withHeader && isCollapsible) { 39971 return /* @__PURE__ */ (0, import_jsx_runtime206.jsxs)( 39972 collapsible_card_exports.Root, 39973 { 39974 className: "dataforms-layouts-card__field", 39975 open: isOpen, 39976 onOpenChange: handleOpenChange, 39977 children: [ 39978 /* @__PURE__ */ (0, import_jsx_runtime206.jsx)(collapsible_card_exports.Header, { children: headerContent }), 39979 /* @__PURE__ */ (0, import_jsx_runtime206.jsx)( 39980 collapsible_card_exports.Content, 39981 { 39982 ref: contentRef, 39983 onBlur: handleBlur, 39984 children: bodyContent 39985 } 39986 ) 39987 ] 39988 } 39989 ); 39990 } 39991 return /* @__PURE__ */ (0, import_jsx_runtime206.jsxs)(card_exports.Root, { className: "dataforms-layouts-card__field", children: [ 39992 withHeader && /* @__PURE__ */ (0, import_jsx_runtime206.jsx)(card_exports.Header, { children: headerContent }), 39993 /* @__PURE__ */ (0, import_jsx_runtime206.jsx)(card_exports.Content, { ref: contentRef, onBlur: handleBlur, children: bodyContent }) 39994 ] }); 39995 } 39996 39997 // packages/dataviews/build-module/components/dataform-layouts/row/index.mjs 39998 var import_components71 = __toESM(require_components(), 1); 39999 var import_jsx_runtime207 = __toESM(require_jsx_runtime(), 1); 40000 function Header5({ title }) { 40001 return /* @__PURE__ */ (0, import_jsx_runtime207.jsx)( 40002 Stack, 40003 { 40004 direction: "column", 40005 className: "dataforms-layouts-row__header", 40006 gap: "lg", 40007 children: /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(Stack, { direction: "row", align: "center", children: /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(import_components71.__experimentalHeading, { level: 2, size: 13, children: title }) }) 40008 } 40009 ); 40010 } 40011 var EMPTY_WRAPPER = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(import_jsx_runtime207.Fragment, { children }); 40012 function FormRowField({ 40013 data, 40014 field, 40015 onChange, 40016 hideLabelFromVision, 40017 markWhenOptional, 40018 validity 40019 }) { 40020 const layout = field.layout; 40021 if (!!field.children) { 40022 const form2 = { 40023 layout: DEFAULT_LAYOUT, 40024 fields: field.children 40025 }; 40026 return /* @__PURE__ */ (0, import_jsx_runtime207.jsxs)("div", { className: "dataforms-layouts-row__field", children: [ 40027 !hideLabelFromVision && field.label && /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(Header5, { title: field.label }), 40028 /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(Stack, { direction: "row", align: layout.alignment, gap: "lg", children: /* @__PURE__ */ (0, import_jsx_runtime207.jsx)( 40029 DataFormLayout, 40030 { 40031 data, 40032 form: form2, 40033 onChange, 40034 validity: validity?.children, 40035 as: EMPTY_WRAPPER, 40036 children: (FieldLayout, childField, childFieldValidity) => /* @__PURE__ */ (0, import_jsx_runtime207.jsx)( 40037 "div", 40038 { 40039 className: "dataforms-layouts-row__field-control", 40040 style: layout.styles[childField.id], 40041 children: /* @__PURE__ */ (0, import_jsx_runtime207.jsx)( 40042 FieldLayout, 40043 { 40044 data, 40045 field: childField, 40046 onChange, 40047 hideLabelFromVision, 40048 markWhenOptional, 40049 validity: childFieldValidity 40050 } 40051 ) 40052 }, 40053 childField.id 40054 ) 40055 } 40056 ) }) 40057 ] }); 40058 } 40059 const RegularLayout = getFormFieldLayout("regular")?.component; 40060 if (!RegularLayout) { 40061 return null; 40062 } 40063 return /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(import_jsx_runtime207.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime207.jsx)("div", { className: "dataforms-layouts-row__field-control", children: /* @__PURE__ */ (0, import_jsx_runtime207.jsx)( 40064 RegularLayout, 40065 { 40066 data, 40067 field, 40068 onChange, 40069 markWhenOptional, 40070 validity 40071 } 40072 ) }) }); 40073 } 40074 40075 // packages/dataviews/build-module/components/dataform-layouts/details/index.mjs 40076 var import_element127 = __toESM(require_element(), 1); 40077 var import_i18n72 = __toESM(require_i18n(), 1); 40078 var import_jsx_runtime208 = __toESM(require_jsx_runtime(), 1); 40079 function FormDetailsField({ 40080 data, 40081 field, 40082 onChange, 40083 validity 40084 }) { 40085 const { fields: fields2 } = (0, import_element127.useContext)(dataform_context_default); 40086 const detailsRef = (0, import_element127.useRef)(null); 40087 const contentRef = (0, import_element127.useRef)(null); 40088 const [touched, setTouched] = (0, import_element127.useState)(false); 40089 const [isOpen, setIsOpen] = (0, import_element127.useState)(false); 40090 const form2 = (0, import_element127.useMemo)( 40091 () => ({ 40092 layout: DEFAULT_LAYOUT, 40093 fields: field.children ?? [] 40094 }), 40095 [field] 40096 ); 40097 (0, import_element127.useEffect)(() => { 40098 const details = detailsRef.current; 40099 if (!details) { 40100 return; 40101 } 40102 const handleToggle = () => { 40103 const nowOpen = details.open; 40104 if (!nowOpen) { 40105 setTouched(true); 40106 } 40107 setIsOpen(nowOpen); 40108 }; 40109 details.addEventListener("toggle", handleToggle); 40110 return () => { 40111 details.removeEventListener("toggle", handleToggle); 40112 }; 40113 }, []); 40114 useReportValidity(contentRef, isOpen && touched); 40115 const handleBlur = (0, import_element127.useCallback)(() => { 40116 setTouched(true); 40117 }, []); 40118 if (!field.children) { 40119 return null; 40120 } 40121 const summaryFieldId = field.layout.summary ?? ""; 40122 const summaryField = summaryFieldId ? fields2.find((fieldDef) => fieldDef.id === summaryFieldId) : void 0; 40123 let summaryContent; 40124 if (summaryField && summaryField.render) { 40125 summaryContent = /* @__PURE__ */ (0, import_jsx_runtime208.jsx)(summaryField.render, { item: data, field: summaryField }); 40126 } else { 40127 summaryContent = field.label || (0, import_i18n72.__)("More details"); 40128 } 40129 return /* @__PURE__ */ (0, import_jsx_runtime208.jsxs)( 40130 "details", 40131 { 40132 ref: detailsRef, 40133 className: "dataforms-layouts-details__details", 40134 children: [ 40135 /* @__PURE__ */ (0, import_jsx_runtime208.jsx)("summary", { className: "dataforms-layouts-details__summary", children: /* @__PURE__ */ (0, import_jsx_runtime208.jsxs)( 40136 Stack, 40137 { 40138 direction: "row", 40139 align: "center", 40140 gap: "md", 40141 className: "dataforms-layouts-details__summary-content", 40142 children: [ 40143 summaryContent, 40144 touched && /* @__PURE__ */ (0, import_jsx_runtime208.jsx)(ValidationBadge, { validity }) 40145 ] 40146 } 40147 ) }), 40148 /* @__PURE__ */ (0, import_jsx_runtime208.jsx)( 40149 "div", 40150 { 40151 ref: contentRef, 40152 className: "dataforms-layouts-details__content", 40153 onBlur: handleBlur, 40154 children: /* @__PURE__ */ (0, import_jsx_runtime208.jsx)( 40155 DataFormLayout, 40156 { 40157 data, 40158 form: form2, 40159 onChange, 40160 validity: validity?.children 40161 } 40162 ) 40163 } 40164 ) 40165 ] 40166 } 40167 ); 40168 } 40169 40170 // packages/dataviews/build-module/components/dataform-layouts/index.mjs 40171 var import_jsx_runtime209 = __toESM(require_jsx_runtime(), 1); 40172 var FORM_FIELD_LAYOUTS = [ 40173 { 40174 type: "regular", 40175 component: FormRegularField, 40176 wrapper: ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime209.jsx)( 40177 Stack, 40178 { 40179 direction: "column", 40180 className: "dataforms-layouts__wrapper", 40181 gap: "lg", 40182 children 40183 } 40184 ) 40185 }, 40186 { 40187 type: "panel", 40188 component: FormPanelField, 40189 wrapper: ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime209.jsx)( 40190 Stack, 40191 { 40192 direction: "column", 40193 className: "dataforms-layouts__wrapper", 40194 gap: "md", 40195 children 40196 } 40197 ) 40198 }, 40199 { 40200 type: "card", 40201 component: FormCardField, 40202 wrapper: ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime209.jsx)( 40203 Stack, 40204 { 40205 direction: "column", 40206 className: "dataforms-layouts__wrapper", 40207 gap: "xl", 40208 children 40209 } 40210 ) 40211 }, 40212 { 40213 type: "row", 40214 component: FormRowField, 40215 wrapper: ({ 40216 children, 40217 layout 40218 }) => /* @__PURE__ */ (0, import_jsx_runtime209.jsx)( 40219 Stack, 40220 { 40221 direction: "column", 40222 className: "dataforms-layouts__wrapper", 40223 gap: "lg", 40224 children: /* @__PURE__ */ (0, import_jsx_runtime209.jsx)("div", { className: "dataforms-layouts-row__field", children: /* @__PURE__ */ (0, import_jsx_runtime209.jsx)( 40225 Stack, 40226 { 40227 direction: "row", 40228 gap: "lg", 40229 align: layout.alignment, 40230 children 40231 } 40232 ) }) 40233 } 40234 ) 40235 }, 40236 { 40237 type: "details", 40238 component: FormDetailsField 40239 } 40240 ]; 40241 function getFormFieldLayout(type) { 40242 return FORM_FIELD_LAYOUTS.find((layout) => layout.type === type); 40243 } 40244 40245 // packages/dataviews/build-module/components/dataform-layouts/data-form-layout.mjs 40246 var import_jsx_runtime210 = __toESM(require_jsx_runtime(), 1); 40247 var DEFAULT_WRAPPER = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime210.jsx)(Stack, { direction: "column", className: "dataforms-layouts__wrapper", gap: "lg", children }); 40248 function DataFormLayout({ 40249 data, 40250 form: form2, 40251 onChange, 40252 validity, 40253 children, 40254 as 40255 }) { 40256 const { fields: fieldDefinitions } = (0, import_element128.useContext)(dataform_context_default); 40257 const markWhenOptional = (0, import_element128.useMemo)(() => { 40258 const requiredCount = fieldDefinitions.filter( 40259 (f2) => !!f2.isValid?.required 40260 ).length; 40261 const optionalCount = fieldDefinitions.length - requiredCount; 40262 return requiredCount > optionalCount; 40263 }, [fieldDefinitions]); 40264 function getFieldDefinition2(field) { 40265 return fieldDefinitions.find( 40266 (fieldDefinition) => fieldDefinition.id === field.id 40267 ); 40268 } 40269 const Wrapper = as ?? getFormFieldLayout(form2.layout.type)?.wrapper ?? DEFAULT_WRAPPER; 40270 return /* @__PURE__ */ (0, import_jsx_runtime210.jsx)(Wrapper, { layout: form2.layout, children: form2.fields.map((formField) => { 40271 const FieldLayout = getFormFieldLayout(formField.layout.type)?.component; 40272 if (!FieldLayout) { 40273 return null; 40274 } 40275 const fieldDefinition = !formField.children ? getFieldDefinition2(formField) : void 0; 40276 if (fieldDefinition && fieldDefinition.isVisible && !fieldDefinition.isVisible(data)) { 40277 return null; 40278 } 40279 if (children) { 40280 return children( 40281 FieldLayout, 40282 formField, 40283 validity?.[formField.id], 40284 markWhenOptional 40285 ); 40286 } 40287 return /* @__PURE__ */ (0, import_jsx_runtime210.jsx)( 40288 FieldLayout, 40289 { 40290 data, 40291 field: formField, 40292 onChange, 40293 markWhenOptional, 40294 validity: validity?.[formField.id] 40295 }, 40296 formField.id 40297 ); 40298 }) }); 40299 } 40300 40301 // packages/dataviews/build-module/dataform/index.mjs 40302 var import_jsx_runtime211 = __toESM(require_jsx_runtime(), 1); 40303 function DataForm({ 40304 data, 40305 form: form2, 40306 fields: fields2, 40307 onChange, 40308 validity 40309 }) { 40310 const normalizedForm = (0, import_element129.useMemo)(() => normalize_form_default(form2), [form2]); 40311 const normalizedFields = (0, import_element129.useMemo)( 40312 () => normalizeFields(fields2), 40313 [fields2] 40314 ); 40315 if (!form2.fields) { 40316 return null; 40317 } 40318 return /* @__PURE__ */ (0, import_jsx_runtime211.jsx)(DataFormProvider, { fields: normalizedFields, children: /* @__PURE__ */ (0, import_jsx_runtime211.jsx)( 40319 DataFormLayout, 40320 { 40321 data, 40322 form: normalizedForm, 40323 onChange, 40324 validity 40325 } 40326 ) }); 40327 } 40328 40329 // packages/dataviews/build-module/utils/filter-sort-and-paginate.mjs 40330 var import_remove_accents2 = __toESM(require_remove_accents(), 1); 40331 var import_deprecated4 = __toESM(require_deprecated(), 1); 40332 function normalizeSearchInput2(input = "") { 40333 return (0, import_remove_accents2.default)(input.trim().toLowerCase()); 40334 } 40335 var EMPTY_ARRAY9 = []; 40336 function filterSortAndPaginate(data, view, fields2) { 40337 if (!data) { 40338 return { 40339 data: EMPTY_ARRAY9, 40340 paginationInfo: { totalItems: 0, totalPages: 0 } 40341 }; 40342 } 40343 const _fields = normalizeFields(fields2); 40344 let filteredData = [...data]; 40345 if (view.search) { 40346 const normalizedSearch = normalizeSearchInput2(view.search); 40347 filteredData = filteredData.filter((item) => { 40348 return _fields.filter((field) => field.enableGlobalSearch).some((field) => { 40349 const fieldValue = field.getValue({ item }); 40350 const values = Array.isArray(fieldValue) ? fieldValue : [fieldValue]; 40351 return values.some( 40352 (value) => normalizeSearchInput2(String(value)).includes( 40353 normalizedSearch 40354 ) 40355 ); 40356 }); 40357 }); 40358 } 40359 if (view.filters && view.filters?.length > 0) { 40360 view.filters.forEach((filter) => { 40361 const field = _fields.find( 40362 (_field) => _field.id === filter.field 40363 ); 40364 if (field) { 40365 if (filter.operator === OPERATOR_IS_NOT_ALL) { 40366 (0, import_deprecated4.default)("The 'isNotAll' filter operator", { 40367 since: "7.0", 40368 alternative: "'isNone'" 40369 }); 40370 } 40371 const handler = field.filter[filter.operator]; 40372 if (handler) { 40373 filteredData = filteredData.filter( 40374 (item) => handler(item, field, filter.value) 40375 ); 40376 } 40377 } 40378 }); 40379 } 40380 const sortByField = view.sort?.field ? _fields.find((field) => { 40381 return field.enableSorting !== false && field.id === view.sort?.field; 40382 }) : null; 40383 const groupByField = view.groupBy?.field ? _fields.find((field) => { 40384 return field.enableSorting !== false && field.id === view.groupBy?.field; 40385 }) : null; 40386 if (sortByField || groupByField) { 40387 filteredData.sort((a2, b2) => { 40388 if (groupByField) { 40389 const groupCompare = groupByField.sort( 40390 a2, 40391 b2, 40392 view.groupBy?.direction ?? "asc" 40393 ); 40394 if (groupCompare !== 0) { 40395 return groupCompare; 40396 } 40397 } 40398 if (sortByField) { 40399 return sortByField.sort(a2, b2, view.sort?.direction ?? "desc"); 40400 } 40401 return 0; 40402 }); 40403 } 40404 let totalItems = filteredData.length; 40405 let totalPages = 1; 40406 if (view.infiniteScrollEnabled && view.startPosition !== void 0 && view.perPage !== void 0) { 40407 const start2 = view.startPosition - 1; 40408 const end = Math.min(start2 + view.perPage, totalItems); 40409 filteredData = filteredData?.slice(start2, end); 40410 } else if (view.page !== void 0 && view.perPage !== void 0) { 40411 const start2 = (view.page - 1) * view.perPage; 40412 totalItems = filteredData?.length || 0; 40413 totalPages = Math.ceil(totalItems / view.perPage); 40414 filteredData = filteredData?.slice(start2, start2 + view.perPage); 40415 } 40416 return { 40417 data: filteredData, 40418 paginationInfo: { 40419 totalItems, 40420 totalPages 40421 } 40422 }; 40423 } 40424 40425 // packages/fields/build-module/lock-unlock.mjs 40426 var import_private_apis6 = __toESM(require_private_apis(), 1); 40427 var { lock: lock5, unlock: unlock5 } = (0, import_private_apis6.__dangerousOptInToUnstableAPIsOnlyForCoreModules)( 40428 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.", 40429 "@wordpress/fields" 40430 ); 40431 40432 // packages/fields/build-module/components/media-edit/index.mjs 40433 var import_components72 = __toESM(require_components(), 1); 40434 var import_blob2 = __toESM(require_blob(), 1); 40435 var import_core_data23 = __toESM(require_core_data(), 1); 40436 var import_data41 = __toESM(require_data(), 1); 40437 var import_element131 = __toESM(require_element(), 1); 40438 var import_i18n73 = __toESM(require_i18n(), 1); 40439 var import_a11y3 = __toESM(require_a11y(), 1); 40440 var import_media_utils = __toESM(require_media_utils(), 1); 40441 var import_notices4 = __toESM(require_notices(), 1); 40442 40443 // packages/fields/build-module/components/media-edit/use-moving-animation.mjs 40444 var import_element130 = __toESM(require_element(), 1); 40445 function getAbsolutePosition2(element) { 40446 return { 40447 top: element.offsetTop, 40448 left: element.offsetLeft 40449 }; 40450 } 40451 function useMovingAnimation2(triggerAnimationOnChange) { 40452 const ref = (0, import_element130.useRef)(null); 40453 const previousRef = (0, import_element130.useRef)(void 0); 40454 if (ref.current) { 40455 previousRef.current = getAbsolutePosition2(ref.current); 40456 } 40457 (0, import_element130.useLayoutEffect)(() => { 40458 const previous = previousRef.current; 40459 if (!previous || !ref.current) { 40460 return; 40461 } 40462 if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) { 40463 return; 40464 } 40465 const controller = new Controller({ 40466 x: 0, 40467 y: 0, 40468 config: { mass: 5, tension: 2e3, friction: 200 }, 40469 onChange({ value }) { 40470 if (!ref.current) { 40471 return; 40472 } 40473 let { x: x22, y: y22 } = value; 40474 x22 = Math.round(x22); 40475 y22 = Math.round(y22); 40476 const finishedMoving = x22 === 0 && y22 === 0; 40477 ref.current.style.transform = finishedMoving ? "" : `translate3d($x22}px,$y22}px,0)`; 40478 } 40479 }); 40480 ref.current.style.transform = ""; 40481 const destination = getAbsolutePosition2(ref.current); 40482 const x2 = Math.round(previous.left - destination.left); 40483 const y2 = Math.round(previous.top - destination.top); 40484 controller.start({ x: 0, y: 0, from: { x: x2, y: y2 } }); 40485 return () => { 40486 controller.stop(); 40487 controller.set({ x: 0, y: 0 }); 40488 }; 40489 }, [triggerAnimationOnChange]); 40490 return ref; 40491 } 40492 40493 // packages/fields/build-module/components/media-edit/index.mjs 40494 var import_jsx_runtime212 = __toESM(require_jsx_runtime(), 1); 40495 var { MediaUploadModal } = unlock5(import_media_utils.privateApis); 40496 function AnimatedMediaItem({ 40497 children, 40498 index: index2, 40499 className 40500 }) { 40501 const ref = useMovingAnimation2(index2); 40502 return /* @__PURE__ */ (0, import_jsx_runtime212.jsx)("div", { ref, className, children }); 40503 } 40504 function normalizeValue2(value) { 40505 if (Array.isArray(value)) { 40506 return value; 40507 } 40508 return value ? [value] : []; 40509 } 40510 function ConditionalMediaUpload({ render: render4, multiple, ...props }) { 40511 const [isModalOpen, setIsModalOpen] = (0, import_element131.useState)(false); 40512 if (window.__experimentalDataViewsMediaModal) { 40513 return /* @__PURE__ */ (0, import_jsx_runtime212.jsxs)(import_jsx_runtime212.Fragment, { children: [ 40514 render4 && render4({ open: () => setIsModalOpen(true) }), 40515 isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime212.jsx)( 40516 MediaUploadModal, 40517 { 40518 ...props, 40519 multiple, 40520 isOpen: isModalOpen, 40521 onClose: () => { 40522 setIsModalOpen(false); 40523 props.onClose?.(); 40524 }, 40525 onSelect: (media) => { 40526 setIsModalOpen(false); 40527 props.onSelect?.(media); 40528 } 40529 } 40530 ) 40531 ] }); 40532 } 40533 return /* @__PURE__ */ (0, import_jsx_runtime212.jsx)( 40534 import_media_utils.MediaUpload, 40535 { 40536 ...props, 40537 render: render4, 40538 multiple: multiple ? "add" : void 0 40539 } 40540 ); 40541 } 40542 function MediaPickerButton({ 40543 open, 40544 children, 40545 label, 40546 showTooltip = false, 40547 onFilesDrop, 40548 attachment, 40549 isUploading = false 40550 }) { 40551 const isBlob = attachment && (0, import_blob2.isBlobURL)(attachment.source_url); 40552 const mediaPickerButton = /* @__PURE__ */ (0, import_jsx_runtime212.jsxs)( 40553 "div", 40554 { 40555 className: clsx_default("fields__media-edit-picker-button", { 40556 "has-attachment": attachment 40557 }), 40558 role: "button", 40559 tabIndex: 0, 40560 onClick: () => { 40561 if (!isUploading) { 40562 open(); 40563 } 40564 }, 40565 onKeyDown: (event) => { 40566 if (isUploading) { 40567 return; 40568 } 40569 if (event.key === "Enter" || event.key === " ") { 40570 event.preventDefault(); 40571 open(); 40572 } 40573 }, 40574 "aria-label": label, 40575 "aria-disabled": isUploading, 40576 children: [ 40577 children, 40578 isBlob && /* @__PURE__ */ (0, import_jsx_runtime212.jsx)("span", { className: "fields__media-edit-picker-button-spinner", children: /* @__PURE__ */ (0, import_jsx_runtime212.jsx)(import_components72.Spinner, {}) }), 40579 !isUploading && /* @__PURE__ */ (0, import_jsx_runtime212.jsx)( 40580 import_components72.DropZone, 40581 { 40582 onFilesDrop: (files) => onFilesDrop(files, attachment?.id) 40583 } 40584 ) 40585 ] 40586 } 40587 ); 40588 if (!showTooltip) { 40589 return mediaPickerButton; 40590 } 40591 return /* @__PURE__ */ (0, import_jsx_runtime212.jsxs)(tooltip_exports.Root, { children: [ 40592 /* @__PURE__ */ (0, import_jsx_runtime212.jsx)(tooltip_exports.Trigger, { render: mediaPickerButton }), 40593 /* @__PURE__ */ (0, import_jsx_runtime212.jsx)(tooltip_exports.Popup, { children: label }) 40594 ] }); 40595 } 40596 var archiveMimeTypes = [ 40597 "application/zip", 40598 "application/x-zip-compressed", 40599 "application/x-rar-compressed", 40600 "application/x-7z-compressed", 40601 "application/x-tar", 40602 "application/x-gzip" 40603 ]; 40604 function MediaTitle({ attachment }) { 40605 return /* @__PURE__ */ (0, import_jsx_runtime212.jsx)(import_components72.__experimentalTruncate, { className: "fields__media-edit-filename", children: attachment.title.rendered }); 40606 } 40607 function MediaEditPlaceholder(props) { 40608 return /* @__PURE__ */ (0, import_jsx_runtime212.jsx)(MediaPickerButton, { ...props, children: /* @__PURE__ */ (0, import_jsx_runtime212.jsx)("span", { className: "fields__media-edit-placeholder", children: props.label }) }); 40609 } 40610 function MoveButtons({ 40611 itemId, 40612 index: index2, 40613 totalItems, 40614 isUploading, 40615 moveItem, 40616 orientation = "vertical" 40617 }) { 40618 const isHorizontal = orientation === "horizontal"; 40619 return /* @__PURE__ */ (0, import_jsx_runtime212.jsxs)(import_jsx_runtime212.Fragment, { children: [ 40620 /* @__PURE__ */ (0, import_jsx_runtime212.jsx)( 40621 import_components72.Button, 40622 { 40623 __next40pxDefaultSize: true, 40624 icon: isHorizontal ? chevron_left_default : chevron_up_default, 40625 label: isHorizontal ? (0, import_i18n73.__)("Move left") : (0, import_i18n73.__)("Move up"), 40626 size: "small", 40627 disabled: isUploading || index2 === 0, 40628 accessibleWhenDisabled: true, 40629 tooltipPosition: "top", 40630 onClick: (event) => { 40631 event.stopPropagation(); 40632 moveItem(itemId, "up"); 40633 } 40634 } 40635 ), 40636 /* @__PURE__ */ (0, import_jsx_runtime212.jsx)( 40637 import_components72.Button, 40638 { 40639 __next40pxDefaultSize: true, 40640 icon: isHorizontal ? chevron_right_default : chevron_down_default, 40641 label: isHorizontal ? (0, import_i18n73.__)("Move right") : (0, import_i18n73.__)("Move down"), 40642 size: "small", 40643 disabled: isUploading || index2 === totalItems - 1, 40644 accessibleWhenDisabled: true, 40645 tooltipPosition: "top", 40646 onClick: (event) => { 40647 event.stopPropagation(); 40648 moveItem(itemId, "down"); 40649 } 40650 } 40651 ) 40652 ] }); 40653 } 40654 function MediaPreview({ attachment }) { 40655 const url = attachment.source_url; 40656 const mimeType = attachment.mime_type || ""; 40657 if (mimeType.startsWith("image")) { 40658 return /* @__PURE__ */ (0, import_jsx_runtime212.jsx)( 40659 "img", 40660 { 40661 className: "fields__media-edit-thumbnail", 40662 alt: attachment.alt_text || "", 40663 src: url 40664 } 40665 ); 40666 } else if (mimeType.startsWith("audio")) { 40667 return /* @__PURE__ */ (0, import_jsx_runtime212.jsx)(import_components72.Icon, { icon: audio_default }); 40668 } else if (mimeType.startsWith("video")) { 40669 return /* @__PURE__ */ (0, import_jsx_runtime212.jsx)(import_components72.Icon, { icon: video_default }); 40670 } else if (archiveMimeTypes.includes(mimeType)) { 40671 return /* @__PURE__ */ (0, import_jsx_runtime212.jsx)(import_components72.Icon, { icon: archive_default }); 40672 } 40673 return /* @__PURE__ */ (0, import_jsx_runtime212.jsx)(import_components72.Icon, { icon: file_default }); 40674 } 40675 function ExpandedMediaEditAttachments({ 40676 allItems, 40677 addButtonLabel, 40678 multiple, 40679 removeItem, 40680 moveItem, 40681 open, 40682 onFilesDrop, 40683 isUploading, 40684 setTargetItemId 40685 }) { 40686 return /* @__PURE__ */ (0, import_jsx_runtime212.jsxs)( 40687 "div", 40688 { 40689 className: clsx_default("fields__media-edit-expanded", { 40690 "is-multiple": multiple, 40691 "is-single": !multiple, 40692 "is-empty": !allItems?.length 40693 }), 40694 children: [ 40695 allItems?.map((attachment, index2) => { 40696 const hasPreviewImage = attachment.mime_type?.startsWith("image"); 40697 const isBlob = (0, import_blob2.isBlobURL)(attachment.source_url); 40698 const attachmentNumericId = attachment.id; 40699 return /* @__PURE__ */ (0, import_jsx_runtime212.jsxs)( 40700 AnimatedMediaItem, 40701 { 40702 index: index2, 40703 className: clsx_default("fields__media-edit-expanded-item", { 40704 "has-preview-image": hasPreviewImage 40705 }), 40706 children: [ 40707 /* @__PURE__ */ (0, import_jsx_runtime212.jsx)( 40708 MediaPickerButton, 40709 { 40710 open: () => { 40711 setTargetItemId(attachmentNumericId); 40712 open(); 40713 }, 40714 label: !isBlob ? (0, import_i18n73.sprintf)( 40715 /* translators: %s: The title of the media item. */ 40716 (0, import_i18n73.__)("Replace %s"), 40717 attachment.title.rendered 40718 ) : (0, import_i18n73.__)("Replace"), 40719 showTooltip: true, 40720 onFilesDrop, 40721 attachment, 40722 isUploading, 40723 children: /* @__PURE__ */ (0, import_jsx_runtime212.jsx)("div", { className: "fields__media-edit-expanded-preview", children: /* @__PURE__ */ (0, import_jsx_runtime212.jsx)( 40724 import_components72.__experimentalVStack, 40725 { 40726 spacing: 0, 40727 alignment: "center", 40728 justify: "center", 40729 className: "fields__media-edit-expanded-preview-stack", 40730 children: (!isBlob || hasPreviewImage) && /* @__PURE__ */ (0, import_jsx_runtime212.jsx)( 40731 MediaPreview, 40732 { 40733 attachment 40734 } 40735 ) 40736 } 40737 ) }) 40738 } 40739 ), 40740 !isBlob && /* @__PURE__ */ (0, import_jsx_runtime212.jsx)("div", { className: "fields__media-edit-expanded-overlay", children: /* @__PURE__ */ (0, import_jsx_runtime212.jsxs)( 40741 import_components72.__experimentalHStack, 40742 { 40743 className: "fields__media-edit-expanded-actions", 40744 spacing: 0, 40745 alignment: "flex-end", 40746 expanded: false, 40747 children: [ 40748 multiple && allItems.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime212.jsx)( 40749 MoveButtons, 40750 { 40751 itemId: attachmentNumericId, 40752 index: index2, 40753 totalItems: allItems.length, 40754 isUploading, 40755 moveItem, 40756 orientation: "horizontal" 40757 } 40758 ), 40759 /* @__PURE__ */ (0, import_jsx_runtime212.jsx)( 40760 import_components72.Button, 40761 { 40762 __next40pxDefaultSize: true, 40763 icon: close_small_default, 40764 label: (0, import_i18n73.__)("Remove"), 40765 size: "small", 40766 disabled: isUploading, 40767 accessibleWhenDisabled: true, 40768 tooltipPosition: "top", 40769 onClick: (event) => { 40770 event.stopPropagation(); 40771 removeItem(attachmentNumericId); 40772 } 40773 } 40774 ) 40775 ] 40776 } 40777 ) }) 40778 ] 40779 }, 40780 attachment.id 40781 ); 40782 }), 40783 (multiple || !allItems?.length) && /* @__PURE__ */ (0, import_jsx_runtime212.jsx)( 40784 MediaEditPlaceholder, 40785 { 40786 open: () => { 40787 setTargetItemId(void 0); 40788 open(); 40789 }, 40790 label: addButtonLabel, 40791 onFilesDrop, 40792 isUploading 40793 } 40794 ) 40795 ] 40796 } 40797 ); 40798 } 40799 function CompactMediaEditAttachments({ 40800 allItems, 40801 addButtonLabel, 40802 multiple, 40803 removeItem, 40804 moveItem, 40805 open, 40806 onFilesDrop, 40807 isUploading, 40808 setTargetItemId 40809 }) { 40810 return /* @__PURE__ */ (0, import_jsx_runtime212.jsxs)(import_jsx_runtime212.Fragment, { children: [ 40811 !!allItems?.length && /* @__PURE__ */ (0, import_jsx_runtime212.jsx)( 40812 "div", 40813 { 40814 className: clsx_default("fields__media-edit-compact-group", { 40815 "is-single": allItems.length === 1 40816 }), 40817 children: /* @__PURE__ */ (0, import_jsx_runtime212.jsx)(import_components72.__experimentalVStack, { spacing: 0, children: allItems.map((attachment, index2) => { 40818 const isBlob = (0, import_blob2.isBlobURL)(attachment.source_url); 40819 const showMoveButtons = multiple && allItems.length > 1; 40820 const attachmentNumericId = attachment.id; 40821 return /* @__PURE__ */ (0, import_jsx_runtime212.jsxs)( 40822 AnimatedMediaItem, 40823 { 40824 index: index2, 40825 className: "fields__media-edit-compact", 40826 children: [ 40827 /* @__PURE__ */ (0, import_jsx_runtime212.jsx)( 40828 MediaPickerButton, 40829 { 40830 open: () => { 40831 setTargetItemId( 40832 attachmentNumericId 40833 ); 40834 open(); 40835 }, 40836 label: (0, import_i18n73.__)("Replace"), 40837 showTooltip: true, 40838 onFilesDrop, 40839 attachment, 40840 isUploading, 40841 children: /* @__PURE__ */ (0, import_jsx_runtime212.jsxs)(import_jsx_runtime212.Fragment, { children: [ 40842 /* @__PURE__ */ (0, import_jsx_runtime212.jsx)( 40843 MediaPreview, 40844 { 40845 attachment 40846 } 40847 ), 40848 !isBlob && /* @__PURE__ */ (0, import_jsx_runtime212.jsx)( 40849 MediaTitle, 40850 { 40851 attachment 40852 } 40853 ) 40854 ] }) 40855 } 40856 ), 40857 !isBlob && /* @__PURE__ */ (0, import_jsx_runtime212.jsxs)( 40858 import_components72.__experimentalHStack, 40859 { 40860 className: "fields__media-edit-compact-movers", 40861 spacing: 0, 40862 alignment: "flex-end", 40863 expanded: false, 40864 children: [ 40865 showMoveButtons && /* @__PURE__ */ (0, import_jsx_runtime212.jsx)( 40866 MoveButtons, 40867 { 40868 itemId: attachmentNumericId, 40869 index: index2, 40870 totalItems: allItems.length, 40871 isUploading, 40872 moveItem, 40873 orientation: "vertical" 40874 } 40875 ), 40876 /* @__PURE__ */ (0, import_jsx_runtime212.jsx)( 40877 import_components72.Button, 40878 { 40879 __next40pxDefaultSize: true, 40880 icon: close_small_default, 40881 label: (0, import_i18n73.__)("Remove"), 40882 size: "small", 40883 disabled: isUploading, 40884 accessibleWhenDisabled: true, 40885 tooltipPosition: "top", 40886 onClick: (event) => { 40887 event.stopPropagation(); 40888 removeItem( 40889 attachmentNumericId 40890 ); 40891 } 40892 } 40893 ) 40894 ] 40895 } 40896 ) 40897 ] 40898 }, 40899 attachment.id 40900 ); 40901 }) }) 40902 } 40903 ), 40904 (multiple || !allItems?.length) && /* @__PURE__ */ (0, import_jsx_runtime212.jsx)( 40905 MediaEditPlaceholder, 40906 { 40907 open: () => { 40908 setTargetItemId(void 0); 40909 open(); 40910 }, 40911 label: addButtonLabel, 40912 onFilesDrop, 40913 isUploading 40914 } 40915 ) 40916 ] }); 40917 } 40918 function MediaEdit({ 40919 data, 40920 field, 40921 onChange, 40922 hideLabelFromVision, 40923 allowedTypes = ["image"], 40924 multiple, 40925 isExpanded, 40926 validity 40927 }) { 40928 const value = field.getValue({ item: data }); 40929 const [isTouched, setIsTouched] = (0, import_element131.useState)(false); 40930 const validityTargetRef = (0, import_element131.useRef)(null); 40931 const [customValidity, setCustomValidity] = (0, import_element131.useState)(void 0); 40932 (0, import_element131.useEffect)(() => { 40933 const validityTarget = validityTargetRef.current; 40934 const handler = () => { 40935 setIsTouched(true); 40936 }; 40937 validityTarget?.addEventListener("invalid", handler); 40938 return () => validityTarget?.removeEventListener("invalid", handler); 40939 }, []); 40940 const attachments = (0, import_data41.useSelect)( 40941 (select4) => { 40942 if (!value) { 40943 return null; 40944 } 40945 const normalizedValue = normalizeValue2(value); 40946 const sortedIds = normalizedValue.toSorted((a2, b2) => a2 - b2); 40947 const { getEntityRecords } = select4(import_core_data23.store); 40948 return getEntityRecords("postType", "attachment", { 40949 include: sortedIds 40950 }); 40951 }, 40952 [value] 40953 ); 40954 const stableAttachmentsRef = (0, import_element131.useRef)( 40955 null 40956 ); 40957 if (attachments !== null) { 40958 stableAttachmentsRef.current = attachments; 40959 } 40960 let stableAttachments = attachments; 40961 if (attachments === null && stableAttachmentsRef.current && value) { 40962 const stableIds = new Set( 40963 stableAttachmentsRef.current.map((a2) => a2.id) 40964 ); 40965 if (normalizeValue2(value).every((id) => stableIds.has(id))) { 40966 stableAttachments = stableAttachmentsRef.current; 40967 } 40968 } 40969 const orderedAttachments = (0, import_element131.useMemo)(() => { 40970 if (!stableAttachments) { 40971 return null; 40972 } 40973 const normalizedValue = normalizeValue2(value); 40974 const attachmentMap = new Map( 40975 stableAttachments.map((a2) => [a2.id, a2]) 40976 ); 40977 return normalizedValue.map((id) => attachmentMap.get(id)).filter((a2) => a2 !== void 0); 40978 }, [stableAttachments, value]); 40979 const { createErrorNotice } = (0, import_data41.useDispatch)(import_notices4.store); 40980 const { receiveEntityRecords } = (0, import_data41.useDispatch)(import_core_data23.store); 40981 const [targetItemId, setTargetItemId] = (0, import_element131.useState)(); 40982 const openModalRef = (0, import_element131.useRef)(void 0); 40983 const [pendingOpen, setPendingOpen] = (0, import_element131.useState)(false); 40984 const [blobs, setBlobs] = (0, import_element131.useState)([]); 40985 (0, import_element131.useEffect)(() => { 40986 if (pendingOpen) { 40987 setPendingOpen(false); 40988 openModalRef.current?.(); 40989 } 40990 }, [pendingOpen]); 40991 const onChangeControl = (0, import_element131.useCallback)( 40992 (newValue) => onChange(field.setValue({ item: data, value: newValue })), 40993 [data, field, onChange] 40994 ); 40995 const removeItem = (0, import_element131.useCallback)( 40996 (itemId) => { 40997 const currentIds = normalizeValue2(value); 40998 const newIds = currentIds.filter((id) => id !== itemId); 40999 setIsTouched(true); 41000 onChangeControl(newIds.length ? newIds : void 0); 41001 }, 41002 [value, onChangeControl] 41003 ); 41004 const moveItem = (0, import_element131.useCallback)( 41005 (itemId, direction) => { 41006 if (!orderedAttachments) { 41007 return; 41008 } 41009 const currentIds = orderedAttachments.map((a2) => a2.id); 41010 const index2 = currentIds.indexOf(itemId); 41011 const newIndex = direction === "up" ? index2 - 1 : index2 + 1; 41012 [currentIds[index2], currentIds[newIndex]] = [ 41013 currentIds[newIndex], 41014 currentIds[index2] 41015 ]; 41016 onChangeControl(currentIds); 41017 }, 41018 [orderedAttachments, onChangeControl] 41019 ); 41020 const onFilesDrop = (0, import_element131.useCallback)( 41021 (files, _targetItemId) => { 41022 setTargetItemId(_targetItemId); 41023 (0, import_media_utils.uploadMedia)({ 41024 allowedTypes: allowedTypes?.length ? allowedTypes : void 0, 41025 filesList: files, 41026 onFileChange(uploadedMedia) { 41027 const blobUrls = uploadedMedia.filter((item) => (0, import_blob2.isBlobURL)(item.url)).map((item) => item.url); 41028 setBlobs(blobUrls); 41029 if (!!blobUrls.length) { 41030 return; 41031 } 41032 receiveEntityRecords( 41033 "postType", 41034 "attachment", 41035 [], 41036 void 0, 41037 true 41038 ); 41039 const uploadedIds = uploadedMedia.map( 41040 (item) => item.id 41041 ); 41042 if (!multiple) { 41043 onChangeControl(uploadedIds[0]); 41044 setTargetItemId(void 0); 41045 return; 41046 } 41047 const currentValue = normalizeValue2(value); 41048 if (_targetItemId === void 0) { 41049 onChangeControl([...currentValue, ...uploadedIds]); 41050 } else { 41051 const newValue = [...currentValue]; 41052 newValue.splice( 41053 currentValue.indexOf(_targetItemId), 41054 1, 41055 ...uploadedIds 41056 ); 41057 onChangeControl(newValue); 41058 } 41059 setTargetItemId(void 0); 41060 }, 41061 onError(error2) { 41062 setTargetItemId(void 0); 41063 setBlobs([]); 41064 createErrorNotice(error2.message, { type: "snackbar" }); 41065 }, 41066 multiple: !!multiple 41067 }); 41068 }, 41069 [ 41070 allowedTypes, 41071 value, 41072 multiple, 41073 createErrorNotice, 41074 onChangeControl, 41075 receiveEntityRecords 41076 ] 41077 ); 41078 const addButtonLabel = field.placeholder || (multiple ? (0, import_i18n73.__)("Choose files") : (0, import_i18n73.__)("Choose file")); 41079 const allItems = (0, import_element131.useMemo)(() => { 41080 if (!blobs.length) { 41081 return orderedAttachments; 41082 } 41083 const items = [ 41084 ...orderedAttachments || [] 41085 ]; 41086 const blobItems = blobs.map((url) => ({ 41087 id: url, 41088 source_url: url, 41089 mime_type: (0, import_blob2.getBlobTypeByURL)(url) 41090 })); 41091 if (targetItemId !== void 0) { 41092 const targetIndex = items.findIndex( 41093 (a2) => a2.id === targetItemId 41094 ); 41095 items.splice(targetIndex, 1, ...blobItems); 41096 } else { 41097 items.push(...blobItems); 41098 } 41099 return items; 41100 }, [orderedAttachments, targetItemId, blobs]); 41101 (0, import_element131.useEffect)(() => { 41102 if (!isTouched) { 41103 return; 41104 } 41105 const input = validityTargetRef.current; 41106 if (!input) { 41107 return; 41108 } 41109 if (validity) { 41110 const customValidityResult = validity?.custom; 41111 setCustomValidity(customValidityResult); 41112 if (customValidityResult?.type === "invalid") { 41113 input.setCustomValidity( 41114 customValidityResult.message || (0, import_i18n73.__)("Invalid") 41115 ); 41116 } else { 41117 input.setCustomValidity(""); 41118 } 41119 } else { 41120 input.setCustomValidity(""); 41121 setCustomValidity(void 0); 41122 } 41123 }, [isTouched, field.isValid, validity]); 41124 (0, import_element131.useEffect)(() => { 41125 if (isTouched && customValidity?.message) { 41126 (0, import_a11y3.speak)(customValidity.message); 41127 } 41128 }, [isTouched, customValidity?.message]); 41129 const onBlur = (0, import_element131.useCallback)( 41130 (event) => { 41131 if (isTouched) { 41132 return; 41133 } 41134 if (!event.relatedTarget || !event.currentTarget.contains(event.relatedTarget)) { 41135 setIsTouched(true); 41136 } 41137 }, 41138 [isTouched] 41139 ); 41140 return /* @__PURE__ */ (0, import_jsx_runtime212.jsxs)("div", { onBlur, children: [ 41141 /* @__PURE__ */ (0, import_jsx_runtime212.jsx)("fieldset", { className: "fields__media-edit", "data-field-id": field.id, children: /* @__PURE__ */ (0, import_jsx_runtime212.jsx)( 41142 ConditionalMediaUpload, 41143 { 41144 onSelect: (selectedMedia) => { 41145 if (!multiple) { 41146 onChangeControl(selectedMedia.id); 41147 setTargetItemId(void 0); 41148 return; 41149 } 41150 const newIds = Array.isArray(selectedMedia) ? selectedMedia.map((m2) => m2.id) : [selectedMedia.id]; 41151 const currentValue = normalizeValue2(value); 41152 if (!currentValue.length) { 41153 onChangeControl(newIds); 41154 } else if (targetItemId === void 0) { 41155 const existingItems = currentValue.filter( 41156 (id) => newIds.includes(id) 41157 ); 41158 const newItems = newIds.filter( 41159 (id) => !currentValue.includes(id) 41160 ); 41161 onChangeControl([ 41162 ...existingItems, 41163 ...newItems 41164 ]); 41165 } else if (selectedMedia.id !== targetItemId) { 41166 const filtered = currentValue.filter( 41167 (id) => id !== selectedMedia.id 41168 ); 41169 onChangeControl( 41170 filtered.map( 41171 (id) => id === targetItemId ? selectedMedia.id : id 41172 ) 41173 ); 41174 } 41175 setTargetItemId(void 0); 41176 }, 41177 onClose: () => setTargetItemId(void 0), 41178 allowedTypes, 41179 value: targetItemId !== void 0 ? targetItemId : value, 41180 multiple: multiple && targetItemId === void 0, 41181 title: field.label, 41182 render: ({ open }) => { 41183 openModalRef.current = open; 41184 const AttachmentsComponent = isExpanded ? ExpandedMediaEditAttachments : CompactMediaEditAttachments; 41185 return /* @__PURE__ */ (0, import_jsx_runtime212.jsxs)(import_components72.__experimentalVStack, { spacing: 2, children: [ 41186 field.label && (hideLabelFromVision ? /* @__PURE__ */ (0, import_jsx_runtime212.jsx)(VisuallyHidden, { render: /* @__PURE__ */ (0, import_jsx_runtime212.jsx)("legend", {}), children: field.label }) : /* @__PURE__ */ (0, import_jsx_runtime212.jsx)( 41187 import_components72.BaseControl.VisualLabel, 41188 { 41189 as: "legend", 41190 style: { marginBottom: 0 }, 41191 children: field.label 41192 } 41193 )), 41194 /* @__PURE__ */ (0, import_jsx_runtime212.jsx)( 41195 AttachmentsComponent, 41196 { 41197 allItems, 41198 addButtonLabel, 41199 multiple, 41200 removeItem, 41201 moveItem, 41202 open: () => setPendingOpen(true), 41203 onFilesDrop, 41204 isUploading: !!blobs.length, 41205 setTargetItemId 41206 } 41207 ), 41208 field.description && /* @__PURE__ */ (0, import_jsx_runtime212.jsx)( 41209 import_components72.__experimentalText, 41210 { 41211 variant: "muted", 41212 className: "fields__media-edit-description", 41213 children: field.description 41214 } 41215 ) 41216 ] }); 41217 } 41218 } 41219 ) }), 41220 /* @__PURE__ */ (0, import_jsx_runtime212.jsx)(VisuallyHidden, { children: /* @__PURE__ */ (0, import_jsx_runtime212.jsx)( 41221 "input", 41222 { 41223 type: "text", 41224 ref: validityTargetRef, 41225 value: value ?? "", 41226 tabIndex: -1, 41227 "aria-hidden": "true", 41228 onChange: () => { 41229 } 41230 } 41231 ) }), 41232 customValidity && /* @__PURE__ */ (0, import_jsx_runtime212.jsxs)( 41233 "p", 41234 { 41235 className: clsx_default( 41236 "components-validated-control__indicator", 41237 { 41238 "is-invalid": customValidity.type === "invalid", 41239 "is-valid": customValidity.type === "valid" 41240 } 41241 ), 41242 children: [ 41243 /* @__PURE__ */ (0, import_jsx_runtime212.jsx)( 41244 import_components72.Icon, 41245 { 41246 className: "components-validated-control__indicator-icon", 41247 icon: error_default, 41248 size: 16, 41249 fill: "currentColor" 41250 } 41251 ), 41252 customValidity.message 41253 ] 41254 } 41255 ) 41256 ] }); 41257 } 41258 41259 // node_modules/tslib/tslib.es6.mjs 41260 var __assign = function() { 41261 __assign = Object.assign || function __assign2(t3) { 41262 for (var s2, i2 = 1, n2 = arguments.length; i2 < n2; i2++) { 41263 s2 = arguments[i2]; 41264 for (var p3 in s2) if (Object.prototype.hasOwnProperty.call(s2, p3)) t3[p3] = s2[p3]; 41265 } 41266 return t3; 41267 }; 41268 return __assign.apply(this, arguments); 41269 }; 41270 41271 // node_modules/lower-case/dist.es2015/index.js 41272 function lowerCase(str) { 41273 return str.toLowerCase(); 41274 } 41275 41276 // node_modules/no-case/dist.es2015/index.js 41277 var DEFAULT_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g]; 41278 var DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi; 41279 function noCase(input, options) { 41280 if (options === void 0) { 41281 options = {}; 41282 } 41283 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; 41284 var result = replace(replace(input, splitRegexp, "$1\0$2"), stripRegexp, "\0"); 41285 var start2 = 0; 41286 var end = result.length; 41287 while (result.charAt(start2) === "\0") 41288 start2++; 41289 while (result.charAt(end - 1) === "\0") 41290 end--; 41291 return result.slice(start2, end).split("\0").map(transform).join(delimiter); 41292 } 41293 function replace(input, re, value) { 41294 if (re instanceof RegExp) 41295 return input.replace(re, value); 41296 return re.reduce(function(input2, re2) { 41297 return input2.replace(re2, value); 41298 }, input); 41299 } 41300 41301 // node_modules/dot-case/dist.es2015/index.js 41302 function dotCase(input, options) { 41303 if (options === void 0) { 41304 options = {}; 41305 } 41306 return noCase(input, __assign({ delimiter: "." }, options)); 41307 } 41308 41309 // node_modules/param-case/dist.es2015/index.js 41310 function paramCase(input, options) { 41311 if (options === void 0) { 41312 options = {}; 41313 } 41314 return dotCase(input, __assign({ delimiter: "-" }, options)); 41315 } 41316 41317 // packages/edit-site/build-module/components/sidebar-identity/index.mjs 41318 var import_jsx_runtime213 = __toESM(require_jsx_runtime(), 1); 41319 var fields = [ 41320 { 41321 id: "title", 41322 type: "text", 41323 label: (0, import_i18n74.__)("Site Title"), 41324 description: (0, import_i18n74.__)( 41325 "Displays in your site's layout via the Site Title block." 41326 ) 41327 }, 41328 { 41329 id: "description", 41330 type: "text", 41331 label: (0, import_i18n74.__)("Site Tagline"), 41332 description: (0, import_i18n74.__)( 41333 "In a few words, explain what this site is about. Displays in your site's layout via the Site Tagline block." 41334 ) 41335 }, 41336 { 41337 id: "site_logo", 41338 type: "media", 41339 label: (0, import_i18n74.__)("Site Logo"), 41340 description: (0, import_i18n74.__)( 41341 "Displays in your site's layout via the Site Logo block." 41342 ), 41343 placeholder: (0, import_i18n74.__)("Choose logo"), 41344 Edit: MediaEdit, 41345 setValue: ({ value }) => ({ 41346 site_logo: value ?? 0 41347 }) 41348 }, 41349 { 41350 id: "site_icon", 41351 type: "media", 41352 label: (0, import_i18n74.__)("Site Icon"), 41353 description: (0, import_i18n74.__)( 41354 "Shown in browser tabs, bookmarks, and mobile apps. It should be square and at least 512 by 512 pixels." 41355 ), 41356 placeholder: (0, import_i18n74.__)("Choose icon"), 41357 Edit: MediaEdit, 41358 setValue: ({ value }) => ({ 41359 site_icon: value ?? 0 41360 }) 41361 } 41362 ]; 41363 var form = { 41364 layout: { 41365 type: "regular", 41366 labelPosition: "top" 41367 }, 41368 fields: ["title", "description", "site_logo", "site_icon"] 41369 }; 41370 function SidebarIdentity() { 41371 const data = (0, import_data42.useSelect)( 41372 (select4) => select4(import_core_data24.store).getEditedEntityRecord("root", "site"), 41373 [] 41374 ); 41375 const { editEntityRecord } = (0, import_data42.useDispatch)(import_core_data24.store); 41376 const onChange = (edits) => { 41377 editEntityRecord("root", "site", void 0, edits); 41378 }; 41379 return /* @__PURE__ */ (0, import_jsx_runtime213.jsx)( 41380 page_default2, 41381 { 41382 title: (0, import_i18n74._x)("Identity", "site identity"), 41383 headingLevel: 2, 41384 hasPadding: true, 41385 children: /* @__PURE__ */ (0, import_jsx_runtime213.jsx)( 41386 DataForm, 41387 { 41388 data, 41389 fields, 41390 form, 41391 onChange 41392 } 41393 ) 41394 } 41395 ); 41396 } 41397 41398 // packages/edit-site/build-module/components/site-editor-routes/identity.mjs 41399 var import_jsx_runtime214 = __toESM(require_jsx_runtime(), 1); 41400 var identityRoute = { 41401 name: "identity", 41402 path: "/identity", 41403 areas: { 41404 sidebar: /* @__PURE__ */ (0, import_jsx_runtime214.jsx)(SidebarNavigationScreenIdentity, {}), 41405 content: /* @__PURE__ */ (0, import_jsx_runtime214.jsx)(SidebarIdentity, {}), 41406 preview: /* @__PURE__ */ (0, import_jsx_runtime214.jsx)(EditSiteEditor, {}), 41407 mobileContent: /* @__PURE__ */ (0, import_jsx_runtime214.jsx)(SidebarIdentity, {}) 41408 }, 41409 widths: { 41410 content: 380 41411 } 41412 }; 41413 41414 // packages/edit-site/build-module/components/site-editor-routes/styles.mjs 41415 var import_router21 = __toESM(require_router(), 1); 41416 var import_editor25 = __toESM(require_editor(), 1); 41417 var import_url15 = __toESM(require_url(), 1); 41418 41419 // packages/edit-site/build-module/components/sidebar-navigation-screen-global-styles/index.mjs 41420 var import_i18n122 = __toESM(require_i18n(), 1); 41421 var import_data55 = __toESM(require_data(), 1); 41422 var import_element164 = __toESM(require_element(), 1); 41423 var import_preferences10 = __toESM(require_preferences(), 1); 41424 var import_editor23 = __toESM(require_editor(), 1); 41425 var import_router19 = __toESM(require_router(), 1); 41426 var import_url13 = __toESM(require_url(), 1); 41427 41428 // packages/global-styles-ui/build-module/global-styles-ui.mjs 41429 var import_components130 = __toESM(require_components(), 1); 41430 var import_blocks8 = __toESM(require_blocks(), 1); 41431 var import_data54 = __toESM(require_data(), 1); 41432 var import_block_editor19 = __toESM(require_block_editor(), 1); 41433 var import_element163 = __toESM(require_element(), 1); 41434 var import_compose27 = __toESM(require_compose(), 1); 41435 41436 // packages/global-styles-ui/build-module/provider.mjs 41437 var import_element133 = __toESM(require_element(), 1); 41438 41439 // packages/global-styles-ui/build-module/context.mjs 41440 var import_element132 = __toESM(require_element(), 1); 41441 var GlobalStylesContext = (0, import_element132.createContext)({ 41442 user: { styles: {}, settings: {} }, 41443 base: { styles: {}, settings: {} }, 41444 merged: { styles: {}, settings: {} }, 41445 onChange: () => { 41446 }, 41447 fontLibraryEnabled: false 41448 }); 41449 41450 // packages/global-styles-ui/build-module/provider.mjs 41451 var import_jsx_runtime215 = __toESM(require_jsx_runtime(), 1); 41452 function GlobalStylesProvider({ 41453 children, 41454 value, 41455 baseValue, 41456 onChange, 41457 fontLibraryEnabled 41458 }) { 41459 const merged = (0, import_element133.useMemo)(() => { 41460 return mergeGlobalStyles(baseValue, value); 41461 }, [baseValue, value]); 41462 const contextValue = (0, import_element133.useMemo)( 41463 () => ({ 41464 user: value, 41465 base: baseValue, 41466 merged, 41467 onChange, 41468 fontLibraryEnabled 41469 }), 41470 [value, baseValue, merged, onChange, fontLibraryEnabled] 41471 ); 41472 return /* @__PURE__ */ (0, import_jsx_runtime215.jsx)(GlobalStylesContext.Provider, { value: contextValue, children }); 41473 } 41474 41475 // packages/global-styles-ui/build-module/screen-root.mjs 41476 var import_components79 = __toESM(require_components(), 1); 41477 var import_i18n79 = __toESM(require_i18n(), 1); 41478 var import_data44 = __toESM(require_data(), 1); 41479 var import_core_data26 = __toESM(require_core_data(), 1); 41480 41481 // packages/global-styles-ui/build-module/icon-with-current-color.mjs 41482 var import_jsx_runtime216 = __toESM(require_jsx_runtime(), 1); 41483 function IconWithCurrentColor({ 41484 className, 41485 ...props 41486 }) { 41487 return /* @__PURE__ */ (0, import_jsx_runtime216.jsx)( 41488 icon_default, 41489 { 41490 className: clsx_default( 41491 className, 41492 "global-styles-ui-icon-with-current-color" 41493 ), 41494 ...props 41495 } 41496 ); 41497 } 41498 41499 // packages/global-styles-ui/build-module/navigation-button.mjs 41500 var import_components73 = __toESM(require_components(), 1); 41501 var import_jsx_runtime217 = __toESM(require_jsx_runtime(), 1); 41502 function GenericNavigationButton({ 41503 icon, 41504 children, 41505 ...props 41506 }) { 41507 return /* @__PURE__ */ (0, import_jsx_runtime217.jsxs)(import_components73.__experimentalItem, { ...props, children: [ 41508 icon && /* @__PURE__ */ (0, import_jsx_runtime217.jsxs)(import_components73.__experimentalHStack, { justify: "flex-start", children: [ 41509 /* @__PURE__ */ (0, import_jsx_runtime217.jsx)(IconWithCurrentColor, { icon, size: 24 }), 41510 /* @__PURE__ */ (0, import_jsx_runtime217.jsx)(import_components73.FlexItem, { children }) 41511 ] }), 41512 !icon && children 41513 ] }); 41514 } 41515 function NavigationButtonAsItem(props) { 41516 return /* @__PURE__ */ (0, import_jsx_runtime217.jsx)(import_components73.Navigator.Button, { as: GenericNavigationButton, ...props }); 41517 } 41518 41519 // packages/global-styles-ui/build-module/root-menu.mjs 41520 var import_components74 = __toESM(require_components(), 1); 41521 var import_i18n77 = __toESM(require_i18n(), 1); 41522 var import_block_editor6 = __toESM(require_block_editor(), 1); 41523 41524 // node_modules/colord/plugins/a11y.mjs 41525 var o2 = function(o3) { 41526 var t3 = o3 / 255; 41527 return t3 < 0.04045 ? t3 / 12.92 : Math.pow((t3 + 0.055) / 1.055, 2.4); 41528 }; 41529 var t2 = function(t3) { 41530 return 0.2126 * o2(t3.r) + 0.7152 * o2(t3.g) + 0.0722 * o2(t3.b); 41531 }; 41532 function a11y_default(o3) { 41533 o3.prototype.luminance = function() { 41534 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; 41535 var o4, r3, n2; 41536 }, o3.prototype.contrast = function(r3) { 41537 void 0 === r3 && (r3 = "#FFF"); 41538 var n2, a2, i2, e2, v2, u2, d2, c6 = r3 instanceof o3 ? r3 : new o3(r3); 41539 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; 41540 }, o3.prototype.isReadable = function(o4, t3) { 41541 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); 41542 var r3, n2, a2, i2, e2; 41543 }; 41544 } 41545 41546 // packages/global-styles-ui/build-module/hooks.mjs 41547 var import_element134 = __toESM(require_element(), 1); 41548 var import_data43 = __toESM(require_data(), 1); 41549 var import_core_data25 = __toESM(require_core_data(), 1); 41550 var import_i18n76 = __toESM(require_i18n(), 1); 41551 41552 // packages/global-styles-ui/build-module/utils.mjs 41553 var import_i18n75 = __toESM(require_i18n(), 1); 41554 41555 // packages/global-styles-ui/build-module/lock-unlock.mjs 41556 var import_private_apis7 = __toESM(require_private_apis(), 1); 41557 var { lock: lock6, unlock: unlock6 } = (0, import_private_apis7.__dangerousOptInToUnstableAPIsOnlyForCoreModules)( 41558 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.", 41559 "@wordpress/global-styles-ui" 41560 ); 41561 41562 // packages/global-styles-ui/build-module/utils.mjs 41563 var { getViewportBreakpoints: getViewportBreakpoints2 } = unlock6(privateApis2); 41564 var VALID_ELEMENT_STATES = { 41565 link: [ 41566 { value: ":link", label: (0, import_i18n75.__)("Link") }, 41567 { value: ":any-link", label: (0, import_i18n75.__)("Any Link") }, 41568 { value: ":visited", label: (0, import_i18n75.__)("Visited") }, 41569 { value: ":hover", label: (0, import_i18n75.__)("Hover") }, 41570 { value: ":focus", label: (0, import_i18n75.__)("Focus") }, 41571 { value: ":focus-visible", label: (0, import_i18n75.__)("Focus-visible") }, 41572 { value: ":active", label: (0, import_i18n75.__)("Active") } 41573 ], 41574 button: [ 41575 { value: ":link", label: (0, import_i18n75.__)("Link") }, 41576 { value: ":any-link", label: (0, import_i18n75.__)("Any Link") }, 41577 { value: ":visited", label: (0, import_i18n75.__)("Visited") }, 41578 { value: ":hover", label: (0, import_i18n75.__)("Hover") }, 41579 { value: ":focus", label: (0, import_i18n75.__)("Focus") }, 41580 { value: ":focus-visible", label: (0, import_i18n75.__)("Focus-visible") }, 41581 { value: ":active", label: (0, import_i18n75.__)("Active") } 41582 ] 41583 }; 41584 var VALID_BLOCK_STATES = { 41585 "core/button": [ 41586 { value: ":hover", label: (0, import_i18n75.__)("Hover") }, 41587 { value: ":focus", label: (0, import_i18n75.__)("Focus") }, 41588 { value: ":focus-visible", label: (0, import_i18n75.__)("Focus-visible") }, 41589 { value: ":active", label: (0, import_i18n75.__)("Active") } 41590 ] 41591 }; 41592 var RESPONSIVE_STATES = [ 41593 { value: "@tablet", label: (0, import_i18n75.__)("Tablet") }, 41594 { value: "@mobile", label: (0, import_i18n75.__)("Mobile") } 41595 ]; 41596 function removePropertiesFromObject(object, properties) { 41597 if (!properties?.length) { 41598 return object; 41599 } 41600 if (typeof object !== "object" || !object || !Object.keys(object).length) { 41601 return object; 41602 } 41603 for (const key in object) { 41604 if (properties.includes(key)) { 41605 delete object[key]; 41606 } else if (typeof object[key] === "object") { 41607 removePropertiesFromObject(object[key], properties); 41608 } 41609 } 41610 return object; 41611 } 41612 var filterObjectByProperties = (object, properties) => { 41613 if (!object || !properties?.length) { 41614 return {}; 41615 } 41616 const newObject = {}; 41617 Object.keys(object).forEach((key) => { 41618 if (properties.includes(key)) { 41619 newObject[key] = object[key]; 41620 } else if (typeof object[key] === "object") { 41621 const newFilter = filterObjectByProperties( 41622 object[key], 41623 properties 41624 ); 41625 if (Object.keys(newFilter).length) { 41626 newObject[key] = newFilter; 41627 } 41628 } 41629 }); 41630 return newObject; 41631 }; 41632 function isVariationWithProperties(variation, properties) { 41633 const variationWithProperties = filterObjectByProperties( 41634 structuredClone(variation), 41635 properties 41636 ); 41637 return areGlobalStylesEqual(variationWithProperties, variation); 41638 } 41639 function getFontFamilyFromSetting(fontFamilies, setting) { 41640 if (!Array.isArray(fontFamilies) || !setting) { 41641 return null; 41642 } 41643 const fontFamilyVariable = setting.replace("var(", "").replace(")", ""); 41644 const fontFamilySlug = fontFamilyVariable?.split("--").slice(-1)[0]; 41645 return fontFamilies.find( 41646 (fontFamily) => fontFamily.slug === fontFamilySlug 41647 ); 41648 } 41649 function getFontFamilies(themeJson) { 41650 const themeFontFamilies = themeJson?.settings?.typography?.fontFamilies?.theme; 41651 const customFontFamilies = themeJson?.settings?.typography?.fontFamilies?.custom; 41652 let fontFamilies = []; 41653 if (themeFontFamilies && customFontFamilies) { 41654 fontFamilies = [...themeFontFamilies, ...customFontFamilies]; 41655 } else if (themeFontFamilies) { 41656 fontFamilies = themeFontFamilies; 41657 } else if (customFontFamilies) { 41658 fontFamilies = customFontFamilies; 41659 } 41660 const bodyFontFamilySetting = themeJson?.styles?.typography?.fontFamily; 41661 const bodyFontFamily = getFontFamilyFromSetting( 41662 fontFamilies, 41663 bodyFontFamilySetting 41664 ); 41665 const headingFontFamilySetting = themeJson?.styles?.elements?.heading?.typography?.fontFamily; 41666 let headingFontFamily; 41667 if (!headingFontFamilySetting) { 41668 headingFontFamily = bodyFontFamily; 41669 } else { 41670 headingFontFamily = getFontFamilyFromSetting( 41671 fontFamilies, 41672 themeJson?.styles?.elements?.heading?.typography?.fontFamily 41673 ); 41674 } 41675 return [bodyFontFamily, headingFontFamily]; 41676 } 41677 41678 // packages/global-styles-ui/build-module/hooks.mjs 41679 k([a11y_default]); 41680 function useStyle3(path, blockName, readFrom = "merged", shouldDecodeEncode = true, state) { 41681 const { user, base, merged, onChange } = (0, import_element134.useContext)(GlobalStylesContext); 41682 const statePathParts = state?.split(".").filter(Boolean) ?? []; 41683 const pseudoSelectorState = statePathParts.find( 41684 (value) => value.startsWith(":") 41685 ); 41686 const statePathWithoutPseudo = statePathParts.filter((value) => !value.startsWith(":")).join("."); 41687 const stylePath = [path, statePathWithoutPseudo].filter(Boolean).join("."); 41688 let sourceValue = merged; 41689 if (readFrom === "base") { 41690 sourceValue = base; 41691 } else if (readFrom === "user") { 41692 sourceValue = user; 41693 } 41694 const styleValue = (0, import_element134.useMemo)(() => { 41695 const rawValue = getStyle( 41696 sourceValue, 41697 stylePath, 41698 blockName, 41699 shouldDecodeEncode 41700 ); 41701 if (pseudoSelectorState) { 41702 return rawValue?.[pseudoSelectorState] ?? {}; 41703 } 41704 return rawValue; 41705 }, [ 41706 sourceValue, 41707 stylePath, 41708 blockName, 41709 shouldDecodeEncode, 41710 pseudoSelectorState 41711 ]); 41712 const setStyleValue = (0, import_element134.useCallback)( 41713 (newValue) => { 41714 let valueToSet = newValue; 41715 if (pseudoSelectorState) { 41716 const fullCurrentValue = getStyle( 41717 user, 41718 stylePath, 41719 blockName, 41720 false 41721 ); 41722 valueToSet = { 41723 ...fullCurrentValue, 41724 [pseudoSelectorState]: newValue 41725 }; 41726 } 41727 const newGlobalStyles = setStyle( 41728 user, 41729 stylePath, 41730 valueToSet, 41731 blockName 41732 ); 41733 onChange(newGlobalStyles); 41734 }, 41735 [user, onChange, stylePath, blockName, pseudoSelectorState] 41736 ); 41737 return [styleValue, setStyleValue]; 41738 } 41739 function useSetting(path, blockName, readFrom = "merged") { 41740 const { user, base, merged, onChange } = (0, import_element134.useContext)(GlobalStylesContext); 41741 let sourceValue = merged; 41742 if (readFrom === "base") { 41743 sourceValue = base; 41744 } else if (readFrom === "user") { 41745 sourceValue = user; 41746 } 41747 const settingValue = (0, import_element134.useMemo)( 41748 () => getSetting(sourceValue, path, blockName), 41749 [sourceValue, path, blockName] 41750 ); 41751 const setSettingValue = (0, import_element134.useCallback)( 41752 (newValue) => { 41753 const newGlobalStyles = setSetting( 41754 user, 41755 path, 41756 newValue, 41757 blockName 41758 ); 41759 onChange(newGlobalStyles); 41760 }, 41761 [user, onChange, path, blockName] 41762 ); 41763 return [settingValue, setSettingValue]; 41764 } 41765 var EMPTY_ARRAY10 = []; 41766 function hasThemeVariation({ 41767 title, 41768 settings: settings2, 41769 styles 41770 }) { 41771 return title === (0, import_i18n76.__)("Default") || Object.keys(settings2 || {}).length > 0 || Object.keys(styles || {}).length > 0; 41772 } 41773 function useCurrentMergeThemeStyleVariationsWithUserConfig(properties = []) { 41774 const { variationsFromTheme } = (0, import_data43.useSelect)((select4) => { 41775 const _variationsFromTheme = select4( 41776 import_core_data25.store 41777 ).__experimentalGetCurrentThemeGlobalStylesVariations?.(); 41778 return { 41779 variationsFromTheme: _variationsFromTheme || EMPTY_ARRAY10 41780 }; 41781 }, []); 41782 const { user: userVariation } = (0, import_element134.useContext)(GlobalStylesContext); 41783 return (0, import_element134.useMemo)(() => { 41784 const clonedUserVariation = structuredClone(userVariation); 41785 const userVariationWithoutProperties = removePropertiesFromObject( 41786 clonedUserVariation, 41787 properties 41788 ); 41789 userVariationWithoutProperties.title = (0, import_i18n76.__)("Default"); 41790 const variationsWithPropertiesAndBase = variationsFromTheme.filter((variation) => { 41791 return isVariationWithProperties(variation, properties); 41792 }).map((variation) => { 41793 return mergeGlobalStyles( 41794 userVariationWithoutProperties, 41795 variation 41796 ); 41797 }); 41798 const variationsByProperties = [ 41799 userVariationWithoutProperties, 41800 ...variationsWithPropertiesAndBase 41801 ]; 41802 return variationsByProperties?.length ? variationsByProperties.filter(hasThemeVariation) : []; 41803 }, [properties, userVariation, variationsFromTheme]); 41804 } 41805 41806 // packages/global-styles-ui/build-module/root-menu.mjs 41807 var import_jsx_runtime218 = __toESM(require_jsx_runtime(), 1); 41808 var { 41809 useHasDimensionsPanel, 41810 useHasTypographyPanel, 41811 useHasColorPanel, 41812 useSettingsForBlockElement, 41813 useHasBackgroundPanel 41814 } = unlock6(import_block_editor6.privateApis); 41815 41816 // packages/global-styles-ui/build-module/preview-styles.mjs 41817 var import_components78 = __toESM(require_components(), 1); 41818 41819 // packages/global-styles-ui/build-module/preview-hooks.mjs 41820 function useStylesPreviewColors() { 41821 const [textColor = "black"] = useStyle3("color.text"); 41822 const [backgroundColor = "white"] = useStyle3("color.background"); 41823 const [headingColor = textColor] = useStyle3( 41824 "elements.h1.color.text" 41825 ); 41826 const [linkColor = headingColor] = useStyle3( 41827 "elements.link.color.text" 41828 ); 41829 const [buttonBackgroundColor = linkColor] = useStyle3( 41830 "elements.button.color.background" 41831 ); 41832 const [coreColors] = useSetting("color.palette.core") || []; 41833 const [themeColors] = useSetting("color.palette.theme") || []; 41834 const [customColors] = useSetting("color.palette.custom") || []; 41835 const paletteColors = (themeColors ?? []).concat(customColors ?? []).concat(coreColors ?? []); 41836 const textColorObject = paletteColors.filter( 41837 ({ color }) => color === textColor 41838 ); 41839 const buttonBackgroundColorObject = paletteColors.filter( 41840 ({ color }) => color === buttonBackgroundColor 41841 ); 41842 const highlightedColors = textColorObject.concat(buttonBackgroundColorObject).concat(paletteColors).filter( 41843 // we exclude these background color because it is already visible in the preview. 41844 ({ color }) => color !== backgroundColor 41845 ).slice(0, 2); 41846 return { 41847 paletteColors, 41848 highlightedColors 41849 }; 41850 } 41851 41852 // packages/global-styles-ui/build-module/typography-example.mjs 41853 var import_element135 = __toESM(require_element(), 1); 41854 var import_components75 = __toESM(require_components(), 1); 41855 var import_i18n78 = __toESM(require_i18n(), 1); 41856 41857 // packages/global-styles-ui/build-module/font-library/utils/preview-styles.mjs 41858 function findNearest(input, numbers) { 41859 if (numbers.length === 0) { 41860 return null; 41861 } 41862 numbers.sort((a2, b2) => Math.abs(input - a2) - Math.abs(input - b2)); 41863 return numbers[0]; 41864 } 41865 function extractFontWeights(fontFaces) { 41866 const result = []; 41867 fontFaces.forEach((face) => { 41868 const weights = String(face.fontWeight).split(" "); 41869 if (weights.length === 2) { 41870 const start2 = parseInt(weights[0]); 41871 const end = parseInt(weights[1]); 41872 for (let i2 = start2; i2 <= end; i2 += 100) { 41873 result.push(i2); 41874 } 41875 } else if (weights.length === 1) { 41876 result.push(parseInt(weights[0])); 41877 } 41878 }); 41879 return result; 41880 } 41881 function formatFontFamily(input) { 41882 const regex = /^(?!generic\([ a-zA-Z\-]+\)$)(?!^[a-zA-Z\-]+$).+/; 41883 const output = input.trim(); 41884 const formatItem = (item) => { 41885 item = item.trim(); 41886 if (item.match(regex)) { 41887 item = item.replace(/^["']|["']$/g, ""); 41888 return `"$item}"`; 41889 } 41890 return item; 41891 }; 41892 if (output.includes(",")) { 41893 return output.split(",").map(formatItem).filter((item) => item !== "").join(", "); 41894 } 41895 return formatItem(output); 41896 } 41897 function getFamilyPreviewStyle(family) { 41898 const style = { 41899 fontFamily: formatFontFamily(family.fontFamily) 41900 }; 41901 if (!("fontFace" in family) || !Array.isArray(family.fontFace)) { 41902 style.fontWeight = "400"; 41903 style.fontStyle = "normal"; 41904 return style; 41905 } 41906 if (family.fontFace) { 41907 const normalFaces = family.fontFace.filter( 41908 (face) => face?.fontStyle && face.fontStyle.toLowerCase() === "normal" 41909 ); 41910 if (normalFaces.length > 0) { 41911 style.fontStyle = "normal"; 41912 const normalWeights = extractFontWeights(normalFaces); 41913 const nearestWeight = findNearest(400, normalWeights); 41914 style.fontWeight = String(nearestWeight) || "400"; 41915 } else { 41916 style.fontStyle = family.fontFace.length && family.fontFace[0].fontStyle || "normal"; 41917 style.fontWeight = family.fontFace.length && String(family.fontFace[0].fontWeight) || "400"; 41918 } 41919 } 41920 return style; 41921 } 41922 41923 // packages/global-styles-ui/build-module/typography-example.mjs 41924 var import_jsx_runtime219 = __toESM(require_jsx_runtime(), 1); 41925 function PreviewTypography({ 41926 fontSize, 41927 variation 41928 }) { 41929 const { base } = (0, import_element135.useContext)(GlobalStylesContext); 41930 let config2 = base; 41931 if (variation) { 41932 config2 = { ...base, ...variation }; 41933 } 41934 const [textColor] = useStyle3("color.text"); 41935 const [bodyFontFamilies, headingFontFamilies] = getFontFamilies(config2); 41936 const bodyPreviewStyle = bodyFontFamilies ? getFamilyPreviewStyle(bodyFontFamilies) : {}; 41937 const headingPreviewStyle = headingFontFamilies ? getFamilyPreviewStyle(headingFontFamilies) : {}; 41938 if (textColor) { 41939 bodyPreviewStyle.color = textColor; 41940 headingPreviewStyle.color = textColor; 41941 } 41942 if (fontSize) { 41943 bodyPreviewStyle.fontSize = fontSize; 41944 headingPreviewStyle.fontSize = fontSize; 41945 } 41946 return /* @__PURE__ */ (0, import_jsx_runtime219.jsxs)( 41947 import_components75.__unstableMotion.div, 41948 { 41949 animate: { 41950 scale: 1, 41951 opacity: 1 41952 }, 41953 initial: { 41954 scale: 0.1, 41955 opacity: 0 41956 }, 41957 transition: { 41958 delay: 0.3, 41959 type: "tween" 41960 }, 41961 style: { 41962 textAlign: "center", 41963 lineHeight: 1 41964 }, 41965 children: [ 41966 /* @__PURE__ */ (0, import_jsx_runtime219.jsx)("span", { style: headingPreviewStyle, children: (0, import_i18n78._x)("A", "Uppercase letter A") }), 41967 /* @__PURE__ */ (0, import_jsx_runtime219.jsx)("span", { style: bodyPreviewStyle, children: (0, import_i18n78._x)("a", "Lowercase letter A") }) 41968 ] 41969 } 41970 ); 41971 } 41972 41973 // packages/global-styles-ui/build-module/highlighted-colors.mjs 41974 var import_components76 = __toESM(require_components(), 1); 41975 var import_jsx_runtime220 = __toESM(require_jsx_runtime(), 1); 41976 function HighlightedColors({ 41977 normalizedColorSwatchSize, 41978 ratio 41979 }) { 41980 const { highlightedColors } = useStylesPreviewColors(); 41981 const scaledSwatchSize = normalizedColorSwatchSize * ratio; 41982 return highlightedColors.map(({ slug, color }, index2) => /* @__PURE__ */ (0, import_jsx_runtime220.jsx)( 41983 import_components76.__unstableMotion.div, 41984 { 41985 style: { 41986 height: scaledSwatchSize, 41987 width: scaledSwatchSize, 41988 background: color, 41989 borderRadius: scaledSwatchSize / 2 41990 }, 41991 animate: { 41992 scale: 1, 41993 opacity: 1 41994 }, 41995 initial: { 41996 scale: 0.1, 41997 opacity: 0 41998 }, 41999 transition: { 42000 delay: index2 === 1 ? 0.2 : 0.1 42001 } 42002 }, 42003 `$slug}-$index2}` 42004 )); 42005 } 42006 42007 // packages/global-styles-ui/build-module/preview-wrapper.mjs 42008 var import_components77 = __toESM(require_components(), 1); 42009 var import_compose22 = __toESM(require_compose(), 1); 42010 var import_element136 = __toESM(require_element(), 1); 42011 var import_jsx_runtime221 = __toESM(require_jsx_runtime(), 1); 42012 var normalizedWidth = 248; 42013 var normalizedHeight = 152; 42014 var THROTTLE_OPTIONS = { 42015 leading: true, 42016 trailing: true 42017 }; 42018 function PreviewWrapper({ 42019 children, 42020 label, 42021 isFocused, 42022 withHoverView 42023 }) { 42024 const [backgroundColor = "white"] = useStyle3("color.background"); 42025 const [gradientValue] = useStyle3("color.gradient"); 42026 const disableMotion = (0, import_compose22.useReducedMotion)(); 42027 const [isHovered, setIsHovered] = (0, import_element136.useState)(false); 42028 const [containerResizeListener, { width }] = (0, import_compose22.useResizeObserver)(); 42029 const [throttledWidth, setThrottledWidthState] = (0, import_element136.useState)(width); 42030 const [ratioState, setRatioState] = (0, import_element136.useState)(); 42031 const setThrottledWidth = (0, import_compose22.useThrottle)( 42032 setThrottledWidthState, 42033 250, 42034 THROTTLE_OPTIONS 42035 ); 42036 (0, import_element136.useLayoutEffect)(() => { 42037 if (width) { 42038 setThrottledWidth(width); 42039 } 42040 }, [width, setThrottledWidth]); 42041 (0, import_element136.useLayoutEffect)(() => { 42042 const newRatio = throttledWidth ? throttledWidth / normalizedWidth : 1; 42043 const ratioDiff = newRatio - (ratioState || 0); 42044 const isRatioDiffBigEnough = Math.abs(ratioDiff) > 0.1; 42045 if (isRatioDiffBigEnough || !ratioState) { 42046 setRatioState(newRatio); 42047 } 42048 }, [throttledWidth, ratioState]); 42049 const fallbackRatio = width ? width / normalizedWidth : 1; 42050 const ratio = ratioState ? ratioState : fallbackRatio; 42051 const isReady = !!width; 42052 return /* @__PURE__ */ (0, import_jsx_runtime221.jsxs)(import_jsx_runtime221.Fragment, { children: [ 42053 /* @__PURE__ */ (0, import_jsx_runtime221.jsx)("div", { style: { position: "relative" }, children: containerResizeListener }), 42054 !isReady && // Match the preview aspect ratio so layout doesn't jump once width is measured. 42055 /* @__PURE__ */ (0, import_jsx_runtime221.jsx)( 42056 Skeleton, 42057 { 42058 className: "global-styles-ui-preview__wrapper", 42059 style: { 42060 aspectRatio: normalizedWidth / normalizedHeight 42061 } 42062 } 42063 ), 42064 isReady && /* @__PURE__ */ (0, import_jsx_runtime221.jsx)( 42065 "div", 42066 { 42067 className: clsx_default("global-styles-ui-preview__wrapper", { 42068 "is-hoverable": withHoverView 42069 }), 42070 style: { 42071 height: normalizedHeight * ratio 42072 }, 42073 onMouseEnter: () => setIsHovered(true), 42074 onMouseLeave: () => setIsHovered(false), 42075 tabIndex: -1, 42076 children: /* @__PURE__ */ (0, import_jsx_runtime221.jsx)( 42077 import_components77.__unstableMotion.div, 42078 { 42079 style: { 42080 height: normalizedHeight * ratio, 42081 width: "100%", 42082 background: gradientValue ?? backgroundColor 42083 }, 42084 initial: "start", 42085 animate: (isHovered || isFocused) && !disableMotion && label ? "hover" : "start", 42086 children: [].concat(children).map( 42087 (child, key) => child({ ratio, key }) 42088 ) 42089 } 42090 ) 42091 } 42092 ) 42093 ] }); 42094 } 42095 var preview_wrapper_default = PreviewWrapper; 42096 42097 // packages/global-styles-ui/build-module/preview-styles.mjs 42098 var import_jsx_runtime222 = __toESM(require_jsx_runtime(), 1); 42099 var firstFrameVariants = { 42100 start: { 42101 scale: 1, 42102 opacity: 1 42103 }, 42104 hover: { 42105 scale: 0, 42106 opacity: 0 42107 } 42108 }; 42109 var midFrameVariants = { 42110 hover: { 42111 opacity: 1 42112 }, 42113 start: { 42114 opacity: 0.5 42115 } 42116 }; 42117 var secondFrameVariants = { 42118 hover: { 42119 scale: 1, 42120 opacity: 1 42121 }, 42122 start: { 42123 scale: 0, 42124 opacity: 0 42125 } 42126 }; 42127 function PreviewStyles({ 42128 label, 42129 isFocused, 42130 withHoverView, 42131 variation 42132 }) { 42133 const [fontWeight] = useStyle3("typography.fontWeight"); 42134 const [fontFamily = "serif"] = useStyle3( 42135 "typography.fontFamily" 42136 ); 42137 const [headingFontFamily = fontFamily] = useStyle3( 42138 "elements.h1.typography.fontFamily" 42139 ); 42140 const [headingFontWeight = fontWeight] = useStyle3( 42141 "elements.h1.typography.fontWeight" 42142 ); 42143 const [textColor = "black"] = useStyle3("color.text"); 42144 const [headingColor = textColor] = useStyle3( 42145 "elements.h1.color.text" 42146 ); 42147 const { paletteColors } = useStylesPreviewColors(); 42148 return /* @__PURE__ */ (0, import_jsx_runtime222.jsxs)( 42149 preview_wrapper_default, 42150 { 42151 label, 42152 isFocused, 42153 withHoverView, 42154 children: [ 42155 ({ ratio, key }) => /* @__PURE__ */ (0, import_jsx_runtime222.jsx)( 42156 import_components78.__unstableMotion.div, 42157 { 42158 variants: firstFrameVariants, 42159 style: { 42160 height: "100%", 42161 overflow: "hidden" 42162 }, 42163 children: /* @__PURE__ */ (0, import_jsx_runtime222.jsxs)( 42164 import_components78.__experimentalHStack, 42165 { 42166 spacing: 10 * ratio, 42167 justify: "center", 42168 style: { 42169 height: "100%", 42170 overflow: "hidden" 42171 }, 42172 children: [ 42173 /* @__PURE__ */ (0, import_jsx_runtime222.jsx)( 42174 PreviewTypography, 42175 { 42176 fontSize: 65 * ratio, 42177 variation 42178 } 42179 ), 42180 /* @__PURE__ */ (0, import_jsx_runtime222.jsx)(import_components78.__experimentalVStack, { spacing: 4 * ratio, children: /* @__PURE__ */ (0, import_jsx_runtime222.jsx)( 42181 HighlightedColors, 42182 { 42183 normalizedColorSwatchSize: 32, 42184 ratio 42185 } 42186 ) }) 42187 ] 42188 } 42189 ) 42190 }, 42191 key 42192 ), 42193 ({ key }) => /* @__PURE__ */ (0, import_jsx_runtime222.jsx)( 42194 import_components78.__unstableMotion.div, 42195 { 42196 variants: withHoverView ? midFrameVariants : void 0, 42197 style: { 42198 height: "100%", 42199 width: "100%", 42200 position: "absolute", 42201 top: 0, 42202 overflow: "hidden", 42203 filter: "blur(60px)", 42204 opacity: 0.1 42205 }, 42206 children: /* @__PURE__ */ (0, import_jsx_runtime222.jsx)( 42207 import_components78.__experimentalHStack, 42208 { 42209 spacing: 0, 42210 justify: "flex-start", 42211 style: { 42212 height: "100%", 42213 overflow: "hidden" 42214 }, 42215 children: paletteColors.slice(0, 4).map(({ color }, index2) => /* @__PURE__ */ (0, import_jsx_runtime222.jsx)( 42216 "div", 42217 { 42218 style: { 42219 height: "100%", 42220 background: color, 42221 flexGrow: 1 42222 } 42223 }, 42224 index2 42225 )) 42226 } 42227 ) 42228 }, 42229 key 42230 ), 42231 ({ ratio, key }) => /* @__PURE__ */ (0, import_jsx_runtime222.jsx)( 42232 import_components78.__unstableMotion.div, 42233 { 42234 variants: secondFrameVariants, 42235 style: { 42236 height: "100%", 42237 width: "100%", 42238 overflow: "hidden", 42239 position: "absolute", 42240 top: 0 42241 }, 42242 children: /* @__PURE__ */ (0, import_jsx_runtime222.jsx)( 42243 import_components78.__experimentalVStack, 42244 { 42245 spacing: 3 * ratio, 42246 justify: "center", 42247 style: { 42248 height: "100%", 42249 overflow: "hidden", 42250 padding: 10 * ratio, 42251 boxSizing: "border-box" 42252 }, 42253 children: label && /* @__PURE__ */ (0, import_jsx_runtime222.jsx)( 42254 "div", 42255 { 42256 style: { 42257 fontSize: 40 * ratio, 42258 fontFamily: headingFontFamily, 42259 color: headingColor, 42260 fontWeight: headingFontWeight, 42261 lineHeight: "1em", 42262 textAlign: "center" 42263 }, 42264 children: label 42265 } 42266 ) 42267 } 42268 ) 42269 }, 42270 key 42271 ) 42272 ] 42273 } 42274 ); 42275 } 42276 var preview_styles_default = PreviewStyles; 42277 42278 // packages/global-styles-ui/build-module/screen-root.mjs 42279 var import_jsx_runtime223 = __toESM(require_jsx_runtime(), 1); 42280 42281 // packages/global-styles-ui/build-module/screen-block-list.mjs 42282 var import_blocks5 = __toESM(require_blocks(), 1); 42283 var import_i18n81 = __toESM(require_i18n(), 1); 42284 var import_components82 = __toESM(require_components(), 1); 42285 var import_data46 = __toESM(require_data(), 1); 42286 var import_element137 = __toESM(require_element(), 1); 42287 var import_block_editor8 = __toESM(require_block_editor(), 1); 42288 var import_compose23 = __toESM(require_compose(), 1); 42289 var import_a11y5 = __toESM(require_a11y(), 1); 42290 42291 // packages/global-styles-ui/build-module/variations/variations-panel.mjs 42292 var import_blocks4 = __toESM(require_blocks(), 1); 42293 var import_data45 = __toESM(require_data(), 1); 42294 var import_components80 = __toESM(require_components(), 1); 42295 var import_jsx_runtime224 = __toESM(require_jsx_runtime(), 1); 42296 function getFilteredBlockStyles(blockStyles, variations) { 42297 return blockStyles?.filter( 42298 (style) => style.source === "block" || variations.includes(style.name) 42299 ) || []; 42300 } 42301 function useBlockVariations(name2) { 42302 const blockStyles = (0, import_data45.useSelect)( 42303 (select4) => { 42304 const { getBlockStyles } = select4(import_blocks4.store); 42305 return getBlockStyles(name2); 42306 }, 42307 [name2] 42308 ); 42309 const [variations] = useStyle3("variations", name2); 42310 const variationNames = Object.keys(variations ?? {}); 42311 return getFilteredBlockStyles(blockStyles, variationNames); 42312 } 42313 42314 // packages/global-styles-ui/build-module/screen-header.mjs 42315 var import_components81 = __toESM(require_components(), 1); 42316 var import_i18n80 = __toESM(require_i18n(), 1); 42317 var import_block_editor7 = __toESM(require_block_editor(), 1); 42318 var import_jsx_runtime225 = __toESM(require_jsx_runtime(), 1); 42319 var { StateControl, StateControlBadges } = unlock6(import_block_editor7.privateApis); 42320 42321 // packages/global-styles-ui/build-module/screen-block-list.mjs 42322 var import_jsx_runtime226 = __toESM(require_jsx_runtime(), 1); 42323 var { 42324 useHasDimensionsPanel: useHasDimensionsPanel2, 42325 useHasTypographyPanel: useHasTypographyPanel2, 42326 useHasBorderPanel, 42327 useSettingsForBlockElement: useSettingsForBlockElement2, 42328 useHasColorPanel: useHasColorPanel2, 42329 useHasBackgroundPanel: useHasBackgroundPanel2 42330 } = unlock6(import_block_editor8.privateApis); 42331 function useSortedBlockTypes() { 42332 const blockItems = (0, import_data46.useSelect)( 42333 (select4) => select4(import_blocks5.store).getBlockTypes(), 42334 [] 42335 ); 42336 const groupByType = (blocks, block) => { 42337 const { core, noncore } = blocks; 42338 const type = block.name.startsWith("core/") ? core : noncore; 42339 type.push(block); 42340 return blocks; 42341 }; 42342 const { core: coreItems, noncore: nonCoreItems } = blockItems.reduce( 42343 groupByType, 42344 { core: [], noncore: [] } 42345 ); 42346 return [...coreItems, ...nonCoreItems]; 42347 } 42348 function useBlockHasGlobalStyles(blockName) { 42349 const [rawSettings] = useSetting("", blockName); 42350 const settings2 = useSettingsForBlockElement2(rawSettings, blockName); 42351 const hasTypographyPanel = useHasTypographyPanel2(settings2); 42352 const hasColorPanel = useHasColorPanel2(settings2); 42353 const hasBackgroundPanel = useHasBackgroundPanel2(settings2); 42354 const hasBorderPanel = useHasBorderPanel(settings2); 42355 const hasDimensionsPanel = useHasDimensionsPanel2(settings2); 42356 const hasLayoutPanel = hasBorderPanel || hasDimensionsPanel; 42357 const hasVariationsPanel = !!useBlockVariations(blockName)?.length; 42358 const hasGlobalStyles = hasTypographyPanel || hasColorPanel || hasBackgroundPanel || hasLayoutPanel || hasVariationsPanel; 42359 return hasGlobalStyles; 42360 } 42361 function BlockMenuItem({ block }) { 42362 const hasBlockMenuItem = useBlockHasGlobalStyles(block.name); 42363 if (!hasBlockMenuItem) { 42364 return null; 42365 } 42366 return /* @__PURE__ */ (0, import_jsx_runtime226.jsx)( 42367 NavigationButtonAsItem, 42368 { 42369 path: "/blocks/" + encodeURIComponent(block.name), 42370 children: /* @__PURE__ */ (0, import_jsx_runtime226.jsxs)(import_components82.__experimentalHStack, { justify: "flex-start", children: [ 42371 /* @__PURE__ */ (0, import_jsx_runtime226.jsx)(import_block_editor8.BlockIcon, { icon: block.icon }), 42372 /* @__PURE__ */ (0, import_jsx_runtime226.jsx)(import_components82.FlexItem, { children: block.title }) 42373 ] }) 42374 } 42375 ); 42376 } 42377 function BlockList({ filterValue }) { 42378 const sortedBlockTypes = useSortedBlockTypes(); 42379 const debouncedSpeak = (0, import_compose23.useDebounce)(import_a11y5.speak, 500); 42380 const { isMatchingSearchTerm } = (0, import_data46.useSelect)(import_blocks5.store); 42381 const filteredBlockTypes = !filterValue ? sortedBlockTypes : sortedBlockTypes.filter( 42382 (blockType) => isMatchingSearchTerm(blockType, filterValue) 42383 ); 42384 const blockTypesListRef = (0, import_element137.useRef)(null); 42385 (0, import_element137.useEffect)(() => { 42386 if (!filterValue) { 42387 return; 42388 } 42389 const count = blockTypesListRef.current?.childElementCount || 0; 42390 const resultsFoundMessage = (0, import_i18n81.sprintf)( 42391 /* translators: %d: number of results. */ 42392 (0, import_i18n81._n)("%d result found.", "%d results found.", count), 42393 count 42394 ); 42395 debouncedSpeak(resultsFoundMessage, "polite"); 42396 }, [filterValue, debouncedSpeak]); 42397 return /* @__PURE__ */ (0, import_jsx_runtime226.jsx)( 42398 "div", 42399 { 42400 ref: blockTypesListRef, 42401 className: "global-styles-ui-block-types-item-list", 42402 role: "list", 42403 children: filteredBlockTypes.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime226.jsx)(import_components82.__experimentalText, { align: "center", as: "p", children: (0, import_i18n81.__)("No blocks found.") }) : filteredBlockTypes.map((block) => /* @__PURE__ */ (0, import_jsx_runtime226.jsx)( 42404 BlockMenuItem, 42405 { 42406 block 42407 }, 42408 "menu-itemblock-" + block.name 42409 )) 42410 } 42411 ); 42412 } 42413 var MemoizedBlockList = (0, import_element137.memo)(BlockList); 42414 42415 // packages/global-styles-ui/build-module/screen-block.mjs 42416 var import_blocks7 = __toESM(require_blocks(), 1); 42417 var import_block_editor10 = __toESM(require_block_editor(), 1); 42418 var import_element139 = __toESM(require_element(), 1); 42419 var import_data47 = __toESM(require_data(), 1); 42420 var import_core_data27 = __toESM(require_core_data(), 1); 42421 var import_components85 = __toESM(require_components(), 1); 42422 var import_i18n82 = __toESM(require_i18n(), 1); 42423 42424 // packages/global-styles-ui/build-module/block-preview-panel.mjs 42425 var import_block_editor9 = __toESM(require_block_editor(), 1); 42426 var import_blocks6 = __toESM(require_blocks(), 1); 42427 var import_components83 = __toESM(require_components(), 1); 42428 var import_element138 = __toESM(require_element(), 1); 42429 var import_jsx_runtime227 = __toESM(require_jsx_runtime(), 1); 42430 var { getViewportBreakpoints: getViewportBreakpoints3, getViewportBreakpointValueInPixels: getViewportBreakpointValueInPixels2 } = unlock6( 42431 privateApis2 42432 ); 42433 42434 // packages/global-styles-ui/build-module/subtitle.mjs 42435 var import_components84 = __toESM(require_components(), 1); 42436 var import_jsx_runtime228 = __toESM(require_jsx_runtime(), 1); 42437 function Subtitle({ children, level = 2 }) { 42438 return /* @__PURE__ */ (0, import_jsx_runtime228.jsx)(import_components84.__experimentalHeading, { className: "global-styles-ui-subtitle", level, children }); 42439 } 42440 42441 // packages/global-styles-ui/build-module/screen-block.mjs 42442 var import_jsx_runtime229 = __toESM(require_jsx_runtime(), 1); 42443 var { 42444 useHasDimensionsPanel: useHasDimensionsPanel3, 42445 useHasTypographyPanel: useHasTypographyPanel3, 42446 useHasBorderPanel: useHasBorderPanel2, 42447 useSettingsForBlockElement: useSettingsForBlockElement3, 42448 useHasColorPanel: useHasColorPanel3, 42449 useHasFiltersPanel, 42450 useHasImageSettingsPanel, 42451 useHasBackgroundPanel: useHasBackgroundPanel3, 42452 BackgroundPanel: StylesBackgroundPanel, 42453 BorderPanel: StylesBorderPanel, 42454 ColorPanel: StylesColorPanel, 42455 TypographyPanel: StylesTypographyPanel, 42456 DimensionsPanel: StylesDimensionsPanel, 42457 FiltersPanel: StylesFiltersPanel, 42458 ImageSettingsPanel, 42459 AdvancedPanel: StylesAdvancedPanel 42460 } = unlock6(import_block_editor10.privateApis); 42461 42462 // packages/global-styles-ui/build-module/screen-typography.mjs 42463 var import_i18n96 = __toESM(require_i18n(), 1); 42464 var import_components104 = __toESM(require_components(), 1); 42465 var import_element151 = __toESM(require_element(), 1); 42466 42467 // packages/global-styles-ui/build-module/screen-body.mjs 42468 var import_components86 = __toESM(require_components(), 1); 42469 var import_jsx_runtime230 = __toESM(require_jsx_runtime(), 1); 42470 42471 // packages/global-styles-ui/build-module/typography-elements.mjs 42472 var import_i18n83 = __toESM(require_i18n(), 1); 42473 var import_components87 = __toESM(require_components(), 1); 42474 var import_jsx_runtime231 = __toESM(require_jsx_runtime(), 1); 42475 42476 // packages/global-styles-ui/build-module/variations/variations-typography.mjs 42477 var import_components89 = __toESM(require_components(), 1); 42478 42479 // packages/global-styles-ui/build-module/preview-typography.mjs 42480 var import_components88 = __toESM(require_components(), 1); 42481 var import_jsx_runtime232 = __toESM(require_jsx_runtime(), 1); 42482 var StylesPreviewTypography = ({ 42483 variation, 42484 isFocused, 42485 withHoverView 42486 }) => { 42487 return /* @__PURE__ */ (0, import_jsx_runtime232.jsx)( 42488 preview_wrapper_default, 42489 { 42490 label: variation.title, 42491 isFocused, 42492 withHoverView, 42493 children: ({ ratio, key }) => /* @__PURE__ */ (0, import_jsx_runtime232.jsx)( 42494 import_components88.__experimentalHStack, 42495 { 42496 spacing: 10 * ratio, 42497 justify: "center", 42498 style: { 42499 height: "100%", 42500 overflow: "hidden" 42501 }, 42502 children: /* @__PURE__ */ (0, import_jsx_runtime232.jsx)( 42503 PreviewTypography, 42504 { 42505 variation, 42506 fontSize: 85 * ratio 42507 } 42508 ) 42509 }, 42510 key 42511 ) 42512 } 42513 ); 42514 }; 42515 var preview_typography_default = StylesPreviewTypography; 42516 42517 // packages/global-styles-ui/build-module/variations/variation.mjs 42518 var import_element140 = __toESM(require_element(), 1); 42519 var import_keycodes5 = __toESM(require_keycodes(), 1); 42520 var import_i18n84 = __toESM(require_i18n(), 1); 42521 var import_jsx_runtime233 = __toESM(require_jsx_runtime(), 1); 42522 function Variation({ 42523 variation, 42524 children, 42525 isPill = false, 42526 properties, 42527 showTooltip = false 42528 }) { 42529 const [isFocused, setIsFocused] = (0, import_element140.useState)(false); 42530 const { 42531 base, 42532 user, 42533 onChange: setUserConfig 42534 } = (0, import_element140.useContext)(GlobalStylesContext); 42535 const context = (0, import_element140.useMemo)(() => { 42536 let merged = mergeGlobalStyles(base, variation); 42537 if (properties) { 42538 merged = filterObjectByProperties(merged, properties); 42539 } 42540 return { 42541 user: variation, 42542 base, 42543 merged, 42544 onChange: () => { 42545 } 42546 }; 42547 }, [variation, base, properties]); 42548 const selectVariation = () => setUserConfig(variation); 42549 const selectOnEnter = (event) => { 42550 if (event.keyCode === import_keycodes5.ENTER) { 42551 event.preventDefault(); 42552 selectVariation(); 42553 } 42554 }; 42555 const isActive = (0, import_element140.useMemo)( 42556 () => areGlobalStylesEqual(user, variation), 42557 [user, variation] 42558 ); 42559 let label = variation?.title; 42560 if (variation?.description) { 42561 label = (0, import_i18n84.sprintf)( 42562 /* translators: 1: variation title. 2: variation description. */ 42563 (0, import_i18n84._x)("%1$s (%2$s)", "variation label"), 42564 variation?.title, 42565 variation?.description 42566 ); 42567 } 42568 const content = /* @__PURE__ */ (0, import_jsx_runtime233.jsx)( 42569 "div", 42570 { 42571 className: clsx_default("global-styles-ui-variations_item", { 42572 "is-active": isActive 42573 }), 42574 role: "button", 42575 onClick: selectVariation, 42576 onKeyDown: selectOnEnter, 42577 tabIndex: 0, 42578 "aria-label": label, 42579 "aria-current": isActive, 42580 onFocus: () => setIsFocused(true), 42581 onBlur: () => setIsFocused(false), 42582 children: /* @__PURE__ */ (0, import_jsx_runtime233.jsx)( 42583 "div", 42584 { 42585 className: clsx_default("global-styles-ui-variations_item-preview", { 42586 "is-pill": isPill 42587 }), 42588 children: children(isFocused) 42589 } 42590 ) 42591 } 42592 ); 42593 return /* @__PURE__ */ (0, import_jsx_runtime233.jsx)(GlobalStylesContext.Provider, { value: context, children: showTooltip ? /* @__PURE__ */ (0, import_jsx_runtime233.jsxs)(tooltip_exports.Root, { children: [ 42594 /* @__PURE__ */ (0, import_jsx_runtime233.jsx)(tooltip_exports.Trigger, { render: content }), 42595 /* @__PURE__ */ (0, import_jsx_runtime233.jsx)(tooltip_exports.Popup, { children: variation?.title }) 42596 ] }) : content }); 42597 } 42598 42599 // packages/global-styles-ui/build-module/variations/variations-typography.mjs 42600 var import_jsx_runtime234 = __toESM(require_jsx_runtime(), 1); 42601 var propertiesToFilter = ["typography"]; 42602 function TypographyVariations({ 42603 title, 42604 gap = 2 42605 }) { 42606 const typographyVariations = useCurrentMergeThemeStyleVariationsWithUserConfig(propertiesToFilter); 42607 if (typographyVariations?.length <= 1) { 42608 return null; 42609 } 42610 return /* @__PURE__ */ (0, import_jsx_runtime234.jsxs)(import_components89.__experimentalVStack, { spacing: 3, children: [ 42611 title && /* @__PURE__ */ (0, import_jsx_runtime234.jsx)(Subtitle, { level: 3, children: title }), 42612 /* @__PURE__ */ (0, import_jsx_runtime234.jsx)( 42613 import_components89.__experimentalGrid, 42614 { 42615 columns: 3, 42616 gap, 42617 className: "global-styles-ui-style-variations-container", 42618 children: typographyVariations.map( 42619 (variation, index2) => { 42620 return /* @__PURE__ */ (0, import_jsx_runtime234.jsx)( 42621 Variation, 42622 { 42623 variation, 42624 properties: propertiesToFilter, 42625 showTooltip: true, 42626 children: () => /* @__PURE__ */ (0, import_jsx_runtime234.jsx)( 42627 preview_typography_default, 42628 { 42629 variation 42630 } 42631 ) 42632 }, 42633 index2 42634 ); 42635 } 42636 ) 42637 } 42638 ) 42639 ] }); 42640 } 42641 42642 // packages/global-styles-ui/build-module/font-families.mjs 42643 var import_i18n94 = __toESM(require_i18n(), 1); 42644 var import_components102 = __toESM(require_components(), 1); 42645 var import_element150 = __toESM(require_element(), 1); 42646 42647 // packages/global-styles-ui/build-module/font-library/context.mjs 42648 var import_element141 = __toESM(require_element(), 1); 42649 var import_data48 = __toESM(require_data(), 1); 42650 var import_core_data29 = __toESM(require_core_data(), 1); 42651 var import_i18n86 = __toESM(require_i18n(), 1); 42652 42653 // packages/global-styles-ui/build-module/font-library/api.mjs 42654 var import_api_fetch3 = __toESM(require_api_fetch(), 1); 42655 var import_core_data28 = __toESM(require_core_data(), 1); 42656 42657 // packages/global-styles-ui/build-module/font-library/utils/index.mjs 42658 var import_components90 = __toESM(require_components(), 1); 42659 42660 // packages/global-styles-ui/build-module/font-library/utils/constants.mjs 42661 var import_i18n85 = __toESM(require_i18n(), 1); 42662 var FONT_WEIGHTS = { 42663 100: (0, import_i18n85._x)("Thin", "font weight"), 42664 200: (0, import_i18n85._x)("Extra-light", "font weight"), 42665 300: (0, import_i18n85._x)("Light", "font weight"), 42666 400: (0, import_i18n85._x)("Normal", "font weight"), 42667 500: (0, import_i18n85._x)("Medium", "font weight"), 42668 600: (0, import_i18n85._x)("Semi-bold", "font weight"), 42669 700: (0, import_i18n85._x)("Bold", "font weight"), 42670 800: (0, import_i18n85._x)("Extra-bold", "font weight"), 42671 900: (0, import_i18n85._x)("Black", "font weight") 42672 }; 42673 var FONT_STYLES = { 42674 normal: (0, import_i18n85._x)("Normal", "font style"), 42675 italic: (0, import_i18n85._x)("Italic", "font style") 42676 }; 42677 42678 // packages/global-styles-ui/build-module/font-library/utils/index.mjs 42679 var { File } = window; 42680 var { kebabCase: kebabCase3 } = unlock6(import_components90.privateApis); 42681 42682 // packages/global-styles-ui/build-module/font-library/context.mjs 42683 var import_jsx_runtime235 = __toESM(require_jsx_runtime(), 1); 42684 var FontLibraryContext = (0, import_element141.createContext)( 42685 {} 42686 ); 42687 FontLibraryContext.displayName = "FontLibraryContext"; 42688 42689 // packages/global-styles-ui/build-module/font-library/modal.mjs 42690 var import_i18n92 = __toESM(require_i18n(), 1); 42691 var import_components100 = __toESM(require_components(), 1); 42692 var import_core_data32 = __toESM(require_core_data(), 1); 42693 var import_data50 = __toESM(require_data(), 1); 42694 42695 // packages/global-styles-ui/build-module/font-library/installed-fonts.mjs 42696 var import_components94 = __toESM(require_components(), 1); 42697 var import_core_data30 = __toESM(require_core_data(), 1); 42698 var import_data49 = __toESM(require_data(), 1); 42699 var import_element145 = __toESM(require_element(), 1); 42700 var import_i18n88 = __toESM(require_i18n(), 1); 42701 42702 // packages/global-styles-ui/build-module/font-library/font-card.mjs 42703 var import_i18n87 = __toESM(require_i18n(), 1); 42704 var import_element143 = __toESM(require_element(), 1); 42705 var import_components92 = __toESM(require_components(), 1); 42706 42707 // packages/global-styles-ui/build-module/font-library/font-demo.mjs 42708 var import_components91 = __toESM(require_components(), 1); 42709 var import_element142 = __toESM(require_element(), 1); 42710 var import_jsx_runtime236 = __toESM(require_jsx_runtime(), 1); 42711 42712 // packages/global-styles-ui/build-module/font-library/font-card.mjs 42713 var import_jsx_runtime237 = __toESM(require_jsx_runtime(), 1); 42714 42715 // packages/global-styles-ui/build-module/font-library/library-font-variant.mjs 42716 var import_element144 = __toESM(require_element(), 1); 42717 var import_components93 = __toESM(require_components(), 1); 42718 var import_jsx_runtime238 = __toESM(require_jsx_runtime(), 1); 42719 42720 // packages/global-styles-ui/build-module/font-library/installed-fonts.mjs 42721 var import_jsx_runtime239 = __toESM(require_jsx_runtime(), 1); 42722 42723 // packages/global-styles-ui/build-module/font-library/font-collection.mjs 42724 var import_element147 = __toESM(require_element(), 1); 42725 var import_components97 = __toESM(require_components(), 1); 42726 var import_compose24 = __toESM(require_compose(), 1); 42727 var import_i18n90 = __toESM(require_i18n(), 1); 42728 var import_core_data31 = __toESM(require_core_data(), 1); 42729 42730 // packages/global-styles-ui/build-module/font-library/google-fonts-confirm-dialog.mjs 42731 var import_i18n89 = __toESM(require_i18n(), 1); 42732 var import_components95 = __toESM(require_components(), 1); 42733 var import_jsx_runtime240 = __toESM(require_jsx_runtime(), 1); 42734 42735 // packages/global-styles-ui/build-module/font-library/collection-font-variant.mjs 42736 var import_element146 = __toESM(require_element(), 1); 42737 var import_components96 = __toESM(require_components(), 1); 42738 var import_jsx_runtime241 = __toESM(require_jsx_runtime(), 1); 42739 42740 // packages/global-styles-ui/build-module/font-library/font-collection.mjs 42741 var import_jsx_runtime242 = __toESM(require_jsx_runtime(), 1); 42742 var DEFAULT_CATEGORY = { 42743 slug: "all", 42744 name: (0, import_i18n90._x)("All", "font categories") 42745 }; 42746 42747 // packages/global-styles-ui/build-module/font-library/upload-fonts.mjs 42748 var import_i18n91 = __toESM(require_i18n(), 1); 42749 var import_components99 = __toESM(require_components(), 1); 42750 var import_element148 = __toESM(require_element(), 1); 42751 42752 // packages/global-styles-ui/build-module/font-library/lib/unbrotli.mjs 42753 var __require2 = /* @__PURE__ */ ((x2) => typeof __require !== "undefined" ? __require : typeof Proxy !== "undefined" ? new Proxy(x2, { 42754 get: (a2, b2) => (typeof __require !== "undefined" ? __require : a2)[b2] 42755 }) : x2)(function(x2) { 42756 if (typeof __require !== "undefined") return __require.apply(this, arguments); 42757 throw Error('Dynamic require of "' + x2 + '" is not supported'); 42758 }); 42759 var unbrotli_default = (function() { 42760 var define, module, exports; 42761 return (/* @__PURE__ */ (function() { 42762 function r3(e2, n2, t3) { 42763 function o3(i22, f2) { 42764 if (!n2[i22]) { 42765 if (!e2[i22]) { 42766 var c6 = "function" == typeof __require2 && __require2; 42767 if (!f2 && c6) return c6(i22, true); 42768 if (u2) return u2(i22, true); 42769 var a2 = new Error("Cannot find module '" + i22 + "'"); 42770 throw a2.code = "MODULE_NOT_FOUND", a2; 42771 } 42772 var p3 = n2[i22] = { exports: {} }; 42773 e2[i22][0].call( 42774 p3.exports, 42775 function(r22) { 42776 var n22 = e2[i22][1][r22]; 42777 return o3(n22 || r22); 42778 }, 42779 p3, 42780 p3.exports, 42781 r3, 42782 e2, 42783 n2, 42784 t3 42785 ); 42786 } 42787 return n2[i22].exports; 42788 } 42789 for (var u2 = "function" == typeof __require2 && __require2, i2 = 0; i2 < t3.length; i2++) 42790 o3(t3[i2]); 42791 return o3; 42792 } 42793 return r3; 42794 })())( 42795 { 42796 1: [ 42797 function(require2, module2, exports2) { 42798 var BROTLI_READ_SIZE = 4096; 42799 var BROTLI_IBUF_SIZE = 2 * BROTLI_READ_SIZE + 32; 42800 var BROTLI_IBUF_MASK = 2 * BROTLI_READ_SIZE - 1; 42801 var kBitMask = new Uint32Array([ 42802 0, 42803 1, 42804 3, 42805 7, 42806 15, 42807 31, 42808 63, 42809 127, 42810 255, 42811 511, 42812 1023, 42813 2047, 42814 4095, 42815 8191, 42816 16383, 42817 32767, 42818 65535, 42819 131071, 42820 262143, 42821 524287, 42822 1048575, 42823 2097151, 42824 4194303, 42825 8388607, 42826 16777215 42827 ]); 42828 function BrotliBitReader(input) { 42829 this.buf_ = new Uint8Array(BROTLI_IBUF_SIZE); 42830 this.input_ = input; 42831 this.reset(); 42832 } 42833 BrotliBitReader.READ_SIZE = BROTLI_READ_SIZE; 42834 BrotliBitReader.IBUF_MASK = BROTLI_IBUF_MASK; 42835 BrotliBitReader.prototype.reset = function() { 42836 this.buf_ptr_ = 0; 42837 this.val_ = 0; 42838 this.pos_ = 0; 42839 this.bit_pos_ = 0; 42840 this.bit_end_pos_ = 0; 42841 this.eos_ = 0; 42842 this.readMoreInput(); 42843 for (var i2 = 0; i2 < 4; i2++) { 42844 this.val_ |= this.buf_[this.pos_] << 8 * i2; 42845 ++this.pos_; 42846 } 42847 return this.bit_end_pos_ > 0; 42848 }; 42849 BrotliBitReader.prototype.readMoreInput = function() { 42850 if (this.bit_end_pos_ > 256) { 42851 return; 42852 } else if (this.eos_) { 42853 if (this.bit_pos_ > this.bit_end_pos_) 42854 throw new Error( 42855 "Unexpected end of input " + this.bit_pos_ + " " + this.bit_end_pos_ 42856 ); 42857 } else { 42858 var dst = this.buf_ptr_; 42859 var bytes_read = this.input_.read( 42860 this.buf_, 42861 dst, 42862 BROTLI_READ_SIZE 42863 ); 42864 if (bytes_read < 0) { 42865 throw new Error("Unexpected end of input"); 42866 } 42867 if (bytes_read < BROTLI_READ_SIZE) { 42868 this.eos_ = 1; 42869 for (var p3 = 0; p3 < 32; p3++) 42870 this.buf_[dst + bytes_read + p3] = 0; 42871 } 42872 if (dst === 0) { 42873 for (var p3 = 0; p3 < 32; p3++) 42874 this.buf_[(BROTLI_READ_SIZE << 1) + p3] = this.buf_[p3]; 42875 this.buf_ptr_ = BROTLI_READ_SIZE; 42876 } else { 42877 this.buf_ptr_ = 0; 42878 } 42879 this.bit_end_pos_ += bytes_read << 3; 42880 } 42881 }; 42882 BrotliBitReader.prototype.fillBitWindow = function() { 42883 while (this.bit_pos_ >= 8) { 42884 this.val_ >>>= 8; 42885 this.val_ |= this.buf_[this.pos_ & BROTLI_IBUF_MASK] << 24; 42886 ++this.pos_; 42887 this.bit_pos_ = this.bit_pos_ - 8 >>> 0; 42888 this.bit_end_pos_ = this.bit_end_pos_ - 8 >>> 0; 42889 } 42890 }; 42891 BrotliBitReader.prototype.readBits = function(n_bits) { 42892 if (32 - this.bit_pos_ < n_bits) { 42893 this.fillBitWindow(); 42894 } 42895 var val = this.val_ >>> this.bit_pos_ & kBitMask[n_bits]; 42896 this.bit_pos_ += n_bits; 42897 return val; 42898 }; 42899 module2.exports = BrotliBitReader; 42900 }, 42901 {} 42902 ], 42903 2: [ 42904 function(require2, module2, exports2) { 42905 var CONTEXT_LSB6 = 0; 42906 var CONTEXT_MSB6 = 1; 42907 var CONTEXT_UTF8 = 2; 42908 var CONTEXT_SIGNED = 3; 42909 exports2.lookup = new Uint8Array([ 42910 /* CONTEXT_UTF8, last byte. */ 42911 /* ASCII range. */ 42912 0, 42913 0, 42914 0, 42915 0, 42916 0, 42917 0, 42918 0, 42919 0, 42920 0, 42921 4, 42922 4, 42923 0, 42924 0, 42925 4, 42926 0, 42927 0, 42928 0, 42929 0, 42930 0, 42931 0, 42932 0, 42933 0, 42934 0, 42935 0, 42936 0, 42937 0, 42938 0, 42939 0, 42940 0, 42941 0, 42942 0, 42943 0, 42944 8, 42945 12, 42946 16, 42947 12, 42948 12, 42949 20, 42950 12, 42951 16, 42952 24, 42953 28, 42954 12, 42955 12, 42956 32, 42957 12, 42958 36, 42959 12, 42960 44, 42961 44, 42962 44, 42963 44, 42964 44, 42965 44, 42966 44, 42967 44, 42968 44, 42969 44, 42970 32, 42971 32, 42972 24, 42973 40, 42974 28, 42975 12, 42976 12, 42977 48, 42978 52, 42979 52, 42980 52, 42981 48, 42982 52, 42983 52, 42984 52, 42985 48, 42986 52, 42987 52, 42988 52, 42989 52, 42990 52, 42991 48, 42992 52, 42993 52, 42994 52, 42995 52, 42996 52, 42997 48, 42998 52, 42999 52, 43000 52, 43001 52, 43002 52, 43003 24, 43004 12, 43005 28, 43006 12, 43007 12, 43008 12, 43009 56, 43010 60, 43011 60, 43012 60, 43013 56, 43014 60, 43015 60, 43016 60, 43017 56, 43018 60, 43019 60, 43020 60, 43021 60, 43022 60, 43023 56, 43024 60, 43025 60, 43026 60, 43027 60, 43028 60, 43029 56, 43030 60, 43031 60, 43032 60, 43033 60, 43034 60, 43035 24, 43036 12, 43037 28, 43038 12, 43039 0, 43040 /* UTF8 continuation byte range. */ 43041 0, 43042 1, 43043 0, 43044 1, 43045 0, 43046 1, 43047 0, 43048 1, 43049 0, 43050 1, 43051 0, 43052 1, 43053 0, 43054 1, 43055 0, 43056 1, 43057 0, 43058 1, 43059 0, 43060 1, 43061 0, 43062 1, 43063 0, 43064 1, 43065 0, 43066 1, 43067 0, 43068 1, 43069 0, 43070 1, 43071 0, 43072 1, 43073 0, 43074 1, 43075 0, 43076 1, 43077 0, 43078 1, 43079 0, 43080 1, 43081 0, 43082 1, 43083 0, 43084 1, 43085 0, 43086 1, 43087 0, 43088 1, 43089 0, 43090 1, 43091 0, 43092 1, 43093 0, 43094 1, 43095 0, 43096 1, 43097 0, 43098 1, 43099 0, 43100 1, 43101 0, 43102 1, 43103 0, 43104 1, 43105 2, 43106 3, 43107 2, 43108 3, 43109 2, 43110 3, 43111 2, 43112 3, 43113 2, 43114 3, 43115 2, 43116 3, 43117 2, 43118 3, 43119 2, 43120 3, 43121 2, 43122 3, 43123 2, 43124 3, 43125 2, 43126 3, 43127 2, 43128 3, 43129 2, 43130 3, 43131 2, 43132 3, 43133 2, 43134 3, 43135 2, 43136 3, 43137 2, 43138 3, 43139 2, 43140 3, 43141 2, 43142 3, 43143 2, 43144 3, 43145 2, 43146 3, 43147 2, 43148 3, 43149 2, 43150 3, 43151 2, 43152 3, 43153 2, 43154 3, 43155 2, 43156 3, 43157 2, 43158 3, 43159 2, 43160 3, 43161 2, 43162 3, 43163 2, 43164 3, 43165 2, 43166 3, 43167 2, 43168 3, 43169 /* ASCII range. */ 43170 0, 43171 0, 43172 0, 43173 0, 43174 0, 43175 0, 43176 0, 43177 0, 43178 0, 43179 0, 43180 0, 43181 0, 43182 0, 43183 0, 43184 0, 43185 0, 43186 0, 43187 0, 43188 0, 43189 0, 43190 0, 43191 0, 43192 0, 43193 0, 43194 0, 43195 0, 43196 0, 43197 0, 43198 0, 43199 0, 43200 0, 43201 0, 43202 0, 43203 1, 43204 1, 43205 1, 43206 1, 43207 1, 43208 1, 43209 1, 43210 1, 43211 1, 43212 1, 43213 1, 43214 1, 43215 1, 43216 1, 43217 1, 43218 2, 43219 2, 43220 2, 43221 2, 43222 2, 43223 2, 43224 2, 43225 2, 43226 2, 43227 2, 43228 1, 43229 1, 43230 1, 43231 1, 43232 1, 43233 1, 43234 1, 43235 2, 43236 2, 43237 2, 43238 2, 43239 2, 43240 2, 43241 2, 43242 2, 43243 2, 43244 2, 43245 2, 43246 2, 43247 2, 43248 2, 43249 2, 43250 2, 43251 2, 43252 2, 43253 2, 43254 2, 43255 2, 43256 2, 43257 2, 43258 2, 43259 2, 43260 2, 43261 1, 43262 1, 43263 1, 43264 1, 43265 1, 43266 1, 43267 3, 43268 3, 43269 3, 43270 3, 43271 3, 43272 3, 43273 3, 43274 3, 43275 3, 43276 3, 43277 3, 43278 3, 43279 3, 43280 3, 43281 3, 43282 3, 43283 3, 43284 3, 43285 3, 43286 3, 43287 3, 43288 3, 43289 3, 43290 3, 43291 3, 43292 3, 43293 1, 43294 1, 43295 1, 43296 1, 43297 0, 43298 /* UTF8 continuation byte range. */ 43299 0, 43300 0, 43301 0, 43302 0, 43303 0, 43304 0, 43305 0, 43306 0, 43307 0, 43308 0, 43309 0, 43310 0, 43311 0, 43312 0, 43313 0, 43314 0, 43315 0, 43316 0, 43317 0, 43318 0, 43319 0, 43320 0, 43321 0, 43322 0, 43323 0, 43324 0, 43325 0, 43326 0, 43327 0, 43328 0, 43329 0, 43330 0, 43331 0, 43332 0, 43333 0, 43334 0, 43335 0, 43336 0, 43337 0, 43338 0, 43339 0, 43340 0, 43341 0, 43342 0, 43343 0, 43344 0, 43345 0, 43346 0, 43347 0, 43348 0, 43349 0, 43350 0, 43351 0, 43352 0, 43353 0, 43354 0, 43355 0, 43356 0, 43357 0, 43358 0, 43359 0, 43360 0, 43361 0, 43362 0, 43363 0, 43364 0, 43365 0, 43366 0, 43367 0, 43368 0, 43369 0, 43370 0, 43371 0, 43372 0, 43373 0, 43374 0, 43375 0, 43376 0, 43377 0, 43378 0, 43379 0, 43380 0, 43381 0, 43382 0, 43383 0, 43384 0, 43385 0, 43386 0, 43387 0, 43388 0, 43389 0, 43390 0, 43391 0, 43392 0, 43393 0, 43394 0, 43395 2, 43396 2, 43397 2, 43398 2, 43399 2, 43400 2, 43401 2, 43402 2, 43403 2, 43404 2, 43405 2, 43406 2, 43407 2, 43408 2, 43409 2, 43410 2, 43411 2, 43412 2, 43413 2, 43414 2, 43415 2, 43416 2, 43417 2, 43418 2, 43419 2, 43420 2, 43421 2, 43422 2, 43423 2, 43424 2, 43425 2, 43426 2, 43427 0, 43428 1, 43429 1, 43430 1, 43431 1, 43432 1, 43433 1, 43434 1, 43435 1, 43436 1, 43437 1, 43438 1, 43439 1, 43440 1, 43441 1, 43442 1, 43443 2, 43444 2, 43445 2, 43446 2, 43447 2, 43448 2, 43449 2, 43450 2, 43451 2, 43452 2, 43453 2, 43454 2, 43455 2, 43456 2, 43457 2, 43458 2, 43459 2, 43460 2, 43461 2, 43462 2, 43463 2, 43464 2, 43465 2, 43466 2, 43467 2, 43468 2, 43469 2, 43470 2, 43471 2, 43472 2, 43473 2, 43474 2, 43475 2, 43476 2, 43477 2, 43478 2, 43479 2, 43480 2, 43481 2, 43482 2, 43483 2, 43484 2, 43485 2, 43486 2, 43487 2, 43488 2, 43489 2, 43490 2, 43491 3, 43492 3, 43493 3, 43494 3, 43495 3, 43496 3, 43497 3, 43498 3, 43499 3, 43500 3, 43501 3, 43502 3, 43503 3, 43504 3, 43505 3, 43506 3, 43507 3, 43508 3, 43509 3, 43510 3, 43511 3, 43512 3, 43513 3, 43514 3, 43515 3, 43516 3, 43517 3, 43518 3, 43519 3, 43520 3, 43521 3, 43522 3, 43523 3, 43524 3, 43525 3, 43526 3, 43527 3, 43528 3, 43529 3, 43530 3, 43531 3, 43532 3, 43533 3, 43534 3, 43535 3, 43536 3, 43537 3, 43538 3, 43539 3, 43540 3, 43541 3, 43542 3, 43543 3, 43544 3, 43545 3, 43546 3, 43547 3, 43548 3, 43549 3, 43550 3, 43551 3, 43552 3, 43553 3, 43554 3, 43555 4, 43556 4, 43557 4, 43558 4, 43559 4, 43560 4, 43561 4, 43562 4, 43563 4, 43564 4, 43565 4, 43566 4, 43567 4, 43568 4, 43569 4, 43570 4, 43571 4, 43572 4, 43573 4, 43574 4, 43575 4, 43576 4, 43577 4, 43578 4, 43579 4, 43580 4, 43581 4, 43582 4, 43583 4, 43584 4, 43585 4, 43586 4, 43587 4, 43588 4, 43589 4, 43590 4, 43591 4, 43592 4, 43593 4, 43594 4, 43595 4, 43596 4, 43597 4, 43598 4, 43599 4, 43600 4, 43601 4, 43602 4, 43603 4, 43604 4, 43605 4, 43606 4, 43607 4, 43608 4, 43609 4, 43610 4, 43611 4, 43612 4, 43613 4, 43614 4, 43615 4, 43616 4, 43617 4, 43618 4, 43619 5, 43620 5, 43621 5, 43622 5, 43623 5, 43624 5, 43625 5, 43626 5, 43627 5, 43628 5, 43629 5, 43630 5, 43631 5, 43632 5, 43633 5, 43634 5, 43635 5, 43636 5, 43637 5, 43638 5, 43639 5, 43640 5, 43641 5, 43642 5, 43643 5, 43644 5, 43645 5, 43646 5, 43647 5, 43648 5, 43649 5, 43650 5, 43651 5, 43652 5, 43653 5, 43654 5, 43655 5, 43656 5, 43657 5, 43658 5, 43659 5, 43660 5, 43661 5, 43662 5, 43663 5, 43664 5, 43665 5, 43666 5, 43667 6, 43668 6, 43669 6, 43670 6, 43671 6, 43672 6, 43673 6, 43674 6, 43675 6, 43676 6, 43677 6, 43678 6, 43679 6, 43680 6, 43681 6, 43682 7, 43683 /* CONTEXT_SIGNED, last byte, same as the above values shifted by 3 bits. */ 43684 0, 43685 8, 43686 8, 43687 8, 43688 8, 43689 8, 43690 8, 43691 8, 43692 8, 43693 8, 43694 8, 43695 8, 43696 8, 43697 8, 43698 8, 43699 8, 43700 16, 43701 16, 43702 16, 43703 16, 43704 16, 43705 16, 43706 16, 43707 16, 43708 16, 43709 16, 43710 16, 43711 16, 43712 16, 43713 16, 43714 16, 43715 16, 43716 16, 43717 16, 43718 16, 43719 16, 43720 16, 43721 16, 43722 16, 43723 16, 43724 16, 43725 16, 43726 16, 43727 16, 43728 16, 43729 16, 43730 16, 43731 16, 43732 16, 43733 16, 43734 16, 43735 16, 43736 16, 43737 16, 43738 16, 43739 16, 43740 16, 43741 16, 43742 16, 43743 16, 43744 16, 43745 16, 43746 16, 43747 16, 43748 24, 43749 24, 43750 24, 43751 24, 43752 24, 43753 24, 43754 24, 43755 24, 43756 24, 43757 24, 43758 24, 43759 24, 43760 24, 43761 24, 43762 24, 43763 24, 43764 24, 43765 24, 43766 24, 43767 24, 43768 24, 43769 24, 43770 24, 43771 24, 43772 24, 43773 24, 43774 24, 43775 24, 43776 24, 43777 24, 43778 24, 43779 24, 43780 24, 43781 24, 43782 24, 43783 24, 43784 24, 43785 24, 43786 24, 43787 24, 43788 24, 43789 24, 43790 24, 43791 24, 43792 24, 43793 24, 43794 24, 43795 24, 43796 24, 43797 24, 43798 24, 43799 24, 43800 24, 43801 24, 43802 24, 43803 24, 43804 24, 43805 24, 43806 24, 43807 24, 43808 24, 43809 24, 43810 24, 43811 24, 43812 32, 43813 32, 43814 32, 43815 32, 43816 32, 43817 32, 43818 32, 43819 32, 43820 32, 43821 32, 43822 32, 43823 32, 43824 32, 43825 32, 43826 32, 43827 32, 43828 32, 43829 32, 43830 32, 43831 32, 43832 32, 43833 32, 43834 32, 43835 32, 43836 32, 43837 32, 43838 32, 43839 32, 43840 32, 43841 32, 43842 32, 43843 32, 43844 32, 43845 32, 43846 32, 43847 32, 43848 32, 43849 32, 43850 32, 43851 32, 43852 32, 43853 32, 43854 32, 43855 32, 43856 32, 43857 32, 43858 32, 43859 32, 43860 32, 43861 32, 43862 32, 43863 32, 43864 32, 43865 32, 43866 32, 43867 32, 43868 32, 43869 32, 43870 32, 43871 32, 43872 32, 43873 32, 43874 32, 43875 32, 43876 40, 43877 40, 43878 40, 43879 40, 43880 40, 43881 40, 43882 40, 43883 40, 43884 40, 43885 40, 43886 40, 43887 40, 43888 40, 43889 40, 43890 40, 43891 40, 43892 40, 43893 40, 43894 40, 43895 40, 43896 40, 43897 40, 43898 40, 43899 40, 43900 40, 43901 40, 43902 40, 43903 40, 43904 40, 43905 40, 43906 40, 43907 40, 43908 40, 43909 40, 43910 40, 43911 40, 43912 40, 43913 40, 43914 40, 43915 40, 43916 40, 43917 40, 43918 40, 43919 40, 43920 40, 43921 40, 43922 40, 43923 40, 43924 48, 43925 48, 43926 48, 43927 48, 43928 48, 43929 48, 43930 48, 43931 48, 43932 48, 43933 48, 43934 48, 43935 48, 43936 48, 43937 48, 43938 48, 43939 56, 43940 /* CONTEXT_LSB6, last byte. */ 43941 0, 43942 1, 43943 2, 43944 3, 43945 4, 43946 5, 43947 6, 43948 7, 43949 8, 43950 9, 43951 10, 43952 11, 43953 12, 43954 13, 43955 14, 43956 15, 43957 16, 43958 17, 43959 18, 43960 19, 43961 20, 43962 21, 43963 22, 43964 23, 43965 24, 43966 25, 43967 26, 43968 27, 43969 28, 43970 29, 43971 30, 43972 31, 43973 32, 43974 33, 43975 34, 43976 35, 43977 36, 43978 37, 43979 38, 43980 39, 43981 40, 43982 41, 43983 42, 43984 43, 43985 44, 43986 45, 43987 46, 43988 47, 43989 48, 43990 49, 43991 50, 43992 51, 43993 52, 43994 53, 43995 54, 43996 55, 43997 56, 43998 57, 43999 58, 44000 59, 44001 60, 44002 61, 44003 62, 44004 63, 44005 0, 44006 1, 44007 2, 44008 3, 44009 4, 44010 5, 44011 6, 44012 7, 44013 8, 44014 9, 44015 10, 44016 11, 44017 12, 44018 13, 44019 14, 44020 15, 44021 16, 44022 17, 44023 18, 44024 19, 44025 20, 44026 21, 44027 22, 44028 23, 44029 24, 44030 25, 44031 26, 44032 27, 44033 28, 44034 29, 44035 30, 44036 31, 44037 32, 44038 33, 44039 34, 44040 35, 44041 36, 44042 37, 44043 38, 44044 39, 44045 40, 44046 41, 44047 42, 44048 43, 44049 44, 44050 45, 44051 46, 44052 47, 44053 48, 44054 49, 44055 50, 44056 51, 44057 52, 44058 53, 44059 54, 44060 55, 44061 56, 44062 57, 44063 58, 44064 59, 44065 60, 44066 61, 44067 62, 44068 63, 44069 0, 44070 1, 44071 2, 44072 3, 44073 4, 44074 5, 44075 6, 44076 7, 44077 8, 44078 9, 44079 10, 44080 11, 44081 12, 44082 13, 44083 14, 44084 15, 44085 16, 44086 17, 44087 18, 44088 19, 44089 20, 44090 21, 44091 22, 44092 23, 44093 24, 44094 25, 44095 26, 44096 27, 44097 28, 44098 29, 44099 30, 44100 31, 44101 32, 44102 33, 44103 34, 44104 35, 44105 36, 44106 37, 44107 38, 44108 39, 44109 40, 44110 41, 44111 42, 44112 43, 44113 44, 44114 45, 44115 46, 44116 47, 44117 48, 44118 49, 44119 50, 44120 51, 44121 52, 44122 53, 44123 54, 44124 55, 44125 56, 44126 57, 44127 58, 44128 59, 44129 60, 44130 61, 44131 62, 44132 63, 44133 0, 44134 1, 44135 2, 44136 3, 44137 4, 44138 5, 44139 6, 44140 7, 44141 8, 44142 9, 44143 10, 44144 11, 44145 12, 44146 13, 44147 14, 44148 15, 44149 16, 44150 17, 44151 18, 44152 19, 44153 20, 44154 21, 44155 22, 44156 23, 44157 24, 44158 25, 44159 26, 44160 27, 44161 28, 44162 29, 44163 30, 44164 31, 44165 32, 44166 33, 44167 34, 44168 35, 44169 36, 44170 37, 44171 38, 44172 39, 44173 40, 44174 41, 44175 42, 44176 43, 44177 44, 44178 45, 44179 46, 44180 47, 44181 48, 44182 49, 44183 50, 44184 51, 44185 52, 44186 53, 44187 54, 44188 55, 44189 56, 44190 57, 44191 58, 44192 59, 44193 60, 44194 61, 44195 62, 44196 63, 44197 /* CONTEXT_MSB6, last byte. */ 44198 0, 44199 0, 44200 0, 44201 0, 44202 1, 44203 1, 44204 1, 44205 1, 44206 2, 44207 2, 44208 2, 44209 2, 44210 3, 44211 3, 44212 3, 44213 3, 44214 4, 44215 4, 44216 4, 44217 4, 44218 5, 44219 5, 44220 5, 44221 5, 44222 6, 44223 6, 44224 6, 44225 6, 44226 7, 44227 7, 44228 7, 44229 7, 44230 8, 44231 8, 44232 8, 44233 8, 44234 9, 44235 9, 44236 9, 44237 9, 44238 10, 44239 10, 44240 10, 44241 10, 44242 11, 44243 11, 44244 11, 44245 11, 44246 12, 44247 12, 44248 12, 44249 12, 44250 13, 44251 13, 44252 13, 44253 13, 44254 14, 44255 14, 44256 14, 44257 14, 44258 15, 44259 15, 44260 15, 44261 15, 44262 16, 44263 16, 44264 16, 44265 16, 44266 17, 44267 17, 44268 17, 44269 17, 44270 18, 44271 18, 44272 18, 44273 18, 44274 19, 44275 19, 44276 19, 44277 19, 44278 20, 44279 20, 44280 20, 44281 20, 44282 21, 44283 21, 44284 21, 44285 21, 44286 22, 44287 22, 44288 22, 44289 22, 44290 23, 44291 23, 44292 23, 44293 23, 44294 24, 44295 24, 44296 24, 44297 24, 44298 25, 44299 25, 44300 25, 44301 25, 44302 26, 44303 26, 44304 26, 44305 26, 44306 27, 44307 27, 44308 27, 44309 27, 44310 28, 44311 28, 44312 28, 44313 28, 44314 29, 44315 29, 44316 29, 44317 29, 44318 30, 44319 30, 44320 30, 44321 30, 44322 31, 44323 31, 44324 31, 44325 31, 44326 32, 44327 32, 44328 32, 44329 32, 44330 33, 44331 33, 44332 33, 44333 33, 44334 34, 44335 34, 44336 34, 44337 34, 44338 35, 44339 35, 44340 35, 44341 35, 44342 36, 44343 36, 44344 36, 44345 36, 44346 37, 44347 37, 44348 37, 44349 37, 44350 38, 44351 38, 44352 38, 44353 38, 44354 39, 44355 39, 44356 39, 44357 39, 44358 40, 44359 40, 44360 40, 44361 40, 44362 41, 44363 41, 44364 41, 44365 41, 44366 42, 44367 42, 44368 42, 44369 42, 44370 43, 44371 43, 44372 43, 44373 43, 44374 44, 44375 44, 44376 44, 44377 44, 44378 45, 44379 45, 44380 45, 44381 45, 44382 46, 44383 46, 44384 46, 44385 46, 44386 47, 44387 47, 44388 47, 44389 47, 44390 48, 44391 48, 44392 48, 44393 48, 44394 49, 44395 49, 44396 49, 44397 49, 44398 50, 44399 50, 44400 50, 44401 50, 44402 51, 44403 51, 44404 51, 44405 51, 44406 52, 44407 52, 44408 52, 44409 52, 44410 53, 44411 53, 44412 53, 44413 53, 44414 54, 44415 54, 44416 54, 44417 54, 44418 55, 44419 55, 44420 55, 44421 55, 44422 56, 44423 56, 44424 56, 44425 56, 44426 57, 44427 57, 44428 57, 44429 57, 44430 58, 44431 58, 44432 58, 44433 58, 44434 59, 44435 59, 44436 59, 44437 59, 44438 60, 44439 60, 44440 60, 44441 60, 44442 61, 44443 61, 44444 61, 44445 61, 44446 62, 44447 62, 44448 62, 44449 62, 44450 63, 44451 63, 44452 63, 44453 63, 44454 /* CONTEXT_{M,L}SB6, second last byte, */ 44455 0, 44456 0, 44457 0, 44458 0, 44459 0, 44460 0, 44461 0, 44462 0, 44463 0, 44464 0, 44465 0, 44466 0, 44467 0, 44468 0, 44469 0, 44470 0, 44471 0, 44472 0, 44473 0, 44474 0, 44475 0, 44476 0, 44477 0, 44478 0, 44479 0, 44480 0, 44481 0, 44482 0, 44483 0, 44484 0, 44485 0, 44486 0, 44487 0, 44488 0, 44489 0, 44490 0, 44491 0, 44492 0, 44493 0, 44494 0, 44495 0, 44496 0, 44497 0, 44498 0, 44499 0, 44500 0, 44501 0, 44502 0, 44503 0, 44504 0, 44505 0, 44506 0, 44507 0, 44508 0, 44509 0, 44510 0, 44511 0, 44512 0, 44513 0, 44514 0, 44515 0, 44516 0, 44517 0, 44518 0, 44519 0, 44520 0, 44521 0, 44522 0, 44523 0, 44524 0, 44525 0, 44526 0, 44527 0, 44528 0, 44529 0, 44530 0, 44531 0, 44532 0, 44533 0, 44534 0, 44535 0, 44536 0, 44537 0, 44538 0, 44539 0, 44540 0, 44541 0, 44542 0, 44543 0, 44544 0, 44545 0, 44546 0, 44547 0, 44548 0, 44549 0, 44550 0, 44551 0, 44552 0, 44553 0, 44554 0, 44555 0, 44556 0, 44557 0, 44558 0, 44559 0, 44560 0, 44561 0, 44562 0, 44563 0, 44564 0, 44565 0, 44566 0, 44567 0, 44568 0, 44569 0, 44570 0, 44571 0, 44572 0, 44573 0, 44574 0, 44575 0, 44576 0, 44577 0, 44578 0, 44579 0, 44580 0, 44581 0, 44582 0, 44583 0, 44584 0, 44585 0, 44586 0, 44587 0, 44588 0, 44589 0, 44590 0, 44591 0, 44592 0, 44593 0, 44594 0, 44595 0, 44596 0, 44597 0, 44598 0, 44599 0, 44600 0, 44601 0, 44602 0, 44603 0, 44604 0, 44605 0, 44606 0, 44607 0, 44608 0, 44609 0, 44610 0, 44611 0, 44612 0, 44613 0, 44614 0, 44615 0, 44616 0, 44617 0, 44618 0, 44619 0, 44620 0, 44621 0, 44622 0, 44623 0, 44624 0, 44625 0, 44626 0, 44627 0, 44628 0, 44629 0, 44630 0, 44631 0, 44632 0, 44633 0, 44634 0, 44635 0, 44636 0, 44637 0, 44638 0, 44639 0, 44640 0, 44641 0, 44642 0, 44643 0, 44644 0, 44645 0, 44646 0, 44647 0, 44648 0, 44649 0, 44650 0, 44651 0, 44652 0, 44653 0, 44654 0, 44655 0, 44656 0, 44657 0, 44658 0, 44659 0, 44660 0, 44661 0, 44662 0, 44663 0, 44664 0, 44665 0, 44666 0, 44667 0, 44668 0, 44669 0, 44670 0, 44671 0, 44672 0, 44673 0, 44674 0, 44675 0, 44676 0, 44677 0, 44678 0, 44679 0, 44680 0, 44681 0, 44682 0, 44683 0, 44684 0, 44685 0, 44686 0, 44687 0, 44688 0, 44689 0, 44690 0, 44691 0, 44692 0, 44693 0, 44694 0, 44695 0, 44696 0, 44697 0, 44698 0, 44699 0, 44700 0, 44701 0, 44702 0, 44703 0, 44704 0, 44705 0, 44706 0, 44707 0, 44708 0, 44709 0, 44710 0 44711 ]); 44712 exports2.lookupOffsets = new Uint16Array([ 44713 /* CONTEXT_LSB6 */ 44714 1024, 44715 1536, 44716 1280, 44717 1536, 44718 0, 44719 256, 44720 768, 44721 512 44722 ]); 44723 }, 44724 {} 44725 ], 44726 3: [ 44727 function(require2, module2, exports2) { 44728 var BrotliInput = require2("./streams").BrotliInput; 44729 var BrotliOutput = require2("./streams").BrotliOutput; 44730 var BrotliBitReader = require2("./bit_reader"); 44731 var BrotliDictionary = require2("./dictionary"); 44732 var HuffmanCode = require2("./huffman").HuffmanCode; 44733 var BrotliBuildHuffmanTable = require2("./huffman").BrotliBuildHuffmanTable; 44734 var Context = require2("./context"); 44735 var Prefix = require2("./prefix"); 44736 var Transform = require2("./transform"); 44737 var kDefaultCodeLength = 8; 44738 var kCodeLengthRepeatCode = 16; 44739 var kNumLiteralCodes = 256; 44740 var kNumInsertAndCopyCodes = 704; 44741 var kNumBlockLengthCodes = 26; 44742 var kLiteralContextBits = 6; 44743 var kDistanceContextBits = 2; 44744 var HUFFMAN_TABLE_BITS = 8; 44745 var HUFFMAN_TABLE_MASK = 255; 44746 var HUFFMAN_MAX_TABLE_SIZE = 1080; 44747 var CODE_LENGTH_CODES = 18; 44748 var kCodeLengthCodeOrder = new Uint8Array([ 44749 1, 44750 2, 44751 3, 44752 4, 44753 0, 44754 5, 44755 17, 44756 6, 44757 16, 44758 7, 44759 8, 44760 9, 44761 10, 44762 11, 44763 12, 44764 13, 44765 14, 44766 15 44767 ]); 44768 var NUM_DISTANCE_SHORT_CODES = 16; 44769 var kDistanceShortCodeIndexOffset = new Uint8Array([ 44770 3, 44771 2, 44772 1, 44773 0, 44774 3, 44775 3, 44776 3, 44777 3, 44778 3, 44779 3, 44780 2, 44781 2, 44782 2, 44783 2, 44784 2, 44785 2 44786 ]); 44787 var kDistanceShortCodeValueOffset = new Int8Array([ 44788 0, 44789 0, 44790 0, 44791 0, 44792 -1, 44793 1, 44794 -2, 44795 2, 44796 -3, 44797 3, 44798 -1, 44799 1, 44800 -2, 44801 2, 44802 -3, 44803 3 44804 ]); 44805 var kMaxHuffmanTableSize = new Uint16Array([ 44806 256, 44807 402, 44808 436, 44809 468, 44810 500, 44811 534, 44812 566, 44813 598, 44814 630, 44815 662, 44816 694, 44817 726, 44818 758, 44819 790, 44820 822, 44821 854, 44822 886, 44823 920, 44824 952, 44825 984, 44826 1016, 44827 1048, 44828 1080 44829 ]); 44830 function DecodeWindowBits(br) { 44831 var n2; 44832 if (br.readBits(1) === 0) { 44833 return 16; 44834 } 44835 n2 = br.readBits(3); 44836 if (n2 > 0) { 44837 return 17 + n2; 44838 } 44839 n2 = br.readBits(3); 44840 if (n2 > 0) { 44841 return 8 + n2; 44842 } 44843 return 17; 44844 } 44845 function DecodeVarLenUint8(br) { 44846 if (br.readBits(1)) { 44847 var nbits = br.readBits(3); 44848 if (nbits === 0) { 44849 return 1; 44850 } else { 44851 return br.readBits(nbits) + (1 << nbits); 44852 } 44853 } 44854 return 0; 44855 } 44856 function MetaBlockLength() { 44857 this.meta_block_length = 0; 44858 this.input_end = 0; 44859 this.is_uncompressed = 0; 44860 this.is_metadata = false; 44861 } 44862 function DecodeMetaBlockLength(br) { 44863 var out = new MetaBlockLength(); 44864 var size_nibbles; 44865 var size_bytes; 44866 var i2; 44867 out.input_end = br.readBits(1); 44868 if (out.input_end && br.readBits(1)) { 44869 return out; 44870 } 44871 size_nibbles = br.readBits(2) + 4; 44872 if (size_nibbles === 7) { 44873 out.is_metadata = true; 44874 if (br.readBits(1) !== 0) 44875 throw new Error("Invalid reserved bit"); 44876 size_bytes = br.readBits(2); 44877 if (size_bytes === 0) return out; 44878 for (i2 = 0; i2 < size_bytes; i2++) { 44879 var next_byte = br.readBits(8); 44880 if (i2 + 1 === size_bytes && size_bytes > 1 && next_byte === 0) 44881 throw new Error("Invalid size byte"); 44882 out.meta_block_length |= next_byte << i2 * 8; 44883 } 44884 } else { 44885 for (i2 = 0; i2 < size_nibbles; ++i2) { 44886 var next_nibble = br.readBits(4); 44887 if (i2 + 1 === size_nibbles && size_nibbles > 4 && next_nibble === 0) 44888 throw new Error("Invalid size nibble"); 44889 out.meta_block_length |= next_nibble << i2 * 4; 44890 } 44891 } 44892 ++out.meta_block_length; 44893 if (!out.input_end && !out.is_metadata) { 44894 out.is_uncompressed = br.readBits(1); 44895 } 44896 return out; 44897 } 44898 function ReadSymbol(table, index2, br) { 44899 var start_index = index2; 44900 var nbits; 44901 br.fillBitWindow(); 44902 index2 += br.val_ >>> br.bit_pos_ & HUFFMAN_TABLE_MASK; 44903 nbits = table[index2].bits - HUFFMAN_TABLE_BITS; 44904 if (nbits > 0) { 44905 br.bit_pos_ += HUFFMAN_TABLE_BITS; 44906 index2 += table[index2].value; 44907 index2 += br.val_ >>> br.bit_pos_ & (1 << nbits) - 1; 44908 } 44909 br.bit_pos_ += table[index2].bits; 44910 return table[index2].value; 44911 } 44912 function ReadHuffmanCodeLengths(code_length_code_lengths, num_symbols, code_lengths, br) { 44913 var symbol3 = 0; 44914 var prev_code_len = kDefaultCodeLength; 44915 var repeat = 0; 44916 var repeat_code_len = 0; 44917 var space = 32768; 44918 var table = []; 44919 for (var i2 = 0; i2 < 32; i2++) 44920 table.push(new HuffmanCode(0, 0)); 44921 BrotliBuildHuffmanTable( 44922 table, 44923 0, 44924 5, 44925 code_length_code_lengths, 44926 CODE_LENGTH_CODES 44927 ); 44928 while (symbol3 < num_symbols && space > 0) { 44929 var p3 = 0; 44930 var code_len; 44931 br.readMoreInput(); 44932 br.fillBitWindow(); 44933 p3 += br.val_ >>> br.bit_pos_ & 31; 44934 br.bit_pos_ += table[p3].bits; 44935 code_len = table[p3].value & 255; 44936 if (code_len < kCodeLengthRepeatCode) { 44937 repeat = 0; 44938 code_lengths[symbol3++] = code_len; 44939 if (code_len !== 0) { 44940 prev_code_len = code_len; 44941 space -= 32768 >> code_len; 44942 } 44943 } else { 44944 var extra_bits = code_len - 14; 44945 var old_repeat; 44946 var repeat_delta; 44947 var new_len = 0; 44948 if (code_len === kCodeLengthRepeatCode) { 44949 new_len = prev_code_len; 44950 } 44951 if (repeat_code_len !== new_len) { 44952 repeat = 0; 44953 repeat_code_len = new_len; 44954 } 44955 old_repeat = repeat; 44956 if (repeat > 0) { 44957 repeat -= 2; 44958 repeat <<= extra_bits; 44959 } 44960 repeat += br.readBits(extra_bits) + 3; 44961 repeat_delta = repeat - old_repeat; 44962 if (symbol3 + repeat_delta > num_symbols) { 44963 throw new Error( 44964 "[ReadHuffmanCodeLengths] symbol + repeat_delta > num_symbols" 44965 ); 44966 } 44967 for (var x2 = 0; x2 < repeat_delta; x2++) 44968 code_lengths[symbol3 + x2] = repeat_code_len; 44969 symbol3 += repeat_delta; 44970 if (repeat_code_len !== 0) { 44971 space -= repeat_delta << 15 - repeat_code_len; 44972 } 44973 } 44974 } 44975 if (space !== 0) { 44976 throw new Error( 44977 "[ReadHuffmanCodeLengths] space = " + space 44978 ); 44979 } 44980 for (; symbol3 < num_symbols; symbol3++) 44981 code_lengths[symbol3] = 0; 44982 } 44983 function ReadHuffmanCode(alphabet_size, tables, table, br) { 44984 var table_size = 0; 44985 var simple_code_or_skip; 44986 var code_lengths = new Uint8Array(alphabet_size); 44987 br.readMoreInput(); 44988 simple_code_or_skip = br.readBits(2); 44989 if (simple_code_or_skip === 1) { 44990 var i2; 44991 var max_bits_counter = alphabet_size - 1; 44992 var max_bits = 0; 44993 var symbols = new Int32Array(4); 44994 var num_symbols = br.readBits(2) + 1; 44995 while (max_bits_counter) { 44996 max_bits_counter >>= 1; 44997 ++max_bits; 44998 } 44999 for (i2 = 0; i2 < num_symbols; ++i2) { 45000 symbols[i2] = br.readBits(max_bits) % alphabet_size; 45001 code_lengths[symbols[i2]] = 2; 45002 } 45003 code_lengths[symbols[0]] = 1; 45004 switch (num_symbols) { 45005 case 1: 45006 break; 45007 case 3: 45008 if (symbols[0] === symbols[1] || symbols[0] === symbols[2] || symbols[1] === symbols[2]) { 45009 throw new Error( 45010 "[ReadHuffmanCode] invalid symbols" 45011 ); 45012 } 45013 break; 45014 case 2: 45015 if (symbols[0] === symbols[1]) { 45016 throw new Error( 45017 "[ReadHuffmanCode] invalid symbols" 45018 ); 45019 } 45020 code_lengths[symbols[1]] = 1; 45021 break; 45022 case 4: 45023 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]) { 45024 throw new Error( 45025 "[ReadHuffmanCode] invalid symbols" 45026 ); 45027 } 45028 if (br.readBits(1)) { 45029 code_lengths[symbols[2]] = 3; 45030 code_lengths[symbols[3]] = 3; 45031 } else { 45032 code_lengths[symbols[0]] = 2; 45033 } 45034 break; 45035 } 45036 } else { 45037 var i2; 45038 var code_length_code_lengths = new Uint8Array( 45039 CODE_LENGTH_CODES 45040 ); 45041 var space = 32; 45042 var num_codes = 0; 45043 var huff = [ 45044 new HuffmanCode(2, 0), 45045 new HuffmanCode(2, 4), 45046 new HuffmanCode(2, 3), 45047 new HuffmanCode(3, 2), 45048 new HuffmanCode(2, 0), 45049 new HuffmanCode(2, 4), 45050 new HuffmanCode(2, 3), 45051 new HuffmanCode(4, 1), 45052 new HuffmanCode(2, 0), 45053 new HuffmanCode(2, 4), 45054 new HuffmanCode(2, 3), 45055 new HuffmanCode(3, 2), 45056 new HuffmanCode(2, 0), 45057 new HuffmanCode(2, 4), 45058 new HuffmanCode(2, 3), 45059 new HuffmanCode(4, 5) 45060 ]; 45061 for (i2 = simple_code_or_skip; i2 < CODE_LENGTH_CODES && space > 0; ++i2) { 45062 var code_len_idx = kCodeLengthCodeOrder[i2]; 45063 var p3 = 0; 45064 var v2; 45065 br.fillBitWindow(); 45066 p3 += br.val_ >>> br.bit_pos_ & 15; 45067 br.bit_pos_ += huff[p3].bits; 45068 v2 = huff[p3].value; 45069 code_length_code_lengths[code_len_idx] = v2; 45070 if (v2 !== 0) { 45071 space -= 32 >> v2; 45072 ++num_codes; 45073 } 45074 } 45075 if (!(num_codes === 1 || space === 0)) 45076 throw new Error( 45077 "[ReadHuffmanCode] invalid num_codes or space" 45078 ); 45079 ReadHuffmanCodeLengths( 45080 code_length_code_lengths, 45081 alphabet_size, 45082 code_lengths, 45083 br 45084 ); 45085 } 45086 table_size = BrotliBuildHuffmanTable( 45087 tables, 45088 table, 45089 HUFFMAN_TABLE_BITS, 45090 code_lengths, 45091 alphabet_size 45092 ); 45093 if (table_size === 0) { 45094 throw new Error( 45095 "[ReadHuffmanCode] BuildHuffmanTable failed: " 45096 ); 45097 } 45098 return table_size; 45099 } 45100 function ReadBlockLength(table, index2, br) { 45101 var code; 45102 var nbits; 45103 code = ReadSymbol(table, index2, br); 45104 nbits = Prefix.kBlockLengthPrefixCode[code].nbits; 45105 return Prefix.kBlockLengthPrefixCode[code].offset + br.readBits(nbits); 45106 } 45107 function TranslateShortCodes(code, ringbuffer, index2) { 45108 var val; 45109 if (code < NUM_DISTANCE_SHORT_CODES) { 45110 index2 += kDistanceShortCodeIndexOffset[code]; 45111 index2 &= 3; 45112 val = ringbuffer[index2] + kDistanceShortCodeValueOffset[code]; 45113 } else { 45114 val = code - NUM_DISTANCE_SHORT_CODES + 1; 45115 } 45116 return val; 45117 } 45118 function MoveToFront(v2, index2) { 45119 var value = v2[index2]; 45120 var i2 = index2; 45121 for (; i2; --i2) v2[i2] = v2[i2 - 1]; 45122 v2[0] = value; 45123 } 45124 function InverseMoveToFrontTransform(v2, v_len) { 45125 var mtf = new Uint8Array(256); 45126 var i2; 45127 for (i2 = 0; i2 < 256; ++i2) { 45128 mtf[i2] = i2; 45129 } 45130 for (i2 = 0; i2 < v_len; ++i2) { 45131 var index2 = v2[i2]; 45132 v2[i2] = mtf[index2]; 45133 if (index2) MoveToFront(mtf, index2); 45134 } 45135 } 45136 function HuffmanTreeGroup(alphabet_size, num_htrees) { 45137 this.alphabet_size = alphabet_size; 45138 this.num_htrees = num_htrees; 45139 this.codes = new Array( 45140 num_htrees + num_htrees * kMaxHuffmanTableSize[alphabet_size + 31 >>> 5] 45141 ); 45142 this.htrees = new Uint32Array(num_htrees); 45143 } 45144 HuffmanTreeGroup.prototype.decode = function(br) { 45145 var i2; 45146 var table_size; 45147 var next = 0; 45148 for (i2 = 0; i2 < this.num_htrees; ++i2) { 45149 this.htrees[i2] = next; 45150 table_size = ReadHuffmanCode( 45151 this.alphabet_size, 45152 this.codes, 45153 next, 45154 br 45155 ); 45156 next += table_size; 45157 } 45158 }; 45159 function DecodeContextMap(context_map_size, br) { 45160 var out = { num_htrees: null, context_map: null }; 45161 var use_rle_for_zeros; 45162 var max_run_length_prefix = 0; 45163 var table; 45164 var i2; 45165 br.readMoreInput(); 45166 var num_htrees = out.num_htrees = DecodeVarLenUint8(br) + 1; 45167 var context_map = out.context_map = new Uint8Array( 45168 context_map_size 45169 ); 45170 if (num_htrees <= 1) { 45171 return out; 45172 } 45173 use_rle_for_zeros = br.readBits(1); 45174 if (use_rle_for_zeros) { 45175 max_run_length_prefix = br.readBits(4) + 1; 45176 } 45177 table = []; 45178 for (i2 = 0; i2 < HUFFMAN_MAX_TABLE_SIZE; i2++) { 45179 table[i2] = new HuffmanCode(0, 0); 45180 } 45181 ReadHuffmanCode( 45182 num_htrees + max_run_length_prefix, 45183 table, 45184 0, 45185 br 45186 ); 45187 for (i2 = 0; i2 < context_map_size; ) { 45188 var code; 45189 br.readMoreInput(); 45190 code = ReadSymbol(table, 0, br); 45191 if (code === 0) { 45192 context_map[i2] = 0; 45193 ++i2; 45194 } else if (code <= max_run_length_prefix) { 45195 var reps = 1 + (1 << code) + br.readBits(code); 45196 while (--reps) { 45197 if (i2 >= context_map_size) { 45198 throw new Error( 45199 "[DecodeContextMap] i >= context_map_size" 45200 ); 45201 } 45202 context_map[i2] = 0; 45203 ++i2; 45204 } 45205 } else { 45206 context_map[i2] = code - max_run_length_prefix; 45207 ++i2; 45208 } 45209 } 45210 if (br.readBits(1)) { 45211 InverseMoveToFrontTransform( 45212 context_map, 45213 context_map_size 45214 ); 45215 } 45216 return out; 45217 } 45218 function DecodeBlockType(max_block_type, trees, tree_type, block_types, ringbuffers, indexes, br) { 45219 var ringbuffer = tree_type * 2; 45220 var index2 = tree_type; 45221 var type_code = ReadSymbol( 45222 trees, 45223 tree_type * HUFFMAN_MAX_TABLE_SIZE, 45224 br 45225 ); 45226 var block_type; 45227 if (type_code === 0) { 45228 block_type = ringbuffers[ringbuffer + (indexes[index2] & 1)]; 45229 } else if (type_code === 1) { 45230 block_type = ringbuffers[ringbuffer + (indexes[index2] - 1 & 1)] + 1; 45231 } else { 45232 block_type = type_code - 2; 45233 } 45234 if (block_type >= max_block_type) { 45235 block_type -= max_block_type; 45236 } 45237 block_types[tree_type] = block_type; 45238 ringbuffers[ringbuffer + (indexes[index2] & 1)] = block_type; 45239 ++indexes[index2]; 45240 } 45241 function CopyUncompressedBlockToOutput(output, len, pos, ringbuffer, ringbuffer_mask, br) { 45242 var rb_size = ringbuffer_mask + 1; 45243 var rb_pos = pos & ringbuffer_mask; 45244 var br_pos = br.pos_ & BrotliBitReader.IBUF_MASK; 45245 var nbytes; 45246 if (len < 8 || br.bit_pos_ + (len << 3) < br.bit_end_pos_) { 45247 while (len-- > 0) { 45248 br.readMoreInput(); 45249 ringbuffer[rb_pos++] = br.readBits(8); 45250 if (rb_pos === rb_size) { 45251 output.write(ringbuffer, rb_size); 45252 rb_pos = 0; 45253 } 45254 } 45255 return; 45256 } 45257 if (br.bit_end_pos_ < 32) { 45258 throw new Error( 45259 "[CopyUncompressedBlockToOutput] br.bit_end_pos_ < 32" 45260 ); 45261 } 45262 while (br.bit_pos_ < 32) { 45263 ringbuffer[rb_pos] = br.val_ >>> br.bit_pos_; 45264 br.bit_pos_ += 8; 45265 ++rb_pos; 45266 --len; 45267 } 45268 nbytes = br.bit_end_pos_ - br.bit_pos_ >> 3; 45269 if (br_pos + nbytes > BrotliBitReader.IBUF_MASK) { 45270 var tail = BrotliBitReader.IBUF_MASK + 1 - br_pos; 45271 for (var x2 = 0; x2 < tail; x2++) 45272 ringbuffer[rb_pos + x2] = br.buf_[br_pos + x2]; 45273 nbytes -= tail; 45274 rb_pos += tail; 45275 len -= tail; 45276 br_pos = 0; 45277 } 45278 for (var x2 = 0; x2 < nbytes; x2++) 45279 ringbuffer[rb_pos + x2] = br.buf_[br_pos + x2]; 45280 rb_pos += nbytes; 45281 len -= nbytes; 45282 if (rb_pos >= rb_size) { 45283 output.write(ringbuffer, rb_size); 45284 rb_pos -= rb_size; 45285 for (var x2 = 0; x2 < rb_pos; x2++) 45286 ringbuffer[x2] = ringbuffer[rb_size + x2]; 45287 } 45288 while (rb_pos + len >= rb_size) { 45289 nbytes = rb_size - rb_pos; 45290 if (br.input_.read(ringbuffer, rb_pos, nbytes) < nbytes) { 45291 throw new Error( 45292 "[CopyUncompressedBlockToOutput] not enough bytes" 45293 ); 45294 } 45295 output.write(ringbuffer, rb_size); 45296 len -= nbytes; 45297 rb_pos = 0; 45298 } 45299 if (br.input_.read(ringbuffer, rb_pos, len) < len) { 45300 throw new Error( 45301 "[CopyUncompressedBlockToOutput] not enough bytes" 45302 ); 45303 } 45304 br.reset(); 45305 } 45306 function JumpToByteBoundary(br) { 45307 var new_bit_pos = br.bit_pos_ + 7 & ~7; 45308 var pad_bits = br.readBits(new_bit_pos - br.bit_pos_); 45309 return pad_bits == 0; 45310 } 45311 function BrotliDecompressedSize(buffer) { 45312 var input = new BrotliInput(buffer); 45313 var br = new BrotliBitReader(input); 45314 DecodeWindowBits(br); 45315 var out = DecodeMetaBlockLength(br); 45316 return out.meta_block_length; 45317 } 45318 exports2.BrotliDecompressedSize = BrotliDecompressedSize; 45319 function BrotliDecompressBuffer(buffer, output_size) { 45320 var input = new BrotliInput(buffer); 45321 if (output_size == null) { 45322 output_size = BrotliDecompressedSize(buffer); 45323 } 45324 var output_buffer = new Uint8Array(output_size); 45325 var output = new BrotliOutput(output_buffer); 45326 BrotliDecompress(input, output); 45327 if (output.pos < output.buffer.length) { 45328 output.buffer = output.buffer.subarray( 45329 0, 45330 output.pos 45331 ); 45332 } 45333 return output.buffer; 45334 } 45335 exports2.BrotliDecompressBuffer = BrotliDecompressBuffer; 45336 function BrotliDecompress(input, output) { 45337 var i2; 45338 var pos = 0; 45339 var input_end = 0; 45340 var window_bits = 0; 45341 var max_backward_distance; 45342 var max_distance = 0; 45343 var ringbuffer_size; 45344 var ringbuffer_mask; 45345 var ringbuffer; 45346 var ringbuffer_end; 45347 var dist_rb = [16, 15, 11, 4]; 45348 var dist_rb_idx = 0; 45349 var prev_byte1 = 0; 45350 var prev_byte2 = 0; 45351 var hgroup = [ 45352 new HuffmanTreeGroup(0, 0), 45353 new HuffmanTreeGroup(0, 0), 45354 new HuffmanTreeGroup(0, 0) 45355 ]; 45356 var block_type_trees; 45357 var block_len_trees; 45358 var br; 45359 var kRingBufferWriteAheadSlack = 128 + BrotliBitReader.READ_SIZE; 45360 br = new BrotliBitReader(input); 45361 window_bits = DecodeWindowBits(br); 45362 max_backward_distance = (1 << window_bits) - 16; 45363 ringbuffer_size = 1 << window_bits; 45364 ringbuffer_mask = ringbuffer_size - 1; 45365 ringbuffer = new Uint8Array( 45366 ringbuffer_size + kRingBufferWriteAheadSlack + BrotliDictionary.maxDictionaryWordLength 45367 ); 45368 ringbuffer_end = ringbuffer_size; 45369 block_type_trees = []; 45370 block_len_trees = []; 45371 for (var x2 = 0; x2 < 3 * HUFFMAN_MAX_TABLE_SIZE; x2++) { 45372 block_type_trees[x2] = new HuffmanCode(0, 0); 45373 block_len_trees[x2] = new HuffmanCode(0, 0); 45374 } 45375 while (!input_end) { 45376 var meta_block_remaining_len = 0; 45377 var is_uncompressed; 45378 var block_length = [1 << 28, 1 << 28, 1 << 28]; 45379 var block_type = [0]; 45380 var num_block_types = [1, 1, 1]; 45381 var block_type_rb = [0, 1, 0, 1, 0, 1]; 45382 var block_type_rb_index = [0]; 45383 var distance_postfix_bits; 45384 var num_direct_distance_codes; 45385 var distance_postfix_mask; 45386 var num_distance_codes; 45387 var context_map = null; 45388 var context_modes = null; 45389 var num_literal_htrees; 45390 var dist_context_map = null; 45391 var num_dist_htrees; 45392 var context_offset = 0; 45393 var context_map_slice = null; 45394 var literal_htree_index = 0; 45395 var dist_context_offset = 0; 45396 var dist_context_map_slice = null; 45397 var dist_htree_index = 0; 45398 var context_lookup_offset1 = 0; 45399 var context_lookup_offset2 = 0; 45400 var context_mode; 45401 var htree_command; 45402 for (i2 = 0; i2 < 3; ++i2) { 45403 hgroup[i2].codes = null; 45404 hgroup[i2].htrees = null; 45405 } 45406 br.readMoreInput(); 45407 var _out = DecodeMetaBlockLength(br); 45408 meta_block_remaining_len = _out.meta_block_length; 45409 if (pos + meta_block_remaining_len > output.buffer.length) { 45410 var tmp = new Uint8Array( 45411 pos + meta_block_remaining_len 45412 ); 45413 tmp.set(output.buffer); 45414 output.buffer = tmp; 45415 } 45416 input_end = _out.input_end; 45417 is_uncompressed = _out.is_uncompressed; 45418 if (_out.is_metadata) { 45419 JumpToByteBoundary(br); 45420 for (; meta_block_remaining_len > 0; --meta_block_remaining_len) { 45421 br.readMoreInput(); 45422 br.readBits(8); 45423 } 45424 continue; 45425 } 45426 if (meta_block_remaining_len === 0) { 45427 continue; 45428 } 45429 if (is_uncompressed) { 45430 br.bit_pos_ = br.bit_pos_ + 7 & ~7; 45431 CopyUncompressedBlockToOutput( 45432 output, 45433 meta_block_remaining_len, 45434 pos, 45435 ringbuffer, 45436 ringbuffer_mask, 45437 br 45438 ); 45439 pos += meta_block_remaining_len; 45440 continue; 45441 } 45442 for (i2 = 0; i2 < 3; ++i2) { 45443 num_block_types[i2] = DecodeVarLenUint8(br) + 1; 45444 if (num_block_types[i2] >= 2) { 45445 ReadHuffmanCode( 45446 num_block_types[i2] + 2, 45447 block_type_trees, 45448 i2 * HUFFMAN_MAX_TABLE_SIZE, 45449 br 45450 ); 45451 ReadHuffmanCode( 45452 kNumBlockLengthCodes, 45453 block_len_trees, 45454 i2 * HUFFMAN_MAX_TABLE_SIZE, 45455 br 45456 ); 45457 block_length[i2] = ReadBlockLength( 45458 block_len_trees, 45459 i2 * HUFFMAN_MAX_TABLE_SIZE, 45460 br 45461 ); 45462 block_type_rb_index[i2] = 1; 45463 } 45464 } 45465 br.readMoreInput(); 45466 distance_postfix_bits = br.readBits(2); 45467 num_direct_distance_codes = NUM_DISTANCE_SHORT_CODES + (br.readBits(4) << distance_postfix_bits); 45468 distance_postfix_mask = (1 << distance_postfix_bits) - 1; 45469 num_distance_codes = num_direct_distance_codes + (48 << distance_postfix_bits); 45470 context_modes = new Uint8Array( 45471 num_block_types[0] 45472 ); 45473 for (i2 = 0; i2 < num_block_types[0]; ++i2) { 45474 br.readMoreInput(); 45475 context_modes[i2] = br.readBits(2) << 1; 45476 } 45477 var _o1 = DecodeContextMap( 45478 num_block_types[0] << kLiteralContextBits, 45479 br 45480 ); 45481 num_literal_htrees = _o1.num_htrees; 45482 context_map = _o1.context_map; 45483 var _o2 = DecodeContextMap( 45484 num_block_types[2] << kDistanceContextBits, 45485 br 45486 ); 45487 num_dist_htrees = _o2.num_htrees; 45488 dist_context_map = _o2.context_map; 45489 hgroup[0] = new HuffmanTreeGroup( 45490 kNumLiteralCodes, 45491 num_literal_htrees 45492 ); 45493 hgroup[1] = new HuffmanTreeGroup( 45494 kNumInsertAndCopyCodes, 45495 num_block_types[1] 45496 ); 45497 hgroup[2] = new HuffmanTreeGroup( 45498 num_distance_codes, 45499 num_dist_htrees 45500 ); 45501 for (i2 = 0; i2 < 3; ++i2) { 45502 hgroup[i2].decode(br); 45503 } 45504 context_map_slice = 0; 45505 dist_context_map_slice = 0; 45506 context_mode = context_modes[block_type[0]]; 45507 context_lookup_offset1 = Context.lookupOffsets[context_mode]; 45508 context_lookup_offset2 = Context.lookupOffsets[context_mode + 1]; 45509 htree_command = hgroup[1].htrees[0]; 45510 while (meta_block_remaining_len > 0) { 45511 var cmd_code; 45512 var range_idx; 45513 var insert_code; 45514 var copy_code; 45515 var insert_length; 45516 var copy_length; 45517 var distance_code; 45518 var distance; 45519 var context; 45520 var j2; 45521 var copy_dst; 45522 br.readMoreInput(); 45523 if (block_length[1] === 0) { 45524 DecodeBlockType( 45525 num_block_types[1], 45526 block_type_trees, 45527 1, 45528 block_type, 45529 block_type_rb, 45530 block_type_rb_index, 45531 br 45532 ); 45533 block_length[1] = ReadBlockLength( 45534 block_len_trees, 45535 HUFFMAN_MAX_TABLE_SIZE, 45536 br 45537 ); 45538 htree_command = hgroup[1].htrees[block_type[1]]; 45539 } 45540 --block_length[1]; 45541 cmd_code = ReadSymbol( 45542 hgroup[1].codes, 45543 htree_command, 45544 br 45545 ); 45546 range_idx = cmd_code >> 6; 45547 if (range_idx >= 2) { 45548 range_idx -= 2; 45549 distance_code = -1; 45550 } else { 45551 distance_code = 0; 45552 } 45553 insert_code = Prefix.kInsertRangeLut[range_idx] + (cmd_code >> 3 & 7); 45554 copy_code = Prefix.kCopyRangeLut[range_idx] + (cmd_code & 7); 45555 insert_length = Prefix.kInsertLengthPrefixCode[insert_code].offset + br.readBits( 45556 Prefix.kInsertLengthPrefixCode[insert_code].nbits 45557 ); 45558 copy_length = Prefix.kCopyLengthPrefixCode[copy_code].offset + br.readBits( 45559 Prefix.kCopyLengthPrefixCode[copy_code].nbits 45560 ); 45561 prev_byte1 = ringbuffer[pos - 1 & ringbuffer_mask]; 45562 prev_byte2 = ringbuffer[pos - 2 & ringbuffer_mask]; 45563 for (j2 = 0; j2 < insert_length; ++j2) { 45564 br.readMoreInput(); 45565 if (block_length[0] === 0) { 45566 DecodeBlockType( 45567 num_block_types[0], 45568 block_type_trees, 45569 0, 45570 block_type, 45571 block_type_rb, 45572 block_type_rb_index, 45573 br 45574 ); 45575 block_length[0] = ReadBlockLength( 45576 block_len_trees, 45577 0, 45578 br 45579 ); 45580 context_offset = block_type[0] << kLiteralContextBits; 45581 context_map_slice = context_offset; 45582 context_mode = context_modes[block_type[0]]; 45583 context_lookup_offset1 = Context.lookupOffsets[context_mode]; 45584 context_lookup_offset2 = Context.lookupOffsets[context_mode + 1]; 45585 } 45586 context = Context.lookup[context_lookup_offset1 + prev_byte1] | Context.lookup[context_lookup_offset2 + prev_byte2]; 45587 literal_htree_index = context_map[context_map_slice + context]; 45588 --block_length[0]; 45589 prev_byte2 = prev_byte1; 45590 prev_byte1 = ReadSymbol( 45591 hgroup[0].codes, 45592 hgroup[0].htrees[literal_htree_index], 45593 br 45594 ); 45595 ringbuffer[pos & ringbuffer_mask] = prev_byte1; 45596 if ((pos & ringbuffer_mask) === ringbuffer_mask) { 45597 output.write( 45598 ringbuffer, 45599 ringbuffer_size 45600 ); 45601 } 45602 ++pos; 45603 } 45604 meta_block_remaining_len -= insert_length; 45605 if (meta_block_remaining_len <= 0) break; 45606 if (distance_code < 0) { 45607 var context; 45608 br.readMoreInput(); 45609 if (block_length[2] === 0) { 45610 DecodeBlockType( 45611 num_block_types[2], 45612 block_type_trees, 45613 2, 45614 block_type, 45615 block_type_rb, 45616 block_type_rb_index, 45617 br 45618 ); 45619 block_length[2] = ReadBlockLength( 45620 block_len_trees, 45621 2 * HUFFMAN_MAX_TABLE_SIZE, 45622 br 45623 ); 45624 dist_context_offset = block_type[2] << kDistanceContextBits; 45625 dist_context_map_slice = dist_context_offset; 45626 } 45627 --block_length[2]; 45628 context = (copy_length > 4 ? 3 : copy_length - 2) & 255; 45629 dist_htree_index = dist_context_map[dist_context_map_slice + context]; 45630 distance_code = ReadSymbol( 45631 hgroup[2].codes, 45632 hgroup[2].htrees[dist_htree_index], 45633 br 45634 ); 45635 if (distance_code >= num_direct_distance_codes) { 45636 var nbits; 45637 var postfix; 45638 var offset4; 45639 distance_code -= num_direct_distance_codes; 45640 postfix = distance_code & distance_postfix_mask; 45641 distance_code >>= distance_postfix_bits; 45642 nbits = (distance_code >> 1) + 1; 45643 offset4 = (2 + (distance_code & 1) << nbits) - 4; 45644 distance_code = num_direct_distance_codes + (offset4 + br.readBits(nbits) << distance_postfix_bits) + postfix; 45645 } 45646 } 45647 distance = TranslateShortCodes( 45648 distance_code, 45649 dist_rb, 45650 dist_rb_idx 45651 ); 45652 if (distance < 0) { 45653 throw new Error( 45654 "[BrotliDecompress] invalid distance" 45655 ); 45656 } 45657 if (pos < max_backward_distance && max_distance !== max_backward_distance) { 45658 max_distance = pos; 45659 } else { 45660 max_distance = max_backward_distance; 45661 } 45662 copy_dst = pos & ringbuffer_mask; 45663 if (distance > max_distance) { 45664 if (copy_length >= BrotliDictionary.minDictionaryWordLength && copy_length <= BrotliDictionary.maxDictionaryWordLength) { 45665 var offset4 = BrotliDictionary.offsetsByLength[copy_length]; 45666 var word_id = distance - max_distance - 1; 45667 var shift4 = BrotliDictionary.sizeBitsByLength[copy_length]; 45668 var mask = (1 << shift4) - 1; 45669 var word_idx = word_id & mask; 45670 var transform_idx = word_id >> shift4; 45671 offset4 += word_idx * copy_length; 45672 if (transform_idx < Transform.kNumTransforms) { 45673 var len = Transform.transformDictionaryWord( 45674 ringbuffer, 45675 copy_dst, 45676 offset4, 45677 copy_length, 45678 transform_idx 45679 ); 45680 copy_dst += len; 45681 pos += len; 45682 meta_block_remaining_len -= len; 45683 if (copy_dst >= ringbuffer_end) { 45684 output.write( 45685 ringbuffer, 45686 ringbuffer_size 45687 ); 45688 for (var _x25 = 0; _x25 < copy_dst - ringbuffer_end; _x25++) 45689 ringbuffer[_x25] = ringbuffer[ringbuffer_end + _x25]; 45690 } 45691 } else { 45692 throw new Error( 45693 "Invalid backward reference. pos: " + pos + " distance: " + distance + " len: " + copy_length + " bytes left: " + meta_block_remaining_len 45694 ); 45695 } 45696 } else { 45697 throw new Error( 45698 "Invalid backward reference. pos: " + pos + " distance: " + distance + " len: " + copy_length + " bytes left: " + meta_block_remaining_len 45699 ); 45700 } 45701 } else { 45702 if (distance_code > 0) { 45703 dist_rb[dist_rb_idx & 3] = distance; 45704 ++dist_rb_idx; 45705 } 45706 if (copy_length > meta_block_remaining_len) { 45707 throw new Error( 45708 "Invalid backward reference. pos: " + pos + " distance: " + distance + " len: " + copy_length + " bytes left: " + meta_block_remaining_len 45709 ); 45710 } 45711 for (j2 = 0; j2 < copy_length; ++j2) { 45712 ringbuffer[pos & ringbuffer_mask] = ringbuffer[pos - distance & ringbuffer_mask]; 45713 if ((pos & ringbuffer_mask) === ringbuffer_mask) { 45714 output.write( 45715 ringbuffer, 45716 ringbuffer_size 45717 ); 45718 } 45719 ++pos; 45720 --meta_block_remaining_len; 45721 } 45722 } 45723 prev_byte1 = ringbuffer[pos - 1 & ringbuffer_mask]; 45724 prev_byte2 = ringbuffer[pos - 2 & ringbuffer_mask]; 45725 } 45726 pos &= 1073741823; 45727 } 45728 output.write(ringbuffer, pos & ringbuffer_mask); 45729 } 45730 exports2.BrotliDecompress = BrotliDecompress; 45731 BrotliDictionary.init(); 45732 }, 45733 { 45734 "./bit_reader": 1, 45735 "./context": 2, 45736 "./dictionary": 6, 45737 "./huffman": 7, 45738 "./prefix": 9, 45739 "./streams": 10, 45740 "./transform": 11 45741 } 45742 ], 45743 4: [ 45744 function(require2, module2, exports2) { 45745 var base64 = require2("base64-js"); 45746 exports2.init = function() { 45747 var BrotliDecompressBuffer = require2("./decode").BrotliDecompressBuffer; 45748 var compressed = base64.toByteArray( 45749 require2("./dictionary.bin.js") 45750 ); 45751 return BrotliDecompressBuffer(compressed); 45752 }; 45753 }, 45754 { "./decode": 3, "./dictionary.bin.js": 5, "base64-js": 8 } 45755 ], 45756 5: [ 45757 function(require2, module2, exports2) { 45758 module2.exports = "W5/fcQLn5gKf2XUbAiQ1XULX+TZz6ADToDsgqk6qVfeC0e4m6OO2wcQ1J76ZBVRV1fRkEsdu//62zQsFEZWSTCnMhcsQKlS2qOhuVYYMGCkV0fXWEoMFbESXrKEZ9wdUEsyw9g4bJlEt1Y6oVMxMRTEVbCIwZzJzboK5j8m4YH02qgXYhv1V+PM435sLVxyHJihaJREEhZGqL03txGFQLm76caGO/ovxKvzCby/3vMTtX/459f0igi7WutnKiMQ6wODSoRh/8Lx1V3Q99MvKtwB6bHdERYRY0hStJoMjNeTsNX7bn+Y7e4EQ3bf8xBc7L0BsyfFPK43dGSXpL6clYC/I328h54/VYrQ5i0648FgbGtl837svJ35L3Mot/+nPlNpWgKx1gGXQYqX6n+bbZ7wuyCHKcUok12Xjqub7NXZGzqBx0SD+uziNf87t7ve42jxSKQoW3nyxVrWIGlFShhCKxjpZZ5MeGna0+lBkk+kaN8F9qFBAFgEogyMBdcX/T1W/WnMOi/7ycWUQloEBKGeC48MkiwqJkJO+12eQiOFHMmck6q/IjWW3RZlany23TBm+cNr/84/oi5GGmGBZWrZ6j+zykVozz5fT/QH/Da6WTbZYYPynVNO7kxzuNN2kxKKWche5WveitPKAecB8YcAHz/+zXLjcLzkdDSktNIDwZE9J9X+tto43oJy65wApM3mDzYtCwX9lM+N5VR3kXYo0Z3t0TtXfgBFg7gU8oN0Dgl7fZlUbhNll+0uuohRVKjrEd8egrSndy5/Tgd2gqjA4CAVuC7ESUmL3DZoGnfhQV8uwnpi8EGvAVVsowNRxPudck7+oqAUDkwZopWqFnW1riss0t1z6iCISVKreYGNvQcXv+1L9+jbP8cd/dPUiqBso2q+7ZyFBvENCkkVr44iyPbtOoOoCecWsiuqMSML5lv+vN5MzUr+Dnh73G7Q1YnRYJVYXHRJaNAOByiaK6CusgFdBPE40r0rvqXV7tksKO2DrHYXBTv8P5ysqxEx8VDXUDDqkPH6NNOV/a2WH8zlkXRELSa8P+heNyJBBP7PgsG1EtWtNef6/i+lcayzQwQCsduidpbKfhWUDgAEmyhGu/zVTacI6RS0zTABrOYueemnVa19u9fT23N/Ta6RvTpof5DWygqreCqrDAgM4LID1+1T/taU6yTFVLqXOv+/MuQOFnaF8vLMKD7tKWDoBdALgxF33zQccCcdHx8fKIVdW69O7qHtXpeGr9jbbpFA+qRMWr5hp0s67FPc7HAiLV0g0/peZlW7hJPYEhZyhpSwahnf93/tZgfqZWXFdmdXBzqxGHLrQKxoAY6fRoBhgCRPmmGueYZ5JexTVDKUIXzkG/fqp/0U3hAgQdJ9zumutK6nqWbaqvm1pgu03IYR+G+8s0jDBBz8cApZFSBeuWasyqo2OMDKAZCozS+GWSvL/HsE9rHxooe17U3s/lTE+VZAk4j3dp6uIGaC0JMiqR5CUsabPyM0dOYDR7Ea7ip4USZlya38YfPtvrX/tBlhHilj55nZ1nfN24AOAi9BVtz/Mbn8AEDJCqJgsVUa6nQnSxv2Fs7l/NlCzpfYEjmPrNyib/+t0ei2eEMjvNhLkHCZlci4WhBe7ePZTmzYqlY9+1pxtS4GB+5lM1BHT9tS270EWUDYFq1I0yY/fNiAk4bk9yBgmef/f2k6AlYQZHsNFnW8wBQxCd68iWv7/35bXfz3JZmfGligWAKRjIs3IpzxQ27vAglHSiOzCYzJ9L9A1CdiyFvyR66ucA4jKifu5ehwER26yV7HjKqn5Mfozo7Coxxt8LWWPT47BeMxX8p0Pjb7hZn+6bw7z3Lw+7653j5sI8CLu5kThpMlj1m4c2ch3jGcP1FsT13vuK3qjecKTZk2kHcOZY40UX+qdaxstZqsqQqgXz+QGF99ZJLqr3VYu4aecl1Ab5GmqS8k/GV5b95zxQ5d4EfXUJ6kTS/CXF/aiqKDOT1T7Jz5z0PwDUcwr9clLN1OJGCiKfqvah+h3XzrBOiLOW8wvn8gW6qE8vPxi+Efv+UH55T7PQFVMh6cZ1pZQlzJpKZ7P7uWvwPGJ6DTlR6wbyj3Iv2HyefnRo/dv7dNx+qaa0N38iBsR++Uil7Wd4afwDNsrzDAK4fXZwvEY/jdKuIKXlfrQd2C39dW7ntnRbIp9OtGy9pPBn/V2ASoi/2UJZfS+xuGLH8bnLuPlzdTNS6zdyk8Dt/h6sfOW5myxh1f+zf3zZ3MX/mO9cQPp5pOx967ZA6/pqHvclNfnUFF+rq+Vd7alKr6KWPcIDhpn6v2K6NlUu6LrKo8b/pYpU/Gazfvtwhn7tEOUuXht5rUJdSf6sLjYf0VTYDgwJ81yaqKTUYej/tbHckSRb/HZicwGJqh1mAHB/IuNs9dc9yuvF3D5Xocm3elWFdq5oEy70dYFit79yaLiNjPj5UUcVmZUVhQEhW5V2Z6Cm4HVH/R8qlamRYwBileuh07CbEce3TXa2JmXWBf+ozt319psboobeZhVnwhMZzOeQJzhpTDbP71Tv8HuZxxUI/+ma3XW6DFDDs4+qmpERwHGBd2edxwUKlODRdUWZ/g0GOezrbzOZauFMai4QU6GVHV6aPNBiBndHSsV4IzpvUiiYyg6OyyrL4Dj5q/Lw3N5kAwftEVl9rNd7Jk5PDij2hTH6wIXnsyXkKePxbmHYgC8A6an5Fob/KH5GtC0l4eFso+VpxedtJHdHpNm+Bvy4C79yVOkrZsLrQ3OHCeB0Ra+kBIRldUGlDCEmq2RwXnfyh6Dz+alk6eftI2n6sastRrGwbwszBeDRS/Fa/KwRJkCzTsLr/JCs5hOPE/MPLYdZ1F1fv7D+VmysX6NpOC8aU9F4Qs6HvDyUy9PvFGDKZ/P5101TYHFl8pjj6wm/qyS75etZhhfg0UEL4OYmHk6m6dO192AzoIyPSV9QedDA4Ml23rRbqxMPMxf7FJnDc5FTElVS/PyqgePzmwVZ26NWhRDQ+oaT7ly7ell4s3DypS1s0g+tOr7XHrrkZj9+x/mJBttrLx98lFIaRZzHz4aC7r52/JQ4VjHahY2/YVXZn/QC2ztQb/sY3uRlyc5vQS8nLPGT/n27495i8HPA152z7Fh5aFpyn1GPJKHuPL8Iw94DuW3KjkURAWZXn4EQy89xiKEHN1mk/tkM4gYDBxwNoYvRfE6LFqsxWJtPrDGbsnLMap3Ka3MUoytW0cvieozOmdERmhcqzG+3HmZv2yZeiIeQTKGdRT4HHNxekm1tY+/n06rGmFleqLscSERzctTKM6G9P0Pc1RmVvrascIxaO1CQCiYPE15bD7c3xSeW7gXxYjgxcrUlcbIvO0r+Yplhx0kTt3qafDOmFyMjgGxXu73rddMHpV1wMubyAGcf/v5dLr5P72Ta9lBF+fzMJrMycwv+9vnU3ANIl1cH9tfW7af8u0/HG0vV47jNFXzFTtaha1xvze/s8KMtCYucXc1nzfd/MQydUXn/b72RBt5wO/3jRcMH9BdhC/yctKBIveRYPrNpDWqBsO8VMmP+WvRaOcA4zRMR1PvSoO92rS7pYEv+fZfEfTMzEdM+6X5tLlyxExhqLRkms5EuLovLfx66de5fL2/yX02H52FPVwahrPqmN/E0oVXnsCKhbi/yRxX83nRbUKWhzYceXOntfuXn51NszJ6MO73pQf5Pl4in3ec4JU8hF7ppV34+mm9r1LY0ee/i1O1wpd8+zfLztE0cqBxggiBi5Bu95v9l3r9r/U5hweLn+TbfxowrWDqdJauKd8+q/dH8sbPkc9ttuyO94f7/XK/nHX46MPFLEb5qQlNPvhJ50/59t9ft3LXu7uVaWaO2bDrDCnRSzZyWvFKxO1+vT8MwwunR3bX0CkfPjqb4K9O19tn5X50PvmYpEwHtiW9WtzuV/s76B1zvLLNkViNd8ySxIl/3orfqP90TyTGaf7/rx8jQzeHJXdmh/N6YDvbvmTBwCdxfEQ1NcL6wNMdSIXNq7b1EUzRy1/Axsyk5p22GMG1b+GxFgbHErZh92wuvco0AuOLXct9hvw2nw/LqIcDRRmJmmZzcgUa7JpM/WV/S9IUfbF56TL2orzqwebdRD8nIYNJ41D/hz37Fo11p2Y21wzPcn713qVGhqtevStYfGH4n69OEJtPvbbLYWvscDqc3Hgnu166+tAyLnxrX0Y5zoYjV++1sI7t5kMr02KT/+uwtkc+rZLOf/qn/s3nYCf13Dg8/sB2diJgjGqjQ+TLhxbzyue2Ob7X6/9lUwW7a+lbznHzOYy8LKW1C/uRPbQY3KW/0gO9LXunHLvPL97afba9bFtc9hmz7GAttjVYlCvQAiOwAk/gC5+hkLEs6tr3AZKxLJtOEwk2dLxTYWsIB/j/ToWtIWzo906FrSG8iaqqqqqqiIiIiAgzMzMzNz+AyK+01/zi8n8S+Y1MjoRaQ80WU/G8MBlO+53VPXANrWm4wzGUVZUjjBJZVdhpcfkjsmcWaO+UEldXi1e+zq+HOsCpknYshuh8pOLISJun7TN0EIGW2xTnlOImeecnoGW4raxe2G1T3HEvfYUYMhG+gAFOAwh5nK8mZhwJMmN7r224QVsNFvZ87Z0qatvknklyPDK3Hy45PgVKXji52Wen4d4PlFVVYGnNap+fSpFbK90rYnhUc6n91Q3AY9E0tJOFrcfZtm/491XbcG/jsViUPPX76qmeuiz+qY1Hk7/1VPM405zWVuoheLUimpWYdVzCmUdKHebMdzgrYrb8mL2eeLSnRWHdonfZa8RsOU9F37w+591l5FLYHiOqWeHtE/lWrBHcRKp3uhtr8yXm8LU/5ms+NM6ZKsqu90cFZ4o58+k4rdrtB97NADFbwmEG7lXqvirhOTOqU14xuUF2myIjURcPHrPOQ4lmM3PeMg7bUuk0nnZi67bXsU6H8lhqIo8TaOrEafCO1ARK9PjC0QOoq2BxmMdgYB9G/lIb9++fqNJ2s7BHGFyBNmZAR8J3KCo012ikaSP8BCrf6VI0X5xdnbhHIO+B5rbOyB54zXkzfObyJ4ecwxfqBJMLFc7m59rNcw7hoHnFZ0b00zee+gTqvjm61Pb4xn0kcDX4jvHM0rBXZypG3DCKnD/Waa/ZtHmtFPgO5eETx+k7RrVg3aSwm2YoNXnCs3XPQDhNn+Fia6IlOOuIG6VJH7TP6ava26ehKHQa2T4N0tcZ9dPCGo3ZdnNltsHQbeYt5vPnJezV/cAeNypdml1vCHI8M81nSRP5Qi2+mI8v/sxiZru9187nRtp3f/42NemcONa+4eVC3PCZzc88aZh851CqSsshe70uPxeN/dmYwlwb3trwMrN1Gq8jbnApcVDx/yDPeYs5/7r62tsQ6lLg+DiFXTEhzR9dHqv0iT4tgj825W+H3XiRUNUZT2kR9Ri0+lp+UM3iQtS8uOE23Ly4KYtvqH13jghUntJRAewuzNLDXp8RxdcaA3cMY6TO2IeSFRXezeWIjCqyhsUdMYuCgYTZSKpBype1zRfq8FshvfBPc6BAQWl7/QxIDp3VGo1J3vn42OEs3qznws+YLRXbymyB19a9XBx6n/owcyxlEYyFWCi+kG9F+EyD/4yn80+agaZ9P7ay2Dny99aK2o91FkfEOY8hBwyfi5uwx2y5SaHmG+oq/zl1FX/8irOf8Y3vAcX/6uLP6A6nvMO24edSGPjQc827Rw2atX+z2bKq0CmW9mOtYnr5/AfDa1ZfPaXnKtlWborup7QYx+Or2uWb+N3N//2+yDcXMqIJdf55xl7/vsj4WoPPlxLxtVrkJ4w/tTe3mLdATOOYwxcq52w5Wxz5MbPdVs5O8/lhfE7dPj0bIiPQ3QV0iqm4m3YX8hRfc6jQ3fWepevMqUDJd86Z4vwM40CWHnn+WphsGHfieF02D3tmZvpWD+kBpNCFcLnZhcmmrhpGzzbdA+sQ1ar18OJD87IOKOFoRNznaHPNHUfUNhvY1iU+uhvEvpKHaUn3qK3exVVyX4joipp3um7FmYJWmA+WbIDshRpbVRx5/nqstCgy87FGbfVB8yDGCqS+2qCsnRwnSAN6zgzxfdB2nBT/vZ4/6uxb6oH8b4VBRxiIB93wLa47hG3w2SL/2Z27yOXJFwZpSJaBYyvajA7vRRYNKqljXKpt/CFD/tSMr18DKKbwB0xggBePatl1nki0yvqW5zchlyZmJ0OTxJ3D+fsYJs/mxYN5+Le5oagtcl+YsVvy8kSjI2YGvGjvmpkRS9W2dtXqWnVuxUhURm1lKtou/hdEq19VBp9OjGvHEQSmrpuf2R24mXGheil8KeiANY8fW1VERUfBImb64j12caBZmRViZHbeVMjCrPDg9A90IXrtnsYCuZtRQ0PyrKDjBNOsPfKsg1pA02gHlVr0OXiFhtp6nJqXVzcbfM0KnzC3ggOENPE9VBdmHKN6LYaijb4wXxJn5A0FSDF5j+h1ooZx885Jt3ZKzO5n7Z5WfNEOtyyPqQEnn7WLv5Fis3PdgMshjF1FRydbNyeBbyKI1oN1TRVrVK7kgsb/zjX4NDPIRMctVeaxVB38Vh1x5KbeJbU138AM5KzmZu3uny0ErygxiJF7GVXUrPzFxrlx1uFdAaZFDN9cvIb74qD9tzBMo7L7WIEYK+sla1DVMHpF0F7b3+Y6S+zjvLeDMCpapmJo1weBWuxKF3rOocih1gun4BoJh1kWnV/Jmiq6uOhK3VfKxEHEkafjLgK3oujaPzY6SXg8phhL4TNR1xvJd1Wa0aYFfPUMLrNBDCh4AuGRTbtKMc6Z1Udj8evY/ZpCuMAUefdo69DZUngoqE1P9A3PJfOf7WixCEj+Y6t7fYeHbbxUAoFV3M89cCKfma3fc1+jKRe7MFWEbQqEfyzO2x/wrO2VYH7iYdQ9BkPyI8/3kXBpLaCpU7eC0Yv/am/tEDu7HZpqg0EvHo0nf/R/gRzUWy33/HXMJQeu1GylKmOkXzlCfGFruAcPPhaGqZOtu19zsJ1SO2Jz4Ztth5cBX6mRQwWmDwryG9FUMlZzNckMdK+IoMJv1rOWnBamS2w2KHiaPMPLC15hCZm4KTpoZyj4E2TqC/P6r7/EhnDMhKicZZ1ZwxuC7DPzDGs53q8gXaI9kFTK+2LTq7bhwsTbrMV8Rsfua5lMS0FwbTitUVnVa1yTb5IX51mmYnUcP9wPr8Ji1tiYJeJV9GZTrQhF7vvdU2OTU42ogJ9FDwhmycI2LIg++03C6scYhUyUuMV5tkw6kGUoL+mjNC38+wMdWNljn6tGPpRES7veqrSn5TRuv+dh6JVL/iDHU1db4c9WK3++OrH3PqziF916UMUKn8G67nN60GfWiHrXYhUG3yVWmyYak59NHj8t1smG4UDiWz2rPHNrKnN4Zo1LBbr2/eF9YZ0n0blx2nG4X+EKFxvS3W28JESD+FWk61VCD3z/URGHiJl++7TdBwkCj6tGOH3qDb0QqcOF9Kzpj0HUb/KyFW3Yhj2VMKJqGZleFBH7vqvf7WqLC3XMuHV8q8a4sTFuxUtkD/6JIBvKaVjv96ndgruKZ1k/BHzqf2K9fLk7HGXANyLDd1vxkK/i055pnzl+zw6zLnwXlVYVtfmacJgEpRP1hbGgrYPVN6v2lG+idQNGmwcKXu/8xEj/P6qe/sB2WmwNp6pp8jaISMkwdleFXYK55NHWLTTbutSUqjBfDGWo/Yg918qQ+8BRZSAHZbfuNZz2O0sov1Ue4CWlVg3rFhM3Kljj9ksGd/NUhk4nH+a5UN2+1i8+NM3vRNp7uQ6sqexSCukEVlVZriHNqFi5rLm9TMWa4qm3idJqppQACol2l4VSuvWLfta4JcXy3bROPNbXOgdOhG47LC0CwW/dMlSx4Jf17aEU3yA1x9p+Yc0jupXgcMuYNku64iYOkGToVDuJvlbEKlJqsmiHbvNrIVZEH+yFdF8DbleZ6iNiWwMqvtMp/mSpwx5KxRrT9p3MAPTHGtMbfvdFhyj9vhaKcn3At8Lc16Ai+vBcSp1ztXi7rCJZx/ql7TXcclq6Q76UeKWDy9boS0WHIjUuWhPG8LBmW5y2rhuTpM5vsLt+HOLh1Yf0DqXa9tsfC+kaKt2htA0ai/L2i7RKoNjEwztkmRU0GfgW1TxUvPFhg0V7DdfWJk5gfrccpYv+MA9M0dkGTLECeYwUixRzjRFdmjG7zdZIl3XKB9YliNKI31lfa7i2JG5C8Ss+rHe0D7Z696/V3DEAOWHnQ9yNahMUl5kENWS6pHKKp2D1BaSrrHdE1w2qNxIztpXgUIrF0bm15YML4b6V1k+GpNysTahKMVrrS85lTVo9OGJ96I47eAy5rYWpRf/mIzeoYU1DKaQCTUVwrhHeyNoDqHel+lLxr9WKzhSYw7vrR6+V5q0pfi2k3L1zqkubY6rrd9ZLvSuWNf0uqnkY+FpTvFzSW9Fp0b9l8JA7THV9eCi/PY/SCZIUYx3BU2alj7Cm3VV6eYpios4b6WuNOJdYXUK3zTqj5CVG2FqYM4Z7CuIU0qO05XR0d71FHM0YhZmJmTRfLlXEumN82BGtzdX0S19t1e+bUieK8zRmqpa4Qc5TSjifmaQsY2ETLjhI36gMR1+7qpjdXXHiceUekfBaucHShAOiFXmv3sNmGQyU5iVgnoocuonQXEPTFwslHtS8R+A47StI9wj0iSrtbi5rMysczFiImsQ+bdFClnFjjpXXwMy6O7qfjOr8Fb0a7ODItisjnn3EQO16+ypd1cwyaAW5Yzxz5QknfMO7643fXW/I9y3U2xH27Oapqr56Z/tEzglj6IbT6HEHjopiXqeRbe5mQQvxtcbDOVverN0ZgMdzqRYRjaXtMRd56Q4cZSmdPvZJdSrhJ1D9zNXPqAEqPIavPdfubt5oke2kmv0dztIszSv2VYuoyf1UuopbsYb+uX9h6WpwjpgtZ6fNNawNJ4q8O3CFoSbioAaOSZMx2GYaPYB+rEb6qjQiNRFQ76TvwNFVKD+BhH9VhcKGsXzmMI7BptU/CNWolM7YzROvpFAntsiWJp6eR2d3GarcYShVYSUqhmYOWj5E96NK2WvmYNTeY7Zs4RUEdv9h9QT4EseKt6LzLrqEOs3hxAY1MaNWpSa6zZx8F3YOVeCYMS88W+CYHDuWe4yoc6YK+djDuEOrBR5lvh0r+Q9uM88lrjx9x9AtgpQVNE8r+3O6Gvw59D+kBF/UMXyhliYUtPjmvXGY6Dk3x+kEOW+GtdMVC4EZTqoS/jmR0P0LS75DOc/w2vnri97M4SdbZ8qeU7gg8DVbERkU5geaMQO3mYrSYyAngeUQqrN0C0/vsFmcgWNXNeidsTAj7/4MncJR0caaBUpbLK1yBCBNRjEv6KvuVSdpPnEMJdsRRtqJ+U8tN1gXA4ePHc6ZT0eviI73UOJF0fEZ8YaneAQqQdGphNvwM4nIqPnXxV0xA0fnCT+oAhJuyw/q8jO0y8CjSteZExwBpIN6SvNp6A5G/abi6egeND/1GTguhuNjaUbbnSbGd4L8937Ezm34Eyi6n1maeOBxh3PI0jzJDf5mh/BsLD7F2GOKvlA/5gtvxI3/eV4sLfKW5Wy+oio+es/u6T8UU+nsofy57Icb/JlZHPFtCgd/x+bwt3ZT+xXTtTtTrGAb4QehC6X9G+8YT+ozcLxDsdCjsuOqwPFnrdLYaFc92Ui0m4fr39lYmlCaqTit7G6O/3kWDkgtXjNH4BiEm/+jegQnihOtfffn33WxsFjhfMd48HT+f6o6X65j7XR8WLSHMFkxbvOYsrRsF1bowDuSQ18Mkxk4qz2zoGPL5fu9h2Hqmt1asl3Q3Yu3szOc+spiCmX4AETBM3pLoTYSp3sVxahyhL8eC4mPN9k2x3o0xkiixIzM3CZFzf5oR4mecQ5+ax2wCah3/crmnHoqR0+KMaOPxRif1oEFRFOO/kTPPmtww+NfMXxEK6gn6iU32U6fFruIz8Q4WgljtnaCVTBgWx7diUdshC9ZEa5yKpRBBeW12r/iNc/+EgNqmhswNB8SBoihHXeDF7rrWDLcmt3V8GYYN7pXRy4DZjj4DJuUBL5iC3DQAaoo4vkftqVTYRGLS3mHZ7gdmdTTqbgNN/PTdTCOTgXolc88MhXAEUMdX0iy1JMuk5wLsgeu0QUYlz2S4skTWwJz6pOm/8ihrmgGfFgri+ZWUK2gAPHgbWa8jaocdSuM4FJYoKicYX/ZSENkg9Q1ZzJfwScfVnR2DegOGwCvmogaWJCLQepv9WNlU6QgsmOwICquU28Mlk3d9W5E81lU/5Ez0LcX6lwKMWDNluNKfBDUy/phJgBcMnfkh9iRxrdOzgs08JdPB85Lwo+GUSb4t3nC+0byqMZtO2fQJ4U2zGIr49t/28qmmGv2RanDD7a3FEcdtutkW8twwwlUSpb8QalodddbBfNHKDQ828BdE7OBgFdiKYohLawFYqpybQoxATZrheLhdI7+0Zlu9Q1myRcd15r9UIm8K2LGJxqTegntqNVMKnf1a8zQiyUR1rxoqjiFxeHxqFcYUTHfDu7rhbWng6qOxOsI+5A1p9mRyEPdVkTlE24vY54W7bWc6jMgZvNXdfC9/9q7408KDsbdL7Utz7QFSDetz2picArzrdpL8OaCHC9V26RroemtDZ5yNM/KGkWMyTmfnInEvwtSD23UcFcjhaE3VKzkoaEMKGBft4XbIO6forTY1lmGQwVmKicBCiArDzE+1oIxE08fWeviIOD5TznqH+OoHadvoOP20drMPe5Irg3XBQziW2XDuHYzjqQQ4wySssjXUs5H+t3FWYMHppUnBHMx/nYIT5d7OmjDbgD9F6na3m4l7KdkeSO3kTEPXafiWinogag7b52taiZhL1TSvBFmEZafFq2H8khQaZXuitCewT5FBgVtPK0j4xUHPfUz3Q28eac1Z139DAP23dgki94EC8vbDPTQC97HPPSWjUNG5tWKMsaxAEMKC0665Xvo1Ntd07wCLNf8Q56mrEPVpCxlIMVlQlWRxM3oAfpgIc+8KC3rEXUog5g06vt7zgXY8grH7hhwVSaeuvC06YYRAwpbyk/Unzj9hLEZNs2oxPQB9yc+GnL6zTgq7rI++KDJwX2SP8Sd6YzTuw5lV/kU6eQxRD12omfQAW6caTR4LikYkBB1CMOrvgRr/VY75+NSB40Cni6bADAtaK+vyxVWpf9NeKJxN2KYQ8Q2xPB3K1s7fuhvWbr2XpgW044VD6DRs0qXoqKf1NFsaGvKJc47leUV3pppP/5VTKFhaGuol4Esfjf5zyCyUHmHthChcYh4hYLQF+AFWsuq4t0wJyWgdwQVOZiV0efRHPoK5+E1vjz9wTJmVkITC9oEstAsyZSgE/dbicwKr89YUxKZI+owD205Tm5lnnmDRuP/JnzxX3gMtlrcX0UesZdxyQqYQuEW4R51vmQ5xOZteUd8SJruMlTUzhtVw/Nq7eUBcqN2/HVotgfngif60yKEtoUx3WYOZlVJuJOh8u59fzSDPFYtQgqDUAGyGhQOAvKroXMcOYY0qjnStJR/G3aP+Jt1sLVlGV8POwr/6OGsqetnyF3TmTqZjENfnXh51oxe9qVUw2M78EzAJ+IM8lZ1MBPQ9ZWSVc4J3mWSrLKrMHReA5qdGoz0ODRsaA+vwxXA2cAM4qlfzBJA6581m4hzxItQw5dxrrBL3Y6kCbUcFxo1S8jyV44q//+7ASNNudZ6xeaNOSIUffqMn4A9lIjFctYn2gpEPAb3f7p3iIBN8H14FUGQ9ct2hPsL+cEsTgUrR47uJVN4n4wt/wgfwwHuOnLd4yobkofy8JvxSQTA7rMpDIc608SlZFJfZYcmbT0tAHpPE8MrtQ42siTUNWxqvWZOmvu9f0JPoQmg+6l7sZWwyfi6PXkxJnwBraUG0MYG4zYHQz3igy/XsFkx5tNQxw43qvI9dU3f0DdhOUlHKjmi1VAr2Kiy0HZwD8VeEbhh0OiDdMYspolQsYdSwjCcjeowIXNZVUPmL2wwIkYhmXKhGozdCJ4lRKbsf4NBh/XnQoS92NJEWOVOFs2YhN8c5QZFeK0pRdAG40hqvLbmoSA8xQmzOOEc7wLcme9JOsjPCEgpCwUs9E2DohMHRhUeyGIN6TFvrbny8nDuilsDpzrH5mS76APoIEJmItS67sQJ+nfwddzmjPxcBEBBCw0kWDwd0EZCkNeOD7NNQhtBm7KHL9mRxj6U1yWU2puzlIDtpYxdH4ZPeXBJkTGAJfUr/oTCz/iypY6uXaR2V1doPxJYlrw2ghH0D5gbrhFcIxzYwi4a/4hqVdf2DdxBp6vGYDjavxMAAoy+1+3aiO6S3W/QAKNVXagDtvsNtx7Ks+HKgo6U21B+QSZgIogV5Bt+BnXisdVfy9VyXV+2P5fMuvdpAjM1o/K9Z+XnE4EOCrue+kcdYHqAQ0/Y/OmNlQ6OI33jH/uD1RalPaHpJAm2av0/xtpqdXVKNDrc9F2izo23Wu7firgbURFDNX9eGGeYBhiypyXZft2j3hTvzE6PMWKsod//rEILDkzBXfi7xh0eFkfb3/1zzPK/PI5Nk3FbZyTl4mq5BfBoVoqiPHO4Q4QKZAlrQ3MdNfi3oxIjvsM3kAFv3fdufurqYR3PSwX/mpGy/GFI/B2MNPiNdOppWVbs/gjF3YH+QA9jMhlAbhvasAHstB0IJew09iAkmXHl1/TEj+jvHOpOGrPRQXbPADM+Ig2/OEcUcpgPTItMtW4DdqgfYVI/+4hAFWYjUGpOP/UwNuB7+BbKOcALbjobdgzeBQfjgNSp2GOpxzGLj70Vvq5cw2AoYENwKLUtJUX8sGRox4dVa/TN4xKwaKcl9XawQR/uNus700Hf17pyNnezrUgaY9e4MADhEDBpsJT6y1gDJs1q6wlwGhuUzGR7C8kgpjPyHWwsvrf3yn1zJEIRa5eSxoLAZOCR9xbuztxFRJW9ZmMYfCFJ0evm9F2fVnuje92Rc4Pl6A8bluN8MZyyJGZ0+sNSb//DvAFxC2BqlEsFwccWeAl6CyBcQV1bx4mQMBP1Jxqk1EUADNLeieS2dUFbQ/c/kvwItbZ7tx0st16viqd53WsRmPTKv2AD8CUnhtPWg5aUegNpsYgasaw2+EVooeNKmrW3MFtj76bYHJm5K9gpAXZXsE5U8DM8XmVOSJ1F1WnLy6nQup+jx52bAb+rCq6y9WXl2B2oZDhfDkW7H3oYfT/4xx5VncBuxMXP2lNfhUVQjSSzSRbuZFE4vFawlzveXxaYKVs8LpvAb8IRYF3ZHiRnm0ADeNPWocwxSzNseG7NrSEVZoHdKWqaGEBz1N8Pt7kFbqh3LYmAbm9i1IChIpLpM5AS6mr6OAPHMwwznVy61YpBYX8xZDN/a+lt7n+x5j4bNOVteZ8lj3hpAHSx1VR8vZHec4AHO9XFCdjZ9eRkSV65ljMmZVzaej2qFn/qt1lvWzNZEfHxK3qOJrHL6crr0CRzMox5f2e8ALBB4UGFZKA3tN6F6IXd32GTJXGQ7DTi9j/dNcLF9jCbDcWGKxoKTYblIwbLDReL00LRcDPMcQuXLMh5YzgtfjkFK1DP1iDzzYYVZz5M/kWYRlRpig1htVRjVCknm+h1M5LiEDXOyHREhvzCGpFZjHS0RsK27o2avgdilrJkalWqPW3D9gmwV37HKmfM3F8YZj2ar+vHFvf3B8CRoH4kDHIK9mrAg+owiEwNjjd9V+FsQKYR8czJrUkf7Qoi2YaW6EVDZp5zYlqiYtuXOTHk4fAcZ7qBbdLDiJq0WNV1l2+Hntk1mMWvxrYmc8kIx8G3rW36J6Ra4lLrTOCgiOihmow+YnzUT19jbV2B3RWqSHyxkhmgsBqMYWvOcUom1jDQ436+fcbu3xf2bbeqU/ca+C4DOKE+e3qvmeMqW3AxejfzBRFVcwVYPq4L0APSWWoJu+5UYX4qg5U6YTioqQGPG9XrnuZ/BkxuYpe6Li87+18EskyQW/uA+uk2rpHpr6hut2TlVbKgWkFpx+AZffweiw2+VittkEyf/ifinS/0ItRL2Jq3tQOcxPaWO2xrG68GdFoUpZgFXaP2wYVtRc6xYCfI1CaBqyWpg4bx8OHBQwsV4XWMibZZ0LYjWEy2IxQ1mZrf1/UNbYCJplWu3nZ4WpodIGVA05d+RWSS+ET9tH3RfGGmNI1cIY7evZZq7o+a0bjjygpmR3mVfalkT/SZGT27Q8QGalwGlDOS9VHCyFAIL0a1Q7JiW3saz9gqY8lqKynFrPCzxkU4SIfLc9VfCI5edgRhDXs0edO992nhTKHriREP1NJC6SROMgQ0xO5kNNZOhMOIT99AUElbxqeZF8A3xrfDJsWtDnUenAHdYWSwAbYjFqQZ+D5gi3hNK8CSxU9i6f6ClL9IGlj1OPMQAsr84YG6ijsJpCaGWj75c3yOZKBB9mNpQNPUKkK0D6wgLH8MGoyRxTX6Y05Q4AnYNXMZwXM4eij/9WpsM/9CoRnFQXGR6MEaY+FXvXEO3RO0JaStk6OXuHVATHJE+1W+TU3bSZ2ksMtqjO0zfSJCdBv7y2d8DMx6TfVme3q0ZpTKMMu4YL/t7ciTNtdDkwPogh3Cnjx7qk08SHwf+dksZ7M2vCOlfsF0hQ6J4ehPCaHTNrM/zBSOqD83dBEBCW/F/LEmeh0nOHd7oVl3/Qo/9GUDkkbj7yz+9cvvu+dDAtx8NzCDTP4iKdZvk9MWiizvtILLepysflSvTLFBZ37RLwiriqyRxYv/zrgFd/9XVHh/OmzBvDX4mitMR/lUavs2Vx6cR94lzAkplm3IRNy4TFfu47tuYs9EQPIPVta4P64tV+sZ7n3ued3cgEx2YK+QL5+xms6osk8qQbTyuKVGdaX9FQqk6qfDnT5ykxk0VK7KZ62b6DNDUfQlqGHxSMKv1P0XN5BqMeKG1P4Wp5QfZDUCEldppoX0U6ss2jIko2XpURKCIhfaOqLPfShdtS37ZrT+jFRSH2xYVV1rmT/MBtRQhxiO4MQ3iAGlaZi+9PWBEIXOVnu9jN1f921lWLZky9bqbM3J2MAAI9jmuAx3gyoEUa6P2ivs0EeNv/OR+AX6q5SW6l5HaoFuS6jr6yg9limu+P0KYKzfMXWcQSfTXzpOzKEKpwI3YGXZpSSy2LTlMgfmFA3CF6R5c9xWEtRuCg2ZPUQ2Nb6dRFTNd4TfGHrnEWSKHPuRyiJSDAZ+KX0VxmSHjGPbQTLVpqixia2uyhQ394gBMt7C3ZAmxn/DJS+l1fBsAo2Eir/C0jG9csd4+/tp12pPc/BVJGaK9mfvr7M/CeztrmCO5qY06Edi4xAGtiEhnWAbzLy2VEyazE1J5nPmgU4RpW4Sa0TnOT6w5lgt3/tMpROigHHmexBGAMY0mdcDbDxWIz41NgdD6oxgHsJRgr5RnT6wZAkTOcStU4NMOQNemSO7gxGahdEsC+NRVGxMUhQmmM0llWRbbmFGHzEqLM4Iw0H7577Kyo+Zf+2cUFIOw93gEY171vQaM0HLwpjpdRR6Jz7V0ckE7XzYJ0TmY9znLdzkva0vNrAGGT5SUZ5uaHDkcGvI0ySpwkasEgZPMseYcu85w8HPdSNi+4T6A83iAwDbxgeFcB1ZM2iGXzFcEOUlYVrEckaOyodfvaYSQ7GuB4ISE0nYJc15X/1ciDTPbPCgYJK55VkEor4LvzL9S2WDy4xj+6FOqVyTAC2ZNowheeeSI5hA/02l8UYkv4nk9iaVn+kCVEUstgk5Hyq+gJm6R9vG3rhuM904he/hFmNQaUIATB1y3vw+OmxP4X5Yi6A5I5jJufHCjF9+AGNwnEllZjUco6XhsO5T5+R3yxz5yLVOnAn0zuS+6zdj0nTJbEZCbXJdtpfYZfCeCOqJHoE2vPPFS6eRLjIJlG69X93nfR0mxSFXzp1Zc0lt/VafDaImhUMtbnqWVb9M4nGNQLN68BHP7AR8Il9dkcxzmBv8PCZlw9guY0lurbBsmNYlwJZsA/B15/HfkbjbwPddaVecls/elmDHNW2r4crAx43feNkfRwsaNq/yyJ0d/p5hZ6AZajz7DBfUok0ZU62gCzz7x8eVfJTKA8IWn45vINLSM1q+HF9CV9qF3zP6Ml21kPPL3CXzkuYUlnSqT+Ij4tI/od5KwIs+tDajDs64owN7tOAd6eucGz+KfO26iNcBFpbWA5732bBNWO4kHNpr9D955L61bvHCF/mwSrz6eQaDjfDEANqGMkFc+NGxpKZzCD2sj/JrHd+zlPQ8Iz7Q+2JVIiVCuCKoK/hlAEHzvk/Piq3mRL1rT/fEh9hoT5GJmeYswg1otiKydizJ/fS2SeKHVu6Z3JEHjiW8NaTQgP5xdBli8nC57XiN9hrquBu99hn9zqwo92+PM2JXtpeVZS0PdqR5mDyDreMMtEws+CpwaRyyzoYtfcvt9PJIW0fJVNNi/FFyRsea7peLvJrL+5b4GOXJ8tAr+ATk9f8KmiIsRhqRy0vFzwRV3Z5dZ3QqIU8JQ/uQpkJbjMUMFj2F9sCFeaBjI4+fL/oN3+LQgjI4zuAfQ+3IPIPFQBccf0clJpsfpnBxD84atwtupkGqKvrH7cGNl/QcWcSi6wcVDML6ljOgYbo+2BOAWNNjlUBPiyitUAwbnhFvLbnqw42kR3Yp2kv2dMeDdcGOX5kT4S6M44KHEB/SpCfl7xgsUvs+JNY9G3O2X/6FEt9FyAn57lrbiu+tl83sCymSvq9eZbe9mchL7MTf/Ta78e80zSf0hYY5eUU7+ff14jv7Xy8qjzfzzzvaJnrIdvFb5BLWKcWGy5/w7+vV2cvIfwHqdTB+RuJK5oj9mbt0Hy94AmjMjjwYNZlNS6uiyxNnwNyt3gdreLb64p/3+08nXkb92LTkkRgFOwk1oGEVllcOj5lv1hfAZywDows0944U8vUFw+A/nuVq/UCygsrmWIBnHyU01d0XJPwriEOvx/ISK6Pk4y2w0gmojZs7lU8TtakBAdne4v/aNxmMpK4VcGMp7si0yqsiolXRuOi1Z1P7SqD3Zmp0CWcyK4Ubmp2SXiXuI5nGLCieFHKHNRIlcY3Pys2dwMTYCaqlyWSITwr2oGXvyU3h1Pf8eQ3w1bnD7ilocVjYDkcXR3Oo1BXgMLTUjNw2xMVwjtp99NhSVc5aIWrDQT5DHPKtCtheBP4zHcw4dz2eRdTMamhlHhtfgqJJHI7NGDUw1XL8vsSeSHyKqDtqoAmrQqsYwvwi7HW3ojWyhIa5oz5xJTaq14NAzFLjVLR12rRNUQ6xohDnrWFb5bG9yf8aCD8d5phoackcNJp+Dw3Due3RM+5Rid7EuIgsnwgpX0rUWh/nqPtByMhMZZ69NpgvRTKZ62ViZ+Q7Dp5r4K0d7EfJuiy06KuIYauRh5Ecrhdt2QpTS1k1AscEHvapNbU3HL1F2TFyR33Wxb5MvH5iZsrn3SDcsxlnnshO8PLwmdGN+paWnQuORtZGX37uhFT64SeuPsx8UOokY6ON85WdQ1dki5zErsJGazcBOddWJEKqNPiJpsMD1GrVLrVY+AOdPWQneTyyP1hRX/lMM4ZogGGOhYuAdr7F/DOiAoc++cn5vlf0zkMUJ40Z1rlgv9BelPqVOpxKeOpzKdF8maK+1Vv23MO9k/8+qpLoxrIGH2EDQlnGmH8CD31G8QqlyQIcpmR5bwmSVw9/Ns6IHgulCRehvZ/+VrM60Cu/r3AontFfrljew74skYe2uyn7JKQtFQBQRJ9ryGic/zQOsbS4scUBctA8cPToQ3x6ZBQu6DPu5m1bnCtP8TllLYA0UTQNVqza5nfew3Mopy1GPUwG5jsl0OVXniPmAcmLqO5HG8Hv3nSLecE9oOjPDXcsTxoCBxYyzBdj4wmnyEV4kvFDunipS8SSkvdaMnTBN9brHUR8xdmmEAp/Pdqk9uextp1t+JrtXwpN/MG2w/qhRMpSNxQ1uhg/kKO30eQ/FyHUDkWHT8V6gGRU4DhDMxZu7xXij9Ui6jlpWmQCqJg3FkOTq3WKneCRYZxBXMNAVLQgHXSCGSqNdjebY94oyIpVjMYehAiFx/tqzBXFHZaL5PeeD74rW5OysFoUXY8sebUZleFTUa/+zBKVTFDopTReXNuZq47QjkWnxjirCommO4L/GrFtVV21EpMyw8wyThL5Y59d88xtlx1g1ttSICDwnof6lt/6zliPzgVUL8jWBjC0o2D6Kg+jNuThkAlaDJsq/AG2aKA//A76avw2KNqtv223P+Wq3StRDDNKFFgtsFukYt1GFDWooFVXitaNhb3RCyJi4cMeNjROiPEDb4k+G3+hD8tsg+5hhmSc/8t2JTSwYoCzAI75doq8QTHe+E/Tw0RQSUDlU+6uBeNN3h6jJGX/mH8oj0i3caCNsjvTnoh73BtyZpsflHLq6AfwJNCDX4S98h4+pCOhGKDhV3rtkKHMa3EG4J9y8zFWI4UsfNzC/Rl5midNn7gwoN9j23HGCQQ+OAZpTTPMdiVow740gIyuEtd0qVxMyNXhHcnuXRKdw5wDUSL358ktjMXmAkvIB73BLa1vfF9BAUZInPYJiwxqFWQQBVk7gQH4ojfUQ/KEjn+A/WR6EEe4CtbpoLe1mzHkajgTIoE0SLDHVauKhrq12zrAXBGbPPWKCt4DGedq3JyGRbmPFW32bE7T20+73BatV/qQhhBWfWBFHfhYWXjALts38FemnoT+9bn1jDBMcUMmYgSc0e7GQjv2MUBwLU8ionCpgV+Qrhg7iUIfUY6JFxR0Y+ZTCPM+rVuq0GNLyJXX6nrUTt8HzFBRY1E/FIm2EeVA9NcXrj7S6YYIChVQCWr/m2fYUjC4j0XLkzZ8GCSLfmkW3PB/xq+nlXsKVBOj7vTvqKCOMq7Ztqr3cQ+N8gBnPaAps+oGwWOkbuxnRYj/x/WjiDclVrs22xMK4qArE1Ztk1456kiJriw6abkNeRHogaPRBgbgF9Z8i/tbzWELN4CvbqtrqV9TtGSnmPS2F9kqOIBaazHYaJ9bi3AoDBvlZasMluxt0BDXfhp02Jn411aVt6S4TUB8ZgFDkI6TP6gwPY85w+oUQSsjIeXVminrwIdK2ZAawb8Se6XOJbOaliQxHSrnAeONDLuCnFejIbp4YDtBcQCwMsYiRZfHefuEJqJcwKTTJ8sx5hjHmJI1sPFHOr6W9AhZ2NAod38mnLQk1gOz2LCAohoQbgMbUK9RMEA3LkiF7Sr9tLZp6lkciIGhE2V546w3Mam53VtVkGbB9w0Yk2XiRnCmbpxmHr2k4eSC0RuNbjNsUfDIfc8DZvRvgUDe1IlKdZTzcT4ZGEb53dp8VtsoZlyXzLHOdAbsp1LPTVaHvLA0GYDFMbAW/WUBfUAdHwqLFAV+3uHvYWrCfhUOR2i89qvCBoOb48usAGdcF2M4aKn79k/43WzBZ+xR1L0uZfia70XP9soQReeuhZiUnXFDG1T8/OXNmssTSnYO+3kVLAgeiY719uDwL9FQycgLPessNihMZbAKG7qwPZyG11G1+ZA3jAX2yddpYfmaKBlmfcK/V0mwIRUDC0nJSOPUl2KB8h13F4dlVZiRhdGY5farwN+f9hEb1cRi41ZcGDn6Xe9MMSTOY81ULJyXIHSWFIQHstVYLiJEiUjktlHiGjntN5/btB8Fu+vp28zl2fZXN+dJDyN6EXhS+0yzqpl/LSJNEUVxmu7BsNdjAY0jVsAhkNuuY0E1G48ej25mSt+00yPbQ4SRCVkIwb6ISvYtmJRPz9Zt5dk76blf+lJwAPH5KDF+vHAmACLoCdG2Adii6dOHnNJnTmZtoOGO8Q1jy1veMw6gbLFToQmfJa7nT7Al89mRbRkZZQxJTKgK5Kc9INzmTJFp0tpAPzNmyL/F08bX3nhCumM/cR/2RPn9emZ3VljokttZD1zVWXlUIqEU7SLk5I0lFRU0AcENXBYazNaVzsVHA/sD3o9hm42wbHIRb/BBQTKzAi8s3+bMtpOOZgLdQzCYPfX3UUxKd1WYVkGH7lh/RBBgMZZwXzU9+GYxdBqlGs0LP+DZ5g2BWNh6FAcR944B+K/JTWI3t9YyVyRhlP4CCoUk/mmF7+r2pilVBjxXBHFaBfBtr9hbVn2zDuI0kEOG3kBx8CGdPOjX1ph1POOZJUO1JEGG0jzUy2tK4X0CgVNYhmkqqQysRNtKuPdCJqK3WW57kaV17vXgiyPrl4KEEWgiGF1euI4QkSFHFf0TDroQiLNKJiLbdhH0YBhriRNCHPxSqJmNNoketaioohqMglh6wLtEGWSM1EZbQg72h0UJAIPVFCAJOThpQGGdKfFovcwEeiBuZHN2Ob4uVM7+gwZLz1D9E7ta4RmMZ24OBBAg7Eh6dLXGofZ4U2TFOCQMKjwhVckjrydRS+YaqCw1kYt6UexuzbNEDyYLTZnrY1PzsHZJT4U+awO2xlqTSYu6n/U29O2wPXgGOEKDMSq+zTUtyc8+6iLp0ivav4FKx+xxVy4FxhIF/pucVDqpsVe2jFOfdZhTzLz2QjtzvsTCvDPU7bzDH2eXVKUV9TZ+qFtaSSxnYgYdXKwVreIgvWhT9eGDB2OvnWyPLfIIIfNnfIxU8nW7MbcH05nhlsYtaW9EZRsxWcKdEqInq1DiZPKCz7iGmAU9/ccnnQud2pNgIGFYOTAWjhIrd63aPDgfj8/sdlD4l+UTlcxTI9jbaMqqN0gQxSHs60IAcW3cH4p3V1aSciTKB29L1tz2eUQhRiTgTvmqc+sGtBNh4ky0mQJGsdycBREP+fAaSs1EREDVo5gvgi5+aCN7NECw30owbCc1mSpjiahyNVwJd1jiGgzSwfTpzf2c5XJvG/g1n0fH88KHNnf+u7ZiRMlXueSIsloJBUtW9ezvsx9grfsX/FNxnbxU1Lvg0hLxixypHKGFAaPu0xCD8oDTeFSyfRT6s8109GMUZL8m2xXp8X2dpPCWWdX84iga4BrTlOfqox4shqEgh/Ht4qRst52cA1xOIUuOxgfUivp6v5f8IVyaryEdpVk72ERAwdT4aoY1usBgmP+0m06Q216H/nubtNYxHaOIYjcach3A8Ez/zc0KcShhel0HCYjFsA0FjYqyJ5ZUH1aZw3+zWC0hLpM6GDfcAdn9fq2orPmZbW6XXrf+Krc9RtvII5jeD3dFoT1KwZJwxfUMvc5KLfn8rROW23Jw89sJ2a5dpB3qWDUBWF2iX8OCuKprHosJ2mflBR+Wqs86VvgI/XMnsqb97+VlKdPVysczPj8Jhzf+WCvGBHijAqYlavbF60soMWlHbvKT+ScvhprgeTln51xX0sF+Eadc/l2s2a5BgkVbHYyz0E85p0LstqH+gEGiR84nBRRFIn8hLSZrGwqjZ3E29cuGi+5Z5bp7EM8MWFa9ssS/vy4VrDfECSv7DSU84DaP0sXI3Ap4lWznQ65nQoTKRWU30gd7Nn8ZowUvGIx4aqyXGwmA/PB4qN8msJUODezUHEl0VP9uo+cZ8vPFodSIB4C7lQYjEFj8yu49C2KIV3qxMFYTevG8KqAr0TPlkbzHHnTpDpvpzziAiNFh8xiT7C/TiyH0EguUw4vxAgpnE27WIypV+uFN2zW7xniF/n75trs9IJ5amB1zXXZ1LFkJ6GbS/dFokzl4cc2mamVwhL4XU0Av5gDWAl+aEWhAP7t2VIwU+EpvfOPDcLASX7H7lZpXA2XQfbSlD4qU18NffNPoAKMNSccBfO9YVVgmlW4RydBqfHAV7+hrZ84WJGho6bNT0YMhxxLdOx/dwGj0oyak9aAkNJ8lRJzUuA8sR+fPyiyTgUHio5+Pp+YaKlHrhR41jY5NESPS3x+zTMe0S2HnLOKCOQPpdxKyviBvdHrCDRqO+l96HhhNBLXWv4yEMuEUYo8kXnYJM8oIgVM4XJ+xXOev4YbWeqsvgq0lmw4/PiYr9sYLt+W5EAuYSFnJEan8CwJwbtASBfLBBpJZiRPor/aCJBZsM+MhvS7ZepyHvU8m5WSmaZnxuLts8ojl6KkS8oSAHkq5GWlCB/NgJ5W3rO2Cj1MK7ahxsCrbTT3a0V/QQH+sErxV4XUWDHx0kkFy25bPmBMBQ6BU3HoHhhYcJB9JhP6NXUWKxnE0raXHB6U9KHpWdQCQI72qevp5fMzcm+AvC85rsynVQhruDA9fp9COe7N56cg1UKGSas89vrN+WlGLYTwi5W+0xYdKEGtGCeNJwXKDU0XqU5uQYnWsMwTENLGtbQMvoGjIFIEMzCRal4rnBAg7D/CSn8MsCvS+FDJJAzoiioJEhZJgAp9n2+1Yznr7H+6eT4YkJ9Mpj60ImcW4i4iHDLn9RydB8dx3QYm3rsX6n4VRrZDsYK6DCGwkwd5n3/INFEpk16fYpP6JtMQpqEMzcOfQGAHXBTEGzuLJ03GYQL9bmV2/7ExDlRf+Uvf1sM2frRtCWmal12pMgtonvSCtR4n1CLUZRdTHDHP1Otwqd+rcdlavnKjUB/OYXQHUJzpNyFoKpQK+2OgrEKpGyIgIBgn2y9QHnTJihZOpEvOKIoHAMGAXHmj21Lym39Mbiow4IF+77xNuewziNVBxr6KD5e+9HzZSBIlUa/AmsDFJFXeyrQakR3FwowTGcADJHcEfhGkXYNGSYo4dh4bxwLM+28xjiqkdn0/3R4UEkvcBrBfn/SzBc1XhKM2VPlJgKSorjDac96V2UnQYXl1/yZPT4DVelgO+soMjexXwYO58VLl5xInQUZI8jc3H2CPnCNb9X05nOxIy4MlecasTqGK6s2az4RjpF2cQP2G28R+7wDPsZDZC/kWtjdoHC7SpdPmqQrUAhMwKVuxCmYTiD9q/O7GHtZvPSN0CAUQN/rymXZNniYLlJDE70bsk6Xxsh4kDOdxe7A2wo7P9F5YvqqRDI6brf79yPCSp4I0jVoO4YnLYtX5nzspR5WB4AKOYtR1ujXbOQpPyYDvfRE3FN5zw0i7reehdi7yV0YDRKRllGCGRk5Yz+Uv1fYl2ZwrnGsqsjgAVo0xEUba8ohjaNMJNwTwZA/wBDWFSCpg1eUH8MYL2zdioxRTqgGQrDZxQyNzyBJPXZF0+oxITJAbj7oNC5JwgDMUJaM5GqlGCWc//KCIrI+aclEe4IA0uzv7cuj6GCdaJONpi13O544vbtIHBF+A+JeDFUQNy61Gki3rtyQ4aUywn6ru314/dkGiP8Iwjo0J/2Txs49ZkwEl4mx+iYUUO55I6pJzU4P+7RRs+DXZkyKUYZqVWrPF4I94m4Wx1tXeE74o9GuX977yvJ/jkdak8+AmoHVjI15V+WwBdARFV2IPirJgVMdsg1Pez2VNHqa7EHWdTkl3XTcyjG9BiueWFvQfXI8aWSkuuRmqi/HUuzqyvLJfNfs0txMqldYYflWB1BS31WkuPJGGwXUCpjiQSktkuBMWwHjSkQxeehqw1Kgz0Trzm7QbtgxiEPDVmWCNCAeCfROTphd1ZNOhzLy6XfJyG6Xgd5MCAZw4xie0Sj5AnY1/akDgNS9YFl3Y06vd6FAsg2gVQJtzG7LVq1OH2frbXNHWH/NY89NNZ4QUSJqL2yEcGADbT38X0bGdukqYlSoliKOcsSTuqhcaemUeYLLoI8+MZor2RxXTRThF1LrHfqf/5LcLAjdl4EERgUysYS2geE+yFdasU91UgUDsc2cSQ1ZoT9+uLOwdgAmifwQqF028INc2IQEDfTmUw3eZxvz7Ud1z3xc1PQfeCvfKsB9jOhRj7rFyb9XcDWLcYj0bByosychMezMLVkFiYcdBBQtvI6K0KRuOZQH2kBsYHJaXTkup8F0eIhO1/GcIwWKpr2mouB7g5TUDJNvORXPXa/mU8bh27TAZYBe2sKx4NSv5OjnHIWD2RuysCzBlUfeNXhDd2jxnHoUlheJ3jBApzURy0fwm2FwwsSU0caQGl0Kv8hopRQE211NnvtLRsmCNrhhpEDoNiZEzD2QdJWKbRRWnaFedXHAELSN0t0bfsCsMf0ktfBoXBoNA+nZN9+pSlmuzspFevmsqqcMllzzvkyXrzoA+Ryo1ePXpdGOoJvhyru+EBRsmOp7MXZ0vNUMUqHLUoKglg1p73sWeZmPc+KAw0pE2zIsFFE5H4192KwDvDxdxEYoDBDNZjbg2bmADTeUKK57IPD4fTYF4c6EnXx/teYMORBDtIhPJneiZny7Nv/zG+YmekIKCoxr6kauE2bZtBLufetNG0BtBY7f+/ImUypMBvdWu/Q7vTMRzw5aQGZWuc1V0HEsItFYMIBnoKGZ0xcarba/TYZq50kCaflFysYjA4EDKHqGdpYWdKYmm+a7TADmW35yfnOYpZYrkpVEtiqF0EujI00aeplNs2k+qyFZNeE3CDPL9P6b4PQ/kataHkVpLSEVGK7EX6rAa7IVNrvZtFvOA6okKvBgMtFDAGZOx88MeBcJ8AR3AgUUeIznAN6tjCUipGDZONm1FjWJp4A3QIzSaIOmZ7DvF/ysYYbM/fFDOV0jntAjRdapxJxL0eThpEhKOjCDDq2ks+3GrwxqIFKLe1WdOzII8XIOPGnwy6LKXVfpSDOTEfaRsGujhpS4hBIsMOqHbl16PJxc4EkaVu9wpEYlF/84NSv5Zum4drMfp9yXbzzAOJqqS4YkI4cBrFrC7bMPiCfgI3nNZAqkk3QOZqR+yyqx+nDQKBBBZ7QKrfGMCL+XpqFaBJU0wpkBdAhbR4hJsmT5aynlvkouoxm/NjD5oe6BzVIO9uktM+/5dEC5P7vZvarmuO/lKXz4sBabVPIATuKTrwbJP8XUkdM6uEctHKXICUJGjaZIWRbZp8czquQYfY6ynBUCfIU+gG6wqSIBmYIm9pZpXdaL121V7q0VjDjmQnXvMe7ysoEZnZL15B0SpxS1jjd83uNIOKZwu5MPzg2NhOx3xMOPYwEn2CUzbSrwAs5OAtrz3GAaUkJOU74XwjaYUmGJdZBS1NJVkGYrToINLKDjxcuIlyfVsKQSG/G4DyiO2SlQvJ0d0Ot1uOG5IFSAkq+PRVMgVMDvOIJMdqjeCFKUGRWBW9wigYvcbU7CQL/7meF2KZAaWl+4y9uhowAX7elogAvItAAxo2+SFxGRsHGEW9BnhlTuWigYxRcnVUBRQHV41LV+Fr5CJYV7sHfeywswx4XMtUx6EkBhR+q8AXXUA8uPJ73Pb49i9KG9fOljvXeyFj9ixgbo6CcbAJ7WHWqKHy/h+YjBwp6VcN7M89FGzQ04qbrQtgrOFybg3gQRTYG5xn73ArkfQWjCJROwy3J38Dx/D7jOa6BBNsitEw1wGq780EEioOeD+ZGp2J66ADiVGMayiHYucMk8nTK2zzT9CnEraAk95kQjy4k0GRElLL5YAKLQErJ5rp1eay9O4Fb6yJGm9U4FaMwPGxtKD6odIIHKoWnhKo1U8KIpFC+MVn59ZXmc7ZTBZfsg6FQ8W10YfTr4u0nYrpHZbZ1jXiLmooF0cOm0+mPnJBXQtepc7n0BqOipNCqI6yyloTeRShNKH04FIo0gcMk0H/xThyN4pPAWjDDkEp3lNNPRNVfpMI44CWRlRgViP64eK0JSRp0WUvCWYumlW/c58Vcz/yMwVcW5oYb9+26TEhwvbxiNg48hl1VI1UXTU//Eta+BMKnGUivctfL5wINDD0giQL1ipt6U7C9cd4+lgqY2lMUZ02Uv6Prs+ZEZer7ZfWBXVghlfOOrClwsoOFKzWEfz6RZu1eCs+K8fLvkts5+BX0gyrFYve0C3qHrn5U/Oh6D/CihmWIrY7HUZRhJaxde+tldu6adYJ+LeXupQw0XExC36RETdNFxcq9glMu4cNQSX9cqR/GQYp+IxUkIcNGWVU7ZtGa6P3XAyodRt0XeS3Tp01AnCh0ZbUh4VrSZeV9RWfSoWyxnY3hzcZ30G/InDq4wxRrEejreBxnhIQbkxenxkaxl+k7eLUQkUR6vKJ2iDFNGX3WmVA1yaOH+mvhBd+sE6vacQzFobwY5BqEAFmejwW5ne7HtVNolOUgJc8CsUxmc/LBi8N5mu9VsIA5HyErnS6zeCz7VLI9+n/hbT6hTokMXTVyXJRKSG2hd2labXTbtmK4fNH3IZBPreSA4FMeVouVN3zG5x9CiGpLw/3pceo4qGqp+rVp+z+7yQ98oEf+nyH4F3+J9IheDBa94Wi63zJbLBCIZm7P0asHGpIJt3PzE3m0S4YIWyXBCVXGikj8MudDPB/6Nm2v4IxJ5gU0ii0guy5SUHqGUYzTP0jIJU5E82RHUXtX4lDdrihBLdP1YaG1AGUC12rQKuIaGvCpMjZC9bWSCYnjDlvpWbkdXMTNeBHLKiuoozMGIvkczmP0aRJSJ8PYnLCVNhKHXBNckH79e8Z8Kc2wUej4sQZoH8qDRGkg86maW/ZQWGNnLcXmq3FlXM6ssR/3P6E/bHMvm6HLrv1yRixit25JsH3/IOr2UV4BWJhxXW5BJ6Xdr07n9kF3ZNAk6/Xpc5MSFmYJ2R7bdL8Kk7q1OU9Elg/tCxJ8giT27wSTySF0GOxg4PbYJdi/Nyia9Nn89CGDulfJemm1aiEr/eleGSN+5MRrVJ4K6lgyTTIW3i9cQ0dAi6FHt0YMbH3wDSAtGLSAccezzxHitt1QdhW36CQgPcA8vIIBh3/JNjf/Obmc2yzpk8edSlS4lVdwgW5vzbYEyFoF4GCBBby1keVNueHAH+evi+H7oOVfS3XuPQSNTXOONAbzJeSb5stwdQHl1ZjrGoE49I8+A9j3t+ahhQj74FCSWpZrj7wRSFJJnnwi1T9HL5qrCFW/JZq6P62XkMWTb+u4lGpKfmmwiJWx178GOG7KbrZGqyWwmuyKWPkNswkZ1q8uptUlviIi+AXh2bOOTOLsrtNkfqbQJeh24reebkINLkjut5r4d9GR/r8CBa9SU0UQhsnZp5cP+RqWCixRm7i4YRFbtZ4EAkhtNa6jHb6gPYQv7MKqkPLRmX3dFsK8XsRLVZ6IEVrCbmNDc8o5mqsogjAQfoC9Bc7R6gfw03m+lQpv6kTfhxscDIX6s0w+fBxtkhjXAXr10UouWCx3C/p/FYwJRS/AXRKkjOb5CLmK4XRe0+xeDDwVkJPZau52bzLEDHCqV0f44pPgKOkYKgTZJ33fmk3Tu8SdxJ02SHM8Fem5SMsWqRyi2F1ynfRJszcFKykdWlNqgDA/L9lKYBmc7Zu/q9ii1FPF47VJkqhirUob53zoiJtVVRVwMR34gV9iqcBaHbRu9kkvqk3yMpfRFG49pKKjIiq7h/VpRwPGTHoY4cg05X5028iHsLvUW/uz+kjPyIEhhcKUwCkJAwbR9pIEGOn8z6svAO8i89sJ3dL5qDWFYbS+HGPRMxYwJItFQN86YESeJQhn2urGiLRffQeLptDl8dAgb+Tp47UQPxWOw17OeChLN1WnzlkPL1T5O+O3Menpn4C3IY5LEepHpnPeZHbvuWfeVtPlkH4LZjPbBrkJT3NoRJzBt86CO0Xq59oQ+8dsm0ymRcmQyn8w71mhmcuEI5byuF+C88VPYly2sEzjlzAQ3vdn/1+Hzguw6qFNNbqenhZGbdiG6RwZaTG7jTA2X9RdXjDN9yj1uQpyO4Lx8KRAcZcbZMafp4wPOd5MdXoFY52V1A8M9hi3sso93+uprE0qYNMjkE22CvK4HuUxqN7oIz5pWuETq1lQAjqlSlqdD2Rnr/ggp/TVkQYjn9lMfYelk2sH5HPdopYo7MHwlV1or9Bxf+QCyLzm92vzG2wjiIjC/ZHEJzeroJl6bdFPTpZho5MV2U86fLQqxNlGIMqCGy+9WYhJ8ob1r0+Whxde9L2PdysETv97O+xVw+VNN1TZSQN5I6l9m5Ip6pLIqLm4a1B1ffH6gHyqT9p82NOjntRWGIofO3bJz5GhkvSWbsXueTAMaJDou99kGLqDlhwBZNEQ4mKPuDvVwSK4WmLluHyhA97pZiVe8g+JxmnJF8IkV/tCs4Jq/HgOoAEGR9tCDsDbDmi3OviUQpG5D8XmKcSAUaFLRXb2lmJTNYdhtYyfjBYZQmN5qT5CNuaD3BVnlkCk7bsMW3AtXkNMMTuW4HjUERSJnVQ0vsBGa1wo3Qh7115XGeTF3NTz8w0440AgU7c3bSXO/KMINaIWXd0oLpoq/0/QJxCQSJ9XnYy1W7TYLBJpHsVWD1ahsA7FjNvRd6mxCiHsm8g6Z0pnzqIpF1dHUtP2ITU5Z1hZHbu+L3BEEStBbL9XYvGfEakv1bmf+bOZGnoiuHEdlBnaChxYKNzB23b8sw8YyT7Ajxfk49eJIAvdbVkdFCe2J0gMefhQ0bIZxhx3fzMIysQNiN8PgOUKxOMur10LduigREDRMZyP4oGWrP1GFY4t6groASsZ421os48wAdnrbovNhLt7ScNULkwZ5AIZJTrbaKYTLjA1oJ3sIuN/aYocm/9uoQHEIlacF1s/TM1fLcPTL38O9fOsjMEIwoPKfvt7opuI9G2Hf/PR4aCLDQ7wNmIdEuXJ/QNL72k5q4NejAldPfe3UVVqzkys8YZ/jYOGOp6c+YzRCrCuq0M11y7TiN6qk7YXRMn/gukxrEimbMQjr3jwRM6dKVZ4RUfWQr8noPXLJq6yh5R3EH1IVOHESst/LItbG2D2vRsZRkAObzvQAAD3mb3/G4NzopI0FAiHfbpq0X72adg6SRj+8OHMShtFxxLZlf/nLgRLbClwl5WmaYSs+yEjkq48tY7Z2bE0N91mJwt+ua0NlRJIDh0HikF4UvSVorFj2YVu9YeS5tfvlVjPSoNu/Zu6dEUfBOT555hahBdN3Sa5Xuj2Rvau1lQNIaC944y0RWj9UiNDskAK1WoL+EfXcC6IbBXFRyVfX/WKXxPAwUyIAGW8ggZ08hcijKTt1YKnUO6QPvcrmDVAb0FCLIXn5id4fD/Jx4tw/gbXs7WF9b2RgXtPhLBG9vF5FEkdHAKrQHZAJC/HWvk7nvzzDzIXZlfFTJoC3JpGgLPBY7SQTjGlUvG577yNutZ1hTfs9/1nkSXK9zzKLRZ3VODeKUovJe0WCq1zVMYxCJMenmNzPIU2S8TA4E7wWmbNkxq9rI2dd6v0VpcAPVMxnDsvWTWFayyqvKZO7Z08a62i/oH2/jxf8rpmfO64in3FLiL1GX8IGtVE9M23yGsIqJbxDTy+LtaMWDaPqkymb5VrQdzOvqldeU0SUi6IirG8UZ3jcpRbwHa1C0Dww9G/SFX3gPvTJQE+kyz+g1BeMILKKO+olcHzctOWgzxYHnOD7dpCRtuZEXACjgqesZMasoPgnuDC4nUviAAxDc5pngjoAITIkvhKwg5d608pdrZcA+qn5TMT6Uo/QzBaOxBCLTJX3Mgk85rMfsnWx86oLxf7p2PX5ONqieTa/qM3tPw4ZXvlAp83NSD8F7+ZgctK1TpoYwtiU2h02HCGioH5tkVCqNVTMH5p00sRy2JU1qyDBP2CII/Dg4WDsIl+zgeX7589srx6YORRQMBfKbodbB743Tl4WLKOEnwWUVBsm94SOlCracU72MSyj068wdpYjyz1FwC2bjQnxnB6Mp/pZ+yyZXtguEaYB+kqhjQ6UUmwSFazOb+rhYjLaoiM+aN9/8KKn0zaCTFpN9eKwWy7/u4EHzO46TdFSNjMfn2iPSJwDPCFHc0I1+vjdAZw5ZjqR/uzi9Zn20oAa5JnLEk/EA3VRWE7J/XrupfFJPtCUuqHPpnlL7ISJtRpSVcB8qsZCm2QEkWoROtCKKxUh3yEcMbWYJwk6DlEBG0bZP6eg06FL3v6RPb7odGuwm7FN8fG4woqtB8e7M5klPpo97GoObNwt+ludTAmxyC5hmcFx+dIvEZKI6igFKHqLH01iY1o7903VzG9QGetyVx5RNmBYUU+zIuSva/yIcECUi4pRmE3VkF2avqulQEUY4yZ/wmNboBzPmAPey3+dSYtBZUjeWWT0pPwCz4Vozxp9xeClIU60qvEFMQCaPvPaA70WlOP9f/ey39macvpGCVa+zfa8gO44wbxpJUlC8GN/pRMTQtzY8Z8/hiNrU+Zq64ZfFGIkdj7m7abcK1EBtws1X4J/hnqvasPvvDSDYWN+QcQVGMqXalkDtTad5rYY0TIR1Eqox3czwPMjKPvF5sFv17Thujr1IZ1Ytl4VX1J0vjXKmLY4lmXipRAro0qVGEcXxEVMMEl54jQMd4J7RjgomU0j1ptjyxY+cLiSyXPfiEcIS2lWDK3ISAy6UZ3Hb5vnPncA94411jcy75ay6B6DSTzK6UTCZR9uDANtPBrvIDgjsfarMiwoax2OlLxaSoYn4iRgkpEGqEkwox5tyI8aKkLlfZ12lO11TxsqRMY89j5JaO55XfPJPDL1LGSnC88Re9Ai+Nu5bZjtwRrvFITUFHPR4ZmxGslQMecgbZO7nHk32qHxYkdvWpup07ojcMCaVrpFAyFZJJbNvBpZfdf39Hdo2kPtT7v0/f8R/B5Nz4f1t9/3zNM/7n6SUHfcWk5dfQFJvcJMgPolGCpOFb/WC0FGWU2asuQyT+rm88ZKZ78Cei/CAh939CH0JYbpZIPtxc2ufXqjS3pHH9lnWK4iJ7OjR/EESpCo2R3MYKyE7rHfhTvWho4cL1QdN4jFTyR6syMwFm124TVDDRXMNveI1Dp/ntwdz8k8kxw7iFSx6+Yx6O+1LzMVrN0BBzziZi9kneZSzgollBnVwBh6oSOPHXrglrOj+QmR/AESrhDpKrWT+8/AiMDxS/5wwRNuGQPLlJ9ovomhJWn8sMLVItQ8N/7IXvtD8kdOoHaw+vBSbFImQsv/OCAIui99E+YSIOMlMvBXkAt+NAZK8wB9Jf8CPtB+TOUOR+z71d/AFXpPBT6+A5FLjxMjLIEoJzrQfquvxEIi+WoUzGR1IzQFNvbYOnxb2PyQ0kGdyXKzW2axQL8lNAXPk6NEjqrRD1oZtKLlFoofrXw0dCNWASHzy+7PSzOUJ3XtaPZsxLDjr+o41fKuKWNmjiZtfkOzItvlV2MDGSheGF0ma04qE3TUEfqJMrXFm7DpK+27DSvCUVf7rbNoljPhha5W7KBqVq0ShUSTbRmuqPtQreVWH4JET5yMhuqMoSd4r/N8sDmeQiQQvi1tcZv7Moc7dT5X5AtCD6kNEGZOzVcNYlpX4AbTsLgSYYliiPyVoniuYYySxsBy5cgb3pD+EK0Gpb0wJg031dPgaL8JZt6sIvzNPEHfVPOjXmaXj4bd4voXzpZ5GApMhILgMbCEWZ2zwgdeQgjNHLbPIt+KqxRwWPLTN6HwZ0Ouijj4UF+Sg0Au8XuIKW0WxlexdrFrDcZJ8Shauat3X0XmHygqgL1nAu2hrJFb4wZXkcS+i36KMyU1yFvYv23bQUJi/3yQpqr/naUOoiEWOxckyq/gq43dFou1DVDaYMZK9tho7+IXXokBCs5GRfOcBK7g3A+jXQ39K4YA8PBRW4m5+yR0ZAxWJncjRVbITvIAPHYRt1EJ3YLiUbqIvoKHtzHKtUy1ddRUQ0AUO41vonZDUOW+mrszw+SW/6Q/IUgNpcXFjkM7F4CSSQ2ExZg85otsMs7kqsQD4OxYeBNDcSpifjMoLb7GEbGWTwasVObmB/bfPcUlq0wYhXCYEDWRW02TP5bBrYsKTGWjnWDDJ1F7zWai0zW/2XsCuvBQjPFcTYaQX3tSXRSm8hsAoDdjArK/OFp6vcWYOE7lizP0Yc+8p16i7/NiXIiiQTp7c7Xus925VEtlKAjUdFhyaiLT7VxDagprMFwix4wZ05u0qj7cDWFd0W9OYHIu3JbJKMXRJ1aYNovugg+QqRN7fNHSi26VSgBpn+JfMuPo3aeqPWik/wI5Rz3BWarPQX4i5+dM0npwVOsX+KsOhC7vDg+OJsz4Q5zlnIeflUWL6QYMbf9WDfLmosLF4Qev3mJiOuHjoor/dMeBpA9iKDkMjYBNbRo414HCxjsHrB4EXNbHzNMDHCLuNBG6Sf+J4MZ/ElVsDSLxjIiGsTPhw8BPjxbfQtskj+dyNMKOOcUYIRBEIqbazz3lmjlRQhplxq673VklMMY6597vu+d89ec/zq7Mi4gQvh87ehYbpOuZEXj5g/Q7S7BFDAAB9DzG35SC853xtWVcnZQoH54jeOqYLR9NDuwxsVthTV7V99n/B7HSbAytbEyVTz/5NhJ8gGIjG0E5j3griULUd5Rg7tQR+90hJgNQKQH2btbSfPcaTOfIexc1db1BxUOhM1vWCpLaYuKr3FdNTt/T3PWCpEUWDKEtzYrjpzlL/wri3MITKsFvtF8QVV/NhVo97aKIBgdliNc10dWdXVDpVtsNn+2UIolrgqdWA4EY8so0YvB4a+aLzMXiMAuOHQrXY0tr+CL10JbvZzgjJJuB1cRkdT7DUqTvnswVUp5kkUSFVtIIFYK05+tQxT6992HHNWVhWxUsD1PkceIrlXuUVRogwmfdhyrf6zzaL8+c0L7GXMZOteAhAVQVwdJh+7nrX7x4LaIIfz2F2v7Dg/uDfz2Fa+4gFm2zHAor8UqimJG3VTJtZEoFXhnDYXvxMJFc6ku2bhbCxzij2z5UNuK0jmp1mnvkVNUfR+SEmj1Lr94Lym75PO7Fs0MIr3GdsWXRXSfgLTVY0FLqba97u1In8NAcY7IC6TjWLigwKEIm43NxTdaVTv9mcKkzuzBkKd8x/xt1p/9BbP7Wyb4bpo1K1gnOpbLvKz58pWl3B55RJ/Z5mRDLPtNQg14jdOEs9+h/V5UVpwrAI8kGbX8KPVPDIMfIqKDjJD9UyDOPhjZ3vFAyecwyq4akUE9mDOtJEK1hpDyi6Ae87sWAClXGTiwPwN7PXWwjxaR79ArHRIPeYKTunVW24sPr/3HPz2IwH8oKH4OlWEmt4BLM6W5g4kMcYbLwj2usodD1088stZA7VOsUSpEVl4w7NMb1EUHMRxAxLF0CIV+0L3iZb+ekB1vSDSFjAZ3hfLJf7gFaXrOKn+mhR+rWw/eTXIcAgl4HvFuBg1LOmOAwJH3eoVEjjwheKA4icbrQCmvAtpQ0mXG0agYp5mj4Rb6mdQ+RV4QBPbxMqh9C7o8nP0Wko2ocnCHeRGhN1XVyT2b9ACsL+6ylUy+yC3QEnaKRIJK91YtaoSrcWZMMwxuM0E9J68Z+YyjA0g8p1PfHAAIROy6Sa04VXOuT6A351FOWhKfTGsFJ3RTJGWYPoLk5FVK4OaYR9hkJvezwF9vQN1126r6isMGXWTqFW+3HL3I/jurlIdDWIVvYY+s6yq7lrFSPAGRdnU7PVwY/SvWbZGpXzy3BQ2LmAJlrONUsZs4oGkly0V267xbD5KMY8woNNsmWG1VVgLCra8aQBBcI4DP2BlNwxhiCtHlaz6OWFoCW0vMR3ErrG7JyMjTSCnvRcsEHgmPnwA6iNpJ2DrFb4gLlhKJyZGaWkA97H6FFdwEcLT6DRQQL++fOkVC4cYGW1TG/3iK5dShRSuiBulmihqgjR45Vi03o2RbQbP3sxt90VxQ6vzdlGfkXmmKmjOi080JSHkLntjvsBJnv7gKscOaTOkEaRQqAnCA4HWtB4XnMtOhpRmH2FH8tTXrIjAGNWEmudQLCkcVlGTQ965Kh0H6ixXbgImQP6b42B49sO5C8pc7iRlgyvSYvcnH9FgQ3azLbQG2cUW96SDojTQStxkOJyOuDGTHAnnWkz29aEwN9FT8EJ4yhXOg+jLTrCPKeEoJ9a7lDXOjEr8AgX4BmnMQ668oW0zYPyQiVMPxKRHtpfnEEyaKhdzNVThlxxDQNdrHeZiUFb6NoY2KwvSb7BnRcpJy+/g/zAYx3fYSN5QEaVD2Y1VsNWxB0BSO12MRsRY8JLfAezRMz5lURuLUnG1ToKk6Q30FughqWN6gBNcFxP/nY/iv+iaUQOa+2Nuym46wtI/DvSfzSp1jEi4SdYBE7YhTiVV5cX9gwboVDMVgZp5YBQlHOQvaDNfcCoCJuYhf5kz5kwiIKPjzgpcRJHPbOhJajeoeRL53cuMahhV8Z7IRr6M4hW0JzT7mzaMUzQpm866zwM7Cs07fJYXuWvjAMkbe5O6V4bu71sOG6JQ4oL8zIeXHheFVavzxmlIyBkgc9IZlEDplMPr8xlcyss4pVUdwK1e7CK2kTsSdq7g5SHRAl3pYUB9Ko4fsh4qleOyJv1z3KFSTSvwEcRO/Ew8ozEDYZSqpfoVW9uhJfYrNAXR0Z3VmeoAD+rVWtwP/13sE/3ICX3HhDG3CMc476dEEC0K3umSAD4j+ZQLVdFOsWL2C1TH5+4KiSWH+lMibo+B55hR3Gq40G1n25sGcN0mEcoU2wN9FCVyQLBhYOu9aHVLWjEKx2JIUZi5ySoHUAI9b8hGzaLMxCZDMLhv8MkcpTqEwz9KFDpCpqQhVmsGQN8m24wyB82FAKNmjgfKRsXRmsSESovAwXjBIoMKSG51p6Um8b3i7GISs7kjTq/PZoioCfJzfKdJTN0Q45kQEQuh9H88M3yEs3DbtRTKALraM0YC8laiMiOOe6ADmTcCiREeAWZelBaEXRaSuj2lx0xHaRYqF65O0Lo5OCFU18A8cMDE4MLYm9w2QSr9NgQAIcRxZsNpA7UJR0e71JL+VU+ISWFk5I97lra8uGg7GlQYhGd4Gc6rxsLFRiIeGO4abP4S4ekQ1fiqDCy87GZHd52fn5aaDGuvOmIofrzpVwMvtbreZ/855OaXTRcNiNE0wzGZSxbjg26v8ko8L537v/XCCWP2MFaArJpvnkep0pA+O86MWjRAZPQRfznZiSIaTppy6m3p6HrNSsY7fDtz7Cl4V/DJAjQDoyiL2uwf1UHVd2AIrzBUSlJaTj4k6NL97a/GqhWKU9RUmjnYKpm2r+JYUcrkCuZKvcYvrg8pDoUKQywY9GDWg03DUFSirlUXBS5SWn/KAntnf0IdHGL/7mwXqDG+LZYjbEdQmqUqq4y54TNmWUP7IgcAw5816YBzwiNIJiE9M4lPCzeI/FGBeYy3p6IAmH4AjXXmvQ4Iy0Y82NTobcAggT2Cdqz6Mx4TdGoq9fn2etrWKUNFyatAHydQTVUQ2S5OWVUlugcNvoUrlA8cJJz9MqOa/W3iVno4zDHfE7zhoY5f5lRTVZDhrQbR8LS4eRLz8iPMyBL6o4PiLlp89FjdokQLaSBmKHUwWp0na5fE3v9zny2YcDXG/jfI9sctulHRbdkI5a4GOPJx4oAJQzVZ/yYAado8KNZUdEFs9ZPiBsausotXMNebEgr0dyopuqfScFJ3ODNPHgclACPdccwv0YJGQdsN2lhoV4HVGBxcEUeUX/alr4nqpcc1CCR3vR7g40zteQg/JvWmFlUE4mAiTpHlYGrB7w+U2KdSwQz2QJKBe/5eiixWipmfP15AFWrK8Sh1GBBYLgzki1wTMhGQmagXqJ2+FuqJ8f0XzXCVJFHQdMAw8xco11HhM347alrAu+wmX3pDFABOvkC+WPX0Uhg1Z5MVHKNROxaR84YV3s12UcM+70cJ460SzEaKLyh472vOMD3XnaK7zxZcXlWqenEvcjmgGNR2OKbI1s8U+iwiW+HotHalp3e1MGDy6BMVIvajnAzkFHbeVsgjmJUkrP9OAwnEHYXVBqYx3q7LvXjoVR0mY8h+ZaOnh053pdsGkmbqhyryN01eVHySr+CkDYkSMeZ1xjPNVM+gVLTDKu2VGsMUJqWO4TwPDP0VOg2/8ITbAUaMGb4LjL7L+Pi11lEVMXTYIlAZ/QHmTENjyx3kDkBdfcvvQt6tKk6jYFM4EG5UXDTaF5+1ZjRz6W7MdJPC+wTkbDUim4p5QQH3b9kGk2Bkilyeur8Bc20wm5uJSBO95GfYDI1EZipoRaH7uVveneqz43tlTZGRQ4a7CNmMHgXyOQQOL6WQkgMUTQDT8vh21aSdz7ERiZT1jK9F+v6wgFvuEmGngSvIUR2CJkc5tx1QygfZnAruONobB1idCLB1FCfO7N1ZdRocT8/Wye+EnDiO9pzqIpnLDl4bkaRKW+ekBVwHn46Shw1X0tclt/0ROijuUB4kIInrVJU4buWf4YITJtjOJ6iKdr1u+flgQeFH70GxKjhdgt/MrwfB4K/sXczQ+9zYcrD4dhY6qZhZ010rrxggWA8JaZyg2pYij8ieYEg1aZJkZK9O1Re7sB0iouf60rK0Gd+AYlp7soqCBCDGwfKeUQhCBn0E0o0GS6PdmjLi0TtCYZeqazqwN+yNINIA8Lk3iPDnWUiIPLGNcHmZDxfeK0iAdxm/T7LnN+gemRL61hHIc0NCAZaiYJR+OHnLWSe8sLrK905B5eEJHNlWq4RmEXIaFTmo49f8w61+NwfEUyuJAwVqZCLFcyHBKAcIVj3sNzfEOXzVKIndxHw+AR93owhbCxUZf6Gs8cz6/1VdrFEPrv330+9s6BtMVPJ3zl/Uf9rUi0Z/opexfdL3ykF76e999GPfVv8fJv/Y/+/5hEMon1tqNFyVRevV9y9/uIvsG3dbB8GRRrgaEXfhx+2xeOFt+cEn3RZanNxdEe2+B6MHpNbrRE53PlDifPvFcp4kO78ILR0T4xyW/WGPyBsqGdoA7zJJCu1TKbGfhnqgnRbxbB2B3UZoeQ2bz2sTVnUwokTcTU21RxN1PYPS3Sar7T0eRIsyCNowr9amwoMU/od9s2APtiKNL6ENOlyKADstAEWKA+sdKDhrJ6BOhRJmZ+QJbAaZ3/5Fq0/lumCgEzGEbu3yi0Y4I4EgVAjqxh4HbuQn0GrRhOWyAfsglQJAVL1y/6yezS2k8RE2MstJLh92NOB3GCYgFXznF4d25qiP4ZCyI4RYGesut6FXK6GwPpKK8WHEkhYui0AyEmr5Ml3uBFtPFdnioI8RiCooa7Z1G1WuyIi3nSNglutc+xY8BkeW3JJXPK6jd2VIMpaSxpVtFq+R+ySK9J6WG5Qvt+C+QH1hyYUOVK7857nFmyDBYgZ/o+AnibzNVqyYCJQvyDXDTK+iXdkA71bY7TL3bvuLxLBQ8kbTvTEY9aqkQ3+MiLWbEgjLzOH+lXgco1ERgzd80rDCymlpaRQbOYnKG/ODoFl46lzT0cjM5FYVvv0qLUbD5lyJtMUaC1pFlTkNONx6lliaX9o0i/1vws5bNKn5OuENQEKmLlcP4o2ZmJjD4zzd3Fk32uQ4uRWkPSUqb4LBe3EXHdORNB2BWsws5daRnMfNVX7isPSb1hMQdAJi1/qmDMfRUlCU74pmnzjbXfL8PVG8NsW6IQM2Ne23iCPIpryJjYbVnm5hCvKpMa7HLViNiNc+xTfDIaKm3jctViD8A1M9YPJNk003VVr4Zo2MuGW8vil8SLaGpPXqG7I4DLdtl8a4Rbx1Lt4w5Huqaa1XzZBtj208EJVGcmKYEuaeN27zT9EE6a09JerXdEbpaNgNqYJdhP1NdqiPKsbDRUi86XvvNC7rME5mrSQtrzAZVndtSjCMqd8BmaeGR4l4YFULGRBeXIV9Y4yxLFdyoUNpiy2IhePSWzBofYPP0eIa2q5JP4j9G8at/AqoSsLAUuRXtvgsqX/zYwsE+of6oSDbUOo4RMJw+DOUTJq+hnqwKim9Yy/napyZNTc2rCq6V9jHtJbxGPDwlzWj/Sk3zF/BHOlT/fSjSq7FqlPI1q6J+ru8Aku008SFINXZfOfnZNOvGPMtEmn2gLPt+H4QLA+/SYe4j398auzhKIp2Pok3mPC5q1IN1HgR+mnEfc4NeeHYwd2/kpszR3cBn7ni9NbIqhtSWFW8xbUJuUPVOeeXu3j0IGZmFNiwaNZ6rH4/zQ2ODz6tFxRLsUYZu1bfd1uIvfQDt4YD/efKYv8VF8bHGDgK22w2Wqwpi43vNCOXFJZCGMqWiPbL8mil6tsmOTXAWCyMCw73e2rADZj2IK6rqksM3EXF2cbLb4vjB14wa/yXK5vwU+05MzERJ5nXsXsW21o7M+gO0js2OyKciP5uF2iXyb2DiptwQeHeqygkrNsqVCSlldxBMpwHi1vfc8RKpP/4L3Lmpq6DZcvhDDfxTCE3splacTcOtXdK2g303dIWBVe2wD/Gvja1cClFQ67gw0t1ZUttsUgQ1Veky8oOpS6ksYEc4bqseCbZy766SvL3FodmnahlWJRgVCNjPxhL/fk2wyvlKhITH/VQCipOI0dNcRa5B1M5HmOBjTLeZQJy237e2mobwmDyJNHePhdDmiknvLKaDbShL+Is1XTCJuLQd2wmdJL7+mKvs294whXQD+vtd88KKk0DXP8B1Xu9J+xo69VOuFgexgTrcvI6SyltuLix9OPuE6/iRJYoBMEXxU4shQMf4Fjqwf1PtnJ/wWSZd29rhZjRmTGgiGTAUQqRz+nCdjeMfYhsBD5Lv60KILWEvNEHfmsDs2L0A252351eUoYxAysVaCJVLdH9QFWAmqJDCODUcdoo12+gd6bW2boY0pBVHWL6LQDK5bYWh1V8vFvi0cRpfwv7cJiMX3AZNJuTddHehTIdU0YQ/sQ1dLoF2xQPcCuHKiuCWOY30DHe1OwcClLAhqAKyqlnIbH/8u9ScJpcS4kgp6HKDUdiOgRaRGSiUCRBjzI5gSksMZKqy7Sd51aeg0tgJ+x0TH9YH2Mgsap9N7ENZdEB0bey2DMTrBA1hn56SErNHf3tKtqyL9b6yXEP97/rc+jgD2N1LNUH6RM9AzP3kSipr06RkKOolR7HO768jjWiH1X92jA7dkg7gcNcjqsZCgfqWw0tPXdLg20cF6vnQypg7gLtkazrHAodyYfENPQZsdfnjMZiNu4nJO97D1/sQE+3vNFzrSDOKw+keLECYf7RJwVHeP/j79833oZ0egonYB2FlFE5qj02B/LVOMJQlsB8uNg3Leg4qtZwntsOSNidR0abbZmAK4sCzvt8Yiuz2yrNCJoH5O8XvX/vLeR/BBYTWj0sOPYM/jyxRd5+/JziKAABaPcw/34UA3aj/gLZxZgRCWN6m4m3demanNgsx0P237/Q+Ew5VYnJPkyCY0cIVHoFn2Ay/e7U4P19APbPFXEHX94N6KhEMPG7iwB3+I+O1jd5n6VSgHegxgaSawO6iQCYFgDsPSMsNOcUj4q3sF6KzGaH/0u5PQoAj/8zq6Uc9MoNrGqhYeb2jQo0WlGlXjxtanZLS24/OIN5Gx/2g684BPDQpwlqnkFcxpmP/osnOXrFuu4PqifouQH0eF5qCkvITQbJw/Zvy5mAHWC9oU+cTiYhJmSfKsCyt1cGVxisKu+NymEQIAyaCgud/V09qT3nk/9s/SWsYtha7yNpzBIMM40rCSGaJ9u6lEkl00vXBiEt7p9P5IBCiavynEOv7FgLqPdeqxRiCwuFVMolSIUBcoyfUC2e2FJSAUgYdVGFf0b0Kn2EZlK97yyxrT2MVgvtRikfdaAW8RwEEfN+B7/eK8bBdp7URpbqn1xcrC6d2UjdsKbzCjBFqkKkoZt7Mrhg6YagE7spkqj0jOrWM+UGQ0MUlG2evP1uE1p2xSv4dMK0dna6ENcNUF+xkaJ7B764NdxLCpuvhblltVRAf7vK5qPttJ/9RYFUUSGcLdibnz6mf7WkPO3MkUUhR2mAOuGv8IWw5XG1ZvoVMnjSAZe6T7WYA99GENxoHkMiKxHlCuK5Gd0INrISImHQrQmv6F4mqU/TTQ8nHMDzCRivKySQ8dqkpQgnUMnwIkaAuc6/FGq1hw3b2Sba398BhUwUZSAIO8XZvnuLdY2n6hOXws+gq9BHUKcKFA6kz6FDnpxLPICa3qGhnc97bo1FT/XJk48LrkHJ2CAtBv0RtN97N21plfpXHvZ8gMJb7Zc4cfI6MbPwsW7AilCSXMFIEUEmir8XLEklA0ztYbGpTTGqttp5hpFTTIqUyaAIqvMT9A/x+Ji5ejA4Bhxb/cl1pUdOD6epd3yilIdO6j297xInoiBPuEDW2/UfslDyhGkQs7Wy253bVnlT+SWg89zYIK/9KXFl5fe+jow2rd5FXv8zDPrmfMXiUPt9QBO/iK4QGbX5j/7Rx1c1vzsY8ONbP3lVIaPrhL4+1QrECTN3nyKavGG0gBBtHvTKhGoBHgMXHStFowN+HKrPriYu+OZ05Frn8okQrPaaxoKP1ULCS/cmKFN3gcH7HQlVjraCeQmtjg1pSQxeuqXiSKgLpxc/1OiZsU4+n4lz4hpahGyWBURLi4642n1gn9qz9bIsaCeEPJ0uJmenMWp2tJmIwLQ6VSgDYErOeBCfSj9P4G/vI7oIF+l/n5fp956QgxGvur77ynawAu3G9MdFbJbu49NZnWnnFcQHjxRuhUYvg1U/e84N4JTecciDAKb/KYIFXzloyuE1eYXf54MmhjTq7B/yBToDzzpx3tJCTo3HCmVPYfmtBRe3mPYEE/6RlTIxbf4fSOcaKFGk4gbaUWe44hVk9SZzhW80yfW5QWBHxmtUzvMhfVQli4gZTktIOZd9mjJ5hsbmzttaHQB29Am3dZkmx3g/qvYocyhZ2PXAWsNQiIaf+Q8W/MWPIK7/TjvCx5q2XRp4lVWydMc2wIQkhadDB0xsnw/kSEyGjLKjI4coVIwtubTF3E7MJ6LS6UOsJKj82XVAVPJJcepfewbzE91ivXZvOvYfsmMevwtPpfMzGmC7WJlyW2j0jh7AF1JLmwEJSKYwIvu6DHc3YnyLH9ZdIBnQ+nOVDRiP+REpqv++typYHIvoJyICGA40d8bR7HR2k7do6UQTHF4oriYeIQbxKe4Th6+/l1BjUtS9hqORh3MbgvYrStXTfSwaBOmAVQZzpYNqsAmQyjY56MUqty3c/xH6GuhNvNaG9vGbG6cPtBM8UA3e8r51D0AR9kozKuGGSMgLz3nAHxDNnc7GTwpLj7/6HeWp1iksDeTjwCLpxejuMtpMnGJgsiku1sOACwQ9ukzESiDRN77YNESxR5LphOlcASXA5uIts1LnBIcn1J7BLWs49DMALSnuz95gdOrTZr0u1SeYHinno/pE58xYoXbVO/S+FEMMs5qyWkMnp8Q3ClyTlZP52Y9nq7b8fITPuVXUk9ohG5EFHw4gAEcjFxfKb3xuAsEjx2z1wxNbSZMcgS9GKyW3R6KwJONgtA64LTyxWm8Bvudp0M1FdJPEGopM4Fvg7G/hsptkhCfHFegv4ENwxPeXmYhxwZy7js+BeM27t9ODBMynVCLJ7RWcBMteZJtvjOYHb5lOnCLYWNEMKC59BA7covu1cANa2PXL05iGdufOzkgFqqHBOrgQVUmLEc+Mkz4Rq8O6WkNr7atNkH4M8d+SD1t/tSzt3oFql+neVs+AwEI5JaBJaxARtY2Z4mKoUqxds4UpZ0sv3zIbNoo0J4fihldQTX3XNcuNcZmcrB5LTWMdzeRuAtBk3cZHYQF6gTi3PNuDJ0nmR+4LPLoHvxQIxRgJ9iNNXqf2SYJhcvCtJiVWo85TsyFOuq7EyBPJrAdhEgE0cTq16FQXhYPJFqSfiVn0IQnPOy0LbU4BeG94QjdYNB0CiQ3QaxQqD2ebSMiNjaVaw8WaM4Z5WnzcVDsr4eGweSLa2DE3BWViaxhZFIcSTjgxNCAfelg+hznVOYoe5VqTYs1g7WtfTm3e4/WduC6p+qqAM8H4ZyrJCGpewThTDPe6H7CzX/zQ8Tm+r65HeZn+MsmxUciEWPlAVaK/VBaQBWfoG/aRL/jSZIQfep/89GjasWmbaWzeEZ2R1FOjvyJT37O9B8046SRSKVEnXWlBqbkb5XCS3qFeuE9xb9+frEknxWB5h1D/hruz2iVDEAS7+qkEz5Ot5agHJc7WCdY94Ws61sURcX5nG8UELGBAHZ3i+3VulAyT0nKNNz4K2LBHBWJcTBX1wzf+//u/j/9+//v87+9/l9Lbh/L/uyNYiTsWV2LwsjaA6MxTuzFMqmxW8Jw/+IppdX8t/Clgi1rI1SN0UC/r6tX/4lUc2VV1OQReSeCsjUpKZchw4XUcjHfw6ryCV3R8s6VXm67vp4n+lcPV9gJwmbKQEsmrJi9c2vkwrm8HFbVYNTaRGq8D91t9n5+U+aD/hNtN3HjC/nC/vUoGFSCkXP+NlRcmLUqLbiUBl4LYf1U/CCvwtd3ryCH8gUmGITAxiH1O5rnGTz7y1LuFjmnFGQ1UWuM7HwfXtWl2fPFKklYwNUpF2IL/TmaRETjQiM5SJacI+3Gv5MBU8lP5Io6gWkawpyzNEVGqOdx4YlO1dCvjbWFZWbCmeiFKPSlMKtKcMFLs/KQxtgAHi7NZNCQ32bBAW2mbHflVZ8wXKi1JKVHkW20bnYnl3dKWJeWJOiX3oKPBD6Zbi0ZvSIuWktUHB8qDR8DMMh1ZfkBL9FS9x5r0hBGLJ8pUCJv3NYH+Ae8p40mZWd5m5fhobFjQeQvqTT4VKWIYfRL0tfaXKiVl75hHReuTJEcqVlug+eOIIc4bdIydtn2K0iNZPsYWQvQio2qbO3OqAlPHDDOB7DfjGEfVF51FqqNacd6QmgFKJpMfLp5DHTv4wXlONKVXF9zTJpDV4m1sYZqJPhotcsliZM8yksKkCkzpiXt+EcRQvSQqmBS9WdWkxMTJXPSw94jqI3varCjQxTazjlMH8jTS8ilaW8014/vwA/LNa+YiFoyyx3s/KswP3O8QW1jtq45yTM/DX9a8M4voTVaO2ebvw1EooDw/yg6Y1faY+WwrdVs5Yt0hQ5EwRfYXSFxray1YvSM+kYmlpLG2/9mm1MfmbKHXr44Ih8nVKb1M537ZANUkCtdsPZ80JVKVKabVHCadaLXg+IV8i5GSwpZti0h6diTaKs9sdpUKEpd7jDUpYmHtiX33SKiO3tuydkaxA7pEc9XIQEOfWJlszj5YpL5bKeQyT7aZSBOamvSHl8xsWvgo26IP/bqk+0EJUz+gkkcvlUlyPp2kdKFtt7y5aCdks9ZJJcFp5ZWeaWKgtnXMN3ORwGLBE0PtkEIek5FY2aVssUZHtsWIvnljMVJtuVIjpZup/5VL1yPOHWWHkOMc6YySWMckczD5jUj2mlLVquFaMU8leGVaqeXis+aRRL8zm4WuBk6cyWfGMxgtr8useQEx7k/PvRoZyd9nde1GUCV84gMX8Ogu/BWezYPSR27llzQnA97oo0pYyxobYUJfsj+ysTm9zJ+S4pk0TGo9VTG0KjqYhTmALfoDZVKla2b5yhv241PxFaLJs3i05K0AAIdcGxCJZmT3ZdT7CliR7q+kur7WdQjygYtOWRL9B8E4s4LI8KpAj7bE0dg7DLOaX+MGeAi0hMMSSWZEz+RudXbZCsGYS0QqiXjH9XQbd8sCB+nIVTq7/T/FDS+zWY9q7Z2fdq1tdLb6v3hKKVDAw5gjj6o9r1wHFROdHc18MJp4SJ2Ucvu+iQ9EgkekW8VCM+psM6y+/2SBy8tNN4a3L1MzP+OLsyvESo5gS7IQOnIqMmviJBVc6zbVG1n8eXiA3j46kmvvtJlewwNDrxk4SbJOtP/TV/lIVK9ueShNbbMHfwnLTLLhbZuO79ec5XvfgRwLFK+w1r5ZWW15rVFZrE+wKqNRv5KqsLNfpGgnoUU6Y71NxEmN7MyqwqAQqoIULOw/LbuUB2+uE75gJt+kq1qY4LoxV+qR/zalupea3D5+WMeaRIn0sAI6DDWDh158fqUb4YhAxhREbUN0qyyJYkBU4V2KARXDT65gW3gRsiv7xSPYEKLwzgriWcWgPr0sbZnv7m1XHNFW6xPdGNZUdxFiUYlmXNjDVWuu7LCkX/nVkrXaJhiYktBISC2xgBXQnNEP+cptWl1eG62a7CPXrnrkTQ5BQASbEqUZWMDiZUisKyHDeLFOaJILUo5f6iDt4ZO8MlqaKLto0AmTHVVbkGuyPa1R/ywZsWRoRDoRdNMMHwYTsklMVnlAd2S0282bgMI8fiJpDh69OSL6K3qbo20KfpNMurnYGQSr/stFqZ7hYsxKlLnKAKhsmB8AIpEQ4bd/NrTLTXefsE6ChRmKWjXKVgpGoPs8GAicgKVw4K0qgDgy1A6hFq1WRat3fHF+FkU+b6H4NWpOU3KXTxrIb2qSHAb+qhm8hiSROi/9ofapjxhyKxxntPpge6KL5Z4+WBMYkAcE6+0Hd3Yh2zBsK2MV3iW0Y6cvOCroXlRb2MMJtdWx+3dkFzGh2Pe3DZ9QpSqpaR/rE1ImOrHqYYyccpiLC22amJIjRWVAherTfpQLmo6/K2pna85GrDuQPlH1Tsar8isAJbXLafSwOof4gg9RkAGm/oYpBQQiPUoyDk2BCQ1k+KILq48ErFo4WSRhHLq/y7mgw3+L85PpP6xWr6cgp9sOjYjKagOrxF148uhuaWtjet953fh1IQiEzgC+d2IgBCcUZqgTAICm2bR8oCjDLBsmg+ThyhfD+zBalsKBY1Ce54Y/t9cwfbLu9SFwEgphfopNA3yNxgyDafUM3mYTovZNgPGdd4ZFFOj1vtfFW3u7N+iHEN1HkeesDMXKPyoCDCGVMo4GCCD6PBhQ3dRZIHy0Y/3MaE5zU9mTCrwwnZojtE+qNpMSkJSpmGe0EzLyFelMJqhfFQ7a50uXxZ8pCc2wxtAKWgHoeamR2O7R+bq7IbPYItO0esdRgoTaY38hZLJ5y02oIVwoPokGIzxAMDuanQ1vn2WDQ00Rh6o5QOaCRu99fwDbQcN0XAuqkFpxT/cfz3slGRVokrNU0iqiMAJFEbKScZdmSkTUznC0U+MfwFOGdLgsewRyPKwBZYSmy6U325iUhBQNxbAC3FLKDV9VSOuQpOOukJ/GAmu/tyEbX9DgEp6dv1zoU0IqzpG6gssSjIYRVPGgU1QAQYRgIT8gEV0EXr1sqeh2I6rXjtmoCYyEDCe/PkFEi/Q48FuT29p557iN+LCwk5CK/CZ2WdAdfQZh2Z9QGrzPLSNRj5igUWzl9Vi0rCqH8G1Kp4QMLkuwMCAypdviDXyOIk0AHTM8HBYKh3b0/F+DxoNj4ZdoZfCpQVdnZarqoMaHWnMLNVcyevytGsrXQEoIbubqWYNo7NRHzdc0zvT21fWVirj7g36iy6pxogfvgHp1xH1Turbz8QyyHnXeBJicpYUctbzApwzZ1HT+FPEXMAgUZetgeGMwt4G+DHiDT2Lu+PT21fjJCAfV16a/Wu1PqOkUHSTKYhWW6PhhHUlNtWzFnA7MbY+r64vkwdpfNB2JfWgWXAvkzd42K4lN9x7Wrg4kIKgXCb4mcW595MCPJ/cTfPAMQMFWwnqwde4w8HZYJFpQwcSMhjVz4B8p6ncSCN1X4klxoIH4BN2J6taBMj6lHkAOs8JJAmXq5xsQtrPIPIIp/HG6i21xMGcFgqDXSRF0xQg14d2uy6HgKE13LSvQe52oShF5Jx1R6avyL4thhXQZHfC94oZzuPUBKFYf1VvDaxIrtV6dNGSx7DO0i1p6CzBkuAmEqyWceQY7F9+U0ObYDzoa1iKao/cOD/v6Q9gHrrr1uCeOk8fST9MG23Ul0KmM3r+Wn6Hi6WAcL7gEeaykicvgjzkjSwFsAXIR81Zx4QJ6oosVyJkCcT+4xAldCcihqvTf94HHUPXYp3REIaR4dhpQF6+FK1H0i9i7Pvh8owu3lO4PT1iuqu+DkL2Bj9+kdfGAg2TXw03iNHyobxofLE2ibjsYDPgeEQlRMR7afXbSGQcnPjI2D+sdtmuQ771dbASUsDndU7t58jrrNGRzISvwioAlHs5FA+cBE5Ccznkd8NMV6BR6ksnKLPZnMUawRDU1MZ/ib3xCdkTblHKu4blNiylH5n213yM0zubEie0o4JhzcfAy3H5qh2l17uLooBNLaO+gzonTH2uF8PQu9EyH+pjGsACTMy4cHzsPdymUSXYJOMP3yTkXqvO/lpvt0cX5ekDEu9PUfBeZODkFuAjXCaGdi6ew4qxJ8PmFfwmPpkgQjQlWqomFY6UkjmcnAtJG75EVR+NpzGpP1Ef5qUUbfowrC3zcSLX3BxgWEgEx/v9cP8H8u1Mvt9/rMDYf6sjwU1xSOPBgzFEeJLMRVFtKo5QHsUYT8ZRLCah27599EuqoC9PYjYO6aoAMHB8X1OHwEAYouHfHB3nyb2B+SnZxM/vw/bCtORjLMSy5aZoEpvgdGvlJfNPFUu/p7Z4VVK1hiI0/UTuB3ZPq4ohEbm7Mntgc1evEtknaosgZSwnDC2BdMmibpeg48X8Ixl+/8+xXdbshQXUPPvx8jT3fkELivHSmqbhblfNFShWAyQnJ3WBU6SMYSIpTDmHjdLVAdlADdz9gCplZw6mTiHqDwIsxbm9ErGusiVpg2w8Q3khKV/R9Oj8PFeF43hmW/nSd99nZzhyjCX3QOZkkB6BsH4H866WGyv9E0hVAzPYah2tkRfQZMmP2rinfOeQalge0ovhduBjJs9a1GBwReerceify49ctOh5/65ATYuMsAkVltmvTLBk4oHpdl6i+p8DoNj4Fb2vhdFYer2JSEilEwPd5n5zNoGBXEjreg/wh2NFnNRaIUHSOXa4eJRwygZoX6vnWnqVdCRT1ARxeFrNBJ+tsdooMwqnYhE7zIxnD8pZH+P0Nu1wWxCPTADfNWmqx626IBJJq6NeapcGeOmbtXvl0TeWG0Y7OGGV4+EHTtNBIT5Wd0Bujl7inXgZgfXTM5efD3qDTJ54O9v3Bkv+tdIRlq1kXcVD0BEMirmFxglNPt5pedb1AnxuCYMChUykwsTIWqT23XDpvTiKEru1cTcEMeniB+HQDehxPXNmkotFdwUPnilB/u4Nx5Xc6l8J9jH1EgKZUUt8t8cyoZleDBEt8oibDmJRAoMKJ5Oe9CSWS5ZMEJvacsGVdXDWjp/Ype5x0p9PXB2PAwt2LRD3d+ftNgpuyvxlP8pB84oB1i73vAVpwyrmXW72hfW6Dzn9Jkj4++0VQ4d0KSx1AsDA4OtXXDo63/w+GD+zC7w5SJaxsmnlYRQ4dgdjA7tTl2KNLnpJ+mvkoDxtt1a4oPaX3EVqj96o9sRKBQqU7ZOiupeAIyLMD+Y3YwHx30XWHB5CQiw7q3mj1EDlP2eBsZbz79ayUMbyHQ7s8gu4Lgip1LiGJj7NQj905/+rgUYKAA5qdrlHKIknWmqfuR+PB8RdBkDg/NgnlT89G72h2NvySnj7UyBwD+mi/IWs1xWbxuVwUIVXun5cMqBtFbrccI+DILjsVQg6eeq0itiRfedn89CvyFtpkxaauEvSANuZmB1p8FGPbU94J9medwsZ9HkUYjmI7OH5HuxendLbxTaYrPuIfE2ffXFKhoNBUp33HsFAXmCV/Vxpq5AYgFoRr5Ay93ZLRlgaIPjhZjXZZChT+aE5iWAXMX0oSFQEtwjiuhQQItTQX5IYrKfKB+queTNplR1Hoflo5/I6aPPmACwQCE2jTOYo5Dz1cs7Sod0KTG/3kEDGk3kUaUCON19xSJCab3kNpWZhSWkO8l+SpW70Wn3g0ciOIJO5JXma6dbos6jyisuxXwUUhj2+1uGhcvuliKtWwsUTw4gi1c/diEEpZHoKoxTBeMDmhPhKTx7TXWRakV8imJR355DcIHkR9IREHxohP4TbyR5LtFU24umRPRmEYHbpe1LghyxPx7YgUHjNbbQFRQhh4KeU1EabXx8FS3JAxp2rwRDoeWkJgWRUSKw6gGP5U2PuO9V4ZuiKXGGzFQuRuf+tkSSsbBtRJKhCi3ENuLlXhPbjTKD4djXVnfXFds6Zb+1XiUrRfyayGxJq1+SYBEfbKlgjiSmk0orgTqzSS+DZ5rTqsJbttiNtp+KMqGE2AHGFw6jQqM5vD6vMptmXV9OAjq49Uf/Lx9Opam+Hn5O9p8qoBBAQixzQZ4eNVkO9sPzJAMyR1y4/RCQQ1s0pV5KAU5sKLw3tkcFbI/JqrjCsK4Mw+W8aod4lioYuawUiCyVWBE/qPaFi5bnkgpfu/ae47174rI1fqQoTbW0HrU6FAejq7ByM0V4zkZTg02/YJK2N7hUQRCeZ4BIgSEqgD8XsjzG6LIsSbuHoIdz/LhFzbNn1clci1NHWJ0/6/O8HJMdIpEZbqi1RrrFfoo/rI/7ufm2MPG5lUI0IYJ4MAiHRTSOFJ2oTverFHYXThkYFIoyFx6rMYFgaOKM4xNWdlOnIcKb/suptptgTOTdVIf4YgdaAjJnIAm4qNNHNQqqAzvi53GkyRCEoseUBrHohZsjUbkR8gfKtc/+Oa72lwxJ8Mq6HDfDATbfbJhzeIuFQJSiw1uZprHlzUf90WgqG76zO0eCB1WdPv1IT6sNxxh91GEL2YpgC97ikFHyoaH92ndwduqZ6IYjkg20DX33MWdoZk7QkcKUCgisIYslOaaLyvIIqRKWQj16jE1DlQWJJaPopWTJjXfixEjRJJo8g4++wuQjbq+WVYjsqCuNIQW3YjnxKe2M5ZKEqq+cX7ZVgnkbsU3RWIyXA1rxv4kGersYJjD//auldXGmcEbcfTeF16Y1708FB1HIfmWv6dSFi6oD4E+RIjCsEZ+kY7dKnwReJJw3xCjKvi3kGN42rvyhUlIz0Bp+fNSV5xwFiuBzG296e5s/oHoFtUyUplmPulIPl+e1CQIQVtjlzLzzzbV+D/OVQtYzo5ixtMi5BmHuG4N/uKfJk5UIREp7+12oZlKtPBomXSzAY0KgtbPzzZoHQxujnREUgBU+O/jKKhgxVhRPtbqyHiUaRwRpHv7pgRPyUrnE7fYkVblGmfTY28tFCvlILC04Tz3ivkNWVazA+OsYrxvRM/hiNn8Fc4bQBeUZABGx5S/xFf9Lbbmk298X7iFg2yeimvsQqqJ+hYbt6uq+Zf9jC+Jcwiccd61NKQtFvGWrgJiHB5lwi6fR8KzYS7EaEHf/ka9EC7H8D+WEa3TEACHBkNSj/cXxFeq4RllC+fUFm2xtstYLL2nos1DfzsC9vqDDdRVcPA3Ho95aEQHvExVThXPqym65llkKlfRXbPTRiDepdylHjmV9YTWAEjlD9DdQnCem7Aj/ml58On366392214B5zrmQz/9ySG2mFqEwjq5sFl5tYJPw5hNz8lyZPUTsr5E0F2C9VMPnZckWP7+mbwp/BiN7f4kf7vtGnZF2JGvjK/sDX1RtcFY5oPQnE4lIAYV49U3C9SP0LCY/9i/WIFK9ORjzM9kG/KGrAuwFmgdEpdLaiqQNpCTGZVuAO65afkY1h33hrqyLjZy92JK3/twdj9pafFcwfXONmPQWldPlMe7jlP24Js0v9m8bIJ9TgS2IuRvE9ZVRaCwSJYOtAfL5H/YS4FfzKWKbek+GFulheyKtDNlBtrdmr+KU+ibHTdalzFUmMfxw3f36x+3cQbJLItSilW9cuvZEMjKw987jykZRlsH/UI+HlKfo2tLwemBEeBFtmxF2xmItA/dAIfQ+rXnm88dqvXa+GapOYVt/2waFimXFx3TC2MUiOi5/Ml+3rj/YU6Ihx2hXgiDXFsUeQkRAD6wF3SCPi2flk7XwKAA4zboqynuELD312EJ88lmDEVOMa1W/K/a8tGylZRMrMoILyoMQzzbDJHNZrhH77L9qSC42HVmKiZ5S0016UTp83gOhCwz9XItK9fgXfK3F5d7nZCBUekoLxrutQaPHa16Rjsa0gTrzyjqTnmcIcrxg6X6dkKiucudc0DD5W4pJPf0vuDW8r5/uw24YfMuxFRpD2ovT2mFX79xH6Jf+MVdv2TYqR6/955QgVPe3JCD/WjAYcLA9tpXgFiEjge2J5ljeI/iUzg91KQuHkII4mmHZxC3XQORLAC6G7uFn5LOmlnXkjFdoO976moNTxElS8HdxWoPAkjjocDR136m2l+f5t6xaaNgdodOvTu0rievnhNAB79WNrVs6EsPgkgfahF9gSFzzAd+rJSraw5Mllit7vUP5YxA843lUpu6/5jAR0RvH4rRXkSg3nE+O5GFyfe+L0s5r3k05FyghSFnKo4TTgs07qj4nTLqOYj6qaW9knJTDkF5OFMYbmCP+8H16Ty482OjvERV6OFyw043L9w3hoJi408sR+SGo1WviXUu8d7qS+ehKjpKwxeCthsm2LBFSFeetx0x4AaKPxtp3CxdWqCsLrB1s/j5TAhc1jNZsXWl6tjo/WDoewxzg8T8NnhZ1niUwL/nhfygLanCnRwaFGDyLw+sfZhyZ1UtYTp8TYB6dE7R3VsKKH95CUxJ8u8N+9u2/9HUNKHW3x3w5GQrfOPafk2w5qZq8MaHT0ebeY3wIsp3rN9lrpIsW9c1ws3VNV+JwNz0Lo9+V7zZr6GD56We6gWVIvtmam5GPPkVAbr74r6SwhuL+TRXtW/0pgyX16VNl4/EAD50TnUPuwrW6OcUO2VlWXS0inq872kk7GUlW6o/ozFKq+Sip6LcTtSDfDrPTcCHhx75H8BeRon+KG2wRwzfDgWhALmiWOMO6h3pm1UCZEPEjScyk7tdLx6WrdA2N1QTPENvNnhCQjW6kl057/qv7IwRryHrZBCwVSbLLnFRiHdTwk8mlYixFt1slEcPD7FVht13HyqVeyD55HOXrh2ElAxJyinGeoFzwKA91zfrdLvDxJSjzmImfvTisreI25EDcVfGsmxLVbfU8PGe/7NmWWKjXcdTJ11jAlVIY/Bv/mcxg/Q10vCHwKG1GW/XbJq5nxDhyLqiorn7Wd7VEVL8UgVzpHMjQ+Z8DUgSukiVwWAKkeTlVVeZ7t1DGnCgJVIdBPZAEK5f8CDyDNo7tK4/5DBjdD5MPV86TaEhGsLVFPQSI68KlBYy84FievdU9gWh6XZrugvtCZmi9vfd6db6V7FmoEcRHnG36VZH8N4aZaldq9zZawt1uBFgxYYx+Gs/qW1jwANeFy+LCoymyM6zgG7j8bGzUyLhvrbJkTYAEdICEb4kMKusKT9V3eIwMLsjdUdgijMc+7iKrr+TxrVWG0U+W95SGrxnxGrE4eaJFfgvAjUM4SAy8UaRwE9j6ZQH5qYAWGtXByvDiLSDfOD0yFA3UCMKSyQ30fyy1mIRg4ZcgZHLNHWl+c9SeijOvbOJxoQy7lTN2r3Y8p6ovxvUY74aOYbuVezryqXA6U+fcp6wSV9X5/OZKP18tB56Ua0gMyxJI7XyNT7IrqN8GsB9rL/kP5KMrjXxgqKLDa+V5OCH6a5hmOWemMUsea9vQl9t5Oce76PrTyTv50ExOqngE3PHPfSL//AItPdB7kGnyTRhVUUFNdJJ2z7RtktZwgmQzhBG/G7QsjZmJfCE7k75EmdIKH7xlnmDrNM/XbTT6FzldcH/rcRGxlPrv4qDScqE7JSmQABJWqRT/TUcJSwoQM+1jvDigvrjjH8oeK2in1S+/yO1j8xAws/T5u0VnIvAPqaE1atNuN0cuRliLcH2j0nTL4JpcR7w9Qya0JoaHgsOiALLCCzRkl1UUESz+ze/gIXHGtDwgYrK6pCFKJ1webSDog4zTlPkgXZqxlQDiYMjhDpwTtBW2WxthWbov9dt2X9XFLFmcF+eEc1UaQ74gqZiZsdj63pH1qcv3Vy8JYciogIVKsJ8Yy3J9w/GhjWVSQAmrS0BPOWK+RKV+0lWqXgYMnIFwpcZVD7zPSp547i9HlflB8gVnSTGmmq1ClO081OW/UH11pEQMfkEdDFzjLC1Cdo/BdL3s7cXb8J++Hzz1rhOUVZFIPehRiZ8VYu6+7Er7j5PSZu9g/GBdmNzJmyCD9wiswj9BZw+T3iBrg81re36ihMLjoVLoWc+62a1U/7qVX5CpvTVF7rocSAKwv4cBVqZm7lLDS/qoXs4fMs/VQi6BtVbNA3uSzKpQfjH1o3x4LrvkOn40zhm6hjduDglzJUwA0POabgdXIndp9fzhOo23Pe+Rk9GSLX0d71Poqry8NQDTzNlsa+JTNG9+UrEf+ngxCjGEsDCc0bz+udVRyHQI1jmEO3S+IOQycEq7XwB6z3wfMfa73m8PVRp+iOgtZfeSBl01xn03vMaQJkyj7vnhGCklsCWVRUl4y+5oNUzQ63B2dbjDF3vikd/3RUMifPYnX5Glfuk2FsV/7RqjI9yKTbE8wJY+74p7qXO8+dIYgjtLD/N8TJtRh04N9tXJA4H59IkMmLElgvr0Q5OCeVfdAt+5hkh4pQgfRMHpL74XatLQpPiOyHRs/OdmHtBf8nOZcxVKzdGclIN16lE7kJ+pVMjspOI+5+TqLRO6m0ZpNXJoZRv9MPDRcAfJUtNZHyig/s2wwReakFgPPJwCQmu1I30/tcBbji+Na53i1W1N+BqoY7Zxo+U/M9XyJ4Ok2SSkBtoOrwuhAY3a03Eu6l8wFdIG1cN+e8hopTkiKF093KuH/BcB39rMiGDLn6XVhGKEaaT/vqb/lufuAdpGExevF1+J9itkFhCfymWr9vGb3BTK4j598zRH7+e+MU9maruZqb0pkGxRDRE1CD4Z8LV4vhgPidk5w2Bq816g3nHw1//j3JStz7NR9HIWELO8TMn3QrP/zZp//+Dv9p429/ogv+GATR+n/UdF+ns9xNkXZQJXY4t9jMkJNUFygAtzndXwjss+yWH9HAnLQQfhAskdZS2l01HLWv7L7us5uTH409pqitvfSOQg/c+Zt7k879P3K9+WV68n7+3cZfuRd/dDPP/03rn+d+/nBvWfgDlt8+LzjqJ/vx3CnNOwiXhho778C96iD+1TBvRZYeP+EH81LE0vVwOOrmCLB3iKzI1x+vJEsrPH4uF0UB4TJ4X3uDfOCo3PYpYe0MF4bouh0DQ/l43fxUF7Y+dpWuvTSffB0yO2UQUETI/LwCZE3BvnevJ7c9zUlY3H58xzke6DNFDQG8n0WtDN4LAYN4nogKav1ezOfK/z+t6tsCTp+dhx4ymjWuCJk1dEUifDP+HyS4iP/Vg9B2jTo9L4NbiBuDS4nuuHW6H+JDQn2JtqRKGkEQPEYE7uzazXIkcxIAqUq1esasZBETlEZY7y7Jo+RoV/IsjY9eIMkUvr42Hc0xqtsavZvhz1OLwSxMOTuqzlhb0WbdOwBH9EYiyBjatz40bUxTHbiWxqJ0uma19qhPruvcWJlbiSSH48OLDDpaHPszvyct41ZfTu10+vjox6kOqK6v0K/gEPphEvMl/vwSv+A4Hhm36JSP9IXTyCZDm4kKsqD5ay8b1Sad/vaiyO5N/sDfEV6Z4q95E+yfjxpqBoBETW2C7xl4pIO2bDODDFurUPwE7EWC2Uplq+AHmBHvir2PSgkR12/Ry65O0aZtQPeXi9mTlF/Wj5GQ+vFkYyhXsLTjrBSP9hwk4GPqDP5rBn5/l8b0mLRAvRSzXHc293bs3s8EsdE3m2exxidWVB4joHR+S+dz5/W+v00K3TqN14CDBth8eWcsTbiwXPsygHdGid0PEdy6HHm2v/IUuV5RVapYmzGsX90mpnIdNGcOOq64Dbc5GUbYpD9M7S+6cLY//QmjxFLP5cuTFRm3vA5rkFZroFnO3bjHF35uU3s8mvL7Tp9nyTc4mymTJ5sLIp7umSnGkO23faehtz3mmTS7fbVx5rP7x3HXIjRNeq/A3xCs9JNB08c9S9BF2O3bOur0ItslFxXgRPdaapBIi4dRpKGxVz7ir69t/bc9qTxjvtOyGOfiLGDhR4fYywHv1WdOplxIV87TpLBy3Wc0QP0P9s4G7FBNOdITS/tep3o3h1TEa5XDDii7fWtqRzUEReP2fbxz7bHWWJdbIOxOUJZtItNZpTFRfj6vm9sYjRxQVO+WTdiOhdPeTJ+8YirPvoeL88l5iLYOHd3b/Imkq+1ZN1El3UikhftuteEYxf1Wujof8Pr4ICTu5ezZyZ4tHQMxlzUHLYO2VMOoNMGL/20S5i2o2obfk+8qqdR7xzbRDbgU0lnuIgz4LelQ5XS7xbLuSQtNS95v3ZUOdaUx/Qd8qxCt6xf2E62yb/HukLO6RyorV8KgYl5YNc75y+KvefrxY+lc/64y9kvWP0a0bDz/rojq+RWjO06WeruWqNFU7r3HPIcLWRql8ICZsz2Ls/qOm/CLn6++X+Qf7mGspYCrZod/lpl6Rw4xN/yuq8gqV4B6aHk1hVE1SfILxWu5gvXqbfARYQpspcxKp1F/c8XOPzkZvmoSw+vEqBLdrq1fr3wAPv5NnM9i8F+jdAuxkP5Z71c6uhK3enlnGymr7UsWZKC12qgUiG8XXGQ9mxnqz4GSIlybF9eXmbqj2sHX+a1jf0gRoONHRdRSrIq03Ty89eQ1GbV/Bk+du4+V15zls+vvERvZ4E7ZbnxWTVjDjb4o/k8jlw44pTIrUGxxuJvBeO+heuhOjpFsO6lVJ/aXnJDa/bM0Ql1cLbXE/Pbv3EZ3vj3iVrB5irjupZTzlnv677NrI9UNYNqbPgp/HZXS+lJmk87wec+7YOxTDo2aw2l3NfDr34VNlvqWJBknuK7oSlZ6/T10zuOoPZOeoIk81N+sL843WJ2Q4Z0fZ3scsqC/JV2fuhWi1jGURSKZV637lf53Xnnx16/vKEXY89aVJ0fv91jGdfG+G4+sniwHes4hS+udOr4RfhFhG/F5gUG35QaU+McuLmclb5ZWmR+sG5V6nf+PxYzlrnFGxpZaK8eqqVo0NfmAWoGfXDiT/FnUbWvzGDOTr8aktOZWg4BYvz5YH12ZbfCcGtNk+dDAZNGWvHov+PIOnY9Prjg8h/wLRrT69suaMVZ5bNuK00lSVpnqSX1NON/81FoP92rYndionwgOiA8WMf4vc8l15KqEEG4yAm2+WAN5Brfu1sq9suWYqgoajgOYt/JCk1gC8wPkK+XKCtRX6TAtgvrnuBgNRmn6I8lVDipOVB9kX6Oxkp4ZKyd1M6Gj8/v2U7k+YQBL95Kb9PQENucJb0JlW3b5tObN7m/Z1j1ev388d7o15zgXsI9CikAGAViR6lkJv7nb4Ak40M2G8TJ447kN+pvfHiOFjSUSP6PM+QfbAywKJCBaxSVxpizHseZUyUBhq59vFwrkyGoRiHbo0apweEZeSLuNiQ+HAekOnarFg00dZNXaPeoHPTRR0FmEyqYExOVaaaO8c0uFUh7U4e/UxdBmthlBDgg257Q33j1hA7HTxSeTTSuVnPZbgW1nodwmG16aKBDKxEetv7D9OjO0JhrbJTnoe+kcGoDJazFSO8/fUN9Jy/g4XK5PUkw2dgPDGpJqBfhe7GA+cjzfE/EGsMM+FV9nj9IAhrSfT/J3QE5TEIYyk5UjsI6ZZcCPr6A8FZUF4g9nnpVmjX90MLSQysIPD0nFzqwCcSJmIb5mYv2Cmk+C1MDFkZQyCBq4c/Yai9LJ6xYkGS/x2s5/frIW2vmG2Wrv0APpCdgCA9snFvfpe8uc0OwdRs4G9973PGEBnQB5qKrCQ6m6X/H7NInZ7y/1674/ZXOVp7OeuCRk8JFS516VHrnH1HkIUIlTIljjHaQtEtkJtosYul77cVwjk3gW1Ajaa6zWeyHGLlpk3VHE2VFzT2yI/EvlGUSz2H9zYE1s4nsKMtMqNyKNtL/59CpFJki5Fou6VXGm8vWATEPwrUVOLvoA8jLuwOzVBCgHB2Cr5V6OwEWtJEKokJkfc87h+sNHTvMb0KVTp5284QTPupoWvQVUwUeogZR3kBMESYo0mfukewRVPKh5+rzLQb7HKjFFIgWhj1w3yN/qCNoPI8XFiUgBNT1hCHBsAz8L7Oyt8wQWUFj92ONn/APyJFg8hzueqoJdNj57ROrFbffuS/XxrSXLTRgj5uxZjpgQYceeMc2wJrahReSKpm3QjHfqExTLAB2ipVumE8pqcZv8LYXQiPHHsgb5BMW8zM5pvQit+mQx8XGaVDcfVbLyMTlY8xcfmm/RSAT/H09UQol5gIz7rESDmnrQ4bURIB4iRXMDQwxgex1GgtDxKp2HayIkR+E/aDmCttNm2C6lytWdfOVzD6X2SpDWjQDlMRvAp1symWv4my1bPCD+E1EmGnMGWhNwmycJnDV2WrQNxO45ukEb08AAffizYKVULp15I4vbNK5DzWwCSUADfmKhfGSUqii1L2UsE8rB7mLuHuUJZOx4+WiizHBJ/hwboaBzhpNOVvgFTf5cJsHef7L1HCI9dOUUbb+YxUJWn6dYOLz+THi91kzY5dtO5c+grX7v0jEbsuoOGnoIreDIg/sFMyG+TyCLIcAWd1IZ1UNFxE8Uie13ucm40U2fcxC0u3WLvLOxwu+F7MWUsHsdtFQZ7W+nlfCASiAKyh8rnP3EyDByvtJb6Kax6/HkLzT9SyEyTMVM1zPtM0MJY14DmsWh4MgD15Ea9Hd00AdkTZ0EiG5NAGuIBzQJJ0JR0na+OB7lQA6UKxMfihIQ7GCCnVz694QvykWXTxpS2soDu+smru1UdIxSvAszBFD1c8c6ZOobA8bJiJIvuycgIXBQIXWwhyTgZDQxJTRXgEwRNAawGSXO0a1DKjdihLVNp/taE/xYhsgwe+VpKEEB4LlraQyE84gEihxCnbfoyOuJIEXy2FIYw+JjRusybKlU2g/vhTSGTydvCvXhYBdtAXtS2v7LkHtmXh/8fly1do8FI/D0f8UbzVb5h+KRhMGSAmR2mhi0YG/uj7wgxcfzCrMvdjitUIpXDX8ae2JcF/36qUWIMwN6JsjaRGNj+jEteGDcFyTUb8X/NHSucKMJp7pduxtD6KuxVlyxxwaeiC1FbGBESO84lbyrAugYxdl+2N8/6AgWpo/IeoAOcsG35IA/b3AuSyoa55L7llBLlaWlEWvuCFd8f8NfcTUgzJv6CbB+6ohWwodlk9nGWFpBAOaz5uEW5xBvmjnHFeDsb0mXwayj3mdYq5gxxNf3H3/tnCgHwjSrpSgVxLmiTtuszdRUFIsn6LiMPjL808vL1uQhDbM7aA43mISXReqjSskynIRcHCJ9qeFopJfx9tqyUoGbSwJex/0aDE3plBPGtNBYgWbdLom3+Q/bjdizR2/AS/c/dH/d3G7pyl1qDXgtOFtEqidwLqxPYtrNEveasWq3vPUUtqTeu8gpov4bdOQRI2kneFvRNMrShyVeEupK1PoLDPMSfWMIJcs267mGB8X9CehQCF0gIyhpP10mbyM7lwW1e6TGvHBV1sg/UyTghHPGRqMyaebC6pbB1WKNCQtlai1GGvmq9zUKaUzLaXsXEBYtHxmFbEZ2kJhR164LhWW2Tlp1dhsGE7ZgIWRBOx3Zcu2DxgH+G83WTPceKG0TgQKKiiNNOlWgvqNEbnrk6fVD+AqRam2OguZb0YWSTX88N+i/ELSxbaUUpPx4vJUzYg/WonSeA8xUK6u7DPHgpqWpEe6D4cXg5uK9FIYVba47V/nb+wyOtk+zG8RrS4EA0ouwa04iByRLSvoJA2FzaobbZtXnq8GdbfqEp5I2dpfpj59TCVif6+E75p665faiX8gS213RqBxTZqfHP46nF6NSenOneuT+vgbLUbdTH2/t0REFXZJOEB6DHvx6N6g9956CYrY/AYcm9gELJXYkrSi+0F0geKDZgOCIYkLU/+GOW5aGj8mvLFgtFH5+XC8hvAE3CvHRfl4ofM/Qwk4x2A+R+nyc9gNu/9Tem7XW4XRnyRymf52z09cTOdr+PG6+P/Vb4QiXlwauc5WB1z3o+IJjlbxI8MyWtSzT+k4sKVbhF3xa+vDts3NxXa87iiu+xRH9cAprnOL2h6vV54iQRXuOAj1s8nLFK8gZ70ThIQcWdF19/2xaJmT0efrkNDkWbpAQPdo92Z8+Hn/aLjbOzB9AI/k12fPs9HhUNDJ1u6ax2VxD3R6PywN7BrLJ26z6s3QoMp76qzzwetrDABKSGkfW5PwS1GvYNUbK6uRqxfyVGNyFB0E+OugMM8kKwmJmupuRWO8XkXXXQECyRVw9UyIrtCtcc4oNqXqr7AURBmKn6Khz3eBN96LwIJrAGP9mr/59uTOSx631suyT+QujDd4beUFpZ0kJEEnjlP+X/Kr2kCKhnENTg4BsMTOmMqlj2WMFLRUlVG0fzdCBgUta9odrJfpVdFomTi6ak0tFjXTcdqqvWBAzjY6hVrH9sbt3Z9gn+AVDpTcQImefbB4edirjzrsNievve4ZT4EUZWV3TxEsIW+9MT/RJoKfZZYSRGfC1CwPG/9rdMOM8qR/LUYvw5f/emUSoD7YSFuOoqchdUg2UePd1eCtFSKgxLSZ764oy4lvRCIH6bowPxZWwxNFctksLeil47pfevcBipkkBIc4ngZG+kxGZ71a72KQ7VaZ6MZOZkQJZXM6kb/Ac0/XkJx8dvyfJcWbI3zONEaEPIW8GbkYjsZcwy+eMoKrYjDmvEEixHzkCSCRPRzhOfJZuLdcbx19EL23MA8rnjTZZ787FGMnkqnpuzB5/90w1gtUSRaWcb0eta8198VEeZMUSfIhyuc4/nywFQ9uqn7jdqXh+5wwv+RK9XouNPbYdoEelNGo34KyySwigsrfCe0v/PlWPvQvQg8R0KgHO18mTVThhQrlbEQ0Kp/JxPdjHyR7E1QPw/ut0r+HDDG7BwZFm9IqEUZRpv2WpzlMkOemeLcAt5CsrzskLGaVOAxyySzZV/D2EY7ydNZMf8e8VhHcKGHAWNszf1EOq8fNstijMY4JXyATwTdncFFqcNDfDo+mWFvxJJpc4sEZtjXyBdoFcxbUmniCoKq5jydUHNjYJxMqN1KzYV62MugcELVhS3Bnd+TLLOh7dws/zSXWzxEb4Nj4aFun5x4kDWLK5TUF/yCXB/cZYvI9kPgVsG2jShtXkxfgT+xzjJofXqPEnIXIQ1lnIdmVzBOM90EXvJUW6a0nZ/7XjJGl8ToO3H/fdxnxmTNKBZxnkpXLVgLXCZywGT3YyS75w/PAH5I/jMuRspej8xZObU9kREbRA+kqjmKRFaKGWAmFQspC+QLbKPf0RaK3OXvBSWqo46p70ws/eZpu6jCtZUgQy6r4tHMPUdAgWGGUYNbuv/1a6K+MVFsd3T183+T8capSo6m0+Sh57fEeG/95dykGJBQMj09DSW2bY0mUonDy9a8trLnnL5B5LW3Nl8rJZNysO8Zb+80zXxqUGFpud3Qzwb7bf+8mq6x0TAnJU9pDQR9YQmZhlna2xuxJt0aCO/f1SU8gblOrbIyMsxTlVUW69VJPzYU2HlRXcqE2lLLxnObZuz2tT9CivfTAUYfmzJlt/lOPgsR6VN64/xQd4Jlk/RV7UKVv2Gx/AWsmTAuCWKhdwC+4HmKEKYZh2Xis4KsUR1BeObs1c13wqFRnocdmuheaTV30gvVXZcouzHKK5zwrN52jXJEuX6dGx3BCpV/++4f3hyaW/cQJLFKqasjsMuO3B3WlMq2gyYfdK1e7L2pO/tRye2mwzwZPfdUMrl5wdLqdd2Kv/wVtnpyWYhd49L6rsOV+8HXPrWH2Kup89l2tz6bf80iYSd+V4LROSOHeamvexR524q4r43rTmtFzQvArpvWfLYFZrbFspBsXNUqqenjxNNsFXatZvlIhk7teUPfK+YL32F8McTnjv0BZNppb+vshoCrtLXjIWq3EJXpVXIlG6ZNL0dh6qEm2WMwDjD3LfOfkGh1/czYc/0qhiD2ozNnH4882MVVt3JbVFkbwowNCO3KL5IoYW5wlVeGCViOuv1svZx7FbzxKzA4zGqBlRRaRWCobXaVq4yYCWbZf8eiJwt3OY+MFiSJengcFP2t0JMfzOiJ7cECvpx7neg1Rc5x+7myPJOXt2FohVRyXtD+/rDoTOyGYInJelZMjolecVHUhUNqvdZWg2J2t0jPmiLFeRD/8fOT4o+NGILb+TufCo9ceBBm3JLVn+MO2675n7qiEX/6W+188cYg3Zn5NSTjgOKfWFSAANa6raCxSoVU851oJLY11WIoYK0du0ec5E4tCnAPoKh71riTsjVIp3gKvBbEYQiNYrmH22oLQWA2AdwMnID6PX9b58dR2QKo4qag1D1Z+L/FwEKTR7osOZPWECPJIHQqPUsM5i/CH5YupVPfFA5pHUBcsesh8eO5YhyWnaVRPZn/BmdXVumZWPxMP5e28zm2uqHgFoT9CymHYNNrzrrjlXZM06HnzDxYNlI5b/QosxLmmrqDFqmogQdqk0WLkUceoAvQxHgkIyvWU69BPFr24VB6+lx75Rna6dGtrmOxDnvBojvi1/4dHjVeg8owofPe1cOnxU1ioh016s/Vudv9mhV9f35At+Sh28h1bpp8xhr09+vf47Elx3Ms6hyp6QvB3t0vnLbOhwo660cp7K0vvepabK7YJfxEWWfrC2YzJfYOjygPwfwd/1amTqa0hZ5ueebhWYVMubRTwIjj+0Oq0ohU3zfRfuL8gt59XsHdwKtxTQQ4Y2qz6gisxnm2UdlmpEkgOsZz7iEk6QOt8BuPwr+NR01LTqXmJo1C76o1N274twJvl+I069TiLpenK/miRxhyY8jvYV6W1WuSwhH9q7kuwnJMtm7IWcqs7HsnyHSqWXLSpYtZGaR1V3t0gauninFPZGtWskF65rtti48UV9uV9KM8kfDYs0pgB00S+TlzTXV6P8mxq15b9En8sz3jWSszcifZa/NuufPNnNTb031pptt0+sRSH/7UG8pzbsgtt3OG3ut7B9JzDMt2mTZuyRNIV8D54TuTrpNcHtgmMlYJeiY9XS83NYJicjRjtJSf9BZLsQv629QdDsKQhTK5CnXhpk7vMNkHzPhm0ExW/VCGApHfPyBagtZQTQmPHx7g5IXXsrQDPzIVhv2LB6Ih138iSDww1JNHrDvzUxvp73MsQBVhW8EbrReaVUcLB1R3PUXyaYG4HpJUcLVxMgDxcPkVRQpL7VTAGabDzbKcvg12t5P8TSGQkrj/gOrpnbiDHwluA73xbXts/L7u468cRWSWRtgTwlQnA47EKg0OiZDgFxAKQQUcsbGomITgeXUAAyKe03eA7Mp4gnyKQmm0LXJtEk6ddksMJCuxDmmHzmVhO+XaN2A54MIh3niw5CF7PwiXFZrnA8wOdeHLvvhdoqIDG9PDI7UnWWHq526T8y6ixJPhkuVKZnoUruOpUgOOp3iIKBjk+yi1vHo5cItHXb1PIKzGaZlRS0g5d3MV2pD8FQdGYLZ73aae/eEIUePMc4NFz8pIUfLCrrF4jVWH5gQneN3S8vANBmUXrEcKGn6hIUN95y1vpsvLwbGpzV9L0ZKTan6TDXM05236uLJcIEMKVAxKNT0K8WljuwNny3BNQRfzovA85beI9zr1AGNYnYCVkR1aGngWURUrgqR+gRrQhxW81l3CHevjvGEPzPMTxdsIfB9dfGRbZU0cg/1mcubtECX4tvaedmNAvTxCJtc2QaoUalGfENCGK7IS/O8CRpdOVca8EWCRwv2sSWE8CJPW5PCugjCXPd3h6U60cPD+bdhtXZuYB6stcoveE7Sm5MM2yvfUHXFSW7KzLmi7/EeEWL0wqcOH9MOSKjhCHHmw+JGLcYE/7SBZQCRggox0ZZTAxrlzNNXYXL5fNIjkdT4YMqVUz6p8YDt049v4OXGdg3qTrtLBUXOZf7ahPlZAY/O+7Sp0bvGSHdyQ8B1LOsplqMb9Se8VAE7gIdSZvxbRSrfl+Lk5Qaqi5QJceqjitdErcHXg/3MryljPSIAMaaloFm1cVwBJ8DNmkDqoGROSHFetrgjQ5CahuKkdH5pRPigMrgTtlFI8ufJPJSUlGgTjbBSvpRc0zypiUn6U5KZqcRoyrtzhmJ7/caeZkmVRwJQeLOG8LY6vP5ChpKhc8Js0El+n6FXqbx9ItdtLtYP92kKfaTLtCi8StLZdENJa9Ex1nOoz1kQ7qxoiZFKRyLf4O4CHRT0T/0W9F8epNKVoeyxUXhy3sQMMsJjQJEyMOjmOhMFgOmmlscV4eFi1CldU92yjwleirEKPW3bPAuEhRZV7JsKV3Lr5cETAiFuX5Nw5UlF7d2HZ96Bh0sgFIL5KGaKSoVYVlvdKpZJVP5+NZ7xDEkQhmDgsDKciazJCXJ6ZN2B3FY2f6VZyGl/t4aunGIAk/BHaS+i+SpdRfnB/OktOvyjinWNfM9Ksr6WwtCa1hCmeRI6icpFM4o8quCLsikU0tMoZI/9EqXRMpKGaWzofl4nQuVQm17d5fU5qXCQeCDqVaL9XJ9qJ08n3G3EFZS28SHEb3cdRBdtO0YcTzil3QknNKEe/smQ1fTb0XbpyNB5xAeuIlf+5KWlEY0DqJbsnzJlQxJPOVyHiKMx5Xu9FcEv1Fbg6Fhm4t+Jyy5JC1W3YO8dYLsO0PXPbxodBgttTbH3rt9Cp1lJIk2r3O1Zqu94eRbnIz2f50lWolYzuKsj4PMok4abHLO8NAC884hiXx5Fy5pWKO0bWL7uEGXaJCtznhP67SlQ4xjWIfgq6EpZ28QMtuZK7JC0RGbl9nA4XtFLug/NLMoH1pGt9IonAJqcEDLyH6TDROcbsmGPaGIxMo41IUAnQVPMPGByp4mOmh9ZQMkBAcksUK55LsZj7E5z5XuZoyWCKu6nHmDq22xI/9Z8YdxJy4kWpD16jLVrpwGLWfyOD0Wd+cBzFBxVaGv7S5k9qwh/5t/LQEXsRqI3Q9Rm3QIoaZW9GlsDaKOUyykyWuhNOprSEi0s1G4rgoiX1V743EELti+pJu5og6X0g6oTynUqlhH9k6ezyRi05NGZHz0nvp3HOJr7ebrAUFrDjbkFBObEvdQWkkUbL0pEvMU46X58vF9j9F3j6kpyetNUBItrEubW9ZvMPM4qNqLlsSBJqOH3XbNwv/cXDXNxN8iFLzUhteisYY+RlHYOuP29/Cb+L+xv+35Rv7xudnZ6ohK4cMPfCG8KI7dNmjNk/H4e84pOxn/sZHK9psfvj8ncA8qJz7O8xqbxESDivGJOZzF7o5PJLQ7g34qAWoyuA+x3btU98LT6ZyGyceIXjrqob2CAVql4VOTQPUQYvHV/g4zAuCZGvYQBtf0wmd5lilrvuEn1BXLny01B4h4SMDlYsnNpm9d7m9h578ufpef9Z4WplqWQvqo52fyUA7J24eZD5av6SyGIV9kpmHNqyvdfzcpEMw97BvknV2fq+MFHun9BT3Lsf8pbzvisWiIQvYkng+8Vxk1V+dli1u56kY50LRjaPdotvT5BwqtwyF+emo/z9J3yVUVGfKrxQtJMOAQWoQii/4dp9wgybSa5mkucmRLtEQZ/pz0tL/NVcgWAd95nEQ3Tg6tNbuyn3Iepz65L3huMUUBntllWuu4DbtOFSMSbpILV4fy6wlM0SOvi6CpLh81c1LreIvKd61uEWBcDw1lUBUW1I0Z+m/PaRlX+PQ/oxg0Ye6KUiIiTF4ADNk59Ydpt5/rkxmq9tV5Kcp/eQLUVVmBzQNVuytQCP6Ezd0G8eLxWyHpmZWJ3bAzkWTtg4lZlw42SQezEmiUPaJUuR/qklVA/87S4ArFCpALdY3QRdUw3G3XbWUp6aq9z0zUizcPa7351p9JXOZyfdZBFnqt90VzQndXB/mwf8LC9STj5kenVpNuqOQQP3mIRJj7eV21FxG8VAxKrEn3c+XfmZ800EPb9/5lIlijscUbB6da0RQaMook0zug1G0tKi/JBC4rw7/D3m4ARzAkzMcVrDcT2SyFtUdWAsFlsPDFqV3N+EjyXaoEePwroaZCiLqEzb8MW+PNE9TmTC01EzWli51PzZvUqkmyuROU+V6ik+Le/9qT6nwzUzf9tP68tYei0YaDGx6kAd7jn1cKqOCuYbiELH9zYqcc4MnRJjkeGiqaGwLImhyeKs+xKJMBlOJ05ow9gGCKZ1VpnMKoSCTbMS+X+23y042zOb5MtcY/6oBeAo1Vy89OTyhpavFP78jXCcFH0t7Gx24hMEOm2gsEfGabVpQgvFqbQKMsknFRRmuPHcZu0Su/WMFphZvB2r/EGbG72rpGGho3h+Msz0uGzJ7hNK2uqQiE1qmn0zgacKYYZBCqsxV+sjbpoVdSilW/b94n2xNb648VmNIoizqEWhBnsen+d0kbCPmRItfWqSBeOd9Wne3c6bcd6uvXOJ6WdiSsuXq0ndhqrQ4QoWUjCjYtZ0EAhnSOP1m44xkf0O7jXghrzSJWxP4a/t72jU29Vu2rvu4n7HfHkkmQOMGSS+NPeLGO5I73mC2B7+lMiBQQZRM9/9liLIfowupUFAbPBbR+lxDM6M8Ptgh1paJq5Rvs7yEuLQv/7d1oU2woFSb3FMPWQOKMuCuJ7pDDjpIclus5TeEoMBy2YdVB4fxmesaCeMNsEgTHKS5WDSGyNUOoEpcC2OFWtIRf0w27ck34/DjxRTVIcc9+kqZE6iMSiVDsiKdP/Xz5XfEhm/sBhO50p1rvJDlkyyxuJ9SPgs7YeUJBjXdeAkE+P9OQJm6SZnn1svcduI78dYmbkE2mtziPrcjVisXG78spLvbZaSFx/Rks9zP4LKn0Cdz/3JsetkT06A8f/yCgMO6Mb1Hme0JJ7b2wZz1qleqTuKBGokhPVUZ0dVu+tnQYNEY1fmkZSz6+EGZ5EzL7657mreZGR3jUfaEk458PDniBzsSmBKhDRzfXameryJv9/D5m6HIqZ0R+ouCE54Dzp4IJuuD1e4Dc5i+PpSORJfG23uVgqixAMDvchMR0nZdH5brclYwRoJRWv/rlxGRI5ffD5NPGmIDt7vDE1434pYdVZIFh89Bs94HGGJbTwrN8T6lh1HZFTOB4lWzWj6EVqxSMvC0/ljWBQ3F2kc/mO2b6tWonT2JEqEwFts8rz2h+oWNds9ceR2cb7zZvJTDppHaEhK5avWqsseWa2Dt5BBhabdWSktS80oMQrL4TvAM9b5HMmyDnO+OkkbMXfUJG7eXqTIG6lqSOEbqVR+qYdP7uWb57WEJqzyh411GAVsDinPs7KvUeXItlcMdOUWzXBH6zscymV1LLVCtc8IePojzXHF9m5b5zGwBRdzcyUJkiu938ApmAayRdJrX1PmVguWUvt2ThQ62czItTyWJMW2An/hdDfMK7SiFQlGIdAbltHz3ycoh7j9V7GxNWBpbtcSdqm4XxRwTawc3cbZ+xfSv9qQfEkDKfZTwCkqWGI/ur250ItXlMlh6vUNWEYIg9A3GzbgmbqvTN8js2YMo87CU5y6nZ4dbJLDQJj9fc7yM7tZzJDZFtqOcU8+mZjYlq4VmifI23iHb1ZoT9E+kT2dolnP1AfiOkt7PQCSykBiXy5mv637IegWSKj9IKrYZf4Lu9+I7ub+mkRdlvYzehh/jaJ9n7HUH5b2IbgeNdkY7wx1yVzxS7pbvky6+nmVUtRllEFfweUQ0/nG017WoUYSxs+j2B4FV/F62EtHlMWZXYrjGHpthnNb1x66LKZ0Qe92INWHdfR/vqp02wMS8r1G4dJqHok8KmQ7947G13a4YXbsGgHcBvRuVu1eAi4/A5+ZixmdSXM73LupB/LH7O9yxLTVXJTyBbI1S49TIROrfVCOb/czZ9pM4JsZx8kUz8dQGv7gUWKxXvTH7QM/3J2OuXXgciUhqY+cgtaOliQQVOYthBLV3xpESZT3rmfEYNZxmpBbb24CRao86prn+i9TNOh8VxRJGXJfXHATJHs1T5txgc/opYrY8XjlGQQbRcoxIBcnVsMjmU1ymmIUL4dviJXndMAJ0Yet+c7O52/p98ytlmAsGBaTAmMhimAnvp1TWNGM9BpuitGj+t810CU2UhorrjPKGtThVC8WaXw04WFnT5fTjqmPyrQ0tN3CkLsctVy2xr0ZWgiWVZ1OrlFjjxJYsOiZv2cAoOvE+7sY0I/TwWcZqMoyIKNOftwP7w++Rfg67ljfovKYa50if3fzE/8aPYVey/Nq35+nH2sLPh/fP5TsylSKGOZ4k69d2PnH43+kq++sRXHQqGArWdwhx+hpwQC6JgT2uxehYU4Zbw7oNb6/HLikPyJROGK2ouyr+vzseESp9G50T4AyFrSqOQ0rroCYP4sMDFBrHn342EyZTMlSyk47rHSq89Y9/nI3zG5lX16Z5lxphguLOcZUndL8wNcrkyjH82jqg8Bo8OYkynrxZvbFno5lUS3OPr8Ko3mX9NoRPdYOKKjD07bvgFgpZ/RF+YzkWvJ/Hs/tUbfeGzGWLxNAjfDzHHMVSDwB5SabQLsIZHiBp43FjGkaienYoDd18hu2BGwOK7U3o70K/WY/kuuKdmdrykIBUdG2mvE91L1JtTbh20mOLbk1vCAamu7utlXeGU2ooVikbU/actcgmsC1FKk2qmj3GWeIWbj4tGIxE7BLcBWUvvcnd/lYxsMV4F917fWeFB/XbINN3qGvIyTpCalz1lVewdIGqeAS/gB8Mi+sA+BqDiX3VGD2eUunTRbSY+AuDy4E3Qx3hAhwnSXX+B0zuj3eQ1miS8Vux2z/l6/BkWtjKGU72aJkOCWhGcSf3+kFkkB15vGOsQrSdFr6qTj0gBYiOlnBO41170gOWHSUoBVRU2JjwppYdhIFDfu7tIRHccSNM5KZOFDPz0TGMAjzzEpeLwTWp+kn201kU6NjbiMQJx83+LX1e1tZ10kuChJZ/XBUQ1dwaBHjTDJDqOympEk8X2M3VtVw21JksChA8w1tTefO3RJ1FMbqZ01bHHkudDB/OhLfe7P5GOHaI28ZXKTMuqo0hLWQ4HabBsGG7NbP1RiXtETz074er6w/OerJWEqjmkq2y51q1BVI+JUudnVa3ogBpzdhFE7fC7kybrAt2Z6RqDjATAUEYeYK45WMupBKQRtQlU+uNsjnzj6ZmGrezA+ASrWxQ6LMkHRXqXwNq7ftv28dUx/ZSJciDXP2SWJsWaN0FjPX9Yko6LobZ7aYW/IdUktI9apTLyHS8DyWPyuoZyxN1TK/vtfxk3HwWh6JczZC8Ftn0bIJay2g+n5wd7lm9rEsKO+svqVmi+c1j88hSCxbzrg4+HEP0Nt1/B6YW1XVm09T1CpAKjc9n18hjqsaFGdfyva1ZG0Xu3ip6N6JGpyTSqY5h4BOlpLPaOnyw45PdXTN+DtAKg7DLrLFTnWusoSBHk3s0d7YouJHq85/R09Tfc37ENXZF48eAYLnq9GLioNcwDZrC6FW6godB8JnqYUPvn0pWLfQz0lM0Yy8Mybgn84Ds3Q9bDP10bLyOV+qzxa4Rd9Dhu7cju8mMaONXK3UqmBQ9qIg7etIwEqM/kECk/Dzja4Bs1xR+Q/tCbc8IKrSGsTdJJ0vge7IG20W687uVmK6icWQ6cD3lwFzgNMGtFvO5qyJeKflGLAAcQZOrkxVwy3cWvqlGpvjmf9Qe6Ap20MPbV92DPV0OhFM4kz8Yr0ffC2zLWSQ1kqY6QdQrttR3kh1YLtQd1kCEv5hVoPIRWl5ERcUTttBIrWp6Xs5Ehh5OUUwI5aEBvuiDmUoENmnVw1FohCrbRp1A1E+XSlWVOTi7ADW+5Ohb9z1vK4qx5R5lPdGCPBJZ00mC+Ssp8VUbgpGAvXWMuWQQRbCqI6Rr2jtxZxtfP7W/8onz+yz0Gs76LaT5HX9ecyiZCB/ZR/gFtMxPsDwohoeCRtiuLxE1GM1vUEUgBv86+eehL58/P56QFGQ/MqOe/vC76L63jzmeax4exd/OKTUvkXg+fOJUHych9xt/9goJMrapSgvXrj8+8vk/N80f22Sewj6cyGqt1B6mztoeklVHHraouhvHJaG/OuBz6DHKMpFmQULU1bRWlyYE0RPXYYkUycIemN7TLtgNCJX6BqdyxDKkegO7nJK5xQ7OVYDZTMf9bVHidtk6DQX9Et+V9M7esgbsYBdEeUpsB0Xvw2kd9+rI7V+m47u+O/tq7mw7262HU1WlS9uFzsV6JxIHNmUCy0QS9e077JGRFbG65z3/dOKB/Zk+yDdKpUmdXjn/aS3N5nv4fK7bMHHmPlHd4E2+iTbV5rpzScRnxk6KARuDTJ8Q1LpK2mP8gj1EbuJ9RIyY+EWK4hCiIDBAS1Tm2IEXAFfgKPgdL9O6mAa06wjCcUAL6EsxPQWO9VNegBPm/0GgkZbDxCynxujX/92vmGcjZRMAY45puak2sFLCLSwXpEsyy5fnF0jGJBhm+fNSHKKUUfy+276A7/feLOFxxUuHRNJI2Osenxyvf8DAGObT60pfTTlhEg9u/KKkhJqm5U1/+BEcSkpFDA5XeCqxwXmPac1jcuZ3JWQ+p0NdWzb/5v1ZvF8GtMTFFEdQjpLO0bwPb0BHNWnip3liDXI2fXf05jjvfJ0NpjLCUgfTh9CMFYVFKEd4Z/OG/2C+N435mnK+9t1gvCiVcaaH7rK4+PjCvpVNiz+t2QyqH1O8x3JKZVl6Q+Lp/XK8wMjVMslOq9FdSw5FtUs/CptXH9PW+wbWHgrV17R5jTVOtGtKFu3nb80T+E0tv9QkzW3J2dbaw/8ddAKZ0pxIaEqLjlPrji3VgJ3GvdFvlqD8075woxh4fVt0JZE0KVFsAvqhe0dqN9b35jtSpnYMXkU+vZq+IAHad3IHc2s/LYrnD1anfG46IFiMIr9oNbZDWvwthqYNqOigaKd/XlLU4XHfk/PXIjPsLy/9/kAtQ+/wKH+hI/IROWj5FPvTZAT9f7j4ZXQyG4M0TujMAFXYkKvEHv1xhySekgXGGqNxWeWKlf8dDAlLuB1cb/qOD+rk7cmwt+1yKpk9cudqBanTi6zTbXRtV8qylNtjyOVKy1HTz0GW9rjt6sSjAZcT5R+KdtyYb0zyqG9pSLuCw5WBwAn7fjBjKLLoxLXMI+52L9cLwIR2B6OllJZLHJ8vDxmWdtF+QJnmt1rsHPIWY20lftk8fYePkAIg6Hgn532QoIpegMxiWgAOfe5/U44APR8Ac0NeZrVh3gEhs12W+tVSiWiUQekf/YBECUy5fdYbA08dd7VzPAP9aiVcIB9k6tY7WdJ1wNV+bHeydNtmC6G5ICtFC1ZwmJU/j8hf0I8TRVKSiz5oYIa93EpUI78X8GYIAZabx47/n8LDAAJ0nNtP1rpROprqKMBRecShca6qXuTSI3jZBLOB3Vp381B5rCGhjSvh/NSVkYp2qIdP/Bg="; 45759 }, 45760 {} 45761 ], 45762 6: [ 45763 function(require2, module2, exports2) { 45764 var data = require2("./dictionary-browser"); 45765 exports2.init = function() { 45766 exports2.dictionary = data.init(); 45767 }; 45768 exports2.offsetsByLength = new Uint32Array([ 45769 0, 45770 0, 45771 0, 45772 0, 45773 0, 45774 4096, 45775 9216, 45776 21504, 45777 35840, 45778 44032, 45779 53248, 45780 63488, 45781 74752, 45782 87040, 45783 93696, 45784 100864, 45785 104704, 45786 106752, 45787 108928, 45788 113536, 45789 115968, 45790 118528, 45791 119872, 45792 121280, 45793 122016 45794 ]); 45795 exports2.sizeBitsByLength = new Uint8Array([ 45796 0, 45797 0, 45798 0, 45799 0, 45800 10, 45801 10, 45802 11, 45803 11, 45804 10, 45805 10, 45806 10, 45807 10, 45808 10, 45809 9, 45810 9, 45811 8, 45812 7, 45813 7, 45814 8, 45815 7, 45816 7, 45817 6, 45818 6, 45819 5, 45820 5 45821 ]); 45822 exports2.minDictionaryWordLength = 4; 45823 exports2.maxDictionaryWordLength = 24; 45824 }, 45825 { "./dictionary-browser": 4 } 45826 ], 45827 7: [ 45828 function(require2, module2, exports2) { 45829 function HuffmanCode(bits, value) { 45830 this.bits = bits; 45831 this.value = value; 45832 } 45833 exports2.HuffmanCode = HuffmanCode; 45834 var MAX_LENGTH = 15; 45835 function GetNextKey(key, len) { 45836 var step = 1 << len - 1; 45837 while (key & step) { 45838 step >>= 1; 45839 } 45840 return (key & step - 1) + step; 45841 } 45842 function ReplicateValue(table, i2, step, end, code) { 45843 do { 45844 end -= step; 45845 table[i2 + end] = new HuffmanCode( 45846 code.bits, 45847 code.value 45848 ); 45849 } while (end > 0); 45850 } 45851 function NextTableBitSize(count, len, root_bits) { 45852 var left = 1 << len - root_bits; 45853 while (len < MAX_LENGTH) { 45854 left -= count[len]; 45855 if (left <= 0) break; 45856 ++len; 45857 left <<= 1; 45858 } 45859 return len - root_bits; 45860 } 45861 exports2.BrotliBuildHuffmanTable = function(root_table, table, root_bits, code_lengths, code_lengths_size) { 45862 var start_table = table; 45863 var code; 45864 var len; 45865 var symbol3; 45866 var key; 45867 var step; 45868 var low; 45869 var mask; 45870 var table_bits; 45871 var table_size; 45872 var total_size; 45873 var sorted; 45874 var count = new Int32Array( 45875 MAX_LENGTH + 1 45876 ); 45877 var offset4 = new Int32Array( 45878 MAX_LENGTH + 1 45879 ); 45880 sorted = new Int32Array(code_lengths_size); 45881 for (symbol3 = 0; symbol3 < code_lengths_size; symbol3++) { 45882 count[code_lengths[symbol3]]++; 45883 } 45884 offset4[1] = 0; 45885 for (len = 1; len < MAX_LENGTH; len++) { 45886 offset4[len + 1] = offset4[len] + count[len]; 45887 } 45888 for (symbol3 = 0; symbol3 < code_lengths_size; symbol3++) { 45889 if (code_lengths[symbol3] !== 0) { 45890 sorted[offset4[code_lengths[symbol3]]++] = symbol3; 45891 } 45892 } 45893 table_bits = root_bits; 45894 table_size = 1 << table_bits; 45895 total_size = table_size; 45896 if (offset4[MAX_LENGTH] === 1) { 45897 for (key = 0; key < total_size; ++key) { 45898 root_table[table + key] = new HuffmanCode( 45899 0, 45900 sorted[0] & 65535 45901 ); 45902 } 45903 return total_size; 45904 } 45905 key = 0; 45906 symbol3 = 0; 45907 for (len = 1, step = 2; len <= root_bits; ++len, step <<= 1) { 45908 for (; count[len] > 0; --count[len]) { 45909 code = new HuffmanCode( 45910 len & 255, 45911 sorted[symbol3++] & 65535 45912 ); 45913 ReplicateValue( 45914 root_table, 45915 table + key, 45916 step, 45917 table_size, 45918 code 45919 ); 45920 key = GetNextKey(key, len); 45921 } 45922 } 45923 mask = total_size - 1; 45924 low = -1; 45925 for (len = root_bits + 1, step = 2; len <= MAX_LENGTH; ++len, step <<= 1) { 45926 for (; count[len] > 0; --count[len]) { 45927 if ((key & mask) !== low) { 45928 table += table_size; 45929 table_bits = NextTableBitSize( 45930 count, 45931 len, 45932 root_bits 45933 ); 45934 table_size = 1 << table_bits; 45935 total_size += table_size; 45936 low = key & mask; 45937 root_table[start_table + low] = new HuffmanCode( 45938 table_bits + root_bits & 255, 45939 table - start_table - low & 65535 45940 ); 45941 } 45942 code = new HuffmanCode( 45943 len - root_bits & 255, 45944 sorted[symbol3++] & 65535 45945 ); 45946 ReplicateValue( 45947 root_table, 45948 table + (key >> root_bits), 45949 step, 45950 table_size, 45951 code 45952 ); 45953 key = GetNextKey(key, len); 45954 } 45955 } 45956 return total_size; 45957 }; 45958 }, 45959 {} 45960 ], 45961 8: [ 45962 function(require2, module2, exports2) { 45963 "use strict"; 45964 exports2.byteLength = byteLength; 45965 exports2.toByteArray = toByteArray; 45966 exports2.fromByteArray = fromByteArray; 45967 var lookup = []; 45968 var revLookup = []; 45969 var Arr = typeof Uint8Array !== "undefined" ? Uint8Array : Array; 45970 var code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; 45971 for (var i2 = 0, len = code.length; i2 < len; ++i2) { 45972 lookup[i2] = code[i2]; 45973 revLookup[code.charCodeAt(i2)] = i2; 45974 } 45975 revLookup["-".charCodeAt(0)] = 62; 45976 revLookup["_".charCodeAt(0)] = 63; 45977 function getLens(b64) { 45978 var len2 = b64.length; 45979 if (len2 % 4 > 0) { 45980 throw new Error( 45981 "Invalid string. Length must be a multiple of 4" 45982 ); 45983 } 45984 var validLen = b64.indexOf("="); 45985 if (validLen === -1) validLen = len2; 45986 var placeHoldersLen = validLen === len2 ? 0 : 4 - validLen % 4; 45987 return [validLen, placeHoldersLen]; 45988 } 45989 function byteLength(b64) { 45990 var lens = getLens(b64); 45991 var validLen = lens[0]; 45992 var placeHoldersLen = lens[1]; 45993 return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen; 45994 } 45995 function _byteLength(b64, validLen, placeHoldersLen) { 45996 return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen; 45997 } 45998 function toByteArray(b64) { 45999 var tmp; 46000 var lens = getLens(b64); 46001 var validLen = lens[0]; 46002 var placeHoldersLen = lens[1]; 46003 var arr = new Arr( 46004 _byteLength(b64, validLen, placeHoldersLen) 46005 ); 46006 var curByte = 0; 46007 var len2 = placeHoldersLen > 0 ? validLen - 4 : validLen; 46008 for (var i22 = 0; i22 < len2; i22 += 4) { 46009 tmp = revLookup[b64.charCodeAt(i22)] << 18 | revLookup[b64.charCodeAt(i22 + 1)] << 12 | revLookup[b64.charCodeAt(i22 + 2)] << 6 | revLookup[b64.charCodeAt(i22 + 3)]; 46010 arr[curByte++] = tmp >> 16 & 255; 46011 arr[curByte++] = tmp >> 8 & 255; 46012 arr[curByte++] = tmp & 255; 46013 } 46014 if (placeHoldersLen === 2) { 46015 tmp = revLookup[b64.charCodeAt(i22)] << 2 | revLookup[b64.charCodeAt(i22 + 1)] >> 4; 46016 arr[curByte++] = tmp & 255; 46017 } 46018 if (placeHoldersLen === 1) { 46019 tmp = revLookup[b64.charCodeAt(i22)] << 10 | revLookup[b64.charCodeAt(i22 + 1)] << 4 | revLookup[b64.charCodeAt(i22 + 2)] >> 2; 46020 arr[curByte++] = tmp >> 8 & 255; 46021 arr[curByte++] = tmp & 255; 46022 } 46023 return arr; 46024 } 46025 function tripletToBase64(num) { 46026 return lookup[num >> 18 & 63] + lookup[num >> 12 & 63] + lookup[num >> 6 & 63] + lookup[num & 63]; 46027 } 46028 function encodeChunk(uint8, start2, end) { 46029 var tmp; 46030 var output = []; 46031 for (var i22 = start2; i22 < end; i22 += 3) { 46032 tmp = (uint8[i22] << 16 & 16711680) + (uint8[i22 + 1] << 8 & 65280) + (uint8[i22 + 2] & 255); 46033 output.push(tripletToBase64(tmp)); 46034 } 46035 return output.join(""); 46036 } 46037 function fromByteArray(uint8) { 46038 var tmp; 46039 var len2 = uint8.length; 46040 var extraBytes = len2 % 3; 46041 var parts = []; 46042 var maxChunkLength = 16383; 46043 for (var i22 = 0, len22 = len2 - extraBytes; i22 < len22; i22 += maxChunkLength) { 46044 parts.push( 46045 encodeChunk( 46046 uint8, 46047 i22, 46048 i22 + maxChunkLength > len22 ? len22 : i22 + maxChunkLength 46049 ) 46050 ); 46051 } 46052 if (extraBytes === 1) { 46053 tmp = uint8[len2 - 1]; 46054 parts.push( 46055 lookup[tmp >> 2] + lookup[tmp << 4 & 63] + "==" 46056 ); 46057 } else if (extraBytes === 2) { 46058 tmp = (uint8[len2 - 2] << 8) + uint8[len2 - 1]; 46059 parts.push( 46060 lookup[tmp >> 10] + lookup[tmp >> 4 & 63] + lookup[tmp << 2 & 63] + "=" 46061 ); 46062 } 46063 return parts.join(""); 46064 } 46065 }, 46066 {} 46067 ], 46068 9: [ 46069 function(require2, module2, exports2) { 46070 function PrefixCodeRange(offset4, nbits) { 46071 this.offset = offset4; 46072 this.nbits = nbits; 46073 } 46074 exports2.kBlockLengthPrefixCode = [ 46075 new PrefixCodeRange(1, 2), 46076 new PrefixCodeRange(5, 2), 46077 new PrefixCodeRange(9, 2), 46078 new PrefixCodeRange(13, 2), 46079 new PrefixCodeRange(17, 3), 46080 new PrefixCodeRange(25, 3), 46081 new PrefixCodeRange(33, 3), 46082 new PrefixCodeRange(41, 3), 46083 new PrefixCodeRange(49, 4), 46084 new PrefixCodeRange(65, 4), 46085 new PrefixCodeRange(81, 4), 46086 new PrefixCodeRange(97, 4), 46087 new PrefixCodeRange(113, 5), 46088 new PrefixCodeRange(145, 5), 46089 new PrefixCodeRange(177, 5), 46090 new PrefixCodeRange(209, 5), 46091 new PrefixCodeRange(241, 6), 46092 new PrefixCodeRange(305, 6), 46093 new PrefixCodeRange(369, 7), 46094 new PrefixCodeRange(497, 8), 46095 new PrefixCodeRange(753, 9), 46096 new PrefixCodeRange(1265, 10), 46097 new PrefixCodeRange(2289, 11), 46098 new PrefixCodeRange(4337, 12), 46099 new PrefixCodeRange(8433, 13), 46100 new PrefixCodeRange(16625, 24) 46101 ]; 46102 exports2.kInsertLengthPrefixCode = [ 46103 new PrefixCodeRange(0, 0), 46104 new PrefixCodeRange(1, 0), 46105 new PrefixCodeRange(2, 0), 46106 new PrefixCodeRange(3, 0), 46107 new PrefixCodeRange(4, 0), 46108 new PrefixCodeRange(5, 0), 46109 new PrefixCodeRange(6, 1), 46110 new PrefixCodeRange(8, 1), 46111 new PrefixCodeRange(10, 2), 46112 new PrefixCodeRange(14, 2), 46113 new PrefixCodeRange(18, 3), 46114 new PrefixCodeRange(26, 3), 46115 new PrefixCodeRange(34, 4), 46116 new PrefixCodeRange(50, 4), 46117 new PrefixCodeRange(66, 5), 46118 new PrefixCodeRange(98, 5), 46119 new PrefixCodeRange(130, 6), 46120 new PrefixCodeRange(194, 7), 46121 new PrefixCodeRange(322, 8), 46122 new PrefixCodeRange(578, 9), 46123 new PrefixCodeRange(1090, 10), 46124 new PrefixCodeRange(2114, 12), 46125 new PrefixCodeRange(6210, 14), 46126 new PrefixCodeRange(22594, 24) 46127 ]; 46128 exports2.kCopyLengthPrefixCode = [ 46129 new PrefixCodeRange(2, 0), 46130 new PrefixCodeRange(3, 0), 46131 new PrefixCodeRange(4, 0), 46132 new PrefixCodeRange(5, 0), 46133 new PrefixCodeRange(6, 0), 46134 new PrefixCodeRange(7, 0), 46135 new PrefixCodeRange(8, 0), 46136 new PrefixCodeRange(9, 0), 46137 new PrefixCodeRange(10, 1), 46138 new PrefixCodeRange(12, 1), 46139 new PrefixCodeRange(14, 2), 46140 new PrefixCodeRange(18, 2), 46141 new PrefixCodeRange(22, 3), 46142 new PrefixCodeRange(30, 3), 46143 new PrefixCodeRange(38, 4), 46144 new PrefixCodeRange(54, 4), 46145 new PrefixCodeRange(70, 5), 46146 new PrefixCodeRange(102, 5), 46147 new PrefixCodeRange(134, 6), 46148 new PrefixCodeRange(198, 7), 46149 new PrefixCodeRange(326, 8), 46150 new PrefixCodeRange(582, 9), 46151 new PrefixCodeRange(1094, 10), 46152 new PrefixCodeRange(2118, 24) 46153 ]; 46154 exports2.kInsertRangeLut = [0, 0, 8, 8, 0, 16, 8, 16, 16]; 46155 exports2.kCopyRangeLut = [0, 8, 0, 8, 16, 0, 16, 8, 16]; 46156 }, 46157 {} 46158 ], 46159 10: [ 46160 function(require2, module2, exports2) { 46161 function BrotliInput(buffer) { 46162 this.buffer = buffer; 46163 this.pos = 0; 46164 } 46165 BrotliInput.prototype.read = function(buf, i2, count) { 46166 if (this.pos + count > this.buffer.length) { 46167 count = this.buffer.length - this.pos; 46168 } 46169 for (var p3 = 0; p3 < count; p3++) 46170 buf[i2 + p3] = this.buffer[this.pos + p3]; 46171 this.pos += count; 46172 return count; 46173 }; 46174 exports2.BrotliInput = BrotliInput; 46175 function BrotliOutput(buf) { 46176 this.buffer = buf; 46177 this.pos = 0; 46178 } 46179 BrotliOutput.prototype.write = function(buf, count) { 46180 if (this.pos + count > this.buffer.length) 46181 throw new Error( 46182 "Output buffer is not large enough" 46183 ); 46184 this.buffer.set(buf.subarray(0, count), this.pos); 46185 this.pos += count; 46186 return count; 46187 }; 46188 exports2.BrotliOutput = BrotliOutput; 46189 }, 46190 {} 46191 ], 46192 11: [ 46193 function(require2, module2, exports2) { 46194 var BrotliDictionary = require2("./dictionary"); 46195 var kIdentity = 0; 46196 var kOmitLast1 = 1; 46197 var kOmitLast2 = 2; 46198 var kOmitLast3 = 3; 46199 var kOmitLast4 = 4; 46200 var kOmitLast5 = 5; 46201 var kOmitLast6 = 6; 46202 var kOmitLast7 = 7; 46203 var kOmitLast8 = 8; 46204 var kOmitLast9 = 9; 46205 var kUppercaseFirst = 10; 46206 var kUppercaseAll = 11; 46207 var kOmitFirst1 = 12; 46208 var kOmitFirst2 = 13; 46209 var kOmitFirst3 = 14; 46210 var kOmitFirst4 = 15; 46211 var kOmitFirst5 = 16; 46212 var kOmitFirst6 = 17; 46213 var kOmitFirst7 = 18; 46214 var kOmitFirst8 = 19; 46215 var kOmitFirst9 = 20; 46216 function Transform(prefix2, transform, suffix) { 46217 this.prefix = new Uint8Array(prefix2.length); 46218 this.transform = transform; 46219 this.suffix = new Uint8Array(suffix.length); 46220 for (var i2 = 0; i2 < prefix2.length; i2++) 46221 this.prefix[i2] = prefix2.charCodeAt(i2); 46222 for (var i2 = 0; i2 < suffix.length; i2++) 46223 this.suffix[i2] = suffix.charCodeAt(i2); 46224 } 46225 var kTransforms = [ 46226 new Transform("", kIdentity, ""), 46227 new Transform("", kIdentity, " "), 46228 new Transform(" ", kIdentity, " "), 46229 new Transform("", kOmitFirst1, ""), 46230 new Transform("", kUppercaseFirst, " "), 46231 new Transform("", kIdentity, " the "), 46232 new Transform(" ", kIdentity, ""), 46233 new Transform("s ", kIdentity, " "), 46234 new Transform("", kIdentity, " of "), 46235 new Transform("", kUppercaseFirst, ""), 46236 new Transform("", kIdentity, " and "), 46237 new Transform("", kOmitFirst2, ""), 46238 new Transform("", kOmitLast1, ""), 46239 new Transform(", ", kIdentity, " "), 46240 new Transform("", kIdentity, ", "), 46241 new Transform(" ", kUppercaseFirst, " "), 46242 new Transform("", kIdentity, " in "), 46243 new Transform("", kIdentity, " to "), 46244 new Transform("e ", kIdentity, " "), 46245 new Transform("", kIdentity, '"'), 46246 new Transform("", kIdentity, "."), 46247 new Transform("", kIdentity, '">'), 46248 new Transform("", kIdentity, "\n"), 46249 new Transform("", kOmitLast3, ""), 46250 new Transform("", kIdentity, "]"), 46251 new Transform("", kIdentity, " for "), 46252 new Transform("", kOmitFirst3, ""), 46253 new Transform("", kOmitLast2, ""), 46254 new Transform("", kIdentity, " a "), 46255 new Transform("", kIdentity, " that "), 46256 new Transform(" ", kUppercaseFirst, ""), 46257 new Transform("", kIdentity, ". "), 46258 new Transform(".", kIdentity, ""), 46259 new Transform(" ", kIdentity, ", "), 46260 new Transform("", kOmitFirst4, ""), 46261 new Transform("", kIdentity, " with "), 46262 new Transform("", kIdentity, "'"), 46263 new Transform("", kIdentity, " from "), 46264 new Transform("", kIdentity, " by "), 46265 new Transform("", kOmitFirst5, ""), 46266 new Transform("", kOmitFirst6, ""), 46267 new Transform(" the ", kIdentity, ""), 46268 new Transform("", kOmitLast4, ""), 46269 new Transform("", kIdentity, ". The "), 46270 new Transform("", kUppercaseAll, ""), 46271 new Transform("", kIdentity, " on "), 46272 new Transform("", kIdentity, " as "), 46273 new Transform("", kIdentity, " is "), 46274 new Transform("", kOmitLast7, ""), 46275 new Transform("", kOmitLast1, "ing "), 46276 new Transform("", kIdentity, "\n "), 46277 new Transform("", kIdentity, ":"), 46278 new Transform(" ", kIdentity, ". "), 46279 new Transform("", kIdentity, "ed "), 46280 new Transform("", kOmitFirst9, ""), 46281 new Transform("", kOmitFirst7, ""), 46282 new Transform("", kOmitLast6, ""), 46283 new Transform("", kIdentity, "("), 46284 new Transform("", kUppercaseFirst, ", "), 46285 new Transform("", kOmitLast8, ""), 46286 new Transform("", kIdentity, " at "), 46287 new Transform("", kIdentity, "ly "), 46288 new Transform(" the ", kIdentity, " of "), 46289 new Transform("", kOmitLast5, ""), 46290 new Transform("", kOmitLast9, ""), 46291 new Transform(" ", kUppercaseFirst, ", "), 46292 new Transform("", kUppercaseFirst, '"'), 46293 new Transform(".", kIdentity, "("), 46294 new Transform("", kUppercaseAll, " "), 46295 new Transform("", kUppercaseFirst, '">'), 46296 new Transform("", kIdentity, '="'), 46297 new Transform(" ", kIdentity, "."), 46298 new Transform(".com/", kIdentity, ""), 46299 new Transform(" the ", kIdentity, " of the "), 46300 new Transform("", kUppercaseFirst, "'"), 46301 new Transform("", kIdentity, ". This "), 46302 new Transform("", kIdentity, ","), 46303 new Transform(".", kIdentity, " "), 46304 new Transform("", kUppercaseFirst, "("), 46305 new Transform("", kUppercaseFirst, "."), 46306 new Transform("", kIdentity, " not "), 46307 new Transform(" ", kIdentity, '="'), 46308 new Transform("", kIdentity, "er "), 46309 new Transform(" ", kUppercaseAll, " "), 46310 new Transform("", kIdentity, "al "), 46311 new Transform(" ", kUppercaseAll, ""), 46312 new Transform("", kIdentity, "='"), 46313 new Transform("", kUppercaseAll, '"'), 46314 new Transform("", kUppercaseFirst, ". "), 46315 new Transform(" ", kIdentity, "("), 46316 new Transform("", kIdentity, "ful "), 46317 new Transform(" ", kUppercaseFirst, ". "), 46318 new Transform("", kIdentity, "ive "), 46319 new Transform("", kIdentity, "less "), 46320 new Transform("", kUppercaseAll, "'"), 46321 new Transform("", kIdentity, "est "), 46322 new Transform(" ", kUppercaseFirst, "."), 46323 new Transform("", kUppercaseAll, '">'), 46324 new Transform(" ", kIdentity, "='"), 46325 new Transform("", kUppercaseFirst, ","), 46326 new Transform("", kIdentity, "ize "), 46327 new Transform("", kUppercaseAll, "."), 46328 new Transform("\xC2\xA0", kIdentity, ""), 46329 new Transform(" ", kIdentity, ","), 46330 new Transform("", kUppercaseFirst, '="'), 46331 new Transform("", kUppercaseAll, '="'), 46332 new Transform("", kIdentity, "ous "), 46333 new Transform("", kUppercaseAll, ", "), 46334 new Transform("", kUppercaseFirst, "='"), 46335 new Transform(" ", kUppercaseFirst, ","), 46336 new Transform(" ", kUppercaseAll, '="'), 46337 new Transform(" ", kUppercaseAll, ", "), 46338 new Transform("", kUppercaseAll, ","), 46339 new Transform("", kUppercaseAll, "("), 46340 new Transform("", kUppercaseAll, ". "), 46341 new Transform(" ", kUppercaseAll, "."), 46342 new Transform("", kUppercaseAll, "='"), 46343 new Transform(" ", kUppercaseAll, ". "), 46344 new Transform(" ", kUppercaseFirst, '="'), 46345 new Transform(" ", kUppercaseAll, "='"), 46346 new Transform(" ", kUppercaseFirst, "='") 46347 ]; 46348 exports2.kTransforms = kTransforms; 46349 exports2.kNumTransforms = kTransforms.length; 46350 function ToUpperCase(p3, i2) { 46351 if (p3[i2] < 192) { 46352 if (p3[i2] >= 97 && p3[i2] <= 122) { 46353 p3[i2] ^= 32; 46354 } 46355 return 1; 46356 } 46357 if (p3[i2] < 224) { 46358 p3[i2 + 1] ^= 32; 46359 return 2; 46360 } 46361 p3[i2 + 2] ^= 5; 46362 return 3; 46363 } 46364 exports2.transformDictionaryWord = function(dst, idx, word, len, transform) { 46365 var prefix2 = kTransforms[transform].prefix; 46366 var suffix = kTransforms[transform].suffix; 46367 var t3 = kTransforms[transform].transform; 46368 var skip = t3 < kOmitFirst1 ? 0 : t3 - (kOmitFirst1 - 1); 46369 var i2 = 0; 46370 var start_idx = idx; 46371 var uppercase; 46372 if (skip > len) { 46373 skip = len; 46374 } 46375 var prefix_pos = 0; 46376 while (prefix_pos < prefix2.length) { 46377 dst[idx++] = prefix2[prefix_pos++]; 46378 } 46379 word += skip; 46380 len -= skip; 46381 if (t3 <= kOmitLast9) { 46382 len -= t3; 46383 } 46384 for (i2 = 0; i2 < len; i2++) { 46385 dst[idx++] = BrotliDictionary.dictionary[word + i2]; 46386 } 46387 uppercase = idx - len; 46388 if (t3 === kUppercaseFirst) { 46389 ToUpperCase(dst, uppercase); 46390 } else if (t3 === kUppercaseAll) { 46391 while (len > 0) { 46392 var step = ToUpperCase(dst, uppercase); 46393 uppercase += step; 46394 len -= step; 46395 } 46396 } 46397 var suffix_pos = 0; 46398 while (suffix_pos < suffix.length) { 46399 dst[idx++] = suffix[suffix_pos++]; 46400 } 46401 return idx - start_idx; 46402 }; 46403 }, 46404 { "./dictionary": 6 } 46405 ], 46406 12: [ 46407 function(require2, module2, exports2) { 46408 module2.exports = require2("./dec/decode").BrotliDecompressBuffer; 46409 }, 46410 { "./dec/decode": 3 } 46411 ] 46412 }, 46413 {}, 46414 [12] 46415 )(12); 46416 })(); 46417 46418 // packages/global-styles-ui/build-module/font-library/lib/inflate.mjs 46419 var __require3 = /* @__PURE__ */ ((x2) => typeof __require !== "undefined" ? __require : typeof Proxy !== "undefined" ? new Proxy(x2, { 46420 get: (a2, b2) => (typeof __require !== "undefined" ? __require : a2)[b2] 46421 }) : x2)(function(x2) { 46422 if (typeof __require !== "undefined") return __require.apply(this, arguments); 46423 throw Error('Dynamic require of "' + x2 + '" is not supported'); 46424 }); 46425 var inflate_default = (function() { 46426 var define, module, exports; 46427 return (/* @__PURE__ */ (function() { 46428 function r3(e2, n2, t3) { 46429 function o3(i22, f2) { 46430 if (!n2[i22]) { 46431 if (!e2[i22]) { 46432 var c6 = "function" == typeof __require3 && __require3; 46433 if (!f2 && c6) return c6(i22, true); 46434 if (u2) return u2(i22, true); 46435 var a2 = new Error("Cannot find module '" + i22 + "'"); 46436 throw a2.code = "MODULE_NOT_FOUND", a2; 46437 } 46438 var p3 = n2[i22] = { exports: {} }; 46439 e2[i22][0].call( 46440 p3.exports, 46441 function(r22) { 46442 var n22 = e2[i22][1][r22]; 46443 return o3(n22 || r22); 46444 }, 46445 p3, 46446 p3.exports, 46447 r3, 46448 e2, 46449 n2, 46450 t3 46451 ); 46452 } 46453 return n2[i22].exports; 46454 } 46455 for (var u2 = "function" == typeof __require3 && __require3, i2 = 0; i2 < t3.length; i2++) 46456 o3(t3[i2]); 46457 return o3; 46458 } 46459 return r3; 46460 })())( 46461 { 46462 1: [ 46463 function(require2, module2, exports2) { 46464 "use strict"; 46465 var TYPED_OK = typeof Uint8Array !== "undefined" && typeof Uint16Array !== "undefined" && typeof Int32Array !== "undefined"; 46466 function _has(obj, key) { 46467 return Object.prototype.hasOwnProperty.call(obj, key); 46468 } 46469 exports2.assign = function(obj) { 46470 var sources = Array.prototype.slice.call( 46471 arguments, 46472 1 46473 ); 46474 while (sources.length) { 46475 var source = sources.shift(); 46476 if (!source) { 46477 continue; 46478 } 46479 if (typeof source !== "object") { 46480 throw new TypeError( 46481 source + "must be non-object" 46482 ); 46483 } 46484 for (var p3 in source) { 46485 if (_has(source, p3)) { 46486 obj[p3] = source[p3]; 46487 } 46488 } 46489 } 46490 return obj; 46491 }; 46492 exports2.shrinkBuf = function(buf, size4) { 46493 if (buf.length === size4) { 46494 return buf; 46495 } 46496 if (buf.subarray) { 46497 return buf.subarray(0, size4); 46498 } 46499 buf.length = size4; 46500 return buf; 46501 }; 46502 var fnTyped = { 46503 arraySet: function(dest, src, src_offs, len, dest_offs) { 46504 if (src.subarray && dest.subarray) { 46505 dest.set( 46506 src.subarray(src_offs, src_offs + len), 46507 dest_offs 46508 ); 46509 return; 46510 } 46511 for (var i2 = 0; i2 < len; i2++) { 46512 dest[dest_offs + i2] = src[src_offs + i2]; 46513 } 46514 }, 46515 // Join array of chunks to single array. 46516 flattenChunks: function(chunks) { 46517 var i2, l2, len, pos, chunk2, result; 46518 len = 0; 46519 for (i2 = 0, l2 = chunks.length; i2 < l2; i2++) { 46520 len += chunks[i2].length; 46521 } 46522 result = new Uint8Array(len); 46523 pos = 0; 46524 for (i2 = 0, l2 = chunks.length; i2 < l2; i2++) { 46525 chunk2 = chunks[i2]; 46526 result.set(chunk2, pos); 46527 pos += chunk2.length; 46528 } 46529 return result; 46530 } 46531 }; 46532 var fnUntyped = { 46533 arraySet: function(dest, src, src_offs, len, dest_offs) { 46534 for (var i2 = 0; i2 < len; i2++) { 46535 dest[dest_offs + i2] = src[src_offs + i2]; 46536 } 46537 }, 46538 // Join array of chunks to single array. 46539 flattenChunks: function(chunks) { 46540 return [].concat.apply([], chunks); 46541 } 46542 }; 46543 exports2.setTyped = function(on) { 46544 if (on) { 46545 exports2.Buf8 = Uint8Array; 46546 exports2.Buf16 = Uint16Array; 46547 exports2.Buf32 = Int32Array; 46548 exports2.assign(exports2, fnTyped); 46549 } else { 46550 exports2.Buf8 = Array; 46551 exports2.Buf16 = Array; 46552 exports2.Buf32 = Array; 46553 exports2.assign(exports2, fnUntyped); 46554 } 46555 }; 46556 exports2.setTyped(TYPED_OK); 46557 }, 46558 {} 46559 ], 46560 2: [ 46561 function(require2, module2, exports2) { 46562 "use strict"; 46563 var utils = require2("./common"); 46564 var STR_APPLY_OK = true; 46565 var STR_APPLY_UIA_OK = true; 46566 try { 46567 String.fromCharCode.apply(null, [0]); 46568 } catch (__149) { 46569 STR_APPLY_OK = false; 46570 } 46571 try { 46572 String.fromCharCode.apply(null, new Uint8Array(1)); 46573 } catch (__149) { 46574 STR_APPLY_UIA_OK = false; 46575 } 46576 var _utf8len = new utils.Buf8(256); 46577 for (var q = 0; q < 256; q++) { 46578 _utf8len[q] = q >= 252 ? 6 : q >= 248 ? 5 : q >= 240 ? 4 : q >= 224 ? 3 : q >= 192 ? 2 : 1; 46579 } 46580 _utf8len[254] = _utf8len[254] = 1; 46581 exports2.string2buf = function(str) { 46582 var buf, c6, c22, m_pos, i2, str_len = str.length, buf_len = 0; 46583 for (m_pos = 0; m_pos < str_len; m_pos++) { 46584 c6 = str.charCodeAt(m_pos); 46585 if ((c6 & 64512) === 55296 && m_pos + 1 < str_len) { 46586 c22 = str.charCodeAt(m_pos + 1); 46587 if ((c22 & 64512) === 56320) { 46588 c6 = 65536 + (c6 - 55296 << 10) + (c22 - 56320); 46589 m_pos++; 46590 } 46591 } 46592 buf_len += c6 < 128 ? 1 : c6 < 2048 ? 2 : c6 < 65536 ? 3 : 4; 46593 } 46594 buf = new utils.Buf8(buf_len); 46595 for (i2 = 0, m_pos = 0; i2 < buf_len; m_pos++) { 46596 c6 = str.charCodeAt(m_pos); 46597 if ((c6 & 64512) === 55296 && m_pos + 1 < str_len) { 46598 c22 = str.charCodeAt(m_pos + 1); 46599 if ((c22 & 64512) === 56320) { 46600 c6 = 65536 + (c6 - 55296 << 10) + (c22 - 56320); 46601 m_pos++; 46602 } 46603 } 46604 if (c6 < 128) { 46605 buf[i2++] = c6; 46606 } else if (c6 < 2048) { 46607 buf[i2++] = 192 | c6 >>> 6; 46608 buf[i2++] = 128 | c6 & 63; 46609 } else if (c6 < 65536) { 46610 buf[i2++] = 224 | c6 >>> 12; 46611 buf[i2++] = 128 | c6 >>> 6 & 63; 46612 buf[i2++] = 128 | c6 & 63; 46613 } else { 46614 buf[i2++] = 240 | c6 >>> 18; 46615 buf[i2++] = 128 | c6 >>> 12 & 63; 46616 buf[i2++] = 128 | c6 >>> 6 & 63; 46617 buf[i2++] = 128 | c6 & 63; 46618 } 46619 } 46620 return buf; 46621 }; 46622 function buf2binstring(buf, len) { 46623 if (len < 65534) { 46624 if (buf.subarray && STR_APPLY_UIA_OK || !buf.subarray && STR_APPLY_OK) { 46625 return String.fromCharCode.apply( 46626 null, 46627 utils.shrinkBuf(buf, len) 46628 ); 46629 } 46630 } 46631 var result = ""; 46632 for (var i2 = 0; i2 < len; i2++) { 46633 result += String.fromCharCode(buf[i2]); 46634 } 46635 return result; 46636 } 46637 exports2.buf2binstring = function(buf) { 46638 return buf2binstring(buf, buf.length); 46639 }; 46640 exports2.binstring2buf = function(str) { 46641 var buf = new utils.Buf8(str.length); 46642 for (var i2 = 0, len = buf.length; i2 < len; i2++) { 46643 buf[i2] = str.charCodeAt(i2); 46644 } 46645 return buf; 46646 }; 46647 exports2.buf2string = function(buf, max2) { 46648 var i2, out, c6, c_len; 46649 var len = max2 || buf.length; 46650 var utf16buf = new Array(len * 2); 46651 for (out = 0, i2 = 0; i2 < len; ) { 46652 c6 = buf[i2++]; 46653 if (c6 < 128) { 46654 utf16buf[out++] = c6; 46655 continue; 46656 } 46657 c_len = _utf8len[c6]; 46658 if (c_len > 4) { 46659 utf16buf[out++] = 65533; 46660 i2 += c_len - 1; 46661 continue; 46662 } 46663 c6 &= c_len === 2 ? 31 : c_len === 3 ? 15 : 7; 46664 while (c_len > 1 && i2 < len) { 46665 c6 = c6 << 6 | buf[i2++] & 63; 46666 c_len--; 46667 } 46668 if (c_len > 1) { 46669 utf16buf[out++] = 65533; 46670 continue; 46671 } 46672 if (c6 < 65536) { 46673 utf16buf[out++] = c6; 46674 } else { 46675 c6 -= 65536; 46676 utf16buf[out++] = 55296 | c6 >> 10 & 1023; 46677 utf16buf[out++] = 56320 | c6 & 1023; 46678 } 46679 } 46680 return buf2binstring(utf16buf, out); 46681 }; 46682 exports2.utf8border = function(buf, max2) { 46683 var pos; 46684 max2 = max2 || buf.length; 46685 if (max2 > buf.length) { 46686 max2 = buf.length; 46687 } 46688 pos = max2 - 1; 46689 while (pos >= 0 && (buf[pos] & 192) === 128) { 46690 pos--; 46691 } 46692 if (pos < 0) { 46693 return max2; 46694 } 46695 if (pos === 0) { 46696 return max2; 46697 } 46698 return pos + _utf8len[buf[pos]] > max2 ? pos : max2; 46699 }; 46700 }, 46701 { "./common": 1 } 46702 ], 46703 3: [ 46704 function(require2, module2, exports2) { 46705 "use strict"; 46706 function adler32(adler, buf, len, pos) { 46707 var s1 = adler & 65535 | 0, s2 = adler >>> 16 & 65535 | 0, n2 = 0; 46708 while (len !== 0) { 46709 n2 = len > 2e3 ? 2e3 : len; 46710 len -= n2; 46711 do { 46712 s1 = s1 + buf[pos++] | 0; 46713 s2 = s2 + s1 | 0; 46714 } while (--n2); 46715 s1 %= 65521; 46716 s2 %= 65521; 46717 } 46718 return s1 | s2 << 16 | 0; 46719 } 46720 module2.exports = adler32; 46721 }, 46722 {} 46723 ], 46724 4: [ 46725 function(require2, module2, exports2) { 46726 "use strict"; 46727 module2.exports = { 46728 /* Allowed flush values; see deflate() and inflate() below for details */ 46729 Z_NO_FLUSH: 0, 46730 Z_PARTIAL_FLUSH: 1, 46731 Z_SYNC_FLUSH: 2, 46732 Z_FULL_FLUSH: 3, 46733 Z_FINISH: 4, 46734 Z_BLOCK: 5, 46735 Z_TREES: 6, 46736 /* Return codes for the compression/decompression functions. Negative values 46737 * are errors, positive values are used for special but normal events. 46738 */ 46739 Z_OK: 0, 46740 Z_STREAM_END: 1, 46741 Z_NEED_DICT: 2, 46742 Z_ERRNO: -1, 46743 Z_STREAM_ERROR: -2, 46744 Z_DATA_ERROR: -3, 46745 //Z_MEM_ERROR: -4, 46746 Z_BUF_ERROR: -5, 46747 //Z_VERSION_ERROR: -6, 46748 /* compression levels */ 46749 Z_NO_COMPRESSION: 0, 46750 Z_BEST_SPEED: 1, 46751 Z_BEST_COMPRESSION: 9, 46752 Z_DEFAULT_COMPRESSION: -1, 46753 Z_FILTERED: 1, 46754 Z_HUFFMAN_ONLY: 2, 46755 Z_RLE: 3, 46756 Z_FIXED: 4, 46757 Z_DEFAULT_STRATEGY: 0, 46758 /* Possible values of the data_type field (though see inflate()) */ 46759 Z_BINARY: 0, 46760 Z_TEXT: 1, 46761 //Z_ASCII: 1, // = Z_TEXT (deprecated) 46762 Z_UNKNOWN: 2, 46763 /* The deflate compression method */ 46764 Z_DEFLATED: 8 46765 //Z_NULL: null // Use -1 or null inline, depending on var type 46766 }; 46767 }, 46768 {} 46769 ], 46770 5: [ 46771 function(require2, module2, exports2) { 46772 "use strict"; 46773 function makeTable() { 46774 var c6, table = []; 46775 for (var n2 = 0; n2 < 256; n2++) { 46776 c6 = n2; 46777 for (var k2 = 0; k2 < 8; k2++) { 46778 c6 = c6 & 1 ? 3988292384 ^ c6 >>> 1 : c6 >>> 1; 46779 } 46780 table[n2] = c6; 46781 } 46782 return table; 46783 } 46784 var crcTable = makeTable(); 46785 function crc32(crc, buf, len, pos) { 46786 var t3 = crcTable, end = pos + len; 46787 crc ^= -1; 46788 for (var i2 = pos; i2 < end; i2++) { 46789 crc = crc >>> 8 ^ t3[(crc ^ buf[i2]) & 255]; 46790 } 46791 return crc ^ -1; 46792 } 46793 module2.exports = crc32; 46794 }, 46795 {} 46796 ], 46797 6: [ 46798 function(require2, module2, exports2) { 46799 "use strict"; 46800 function GZheader() { 46801 this.text = 0; 46802 this.time = 0; 46803 this.xflags = 0; 46804 this.os = 0; 46805 this.extra = null; 46806 this.extra_len = 0; 46807 this.name = ""; 46808 this.comment = ""; 46809 this.hcrc = 0; 46810 this.done = false; 46811 } 46812 module2.exports = GZheader; 46813 }, 46814 {} 46815 ], 46816 7: [ 46817 function(require2, module2, exports2) { 46818 "use strict"; 46819 var BAD = 30; 46820 var TYPE = 12; 46821 module2.exports = function inflate_fast(strm, start2) { 46822 var state; 46823 var _in; 46824 var last; 46825 var _out; 46826 var beg; 46827 var end; 46828 var dmax; 46829 var wsize; 46830 var whave; 46831 var wnext; 46832 var s_window; 46833 var hold; 46834 var bits; 46835 var lcode; 46836 var dcode; 46837 var lmask; 46838 var dmask; 46839 var here; 46840 var op; 46841 var len; 46842 var dist; 46843 var from; 46844 var from_source; 46845 var input, output; 46846 state = strm.state; 46847 _in = strm.next_in; 46848 input = strm.input; 46849 last = _in + (strm.avail_in - 5); 46850 _out = strm.next_out; 46851 output = strm.output; 46852 beg = _out - (start2 - strm.avail_out); 46853 end = _out + (strm.avail_out - 257); 46854 dmax = state.dmax; 46855 wsize = state.wsize; 46856 whave = state.whave; 46857 wnext = state.wnext; 46858 s_window = state.window; 46859 hold = state.hold; 46860 bits = state.bits; 46861 lcode = state.lencode; 46862 dcode = state.distcode; 46863 lmask = (1 << state.lenbits) - 1; 46864 dmask = (1 << state.distbits) - 1; 46865 top: do { 46866 if (bits < 15) { 46867 hold += input[_in++] << bits; 46868 bits += 8; 46869 hold += input[_in++] << bits; 46870 bits += 8; 46871 } 46872 here = lcode[hold & lmask]; 46873 dolen: for (; ; ) { 46874 op = here >>> 24; 46875 hold >>>= op; 46876 bits -= op; 46877 op = here >>> 16 & 255; 46878 if (op === 0) { 46879 output[_out++] = here & 65535; 46880 } else if (op & 16) { 46881 len = here & 65535; 46882 op &= 15; 46883 if (op) { 46884 if (bits < op) { 46885 hold += input[_in++] << bits; 46886 bits += 8; 46887 } 46888 len += hold & (1 << op) - 1; 46889 hold >>>= op; 46890 bits -= op; 46891 } 46892 if (bits < 15) { 46893 hold += input[_in++] << bits; 46894 bits += 8; 46895 hold += input[_in++] << bits; 46896 bits += 8; 46897 } 46898 here = dcode[hold & dmask]; 46899 dodist: for (; ; ) { 46900 op = here >>> 24; 46901 hold >>>= op; 46902 bits -= op; 46903 op = here >>> 16 & 255; 46904 if (op & 16) { 46905 dist = here & 65535; 46906 op &= 15; 46907 if (bits < op) { 46908 hold += input[_in++] << bits; 46909 bits += 8; 46910 if (bits < op) { 46911 hold += input[_in++] << bits; 46912 bits += 8; 46913 } 46914 } 46915 dist += hold & (1 << op) - 1; 46916 if (dist > dmax) { 46917 strm.msg = "invalid distance too far back"; 46918 state.mode = BAD; 46919 break top; 46920 } 46921 hold >>>= op; 46922 bits -= op; 46923 op = _out - beg; 46924 if (dist > op) { 46925 op = dist - op; 46926 if (op > whave) { 46927 if (state.sane) { 46928 strm.msg = "invalid distance too far back"; 46929 state.mode = BAD; 46930 break top; 46931 } 46932 } 46933 from = 0; 46934 from_source = s_window; 46935 if (wnext === 0) { 46936 from += wsize - op; 46937 if (op < len) { 46938 len -= op; 46939 do { 46940 output[_out++] = s_window[from++]; 46941 } while (--op); 46942 from = _out - dist; 46943 from_source = output; 46944 } 46945 } else if (wnext < op) { 46946 from += wsize + wnext - op; 46947 op -= wnext; 46948 if (op < len) { 46949 len -= op; 46950 do { 46951 output[_out++] = s_window[from++]; 46952 } while (--op); 46953 from = 0; 46954 if (wnext < len) { 46955 op = wnext; 46956 len -= op; 46957 do { 46958 output[_out++] = s_window[from++]; 46959 } while (--op); 46960 from = _out - dist; 46961 from_source = output; 46962 } 46963 } 46964 } else { 46965 from += wnext - op; 46966 if (op < len) { 46967 len -= op; 46968 do { 46969 output[_out++] = s_window[from++]; 46970 } while (--op); 46971 from = _out - dist; 46972 from_source = output; 46973 } 46974 } 46975 while (len > 2) { 46976 output[_out++] = from_source[from++]; 46977 output[_out++] = from_source[from++]; 46978 output[_out++] = from_source[from++]; 46979 len -= 3; 46980 } 46981 if (len) { 46982 output[_out++] = from_source[from++]; 46983 if (len > 1) { 46984 output[_out++] = from_source[from++]; 46985 } 46986 } 46987 } else { 46988 from = _out - dist; 46989 do { 46990 output[_out++] = output[from++]; 46991 output[_out++] = output[from++]; 46992 output[_out++] = output[from++]; 46993 len -= 3; 46994 } while (len > 2); 46995 if (len) { 46996 output[_out++] = output[from++]; 46997 if (len > 1) { 46998 output[_out++] = output[from++]; 46999 } 47000 } 47001 } 47002 } else if ((op & 64) === 0) { 47003 here = dcode[(here & 65535) + (hold & (1 << op) - 1)]; 47004 continue dodist; 47005 } else { 47006 strm.msg = "invalid distance code"; 47007 state.mode = BAD; 47008 break top; 47009 } 47010 break; 47011 } 47012 } else if ((op & 64) === 0) { 47013 here = lcode[(here & 65535) + (hold & (1 << op) - 1)]; 47014 continue dolen; 47015 } else if (op & 32) { 47016 state.mode = TYPE; 47017 break top; 47018 } else { 47019 strm.msg = "invalid literal/length code"; 47020 state.mode = BAD; 47021 break top; 47022 } 47023 break; 47024 } 47025 } while (_in < last && _out < end); 47026 len = bits >> 3; 47027 _in -= len; 47028 bits -= len << 3; 47029 hold &= (1 << bits) - 1; 47030 strm.next_in = _in; 47031 strm.next_out = _out; 47032 strm.avail_in = _in < last ? 5 + (last - _in) : 5 - (_in - last); 47033 strm.avail_out = _out < end ? 257 + (end - _out) : 257 - (_out - end); 47034 state.hold = hold; 47035 state.bits = bits; 47036 return; 47037 }; 47038 }, 47039 {} 47040 ], 47041 8: [ 47042 function(require2, module2, exports2) { 47043 "use strict"; 47044 var utils = require2("../utils/common"); 47045 var adler32 = require2("./adler32"); 47046 var crc32 = require2("./crc32"); 47047 var inflate_fast = require2("./inffast"); 47048 var inflate_table = require2("./inftrees"); 47049 var CODES = 0; 47050 var LENS = 1; 47051 var DISTS = 2; 47052 var Z_FINISH = 4; 47053 var Z_BLOCK = 5; 47054 var Z_TREES = 6; 47055 var Z_OK = 0; 47056 var Z_STREAM_END = 1; 47057 var Z_NEED_DICT = 2; 47058 var Z_STREAM_ERROR = -2; 47059 var Z_DATA_ERROR = -3; 47060 var Z_MEM_ERROR = -4; 47061 var Z_BUF_ERROR = -5; 47062 var Z_DEFLATED = 8; 47063 var HEAD = 1; 47064 var FLAGS = 2; 47065 var TIME = 3; 47066 var OS = 4; 47067 var EXLEN = 5; 47068 var EXTRA = 6; 47069 var NAME = 7; 47070 var COMMENT = 8; 47071 var HCRC = 9; 47072 var DICTID = 10; 47073 var DICT = 11; 47074 var TYPE = 12; 47075 var TYPEDO = 13; 47076 var STORED = 14; 47077 var COPY_ = 15; 47078 var COPY = 16; 47079 var TABLE = 17; 47080 var LENLENS = 18; 47081 var CODELENS = 19; 47082 var LEN_ = 20; 47083 var LEN = 21; 47084 var LENEXT = 22; 47085 var DIST = 23; 47086 var DISTEXT = 24; 47087 var MATCH = 25; 47088 var LIT = 26; 47089 var CHECK = 27; 47090 var LENGTH = 28; 47091 var DONE = 29; 47092 var BAD = 30; 47093 var MEM = 31; 47094 var SYNC = 32; 47095 var ENOUGH_LENS = 852; 47096 var ENOUGH_DISTS = 592; 47097 var MAX_WBITS = 15; 47098 var DEF_WBITS = MAX_WBITS; 47099 function zswap32(q) { 47100 return (q >>> 24 & 255) + (q >>> 8 & 65280) + ((q & 65280) << 8) + ((q & 255) << 24); 47101 } 47102 function InflateState() { 47103 this.mode = 0; 47104 this.last = false; 47105 this.wrap = 0; 47106 this.havedict = false; 47107 this.flags = 0; 47108 this.dmax = 0; 47109 this.check = 0; 47110 this.total = 0; 47111 this.head = null; 47112 this.wbits = 0; 47113 this.wsize = 0; 47114 this.whave = 0; 47115 this.wnext = 0; 47116 this.window = null; 47117 this.hold = 0; 47118 this.bits = 0; 47119 this.length = 0; 47120 this.offset = 0; 47121 this.extra = 0; 47122 this.lencode = null; 47123 this.distcode = null; 47124 this.lenbits = 0; 47125 this.distbits = 0; 47126 this.ncode = 0; 47127 this.nlen = 0; 47128 this.ndist = 0; 47129 this.have = 0; 47130 this.next = null; 47131 this.lens = new utils.Buf16( 47132 320 47133 ); 47134 this.work = new utils.Buf16( 47135 288 47136 ); 47137 this.lendyn = null; 47138 this.distdyn = null; 47139 this.sane = 0; 47140 this.back = 0; 47141 this.was = 0; 47142 } 47143 function inflateResetKeep(strm) { 47144 var state; 47145 if (!strm || !strm.state) { 47146 return Z_STREAM_ERROR; 47147 } 47148 state = strm.state; 47149 strm.total_in = strm.total_out = state.total = 0; 47150 strm.msg = ""; 47151 if (state.wrap) { 47152 strm.adler = state.wrap & 1; 47153 } 47154 state.mode = HEAD; 47155 state.last = 0; 47156 state.havedict = 0; 47157 state.dmax = 32768; 47158 state.head = null; 47159 state.hold = 0; 47160 state.bits = 0; 47161 state.lencode = state.lendyn = new utils.Buf32( 47162 ENOUGH_LENS 47163 ); 47164 state.distcode = state.distdyn = new utils.Buf32( 47165 ENOUGH_DISTS 47166 ); 47167 state.sane = 1; 47168 state.back = -1; 47169 return Z_OK; 47170 } 47171 function inflateReset(strm) { 47172 var state; 47173 if (!strm || !strm.state) { 47174 return Z_STREAM_ERROR; 47175 } 47176 state = strm.state; 47177 state.wsize = 0; 47178 state.whave = 0; 47179 state.wnext = 0; 47180 return inflateResetKeep(strm); 47181 } 47182 function inflateReset2(strm, windowBits) { 47183 var wrap; 47184 var state; 47185 if (!strm || !strm.state) { 47186 return Z_STREAM_ERROR; 47187 } 47188 state = strm.state; 47189 if (windowBits < 0) { 47190 wrap = 0; 47191 windowBits = -windowBits; 47192 } else { 47193 wrap = (windowBits >> 4) + 1; 47194 if (windowBits < 48) { 47195 windowBits &= 15; 47196 } 47197 } 47198 if (windowBits && (windowBits < 8 || windowBits > 15)) { 47199 return Z_STREAM_ERROR; 47200 } 47201 if (state.window !== null && state.wbits !== windowBits) { 47202 state.window = null; 47203 } 47204 state.wrap = wrap; 47205 state.wbits = windowBits; 47206 return inflateReset(strm); 47207 } 47208 function inflateInit2(strm, windowBits) { 47209 var ret; 47210 var state; 47211 if (!strm) { 47212 return Z_STREAM_ERROR; 47213 } 47214 state = new InflateState(); 47215 strm.state = state; 47216 state.window = null; 47217 ret = inflateReset2(strm, windowBits); 47218 if (ret !== Z_OK) { 47219 strm.state = null; 47220 } 47221 return ret; 47222 } 47223 function inflateInit(strm) { 47224 return inflateInit2(strm, DEF_WBITS); 47225 } 47226 var virgin = true; 47227 var lenfix, distfix; 47228 function fixedtables(state) { 47229 if (virgin) { 47230 var sym; 47231 lenfix = new utils.Buf32(512); 47232 distfix = new utils.Buf32(32); 47233 sym = 0; 47234 while (sym < 144) { 47235 state.lens[sym++] = 8; 47236 } 47237 while (sym < 256) { 47238 state.lens[sym++] = 9; 47239 } 47240 while (sym < 280) { 47241 state.lens[sym++] = 7; 47242 } 47243 while (sym < 288) { 47244 state.lens[sym++] = 8; 47245 } 47246 inflate_table( 47247 LENS, 47248 state.lens, 47249 0, 47250 288, 47251 lenfix, 47252 0, 47253 state.work, 47254 { bits: 9 } 47255 ); 47256 sym = 0; 47257 while (sym < 32) { 47258 state.lens[sym++] = 5; 47259 } 47260 inflate_table( 47261 DISTS, 47262 state.lens, 47263 0, 47264 32, 47265 distfix, 47266 0, 47267 state.work, 47268 { bits: 5 } 47269 ); 47270 virgin = false; 47271 } 47272 state.lencode = lenfix; 47273 state.lenbits = 9; 47274 state.distcode = distfix; 47275 state.distbits = 5; 47276 } 47277 function updatewindow(strm, src, end, copy) { 47278 var dist; 47279 var state = strm.state; 47280 if (state.window === null) { 47281 state.wsize = 1 << state.wbits; 47282 state.wnext = 0; 47283 state.whave = 0; 47284 state.window = new utils.Buf8(state.wsize); 47285 } 47286 if (copy >= state.wsize) { 47287 utils.arraySet( 47288 state.window, 47289 src, 47290 end - state.wsize, 47291 state.wsize, 47292 0 47293 ); 47294 state.wnext = 0; 47295 state.whave = state.wsize; 47296 } else { 47297 dist = state.wsize - state.wnext; 47298 if (dist > copy) { 47299 dist = copy; 47300 } 47301 utils.arraySet( 47302 state.window, 47303 src, 47304 end - copy, 47305 dist, 47306 state.wnext 47307 ); 47308 copy -= dist; 47309 if (copy) { 47310 utils.arraySet( 47311 state.window, 47312 src, 47313 end - copy, 47314 copy, 47315 0 47316 ); 47317 state.wnext = copy; 47318 state.whave = state.wsize; 47319 } else { 47320 state.wnext += dist; 47321 if (state.wnext === state.wsize) { 47322 state.wnext = 0; 47323 } 47324 if (state.whave < state.wsize) { 47325 state.whave += dist; 47326 } 47327 } 47328 } 47329 return 0; 47330 } 47331 function inflate(strm, flush2) { 47332 var state; 47333 var input, output; 47334 var next; 47335 var put; 47336 var have, left; 47337 var hold; 47338 var bits; 47339 var _in, _out; 47340 var copy; 47341 var from; 47342 var from_source; 47343 var here = 0; 47344 var here_bits, here_op, here_val; 47345 var last_bits, last_op, last_val; 47346 var len; 47347 var ret; 47348 var hbuf = new utils.Buf8( 47349 4 47350 ); 47351 var opts; 47352 var n2; 47353 var order = ( 47354 /* permutation of code lengths */ 47355 [ 47356 16, 47357 17, 47358 18, 47359 0, 47360 8, 47361 7, 47362 9, 47363 6, 47364 10, 47365 5, 47366 11, 47367 4, 47368 12, 47369 3, 47370 13, 47371 2, 47372 14, 47373 1, 47374 15 47375 ] 47376 ); 47377 if (!strm || !strm.state || !strm.output || !strm.input && strm.avail_in !== 0) { 47378 return Z_STREAM_ERROR; 47379 } 47380 state = strm.state; 47381 if (state.mode === TYPE) { 47382 state.mode = TYPEDO; 47383 } 47384 put = strm.next_out; 47385 output = strm.output; 47386 left = strm.avail_out; 47387 next = strm.next_in; 47388 input = strm.input; 47389 have = strm.avail_in; 47390 hold = state.hold; 47391 bits = state.bits; 47392 _in = have; 47393 _out = left; 47394 ret = Z_OK; 47395 inf_leave: for (; ; ) { 47396 switch (state.mode) { 47397 case HEAD: 47398 if (state.wrap === 0) { 47399 state.mode = TYPEDO; 47400 break; 47401 } 47402 while (bits < 16) { 47403 if (have === 0) { 47404 break inf_leave; 47405 } 47406 have--; 47407 hold += input[next++] << bits; 47408 bits += 8; 47409 } 47410 if (state.wrap & 2 && hold === 35615) { 47411 state.check = 0; 47412 hbuf[0] = hold & 255; 47413 hbuf[1] = hold >>> 8 & 255; 47414 state.check = crc32( 47415 state.check, 47416 hbuf, 47417 2, 47418 0 47419 ); 47420 hold = 0; 47421 bits = 0; 47422 state.mode = FLAGS; 47423 break; 47424 } 47425 state.flags = 0; 47426 if (state.head) { 47427 state.head.done = false; 47428 } 47429 if (!(state.wrap & 1) || (((hold & 255) << 8) + (hold >> 8)) % 31) { 47430 strm.msg = "incorrect header check"; 47431 state.mode = BAD; 47432 break; 47433 } 47434 if ((hold & 15) !== Z_DEFLATED) { 47435 strm.msg = "unknown compression method"; 47436 state.mode = BAD; 47437 break; 47438 } 47439 hold >>>= 4; 47440 bits -= 4; 47441 len = (hold & 15) + 8; 47442 if (state.wbits === 0) { 47443 state.wbits = len; 47444 } else if (len > state.wbits) { 47445 strm.msg = "invalid window size"; 47446 state.mode = BAD; 47447 break; 47448 } 47449 state.dmax = 1 << len; 47450 strm.adler = state.check = 1; 47451 state.mode = hold & 512 ? DICTID : TYPE; 47452 hold = 0; 47453 bits = 0; 47454 break; 47455 case FLAGS: 47456 while (bits < 16) { 47457 if (have === 0) { 47458 break inf_leave; 47459 } 47460 have--; 47461 hold += input[next++] << bits; 47462 bits += 8; 47463 } 47464 state.flags = hold; 47465 if ((state.flags & 255) !== Z_DEFLATED) { 47466 strm.msg = "unknown compression method"; 47467 state.mode = BAD; 47468 break; 47469 } 47470 if (state.flags & 57344) { 47471 strm.msg = "unknown header flags set"; 47472 state.mode = BAD; 47473 break; 47474 } 47475 if (state.head) { 47476 state.head.text = hold >> 8 & 1; 47477 } 47478 if (state.flags & 512) { 47479 hbuf[0] = hold & 255; 47480 hbuf[1] = hold >>> 8 & 255; 47481 state.check = crc32( 47482 state.check, 47483 hbuf, 47484 2, 47485 0 47486 ); 47487 } 47488 hold = 0; 47489 bits = 0; 47490 state.mode = TIME; 47491 /* falls through */ 47492 case TIME: 47493 while (bits < 32) { 47494 if (have === 0) { 47495 break inf_leave; 47496 } 47497 have--; 47498 hold += input[next++] << bits; 47499 bits += 8; 47500 } 47501 if (state.head) { 47502 state.head.time = hold; 47503 } 47504 if (state.flags & 512) { 47505 hbuf[0] = hold & 255; 47506 hbuf[1] = hold >>> 8 & 255; 47507 hbuf[2] = hold >>> 16 & 255; 47508 hbuf[3] = hold >>> 24 & 255; 47509 state.check = crc32( 47510 state.check, 47511 hbuf, 47512 4, 47513 0 47514 ); 47515 } 47516 hold = 0; 47517 bits = 0; 47518 state.mode = OS; 47519 /* falls through */ 47520 case OS: 47521 while (bits < 16) { 47522 if (have === 0) { 47523 break inf_leave; 47524 } 47525 have--; 47526 hold += input[next++] << bits; 47527 bits += 8; 47528 } 47529 if (state.head) { 47530 state.head.xflags = hold & 255; 47531 state.head.os = hold >> 8; 47532 } 47533 if (state.flags & 512) { 47534 hbuf[0] = hold & 255; 47535 hbuf[1] = hold >>> 8 & 255; 47536 state.check = crc32( 47537 state.check, 47538 hbuf, 47539 2, 47540 0 47541 ); 47542 } 47543 hold = 0; 47544 bits = 0; 47545 state.mode = EXLEN; 47546 /* falls through */ 47547 case EXLEN: 47548 if (state.flags & 1024) { 47549 while (bits < 16) { 47550 if (have === 0) { 47551 break inf_leave; 47552 } 47553 have--; 47554 hold += input[next++] << bits; 47555 bits += 8; 47556 } 47557 state.length = hold; 47558 if (state.head) { 47559 state.head.extra_len = hold; 47560 } 47561 if (state.flags & 512) { 47562 hbuf[0] = hold & 255; 47563 hbuf[1] = hold >>> 8 & 255; 47564 state.check = crc32( 47565 state.check, 47566 hbuf, 47567 2, 47568 0 47569 ); 47570 } 47571 hold = 0; 47572 bits = 0; 47573 } else if (state.head) { 47574 state.head.extra = null; 47575 } 47576 state.mode = EXTRA; 47577 /* falls through */ 47578 case EXTRA: 47579 if (state.flags & 1024) { 47580 copy = state.length; 47581 if (copy > have) { 47582 copy = have; 47583 } 47584 if (copy) { 47585 if (state.head) { 47586 len = state.head.extra_len - state.length; 47587 if (!state.head.extra) { 47588 state.head.extra = new Array( 47589 state.head.extra_len 47590 ); 47591 } 47592 utils.arraySet( 47593 state.head.extra, 47594 input, 47595 next, 47596 // extra field is limited to 65536 bytes 47597 // - no need for additional size check 47598 copy, 47599 /*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/ 47600 len 47601 ); 47602 } 47603 if (state.flags & 512) { 47604 state.check = crc32( 47605 state.check, 47606 input, 47607 copy, 47608 next 47609 ); 47610 } 47611 have -= copy; 47612 next += copy; 47613 state.length -= copy; 47614 } 47615 if (state.length) { 47616 break inf_leave; 47617 } 47618 } 47619 state.length = 0; 47620 state.mode = NAME; 47621 /* falls through */ 47622 case NAME: 47623 if (state.flags & 2048) { 47624 if (have === 0) { 47625 break inf_leave; 47626 } 47627 copy = 0; 47628 do { 47629 len = input[next + copy++]; 47630 if (state.head && len && state.length < 65536) { 47631 state.head.name += String.fromCharCode(len); 47632 } 47633 } while (len && copy < have); 47634 if (state.flags & 512) { 47635 state.check = crc32( 47636 state.check, 47637 input, 47638 copy, 47639 next 47640 ); 47641 } 47642 have -= copy; 47643 next += copy; 47644 if (len) { 47645 break inf_leave; 47646 } 47647 } else if (state.head) { 47648 state.head.name = null; 47649 } 47650 state.length = 0; 47651 state.mode = COMMENT; 47652 /* falls through */ 47653 case COMMENT: 47654 if (state.flags & 4096) { 47655 if (have === 0) { 47656 break inf_leave; 47657 } 47658 copy = 0; 47659 do { 47660 len = input[next + copy++]; 47661 if (state.head && len && state.length < 65536) { 47662 state.head.comment += String.fromCharCode(len); 47663 } 47664 } while (len && copy < have); 47665 if (state.flags & 512) { 47666 state.check = crc32( 47667 state.check, 47668 input, 47669 copy, 47670 next 47671 ); 47672 } 47673 have -= copy; 47674 next += copy; 47675 if (len) { 47676 break inf_leave; 47677 } 47678 } else if (state.head) { 47679 state.head.comment = null; 47680 } 47681 state.mode = HCRC; 47682 /* falls through */ 47683 case HCRC: 47684 if (state.flags & 512) { 47685 while (bits < 16) { 47686 if (have === 0) { 47687 break inf_leave; 47688 } 47689 have--; 47690 hold += input[next++] << bits; 47691 bits += 8; 47692 } 47693 if (hold !== (state.check & 65535)) { 47694 strm.msg = "header crc mismatch"; 47695 state.mode = BAD; 47696 break; 47697 } 47698 hold = 0; 47699 bits = 0; 47700 } 47701 if (state.head) { 47702 state.head.hcrc = state.flags >> 9 & 1; 47703 state.head.done = true; 47704 } 47705 strm.adler = state.check = 0; 47706 state.mode = TYPE; 47707 break; 47708 case DICTID: 47709 while (bits < 32) { 47710 if (have === 0) { 47711 break inf_leave; 47712 } 47713 have--; 47714 hold += input[next++] << bits; 47715 bits += 8; 47716 } 47717 strm.adler = state.check = zswap32(hold); 47718 hold = 0; 47719 bits = 0; 47720 state.mode = DICT; 47721 /* falls through */ 47722 case DICT: 47723 if (state.havedict === 0) { 47724 strm.next_out = put; 47725 strm.avail_out = left; 47726 strm.next_in = next; 47727 strm.avail_in = have; 47728 state.hold = hold; 47729 state.bits = bits; 47730 return Z_NEED_DICT; 47731 } 47732 strm.adler = state.check = 1; 47733 state.mode = TYPE; 47734 /* falls through */ 47735 case TYPE: 47736 if (flush2 === Z_BLOCK || flush2 === Z_TREES) { 47737 break inf_leave; 47738 } 47739 /* falls through */ 47740 case TYPEDO: 47741 if (state.last) { 47742 hold >>>= bits & 7; 47743 bits -= bits & 7; 47744 state.mode = CHECK; 47745 break; 47746 } 47747 while (bits < 3) { 47748 if (have === 0) { 47749 break inf_leave; 47750 } 47751 have--; 47752 hold += input[next++] << bits; 47753 bits += 8; 47754 } 47755 state.last = hold & 1; 47756 hold >>>= 1; 47757 bits -= 1; 47758 switch (hold & 3) { 47759 case 0: 47760 state.mode = STORED; 47761 break; 47762 case 1: 47763 fixedtables(state); 47764 state.mode = LEN_; 47765 if (flush2 === Z_TREES) { 47766 hold >>>= 2; 47767 bits -= 2; 47768 break inf_leave; 47769 } 47770 break; 47771 case 2: 47772 state.mode = TABLE; 47773 break; 47774 case 3: 47775 strm.msg = "invalid block type"; 47776 state.mode = BAD; 47777 } 47778 hold >>>= 2; 47779 bits -= 2; 47780 break; 47781 case STORED: 47782 hold >>>= bits & 7; 47783 bits -= bits & 7; 47784 while (bits < 32) { 47785 if (have === 0) { 47786 break inf_leave; 47787 } 47788 have--; 47789 hold += input[next++] << bits; 47790 bits += 8; 47791 } 47792 if ((hold & 65535) !== (hold >>> 16 ^ 65535)) { 47793 strm.msg = "invalid stored block lengths"; 47794 state.mode = BAD; 47795 break; 47796 } 47797 state.length = hold & 65535; 47798 hold = 0; 47799 bits = 0; 47800 state.mode = COPY_; 47801 if (flush2 === Z_TREES) { 47802 break inf_leave; 47803 } 47804 /* falls through */ 47805 case COPY_: 47806 state.mode = COPY; 47807 /* falls through */ 47808 case COPY: 47809 copy = state.length; 47810 if (copy) { 47811 if (copy > have) { 47812 copy = have; 47813 } 47814 if (copy > left) { 47815 copy = left; 47816 } 47817 if (copy === 0) { 47818 break inf_leave; 47819 } 47820 utils.arraySet( 47821 output, 47822 input, 47823 next, 47824 copy, 47825 put 47826 ); 47827 have -= copy; 47828 next += copy; 47829 left -= copy; 47830 put += copy; 47831 state.length -= copy; 47832 break; 47833 } 47834 state.mode = TYPE; 47835 break; 47836 case TABLE: 47837 while (bits < 14) { 47838 if (have === 0) { 47839 break inf_leave; 47840 } 47841 have--; 47842 hold += input[next++] << bits; 47843 bits += 8; 47844 } 47845 state.nlen = (hold & 31) + 257; 47846 hold >>>= 5; 47847 bits -= 5; 47848 state.ndist = (hold & 31) + 1; 47849 hold >>>= 5; 47850 bits -= 5; 47851 state.ncode = (hold & 15) + 4; 47852 hold >>>= 4; 47853 bits -= 4; 47854 if (state.nlen > 286 || state.ndist > 30) { 47855 strm.msg = "too many length or distance symbols"; 47856 state.mode = BAD; 47857 break; 47858 } 47859 state.have = 0; 47860 state.mode = LENLENS; 47861 /* falls through */ 47862 case LENLENS: 47863 while (state.have < state.ncode) { 47864 while (bits < 3) { 47865 if (have === 0) { 47866 break inf_leave; 47867 } 47868 have--; 47869 hold += input[next++] << bits; 47870 bits += 8; 47871 } 47872 state.lens[order[state.have++]] = hold & 7; 47873 hold >>>= 3; 47874 bits -= 3; 47875 } 47876 while (state.have < 19) { 47877 state.lens[order[state.have++]] = 0; 47878 } 47879 state.lencode = state.lendyn; 47880 state.lenbits = 7; 47881 opts = { bits: state.lenbits }; 47882 ret = inflate_table( 47883 CODES, 47884 state.lens, 47885 0, 47886 19, 47887 state.lencode, 47888 0, 47889 state.work, 47890 opts 47891 ); 47892 state.lenbits = opts.bits; 47893 if (ret) { 47894 strm.msg = "invalid code lengths set"; 47895 state.mode = BAD; 47896 break; 47897 } 47898 state.have = 0; 47899 state.mode = CODELENS; 47900 /* falls through */ 47901 case CODELENS: 47902 while (state.have < state.nlen + state.ndist) { 47903 for (; ; ) { 47904 here = state.lencode[hold & (1 << state.lenbits) - 1]; 47905 here_bits = here >>> 24; 47906 here_op = here >>> 16 & 255; 47907 here_val = here & 65535; 47908 if (here_bits <= bits) { 47909 break; 47910 } 47911 if (have === 0) { 47912 break inf_leave; 47913 } 47914 have--; 47915 hold += input[next++] << bits; 47916 bits += 8; 47917 } 47918 if (here_val < 16) { 47919 hold >>>= here_bits; 47920 bits -= here_bits; 47921 state.lens[state.have++] = here_val; 47922 } else { 47923 if (here_val === 16) { 47924 n2 = here_bits + 2; 47925 while (bits < n2) { 47926 if (have === 0) { 47927 break inf_leave; 47928 } 47929 have--; 47930 hold += input[next++] << bits; 47931 bits += 8; 47932 } 47933 hold >>>= here_bits; 47934 bits -= here_bits; 47935 if (state.have === 0) { 47936 strm.msg = "invalid bit length repeat"; 47937 state.mode = BAD; 47938 break; 47939 } 47940 len = state.lens[state.have - 1]; 47941 copy = 3 + (hold & 3); 47942 hold >>>= 2; 47943 bits -= 2; 47944 } else if (here_val === 17) { 47945 n2 = here_bits + 3; 47946 while (bits < n2) { 47947 if (have === 0) { 47948 break inf_leave; 47949 } 47950 have--; 47951 hold += input[next++] << bits; 47952 bits += 8; 47953 } 47954 hold >>>= here_bits; 47955 bits -= here_bits; 47956 len = 0; 47957 copy = 3 + (hold & 7); 47958 hold >>>= 3; 47959 bits -= 3; 47960 } else { 47961 n2 = here_bits + 7; 47962 while (bits < n2) { 47963 if (have === 0) { 47964 break inf_leave; 47965 } 47966 have--; 47967 hold += input[next++] << bits; 47968 bits += 8; 47969 } 47970 hold >>>= here_bits; 47971 bits -= here_bits; 47972 len = 0; 47973 copy = 11 + (hold & 127); 47974 hold >>>= 7; 47975 bits -= 7; 47976 } 47977 if (state.have + copy > state.nlen + state.ndist) { 47978 strm.msg = "invalid bit length repeat"; 47979 state.mode = BAD; 47980 break; 47981 } 47982 while (copy--) { 47983 state.lens[state.have++] = len; 47984 } 47985 } 47986 } 47987 if (state.mode === BAD) { 47988 break; 47989 } 47990 if (state.lens[256] === 0) { 47991 strm.msg = "invalid code -- missing end-of-block"; 47992 state.mode = BAD; 47993 break; 47994 } 47995 state.lenbits = 9; 47996 opts = { bits: state.lenbits }; 47997 ret = inflate_table( 47998 LENS, 47999 state.lens, 48000 0, 48001 state.nlen, 48002 state.lencode, 48003 0, 48004 state.work, 48005 opts 48006 ); 48007 state.lenbits = opts.bits; 48008 if (ret) { 48009 strm.msg = "invalid literal/lengths set"; 48010 state.mode = BAD; 48011 break; 48012 } 48013 state.distbits = 6; 48014 state.distcode = state.distdyn; 48015 opts = { bits: state.distbits }; 48016 ret = inflate_table( 48017 DISTS, 48018 state.lens, 48019 state.nlen, 48020 state.ndist, 48021 state.distcode, 48022 0, 48023 state.work, 48024 opts 48025 ); 48026 state.distbits = opts.bits; 48027 if (ret) { 48028 strm.msg = "invalid distances set"; 48029 state.mode = BAD; 48030 break; 48031 } 48032 state.mode = LEN_; 48033 if (flush2 === Z_TREES) { 48034 break inf_leave; 48035 } 48036 /* falls through */ 48037 case LEN_: 48038 state.mode = LEN; 48039 /* falls through */ 48040 case LEN: 48041 if (have >= 6 && left >= 258) { 48042 strm.next_out = put; 48043 strm.avail_out = left; 48044 strm.next_in = next; 48045 strm.avail_in = have; 48046 state.hold = hold; 48047 state.bits = bits; 48048 inflate_fast(strm, _out); 48049 put = strm.next_out; 48050 output = strm.output; 48051 left = strm.avail_out; 48052 next = strm.next_in; 48053 input = strm.input; 48054 have = strm.avail_in; 48055 hold = state.hold; 48056 bits = state.bits; 48057 if (state.mode === TYPE) { 48058 state.back = -1; 48059 } 48060 break; 48061 } 48062 state.back = 0; 48063 for (; ; ) { 48064 here = state.lencode[hold & (1 << state.lenbits) - 1]; 48065 here_bits = here >>> 24; 48066 here_op = here >>> 16 & 255; 48067 here_val = here & 65535; 48068 if (here_bits <= bits) { 48069 break; 48070 } 48071 if (have === 0) { 48072 break inf_leave; 48073 } 48074 have--; 48075 hold += input[next++] << bits; 48076 bits += 8; 48077 } 48078 if (here_op && (here_op & 240) === 0) { 48079 last_bits = here_bits; 48080 last_op = here_op; 48081 last_val = here_val; 48082 for (; ; ) { 48083 here = state.lencode[last_val + ((hold & (1 << last_bits + last_op) - 1) >> last_bits)]; 48084 here_bits = here >>> 24; 48085 here_op = here >>> 16 & 255; 48086 here_val = here & 65535; 48087 if (last_bits + here_bits <= bits) { 48088 break; 48089 } 48090 if (have === 0) { 48091 break inf_leave; 48092 } 48093 have--; 48094 hold += input[next++] << bits; 48095 bits += 8; 48096 } 48097 hold >>>= last_bits; 48098 bits -= last_bits; 48099 state.back += last_bits; 48100 } 48101 hold >>>= here_bits; 48102 bits -= here_bits; 48103 state.back += here_bits; 48104 state.length = here_val; 48105 if (here_op === 0) { 48106 state.mode = LIT; 48107 break; 48108 } 48109 if (here_op & 32) { 48110 state.back = -1; 48111 state.mode = TYPE; 48112 break; 48113 } 48114 if (here_op & 64) { 48115 strm.msg = "invalid literal/length code"; 48116 state.mode = BAD; 48117 break; 48118 } 48119 state.extra = here_op & 15; 48120 state.mode = LENEXT; 48121 /* falls through */ 48122 case LENEXT: 48123 if (state.extra) { 48124 n2 = state.extra; 48125 while (bits < n2) { 48126 if (have === 0) { 48127 break inf_leave; 48128 } 48129 have--; 48130 hold += input[next++] << bits; 48131 bits += 8; 48132 } 48133 state.length += hold & (1 << state.extra) - 1; 48134 hold >>>= state.extra; 48135 bits -= state.extra; 48136 state.back += state.extra; 48137 } 48138 state.was = state.length; 48139 state.mode = DIST; 48140 /* falls through */ 48141 case DIST: 48142 for (; ; ) { 48143 here = state.distcode[hold & (1 << state.distbits) - 1]; 48144 here_bits = here >>> 24; 48145 here_op = here >>> 16 & 255; 48146 here_val = here & 65535; 48147 if (here_bits <= bits) { 48148 break; 48149 } 48150 if (have === 0) { 48151 break inf_leave; 48152 } 48153 have--; 48154 hold += input[next++] << bits; 48155 bits += 8; 48156 } 48157 if ((here_op & 240) === 0) { 48158 last_bits = here_bits; 48159 last_op = here_op; 48160 last_val = here_val; 48161 for (; ; ) { 48162 here = state.distcode[last_val + ((hold & (1 << last_bits + last_op) - 1) >> last_bits)]; 48163 here_bits = here >>> 24; 48164 here_op = here >>> 16 & 255; 48165 here_val = here & 65535; 48166 if (last_bits + here_bits <= bits) { 48167 break; 48168 } 48169 if (have === 0) { 48170 break inf_leave; 48171 } 48172 have--; 48173 hold += input[next++] << bits; 48174 bits += 8; 48175 } 48176 hold >>>= last_bits; 48177 bits -= last_bits; 48178 state.back += last_bits; 48179 } 48180 hold >>>= here_bits; 48181 bits -= here_bits; 48182 state.back += here_bits; 48183 if (here_op & 64) { 48184 strm.msg = "invalid distance code"; 48185 state.mode = BAD; 48186 break; 48187 } 48188 state.offset = here_val; 48189 state.extra = here_op & 15; 48190 state.mode = DISTEXT; 48191 /* falls through */ 48192 case DISTEXT: 48193 if (state.extra) { 48194 n2 = state.extra; 48195 while (bits < n2) { 48196 if (have === 0) { 48197 break inf_leave; 48198 } 48199 have--; 48200 hold += input[next++] << bits; 48201 bits += 8; 48202 } 48203 state.offset += hold & (1 << state.extra) - 1; 48204 hold >>>= state.extra; 48205 bits -= state.extra; 48206 state.back += state.extra; 48207 } 48208 if (state.offset > state.dmax) { 48209 strm.msg = "invalid distance too far back"; 48210 state.mode = BAD; 48211 break; 48212 } 48213 state.mode = MATCH; 48214 /* falls through */ 48215 case MATCH: 48216 if (left === 0) { 48217 break inf_leave; 48218 } 48219 copy = _out - left; 48220 if (state.offset > copy) { 48221 copy = state.offset - copy; 48222 if (copy > state.whave) { 48223 if (state.sane) { 48224 strm.msg = "invalid distance too far back"; 48225 state.mode = BAD; 48226 break; 48227 } 48228 } 48229 if (copy > state.wnext) { 48230 copy -= state.wnext; 48231 from = state.wsize - copy; 48232 } else { 48233 from = state.wnext - copy; 48234 } 48235 if (copy > state.length) { 48236 copy = state.length; 48237 } 48238 from_source = state.window; 48239 } else { 48240 from_source = output; 48241 from = put - state.offset; 48242 copy = state.length; 48243 } 48244 if (copy > left) { 48245 copy = left; 48246 } 48247 left -= copy; 48248 state.length -= copy; 48249 do { 48250 output[put++] = from_source[from++]; 48251 } while (--copy); 48252 if (state.length === 0) { 48253 state.mode = LEN; 48254 } 48255 break; 48256 case LIT: 48257 if (left === 0) { 48258 break inf_leave; 48259 } 48260 output[put++] = state.length; 48261 left--; 48262 state.mode = LEN; 48263 break; 48264 case CHECK: 48265 if (state.wrap) { 48266 while (bits < 32) { 48267 if (have === 0) { 48268 break inf_leave; 48269 } 48270 have--; 48271 hold |= input[next++] << bits; 48272 bits += 8; 48273 } 48274 _out -= left; 48275 strm.total_out += _out; 48276 state.total += _out; 48277 if (_out) { 48278 strm.adler = state.check = /*UPDATE(state.check, put - _out, _out);*/ 48279 state.flags ? crc32( 48280 state.check, 48281 output, 48282 _out, 48283 put - _out 48284 ) : adler32( 48285 state.check, 48286 output, 48287 _out, 48288 put - _out 48289 ); 48290 } 48291 _out = left; 48292 if ((state.flags ? hold : zswap32(hold)) !== state.check) { 48293 strm.msg = "incorrect data check"; 48294 state.mode = BAD; 48295 break; 48296 } 48297 hold = 0; 48298 bits = 0; 48299 } 48300 state.mode = LENGTH; 48301 /* falls through */ 48302 case LENGTH: 48303 if (state.wrap && state.flags) { 48304 while (bits < 32) { 48305 if (have === 0) { 48306 break inf_leave; 48307 } 48308 have--; 48309 hold += input[next++] << bits; 48310 bits += 8; 48311 } 48312 if (hold !== (state.total & 4294967295)) { 48313 strm.msg = "incorrect length check"; 48314 state.mode = BAD; 48315 break; 48316 } 48317 hold = 0; 48318 bits = 0; 48319 } 48320 state.mode = DONE; 48321 /* falls through */ 48322 case DONE: 48323 ret = Z_STREAM_END; 48324 break inf_leave; 48325 case BAD: 48326 ret = Z_DATA_ERROR; 48327 break inf_leave; 48328 case MEM: 48329 return Z_MEM_ERROR; 48330 case SYNC: 48331 /* falls through */ 48332 default: 48333 return Z_STREAM_ERROR; 48334 } 48335 } 48336 strm.next_out = put; 48337 strm.avail_out = left; 48338 strm.next_in = next; 48339 strm.avail_in = have; 48340 state.hold = hold; 48341 state.bits = bits; 48342 if (state.wsize || _out !== strm.avail_out && state.mode < BAD && (state.mode < CHECK || flush2 !== Z_FINISH)) { 48343 if (updatewindow( 48344 strm, 48345 strm.output, 48346 strm.next_out, 48347 _out - strm.avail_out 48348 )) { 48349 state.mode = MEM; 48350 return Z_MEM_ERROR; 48351 } 48352 } 48353 _in -= strm.avail_in; 48354 _out -= strm.avail_out; 48355 strm.total_in += _in; 48356 strm.total_out += _out; 48357 state.total += _out; 48358 if (state.wrap && _out) { 48359 strm.adler = state.check = /*UPDATE(state.check, strm.next_out - _out, _out);*/ 48360 state.flags ? crc32( 48361 state.check, 48362 output, 48363 _out, 48364 strm.next_out - _out 48365 ) : adler32( 48366 state.check, 48367 output, 48368 _out, 48369 strm.next_out - _out 48370 ); 48371 } 48372 strm.data_type = state.bits + (state.last ? 64 : 0) + (state.mode === TYPE ? 128 : 0) + (state.mode === LEN_ || state.mode === COPY_ ? 256 : 0); 48373 if ((_in === 0 && _out === 0 || flush2 === Z_FINISH) && ret === Z_OK) { 48374 ret = Z_BUF_ERROR; 48375 } 48376 return ret; 48377 } 48378 function inflateEnd(strm) { 48379 if (!strm || !strm.state) { 48380 return Z_STREAM_ERROR; 48381 } 48382 var state = strm.state; 48383 if (state.window) { 48384 state.window = null; 48385 } 48386 strm.state = null; 48387 return Z_OK; 48388 } 48389 function inflateGetHeader(strm, head2) { 48390 var state; 48391 if (!strm || !strm.state) { 48392 return Z_STREAM_ERROR; 48393 } 48394 state = strm.state; 48395 if ((state.wrap & 2) === 0) { 48396 return Z_STREAM_ERROR; 48397 } 48398 state.head = head2; 48399 head2.done = false; 48400 return Z_OK; 48401 } 48402 function inflateSetDictionary(strm, dictionary) { 48403 var dictLength = dictionary.length; 48404 var state; 48405 var dictid; 48406 var ret; 48407 if (!strm || !strm.state) { 48408 return Z_STREAM_ERROR; 48409 } 48410 state = strm.state; 48411 if (state.wrap !== 0 && state.mode !== DICT) { 48412 return Z_STREAM_ERROR; 48413 } 48414 if (state.mode === DICT) { 48415 dictid = 1; 48416 dictid = adler32( 48417 dictid, 48418 dictionary, 48419 dictLength, 48420 0 48421 ); 48422 if (dictid !== state.check) { 48423 return Z_DATA_ERROR; 48424 } 48425 } 48426 ret = updatewindow( 48427 strm, 48428 dictionary, 48429 dictLength, 48430 dictLength 48431 ); 48432 if (ret) { 48433 state.mode = MEM; 48434 return Z_MEM_ERROR; 48435 } 48436 state.havedict = 1; 48437 return Z_OK; 48438 } 48439 exports2.inflateReset = inflateReset; 48440 exports2.inflateReset2 = inflateReset2; 48441 exports2.inflateResetKeep = inflateResetKeep; 48442 exports2.inflateInit = inflateInit; 48443 exports2.inflateInit2 = inflateInit2; 48444 exports2.inflate = inflate; 48445 exports2.inflateEnd = inflateEnd; 48446 exports2.inflateGetHeader = inflateGetHeader; 48447 exports2.inflateSetDictionary = inflateSetDictionary; 48448 exports2.inflateInfo = "pako inflate (from Nodeca project)"; 48449 }, 48450 { 48451 "../utils/common": 1, 48452 "./adler32": 3, 48453 "./crc32": 5, 48454 "./inffast": 7, 48455 "./inftrees": 9 48456 } 48457 ], 48458 9: [ 48459 function(require2, module2, exports2) { 48460 "use strict"; 48461 var utils = require2("../utils/common"); 48462 var MAXBITS = 15; 48463 var ENOUGH_LENS = 852; 48464 var ENOUGH_DISTS = 592; 48465 var CODES = 0; 48466 var LENS = 1; 48467 var DISTS = 2; 48468 var lbase = [ 48469 /* Length codes 257..285 base */ 48470 3, 48471 4, 48472 5, 48473 6, 48474 7, 48475 8, 48476 9, 48477 10, 48478 11, 48479 13, 48480 15, 48481 17, 48482 19, 48483 23, 48484 27, 48485 31, 48486 35, 48487 43, 48488 51, 48489 59, 48490 67, 48491 83, 48492 99, 48493 115, 48494 131, 48495 163, 48496 195, 48497 227, 48498 258, 48499 0, 48500 0 48501 ]; 48502 var lext = [ 48503 /* Length codes 257..285 extra */ 48504 16, 48505 16, 48506 16, 48507 16, 48508 16, 48509 16, 48510 16, 48511 16, 48512 17, 48513 17, 48514 17, 48515 17, 48516 18, 48517 18, 48518 18, 48519 18, 48520 19, 48521 19, 48522 19, 48523 19, 48524 20, 48525 20, 48526 20, 48527 20, 48528 21, 48529 21, 48530 21, 48531 21, 48532 16, 48533 72, 48534 78 48535 ]; 48536 var dbase = [ 48537 /* Distance codes 0..29 base */ 48538 1, 48539 2, 48540 3, 48541 4, 48542 5, 48543 7, 48544 9, 48545 13, 48546 17, 48547 25, 48548 33, 48549 49, 48550 65, 48551 97, 48552 129, 48553 193, 48554 257, 48555 385, 48556 513, 48557 769, 48558 1025, 48559 1537, 48560 2049, 48561 3073, 48562 4097, 48563 6145, 48564 8193, 48565 12289, 48566 16385, 48567 24577, 48568 0, 48569 0 48570 ]; 48571 var dext = [ 48572 /* Distance codes 0..29 extra */ 48573 16, 48574 16, 48575 16, 48576 16, 48577 17, 48578 17, 48579 18, 48580 18, 48581 19, 48582 19, 48583 20, 48584 20, 48585 21, 48586 21, 48587 22, 48588 22, 48589 23, 48590 23, 48591 24, 48592 24, 48593 25, 48594 25, 48595 26, 48596 26, 48597 27, 48598 27, 48599 28, 48600 28, 48601 29, 48602 29, 48603 64, 48604 64 48605 ]; 48606 module2.exports = function inflate_table(type, lens, lens_index, codes, table, table_index, work, opts) { 48607 var bits = opts.bits; 48608 var len = 0; 48609 var sym = 0; 48610 var min2 = 0, max2 = 0; 48611 var root = 0; 48612 var curr = 0; 48613 var drop = 0; 48614 var left = 0; 48615 var used = 0; 48616 var huff = 0; 48617 var incr; 48618 var fill; 48619 var low; 48620 var mask; 48621 var next; 48622 var base = null; 48623 var base_index = 0; 48624 var end; 48625 var count = new utils.Buf16(MAXBITS + 1); 48626 var offs = new utils.Buf16(MAXBITS + 1); 48627 var extra = null; 48628 var extra_index = 0; 48629 var here_bits, here_op, here_val; 48630 for (len = 0; len <= MAXBITS; len++) { 48631 count[len] = 0; 48632 } 48633 for (sym = 0; sym < codes; sym++) { 48634 count[lens[lens_index + sym]]++; 48635 } 48636 root = bits; 48637 for (max2 = MAXBITS; max2 >= 1; max2--) { 48638 if (count[max2] !== 0) { 48639 break; 48640 } 48641 } 48642 if (root > max2) { 48643 root = max2; 48644 } 48645 if (max2 === 0) { 48646 table[table_index++] = 1 << 24 | 64 << 16 | 0; 48647 table[table_index++] = 1 << 24 | 64 << 16 | 0; 48648 opts.bits = 1; 48649 return 0; 48650 } 48651 for (min2 = 1; min2 < max2; min2++) { 48652 if (count[min2] !== 0) { 48653 break; 48654 } 48655 } 48656 if (root < min2) { 48657 root = min2; 48658 } 48659 left = 1; 48660 for (len = 1; len <= MAXBITS; len++) { 48661 left <<= 1; 48662 left -= count[len]; 48663 if (left < 0) { 48664 return -1; 48665 } 48666 } 48667 if (left > 0 && (type === CODES || max2 !== 1)) { 48668 return -1; 48669 } 48670 offs[1] = 0; 48671 for (len = 1; len < MAXBITS; len++) { 48672 offs[len + 1] = offs[len] + count[len]; 48673 } 48674 for (sym = 0; sym < codes; sym++) { 48675 if (lens[lens_index + sym] !== 0) { 48676 work[offs[lens[lens_index + sym]]++] = sym; 48677 } 48678 } 48679 if (type === CODES) { 48680 base = extra = work; 48681 end = 19; 48682 } else if (type === LENS) { 48683 base = lbase; 48684 base_index -= 257; 48685 extra = lext; 48686 extra_index -= 257; 48687 end = 256; 48688 } else { 48689 base = dbase; 48690 extra = dext; 48691 end = -1; 48692 } 48693 huff = 0; 48694 sym = 0; 48695 len = min2; 48696 next = table_index; 48697 curr = root; 48698 drop = 0; 48699 low = -1; 48700 used = 1 << root; 48701 mask = used - 1; 48702 if (type === LENS && used > ENOUGH_LENS || type === DISTS && used > ENOUGH_DISTS) { 48703 return 1; 48704 } 48705 for (; ; ) { 48706 here_bits = len - drop; 48707 if (work[sym] < end) { 48708 here_op = 0; 48709 here_val = work[sym]; 48710 } else if (work[sym] > end) { 48711 here_op = extra[extra_index + work[sym]]; 48712 here_val = base[base_index + work[sym]]; 48713 } else { 48714 here_op = 32 + 64; 48715 here_val = 0; 48716 } 48717 incr = 1 << len - drop; 48718 fill = 1 << curr; 48719 min2 = fill; 48720 do { 48721 fill -= incr; 48722 table[next + (huff >> drop) + fill] = here_bits << 24 | here_op << 16 | here_val | 0; 48723 } while (fill !== 0); 48724 incr = 1 << len - 1; 48725 while (huff & incr) { 48726 incr >>= 1; 48727 } 48728 if (incr !== 0) { 48729 huff &= incr - 1; 48730 huff += incr; 48731 } else { 48732 huff = 0; 48733 } 48734 sym++; 48735 if (--count[len] === 0) { 48736 if (len === max2) { 48737 break; 48738 } 48739 len = lens[lens_index + work[sym]]; 48740 } 48741 if (len > root && (huff & mask) !== low) { 48742 if (drop === 0) { 48743 drop = root; 48744 } 48745 next += min2; 48746 curr = len - drop; 48747 left = 1 << curr; 48748 while (curr + drop < max2) { 48749 left -= count[curr + drop]; 48750 if (left <= 0) { 48751 break; 48752 } 48753 curr++; 48754 left <<= 1; 48755 } 48756 used += 1 << curr; 48757 if (type === LENS && used > ENOUGH_LENS || type === DISTS && used > ENOUGH_DISTS) { 48758 return 1; 48759 } 48760 low = huff & mask; 48761 table[low] = root << 24 | curr << 16 | next - table_index | 0; 48762 } 48763 } 48764 if (huff !== 0) { 48765 table[next + huff] = len - drop << 24 | 64 << 16 | 0; 48766 } 48767 opts.bits = root; 48768 return 0; 48769 }; 48770 }, 48771 { "../utils/common": 1 } 48772 ], 48773 10: [ 48774 function(require2, module2, exports2) { 48775 "use strict"; 48776 module2.exports = { 48777 2: "need dictionary", 48778 1: "stream end", 48779 0: "", 48780 "-1": "file error", 48781 "-2": "stream error", 48782 "-3": "data error", 48783 "-4": "insufficient memory", 48784 "-5": "buffer error", 48785 "-6": "incompatible version" 48786 }; 48787 }, 48788 {} 48789 ], 48790 11: [ 48791 function(require2, module2, exports2) { 48792 "use strict"; 48793 function ZStream() { 48794 this.input = null; 48795 this.next_in = 0; 48796 this.avail_in = 0; 48797 this.total_in = 0; 48798 this.output = null; 48799 this.next_out = 0; 48800 this.avail_out = 0; 48801 this.total_out = 0; 48802 this.msg = ""; 48803 this.state = null; 48804 this.data_type = 2; 48805 this.adler = 0; 48806 } 48807 module2.exports = ZStream; 48808 }, 48809 {} 48810 ], 48811 "/lib/inflate.js": [ 48812 function(require2, module2, exports2) { 48813 "use strict"; 48814 var zlib_inflate = require2("./zlib/inflate"); 48815 var utils = require2("./utils/common"); 48816 var strings = require2("./utils/strings"); 48817 var c6 = require2("./zlib/constants"); 48818 var msg = require2("./zlib/messages"); 48819 var ZStream = require2("./zlib/zstream"); 48820 var GZheader = require2("./zlib/gzheader"); 48821 var toString = Object.prototype.toString; 48822 function Inflate(options) { 48823 if (!(this instanceof Inflate)) 48824 return new Inflate(options); 48825 this.options = utils.assign( 48826 { 48827 chunkSize: 16384, 48828 windowBits: 0, 48829 to: "" 48830 }, 48831 options || {} 48832 ); 48833 var opt = this.options; 48834 if (opt.raw && opt.windowBits >= 0 && opt.windowBits < 16) { 48835 opt.windowBits = -opt.windowBits; 48836 if (opt.windowBits === 0) { 48837 opt.windowBits = -15; 48838 } 48839 } 48840 if (opt.windowBits >= 0 && opt.windowBits < 16 && !(options && options.windowBits)) { 48841 opt.windowBits += 32; 48842 } 48843 if (opt.windowBits > 15 && opt.windowBits < 48) { 48844 if ((opt.windowBits & 15) === 0) { 48845 opt.windowBits |= 15; 48846 } 48847 } 48848 this.err = 0; 48849 this.msg = ""; 48850 this.ended = false; 48851 this.chunks = []; 48852 this.strm = new ZStream(); 48853 this.strm.avail_out = 0; 48854 var status = zlib_inflate.inflateInit2( 48855 this.strm, 48856 opt.windowBits 48857 ); 48858 if (status !== c6.Z_OK) { 48859 throw new Error(msg[status]); 48860 } 48861 this.header = new GZheader(); 48862 zlib_inflate.inflateGetHeader(this.strm, this.header); 48863 if (opt.dictionary) { 48864 if (typeof opt.dictionary === "string") { 48865 opt.dictionary = strings.string2buf( 48866 opt.dictionary 48867 ); 48868 } else if (toString.call(opt.dictionary) === "[object ArrayBuffer]") { 48869 opt.dictionary = new Uint8Array( 48870 opt.dictionary 48871 ); 48872 } 48873 if (opt.raw) { 48874 status = zlib_inflate.inflateSetDictionary( 48875 this.strm, 48876 opt.dictionary 48877 ); 48878 if (status !== c6.Z_OK) { 48879 throw new Error(msg[status]); 48880 } 48881 } 48882 } 48883 } 48884 Inflate.prototype.push = function(data, mode) { 48885 var strm = this.strm; 48886 var chunkSize = this.options.chunkSize; 48887 var dictionary = this.options.dictionary; 48888 var status, _mode; 48889 var next_out_utf8, tail, utf8str; 48890 var allowBufError = false; 48891 if (this.ended) { 48892 return false; 48893 } 48894 _mode = mode === ~~mode ? mode : mode === true ? c6.Z_FINISH : c6.Z_NO_FLUSH; 48895 if (typeof data === "string") { 48896 strm.input = strings.binstring2buf(data); 48897 } else if (toString.call(data) === "[object ArrayBuffer]") { 48898 strm.input = new Uint8Array(data); 48899 } else { 48900 strm.input = data; 48901 } 48902 strm.next_in = 0; 48903 strm.avail_in = strm.input.length; 48904 do { 48905 if (strm.avail_out === 0) { 48906 strm.output = new utils.Buf8(chunkSize); 48907 strm.next_out = 0; 48908 strm.avail_out = chunkSize; 48909 } 48910 status = zlib_inflate.inflate( 48911 strm, 48912 c6.Z_NO_FLUSH 48913 ); 48914 if (status === c6.Z_NEED_DICT && dictionary) { 48915 status = zlib_inflate.inflateSetDictionary( 48916 this.strm, 48917 dictionary 48918 ); 48919 } 48920 if (status === c6.Z_BUF_ERROR && allowBufError === true) { 48921 status = c6.Z_OK; 48922 allowBufError = false; 48923 } 48924 if (status !== c6.Z_STREAM_END && status !== c6.Z_OK) { 48925 this.onEnd(status); 48926 this.ended = true; 48927 return false; 48928 } 48929 if (strm.next_out) { 48930 if (strm.avail_out === 0 || status === c6.Z_STREAM_END || strm.avail_in === 0 && (_mode === c6.Z_FINISH || _mode === c6.Z_SYNC_FLUSH)) { 48931 if (this.options.to === "string") { 48932 next_out_utf8 = strings.utf8border( 48933 strm.output, 48934 strm.next_out 48935 ); 48936 tail = strm.next_out - next_out_utf8; 48937 utf8str = strings.buf2string( 48938 strm.output, 48939 next_out_utf8 48940 ); 48941 strm.next_out = tail; 48942 strm.avail_out = chunkSize - tail; 48943 if (tail) { 48944 utils.arraySet( 48945 strm.output, 48946 strm.output, 48947 next_out_utf8, 48948 tail, 48949 0 48950 ); 48951 } 48952 this.onData(utf8str); 48953 } else { 48954 this.onData( 48955 utils.shrinkBuf( 48956 strm.output, 48957 strm.next_out 48958 ) 48959 ); 48960 } 48961 } 48962 } 48963 if (strm.avail_in === 0 && strm.avail_out === 0) { 48964 allowBufError = true; 48965 } 48966 } while ((strm.avail_in > 0 || strm.avail_out === 0) && status !== c6.Z_STREAM_END); 48967 if (status === c6.Z_STREAM_END) { 48968 _mode = c6.Z_FINISH; 48969 } 48970 if (_mode === c6.Z_FINISH) { 48971 status = zlib_inflate.inflateEnd(this.strm); 48972 this.onEnd(status); 48973 this.ended = true; 48974 return status === c6.Z_OK; 48975 } 48976 if (_mode === c6.Z_SYNC_FLUSH) { 48977 this.onEnd(c6.Z_OK); 48978 strm.avail_out = 0; 48979 return true; 48980 } 48981 return true; 48982 }; 48983 Inflate.prototype.onData = function(chunk2) { 48984 this.chunks.push(chunk2); 48985 }; 48986 Inflate.prototype.onEnd = function(status) { 48987 if (status === c6.Z_OK) { 48988 if (this.options.to === "string") { 48989 this.result = this.chunks.join(""); 48990 } else { 48991 this.result = utils.flattenChunks( 48992 this.chunks 48993 ); 48994 } 48995 } 48996 this.chunks = []; 48997 this.err = status; 48998 this.msg = this.strm.msg; 48999 }; 49000 function inflate(input, options) { 49001 var inflator = new Inflate(options); 49002 inflator.push(input, true); 49003 if (inflator.err) { 49004 throw inflator.msg || msg[inflator.err]; 49005 } 49006 return inflator.result; 49007 } 49008 function inflateRaw(input, options) { 49009 options = options || {}; 49010 options.raw = true; 49011 return inflate(input, options); 49012 } 49013 exports2.Inflate = Inflate; 49014 exports2.inflate = inflate; 49015 exports2.inflateRaw = inflateRaw; 49016 exports2.ungzip = inflate; 49017 }, 49018 { 49019 "./utils/common": 1, 49020 "./utils/strings": 2, 49021 "./zlib/constants": 4, 49022 "./zlib/gzheader": 6, 49023 "./zlib/inflate": 8, 49024 "./zlib/messages": 10, 49025 "./zlib/zstream": 11 49026 } 49027 ] 49028 }, 49029 {}, 49030 [] 49031 )("/lib/inflate.js"); 49032 })(); 49033 49034 // packages/global-styles-ui/build-module/font-library/lib/lib-font.browser.mjs 49035 var fetchFunction = globalThis.fetch; 49036 var Event2 = class { 49037 constructor(type, detail = {}, msg) { 49038 this.type = type; 49039 this.detail = detail; 49040 this.msg = msg; 49041 Object.defineProperty(this, `__mayPropagate`, { 49042 enumerable: false, 49043 writable: true 49044 }); 49045 this.__mayPropagate = true; 49046 } 49047 preventDefault() { 49048 } 49049 stopPropagation() { 49050 this.__mayPropagate = false; 49051 } 49052 valueOf() { 49053 return this; 49054 } 49055 toString() { 49056 return this.msg ? `[$this.type} event]: $this.msg}` : `[$this.type} event]`; 49057 } 49058 }; 49059 var EventManager = class { 49060 constructor() { 49061 this.listeners = {}; 49062 } 49063 addEventListener(type, listener, useCapture) { 49064 let bin = this.listeners[type] || []; 49065 if (useCapture) bin.unshift(listener); 49066 else bin.push(listener); 49067 this.listeners[type] = bin; 49068 } 49069 removeEventListener(type, listener) { 49070 let bin = this.listeners[type] || []; 49071 let pos = bin.findIndex((e2) => e2 === listener); 49072 if (pos > -1) { 49073 bin.splice(pos, 1); 49074 this.listeners[type] = bin; 49075 } 49076 } 49077 dispatch(event) { 49078 let bin = this.listeners[event.type]; 49079 if (bin) { 49080 for (let l2 = 0, e2 = bin.length; l2 < e2; l2++) { 49081 if (!event.__mayPropagate) break; 49082 bin[l2](event); 49083 } 49084 } 49085 } 49086 }; 49087 var startDate = (/* @__PURE__ */ new Date(`1904-01-01T00:00:00+0000`)).getTime(); 49088 function asText(data) { 49089 return Array.from(data).map((v2) => String.fromCharCode(v2)).join(``); 49090 } 49091 var Parser = class { 49092 constructor(dict, dataview, name2) { 49093 this.name = (name2 || dict.tag || ``).trim(); 49094 this.length = dict.length; 49095 this.start = dict.offset; 49096 this.offset = 0; 49097 this.data = dataview; 49098 [ 49099 `getInt8`, 49100 `getUint8`, 49101 `getInt16`, 49102 `getUint16`, 49103 `getInt32`, 49104 `getUint32`, 49105 `getBigInt64`, 49106 `getBigUint64` 49107 ].forEach((name3) => { 49108 let fn = name3.replace(/get(Big)?/, "").toLowerCase(); 49109 let increment = parseInt(name3.replace(/[^\d]/g, "")) / 8; 49110 Object.defineProperty(this, fn, { 49111 get: () => this.getValue(name3, increment) 49112 }); 49113 }); 49114 } 49115 get currentPosition() { 49116 return this.start + this.offset; 49117 } 49118 set currentPosition(position) { 49119 this.start = position; 49120 this.offset = 0; 49121 } 49122 skip(n2 = 0, bits = 8) { 49123 this.offset += n2 * bits / 8; 49124 } 49125 getValue(type, increment) { 49126 let pos = this.start + this.offset; 49127 this.offset += increment; 49128 try { 49129 return this.data[type](pos); 49130 } catch (e2) { 49131 console.error(`parser`, type, increment, this); 49132 console.error(`parser`, this.start, this.offset); 49133 throw e2; 49134 } 49135 } 49136 flags(n2) { 49137 if (n2 === 8 || n2 === 16 || n2 === 32 || n2 === 64) { 49138 return this[`uint$n2}`].toString(2).padStart(n2, 0).split(``).map((v2) => v2 === "1"); 49139 } 49140 console.error( 49141 `Error parsing flags: flag types can only be 1, 2, 4, or 8 bytes long` 49142 ); 49143 console.trace(); 49144 } 49145 get tag() { 49146 const t3 = this.uint32; 49147 return asText([ 49148 t3 >> 24 & 255, 49149 t3 >> 16 & 255, 49150 t3 >> 8 & 255, 49151 t3 & 255 49152 ]); 49153 } 49154 get fixed() { 49155 let major = this.int16; 49156 let minor = Math.round(1e3 * this.uint16 / 65356); 49157 return major + minor / 1e3; 49158 } 49159 get legacyFixed() { 49160 let major = this.uint16; 49161 let minor = this.uint16.toString(16).padStart(4, 0); 49162 return parseFloat(`$major}.$minor}`); 49163 } 49164 get uint24() { 49165 return (this.uint8 << 16) + (this.uint8 << 8) + this.uint8; 49166 } 49167 get uint128() { 49168 let value = 0; 49169 for (let i2 = 0; i2 < 5; i2++) { 49170 let byte = this.uint8; 49171 value = value * 128 + (byte & 127); 49172 if (byte < 128) break; 49173 } 49174 return value; 49175 } 49176 get longdatetime() { 49177 return new Date(startDate + 1e3 * parseInt(this.int64.toString())); 49178 } 49179 get fword() { 49180 return this.int16; 49181 } 49182 get ufword() { 49183 return this.uint16; 49184 } 49185 get Offset16() { 49186 return this.uint16; 49187 } 49188 get Offset32() { 49189 return this.uint32; 49190 } 49191 get F2DOT14() { 49192 const bits = p.uint16; 49193 const integer = [0, 1, -2, -1][bits >> 14]; 49194 const fraction = bits & 16383; 49195 return integer + fraction / 16384; 49196 } 49197 verifyLength() { 49198 if (this.offset != this.length) { 49199 console.error( 49200 `unexpected parsed table size ($this.offset}) for "$this.name}" (expected $this.length})` 49201 ); 49202 } 49203 } 49204 readBytes(n2 = 0, position = 0, bits = 8, signed = false) { 49205 n2 = n2 || this.length; 49206 if (n2 === 0) return []; 49207 if (position) this.currentPosition = position; 49208 const fn = `$signed ? `` : `u`}int$bits}`, slice = []; 49209 while (n2--) slice.push(this[fn]); 49210 return slice; 49211 } 49212 }; 49213 var ParsedData = class { 49214 constructor(parser) { 49215 const pGetter = { enumerable: false, get: () => parser }; 49216 Object.defineProperty(this, `parser`, pGetter); 49217 const start2 = parser.currentPosition; 49218 const startGetter = { enumerable: false, get: () => start2 }; 49219 Object.defineProperty(this, `start`, startGetter); 49220 } 49221 load(struct) { 49222 Object.keys(struct).forEach((p22) => { 49223 let props = Object.getOwnPropertyDescriptor(struct, p22); 49224 if (props.get) { 49225 this[p22] = props.get.bind(this); 49226 } else if (props.value !== void 0) { 49227 this[p22] = props.value; 49228 } 49229 }); 49230 if (this.parser.length) { 49231 this.parser.verifyLength(); 49232 } 49233 } 49234 }; 49235 var SimpleTable = class extends ParsedData { 49236 constructor(dict, dataview, name2) { 49237 const { parser, start: start2 } = super( 49238 new Parser(dict, dataview, name2) 49239 ); 49240 const pGetter = { enumerable: false, get: () => parser }; 49241 Object.defineProperty(this, `p`, pGetter); 49242 const startGetter = { enumerable: false, get: () => start2 }; 49243 Object.defineProperty(this, `tableStart`, startGetter); 49244 } 49245 }; 49246 function lazy$1(object, property, getter) { 49247 let val; 49248 Object.defineProperty(object, property, { 49249 get: () => { 49250 if (val) return val; 49251 val = getter(); 49252 return val; 49253 }, 49254 enumerable: true 49255 }); 49256 } 49257 var SFNT = class extends SimpleTable { 49258 constructor(font2, dataview, createTable2) { 49259 const { p: p22 } = super({ offset: 0, length: 12 }, dataview, `sfnt`); 49260 this.version = p22.uint32; 49261 this.numTables = p22.uint16; 49262 this.searchRange = p22.uint16; 49263 this.entrySelector = p22.uint16; 49264 this.rangeShift = p22.uint16; 49265 p22.verifyLength(); 49266 this.directory = [...new Array(this.numTables)].map( 49267 (_) => new TableRecord(p22) 49268 ); 49269 this.tables = {}; 49270 this.directory.forEach((entry) => { 49271 const getter = () => createTable2( 49272 this.tables, 49273 { 49274 tag: entry.tag, 49275 offset: entry.offset, 49276 length: entry.length 49277 }, 49278 dataview 49279 ); 49280 lazy$1(this.tables, entry.tag.trim(), getter); 49281 }); 49282 } 49283 }; 49284 var TableRecord = class { 49285 constructor(p22) { 49286 this.tag = p22.tag; 49287 this.checksum = p22.uint32; 49288 this.offset = p22.uint32; 49289 this.length = p22.uint32; 49290 } 49291 }; 49292 var gzipDecode = inflate_default.inflate || void 0; 49293 var nativeGzipDecode = void 0; 49294 var WOFF$1 = class extends SimpleTable { 49295 constructor(font2, dataview, createTable2) { 49296 const { p: p22 } = super({ offset: 0, length: 44 }, dataview, `woff`); 49297 this.signature = p22.tag; 49298 this.flavor = p22.uint32; 49299 this.length = p22.uint32; 49300 this.numTables = p22.uint16; 49301 p22.uint16; 49302 this.totalSfntSize = p22.uint32; 49303 this.majorVersion = p22.uint16; 49304 this.minorVersion = p22.uint16; 49305 this.metaOffset = p22.uint32; 49306 this.metaLength = p22.uint32; 49307 this.metaOrigLength = p22.uint32; 49308 this.privOffset = p22.uint32; 49309 this.privLength = p22.uint32; 49310 p22.verifyLength(); 49311 this.directory = [...new Array(this.numTables)].map( 49312 (_) => new WoffTableDirectoryEntry(p22) 49313 ); 49314 buildWoffLazyLookups(this, dataview, createTable2); 49315 } 49316 }; 49317 var WoffTableDirectoryEntry = class { 49318 constructor(p22) { 49319 this.tag = p22.tag; 49320 this.offset = p22.uint32; 49321 this.compLength = p22.uint32; 49322 this.origLength = p22.uint32; 49323 this.origChecksum = p22.uint32; 49324 } 49325 }; 49326 function buildWoffLazyLookups(woff, dataview, createTable2) { 49327 woff.tables = {}; 49328 woff.directory.forEach((entry) => { 49329 lazy$1(woff.tables, entry.tag.trim(), () => { 49330 let offset4 = 0; 49331 let view = dataview; 49332 if (entry.compLength !== entry.origLength) { 49333 const data = dataview.buffer.slice( 49334 entry.offset, 49335 entry.offset + entry.compLength 49336 ); 49337 let unpacked; 49338 if (gzipDecode) { 49339 unpacked = gzipDecode(new Uint8Array(data)); 49340 } else if (nativeGzipDecode) { 49341 unpacked = nativeGzipDecode(new Uint8Array(data)); 49342 } else { 49343 const msg = `no brotli decoder available to decode WOFF2 font`; 49344 if (font.onerror) font.onerror(msg); 49345 throw new Error(msg); 49346 } 49347 view = new DataView(unpacked.buffer); 49348 } else { 49349 offset4 = entry.offset; 49350 } 49351 return createTable2( 49352 woff.tables, 49353 { tag: entry.tag, offset: offset4, length: entry.origLength }, 49354 view 49355 ); 49356 }); 49357 }); 49358 } 49359 var brotliDecode = unbrotli_default; 49360 var nativeBrotliDecode = void 0; 49361 var WOFF2$1 = class extends SimpleTable { 49362 constructor(font2, dataview, createTable2) { 49363 const { p: p22 } = super({ offset: 0, length: 48 }, dataview, `woff2`); 49364 this.signature = p22.tag; 49365 this.flavor = p22.uint32; 49366 this.length = p22.uint32; 49367 this.numTables = p22.uint16; 49368 p22.uint16; 49369 this.totalSfntSize = p22.uint32; 49370 this.totalCompressedSize = p22.uint32; 49371 this.majorVersion = p22.uint16; 49372 this.minorVersion = p22.uint16; 49373 this.metaOffset = p22.uint32; 49374 this.metaLength = p22.uint32; 49375 this.metaOrigLength = p22.uint32; 49376 this.privOffset = p22.uint32; 49377 this.privLength = p22.uint32; 49378 p22.verifyLength(); 49379 this.directory = [...new Array(this.numTables)].map( 49380 (_) => new Woff2TableDirectoryEntry(p22) 49381 ); 49382 let dictOffset = p22.currentPosition; 49383 this.directory[0].offset = 0; 49384 this.directory.forEach((e2, i2) => { 49385 let next = this.directory[i2 + 1]; 49386 if (next) { 49387 next.offset = e2.offset + (e2.transformLength !== void 0 ? e2.transformLength : e2.origLength); 49388 } 49389 }); 49390 let decoded; 49391 let buffer = dataview.buffer.slice(dictOffset); 49392 if (brotliDecode) { 49393 decoded = brotliDecode(new Uint8Array(buffer)); 49394 } else if (nativeBrotliDecode) { 49395 decoded = new Uint8Array(nativeBrotliDecode(buffer)); 49396 } else { 49397 const msg = `no brotli decoder available to decode WOFF2 font`; 49398 if (font2.onerror) font2.onerror(msg); 49399 throw new Error(msg); 49400 } 49401 buildWoff2LazyLookups(this, decoded, createTable2); 49402 } 49403 }; 49404 var Woff2TableDirectoryEntry = class { 49405 constructor(p22) { 49406 this.flags = p22.uint8; 49407 const tagNumber = this.tagNumber = this.flags & 63; 49408 if (tagNumber === 63) { 49409 this.tag = p22.tag; 49410 } else { 49411 this.tag = getWOFF2Tag(tagNumber); 49412 } 49413 const transformVersion = this.transformVersion = (this.flags & 192) >> 6; 49414 let hasTransforms = transformVersion !== 0; 49415 if (this.tag === `glyf` || this.tag === `loca`) { 49416 hasTransforms = this.transformVersion !== 3; 49417 } 49418 this.origLength = p22.uint128; 49419 if (hasTransforms) { 49420 this.transformLength = p22.uint128; 49421 } 49422 } 49423 }; 49424 function buildWoff2LazyLookups(woff2, decoded, createTable2) { 49425 woff2.tables = {}; 49426 woff2.directory.forEach((entry) => { 49427 lazy$1(woff2.tables, entry.tag.trim(), () => { 49428 const start2 = entry.offset; 49429 const end = start2 + (entry.transformLength ? entry.transformLength : entry.origLength); 49430 const data = new DataView(decoded.slice(start2, end).buffer); 49431 try { 49432 return createTable2( 49433 woff2.tables, 49434 { tag: entry.tag, offset: 0, length: entry.origLength }, 49435 data 49436 ); 49437 } catch (e2) { 49438 console.error(e2); 49439 } 49440 }); 49441 }); 49442 } 49443 function getWOFF2Tag(flag) { 49444 return [ 49445 `cmap`, 49446 `head`, 49447 `hhea`, 49448 `hmtx`, 49449 `maxp`, 49450 `name`, 49451 `OS/2`, 49452 `post`, 49453 `cvt `, 49454 `fpgm`, 49455 `glyf`, 49456 `loca`, 49457 `prep`, 49458 `CFF `, 49459 `VORG`, 49460 `EBDT`, 49461 `EBLC`, 49462 `gasp`, 49463 `hdmx`, 49464 `kern`, 49465 `LTSH`, 49466 `PCLT`, 49467 `VDMX`, 49468 `vhea`, 49469 `vmtx`, 49470 `BASE`, 49471 `GDEF`, 49472 `GPOS`, 49473 `GSUB`, 49474 `EBSC`, 49475 `JSTF`, 49476 `MATH`, 49477 `CBDT`, 49478 `CBLC`, 49479 `COLR`, 49480 `CPAL`, 49481 `SVG `, 49482 `sbix`, 49483 `acnt`, 49484 `avar`, 49485 `bdat`, 49486 `bloc`, 49487 `bsln`, 49488 `cvar`, 49489 `fdsc`, 49490 `feat`, 49491 `fmtx`, 49492 `fvar`, 49493 `gvar`, 49494 `hsty`, 49495 `just`, 49496 `lcar`, 49497 `mort`, 49498 `morx`, 49499 `opbd`, 49500 `prop`, 49501 `trak`, 49502 `Zapf`, 49503 `Silf`, 49504 `Glat`, 49505 `Gloc`, 49506 `Feat`, 49507 `Sill` 49508 ][flag & 63]; 49509 } 49510 var tableClasses = {}; 49511 var tableClassesLoaded = false; 49512 Promise.all([ 49513 Promise.resolve().then(function() { 49514 return cmap$1; 49515 }), 49516 Promise.resolve().then(function() { 49517 return head$1; 49518 }), 49519 Promise.resolve().then(function() { 49520 return hhea$1; 49521 }), 49522 Promise.resolve().then(function() { 49523 return hmtx$1; 49524 }), 49525 Promise.resolve().then(function() { 49526 return maxp$1; 49527 }), 49528 Promise.resolve().then(function() { 49529 return name$1; 49530 }), 49531 Promise.resolve().then(function() { 49532 return OS2$1; 49533 }), 49534 Promise.resolve().then(function() { 49535 return post$1; 49536 }), 49537 Promise.resolve().then(function() { 49538 return BASE$1; 49539 }), 49540 Promise.resolve().then(function() { 49541 return GDEF$1; 49542 }), 49543 Promise.resolve().then(function() { 49544 return GSUB$1; 49545 }), 49546 Promise.resolve().then(function() { 49547 return GPOS$1; 49548 }), 49549 Promise.resolve().then(function() { 49550 return SVG$1; 49551 }), 49552 Promise.resolve().then(function() { 49553 return fvar$1; 49554 }), 49555 Promise.resolve().then(function() { 49556 return cvt$1; 49557 }), 49558 Promise.resolve().then(function() { 49559 return fpgm$1; 49560 }), 49561 Promise.resolve().then(function() { 49562 return gasp$1; 49563 }), 49564 Promise.resolve().then(function() { 49565 return glyf$1; 49566 }), 49567 Promise.resolve().then(function() { 49568 return loca$1; 49569 }), 49570 Promise.resolve().then(function() { 49571 return prep$1; 49572 }), 49573 Promise.resolve().then(function() { 49574 return CFF$1; 49575 }), 49576 Promise.resolve().then(function() { 49577 return CFF2$1; 49578 }), 49579 Promise.resolve().then(function() { 49580 return VORG$1; 49581 }), 49582 Promise.resolve().then(function() { 49583 return EBLC$1; 49584 }), 49585 Promise.resolve().then(function() { 49586 return EBDT$1; 49587 }), 49588 Promise.resolve().then(function() { 49589 return EBSC$1; 49590 }), 49591 Promise.resolve().then(function() { 49592 return CBLC$1; 49593 }), 49594 Promise.resolve().then(function() { 49595 return CBDT$1; 49596 }), 49597 Promise.resolve().then(function() { 49598 return sbix$1; 49599 }), 49600 Promise.resolve().then(function() { 49601 return COLR$1; 49602 }), 49603 Promise.resolve().then(function() { 49604 return CPAL$1; 49605 }), 49606 Promise.resolve().then(function() { 49607 return DSIG$1; 49608 }), 49609 Promise.resolve().then(function() { 49610 return hdmx$1; 49611 }), 49612 Promise.resolve().then(function() { 49613 return kern$1; 49614 }), 49615 Promise.resolve().then(function() { 49616 return LTSH$1; 49617 }), 49618 Promise.resolve().then(function() { 49619 return MERG$1; 49620 }), 49621 Promise.resolve().then(function() { 49622 return meta$1; 49623 }), 49624 Promise.resolve().then(function() { 49625 return PCLT$1; 49626 }), 49627 Promise.resolve().then(function() { 49628 return VDMX$1; 49629 }), 49630 Promise.resolve().then(function() { 49631 return vhea$1; 49632 }), 49633 Promise.resolve().then(function() { 49634 return vmtx$1; 49635 }) 49636 ]).then((data) => { 49637 data.forEach((e2) => { 49638 let name2 = Object.keys(e2)[0]; 49639 tableClasses[name2] = e2[name2]; 49640 }); 49641 tableClassesLoaded = true; 49642 }); 49643 function createTable(tables, dict, dataview) { 49644 let name2 = dict.tag.replace(/[^\w\d]/g, ``); 49645 let Type = tableClasses[name2]; 49646 if (Type) return new Type(dict, dataview, tables); 49647 console.warn( 49648 `lib-font has no definition for $name2}. The table was skipped.` 49649 ); 49650 return {}; 49651 } 49652 function loadTableClasses() { 49653 let count = 0; 49654 function checkLoaded(resolve, reject) { 49655 if (!tableClassesLoaded) { 49656 if (count > 10) { 49657 return reject(new Error(`loading took too long`)); 49658 } 49659 count++; 49660 return setTimeout(() => checkLoaded(resolve), 250); 49661 } 49662 resolve(createTable); 49663 } 49664 return new Promise((resolve, reject) => checkLoaded(resolve)); 49665 } 49666 function getFontCSSFormat(path, errorOnStyle) { 49667 let pos = path.lastIndexOf(`.`); 49668 let ext = (path.substring(pos + 1) || ``).toLowerCase(); 49669 let format6 = { 49670 ttf: `truetype`, 49671 otf: `opentype`, 49672 woff: `woff`, 49673 woff2: `woff2` 49674 }[ext]; 49675 if (format6) return format6; 49676 let msg = { 49677 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.`, 49678 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.`, 49679 fon: `The .fon format is not supported: this is an ancient Windows bitmap font format.`, 49680 ttc: `Based on the current CSS specification, font collections are not (yet?) supported.` 49681 }[ext]; 49682 if (!msg) msg = `$path} is not a known webfont format.`; 49683 if (errorOnStyle) { 49684 throw new Error(msg); 49685 } else { 49686 console.warn(`Could not load font: $msg}`); 49687 } 49688 } 49689 async function setupFontFace(name2, url, options = {}) { 49690 if (!globalThis.document) return; 49691 let format6 = getFontCSSFormat(url, options.errorOnStyle); 49692 if (!format6) return; 49693 let style = document.createElement(`style`); 49694 style.className = `injected-by-Font-js`; 49695 let rules = []; 49696 if (options.styleRules) { 49697 rules = Object.entries(options.styleRules).map( 49698 ([key, value]) => `$key}: $value};` 49699 ); 49700 } 49701 style.textContent = ` 49702 @font-face { 49703 font-family: "$name2}"; 49704 $rules.join( 49705 ` 49706 ` 49707 )} 49708 src: url("$url}") format("$format6}"); 49709 }`; 49710 globalThis.document.head.appendChild(style); 49711 return style; 49712 } 49713 var TTF = [0, 1, 0, 0]; 49714 var OTF = [79, 84, 84, 79]; 49715 var WOFF = [119, 79, 70, 70]; 49716 var WOFF2 = [119, 79, 70, 50]; 49717 function match2(ar1, ar2) { 49718 if (ar1.length !== ar2.length) return; 49719 for (let i2 = 0; i2 < ar1.length; i2++) { 49720 if (ar1[i2] !== ar2[i2]) return; 49721 } 49722 return true; 49723 } 49724 function validFontFormat(dataview) { 49725 const LEAD_BYTES = [ 49726 dataview.getUint8(0), 49727 dataview.getUint8(1), 49728 dataview.getUint8(2), 49729 dataview.getUint8(3) 49730 ]; 49731 if (match2(LEAD_BYTES, TTF) || match2(LEAD_BYTES, OTF)) return `SFNT`; 49732 if (match2(LEAD_BYTES, WOFF)) return `WOFF`; 49733 if (match2(LEAD_BYTES, WOFF2)) return `WOFF2`; 49734 } 49735 function checkFetchResponseStatus(response) { 49736 if (!response.ok) { 49737 throw new Error( 49738 `HTTP $response.status} - $response.statusText}` 49739 ); 49740 } 49741 return response; 49742 } 49743 var Font = class extends EventManager { 49744 constructor(name2, options = {}) { 49745 super(); 49746 this.name = name2; 49747 this.options = options; 49748 this.metrics = false; 49749 } 49750 get src() { 49751 return this.__src; 49752 } 49753 set src(src) { 49754 this.__src = src; 49755 (async () => { 49756 if (globalThis.document && !this.options.skipStyleSheet) { 49757 await setupFontFace(this.name, src, this.options); 49758 } 49759 this.loadFont(src); 49760 })(); 49761 } 49762 async loadFont(url, filename) { 49763 fetch(url).then( 49764 (response) => checkFetchResponseStatus(response) && response.arrayBuffer() 49765 ).then( 49766 (buffer) => this.fromDataBuffer(buffer, filename || url) 49767 ).catch((err) => { 49768 const evt = new Event2( 49769 `error`, 49770 err, 49771 `Failed to load font at $filename || url}` 49772 ); 49773 this.dispatch(evt); 49774 if (this.onerror) this.onerror(evt); 49775 }); 49776 } 49777 async fromDataBuffer(buffer, filenameOrUrL) { 49778 this.fontData = new DataView(buffer); 49779 let type = validFontFormat(this.fontData); 49780 if (!type) { 49781 throw new Error( 49782 `$filenameOrUrL} is either an unsupported font format, or not a font at all.` 49783 ); 49784 } 49785 await this.parseBasicData(type); 49786 const evt = new Event2("load", { font: this }); 49787 this.dispatch(evt); 49788 if (this.onload) this.onload(evt); 49789 } 49790 async parseBasicData(type) { 49791 return loadTableClasses().then((createTable2) => { 49792 if (type === `SFNT`) { 49793 this.opentype = new SFNT(this, this.fontData, createTable2); 49794 } 49795 if (type === `WOFF`) { 49796 this.opentype = new WOFF$1(this, this.fontData, createTable2); 49797 } 49798 if (type === `WOFF2`) { 49799 this.opentype = new WOFF2$1(this, this.fontData, createTable2); 49800 } 49801 return this.opentype; 49802 }); 49803 } 49804 getGlyphId(char) { 49805 return this.opentype.tables.cmap.getGlyphId(char); 49806 } 49807 reverse(glyphid) { 49808 return this.opentype.tables.cmap.reverse(glyphid); 49809 } 49810 supports(char) { 49811 return this.getGlyphId(char) !== 0; 49812 } 49813 supportsVariation(variation) { 49814 return this.opentype.tables.cmap.supportsVariation(variation) !== false; 49815 } 49816 measureText(text, size4 = 16) { 49817 if (this.__unloaded) 49818 throw new Error( 49819 "Cannot measure text: font was unloaded. Please reload before calling measureText()" 49820 ); 49821 let d2 = document.createElement("div"); 49822 d2.textContent = text; 49823 d2.style.fontFamily = this.name; 49824 d2.style.fontSize = `$size4}px`; 49825 d2.style.color = `transparent`; 49826 d2.style.background = `transparent`; 49827 d2.style.top = `0`; 49828 d2.style.left = `0`; 49829 d2.style.position = `absolute`; 49830 document.body.appendChild(d2); 49831 let bbox = d2.getBoundingClientRect(); 49832 document.body.removeChild(d2); 49833 const OS22 = this.opentype.tables["OS/2"]; 49834 bbox.fontSize = size4; 49835 bbox.ascender = OS22.sTypoAscender; 49836 bbox.descender = OS22.sTypoDescender; 49837 return bbox; 49838 } 49839 unload() { 49840 if (this.styleElement.parentNode) { 49841 this.styleElement.parentNode.removeElement(this.styleElement); 49842 const evt = new Event2("unload", { font: this }); 49843 this.dispatch(evt); 49844 if (this.onunload) this.onunload(evt); 49845 } 49846 this._unloaded = true; 49847 } 49848 load() { 49849 if (this.__unloaded) { 49850 delete this.__unloaded; 49851 document.head.appendChild(this.styleElement); 49852 const evt = new Event2("load", { font: this }); 49853 this.dispatch(evt); 49854 if (this.onload) this.onload(evt); 49855 } 49856 } 49857 }; 49858 globalThis.Font = Font; 49859 var Subtable = class extends ParsedData { 49860 constructor(p22, plaformID, encodingID) { 49861 super(p22); 49862 this.plaformID = plaformID; 49863 this.encodingID = encodingID; 49864 } 49865 }; 49866 var Format0 = class extends Subtable { 49867 constructor(p22, platformID, encodingID) { 49868 super(p22, platformID, encodingID); 49869 this.format = 0; 49870 this.length = p22.uint16; 49871 this.language = p22.uint16; 49872 this.glyphIdArray = [...new Array(256)].map((_) => p22.uint8); 49873 } 49874 supports(charCode) { 49875 if (charCode.charCodeAt) { 49876 charCode = -1; 49877 console.warn( 49878 `supports(character) not implemented for cmap subtable format 0. only supports(id) is implemented.` 49879 ); 49880 } 49881 return 0 <= charCode && charCode <= 255; 49882 } 49883 reverse(glyphID) { 49884 console.warn(`reverse not implemented for cmap subtable format 0`); 49885 return {}; 49886 } 49887 getSupportedCharCodes() { 49888 return [{ start: 1, end: 256 }]; 49889 } 49890 }; 49891 var Format2 = class extends Subtable { 49892 constructor(p22, platformID, encodingID) { 49893 super(p22, platformID, encodingID); 49894 this.format = 2; 49895 this.length = p22.uint16; 49896 this.language = p22.uint16; 49897 this.subHeaderKeys = [...new Array(256)].map((_) => p22.uint16); 49898 const subHeaderCount = Math.max(...this.subHeaderKeys); 49899 const subHeaderOffset = p22.currentPosition; 49900 lazy$1(this, `subHeaders`, () => { 49901 p22.currentPosition = subHeaderOffset; 49902 return [...new Array(subHeaderCount)].map( 49903 (_) => new SubHeader(p22) 49904 ); 49905 }); 49906 const glyphIndexOffset = subHeaderOffset + subHeaderCount * 8; 49907 lazy$1(this, `glyphIndexArray`, () => { 49908 p22.currentPosition = glyphIndexOffset; 49909 return [...new Array(subHeaderCount)].map((_) => p22.uint16); 49910 }); 49911 } 49912 supports(charCode) { 49913 if (charCode.charCodeAt) { 49914 charCode = -1; 49915 console.warn( 49916 `supports(character) not implemented for cmap subtable format 2. only supports(id) is implemented.` 49917 ); 49918 } 49919 const low = charCode && 255; 49920 const high = charCode && 65280; 49921 const subHeaderKey = this.subHeaders[high]; 49922 const subheader = this.subHeaders[subHeaderKey]; 49923 const first = subheader.firstCode; 49924 const last = first + subheader.entryCount; 49925 return first <= low && low <= last; 49926 } 49927 reverse(glyphID) { 49928 console.warn(`reverse not implemented for cmap subtable format 2`); 49929 return {}; 49930 } 49931 getSupportedCharCodes(preservePropNames = false) { 49932 if (preservePropNames) { 49933 return this.subHeaders.map((h2) => ({ 49934 firstCode: h2.firstCode, 49935 lastCode: h2.lastCode 49936 })); 49937 } 49938 return this.subHeaders.map((h2) => ({ 49939 start: h2.firstCode, 49940 end: h2.lastCode 49941 })); 49942 } 49943 }; 49944 var SubHeader = class { 49945 constructor(p22) { 49946 this.firstCode = p22.uint16; 49947 this.entryCount = p22.uint16; 49948 this.lastCode = this.first + this.entryCount; 49949 this.idDelta = p22.int16; 49950 this.idRangeOffset = p22.uint16; 49951 } 49952 }; 49953 var Format4 = class extends Subtable { 49954 constructor(p22, platformID, encodingID) { 49955 super(p22, platformID, encodingID); 49956 this.format = 4; 49957 this.length = p22.uint16; 49958 this.language = p22.uint16; 49959 this.segCountX2 = p22.uint16; 49960 this.segCount = this.segCountX2 / 2; 49961 this.searchRange = p22.uint16; 49962 this.entrySelector = p22.uint16; 49963 this.rangeShift = p22.uint16; 49964 const endCodePosition = p22.currentPosition; 49965 lazy$1( 49966 this, 49967 `endCode`, 49968 () => p22.readBytes(this.segCount, endCodePosition, 16) 49969 ); 49970 const startCodePosition = endCodePosition + 2 + this.segCountX2; 49971 lazy$1( 49972 this, 49973 `startCode`, 49974 () => p22.readBytes(this.segCount, startCodePosition, 16) 49975 ); 49976 const idDeltaPosition = startCodePosition + this.segCountX2; 49977 lazy$1( 49978 this, 49979 `idDelta`, 49980 () => p22.readBytes(this.segCount, idDeltaPosition, 16, true) 49981 ); 49982 const idRangePosition = idDeltaPosition + this.segCountX2; 49983 lazy$1( 49984 this, 49985 `idRangeOffset`, 49986 () => p22.readBytes(this.segCount, idRangePosition, 16) 49987 ); 49988 const glyphIdArrayPosition = idRangePosition + this.segCountX2; 49989 const glyphIdArrayLength = this.length - (glyphIdArrayPosition - this.tableStart); 49990 lazy$1( 49991 this, 49992 `glyphIdArray`, 49993 () => p22.readBytes(glyphIdArrayLength, glyphIdArrayPosition, 16) 49994 ); 49995 lazy$1( 49996 this, 49997 `segments`, 49998 () => this.buildSegments(idRangePosition, glyphIdArrayPosition, p22) 49999 ); 50000 } 50001 buildSegments(idRangePosition, glyphIdArrayPosition, p22) { 50002 const build = (_, i2) => { 50003 let startCode = this.startCode[i2], endCode = this.endCode[i2], idDelta = this.idDelta[i2], idRangeOffset = this.idRangeOffset[i2], idRangeOffsetPointer = idRangePosition + 2 * i2, glyphIDs = []; 50004 if (idRangeOffset === 0) { 50005 for (let i22 = startCode + idDelta, e2 = endCode + idDelta; i22 <= e2; i22++) { 50006 glyphIDs.push(i22); 50007 } 50008 } else { 50009 for (let i22 = 0, e2 = endCode - startCode; i22 <= e2; i22++) { 50010 p22.currentPosition = idRangeOffsetPointer + idRangeOffset + i22 * 2; 50011 glyphIDs.push(p22.uint16); 50012 } 50013 } 50014 return { 50015 startCode, 50016 endCode, 50017 idDelta, 50018 idRangeOffset, 50019 glyphIDs 50020 }; 50021 }; 50022 return [...new Array(this.segCount)].map(build); 50023 } 50024 reverse(glyphID) { 50025 let s2 = this.segments.find((v2) => v2.glyphIDs.includes(glyphID)); 50026 if (!s2) return {}; 50027 const code = s2.startCode + s2.glyphIDs.indexOf(glyphID); 50028 return { code, unicode: String.fromCodePoint(code) }; 50029 } 50030 getGlyphId(charCode) { 50031 if (charCode.charCodeAt) charCode = charCode.charCodeAt(0); 50032 if (55296 <= charCode && charCode <= 57343) return 0; 50033 if ((charCode & 65534) === 65534 || (charCode & 65535) === 65535) 50034 return 0; 50035 let segment = this.segments.find( 50036 (s2) => s2.startCode <= charCode && charCode <= s2.endCode 50037 ); 50038 if (!segment) return 0; 50039 return segment.glyphIDs[charCode - segment.startCode]; 50040 } 50041 supports(charCode) { 50042 return this.getGlyphId(charCode) !== 0; 50043 } 50044 getSupportedCharCodes(preservePropNames = false) { 50045 if (preservePropNames) return this.segments; 50046 return this.segments.map((v2) => ({ 50047 start: v2.startCode, 50048 end: v2.endCode 50049 })); 50050 } 50051 }; 50052 var Format6 = class extends Subtable { 50053 constructor(p22, platformID, encodingID) { 50054 super(p22, platformID, encodingID); 50055 this.format = 6; 50056 this.length = p22.uint16; 50057 this.language = p22.uint16; 50058 this.firstCode = p22.uint16; 50059 this.entryCount = p22.uint16; 50060 this.lastCode = this.firstCode + this.entryCount - 1; 50061 const getter = () => [...new Array(this.entryCount)].map((_) => p22.uint16); 50062 lazy$1(this, `glyphIdArray`, getter); 50063 } 50064 supports(charCode) { 50065 if (charCode.charCodeAt) { 50066 charCode = -1; 50067 console.warn( 50068 `supports(character) not implemented for cmap subtable format 6. only supports(id) is implemented.` 50069 ); 50070 } 50071 if (charCode < this.firstCode) return {}; 50072 if (charCode > this.firstCode + this.entryCount) return {}; 50073 const code = charCode - this.firstCode; 50074 return { code, unicode: String.fromCodePoint(code) }; 50075 } 50076 reverse(glyphID) { 50077 let pos = this.glyphIdArray.indexOf(glyphID); 50078 if (pos > -1) return this.firstCode + pos; 50079 } 50080 getSupportedCharCodes(preservePropNames = false) { 50081 if (preservePropNames) { 50082 return [{ firstCode: this.firstCode, lastCode: this.lastCode }]; 50083 } 50084 return [{ start: this.firstCode, end: this.lastCode }]; 50085 } 50086 }; 50087 var Format8 = class extends Subtable { 50088 constructor(p22, platformID, encodingID) { 50089 super(p22, platformID, encodingID); 50090 this.format = 8; 50091 p22.uint16; 50092 this.length = p22.uint32; 50093 this.language = p22.uint32; 50094 this.is32 = [...new Array(8192)].map((_) => p22.uint8); 50095 this.numGroups = p22.uint32; 50096 const getter = () => [...new Array(this.numGroups)].map( 50097 (_) => new SequentialMapGroup$1(p22) 50098 ); 50099 lazy$1(this, `groups`, getter); 50100 } 50101 supports(charCode) { 50102 if (charCode.charCodeAt) { 50103 charCode = -1; 50104 console.warn( 50105 `supports(character) not implemented for cmap subtable format 8. only supports(id) is implemented.` 50106 ); 50107 } 50108 return this.groups.findIndex( 50109 (s2) => s2.startcharCode <= charCode && charCode <= s2.endcharCode 50110 ) !== -1; 50111 } 50112 reverse(glyphID) { 50113 console.warn(`reverse not implemented for cmap subtable format 8`); 50114 return {}; 50115 } 50116 getSupportedCharCodes(preservePropNames = false) { 50117 if (preservePropNames) return this.groups; 50118 return this.groups.map((v2) => ({ 50119 start: v2.startcharCode, 50120 end: v2.endcharCode 50121 })); 50122 } 50123 }; 50124 var SequentialMapGroup$1 = class { 50125 constructor(p22) { 50126 this.startcharCode = p22.uint32; 50127 this.endcharCode = p22.uint32; 50128 this.startGlyphID = p22.uint32; 50129 } 50130 }; 50131 var Format10 = class extends Subtable { 50132 constructor(p22, platformID, encodingID) { 50133 super(p22, platformID, encodingID); 50134 this.format = 10; 50135 p22.uint16; 50136 this.length = p22.uint32; 50137 this.language = p22.uint32; 50138 this.startCharCode = p22.uint32; 50139 this.numChars = p22.uint32; 50140 this.endCharCode = this.startCharCode + this.numChars; 50141 const getter = () => [...new Array(this.numChars)].map((_) => p22.uint16); 50142 lazy$1(this, `glyphs`, getter); 50143 } 50144 supports(charCode) { 50145 if (charCode.charCodeAt) { 50146 charCode = -1; 50147 console.warn( 50148 `supports(character) not implemented for cmap subtable format 10. only supports(id) is implemented.` 50149 ); 50150 } 50151 if (charCode < this.startCharCode) return false; 50152 if (charCode > this.startCharCode + this.numChars) return false; 50153 return charCode - this.startCharCode; 50154 } 50155 reverse(glyphID) { 50156 console.warn(`reverse not implemented for cmap subtable format 10`); 50157 return {}; 50158 } 50159 getSupportedCharCodes(preservePropNames = false) { 50160 if (preservePropNames) { 50161 return [ 50162 { 50163 startCharCode: this.startCharCode, 50164 endCharCode: this.endCharCode 50165 } 50166 ]; 50167 } 50168 return [{ start: this.startCharCode, end: this.endCharCode }]; 50169 } 50170 }; 50171 var Format12 = class extends Subtable { 50172 constructor(p22, platformID, encodingID) { 50173 super(p22, platformID, encodingID); 50174 this.format = 12; 50175 p22.uint16; 50176 this.length = p22.uint32; 50177 this.language = p22.uint32; 50178 this.numGroups = p22.uint32; 50179 const getter = () => [...new Array(this.numGroups)].map( 50180 (_) => new SequentialMapGroup(p22) 50181 ); 50182 lazy$1(this, `groups`, getter); 50183 } 50184 supports(charCode) { 50185 if (charCode.charCodeAt) charCode = charCode.charCodeAt(0); 50186 if (55296 <= charCode && charCode <= 57343) return 0; 50187 if ((charCode & 65534) === 65534 || (charCode & 65535) === 65535) 50188 return 0; 50189 return this.groups.findIndex( 50190 (s2) => s2.startCharCode <= charCode && charCode <= s2.endCharCode 50191 ) !== -1; 50192 } 50193 reverse(glyphID) { 50194 for (let group of this.groups) { 50195 let start2 = group.startGlyphID; 50196 if (start2 > glyphID) continue; 50197 if (start2 === glyphID) return group.startCharCode; 50198 let end = start2 + (group.endCharCode - group.startCharCode); 50199 if (end < glyphID) continue; 50200 const code = group.startCharCode + (glyphID - start2); 50201 return { code, unicode: String.fromCodePoint(code) }; 50202 } 50203 return {}; 50204 } 50205 getSupportedCharCodes(preservePropNames = false) { 50206 if (preservePropNames) return this.groups; 50207 return this.groups.map((v2) => ({ 50208 start: v2.startCharCode, 50209 end: v2.endCharCode 50210 })); 50211 } 50212 }; 50213 var SequentialMapGroup = class { 50214 constructor(p22) { 50215 this.startCharCode = p22.uint32; 50216 this.endCharCode = p22.uint32; 50217 this.startGlyphID = p22.uint32; 50218 } 50219 }; 50220 var Format13 = class extends Subtable { 50221 constructor(p22, platformID, encodingID) { 50222 super(p22, platformID, encodingID); 50223 this.format = 13; 50224 p22.uint16; 50225 this.length = p22.uint32; 50226 this.language = p22.uint32; 50227 this.numGroups = p22.uint32; 50228 const getter = [...new Array(this.numGroups)].map( 50229 (_) => new ConstantMapGroup(p22) 50230 ); 50231 lazy$1(this, `groups`, getter); 50232 } 50233 supports(charCode) { 50234 if (charCode.charCodeAt) charCode = charCode.charCodeAt(0); 50235 return this.groups.findIndex( 50236 (s2) => s2.startCharCode <= charCode && charCode <= s2.endCharCode 50237 ) !== -1; 50238 } 50239 reverse(glyphID) { 50240 console.warn(`reverse not implemented for cmap subtable format 13`); 50241 return {}; 50242 } 50243 getSupportedCharCodes(preservePropNames = false) { 50244 if (preservePropNames) return this.groups; 50245 return this.groups.map((v2) => ({ 50246 start: v2.startCharCode, 50247 end: v2.endCharCode 50248 })); 50249 } 50250 }; 50251 var ConstantMapGroup = class { 50252 constructor(p22) { 50253 this.startCharCode = p22.uint32; 50254 this.endCharCode = p22.uint32; 50255 this.glyphID = p22.uint32; 50256 } 50257 }; 50258 var Format14 = class extends Subtable { 50259 constructor(p22, platformID, encodingID) { 50260 super(p22, platformID, encodingID); 50261 this.subTableStart = p22.currentPosition; 50262 this.format = 14; 50263 this.length = p22.uint32; 50264 this.numVarSelectorRecords = p22.uint32; 50265 lazy$1( 50266 this, 50267 `varSelectors`, 50268 () => [...new Array(this.numVarSelectorRecords)].map( 50269 (_) => new VariationSelector(p22) 50270 ) 50271 ); 50272 } 50273 supports() { 50274 console.warn(`supports not implemented for cmap subtable format 14`); 50275 return 0; 50276 } 50277 getSupportedCharCodes() { 50278 console.warn( 50279 `getSupportedCharCodes not implemented for cmap subtable format 14` 50280 ); 50281 return []; 50282 } 50283 reverse(glyphID) { 50284 console.warn(`reverse not implemented for cmap subtable format 14`); 50285 return {}; 50286 } 50287 supportsVariation(variation) { 50288 let v2 = this.varSelector.find( 50289 (uvs) => uvs.varSelector === variation 50290 ); 50291 return v2 ? v2 : false; 50292 } 50293 getSupportedVariations() { 50294 return this.varSelectors.map((v2) => v2.varSelector); 50295 } 50296 }; 50297 var VariationSelector = class { 50298 constructor(p22) { 50299 this.varSelector = p22.uint24; 50300 this.defaultUVSOffset = p22.Offset32; 50301 this.nonDefaultUVSOffset = p22.Offset32; 50302 } 50303 }; 50304 function createSubTable(parser, platformID, encodingID) { 50305 const format6 = parser.uint16; 50306 if (format6 === 0) return new Format0(parser, platformID, encodingID); 50307 if (format6 === 2) return new Format2(parser, platformID, encodingID); 50308 if (format6 === 4) return new Format4(parser, platformID, encodingID); 50309 if (format6 === 6) return new Format6(parser, platformID, encodingID); 50310 if (format6 === 8) return new Format8(parser, platformID, encodingID); 50311 if (format6 === 10) return new Format10(parser, platformID, encodingID); 50312 if (format6 === 12) return new Format12(parser, platformID, encodingID); 50313 if (format6 === 13) return new Format13(parser, platformID, encodingID); 50314 if (format6 === 14) return new Format14(parser, platformID, encodingID); 50315 return {}; 50316 } 50317 var cmap = class extends SimpleTable { 50318 constructor(dict, dataview) { 50319 const { p: p22 } = super(dict, dataview); 50320 this.version = p22.uint16; 50321 this.numTables = p22.uint16; 50322 this.encodingRecords = [...new Array(this.numTables)].map( 50323 (_) => new EncodingRecord(p22, this.tableStart) 50324 ); 50325 } 50326 getSubTable(tableID) { 50327 return this.encodingRecords[tableID].table; 50328 } 50329 getSupportedEncodings() { 50330 return this.encodingRecords.map((r3) => ({ 50331 platformID: r3.platformID, 50332 encodingId: r3.encodingID 50333 })); 50334 } 50335 getSupportedCharCodes(platformID, encodingID) { 50336 const recordID = this.encodingRecords.findIndex( 50337 (r3) => r3.platformID === platformID && r3.encodingID === encodingID 50338 ); 50339 if (recordID === -1) return false; 50340 const subtable = this.getSubTable(recordID); 50341 return subtable.getSupportedCharCodes(); 50342 } 50343 reverse(glyphid) { 50344 for (let i2 = 0; i2 < this.numTables; i2++) { 50345 let code = this.getSubTable(i2).reverse(glyphid); 50346 if (code) return code; 50347 } 50348 } 50349 getGlyphId(char) { 50350 let last = 0; 50351 this.encodingRecords.some((_, tableID) => { 50352 let t3 = this.getSubTable(tableID); 50353 if (!t3.getGlyphId) return false; 50354 last = t3.getGlyphId(char); 50355 return last !== 0; 50356 }); 50357 return last; 50358 } 50359 supports(char) { 50360 return this.encodingRecords.some((_, tableID) => { 50361 const t3 = this.getSubTable(tableID); 50362 return t3.supports && t3.supports(char) !== false; 50363 }); 50364 } 50365 supportsVariation(variation) { 50366 return this.encodingRecords.some((_, tableID) => { 50367 const t3 = this.getSubTable(tableID); 50368 return t3.supportsVariation && t3.supportsVariation(variation) !== false; 50369 }); 50370 } 50371 }; 50372 var EncodingRecord = class { 50373 constructor(p22, tableStart) { 50374 const platformID = this.platformID = p22.uint16; 50375 const encodingID = this.encodingID = p22.uint16; 50376 const offset4 = this.offset = p22.Offset32; 50377 lazy$1(this, `table`, () => { 50378 p22.currentPosition = tableStart + offset4; 50379 return createSubTable(p22, platformID, encodingID); 50380 }); 50381 } 50382 }; 50383 var cmap$1 = Object.freeze({ __proto__: null, cmap }); 50384 var head = class extends SimpleTable { 50385 constructor(dict, dataview) { 50386 const { p: p22 } = super(dict, dataview); 50387 this.load({ 50388 majorVersion: p22.uint16, 50389 minorVersion: p22.uint16, 50390 fontRevision: p22.fixed, 50391 checkSumAdjustment: p22.uint32, 50392 magicNumber: p22.uint32, 50393 flags: p22.flags(16), 50394 unitsPerEm: p22.uint16, 50395 created: p22.longdatetime, 50396 modified: p22.longdatetime, 50397 xMin: p22.int16, 50398 yMin: p22.int16, 50399 xMax: p22.int16, 50400 yMax: p22.int16, 50401 macStyle: p22.flags(16), 50402 lowestRecPPEM: p22.uint16, 50403 fontDirectionHint: p22.uint16, 50404 indexToLocFormat: p22.uint16, 50405 glyphDataFormat: p22.uint16 50406 }); 50407 } 50408 }; 50409 var head$1 = Object.freeze({ __proto__: null, head }); 50410 var hhea = class extends SimpleTable { 50411 constructor(dict, dataview) { 50412 const { p: p22 } = super(dict, dataview); 50413 this.majorVersion = p22.uint16; 50414 this.minorVersion = p22.uint16; 50415 this.ascender = p22.fword; 50416 this.descender = p22.fword; 50417 this.lineGap = p22.fword; 50418 this.advanceWidthMax = p22.ufword; 50419 this.minLeftSideBearing = p22.fword; 50420 this.minRightSideBearing = p22.fword; 50421 this.xMaxExtent = p22.fword; 50422 this.caretSlopeRise = p22.int16; 50423 this.caretSlopeRun = p22.int16; 50424 this.caretOffset = p22.int16; 50425 p22.int16; 50426 p22.int16; 50427 p22.int16; 50428 p22.int16; 50429 this.metricDataFormat = p22.int16; 50430 this.numberOfHMetrics = p22.uint16; 50431 p22.verifyLength(); 50432 } 50433 }; 50434 var hhea$1 = Object.freeze({ __proto__: null, hhea }); 50435 var hmtx = class extends SimpleTable { 50436 constructor(dict, dataview, tables) { 50437 const { p: p22 } = super(dict, dataview); 50438 const numberOfHMetrics = tables.hhea.numberOfHMetrics; 50439 const numGlyphs = tables.maxp.numGlyphs; 50440 const metricsStart = p22.currentPosition; 50441 lazy$1(this, `hMetrics`, () => { 50442 p22.currentPosition = metricsStart; 50443 return [...new Array(numberOfHMetrics)].map( 50444 (_) => new LongHorMetric(p22.uint16, p22.int16) 50445 ); 50446 }); 50447 if (numberOfHMetrics < numGlyphs) { 50448 const lsbStart = metricsStart + numberOfHMetrics * 4; 50449 lazy$1(this, `leftSideBearings`, () => { 50450 p22.currentPosition = lsbStart; 50451 return [...new Array(numGlyphs - numberOfHMetrics)].map( 50452 (_) => p22.int16 50453 ); 50454 }); 50455 } 50456 } 50457 }; 50458 var LongHorMetric = class { 50459 constructor(w2, b2) { 50460 this.advanceWidth = w2; 50461 this.lsb = b2; 50462 } 50463 }; 50464 var hmtx$1 = Object.freeze({ __proto__: null, hmtx }); 50465 var maxp = class extends SimpleTable { 50466 constructor(dict, dataview) { 50467 const { p: p22 } = super(dict, dataview); 50468 this.version = p22.legacyFixed; 50469 this.numGlyphs = p22.uint16; 50470 if (this.version === 1) { 50471 this.maxPoints = p22.uint16; 50472 this.maxContours = p22.uint16; 50473 this.maxCompositePoints = p22.uint16; 50474 this.maxCompositeContours = p22.uint16; 50475 this.maxZones = p22.uint16; 50476 this.maxTwilightPoints = p22.uint16; 50477 this.maxStorage = p22.uint16; 50478 this.maxFunctionDefs = p22.uint16; 50479 this.maxInstructionDefs = p22.uint16; 50480 this.maxStackElements = p22.uint16; 50481 this.maxSizeOfInstructions = p22.uint16; 50482 this.maxComponentElements = p22.uint16; 50483 this.maxComponentDepth = p22.uint16; 50484 } 50485 p22.verifyLength(); 50486 } 50487 }; 50488 var maxp$1 = Object.freeze({ __proto__: null, maxp }); 50489 var name = class extends SimpleTable { 50490 constructor(dict, dataview) { 50491 const { p: p22 } = super(dict, dataview); 50492 this.format = p22.uint16; 50493 this.count = p22.uint16; 50494 this.stringOffset = p22.Offset16; 50495 this.nameRecords = [...new Array(this.count)].map( 50496 (_) => new NameRecord(p22, this) 50497 ); 50498 if (this.format === 1) { 50499 this.langTagCount = p22.uint16; 50500 this.langTagRecords = [...new Array(this.langTagCount)].map( 50501 (_) => new LangTagRecord(p22.uint16, p22.Offset16) 50502 ); 50503 } 50504 this.stringStart = this.tableStart + this.stringOffset; 50505 } 50506 get(nameID) { 50507 let record = this.nameRecords.find( 50508 (record2) => record2.nameID === nameID 50509 ); 50510 if (record) return record.string; 50511 } 50512 }; 50513 var LangTagRecord = class { 50514 constructor(length, offset4) { 50515 this.length = length; 50516 this.offset = offset4; 50517 } 50518 }; 50519 var NameRecord = class { 50520 constructor(p22, nameTable) { 50521 this.platformID = p22.uint16; 50522 this.encodingID = p22.uint16; 50523 this.languageID = p22.uint16; 50524 this.nameID = p22.uint16; 50525 this.length = p22.uint16; 50526 this.offset = p22.Offset16; 50527 lazy$1(this, `string`, () => { 50528 p22.currentPosition = nameTable.stringStart + this.offset; 50529 return decodeString(p22, this); 50530 }); 50531 } 50532 }; 50533 function decodeString(p22, record) { 50534 const { platformID, length } = record; 50535 if (length === 0) return ``; 50536 if (platformID === 0 || platformID === 3) { 50537 const str2 = []; 50538 for (let i2 = 0, e2 = length / 2; i2 < e2; i2++) 50539 str2[i2] = String.fromCharCode(p22.uint16); 50540 return str2.join(``); 50541 } 50542 const bytes = p22.readBytes(length); 50543 const str = []; 50544 bytes.forEach(function(b2, i2) { 50545 str[i2] = String.fromCharCode(b2); 50546 }); 50547 return str.join(``); 50548 } 50549 var name$1 = Object.freeze({ __proto__: null, name }); 50550 var OS2 = class extends SimpleTable { 50551 constructor(dict, dataview) { 50552 const { p: p22 } = super(dict, dataview); 50553 this.version = p22.uint16; 50554 this.xAvgCharWidth = p22.int16; 50555 this.usWeightClass = p22.uint16; 50556 this.usWidthClass = p22.uint16; 50557 this.fsType = p22.uint16; 50558 this.ySubscriptXSize = p22.int16; 50559 this.ySubscriptYSize = p22.int16; 50560 this.ySubscriptXOffset = p22.int16; 50561 this.ySubscriptYOffset = p22.int16; 50562 this.ySuperscriptXSize = p22.int16; 50563 this.ySuperscriptYSize = p22.int16; 50564 this.ySuperscriptXOffset = p22.int16; 50565 this.ySuperscriptYOffset = p22.int16; 50566 this.yStrikeoutSize = p22.int16; 50567 this.yStrikeoutPosition = p22.int16; 50568 this.sFamilyClass = p22.int16; 50569 this.panose = [...new Array(10)].map((_) => p22.uint8); 50570 this.ulUnicodeRange1 = p22.flags(32); 50571 this.ulUnicodeRange2 = p22.flags(32); 50572 this.ulUnicodeRange3 = p22.flags(32); 50573 this.ulUnicodeRange4 = p22.flags(32); 50574 this.achVendID = p22.tag; 50575 this.fsSelection = p22.uint16; 50576 this.usFirstCharIndex = p22.uint16; 50577 this.usLastCharIndex = p22.uint16; 50578 this.sTypoAscender = p22.int16; 50579 this.sTypoDescender = p22.int16; 50580 this.sTypoLineGap = p22.int16; 50581 this.usWinAscent = p22.uint16; 50582 this.usWinDescent = p22.uint16; 50583 if (this.version === 0) return p22.verifyLength(); 50584 this.ulCodePageRange1 = p22.flags(32); 50585 this.ulCodePageRange2 = p22.flags(32); 50586 if (this.version === 1) return p22.verifyLength(); 50587 this.sxHeight = p22.int16; 50588 this.sCapHeight = p22.int16; 50589 this.usDefaultChar = p22.uint16; 50590 this.usBreakChar = p22.uint16; 50591 this.usMaxContext = p22.uint16; 50592 if (this.version <= 4) return p22.verifyLength(); 50593 this.usLowerOpticalPointSize = p22.uint16; 50594 this.usUpperOpticalPointSize = p22.uint16; 50595 if (this.version === 5) return p22.verifyLength(); 50596 } 50597 }; 50598 var OS2$1 = Object.freeze({ __proto__: null, OS2 }); 50599 var post = class extends SimpleTable { 50600 constructor(dict, dataview) { 50601 const { p: p22 } = super(dict, dataview); 50602 this.version = p22.legacyFixed; 50603 this.italicAngle = p22.fixed; 50604 this.underlinePosition = p22.fword; 50605 this.underlineThickness = p22.fword; 50606 this.isFixedPitch = p22.uint32; 50607 this.minMemType42 = p22.uint32; 50608 this.maxMemType42 = p22.uint32; 50609 this.minMemType1 = p22.uint32; 50610 this.maxMemType1 = p22.uint32; 50611 if (this.version === 1 || this.version === 3) return p22.verifyLength(); 50612 this.numGlyphs = p22.uint16; 50613 if (this.version === 2) { 50614 this.glyphNameIndex = [...new Array(this.numGlyphs)].map( 50615 (_) => p22.uint16 50616 ); 50617 this.namesOffset = p22.currentPosition; 50618 this.glyphNameOffsets = [1]; 50619 for (let i2 = 0; i2 < this.numGlyphs; i2++) { 50620 let index2 = this.glyphNameIndex[i2]; 50621 if (index2 < macStrings.length) { 50622 this.glyphNameOffsets.push(this.glyphNameOffsets[i2]); 50623 continue; 50624 } 50625 let bytelength = p22.int8; 50626 p22.skip(bytelength); 50627 this.glyphNameOffsets.push( 50628 this.glyphNameOffsets[i2] + bytelength + 1 50629 ); 50630 } 50631 } 50632 if (this.version === 2.5) { 50633 this.offset = [...new Array(this.numGlyphs)].map( 50634 (_) => p22.int8 50635 ); 50636 } 50637 } 50638 getGlyphName(glyphid) { 50639 if (this.version !== 2) { 50640 console.warn( 50641 `post table version $this.version} does not support glyph name lookups` 50642 ); 50643 return ``; 50644 } 50645 let index2 = this.glyphNameIndex[glyphid]; 50646 if (index2 < 258) return macStrings[index2]; 50647 let offset4 = this.glyphNameOffsets[glyphid]; 50648 let next = this.glyphNameOffsets[glyphid + 1]; 50649 let len = next - offset4 - 1; 50650 if (len === 0) return `.notdef.`; 50651 this.parser.currentPosition = this.namesOffset + offset4; 50652 const data = this.parser.readBytes( 50653 len, 50654 this.namesOffset + offset4, 50655 8, 50656 true 50657 ); 50658 return data.map((b2) => String.fromCharCode(b2)).join(``); 50659 } 50660 }; 50661 var macStrings = [ 50662 `.notdef`, 50663 `.null`, 50664 `nonmarkingreturn`, 50665 `space`, 50666 `exclam`, 50667 `quotedbl`, 50668 `numbersign`, 50669 `dollar`, 50670 `percent`, 50671 `ampersand`, 50672 `quotesingle`, 50673 `parenleft`, 50674 `parenright`, 50675 `asterisk`, 50676 `plus`, 50677 `comma`, 50678 `hyphen`, 50679 `period`, 50680 `slash`, 50681 `zero`, 50682 `one`, 50683 `two`, 50684 `three`, 50685 `four`, 50686 `five`, 50687 `six`, 50688 `seven`, 50689 `eight`, 50690 `nine`, 50691 `colon`, 50692 `semicolon`, 50693 `less`, 50694 `equal`, 50695 `greater`, 50696 `question`, 50697 `at`, 50698 `A`, 50699 `B`, 50700 `C`, 50701 `D`, 50702 `E`, 50703 `F`, 50704 `G`, 50705 `H`, 50706 `I`, 50707 `J`, 50708 `K`, 50709 `L`, 50710 `M`, 50711 `N`, 50712 `O`, 50713 `P`, 50714 `Q`, 50715 `R`, 50716 `S`, 50717 `T`, 50718 `U`, 50719 `V`, 50720 `W`, 50721 `X`, 50722 `Y`, 50723 `Z`, 50724 `bracketleft`, 50725 `backslash`, 50726 `bracketright`, 50727 `asciicircum`, 50728 `underscore`, 50729 `grave`, 50730 `a`, 50731 `b`, 50732 `c`, 50733 `d`, 50734 `e`, 50735 `f`, 50736 `g`, 50737 `h`, 50738 `i`, 50739 `j`, 50740 `k`, 50741 `l`, 50742 `m`, 50743 `n`, 50744 `o`, 50745 `p`, 50746 `q`, 50747 `r`, 50748 `s`, 50749 `t`, 50750 `u`, 50751 `v`, 50752 `w`, 50753 `x`, 50754 `y`, 50755 `z`, 50756 `braceleft`, 50757 `bar`, 50758 `braceright`, 50759 `asciitilde`, 50760 `Adieresis`, 50761 `Aring`, 50762 `Ccedilla`, 50763 `Eacute`, 50764 `Ntilde`, 50765 `Odieresis`, 50766 `Udieresis`, 50767 `aacute`, 50768 `agrave`, 50769 `acircumflex`, 50770 `adieresis`, 50771 `atilde`, 50772 `aring`, 50773 `ccedilla`, 50774 `eacute`, 50775 `egrave`, 50776 `ecircumflex`, 50777 `edieresis`, 50778 `iacute`, 50779 `igrave`, 50780 `icircumflex`, 50781 `idieresis`, 50782 `ntilde`, 50783 `oacute`, 50784 `ograve`, 50785 `ocircumflex`, 50786 `odieresis`, 50787 `otilde`, 50788 `uacute`, 50789 `ugrave`, 50790 `ucircumflex`, 50791 `udieresis`, 50792 `dagger`, 50793 `degree`, 50794 `cent`, 50795 `sterling`, 50796 `section`, 50797 `bullet`, 50798 `paragraph`, 50799 `germandbls`, 50800 `registered`, 50801 `copyright`, 50802 `trademark`, 50803 `acute`, 50804 `dieresis`, 50805 `notequal`, 50806 `AE`, 50807 `Oslash`, 50808 `infinity`, 50809 `plusminus`, 50810 `lessequal`, 50811 `greaterequal`, 50812 `yen`, 50813 `mu`, 50814 `partialdiff`, 50815 `summation`, 50816 `product`, 50817 `pi`, 50818 `integral`, 50819 `ordfeminine`, 50820 `ordmasculine`, 50821 `Omega`, 50822 `ae`, 50823 `oslash`, 50824 `questiondown`, 50825 `exclamdown`, 50826 `logicalnot`, 50827 `radical`, 50828 `florin`, 50829 `approxequal`, 50830 `Delta`, 50831 `guillemotleft`, 50832 `guillemotright`, 50833 `ellipsis`, 50834 `nonbreakingspace`, 50835 `Agrave`, 50836 `Atilde`, 50837 `Otilde`, 50838 `OE`, 50839 `oe`, 50840 `endash`, 50841 `emdash`, 50842 `quotedblleft`, 50843 `quotedblright`, 50844 `quoteleft`, 50845 `quoteright`, 50846 `divide`, 50847 `lozenge`, 50848 `ydieresis`, 50849 `Ydieresis`, 50850 `fraction`, 50851 `currency`, 50852 `guilsinglleft`, 50853 `guilsinglright`, 50854 `fi`, 50855 `fl`, 50856 `daggerdbl`, 50857 `periodcentered`, 50858 `quotesinglbase`, 50859 `quotedblbase`, 50860 `perthousand`, 50861 `Acircumflex`, 50862 `Ecircumflex`, 50863 `Aacute`, 50864 `Edieresis`, 50865 `Egrave`, 50866 `Iacute`, 50867 `Icircumflex`, 50868 `Idieresis`, 50869 `Igrave`, 50870 `Oacute`, 50871 `Ocircumflex`, 50872 `apple`, 50873 `Ograve`, 50874 `Uacute`, 50875 `Ucircumflex`, 50876 `Ugrave`, 50877 `dotlessi`, 50878 `circumflex`, 50879 `tilde`, 50880 `macron`, 50881 `breve`, 50882 `dotaccent`, 50883 `ring`, 50884 `cedilla`, 50885 `hungarumlaut`, 50886 `ogonek`, 50887 `caron`, 50888 `Lslash`, 50889 `lslash`, 50890 `Scaron`, 50891 `scaron`, 50892 `Zcaron`, 50893 `zcaron`, 50894 `brokenbar`, 50895 `Eth`, 50896 `eth`, 50897 `Yacute`, 50898 `yacute`, 50899 `Thorn`, 50900 `thorn`, 50901 `minus`, 50902 `multiply`, 50903 `onesuperior`, 50904 `twosuperior`, 50905 `threesuperior`, 50906 `onehalf`, 50907 `onequarter`, 50908 `threequarters`, 50909 `franc`, 50910 `Gbreve`, 50911 `gbreve`, 50912 `Idotaccent`, 50913 `Scedilla`, 50914 `scedilla`, 50915 `Cacute`, 50916 `cacute`, 50917 `Ccaron`, 50918 `ccaron`, 50919 `dcroat` 50920 ]; 50921 var post$1 = Object.freeze({ __proto__: null, post }); 50922 var BASE = class extends SimpleTable { 50923 constructor(dict, dataview) { 50924 const { p: p22 } = super(dict, dataview); 50925 this.majorVersion = p22.uint16; 50926 this.minorVersion = p22.uint16; 50927 this.horizAxisOffset = p22.Offset16; 50928 this.vertAxisOffset = p22.Offset16; 50929 lazy$1( 50930 this, 50931 `horizAxis`, 50932 () => new AxisTable( 50933 { offset: dict.offset + this.horizAxisOffset }, 50934 dataview 50935 ) 50936 ); 50937 lazy$1( 50938 this, 50939 `vertAxis`, 50940 () => new AxisTable( 50941 { offset: dict.offset + this.vertAxisOffset }, 50942 dataview 50943 ) 50944 ); 50945 if (this.majorVersion === 1 && this.minorVersion === 1) { 50946 this.itemVarStoreOffset = p22.Offset32; 50947 lazy$1( 50948 this, 50949 `itemVarStore`, 50950 () => new AxisTable( 50951 { offset: dict.offset + this.itemVarStoreOffset }, 50952 dataview 50953 ) 50954 ); 50955 } 50956 } 50957 }; 50958 var AxisTable = class extends SimpleTable { 50959 constructor(dict, dataview) { 50960 const { p: p22 } = super(dict, dataview, `AxisTable`); 50961 this.baseTagListOffset = p22.Offset16; 50962 this.baseScriptListOffset = p22.Offset16; 50963 lazy$1( 50964 this, 50965 `baseTagList`, 50966 () => new BaseTagListTable( 50967 { offset: dict.offset + this.baseTagListOffset }, 50968 dataview 50969 ) 50970 ); 50971 lazy$1( 50972 this, 50973 `baseScriptList`, 50974 () => new BaseScriptListTable( 50975 { offset: dict.offset + this.baseScriptListOffset }, 50976 dataview 50977 ) 50978 ); 50979 } 50980 }; 50981 var BaseTagListTable = class extends SimpleTable { 50982 constructor(dict, dataview) { 50983 const { p: p22 } = super(dict, dataview, `BaseTagListTable`); 50984 this.baseTagCount = p22.uint16; 50985 this.baselineTags = [...new Array(this.baseTagCount)].map( 50986 (_) => p22.tag 50987 ); 50988 } 50989 }; 50990 var BaseScriptListTable = class extends SimpleTable { 50991 constructor(dict, dataview) { 50992 const { p: p22 } = super(dict, dataview, `BaseScriptListTable`); 50993 this.baseScriptCount = p22.uint16; 50994 const recordStart = p22.currentPosition; 50995 lazy$1(this, `baseScriptRecords`, () => { 50996 p22.currentPosition = recordStart; 50997 return [...new Array(this.baseScriptCount)].map( 50998 (_) => new BaseScriptRecord(this.start, p22) 50999 ); 51000 }); 51001 } 51002 }; 51003 var BaseScriptRecord = class { 51004 constructor(baseScriptListTableStart, p22) { 51005 this.baseScriptTag = p22.tag; 51006 this.baseScriptOffset = p22.Offset16; 51007 lazy$1(this, `baseScriptTable`, () => { 51008 p22.currentPosition = baseScriptListTableStart + this.baseScriptOffset; 51009 return new BaseScriptTable(p22); 51010 }); 51011 } 51012 }; 51013 var BaseScriptTable = class { 51014 constructor(p22) { 51015 this.start = p22.currentPosition; 51016 this.baseValuesOffset = p22.Offset16; 51017 this.defaultMinMaxOffset = p22.Offset16; 51018 this.baseLangSysCount = p22.uint16; 51019 this.baseLangSysRecords = [...new Array(this.baseLangSysCount)].map( 51020 (_) => new BaseLangSysRecord(this.start, p22) 51021 ); 51022 lazy$1(this, `baseValues`, () => { 51023 p22.currentPosition = this.start + this.baseValuesOffset; 51024 return new BaseValuesTable(p22); 51025 }); 51026 lazy$1(this, `defaultMinMax`, () => { 51027 p22.currentPosition = this.start + this.defaultMinMaxOffset; 51028 return new MinMaxTable(p22); 51029 }); 51030 } 51031 }; 51032 var BaseLangSysRecord = class { 51033 constructor(baseScriptTableStart, p22) { 51034 this.baseLangSysTag = p22.tag; 51035 this.minMaxOffset = p22.Offset16; 51036 lazy$1(this, `minMax`, () => { 51037 p22.currentPosition = baseScriptTableStart + this.minMaxOffset; 51038 return new MinMaxTable(p22); 51039 }); 51040 } 51041 }; 51042 var BaseValuesTable = class { 51043 constructor(p22) { 51044 this.parser = p22; 51045 this.start = p22.currentPosition; 51046 this.defaultBaselineIndex = p22.uint16; 51047 this.baseCoordCount = p22.uint16; 51048 this.baseCoords = [...new Array(this.baseCoordCount)].map( 51049 (_) => p22.Offset16 51050 ); 51051 } 51052 getTable(id) { 51053 this.parser.currentPosition = this.start + this.baseCoords[id]; 51054 return new BaseCoordTable(this.parser); 51055 } 51056 }; 51057 var MinMaxTable = class { 51058 constructor(p22) { 51059 this.minCoord = p22.Offset16; 51060 this.maxCoord = p22.Offset16; 51061 this.featMinMaxCount = p22.uint16; 51062 const recordStart = p22.currentPosition; 51063 lazy$1(this, `featMinMaxRecords`, () => { 51064 p22.currentPosition = recordStart; 51065 return [...new Array(this.featMinMaxCount)].map( 51066 (_) => new FeatMinMaxRecord(p22) 51067 ); 51068 }); 51069 } 51070 }; 51071 var FeatMinMaxRecord = class { 51072 constructor(p22) { 51073 this.featureTableTag = p22.tag; 51074 this.minCoord = p22.Offset16; 51075 this.maxCoord = p22.Offset16; 51076 } 51077 }; 51078 var BaseCoordTable = class { 51079 constructor(p22) { 51080 this.baseCoordFormat = p22.uint16; 51081 this.coordinate = p22.int16; 51082 if (this.baseCoordFormat === 2) { 51083 this.referenceGlyph = p22.uint16; 51084 this.baseCoordPoint = p22.uint16; 51085 } 51086 if (this.baseCoordFormat === 3) { 51087 this.deviceTable = p22.Offset16; 51088 } 51089 } 51090 }; 51091 var BASE$1 = Object.freeze({ __proto__: null, BASE }); 51092 var ClassDefinition = class { 51093 constructor(p22) { 51094 this.classFormat = p22.uint16; 51095 if (this.classFormat === 1) { 51096 this.startGlyphID = p22.uint16; 51097 this.glyphCount = p22.uint16; 51098 this.classValueArray = [...new Array(this.glyphCount)].map( 51099 (_) => p22.uint16 51100 ); 51101 } 51102 if (this.classFormat === 2) { 51103 this.classRangeCount = p22.uint16; 51104 this.classRangeRecords = [ 51105 ...new Array(this.classRangeCount) 51106 ].map((_) => new ClassRangeRecord(p22)); 51107 } 51108 } 51109 }; 51110 var ClassRangeRecord = class { 51111 constructor(p22) { 51112 this.startGlyphID = p22.uint16; 51113 this.endGlyphID = p22.uint16; 51114 this.class = p22.uint16; 51115 } 51116 }; 51117 var CoverageTable = class extends ParsedData { 51118 constructor(p22) { 51119 super(p22); 51120 this.coverageFormat = p22.uint16; 51121 if (this.coverageFormat === 1) { 51122 this.glyphCount = p22.uint16; 51123 this.glyphArray = [...new Array(this.glyphCount)].map( 51124 (_) => p22.uint16 51125 ); 51126 } 51127 if (this.coverageFormat === 2) { 51128 this.rangeCount = p22.uint16; 51129 this.rangeRecords = [...new Array(this.rangeCount)].map( 51130 (_) => new CoverageRangeRecord(p22) 51131 ); 51132 } 51133 } 51134 }; 51135 var CoverageRangeRecord = class { 51136 constructor(p22) { 51137 this.startGlyphID = p22.uint16; 51138 this.endGlyphID = p22.uint16; 51139 this.startCoverageIndex = p22.uint16; 51140 } 51141 }; 51142 var ItemVariationStoreTable = class { 51143 constructor(table, p22) { 51144 this.table = table; 51145 this.parser = p22; 51146 this.start = p22.currentPosition; 51147 this.format = p22.uint16; 51148 this.variationRegionListOffset = p22.Offset32; 51149 this.itemVariationDataCount = p22.uint16; 51150 this.itemVariationDataOffsets = [ 51151 ...new Array(this.itemVariationDataCount) 51152 ].map((_) => p22.Offset32); 51153 } 51154 }; 51155 var GDEF = class extends SimpleTable { 51156 constructor(dict, dataview) { 51157 const { p: p22 } = super(dict, dataview); 51158 this.majorVersion = p22.uint16; 51159 this.minorVersion = p22.uint16; 51160 this.glyphClassDefOffset = p22.Offset16; 51161 lazy$1(this, `glyphClassDefs`, () => { 51162 if (this.glyphClassDefOffset === 0) return void 0; 51163 p22.currentPosition = this.tableStart + this.glyphClassDefOffset; 51164 return new ClassDefinition(p22); 51165 }); 51166 this.attachListOffset = p22.Offset16; 51167 lazy$1(this, `attachList`, () => { 51168 if (this.attachListOffset === 0) return void 0; 51169 p22.currentPosition = this.tableStart + this.attachListOffset; 51170 return new AttachList(p22); 51171 }); 51172 this.ligCaretListOffset = p22.Offset16; 51173 lazy$1(this, `ligCaretList`, () => { 51174 if (this.ligCaretListOffset === 0) return void 0; 51175 p22.currentPosition = this.tableStart + this.ligCaretListOffset; 51176 return new LigCaretList(p22); 51177 }); 51178 this.markAttachClassDefOffset = p22.Offset16; 51179 lazy$1(this, `markAttachClassDef`, () => { 51180 if (this.markAttachClassDefOffset === 0) return void 0; 51181 p22.currentPosition = this.tableStart + this.markAttachClassDefOffset; 51182 return new ClassDefinition(p22); 51183 }); 51184 if (this.minorVersion >= 2) { 51185 this.markGlyphSetsDefOffset = p22.Offset16; 51186 lazy$1(this, `markGlyphSetsDef`, () => { 51187 if (this.markGlyphSetsDefOffset === 0) return void 0; 51188 p22.currentPosition = this.tableStart + this.markGlyphSetsDefOffset; 51189 return new MarkGlyphSetsTable(p22); 51190 }); 51191 } 51192 if (this.minorVersion === 3) { 51193 this.itemVarStoreOffset = p22.Offset32; 51194 lazy$1(this, `itemVarStore`, () => { 51195 if (this.itemVarStoreOffset === 0) return void 0; 51196 p22.currentPosition = this.tableStart + this.itemVarStoreOffset; 51197 return new ItemVariationStoreTable(p22); 51198 }); 51199 } 51200 } 51201 }; 51202 var AttachList = class extends ParsedData { 51203 constructor(p22) { 51204 super(p22); 51205 this.coverageOffset = p22.Offset16; 51206 this.glyphCount = p22.uint16; 51207 this.attachPointOffsets = [...new Array(this.glyphCount)].map( 51208 (_) => p22.Offset16 51209 ); 51210 } 51211 getPoint(pointID) { 51212 this.parser.currentPosition = this.start + this.attachPointOffsets[pointID]; 51213 return new AttachPoint(this.parser); 51214 } 51215 }; 51216 var AttachPoint = class { 51217 constructor(p22) { 51218 this.pointCount = p22.uint16; 51219 this.pointIndices = [...new Array(this.pointCount)].map( 51220 (_) => p22.uint16 51221 ); 51222 } 51223 }; 51224 var LigCaretList = class extends ParsedData { 51225 constructor(p22) { 51226 super(p22); 51227 this.coverageOffset = p22.Offset16; 51228 lazy$1(this, `coverage`, () => { 51229 p22.currentPosition = this.start + this.coverageOffset; 51230 return new CoverageTable(p22); 51231 }); 51232 this.ligGlyphCount = p22.uint16; 51233 this.ligGlyphOffsets = [...new Array(this.ligGlyphCount)].map( 51234 (_) => p22.Offset16 51235 ); 51236 } 51237 getLigGlyph(ligGlyphID) { 51238 this.parser.currentPosition = this.start + this.ligGlyphOffsets[ligGlyphID]; 51239 return new LigGlyph(this.parser); 51240 } 51241 }; 51242 var LigGlyph = class extends ParsedData { 51243 constructor(p22) { 51244 super(p22); 51245 this.caretCount = p22.uint16; 51246 this.caretValueOffsets = [...new Array(this.caretCount)].map( 51247 (_) => p22.Offset16 51248 ); 51249 } 51250 getCaretValue(caretID) { 51251 this.parser.currentPosition = this.start + this.caretValueOffsets[caretID]; 51252 return new CaretValue(this.parser); 51253 } 51254 }; 51255 var CaretValue = class { 51256 constructor(p22) { 51257 this.caretValueFormat = p22.uint16; 51258 if (this.caretValueFormat === 1) { 51259 this.coordinate = p22.int16; 51260 } 51261 if (this.caretValueFormat === 2) { 51262 this.caretValuePointIndex = p22.uint16; 51263 } 51264 if (this.caretValueFormat === 3) { 51265 this.coordinate = p22.int16; 51266 this.deviceOffset = p22.Offset16; 51267 } 51268 } 51269 }; 51270 var MarkGlyphSetsTable = class extends ParsedData { 51271 constructor(p22) { 51272 super(p22); 51273 this.markGlyphSetTableFormat = p22.uint16; 51274 this.markGlyphSetCount = p22.uint16; 51275 this.coverageOffsets = [...new Array(this.markGlyphSetCount)].map( 51276 (_) => p22.Offset32 51277 ); 51278 } 51279 getMarkGlyphSet(markGlyphSetID) { 51280 this.parser.currentPosition = this.start + this.coverageOffsets[markGlyphSetID]; 51281 return new CoverageTable(this.parser); 51282 } 51283 }; 51284 var GDEF$1 = Object.freeze({ __proto__: null, GDEF }); 51285 var ScriptList = class extends ParsedData { 51286 static EMPTY = { scriptCount: 0, scriptRecords: [] }; 51287 constructor(p22) { 51288 super(p22); 51289 this.scriptCount = p22.uint16; 51290 this.scriptRecords = [...new Array(this.scriptCount)].map( 51291 (_) => new ScriptRecord(p22) 51292 ); 51293 } 51294 }; 51295 var ScriptRecord = class { 51296 constructor(p22) { 51297 this.scriptTag = p22.tag; 51298 this.scriptOffset = p22.Offset16; 51299 } 51300 }; 51301 var ScriptTable = class extends ParsedData { 51302 constructor(p22) { 51303 super(p22); 51304 this.defaultLangSys = p22.Offset16; 51305 this.langSysCount = p22.uint16; 51306 this.langSysRecords = [...new Array(this.langSysCount)].map( 51307 (_) => new LangSysRecord(p22) 51308 ); 51309 } 51310 }; 51311 var LangSysRecord = class { 51312 constructor(p22) { 51313 this.langSysTag = p22.tag; 51314 this.langSysOffset = p22.Offset16; 51315 } 51316 }; 51317 var LangSysTable = class { 51318 constructor(p22) { 51319 this.lookupOrder = p22.Offset16; 51320 this.requiredFeatureIndex = p22.uint16; 51321 this.featureIndexCount = p22.uint16; 51322 this.featureIndices = [...new Array(this.featureIndexCount)].map( 51323 (_) => p22.uint16 51324 ); 51325 } 51326 }; 51327 var FeatureList = class extends ParsedData { 51328 static EMPTY = { featureCount: 0, featureRecords: [] }; 51329 constructor(p22) { 51330 super(p22); 51331 this.featureCount = p22.uint16; 51332 this.featureRecords = [...new Array(this.featureCount)].map( 51333 (_) => new FeatureRecord(p22) 51334 ); 51335 } 51336 }; 51337 var FeatureRecord = class { 51338 constructor(p22) { 51339 this.featureTag = p22.tag; 51340 this.featureOffset = p22.Offset16; 51341 } 51342 }; 51343 var FeatureTable = class extends ParsedData { 51344 constructor(p22) { 51345 super(p22); 51346 this.featureParams = p22.Offset16; 51347 this.lookupIndexCount = p22.uint16; 51348 this.lookupListIndices = [...new Array(this.lookupIndexCount)].map( 51349 (_) => p22.uint16 51350 ); 51351 } 51352 getFeatureParams() { 51353 if (this.featureParams > 0) { 51354 const p22 = this.parser; 51355 p22.currentPosition = this.start + this.featureParams; 51356 const tag = this.featureTag; 51357 if (tag === `size`) return new Size(p22); 51358 if (tag.startsWith(`cc`)) return new CharacterVariant(p22); 51359 if (tag.startsWith(`ss`)) return new StylisticSet(p22); 51360 } 51361 } 51362 }; 51363 var CharacterVariant = class { 51364 constructor(p22) { 51365 this.format = p22.uint16; 51366 this.featUiLabelNameId = p22.uint16; 51367 this.featUiTooltipTextNameId = p22.uint16; 51368 this.sampleTextNameId = p22.uint16; 51369 this.numNamedParameters = p22.uint16; 51370 this.firstParamUiLabelNameId = p22.uint16; 51371 this.charCount = p22.uint16; 51372 this.character = [...new Array(this.charCount)].map( 51373 (_) => p22.uint24 51374 ); 51375 } 51376 }; 51377 var Size = class { 51378 constructor(p22) { 51379 this.designSize = p22.uint16; 51380 this.subfamilyIdentifier = p22.uint16; 51381 this.subfamilyNameID = p22.uint16; 51382 this.smallEnd = p22.uint16; 51383 this.largeEnd = p22.uint16; 51384 } 51385 }; 51386 var StylisticSet = class { 51387 constructor(p22) { 51388 this.version = p22.uint16; 51389 this.UINameID = p22.uint16; 51390 } 51391 }; 51392 function undoCoverageOffsetParsing(instance) { 51393 instance.parser.currentPosition -= 2; 51394 delete instance.coverageOffset; 51395 delete instance.getCoverageTable; 51396 } 51397 var LookupType$1 = class extends ParsedData { 51398 constructor(p22) { 51399 super(p22); 51400 this.substFormat = p22.uint16; 51401 this.coverageOffset = p22.Offset16; 51402 } 51403 getCoverageTable() { 51404 let p22 = this.parser; 51405 p22.currentPosition = this.start + this.coverageOffset; 51406 return new CoverageTable(p22); 51407 } 51408 }; 51409 var SubstLookupRecord = class { 51410 constructor(p22) { 51411 this.glyphSequenceIndex = p22.uint16; 51412 this.lookupListIndex = p22.uint16; 51413 } 51414 }; 51415 var LookupType1$1 = class extends LookupType$1 { 51416 constructor(p22) { 51417 super(p22); 51418 this.deltaGlyphID = p22.int16; 51419 } 51420 }; 51421 var LookupType2$1 = class extends LookupType$1 { 51422 constructor(p22) { 51423 super(p22); 51424 this.sequenceCount = p22.uint16; 51425 this.sequenceOffsets = [...new Array(this.sequenceCount)].map( 51426 (_) => p22.Offset16 51427 ); 51428 } 51429 getSequence(index2) { 51430 let p22 = this.parser; 51431 p22.currentPosition = this.start + this.sequenceOffsets[index2]; 51432 return new SequenceTable(p22); 51433 } 51434 }; 51435 var SequenceTable = class { 51436 constructor(p22) { 51437 this.glyphCount = p22.uint16; 51438 this.substituteGlyphIDs = [...new Array(this.glyphCount)].map( 51439 (_) => p22.uint16 51440 ); 51441 } 51442 }; 51443 var LookupType3$1 = class extends LookupType$1 { 51444 constructor(p22) { 51445 super(p22); 51446 this.alternateSetCount = p22.uint16; 51447 this.alternateSetOffsets = [ 51448 ...new Array(this.alternateSetCount) 51449 ].map((_) => p22.Offset16); 51450 } 51451 getAlternateSet(index2) { 51452 let p22 = this.parser; 51453 p22.currentPosition = this.start + this.alternateSetOffsets[index2]; 51454 return new AlternateSetTable(p22); 51455 } 51456 }; 51457 var AlternateSetTable = class { 51458 constructor(p22) { 51459 this.glyphCount = p22.uint16; 51460 this.alternateGlyphIDs = [...new Array(this.glyphCount)].map( 51461 (_) => p22.uint16 51462 ); 51463 } 51464 }; 51465 var LookupType4$1 = class extends LookupType$1 { 51466 constructor(p22) { 51467 super(p22); 51468 this.ligatureSetCount = p22.uint16; 51469 this.ligatureSetOffsets = [...new Array(this.ligatureSetCount)].map( 51470 (_) => p22.Offset16 51471 ); 51472 } 51473 getLigatureSet(index2) { 51474 let p22 = this.parser; 51475 p22.currentPosition = this.start + this.ligatureSetOffsets[index2]; 51476 return new LigatureSetTable(p22); 51477 } 51478 }; 51479 var LigatureSetTable = class extends ParsedData { 51480 constructor(p22) { 51481 super(p22); 51482 this.ligatureCount = p22.uint16; 51483 this.ligatureOffsets = [...new Array(this.ligatureCount)].map( 51484 (_) => p22.Offset16 51485 ); 51486 } 51487 getLigature(index2) { 51488 let p22 = this.parser; 51489 p22.currentPosition = this.start + this.ligatureOffsets[index2]; 51490 return new LigatureTable(p22); 51491 } 51492 }; 51493 var LigatureTable = class { 51494 constructor(p22) { 51495 this.ligatureGlyph = p22.uint16; 51496 this.componentCount = p22.uint16; 51497 this.componentGlyphIDs = [ 51498 ...new Array(this.componentCount - 1) 51499 ].map((_) => p22.uint16); 51500 } 51501 }; 51502 var LookupType5$1 = class extends LookupType$1 { 51503 constructor(p22) { 51504 super(p22); 51505 if (this.substFormat === 1) { 51506 this.subRuleSetCount = p22.uint16; 51507 this.subRuleSetOffsets = [ 51508 ...new Array(this.subRuleSetCount) 51509 ].map((_) => p22.Offset16); 51510 } 51511 if (this.substFormat === 2) { 51512 this.classDefOffset = p22.Offset16; 51513 this.subClassSetCount = p22.uint16; 51514 this.subClassSetOffsets = [ 51515 ...new Array(this.subClassSetCount) 51516 ].map((_) => p22.Offset16); 51517 } 51518 if (this.substFormat === 3) { 51519 undoCoverageOffsetParsing(this); 51520 this.glyphCount = p22.uint16; 51521 this.substitutionCount = p22.uint16; 51522 this.coverageOffsets = [...new Array(this.glyphCount)].map( 51523 (_) => p22.Offset16 51524 ); 51525 this.substLookupRecords = [ 51526 ...new Array(this.substitutionCount) 51527 ].map((_) => new SubstLookupRecord(p22)); 51528 } 51529 } 51530 getSubRuleSet(index2) { 51531 if (this.substFormat !== 1) 51532 throw new Error( 51533 `lookup type 5.$this.substFormat} has no subrule sets.` 51534 ); 51535 let p22 = this.parser; 51536 p22.currentPosition = this.start + this.subRuleSetOffsets[index2]; 51537 return new SubRuleSetTable(p22); 51538 } 51539 getSubClassSet(index2) { 51540 if (this.substFormat !== 2) 51541 throw new Error( 51542 `lookup type 5.$this.substFormat} has no subclass sets.` 51543 ); 51544 let p22 = this.parser; 51545 p22.currentPosition = this.start + this.subClassSetOffsets[index2]; 51546 return new SubClassSetTable(p22); 51547 } 51548 getCoverageTable(index2) { 51549 if (this.substFormat !== 3 && !index2) 51550 return super.getCoverageTable(); 51551 if (!index2) 51552 throw new Error( 51553 `lookup type 5.$this.substFormat} requires an coverage table index.` 51554 ); 51555 let p22 = this.parser; 51556 p22.currentPosition = this.start + this.coverageOffsets[index2]; 51557 return new CoverageTable(p22); 51558 } 51559 }; 51560 var SubRuleSetTable = class extends ParsedData { 51561 constructor(p22) { 51562 super(p22); 51563 this.subRuleCount = p22.uint16; 51564 this.subRuleOffsets = [...new Array(this.subRuleCount)].map( 51565 (_) => p22.Offset16 51566 ); 51567 } 51568 getSubRule(index2) { 51569 let p22 = this.parser; 51570 p22.currentPosition = this.start + this.subRuleOffsets[index2]; 51571 return new SubRuleTable(p22); 51572 } 51573 }; 51574 var SubRuleTable = class { 51575 constructor(p22) { 51576 this.glyphCount = p22.uint16; 51577 this.substitutionCount = p22.uint16; 51578 this.inputSequence = [...new Array(this.glyphCount - 1)].map( 51579 (_) => p22.uint16 51580 ); 51581 this.substLookupRecords = [ 51582 ...new Array(this.substitutionCount) 51583 ].map((_) => new SubstLookupRecord(p22)); 51584 } 51585 }; 51586 var SubClassSetTable = class extends ParsedData { 51587 constructor(p22) { 51588 super(p22); 51589 this.subClassRuleCount = p22.uint16; 51590 this.subClassRuleOffsets = [ 51591 ...new Array(this.subClassRuleCount) 51592 ].map((_) => p22.Offset16); 51593 } 51594 getSubClass(index2) { 51595 let p22 = this.parser; 51596 p22.currentPosition = this.start + this.subClassRuleOffsets[index2]; 51597 return new SubClassRuleTable(p22); 51598 } 51599 }; 51600 var SubClassRuleTable = class extends SubRuleTable { 51601 constructor(p22) { 51602 super(p22); 51603 } 51604 }; 51605 var LookupType6$1 = class extends LookupType$1 { 51606 constructor(p22) { 51607 super(p22); 51608 if (this.substFormat === 1) { 51609 this.chainSubRuleSetCount = p22.uint16; 51610 this.chainSubRuleSetOffsets = [ 51611 ...new Array(this.chainSubRuleSetCount) 51612 ].map((_) => p22.Offset16); 51613 } 51614 if (this.substFormat === 2) { 51615 this.backtrackClassDefOffset = p22.Offset16; 51616 this.inputClassDefOffset = p22.Offset16; 51617 this.lookaheadClassDefOffset = p22.Offset16; 51618 this.chainSubClassSetCount = p22.uint16; 51619 this.chainSubClassSetOffsets = [ 51620 ...new Array(this.chainSubClassSetCount) 51621 ].map((_) => p22.Offset16); 51622 } 51623 if (this.substFormat === 3) { 51624 undoCoverageOffsetParsing(this); 51625 this.backtrackGlyphCount = p22.uint16; 51626 this.backtrackCoverageOffsets = [ 51627 ...new Array(this.backtrackGlyphCount) 51628 ].map((_) => p22.Offset16); 51629 this.inputGlyphCount = p22.uint16; 51630 this.inputCoverageOffsets = [ 51631 ...new Array(this.inputGlyphCount) 51632 ].map((_) => p22.Offset16); 51633 this.lookaheadGlyphCount = p22.uint16; 51634 this.lookaheadCoverageOffsets = [ 51635 ...new Array(this.lookaheadGlyphCount) 51636 ].map((_) => p22.Offset16); 51637 this.seqLookupCount = p22.uint16; 51638 this.seqLookupRecords = [ 51639 ...new Array(this.substitutionCount) 51640 ].map((_) => new SequenceLookupRecord(p22)); 51641 } 51642 } 51643 getChainSubRuleSet(index2) { 51644 if (this.substFormat !== 1) 51645 throw new Error( 51646 `lookup type 6.$this.substFormat} has no chainsubrule sets.` 51647 ); 51648 let p22 = this.parser; 51649 p22.currentPosition = this.start + this.chainSubRuleSetOffsets[index2]; 51650 return new ChainSubRuleSetTable(p22); 51651 } 51652 getChainSubClassSet(index2) { 51653 if (this.substFormat !== 2) 51654 throw new Error( 51655 `lookup type 6.$this.substFormat} has no chainsubclass sets.` 51656 ); 51657 let p22 = this.parser; 51658 p22.currentPosition = this.start + this.chainSubClassSetOffsets[index2]; 51659 return new ChainSubClassSetTable(p22); 51660 } 51661 getCoverageFromOffset(offset4) { 51662 if (this.substFormat !== 3) 51663 throw new Error( 51664 `lookup type 6.$this.substFormat} does not use contextual coverage offsets.` 51665 ); 51666 let p22 = this.parser; 51667 p22.currentPosition = this.start + offset4; 51668 return new CoverageTable(p22); 51669 } 51670 }; 51671 var ChainSubRuleSetTable = class extends ParsedData { 51672 constructor(p22) { 51673 super(p22); 51674 this.chainSubRuleCount = p22.uint16; 51675 this.chainSubRuleOffsets = [ 51676 ...new Array(this.chainSubRuleCount) 51677 ].map((_) => p22.Offset16); 51678 } 51679 getSubRule(index2) { 51680 let p22 = this.parser; 51681 p22.currentPosition = this.start + this.chainSubRuleOffsets[index2]; 51682 return new ChainSubRuleTable(p22); 51683 } 51684 }; 51685 var ChainSubRuleTable = class { 51686 constructor(p22) { 51687 this.backtrackGlyphCount = p22.uint16; 51688 this.backtrackSequence = [ 51689 ...new Array(this.backtrackGlyphCount) 51690 ].map((_) => p22.uint16); 51691 this.inputGlyphCount = p22.uint16; 51692 this.inputSequence = [...new Array(this.inputGlyphCount - 1)].map( 51693 (_) => p22.uint16 51694 ); 51695 this.lookaheadGlyphCount = p22.uint16; 51696 this.lookAheadSequence = [ 51697 ...new Array(this.lookAheadGlyphCount) 51698 ].map((_) => p22.uint16); 51699 this.substitutionCount = p22.uint16; 51700 this.substLookupRecords = [...new Array(this.SubstCount)].map( 51701 (_) => new SubstLookupRecord(p22) 51702 ); 51703 } 51704 }; 51705 var ChainSubClassSetTable = class extends ParsedData { 51706 constructor(p22) { 51707 super(p22); 51708 this.chainSubClassRuleCount = p22.uint16; 51709 this.chainSubClassRuleOffsets = [ 51710 ...new Array(this.chainSubClassRuleCount) 51711 ].map((_) => p22.Offset16); 51712 } 51713 getSubClass(index2) { 51714 let p22 = this.parser; 51715 p22.currentPosition = this.start + this.chainSubRuleOffsets[index2]; 51716 return new ChainSubClassRuleTable(p22); 51717 } 51718 }; 51719 var ChainSubClassRuleTable = class { 51720 constructor(p22) { 51721 this.backtrackGlyphCount = p22.uint16; 51722 this.backtrackSequence = [ 51723 ...new Array(this.backtrackGlyphCount) 51724 ].map((_) => p22.uint16); 51725 this.inputGlyphCount = p22.uint16; 51726 this.inputSequence = [...new Array(this.inputGlyphCount - 1)].map( 51727 (_) => p22.uint16 51728 ); 51729 this.lookaheadGlyphCount = p22.uint16; 51730 this.lookAheadSequence = [ 51731 ...new Array(this.lookAheadGlyphCount) 51732 ].map((_) => p22.uint16); 51733 this.substitutionCount = p22.uint16; 51734 this.substLookupRecords = [ 51735 ...new Array(this.substitutionCount) 51736 ].map((_) => new SequenceLookupRecord(p22)); 51737 } 51738 }; 51739 var SequenceLookupRecord = class extends ParsedData { 51740 constructor(p22) { 51741 super(p22); 51742 this.sequenceIndex = p22.uint16; 51743 this.lookupListIndex = p22.uint16; 51744 } 51745 }; 51746 var LookupType7$1 = class extends ParsedData { 51747 constructor(p22) { 51748 super(p22); 51749 this.substFormat = p22.uint16; 51750 this.extensionLookupType = p22.uint16; 51751 this.extensionOffset = p22.Offset32; 51752 } 51753 }; 51754 var LookupType8$1 = class extends LookupType$1 { 51755 constructor(p22) { 51756 super(p22); 51757 this.backtrackGlyphCount = p22.uint16; 51758 this.backtrackCoverageOffsets = [ 51759 ...new Array(this.backtrackGlyphCount) 51760 ].map((_) => p22.Offset16); 51761 this.lookaheadGlyphCount = p22.uint16; 51762 this.lookaheadCoverageOffsets = [ 51763 new Array(this.lookaheadGlyphCount) 51764 ].map((_) => p22.Offset16); 51765 this.glyphCount = p22.uint16; 51766 this.substituteGlyphIDs = [...new Array(this.glyphCount)].map( 51767 (_) => p22.uint16 51768 ); 51769 } 51770 }; 51771 var GSUBtables = { 51772 buildSubtable: function(type, p22) { 51773 const subtable = new [ 51774 void 0, 51775 LookupType1$1, 51776 LookupType2$1, 51777 LookupType3$1, 51778 LookupType4$1, 51779 LookupType5$1, 51780 LookupType6$1, 51781 LookupType7$1, 51782 LookupType8$1 51783 ][type](p22); 51784 subtable.type = type; 51785 return subtable; 51786 } 51787 }; 51788 var LookupType = class extends ParsedData { 51789 constructor(p22) { 51790 super(p22); 51791 } 51792 }; 51793 var LookupType1 = class extends LookupType { 51794 constructor(p22) { 51795 super(p22); 51796 console.log(`lookup type 1`); 51797 } 51798 }; 51799 var LookupType2 = class extends LookupType { 51800 constructor(p22) { 51801 super(p22); 51802 console.log(`lookup type 2`); 51803 } 51804 }; 51805 var LookupType3 = class extends LookupType { 51806 constructor(p22) { 51807 super(p22); 51808 console.log(`lookup type 3`); 51809 } 51810 }; 51811 var LookupType4 = class extends LookupType { 51812 constructor(p22) { 51813 super(p22); 51814 console.log(`lookup type 4`); 51815 } 51816 }; 51817 var LookupType5 = class extends LookupType { 51818 constructor(p22) { 51819 super(p22); 51820 console.log(`lookup type 5`); 51821 } 51822 }; 51823 var LookupType6 = class extends LookupType { 51824 constructor(p22) { 51825 super(p22); 51826 console.log(`lookup type 6`); 51827 } 51828 }; 51829 var LookupType7 = class extends LookupType { 51830 constructor(p22) { 51831 super(p22); 51832 console.log(`lookup type 7`); 51833 } 51834 }; 51835 var LookupType8 = class extends LookupType { 51836 constructor(p22) { 51837 super(p22); 51838 console.log(`lookup type 8`); 51839 } 51840 }; 51841 var LookupType9 = class extends LookupType { 51842 constructor(p22) { 51843 super(p22); 51844 console.log(`lookup type 9`); 51845 } 51846 }; 51847 var GPOStables = { 51848 buildSubtable: function(type, p22) { 51849 const subtable = new [ 51850 void 0, 51851 LookupType1, 51852 LookupType2, 51853 LookupType3, 51854 LookupType4, 51855 LookupType5, 51856 LookupType6, 51857 LookupType7, 51858 LookupType8, 51859 LookupType9 51860 ][type](p22); 51861 subtable.type = type; 51862 return subtable; 51863 } 51864 }; 51865 var LookupList = class extends ParsedData { 51866 static EMPTY = { lookupCount: 0, lookups: [] }; 51867 constructor(p22) { 51868 super(p22); 51869 this.lookupCount = p22.uint16; 51870 this.lookups = [...new Array(this.lookupCount)].map( 51871 (_) => p22.Offset16 51872 ); 51873 } 51874 }; 51875 var LookupTable = class extends ParsedData { 51876 constructor(p22, type) { 51877 super(p22); 51878 this.ctType = type; 51879 this.lookupType = p22.uint16; 51880 this.lookupFlag = p22.uint16; 51881 this.subTableCount = p22.uint16; 51882 this.subtableOffsets = [...new Array(this.subTableCount)].map( 51883 (_) => p22.Offset16 51884 ); 51885 this.markFilteringSet = p22.uint16; 51886 } 51887 get rightToLeft() { 51888 return this.lookupFlag & true; 51889 } 51890 get ignoreBaseGlyphs() { 51891 return this.lookupFlag & true; 51892 } 51893 get ignoreLigatures() { 51894 return this.lookupFlag & true; 51895 } 51896 get ignoreMarks() { 51897 return this.lookupFlag & true; 51898 } 51899 get useMarkFilteringSet() { 51900 return this.lookupFlag & true; 51901 } 51902 get markAttachmentType() { 51903 return this.lookupFlag & true; 51904 } 51905 getSubTable(index2) { 51906 const builder = this.ctType === `GSUB` ? GSUBtables : GPOStables; 51907 this.parser.currentPosition = this.start + this.subtableOffsets[index2]; 51908 return builder.buildSubtable(this.lookupType, this.parser); 51909 } 51910 }; 51911 var CommonLayoutTable = class extends SimpleTable { 51912 constructor(dict, dataview, name2) { 51913 const { p: p22, tableStart } = super(dict, dataview, name2); 51914 this.majorVersion = p22.uint16; 51915 this.minorVersion = p22.uint16; 51916 this.scriptListOffset = p22.Offset16; 51917 this.featureListOffset = p22.Offset16; 51918 this.lookupListOffset = p22.Offset16; 51919 if (this.majorVersion === 1 && this.minorVersion === 1) { 51920 this.featureVariationsOffset = p22.Offset32; 51921 } 51922 const no_content = !(this.scriptListOffset || this.featureListOffset || this.lookupListOffset); 51923 lazy$1(this, `scriptList`, () => { 51924 if (no_content) return ScriptList.EMPTY; 51925 p22.currentPosition = tableStart + this.scriptListOffset; 51926 return new ScriptList(p22); 51927 }); 51928 lazy$1(this, `featureList`, () => { 51929 if (no_content) return FeatureList.EMPTY; 51930 p22.currentPosition = tableStart + this.featureListOffset; 51931 return new FeatureList(p22); 51932 }); 51933 lazy$1(this, `lookupList`, () => { 51934 if (no_content) return LookupList.EMPTY; 51935 p22.currentPosition = tableStart + this.lookupListOffset; 51936 return new LookupList(p22); 51937 }); 51938 if (this.featureVariationsOffset) { 51939 lazy$1(this, `featureVariations`, () => { 51940 if (no_content) return FeatureVariations.EMPTY; 51941 p22.currentPosition = tableStart + this.featureVariationsOffset; 51942 return new FeatureVariations(p22); 51943 }); 51944 } 51945 } 51946 getSupportedScripts() { 51947 return this.scriptList.scriptRecords.map((r3) => r3.scriptTag); 51948 } 51949 getScriptTable(scriptTag) { 51950 let record = this.scriptList.scriptRecords.find( 51951 (r3) => r3.scriptTag === scriptTag 51952 ); 51953 this.parser.currentPosition = this.scriptList.start + record.scriptOffset; 51954 let table = new ScriptTable(this.parser); 51955 table.scriptTag = scriptTag; 51956 return table; 51957 } 51958 ensureScriptTable(arg) { 51959 if (typeof arg === "string") { 51960 return this.getScriptTable(arg); 51961 } 51962 return arg; 51963 } 51964 getSupportedLangSys(scriptTable) { 51965 scriptTable = this.ensureScriptTable(scriptTable); 51966 const hasDefault = scriptTable.defaultLangSys !== 0; 51967 const supported = scriptTable.langSysRecords.map( 51968 (l2) => l2.langSysTag 51969 ); 51970 if (hasDefault) supported.unshift(`dflt`); 51971 return supported; 51972 } 51973 getDefaultLangSysTable(scriptTable) { 51974 scriptTable = this.ensureScriptTable(scriptTable); 51975 let offset4 = scriptTable.defaultLangSys; 51976 if (offset4 !== 0) { 51977 this.parser.currentPosition = scriptTable.start + offset4; 51978 let table = new LangSysTable(this.parser); 51979 table.langSysTag = ``; 51980 table.defaultForScript = scriptTable.scriptTag; 51981 return table; 51982 } 51983 } 51984 getLangSysTable(scriptTable, langSysTag = `dflt`) { 51985 if (langSysTag === `dflt`) 51986 return this.getDefaultLangSysTable(scriptTable); 51987 scriptTable = this.ensureScriptTable(scriptTable); 51988 let record = scriptTable.langSysRecords.find( 51989 (l2) => l2.langSysTag === langSysTag 51990 ); 51991 this.parser.currentPosition = scriptTable.start + record.langSysOffset; 51992 let table = new LangSysTable(this.parser); 51993 table.langSysTag = langSysTag; 51994 return table; 51995 } 51996 getFeatures(langSysTable) { 51997 return langSysTable.featureIndices.map( 51998 (index2) => this.getFeature(index2) 51999 ); 52000 } 52001 getFeature(indexOrTag) { 52002 let record; 52003 if (parseInt(indexOrTag) == indexOrTag) { 52004 record = this.featureList.featureRecords[indexOrTag]; 52005 } else { 52006 record = this.featureList.featureRecords.find( 52007 (f2) => f2.featureTag === indexOrTag 52008 ); 52009 } 52010 if (!record) return; 52011 this.parser.currentPosition = this.featureList.start + record.featureOffset; 52012 let table = new FeatureTable(this.parser); 52013 table.featureTag = record.featureTag; 52014 return table; 52015 } 52016 getLookups(featureTable) { 52017 return featureTable.lookupListIndices.map( 52018 (index2) => this.getLookup(index2) 52019 ); 52020 } 52021 getLookup(lookupIndex, type) { 52022 let lookupOffset = this.lookupList.lookups[lookupIndex]; 52023 this.parser.currentPosition = this.lookupList.start + lookupOffset; 52024 return new LookupTable(this.parser, type); 52025 } 52026 }; 52027 var GSUB = class extends CommonLayoutTable { 52028 constructor(dict, dataview) { 52029 super(dict, dataview, `GSUB`); 52030 } 52031 getLookup(lookupIndex) { 52032 return super.getLookup(lookupIndex, `GSUB`); 52033 } 52034 }; 52035 var GSUB$1 = Object.freeze({ __proto__: null, GSUB }); 52036 var GPOS = class extends CommonLayoutTable { 52037 constructor(dict, dataview) { 52038 super(dict, dataview, `GPOS`); 52039 } 52040 getLookup(lookupIndex) { 52041 return super.getLookup(lookupIndex, `GPOS`); 52042 } 52043 }; 52044 var GPOS$1 = Object.freeze({ __proto__: null, GPOS }); 52045 var SVG69 = class extends SimpleTable { 52046 constructor(dict, dataview) { 52047 const { p: p22 } = super(dict, dataview); 52048 this.version = p22.uint16; 52049 this.offsetToSVGDocumentList = p22.Offset32; 52050 p22.currentPosition = this.tableStart + this.offsetToSVGDocumentList; 52051 this.documentList = new SVGDocumentList(p22); 52052 } 52053 }; 52054 var SVGDocumentList = class extends ParsedData { 52055 constructor(p22) { 52056 super(p22); 52057 this.numEntries = p22.uint16; 52058 this.documentRecords = [...new Array(this.numEntries)].map( 52059 (_) => new SVGDocumentRecord(p22) 52060 ); 52061 } 52062 getDocument(documentID) { 52063 let record = this.documentRecords[documentID]; 52064 if (!record) return ""; 52065 let offset4 = this.start + record.svgDocOffset; 52066 this.parser.currentPosition = offset4; 52067 return this.parser.readBytes(record.svgDocLength); 52068 } 52069 getDocumentForGlyph(glyphID) { 52070 let id = this.documentRecords.findIndex( 52071 (d2) => d2.startGlyphID <= glyphID && glyphID <= d2.endGlyphID 52072 ); 52073 if (id === -1) return ""; 52074 return this.getDocument(id); 52075 } 52076 }; 52077 var SVGDocumentRecord = class { 52078 constructor(p22) { 52079 this.startGlyphID = p22.uint16; 52080 this.endGlyphID = p22.uint16; 52081 this.svgDocOffset = p22.Offset32; 52082 this.svgDocLength = p22.uint32; 52083 } 52084 }; 52085 var SVG$1 = Object.freeze({ __proto__: null, SVG: SVG69 }); 52086 var fvar = class extends SimpleTable { 52087 constructor(dict, dataview) { 52088 const { p: p22 } = super(dict, dataview); 52089 this.majorVersion = p22.uint16; 52090 this.minorVersion = p22.uint16; 52091 this.axesArrayOffset = p22.Offset16; 52092 p22.uint16; 52093 this.axisCount = p22.uint16; 52094 this.axisSize = p22.uint16; 52095 this.instanceCount = p22.uint16; 52096 this.instanceSize = p22.uint16; 52097 const axisStart = this.tableStart + this.axesArrayOffset; 52098 lazy$1(this, `axes`, () => { 52099 p22.currentPosition = axisStart; 52100 return [...new Array(this.axisCount)].map( 52101 (_) => new VariationAxisRecord(p22) 52102 ); 52103 }); 52104 const instanceStart = axisStart + this.axisCount * this.axisSize; 52105 lazy$1(this, `instances`, () => { 52106 let instances = []; 52107 for (let i2 = 0; i2 < this.instanceCount; i2++) { 52108 p22.currentPosition = instanceStart + i2 * this.instanceSize; 52109 instances.push( 52110 new InstanceRecord(p22, this.axisCount, this.instanceSize) 52111 ); 52112 } 52113 return instances; 52114 }); 52115 } 52116 getSupportedAxes() { 52117 return this.axes.map((a2) => a2.tag); 52118 } 52119 getAxis(name2) { 52120 return this.axes.find((a2) => a2.tag === name2); 52121 } 52122 }; 52123 var VariationAxisRecord = class { 52124 constructor(p22) { 52125 this.tag = p22.tag; 52126 this.minValue = p22.fixed; 52127 this.defaultValue = p22.fixed; 52128 this.maxValue = p22.fixed; 52129 this.flags = p22.flags(16); 52130 this.axisNameID = p22.uint16; 52131 } 52132 }; 52133 var InstanceRecord = class { 52134 constructor(p22, axisCount, size4) { 52135 let start2 = p22.currentPosition; 52136 this.subfamilyNameID = p22.uint16; 52137 p22.uint16; 52138 this.coordinates = [...new Array(axisCount)].map( 52139 (_) => p22.fixed 52140 ); 52141 if (p22.currentPosition - start2 < size4) { 52142 this.postScriptNameID = p22.uint16; 52143 } 52144 } 52145 }; 52146 var fvar$1 = Object.freeze({ __proto__: null, fvar }); 52147 var cvt = class extends SimpleTable { 52148 constructor(dict, dataview) { 52149 const { p: p22 } = super(dict, dataview); 52150 const n2 = dict.length / 2; 52151 lazy$1( 52152 this, 52153 `items`, 52154 () => [...new Array(n2)].map((_) => p22.fword) 52155 ); 52156 } 52157 }; 52158 var cvt$1 = Object.freeze({ __proto__: null, cvt }); 52159 var fpgm = class extends SimpleTable { 52160 constructor(dict, dataview) { 52161 const { p: p22 } = super(dict, dataview); 52162 lazy$1( 52163 this, 52164 `instructions`, 52165 () => [...new Array(dict.length)].map((_) => p22.uint8) 52166 ); 52167 } 52168 }; 52169 var fpgm$1 = Object.freeze({ __proto__: null, fpgm }); 52170 var gasp = class extends SimpleTable { 52171 constructor(dict, dataview) { 52172 const { p: p22 } = super(dict, dataview); 52173 this.version = p22.uint16; 52174 this.numRanges = p22.uint16; 52175 const getter = () => [...new Array(this.numRanges)].map( 52176 (_) => new GASPRange(p22) 52177 ); 52178 lazy$1(this, `gaspRanges`, getter); 52179 } 52180 }; 52181 var GASPRange = class { 52182 constructor(p22) { 52183 this.rangeMaxPPEM = p22.uint16; 52184 this.rangeGaspBehavior = p22.uint16; 52185 } 52186 }; 52187 var gasp$1 = Object.freeze({ __proto__: null, gasp }); 52188 var glyf = class extends SimpleTable { 52189 constructor(dict, dataview) { 52190 super(dict, dataview); 52191 } 52192 getGlyphData(offset4, length) { 52193 this.parser.currentPosition = this.tableStart + offset4; 52194 return this.parser.readBytes(length); 52195 } 52196 }; 52197 var glyf$1 = Object.freeze({ __proto__: null, glyf }); 52198 var loca = class extends SimpleTable { 52199 constructor(dict, dataview, tables) { 52200 const { p: p22 } = super(dict, dataview); 52201 const n2 = tables.maxp.numGlyphs + 1; 52202 if (tables.head.indexToLocFormat === 0) { 52203 this.x2 = true; 52204 lazy$1( 52205 this, 52206 `offsets`, 52207 () => [...new Array(n2)].map((_) => p22.Offset16) 52208 ); 52209 } else { 52210 lazy$1( 52211 this, 52212 `offsets`, 52213 () => [...new Array(n2)].map((_) => p22.Offset32) 52214 ); 52215 } 52216 } 52217 getGlyphDataOffsetAndLength(glyphID) { 52218 let offset4 = this.offsets[glyphID] * this.x2 ? 2 : 1; 52219 let nextOffset = this.offsets[glyphID + 1] * this.x2 ? 2 : 1; 52220 return { offset: offset4, length: nextOffset - offset4 }; 52221 } 52222 }; 52223 var loca$1 = Object.freeze({ __proto__: null, loca }); 52224 var prep = class extends SimpleTable { 52225 constructor(dict, dataview) { 52226 const { p: p22 } = super(dict, dataview); 52227 lazy$1( 52228 this, 52229 `instructions`, 52230 () => [...new Array(dict.length)].map((_) => p22.uint8) 52231 ); 52232 } 52233 }; 52234 var prep$1 = Object.freeze({ __proto__: null, prep }); 52235 var CFF = class extends SimpleTable { 52236 constructor(dict, dataview) { 52237 const { p: p22 } = super(dict, dataview); 52238 lazy$1(this, `data`, () => p22.readBytes()); 52239 } 52240 }; 52241 var CFF$1 = Object.freeze({ __proto__: null, CFF }); 52242 var CFF2 = class extends SimpleTable { 52243 constructor(dict, dataview) { 52244 const { p: p22 } = super(dict, dataview); 52245 lazy$1(this, `data`, () => p22.readBytes()); 52246 } 52247 }; 52248 var CFF2$1 = Object.freeze({ __proto__: null, CFF2 }); 52249 var VORG = class extends SimpleTable { 52250 constructor(dict, dataview) { 52251 const { p: p22 } = super(dict, dataview); 52252 this.majorVersion = p22.uint16; 52253 this.minorVersion = p22.uint16; 52254 this.defaultVertOriginY = p22.int16; 52255 this.numVertOriginYMetrics = p22.uint16; 52256 lazy$1( 52257 this, 52258 `vertORiginYMetrics`, 52259 () => [...new Array(this.numVertOriginYMetrics)].map( 52260 (_) => new VertOriginYMetric(p22) 52261 ) 52262 ); 52263 } 52264 }; 52265 var VertOriginYMetric = class { 52266 constructor(p22) { 52267 this.glyphIndex = p22.uint16; 52268 this.vertOriginY = p22.int16; 52269 } 52270 }; 52271 var VORG$1 = Object.freeze({ __proto__: null, VORG }); 52272 var BitmapSize = class { 52273 constructor(p22) { 52274 this.indexSubTableArrayOffset = p22.Offset32; 52275 this.indexTablesSize = p22.uint32; 52276 this.numberofIndexSubTables = p22.uint32; 52277 this.colorRef = p22.uint32; 52278 this.hori = new SbitLineMetrics(p22); 52279 this.vert = new SbitLineMetrics(p22); 52280 this.startGlyphIndex = p22.uint16; 52281 this.endGlyphIndex = p22.uint16; 52282 this.ppemX = p22.uint8; 52283 this.ppemY = p22.uint8; 52284 this.bitDepth = p22.uint8; 52285 this.flags = p22.int8; 52286 } 52287 }; 52288 var BitmapScale = class { 52289 constructor(p22) { 52290 this.hori = new SbitLineMetrics(p22); 52291 this.vert = new SbitLineMetrics(p22); 52292 this.ppemX = p22.uint8; 52293 this.ppemY = p22.uint8; 52294 this.substitutePpemX = p22.uint8; 52295 this.substitutePpemY = p22.uint8; 52296 } 52297 }; 52298 var SbitLineMetrics = class { 52299 constructor(p22) { 52300 this.ascender = p22.int8; 52301 this.descender = p22.int8; 52302 this.widthMax = p22.uint8; 52303 this.caretSlopeNumerator = p22.int8; 52304 this.caretSlopeDenominator = p22.int8; 52305 this.caretOffset = p22.int8; 52306 this.minOriginSB = p22.int8; 52307 this.minAdvanceSB = p22.int8; 52308 this.maxBeforeBL = p22.int8; 52309 this.minAfterBL = p22.int8; 52310 this.pad1 = p22.int8; 52311 this.pad2 = p22.int8; 52312 } 52313 }; 52314 var EBLC = class extends SimpleTable { 52315 constructor(dict, dataview, name2) { 52316 const { p: p22 } = super(dict, dataview, name2); 52317 this.majorVersion = p22.uint16; 52318 this.minorVersion = p22.uint16; 52319 this.numSizes = p22.uint32; 52320 lazy$1( 52321 this, 52322 `bitMapSizes`, 52323 () => [...new Array(this.numSizes)].map( 52324 (_) => new BitmapSize(p22) 52325 ) 52326 ); 52327 } 52328 }; 52329 var EBLC$1 = Object.freeze({ __proto__: null, EBLC }); 52330 var EBDT = class extends SimpleTable { 52331 constructor(dict, dataview, name2) { 52332 const { p: p22 } = super(dict, dataview, name2); 52333 this.majorVersion = p22.uint16; 52334 this.minorVersion = p22.uint16; 52335 } 52336 }; 52337 var EBDT$1 = Object.freeze({ __proto__: null, EBDT }); 52338 var EBSC = class extends SimpleTable { 52339 constructor(dict, dataview) { 52340 const { p: p22 } = super(dict, dataview); 52341 this.majorVersion = p22.uint16; 52342 this.minorVersion = p22.uint16; 52343 this.numSizes = p22.uint32; 52344 lazy$1( 52345 this, 52346 `bitmapScales`, 52347 () => [...new Array(this.numSizes)].map( 52348 (_) => new BitmapScale(p22) 52349 ) 52350 ); 52351 } 52352 }; 52353 var EBSC$1 = Object.freeze({ __proto__: null, EBSC }); 52354 var CBLC = class extends EBLC { 52355 constructor(dict, dataview) { 52356 super(dict, dataview, `CBLC`); 52357 } 52358 }; 52359 var CBLC$1 = Object.freeze({ __proto__: null, CBLC }); 52360 var CBDT = class extends EBDT { 52361 constructor(dict, dataview) { 52362 super(dict, dataview, `CBDT`); 52363 } 52364 }; 52365 var CBDT$1 = Object.freeze({ __proto__: null, CBDT }); 52366 var sbix = class extends SimpleTable { 52367 constructor(dict, dataview) { 52368 const { p: p22 } = super(dict, dataview); 52369 this.version = p22.uint16; 52370 this.flags = p22.flags(16); 52371 this.numStrikes = p22.uint32; 52372 lazy$1( 52373 this, 52374 `strikeOffsets`, 52375 () => [...new Array(this.numStrikes)].map((_) => p22.Offset32) 52376 ); 52377 } 52378 }; 52379 var sbix$1 = Object.freeze({ __proto__: null, sbix }); 52380 var COLR = class extends SimpleTable { 52381 constructor(dict, dataview) { 52382 const { p: p22 } = super(dict, dataview); 52383 this.version = p22.uint16; 52384 this.numBaseGlyphRecords = p22.uint16; 52385 this.baseGlyphRecordsOffset = p22.Offset32; 52386 this.layerRecordsOffset = p22.Offset32; 52387 this.numLayerRecords = p22.uint16; 52388 } 52389 getBaseGlyphRecord(glyphID) { 52390 let start2 = this.tableStart + this.baseGlyphRecordsOffset; 52391 this.parser.currentPosition = start2; 52392 let first = new BaseGlyphRecord(this.parser); 52393 let firstID = first.gID; 52394 let end = this.tableStart + this.layerRecordsOffset - 6; 52395 this.parser.currentPosition = end; 52396 let last = new BaseGlyphRecord(this.parser); 52397 let lastID = last.gID; 52398 if (firstID === glyphID) return first; 52399 if (lastID === glyphID) return last; 52400 while (true) { 52401 if (start2 === end) break; 52402 let mid = start2 + (end - start2) / 12; 52403 this.parser.currentPosition = mid; 52404 let middle = new BaseGlyphRecord(this.parser); 52405 let midID = middle.gID; 52406 if (midID === glyphID) return middle; 52407 else if (midID > glyphID) { 52408 end = mid; 52409 } else if (midID < glyphID) { 52410 start2 = mid; 52411 } 52412 } 52413 return false; 52414 } 52415 getLayers(glyphID) { 52416 let record = this.getBaseGlyphRecord(glyphID); 52417 this.parser.currentPosition = this.tableStart + this.layerRecordsOffset + 4 * record.firstLayerIndex; 52418 return [...new Array(record.numLayers)].map( 52419 (_) => new LayerRecord(p) 52420 ); 52421 } 52422 }; 52423 var BaseGlyphRecord = class { 52424 constructor(p22) { 52425 this.gID = p22.uint16; 52426 this.firstLayerIndex = p22.uint16; 52427 this.numLayers = p22.uint16; 52428 } 52429 }; 52430 var LayerRecord = class { 52431 constructor(p22) { 52432 this.gID = p22.uint16; 52433 this.paletteIndex = p22.uint16; 52434 } 52435 }; 52436 var COLR$1 = Object.freeze({ __proto__: null, COLR }); 52437 var CPAL = class extends SimpleTable { 52438 constructor(dict, dataview) { 52439 const { p: p22 } = super(dict, dataview); 52440 this.version = p22.uint16; 52441 this.numPaletteEntries = p22.uint16; 52442 const numPalettes = this.numPalettes = p22.uint16; 52443 this.numColorRecords = p22.uint16; 52444 this.offsetFirstColorRecord = p22.Offset32; 52445 this.colorRecordIndices = [...new Array(this.numPalettes)].map( 52446 (_) => p22.uint16 52447 ); 52448 lazy$1(this, `colorRecords`, () => { 52449 p22.currentPosition = this.tableStart + this.offsetFirstColorRecord; 52450 return [...new Array(this.numColorRecords)].map( 52451 (_) => new ColorRecord(p22) 52452 ); 52453 }); 52454 if (this.version === 1) { 52455 this.offsetPaletteTypeArray = p22.Offset32; 52456 this.offsetPaletteLabelArray = p22.Offset32; 52457 this.offsetPaletteEntryLabelArray = p22.Offset32; 52458 lazy$1(this, `paletteTypeArray`, () => { 52459 p22.currentPosition = this.tableStart + this.offsetPaletteTypeArray; 52460 return new PaletteTypeArray(p22, numPalettes); 52461 }); 52462 lazy$1(this, `paletteLabelArray`, () => { 52463 p22.currentPosition = this.tableStart + this.offsetPaletteLabelArray; 52464 return new PaletteLabelsArray(p22, numPalettes); 52465 }); 52466 lazy$1(this, `paletteEntryLabelArray`, () => { 52467 p22.currentPosition = this.tableStart + this.offsetPaletteEntryLabelArray; 52468 return new PaletteEntryLabelArray(p22, numPalettes); 52469 }); 52470 } 52471 } 52472 }; 52473 var ColorRecord = class { 52474 constructor(p22) { 52475 this.blue = p22.uint8; 52476 this.green = p22.uint8; 52477 this.red = p22.uint8; 52478 this.alpha = p22.uint8; 52479 } 52480 }; 52481 var PaletteTypeArray = class { 52482 constructor(p22, numPalettes) { 52483 this.paletteTypes = [...new Array(numPalettes)].map( 52484 (_) => p22.uint32 52485 ); 52486 } 52487 }; 52488 var PaletteLabelsArray = class { 52489 constructor(p22, numPalettes) { 52490 this.paletteLabels = [...new Array(numPalettes)].map( 52491 (_) => p22.uint16 52492 ); 52493 } 52494 }; 52495 var PaletteEntryLabelArray = class { 52496 constructor(p22, numPalettes) { 52497 this.paletteEntryLabels = [...new Array(numPalettes)].map( 52498 (_) => p22.uint16 52499 ); 52500 } 52501 }; 52502 var CPAL$1 = Object.freeze({ __proto__: null, CPAL }); 52503 var DSIG = class extends SimpleTable { 52504 constructor(dict, dataview) { 52505 const { p: p22 } = super(dict, dataview); 52506 this.version = p22.uint32; 52507 this.numSignatures = p22.uint16; 52508 this.flags = p22.uint16; 52509 this.signatureRecords = [...new Array(this.numSignatures)].map( 52510 (_) => new SignatureRecord(p22) 52511 ); 52512 } 52513 getData(signatureID) { 52514 const record = this.signatureRecords[signatureID]; 52515 this.parser.currentPosition = this.tableStart + record.offset; 52516 return new SignatureBlockFormat1(this.parser); 52517 } 52518 }; 52519 var SignatureRecord = class { 52520 constructor(p22) { 52521 this.format = p22.uint32; 52522 this.length = p22.uint32; 52523 this.offset = p22.Offset32; 52524 } 52525 }; 52526 var SignatureBlockFormat1 = class { 52527 constructor(p22) { 52528 p22.uint16; 52529 p22.uint16; 52530 this.signatureLength = p22.uint32; 52531 this.signature = p22.readBytes(this.signatureLength); 52532 } 52533 }; 52534 var DSIG$1 = Object.freeze({ __proto__: null, DSIG }); 52535 var hdmx = class extends SimpleTable { 52536 constructor(dict, dataview, tables) { 52537 const { p: p22 } = super(dict, dataview); 52538 const numGlyphs = tables.hmtx.numGlyphs; 52539 this.version = p22.uint16; 52540 this.numRecords = p22.int16; 52541 this.sizeDeviceRecord = p22.int32; 52542 this.records = [...new Array(numRecords)].map( 52543 (_) => new DeviceRecord(p22, numGlyphs) 52544 ); 52545 } 52546 }; 52547 var DeviceRecord = class { 52548 constructor(p22, numGlyphs) { 52549 this.pixelSize = p22.uint8; 52550 this.maxWidth = p22.uint8; 52551 this.widths = p22.readBytes(numGlyphs); 52552 } 52553 }; 52554 var hdmx$1 = Object.freeze({ __proto__: null, hdmx }); 52555 var kern = class extends SimpleTable { 52556 constructor(dict, dataview) { 52557 const { p: p22 } = super(dict, dataview); 52558 this.version = p22.uint16; 52559 this.nTables = p22.uint16; 52560 lazy$1(this, `tables`, () => { 52561 let offset4 = this.tableStart + 4; 52562 const tables = []; 52563 for (let i2 = 0; i2 < this.nTables; i2++) { 52564 p22.currentPosition = offset4; 52565 let subtable = new KernSubTable(p22); 52566 tables.push(subtable); 52567 offset4 += subtable; 52568 } 52569 return tables; 52570 }); 52571 } 52572 }; 52573 var KernSubTable = class { 52574 constructor(p22) { 52575 this.version = p22.uint16; 52576 this.length = p22.uint16; 52577 this.coverage = p22.flags(8); 52578 this.format = p22.uint8; 52579 if (this.format === 0) { 52580 this.nPairs = p22.uint16; 52581 this.searchRange = p22.uint16; 52582 this.entrySelector = p22.uint16; 52583 this.rangeShift = p22.uint16; 52584 lazy$1( 52585 this, 52586 `pairs`, 52587 () => [...new Array(this.nPairs)].map((_) => new Pair(p22)) 52588 ); 52589 } 52590 if (this.format === 2) { 52591 console.warn( 52592 `Kern subtable format 2 is not supported: this parser currently only parses universal table data.` 52593 ); 52594 } 52595 } 52596 get horizontal() { 52597 return this.coverage[0]; 52598 } 52599 get minimum() { 52600 return this.coverage[1]; 52601 } 52602 get crossstream() { 52603 return this.coverage[2]; 52604 } 52605 get override() { 52606 return this.coverage[3]; 52607 } 52608 }; 52609 var Pair = class { 52610 constructor(p22) { 52611 this.left = p22.uint16; 52612 this.right = p22.uint16; 52613 this.value = p22.fword; 52614 } 52615 }; 52616 var kern$1 = Object.freeze({ __proto__: null, kern }); 52617 var LTSH = class extends SimpleTable { 52618 constructor(dict, dataview) { 52619 const { p: p22 } = super(dict, dataview); 52620 this.version = p22.uint16; 52621 this.numGlyphs = p22.uint16; 52622 this.yPels = p22.readBytes(this.numGlyphs); 52623 } 52624 }; 52625 var LTSH$1 = Object.freeze({ __proto__: null, LTSH }); 52626 var MERG = class extends SimpleTable { 52627 constructor(dict, dataview) { 52628 const { p: p22 } = super(dict, dataview); 52629 this.version = p22.uint16; 52630 this.mergeClassCount = p22.uint16; 52631 this.mergeDataOffset = p22.Offset16; 52632 this.classDefCount = p22.uint16; 52633 this.offsetToClassDefOffsets = p22.Offset16; 52634 lazy$1( 52635 this, 52636 `mergeEntryMatrix`, 52637 () => [...new Array(this.mergeClassCount)].map( 52638 (_) => p22.readBytes(this.mergeClassCount) 52639 ) 52640 ); 52641 console.warn(`Full MERG parsing is currently not supported.`); 52642 console.warn( 52643 `If you need this table parsed, please file an issue, or better yet, a PR.` 52644 ); 52645 } 52646 }; 52647 var MERG$1 = Object.freeze({ __proto__: null, MERG }); 52648 var meta = class extends SimpleTable { 52649 constructor(dict, dataview) { 52650 const { p: p22 } = super(dict, dataview); 52651 this.version = p22.uint32; 52652 this.flags = p22.uint32; 52653 p22.uint32; 52654 this.dataMapsCount = p22.uint32; 52655 this.dataMaps = [...new Array(this.dataMapsCount)].map( 52656 (_) => new DataMap(this.tableStart, p22) 52657 ); 52658 } 52659 }; 52660 var DataMap = class { 52661 constructor(tableStart, p22) { 52662 this.tableStart = tableStart; 52663 this.parser = p22; 52664 this.tag = p22.tag; 52665 this.dataOffset = p22.Offset32; 52666 this.dataLength = p22.uint32; 52667 } 52668 getData() { 52669 this.parser.currentField = this.tableStart + this.dataOffset; 52670 return this.parser.readBytes(this.dataLength); 52671 } 52672 }; 52673 var meta$1 = Object.freeze({ __proto__: null, meta }); 52674 var PCLT = class extends SimpleTable { 52675 constructor(dict, dataview) { 52676 super(dict, dataview); 52677 console.warn( 52678 `This font uses a PCLT table, which is currently not supported by this parser.` 52679 ); 52680 console.warn( 52681 `If you need this table parsed, please file an issue, or better yet, a PR.` 52682 ); 52683 } 52684 }; 52685 var PCLT$1 = Object.freeze({ __proto__: null, PCLT }); 52686 var VDMX = class extends SimpleTable { 52687 constructor(dict, dataview) { 52688 const { p: p22 } = super(dict, dataview); 52689 this.version = p22.uint16; 52690 this.numRecs = p22.uint16; 52691 this.numRatios = p22.uint16; 52692 this.ratRanges = [...new Array(this.numRatios)].map( 52693 (_) => new RatioRange(p22) 52694 ); 52695 this.offsets = [...new Array(this.numRatios)].map( 52696 (_) => p22.Offset16 52697 ); 52698 this.VDMXGroups = [...new Array(this.numRecs)].map( 52699 (_) => new VDMXGroup(p22) 52700 ); 52701 } 52702 }; 52703 var RatioRange = class { 52704 constructor(p22) { 52705 this.bCharSet = p22.uint8; 52706 this.xRatio = p22.uint8; 52707 this.yStartRatio = p22.uint8; 52708 this.yEndRatio = p22.uint8; 52709 } 52710 }; 52711 var VDMXGroup = class { 52712 constructor(p22) { 52713 this.recs = p22.uint16; 52714 this.startsz = p22.uint8; 52715 this.endsz = p22.uint8; 52716 this.records = [...new Array(this.recs)].map( 52717 (_) => new vTable(p22) 52718 ); 52719 } 52720 }; 52721 var vTable = class { 52722 constructor(p22) { 52723 this.yPelHeight = p22.uint16; 52724 this.yMax = p22.int16; 52725 this.yMin = p22.int16; 52726 } 52727 }; 52728 var VDMX$1 = Object.freeze({ __proto__: null, VDMX }); 52729 var vhea = class extends SimpleTable { 52730 constructor(dict, dataview) { 52731 const { p: p22 } = super(dict, dataview); 52732 this.version = p22.fixed; 52733 this.ascent = this.vertTypoAscender = p22.int16; 52734 this.descent = this.vertTypoDescender = p22.int16; 52735 this.lineGap = this.vertTypoLineGap = p22.int16; 52736 this.advanceHeightMax = p22.int16; 52737 this.minTopSideBearing = p22.int16; 52738 this.minBottomSideBearing = p22.int16; 52739 this.yMaxExtent = p22.int16; 52740 this.caretSlopeRise = p22.int16; 52741 this.caretSlopeRun = p22.int16; 52742 this.caretOffset = p22.int16; 52743 this.reserved = p22.int16; 52744 this.reserved = p22.int16; 52745 this.reserved = p22.int16; 52746 this.reserved = p22.int16; 52747 this.metricDataFormat = p22.int16; 52748 this.numOfLongVerMetrics = p22.uint16; 52749 p22.verifyLength(); 52750 } 52751 }; 52752 var vhea$1 = Object.freeze({ __proto__: null, vhea }); 52753 var vmtx = class extends SimpleTable { 52754 constructor(dict, dataview, tables) { 52755 super(dict, dataview); 52756 const numOfLongVerMetrics = tables.vhea.numOfLongVerMetrics; 52757 const numGlyphs = tables.maxp.numGlyphs; 52758 const metricsStart = p.currentPosition; 52759 lazy(this, `vMetrics`, () => { 52760 p.currentPosition = metricsStart; 52761 return [...new Array(numOfLongVerMetrics)].map( 52762 (_) => new LongVertMetric(p.uint16, p.int16) 52763 ); 52764 }); 52765 if (numOfLongVerMetrics < numGlyphs) { 52766 const tsbStart = metricsStart + numOfLongVerMetrics * 4; 52767 lazy(this, `topSideBearings`, () => { 52768 p.currentPosition = tsbStart; 52769 return [...new Array(numGlyphs - numOfLongVerMetrics)].map( 52770 (_) => p.int16 52771 ); 52772 }); 52773 } 52774 } 52775 }; 52776 var LongVertMetric = class { 52777 constructor(h2, b2) { 52778 this.advanceHeight = h2; 52779 this.topSideBearing = b2; 52780 } 52781 }; 52782 var vmtx$1 = Object.freeze({ __proto__: null, vmtx }); 52783 52784 // packages/global-styles-ui/build-module/font-library/utils/make-families-from-faces.mjs 52785 var import_components98 = __toESM(require_components(), 1); 52786 var { kebabCase: kebabCase4 } = unlock6(import_components98.privateApis); 52787 52788 // packages/global-styles-ui/build-module/font-library/upload-fonts.mjs 52789 var import_jsx_runtime243 = __toESM(require_jsx_runtime(), 1); 52790 52791 // packages/global-styles-ui/build-module/font-library/modal.mjs 52792 var import_jsx_runtime244 = __toESM(require_jsx_runtime(), 1); 52793 var { Tabs } = unlock6(import_components100.privateApis); 52794 var DEFAULT_TAB = { 52795 id: "installed-fonts", 52796 title: (0, import_i18n92._x)("Library", "Font library") 52797 }; 52798 var UPLOAD_TAB = { 52799 id: "upload-fonts", 52800 title: (0, import_i18n92._x)("Upload", "noun") 52801 }; 52802 52803 // packages/global-styles-ui/build-module/font-family-item.mjs 52804 var import_i18n93 = __toESM(require_i18n(), 1); 52805 var import_components101 = __toESM(require_components(), 1); 52806 var import_element149 = __toESM(require_element(), 1); 52807 var import_jsx_runtime245 = __toESM(require_jsx_runtime(), 1); 52808 52809 // packages/global-styles-ui/build-module/font-families.mjs 52810 var import_jsx_runtime246 = __toESM(require_jsx_runtime(), 1); 52811 52812 // packages/global-styles-ui/build-module/font-sizes/font-sizes-count.mjs 52813 var import_i18n95 = __toESM(require_i18n(), 1); 52814 var import_components103 = __toESM(require_components(), 1); 52815 var import_jsx_runtime247 = __toESM(require_jsx_runtime(), 1); 52816 52817 // packages/global-styles-ui/build-module/screen-typography.mjs 52818 var import_jsx_runtime248 = __toESM(require_jsx_runtime(), 1); 52819 52820 // packages/global-styles-ui/build-module/screen-typography-element.mjs 52821 var import_i18n97 = __toESM(require_i18n(), 1); 52822 var import_components105 = __toESM(require_components(), 1); 52823 var import_element152 = __toESM(require_element(), 1); 52824 52825 // packages/global-styles-ui/build-module/typography-panel.mjs 52826 var import_block_editor11 = __toESM(require_block_editor(), 1); 52827 var import_jsx_runtime249 = __toESM(require_jsx_runtime(), 1); 52828 var { useSettingsForBlockElement: useSettingsForBlockElement4, TypographyPanel: StylesTypographyPanel2 } = unlock6(import_block_editor11.privateApis); 52829 52830 // packages/global-styles-ui/build-module/typography-preview.mjs 52831 var import_jsx_runtime250 = __toESM(require_jsx_runtime(), 1); 52832 52833 // packages/global-styles-ui/build-module/screen-typography-element.mjs 52834 var import_jsx_runtime251 = __toESM(require_jsx_runtime(), 1); 52835 var elements = { 52836 text: { 52837 description: (0, import_i18n97.__)("Manage the fonts used on the site."), 52838 title: (0, import_i18n97.__)("Text") 52839 }, 52840 link: { 52841 description: (0, import_i18n97.__)("Manage the fonts and typography used on the links."), 52842 title: (0, import_i18n97.__)("Links") 52843 }, 52844 heading: { 52845 description: (0, import_i18n97.__)("Manage the fonts and typography used on headings."), 52846 title: (0, import_i18n97.__)("Headings") 52847 }, 52848 caption: { 52849 description: (0, import_i18n97.__)("Manage the fonts and typography used on captions."), 52850 title: (0, import_i18n97.__)("Captions") 52851 }, 52852 button: { 52853 description: (0, import_i18n97.__)("Manage the fonts and typography used on buttons."), 52854 title: (0, import_i18n97.__)("Buttons") 52855 } 52856 }; 52857 52858 // packages/global-styles-ui/build-module/screen-colors.mjs 52859 var import_i18n99 = __toESM(require_i18n(), 1); 52860 var import_components108 = __toESM(require_components(), 1); 52861 var import_block_editor12 = __toESM(require_block_editor(), 1); 52862 52863 // packages/global-styles-ui/build-module/palette.mjs 52864 var import_components107 = __toESM(require_components(), 1); 52865 var import_i18n98 = __toESM(require_i18n(), 1); 52866 var import_element153 = __toESM(require_element(), 1); 52867 52868 // packages/global-styles-ui/build-module/color-indicator-wrapper.mjs 52869 var import_components106 = __toESM(require_components(), 1); 52870 var import_jsx_runtime252 = __toESM(require_jsx_runtime(), 1); 52871 52872 // packages/global-styles-ui/build-module/palette.mjs 52873 var import_jsx_runtime253 = __toESM(require_jsx_runtime(), 1); 52874 52875 // packages/global-styles-ui/build-module/screen-colors.mjs 52876 var import_jsx_runtime254 = __toESM(require_jsx_runtime(), 1); 52877 var { useSettingsForBlockElement: useSettingsForBlockElement5, ColorPanel: StylesColorPanel2 } = unlock6( 52878 import_block_editor12.privateApis 52879 ); 52880 52881 // packages/global-styles-ui/build-module/screen-color-palette.mjs 52882 var import_i18n102 = __toESM(require_i18n(), 1); 52883 52884 // packages/global-styles-ui/build-module/color-palette-panel.mjs 52885 var import_compose25 = __toESM(require_compose(), 1); 52886 var import_components111 = __toESM(require_components(), 1); 52887 var import_i18n100 = __toESM(require_i18n(), 1); 52888 52889 // packages/global-styles-ui/build-module/variations/variations-color.mjs 52890 var import_components110 = __toESM(require_components(), 1); 52891 52892 // packages/global-styles-ui/build-module/preview-colors.mjs 52893 var import_components109 = __toESM(require_components(), 1); 52894 52895 // packages/global-styles-ui/build-module/preset-colors.mjs 52896 var import_jsx_runtime255 = __toESM(require_jsx_runtime(), 1); 52897 function PresetColors() { 52898 const { paletteColors } = useStylesPreviewColors(); 52899 return paletteColors.slice(0, 4).map(({ slug, color }, index2) => /* @__PURE__ */ (0, import_jsx_runtime255.jsx)( 52900 "div", 52901 { 52902 style: { 52903 flexGrow: 1, 52904 height: "100%", 52905 background: color 52906 } 52907 }, 52908 `$slug}-$index2}` 52909 )); 52910 } 52911 52912 // packages/global-styles-ui/build-module/preview-colors.mjs 52913 var import_jsx_runtime256 = __toESM(require_jsx_runtime(), 1); 52914 var firstFrameVariants2 = { 52915 start: { 52916 scale: 1, 52917 opacity: 1 52918 }, 52919 hover: { 52920 scale: 0, 52921 opacity: 0 52922 } 52923 }; 52924 var StylesPreviewColors = ({ 52925 label, 52926 isFocused, 52927 withHoverView 52928 }) => { 52929 return /* @__PURE__ */ (0, import_jsx_runtime256.jsx)( 52930 preview_wrapper_default, 52931 { 52932 label, 52933 isFocused, 52934 withHoverView, 52935 children: ({ key }) => /* @__PURE__ */ (0, import_jsx_runtime256.jsx)( 52936 import_components109.__unstableMotion.div, 52937 { 52938 variants: firstFrameVariants2, 52939 style: { 52940 height: "100%", 52941 overflow: "hidden" 52942 }, 52943 children: /* @__PURE__ */ (0, import_jsx_runtime256.jsx)( 52944 import_components109.__experimentalHStack, 52945 { 52946 spacing: 0, 52947 justify: "center", 52948 style: { 52949 height: "100%", 52950 overflow: "hidden" 52951 }, 52952 children: /* @__PURE__ */ (0, import_jsx_runtime256.jsx)(PresetColors, {}) 52953 } 52954 ) 52955 }, 52956 key 52957 ) 52958 } 52959 ); 52960 }; 52961 var preview_colors_default = StylesPreviewColors; 52962 52963 // packages/global-styles-ui/build-module/variations/variations-color.mjs 52964 var import_jsx_runtime257 = __toESM(require_jsx_runtime(), 1); 52965 var propertiesToFilter2 = ["color"]; 52966 function ColorVariations({ 52967 title, 52968 gap = 2 52969 }) { 52970 const colorVariations = useCurrentMergeThemeStyleVariationsWithUserConfig(propertiesToFilter2); 52971 if (colorVariations?.length <= 1) { 52972 return null; 52973 } 52974 return /* @__PURE__ */ (0, import_jsx_runtime257.jsxs)(import_components110.__experimentalVStack, { spacing: 3, children: [ 52975 title && /* @__PURE__ */ (0, import_jsx_runtime257.jsx)(Subtitle, { level: 3, children: title }), 52976 /* @__PURE__ */ (0, import_jsx_runtime257.jsx)(import_components110.__experimentalGrid, { gap, children: colorVariations.map((variation, index2) => /* @__PURE__ */ (0, import_jsx_runtime257.jsx)( 52977 Variation, 52978 { 52979 variation, 52980 isPill: true, 52981 properties: propertiesToFilter2, 52982 showTooltip: true, 52983 children: () => /* @__PURE__ */ (0, import_jsx_runtime257.jsx)(preview_colors_default, {}) 52984 }, 52985 index2 52986 )) }) 52987 ] }); 52988 } 52989 52990 // packages/global-styles-ui/build-module/color-palette-panel.mjs 52991 var import_jsx_runtime258 = __toESM(require_jsx_runtime(), 1); 52992 52993 // packages/global-styles-ui/build-module/gradients-palette-panel.mjs 52994 var import_compose26 = __toESM(require_compose(), 1); 52995 var import_components112 = __toESM(require_components(), 1); 52996 var import_i18n101 = __toESM(require_i18n(), 1); 52997 var import_jsx_runtime259 = __toESM(require_jsx_runtime(), 1); 52998 52999 // packages/global-styles-ui/build-module/screen-color-palette.mjs 53000 var import_jsx_runtime260 = __toESM(require_jsx_runtime(), 1); 53001 53002 // packages/global-styles-ui/build-module/screen-background.mjs 53003 var import_i18n103 = __toESM(require_i18n(), 1); 53004 var import_block_editor14 = __toESM(require_block_editor(), 1); 53005 var import_components113 = __toESM(require_components(), 1); 53006 53007 // packages/global-styles-ui/build-module/background-panel.mjs 53008 var import_block_editor13 = __toESM(require_block_editor(), 1); 53009 var import_jsx_runtime261 = __toESM(require_jsx_runtime(), 1); 53010 var { BackgroundPanel: StylesBackgroundPanel2 } = unlock6( 53011 import_block_editor13.privateApis 53012 ); 53013 53014 // packages/global-styles-ui/build-module/screen-background.mjs 53015 var import_jsx_runtime262 = __toESM(require_jsx_runtime(), 1); 53016 var { useHasBackgroundPanel: useHasBackgroundPanel4 } = unlock6(import_block_editor14.privateApis); 53017 53018 // packages/global-styles-ui/build-module/shadows-panel.mjs 53019 var import_components115 = __toESM(require_components(), 1); 53020 var import_i18n105 = __toESM(require_i18n(), 1); 53021 var import_element154 = __toESM(require_element(), 1); 53022 53023 // packages/global-styles-ui/build-module/confirm-reset-shadow-dialog.mjs 53024 var import_components114 = __toESM(require_components(), 1); 53025 var import_i18n104 = __toESM(require_i18n(), 1); 53026 var import_jsx_runtime263 = __toESM(require_jsx_runtime(), 1); 53027 53028 // packages/global-styles-ui/build-module/shadows-panel.mjs 53029 var import_jsx_runtime264 = __toESM(require_jsx_runtime(), 1); 53030 var { Menu: Menu6 } = unlock6(import_components115.privateApis); 53031 53032 // packages/global-styles-ui/build-module/shadows-edit-panel.mjs 53033 var import_components116 = __toESM(require_components(), 1); 53034 var import_i18n106 = __toESM(require_i18n(), 1); 53035 var import_element155 = __toESM(require_element(), 1); 53036 var import_jsx_runtime265 = __toESM(require_jsx_runtime(), 1); 53037 var { Menu: Menu7 } = unlock6(import_components116.privateApis); 53038 var customShadowMenuItems = [ 53039 { 53040 label: (0, import_i18n106.__)("Rename"), 53041 action: "rename" 53042 }, 53043 { 53044 label: (0, import_i18n106.__)("Delete"), 53045 action: "delete" 53046 } 53047 ]; 53048 var presetShadowMenuItems = [ 53049 { 53050 label: (0, import_i18n106.__)("Reset"), 53051 action: "reset" 53052 } 53053 ]; 53054 53055 // packages/global-styles-ui/build-module/screen-shadows.mjs 53056 var import_jsx_runtime266 = __toESM(require_jsx_runtime(), 1); 53057 53058 // packages/global-styles-ui/build-module/screen-layout.mjs 53059 var import_i18n107 = __toESM(require_i18n(), 1); 53060 var import_block_editor16 = __toESM(require_block_editor(), 1); 53061 53062 // packages/global-styles-ui/build-module/dimensions-panel.mjs 53063 var import_block_editor15 = __toESM(require_block_editor(), 1); 53064 var import_element156 = __toESM(require_element(), 1); 53065 var import_jsx_runtime267 = __toESM(require_jsx_runtime(), 1); 53066 var { useSettingsForBlockElement: useSettingsForBlockElement6, DimensionsPanel: StylesDimensionsPanel2 } = unlock6(import_block_editor15.privateApis); 53067 53068 // packages/global-styles-ui/build-module/screen-layout.mjs 53069 var import_jsx_runtime268 = __toESM(require_jsx_runtime(), 1); 53070 var { useHasDimensionsPanel: useHasDimensionsPanel4, useSettingsForBlockElement: useSettingsForBlockElement7 } = unlock6( 53071 import_block_editor16.privateApis 53072 ); 53073 53074 // packages/global-styles-ui/build-module/screen-style-variations.mjs 53075 var import_components119 = __toESM(require_components(), 1); 53076 var import_i18n110 = __toESM(require_i18n(), 1); 53077 53078 // packages/global-styles-ui/build-module/style-variations-content.mjs 53079 var import_i18n109 = __toESM(require_i18n(), 1); 53080 var import_components118 = __toESM(require_components(), 1); 53081 53082 // packages/global-styles-ui/build-module/style-variations-container.mjs 53083 var import_core_data33 = __toESM(require_core_data(), 1); 53084 var import_data51 = __toESM(require_data(), 1); 53085 var import_element157 = __toESM(require_element(), 1); 53086 var import_components117 = __toESM(require_components(), 1); 53087 var import_i18n108 = __toESM(require_i18n(), 1); 53088 var import_jsx_runtime269 = __toESM(require_jsx_runtime(), 1); 53089 function StyleVariationsContainer({ 53090 gap = 2 53091 }) { 53092 const { user } = (0, import_element157.useContext)(GlobalStylesContext); 53093 const userStyles = user?.styles; 53094 const variations = (0, import_data51.useSelect)((select4) => { 53095 const result = select4( 53096 import_core_data33.store 53097 ).__experimentalGetCurrentThemeGlobalStylesVariations(); 53098 return Array.isArray(result) ? result : void 0; 53099 }, []); 53100 const fullStyleVariations = variations?.filter( 53101 (variation) => { 53102 return !isVariationWithProperties(variation, ["color"]) && !isVariationWithProperties(variation, [ 53103 "typography", 53104 "spacing" 53105 ]); 53106 } 53107 ); 53108 const themeVariations = (0, import_element157.useMemo)(() => { 53109 const withEmptyVariation = [ 53110 { 53111 title: (0, import_i18n108.__)("Default"), 53112 settings: {}, 53113 styles: {} 53114 }, 53115 ...fullStyleVariations ?? [] 53116 ]; 53117 return [ 53118 ...withEmptyVariation.map((variation) => { 53119 const blockStyles = variation?.styles?.blocks ? { ...variation.styles.blocks } : {}; 53120 if (userStyles?.blocks) { 53121 Object.keys(userStyles.blocks).forEach((blockName) => { 53122 if (userStyles.blocks?.[blockName]?.css) { 53123 const variationBlockStyles = blockStyles[blockName] || {}; 53124 const customCSS = { 53125 css: `$blockStyles[blockName]?.css || ""} $userStyles.blocks?.[blockName]?.css?.trim() || ""}` 53126 }; 53127 blockStyles[blockName] = { 53128 ...variationBlockStyles, 53129 ...customCSS 53130 }; 53131 } 53132 }); 53133 } 53134 const css = userStyles?.css || variation.styles?.css ? { 53135 css: `$variation.styles?.css || ""} $userStyles?.css || ""}` 53136 } : {}; 53137 const blocks = Object.keys(blockStyles).length > 0 ? { blocks: blockStyles } : {}; 53138 const styles = { 53139 ...variation.styles, 53140 ...css, 53141 ...blocks 53142 }; 53143 return { 53144 ...variation, 53145 settings: variation.settings ?? {}, 53146 styles 53147 }; 53148 }) 53149 ]; 53150 }, [fullStyleVariations, userStyles?.blocks, userStyles?.css]); 53151 if (!fullStyleVariations || fullStyleVariations.length < 1) { 53152 return null; 53153 } 53154 return /* @__PURE__ */ (0, import_jsx_runtime269.jsx)( 53155 import_components117.__experimentalGrid, 53156 { 53157 columns: 2, 53158 className: "global-styles-ui-style-variations-container", 53159 gap, 53160 children: themeVariations.map( 53161 (variation, index2) => /* @__PURE__ */ (0, import_jsx_runtime269.jsx)(Variation, { variation, children: (isFocused) => /* @__PURE__ */ (0, import_jsx_runtime269.jsx)( 53162 preview_styles_default, 53163 { 53164 label: variation?.title, 53165 withHoverView: true, 53166 isFocused, 53167 variation 53168 } 53169 ) }, index2) 53170 ) 53171 } 53172 ); 53173 } 53174 var style_variations_container_default = StyleVariationsContainer; 53175 53176 // packages/global-styles-ui/build-module/style-variations-content.mjs 53177 var import_jsx_runtime270 = __toESM(require_jsx_runtime(), 1); 53178 53179 // packages/global-styles-ui/build-module/screen-style-variations.mjs 53180 var import_jsx_runtime271 = __toESM(require_jsx_runtime(), 1); 53181 53182 // packages/global-styles-ui/build-module/screen-css.mjs 53183 var import_i18n111 = __toESM(require_i18n(), 1); 53184 var import_components120 = __toESM(require_components(), 1); 53185 var import_block_editor17 = __toESM(require_block_editor(), 1); 53186 var import_jsx_runtime272 = __toESM(require_jsx_runtime(), 1); 53187 var { AdvancedPanel: StylesAdvancedPanel2 } = unlock6(import_block_editor17.privateApis); 53188 53189 // packages/global-styles-ui/build-module/screen-revisions/index.mjs 53190 var import_i18n114 = __toESM(require_i18n(), 1); 53191 var import_components123 = __toESM(require_components(), 1); 53192 var import_element159 = __toESM(require_element(), 1); 53193 53194 // packages/global-styles-ui/build-module/screen-revisions/use-global-styles-revisions.mjs 53195 var import_data52 = __toESM(require_data(), 1); 53196 var import_core_data34 = __toESM(require_core_data(), 1); 53197 var import_element158 = __toESM(require_element(), 1); 53198 var SITE_EDITOR_AUTHORS_QUERY = { 53199 per_page: -1, 53200 _fields: "id,name,avatar_urls", 53201 context: "view", 53202 capabilities: ["edit_theme_options"] 53203 }; 53204 var DEFAULT_QUERY = { per_page: 100, page: 1 }; 53205 var EMPTY_ARRAY11 = []; 53206 function useGlobalStylesRevisions({ 53207 query 53208 } = {}) { 53209 const { user: userConfig } = (0, import_element158.useContext)(GlobalStylesContext); 53210 const _query = (0, import_element158.useMemo)( 53211 () => ({ ...DEFAULT_QUERY, ...query }), 53212 [query] 53213 ); 53214 const { 53215 authors, 53216 currentUser, 53217 isDirty, 53218 revisions, 53219 isLoadingGlobalStylesRevisions, 53220 revisionsCount 53221 } = (0, import_data52.useSelect)( 53222 (select4) => { 53223 const { 53224 __experimentalGetDirtyEntityRecords, 53225 getCurrentUser, 53226 getUsers, 53227 getRevisions, 53228 __experimentalGetCurrentGlobalStylesId, 53229 getEntityRecord, 53230 isResolving 53231 } = select4(import_core_data34.store); 53232 const dirtyEntityRecords = __experimentalGetDirtyEntityRecords() || []; 53233 const _currentUser = getCurrentUser(); 53234 const _isDirty = dirtyEntityRecords.length > 0; 53235 const globalStylesId = __experimentalGetCurrentGlobalStylesId(); 53236 const globalStyles = globalStylesId ? getEntityRecord( 53237 "root", 53238 "globalStyles", 53239 globalStylesId 53240 ) : void 0; 53241 const _revisionsCount = ( 53242 // @ts-expect-error - _links is not typed in GlobalStylesRevision 53243 globalStyles?._links?.["version-history"]?.[0]?.count ?? 0 53244 ); 53245 const globalStylesRevisions = globalStylesId ? getRevisions( 53246 "root", 53247 "globalStyles", 53248 globalStylesId, 53249 _query 53250 ) || EMPTY_ARRAY11 : EMPTY_ARRAY11; 53251 const _authors = getUsers(SITE_EDITOR_AUTHORS_QUERY) || EMPTY_ARRAY11; 53252 const _isResolving = globalStylesId ? isResolving("getRevisions", [ 53253 "root", 53254 "globalStyles", 53255 globalStylesId, 53256 _query 53257 ]) : false; 53258 return { 53259 authors: _authors, 53260 currentUser: _currentUser, 53261 isDirty: _isDirty, 53262 revisions: globalStylesRevisions, 53263 isLoadingGlobalStylesRevisions: _isResolving, 53264 revisionsCount: _revisionsCount 53265 }; 53266 }, 53267 [_query] 53268 ); 53269 return (0, import_element158.useMemo)(() => { 53270 if (!authors.length || isLoadingGlobalStylesRevisions) { 53271 return { 53272 revisions: EMPTY_ARRAY11, 53273 hasUnsavedChanges: isDirty, 53274 isLoading: true, 53275 revisionsCount 53276 }; 53277 } 53278 const _modifiedRevisions = revisions.map((revision) => { 53279 return { 53280 ...revision, 53281 author: authors.find( 53282 (author) => author.id === revision.author 53283 ) 53284 }; 53285 }); 53286 const fetchedRevisionsCount = revisions.length; 53287 if (fetchedRevisionsCount) { 53288 if (_modifiedRevisions[0].id !== "unsaved" && _query.page === 1) { 53289 _modifiedRevisions[0].isLatest = true; 53290 } 53291 if (isDirty && userConfig && Object.keys(userConfig).length > 0 && currentUser && _query.page === 1) { 53292 const unsavedRevision = { 53293 id: "unsaved", 53294 styles: userConfig?.styles, 53295 settings: userConfig?.settings, 53296 _links: userConfig?._links, 53297 author: { 53298 name: currentUser?.name || "", 53299 // @ts-expect-error - avatar_urls is not typed in User 53300 avatar_urls: currentUser?.avatar_urls || {} 53301 }, 53302 modified: /* @__PURE__ */ new Date() 53303 }; 53304 _modifiedRevisions.unshift(unsavedRevision); 53305 } 53306 if (_query.per_page && _query.page === Math.ceil(revisionsCount / _query.per_page)) { 53307 _modifiedRevisions.push({ 53308 id: "parent", 53309 styles: {}, 53310 settings: {} 53311 }); 53312 } 53313 } 53314 return { 53315 revisions: _modifiedRevisions, 53316 hasUnsavedChanges: isDirty, 53317 isLoading: false, 53318 revisionsCount 53319 }; 53320 }, [ 53321 isDirty, 53322 revisions, 53323 currentUser, 53324 authors, 53325 userConfig, 53326 isLoadingGlobalStylesRevisions, 53327 revisionsCount, 53328 _query.page, 53329 _query.per_page 53330 ]); 53331 } 53332 53333 // packages/global-styles-ui/build-module/screen-revisions/revisions-buttons.mjs 53334 var import_i18n112 = __toESM(require_i18n(), 1); 53335 var import_components121 = __toESM(require_components(), 1); 53336 var import_date10 = __toESM(require_date(), 1); 53337 var import_core_data35 = __toESM(require_core_data(), 1); 53338 var import_data53 = __toESM(require_data(), 1); 53339 var import_keycodes6 = __toESM(require_keycodes(), 1); 53340 var import_jsx_runtime273 = __toESM(require_jsx_runtime(), 1); 53341 var { Badge: WCBadge3 } = unlock6(import_components121.privateApis); 53342 var DAY_IN_MILLISECONDS = 60 * 60 * 1e3 * 24; 53343 53344 // packages/global-styles-ui/build-module/pagination/index.mjs 53345 var import_components122 = __toESM(require_components(), 1); 53346 var import_i18n113 = __toESM(require_i18n(), 1); 53347 var import_jsx_runtime274 = __toESM(require_jsx_runtime(), 1); 53348 53349 // packages/global-styles-ui/build-module/screen-revisions/index.mjs 53350 var import_jsx_runtime275 = __toESM(require_jsx_runtime(), 1); 53351 53352 // packages/global-styles-ui/build-module/font-sizes/font-sizes.mjs 53353 var import_i18n116 = __toESM(require_i18n(), 1); 53354 var import_components125 = __toESM(require_components(), 1); 53355 var import_element160 = __toESM(require_element(), 1); 53356 53357 // packages/global-styles-ui/build-module/font-sizes/confirm-reset-font-sizes-dialog.mjs 53358 var import_components124 = __toESM(require_components(), 1); 53359 var import_i18n115 = __toESM(require_i18n(), 1); 53360 var import_jsx_runtime276 = __toESM(require_jsx_runtime(), 1); 53361 53362 // packages/global-styles-ui/build-module/font-sizes/font-sizes.mjs 53363 var import_jsx_runtime277 = __toESM(require_jsx_runtime(), 1); 53364 var { Menu: Menu8 } = unlock6(import_components125.privateApis); 53365 53366 // packages/global-styles-ui/build-module/font-sizes/font-size.mjs 53367 var import_i18n120 = __toESM(require_i18n(), 1); 53368 var import_components129 = __toESM(require_components(), 1); 53369 var import_element162 = __toESM(require_element(), 1); 53370 53371 // packages/global-styles-ui/build-module/font-sizes/font-size-preview.mjs 53372 var import_block_editor18 = __toESM(require_block_editor(), 1); 53373 var import_i18n117 = __toESM(require_i18n(), 1); 53374 var import_jsx_runtime278 = __toESM(require_jsx_runtime(), 1); 53375 53376 // packages/global-styles-ui/build-module/font-sizes/confirm-delete-font-size-dialog.mjs 53377 var import_components126 = __toESM(require_components(), 1); 53378 var import_i18n118 = __toESM(require_i18n(), 1); 53379 var import_jsx_runtime279 = __toESM(require_jsx_runtime(), 1); 53380 53381 // packages/global-styles-ui/build-module/font-sizes/rename-font-size-dialog.mjs 53382 var import_components127 = __toESM(require_components(), 1); 53383 var import_i18n119 = __toESM(require_i18n(), 1); 53384 var import_element161 = __toESM(require_element(), 1); 53385 var import_jsx_runtime280 = __toESM(require_jsx_runtime(), 1); 53386 53387 // packages/global-styles-ui/build-module/size-control/index.mjs 53388 var import_components128 = __toESM(require_components(), 1); 53389 var import_jsx_runtime281 = __toESM(require_jsx_runtime(), 1); 53390 53391 // packages/global-styles-ui/build-module/font-sizes/font-size.mjs 53392 var import_jsx_runtime282 = __toESM(require_jsx_runtime(), 1); 53393 var { Menu: Menu9 } = unlock6(import_components129.privateApis); 53394 53395 // packages/global-styles-ui/build-module/global-styles-ui.mjs 53396 var import_jsx_runtime283 = __toESM(require_jsx_runtime(), 1); 53397 53398 // packages/global-styles-ui/build-module/with-global-styles-provider.mjs 53399 var import_jsx_runtime284 = __toESM(require_jsx_runtime(), 1); 53400 function withGlobalStylesProvider(Component) { 53401 return function WrappedComponent({ 53402 value, 53403 baseValue, 53404 onChange, 53405 ...props 53406 }) { 53407 return /* @__PURE__ */ (0, import_jsx_runtime284.jsx)( 53408 GlobalStylesProvider, 53409 { 53410 value, 53411 baseValue, 53412 onChange, 53413 children: /* @__PURE__ */ (0, import_jsx_runtime284.jsx)(Component, { ...props }) 53414 } 53415 ); 53416 }; 53417 } 53418 53419 // packages/global-styles-ui/build-module/style-variations.mjs 53420 var StyleVariations = withGlobalStylesProvider(style_variations_container_default); 53421 53422 // packages/global-styles-ui/build-module/color-variations.mjs 53423 var ColorVariations2 = withGlobalStylesProvider(ColorVariations); 53424 53425 // packages/global-styles-ui/build-module/typography-variations.mjs 53426 var TypographyVariations2 = withGlobalStylesProvider(TypographyVariations); 53427 53428 // packages/global-styles-ui/build-module/font-library/font-library.mjs 53429 var import_jsx_runtime285 = __toESM(require_jsx_runtime(), 1); 53430 53431 // packages/edit-site/build-module/components/sidebar-navigation-screen-details-footer/index.mjs 53432 var import_i18n121 = __toESM(require_i18n(), 1); 53433 var import_url12 = __toESM(require_url(), 1); 53434 var import_components131 = __toESM(require_components(), 1); 53435 var import_jsx_runtime286 = __toESM(require_jsx_runtime(), 1); 53436 function SidebarNavigationScreenDetailsFooter({ 53437 record, 53438 revisionsCount, 53439 ...otherProps 53440 }) { 53441 const hrefProps = {}; 53442 const lastRevisionId = record?._links?.["predecessor-version"]?.[0]?.id ?? null; 53443 revisionsCount = revisionsCount || record?._links?.["version-history"]?.[0]?.count || 0; 53444 if (lastRevisionId && revisionsCount > 1) { 53445 hrefProps.href = (0, import_url12.addQueryArgs)("revision.php", { 53446 revision: record?._links["predecessor-version"][0].id 53447 }); 53448 hrefProps.as = "a"; 53449 } 53450 return /* @__PURE__ */ (0, import_jsx_runtime286.jsx)( 53451 import_components131.__experimentalItemGroup, 53452 { 53453 size: "large", 53454 className: "edit-site-sidebar-navigation-screen-details-footer", 53455 children: /* @__PURE__ */ (0, import_jsx_runtime286.jsx)( 53456 SidebarNavigationItem, 53457 { 53458 icon: backup_default, 53459 ...hrefProps, 53460 ...otherProps, 53461 children: (0, import_i18n121.sprintf)( 53462 /* translators: %d: Number of Styles revisions. */ 53463 (0, import_i18n121._n)("%d Revision", "%d Revisions", revisionsCount), 53464 revisionsCount 53465 ) 53466 } 53467 ) 53468 } 53469 ); 53470 } 53471 53472 // packages/edit-site/build-module/components/sidebar-navigation-screen-global-styles/index.mjs 53473 var import_jsx_runtime287 = __toESM(require_jsx_runtime(), 1); 53474 var { useLocation: useLocation19, useHistory: useHistory12 } = unlock(import_router19.privateApis); 53475 function SidebarNavigationScreenGlobalStyles() { 53476 const history = useHistory12(); 53477 const { path } = useLocation19(); 53478 const { 53479 revisions, 53480 isLoading: isLoadingRevisions, 53481 revisionsCount 53482 } = useGlobalStylesRevisions(); 53483 const { openGeneralSidebar: openGeneralSidebar2 } = (0, import_data55.useDispatch)(store); 53484 const { setStylesPath } = unlock((0, import_data55.useDispatch)(import_editor23.store)); 53485 const { set: setPreference } = (0, import_data55.useDispatch)(import_preferences10.store); 53486 const openGlobalStyles = (0, import_element164.useCallback)(async () => { 53487 history.navigate((0, import_url13.addQueryArgs)(path, { canvas: "edit" }), { 53488 transition: "canvas-mode-edit-transition" 53489 }); 53490 return Promise.all([ 53491 setPreference("core", "distractionFree", false), 53492 openGeneralSidebar2("edit-site/global-styles") 53493 ]); 53494 }, [path, history, openGeneralSidebar2, setPreference]); 53495 const openRevisions = (0, import_element164.useCallback)(async () => { 53496 await openGlobalStyles(); 53497 setStylesPath("/revisions"); 53498 }, [openGlobalStyles, setStylesPath]); 53499 const shouldShowGlobalStylesFooter = !!revisionsCount && !isLoadingRevisions; 53500 return /* @__PURE__ */ (0, import_jsx_runtime287.jsx)(import_jsx_runtime287.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime287.jsx)( 53501 SidebarNavigationScreen, 53502 { 53503 title: (0, import_i18n122.__)("Design"), 53504 isRoot: true, 53505 description: (0, import_i18n122.__)( 53506 "Customize the appearance of your website using the block editor." 53507 ), 53508 content: /* @__PURE__ */ (0, import_jsx_runtime287.jsx)(MainSidebarNavigationContent, {}), 53509 footer: shouldShowGlobalStylesFooter && /* @__PURE__ */ (0, import_jsx_runtime287.jsx)( 53510 SidebarNavigationScreenDetailsFooter, 53511 { 53512 record: revisions?.[0], 53513 revisionsCount, 53514 onClick: openRevisions 53515 } 53516 ) 53517 } 53518 ) }); 53519 } 53520 53521 // packages/edit-site/build-module/components/sidebar-global-styles/index.mjs 53522 var import_i18n123 = __toESM(require_i18n(), 1); 53523 var import_element165 = __toESM(require_element(), 1); 53524 var import_router20 = __toESM(require_router(), 1); 53525 var import_editor24 = __toESM(require_editor(), 1); 53526 var import_compose28 = __toESM(require_compose(), 1); 53527 var import_data56 = __toESM(require_data(), 1); 53528 var import_components132 = __toESM(require_components(), 1); 53529 var import_url14 = __toESM(require_url(), 1); 53530 var import_jsx_runtime288 = __toESM(require_jsx_runtime(), 1); 53531 var { GlobalStylesUIWrapper, GlobalStylesActionMenu } = unlock(import_editor24.privateApis); 53532 var { useLocation: useLocation20, useHistory: useHistory13 } = unlock(import_router20.privateApis); 53533 var GlobalStylesPageActions = ({ 53534 isStyleBookOpened, 53535 setIsStyleBookOpened, 53536 path, 53537 onChangeSection 53538 }) => { 53539 const history = useHistory13(); 53540 return /* @__PURE__ */ (0, import_jsx_runtime288.jsxs)(import_components132.__experimentalHStack, { className: "edit-site-styles__header-actions", children: [ 53541 /* @__PURE__ */ (0, import_jsx_runtime288.jsx)( 53542 import_components132.Button, 53543 { 53544 isPressed: isStyleBookOpened, 53545 icon: seen_default, 53546 label: (0, import_i18n123.__)("Style Book"), 53547 onClick: () => { 53548 setIsStyleBookOpened(!isStyleBookOpened); 53549 const updatedPath = !isStyleBookOpened ? (0, import_url14.addQueryArgs)(path, { preview: "stylebook" }) : (0, import_url14.removeQueryArgs)(path, "preview"); 53550 history.navigate(updatedPath); 53551 }, 53552 size: "compact" 53553 } 53554 ), 53555 /* @__PURE__ */ (0, import_jsx_runtime288.jsx)( 53556 GlobalStylesActionMenu, 53557 { 53558 hideWelcomeGuide: true, 53559 onChangePath: onChangeSection 53560 } 53561 ) 53562 ] }); 53563 }; 53564 var useSection = () => { 53565 const { path, query } = useLocation20(); 53566 const history = useHistory13(); 53567 return (0, import_element165.useMemo)(() => { 53568 return [ 53569 query.section ?? "/", 53570 (updatedSection) => { 53571 history.navigate( 53572 (0, import_url14.addQueryArgs)(path, { 53573 section: updatedSection 53574 }) 53575 ); 53576 } 53577 ]; 53578 }, [path, query.section, history]); 53579 }; 53580 function SidebarGlobalStyles() { 53581 const { path } = useLocation20(); 53582 const [isStyleBookOpened, setIsStyleBookOpened] = (0, import_element165.useState)( 53583 path.includes("preview=stylebook") 53584 ); 53585 const isMobileViewport = (0, import_compose28.useViewportMatch)("medium", "<"); 53586 const [section, onChangeSection] = useSection(); 53587 const settings2 = (0, import_data56.useSelect)( 53588 (select4) => select4(store).getSettings(), 53589 [] 53590 ); 53591 return /* @__PURE__ */ (0, import_jsx_runtime288.jsx)( 53592 page_default2, 53593 { 53594 actions: !isMobileViewport ? /* @__PURE__ */ (0, import_jsx_runtime288.jsx)( 53595 GlobalStylesPageActions, 53596 { 53597 isStyleBookOpened, 53598 setIsStyleBookOpened, 53599 path, 53600 onChangeSection 53601 } 53602 ) : null, 53603 className: "edit-site-styles", 53604 title: (0, import_i18n123.__)("Styles"), 53605 headingLevel: 2, 53606 children: /* @__PURE__ */ (0, import_jsx_runtime288.jsx)( 53607 GlobalStylesUIWrapper, 53608 { 53609 path: section, 53610 onPathChange: onChangeSection, 53611 settings: settings2 53612 } 53613 ) 53614 } 53615 ); 53616 } 53617 53618 // packages/edit-site/build-module/components/site-editor-routes/styles.mjs 53619 var import_jsx_runtime289 = __toESM(require_jsx_runtime(), 1); 53620 var { useLocation: useLocation21, useHistory: useHistory14 } = unlock(import_router21.privateApis); 53621 var { StyleBookPreview, useGlobalStyles: useGlobalStyles3 } = unlock(import_editor25.privateApis); 53622 function StyleBookPreviewArea({ siteData }) { 53623 const { path, query } = useLocation21(); 53624 const history = useHistory14(); 53625 const { user: userConfig } = useGlobalStyles3(); 53626 const section = query.section ?? "/"; 53627 const onChangeSection = (updatedSection) => { 53628 history.navigate( 53629 (0, import_url15.addQueryArgs)(path, { 53630 section: updatedSection 53631 }) 53632 ); 53633 }; 53634 return /* @__PURE__ */ (0, import_jsx_runtime289.jsx)( 53635 StyleBookPreview, 53636 { 53637 path: section, 53638 onPathChange: onChangeSection, 53639 settings: siteData.editorSettings, 53640 userConfig 53641 } 53642 ); 53643 } 53644 function StylesPreviewArea({ siteData }) { 53645 const { query } = useLocation21(); 53646 if (query.preview === "stylebook") { 53647 return /* @__PURE__ */ (0, import_jsx_runtime289.jsx)(StyleBookPreviewArea, { siteData }); 53648 } 53649 return /* @__PURE__ */ (0, import_jsx_runtime289.jsx)(EditSiteEditor, {}); 53650 } 53651 var stylesRoute = { 53652 name: "styles", 53653 path: "/styles", 53654 areas: { 53655 content: /* @__PURE__ */ (0, import_jsx_runtime289.jsx)(SidebarGlobalStyles, {}), 53656 sidebar: /* @__PURE__ */ (0, import_jsx_runtime289.jsx)(SidebarNavigationScreenGlobalStyles, { backPath: "/" }), 53657 preview: ({ siteData }) => /* @__PURE__ */ (0, import_jsx_runtime289.jsx)(StylesPreviewArea, { siteData }), 53658 mobileContent: /* @__PURE__ */ (0, import_jsx_runtime289.jsx)(SidebarGlobalStyles, {}) 53659 }, 53660 widths: { 53661 content: 380 53662 } 53663 }; 53664 53665 // packages/edit-site/build-module/components/sidebar-navigation-screen-navigation-menus/index.mjs 53666 var import_i18n132 = __toESM(require_i18n(), 1); 53667 var import_core_data40 = __toESM(require_core_data(), 1); 53668 var import_data62 = __toESM(require_data(), 1); 53669 var import_html_entities7 = __toESM(require_html_entities(), 1); 53670 var import_components138 = __toESM(require_components(), 1); 53671 53672 // packages/edit-site/build-module/components/sidebar-navigation-screen-navigation-menus/constants.mjs 53673 var PRELOADED_NAVIGATION_MENUS_QUERY = { 53674 per_page: 100, 53675 status: ["publish", "draft"], 53676 order: "desc", 53677 orderby: "date" 53678 }; 53679 53680 // packages/edit-site/build-module/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.mjs 53681 var import_i18n129 = __toESM(require_i18n(), 1); 53682 var import_html_entities5 = __toESM(require_html_entities(), 1); 53683 53684 // packages/edit-site/build-module/components/sidebar-navigation-screen-navigation-menu/more-menu.mjs 53685 var import_components135 = __toESM(require_components(), 1); 53686 var import_i18n126 = __toESM(require_i18n(), 1); 53687 var import_element167 = __toESM(require_element(), 1); 53688 var import_router22 = __toESM(require_router(), 1); 53689 53690 // packages/edit-site/build-module/components/sidebar-navigation-screen-navigation-menu/rename-modal.mjs 53691 var import_components133 = __toESM(require_components(), 1); 53692 var import_i18n124 = __toESM(require_i18n(), 1); 53693 var import_element166 = __toESM(require_element(), 1); 53694 var import_jsx_runtime290 = __toESM(require_jsx_runtime(), 1); 53695 var notEmptyString = (testString) => testString?.trim()?.length > 0; 53696 function RenameModal({ menuTitle, onClose, onSave }) { 53697 const [editedMenuTitle, setEditedMenuTitle] = (0, import_element166.useState)(menuTitle); 53698 const titleHasChanged = editedMenuTitle !== menuTitle; 53699 const isEditedMenuTitleValid = titleHasChanged && notEmptyString(editedMenuTitle); 53700 return /* @__PURE__ */ (0, import_jsx_runtime290.jsx)( 53701 import_components133.Modal, 53702 { 53703 title: (0, import_i18n124.__)("Rename"), 53704 onRequestClose: onClose, 53705 focusOnMount: "firstContentElement", 53706 size: "small", 53707 children: /* @__PURE__ */ (0, import_jsx_runtime290.jsx)("form", { className: "sidebar-navigation__rename-modal-form", children: /* @__PURE__ */ (0, import_jsx_runtime290.jsxs)(import_components133.__experimentalVStack, { spacing: "3", children: [ 53708 /* @__PURE__ */ (0, import_jsx_runtime290.jsx)( 53709 import_components133.TextControl, 53710 { 53711 value: editedMenuTitle, 53712 placeholder: (0, import_i18n124.__)("Navigation title"), 53713 onChange: setEditedMenuTitle, 53714 label: (0, import_i18n124.__)("Name") 53715 } 53716 ), 53717 /* @__PURE__ */ (0, import_jsx_runtime290.jsxs)(import_components133.__experimentalHStack, { justify: "right", children: [ 53718 /* @__PURE__ */ (0, import_jsx_runtime290.jsx)( 53719 import_components133.Button, 53720 { 53721 __next40pxDefaultSize: true, 53722 variant: "tertiary", 53723 onClick: onClose, 53724 children: (0, import_i18n124.__)("Cancel") 53725 } 53726 ), 53727 /* @__PURE__ */ (0, import_jsx_runtime290.jsx)( 53728 import_components133.Button, 53729 { 53730 __next40pxDefaultSize: true, 53731 accessibleWhenDisabled: true, 53732 disabled: !isEditedMenuTitleValid, 53733 variant: "primary", 53734 type: "submit", 53735 onClick: (e2) => { 53736 e2.preventDefault(); 53737 if (!isEditedMenuTitleValid) { 53738 return; 53739 } 53740 onSave({ title: editedMenuTitle }); 53741 onClose(); 53742 }, 53743 children: (0, import_i18n124.__)("Save") 53744 } 53745 ) 53746 ] }) 53747 ] }) }) 53748 } 53749 ); 53750 } 53751 53752 // packages/edit-site/build-module/components/sidebar-navigation-screen-navigation-menu/delete-confirm-dialog.mjs 53753 var import_components134 = __toESM(require_components(), 1); 53754 var import_i18n125 = __toESM(require_i18n(), 1); 53755 var import_jsx_runtime291 = __toESM(require_jsx_runtime(), 1); 53756 function DeleteConfirmDialog({ onClose, onConfirm }) { 53757 return /* @__PURE__ */ (0, import_jsx_runtime291.jsx)( 53758 import_components134.__experimentalConfirmDialog, 53759 { 53760 isOpen: true, 53761 onConfirm: () => { 53762 onConfirm(); 53763 onClose(); 53764 }, 53765 onCancel: onClose, 53766 confirmButtonText: (0, import_i18n125.__)("Delete"), 53767 size: "medium", 53768 children: (0, import_i18n125.__)("Are you sure you want to delete this Navigation Menu?") 53769 } 53770 ); 53771 } 53772 53773 // packages/edit-site/build-module/components/sidebar-navigation-screen-navigation-menu/more-menu.mjs 53774 var import_jsx_runtime292 = __toESM(require_jsx_runtime(), 1); 53775 var { useHistory: useHistory15 } = unlock(import_router22.privateApis); 53776 var POPOVER_PROPS = { 53777 position: "bottom right" 53778 }; 53779 function ScreenNavigationMoreMenu(props) { 53780 const { onDelete, onSave, onDuplicate, menuTitle, menuId } = props; 53781 const [renameModalOpen, setRenameModalOpen] = (0, import_element167.useState)(false); 53782 const [deleteConfirmDialogOpen, setDeleteConfirmDialogOpen] = (0, import_element167.useState)(false); 53783 const history = useHistory15(); 53784 const closeModals = () => { 53785 setRenameModalOpen(false); 53786 setDeleteConfirmDialogOpen(false); 53787 }; 53788 const openRenameModal = () => setRenameModalOpen(true); 53789 const openDeleteConfirmDialog = () => setDeleteConfirmDialogOpen(true); 53790 return /* @__PURE__ */ (0, import_jsx_runtime292.jsxs)(import_jsx_runtime292.Fragment, { children: [ 53791 /* @__PURE__ */ (0, import_jsx_runtime292.jsx)( 53792 import_components135.DropdownMenu, 53793 { 53794 className: "sidebar-navigation__more-menu", 53795 label: (0, import_i18n126.__)("Actions"), 53796 icon: more_vertical_default, 53797 popoverProps: POPOVER_PROPS, 53798 children: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime292.jsxs)(import_components135.MenuGroup, { children: [ 53799 /* @__PURE__ */ (0, import_jsx_runtime292.jsx)( 53800 import_components135.MenuItem, 53801 { 53802 onClick: () => { 53803 openRenameModal(); 53804 onClose(); 53805 }, 53806 children: (0, import_i18n126.__)("Rename") 53807 } 53808 ), 53809 /* @__PURE__ */ (0, import_jsx_runtime292.jsx)( 53810 import_components135.MenuItem, 53811 { 53812 onClick: () => { 53813 history.navigate( 53814 `/wp_navigation/$menuId}?canvas=edit` 53815 ); 53816 }, 53817 children: (0, import_i18n126.__)("Edit") 53818 } 53819 ), 53820 /* @__PURE__ */ (0, import_jsx_runtime292.jsx)( 53821 import_components135.MenuItem, 53822 { 53823 onClick: () => { 53824 onDuplicate(); 53825 onClose(); 53826 }, 53827 children: (0, import_i18n126.__)("Duplicate") 53828 } 53829 ), 53830 /* @__PURE__ */ (0, import_jsx_runtime292.jsx)( 53831 import_components135.MenuItem, 53832 { 53833 isDestructive: true, 53834 onClick: () => { 53835 openDeleteConfirmDialog(); 53836 onClose(); 53837 }, 53838 children: (0, import_i18n126.__)("Delete") 53839 } 53840 ) 53841 ] }) 53842 } 53843 ), 53844 deleteConfirmDialogOpen && /* @__PURE__ */ (0, import_jsx_runtime292.jsx)( 53845 DeleteConfirmDialog, 53846 { 53847 onClose: closeModals, 53848 onConfirm: onDelete 53849 } 53850 ), 53851 renameModalOpen && /* @__PURE__ */ (0, import_jsx_runtime292.jsx)( 53852 RenameModal, 53853 { 53854 onClose: closeModals, 53855 menuTitle, 53856 onSave 53857 } 53858 ) 53859 ] }); 53860 } 53861 53862 // packages/edit-site/build-module/components/sidebar-navigation-screen-navigation-menu/navigation-menu-editor.mjs 53863 var import_element170 = __toESM(require_element(), 1); 53864 var import_data59 = __toESM(require_data(), 1); 53865 var import_block_editor22 = __toESM(require_block_editor(), 1); 53866 var import_blocks10 = __toESM(require_blocks(), 1); 53867 var import_core_data37 = __toESM(require_core_data(), 1); 53868 53869 // packages/edit-site/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.mjs 53870 var import_block_editor21 = __toESM(require_block_editor(), 1); 53871 var import_data58 = __toESM(require_data(), 1); 53872 var import_blocks9 = __toESM(require_blocks(), 1); 53873 var import_element169 = __toESM(require_element(), 1); 53874 var import_core_data36 = __toESM(require_core_data(), 1); 53875 var import_block_library2 = __toESM(require_block_library(), 1); 53876 53877 // packages/edit-site/build-module/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.mjs 53878 var import_components136 = __toESM(require_components(), 1); 53879 var import_data57 = __toESM(require_data(), 1); 53880 var import_element168 = __toESM(require_element(), 1); 53881 var import_i18n127 = __toESM(require_i18n(), 1); 53882 var import_block_editor20 = __toESM(require_block_editor(), 1); 53883 var import_router23 = __toESM(require_router(), 1); 53884 var import_jsx_runtime293 = __toESM(require_jsx_runtime(), 1); 53885 var POPOVER_PROPS2 = { 53886 className: "block-editor-block-settings-menu__popover", 53887 placement: "bottom-start" 53888 }; 53889 var { useHistory: useHistory16, useLocation: useLocation22 } = unlock(import_router23.privateApis); 53890 function LeafMoreMenu(props) { 53891 const history = useHistory16(); 53892 const { path } = useLocation22(); 53893 const { block } = props; 53894 const { clientId } = block; 53895 const { moveBlocksDown, moveBlocksUp, removeBlocks } = (0, import_data57.useDispatch)(import_block_editor20.store); 53896 const removeLabel = (0, import_i18n127.sprintf)( 53897 /* translators: %s: block name */ 53898 (0, import_i18n127.__)("Remove %s"), 53899 (0, import_block_editor20.BlockTitle)({ clientId, maximumLength: 25 }) 53900 ); 53901 const goToLabel = (0, import_i18n127.sprintf)( 53902 /* translators: %s: block name */ 53903 (0, import_i18n127.__)("Go to %s"), 53904 (0, import_block_editor20.BlockTitle)({ clientId, maximumLength: 25 }) 53905 ); 53906 const rootClientId = (0, import_data57.useSelect)( 53907 (select4) => { 53908 const { getBlockRootClientId } = select4(import_block_editor20.store); 53909 return getBlockRootClientId(clientId); 53910 }, 53911 [clientId] 53912 ); 53913 const onGoToPage = (0, import_element168.useCallback)( 53914 (selectedBlock) => { 53915 const { attributes, name: name2 } = selectedBlock; 53916 if (attributes.kind === "post-type" && attributes.id && attributes.type && history) { 53917 history.navigate( 53918 `/$attributes.type}/$attributes.id}?canvas=edit`, 53919 { 53920 state: { backPath: path } 53921 } 53922 ); 53923 } 53924 if (name2 === "core/page-list-item" && attributes.id && history) { 53925 history.navigate(`/page/$attributes.id}?canvas=edit`, { 53926 state: { backPath: path } 53927 }); 53928 } 53929 }, 53930 [path, history] 53931 ); 53932 return /* @__PURE__ */ (0, import_jsx_runtime293.jsx)( 53933 import_components136.DropdownMenu, 53934 { 53935 icon: more_vertical_default, 53936 label: (0, import_i18n127.__)("Options"), 53937 className: "block-editor-block-settings-menu", 53938 popoverProps: POPOVER_PROPS2, 53939 noIcons: true, 53940 ...props, 53941 children: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime293.jsxs)(import_jsx_runtime293.Fragment, { children: [ 53942 /* @__PURE__ */ (0, import_jsx_runtime293.jsxs)(import_components136.MenuGroup, { children: [ 53943 /* @__PURE__ */ (0, import_jsx_runtime293.jsx)( 53944 import_components136.MenuItem, 53945 { 53946 icon: chevron_up_default, 53947 onClick: () => { 53948 moveBlocksUp([clientId], rootClientId); 53949 onClose(); 53950 }, 53951 children: (0, import_i18n127.__)("Move up") 53952 } 53953 ), 53954 /* @__PURE__ */ (0, import_jsx_runtime293.jsx)( 53955 import_components136.MenuItem, 53956 { 53957 icon: chevron_down_default, 53958 onClick: () => { 53959 moveBlocksDown([clientId], rootClientId); 53960 onClose(); 53961 }, 53962 children: (0, import_i18n127.__)("Move down") 53963 } 53964 ), 53965 block.attributes?.type === "page" && block.attributes?.id && /* @__PURE__ */ (0, import_jsx_runtime293.jsx)( 53966 import_components136.MenuItem, 53967 { 53968 onClick: () => { 53969 onGoToPage(block); 53970 onClose(); 53971 }, 53972 children: goToLabel 53973 } 53974 ) 53975 ] }), 53976 /* @__PURE__ */ (0, import_jsx_runtime293.jsx)(import_components136.MenuGroup, { children: /* @__PURE__ */ (0, import_jsx_runtime293.jsx)( 53977 import_components136.MenuItem, 53978 { 53979 onClick: () => { 53980 removeBlocks([clientId], false); 53981 onClose(); 53982 }, 53983 children: removeLabel 53984 } 53985 ) }) 53986 ] }) 53987 } 53988 ); 53989 } 53990 53991 // packages/edit-site/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.mjs 53992 var import_jsx_runtime294 = __toESM(require_jsx_runtime(), 1); 53993 var { PrivateListView } = unlock(import_block_editor21.privateApis); 53994 var { NavigationLinkUI } = unlock(import_block_library2.privateApis); 53995 var MAX_PAGE_COUNT = 100; 53996 var PAGES_QUERY = [ 53997 "postType", 53998 "page", 53999 { 54000 per_page: MAX_PAGE_COUNT, 54001 _fields: ["id", "link", "menu_order", "parent", "title", "type"], 54002 // TODO: When https://core.trac.wordpress.org/ticket/39037 REST API support for multiple orderby 54003 // values is resolved, update 'orderby' to [ 'menu_order', 'post_title' ] to provide a consistent 54004 // sort. 54005 orderby: "menu_order", 54006 order: "asc" 54007 } 54008 ]; 54009 function NavigationMenuContent({ rootClientId }) { 54010 const { listViewRootClientId, isLoading } = (0, import_data58.useSelect)( 54011 (select4) => { 54012 const { 54013 areInnerBlocksControlled, 54014 getBlockName, 54015 getBlockCount, 54016 getBlockOrder 54017 } = select4(import_block_editor21.store); 54018 const { isResolving } = select4(import_core_data36.store); 54019 const blockClientIds = getBlockOrder(rootClientId); 54020 const hasOnlyPageListBlock = blockClientIds.length === 1 && getBlockName(blockClientIds[0]) === "core/page-list"; 54021 const pageListHasBlocks = hasOnlyPageListBlock && getBlockCount(blockClientIds[0]) > 0; 54022 const isLoadingPages = isResolving( 54023 "getEntityRecords", 54024 PAGES_QUERY 54025 ); 54026 return { 54027 listViewRootClientId: pageListHasBlocks ? blockClientIds[0] : rootClientId, 54028 // This is a small hack to wait for the navigation block 54029 // to actually load its inner blocks. 54030 isLoading: !areInnerBlocksControlled(rootClientId) || isLoadingPages 54031 }; 54032 }, 54033 [rootClientId] 54034 ); 54035 const { replaceBlock, __unstableMarkNextChangeAsNotPersistent } = (0, import_data58.useDispatch)(import_block_editor21.store); 54036 const offCanvasOnselect = (0, import_element169.useCallback)( 54037 (block) => { 54038 if (block.name === "core/navigation-link" && !block.attributes.url) { 54039 __unstableMarkNextChangeAsNotPersistent(); 54040 replaceBlock( 54041 block.clientId, 54042 (0, import_blocks9.createBlock)("core/navigation-link", block.attributes) 54043 ); 54044 } 54045 }, 54046 [__unstableMarkNextChangeAsNotPersistent, replaceBlock] 54047 ); 54048 return /* @__PURE__ */ (0, import_jsx_runtime294.jsxs)(import_jsx_runtime294.Fragment, { children: [ 54049 !isLoading && /* @__PURE__ */ (0, import_jsx_runtime294.jsx)( 54050 PrivateListView, 54051 { 54052 rootClientId: listViewRootClientId, 54053 onSelect: offCanvasOnselect, 54054 blockSettingsMenu: LeafMoreMenu, 54055 showAppender: true, 54056 additionalBlockContent: NavigationLinkUI, 54057 isExpanded: true 54058 } 54059 ), 54060 /* @__PURE__ */ (0, import_jsx_runtime294.jsx)("div", { className: "edit-site-sidebar-navigation-screen-navigation-menus__helper-block-editor", children: /* @__PURE__ */ (0, import_jsx_runtime294.jsx)(import_block_editor21.BlockList, {}) }) 54061 ] }); 54062 } 54063 54064 // packages/edit-site/build-module/components/sidebar-navigation-screen-navigation-menu/navigation-menu-editor.mjs 54065 var import_jsx_runtime295 = __toESM(require_jsx_runtime(), 1); 54066 var noop6 = () => { 54067 }; 54068 function NavigationMenuEditor({ navigationMenuId }) { 54069 const { storedSettings } = (0, import_data59.useSelect)((select4) => { 54070 const { getSettings: getSettings7 } = unlock(select4(store)); 54071 return { 54072 storedSettings: getSettings7() 54073 }; 54074 }, []); 54075 const settings2 = (0, import_element170.useMemo)(() => { 54076 return { 54077 ...storedSettings, 54078 __experimentalFetchLinkSuggestions: (search, searchOptions) => (0, import_core_data37.__experimentalFetchLinkSuggestions)(search, searchOptions, storedSettings) 54079 }; 54080 }, [storedSettings]); 54081 const blocks = (0, import_element170.useMemo)(() => { 54082 if (!navigationMenuId) { 54083 return []; 54084 } 54085 return [(0, import_blocks10.createBlock)("core/navigation", { ref: navigationMenuId })]; 54086 }, [navigationMenuId]); 54087 if (!navigationMenuId || !blocks?.length) { 54088 return null; 54089 } 54090 return /* @__PURE__ */ (0, import_jsx_runtime295.jsx)( 54091 import_block_editor22.BlockEditorProvider, 54092 { 54093 settings: settings2, 54094 value: blocks, 54095 onChange: noop6, 54096 onInput: noop6, 54097 children: /* @__PURE__ */ (0, import_jsx_runtime295.jsx)("div", { className: "edit-site-sidebar-navigation-screen-navigation-menus__content", children: /* @__PURE__ */ (0, import_jsx_runtime295.jsx)(NavigationMenuContent, { rootClientId: blocks[0].clientId }) }) 54098 } 54099 ); 54100 } 54101 54102 // packages/edit-site/build-module/components/sidebar-navigation-screen-navigation-menus/build-navigation-label.mjs 54103 var import_i18n128 = __toESM(require_i18n(), 1); 54104 var import_html_entities4 = __toESM(require_html_entities(), 1); 54105 function buildNavigationLabel(title, id, status) { 54106 if (!title?.rendered) { 54107 return (0, import_i18n128.sprintf)((0, import_i18n128.__)("(no title %s)"), id); 54108 } 54109 if (status === "publish") { 54110 return (0, import_html_entities4.decodeEntities)(title?.rendered); 54111 } 54112 return (0, import_i18n128.sprintf)( 54113 // translators: 1: title of the menu. 2: status of the menu (draft, pending, etc.). 54114 (0, import_i18n128._x)("%1$s (%2$s)", "menu label"), 54115 (0, import_html_entities4.decodeEntities)(title?.rendered), 54116 status 54117 ); 54118 } 54119 54120 // packages/edit-site/build-module/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.mjs 54121 var import_jsx_runtime296 = __toESM(require_jsx_runtime(), 1); 54122 function SingleNavigationMenu({ 54123 navigationMenu, 54124 backPath, 54125 handleDelete, 54126 handleDuplicate, 54127 handleSave 54128 }) { 54129 const menuTitle = navigationMenu?.title?.rendered; 54130 return /* @__PURE__ */ (0, import_jsx_runtime296.jsx)( 54131 SidebarNavigationScreenWrapper, 54132 { 54133 actions: /* @__PURE__ */ (0, import_jsx_runtime296.jsx)(import_jsx_runtime296.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime296.jsx)( 54134 ScreenNavigationMoreMenu, 54135 { 54136 menuId: navigationMenu?.id, 54137 menuTitle: (0, import_html_entities5.decodeEntities)(menuTitle), 54138 onDelete: handleDelete, 54139 onSave: handleSave, 54140 onDuplicate: handleDuplicate 54141 } 54142 ) }), 54143 backPath, 54144 title: buildNavigationLabel( 54145 navigationMenu?.title, 54146 navigationMenu?.id, 54147 navigationMenu?.status 54148 ), 54149 description: (0, import_i18n129.__)( 54150 "Navigation Menus are a curated collection of blocks that allow visitors to get around your site." 54151 ), 54152 children: /* @__PURE__ */ (0, import_jsx_runtime296.jsx)(NavigationMenuEditor, { navigationMenuId: navigationMenu?.id }) 54153 } 54154 ); 54155 } 54156 54157 // packages/edit-site/build-module/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.mjs 54158 var import_core_data39 = __toESM(require_core_data(), 1); 54159 var import_i18n131 = __toESM(require_i18n(), 1); 54160 var import_data61 = __toESM(require_data(), 1); 54161 var import_notices5 = __toESM(require_notices(), 1); 54162 var import_router25 = __toESM(require_router(), 1); 54163 54164 // packages/edit-site/build-module/components/sidebar-navigation-screen-navigation-menu/index.mjs 54165 var import_core_data38 = __toESM(require_core_data(), 1); 54166 var import_components137 = __toESM(require_components(), 1); 54167 var import_i18n130 = __toESM(require_i18n(), 1); 54168 var import_data60 = __toESM(require_data(), 1); 54169 var import_html_entities6 = __toESM(require_html_entities(), 1); 54170 var import_router24 = __toESM(require_router(), 1); 54171 var import_jsx_runtime297 = __toESM(require_jsx_runtime(), 1); 54172 var { useLocation: useLocation23 } = unlock(import_router24.privateApis); 54173 var postType = `wp_navigation`; 54174 function SidebarNavigationScreenNavigationMenu({ backPath }) { 54175 const { 54176 params: { postId } 54177 } = useLocation23(); 54178 const { record: navigationMenu, isResolving } = (0, import_core_data38.useEntityRecord)( 54179 "postType", 54180 postType, 54181 postId 54182 ); 54183 const { isSaving, isDeleting } = (0, import_data60.useSelect)( 54184 (select4) => { 54185 const { isSavingEntityRecord, isDeletingEntityRecord } = select4(import_core_data38.store); 54186 return { 54187 isSaving: isSavingEntityRecord("postType", postType, postId), 54188 isDeleting: isDeletingEntityRecord( 54189 "postType", 54190 postType, 54191 postId 54192 ) 54193 }; 54194 }, 54195 [postId] 54196 ); 54197 const isLoading = isResolving || isSaving || isDeleting; 54198 const menuTitle = navigationMenu?.title?.rendered || navigationMenu?.slug; 54199 const { handleSave, handleDelete, handleDuplicate } = useNavigationMenuHandlers(); 54200 const _handleDelete = () => handleDelete(navigationMenu); 54201 const _handleSave = (edits) => handleSave(navigationMenu, edits); 54202 const _handleDuplicate = () => handleDuplicate(navigationMenu); 54203 if (isLoading) { 54204 return /* @__PURE__ */ (0, import_jsx_runtime297.jsx)( 54205 SidebarNavigationScreenWrapper, 54206 { 54207 description: (0, import_i18n130.__)( 54208 "Navigation Menus are a curated collection of blocks that allow visitors to get around your site." 54209 ), 54210 backPath, 54211 children: /* @__PURE__ */ (0, import_jsx_runtime297.jsx)(import_components137.Spinner, { className: "edit-site-sidebar-navigation-screen-navigation-menus__loading" }) 54212 } 54213 ); 54214 } 54215 if (!isLoading && !navigationMenu) { 54216 return /* @__PURE__ */ (0, import_jsx_runtime297.jsx)( 54217 SidebarNavigationScreenWrapper, 54218 { 54219 description: (0, import_i18n130.__)("Navigation Menu missing."), 54220 backPath 54221 } 54222 ); 54223 } 54224 if (!navigationMenu?.content?.raw) { 54225 return /* @__PURE__ */ (0, import_jsx_runtime297.jsx)( 54226 SidebarNavigationScreenWrapper, 54227 { 54228 actions: /* @__PURE__ */ (0, import_jsx_runtime297.jsx)( 54229 ScreenNavigationMoreMenu, 54230 { 54231 menuId: navigationMenu?.id, 54232 menuTitle: (0, import_html_entities6.decodeEntities)(menuTitle), 54233 onDelete: _handleDelete, 54234 onSave: _handleSave, 54235 onDuplicate: _handleDuplicate 54236 } 54237 ), 54238 backPath, 54239 title: buildNavigationLabel( 54240 navigationMenu?.title, 54241 navigationMenu?.id, 54242 navigationMenu?.status 54243 ), 54244 description: (0, import_i18n130.__)("This Navigation Menu is empty.") 54245 } 54246 ); 54247 } 54248 return /* @__PURE__ */ (0, import_jsx_runtime297.jsx)( 54249 SingleNavigationMenu, 54250 { 54251 navigationMenu, 54252 backPath, 54253 handleDelete: _handleDelete, 54254 handleSave: _handleSave, 54255 handleDuplicate: _handleDuplicate 54256 } 54257 ); 54258 } 54259 54260 // packages/edit-site/build-module/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.mjs 54261 var { useHistory: useHistory17 } = unlock(import_router25.privateApis); 54262 function useDeleteNavigationMenu() { 54263 const { deleteEntityRecord } = (0, import_data61.useDispatch)(import_core_data39.store); 54264 const { createSuccessNotice, createErrorNotice } = (0, import_data61.useDispatch)(import_notices5.store); 54265 const history = useHistory17(); 54266 const handleDelete = async (navigationMenu) => { 54267 const postId = navigationMenu?.id; 54268 try { 54269 await deleteEntityRecord( 54270 "postType", 54271 postType, 54272 postId, 54273 { 54274 force: true 54275 }, 54276 { 54277 throwOnError: true 54278 } 54279 ); 54280 createSuccessNotice( 54281 (0, import_i18n131.__)("Navigation Menu successfully deleted."), 54282 { 54283 type: "snackbar" 54284 } 54285 ); 54286 history.navigate("/navigation"); 54287 } catch (error2) { 54288 createErrorNotice( 54289 (0, import_i18n131.sprintf)( 54290 /* translators: %s: error message describing why the navigation menu could not be deleted. */ 54291 (0, import_i18n131.__)(`Unable to delete Navigation Menu (%s).`), 54292 error2?.message 54293 ), 54294 { 54295 type: "snackbar" 54296 } 54297 ); 54298 } 54299 }; 54300 return handleDelete; 54301 } 54302 function useSaveNavigationMenu() { 54303 const { getEditedEntityRecord } = (0, import_data61.useSelect)((select4) => { 54304 const { getEditedEntityRecord: getEditedEntityRecordSelector } = select4(import_core_data39.store); 54305 return { 54306 getEditedEntityRecord: getEditedEntityRecordSelector 54307 }; 54308 }, []); 54309 const { 54310 editEntityRecord, 54311 __experimentalSaveSpecifiedEntityEdits: saveSpecifiedEntityEdits 54312 } = (0, import_data61.useDispatch)(import_core_data39.store); 54313 const { createSuccessNotice, createErrorNotice } = (0, import_data61.useDispatch)(import_notices5.store); 54314 const handleSave = async (navigationMenu, edits) => { 54315 if (!edits) { 54316 return; 54317 } 54318 const postId = navigationMenu?.id; 54319 const originalRecord = getEditedEntityRecord( 54320 "postType", 54321 NAVIGATION_POST_TYPE, 54322 postId 54323 ); 54324 editEntityRecord("postType", postType, postId, edits); 54325 const recordPropertiesToSave = Object.keys(edits); 54326 try { 54327 await saveSpecifiedEntityEdits( 54328 "postType", 54329 postType, 54330 postId, 54331 recordPropertiesToSave, 54332 { 54333 throwOnError: true 54334 } 54335 ); 54336 createSuccessNotice((0, import_i18n131.__)("Renamed Navigation Menu"), { 54337 type: "snackbar" 54338 }); 54339 } catch (error2) { 54340 editEntityRecord("postType", postType, postId, originalRecord); 54341 createErrorNotice( 54342 (0, import_i18n131.sprintf)( 54343 /* translators: %s: error message describing why the navigation menu could not be renamed. */ 54344 (0, import_i18n131.__)(`Unable to rename Navigation Menu (%s).`), 54345 error2?.message 54346 ), 54347 { 54348 type: "snackbar" 54349 } 54350 ); 54351 } 54352 }; 54353 return handleSave; 54354 } 54355 function useDuplicateNavigationMenu() { 54356 const history = useHistory17(); 54357 const { saveEntityRecord } = (0, import_data61.useDispatch)(import_core_data39.store); 54358 const { createSuccessNotice, createErrorNotice } = (0, import_data61.useDispatch)(import_notices5.store); 54359 const handleDuplicate = async (navigationMenu) => { 54360 const menuTitle = navigationMenu?.title?.rendered || navigationMenu?.slug; 54361 try { 54362 const savedRecord = await saveEntityRecord( 54363 "postType", 54364 postType, 54365 { 54366 title: (0, import_i18n131.sprintf)( 54367 /* translators: %s: Navigation menu title */ 54368 (0, import_i18n131._x)("%s (Copy)", "navigation menu"), 54369 menuTitle 54370 ), 54371 content: navigationMenu?.content?.raw, 54372 status: "publish" 54373 }, 54374 { 54375 throwOnError: true 54376 } 54377 ); 54378 if (savedRecord) { 54379 createSuccessNotice((0, import_i18n131.__)("Duplicated Navigation Menu"), { 54380 type: "snackbar" 54381 }); 54382 history.navigate(`/wp_navigation/$savedRecord.id}`); 54383 } 54384 } catch (error2) { 54385 createErrorNotice( 54386 (0, import_i18n131.sprintf)( 54387 /* translators: %s: error message describing why the navigation menu could not be deleted. */ 54388 (0, import_i18n131.__)(`Unable to duplicate Navigation Menu (%s).`), 54389 error2?.message 54390 ), 54391 { 54392 type: "snackbar" 54393 } 54394 ); 54395 } 54396 }; 54397 return handleDuplicate; 54398 } 54399 function useNavigationMenuHandlers() { 54400 return { 54401 handleDelete: useDeleteNavigationMenu(), 54402 handleSave: useSaveNavigationMenu(), 54403 handleDuplicate: useDuplicateNavigationMenu() 54404 }; 54405 } 54406 54407 // packages/edit-site/build-module/components/sidebar-navigation-screen-navigation-menus/index.mjs 54408 var import_jsx_runtime298 = __toESM(require_jsx_runtime(), 1); 54409 function buildMenuLabel(title, id, status) { 54410 if (!title) { 54411 return (0, import_i18n132.sprintf)((0, import_i18n132.__)("(no title %s)"), id); 54412 } 54413 if (status === "publish") { 54414 return (0, import_html_entities7.decodeEntities)(title); 54415 } 54416 return (0, import_i18n132.sprintf)( 54417 // translators: 1: title of the menu. 2: status of the menu (draft, pending, etc.). 54418 (0, import_i18n132._x)("%1$s (%2$s)", "menu label"), 54419 (0, import_html_entities7.decodeEntities)(title), 54420 status 54421 ); 54422 } 54423 function SidebarNavigationScreenNavigationMenus({ backPath }) { 54424 const { 54425 records: navigationMenus, 54426 isResolving: isResolvingNavigationMenus, 54427 hasResolved: hasResolvedNavigationMenus 54428 } = (0, import_core_data40.useEntityRecords)( 54429 "postType", 54430 NAVIGATION_POST_TYPE, 54431 PRELOADED_NAVIGATION_MENUS_QUERY 54432 ); 54433 const isLoading = isResolvingNavigationMenus && !hasResolvedNavigationMenus; 54434 const { getNavigationFallbackId } = unlock((0, import_data62.useSelect)(import_core_data40.store)); 54435 const isCreatingNavigationFallback = (0, import_data62.useSelect)( 54436 (select4) => select4(import_core_data40.store).isResolving("getNavigationFallbackId"), 54437 [] 54438 ); 54439 const firstNavigationMenu = navigationMenus?.[0]; 54440 if (!firstNavigationMenu && !isResolvingNavigationMenus && hasResolvedNavigationMenus && // Ensure a fallback navigation is created only once 54441 !isCreatingNavigationFallback) { 54442 getNavigationFallbackId(); 54443 } 54444 const { handleSave, handleDelete, handleDuplicate } = useNavigationMenuHandlers(); 54445 const hasNavigationMenus = !!navigationMenus?.length; 54446 if (isLoading) { 54447 return /* @__PURE__ */ (0, import_jsx_runtime298.jsx)(SidebarNavigationScreenWrapper, { backPath, children: /* @__PURE__ */ (0, import_jsx_runtime298.jsx)(import_components138.Spinner, { className: "edit-site-sidebar-navigation-screen-navigation-menus__loading" }) }); 54448 } 54449 if (!isLoading && !hasNavigationMenus) { 54450 return /* @__PURE__ */ (0, import_jsx_runtime298.jsx)( 54451 SidebarNavigationScreenWrapper, 54452 { 54453 description: (0, import_i18n132.__)("No Navigation Menus found."), 54454 backPath 54455 } 54456 ); 54457 } 54458 if (navigationMenus?.length === 1) { 54459 return /* @__PURE__ */ (0, import_jsx_runtime298.jsx)( 54460 SingleNavigationMenu, 54461 { 54462 navigationMenu: firstNavigationMenu, 54463 backPath, 54464 handleDelete: () => handleDelete(firstNavigationMenu), 54465 handleDuplicate: () => handleDuplicate(firstNavigationMenu), 54466 handleSave: (edits) => handleSave(firstNavigationMenu, edits) 54467 } 54468 ); 54469 } 54470 return /* @__PURE__ */ (0, import_jsx_runtime298.jsx)(SidebarNavigationScreenWrapper, { backPath, children: /* @__PURE__ */ (0, import_jsx_runtime298.jsx)(import_components138.__experimentalItemGroup, { className: "edit-site-sidebar-navigation-screen-navigation-menus", children: navigationMenus?.map(({ id, title, status }, index2) => /* @__PURE__ */ (0, import_jsx_runtime298.jsx)( 54471 NavMenuItem, 54472 { 54473 postId: id, 54474 withChevron: true, 54475 icon: navigation_default, 54476 children: buildMenuLabel(title?.rendered, index2 + 1, status) 54477 }, 54478 id 54479 )) }) }); 54480 } 54481 function SidebarNavigationScreenWrapper({ 54482 children, 54483 actions, 54484 title, 54485 description, 54486 backPath 54487 }) { 54488 return /* @__PURE__ */ (0, import_jsx_runtime298.jsx)( 54489 SidebarNavigationScreen, 54490 { 54491 title: title || (0, import_i18n132.__)("Navigation"), 54492 actions, 54493 description: description || (0, import_i18n132.__)("Manage your Navigation Menus."), 54494 backPath, 54495 content: children 54496 } 54497 ); 54498 } 54499 var NavMenuItem = ({ postId, ...props }) => { 54500 return /* @__PURE__ */ (0, import_jsx_runtime298.jsx)( 54501 SidebarNavigationItem, 54502 { 54503 to: `/wp_navigation/$postId}`, 54504 ...props 54505 } 54506 ); 54507 }; 54508 54509 // packages/edit-site/build-module/components/site-editor-routes/navigation.mjs 54510 var import_jsx_runtime299 = __toESM(require_jsx_runtime(), 1); 54511 var navigationRoute = { 54512 name: "navigation", 54513 path: "/navigation", 54514 areas: { 54515 sidebar({ siteData }) { 54516 if (!isThemeDataLoaded(siteData)) { 54517 return null; 54518 } 54519 return siteData.currentTheme.is_block_theme ? /* @__PURE__ */ (0, import_jsx_runtime299.jsx)(SidebarNavigationScreenNavigationMenus, { backPath: "/" }) : /* @__PURE__ */ (0, import_jsx_runtime299.jsx)(SidebarNavigationScreenUnsupported, {}); 54520 }, 54521 preview({ siteData }) { 54522 const isBlockTheme = siteData.currentTheme?.is_block_theme; 54523 return isBlockTheme ? /* @__PURE__ */ (0, import_jsx_runtime299.jsx)(EditSiteEditor, {}) : void 0; 54524 }, 54525 mobileSidebar({ siteData }) { 54526 if (!isThemeDataLoaded(siteData)) { 54527 return /* @__PURE__ */ (0, import_jsx_runtime299.jsx)(import_jsx_runtime299.Fragment, {}); 54528 } 54529 return siteData.currentTheme.is_block_theme ? /* @__PURE__ */ (0, import_jsx_runtime299.jsx)(SidebarNavigationScreenNavigationMenus, { backPath: "/" }) : /* @__PURE__ */ (0, import_jsx_runtime299.jsx)(SidebarNavigationScreenUnsupported, {}); 54530 } 54531 } 54532 }; 54533 54534 // packages/edit-site/build-module/components/site-editor-routes/navigation-item.mjs 54535 var import_jsx_runtime300 = __toESM(require_jsx_runtime(), 1); 54536 var navigationItemRoute = { 54537 name: "navigation-item", 54538 path: "/wp_navigation/:postId", 54539 areas: { 54540 sidebar({ siteData }) { 54541 if (!isThemeDataLoaded(siteData)) { 54542 return null; 54543 } 54544 return siteData.currentTheme.is_block_theme ? /* @__PURE__ */ (0, import_jsx_runtime300.jsx)(SidebarNavigationScreenNavigationMenu, { backPath: "/navigation" }) : /* @__PURE__ */ (0, import_jsx_runtime300.jsx)(SidebarNavigationScreenUnsupported, {}); 54545 }, 54546 preview({ siteData }) { 54547 if (!isThemeDataLoaded(siteData)) { 54548 return null; 54549 } 54550 return siteData.currentTheme.is_block_theme ? /* @__PURE__ */ (0, import_jsx_runtime300.jsx)(EditSiteEditor, {}) : /* @__PURE__ */ (0, import_jsx_runtime300.jsx)(SidebarNavigationScreenUnsupported, {}); 54551 }, 54552 mobileSidebar({ siteData }) { 54553 if (!isThemeDataLoaded(siteData)) { 54554 return /* @__PURE__ */ (0, import_jsx_runtime300.jsx)(import_jsx_runtime300.Fragment, {}); 54555 } 54556 return siteData.currentTheme.is_block_theme ? /* @__PURE__ */ (0, import_jsx_runtime300.jsx)(SidebarNavigationScreenNavigationMenu, { backPath: "/navigation" }) : /* @__PURE__ */ (0, import_jsx_runtime300.jsx)(SidebarNavigationScreenUnsupported, {}); 54557 } 54558 } 54559 }; 54560 54561 // packages/edit-site/build-module/components/sidebar-navigation-screen-patterns/index.mjs 54562 var import_components139 = __toESM(require_components(), 1); 54563 var import_editor29 = __toESM(require_editor(), 1); 54564 var import_element175 = __toESM(require_element(), 1); 54565 var import_i18n134 = __toESM(require_i18n(), 1); 54566 var import_router26 = __toESM(require_router(), 1); 54567 54568 // node_modules/dequal/dist/index.mjs 54569 var has = Object.prototype.hasOwnProperty; 54570 function find(iter, tar, key) { 54571 for (key of iter.keys()) { 54572 if (dequal(key, tar)) return key; 54573 } 54574 } 54575 function dequal(foo, bar) { 54576 var ctor, len, tmp; 54577 if (foo === bar) return true; 54578 if (foo && bar && (ctor = foo.constructor) === bar.constructor) { 54579 if (ctor === Date) return foo.getTime() === bar.getTime(); 54580 if (ctor === RegExp) return foo.toString() === bar.toString(); 54581 if (ctor === Array) { 54582 if ((len = foo.length) === bar.length) { 54583 while (len-- && dequal(foo[len], bar[len])) ; 54584 } 54585 return len === -1; 54586 } 54587 if (ctor === Set) { 54588 if (foo.size !== bar.size) { 54589 return false; 54590 } 54591 for (len of foo) { 54592 tmp = len; 54593 if (tmp && typeof tmp === "object") { 54594 tmp = find(bar, tmp); 54595 if (!tmp) return false; 54596 } 54597 if (!bar.has(tmp)) return false; 54598 } 54599 return true; 54600 } 54601 if (ctor === Map) { 54602 if (foo.size !== bar.size) { 54603 return false; 54604 } 54605 for (len of foo) { 54606 tmp = len[0]; 54607 if (tmp && typeof tmp === "object") { 54608 tmp = find(bar, tmp); 54609 if (!tmp) return false; 54610 } 54611 if (!dequal(len[1], bar.get(tmp))) { 54612 return false; 54613 } 54614 } 54615 return true; 54616 } 54617 if (ctor === ArrayBuffer) { 54618 foo = new Uint8Array(foo); 54619 bar = new Uint8Array(bar); 54620 } else if (ctor === DataView) { 54621 if ((len = foo.byteLength) === bar.byteLength) { 54622 while (len-- && foo.getInt8(len) === bar.getInt8(len)) ; 54623 } 54624 return len === -1; 54625 } 54626 if (ArrayBuffer.isView(foo)) { 54627 if ((len = foo.byteLength) === bar.byteLength) { 54628 while (len-- && foo[len] === bar[len]) ; 54629 } 54630 return len === -1; 54631 } 54632 if (!ctor || typeof foo === "object") { 54633 len = 0; 54634 for (ctor in foo) { 54635 if (has.call(foo, ctor) && ++len && !has.call(bar, ctor)) return false; 54636 if (!(ctor in bar) || !dequal(foo[ctor], bar[ctor])) return false; 54637 } 54638 return Object.keys(bar).length === len; 54639 } 54640 } 54641 return foo !== foo && bar !== bar; 54642 } 54643 54644 // packages/views/build-module/use-view.mjs 54645 var import_element171 = __toESM(require_element(), 1); 54646 var import_data63 = __toESM(require_data(), 1); 54647 var import_preferences11 = __toESM(require_preferences(), 1); 54648 54649 // packages/views/build-module/preference-keys.mjs 54650 function generatePreferenceKey(kind, name2, slug) { 54651 return `dataviews-$kind}-$name2}-$slug}`; 54652 } 54653 54654 // packages/views/build-module/resolve-view.mjs 54655 var QUERY_PARAMS = ["page", "search"]; 54656 function isPlainObject2(value) { 54657 return typeof value === "object" && value !== null && !Array.isArray(value); 54658 } 54659 function withoutQueryParams(layer) { 54660 const result = isPlainObject2(layer) ? { ...layer } : {}; 54661 for (const key of QUERY_PARAMS) { 54662 delete result[key]; 54663 } 54664 return result; 54665 } 54666 function mergeLayer(lower, upper) { 54667 const result = { ...lower }; 54668 for (const key of Object.keys(upper)) { 54669 const value = upper[key]; 54670 const current = result[key]; 54671 result[key] = isPlainObject2(current) && isPlainObject2(value) ? mergeLayer(current, value) : value; 54672 } 54673 return result; 54674 } 54675 function diffLayer(value, base, persisted = {}) { 54676 const result = {}; 54677 for (const key of Object.keys(value)) { 54678 const next = value[key]; 54679 const current = base[key]; 54680 const prev = persisted[key]; 54681 if (next === void 0) { 54682 continue; 54683 } 54684 if (isPlainObject2(next) && isPlainObject2(current)) { 54685 const nested = diffLayer( 54686 next, 54687 current, 54688 isPlainObject2(prev) ? prev : {} 54689 ); 54690 if (Object.keys(nested).length > 0) { 54691 result[key] = nested; 54692 } 54693 } else if (!dequal(next, current)) { 54694 result[key] = next; 54695 } else if (prev !== void 0 && dequal(next, prev)) { 54696 result[key] = prev; 54697 } 54698 } 54699 return result; 54700 } 54701 function getLockedFilters(overrides) { 54702 return (overrides?.filters ?? []).filter((filter) => filter.isLocked); 54703 } 54704 function applyLockedFilters(view, overrides) { 54705 const locked = getLockedFilters(overrides); 54706 if (locked.length === 0) { 54707 return view; 54708 } 54709 const rest = (view.filters ?? []).filter( 54710 (filter) => !locked.some((f2) => f2.field === filter.field) 54711 ); 54712 return { ...view, filters: [...locked, ...rest] }; 54713 } 54714 function resolveBaseView(layers, effectiveType) { 54715 const { defaultView, defaultLayouts: defaultLayouts2, activeViewOverrides } = layers; 54716 const layoutDefaults = defaultLayouts2?.[effectiveType]; 54717 return applyLockedFilters( 54718 [layoutDefaults, activeViewOverrides].reduce( 54719 (lower, upper) => mergeLayer(lower, withoutQueryParams(upper)), 54720 withoutQueryParams(defaultView) 54721 ), 54722 activeViewOverrides 54723 ); 54724 } 54725 function resolveView(args) { 54726 const { defaultView, activeViewOverrides, persistedView, page, search } = args; 54727 const effectiveType = persistedView?.type ?? activeViewOverrides?.type ?? defaultView?.type; 54728 const baseView = resolveBaseView(args, effectiveType); 54729 const view = { 54730 ...applyLockedFilters( 54731 mergeLayer(baseView, withoutQueryParams(persistedView)), 54732 activeViewOverrides 54733 ), 54734 page: Number(page ?? 1), 54735 search: search ?? "" 54736 }; 54737 return view; 54738 } 54739 function getUserModifications(newView, layers) { 54740 const { activeViewOverrides, persistedView } = layers; 54741 const baseView = resolveBaseView(layers, newView.type); 54742 const modifications = diffLayer( 54743 withoutQueryParams(newView), 54744 withoutQueryParams(baseView), 54745 withoutQueryParams(persistedView) 54746 ); 54747 const locked = getLockedFilters(activeViewOverrides); 54748 if (locked.length > 0 && Array.isArray(modifications.filters)) { 54749 modifications.filters = modifications.filters.filter( 54750 (filter) => !locked.some((f2) => f2.field === filter.field) 54751 ); 54752 } 54753 return Object.keys(modifications).length > 0 ? modifications : void 0; 54754 } 54755 54756 // packages/views/build-module/use-view.mjs 54757 function useView(config2) { 54758 const { 54759 kind, 54760 name: name2, 54761 slug, 54762 defaultView, 54763 defaultLayouts: defaultLayouts2, 54764 activeViewOverrides, 54765 queryParams, 54766 onChangeQueryParams 54767 } = config2; 54768 const preferenceKey = generatePreferenceKey(kind, name2, slug); 54769 const persistedView = (0, import_data63.useSelect)( 54770 (select4) => { 54771 return select4(import_preferences11.store).get( 54772 "core/views", 54773 preferenceKey 54774 ); 54775 }, 54776 [preferenceKey] 54777 ); 54778 const { set: set3 } = (0, import_data63.useDispatch)(import_preferences11.store); 54779 const page = Number(queryParams?.page ?? 1); 54780 const search = queryParams?.search ?? ""; 54781 const view = (0, import_element171.useMemo)( 54782 () => resolveView({ 54783 defaultView, 54784 defaultLayouts: defaultLayouts2, 54785 activeViewOverrides, 54786 persistedView, 54787 page, 54788 search 54789 }), 54790 [ 54791 defaultView, 54792 defaultLayouts2, 54793 activeViewOverrides, 54794 persistedView, 54795 page, 54796 search 54797 ] 54798 ); 54799 const isModified = !!persistedView && Object.keys(persistedView).length > 0; 54800 const updateView = (0, import_element171.useCallback)( 54801 (newView) => { 54802 const newQueryParams = { 54803 page: Number(newView?.page ?? 1), 54804 search: newView?.search ?? "" 54805 }; 54806 if (onChangeQueryParams && !dequal(newQueryParams, { page, search })) { 54807 onChangeQueryParams(newQueryParams); 54808 } 54809 const modifications = getUserModifications(newView, { 54810 defaultView, 54811 defaultLayouts: defaultLayouts2, 54812 activeViewOverrides, 54813 persistedView 54814 }); 54815 if (!dequal(modifications, persistedView)) { 54816 set3("core/views", preferenceKey, modifications); 54817 } 54818 }, 54819 [ 54820 onChangeQueryParams, 54821 page, 54822 search, 54823 defaultView, 54824 defaultLayouts2, 54825 activeViewOverrides, 54826 persistedView, 54827 set3, 54828 preferenceKey 54829 ] 54830 ); 54831 const resetToDefault = (0, import_element171.useCallback)(() => { 54832 set3("core/views", preferenceKey, void 0); 54833 }, [preferenceKey, set3]); 54834 return { 54835 view, 54836 isModified, 54837 updateView, 54838 resetToDefault 54839 }; 54840 } 54841 54842 // packages/views/build-module/load-view.mjs 54843 var import_data64 = __toESM(require_data(), 1); 54844 var import_preferences12 = __toESM(require_preferences(), 1); 54845 async function loadView(config2) { 54846 const { 54847 kind, 54848 name: name2, 54849 slug, 54850 defaultView, 54851 defaultLayouts: defaultLayouts2, 54852 activeViewOverrides, 54853 queryParams 54854 } = config2; 54855 const preferenceKey = generatePreferenceKey(kind, name2, slug); 54856 const persistedView = (0, import_data64.select)( 54857 import_preferences12.store 54858 ).get("core/views", preferenceKey); 54859 return resolveView({ 54860 defaultView, 54861 defaultLayouts: defaultLayouts2, 54862 activeViewOverrides, 54863 persistedView, 54864 page: queryParams?.page, 54865 search: queryParams?.search 54866 }); 54867 } 54868 54869 // packages/views/build-module/use-view-config.mjs 54870 var import_data65 = __toESM(require_data(), 1); 54871 var import_core_data41 = __toESM(require_core_data(), 1); 54872 54873 // packages/views/build-module/lock-unlock.mjs 54874 var import_private_apis8 = __toESM(require_private_apis(), 1); 54875 var { lock: lock7, unlock: unlock7 } = (0, import_private_apis8.__dangerousOptInToUnstableAPIsOnlyForCoreModules)( 54876 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.", 54877 "@wordpress/views" 54878 ); 54879 54880 // packages/views/build-module/use-view-config.mjs 54881 function useViewConfig({ 54882 kind, 54883 name: name2, 54884 fields: fields2 54885 }) { 54886 const fieldList = Array.isArray(fields2) ? fields2 : fields2?.split(","); 54887 const fieldsKey = fieldList ? [...fieldList].sort().join(",") : void 0; 54888 return (0, import_data65.useSelect)( 54889 (select4) => { 54890 return unlock7(select4(import_core_data41.store)).getViewConfig(kind, name2, { 54891 fields: fieldsKey 54892 }); 54893 }, 54894 [kind, name2, fieldsKey] 54895 ); 54896 } 54897 54898 // packages/edit-site/build-module/components/sidebar-navigation-screen-patterns/category-item.mjs 54899 var import_jsx_runtime301 = __toESM(require_jsx_runtime(), 1); 54900 function CategoryItem({ 54901 count, 54902 icon, 54903 id, 54904 isActive, 54905 label, 54906 type 54907 }) { 54908 if (!count) { 54909 return; 54910 } 54911 const queryArgs = [`postType=$type}`]; 54912 if (id) { 54913 queryArgs.push(`categoryId=$id}`); 54914 } 54915 return /* @__PURE__ */ (0, import_jsx_runtime301.jsx)( 54916 SidebarNavigationItem, 54917 { 54918 icon, 54919 suffix: /* @__PURE__ */ (0, import_jsx_runtime301.jsx)("span", { children: count }), 54920 "aria-current": isActive ? "true" : void 0, 54921 to: `/pattern?$queryArgs.join("&")}`, 54922 children: label 54923 } 54924 ); 54925 } 54926 54927 // packages/edit-site/build-module/components/sidebar-navigation-screen-patterns/use-pattern-categories.mjs 54928 var import_element174 = __toESM(require_element(), 1); 54929 var import_i18n133 = __toESM(require_i18n(), 1); 54930 54931 // packages/edit-site/build-module/components/sidebar-navigation-screen-patterns/use-default-pattern-categories.mjs 54932 var import_core_data42 = __toESM(require_core_data(), 1); 54933 var import_data66 = __toESM(require_data(), 1); 54934 function useDefaultPatternCategories() { 54935 const blockPatternCategories = (0, import_data66.useSelect)((select4) => { 54936 const { getSettings: getSettings7 } = unlock(select4(store)); 54937 const settings2 = getSettings7(); 54938 return settings2.__experimentalAdditionalBlockPatternCategories ?? settings2.__experimentalBlockPatternCategories; 54939 }); 54940 const restBlockPatternCategories = (0, import_data66.useSelect)( 54941 (select4) => select4(import_core_data42.store).getBlockPatternCategories() 54942 ); 54943 return [ 54944 ...blockPatternCategories || [], 54945 ...restBlockPatternCategories || [] 54946 ]; 54947 } 54948 54949 // packages/edit-site/build-module/components/sidebar-navigation-screen-patterns/use-theme-patterns.mjs 54950 var import_core_data43 = __toESM(require_core_data(), 1); 54951 var import_data67 = __toESM(require_data(), 1); 54952 var import_element172 = __toESM(require_element(), 1); 54953 54954 // packages/edit-site/build-module/components/page-patterns/utils.mjs 54955 var filterOutDuplicatesByName = (currentItem, index2, items) => index2 === items.findIndex((item) => currentItem.name === item.name); 54956 54957 // packages/edit-site/build-module/components/sidebar-navigation-screen-patterns/use-theme-patterns.mjs 54958 function useThemePatterns() { 54959 const blockPatterns = (0, import_data67.useSelect)((select4) => { 54960 const { getSettings: getSettings7 } = unlock(select4(store)); 54961 return getSettings7().__experimentalAdditionalBlockPatterns ?? getSettings7().__experimentalBlockPatterns; 54962 }); 54963 const restBlockPatterns = (0, import_data67.useSelect)( 54964 (select4) => select4(import_core_data43.store).getBlockPatterns() 54965 ); 54966 const patterns = (0, import_element172.useMemo)( 54967 () => [...blockPatterns || [], ...restBlockPatterns || []].filter( 54968 (pattern) => !EXCLUDED_PATTERN_SOURCES.includes(pattern.source) 54969 ).filter(filterOutDuplicatesByName).filter((pattern) => pattern.inserter !== false), 54970 [blockPatterns, restBlockPatterns] 54971 ); 54972 return patterns; 54973 } 54974 54975 // packages/edit-site/build-module/components/page-patterns/use-patterns.mjs 54976 var import_blocks11 = __toESM(require_blocks(), 1); 54977 var import_data68 = __toESM(require_data(), 1); 54978 var import_core_data44 = __toESM(require_core_data(), 1); 54979 var import_element173 = __toESM(require_element(), 1); 54980 54981 // packages/edit-site/build-module/components/page-patterns/search-items.mjs 54982 var import_block_editor23 = __toESM(require_block_editor(), 1); 54983 var { extractWords, getNormalizedSearchTerms, normalizeString: normalizeString2 } = unlock( 54984 import_block_editor23.privateApis 54985 ); 54986 var defaultGetName = (item) => { 54987 if (item.type === PATTERN_TYPES.user) { 54988 return item.slug; 54989 } 54990 if (item.type === TEMPLATE_PART_POST_TYPE) { 54991 return ""; 54992 } 54993 return item.name || ""; 54994 }; 54995 var defaultGetTitle = (item) => { 54996 if (typeof item.title === "string") { 54997 return item.title; 54998 } 54999 if (item.title && item.title.rendered) { 55000 return item.title.rendered; 55001 } 55002 if (item.title && item.title.raw) { 55003 return item.title.raw; 55004 } 55005 return ""; 55006 }; 55007 var defaultGetDescription = (item) => { 55008 if (item.type === PATTERN_TYPES.user) { 55009 return item.excerpt.raw; 55010 } 55011 return item.description || ""; 55012 }; 55013 var defaultGetKeywords = (item) => item.keywords || []; 55014 var defaultHasCategory = () => false; 55015 var removeMatchingTerms = (unmatchedTerms, unprocessedTerms) => { 55016 return unmatchedTerms.filter( 55017 (term) => !getNormalizedSearchTerms(unprocessedTerms).some( 55018 (unprocessedTerm) => unprocessedTerm.includes(term) 55019 ) 55020 ); 55021 }; 55022 var searchItems = (items = [], searchInput = "", config2 = {}) => { 55023 const normalizedSearchTerms = getNormalizedSearchTerms(searchInput); 55024 const onlyFilterByCategory = config2.categoryId !== PATTERN_DEFAULT_CATEGORY && !normalizedSearchTerms.length; 55025 const searchRankConfig = { ...config2, onlyFilterByCategory }; 55026 const threshold = onlyFilterByCategory ? 0 : 1; 55027 const rankedItems = items.map((item) => { 55028 return [ 55029 item, 55030 getItemSearchRank(item, searchInput, searchRankConfig) 55031 ]; 55032 }).filter(([, rank]) => rank > threshold); 55033 if (normalizedSearchTerms.length === 0) { 55034 return rankedItems.map(([item]) => item); 55035 } 55036 rankedItems.sort(([, rank1], [, rank2]) => rank2 - rank1); 55037 return rankedItems.map(([item]) => item); 55038 }; 55039 function getItemSearchRank(item, searchTerm, config2) { 55040 const { 55041 categoryId, 55042 getName = defaultGetName, 55043 getTitle = defaultGetTitle, 55044 getDescription = defaultGetDescription, 55045 getKeywords = defaultGetKeywords, 55046 hasCategory = defaultHasCategory, 55047 onlyFilterByCategory 55048 } = config2; 55049 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; 55050 if (!rank || onlyFilterByCategory) { 55051 return rank; 55052 } 55053 const name2 = getName(item); 55054 const title = getTitle(item); 55055 const description = getDescription(item); 55056 const keywords = getKeywords(item); 55057 const normalizedSearchInput = normalizeString2(searchTerm); 55058 const normalizedTitle = normalizeString2(title); 55059 if (normalizedSearchInput === normalizedTitle) { 55060 rank += 30; 55061 } else if (normalizedTitle.startsWith(normalizedSearchInput)) { 55062 rank += 20; 55063 } else { 55064 const terms = [name2, title, description, ...keywords].join(" "); 55065 const normalizedSearchTerms = extractWords(normalizedSearchInput); 55066 const unmatchedTerms = removeMatchingTerms( 55067 normalizedSearchTerms, 55068 terms 55069 ); 55070 if (unmatchedTerms.length === 0) { 55071 rank += 10; 55072 } 55073 } 55074 return rank; 55075 } 55076 55077 // packages/edit-site/build-module/components/page-patterns/use-patterns.mjs 55078 var EMPTY_PATTERN_LIST = []; 55079 var selectTemplateParts = (0, import_data68.createSelector)( 55080 (select4, categoryId, search = "") => { 55081 const { 55082 getEntityRecords, 55083 getCurrentTheme, 55084 isResolving: isResolvingSelector 55085 } = select4(import_core_data44.store); 55086 const query = { per_page: -1 }; 55087 const templateParts = getEntityRecords("postType", TEMPLATE_PART_POST_TYPE, query) ?? EMPTY_PATTERN_LIST; 55088 const knownAreas = getCurrentTheme()?.default_template_part_areas || []; 55089 const templatePartAreas = knownAreas.map((area) => area.area); 55090 const templatePartHasCategory = (item, category) => { 55091 if (category !== TEMPLATE_PART_AREA_DEFAULT_CATEGORY) { 55092 return item.area === category; 55093 } 55094 return item.area === category || !templatePartAreas.includes(item.area); 55095 }; 55096 const isResolving = isResolvingSelector("getEntityRecords", [ 55097 "postType", 55098 TEMPLATE_PART_POST_TYPE, 55099 query 55100 ]); 55101 const patterns = searchItems(templateParts, search, { 55102 categoryId, 55103 hasCategory: templatePartHasCategory 55104 }); 55105 return { patterns, isResolving }; 55106 }, 55107 (select4) => [ 55108 select4(import_core_data44.store).getEntityRecords( 55109 "postType", 55110 TEMPLATE_PART_POST_TYPE, 55111 { 55112 per_page: -1 55113 } 55114 ), 55115 select4(import_core_data44.store).isResolving("getEntityRecords", [ 55116 "postType", 55117 TEMPLATE_PART_POST_TYPE, 55118 { per_page: -1 } 55119 ]), 55120 select4(import_core_data44.store).getCurrentTheme()?.default_template_part_areas 55121 ] 55122 ); 55123 var selectThemePatterns = (0, import_data68.createSelector)( 55124 (select4) => { 55125 const { getSettings: getSettings7 } = unlock(select4(store)); 55126 const { isResolving: isResolvingSelector } = select4(import_core_data44.store); 55127 const settings2 = getSettings7(); 55128 const blockPatterns = settings2.__experimentalAdditionalBlockPatterns ?? settings2.__experimentalBlockPatterns; 55129 const restBlockPatterns = select4(import_core_data44.store).getBlockPatterns(); 55130 const patterns = [ 55131 ...blockPatterns || [], 55132 ...restBlockPatterns || [] 55133 ].filter( 55134 (pattern) => !EXCLUDED_PATTERN_SOURCES.includes(pattern.source) 55135 ).filter(filterOutDuplicatesByName).filter((pattern) => pattern.inserter !== false).map((pattern) => ({ 55136 ...pattern, 55137 keywords: pattern.keywords || [], 55138 type: PATTERN_TYPES.theme, 55139 blocks: (0, import_blocks11.parse)(pattern.content, { 55140 __unstableSkipMigrationLogs: true 55141 }) 55142 })); 55143 return { 55144 patterns, 55145 isResolving: isResolvingSelector("getBlockPatterns") 55146 }; 55147 }, 55148 (select4) => [ 55149 select4(import_core_data44.store).getBlockPatterns(), 55150 select4(import_core_data44.store).isResolving("getBlockPatterns"), 55151 unlock(select4(store)).getSettings() 55152 ] 55153 ); 55154 var selectPatterns = (0, import_data68.createSelector)( 55155 (select4, categoryId, syncStatus, search = "") => { 55156 const { 55157 patterns: themePatterns, 55158 isResolving: isResolvingThemePatterns 55159 } = selectThemePatterns(select4); 55160 const { 55161 patterns: userPatterns, 55162 isResolving: isResolvingUserPatterns, 55163 categories: userPatternCategories 55164 } = selectUserPatterns(select4); 55165 let patterns = [ 55166 ...themePatterns || [], 55167 ...userPatterns || [] 55168 ]; 55169 if (syncStatus) { 55170 patterns = patterns.filter((pattern) => { 55171 return pattern.type === PATTERN_TYPES.user ? (pattern.wp_pattern_sync_status || PATTERN_SYNC_TYPES.full) === syncStatus : syncStatus === PATTERN_SYNC_TYPES.unsynced; 55172 }); 55173 } 55174 if (categoryId) { 55175 patterns = searchItems(patterns, search, { 55176 categoryId, 55177 hasCategory: (item, currentCategory) => { 55178 if (item.type === PATTERN_TYPES.user) { 55179 return item.wp_pattern_category?.some( 55180 (catId) => userPatternCategories.find( 55181 (cat) => cat.id === catId 55182 )?.slug === currentCategory 55183 ); 55184 } 55185 return item.categories?.includes(currentCategory); 55186 } 55187 }); 55188 } else { 55189 patterns = searchItems(patterns, search, { 55190 hasCategory: (item) => { 55191 if (item.type === PATTERN_TYPES.user) { 55192 return userPatternCategories?.length && (!item.wp_pattern_category?.length || !item.wp_pattern_category?.some( 55193 (catId) => userPatternCategories.find( 55194 (cat) => cat.id === catId 55195 ) 55196 )); 55197 } 55198 return !item.hasOwnProperty("categories"); 55199 } 55200 }); 55201 } 55202 return { 55203 patterns, 55204 isResolving: isResolvingThemePatterns || isResolvingUserPatterns 55205 }; 55206 }, 55207 (select4) => [ 55208 selectThemePatterns(select4), 55209 selectUserPatterns(select4) 55210 ] 55211 ); 55212 var selectUserPatterns = (0, import_data68.createSelector)( 55213 (select4, syncStatus, search = "") => { 55214 const { 55215 getEntityRecords, 55216 isResolving: isResolvingSelector, 55217 getUserPatternCategories 55218 } = select4(import_core_data44.store); 55219 const query = { per_page: -1 }; 55220 const patternPosts = getEntityRecords( 55221 "postType", 55222 PATTERN_TYPES.user, 55223 query 55224 ); 55225 const userPatternCategories = getUserPatternCategories(); 55226 const categories = /* @__PURE__ */ new Map(); 55227 userPatternCategories.forEach( 55228 (userCategory) => categories.set(userCategory.id, userCategory) 55229 ); 55230 let patterns = patternPosts ?? EMPTY_PATTERN_LIST; 55231 const isResolving = isResolvingSelector("getEntityRecords", [ 55232 "postType", 55233 PATTERN_TYPES.user, 55234 query 55235 ]); 55236 if (syncStatus) { 55237 patterns = patterns.filter( 55238 (pattern) => pattern.wp_pattern_sync_status || PATTERN_SYNC_TYPES.full === syncStatus 55239 ); 55240 } 55241 patterns = searchItems(patterns, search, { 55242 // We exit user pattern retrieval early if we aren't in the 55243 // catch-all category for user created patterns, so it has 55244 // to be in the category. 55245 hasCategory: () => true 55246 }); 55247 return { 55248 patterns, 55249 isResolving, 55250 categories: userPatternCategories 55251 }; 55252 }, 55253 (select4) => [ 55254 select4(import_core_data44.store).getEntityRecords("postType", PATTERN_TYPES.user, { 55255 per_page: -1 55256 }), 55257 select4(import_core_data44.store).isResolving("getEntityRecords", [ 55258 "postType", 55259 PATTERN_TYPES.user, 55260 { per_page: -1 } 55261 ]), 55262 select4(import_core_data44.store).getUserPatternCategories() 55263 ] 55264 ); 55265 function useAugmentPatternsWithPermissions(patterns) { 55266 const idsAndTypes = (0, import_element173.useMemo)( 55267 () => patterns?.filter((record) => record.type !== PATTERN_TYPES.theme).map((record) => [record.type, record.id]) ?? [], 55268 [patterns] 55269 ); 55270 const permissions = (0, import_data68.useSelect)( 55271 (select4) => { 55272 const { getEntityRecordPermissions } = unlock( 55273 select4(import_core_data44.store) 55274 ); 55275 return idsAndTypes.reduce((acc, [type, id]) => { 55276 acc[id] = getEntityRecordPermissions("postType", type, id); 55277 return acc; 55278 }, {}); 55279 }, 55280 [idsAndTypes] 55281 ); 55282 return (0, import_element173.useMemo)( 55283 () => patterns?.map((record) => ({ 55284 ...record, 55285 permissions: permissions?.[record.id] ?? {} 55286 })) ?? [], 55287 [patterns, permissions] 55288 ); 55289 } 55290 var usePatterns = (postType2, categoryId, { search = "", syncStatus } = {}) => { 55291 return (0, import_data68.useSelect)( 55292 (select4) => { 55293 if (postType2 === TEMPLATE_PART_POST_TYPE) { 55294 return selectTemplateParts(select4, categoryId, search); 55295 } else if (postType2 === PATTERN_TYPES.user && !!categoryId) { 55296 const appliedCategory = categoryId === "uncategorized" ? "" : categoryId; 55297 return selectPatterns( 55298 select4, 55299 appliedCategory, 55300 syncStatus, 55301 search 55302 ); 55303 } else if (postType2 === PATTERN_TYPES.user) { 55304 return selectUserPatterns(select4, syncStatus, search); 55305 } 55306 return { 55307 patterns: EMPTY_PATTERN_LIST, 55308 isResolving: false 55309 }; 55310 }, 55311 [categoryId, postType2, search, syncStatus] 55312 ); 55313 }; 55314 var use_patterns_default = usePatterns; 55315 55316 // packages/edit-site/build-module/components/sidebar-navigation-screen-patterns/use-pattern-categories.mjs 55317 function usePatternCategories() { 55318 const defaultCategories = useDefaultPatternCategories(); 55319 defaultCategories.push({ 55320 name: TEMPLATE_PART_AREA_DEFAULT_CATEGORY, 55321 label: (0, import_i18n133.__)("Uncategorized") 55322 }); 55323 const themePatterns = useThemePatterns(); 55324 const { patterns: userPatterns, categories: userPatternCategories } = use_patterns_default(PATTERN_TYPES.user); 55325 const patternCategories = (0, import_element174.useMemo)(() => { 55326 const categoryMap = {}; 55327 const categoriesWithCounts = []; 55328 defaultCategories.forEach((category) => { 55329 if (!categoryMap[category.name]) { 55330 categoryMap[category.name] = { ...category, count: 0 }; 55331 } 55332 }); 55333 userPatternCategories.forEach((category) => { 55334 if (!categoryMap[category.name]) { 55335 categoryMap[category.name] = { ...category, count: 0 }; 55336 } 55337 }); 55338 themePatterns.forEach((pattern) => { 55339 pattern.categories?.forEach((category) => { 55340 if (categoryMap[category]) { 55341 categoryMap[category].count += 1; 55342 } 55343 }); 55344 if (!pattern.categories?.length) { 55345 categoryMap.uncategorized.count += 1; 55346 } 55347 }); 55348 userPatterns.forEach((pattern) => { 55349 pattern.wp_pattern_category?.forEach((catId) => { 55350 const category = userPatternCategories.find( 55351 (cat) => cat.id === catId 55352 )?.name; 55353 if (categoryMap[category]) { 55354 categoryMap[category].count += 1; 55355 } 55356 }); 55357 if (!pattern.wp_pattern_category?.length || !pattern.wp_pattern_category?.some( 55358 (catId) => userPatternCategories.find((cat) => cat.id === catId) 55359 )) { 55360 categoryMap.uncategorized.count += 1; 55361 } 55362 }); 55363 [...defaultCategories, ...userPatternCategories].forEach( 55364 (category) => { 55365 if (categoryMap[category.name].count && !categoriesWithCounts.find( 55366 (cat) => cat.name === category.name 55367 )) { 55368 categoriesWithCounts.push(categoryMap[category.name]); 55369 } 55370 } 55371 ); 55372 const sortedCategories = categoriesWithCounts.sort( 55373 (a2, b2) => a2.label.localeCompare(b2.label) 55374 ); 55375 sortedCategories.unshift({ 55376 name: PATTERN_USER_CATEGORY, 55377 label: (0, import_i18n133.__)("My patterns"), 55378 count: userPatterns.length 55379 }); 55380 sortedCategories.unshift({ 55381 name: PATTERN_DEFAULT_CATEGORY, 55382 label: (0, import_i18n133.__)("All patterns"), 55383 description: (0, import_i18n133.__)("A list of all patterns from all sources."), 55384 count: themePatterns.length + userPatterns.length 55385 }); 55386 return sortedCategories; 55387 }, [ 55388 defaultCategories, 55389 themePatterns, 55390 userPatternCategories, 55391 userPatterns 55392 ]); 55393 return { patternCategories, hasPatterns: !!patternCategories.length }; 55394 } 55395 55396 // packages/edit-site/build-module/components/sidebar-navigation-screen-patterns/use-template-part-areas.mjs 55397 var import_core_data45 = __toESM(require_core_data(), 1); 55398 var import_data69 = __toESM(require_data(), 1); 55399 var import_block_library3 = __toESM(require_block_library(), 1); 55400 var { NAVIGATION_OVERLAY_TEMPLATE_PART_AREA } = unlock( 55401 import_block_library3.privateApis 55402 ); 55403 var useTemplatePartsGroupedByArea = (items) => { 55404 const allItems = items || []; 55405 const templatePartAreas = (0, import_data69.useSelect)( 55406 (select4) => select4(import_core_data45.store).getCurrentTheme()?.default_template_part_areas || [], 55407 [] 55408 ); 55409 const knownAreas = { 55410 header: {}, 55411 footer: {}, 55412 sidebar: {}, 55413 uncategorized: {}, 55414 [NAVIGATION_OVERLAY_TEMPLATE_PART_AREA]: {} 55415 }; 55416 templatePartAreas.forEach( 55417 (templatePartArea) => knownAreas[templatePartArea.area] = { 55418 ...templatePartArea, 55419 templateParts: [] 55420 } 55421 ); 55422 const groupedByArea = allItems.reduce((accumulator, item) => { 55423 const key = accumulator[item.area] ? item.area : TEMPLATE_PART_AREA_DEFAULT_CATEGORY; 55424 accumulator[key]?.templateParts?.push(item); 55425 return accumulator; 55426 }, knownAreas); 55427 return groupedByArea; 55428 }; 55429 function useTemplatePartAreas() { 55430 const { records: templateParts, isResolving: isLoading } = (0, import_core_data45.useEntityRecords)( 55431 "postType", 55432 TEMPLATE_PART_POST_TYPE, 55433 { per_page: -1 } 55434 ); 55435 return { 55436 hasTemplateParts: templateParts ? !!templateParts.length : false, 55437 isLoading, 55438 templatePartAreas: useTemplatePartsGroupedByArea(templateParts) 55439 }; 55440 } 55441 55442 // packages/edit-site/build-module/components/sidebar-navigation-screen-patterns/index.mjs 55443 var import_jsx_runtime302 = __toESM(require_jsx_runtime(), 1); 55444 var VIEW_CONFIG_FIELDS = ["view_list"]; 55445 var { useLocation: useLocation24 } = unlock(import_router26.privateApis); 55446 function CategoriesGroup({ 55447 templatePartViews, 55448 patternViews, 55449 templatePartCounts, 55450 patternCounts, 55451 currentCategory, 55452 currentType 55453 }) { 55454 return /* @__PURE__ */ (0, import_jsx_runtime302.jsxs)(import_components139.__experimentalItemGroup, { className: "edit-site-sidebar-navigation-screen-patterns__group", children: [ 55455 templatePartViews?.map((view) => /* @__PURE__ */ (0, import_jsx_runtime302.jsx)( 55456 CategoryItem, 55457 { 55458 count: templatePartCounts[view.slug], 55459 icon: (0, import_editor29.getTemplatePartIcon)( 55460 view.slug === TEMPLATE_PART_ALL_AREAS_CATEGORY ? void 0 : view.slug 55461 ), 55462 label: view.title, 55463 id: view.slug, 55464 type: TEMPLATE_PART_POST_TYPE, 55465 isActive: currentCategory === view.slug && currentType === TEMPLATE_PART_POST_TYPE 55466 }, 55467 view.slug 55468 )), 55469 /* @__PURE__ */ (0, import_jsx_runtime302.jsx)("div", { className: "edit-site-sidebar-navigation-screen-patterns__divider" }), 55470 patternViews?.map((view) => /* @__PURE__ */ (0, import_jsx_runtime302.jsx)( 55471 CategoryItem, 55472 { 55473 count: patternCounts[view.slug], 55474 label: view.title, 55475 icon: file_default, 55476 id: view.slug, 55477 type: PATTERN_TYPES.user, 55478 isActive: currentCategory === `$view.slug}` && currentType === PATTERN_TYPES.user 55479 }, 55480 view.slug 55481 )) 55482 ] }); 55483 } 55484 function SidebarNavigationScreenPatterns({ backPath }) { 55485 const { 55486 query: { postType: postType2 = "wp_block", categoryId } 55487 } = useLocation24(); 55488 const currentCategory = categoryId || (postType2 === PATTERN_TYPES.user ? PATTERN_DEFAULT_CATEGORY : TEMPLATE_PART_ALL_AREAS_CATEGORY); 55489 const { view_list: templatePartViews } = useViewConfig({ 55490 kind: "postType", 55491 name: TEMPLATE_PART_POST_TYPE, 55492 fields: VIEW_CONFIG_FIELDS 55493 }); 55494 const { view_list: patternViews } = useViewConfig({ 55495 kind: "postType", 55496 name: PATTERN_TYPES.user, 55497 fields: VIEW_CONFIG_FIELDS 55498 }); 55499 const { templatePartAreas, isLoading, hasTemplateParts } = useTemplatePartAreas(); 55500 const templatePartCounts = (0, import_element175.useMemo)(() => { 55501 const counts = { [TEMPLATE_PART_ALL_AREAS_CATEGORY]: 0 }; 55502 Object.entries(templatePartAreas).forEach( 55503 ([area, { templateParts }]) => { 55504 const count = templateParts?.length || 0; 55505 counts[area] = count; 55506 counts[TEMPLATE_PART_ALL_AREAS_CATEGORY] += count; 55507 } 55508 ); 55509 return counts; 55510 }, [templatePartAreas]); 55511 const { patternCategories } = usePatternCategories(); 55512 const patternCounts = (0, import_element175.useMemo)(() => { 55513 const counts = {}; 55514 patternCategories.forEach((cat) => { 55515 counts[cat.name] = cat.count; 55516 }); 55517 return counts; 55518 }, [patternCategories]); 55519 const hasPatterns = patternCounts[PATTERN_DEFAULT_CATEGORY] > 0; 55520 return /* @__PURE__ */ (0, import_jsx_runtime302.jsx)( 55521 SidebarNavigationScreen, 55522 { 55523 title: (0, import_i18n134.__)("Patterns"), 55524 description: (0, import_i18n134.__)( 55525 "Manage what patterns are available when editing the site." 55526 ), 55527 isRoot: !backPath, 55528 backPath, 55529 content: /* @__PURE__ */ (0, import_jsx_runtime302.jsxs)(import_jsx_runtime302.Fragment, { children: [ 55530 isLoading && (0, import_i18n134.__)("Loading items\u2026"), 55531 !isLoading && /* @__PURE__ */ (0, import_jsx_runtime302.jsxs)(import_jsx_runtime302.Fragment, { children: [ 55532 !hasTemplateParts && !hasPatterns && /* @__PURE__ */ (0, import_jsx_runtime302.jsx)(import_components139.__experimentalItemGroup, { className: "edit-site-sidebar-navigation-screen-patterns__group", children: /* @__PURE__ */ (0, import_jsx_runtime302.jsx)(import_components139.__experimentalItem, { children: (0, import_i18n134.__)("No items found") }) }), 55533 /* @__PURE__ */ (0, import_jsx_runtime302.jsx)( 55534 CategoriesGroup, 55535 { 55536 templatePartViews, 55537 patternViews, 55538 templatePartCounts, 55539 patternCounts, 55540 currentCategory, 55541 currentType: postType2 55542 } 55543 ) 55544 ] }) 55545 ] }) 55546 } 55547 ); 55548 } 55549 55550 // packages/edit-site/build-module/components/page-patterns/index.mjs 55551 var import_i18n141 = __toESM(require_i18n(), 1); 55552 var import_element182 = __toESM(require_element(), 1); 55553 var import_block_editor26 = __toESM(require_block_editor(), 1); 55554 var import_core_data50 = __toESM(require_core_data(), 1); 55555 var import_editor33 = __toESM(require_editor(), 1); 55556 var import_router30 = __toESM(require_router(), 1); 55557 var import_data74 = __toESM(require_data(), 1); 55558 var import_url17 = __toESM(require_url(), 1); 55559 55560 // packages/edit-site/build-module/components/page-patterns/use-pattern-settings.mjs 55561 var import_core_data46 = __toESM(require_core_data(), 1); 55562 var import_data70 = __toESM(require_data(), 1); 55563 var import_element176 = __toESM(require_element(), 1); 55564 var import_block_editor24 = __toESM(require_block_editor(), 1); 55565 var import_editor30 = __toESM(require_editor(), 1); 55566 var { useGlobalStyles: useGlobalStyles4 } = unlock(import_editor30.privateApis); 55567 var { globalStylesDataKey } = unlock(import_block_editor24.privateApis); 55568 function usePatternSettings() { 55569 const { merged: mergedConfig } = useGlobalStyles4(); 55570 const storedSettings = (0, import_data70.useSelect)((select4) => { 55571 const { getSettings: getSettings7 } = unlock(select4(store)); 55572 return getSettings7(); 55573 }, []); 55574 const settingsBlockPatterns = storedSettings.__experimentalAdditionalBlockPatterns ?? // WP 6.0 55575 storedSettings.__experimentalBlockPatterns; 55576 const restBlockPatterns = (0, import_data70.useSelect)( 55577 (select4) => select4(import_core_data46.store).getBlockPatterns(), 55578 [] 55579 ); 55580 const blockPatterns = (0, import_element176.useMemo)( 55581 () => [ 55582 ...settingsBlockPatterns || [], 55583 ...restBlockPatterns || [] 55584 ].filter(filterOutDuplicatesByName), 55585 [settingsBlockPatterns, restBlockPatterns] 55586 ); 55587 const [globalStyles, globalSettings] = (0, import_element176.useMemo)(() => { 55588 return generateGlobalStyles(mergedConfig, [], { 55589 disableRootPadding: false 55590 }); 55591 }, [mergedConfig]); 55592 const settings2 = (0, import_element176.useMemo)(() => { 55593 const { 55594 __experimentalAdditionalBlockPatterns, 55595 styles, 55596 __experimentalFeatures, 55597 ...restStoredSettings 55598 } = storedSettings; 55599 const nonGlobalStyles = (styles ?? []).filter( 55600 (style) => !style.isGlobalStyles 55601 ); 55602 return { 55603 ...restStoredSettings, 55604 styles: [...nonGlobalStyles, ...globalStyles], 55605 __experimentalFeatures: globalSettings, 55606 [globalStylesDataKey]: mergedConfig.styles ?? {}, 55607 __experimentalBlockPatterns: blockPatterns, 55608 isPreviewMode: true 55609 }; 55610 }, [ 55611 storedSettings, 55612 blockPatterns, 55613 globalStyles, 55614 globalSettings, 55615 mergedConfig 55616 ]); 55617 return settings2; 55618 } 55619 55620 // packages/edit-site/build-module/components/page-patterns/actions.mjs 55621 var import_components143 = __toESM(require_components(), 1); 55622 var import_i18n138 = __toESM(require_i18n(), 1); 55623 55624 // packages/edit-site/build-module/components/add-new-pattern/index.mjs 55625 var import_components140 = __toESM(require_components(), 1); 55626 var import_element177 = __toESM(require_element(), 1); 55627 var import_i18n135 = __toESM(require_i18n(), 1); 55628 var import_data71 = __toESM(require_data(), 1); 55629 var import_router27 = __toESM(require_router(), 1); 55630 var import_patterns2 = __toESM(require_patterns(), 1); 55631 var import_notices6 = __toESM(require_notices(), 1); 55632 var import_core_data47 = __toESM(require_core_data(), 1); 55633 var import_editor31 = __toESM(require_editor(), 1); 55634 var import_jsx_runtime303 = __toESM(require_jsx_runtime(), 1); 55635 var { useHistory: useHistory18, useLocation: useLocation25 } = unlock(import_router27.privateApis); 55636 var { CreatePatternModal, useAddPatternCategory } = unlock( 55637 import_patterns2.privateApis 55638 ); 55639 var { CreateTemplatePartModal } = unlock(import_editor31.privateApis); 55640 function AddNewPattern() { 55641 const history = useHistory18(); 55642 const location = useLocation25(); 55643 const [showPatternModal, setShowPatternModal] = (0, import_element177.useState)(false); 55644 const [showTemplatePartModal, setShowTemplatePartModal] = (0, import_element177.useState)(false); 55645 const { createPatternFromFile } = unlock((0, import_data71.useDispatch)(import_patterns2.store)); 55646 const { createSuccessNotice, createErrorNotice } = (0, import_data71.useDispatch)(import_notices6.store); 55647 const patternUploadInputRef = (0, import_element177.useRef)(); 55648 const { 55649 isBlockBasedTheme, 55650 addNewPatternLabel, 55651 addNewTemplatePartLabel, 55652 canCreatePattern, 55653 canCreateTemplatePart 55654 } = (0, import_data71.useSelect)((select4) => { 55655 const { getCurrentTheme, getPostType: getPostType2, canUser } = select4(import_core_data47.store); 55656 return { 55657 isBlockBasedTheme: getCurrentTheme()?.is_block_theme, 55658 addNewPatternLabel: getPostType2(PATTERN_TYPES.user)?.labels?.add_new_item, 55659 addNewTemplatePartLabel: getPostType2(TEMPLATE_PART_POST_TYPE)?.labels?.add_new_item, 55660 // Blocks refers to the wp_block post type, this checks the ability to create a post of that type. 55661 canCreatePattern: canUser("create", { 55662 kind: "postType", 55663 name: PATTERN_TYPES.user 55664 }), 55665 canCreateTemplatePart: canUser("create", { 55666 kind: "postType", 55667 name: TEMPLATE_PART_POST_TYPE 55668 }) 55669 }; 55670 }, []); 55671 function handleCreatePattern({ pattern }) { 55672 setShowPatternModal(false); 55673 history.navigate( 55674 `/$PATTERN_TYPES.user}/$pattern.id}?canvas=edit` 55675 ); 55676 } 55677 function handleCreateTemplatePart(templatePart) { 55678 setShowTemplatePartModal(false); 55679 history.navigate( 55680 `/$TEMPLATE_PART_POST_TYPE}/$templatePart.id}?canvas=edit` 55681 ); 55682 } 55683 function handleError() { 55684 setShowPatternModal(false); 55685 setShowTemplatePartModal(false); 55686 } 55687 const controls = []; 55688 if (canCreatePattern) { 55689 controls.push({ 55690 icon: symbol_default, 55691 onClick: () => setShowPatternModal(true), 55692 title: addNewPatternLabel 55693 }); 55694 } 55695 if (isBlockBasedTheme && canCreateTemplatePart) { 55696 controls.push({ 55697 icon: symbol_filled_default, 55698 onClick: () => setShowTemplatePartModal(true), 55699 title: addNewTemplatePartLabel 55700 }); 55701 } 55702 if (canCreatePattern) { 55703 controls.push({ 55704 icon: upload_default, 55705 onClick: () => { 55706 patternUploadInputRef.current.click(); 55707 }, 55708 title: (0, import_i18n135.__)("Import pattern from JSON") 55709 }); 55710 } 55711 const { categoryMap, findOrCreateTerm } = useAddPatternCategory(); 55712 if (controls.length === 0) { 55713 return null; 55714 } 55715 return /* @__PURE__ */ (0, import_jsx_runtime303.jsxs)(import_jsx_runtime303.Fragment, { children: [ 55716 addNewPatternLabel && /* @__PURE__ */ (0, import_jsx_runtime303.jsx)( 55717 import_components140.DropdownMenu, 55718 { 55719 controls, 55720 icon: null, 55721 toggleProps: { 55722 variant: "primary", 55723 showTooltip: false, 55724 size: "compact", 55725 __next40pxDefaultSize: true 55726 }, 55727 text: addNewPatternLabel, 55728 label: addNewPatternLabel 55729 } 55730 ), 55731 showPatternModal && /* @__PURE__ */ (0, import_jsx_runtime303.jsx)( 55732 CreatePatternModal, 55733 { 55734 onClose: () => setShowPatternModal(false), 55735 onSuccess: handleCreatePattern, 55736 onError: handleError 55737 } 55738 ), 55739 showTemplatePartModal && /* @__PURE__ */ (0, import_jsx_runtime303.jsx)( 55740 CreateTemplatePartModal, 55741 { 55742 closeModal: () => setShowTemplatePartModal(false), 55743 blocks: [], 55744 onCreate: handleCreateTemplatePart, 55745 onError: handleError 55746 } 55747 ), 55748 /* @__PURE__ */ (0, import_jsx_runtime303.jsx)( 55749 "input", 55750 { 55751 type: "file", 55752 accept: ".json", 55753 hidden: true, 55754 ref: patternUploadInputRef, 55755 onChange: async (event) => { 55756 const file = event.target.files?.[0]; 55757 if (!file) { 55758 return; 55759 } 55760 try { 55761 let currentCategoryId; 55762 if (location.query.postType !== TEMPLATE_PART_POST_TYPE) { 55763 const currentCategory = Array.from( 55764 categoryMap.values() 55765 ).find( 55766 (term) => term.name === location.query.categoryId 55767 ); 55768 if (currentCategory) { 55769 currentCategoryId = currentCategory.id || await findOrCreateTerm( 55770 currentCategory.label 55771 ); 55772 } 55773 } 55774 const pattern = await createPatternFromFile( 55775 file, 55776 currentCategoryId ? [currentCategoryId] : void 0 55777 ); 55778 if (!currentCategoryId && location.query.categoryId !== "my-patterns") { 55779 history.navigate( 55780 `/pattern?categoryId=$PATTERN_DEFAULT_CATEGORY}` 55781 ); 55782 } 55783 createSuccessNotice( 55784 (0, import_i18n135.sprintf)( 55785 // translators: %s: The imported pattern's title. 55786 (0, import_i18n135.__)('Imported "%s" from JSON.'), 55787 pattern.title.raw 55788 ), 55789 { 55790 type: "snackbar", 55791 id: "import-pattern-success" 55792 } 55793 ); 55794 } catch (err) { 55795 createErrorNotice(err.message, { 55796 type: "snackbar", 55797 id: "import-pattern-error" 55798 }); 55799 } finally { 55800 event.target.value = ""; 55801 } 55802 } 55803 } 55804 ) 55805 ] }); 55806 } 55807 55808 // packages/edit-site/build-module/components/page-patterns/rename-category-menu-item.mjs 55809 var import_components141 = __toESM(require_components(), 1); 55810 var import_element178 = __toESM(require_element(), 1); 55811 var import_i18n136 = __toESM(require_i18n(), 1); 55812 var import_patterns3 = __toESM(require_patterns(), 1); 55813 var import_jsx_runtime304 = __toESM(require_jsx_runtime(), 1); 55814 var { RenamePatternCategoryModal } = unlock(import_patterns3.privateApis); 55815 function RenameCategoryMenuItem({ category, onClose }) { 55816 const [isModalOpen, setIsModalOpen] = (0, import_element178.useState)(false); 55817 return /* @__PURE__ */ (0, import_jsx_runtime304.jsxs)(import_jsx_runtime304.Fragment, { children: [ 55818 /* @__PURE__ */ (0, import_jsx_runtime304.jsx)(import_components141.MenuItem, { onClick: () => setIsModalOpen(true), children: (0, import_i18n136.__)("Rename") }), 55819 isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime304.jsx)( 55820 RenameModal2, 55821 { 55822 category, 55823 onClose: () => { 55824 setIsModalOpen(false); 55825 onClose(); 55826 } 55827 } 55828 ) 55829 ] }); 55830 } 55831 function RenameModal2({ category, onClose }) { 55832 const normalizedCategory = { 55833 id: category.id, 55834 slug: category.slug, 55835 name: category.label 55836 }; 55837 const existingCategories = usePatternCategories(); 55838 return /* @__PURE__ */ (0, import_jsx_runtime304.jsx)( 55839 RenamePatternCategoryModal, 55840 { 55841 category: normalizedCategory, 55842 existingCategories, 55843 onClose, 55844 overlayClassName: "edit-site-list__rename-modal", 55845 focusOnMount: "firstContentElement", 55846 size: "small" 55847 } 55848 ); 55849 } 55850 55851 // packages/edit-site/build-module/components/page-patterns/delete-category-menu-item.mjs 55852 var import_components142 = __toESM(require_components(), 1); 55853 var import_core_data48 = __toESM(require_core_data(), 1); 55854 var import_data72 = __toESM(require_data(), 1); 55855 var import_element179 = __toESM(require_element(), 1); 55856 var import_html_entities8 = __toESM(require_html_entities(), 1); 55857 var import_i18n137 = __toESM(require_i18n(), 1); 55858 var import_notices7 = __toESM(require_notices(), 1); 55859 var import_router28 = __toESM(require_router(), 1); 55860 var import_jsx_runtime305 = __toESM(require_jsx_runtime(), 1); 55861 var { useHistory: useHistory19 } = unlock(import_router28.privateApis); 55862 function DeleteCategoryMenuItem({ category, onClose }) { 55863 const [isModalOpen, setIsModalOpen] = (0, import_element179.useState)(false); 55864 const history = useHistory19(); 55865 const { createSuccessNotice, createErrorNotice } = (0, import_data72.useDispatch)(import_notices7.store); 55866 const { deleteEntityRecord, invalidateResolution } = (0, import_data72.useDispatch)(import_core_data48.store); 55867 const onDelete = async () => { 55868 try { 55869 await deleteEntityRecord( 55870 "taxonomy", 55871 "wp_pattern_category", 55872 category.id, 55873 { force: true }, 55874 { throwOnError: true } 55875 ); 55876 invalidateResolution("getUserPatternCategories"); 55877 invalidateResolution("getEntityRecords", [ 55878 "postType", 55879 PATTERN_TYPES.user, 55880 { per_page: -1 } 55881 ]); 55882 createSuccessNotice( 55883 (0, import_i18n137.sprintf)( 55884 /* translators: %s: The pattern category's name */ 55885 (0, import_i18n137._x)('"%s" deleted.', "pattern category"), 55886 category.label 55887 ), 55888 { type: "snackbar", id: "pattern-category-delete" } 55889 ); 55890 onClose?.(); 55891 history.navigate( 55892 `/pattern?categoryId=$PATTERN_DEFAULT_CATEGORY}` 55893 ); 55894 } catch (error2) { 55895 const errorMessage = error2.message && error2.code !== "unknown_error" ? error2.message : (0, import_i18n137.__)( 55896 "An error occurred while deleting the pattern category." 55897 ); 55898 createErrorNotice(errorMessage, { 55899 type: "snackbar", 55900 id: "pattern-category-delete" 55901 }); 55902 } 55903 }; 55904 return /* @__PURE__ */ (0, import_jsx_runtime305.jsxs)(import_jsx_runtime305.Fragment, { children: [ 55905 /* @__PURE__ */ (0, import_jsx_runtime305.jsx)(import_components142.MenuItem, { isDestructive: true, onClick: () => setIsModalOpen(true), children: (0, import_i18n137.__)("Delete") }), 55906 /* @__PURE__ */ (0, import_jsx_runtime305.jsx)( 55907 import_components142.__experimentalConfirmDialog, 55908 { 55909 isOpen: isModalOpen, 55910 onConfirm: onDelete, 55911 onCancel: () => setIsModalOpen(false), 55912 confirmButtonText: (0, import_i18n137.__)("Delete"), 55913 className: "edit-site-patterns__delete-modal", 55914 title: (0, import_i18n137.sprintf)( 55915 // translators: %s: The pattern category's name. 55916 (0, import_i18n137._x)('Delete "%s"?', "pattern category"), 55917 (0, import_html_entities8.decodeEntities)(category.label) 55918 ), 55919 size: "medium", 55920 __experimentalHideHeader: false, 55921 children: (0, import_i18n137.sprintf)( 55922 // translators: %s: The pattern category's name. 55923 (0, import_i18n137.__)( 55924 'Are you sure you want to delete the category "%s"? The patterns will not be deleted.' 55925 ), 55926 (0, import_html_entities8.decodeEntities)(category.label) 55927 ) 55928 } 55929 ) 55930 ] }); 55931 } 55932 55933 // packages/edit-site/build-module/components/page-patterns/actions.mjs 55934 var import_jsx_runtime306 = __toESM(require_jsx_runtime(), 1); 55935 function PatternsActions({ categoryId, type }) { 55936 const { patternCategories } = usePatternCategories(); 55937 let patternCategory; 55938 if (type === PATTERN_TYPES.user && !!categoryId) { 55939 patternCategory = patternCategories.find( 55940 (category) => category.name === categoryId 55941 ); 55942 } 55943 return /* @__PURE__ */ (0, import_jsx_runtime306.jsxs)(import_jsx_runtime306.Fragment, { children: [ 55944 /* @__PURE__ */ (0, import_jsx_runtime306.jsx)(AddNewPattern, {}), 55945 !!patternCategory?.id && /* @__PURE__ */ (0, import_jsx_runtime306.jsx)( 55946 import_components143.DropdownMenu, 55947 { 55948 icon: more_vertical_default, 55949 label: (0, import_i18n138.__)("Actions"), 55950 toggleProps: { 55951 className: "edit-site-patterns__button", 55952 size: "compact" 55953 }, 55954 children: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime306.jsxs)(import_components143.MenuGroup, { children: [ 55955 /* @__PURE__ */ (0, import_jsx_runtime306.jsx)( 55956 RenameCategoryMenuItem, 55957 { 55958 category: patternCategory, 55959 onClose 55960 } 55961 ), 55962 /* @__PURE__ */ (0, import_jsx_runtime306.jsx)( 55963 DeleteCategoryMenuItem, 55964 { 55965 category: patternCategory, 55966 onClose 55967 } 55968 ) 55969 ] }) 55970 } 55971 ) 55972 ] }); 55973 } 55974 55975 // packages/edit-site/build-module/components/dataviews-actions/index.mjs 55976 var import_i18n139 = __toESM(require_i18n(), 1); 55977 var import_element180 = __toESM(require_element(), 1); 55978 var import_router29 = __toESM(require_router(), 1); 55979 var import_data73 = __toESM(require_data(), 1); 55980 var import_core_data49 = __toESM(require_core_data(), 1); 55981 var import_url16 = __toESM(require_url(), 1); 55982 var { useLocation: useLocation26, useHistory: useHistory20 } = unlock(import_router29.privateApis); 55983 var useSetActiveTemplateAction = () => { 55984 const activeTheme = (0, import_data73.useSelect)( 55985 (select4) => select4(import_core_data49.store).getCurrentTheme() 55986 ); 55987 const { getEntityRecord } = (0, import_data73.useSelect)(import_core_data49.store); 55988 const { editEntityRecord, saveEditedEntityRecord } = (0, import_data73.useDispatch)(import_core_data49.store); 55989 return (0, import_element180.useMemo)( 55990 () => ({ 55991 id: "set-active-template", 55992 label(items) { 55993 return items.some((item) => item._isActive) ? (0, import_i18n139.__)("Deactivate") : (0, import_i18n139.__)("Activate"); 55994 }, 55995 isPrimary: true, 55996 icon: pencil_default, 55997 isEligible(item) { 55998 if (item.theme !== activeTheme.stylesheet) { 55999 return false; 56000 } 56001 if (typeof item.id !== "number") { 56002 return item._isActive === false; 56003 } 56004 return true; 56005 }, 56006 async callback(items) { 56007 const deactivate = items.some((item) => item._isActive); 56008 const activeTemplates = { 56009 ...await getEntityRecord("root", "site").active_templates ?? {} 56010 }; 56011 for (const item of items) { 56012 if (deactivate) { 56013 delete activeTemplates[item.slug]; 56014 } else { 56015 activeTemplates[item.slug] = item.id; 56016 } 56017 } 56018 await editEntityRecord("root", "site", void 0, { 56019 active_templates: activeTemplates 56020 }); 56021 await saveEditedEntityRecord("root", "site"); 56022 } 56023 }), 56024 [ 56025 editEntityRecord, 56026 saveEditedEntityRecord, 56027 getEntityRecord, 56028 activeTheme 56029 ] 56030 ); 56031 }; 56032 var useEditPostAction = () => { 56033 const history = useHistory20(); 56034 return (0, import_element180.useMemo)( 56035 () => ({ 56036 id: "edit-post", 56037 label: (0, import_i18n139.__)("Edit"), 56038 icon: pencil_default, 56039 isEligible(post2) { 56040 if (post2.status === "trash") { 56041 return false; 56042 } 56043 return post2.type !== PATTERN_TYPES.theme; 56044 }, 56045 callback(items) { 56046 const post2 = items[0]; 56047 history.navigate(`/$post2.type}/$post2.id}?canvas=edit`); 56048 } 56049 }), 56050 [history] 56051 ); 56052 }; 56053 var useQuickEditPostAction = () => { 56054 const history = useHistory20(); 56055 const { path, query } = useLocation26(); 56056 return (0, import_element180.useMemo)( 56057 () => ({ 56058 id: "quick-edit", 56059 label: (0, import_i18n139.__)("Quick Edit"), 56060 icon: drawer_right_default, 56061 isPrimary: true, 56062 supportsBulk: true, 56063 isEligible(post2) { 56064 if (post2.status === "trash") { 56065 return false; 56066 } 56067 return post2.type === "page"; 56068 }, 56069 callback(items) { 56070 history.navigate( 56071 (0, import_url16.addQueryArgs)(path, { 56072 ...query, 56073 quickEdit: true, 56074 postId: items.map((item) => item.id).join(",") 56075 }) 56076 ); 56077 } 56078 }), 56079 [history, path, query] 56080 ); 56081 }; 56082 56083 // packages/edit-site/build-module/components/page-patterns/fields.mjs 56084 var import_i18n140 = __toESM(require_i18n(), 1); 56085 var import_element181 = __toESM(require_element(), 1); 56086 var import_block_editor25 = __toESM(require_block_editor(), 1); 56087 var import_blocks12 = __toESM(require_blocks(), 1); 56088 var import_editor32 = __toESM(require_editor(), 1); 56089 var import_jsx_runtime307 = __toESM(require_jsx_runtime(), 1); 56090 var { useStyle: useStyle4 } = unlock(import_editor32.privateApis); 56091 function PreviewField({ item }) { 56092 const descriptionId = (0, import_element181.useId)(); 56093 const description = item.description || item?.excerpt?.raw; 56094 const isTemplatePart2 = item.type === TEMPLATE_PART_POST_TYPE; 56095 const backgroundColor = useStyle4("color.background"); 56096 const blocks = (0, import_element181.useMemo)(() => { 56097 return item.blocks ?? (0, import_blocks12.parse)(item.content.raw, { 56098 __unstableSkipMigrationLogs: true 56099 }); 56100 }, [item?.content?.raw, item.blocks]); 56101 const isEmpty2 = !blocks?.length; 56102 return /* @__PURE__ */ (0, import_jsx_runtime307.jsxs)( 56103 "div", 56104 { 56105 className: "page-patterns-preview-field", 56106 style: { backgroundColor }, 56107 "aria-describedby": !!description ? descriptionId : void 0, 56108 children: [ 56109 isEmpty2 && isTemplatePart2 && (0, import_i18n140.__)("Empty template part"), 56110 isEmpty2 && !isTemplatePart2 && (0, import_i18n140.__)("Empty pattern"), 56111 !isEmpty2 && /* @__PURE__ */ (0, import_jsx_runtime307.jsx)(import_block_editor25.BlockPreview.Async, { children: /* @__PURE__ */ (0, import_jsx_runtime307.jsx)( 56112 import_block_editor25.BlockPreview, 56113 { 56114 blocks, 56115 viewportWidth: item.viewportWidth 56116 } 56117 ) }), 56118 !!description && /* @__PURE__ */ (0, import_jsx_runtime307.jsx)("div", { hidden: true, id: descriptionId, children: description }) 56119 ] 56120 } 56121 ); 56122 } 56123 var previewField = { 56124 label: (0, import_i18n140.__)("Preview"), 56125 id: "preview", 56126 render: PreviewField, 56127 enableSorting: false 56128 }; 56129 56130 // packages/edit-site/build-module/components/page-patterns/index.mjs 56131 var import_jsx_runtime308 = __toESM(require_jsx_runtime(), 1); 56132 var { ExperimentalBlockEditorProvider } = unlock(import_block_editor26.privateApis); 56133 var { usePostActions, usePostFields } = unlock(import_editor33.privateApis); 56134 var { useLocation: useLocation27, useHistory: useHistory21 } = unlock(import_router30.privateApis); 56135 var EMPTY_ARRAY12 = []; 56136 var VIEW_CONFIG_FIELDS2 = ["default_view", "default_layouts"]; 56137 function usePagePatternsHeader(type, categoryId) { 56138 const { patternCategories } = usePatternCategories(); 56139 const templatePartAreas = (0, import_data74.useSelect)( 56140 (select4) => select4(import_core_data50.store).getCurrentTheme()?.default_template_part_areas || [], 56141 [] 56142 ); 56143 let title, description, patternCategory; 56144 if (type === TEMPLATE_PART_POST_TYPE) { 56145 const templatePartArea = templatePartAreas.find( 56146 (area) => area.area === categoryId 56147 ); 56148 title = templatePartArea?.label || (0, import_i18n141.__)("All Template Parts"); 56149 description = templatePartArea?.description || (0, import_i18n141.__)("Includes every template part defined for any area."); 56150 } else if (type === PATTERN_TYPES.user && !!categoryId) { 56151 patternCategory = patternCategories.find( 56152 (category) => category.name === categoryId 56153 ); 56154 title = patternCategory?.label; 56155 description = patternCategory?.description; 56156 } 56157 return { title, description }; 56158 } 56159 function DataviewsPatterns() { 56160 const { path, query } = useLocation27(); 56161 const { postType: postType2 = "wp_block", categoryId: categoryIdFromURL } = query; 56162 const history = useHistory21(); 56163 const categoryId = categoryIdFromURL || PATTERN_DEFAULT_CATEGORY; 56164 const { default_view: defaultView, default_layouts: defaultLayouts2 } = useViewConfig({ 56165 kind: "postType", 56166 name: postType2, 56167 fields: VIEW_CONFIG_FIELDS2 56168 }); 56169 const { view, updateView, isModified, resetToDefault } = useView({ 56170 kind: "postType", 56171 name: postType2, 56172 slug: "default", 56173 defaultView, 56174 defaultLayouts: defaultLayouts2, 56175 queryParams: { 56176 page: query.pageNumber, 56177 search: query.search 56178 }, 56179 onChangeQueryParams: (params) => { 56180 history.navigate( 56181 (0, import_url17.addQueryArgs)(path, { 56182 ...query, 56183 pageNumber: params.page, 56184 search: params.search 56185 }) 56186 ); 56187 } 56188 }); 56189 const viewSyncStatus = view.filters?.find( 56190 ({ field }) => field === "sync-status" 56191 )?.value; 56192 const { patterns, isResolving } = use_patterns_default(postType2, categoryId, { 56193 search: view.search, 56194 syncStatus: viewSyncStatus 56195 }); 56196 const postTypeFields = usePostFields({ postType: postType2 }); 56197 const fields2 = (0, import_element182.useMemo)(() => { 56198 return [previewField, ...postTypeFields || []]; 56199 }, [postTypeFields]); 56200 const { data, paginationInfo } = (0, import_element182.useMemo)(() => { 56201 const viewWithoutFilters = { ...view }; 56202 delete viewWithoutFilters.search; 56203 if (postType2 !== TEMPLATE_PART_POST_TYPE) { 56204 viewWithoutFilters.filters = []; 56205 } 56206 return filterSortAndPaginate(patterns, viewWithoutFilters, fields2); 56207 }, [patterns, view, fields2, postType2]); 56208 const dataWithPermissions = useAugmentPatternsWithPermissions(data); 56209 const templatePartActions = usePostActions({ 56210 postType: TEMPLATE_PART_POST_TYPE, 56211 context: "list" 56212 }); 56213 const patternActions = usePostActions({ 56214 postType: PATTERN_TYPES.user, 56215 context: "list" 56216 }); 56217 const editAction = useEditPostAction(); 56218 const actions = (0, import_element182.useMemo)(() => { 56219 if (postType2 === TEMPLATE_PART_POST_TYPE) { 56220 return [editAction, ...templatePartActions].filter(Boolean); 56221 } 56222 return [editAction, ...patternActions].filter(Boolean); 56223 }, [editAction, postType2, templatePartActions, patternActions]); 56224 const settings2 = usePatternSettings(); 56225 const { title, description } = usePagePatternsHeader( 56226 postType2, 56227 categoryId 56228 ); 56229 return /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(ExperimentalBlockEditorProvider, { settings: settings2, children: /* @__PURE__ */ (0, import_jsx_runtime308.jsx)( 56230 page_default2, 56231 { 56232 className: "edit-site-page-patterns-dataviews", 56233 title, 56234 headingLevel: 2, 56235 subTitle: description, 56236 actions: /* @__PURE__ */ (0, import_jsx_runtime308.jsx)( 56237 PatternsActions, 56238 { 56239 categoryId, 56240 type: postType2 56241 } 56242 ), 56243 children: /* @__PURE__ */ (0, import_jsx_runtime308.jsx)( 56244 dataviews_default, 56245 { 56246 paginationInfo, 56247 fields: fields2, 56248 actions, 56249 data: dataWithPermissions || EMPTY_ARRAY12, 56250 getItemId: (item) => item.name ?? item.id, 56251 isLoading: isResolving, 56252 isItemClickable: (item) => item.type !== PATTERN_TYPES.theme, 56253 onClickItem: (item) => { 56254 history.navigate( 56255 `/$item.type}/${[ 56256 PATTERN_TYPES.user, 56257 TEMPLATE_PART_POST_TYPE 56258 ].includes(item.type) ? item.id : item.name}?canvas=edit` 56259 ); 56260 }, 56261 view, 56262 onChangeView: updateView, 56263 defaultLayouts: defaultLayouts2, 56264 onReset: isModified ? resetToDefault : false 56265 }, 56266 categoryId + postType2 56267 ) 56268 } 56269 ) }); 56270 } 56271 56272 // packages/edit-site/build-module/components/site-editor-routes/patterns.mjs 56273 var import_jsx_runtime309 = __toESM(require_jsx_runtime(), 1); 56274 var patternsRoute = { 56275 name: "patterns", 56276 path: "/pattern", 56277 areas: { 56278 sidebar({ siteData }) { 56279 const isBlockTheme = siteData.currentTheme?.is_block_theme; 56280 const backPath = isBlockTheme || isClassicThemeWithStyleBookSupport(siteData) ? "/" : void 0; 56281 return /* @__PURE__ */ (0, import_jsx_runtime309.jsx)(SidebarNavigationScreenPatterns, { backPath }); 56282 }, 56283 content: /* @__PURE__ */ (0, import_jsx_runtime309.jsx)(DataviewsPatterns, {}), 56284 mobileSidebar({ siteData, query }) { 56285 if (query.categoryId) { 56286 return void 0; 56287 } 56288 const isBlockTheme = siteData.currentTheme?.is_block_theme; 56289 const backPath = isBlockTheme || isClassicThemeWithStyleBookSupport(siteData) ? "/" : void 0; 56290 return /* @__PURE__ */ (0, import_jsx_runtime309.jsx)(SidebarNavigationScreenPatterns, { backPath }); 56291 }, 56292 mobileContent({ query }) { 56293 return query.categoryId ? /* @__PURE__ */ (0, import_jsx_runtime309.jsx)(DataviewsPatterns, {}) : void 0; 56294 } 56295 } 56296 }; 56297 56298 // packages/edit-site/build-module/components/site-editor-routes/pattern-item.mjs 56299 var import_jsx_runtime310 = __toESM(require_jsx_runtime(), 1); 56300 var patternItemRoute = { 56301 name: "pattern-item", 56302 path: "/wp_block/:postId", 56303 areas: { 56304 sidebar({ siteData }) { 56305 const isBlockTheme = siteData.currentTheme?.is_block_theme; 56306 const backPath = isBlockTheme || isClassicThemeWithStyleBookSupport(siteData) ? "/" : void 0; 56307 return /* @__PURE__ */ (0, import_jsx_runtime310.jsx)(SidebarNavigationScreenPatterns, { backPath }); 56308 }, 56309 // Also rendered on mobile, where this route is only reached at canvas=edit. 56310 preview: /* @__PURE__ */ (0, import_jsx_runtime310.jsx)(EditSiteEditor, {}) 56311 } 56312 }; 56313 56314 // packages/edit-site/build-module/components/site-editor-routes/template-part-item.mjs 56315 var import_jsx_runtime311 = __toESM(require_jsx_runtime(), 1); 56316 var templatePartItemRoute = { 56317 name: "template-part-item", 56318 path: "/wp_template_part/*postId", 56319 areas: { 56320 sidebar: /* @__PURE__ */ (0, import_jsx_runtime311.jsx)(SidebarNavigationScreenPatterns, { backPath: "/" }), 56321 // Also rendered on mobile, where this route is only reached at canvas=edit. 56322 preview: /* @__PURE__ */ (0, import_jsx_runtime311.jsx)(EditSiteEditor, {}) 56323 } 56324 }; 56325 56326 // packages/edit-site/build-module/components/site-editor-routes/templates.mjs 56327 var import_data83 = __toESM(require_data(), 1); 56328 var import_core_data63 = __toESM(require_core_data(), 1); 56329 56330 // packages/edit-site/build-module/components/sidebar-navigation-screen-templates-browse/index.mjs 56331 var import_i18n143 = __toESM(require_i18n(), 1); 56332 56333 // packages/edit-site/build-module/components/sidebar-navigation-screen-templates-browse/content.mjs 56334 var import_core_data52 = __toESM(require_core_data(), 1); 56335 var import_element183 = __toESM(require_element(), 1); 56336 var import_components144 = __toESM(require_components(), 1); 56337 var import_i18n142 = __toESM(require_i18n(), 1); 56338 var import_router31 = __toESM(require_router(), 1); 56339 var import_url18 = __toESM(require_url(), 1); 56340 56341 // packages/edit-site/build-module/components/page-templates/hooks.mjs 56342 var import_core_data51 = __toESM(require_core_data(), 1); 56343 var import_data75 = __toESM(require_data(), 1); 56344 function useAddedBy(postType2, postId) { 56345 return (0, import_data75.useSelect)( 56346 (select4) => { 56347 const { getEntityRecord, getUser, getEditedEntityRecord } = select4(import_core_data51.store); 56348 const template = getEditedEntityRecord( 56349 "postType", 56350 postType2, 56351 postId 56352 ); 56353 const originalSource = template?.original_source; 56354 const authorText = template?.author_text; 56355 switch (originalSource) { 56356 case "theme": { 56357 return { 56358 type: originalSource, 56359 icon: layout_default, 56360 text: authorText, 56361 isCustomized: template.source === TEMPLATE_ORIGINS.custom 56362 }; 56363 } 56364 case "plugin": { 56365 return { 56366 type: originalSource, 56367 icon: plugins_default, 56368 text: authorText, 56369 isCustomized: template.source === TEMPLATE_ORIGINS.custom 56370 }; 56371 } 56372 case "site": { 56373 const siteData = getEntityRecord( 56374 "root", 56375 "__unstableBase" 56376 ); 56377 return { 56378 type: originalSource, 56379 icon: globe_default, 56380 imageUrl: siteData?.site_logo ? getEntityRecord( 56381 "postType", 56382 "attachment", 56383 siteData.site_logo 56384 )?.source_url : void 0, 56385 text: authorText, 56386 isCustomized: false 56387 }; 56388 } 56389 default: { 56390 const user = getUser(template.author); 56391 return { 56392 type: "user", 56393 icon: comment_author_avatar_default, 56394 imageUrl: user?.avatar_urls?.[48], 56395 text: authorText ?? user?.name, 56396 isCustomized: false 56397 }; 56398 } 56399 } 56400 }, 56401 [postType2, postId] 56402 ); 56403 } 56404 56405 // packages/edit-site/build-module/components/sidebar-navigation-screen-templates-browse/content.mjs 56406 var import_jsx_runtime312 = __toESM(require_jsx_runtime(), 1); 56407 var { useLocation: useLocation28 } = unlock(import_router31.privateApis); 56408 var EMPTY_ARRAY13 = []; 56409 function TemplateDataviewItem({ template, isActive }) { 56410 const { text, icon } = useAddedBy(template.type, template.id); 56411 return /* @__PURE__ */ (0, import_jsx_runtime312.jsx)( 56412 SidebarNavigationItem, 56413 { 56414 to: (0, import_url18.addQueryArgs)("/template", { activeView: text }), 56415 icon, 56416 "aria-current": isActive, 56417 children: text 56418 } 56419 ); 56420 } 56421 function DataviewsTemplatesSidebarContent() { 56422 const { 56423 query: { activeView = "active" } 56424 } = useLocation28(); 56425 const { records } = (0, import_core_data52.useEntityRecords)("root", "registeredTemplate", { 56426 // This should not be needed, the endpoint returns all registered 56427 // templates, but it's not possible right now to turn off pagination for 56428 // entity configs. 56429 per_page: -1 56430 }); 56431 const firstItemPerAuthorText = (0, import_element183.useMemo)(() => { 56432 const firstItemPerAuthor = records?.reduce((acc, template) => { 56433 const author = template.author_text; 56434 if (author && !acc[author]) { 56435 acc[author] = template; 56436 } 56437 return acc; 56438 }, {}); 56439 return (firstItemPerAuthor && Object.values(firstItemPerAuthor)) ?? EMPTY_ARRAY13; 56440 }, [records]); 56441 return /* @__PURE__ */ (0, import_jsx_runtime312.jsxs)(import_components144.__experimentalItemGroup, { className: "edit-site-sidebar-navigation-screen-templates-browse", children: [ 56442 /* @__PURE__ */ (0, import_jsx_runtime312.jsx)( 56443 SidebarNavigationItem, 56444 { 56445 to: "/template", 56446 icon: published_default, 56447 "aria-current": activeView === "active", 56448 children: (0, import_i18n142.__)("Active templates") 56449 } 56450 ), 56451 /* @__PURE__ */ (0, import_jsx_runtime312.jsx)( 56452 SidebarNavigationItem, 56453 { 56454 to: (0, import_url18.addQueryArgs)("/template", { activeView: "user" }), 56455 icon: comment_author_avatar_default, 56456 "aria-current": activeView === "user", 56457 // Let's avoid calling them "custom templates" to avoid 56458 // confusion. "Created" is closest to meaning database 56459 // templates, created by users. 56460 // https://developer.wordpress.org/themes/classic-themes/templates/page-template-files/#creating-custom-page-templates-for-global-use 56461 children: (0, import_i18n142.__)("Created templates") 56462 } 56463 ), 56464 firstItemPerAuthorText.map((template) => { 56465 return /* @__PURE__ */ (0, import_jsx_runtime312.jsx)( 56466 TemplateDataviewItem, 56467 { 56468 template, 56469 isActive: activeView === template.author_text 56470 }, 56471 template.author_text 56472 ); 56473 }) 56474 ] }); 56475 } 56476 56477 // packages/edit-site/build-module/components/sidebar-navigation-screen-templates-browse/content-legacy.mjs 56478 var import_core_data53 = __toESM(require_core_data(), 1); 56479 var import_data76 = __toESM(require_data(), 1); 56480 56481 // packages/edit-site/build-module/components/sidebar-dataviews/index.mjs 56482 var import_components145 = __toESM(require_components(), 1); 56483 var import_router32 = __toESM(require_router(), 1); 56484 var import_url19 = __toESM(require_url(), 1); 56485 var import_jsx_runtime313 = __toESM(require_jsx_runtime(), 1); 56486 var { useLocation: useLocation29 } = unlock(import_router32.privateApis); 56487 var VIEW_CONFIG_FIELDS3 = ["view_list"]; 56488 var SLUG_TO_ICON = { 56489 all: pages_default, 56490 published: published_default, 56491 future: scheduled_default, 56492 drafts: drafts_default, 56493 pending: pending_default, 56494 private: not_allowed_default, 56495 trash: trash_default 56496 }; 56497 var defaultResolveIcon = (view) => { 56498 return SLUG_TO_ICON[view.slug]; 56499 }; 56500 function DataViewsSidebarContent({ 56501 postType: postType2, 56502 resolveIcon = defaultResolveIcon 56503 }) { 56504 const { 56505 path, 56506 query: { activeView = "all" } 56507 } = useLocation29(); 56508 const { view_list: viewList } = useViewConfig({ 56509 kind: "postType", 56510 name: postType2, 56511 fields: VIEW_CONFIG_FIELDS3 56512 }); 56513 if (!postType2) { 56514 return null; 56515 } 56516 return /* @__PURE__ */ (0, import_jsx_runtime313.jsx)(import_jsx_runtime313.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime313.jsx)(import_components145.__experimentalItemGroup, { className: "edit-site-sidebar-dataviews", children: viewList?.map((view) => { 56517 const isActive = view.slug === activeView; 56518 const slug = view.slug === "all" ? void 0 : view.slug; 56519 const icon = resolveIcon(view); 56520 return /* @__PURE__ */ (0, import_jsx_runtime313.jsx)( 56521 SidebarNavigationItem, 56522 { 56523 icon, 56524 to: (0, import_url19.addQueryArgs)(path, { 56525 activeView: slug 56526 }), 56527 "aria-current": isActive ? "true" : void 0, 56528 children: view.title 56529 }, 56530 view.slug 56531 ); 56532 }) }) }); 56533 } 56534 56535 // packages/edit-site/build-module/components/sidebar-navigation-screen-templates-browse/content-legacy.mjs 56536 var import_jsx_runtime314 = __toESM(require_jsx_runtime(), 1); 56537 var SOURCE_TO_ICON = { 56538 user: comment_author_avatar_default, 56539 theme: layout_default, 56540 plugin: plugins_default, 56541 site: globe_default 56542 }; 56543 function DataviewsTemplatesSidebarContent2() { 56544 const authorSourceMap = (0, import_data76.useSelect)((select4) => { 56545 const templates = select4(import_core_data53.store).getEntityRecords( 56546 "postType", 56547 TEMPLATE_POST_TYPE, 56548 { per_page: -1 } 56549 ); 56550 if (!templates) { 56551 return {}; 56552 } 56553 const map = {}; 56554 for (const template of templates) { 56555 if (template.author_text && template.original_source && !map[template.author_text]) { 56556 map[template.author_text] = template.original_source; 56557 } 56558 } 56559 return map; 56560 }, []); 56561 const resolveIcon = (view) => { 56562 const source = authorSourceMap[view.slug]; 56563 return SOURCE_TO_ICON[source] ?? layout_default; 56564 }; 56565 return /* @__PURE__ */ (0, import_jsx_runtime314.jsx)( 56566 DataViewsSidebarContent, 56567 { 56568 postType: TEMPLATE_POST_TYPE, 56569 resolveIcon 56570 } 56571 ); 56572 } 56573 56574 // packages/edit-site/build-module/components/sidebar-navigation-screen-templates-browse/index.mjs 56575 var import_jsx_runtime315 = __toESM(require_jsx_runtime(), 1); 56576 function SidebarNavigationScreenTemplatesBrowse({ backPath }) { 56577 return /* @__PURE__ */ (0, import_jsx_runtime315.jsx)( 56578 SidebarNavigationScreen, 56579 { 56580 title: (0, import_i18n143.__)("Templates"), 56581 description: (0, import_i18n143.__)( 56582 "Create new templates, or reset any customizations made to the templates supplied by your theme." 56583 ), 56584 backPath, 56585 content: window?.__experimentalTemplateActivate ? /* @__PURE__ */ (0, import_jsx_runtime315.jsx)(DataviewsTemplatesSidebarContent, {}) : /* @__PURE__ */ (0, import_jsx_runtime315.jsx)(DataviewsTemplatesSidebarContent2, {}) 56586 } 56587 ); 56588 } 56589 56590 // packages/edit-site/build-module/components/page-templates/index.mjs 56591 var import_i18n149 = __toESM(require_i18n(), 1); 56592 var import_html_entities13 = __toESM(require_html_entities(), 1); 56593 var import_element189 = __toESM(require_element(), 1); 56594 var import_core_data58 = __toESM(require_core_data(), 1); 56595 var import_router34 = __toESM(require_router(), 1); 56596 var import_editor37 = __toESM(require_editor(), 1); 56597 var import_url22 = __toESM(require_url(), 1); 56598 var import_data80 = __toESM(require_data(), 1); 56599 var import_compose31 = __toESM(require_compose(), 1); 56600 var import_components150 = __toESM(require_components(), 1); 56601 var import_notices9 = __toESM(require_notices(), 1); 56602 56603 // packages/edit-site/build-module/components/add-new-template/index.mjs 56604 var import_components148 = __toESM(require_components(), 1); 56605 var import_html_entities11 = __toESM(require_html_entities(), 1); 56606 var import_element187 = __toESM(require_element(), 1); 56607 var import_data78 = __toESM(require_data(), 1); 56608 var import_core_data56 = __toESM(require_core_data(), 1); 56609 var import_compose30 = __toESM(require_compose(), 1); 56610 var import_i18n147 = __toESM(require_i18n(), 1); 56611 var import_notices8 = __toESM(require_notices(), 1); 56612 var import_router33 = __toESM(require_router(), 1); 56613 var import_dom26 = __toESM(require_dom(), 1); 56614 56615 // packages/edit-site/build-module/components/add-new-template/add-custom-template-modal-content.mjs 56616 var import_element185 = __toESM(require_element(), 1); 56617 var import_i18n145 = __toESM(require_i18n(), 1); 56618 var import_components146 = __toESM(require_components(), 1); 56619 var import_core_data55 = __toESM(require_core_data(), 1); 56620 var import_html_entities10 = __toESM(require_html_entities(), 1); 56621 var import_compose29 = __toESM(require_compose(), 1); 56622 var import_dom25 = __toESM(require_dom(), 1); 56623 var import_url21 = __toESM(require_url(), 1); 56624 56625 // packages/edit-site/build-module/components/add-new-template/utils.mjs 56626 var import_data77 = __toESM(require_data(), 1); 56627 var import_core_data54 = __toESM(require_core_data(), 1); 56628 var import_html_entities9 = __toESM(require_html_entities(), 1); 56629 var import_element184 = __toESM(require_element(), 1); 56630 var import_i18n144 = __toESM(require_i18n(), 1); 56631 var import_url20 = __toESM(require_url(), 1); 56632 var EMPTY_OBJECT2 = {}; 56633 var getValueFromObjectPath2 = (object, path) => { 56634 let value = object; 56635 path.split(".").forEach((fieldName) => { 56636 value = value?.[fieldName]; 56637 }); 56638 return value; 56639 }; 56640 function prefixSlug(prefix2, slug) { 56641 return `$prefix2}-${(0, import_url20.safeDecodeURI)(slug)}`; 56642 } 56643 var mapToIHasNameAndId = (entities, path) => { 56644 return (entities || []).map((entity) => ({ 56645 ...entity, 56646 name: (0, import_html_entities9.decodeEntities)(getValueFromObjectPath2(entity, path)) 56647 })); 56648 }; 56649 var useExistingTemplates = () => { 56650 return (0, import_data77.useSelect)( 56651 (select4) => select4(import_core_data54.store).getEntityRecords( 56652 "postType", 56653 TEMPLATE_POST_TYPE, 56654 { 56655 per_page: -1 56656 } 56657 ), 56658 [] 56659 ); 56660 }; 56661 var useDefaultTemplateTypes = () => { 56662 return (0, import_data77.useSelect)( 56663 (select4) => select4(import_core_data54.store).getCurrentTheme()?.default_template_types || [], 56664 [] 56665 ); 56666 }; 56667 var usePublicPostTypes = () => { 56668 const postTypes = (0, import_data77.useSelect)( 56669 (select4) => select4(import_core_data54.store).getPostTypes({ per_page: -1 }), 56670 [] 56671 ); 56672 return (0, import_element184.useMemo)(() => { 56673 const excludedPostTypes = ["attachment"]; 56674 return postTypes?.filter( 56675 ({ viewable, slug }) => viewable && !excludedPostTypes.includes(slug) 56676 ).sort((a2, b2) => { 56677 if (a2.slug === "post" || b2.slug === "post") { 56678 return 0; 56679 } 56680 return a2.name.localeCompare(b2.name); 56681 }); 56682 }, [postTypes]); 56683 }; 56684 var usePublicTaxonomies = () => { 56685 const taxonomies = (0, import_data77.useSelect)( 56686 (select4) => select4(import_core_data54.store).getTaxonomies({ per_page: -1 }), 56687 [] 56688 ); 56689 return (0, import_element184.useMemo)(() => { 56690 return taxonomies?.filter( 56691 ({ visibility }) => visibility?.publicly_queryable 56692 ); 56693 }, [taxonomies]); 56694 }; 56695 function usePostTypeArchiveMenuItems() { 56696 const publicPostTypes = usePublicPostTypes(); 56697 const postTypesWithArchives = (0, import_element184.useMemo)( 56698 () => publicPostTypes?.filter((postType2) => postType2.has_archive), 56699 [publicPostTypes] 56700 ); 56701 const existingTemplates = useExistingTemplates(); 56702 const postTypeLabels = (0, import_element184.useMemo)( 56703 () => publicPostTypes?.reduce((accumulator, { labels }) => { 56704 const singularName = labels.singular_name.toLowerCase(); 56705 accumulator[singularName] = (accumulator[singularName] || 0) + 1; 56706 return accumulator; 56707 }, {}), 56708 [publicPostTypes] 56709 ); 56710 const needsUniqueIdentifier = (0, import_element184.useCallback)( 56711 ({ labels, slug }) => { 56712 const singularName = labels.singular_name.toLowerCase(); 56713 return postTypeLabels[singularName] > 1 && singularName !== slug; 56714 }, 56715 [postTypeLabels] 56716 ); 56717 return (0, import_element184.useMemo)( 56718 () => postTypesWithArchives?.filter( 56719 (postType2) => !(existingTemplates || []).some( 56720 (existingTemplate) => existingTemplate.slug === "archive-" + postType2.slug 56721 ) 56722 ).map((postType2) => { 56723 let title; 56724 if (needsUniqueIdentifier(postType2)) { 56725 title = (0, import_i18n144.sprintf)( 56726 // translators: %1s: Name of the post type e.g: "Post"; %2s: Slug of the post type e.g: "book". 56727 (0, import_i18n144.__)("Archive: %1$s (%2$s)"), 56728 postType2.labels.singular_name, 56729 postType2.slug 56730 ); 56731 } else { 56732 title = (0, import_i18n144.sprintf)( 56733 // translators: %s: Name of the post type e.g: "Post". 56734 (0, import_i18n144.__)("Archive: %s"), 56735 postType2.labels.singular_name 56736 ); 56737 } 56738 return { 56739 slug: "archive-" + postType2.slug, 56740 description: (0, import_i18n144.sprintf)( 56741 // translators: %s: Name of the post type e.g: "Post". 56742 (0, import_i18n144.__)( 56743 "Displays an archive with the latest posts of type: %s." 56744 ), 56745 postType2.labels.singular_name 56746 ), 56747 title, 56748 // `icon` is the `menu_icon` property of a post type. We 56749 // only handle `dashicons` for now, even if the `menu_icon` 56750 // also supports urls and svg as values. 56751 icon: typeof postType2.icon === "string" && postType2.icon.startsWith("dashicons-") ? postType2.icon.slice(10) : archive_default, 56752 templatePrefix: "archive" 56753 }; 56754 }) || [], 56755 [postTypesWithArchives, existingTemplates, needsUniqueIdentifier] 56756 ); 56757 } 56758 var usePostTypeMenuItems = (onClickMenuItem) => { 56759 const publicPostTypes = usePublicPostTypes(); 56760 const defaultTemplateTypes = useDefaultTemplateTypes(); 56761 const templateLabels = (0, import_element184.useMemo)( 56762 () => publicPostTypes?.reduce((accumulator, { labels }) => { 56763 const templateName = (labels.template_name || labels.singular_name).toLowerCase(); 56764 accumulator[templateName] = (accumulator[templateName] || 0) + 1; 56765 return accumulator; 56766 }, {}), 56767 [publicPostTypes] 56768 ); 56769 const needsUniqueIdentifier = (0, import_element184.useCallback)( 56770 ({ labels, slug }) => { 56771 const templateName = (labels.template_name || labels.singular_name).toLowerCase(); 56772 return templateLabels[templateName] > 1 && templateName !== slug; 56773 }, 56774 [templateLabels] 56775 ); 56776 const templatePrefixes = (0, import_element184.useMemo)( 56777 () => publicPostTypes?.reduce((accumulator, { slug }) => { 56778 let suffix = slug; 56779 if (slug !== "page") { 56780 suffix = `single-$suffix}`; 56781 } 56782 accumulator[slug] = suffix; 56783 return accumulator; 56784 }, {}), 56785 [publicPostTypes] 56786 ); 56787 const postTypesInfo = useEntitiesInfo("postType", templatePrefixes); 56788 const menuItems = (publicPostTypes || []).reduce( 56789 (accumulator, postType2) => { 56790 const { slug, labels, icon } = postType2; 56791 const generalTemplateSlug = templatePrefixes[slug]; 56792 const defaultTemplateType = defaultTemplateTypes?.find( 56793 ({ slug: _slug }) => _slug === generalTemplateSlug 56794 ); 56795 const _needsUniqueIdentifier = needsUniqueIdentifier(postType2); 56796 let menuItemTitle = labels.template_name || (0, import_i18n144.sprintf)( 56797 // translators: %s: Name of the post type e.g: "Post". 56798 (0, import_i18n144.__)("Single item: %s"), 56799 labels.singular_name 56800 ); 56801 if (_needsUniqueIdentifier) { 56802 menuItemTitle = labels.template_name ? (0, import_i18n144.sprintf)( 56803 // translators: 1: Name of the template e.g: "Single Item: Post". 2: Slug of the post type e.g: "book". 56804 (0, import_i18n144._x)("%1$s (%2$s)", "post type menu label"), 56805 labels.template_name, 56806 slug 56807 ) : (0, import_i18n144.sprintf)( 56808 // translators: 1: Name of the post type e.g: "Post". 2: Slug of the post type e.g: "book". 56809 (0, import_i18n144._x)( 56810 "Single item: %1$s (%2$s)", 56811 "post type menu label" 56812 ), 56813 labels.singular_name, 56814 slug 56815 ); 56816 } 56817 const menuItem = defaultTemplateType ? { 56818 ...defaultTemplateType, 56819 templatePrefix: templatePrefixes[slug] 56820 } : { 56821 slug: generalTemplateSlug, 56822 title: menuItemTitle, 56823 description: (0, import_i18n144.sprintf)( 56824 // translators: %s: Name of the post type e.g: "Post". 56825 (0, import_i18n144.__)("Displays a single item: %s."), 56826 labels.singular_name 56827 ), 56828 // `icon` is the `menu_icon` property of a post type. We 56829 // only handle `dashicons` for now, even if the `menu_icon` 56830 // also supports urls and svg as values. 56831 icon: typeof icon === "string" && icon.startsWith("dashicons-") ? icon.slice(10) : post_default, 56832 templatePrefix: templatePrefixes[slug] 56833 }; 56834 const hasEntities = postTypesInfo?.[slug]?.hasEntities; 56835 if (hasEntities) { 56836 menuItem.onClick = (template) => { 56837 onClickMenuItem({ 56838 type: "postType", 56839 slug, 56840 config: { 56841 recordNamePath: "title.rendered", 56842 queryArgs: ({ search }) => { 56843 return { 56844 _fields: "id,title,slug,link", 56845 orderBy: search ? "relevance" : "modified", 56846 exclude: postTypesInfo[slug].existingEntitiesIds 56847 }; 56848 }, 56849 getSpecificTemplate: (suggestion) => { 56850 const templateSlug = prefixSlug( 56851 templatePrefixes[slug], 56852 suggestion.slug 56853 ); 56854 return { 56855 title: templateSlug, 56856 slug: templateSlug, 56857 templatePrefix: templatePrefixes[slug] 56858 }; 56859 } 56860 }, 56861 labels, 56862 template 56863 }); 56864 }; 56865 } 56866 if (hasEntities) { 56867 accumulator.push(menuItem); 56868 } 56869 return accumulator; 56870 }, 56871 [] 56872 ); 56873 const postTypesMenuItems = (0, import_element184.useMemo)( 56874 () => menuItems.reduce( 56875 (accumulator, postType2) => { 56876 const { slug } = postType2; 56877 let key = "postTypesMenuItems"; 56878 if (slug === "page") { 56879 key = "defaultPostTypesMenuItems"; 56880 } 56881 accumulator[key].push(postType2); 56882 return accumulator; 56883 }, 56884 { defaultPostTypesMenuItems: [], postTypesMenuItems: [] } 56885 ), 56886 [menuItems] 56887 ); 56888 return postTypesMenuItems; 56889 }; 56890 var useTaxonomiesMenuItems = (onClickMenuItem) => { 56891 const publicTaxonomies = usePublicTaxonomies(); 56892 const existingTemplates = useExistingTemplates(); 56893 const defaultTemplateTypes = useDefaultTemplateTypes(); 56894 const templatePrefixes = (0, import_element184.useMemo)( 56895 () => publicTaxonomies?.reduce((accumulator, { slug }) => { 56896 let suffix = slug; 56897 if (!["category", "post_tag"].includes(slug)) { 56898 suffix = `taxonomy-$suffix}`; 56899 } 56900 if (slug === "post_tag") { 56901 suffix = `tag`; 56902 } 56903 accumulator[slug] = suffix; 56904 return accumulator; 56905 }, {}), 56906 [publicTaxonomies] 56907 ); 56908 const taxonomyLabels = publicTaxonomies?.reduce( 56909 (accumulator, { labels }) => { 56910 const templateName = (labels.template_name || labels.singular_name).toLowerCase(); 56911 accumulator[templateName] = (accumulator[templateName] || 0) + 1; 56912 return accumulator; 56913 }, 56914 {} 56915 ); 56916 const needsUniqueIdentifier = (labels, slug) => { 56917 if (["category", "post_tag"].includes(slug)) { 56918 return false; 56919 } 56920 const templateName = (labels.template_name || labels.singular_name).toLowerCase(); 56921 return taxonomyLabels[templateName] > 1 && templateName !== slug; 56922 }; 56923 const taxonomiesInfo = useEntitiesInfo("taxonomy", templatePrefixes); 56924 const existingTemplateSlugs = (existingTemplates || []).map( 56925 ({ slug }) => slug 56926 ); 56927 const menuItems = (publicTaxonomies || []).reduce( 56928 (accumulator, taxonomy) => { 56929 const { slug, labels } = taxonomy; 56930 const generalTemplateSlug = templatePrefixes[slug]; 56931 const defaultTemplateType = defaultTemplateTypes?.find( 56932 ({ slug: _slug }) => _slug === generalTemplateSlug 56933 ); 56934 const hasGeneralTemplate = existingTemplateSlugs?.includes(generalTemplateSlug); 56935 const _needsUniqueIdentifier = needsUniqueIdentifier( 56936 labels, 56937 slug 56938 ); 56939 let menuItemTitle = labels.template_name || labels.singular_name; 56940 if (_needsUniqueIdentifier) { 56941 menuItemTitle = labels.template_name ? (0, import_i18n144.sprintf)( 56942 // translators: 1: Name of the template e.g: "Products by Category". 2: Slug of the taxonomy e.g: "product_cat". 56943 (0, import_i18n144._x)("%1$s (%2$s)", "taxonomy template menu label"), 56944 labels.template_name, 56945 slug 56946 ) : (0, import_i18n144.sprintf)( 56947 // translators: 1: Name of the taxonomy e.g: "Category". 2: Slug of the taxonomy e.g: "product_cat". 56948 (0, import_i18n144._x)("%1$s (%2$s)", "taxonomy menu label"), 56949 labels.singular_name, 56950 slug 56951 ); 56952 } 56953 const menuItem = defaultTemplateType ? { 56954 ...defaultTemplateType, 56955 templatePrefix: templatePrefixes[slug] 56956 } : { 56957 slug: generalTemplateSlug, 56958 title: menuItemTitle, 56959 description: (0, import_i18n144.sprintf)( 56960 // translators: %s: Name of the taxonomy e.g: "Product Categories". 56961 (0, import_i18n144.__)("Displays taxonomy: %s."), 56962 labels.singular_name 56963 ), 56964 icon: block_meta_default, 56965 templatePrefix: templatePrefixes[slug] 56966 }; 56967 const hasEntities = taxonomiesInfo?.[slug]?.hasEntities; 56968 if (hasEntities) { 56969 menuItem.onClick = (template) => { 56970 onClickMenuItem({ 56971 type: "taxonomy", 56972 slug, 56973 config: { 56974 queryArgs: ({ search }) => { 56975 return { 56976 _fields: "id,name,slug,link", 56977 orderBy: search ? "name" : "count", 56978 exclude: taxonomiesInfo[slug].existingEntitiesIds 56979 }; 56980 }, 56981 getSpecificTemplate: (suggestion) => { 56982 const templateSlug = prefixSlug( 56983 templatePrefixes[slug], 56984 suggestion.slug 56985 ); 56986 return { 56987 title: templateSlug, 56988 slug: templateSlug, 56989 templatePrefix: templatePrefixes[slug] 56990 }; 56991 } 56992 }, 56993 labels, 56994 hasGeneralTemplate, 56995 template 56996 }); 56997 }; 56998 } 56999 if (!hasGeneralTemplate || hasEntities) { 57000 accumulator.push(menuItem); 57001 } 57002 return accumulator; 57003 }, 57004 [] 57005 ); 57006 const taxonomiesMenuItems = (0, import_element184.useMemo)( 57007 () => menuItems.reduce( 57008 (accumulator, taxonomy) => { 57009 const { slug } = taxonomy; 57010 let key = "taxonomiesMenuItems"; 57011 if (["category", "tag"].includes(slug)) { 57012 key = "defaultTaxonomiesMenuItems"; 57013 } 57014 accumulator[key].push(taxonomy); 57015 return accumulator; 57016 }, 57017 { defaultTaxonomiesMenuItems: [], taxonomiesMenuItems: [] } 57018 ), 57019 [menuItems] 57020 ); 57021 return taxonomiesMenuItems; 57022 }; 57023 var USE_AUTHOR_MENU_ITEM_TEMPLATE_PREFIX = { user: "author" }; 57024 var USE_AUTHOR_MENU_ITEM_QUERY_PARAMETERS = { user: { who: "authors" } }; 57025 function useAuthorMenuItem(onClickMenuItem) { 57026 const existingTemplates = useExistingTemplates(); 57027 const defaultTemplateTypes = useDefaultTemplateTypes(); 57028 const authorInfo = useEntitiesInfo( 57029 "root", 57030 USE_AUTHOR_MENU_ITEM_TEMPLATE_PREFIX, 57031 USE_AUTHOR_MENU_ITEM_QUERY_PARAMETERS 57032 ); 57033 let authorMenuItem = defaultTemplateTypes?.find( 57034 ({ slug }) => slug === "author" 57035 ); 57036 if (!authorMenuItem) { 57037 authorMenuItem = { 57038 description: (0, import_i18n144.__)( 57039 "Displays latest posts written by a single author." 57040 ), 57041 slug: "author", 57042 title: "Author" 57043 }; 57044 } 57045 const hasGeneralTemplate = !!existingTemplates?.find( 57046 ({ slug }) => slug === "author" 57047 ); 57048 if (authorInfo.user?.hasEntities) { 57049 authorMenuItem = { ...authorMenuItem, templatePrefix: "author" }; 57050 authorMenuItem.onClick = (template) => { 57051 onClickMenuItem({ 57052 type: "root", 57053 slug: "user", 57054 config: { 57055 queryArgs: ({ search }) => { 57056 return { 57057 _fields: "id,name,slug,link", 57058 orderBy: search ? "name" : "registered_date", 57059 exclude: authorInfo.user.existingEntitiesIds, 57060 who: "authors" 57061 }; 57062 }, 57063 getSpecificTemplate: (suggestion) => { 57064 const templateSlug = prefixSlug( 57065 "author", 57066 suggestion.slug 57067 ); 57068 return { 57069 title: (0, import_i18n144.sprintf)( 57070 // translators: %s: Name of the author e.g: "Admin". 57071 (0, import_i18n144.__)("Author: %s"), 57072 suggestion.name 57073 ), 57074 slug: templateSlug, 57075 templatePrefix: "author" 57076 }; 57077 } 57078 }, 57079 labels: { 57080 singular_name: (0, import_i18n144.__)("Author"), 57081 search_items: (0, import_i18n144.__)("Search Authors"), 57082 not_found: (0, import_i18n144.__)("No authors found."), 57083 all_items: (0, import_i18n144.__)("All Authors") 57084 }, 57085 hasGeneralTemplate, 57086 template 57087 }); 57088 }; 57089 } 57090 if (!hasGeneralTemplate || authorInfo.user?.hasEntities) { 57091 return authorMenuItem; 57092 } 57093 } 57094 var useEntitiesInfo = (entityName, templatePrefixes, additionalQueryParameters = EMPTY_OBJECT2) => { 57095 const entitiesHasRecords = (0, import_data77.useSelect)( 57096 (select4) => { 57097 return Object.keys(templatePrefixes || {}).reduce( 57098 (accumulator, slug) => { 57099 const records = select4(import_core_data54.store).getEntityRecords( 57100 entityName, 57101 slug, 57102 { 57103 per_page: 1, 57104 _fields: "id", 57105 context: "view", 57106 ...additionalQueryParameters[slug] 57107 } 57108 ); 57109 accumulator[slug] = records === null || records.length > 0; 57110 return accumulator; 57111 }, 57112 {} 57113 ); 57114 }, 57115 [templatePrefixes, entityName, additionalQueryParameters] 57116 ); 57117 const entitiesInfo = (0, import_element184.useMemo)(() => { 57118 return Object.keys(templatePrefixes || {}).reduce( 57119 (accumulator, slug) => { 57120 accumulator[slug] = { 57121 hasEntities: entitiesHasRecords[slug] 57122 }; 57123 return accumulator; 57124 }, 57125 {} 57126 ); 57127 }, [templatePrefixes, entitiesHasRecords]); 57128 return entitiesInfo; 57129 }; 57130 57131 // packages/edit-site/build-module/components/add-new-template/add-custom-template-modal-content.mjs 57132 var import_jsx_runtime316 = __toESM(require_jsx_runtime(), 1); 57133 var EMPTY_ARRAY14 = []; 57134 function SuggestionListItem({ 57135 suggestion, 57136 search, 57137 onSelect, 57138 entityForSuggestions 57139 }) { 57140 const baseCssClass = "edit-site-custom-template-modal__suggestions_list__list-item"; 57141 return /* @__PURE__ */ (0, import_jsx_runtime316.jsxs)( 57142 import_components146.Composite.Item, 57143 { 57144 render: /* @__PURE__ */ (0, import_jsx_runtime316.jsx)( 57145 import_components146.Button, 57146 { 57147 __next40pxDefaultSize: true, 57148 role: "option", 57149 className: baseCssClass, 57150 onClick: () => onSelect( 57151 entityForSuggestions.config.getSpecificTemplate( 57152 suggestion 57153 ) 57154 ) 57155 } 57156 ), 57157 children: [ 57158 /* @__PURE__ */ (0, import_jsx_runtime316.jsx)( 57159 import_components146.__experimentalText, 57160 { 57161 size: "body", 57162 lineHeight: 1.53846153846, 57163 weight: "var(--wpds-typography-font-weight-emphasis, 600)", 57164 className: `$baseCssClass}__title`, 57165 children: /* @__PURE__ */ (0, import_jsx_runtime316.jsx)( 57166 import_components146.TextHighlight, 57167 { 57168 text: (0, import_html_entities10.decodeEntities)(suggestion.name), 57169 highlight: search 57170 } 57171 ) 57172 } 57173 ), 57174 suggestion.link && /* @__PURE__ */ (0, import_jsx_runtime316.jsx)( 57175 import_components146.__experimentalText, 57176 { 57177 size: "body", 57178 lineHeight: 1.53846153846, 57179 className: `$baseCssClass}__info`, 57180 children: (0, import_url21.safeDecodeURI)(suggestion.link) 57181 } 57182 ) 57183 ] 57184 } 57185 ); 57186 } 57187 function useSearchSuggestions(entityForSuggestions, search) { 57188 const { config: config2 } = entityForSuggestions; 57189 const query = (0, import_element185.useMemo)( 57190 () => ({ 57191 order: "asc", 57192 context: "view", 57193 search, 57194 per_page: search ? 20 : 10, 57195 ...config2.queryArgs(search) 57196 }), 57197 [search, config2] 57198 ); 57199 const { records: searchResults, hasResolved: searchHasResolved } = (0, import_core_data55.useEntityRecords)( 57200 entityForSuggestions.type, 57201 entityForSuggestions.slug, 57202 query 57203 ); 57204 const [suggestions, setSuggestions] = (0, import_element185.useState)(EMPTY_ARRAY14); 57205 (0, import_element185.useEffect)(() => { 57206 if (!searchHasResolved) { 57207 return; 57208 } 57209 let newSuggestions = EMPTY_ARRAY14; 57210 if (searchResults?.length) { 57211 newSuggestions = searchResults; 57212 if (config2.recordNamePath) { 57213 newSuggestions = mapToIHasNameAndId( 57214 newSuggestions, 57215 config2.recordNamePath 57216 ); 57217 } 57218 } 57219 setSuggestions(newSuggestions); 57220 }, [searchResults, searchHasResolved]); 57221 return suggestions; 57222 } 57223 function SuggestionList({ entityForSuggestions, onSelect }) { 57224 const [search, setSearch, debouncedSearch] = (0, import_compose29.useDebouncedInput)(); 57225 const suggestions = useSearchSuggestions( 57226 entityForSuggestions, 57227 debouncedSearch 57228 ); 57229 const { labels } = entityForSuggestions; 57230 const [showSearchControl, setShowSearchControl] = (0, import_element185.useState)(false); 57231 if (!showSearchControl && suggestions?.length > 9) { 57232 setShowSearchControl(true); 57233 } 57234 return /* @__PURE__ */ (0, import_jsx_runtime316.jsxs)(import_jsx_runtime316.Fragment, { children: [ 57235 showSearchControl && /* @__PURE__ */ (0, import_jsx_runtime316.jsx)( 57236 import_components146.SearchControl, 57237 { 57238 onChange: setSearch, 57239 value: search, 57240 label: labels.search_items, 57241 placeholder: labels.search_items 57242 } 57243 ), 57244 !!suggestions?.length && /* @__PURE__ */ (0, import_jsx_runtime316.jsx)( 57245 import_components146.Composite, 57246 { 57247 orientation: "vertical", 57248 role: "listbox", 57249 className: "edit-site-custom-template-modal__suggestions_list", 57250 "aria-label": (0, import_i18n145.__)("Suggestions list"), 57251 children: suggestions.map((suggestion) => /* @__PURE__ */ (0, import_jsx_runtime316.jsx)( 57252 SuggestionListItem, 57253 { 57254 suggestion, 57255 search: debouncedSearch, 57256 onSelect, 57257 entityForSuggestions 57258 }, 57259 suggestion.slug 57260 )) 57261 } 57262 ), 57263 debouncedSearch && !suggestions?.length && /* @__PURE__ */ (0, import_jsx_runtime316.jsx)( 57264 import_components146.__experimentalText, 57265 { 57266 as: "p", 57267 className: "edit-site-custom-template-modal__no-results", 57268 children: labels.not_found 57269 } 57270 ) 57271 ] }); 57272 } 57273 function AddCustomTemplateModalContent({ 57274 onSelect, 57275 entityForSuggestions, 57276 onBack, 57277 containerRef 57278 }) { 57279 const [showSearchEntities, setShowSearchEntities] = (0, import_element185.useState)(); 57280 (0, import_element185.useEffect)(() => { 57281 if (containerRef.current) { 57282 const [firstFocusable] = import_dom25.focus.focusable.find( 57283 containerRef.current 57284 ); 57285 firstFocusable?.focus(); 57286 } 57287 }, [showSearchEntities]); 57288 return /* @__PURE__ */ (0, import_jsx_runtime316.jsxs)( 57289 import_components146.__experimentalVStack, 57290 { 57291 spacing: 4, 57292 className: "edit-site-custom-template-modal__contents-wrapper", 57293 alignment: "left", 57294 children: [ 57295 !showSearchEntities && /* @__PURE__ */ (0, import_jsx_runtime316.jsxs)(import_jsx_runtime316.Fragment, { children: [ 57296 /* @__PURE__ */ (0, import_jsx_runtime316.jsx)(import_components146.__experimentalText, { as: "p", children: (0, import_i18n145.__)( 57297 "Select whether to create a single template for all items or a specific one." 57298 ) }), 57299 /* @__PURE__ */ (0, import_jsx_runtime316.jsxs)( 57300 import_components146.Flex, 57301 { 57302 className: "edit-site-custom-template-modal__contents", 57303 gap: "4", 57304 align: "initial", 57305 children: [ 57306 /* @__PURE__ */ (0, import_jsx_runtime316.jsxs)( 57307 import_components146.FlexItem, 57308 { 57309 isBlock: true, 57310 as: import_components146.Button, 57311 onClick: () => { 57312 const { 57313 slug, 57314 title, 57315 description, 57316 templatePrefix 57317 } = entityForSuggestions.template; 57318 onSelect({ 57319 slug, 57320 title, 57321 description, 57322 templatePrefix 57323 }); 57324 }, 57325 children: [ 57326 /* @__PURE__ */ (0, import_jsx_runtime316.jsx)( 57327 import_components146.__experimentalText, 57328 { 57329 as: "span", 57330 weight: "var(--wpds-typography-font-weight-emphasis, 600)", 57331 lineHeight: 1.53846153846, 57332 children: entityForSuggestions.labels.all_items 57333 } 57334 ), 57335 /* @__PURE__ */ (0, import_jsx_runtime316.jsx)( 57336 import_components146.__experimentalText, 57337 { 57338 as: "span", 57339 lineHeight: 1.53846153846, 57340 // 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. 57341 children: (0, import_i18n145.__)("For all items") 57342 } 57343 ) 57344 ] 57345 } 57346 ), 57347 /* @__PURE__ */ (0, import_jsx_runtime316.jsxs)( 57348 import_components146.FlexItem, 57349 { 57350 isBlock: true, 57351 as: import_components146.Button, 57352 onClick: () => { 57353 setShowSearchEntities(true); 57354 }, 57355 children: [ 57356 /* @__PURE__ */ (0, import_jsx_runtime316.jsx)( 57357 import_components146.__experimentalText, 57358 { 57359 as: "span", 57360 weight: "var(--wpds-typography-font-weight-emphasis, 600)", 57361 lineHeight: 1.53846153846, 57362 children: entityForSuggestions.labels.singular_name 57363 } 57364 ), 57365 /* @__PURE__ */ (0, import_jsx_runtime316.jsx)( 57366 import_components146.__experimentalText, 57367 { 57368 as: "span", 57369 lineHeight: 1.53846153846, 57370 // 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. 57371 children: (0, import_i18n145.__)("For a specific item") 57372 } 57373 ) 57374 ] 57375 } 57376 ) 57377 ] 57378 } 57379 ), 57380 /* @__PURE__ */ (0, import_jsx_runtime316.jsx)(import_components146.Flex, { justify: "right", children: /* @__PURE__ */ (0, import_jsx_runtime316.jsx)( 57381 import_components146.Button, 57382 { 57383 __next40pxDefaultSize: true, 57384 variant: "tertiary", 57385 onClick: onBack, 57386 children: (0, import_i18n145.__)("Back") 57387 } 57388 ) }) 57389 ] }), 57390 showSearchEntities && /* @__PURE__ */ (0, import_jsx_runtime316.jsxs)(import_jsx_runtime316.Fragment, { children: [ 57391 /* @__PURE__ */ (0, import_jsx_runtime316.jsx)(import_components146.__experimentalText, { as: "p", children: (0, import_i18n145.__)( 57392 "This template will be used only for the specific item chosen." 57393 ) }), 57394 /* @__PURE__ */ (0, import_jsx_runtime316.jsx)( 57395 SuggestionList, 57396 { 57397 entityForSuggestions, 57398 onSelect 57399 } 57400 ), 57401 /* @__PURE__ */ (0, import_jsx_runtime316.jsx)(import_components146.Flex, { justify: "right", children: /* @__PURE__ */ (0, import_jsx_runtime316.jsx)( 57402 import_components146.Button, 57403 { 57404 __next40pxDefaultSize: true, 57405 variant: "tertiary", 57406 onClick: () => { 57407 if (entityForSuggestions.hasGeneralTemplate) { 57408 onBack(); 57409 } else { 57410 setShowSearchEntities(false); 57411 } 57412 }, 57413 children: (0, import_i18n145.__)("Back") 57414 } 57415 ) }) 57416 ] }) 57417 ] 57418 } 57419 ); 57420 } 57421 var add_custom_template_modal_content_default = AddCustomTemplateModalContent; 57422 57423 // packages/edit-site/build-module/components/add-new-template/add-custom-generic-template-modal-content.mjs 57424 var import_element186 = __toESM(require_element(), 1); 57425 var import_i18n146 = __toESM(require_i18n(), 1); 57426 var import_components147 = __toESM(require_components(), 1); 57427 var import_jsx_runtime317 = __toESM(require_jsx_runtime(), 1); 57428 function AddCustomGenericTemplateModalContent({ createTemplate, onBack }) { 57429 const [title, setTitle] = (0, import_element186.useState)(""); 57430 const defaultTitle = (0, import_i18n146.__)("Custom Template"); 57431 const [isBusy, setIsBusy] = (0, import_element186.useState)(false); 57432 const inputRef = (0, import_element186.useRef)(); 57433 (0, import_element186.useEffect)(() => { 57434 if (inputRef.current) { 57435 inputRef.current.focus(); 57436 } 57437 }, []); 57438 async function onCreateTemplate(event) { 57439 event.preventDefault(); 57440 if (isBusy) { 57441 return; 57442 } 57443 setIsBusy(true); 57444 try { 57445 await createTemplate( 57446 { 57447 slug: paramCase(title || defaultTitle) || "wp-custom-template", 57448 title: title || defaultTitle 57449 }, 57450 false 57451 ); 57452 } finally { 57453 setIsBusy(false); 57454 } 57455 } 57456 return /* @__PURE__ */ (0, import_jsx_runtime317.jsx)("form", { onSubmit: onCreateTemplate, children: /* @__PURE__ */ (0, import_jsx_runtime317.jsxs)(import_components147.__experimentalVStack, { spacing: 6, children: [ 57457 /* @__PURE__ */ (0, import_jsx_runtime317.jsx)( 57458 import_components147.TextControl, 57459 { 57460 label: (0, import_i18n146.__)("Name"), 57461 value: title, 57462 onChange: setTitle, 57463 placeholder: defaultTitle, 57464 disabled: isBusy, 57465 ref: inputRef, 57466 help: (0, import_i18n146.__)( 57467 // eslint-disable-next-line no-restricted-syntax -- 'sidebar' is a common web design term for layouts 57468 'Describe the template, e.g. "Post with sidebar". A custom template can be manually applied to any post or page.' 57469 ) 57470 } 57471 ), 57472 /* @__PURE__ */ (0, import_jsx_runtime317.jsxs)( 57473 import_components147.__experimentalHStack, 57474 { 57475 className: "edit-site-custom-generic-template__modal-actions", 57476 justify: "right", 57477 children: [ 57478 /* @__PURE__ */ (0, import_jsx_runtime317.jsx)( 57479 import_components147.Button, 57480 { 57481 __next40pxDefaultSize: true, 57482 variant: "tertiary", 57483 onClick: onBack, 57484 children: (0, import_i18n146.__)("Back") 57485 } 57486 ), 57487 /* @__PURE__ */ (0, import_jsx_runtime317.jsx)( 57488 import_components147.Button, 57489 { 57490 __next40pxDefaultSize: true, 57491 variant: "primary", 57492 type: "submit", 57493 isBusy, 57494 "aria-disabled": isBusy, 57495 children: (0, import_i18n146.__)("Create") 57496 } 57497 ) 57498 ] 57499 } 57500 ) 57501 ] }) }); 57502 } 57503 var add_custom_generic_template_modal_content_default = AddCustomGenericTemplateModalContent; 57504 57505 // packages/edit-site/build-module/components/add-new-template/index.mjs 57506 var import_jsx_runtime318 = __toESM(require_jsx_runtime(), 1); 57507 var { useHistory: useHistory22 } = unlock(import_router33.privateApis); 57508 var DEFAULT_TEMPLATE_SLUGS = [ 57509 "front-page", 57510 "home", 57511 "single", 57512 "page", 57513 "index", 57514 "archive", 57515 "author", 57516 "category", 57517 "date", 57518 "tag", 57519 "search", 57520 "404" 57521 ]; 57522 var TEMPLATE_ICONS = { 57523 "front-page": home_default, 57524 home: verse_default, 57525 single: pin_default, 57526 page: page_default, 57527 archive: archive_default, 57528 search: search_default, 57529 404: not_found_default, 57530 index: list_default, 57531 category: category_default, 57532 author: comment_author_avatar_default, 57533 taxonomy: block_meta_default, 57534 date: calendar_default, 57535 tag: tag_default, 57536 attachment: media_default 57537 }; 57538 function TemplateListItem({ 57539 title, 57540 direction, 57541 className, 57542 description, 57543 icon, 57544 onClick, 57545 children 57546 }) { 57547 return /* @__PURE__ */ (0, import_jsx_runtime318.jsx)( 57548 import_components148.Button, 57549 { 57550 __next40pxDefaultSize: true, 57551 className, 57552 onClick, 57553 label: description, 57554 showTooltip: !!description, 57555 children: /* @__PURE__ */ (0, import_jsx_runtime318.jsxs)( 57556 import_components148.Flex, 57557 { 57558 as: "span", 57559 spacing: 2, 57560 align: "center", 57561 justify: "center", 57562 style: { width: "100%" }, 57563 direction, 57564 children: [ 57565 /* @__PURE__ */ (0, import_jsx_runtime318.jsx)("div", { className: "edit-site-add-new-template__template-icon", children: /* @__PURE__ */ (0, import_jsx_runtime318.jsx)(import_components148.Icon, { icon }) }), 57566 /* @__PURE__ */ (0, import_jsx_runtime318.jsxs)( 57567 import_components148.__experimentalVStack, 57568 { 57569 className: "edit-site-add-new-template__template-name", 57570 alignment: "center", 57571 spacing: 0, 57572 children: [ 57573 /* @__PURE__ */ (0, import_jsx_runtime318.jsx)( 57574 import_components148.__experimentalText, 57575 { 57576 align: "center", 57577 weight: "var(--wpds-typography-font-weight-emphasis, 600)", 57578 lineHeight: 1.53846153846, 57579 children: title 57580 } 57581 ), 57582 children 57583 ] 57584 } 57585 ) 57586 ] 57587 } 57588 ) 57589 } 57590 ); 57591 } 57592 var modalContentMap = { 57593 templatesList: 1, 57594 customTemplate: 2, 57595 customGenericTemplate: 3 57596 }; 57597 function NewTemplateModal({ onClose }) { 57598 const [modalContent, setModalContent] = (0, import_element187.useState)( 57599 modalContentMap.templatesList 57600 ); 57601 const [entityForSuggestions, setEntityForSuggestions] = (0, import_element187.useState)({}); 57602 const [isSubmitting, setIsSubmitting] = (0, import_element187.useState)(false); 57603 const missingTemplates = useMissingTemplates( 57604 setEntityForSuggestions, 57605 () => setModalContent(modalContentMap.customTemplate) 57606 ); 57607 const history = useHistory22(); 57608 const { saveEntityRecord } = (0, import_data78.useDispatch)(import_core_data56.store); 57609 const { createErrorNotice, createSuccessNotice } = (0, import_data78.useDispatch)(import_notices8.store); 57610 const containerRef = (0, import_element187.useRef)(null); 57611 const isMobile = (0, import_compose30.useViewportMatch)("medium", "<"); 57612 const homeUrl = (0, import_data78.useSelect)((select4) => { 57613 return select4(import_core_data56.store).getEntityRecord("root", "__unstableBase")?.home; 57614 }, []); 57615 const TEMPLATE_SHORT_DESCRIPTIONS = { 57616 "front-page": homeUrl, 57617 date: (0, import_i18n147.sprintf)( 57618 // translators: %s: The homepage url. 57619 (0, import_i18n147.__)("E.g. %s"), 57620 homeUrl + "/" + (/* @__PURE__ */ new Date()).getFullYear() 57621 ) 57622 }; 57623 (0, import_element187.useEffect)(() => { 57624 if (containerRef.current && modalContent === modalContentMap.templatesList) { 57625 const [firstFocusable] = import_dom26.focus.focusable.find( 57626 containerRef.current 57627 ); 57628 firstFocusable?.focus(); 57629 } 57630 }, [modalContent]); 57631 async function createTemplate(template, isWPSuggestion = true) { 57632 if (isSubmitting) { 57633 return; 57634 } 57635 setIsSubmitting(true); 57636 try { 57637 const { title, description, slug } = template; 57638 const newTemplate = await saveEntityRecord( 57639 "postType", 57640 TEMPLATE_POST_TYPE, 57641 { 57642 description, 57643 // Slugs need to be strings, so this is for template `404` 57644 slug: slug.toString(), 57645 status: "publish", 57646 title, 57647 // This adds a post meta field in template that is part of `is_custom` value calculation. 57648 meta: { 57649 is_wp_suggestion: isWPSuggestion 57650 } 57651 }, 57652 { throwOnError: true } 57653 ); 57654 history.navigate( 57655 `/$TEMPLATE_POST_TYPE}/$newTemplate.id}?canvas=edit` 57656 ); 57657 createSuccessNotice( 57658 (0, import_i18n147.sprintf)( 57659 // translators: %s: Title of the created post or template, e.g: "Hello world". 57660 (0, import_i18n147.__)('"%s" successfully created.'), 57661 (0, import_html_entities11.decodeEntities)(newTemplate.title?.rendered || title) || (0, import_i18n147.__)("(no title)") 57662 ), 57663 { 57664 type: "snackbar" 57665 } 57666 ); 57667 } catch (error2) { 57668 const errorMessage = error2.message && error2.code !== "unknown_error" ? error2.message : (0, import_i18n147.__)("An error occurred while creating the template."); 57669 createErrorNotice(errorMessage, { 57670 type: "snackbar" 57671 }); 57672 } finally { 57673 setIsSubmitting(false); 57674 } 57675 } 57676 const onModalClose = () => { 57677 onClose(); 57678 setModalContent(modalContentMap.templatesList); 57679 }; 57680 let modalTitle = (0, import_i18n147.__)("Add template"); 57681 if (modalContent === modalContentMap.customTemplate) { 57682 modalTitle = (0, import_i18n147.sprintf)( 57683 // translators: %s: Name of the post type e.g: "Post". 57684 (0, import_i18n147.__)("Add template: %s"), 57685 entityForSuggestions.labels.singular_name 57686 ); 57687 } else if (modalContent === modalContentMap.customGenericTemplate) { 57688 modalTitle = (0, import_i18n147.__)("Create custom template"); 57689 } 57690 return /* @__PURE__ */ (0, import_jsx_runtime318.jsxs)( 57691 import_components148.Modal, 57692 { 57693 title: modalTitle, 57694 className: clsx_default("edit-site-add-new-template__modal", { 57695 "edit-site-add-new-template__modal_template_list": modalContent === modalContentMap.templatesList, 57696 "edit-site-custom-template-modal": modalContent === modalContentMap.customTemplate 57697 }), 57698 onRequestClose: onModalClose, 57699 overlayClassName: modalContent === modalContentMap.customGenericTemplate ? "edit-site-custom-generic-template__modal" : void 0, 57700 ref: containerRef, 57701 children: [ 57702 modalContent === modalContentMap.templatesList && /* @__PURE__ */ (0, import_jsx_runtime318.jsxs)( 57703 import_components148.__experimentalGrid, 57704 { 57705 columns: isMobile ? 2 : 3, 57706 gap: 4, 57707 align: "flex-start", 57708 justify: "center", 57709 className: "edit-site-add-new-template__template-list__contents", 57710 children: [ 57711 /* @__PURE__ */ (0, import_jsx_runtime318.jsx)(import_components148.Flex, { className: "edit-site-add-new-template__template-list__prompt", children: (0, import_i18n147.__)( 57712 "Select what the new template should apply to:" 57713 ) }), 57714 missingTemplates.map((template) => { 57715 const { title, slug, onClick } = template; 57716 return /* @__PURE__ */ (0, import_jsx_runtime318.jsx)( 57717 TemplateListItem, 57718 { 57719 title, 57720 direction: "column", 57721 className: "edit-site-add-new-template__template-button", 57722 description: TEMPLATE_SHORT_DESCRIPTIONS[slug], 57723 icon: TEMPLATE_ICONS[slug] || layout_default, 57724 onClick: () => onClick ? onClick(template) : createTemplate(template) 57725 }, 57726 slug 57727 ); 57728 }), 57729 /* @__PURE__ */ (0, import_jsx_runtime318.jsx)( 57730 TemplateListItem, 57731 { 57732 title: (0, import_i18n147.__)("Custom template"), 57733 direction: "row", 57734 className: "edit-site-add-new-template__custom-template-button", 57735 icon: pencil_default, 57736 onClick: () => setModalContent( 57737 modalContentMap.customGenericTemplate 57738 ), 57739 children: /* @__PURE__ */ (0, import_jsx_runtime318.jsx)( 57740 import_components148.__experimentalText, 57741 { 57742 lineHeight: 1.53846153846, 57743 children: (0, import_i18n147.__)( 57744 "A custom template can be manually applied to any post or page." 57745 ) 57746 } 57747 ) 57748 } 57749 ) 57750 ] 57751 } 57752 ), 57753 modalContent === modalContentMap.customTemplate && /* @__PURE__ */ (0, import_jsx_runtime318.jsx)( 57754 add_custom_template_modal_content_default, 57755 { 57756 onSelect: createTemplate, 57757 entityForSuggestions, 57758 onBack: () => setModalContent(modalContentMap.templatesList), 57759 containerRef 57760 } 57761 ), 57762 modalContent === modalContentMap.customGenericTemplate && /* @__PURE__ */ (0, import_jsx_runtime318.jsx)( 57763 add_custom_generic_template_modal_content_default, 57764 { 57765 createTemplate, 57766 onBack: () => setModalContent(modalContentMap.templatesList) 57767 } 57768 ) 57769 ] 57770 } 57771 ); 57772 } 57773 function NewTemplate() { 57774 const [showModal, setShowModal] = (0, import_element187.useState)(false); 57775 const { postType: postType2 } = (0, import_data78.useSelect)((select4) => { 57776 const { getPostType: getPostType2 } = select4(import_core_data56.store); 57777 return { 57778 postType: getPostType2(TEMPLATE_POST_TYPE) 57779 }; 57780 }, []); 57781 if (!postType2) { 57782 return null; 57783 } 57784 return /* @__PURE__ */ (0, import_jsx_runtime318.jsxs)(import_jsx_runtime318.Fragment, { children: [ 57785 /* @__PURE__ */ (0, import_jsx_runtime318.jsx)( 57786 import_components148.Button, 57787 { 57788 variant: "primary", 57789 onClick: () => setShowModal(true), 57790 label: postType2.labels.add_new_item, 57791 size: "compact", 57792 __next40pxDefaultSize: true, 57793 children: postType2.labels.add_new_item 57794 } 57795 ), 57796 showModal && /* @__PURE__ */ (0, import_jsx_runtime318.jsx)(NewTemplateModal, { onClose: () => setShowModal(false) }) 57797 ] }); 57798 } 57799 function useMissingTemplates(setEntityForSuggestions, onClick) { 57800 const defaultTemplateTypes = useDefaultTemplateTypes(); 57801 const missingDefaultTemplates = (defaultTemplateTypes || []).filter( 57802 (template) => DEFAULT_TEMPLATE_SLUGS.includes(template.slug) 57803 ); 57804 const onClickMenuItem = (_entityForSuggestions) => { 57805 onClick?.(); 57806 setEntityForSuggestions(_entityForSuggestions); 57807 }; 57808 const enhancedMissingDefaultTemplateTypes = [...missingDefaultTemplates]; 57809 const { defaultTaxonomiesMenuItems, taxonomiesMenuItems } = useTaxonomiesMenuItems(onClickMenuItem); 57810 const { defaultPostTypesMenuItems, postTypesMenuItems } = usePostTypeMenuItems(onClickMenuItem); 57811 const authorMenuItem = useAuthorMenuItem(onClickMenuItem); 57812 [ 57813 ...defaultTaxonomiesMenuItems, 57814 ...defaultPostTypesMenuItems, 57815 authorMenuItem 57816 ].forEach((menuItem) => { 57817 if (!menuItem) { 57818 return; 57819 } 57820 const matchIndex = enhancedMissingDefaultTemplateTypes.findIndex( 57821 (template) => template.slug === menuItem.slug 57822 ); 57823 if (matchIndex > -1) { 57824 enhancedMissingDefaultTemplateTypes[matchIndex] = menuItem; 57825 } else { 57826 enhancedMissingDefaultTemplateTypes.push(menuItem); 57827 } 57828 }); 57829 enhancedMissingDefaultTemplateTypes?.sort((template1, template2) => { 57830 return DEFAULT_TEMPLATE_SLUGS.indexOf(template1.slug) - DEFAULT_TEMPLATE_SLUGS.indexOf(template2.slug); 57831 }); 57832 const missingTemplates = [ 57833 ...enhancedMissingDefaultTemplateTypes, 57834 ...usePostTypeArchiveMenuItems(), 57835 ...postTypesMenuItems, 57836 ...taxonomiesMenuItems 57837 ]; 57838 return missingTemplates; 57839 } 57840 var add_new_template_default = (0, import_element187.memo)(NewTemplate); 57841 57842 // packages/edit-site/build-module/components/page-templates/fields.mjs 57843 var import_components149 = __toESM(require_components(), 1); 57844 var import_i18n148 = __toESM(require_i18n(), 1); 57845 var import_element188 = __toESM(require_element(), 1); 57846 var import_html_entities12 = __toESM(require_html_entities(), 1); 57847 var import_blocks13 = __toESM(require_blocks(), 1); 57848 var import_block_editor27 = __toESM(require_block_editor(), 1); 57849 var import_editor36 = __toESM(require_editor(), 1); 57850 var import_core_data57 = __toESM(require_core_data(), 1); 57851 var import_data79 = __toESM(require_data(), 1); 57852 var import_jsx_runtime319 = __toESM(require_jsx_runtime(), 1); 57853 var { Badge: WCBadge4 } = unlock(import_components149.privateApis); 57854 var { useEntityRecordsWithPermissions } = unlock(import_core_data57.privateApis); 57855 var { useStyle: useStyle5 } = unlock(import_editor36.privateApis); 57856 function useAllDefaultTemplateTypes() { 57857 const defaultTemplateTypes = useDefaultTemplateTypes(); 57858 const { records: staticRecords } = useEntityRecordsWithPermissions( 57859 "root", 57860 "registeredTemplate" 57861 ); 57862 return [ 57863 ...defaultTemplateTypes, 57864 ...staticRecords?.filter((record) => !record.is_custom).map((record) => { 57865 return { 57866 slug: record.slug, 57867 title: record.title.rendered, 57868 description: record.description 57869 }; 57870 }) 57871 ]; 57872 } 57873 function PreviewField2({ item }) { 57874 const settings2 = usePatternSettings(); 57875 const backgroundColor = useStyle5("color.background") ?? "white"; 57876 const blocks = (0, import_element188.useMemo)(() => { 57877 return (0, import_blocks13.parse)(item.content.raw); 57878 }, [item.content.raw]); 57879 const isEmpty2 = !blocks?.length; 57880 return /* @__PURE__ */ (0, import_jsx_runtime319.jsx)(import_editor36.EditorProvider, { post: item, settings: settings2, children: /* @__PURE__ */ (0, import_jsx_runtime319.jsxs)( 57881 "div", 57882 { 57883 className: "page-templates-preview-field", 57884 style: { backgroundColor }, 57885 children: [ 57886 isEmpty2 && (0, import_i18n148.__)("Empty template"), 57887 !isEmpty2 && /* @__PURE__ */ (0, import_jsx_runtime319.jsx)(import_block_editor27.BlockPreview.Async, { children: /* @__PURE__ */ (0, import_jsx_runtime319.jsx)(import_block_editor27.BlockPreview, { blocks }) }) 57888 ] 57889 } 57890 ) }); 57891 } 57892 var previewField2 = { 57893 label: (0, import_i18n148.__)("Preview"), 57894 id: "preview", 57895 render: PreviewField2, 57896 enableSorting: false 57897 }; 57898 var descriptionField = { 57899 label: (0, import_i18n148.__)("Description"), 57900 id: "description", 57901 render: window?.__experimentalTemplateActivate ? function RenderDescription({ item }) { 57902 const defaultTemplateTypes = useAllDefaultTemplateTypes(); 57903 const defaultTemplateType = defaultTemplateTypes.find( 57904 (type) => type.slug === item.slug 57905 ); 57906 return item.description ? (0, import_html_entities12.decodeEntities)(item.description) : defaultTemplateType?.description; 57907 } : ({ item }) => { 57908 return item.description && (0, import_html_entities12.decodeEntities)(item.description); 57909 }, 57910 enableSorting: false, 57911 enableGlobalSearch: true 57912 }; 57913 function AuthorField({ item }) { 57914 const [isImageLoaded, setIsImageLoaded] = (0, import_element188.useState)(false); 57915 const { text, icon, imageUrl } = useAddedBy(item.type, item.id); 57916 return /* @__PURE__ */ (0, import_jsx_runtime319.jsxs)(import_components149.__experimentalHStack, { alignment: "left", spacing: 0, children: [ 57917 imageUrl && /* @__PURE__ */ (0, import_jsx_runtime319.jsx)( 57918 "div", 57919 { 57920 className: clsx_default("fields-controls__author-avatar", { 57921 "is-loaded": isImageLoaded 57922 }), 57923 children: /* @__PURE__ */ (0, import_jsx_runtime319.jsx)( 57924 "img", 57925 { 57926 onLoad: () => setIsImageLoaded(true), 57927 alt: "", 57928 src: imageUrl 57929 } 57930 ) 57931 } 57932 ), 57933 !imageUrl && /* @__PURE__ */ (0, import_jsx_runtime319.jsx)("div", { className: "fields-controls__author-icon", children: /* @__PURE__ */ (0, import_jsx_runtime319.jsx)(import_components149.Icon, { icon }) }), 57934 /* @__PURE__ */ (0, import_jsx_runtime319.jsx)("span", { className: "fields-controls__author-name", children: text }) 57935 ] }); 57936 } 57937 var authorField = { 57938 label: (0, import_i18n148.__)("Author"), 57939 id: "author", 57940 getValue: ({ item }) => item.author_text ?? item.author, 57941 render: AuthorField 57942 }; 57943 var activeField = { 57944 label: (0, import_i18n148.__)("Status"), 57945 id: "active", 57946 type: "boolean", 57947 getValue: ({ item }) => item._isActive, 57948 render: function Render({ item }) { 57949 const activeLabel = item._isCustom ? (0, import_i18n148._x)("Active when used", "template") : (0, import_i18n148._x)("Active", "template"); 57950 const activeIntent = item._isCustom ? "info" : "success"; 57951 const isActive = item._isActive; 57952 return /* @__PURE__ */ (0, import_jsx_runtime319.jsx)(WCBadge4, { intent: isActive ? activeIntent : "default", children: isActive ? activeLabel : (0, import_i18n148._x)("Inactive", "template") }); 57953 } 57954 }; 57955 var useThemeField = () => { 57956 const activeTheme = (0, import_data79.useSelect)( 57957 (select4) => select4(import_core_data57.store).getCurrentTheme() 57958 ); 57959 return (0, import_element188.useMemo)( 57960 () => ({ 57961 label: (0, import_i18n148.__)("Compatible Theme"), 57962 id: "theme", 57963 getValue: ({ item }) => item.theme, 57964 render: function Render3({ item }) { 57965 if (item.theme === activeTheme.stylesheet) { 57966 return /* @__PURE__ */ (0, import_jsx_runtime319.jsx)(WCBadge4, { intent: "success", children: item.theme }); 57967 } 57968 return /* @__PURE__ */ (0, import_jsx_runtime319.jsx)(WCBadge4, { intent: "error", children: item.theme }); 57969 } 57970 }), 57971 [activeTheme] 57972 ); 57973 }; 57974 var slugField = { 57975 label: (0, import_i18n148.__)("Template Type"), 57976 id: "slug", 57977 getValue: ({ item }) => item.slug, 57978 render: function Render2({ item }) { 57979 const defaultTemplateTypes = useAllDefaultTemplateTypes(); 57980 const defaultTemplateType = defaultTemplateTypes.find( 57981 (type) => type.slug === item.slug 57982 ); 57983 return defaultTemplateType?.title || (0, import_i18n148._x)("Custom", "template type"); 57984 } 57985 }; 57986 57987 // packages/edit-site/build-module/components/page-templates/view-utils.mjs 57988 var defaultLayouts = { 57989 table: { 57990 showMedia: false 57991 }, 57992 grid: { 57993 showMedia: true 57994 }, 57995 list: { 57996 showMedia: false 57997 } 57998 }; 57999 var DEFAULT_VIEW = { 58000 type: "grid", 58001 perPage: 20, 58002 sort: { 58003 field: "title", 58004 direction: "asc" 58005 }, 58006 titleField: "title", 58007 descriptionField: "description", 58008 mediaField: "preview", 58009 fields: ["author", "active", "slug", "theme"], 58010 filters: [], 58011 ...defaultLayouts.grid 58012 }; 58013 function getActiveViewOverridesForTab(activeView) { 58014 if (activeView === "user") { 58015 return { 58016 sort: { field: "date", direction: "desc" } 58017 }; 58018 } 58019 if (activeView === "active") { 58020 return {}; 58021 } 58022 return { 58023 filters: [ 58024 { 58025 field: "author", 58026 operator: "is", 58027 value: activeView, 58028 isLocked: true 58029 } 58030 ] 58031 }; 58032 } 58033 58034 // packages/edit-site/build-module/components/page-templates/index.mjs 58035 var import_jsx_runtime320 = __toESM(require_jsx_runtime(), 1); 58036 var { usePostActions: usePostActions2, usePostFields: usePostFields2, templateTitleField } = unlock(import_editor37.privateApis); 58037 var { useHistory: useHistory23, useLocation: useLocation30 } = unlock(import_router34.privateApis); 58038 var { useEntityRecordsWithPermissions: useEntityRecordsWithPermissions2 } = unlock(import_core_data58.privateApis); 58039 function PageTemplates() { 58040 const { path, query } = useLocation30(); 58041 const { activeView = "active", postId } = query; 58042 const [selection, setSelection] = (0, import_element189.useState)([postId]); 58043 const [selectedRegisteredTemplate, setSelectedRegisteredTemplate] = (0, import_element189.useState)(false); 58044 const defaultView = DEFAULT_VIEW; 58045 const activeViewOverrides = (0, import_element189.useMemo)( 58046 () => getActiveViewOverridesForTab(activeView), 58047 [activeView] 58048 ); 58049 const { view, updateView, isModified, resetToDefault } = useView({ 58050 kind: "postType", 58051 name: TEMPLATE_POST_TYPE, 58052 slug: "default", 58053 defaultView, 58054 activeViewOverrides, 58055 queryParams: { 58056 page: query.pageNumber, 58057 search: query.search 58058 }, 58059 onChangeQueryParams: (newQueryParams) => { 58060 history.navigate( 58061 (0, import_url22.addQueryArgs)(path, { 58062 ...query, 58063 pageNumber: newQueryParams.page, 58064 search: newQueryParams.search || void 0 58065 }) 58066 ); 58067 } 58068 }); 58069 const { activeTemplatesOption, activeTheme, defaultTemplateTypes } = (0, import_data80.useSelect)((select4) => { 58070 const { getEntityRecord, getCurrentTheme } = select4(import_core_data58.store); 58071 return { 58072 activeTemplatesOption: getEntityRecord("root", "site")?.active_templates, 58073 activeTheme: getCurrentTheme(), 58074 defaultTemplateTypes: select4(import_core_data58.store).getCurrentTheme()?.default_template_types 58075 }; 58076 }); 58077 const { records: userRecords, isResolving: isLoadingUserRecords } = useEntityRecordsWithPermissions2("postType", TEMPLATE_POST_TYPE, { 58078 per_page: -1, 58079 combinedTemplates: false 58080 }); 58081 const { records: staticRecords, isResolving: isLoadingStaticData } = useEntityRecordsWithPermissions2("root", "registeredTemplate", { 58082 // This should not be needed, the endpoint returns all registered 58083 // templates, but it's not possible right now to turn off pagination 58084 // for entity configs. 58085 per_page: -1 58086 }); 58087 const activeTemplates = (0, import_element189.useMemo)(() => { 58088 const _active = [...staticRecords]; 58089 if (activeTemplatesOption) { 58090 for (const activeSlug in activeTemplatesOption) { 58091 const activeId = activeTemplatesOption[activeSlug]; 58092 const template = userRecords.find( 58093 (userRecord) => userRecord.id === activeId && userRecord.theme === activeTheme.stylesheet 58094 ); 58095 if (template) { 58096 const index2 = _active.findIndex( 58097 ({ slug }) => slug === template.slug 58098 ); 58099 if (index2 !== -1) { 58100 _active[index2] = template; 58101 } else { 58102 _active.push(template); 58103 } 58104 } 58105 } 58106 } 58107 return _active; 58108 }, [userRecords, staticRecords, activeTemplatesOption, activeTheme]); 58109 let isLoadingData; 58110 if (activeView === "active") { 58111 isLoadingData = isLoadingUserRecords || isLoadingStaticData; 58112 } else if (activeView === "user") { 58113 isLoadingData = isLoadingUserRecords; 58114 } else { 58115 isLoadingData = isLoadingStaticData; 58116 } 58117 const records = (0, import_element189.useMemo)(() => { 58118 function isCustom(record) { 58119 return record.is_custom ?? // For user templates it's custom if the is_wp_suggestion meta 58120 // field is not set and the slug is not found in the default 58121 // template types. 58122 (!record.meta?.is_wp_suggestion && !defaultTemplateTypes.some( 58123 (type) => type.slug === record.slug 58124 )); 58125 } 58126 let _records; 58127 if (activeView === "active") { 58128 _records = activeTemplates.filter( 58129 (record) => !isCustom(record) 58130 ); 58131 } else if (activeView === "user") { 58132 _records = userRecords; 58133 } else { 58134 _records = staticRecords; 58135 } 58136 return _records.map((record) => ({ 58137 ...record, 58138 _isActive: activeTemplates.some( 58139 (template) => template.id === record.id 58140 ), 58141 _isCustom: isCustom(record) 58142 })); 58143 }, [ 58144 activeTemplates, 58145 defaultTemplateTypes, 58146 userRecords, 58147 staticRecords, 58148 activeView 58149 ]); 58150 const users = (0, import_data80.useSelect)( 58151 (select4) => { 58152 const { getUser } = select4(import_core_data58.store); 58153 return records.reduce((acc, record) => { 58154 if (record.author_text) { 58155 if (!acc[record.author_text]) { 58156 acc[record.author_text] = record.author_text; 58157 } 58158 } else if (record.author) { 58159 if (!acc[record.author]) { 58160 acc[record.author] = getUser(record.author); 58161 } 58162 } 58163 return acc; 58164 }, {}); 58165 }, 58166 [records] 58167 ); 58168 const history = useHistory23(); 58169 const onChangeSelection = (0, import_element189.useCallback)( 58170 (items) => { 58171 setSelection(items); 58172 if (view?.type === "list") { 58173 history.navigate( 58174 (0, import_url22.addQueryArgs)(path, { 58175 postId: items.length === 1 ? items[0] : void 0 58176 }) 58177 ); 58178 } 58179 }, 58180 [history, path, view?.type] 58181 ); 58182 const postTypeFields = usePostFields2({ 58183 postType: TEMPLATE_POST_TYPE 58184 }); 58185 const dateField = postTypeFields.find((field) => field.id === "date"); 58186 const themeField = useThemeField(); 58187 const fields2 = (0, import_element189.useMemo)(() => { 58188 const _fields = [ 58189 previewField2, 58190 templateTitleField, 58191 descriptionField, 58192 activeField, 58193 slugField 58194 ]; 58195 if (activeView === "user") { 58196 _fields.push(themeField); 58197 if (dateField) { 58198 _fields.push(dateField); 58199 } 58200 } 58201 const elements2 = []; 58202 for (const author in users) { 58203 elements2.push({ 58204 value: users[author]?.id ?? author, 58205 label: users[author]?.name ?? author 58206 }); 58207 } 58208 _fields.push({ 58209 ...authorField, 58210 elements: elements2 58211 }); 58212 return _fields; 58213 }, [users, activeView, themeField, dateField]); 58214 const { data, paginationInfo } = (0, import_element189.useMemo)(() => { 58215 return filterSortAndPaginate(records, view, fields2); 58216 }, [records, view, fields2]); 58217 const { createSuccessNotice } = (0, import_data80.useDispatch)(import_notices9.store); 58218 const onActionPerformed = (0, import_element189.useCallback)( 58219 (actionId, items) => { 58220 switch (actionId) { 58221 case "duplicate-post": 58222 { 58223 const newItem = items[0]; 58224 const _title = typeof newItem.title === "string" ? newItem.title : newItem.title?.rendered; 58225 history.navigate(`/template?activeView=user`); 58226 createSuccessNotice( 58227 (0, import_i18n149.sprintf)( 58228 // translators: %s: Title of the created post or template, e.g: "Hello world". 58229 (0, import_i18n149.__)('"%s" successfully created.'), 58230 (0, import_html_entities13.decodeEntities)(_title) || (0, import_i18n149.__)("(no title)") 58231 ), 58232 { 58233 type: "snackbar", 58234 id: "duplicate-post-action", 58235 actions: [ 58236 { 58237 label: (0, import_i18n149.__)("Edit"), 58238 onClick: () => { 58239 history.navigate( 58240 `/$newItem.type}/$newItem.id}?canvas=edit` 58241 ); 58242 } 58243 } 58244 ] 58245 } 58246 ); 58247 } 58248 break; 58249 } 58250 }, 58251 [history, createSuccessNotice] 58252 ); 58253 const postTypeActions = usePostActions2({ 58254 postType: TEMPLATE_POST_TYPE, 58255 context: "list", 58256 onActionPerformed 58257 }); 58258 const editAction = useEditPostAction(); 58259 const setActiveTemplateAction = useSetActiveTemplateAction(); 58260 const actions = (0, import_element189.useMemo)( 58261 () => activeView === "user" ? [setActiveTemplateAction, editAction, ...postTypeActions] : [setActiveTemplateAction, ...postTypeActions], 58262 [postTypeActions, setActiveTemplateAction, editAction, activeView] 58263 ); 58264 const onChangeView = (0, import_compose31.useEvent)((newView) => { 58265 updateView(newView); 58266 if (newView.type !== view.type) { 58267 history.invalidate(); 58268 } 58269 }); 58270 const duplicateAction = actions.find( 58271 (action) => action.id === "duplicate-post" 58272 ); 58273 return /* @__PURE__ */ (0, import_jsx_runtime320.jsxs)( 58274 page_default2, 58275 { 58276 className: "edit-site-page-templates", 58277 title: (0, import_i18n149.__)("Templates"), 58278 headingLevel: 2, 58279 actions: /* @__PURE__ */ (0, import_jsx_runtime320.jsx)(add_new_template_default, {}), 58280 children: [ 58281 /* @__PURE__ */ (0, import_jsx_runtime320.jsx)( 58282 dataviews_default, 58283 { 58284 paginationInfo, 58285 fields: fields2, 58286 actions, 58287 data, 58288 isLoading: isLoadingData, 58289 view, 58290 onChangeView, 58291 onChangeSelection, 58292 isItemClickable: () => true, 58293 onClickItem: (item) => { 58294 if (typeof item.id === "string") { 58295 setSelectedRegisteredTemplate(item); 58296 } else { 58297 history.navigate( 58298 `/$item.type}/$item.id}?canvas=edit` 58299 ); 58300 } 58301 }, 58302 selection, 58303 defaultLayouts, 58304 onReset: isModified ? () => { 58305 resetToDefault(); 58306 history.invalidate(); 58307 } : false 58308 }, 58309 activeView 58310 ), 58311 selectedRegisteredTemplate && duplicateAction && /* @__PURE__ */ (0, import_jsx_runtime320.jsx)( 58312 import_components150.Modal, 58313 { 58314 title: (0, import_i18n149.__)("Duplicate"), 58315 onRequestClose: () => setSelectedRegisteredTemplate(), 58316 size: "small", 58317 children: /* @__PURE__ */ (0, import_jsx_runtime320.jsx)( 58318 duplicateAction.RenderModal, 58319 { 58320 items: [selectedRegisteredTemplate], 58321 closeModal: () => setSelectedRegisteredTemplate() 58322 } 58323 ) 58324 } 58325 ) 58326 ] 58327 } 58328 ); 58329 } 58330 58331 // packages/edit-site/build-module/components/page-templates/index-legacy.mjs 58332 var import_i18n154 = __toESM(require_i18n(), 1); 58333 var import_element194 = __toESM(require_element(), 1); 58334 var import_core_data62 = __toESM(require_core_data(), 1); 58335 var import_router36 = __toESM(require_router(), 1); 58336 var import_editor38 = __toESM(require_editor(), 1); 58337 var import_url25 = __toESM(require_url(), 1); 58338 var import_compose34 = __toESM(require_compose(), 1); 58339 58340 // packages/edit-site/build-module/components/add-new-template-legacy/index.mjs 58341 var import_components153 = __toESM(require_components(), 1); 58342 var import_html_entities16 = __toESM(require_html_entities(), 1); 58343 var import_element193 = __toESM(require_element(), 1); 58344 var import_data82 = __toESM(require_data(), 1); 58345 var import_core_data61 = __toESM(require_core_data(), 1); 58346 var import_compose33 = __toESM(require_compose(), 1); 58347 var import_i18n153 = __toESM(require_i18n(), 1); 58348 var import_notices10 = __toESM(require_notices(), 1); 58349 var import_router35 = __toESM(require_router(), 1); 58350 var import_dom28 = __toESM(require_dom(), 1); 58351 58352 // packages/edit-site/build-module/components/add-new-template-legacy/add-custom-template-modal-content.mjs 58353 var import_element191 = __toESM(require_element(), 1); 58354 var import_i18n151 = __toESM(require_i18n(), 1); 58355 var import_components151 = __toESM(require_components(), 1); 58356 var import_core_data60 = __toESM(require_core_data(), 1); 58357 var import_html_entities15 = __toESM(require_html_entities(), 1); 58358 var import_compose32 = __toESM(require_compose(), 1); 58359 var import_dom27 = __toESM(require_dom(), 1); 58360 var import_url24 = __toESM(require_url(), 1); 58361 58362 // packages/edit-site/build-module/components/add-new-template-legacy/utils.mjs 58363 var import_data81 = __toESM(require_data(), 1); 58364 var import_core_data59 = __toESM(require_core_data(), 1); 58365 var import_html_entities14 = __toESM(require_html_entities(), 1); 58366 var import_element190 = __toESM(require_element(), 1); 58367 var import_i18n150 = __toESM(require_i18n(), 1); 58368 var import_url23 = __toESM(require_url(), 1); 58369 var EMPTY_OBJECT3 = {}; 58370 var getValueFromObjectPath3 = (object, path) => { 58371 let value = object; 58372 path.split(".").forEach((fieldName) => { 58373 value = value?.[fieldName]; 58374 }); 58375 return value; 58376 }; 58377 function prefixSlug2(prefix2, slug) { 58378 return `$prefix2}-${(0, import_url23.safeDecodeURI)(slug)}`; 58379 } 58380 var mapToIHasNameAndId2 = (entities, path) => { 58381 return (entities || []).map((entity) => ({ 58382 ...entity, 58383 name: (0, import_html_entities14.decodeEntities)(getValueFromObjectPath3(entity, path)) 58384 })); 58385 }; 58386 var useExistingTemplates2 = () => { 58387 return (0, import_data81.useSelect)( 58388 (select4) => select4(import_core_data59.store).getEntityRecords( 58389 "postType", 58390 TEMPLATE_POST_TYPE, 58391 { 58392 per_page: -1 58393 } 58394 ), 58395 [] 58396 ); 58397 }; 58398 var useDefaultTemplateTypes2 = () => { 58399 return (0, import_data81.useSelect)( 58400 (select4) => select4(import_core_data59.store).getCurrentTheme()?.default_template_types || [], 58401 [] 58402 ); 58403 }; 58404 var usePublicPostTypes2 = () => { 58405 const postTypes = (0, import_data81.useSelect)( 58406 (select4) => select4(import_core_data59.store).getPostTypes({ per_page: -1 }), 58407 [] 58408 ); 58409 return (0, import_element190.useMemo)(() => { 58410 const excludedPostTypes = ["attachment"]; 58411 return postTypes?.filter( 58412 ({ viewable, slug }) => viewable && !excludedPostTypes.includes(slug) 58413 ).sort((a2, b2) => { 58414 if (a2.slug === "post" || b2.slug === "post") { 58415 return 0; 58416 } 58417 return a2.name.localeCompare(b2.name); 58418 }); 58419 }, [postTypes]); 58420 }; 58421 var usePublicTaxonomies2 = () => { 58422 const taxonomies = (0, import_data81.useSelect)( 58423 (select4) => select4(import_core_data59.store).getTaxonomies({ per_page: -1 }), 58424 [] 58425 ); 58426 return (0, import_element190.useMemo)(() => { 58427 return taxonomies?.filter( 58428 ({ visibility }) => visibility?.publicly_queryable 58429 ); 58430 }, [taxonomies]); 58431 }; 58432 function usePostTypeArchiveMenuItems2() { 58433 const publicPostTypes = usePublicPostTypes2(); 58434 const postTypesWithArchives = (0, import_element190.useMemo)( 58435 () => publicPostTypes?.filter((postType2) => postType2.has_archive), 58436 [publicPostTypes] 58437 ); 58438 const existingTemplates = useExistingTemplates2(); 58439 const postTypeLabels = (0, import_element190.useMemo)( 58440 () => publicPostTypes?.reduce((accumulator, { labels }) => { 58441 const singularName = labels.singular_name.toLowerCase(); 58442 accumulator[singularName] = (accumulator[singularName] || 0) + 1; 58443 return accumulator; 58444 }, {}), 58445 [publicPostTypes] 58446 ); 58447 const needsUniqueIdentifier = (0, import_element190.useCallback)( 58448 ({ labels, slug }) => { 58449 const singularName = labels.singular_name.toLowerCase(); 58450 return postTypeLabels[singularName] > 1 && singularName !== slug; 58451 }, 58452 [postTypeLabels] 58453 ); 58454 return (0, import_element190.useMemo)( 58455 () => postTypesWithArchives?.filter( 58456 (postType2) => !(existingTemplates || []).some( 58457 (existingTemplate) => existingTemplate.slug === "archive-" + postType2.slug 58458 ) 58459 ).map((postType2) => { 58460 let title; 58461 if (needsUniqueIdentifier(postType2)) { 58462 title = (0, import_i18n150.sprintf)( 58463 // translators: %1s: Name of the post type e.g: "Post"; %2s: Slug of the post type e.g: "book". 58464 (0, import_i18n150.__)("Archive: %1$s (%2$s)"), 58465 postType2.labels.singular_name, 58466 postType2.slug 58467 ); 58468 } else { 58469 title = (0, import_i18n150.sprintf)( 58470 // translators: %s: Name of the post type e.g: "Post". 58471 (0, import_i18n150.__)("Archive: %s"), 58472 postType2.labels.singular_name 58473 ); 58474 } 58475 return { 58476 slug: "archive-" + postType2.slug, 58477 description: (0, import_i18n150.sprintf)( 58478 // translators: %s: Name of the post type e.g: "Post". 58479 (0, import_i18n150.__)( 58480 "Displays an archive with the latest posts of type: %s." 58481 ), 58482 postType2.labels.singular_name 58483 ), 58484 title, 58485 // `icon` is the `menu_icon` property of a post type. We 58486 // only handle `dashicons` for now, even if the `menu_icon` 58487 // also supports urls and svg as values. 58488 icon: typeof postType2.icon === "string" && postType2.icon.startsWith("dashicons-") ? postType2.icon.slice(10) : archive_default, 58489 templatePrefix: "archive" 58490 }; 58491 }) || [], 58492 [postTypesWithArchives, existingTemplates, needsUniqueIdentifier] 58493 ); 58494 } 58495 var usePostTypeMenuItems2 = (onClickMenuItem) => { 58496 const publicPostTypes = usePublicPostTypes2(); 58497 const existingTemplates = useExistingTemplates2(); 58498 const defaultTemplateTypes = useDefaultTemplateTypes2(); 58499 const templateLabels = (0, import_element190.useMemo)( 58500 () => publicPostTypes?.reduce((accumulator, { labels }) => { 58501 const templateName = (labels.template_name || labels.singular_name).toLowerCase(); 58502 accumulator[templateName] = (accumulator[templateName] || 0) + 1; 58503 return accumulator; 58504 }, {}), 58505 [publicPostTypes] 58506 ); 58507 const needsUniqueIdentifier = (0, import_element190.useCallback)( 58508 ({ labels, slug }) => { 58509 const templateName = (labels.template_name || labels.singular_name).toLowerCase(); 58510 return templateLabels[templateName] > 1 && templateName !== slug; 58511 }, 58512 [templateLabels] 58513 ); 58514 const templatePrefixes = (0, import_element190.useMemo)( 58515 () => publicPostTypes?.reduce((accumulator, { slug }) => { 58516 let suffix = slug; 58517 if (slug !== "page") { 58518 suffix = `single-$suffix}`; 58519 } 58520 accumulator[slug] = suffix; 58521 return accumulator; 58522 }, {}), 58523 [publicPostTypes] 58524 ); 58525 const postTypesInfo = useEntitiesInfo2("postType", templatePrefixes); 58526 const existingTemplateSlugs = (existingTemplates || []).map( 58527 ({ slug }) => slug 58528 ); 58529 const menuItems = (publicPostTypes || []).reduce( 58530 (accumulator, postType2) => { 58531 const { slug, labels, icon } = postType2; 58532 const generalTemplateSlug = templatePrefixes[slug]; 58533 const defaultTemplateType = defaultTemplateTypes?.find( 58534 ({ slug: _slug }) => _slug === generalTemplateSlug 58535 ); 58536 const hasGeneralTemplate = existingTemplateSlugs?.includes(generalTemplateSlug); 58537 const _needsUniqueIdentifier = needsUniqueIdentifier(postType2); 58538 let menuItemTitle = labels.template_name || (0, import_i18n150.sprintf)( 58539 // translators: %s: Name of the post type e.g: "Post". 58540 (0, import_i18n150.__)("Single item: %s"), 58541 labels.singular_name 58542 ); 58543 if (_needsUniqueIdentifier) { 58544 menuItemTitle = labels.template_name ? (0, import_i18n150.sprintf)( 58545 // translators: 1: Name of the template e.g: "Single Item: Post". 2: Slug of the post type e.g: "book". 58546 (0, import_i18n150._x)("%1$s (%2$s)", "post type menu label"), 58547 labels.template_name, 58548 slug 58549 ) : (0, import_i18n150.sprintf)( 58550 // translators: 1: Name of the post type e.g: "Post". 2: Slug of the post type e.g: "book". 58551 (0, import_i18n150._x)( 58552 "Single item: %1$s (%2$s)", 58553 "post type menu label" 58554 ), 58555 labels.singular_name, 58556 slug 58557 ); 58558 } 58559 const menuItem = defaultTemplateType ? { 58560 ...defaultTemplateType, 58561 templatePrefix: templatePrefixes[slug] 58562 } : { 58563 slug: generalTemplateSlug, 58564 title: menuItemTitle, 58565 description: (0, import_i18n150.sprintf)( 58566 // translators: %s: Name of the post type e.g: "Post". 58567 (0, import_i18n150.__)("Displays a single item: %s."), 58568 labels.singular_name 58569 ), 58570 // `icon` is the `menu_icon` property of a post type. We 58571 // only handle `dashicons` for now, even if the `menu_icon` 58572 // also supports urls and svg as values. 58573 icon: typeof icon === "string" && icon.startsWith("dashicons-") ? icon.slice(10) : post_default, 58574 templatePrefix: templatePrefixes[slug] 58575 }; 58576 const hasEntities = postTypesInfo?.[slug]?.hasEntities; 58577 if (hasEntities) { 58578 menuItem.onClick = (template) => { 58579 onClickMenuItem({ 58580 type: "postType", 58581 slug, 58582 config: { 58583 recordNamePath: "title.rendered", 58584 queryArgs: ({ search }) => { 58585 return { 58586 _fields: "id,title,slug,link", 58587 orderBy: search ? "relevance" : "modified", 58588 exclude: postTypesInfo[slug].existingEntitiesIds 58589 }; 58590 }, 58591 getSpecificTemplate: (suggestion) => { 58592 const templateSlug = prefixSlug2( 58593 templatePrefixes[slug], 58594 suggestion.slug 58595 ); 58596 return { 58597 title: templateSlug, 58598 slug: templateSlug, 58599 templatePrefix: templatePrefixes[slug] 58600 }; 58601 } 58602 }, 58603 labels, 58604 hasGeneralTemplate, 58605 template 58606 }); 58607 }; 58608 } 58609 if (!hasGeneralTemplate || hasEntities) { 58610 accumulator.push(menuItem); 58611 } 58612 return accumulator; 58613 }, 58614 [] 58615 ); 58616 const postTypesMenuItems = (0, import_element190.useMemo)( 58617 () => menuItems.reduce( 58618 (accumulator, postType2) => { 58619 const { slug } = postType2; 58620 let key = "postTypesMenuItems"; 58621 if (slug === "page") { 58622 key = "defaultPostTypesMenuItems"; 58623 } 58624 accumulator[key].push(postType2); 58625 return accumulator; 58626 }, 58627 { defaultPostTypesMenuItems: [], postTypesMenuItems: [] } 58628 ), 58629 [menuItems] 58630 ); 58631 return postTypesMenuItems; 58632 }; 58633 var useTaxonomiesMenuItems2 = (onClickMenuItem) => { 58634 const publicTaxonomies = usePublicTaxonomies2(); 58635 const existingTemplates = useExistingTemplates2(); 58636 const defaultTemplateTypes = useDefaultTemplateTypes2(); 58637 const templatePrefixes = (0, import_element190.useMemo)( 58638 () => publicTaxonomies?.reduce((accumulator, { slug }) => { 58639 let suffix = slug; 58640 if (!["category", "post_tag"].includes(slug)) { 58641 suffix = `taxonomy-$suffix}`; 58642 } 58643 if (slug === "post_tag") { 58644 suffix = `tag`; 58645 } 58646 accumulator[slug] = suffix; 58647 return accumulator; 58648 }, {}), 58649 [publicTaxonomies] 58650 ); 58651 const taxonomyLabels = publicTaxonomies?.reduce( 58652 (accumulator, { labels }) => { 58653 const templateName = (labels.template_name || labels.singular_name).toLowerCase(); 58654 accumulator[templateName] = (accumulator[templateName] || 0) + 1; 58655 return accumulator; 58656 }, 58657 {} 58658 ); 58659 const needsUniqueIdentifier = (labels, slug) => { 58660 if (["category", "post_tag"].includes(slug)) { 58661 return false; 58662 } 58663 const templateName = (labels.template_name || labels.singular_name).toLowerCase(); 58664 return taxonomyLabels[templateName] > 1 && templateName !== slug; 58665 }; 58666 const taxonomiesInfo = useEntitiesInfo2("taxonomy", templatePrefixes); 58667 const existingTemplateSlugs = (existingTemplates || []).map( 58668 ({ slug }) => slug 58669 ); 58670 const menuItems = (publicTaxonomies || []).reduce( 58671 (accumulator, taxonomy) => { 58672 const { slug, labels } = taxonomy; 58673 const generalTemplateSlug = templatePrefixes[slug]; 58674 const defaultTemplateType = defaultTemplateTypes?.find( 58675 ({ slug: _slug }) => _slug === generalTemplateSlug 58676 ); 58677 const hasGeneralTemplate = existingTemplateSlugs?.includes(generalTemplateSlug); 58678 const _needsUniqueIdentifier = needsUniqueIdentifier( 58679 labels, 58680 slug 58681 ); 58682 let menuItemTitle = labels.template_name || labels.singular_name; 58683 if (_needsUniqueIdentifier) { 58684 menuItemTitle = labels.template_name ? (0, import_i18n150.sprintf)( 58685 // translators: 1: Name of the template e.g: "Products by Category". 2: Slug of the taxonomy e.g: "product_cat". 58686 (0, import_i18n150._x)("%1$s (%2$s)", "taxonomy template menu label"), 58687 labels.template_name, 58688 slug 58689 ) : (0, import_i18n150.sprintf)( 58690 // translators: 1: Name of the taxonomy e.g: "Category". 2: Slug of the taxonomy e.g: "product_cat". 58691 (0, import_i18n150._x)("%1$s (%2$s)", "taxonomy menu label"), 58692 labels.singular_name, 58693 slug 58694 ); 58695 } 58696 const menuItem = defaultTemplateType ? { 58697 ...defaultTemplateType, 58698 templatePrefix: templatePrefixes[slug] 58699 } : { 58700 slug: generalTemplateSlug, 58701 title: menuItemTitle, 58702 description: (0, import_i18n150.sprintf)( 58703 // translators: %s: Name of the taxonomy e.g: "Product Categories". 58704 (0, import_i18n150.__)("Displays taxonomy: %s."), 58705 labels.singular_name 58706 ), 58707 icon: block_meta_default, 58708 templatePrefix: templatePrefixes[slug] 58709 }; 58710 const hasEntities = taxonomiesInfo?.[slug]?.hasEntities; 58711 if (hasEntities) { 58712 menuItem.onClick = (template) => { 58713 onClickMenuItem({ 58714 type: "taxonomy", 58715 slug, 58716 config: { 58717 queryArgs: ({ search }) => { 58718 return { 58719 _fields: "id,name,slug,link", 58720 orderBy: search ? "name" : "count", 58721 exclude: taxonomiesInfo[slug].existingEntitiesIds 58722 }; 58723 }, 58724 getSpecificTemplate: (suggestion) => { 58725 const templateSlug = prefixSlug2( 58726 templatePrefixes[slug], 58727 suggestion.slug 58728 ); 58729 return { 58730 title: templateSlug, 58731 slug: templateSlug, 58732 templatePrefix: templatePrefixes[slug] 58733 }; 58734 } 58735 }, 58736 labels, 58737 hasGeneralTemplate, 58738 template 58739 }); 58740 }; 58741 } 58742 if (!hasGeneralTemplate || hasEntities) { 58743 accumulator.push(menuItem); 58744 } 58745 return accumulator; 58746 }, 58747 [] 58748 ); 58749 const taxonomiesMenuItems = (0, import_element190.useMemo)( 58750 () => menuItems.reduce( 58751 (accumulator, taxonomy) => { 58752 const { slug } = taxonomy; 58753 let key = "taxonomiesMenuItems"; 58754 if (["category", "tag"].includes(slug)) { 58755 key = "defaultTaxonomiesMenuItems"; 58756 } 58757 accumulator[key].push(taxonomy); 58758 return accumulator; 58759 }, 58760 { defaultTaxonomiesMenuItems: [], taxonomiesMenuItems: [] } 58761 ), 58762 [menuItems] 58763 ); 58764 return taxonomiesMenuItems; 58765 }; 58766 var USE_AUTHOR_MENU_ITEM_TEMPLATE_PREFIX2 = { user: "author" }; 58767 var USE_AUTHOR_MENU_ITEM_QUERY_PARAMETERS2 = { user: { who: "authors" } }; 58768 function useAuthorMenuItem2(onClickMenuItem) { 58769 const existingTemplates = useExistingTemplates2(); 58770 const defaultTemplateTypes = useDefaultTemplateTypes2(); 58771 const authorInfo = useEntitiesInfo2( 58772 "root", 58773 USE_AUTHOR_MENU_ITEM_TEMPLATE_PREFIX2, 58774 USE_AUTHOR_MENU_ITEM_QUERY_PARAMETERS2 58775 ); 58776 let authorMenuItem = defaultTemplateTypes?.find( 58777 ({ slug }) => slug === "author" 58778 ); 58779 if (!authorMenuItem) { 58780 authorMenuItem = { 58781 description: (0, import_i18n150.__)( 58782 "Displays latest posts written by a single author." 58783 ), 58784 slug: "author", 58785 title: "Author" 58786 }; 58787 } 58788 const hasGeneralTemplate = !!existingTemplates?.find( 58789 ({ slug }) => slug === "author" 58790 ); 58791 if (authorInfo.user?.hasEntities) { 58792 authorMenuItem = { ...authorMenuItem, templatePrefix: "author" }; 58793 authorMenuItem.onClick = (template) => { 58794 onClickMenuItem({ 58795 type: "root", 58796 slug: "user", 58797 config: { 58798 queryArgs: ({ search }) => { 58799 return { 58800 _fields: "id,name,slug,link", 58801 orderBy: search ? "name" : "registered_date", 58802 exclude: authorInfo.user.existingEntitiesIds, 58803 who: "authors" 58804 }; 58805 }, 58806 getSpecificTemplate: (suggestion) => { 58807 const templateSlug = prefixSlug2( 58808 "author", 58809 suggestion.slug 58810 ); 58811 return { 58812 title: templateSlug, 58813 slug: templateSlug, 58814 templatePrefix: "author" 58815 }; 58816 } 58817 }, 58818 labels: { 58819 singular_name: (0, import_i18n150.__)("Author"), 58820 search_items: (0, import_i18n150.__)("Search Authors"), 58821 not_found: (0, import_i18n150.__)("No authors found."), 58822 all_items: (0, import_i18n150.__)("All Authors") 58823 }, 58824 hasGeneralTemplate, 58825 template 58826 }); 58827 }; 58828 } 58829 if (!hasGeneralTemplate || authorInfo.user?.hasEntities) { 58830 return authorMenuItem; 58831 } 58832 } 58833 var useExistingTemplateSlugs = (templatePrefixes) => { 58834 const existingTemplates = useExistingTemplates2(); 58835 const existingSlugs = (0, import_element190.useMemo)(() => { 58836 return Object.entries(templatePrefixes || {}).reduce( 58837 (accumulator, [slug, prefix2]) => { 58838 const slugsWithTemplates = (existingTemplates || []).reduce( 58839 (_accumulator, existingTemplate) => { 58840 const _prefix = `$prefix2}-`; 58841 if (existingTemplate.slug.startsWith(_prefix)) { 58842 _accumulator.push( 58843 existingTemplate.slug.substring( 58844 _prefix.length 58845 ) 58846 ); 58847 } 58848 return _accumulator; 58849 }, 58850 [] 58851 ); 58852 if (slugsWithTemplates.length) { 58853 accumulator[slug] = slugsWithTemplates; 58854 } 58855 return accumulator; 58856 }, 58857 {} 58858 ); 58859 }, [templatePrefixes, existingTemplates]); 58860 return existingSlugs; 58861 }; 58862 var useTemplatesToExclude = (entityName, templatePrefixes, additionalQueryParameters = {}) => { 58863 const slugsToExcludePerEntity = useExistingTemplateSlugs(templatePrefixes); 58864 const recordsToExcludePerEntity = (0, import_data81.useSelect)( 58865 (select4) => { 58866 return Object.entries(slugsToExcludePerEntity || {}).reduce( 58867 (accumulator, [slug, slugsWithTemplates]) => { 58868 const entitiesWithTemplates = select4( 58869 import_core_data59.store 58870 ).getEntityRecords(entityName, slug, { 58871 _fields: "id", 58872 context: "view", 58873 slug: slugsWithTemplates, 58874 ...additionalQueryParameters[slug] 58875 }); 58876 if (entitiesWithTemplates?.length) { 58877 accumulator[slug] = entitiesWithTemplates; 58878 } 58879 return accumulator; 58880 }, 58881 {} 58882 ); 58883 }, 58884 [slugsToExcludePerEntity] 58885 ); 58886 return recordsToExcludePerEntity; 58887 }; 58888 var useEntitiesInfo2 = (entityName, templatePrefixes, additionalQueryParameters = EMPTY_OBJECT3) => { 58889 const recordsToExcludePerEntity = useTemplatesToExclude( 58890 entityName, 58891 templatePrefixes, 58892 additionalQueryParameters 58893 ); 58894 const entitiesHasRecords = (0, import_data81.useSelect)( 58895 (select4) => { 58896 return Object.keys(templatePrefixes || {}).reduce( 58897 (accumulator, slug) => { 58898 const existingEntitiesIds = recordsToExcludePerEntity?.[slug]?.map( 58899 ({ id }) => id 58900 ) || []; 58901 const records = select4(import_core_data59.store).getEntityRecords( 58902 entityName, 58903 slug, 58904 { 58905 per_page: 1, 58906 _fields: "id", 58907 context: "view", 58908 exclude: existingEntitiesIds, 58909 ...additionalQueryParameters[slug] 58910 } 58911 ); 58912 accumulator[slug] = records === null || records.length > 0; 58913 return accumulator; 58914 }, 58915 {} 58916 ); 58917 }, 58918 [ 58919 templatePrefixes, 58920 recordsToExcludePerEntity, 58921 entityName, 58922 additionalQueryParameters 58923 ] 58924 ); 58925 const entitiesInfo = (0, import_element190.useMemo)(() => { 58926 return Object.keys(templatePrefixes || {}).reduce( 58927 (accumulator, slug) => { 58928 const existingEntitiesIds = recordsToExcludePerEntity?.[slug]?.map( 58929 ({ id }) => id 58930 ) || []; 58931 accumulator[slug] = { 58932 hasEntities: entitiesHasRecords[slug], 58933 existingEntitiesIds 58934 }; 58935 return accumulator; 58936 }, 58937 {} 58938 ); 58939 }, [templatePrefixes, recordsToExcludePerEntity, entitiesHasRecords]); 58940 return entitiesInfo; 58941 }; 58942 58943 // packages/edit-site/build-module/components/add-new-template-legacy/add-custom-template-modal-content.mjs 58944 var import_jsx_runtime321 = __toESM(require_jsx_runtime(), 1); 58945 var EMPTY_ARRAY15 = []; 58946 function SuggestionListItem2({ 58947 suggestion, 58948 search, 58949 onSelect, 58950 entityForSuggestions 58951 }) { 58952 const baseCssClass = "edit-site-custom-template-modal__suggestions_list__list-item"; 58953 return /* @__PURE__ */ (0, import_jsx_runtime321.jsxs)( 58954 import_components151.Composite.Item, 58955 { 58956 render: /* @__PURE__ */ (0, import_jsx_runtime321.jsx)( 58957 import_components151.Button, 58958 { 58959 __next40pxDefaultSize: true, 58960 role: "option", 58961 className: baseCssClass, 58962 onClick: () => onSelect( 58963 entityForSuggestions.config.getSpecificTemplate( 58964 suggestion 58965 ) 58966 ) 58967 } 58968 ), 58969 children: [ 58970 /* @__PURE__ */ (0, import_jsx_runtime321.jsx)( 58971 import_components151.__experimentalText, 58972 { 58973 size: "body", 58974 lineHeight: 1.53846153846, 58975 weight: "var(--wpds-typography-font-weight-emphasis, 600)", 58976 className: `$baseCssClass}__title`, 58977 children: /* @__PURE__ */ (0, import_jsx_runtime321.jsx)( 58978 import_components151.TextHighlight, 58979 { 58980 text: (0, import_html_entities15.decodeEntities)(suggestion.name), 58981 highlight: search 58982 } 58983 ) 58984 } 58985 ), 58986 suggestion.link && /* @__PURE__ */ (0, import_jsx_runtime321.jsx)( 58987 import_components151.__experimentalText, 58988 { 58989 size: "body", 58990 lineHeight: 1.53846153846, 58991 className: `$baseCssClass}__info`, 58992 children: (0, import_url24.safeDecodeURI)(suggestion.link) 58993 } 58994 ) 58995 ] 58996 } 58997 ); 58998 } 58999 function useSearchSuggestions2(entityForSuggestions, search) { 59000 const { config: config2 } = entityForSuggestions; 59001 const query = (0, import_element191.useMemo)( 59002 () => ({ 59003 order: "asc", 59004 context: "view", 59005 search, 59006 per_page: search ? 20 : 10, 59007 ...config2.queryArgs(search) 59008 }), 59009 [search, config2] 59010 ); 59011 const { records: searchResults, hasResolved: searchHasResolved } = (0, import_core_data60.useEntityRecords)( 59012 entityForSuggestions.type, 59013 entityForSuggestions.slug, 59014 query 59015 ); 59016 const [suggestions, setSuggestions] = (0, import_element191.useState)(EMPTY_ARRAY15); 59017 (0, import_element191.useEffect)(() => { 59018 if (!searchHasResolved) { 59019 return; 59020 } 59021 let newSuggestions = EMPTY_ARRAY15; 59022 if (searchResults?.length) { 59023 newSuggestions = searchResults; 59024 if (config2.recordNamePath) { 59025 newSuggestions = mapToIHasNameAndId2( 59026 newSuggestions, 59027 config2.recordNamePath 59028 ); 59029 } 59030 } 59031 setSuggestions(newSuggestions); 59032 }, [searchResults, searchHasResolved]); 59033 return suggestions; 59034 } 59035 function SuggestionList2({ entityForSuggestions, onSelect }) { 59036 const [search, setSearch, debouncedSearch] = (0, import_compose32.useDebouncedInput)(); 59037 const suggestions = useSearchSuggestions2( 59038 entityForSuggestions, 59039 debouncedSearch 59040 ); 59041 const { labels } = entityForSuggestions; 59042 const [showSearchControl, setShowSearchControl] = (0, import_element191.useState)(false); 59043 if (!showSearchControl && suggestions?.length > 9) { 59044 setShowSearchControl(true); 59045 } 59046 return /* @__PURE__ */ (0, import_jsx_runtime321.jsxs)(import_jsx_runtime321.Fragment, { children: [ 59047 showSearchControl && /* @__PURE__ */ (0, import_jsx_runtime321.jsx)( 59048 import_components151.SearchControl, 59049 { 59050 onChange: setSearch, 59051 value: search, 59052 label: labels.search_items, 59053 placeholder: labels.search_items 59054 } 59055 ), 59056 !!suggestions?.length && /* @__PURE__ */ (0, import_jsx_runtime321.jsx)( 59057 import_components151.Composite, 59058 { 59059 orientation: "vertical", 59060 role: "listbox", 59061 className: "edit-site-custom-template-modal__suggestions_list", 59062 "aria-label": (0, import_i18n151.__)("Suggestions list"), 59063 children: suggestions.map((suggestion) => /* @__PURE__ */ (0, import_jsx_runtime321.jsx)( 59064 SuggestionListItem2, 59065 { 59066 suggestion, 59067 search: debouncedSearch, 59068 onSelect, 59069 entityForSuggestions 59070 }, 59071 suggestion.slug 59072 )) 59073 } 59074 ), 59075 debouncedSearch && !suggestions?.length && /* @__PURE__ */ (0, import_jsx_runtime321.jsx)( 59076 import_components151.__experimentalText, 59077 { 59078 as: "p", 59079 className: "edit-site-custom-template-modal__no-results", 59080 children: labels.not_found 59081 } 59082 ) 59083 ] }); 59084 } 59085 function AddCustomTemplateModalContent2({ 59086 onSelect, 59087 entityForSuggestions, 59088 onBack, 59089 containerRef 59090 }) { 59091 const [showSearchEntities, setShowSearchEntities] = (0, import_element191.useState)( 59092 entityForSuggestions.hasGeneralTemplate 59093 ); 59094 (0, import_element191.useEffect)(() => { 59095 if (containerRef.current) { 59096 const [firstFocusable] = import_dom27.focus.focusable.find( 59097 containerRef.current 59098 ); 59099 firstFocusable?.focus(); 59100 } 59101 }, [showSearchEntities]); 59102 return /* @__PURE__ */ (0, import_jsx_runtime321.jsxs)( 59103 import_components151.__experimentalVStack, 59104 { 59105 spacing: 4, 59106 className: "edit-site-custom-template-modal__contents-wrapper", 59107 alignment: "left", 59108 children: [ 59109 !showSearchEntities && /* @__PURE__ */ (0, import_jsx_runtime321.jsxs)(import_jsx_runtime321.Fragment, { children: [ 59110 /* @__PURE__ */ (0, import_jsx_runtime321.jsx)(import_components151.__experimentalText, { as: "p", children: (0, import_i18n151.__)( 59111 "Select whether to create a single template for all items or a specific one." 59112 ) }), 59113 /* @__PURE__ */ (0, import_jsx_runtime321.jsxs)( 59114 import_components151.Flex, 59115 { 59116 className: "edit-site-custom-template-modal__contents", 59117 gap: "4", 59118 align: "initial", 59119 children: [ 59120 /* @__PURE__ */ (0, import_jsx_runtime321.jsxs)( 59121 import_components151.FlexItem, 59122 { 59123 isBlock: true, 59124 as: import_components151.Button, 59125 onClick: () => { 59126 const { 59127 slug, 59128 title, 59129 description, 59130 templatePrefix 59131 } = entityForSuggestions.template; 59132 onSelect({ 59133 slug, 59134 title, 59135 description, 59136 templatePrefix 59137 }); 59138 }, 59139 children: [ 59140 /* @__PURE__ */ (0, import_jsx_runtime321.jsx)( 59141 import_components151.__experimentalText, 59142 { 59143 as: "span", 59144 weight: "var(--wpds-typography-font-weight-emphasis, 600)", 59145 lineHeight: 1.53846153846, 59146 children: entityForSuggestions.labels.all_items 59147 } 59148 ), 59149 /* @__PURE__ */ (0, import_jsx_runtime321.jsx)( 59150 import_components151.__experimentalText, 59151 { 59152 as: "span", 59153 lineHeight: 1.53846153846, 59154 // 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. 59155 children: (0, import_i18n151.__)("For all items") 59156 } 59157 ) 59158 ] 59159 } 59160 ), 59161 /* @__PURE__ */ (0, import_jsx_runtime321.jsxs)( 59162 import_components151.FlexItem, 59163 { 59164 isBlock: true, 59165 as: import_components151.Button, 59166 onClick: () => { 59167 setShowSearchEntities(true); 59168 }, 59169 children: [ 59170 /* @__PURE__ */ (0, import_jsx_runtime321.jsx)( 59171 import_components151.__experimentalText, 59172 { 59173 as: "span", 59174 weight: "var(--wpds-typography-font-weight-emphasis, 600)", 59175 lineHeight: 1.53846153846, 59176 children: entityForSuggestions.labels.singular_name 59177 } 59178 ), 59179 /* @__PURE__ */ (0, import_jsx_runtime321.jsx)( 59180 import_components151.__experimentalText, 59181 { 59182 as: "span", 59183 lineHeight: 1.53846153846, 59184 // 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. 59185 children: (0, import_i18n151.__)("For a specific item") 59186 } 59187 ) 59188 ] 59189 } 59190 ) 59191 ] 59192 } 59193 ), 59194 /* @__PURE__ */ (0, import_jsx_runtime321.jsx)(import_components151.Flex, { justify: "right", children: /* @__PURE__ */ (0, import_jsx_runtime321.jsx)( 59195 import_components151.Button, 59196 { 59197 __next40pxDefaultSize: true, 59198 variant: "tertiary", 59199 onClick: onBack, 59200 children: (0, import_i18n151.__)("Back") 59201 } 59202 ) }) 59203 ] }), 59204 showSearchEntities && /* @__PURE__ */ (0, import_jsx_runtime321.jsxs)(import_jsx_runtime321.Fragment, { children: [ 59205 /* @__PURE__ */ (0, import_jsx_runtime321.jsx)(import_components151.__experimentalText, { as: "p", children: (0, import_i18n151.__)( 59206 "This template will be used only for the specific item chosen." 59207 ) }), 59208 /* @__PURE__ */ (0, import_jsx_runtime321.jsx)( 59209 SuggestionList2, 59210 { 59211 entityForSuggestions, 59212 onSelect 59213 } 59214 ), 59215 /* @__PURE__ */ (0, import_jsx_runtime321.jsx)(import_components151.Flex, { justify: "right", children: /* @__PURE__ */ (0, import_jsx_runtime321.jsx)( 59216 import_components151.Button, 59217 { 59218 __next40pxDefaultSize: true, 59219 variant: "tertiary", 59220 onClick: () => { 59221 if (entityForSuggestions.hasGeneralTemplate) { 59222 onBack(); 59223 } else { 59224 setShowSearchEntities(false); 59225 } 59226 }, 59227 children: (0, import_i18n151.__)("Back") 59228 } 59229 ) }) 59230 ] }) 59231 ] 59232 } 59233 ); 59234 } 59235 var add_custom_template_modal_content_default2 = AddCustomTemplateModalContent2; 59236 59237 // packages/edit-site/build-module/components/add-new-template-legacy/add-custom-generic-template-modal-content.mjs 59238 var import_element192 = __toESM(require_element(), 1); 59239 var import_i18n152 = __toESM(require_i18n(), 1); 59240 var import_components152 = __toESM(require_components(), 1); 59241 var import_jsx_runtime322 = __toESM(require_jsx_runtime(), 1); 59242 function AddCustomGenericTemplateModalContent2({ createTemplate, onBack }) { 59243 const [title, setTitle] = (0, import_element192.useState)(""); 59244 const defaultTitle = (0, import_i18n152.__)("Custom Template"); 59245 const [isBusy, setIsBusy] = (0, import_element192.useState)(false); 59246 const inputRef = (0, import_element192.useRef)(); 59247 (0, import_element192.useEffect)(() => { 59248 if (inputRef.current) { 59249 inputRef.current.focus(); 59250 } 59251 }, []); 59252 async function onCreateTemplate(event) { 59253 event.preventDefault(); 59254 if (isBusy) { 59255 return; 59256 } 59257 setIsBusy(true); 59258 try { 59259 await createTemplate( 59260 { 59261 slug: paramCase(title || defaultTitle) || "wp-custom-template", 59262 title: title || defaultTitle 59263 }, 59264 false 59265 ); 59266 } finally { 59267 setIsBusy(false); 59268 } 59269 } 59270 return /* @__PURE__ */ (0, import_jsx_runtime322.jsx)("form", { onSubmit: onCreateTemplate, children: /* @__PURE__ */ (0, import_jsx_runtime322.jsxs)(import_components152.__experimentalVStack, { spacing: 6, children: [ 59271 /* @__PURE__ */ (0, import_jsx_runtime322.jsx)( 59272 import_components152.TextControl, 59273 { 59274 label: (0, import_i18n152.__)("Name"), 59275 value: title, 59276 onChange: setTitle, 59277 placeholder: defaultTitle, 59278 disabled: isBusy, 59279 ref: inputRef, 59280 help: (0, import_i18n152.__)( 59281 // eslint-disable-next-line no-restricted-syntax -- 'sidebar' is a common web design term for layouts 59282 'Describe the template, e.g. "Post with sidebar". A custom template can be manually applied to any post or page.' 59283 ) 59284 } 59285 ), 59286 /* @__PURE__ */ (0, import_jsx_runtime322.jsxs)( 59287 import_components152.__experimentalHStack, 59288 { 59289 className: "edit-site-custom-generic-template__modal-actions", 59290 justify: "right", 59291 children: [ 59292 /* @__PURE__ */ (0, import_jsx_runtime322.jsx)( 59293 import_components152.Button, 59294 { 59295 __next40pxDefaultSize: true, 59296 variant: "tertiary", 59297 onClick: onBack, 59298 children: (0, import_i18n152.__)("Back") 59299 } 59300 ), 59301 /* @__PURE__ */ (0, import_jsx_runtime322.jsx)( 59302 import_components152.Button, 59303 { 59304 __next40pxDefaultSize: true, 59305 variant: "primary", 59306 type: "submit", 59307 isBusy, 59308 "aria-disabled": isBusy, 59309 children: (0, import_i18n152.__)("Create") 59310 } 59311 ) 59312 ] 59313 } 59314 ) 59315 ] }) }); 59316 } 59317 var add_custom_generic_template_modal_content_default2 = AddCustomGenericTemplateModalContent2; 59318 59319 // packages/edit-site/build-module/components/add-new-template-legacy/index.mjs 59320 var import_jsx_runtime323 = __toESM(require_jsx_runtime(), 1); 59321 var { useHistory: useHistory24 } = unlock(import_router35.privateApis); 59322 var DEFAULT_TEMPLATE_SLUGS2 = [ 59323 "front-page", 59324 "home", 59325 "single", 59326 "page", 59327 "index", 59328 "archive", 59329 "author", 59330 "category", 59331 "date", 59332 "tag", 59333 "search", 59334 "404" 59335 ]; 59336 var TEMPLATE_ICONS2 = { 59337 "front-page": home_default, 59338 home: verse_default, 59339 single: pin_default, 59340 page: page_default, 59341 archive: archive_default, 59342 search: search_default, 59343 404: not_found_default, 59344 index: list_default, 59345 category: category_default, 59346 author: comment_author_avatar_default, 59347 taxonomy: block_meta_default, 59348 date: calendar_default, 59349 tag: tag_default, 59350 attachment: media_default 59351 }; 59352 function TemplateListItem2({ 59353 title, 59354 direction, 59355 className, 59356 description, 59357 icon, 59358 onClick, 59359 children 59360 }) { 59361 return /* @__PURE__ */ (0, import_jsx_runtime323.jsx)( 59362 import_components153.Button, 59363 { 59364 __next40pxDefaultSize: true, 59365 className, 59366 onClick, 59367 label: description, 59368 showTooltip: !!description, 59369 children: /* @__PURE__ */ (0, import_jsx_runtime323.jsxs)( 59370 import_components153.Flex, 59371 { 59372 as: "span", 59373 spacing: 2, 59374 align: "center", 59375 justify: "center", 59376 style: { width: "100%" }, 59377 direction, 59378 children: [ 59379 /* @__PURE__ */ (0, import_jsx_runtime323.jsx)("div", { className: "edit-site-add-new-template__template-icon", children: /* @__PURE__ */ (0, import_jsx_runtime323.jsx)(import_components153.Icon, { icon }) }), 59380 /* @__PURE__ */ (0, import_jsx_runtime323.jsxs)( 59381 import_components153.__experimentalVStack, 59382 { 59383 className: "edit-site-add-new-template__template-name", 59384 alignment: "center", 59385 spacing: 0, 59386 children: [ 59387 /* @__PURE__ */ (0, import_jsx_runtime323.jsx)( 59388 import_components153.__experimentalText, 59389 { 59390 align: "center", 59391 weight: "var(--wpds-typography-font-weight-emphasis, 600)", 59392 lineHeight: 1.53846153846, 59393 children: title 59394 } 59395 ), 59396 children 59397 ] 59398 } 59399 ) 59400 ] 59401 } 59402 ) 59403 } 59404 ); 59405 } 59406 var modalContentMap2 = { 59407 templatesList: 1, 59408 customTemplate: 2, 59409 customGenericTemplate: 3 59410 }; 59411 function NewTemplateModal2({ onClose }) { 59412 const [modalContent, setModalContent] = (0, import_element193.useState)( 59413 modalContentMap2.templatesList 59414 ); 59415 const [entityForSuggestions, setEntityForSuggestions] = (0, import_element193.useState)({}); 59416 const [isSubmitting, setIsSubmitting] = (0, import_element193.useState)(false); 59417 const missingTemplates = useMissingTemplates2( 59418 setEntityForSuggestions, 59419 () => setModalContent(modalContentMap2.customTemplate) 59420 ); 59421 const history = useHistory24(); 59422 const { saveEntityRecord } = (0, import_data82.useDispatch)(import_core_data61.store); 59423 const { createErrorNotice, createSuccessNotice } = (0, import_data82.useDispatch)(import_notices10.store); 59424 const containerRef = (0, import_element193.useRef)(null); 59425 const isMobile = (0, import_compose33.useViewportMatch)("medium", "<"); 59426 const homeUrl = (0, import_data82.useSelect)((select4) => { 59427 return select4(import_core_data61.store).getEntityRecord("root", "__unstableBase")?.home; 59428 }, []); 59429 const TEMPLATE_SHORT_DESCRIPTIONS = { 59430 "front-page": homeUrl, 59431 date: (0, import_i18n153.sprintf)( 59432 // translators: %s: The homepage url. 59433 (0, import_i18n153.__)("E.g. %s"), 59434 homeUrl + "/" + (/* @__PURE__ */ new Date()).getFullYear() 59435 ) 59436 }; 59437 (0, import_element193.useEffect)(() => { 59438 if (containerRef.current && modalContent === modalContentMap2.templatesList) { 59439 const [firstFocusable] = import_dom28.focus.focusable.find( 59440 containerRef.current 59441 ); 59442 firstFocusable?.focus(); 59443 } 59444 }, [modalContent]); 59445 async function createTemplate(template, isWPSuggestion = true) { 59446 if (isSubmitting) { 59447 return; 59448 } 59449 setIsSubmitting(true); 59450 try { 59451 const { title, description, slug } = template; 59452 const newTemplate = await saveEntityRecord( 59453 "postType", 59454 TEMPLATE_POST_TYPE, 59455 { 59456 description, 59457 // Slugs need to be strings, so this is for template `404` 59458 slug: slug.toString(), 59459 status: "publish", 59460 title, 59461 // This adds a post meta field in template that is part of `is_custom` value calculation. 59462 is_wp_suggestion: isWPSuggestion 59463 }, 59464 { throwOnError: true } 59465 ); 59466 history.navigate( 59467 `/$TEMPLATE_POST_TYPE}/$newTemplate.id}?canvas=edit` 59468 ); 59469 createSuccessNotice( 59470 (0, import_i18n153.sprintf)( 59471 // translators: %s: Title of the created post or template, e.g: "Hello world". 59472 (0, import_i18n153.__)('"%s" successfully created.'), 59473 (0, import_html_entities16.decodeEntities)(newTemplate.title?.rendered || title) || (0, import_i18n153.__)("(no title)") 59474 ), 59475 { 59476 type: "snackbar" 59477 } 59478 ); 59479 } catch (error2) { 59480 const errorMessage = error2.message && error2.code !== "unknown_error" ? error2.message : (0, import_i18n153.__)("An error occurred while creating the template."); 59481 createErrorNotice(errorMessage, { 59482 type: "snackbar" 59483 }); 59484 } finally { 59485 setIsSubmitting(false); 59486 } 59487 } 59488 const onModalClose = () => { 59489 onClose(); 59490 setModalContent(modalContentMap2.templatesList); 59491 }; 59492 let modalTitle = (0, import_i18n153.__)("Add template"); 59493 if (modalContent === modalContentMap2.customTemplate) { 59494 modalTitle = (0, import_i18n153.sprintf)( 59495 // translators: %s: Name of the post type e.g: "Post". 59496 (0, import_i18n153.__)("Add template: %s"), 59497 entityForSuggestions.labels.singular_name 59498 ); 59499 } else if (modalContent === modalContentMap2.customGenericTemplate) { 59500 modalTitle = (0, import_i18n153.__)("Create custom template"); 59501 } 59502 return /* @__PURE__ */ (0, import_jsx_runtime323.jsxs)( 59503 import_components153.Modal, 59504 { 59505 title: modalTitle, 59506 className: clsx_default("edit-site-add-new-template__modal", { 59507 "edit-site-add-new-template__modal_template_list": modalContent === modalContentMap2.templatesList, 59508 "edit-site-custom-template-modal": modalContent === modalContentMap2.customTemplate 59509 }), 59510 onRequestClose: onModalClose, 59511 overlayClassName: modalContent === modalContentMap2.customGenericTemplate ? "edit-site-custom-generic-template__modal" : void 0, 59512 ref: containerRef, 59513 children: [ 59514 modalContent === modalContentMap2.templatesList && /* @__PURE__ */ (0, import_jsx_runtime323.jsxs)( 59515 import_components153.__experimentalGrid, 59516 { 59517 columns: isMobile ? 2 : 3, 59518 gap: 4, 59519 align: "flex-start", 59520 justify: "center", 59521 className: "edit-site-add-new-template__template-list__contents", 59522 children: [ 59523 /* @__PURE__ */ (0, import_jsx_runtime323.jsx)(import_components153.Flex, { className: "edit-site-add-new-template__template-list__prompt", children: (0, import_i18n153.__)( 59524 "Select what the new template should apply to:" 59525 ) }), 59526 missingTemplates.map((template) => { 59527 const { title, slug, onClick } = template; 59528 return /* @__PURE__ */ (0, import_jsx_runtime323.jsx)( 59529 TemplateListItem2, 59530 { 59531 title, 59532 direction: "column", 59533 className: "edit-site-add-new-template__template-button", 59534 description: TEMPLATE_SHORT_DESCRIPTIONS[slug], 59535 icon: TEMPLATE_ICONS2[slug] || layout_default, 59536 onClick: () => onClick ? onClick(template) : createTemplate(template) 59537 }, 59538 slug 59539 ); 59540 }), 59541 /* @__PURE__ */ (0, import_jsx_runtime323.jsx)( 59542 TemplateListItem2, 59543 { 59544 title: (0, import_i18n153.__)("Custom template"), 59545 direction: "row", 59546 className: "edit-site-add-new-template__custom-template-button", 59547 icon: pencil_default, 59548 onClick: () => setModalContent( 59549 modalContentMap2.customGenericTemplate 59550 ), 59551 children: /* @__PURE__ */ (0, import_jsx_runtime323.jsx)( 59552 import_components153.__experimentalText, 59553 { 59554 lineHeight: 1.53846153846, 59555 children: (0, import_i18n153.__)( 59556 "A custom template can be manually applied to any post or page." 59557 ) 59558 } 59559 ) 59560 } 59561 ) 59562 ] 59563 } 59564 ), 59565 modalContent === modalContentMap2.customTemplate && /* @__PURE__ */ (0, import_jsx_runtime323.jsx)( 59566 add_custom_template_modal_content_default2, 59567 { 59568 onSelect: createTemplate, 59569 entityForSuggestions, 59570 onBack: () => setModalContent(modalContentMap2.templatesList), 59571 containerRef 59572 } 59573 ), 59574 modalContent === modalContentMap2.customGenericTemplate && /* @__PURE__ */ (0, import_jsx_runtime323.jsx)( 59575 add_custom_generic_template_modal_content_default2, 59576 { 59577 createTemplate, 59578 onBack: () => setModalContent(modalContentMap2.templatesList) 59579 } 59580 ) 59581 ] 59582 } 59583 ); 59584 } 59585 function NewTemplate2() { 59586 const [showModal, setShowModal] = (0, import_element193.useState)(false); 59587 const { postType: postType2 } = (0, import_data82.useSelect)((select4) => { 59588 const { getPostType: getPostType2 } = select4(import_core_data61.store); 59589 return { 59590 postType: getPostType2(TEMPLATE_POST_TYPE) 59591 }; 59592 }, []); 59593 if (!postType2) { 59594 return null; 59595 } 59596 return /* @__PURE__ */ (0, import_jsx_runtime323.jsxs)(import_jsx_runtime323.Fragment, { children: [ 59597 /* @__PURE__ */ (0, import_jsx_runtime323.jsx)( 59598 import_components153.Button, 59599 { 59600 variant: "primary", 59601 onClick: () => setShowModal(true), 59602 label: postType2.labels.add_new_item, 59603 size: "compact", 59604 __next40pxDefaultSize: true, 59605 children: postType2.labels.add_new_item 59606 } 59607 ), 59608 showModal && /* @__PURE__ */ (0, import_jsx_runtime323.jsx)(NewTemplateModal2, { onClose: () => setShowModal(false) }) 59609 ] }); 59610 } 59611 function useMissingTemplates2(setEntityForSuggestions, onClick) { 59612 const existingTemplates = useExistingTemplates2(); 59613 const defaultTemplateTypes = useDefaultTemplateTypes2(); 59614 const existingTemplateSlugs = (existingTemplates || []).map( 59615 ({ slug }) => slug 59616 ); 59617 const missingDefaultTemplates = (defaultTemplateTypes || []).filter( 59618 (template) => DEFAULT_TEMPLATE_SLUGS2.includes(template.slug) && !existingTemplateSlugs.includes(template.slug) 59619 ); 59620 const onClickMenuItem = (_entityForSuggestions) => { 59621 onClick?.(); 59622 setEntityForSuggestions(_entityForSuggestions); 59623 }; 59624 const enhancedMissingDefaultTemplateTypes = [...missingDefaultTemplates]; 59625 const { defaultTaxonomiesMenuItems, taxonomiesMenuItems } = useTaxonomiesMenuItems2(onClickMenuItem); 59626 const { defaultPostTypesMenuItems, postTypesMenuItems } = usePostTypeMenuItems2(onClickMenuItem); 59627 const authorMenuItem = useAuthorMenuItem2(onClickMenuItem); 59628 [ 59629 ...defaultTaxonomiesMenuItems, 59630 ...defaultPostTypesMenuItems, 59631 authorMenuItem 59632 ].forEach((menuItem) => { 59633 if (!menuItem) { 59634 return; 59635 } 59636 const matchIndex = enhancedMissingDefaultTemplateTypes.findIndex( 59637 (template) => template.slug === menuItem.slug 59638 ); 59639 if (matchIndex > -1) { 59640 enhancedMissingDefaultTemplateTypes[matchIndex] = menuItem; 59641 } else { 59642 enhancedMissingDefaultTemplateTypes.push(menuItem); 59643 } 59644 }); 59645 enhancedMissingDefaultTemplateTypes?.sort((template1, template2) => { 59646 return DEFAULT_TEMPLATE_SLUGS2.indexOf(template1.slug) - DEFAULT_TEMPLATE_SLUGS2.indexOf(template2.slug); 59647 }); 59648 const missingTemplates = [ 59649 ...enhancedMissingDefaultTemplateTypes, 59650 ...usePostTypeArchiveMenuItems2(), 59651 ...postTypesMenuItems, 59652 ...taxonomiesMenuItems 59653 ]; 59654 return missingTemplates; 59655 } 59656 var add_new_template_legacy_default = (0, import_element193.memo)(NewTemplate2); 59657 59658 // packages/edit-site/build-module/components/page-templates/index-legacy.mjs 59659 var import_jsx_runtime324 = __toESM(require_jsx_runtime(), 1); 59660 var { usePostActions: usePostActions3, usePostFields: usePostFields3 } = unlock(import_editor38.privateApis); 59661 var { useHistory: useHistory25, useLocation: useLocation31 } = unlock(import_router36.privateApis); 59662 var { useEntityRecordsWithPermissions: useEntityRecordsWithPermissions3 } = unlock(import_core_data62.privateApis); 59663 var VIEW_CONFIG_FIELDS4 = ["default_view", "default_layouts", "view_list"]; 59664 function PageTemplates2() { 59665 const { path, query } = useLocation31(); 59666 const { activeView = "all", postId } = query; 59667 const [selection, setSelection] = (0, import_element194.useState)([postId]); 59668 const { 59669 default_view: defaultView, 59670 default_layouts: defaultLayouts2, 59671 view_list: viewList 59672 } = useViewConfig({ 59673 kind: "postType", 59674 name: TEMPLATE_POST_TYPE, 59675 fields: VIEW_CONFIG_FIELDS4 59676 }); 59677 const activeViewOverrides = (0, import_element194.useMemo)( 59678 () => viewList?.find((v2) => v2.slug === activeView)?.view ?? {}, 59679 [viewList, activeView] 59680 ); 59681 const { view, updateView, isModified, resetToDefault } = useView({ 59682 kind: "postType", 59683 name: TEMPLATE_POST_TYPE, 59684 slug: "default", 59685 defaultView, 59686 activeViewOverrides, 59687 defaultLayouts: defaultLayouts2, 59688 queryParams: { 59689 page: query.pageNumber, 59690 search: query.search 59691 }, 59692 onChangeQueryParams: (newQueryParams) => { 59693 history.navigate( 59694 (0, import_url25.addQueryArgs)(path, { 59695 ...query, 59696 pageNumber: newQueryParams.page, 59697 search: newQueryParams.search || void 0 59698 }) 59699 ); 59700 } 59701 }); 59702 const { records, isResolving: isLoadingData } = useEntityRecordsWithPermissions3("postType", TEMPLATE_POST_TYPE, { 59703 per_page: -1 59704 }); 59705 const history = useHistory25(); 59706 const onChangeSelection = (0, import_element194.useCallback)( 59707 (items) => { 59708 setSelection(items); 59709 if (view?.type === "list") { 59710 history.navigate( 59711 (0, import_url25.addQueryArgs)(path, { 59712 postId: items.length === 1 ? items[0] : void 0 59713 }) 59714 ); 59715 } 59716 }, 59717 [history, path, view?.type] 59718 ); 59719 const postFields = usePostFields3({ postType: TEMPLATE_POST_TYPE }); 59720 const fields2 = (0, import_element194.useMemo)(() => { 59721 return [previewField2, ...postFields || []]; 59722 }, [postFields]); 59723 const { data, paginationInfo } = (0, import_element194.useMemo)(() => { 59724 return filterSortAndPaginate(records, view, fields2); 59725 }, [records, view, fields2]); 59726 const postTypeActions = usePostActions3({ 59727 postType: TEMPLATE_POST_TYPE, 59728 context: "list" 59729 }); 59730 const editAction = useEditPostAction(); 59731 const actions = (0, import_element194.useMemo)( 59732 () => [editAction, ...postTypeActions], 59733 [postTypeActions, editAction] 59734 ); 59735 const onChangeView = (0, import_compose34.useEvent)((newView) => { 59736 updateView(newView); 59737 if (newView.type !== view.type) { 59738 history.invalidate(); 59739 } 59740 }); 59741 return /* @__PURE__ */ (0, import_jsx_runtime324.jsx)( 59742 page_default2, 59743 { 59744 className: "edit-site-page-templates", 59745 title: (0, import_i18n154.__)("Templates"), 59746 headingLevel: 2, 59747 actions: /* @__PURE__ */ (0, import_jsx_runtime324.jsx)(add_new_template_legacy_default, {}), 59748 children: /* @__PURE__ */ (0, import_jsx_runtime324.jsx)( 59749 dataviews_default, 59750 { 59751 paginationInfo, 59752 fields: fields2, 59753 actions, 59754 data, 59755 isLoading: isLoadingData, 59756 view, 59757 onChangeView, 59758 onChangeSelection, 59759 isItemClickable: () => true, 59760 onClickItem: ({ id }) => { 59761 history.navigate(`/wp_template/$id}?canvas=edit`); 59762 }, 59763 selection, 59764 defaultLayouts: defaultLayouts2, 59765 onReset: isModified ? () => { 59766 resetToDefault(); 59767 history.invalidate(); 59768 } : false 59769 }, 59770 activeView 59771 ) 59772 } 59773 ); 59774 } 59775 59776 // packages/edit-site/build-module/components/site-editor-routes/templates.mjs 59777 var import_jsx_runtime325 = __toESM(require_jsx_runtime(), 1); 59778 async function isTemplateListView(query) { 59779 const { activeView = "active" } = query; 59780 const config2 = await unlock((0, import_data83.resolveSelect)(import_core_data63.store)).getViewConfig( 59781 "postType", 59782 "wp_template" 59783 ); 59784 const defaultView = config2?.default_view; 59785 const activeViewOverrides = config2?.view_list?.find((v2) => v2.slug === activeView)?.view ?? {}; 59786 const view = await loadView({ 59787 kind: "postType", 59788 name: "wp_template", 59789 slug: "default", 59790 defaultView, 59791 activeViewOverrides 59792 }); 59793 return view.type === "list"; 59794 } 59795 var templatesRoute = { 59796 name: "templates", 59797 path: "/template", 59798 areas: { 59799 sidebar({ siteData }) { 59800 if (!isThemeDataLoaded(siteData)) { 59801 return null; 59802 } 59803 return siteData.currentTheme.is_block_theme ? /* @__PURE__ */ (0, import_jsx_runtime325.jsx)(SidebarNavigationScreenTemplatesBrowse, { backPath: "/" }) : /* @__PURE__ */ (0, import_jsx_runtime325.jsx)(SidebarNavigationScreenUnsupported, {}); 59804 }, 59805 content({ siteData }) { 59806 const isBlockTheme = siteData.currentTheme?.is_block_theme; 59807 if (!isBlockTheme) { 59808 return void 0; 59809 } 59810 return window?.__experimentalTemplateActivate ? /* @__PURE__ */ (0, import_jsx_runtime325.jsx)(PageTemplates, {}) : /* @__PURE__ */ (0, import_jsx_runtime325.jsx)(PageTemplates2, {}); 59811 }, 59812 async preview({ query, siteData }) { 59813 const isBlockTheme = siteData.currentTheme?.is_block_theme; 59814 if (!isBlockTheme) { 59815 return void 0; 59816 } 59817 const isListView2 = await isTemplateListView(query); 59818 return isListView2 ? /* @__PURE__ */ (0, import_jsx_runtime325.jsx)(EditSiteEditor, {}) : void 0; 59819 }, 59820 mobileSidebar({ siteData }) { 59821 if (!isThemeDataLoaded(siteData)) { 59822 return /* @__PURE__ */ (0, import_jsx_runtime325.jsx)(import_jsx_runtime325.Fragment, {}); 59823 } 59824 if (!siteData.currentTheme.is_block_theme) { 59825 return /* @__PURE__ */ (0, import_jsx_runtime325.jsx)(SidebarNavigationScreenUnsupported, {}); 59826 } 59827 return void 0; 59828 }, 59829 mobileContent({ siteData }) { 59830 const isBlockTheme = siteData.currentTheme?.is_block_theme; 59831 if (!isBlockTheme) { 59832 return void 0; 59833 } 59834 const isTemplateActivateEnabled = typeof window !== "undefined" && window.__experimentalTemplateActivate; 59835 return isTemplateActivateEnabled ? /* @__PURE__ */ (0, import_jsx_runtime325.jsx)(PageTemplates, {}) : /* @__PURE__ */ (0, import_jsx_runtime325.jsx)(PageTemplates2, {}); 59836 } 59837 }, 59838 widths: { 59839 async content({ query }) { 59840 const isListView2 = await isTemplateListView(query); 59841 return isListView2 ? 380 : void 0; 59842 } 59843 } 59844 }; 59845 59846 // packages/edit-site/build-module/components/site-editor-routes/template-item.mjs 59847 var import_jsx_runtime326 = __toESM(require_jsx_runtime(), 1); 59848 var areas = { 59849 sidebar({ siteData }) { 59850 if (!isThemeDataLoaded(siteData)) { 59851 return null; 59852 } 59853 return siteData.currentTheme.is_block_theme ? /* @__PURE__ */ (0, import_jsx_runtime326.jsx)(SidebarNavigationScreenTemplatesBrowse, { backPath: "/" }) : /* @__PURE__ */ (0, import_jsx_runtime326.jsx)(SidebarNavigationScreenUnsupported, {}); 59854 }, 59855 // Also rendered on mobile, where this route is only reached at canvas=edit. 59856 preview({ siteData }) { 59857 if (!isThemeDataLoaded(siteData)) { 59858 return null; 59859 } 59860 return siteData.currentTheme.is_block_theme ? /* @__PURE__ */ (0, import_jsx_runtime326.jsx)(EditSiteEditor, {}) : /* @__PURE__ */ (0, import_jsx_runtime326.jsx)(SidebarNavigationScreenUnsupported, {}); 59861 } 59862 }; 59863 var templateItemRoute = { 59864 name: "template-item", 59865 path: "/wp_template/*postId", 59866 areas 59867 }; 59868 59869 // packages/edit-site/build-module/components/site-editor-routes/pages.mjs 59870 var import_i18n157 = __toESM(require_i18n(), 1); 59871 var import_data87 = __toESM(require_data(), 1); 59872 var import_core_data68 = __toESM(require_core_data(), 1); 59873 59874 // packages/edit-site/build-module/components/post-list/index.mjs 59875 var import_components156 = __toESM(require_components(), 1); 59876 var import_core_data67 = __toESM(require_core_data(), 1); 59877 var import_element198 = __toESM(require_element(), 1); 59878 var import_router37 = __toESM(require_router(), 1); 59879 var import_data86 = __toESM(require_data(), 1); 59880 var import_editor42 = __toESM(require_editor(), 1); 59881 var import_compose35 = __toESM(require_compose(), 1); 59882 var import_url26 = __toESM(require_url(), 1); 59883 59884 // packages/edit-site/build-module/components/add-new-post/index.mjs 59885 var import_components154 = __toESM(require_components(), 1); 59886 var import_i18n155 = __toESM(require_i18n(), 1); 59887 var import_data84 = __toESM(require_data(), 1); 59888 var import_element195 = __toESM(require_element(), 1); 59889 var import_core_data64 = __toESM(require_core_data(), 1); 59890 var import_notices11 = __toESM(require_notices(), 1); 59891 var import_html_entities17 = __toESM(require_html_entities(), 1); 59892 var import_blocks14 = __toESM(require_blocks(), 1); 59893 var import_jsx_runtime327 = __toESM(require_jsx_runtime(), 1); 59894 function AddNewPostModal({ postType: postType2, onSave, onClose }) { 59895 const labels = (0, import_data84.useSelect)( 59896 (select4) => select4(import_core_data64.store).getPostType(postType2)?.labels, 59897 [postType2] 59898 ); 59899 const [isCreatingPost, setIsCreatingPost] = (0, import_element195.useState)(false); 59900 const [title, setTitle] = (0, import_element195.useState)(""); 59901 const { saveEntityRecord } = (0, import_data84.useDispatch)(import_core_data64.store); 59902 const { createErrorNotice, createSuccessNotice } = (0, import_data84.useDispatch)(import_notices11.store); 59903 const { resolveSelect: resolveSelect4 } = (0, import_data84.useRegistry)(); 59904 async function createPost(event) { 59905 event.preventDefault(); 59906 if (isCreatingPost) { 59907 return; 59908 } 59909 setIsCreatingPost(true); 59910 try { 59911 const postTypeObject = await resolveSelect4(import_core_data64.store).getPostType(postType2); 59912 const newPage = await saveEntityRecord( 59913 "postType", 59914 postType2, 59915 { 59916 status: "draft", 59917 title, 59918 slug: title ?? void 0, 59919 content: !!postTypeObject.template && postTypeObject.template.length ? (0, import_blocks14.serialize)( 59920 (0, import_blocks14.synchronizeBlocksWithTemplate)( 59921 [], 59922 postTypeObject.template 59923 ) 59924 ) : void 0 59925 }, 59926 { throwOnError: true } 59927 ); 59928 onSave(newPage); 59929 createSuccessNotice( 59930 (0, import_i18n155.sprintf)( 59931 // translators: %s: Title of the created post or template, e.g: "Hello world". 59932 (0, import_i18n155.__)('"%s" successfully created.'), 59933 (0, import_html_entities17.decodeEntities)(newPage.title?.rendered || title) || (0, import_i18n155.__)("(no title)") 59934 ), 59935 { type: "snackbar" } 59936 ); 59937 } catch (error2) { 59938 const errorMessage = error2.message && error2.code !== "unknown_error" ? error2.message : (0, import_i18n155.__)("An error occurred while creating the item."); 59939 createErrorNotice(errorMessage, { 59940 type: "snackbar" 59941 }); 59942 } finally { 59943 setIsCreatingPost(false); 59944 } 59945 } 59946 return /* @__PURE__ */ (0, import_jsx_runtime327.jsx)( 59947 import_components154.Modal, 59948 { 59949 title: ( 59950 // translators: %s: post type singular_name label e.g: "Page". 59951 (0, import_i18n155.sprintf)((0, import_i18n155.__)("Draft new: %s"), labels?.singular_name) 59952 ), 59953 onRequestClose: onClose, 59954 focusOnMount: "firstContentElement", 59955 size: "small", 59956 children: /* @__PURE__ */ (0, import_jsx_runtime327.jsx)("form", { onSubmit: createPost, children: /* @__PURE__ */ (0, import_jsx_runtime327.jsxs)(import_components154.__experimentalVStack, { spacing: 4, children: [ 59957 /* @__PURE__ */ (0, import_jsx_runtime327.jsx)( 59958 import_components154.TextControl, 59959 { 59960 label: (0, import_i18n155.__)("Title"), 59961 onChange: setTitle, 59962 placeholder: (0, import_i18n155.__)("No title"), 59963 value: title 59964 } 59965 ), 59966 /* @__PURE__ */ (0, import_jsx_runtime327.jsxs)(import_components154.__experimentalHStack, { spacing: 2, justify: "end", children: [ 59967 /* @__PURE__ */ (0, import_jsx_runtime327.jsx)( 59968 import_components154.Button, 59969 { 59970 __next40pxDefaultSize: true, 59971 variant: "tertiary", 59972 onClick: onClose, 59973 children: (0, import_i18n155.__)("Cancel") 59974 } 59975 ), 59976 /* @__PURE__ */ (0, import_jsx_runtime327.jsx)( 59977 import_components154.Button, 59978 { 59979 __next40pxDefaultSize: true, 59980 variant: "primary", 59981 type: "submit", 59982 isBusy: isCreatingPost, 59983 "aria-disabled": isCreatingPost, 59984 children: (0, import_i18n155.__)("Create draft") 59985 } 59986 ) 59987 ] }) 59988 ] }) }) 59989 } 59990 ); 59991 } 59992 59993 // packages/edit-site/build-module/components/post-list/use-notes-count.mjs 59994 var import_element196 = __toESM(require_element(), 1); 59995 var import_core_data65 = __toESM(require_core_data(), 1); 59996 function useNotesCount(postIds) { 59997 const { records: notes, isResolving } = (0, import_core_data65.useEntityRecords)( 59998 "root", 59999 "comment", 60000 { 60001 post: postIds, 60002 type: "note", 60003 status: "all", 60004 per_page: -1, 60005 _fields: "id,post" 60006 }, 60007 { 60008 enabled: postIds?.length > 0 60009 } 60010 ); 60011 const notesCount = (0, import_element196.useMemo)(() => { 60012 if (!notes || notes.length === 0) { 60013 return {}; 60014 } 60015 const counts = {}; 60016 notes.forEach((note) => { 60017 const postId = note.post; 60018 counts[postId] = (counts[postId] || 0) + 1; 60019 }); 60020 return counts; 60021 }, [notes]); 60022 return { notesCount, isResolving }; 60023 } 60024 60025 // packages/edit-site/build-module/components/post-list/quick-edit-modal.mjs 60026 var import_i18n156 = __toESM(require_i18n(), 1); 60027 var import_data85 = __toESM(require_data(), 1); 60028 var import_core_data66 = __toESM(require_core_data(), 1); 60029 var import_components155 = __toESM(require_components(), 1); 60030 var import_element197 = __toESM(require_element(), 1); 60031 var import_editor41 = __toESM(require_editor(), 1); 60032 var import_jsx_runtime328 = __toESM(require_jsx_runtime(), 1); 60033 var { usePostFields: usePostFields4, PostCardPanel } = unlock(import_editor41.privateApis); 60034 var fieldsWithBulkEditSupport = ["status", "date", "author", "discussion"]; 60035 function QuickEditModal({ 60036 postType: postType2, 60037 postId, 60038 closeModal, 60039 quickEditForm 60040 }) { 60041 const isBulk = postId.length > 1; 60042 const [localEdits, setLocalEdits] = (0, import_element197.useState)({}); 60043 const { record, hasFinishedResolution, canSwitchTemplate } = (0, import_data85.useSelect)( 60044 (select4) => { 60045 const { 60046 getEditedEntityRecord, 60047 hasFinishedResolution: hasFinished 60048 } = select4(import_core_data66.store); 60049 if (isBulk) { 60050 return { 60051 record: null, 60052 hasFinishedResolution: true 60053 }; 60054 } 60055 const args = ["postType", postType2, postId[0]]; 60056 const { getHomePage, getPostsPageId } = unlock( 60057 select4(import_core_data66.store) 60058 ); 60059 const singlePostId = String(postId[0]); 60060 const isPostsPage = singlePostId !== void 0 && getPostsPageId() === singlePostId; 60061 const isFrontPage = singlePostId !== void 0 && postType2 === "page" && getHomePage()?.postId === singlePostId; 60062 return { 60063 record: getEditedEntityRecord(...args), 60064 hasFinishedResolution: hasFinished( 60065 "getEditedEntityRecord", 60066 args 60067 ), 60068 canSwitchTemplate: !isPostsPage && !isFrontPage 60069 }; 60070 }, 60071 [postType2, postId, isBulk] 60072 ); 60073 const { editEntityRecord, saveEditedEntityRecord } = (0, import_data85.useDispatch)(import_core_data66.store); 60074 const _fields = usePostFields4({ postType: postType2 }); 60075 const fields2 = (0, import_element197.useMemo)( 60076 () => _fields?.map((field) => { 60077 if (field.id === "status") { 60078 return { 60079 ...field, 60080 elements: field.elements.filter( 60081 (element) => element.value !== "trash" 60082 ) 60083 }; 60084 } 60085 if (field.id === "template") { 60086 return { 60087 ...field, 60088 readOnly: !canSwitchTemplate 60089 }; 60090 } 60091 return field; 60092 }), 60093 [_fields, canSwitchTemplate] 60094 ); 60095 const form2 = (0, import_element197.useMemo)(() => { 60096 if (!quickEditForm) { 60097 return { layout: { type: "panel" }, fields: [] }; 60098 } 60099 if (!isBulk) { 60100 return quickEditForm; 60101 } 60102 return { 60103 ...quickEditForm, 60104 fields: (quickEditForm.fields ?? []).filter( 60105 (field) => fieldsWithBulkEditSupport.includes( 60106 typeof field === "string" ? field : field.id 60107 ) 60108 ) 60109 }; 60110 }, [isBulk, quickEditForm]); 60111 const onChange = (edits) => { 60112 const currentData = { ...record, ...localEdits }; 60113 if (edits.status && edits.status !== "future" && currentData?.status === "future" && new Date(currentData.date) > /* @__PURE__ */ new Date()) { 60114 edits.date = null; 60115 } 60116 if (edits.status && edits.status === "private" && currentData?.password) { 60117 edits.password = ""; 60118 } 60119 setLocalEdits((prev) => ({ ...prev, ...edits })); 60120 }; 60121 (0, import_element197.useEffect)(() => { 60122 setLocalEdits({}); 60123 }, [postId]); 60124 const onSave = async () => { 60125 for (const id of postId) { 60126 editEntityRecord("postType", postType2, id, localEdits); 60127 } 60128 if (isBulk) { 60129 await Promise.allSettled( 60130 postId.map( 60131 (id) => saveEditedEntityRecord("postType", postType2, id) 60132 ) 60133 ); 60134 } else { 60135 await saveEditedEntityRecord("postType", postType2, postId[0]); 60136 } 60137 closeModal?.(); 60138 }; 60139 return /* @__PURE__ */ (0, import_jsx_runtime328.jsxs)( 60140 import_components155.Modal, 60141 { 60142 overlayClassName: "dataviews-action-modal__quick-edit", 60143 __experimentalHideHeader: true, 60144 onRequestClose: closeModal, 60145 focusOnMount: "firstElement", 60146 children: [ 60147 /* @__PURE__ */ (0, import_jsx_runtime328.jsx)("div", { className: "dataviews-action-modal__quick-edit-header", children: /* @__PURE__ */ (0, import_jsx_runtime328.jsx)( 60148 PostCardPanel, 60149 { 60150 postType: postType2, 60151 postId, 60152 hideActions: true 60153 } 60154 ) }), 60155 /* @__PURE__ */ (0, import_jsx_runtime328.jsx)("div", { className: "dataviews-action-modal__quick-edit-content", children: hasFinishedResolution && /* @__PURE__ */ (0, import_jsx_runtime328.jsx)( 60156 DataForm, 60157 { 60158 data: { ...record, ...localEdits }, 60159 fields: fields2, 60160 form: form2, 60161 onChange 60162 } 60163 ) }), 60164 /* @__PURE__ */ (0, import_jsx_runtime328.jsxs)(import_components155.__experimentalHStack, { className: "dataviews-action-modal__quick-edit-footer", children: [ 60165 /* @__PURE__ */ (0, import_jsx_runtime328.jsx)( 60166 import_components155.Button, 60167 { 60168 __next40pxDefaultSize: true, 60169 variant: "secondary", 60170 onClick: closeModal, 60171 children: (0, import_i18n156.__)("Cancel") 60172 } 60173 ), 60174 /* @__PURE__ */ (0, import_jsx_runtime328.jsx)( 60175 import_components155.Button, 60176 { 60177 __next40pxDefaultSize: true, 60178 variant: "primary", 60179 onClick: onSave, 60180 children: (0, import_i18n156.__)("Done") 60181 } 60182 ) 60183 ] }) 60184 ] 60185 } 60186 ); 60187 } 60188 60189 // packages/edit-site/build-module/components/post-list/index.mjs 60190 var import_jsx_runtime329 = __toESM(require_jsx_runtime(), 1); 60191 var { usePostActions: usePostActions4, usePostFields: usePostFields5 } = unlock(import_editor42.privateApis); 60192 var { useLocation: useLocation32, useHistory: useHistory26 } = unlock(import_router37.privateApis); 60193 var { useEntityRecordsWithPermissions: useEntityRecordsWithPermissions4 } = unlock(import_core_data67.privateApis); 60194 var EMPTY_ARRAY16 = []; 60195 var DEFAULT_STATUSES = "draft,future,pending,private,publish"; 60196 function getItemId(item) { 60197 return item.id.toString(); 60198 } 60199 function getItemLevel(item) { 60200 return item.level; 60201 } 60202 function PostList({ postType: postType2 }) { 60203 const { path, query } = useLocation32(); 60204 const { activeView = "all", postId, quickEdit = false } = query; 60205 const history = useHistory26(); 60206 const { 60207 default_view: defaultView, 60208 default_layouts: defaultLayouts2, 60209 view_list: viewList, 60210 form: quickEditForm 60211 } = useViewConfig({ 60212 kind: "postType", 60213 name: postType2 60214 }); 60215 const activeViewOverrides = (0, import_element198.useMemo)( 60216 () => viewList?.find((v2) => v2.slug === activeView)?.view ?? {}, 60217 [viewList, activeView] 60218 ); 60219 const { view, updateView, isModified, resetToDefault } = useView({ 60220 kind: "postType", 60221 name: postType2, 60222 slug: "default", 60223 defaultView, 60224 defaultLayouts: defaultLayouts2, 60225 activeViewOverrides, 60226 queryParams: { 60227 page: query.pageNumber, 60228 search: query.search 60229 }, 60230 onChangeQueryParams: (newQueryParams) => { 60231 history.navigate( 60232 (0, import_url26.addQueryArgs)(path, { 60233 ...query, 60234 pageNumber: newQueryParams.page, 60235 search: newQueryParams.search || void 0 60236 }) 60237 ); 60238 } 60239 }); 60240 const onChangeView = (0, import_compose35.useEvent)((newView) => { 60241 updateView(newView); 60242 if (newView.type !== view.type) { 60243 history.invalidate(); 60244 } 60245 }); 60246 const [selection, setSelection] = (0, import_element198.useState)(postId?.split(",") ?? []); 60247 const onChangeSelection = (0, import_element198.useCallback)( 60248 (items) => { 60249 setSelection(items); 60250 history.navigate( 60251 (0, import_url26.addQueryArgs)(path, { 60252 postId: items.join(",") 60253 }) 60254 ); 60255 }, 60256 [path, history] 60257 ); 60258 (0, import_element198.useEffect)(() => { 60259 const newSelection = postId?.split(",") ?? []; 60260 setSelection(newSelection); 60261 }, [postId]); 60262 const fields2 = usePostFields5({ 60263 postType: postType2 60264 }); 60265 const queryArgs = (0, import_element198.useMemo)(() => { 60266 const filters = {}; 60267 view.filters?.forEach((filter) => { 60268 if (filter.field === "status" && filter.operator === OPERATOR_IS_ANY) { 60269 filters.status = filter.value; 60270 } 60271 if (filter.field === "author" && filter.operator === OPERATOR_IS_ANY) { 60272 filters.author = filter.value; 60273 } else if (filter.field === "author" && filter.operator === OPERATOR_IS_NONE) { 60274 filters.author_exclude = filter.value; 60275 } 60276 if (filter.field === "date") { 60277 if (!filter.value) { 60278 return; 60279 } 60280 if (filter.operator === OPERATOR_BEFORE) { 60281 filters.before = filter.value; 60282 } else if (filter.operator === OPERATOR_AFTER) { 60283 filters.after = filter.value; 60284 } 60285 } 60286 }); 60287 if (!filters.status || filters.status === "") { 60288 filters.status = DEFAULT_STATUSES; 60289 } 60290 return { 60291 per_page: view.perPage, 60292 page: view.page, 60293 _embed: "author,wp:featuredmedia", 60294 order: view.sort?.direction, 60295 orderby: view.sort?.field, 60296 orderby_hierarchy: !!view.showLevels, 60297 search: view.search, 60298 ...filters 60299 }; 60300 }, [view]); 60301 const { 60302 records, 60303 isResolving: isLoadingData, 60304 totalItems, 60305 totalPages, 60306 hasResolved 60307 } = useEntityRecordsWithPermissions4("postType", postType2, queryArgs); 60308 const postIds = (0, import_element198.useMemo)( 60309 () => records?.map((record) => record.id) ?? [], 60310 [records] 60311 ); 60312 const { notesCount, isLoading: isLoadingNotesCount } = useNotesCount(postIds); 60313 const data = (0, import_element198.useMemo)(() => { 60314 let processedRecords = records; 60315 if (view?.sort?.field === "author") { 60316 processedRecords = filterSortAndPaginate( 60317 records, 60318 { sort: { ...view.sort } }, 60319 fields2 60320 ).data; 60321 } 60322 if (processedRecords) { 60323 return processedRecords.map((record) => ({ 60324 ...record, 60325 notesCount: notesCount[record.id] ?? 0 60326 })); 60327 } 60328 return processedRecords; 60329 }, [records, fields2, view?.sort, notesCount]); 60330 const ids = data?.map((record) => getItemId(record)) ?? []; 60331 const prevIds = (0, import_compose35.usePrevious)(ids) ?? []; 60332 const deletedIds = prevIds.filter((id) => !ids.includes(id)); 60333 const postIdWasDeleted = deletedIds.includes(postId); 60334 (0, import_element198.useEffect)(() => { 60335 if (postIdWasDeleted) { 60336 history.navigate( 60337 (0, import_url26.addQueryArgs)(path, { 60338 postId: void 0 60339 }) 60340 ); 60341 } 60342 }, [history, postIdWasDeleted, path]); 60343 const paginationInfo = (0, import_element198.useMemo)( 60344 () => ({ 60345 totalItems, 60346 totalPages 60347 }), 60348 [totalItems, totalPages] 60349 ); 60350 const { labels, canCreateRecord } = (0, import_data86.useSelect)( 60351 (select4) => { 60352 const { getPostType: getPostType2, canUser } = select4(import_core_data67.store); 60353 return { 60354 labels: getPostType2(postType2)?.labels, 60355 canCreateRecord: canUser("create", { 60356 kind: "postType", 60357 name: postType2 60358 }) 60359 }; 60360 }, 60361 [postType2] 60362 ); 60363 const postTypeActions = usePostActions4({ 60364 postType: postType2, 60365 context: "list" 60366 }); 60367 const editAction = useEditPostAction(); 60368 const quickEditAction = useQuickEditPostAction(); 60369 const actions = (0, import_element198.useMemo)(() => { 60370 if (view.type === LAYOUT_LIST) { 60371 const editActionPrimary = { ...editAction, isPrimary: true }; 60372 return [editActionPrimary, ...postTypeActions]; 60373 } 60374 return [editAction, quickEditAction, ...postTypeActions]; 60375 }, [view.type, editAction, quickEditAction, postTypeActions]); 60376 const [showAddPostModal, setShowAddPostModal] = (0, import_element198.useState)(false); 60377 const openModal = () => setShowAddPostModal(true); 60378 const closeModal = () => setShowAddPostModal(false); 60379 const handleNewPage = ({ type, id }) => { 60380 history.navigate(`/$type}/$id}?canvas=edit`); 60381 closeModal(); 60382 }; 60383 const closeQuickEditModal = () => { 60384 history.navigate( 60385 (0, import_url26.addQueryArgs)(path, { 60386 ...query, 60387 quickEdit: void 0 60388 }) 60389 ); 60390 }; 60391 return /* @__PURE__ */ (0, import_jsx_runtime329.jsxs)( 60392 page_default2, 60393 { 60394 title: labels?.name, 60395 headingLevel: 2, 60396 actions: /* @__PURE__ */ (0, import_jsx_runtime329.jsx)(import_jsx_runtime329.Fragment, { children: labels?.add_new_item && canCreateRecord && /* @__PURE__ */ (0, import_jsx_runtime329.jsxs)(import_jsx_runtime329.Fragment, { children: [ 60397 /* @__PURE__ */ (0, import_jsx_runtime329.jsx)( 60398 import_components156.Button, 60399 { 60400 variant: "primary", 60401 onClick: openModal, 60402 size: "compact", 60403 __next40pxDefaultSize: true, 60404 children: labels.add_new_item 60405 } 60406 ), 60407 showAddPostModal && /* @__PURE__ */ (0, import_jsx_runtime329.jsx)( 60408 AddNewPostModal, 60409 { 60410 postType: postType2, 60411 onSave: handleNewPage, 60412 onClose: closeModal 60413 } 60414 ) 60415 ] }) }), 60416 children: [ 60417 /* @__PURE__ */ (0, import_jsx_runtime329.jsx)( 60418 dataviews_default, 60419 { 60420 paginationInfo, 60421 fields: fields2, 60422 actions, 60423 data: data || EMPTY_ARRAY16, 60424 isLoading: isLoadingData || isLoadingNotesCount || !hasResolved, 60425 view, 60426 onChangeView, 60427 selection, 60428 onChangeSelection, 60429 isItemClickable: (item) => item.status !== "trash", 60430 onClickItem: ({ id }) => { 60431 history.navigate(`/$postType2}/$id}?canvas=edit`); 60432 }, 60433 getItemId, 60434 getItemLevel, 60435 defaultLayouts: defaultLayouts2, 60436 onReset: isModified ? () => { 60437 resetToDefault(); 60438 history.invalidate(); 60439 } : false 60440 }, 60441 activeView 60442 ), 60443 quickEdit && !isLoadingData && selection.length > 0 && view.type !== LAYOUT_LIST && /* @__PURE__ */ (0, import_jsx_runtime329.jsx)( 60444 QuickEditModal, 60445 { 60446 postType: postType2, 60447 postId: selection, 60448 closeModal: closeQuickEditModal, 60449 quickEditForm 60450 } 60451 ) 60452 ] 60453 } 60454 ); 60455 } 60456 60457 // packages/edit-site/build-module/components/site-editor-routes/pages.mjs 60458 var import_jsx_runtime330 = __toESM(require_jsx_runtime(), 1); 60459 async function isListView(query) { 60460 const { activeView = "all" } = query; 60461 const config2 = await unlock((0, import_data87.resolveSelect)(import_core_data68.store)).getViewConfig( 60462 "postType", 60463 "page" 60464 ); 60465 const defaultView = config2?.default_view; 60466 const defaultLayouts2 = config2?.default_layouts; 60467 const viewEntry = config2?.view_list?.find((v2) => v2.slug === activeView); 60468 const view = await loadView({ 60469 kind: "postType", 60470 name: "page", 60471 slug: "default", 60472 defaultView, 60473 defaultLayouts: defaultLayouts2, 60474 activeViewOverrides: viewEntry?.view ?? {} 60475 }); 60476 return view.type === "list"; 60477 } 60478 var pagesRoute = { 60479 name: "pages", 60480 path: "/page", 60481 areas: { 60482 sidebar({ siteData }) { 60483 if (!isThemeDataLoaded(siteData)) { 60484 return null; 60485 } 60486 return siteData.currentTheme.is_block_theme ? /* @__PURE__ */ (0, import_jsx_runtime330.jsx)( 60487 SidebarNavigationScreen, 60488 { 60489 title: (0, import_i18n157.__)("Pages"), 60490 backPath: "/", 60491 content: /* @__PURE__ */ (0, import_jsx_runtime330.jsx)(DataViewsSidebarContent, { postType: "page" }) 60492 } 60493 ) : /* @__PURE__ */ (0, import_jsx_runtime330.jsx)(SidebarNavigationScreenUnsupported, {}); 60494 }, 60495 content({ siteData }) { 60496 const isBlockTheme = siteData.currentTheme?.is_block_theme; 60497 return isBlockTheme ? /* @__PURE__ */ (0, import_jsx_runtime330.jsx)(PostList, { postType: "page" }) : void 0; 60498 }, 60499 async preview({ query, siteData }) { 60500 const isBlockTheme = siteData.currentTheme?.is_block_theme; 60501 if (!isBlockTheme) { 60502 return void 0; 60503 } 60504 const isList = await isListView(query); 60505 return isList ? /* @__PURE__ */ (0, import_jsx_runtime330.jsx)(EditSiteEditor, {}) : void 0; 60506 }, 60507 mobileSidebar({ siteData }) { 60508 if (!isThemeDataLoaded(siteData)) { 60509 return /* @__PURE__ */ (0, import_jsx_runtime330.jsx)(import_jsx_runtime330.Fragment, {}); 60510 } 60511 return siteData.currentTheme.is_block_theme ? void 0 : /* @__PURE__ */ (0, import_jsx_runtime330.jsx)(SidebarNavigationScreenUnsupported, {}); 60512 }, 60513 mobileContent({ siteData }) { 60514 const isBlockTheme = siteData.currentTheme?.is_block_theme; 60515 return isBlockTheme ? /* @__PURE__ */ (0, import_jsx_runtime330.jsx)(PostList, { postType: "page" }) : void 0; 60516 } 60517 }, 60518 widths: { 60519 async content({ query }) { 60520 const isList = await isListView(query); 60521 return isList ? 380 : void 0; 60522 } 60523 } 60524 }; 60525 60526 // packages/edit-site/build-module/components/site-editor-routes/page-item.mjs 60527 var import_i18n158 = __toESM(require_i18n(), 1); 60528 var import_jsx_runtime331 = __toESM(require_jsx_runtime(), 1); 60529 var pageItemRoute = { 60530 name: "page-item", 60531 path: "/page/:postId", 60532 areas: { 60533 sidebar({ siteData }) { 60534 if (!isThemeDataLoaded(siteData)) { 60535 return null; 60536 } 60537 return siteData.currentTheme.is_block_theme ? /* @__PURE__ */ (0, import_jsx_runtime331.jsx)( 60538 SidebarNavigationScreen, 60539 { 60540 title: (0, import_i18n158.__)("Pages"), 60541 backPath: "/", 60542 content: /* @__PURE__ */ (0, import_jsx_runtime331.jsx)(DataViewsSidebarContent, { postType: "page" }) 60543 } 60544 ) : /* @__PURE__ */ (0, import_jsx_runtime331.jsx)(SidebarNavigationScreenUnsupported, {}); 60545 }, 60546 // Also rendered on mobile, where this route is only reached at canvas=edit. 60547 preview({ siteData }) { 60548 if (!isThemeDataLoaded(siteData)) { 60549 return null; 60550 } 60551 return siteData.currentTheme.is_block_theme ? /* @__PURE__ */ (0, import_jsx_runtime331.jsx)(EditSiteEditor, {}) : /* @__PURE__ */ (0, import_jsx_runtime331.jsx)(SidebarNavigationScreenUnsupported, {}); 60552 } 60553 } 60554 }; 60555 60556 // packages/edit-site/build-module/components/site-editor-routes/stylebook.mjs 60557 var import_i18n159 = __toESM(require_i18n(), 1); 60558 var import_editor45 = __toESM(require_editor(), 1); 60559 var import_jsx_runtime332 = __toESM(require_jsx_runtime(), 1); 60560 var { StyleBookPreview: StyleBookPreview2 } = unlock(import_editor45.privateApis); 60561 var stylebookRoute = { 60562 name: "stylebook", 60563 path: "/stylebook", 60564 areas: { 60565 sidebar({ siteData }) { 60566 if (!isThemeDataLoaded(siteData)) { 60567 return null; 60568 } 60569 return isClassicThemeWithStyleBookSupport(siteData) ? /* @__PURE__ */ (0, import_jsx_runtime332.jsx)( 60570 SidebarNavigationScreen, 60571 { 60572 title: (0, import_i18n159.__)("Styles"), 60573 backPath: "/", 60574 description: (0, import_i18n159.__)( 60575 `Preview your website's visual identity: colors, typography, and blocks.` 60576 ) 60577 } 60578 ) : /* @__PURE__ */ (0, import_jsx_runtime332.jsx)(SidebarNavigationScreenUnsupported, {}); 60579 }, 60580 preview({ siteData }) { 60581 return isClassicThemeWithStyleBookSupport(siteData) ? /* @__PURE__ */ (0, import_jsx_runtime332.jsx)( 60582 StyleBookPreview2, 60583 { 60584 isStatic: true, 60585 settings: siteData.editorSettings 60586 } 60587 ) : void 0; 60588 }, 60589 mobileContent({ siteData }) { 60590 return isClassicThemeWithStyleBookSupport(siteData) ? /* @__PURE__ */ (0, import_jsx_runtime332.jsx)( 60591 StyleBookPreview2, 60592 { 60593 isStatic: true, 60594 settings: siteData.editorSettings 60595 } 60596 ) : void 0; 60597 } 60598 } 60599 }; 60600 60601 // packages/edit-site/build-module/components/site-editor-routes/notfound.mjs 60602 var import_i18n160 = __toESM(require_i18n(), 1); 60603 var import_components157 = __toESM(require_components(), 1); 60604 var import_jsx_runtime333 = __toESM(require_jsx_runtime(), 1); 60605 function NotFoundError() { 60606 return /* @__PURE__ */ (0, import_jsx_runtime333.jsx)(import_components157.Notice, { status: "error", isDismissible: false, children: (0, import_i18n160.__)( 60607 "The requested page could not be found. Please check the URL." 60608 ) }); 60609 } 60610 var notFoundRoute = { 60611 name: "notfound", 60612 path: "*", 60613 areas: { 60614 sidebar: /* @__PURE__ */ (0, import_jsx_runtime333.jsx)(SidebarNavigationScreenMain, {}), 60615 mobileSidebar: /* @__PURE__ */ (0, import_jsx_runtime333.jsx)( 60616 SidebarNavigationScreenMain, 60617 { 60618 customDescription: /* @__PURE__ */ (0, import_jsx_runtime333.jsx)(NotFoundError, {}) 60619 } 60620 ), 60621 content: /* @__PURE__ */ (0, import_jsx_runtime333.jsx)(import_components157.__experimentalSpacer, { padding: 2, children: /* @__PURE__ */ (0, import_jsx_runtime333.jsx)(NotFoundError, {}) }) 60622 } 60623 }; 60624 60625 // packages/edit-site/build-module/components/site-editor-routes/index.mjs 60626 var routes2 = [ 60627 pageItemRoute, 60628 pagesRoute, 60629 templateItemRoute, 60630 templatesRoute, 60631 templatePartItemRoute, 60632 patternItemRoute, 60633 patternsRoute, 60634 navigationItemRoute, 60635 navigationRoute, 60636 identityRoute, 60637 stylesRoute, 60638 homeRoute, 60639 stylebookRoute, 60640 notFoundRoute 60641 ]; 60642 function useRegisterSiteEditorRoutes() { 60643 const registry = (0, import_data88.useRegistry)(); 60644 const { registerRoute: registerRoute2 } = unlock((0, import_data88.useDispatch)(store)); 60645 (0, import_element199.useEffect)(() => { 60646 registry.batch(() => { 60647 routes2.forEach(registerRoute2); 60648 }); 60649 }, [registry, registerRoute2]); 60650 } 60651 60652 // packages/edit-site/build-module/components/app/index.mjs 60653 var import_jsx_runtime334 = __toESM(require_jsx_runtime(), 1); 60654 var { RouterProvider } = unlock(import_router38.privateApis); 60655 function AppLayout() { 60656 useCommonCommands(); 60657 useSetCommandContext(); 60658 return /* @__PURE__ */ (0, import_jsx_runtime334.jsx)(LayoutWithGlobalStylesProvider, {}); 60659 } 60660 function App() { 60661 useRegisterSiteEditorRoutes(); 60662 const { routes: routes3, currentTheme, editorSettings } = (0, import_data89.useSelect)((select4) => { 60663 return { 60664 routes: unlock(select4(store)).getRoutes(), 60665 currentTheme: select4(import_core_data69.store).getCurrentTheme(), 60666 // This is a temp solution until the has_theme_json value is available for the current theme. 60667 editorSettings: select4(store).getSettings() 60668 }; 60669 }, []); 60670 const beforeNavigate = (0, import_element200.useCallback)(({ path, query }) => { 60671 if (!isPreviewingTheme()) { 60672 return { path, query }; 60673 } 60674 return { 60675 path, 60676 query: { 60677 ...query, 60678 wp_theme_preview: "wp_theme_preview" in query ? query.wp_theme_preview : currentlyPreviewingTheme() 60679 } 60680 }; 60681 }, []); 60682 const matchResolverArgsValue = (0, import_element200.useMemo)( 60683 () => ({ 60684 siteData: { currentTheme, editorSettings } 60685 }), 60686 [currentTheme, editorSettings] 60687 ); 60688 return /* @__PURE__ */ (0, import_jsx_runtime334.jsx)( 60689 RouterProvider, 60690 { 60691 routes: routes3, 60692 pathArg: "p", 60693 beforeNavigate, 60694 matchResolverArgs: matchResolverArgsValue, 60695 children: /* @__PURE__ */ (0, import_jsx_runtime334.jsx)(AppLayout, {}) 60696 } 60697 ); 60698 } 60699 60700 // packages/edit-site/build-module/deprecated.mjs 60701 var import_editor46 = __toESM(require_editor(), 1); 60702 var import_url27 = __toESM(require_url(), 1); 60703 var import_deprecated5 = __toESM(require_deprecated(), 1); 60704 var import_jsx_runtime335 = __toESM(require_jsx_runtime(), 1); 60705 var isSiteEditor = (0, import_url27.getPath)(window.location.href)?.includes( 60706 "site-editor.php" 60707 ); 60708 var deprecateSlot = (name2) => { 60709 (0, import_deprecated5.default)(`wp.editPost.$name2}`, { 60710 since: "6.6", 60711 alternative: `wp.editor.$name2}` 60712 }); 60713 }; 60714 function PluginMoreMenuItem(props) { 60715 if (!isSiteEditor) { 60716 return null; 60717 } 60718 deprecateSlot("PluginMoreMenuItem"); 60719 return /* @__PURE__ */ (0, import_jsx_runtime335.jsx)(import_editor46.PluginMoreMenuItem, { ...props }); 60720 } 60721 function PluginSidebar(props) { 60722 if (!isSiteEditor) { 60723 return null; 60724 } 60725 deprecateSlot("PluginSidebar"); 60726 return /* @__PURE__ */ (0, import_jsx_runtime335.jsx)(import_editor46.PluginSidebar, { ...props }); 60727 } 60728 function PluginSidebarMoreMenuItem(props) { 60729 if (!isSiteEditor) { 60730 return null; 60731 } 60732 deprecateSlot("PluginSidebarMoreMenuItem"); 60733 return /* @__PURE__ */ (0, import_jsx_runtime335.jsx)(import_editor46.PluginSidebarMoreMenuItem, { ...props }); 60734 } 60735 60736 // packages/edit-site/build-module/index.mjs 60737 var import_jsx_runtime336 = __toESM(require_jsx_runtime(), 1); 60738 var { registerCoreBlockBindingsSources } = unlock(import_editor47.privateApis); 60739 function initializeEditor(id, settings2) { 60740 const target = document.getElementById(id); 60741 const root = (0, import_element201.createRoot)(target); 60742 (0, import_data90.dispatch)(import_blocks15.store).reapplyBlockTypeFilters(); 60743 const coreBlocks = (0, import_block_library4.__experimentalGetCoreBlocks)().filter( 60744 ({ name: name2 }) => name2 !== "core/freeform" 60745 ); 60746 (0, import_block_library4.registerCoreBlocks)(coreBlocks); 60747 registerCoreBlockBindingsSources(); 60748 (0, import_data90.dispatch)(import_blocks15.store).setFreeformFallbackBlockName("core/html"); 60749 (0, import_widgets.registerLegacyWidgetBlock)({ inserter: false }); 60750 (0, import_widgets.registerWidgetGroupBlock)({ inserter: false }); 60751 if (false) { 60752 (0, import_block_library4.__experimentalRegisterExperimentalCoreBlocks)({ 60753 enableFSEBlocks: true 60754 }); 60755 } 60756 (0, import_data90.dispatch)(import_preferences13.store).setDefaults("core/edit-site", { 60757 welcomeGuide: true, 60758 welcomeGuideStyles: true, 60759 welcomeGuidePage: true, 60760 welcomeGuideTemplate: true 60761 }); 60762 (0, import_data90.dispatch)(import_preferences13.store).setDefaults("core", { 60763 allowRightClickOverrides: true, 60764 distractionFree: false, 60765 editorMode: "visual", 60766 editorTool: "edit", 60767 fixedToolbar: false, 60768 focusMode: false, 60769 inactivePanels: [], 60770 keepCaretInsideBlock: false, 60771 openPanels: ["post-status"], 60772 showBlockBreadcrumbs: true, 60773 showListViewByDefault: false, 60774 enableChoosePatternModal: true, 60775 showCollaborationCursor: false, 60776 showCollaborationJoinNotifications: true, 60777 showCollaborationLeaveNotifications: true, 60778 showCollaborationPostSaveNotifications: true 60779 }); 60780 if (window.__clientSideMediaProcessing) { 60781 (0, import_data90.dispatch)(import_preferences13.store).setDefaults("core/media", { 60782 requireApproval: true, 60783 optimizeOnUpload: true 60784 }); 60785 } 60786 (0, import_data90.dispatch)(store).updateSettings(settings2); 60787 window.addEventListener("dragover", (e2) => e2.preventDefault(), false); 60788 window.addEventListener("drop", (e2) => e2.preventDefault(), false); 60789 root.render( 60790 /* @__PURE__ */ (0, import_jsx_runtime336.jsx)(import_element201.StrictMode, { children: /* @__PURE__ */ (0, import_jsx_runtime336.jsx)(App, {}) }) 60791 ); 60792 return root; 60793 } 60794 function reinitializeEditor() { 60795 (0, import_deprecated6.default)("wp.editSite.reinitializeEditor", { 60796 since: "6.2", 60797 version: "6.3" 60798 }); 60799 } 60800 return __toCommonJS(index_exports); 60801 })(); 60802 /*! Bundled license information: 60803 60804 use-sync-external-store/cjs/use-sync-external-store-shim.development.js: 60805 (** 60806 * @license React 60807 * use-sync-external-store-shim.development.js 60808 * 60809 * Copyright (c) Meta Platforms, Inc. and affiliates. 60810 * 60811 * This source code is licensed under the MIT license found in the 60812 * LICENSE file in the root directory of this source tree. 60813 *) 60814 60815 use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js: 60816 (** 60817 * @license React 60818 * use-sync-external-store-shim/with-selector.development.js 60819 * 60820 * Copyright (c) Meta Platforms, Inc. and affiliates. 60821 * 60822 * This source code is licensed under the MIT license found in the 60823 * LICENSE file in the root directory of this source tree. 60824 *) 60825 60826 is-plain-object/dist/is-plain-object.mjs: 60827 (*! 60828 * is-plain-object <https://github.com/jonschlinkert/is-plain-object> 60829 * 60830 * Copyright (c) 2014-2017, Jon Schlinkert. 60831 * Released under the MIT License. 60832 *) 60833 */ 60834 (window.wp ||= {}).editSite = wp.editSite; 60835 })();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated : Sat Aug 8 08:20:21 2026 | Cross-referenced by PHPXref |