| [ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 "use strict"; 2 var wp; 3 (wp ||= {}).editor = (() => { 4 var __create = Object.create; 5 var __defProp = Object.defineProperty; 6 var __getOwnPropDesc = Object.getOwnPropertyDescriptor; 7 var __getOwnPropNames = Object.getOwnPropertyNames; 8 var __getProtoOf = Object.getPrototypeOf; 9 var __hasOwnProp = Object.prototype.hasOwnProperty; 10 var __require = /* @__PURE__ */ ((x2) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x2, { 11 get: (a3, b3) => (typeof require !== "undefined" ? require : a3)[b3] 12 }) : x2)(function(x2) { 13 if (typeof require !== "undefined") return require.apply(this, arguments); 14 throw Error('Dynamic require of "' + x2 + '" is not supported'); 15 }); 16 var __commonJS = (cb, mod) => function __require4() { 17 return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; 18 }; 19 var __export = (target, all) => { 20 for (var name2 in all) 21 __defProp(target, name2, { get: all[name2], enumerable: true }); 22 }; 23 var __copyProps = (to, from, except, desc) => { 24 if (from && typeof from === "object" || typeof from === "function") { 25 for (let key of __getOwnPropNames(from)) 26 if (!__hasOwnProp.call(to, key) && key !== except) 27 __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); 28 } 29 return to; 30 }; 31 var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( 32 // If the importer is in node compatibility mode or this is not an ESM 33 // file that has been converted to a CommonJS file using a Babel- 34 // compatible transform (i.e. "__esModule" has not been set), then set 35 // "default" to the CommonJS "module.exports" for node compatibility. 36 isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, 37 mod 38 )); 39 var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); 40 41 // package-external:@wordpress/data 42 var require_data = __commonJS({ 43 "package-external:@wordpress/data"(exports, module) { 44 module.exports = window.wp.data; 45 } 46 }); 47 48 // package-external:@wordpress/core-data 49 var require_core_data = __commonJS({ 50 "package-external:@wordpress/core-data"(exports, module) { 51 module.exports = window.wp.coreData; 52 } 53 }); 54 55 // package-external:@wordpress/element 56 var require_element = __commonJS({ 57 "package-external:@wordpress/element"(exports, module) { 58 module.exports = window.wp.element; 59 } 60 }); 61 62 // package-external:@wordpress/compose 63 var require_compose = __commonJS({ 64 "package-external:@wordpress/compose"(exports, module) { 65 module.exports = window.wp.compose; 66 } 67 }); 68 69 // package-external:@wordpress/hooks 70 var require_hooks = __commonJS({ 71 "package-external:@wordpress/hooks"(exports, module) { 72 module.exports = window.wp.hooks; 73 } 74 }); 75 76 // package-external:@wordpress/block-editor 77 var require_block_editor = __commonJS({ 78 "package-external:@wordpress/block-editor"(exports, module) { 79 module.exports = window.wp.blockEditor; 80 } 81 }); 82 83 // package-external:@wordpress/blocks 84 var require_blocks = __commonJS({ 85 "package-external:@wordpress/blocks"(exports, module) { 86 module.exports = window.wp.blocks; 87 } 88 }); 89 90 // package-external:@wordpress/date 91 var require_date = __commonJS({ 92 "package-external:@wordpress/date"(exports, module) { 93 module.exports = window.wp.date; 94 } 95 }); 96 97 // package-external:@wordpress/url 98 var require_url = __commonJS({ 99 "package-external:@wordpress/url"(exports, module) { 100 module.exports = window.wp.url; 101 } 102 }); 103 104 // package-external:@wordpress/deprecated 105 var require_deprecated = __commonJS({ 106 "package-external:@wordpress/deprecated"(exports, module) { 107 module.exports = window.wp.deprecated; 108 } 109 }); 110 111 // package-external:@wordpress/preferences 112 var require_preferences = __commonJS({ 113 "package-external:@wordpress/preferences"(exports, module) { 114 module.exports = window.wp.preferences; 115 } 116 }); 117 118 // package-external:@wordpress/primitives 119 var require_primitives = __commonJS({ 120 "package-external:@wordpress/primitives"(exports, module) { 121 module.exports = window.wp.primitives; 122 } 123 }); 124 125 // vendor-external:react/jsx-runtime 126 var require_jsx_runtime = __commonJS({ 127 "vendor-external:react/jsx-runtime"(exports, module) { 128 module.exports = window.ReactJSXRuntime; 129 } 130 }); 131 132 // package-external:@wordpress/private-apis 133 var require_private_apis = __commonJS({ 134 "package-external:@wordpress/private-apis"(exports, module) { 135 module.exports = window.wp.privateApis; 136 } 137 }); 138 139 // package-external:@wordpress/a11y 140 var require_a11y = __commonJS({ 141 "package-external:@wordpress/a11y"(exports, module) { 142 module.exports = window.wp.a11y; 143 } 144 }); 145 146 // package-external:@wordpress/api-fetch 147 var require_api_fetch = __commonJS({ 148 "package-external:@wordpress/api-fetch"(exports, module) { 149 module.exports = window.wp.apiFetch; 150 } 151 }); 152 153 // package-external:@wordpress/notices 154 var require_notices = __commonJS({ 155 "package-external:@wordpress/notices"(exports, module) { 156 module.exports = window.wp.notices; 157 } 158 }); 159 160 // package-external:@wordpress/i18n 161 var require_i18n = __commonJS({ 162 "package-external:@wordpress/i18n"(exports, module) { 163 module.exports = window.wp.i18n; 164 } 165 }); 166 167 // package-external:@wordpress/html-entities 168 var require_html_entities = __commonJS({ 169 "package-external:@wordpress/html-entities"(exports, module) { 170 module.exports = window.wp.htmlEntities; 171 } 172 }); 173 174 // package-external:@wordpress/components 175 var require_components = __commonJS({ 176 "package-external:@wordpress/components"(exports, module) { 177 module.exports = window.wp.components; 178 } 179 }); 180 181 // package-external:@wordpress/patterns 182 var require_patterns = __commonJS({ 183 "package-external:@wordpress/patterns"(exports, module) { 184 module.exports = window.wp.patterns; 185 } 186 }); 187 188 // package-external:@wordpress/media-utils 189 var require_media_utils = __commonJS({ 190 "package-external:@wordpress/media-utils"(exports, module) { 191 module.exports = window.wp.mediaUtils; 192 } 193 }); 194 195 // node_modules/remove-accents/index.js 196 var require_remove_accents = __commonJS({ 197 "node_modules/remove-accents/index.js"(exports, module) { 198 var characterMap = { 199 "\xC0": "A", 200 "\xC1": "A", 201 "\xC2": "A", 202 "\xC3": "A", 203 "\xC4": "A", 204 "\xC5": "A", 205 "\u1EA4": "A", 206 "\u1EAE": "A", 207 "\u1EB2": "A", 208 "\u1EB4": "A", 209 "\u1EB6": "A", 210 "\xC6": "AE", 211 "\u1EA6": "A", 212 "\u1EB0": "A", 213 "\u0202": "A", 214 "\u1EA2": "A", 215 "\u1EA0": "A", 216 "\u1EA8": "A", 217 "\u1EAA": "A", 218 "\u1EAC": "A", 219 "\xC7": "C", 220 "\u1E08": "C", 221 "\xC8": "E", 222 "\xC9": "E", 223 "\xCA": "E", 224 "\xCB": "E", 225 "\u1EBE": "E", 226 "\u1E16": "E", 227 "\u1EC0": "E", 228 "\u1E14": "E", 229 "\u1E1C": "E", 230 "\u0206": "E", 231 "\u1EBA": "E", 232 "\u1EBC": "E", 233 "\u1EB8": "E", 234 "\u1EC2": "E", 235 "\u1EC4": "E", 236 "\u1EC6": "E", 237 "\xCC": "I", 238 "\xCD": "I", 239 "\xCE": "I", 240 "\xCF": "I", 241 "\u1E2E": "I", 242 "\u020A": "I", 243 "\u1EC8": "I", 244 "\u1ECA": "I", 245 "\xD0": "D", 246 "\xD1": "N", 247 "\xD2": "O", 248 "\xD3": "O", 249 "\xD4": "O", 250 "\xD5": "O", 251 "\xD6": "O", 252 "\xD8": "O", 253 "\u1ED0": "O", 254 "\u1E4C": "O", 255 "\u1E52": "O", 256 "\u020E": "O", 257 "\u1ECE": "O", 258 "\u1ECC": "O", 259 "\u1ED4": "O", 260 "\u1ED6": "O", 261 "\u1ED8": "O", 262 "\u1EDC": "O", 263 "\u1EDE": "O", 264 "\u1EE0": "O", 265 "\u1EDA": "O", 266 "\u1EE2": "O", 267 "\xD9": "U", 268 "\xDA": "U", 269 "\xDB": "U", 270 "\xDC": "U", 271 "\u1EE6": "U", 272 "\u1EE4": "U", 273 "\u1EEC": "U", 274 "\u1EEE": "U", 275 "\u1EF0": "U", 276 "\xDD": "Y", 277 "\xE0": "a", 278 "\xE1": "a", 279 "\xE2": "a", 280 "\xE3": "a", 281 "\xE4": "a", 282 "\xE5": "a", 283 "\u1EA5": "a", 284 "\u1EAF": "a", 285 "\u1EB3": "a", 286 "\u1EB5": "a", 287 "\u1EB7": "a", 288 "\xE6": "ae", 289 "\u1EA7": "a", 290 "\u1EB1": "a", 291 "\u0203": "a", 292 "\u1EA3": "a", 293 "\u1EA1": "a", 294 "\u1EA9": "a", 295 "\u1EAB": "a", 296 "\u1EAD": "a", 297 "\xE7": "c", 298 "\u1E09": "c", 299 "\xE8": "e", 300 "\xE9": "e", 301 "\xEA": "e", 302 "\xEB": "e", 303 "\u1EBF": "e", 304 "\u1E17": "e", 305 "\u1EC1": "e", 306 "\u1E15": "e", 307 "\u1E1D": "e", 308 "\u0207": "e", 309 "\u1EBB": "e", 310 "\u1EBD": "e", 311 "\u1EB9": "e", 312 "\u1EC3": "e", 313 "\u1EC5": "e", 314 "\u1EC7": "e", 315 "\xEC": "i", 316 "\xED": "i", 317 "\xEE": "i", 318 "\xEF": "i", 319 "\u1E2F": "i", 320 "\u020B": "i", 321 "\u1EC9": "i", 322 "\u1ECB": "i", 323 "\xF0": "d", 324 "\xF1": "n", 325 "\xF2": "o", 326 "\xF3": "o", 327 "\xF4": "o", 328 "\xF5": "o", 329 "\xF6": "o", 330 "\xF8": "o", 331 "\u1ED1": "o", 332 "\u1E4D": "o", 333 "\u1E53": "o", 334 "\u020F": "o", 335 "\u1ECF": "o", 336 "\u1ECD": "o", 337 "\u1ED5": "o", 338 "\u1ED7": "o", 339 "\u1ED9": "o", 340 "\u1EDD": "o", 341 "\u1EDF": "o", 342 "\u1EE1": "o", 343 "\u1EDB": "o", 344 "\u1EE3": "o", 345 "\xF9": "u", 346 "\xFA": "u", 347 "\xFB": "u", 348 "\xFC": "u", 349 "\u1EE7": "u", 350 "\u1EE5": "u", 351 "\u1EED": "u", 352 "\u1EEF": "u", 353 "\u1EF1": "u", 354 "\xFD": "y", 355 "\xFF": "y", 356 "\u0100": "A", 357 "\u0101": "a", 358 "\u0102": "A", 359 "\u0103": "a", 360 "\u0104": "A", 361 "\u0105": "a", 362 "\u0106": "C", 363 "\u0107": "c", 364 "\u0108": "C", 365 "\u0109": "c", 366 "\u010A": "C", 367 "\u010B": "c", 368 "\u010C": "C", 369 "\u010D": "c", 370 "C\u0306": "C", 371 "c\u0306": "c", 372 "\u010E": "D", 373 "\u010F": "d", 374 "\u0110": "D", 375 "\u0111": "d", 376 "\u0112": "E", 377 "\u0113": "e", 378 "\u0114": "E", 379 "\u0115": "e", 380 "\u0116": "E", 381 "\u0117": "e", 382 "\u0118": "E", 383 "\u0119": "e", 384 "\u011A": "E", 385 "\u011B": "e", 386 "\u011C": "G", 387 "\u01F4": "G", 388 "\u011D": "g", 389 "\u01F5": "g", 390 "\u011E": "G", 391 "\u011F": "g", 392 "\u0120": "G", 393 "\u0121": "g", 394 "\u0122": "G", 395 "\u0123": "g", 396 "\u0124": "H", 397 "\u0125": "h", 398 "\u0126": "H", 399 "\u0127": "h", 400 "\u1E2A": "H", 401 "\u1E2B": "h", 402 "\u0128": "I", 403 "\u0129": "i", 404 "\u012A": "I", 405 "\u012B": "i", 406 "\u012C": "I", 407 "\u012D": "i", 408 "\u012E": "I", 409 "\u012F": "i", 410 "\u0130": "I", 411 "\u0131": "i", 412 "\u0132": "IJ", 413 "\u0133": "ij", 414 "\u0134": "J", 415 "\u0135": "j", 416 "\u0136": "K", 417 "\u0137": "k", 418 "\u1E30": "K", 419 "\u1E31": "k", 420 "K\u0306": "K", 421 "k\u0306": "k", 422 "\u0139": "L", 423 "\u013A": "l", 424 "\u013B": "L", 425 "\u013C": "l", 426 "\u013D": "L", 427 "\u013E": "l", 428 "\u013F": "L", 429 "\u0140": "l", 430 "\u0141": "l", 431 "\u0142": "l", 432 "\u1E3E": "M", 433 "\u1E3F": "m", 434 "M\u0306": "M", 435 "m\u0306": "m", 436 "\u0143": "N", 437 "\u0144": "n", 438 "\u0145": "N", 439 "\u0146": "n", 440 "\u0147": "N", 441 "\u0148": "n", 442 "\u0149": "n", 443 "N\u0306": "N", 444 "n\u0306": "n", 445 "\u014C": "O", 446 "\u014D": "o", 447 "\u014E": "O", 448 "\u014F": "o", 449 "\u0150": "O", 450 "\u0151": "o", 451 "\u0152": "OE", 452 "\u0153": "oe", 453 "P\u0306": "P", 454 "p\u0306": "p", 455 "\u0154": "R", 456 "\u0155": "r", 457 "\u0156": "R", 458 "\u0157": "r", 459 "\u0158": "R", 460 "\u0159": "r", 461 "R\u0306": "R", 462 "r\u0306": "r", 463 "\u0212": "R", 464 "\u0213": "r", 465 "\u015A": "S", 466 "\u015B": "s", 467 "\u015C": "S", 468 "\u015D": "s", 469 "\u015E": "S", 470 "\u0218": "S", 471 "\u0219": "s", 472 "\u015F": "s", 473 "\u0160": "S", 474 "\u0161": "s", 475 "\u0162": "T", 476 "\u0163": "t", 477 "\u021B": "t", 478 "\u021A": "T", 479 "\u0164": "T", 480 "\u0165": "t", 481 "\u0166": "T", 482 "\u0167": "t", 483 "T\u0306": "T", 484 "t\u0306": "t", 485 "\u0168": "U", 486 "\u0169": "u", 487 "\u016A": "U", 488 "\u016B": "u", 489 "\u016C": "U", 490 "\u016D": "u", 491 "\u016E": "U", 492 "\u016F": "u", 493 "\u0170": "U", 494 "\u0171": "u", 495 "\u0172": "U", 496 "\u0173": "u", 497 "\u0216": "U", 498 "\u0217": "u", 499 "V\u0306": "V", 500 "v\u0306": "v", 501 "\u0174": "W", 502 "\u0175": "w", 503 "\u1E82": "W", 504 "\u1E83": "w", 505 "X\u0306": "X", 506 "x\u0306": "x", 507 "\u0176": "Y", 508 "\u0177": "y", 509 "\u0178": "Y", 510 "Y\u0306": "Y", 511 "y\u0306": "y", 512 "\u0179": "Z", 513 "\u017A": "z", 514 "\u017B": "Z", 515 "\u017C": "z", 516 "\u017D": "Z", 517 "\u017E": "z", 518 "\u017F": "s", 519 "\u0192": "f", 520 "\u01A0": "O", 521 "\u01A1": "o", 522 "\u01AF": "U", 523 "\u01B0": "u", 524 "\u01CD": "A", 525 "\u01CE": "a", 526 "\u01CF": "I", 527 "\u01D0": "i", 528 "\u01D1": "O", 529 "\u01D2": "o", 530 "\u01D3": "U", 531 "\u01D4": "u", 532 "\u01D5": "U", 533 "\u01D6": "u", 534 "\u01D7": "U", 535 "\u01D8": "u", 536 "\u01D9": "U", 537 "\u01DA": "u", 538 "\u01DB": "U", 539 "\u01DC": "u", 540 "\u1EE8": "U", 541 "\u1EE9": "u", 542 "\u1E78": "U", 543 "\u1E79": "u", 544 "\u01FA": "A", 545 "\u01FB": "a", 546 "\u01FC": "AE", 547 "\u01FD": "ae", 548 "\u01FE": "O", 549 "\u01FF": "o", 550 "\xDE": "TH", 551 "\xFE": "th", 552 "\u1E54": "P", 553 "\u1E55": "p", 554 "\u1E64": "S", 555 "\u1E65": "s", 556 "X\u0301": "X", 557 "x\u0301": "x", 558 "\u0403": "\u0413", 559 "\u0453": "\u0433", 560 "\u040C": "\u041A", 561 "\u045C": "\u043A", 562 "A\u030B": "A", 563 "a\u030B": "a", 564 "E\u030B": "E", 565 "e\u030B": "e", 566 "I\u030B": "I", 567 "i\u030B": "i", 568 "\u01F8": "N", 569 "\u01F9": "n", 570 "\u1ED2": "O", 571 "\u1ED3": "o", 572 "\u1E50": "O", 573 "\u1E51": "o", 574 "\u1EEA": "U", 575 "\u1EEB": "u", 576 "\u1E80": "W", 577 "\u1E81": "w", 578 "\u1EF2": "Y", 579 "\u1EF3": "y", 580 "\u0200": "A", 581 "\u0201": "a", 582 "\u0204": "E", 583 "\u0205": "e", 584 "\u0208": "I", 585 "\u0209": "i", 586 "\u020C": "O", 587 "\u020D": "o", 588 "\u0210": "R", 589 "\u0211": "r", 590 "\u0214": "U", 591 "\u0215": "u", 592 "B\u030C": "B", 593 "b\u030C": "b", 594 "\u010C\u0323": "C", 595 "\u010D\u0323": "c", 596 "\xCA\u030C": "E", 597 "\xEA\u030C": "e", 598 "F\u030C": "F", 599 "f\u030C": "f", 600 "\u01E6": "G", 601 "\u01E7": "g", 602 "\u021E": "H", 603 "\u021F": "h", 604 "J\u030C": "J", 605 "\u01F0": "j", 606 "\u01E8": "K", 607 "\u01E9": "k", 608 "M\u030C": "M", 609 "m\u030C": "m", 610 "P\u030C": "P", 611 "p\u030C": "p", 612 "Q\u030C": "Q", 613 "q\u030C": "q", 614 "\u0158\u0329": "R", 615 "\u0159\u0329": "r", 616 "\u1E66": "S", 617 "\u1E67": "s", 618 "V\u030C": "V", 619 "v\u030C": "v", 620 "W\u030C": "W", 621 "w\u030C": "w", 622 "X\u030C": "X", 623 "x\u030C": "x", 624 "Y\u030C": "Y", 625 "y\u030C": "y", 626 "A\u0327": "A", 627 "a\u0327": "a", 628 "B\u0327": "B", 629 "b\u0327": "b", 630 "\u1E10": "D", 631 "\u1E11": "d", 632 "\u0228": "E", 633 "\u0229": "e", 634 "\u0190\u0327": "E", 635 "\u025B\u0327": "e", 636 "\u1E28": "H", 637 "\u1E29": "h", 638 "I\u0327": "I", 639 "i\u0327": "i", 640 "\u0197\u0327": "I", 641 "\u0268\u0327": "i", 642 "M\u0327": "M", 643 "m\u0327": "m", 644 "O\u0327": "O", 645 "o\u0327": "o", 646 "Q\u0327": "Q", 647 "q\u0327": "q", 648 "U\u0327": "U", 649 "u\u0327": "u", 650 "X\u0327": "X", 651 "x\u0327": "x", 652 "Z\u0327": "Z", 653 "z\u0327": "z", 654 "\u0439": "\u0438", 655 "\u0419": "\u0418", 656 "\u0451": "\u0435", 657 "\u0401": "\u0415" 658 }; 659 var chars = Object.keys(characterMap).join("|"); 660 var allAccents = new RegExp(chars, "g"); 661 var firstAccent = new RegExp(chars, ""); 662 function matcher(match2) { 663 return characterMap[match2]; 664 } 665 var removeAccents4 = function(string) { 666 return string.replace(allAccents, matcher); 667 }; 668 var hasAccents = function(string) { 669 return !!string.match(firstAccent); 670 }; 671 module.exports = removeAccents4; 672 module.exports.has = hasAccents; 673 module.exports.remove = removeAccents4; 674 } 675 }); 676 677 // package-external:@wordpress/blob 678 var require_blob = __commonJS({ 679 "package-external:@wordpress/blob"(exports, module) { 680 module.exports = window.wp.blob; 681 } 682 }); 683 684 // package-external:@wordpress/style-engine 685 var require_style_engine = __commonJS({ 686 "package-external:@wordpress/style-engine"(exports, module) { 687 module.exports = window.wp.styleEngine; 688 } 689 }); 690 691 // node_modules/fast-deep-equal/es6/index.js 692 var require_es6 = __commonJS({ 693 "node_modules/fast-deep-equal/es6/index.js"(exports, module) { 694 "use strict"; 695 module.exports = function equal(a3, b3) { 696 if (a3 === b3) return true; 697 if (a3 && b3 && typeof a3 == "object" && typeof b3 == "object") { 698 if (a3.constructor !== b3.constructor) return false; 699 var length, i3, keys; 700 if (Array.isArray(a3)) { 701 length = a3.length; 702 if (length != b3.length) return false; 703 for (i3 = length; i3-- !== 0; ) 704 if (!equal(a3[i3], b3[i3])) return false; 705 return true; 706 } 707 if (a3 instanceof Map && b3 instanceof Map) { 708 if (a3.size !== b3.size) return false; 709 for (i3 of a3.entries()) 710 if (!b3.has(i3[0])) return false; 711 for (i3 of a3.entries()) 712 if (!equal(i3[1], b3.get(i3[0]))) return false; 713 return true; 714 } 715 if (a3 instanceof Set && b3 instanceof Set) { 716 if (a3.size !== b3.size) return false; 717 for (i3 of a3.entries()) 718 if (!b3.has(i3[0])) return false; 719 return true; 720 } 721 if (ArrayBuffer.isView(a3) && ArrayBuffer.isView(b3)) { 722 length = a3.length; 723 if (length != b3.length) return false; 724 for (i3 = length; i3-- !== 0; ) 725 if (a3[i3] !== b3[i3]) return false; 726 return true; 727 } 728 if (a3.constructor === RegExp) return a3.source === b3.source && a3.flags === b3.flags; 729 if (a3.valueOf !== Object.prototype.valueOf) return a3.valueOf() === b3.valueOf(); 730 if (a3.toString !== Object.prototype.toString) return a3.toString() === b3.toString(); 731 keys = Object.keys(a3); 732 length = keys.length; 733 if (length !== Object.keys(b3).length) return false; 734 for (i3 = length; i3-- !== 0; ) 735 if (!Object.prototype.hasOwnProperty.call(b3, keys[i3])) return false; 736 for (i3 = length; i3-- !== 0; ) { 737 var key = keys[i3]; 738 if (!equal(a3[key], b3[key])) return false; 739 } 740 return true; 741 } 742 return a3 !== a3 && b3 !== b3; 743 }; 744 } 745 }); 746 747 // node_modules/deepmerge/dist/cjs.js 748 var require_cjs = __commonJS({ 749 "node_modules/deepmerge/dist/cjs.js"(exports, module) { 750 "use strict"; 751 var isMergeableObject = function isMergeableObject2(value) { 752 return isNonNullObject(value) && !isSpecial(value); 753 }; 754 function isNonNullObject(value) { 755 return !!value && typeof value === "object"; 756 } 757 function isSpecial(value) { 758 var stringValue = Object.prototype.toString.call(value); 759 return stringValue === "[object RegExp]" || stringValue === "[object Date]" || isReactElement(value); 760 } 761 var canUseSymbol = typeof Symbol === "function" && Symbol.for; 762 var REACT_ELEMENT_TYPE = canUseSymbol ? Symbol.for("react.element") : 60103; 763 function isReactElement(value) { 764 return value.$$typeof === REACT_ELEMENT_TYPE; 765 } 766 function emptyTarget(val) { 767 return Array.isArray(val) ? [] : {}; 768 } 769 function cloneUnlessOtherwiseSpecified(value, options) { 770 return options.clone !== false && options.isMergeableObject(value) ? deepmerge2(emptyTarget(value), value, options) : value; 771 } 772 function defaultArrayMerge(target, source, options) { 773 return target.concat(source).map(function(element) { 774 return cloneUnlessOtherwiseSpecified(element, options); 775 }); 776 } 777 function getMergeFunction(key, options) { 778 if (!options.customMerge) { 779 return deepmerge2; 780 } 781 var customMerge = options.customMerge(key); 782 return typeof customMerge === "function" ? customMerge : deepmerge2; 783 } 784 function getEnumerableOwnPropertySymbols(target) { 785 return Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(target).filter(function(symbol) { 786 return Object.propertyIsEnumerable.call(target, symbol); 787 }) : []; 788 } 789 function getKeys(target) { 790 return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target)); 791 } 792 function propertyIsOnObject(object, property) { 793 try { 794 return property in object; 795 } catch (_) { 796 return false; 797 } 798 } 799 function propertyIsUnsafe(target, key) { 800 return propertyIsOnObject(target, key) && !(Object.hasOwnProperty.call(target, key) && Object.propertyIsEnumerable.call(target, key)); 801 } 802 function mergeObject(target, source, options) { 803 var destination = {}; 804 if (options.isMergeableObject(target)) { 805 getKeys(target).forEach(function(key) { 806 destination[key] = cloneUnlessOtherwiseSpecified(target[key], options); 807 }); 808 } 809 getKeys(source).forEach(function(key) { 810 if (propertyIsUnsafe(target, key)) { 811 return; 812 } 813 if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) { 814 destination[key] = getMergeFunction(key, options)(target[key], source[key], options); 815 } else { 816 destination[key] = cloneUnlessOtherwiseSpecified(source[key], options); 817 } 818 }); 819 return destination; 820 } 821 function deepmerge2(target, source, options) { 822 options = options || {}; 823 options.arrayMerge = options.arrayMerge || defaultArrayMerge; 824 options.isMergeableObject = options.isMergeableObject || isMergeableObject; 825 options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified; 826 var sourceIsArray = Array.isArray(source); 827 var targetIsArray = Array.isArray(target); 828 var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray; 829 if (!sourceAndTargetTypesMatch) { 830 return cloneUnlessOtherwiseSpecified(source, options); 831 } else if (sourceIsArray) { 832 return options.arrayMerge(target, source, options); 833 } else { 834 return mergeObject(target, source, options); 835 } 836 } 837 deepmerge2.all = function deepmergeAll(array, options) { 838 if (!Array.isArray(array)) { 839 throw new Error("first argument should be an array"); 840 } 841 return array.reduce(function(prev, next) { 842 return deepmerge2(prev, next, options); 843 }, {}); 844 }; 845 var deepmerge_1 = deepmerge2; 846 module.exports = deepmerge_1; 847 } 848 }); 849 850 // package-external:@wordpress/commands 851 var require_commands = __commonJS({ 852 "package-external:@wordpress/commands"(exports, module) { 853 module.exports = window.wp.commands; 854 } 855 }); 856 857 // package-external:@wordpress/viewport 858 var require_viewport = __commonJS({ 859 "package-external:@wordpress/viewport"(exports, module) { 860 module.exports = window.wp.viewport; 861 } 862 }); 863 864 // package-external:@wordpress/plugins 865 var require_plugins = __commonJS({ 866 "package-external:@wordpress/plugins"(exports, module) { 867 module.exports = window.wp.plugins; 868 } 869 }); 870 871 // package-external:@wordpress/keyboard-shortcuts 872 var require_keyboard_shortcuts = __commonJS({ 873 "package-external:@wordpress/keyboard-shortcuts"(exports, module) { 874 module.exports = window.wp.keyboardShortcuts; 875 } 876 }); 877 878 // package-external:@wordpress/keycodes 879 var require_keycodes = __commonJS({ 880 "package-external:@wordpress/keycodes"(exports, module) { 881 module.exports = window.wp.keycodes; 882 } 883 }); 884 885 // node_modules/fast-deep-equal/index.js 886 var require_fast_deep_equal = __commonJS({ 887 "node_modules/fast-deep-equal/index.js"(exports, module) { 888 "use strict"; 889 module.exports = function equal(a3, b3) { 890 if (a3 === b3) return true; 891 if (a3 && b3 && typeof a3 == "object" && typeof b3 == "object") { 892 if (a3.constructor !== b3.constructor) return false; 893 var length, i3, keys; 894 if (Array.isArray(a3)) { 895 length = a3.length; 896 if (length != b3.length) return false; 897 for (i3 = length; i3-- !== 0; ) 898 if (!equal(a3[i3], b3[i3])) return false; 899 return true; 900 } 901 if (a3.constructor === RegExp) return a3.source === b3.source && a3.flags === b3.flags; 902 if (a3.valueOf !== Object.prototype.valueOf) return a3.valueOf() === b3.valueOf(); 903 if (a3.toString !== Object.prototype.toString) return a3.toString() === b3.toString(); 904 keys = Object.keys(a3); 905 length = keys.length; 906 if (length !== Object.keys(b3).length) return false; 907 for (i3 = length; i3-- !== 0; ) 908 if (!Object.prototype.hasOwnProperty.call(b3, keys[i3])) return false; 909 for (i3 = length; i3-- !== 0; ) { 910 var key = keys[i3]; 911 if (!equal(a3[key], b3[key])) return false; 912 } 913 return true; 914 } 915 return a3 !== a3 && b3 !== b3; 916 }; 917 } 918 }); 919 920 // package-external:@wordpress/dom 921 var require_dom = __commonJS({ 922 "package-external:@wordpress/dom"(exports, module) { 923 module.exports = window.wp.dom; 924 } 925 }); 926 927 // package-external:@wordpress/rich-text 928 var require_rich_text = __commonJS({ 929 "package-external:@wordpress/rich-text"(exports, module) { 930 module.exports = window.wp.richText; 931 } 932 }); 933 934 // package-external:@wordpress/warning 935 var require_warning = __commonJS({ 936 "package-external:@wordpress/warning"(exports, module) { 937 module.exports = window.wp.warning; 938 } 939 }); 940 941 // vendor-external:react 942 var require_react = __commonJS({ 943 "vendor-external:react"(exports, module) { 944 module.exports = window.React; 945 } 946 }); 947 948 // node_modules/react-is/cjs/react-is.development.js 949 var require_react_is_development = __commonJS({ 950 "node_modules/react-is/cjs/react-is.development.js"(exports) { 951 "use strict"; 952 if (true) { 953 (function() { 954 "use strict"; 955 var hasSymbol = typeof Symbol === "function" && Symbol.for; 956 var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for("react.element") : 60103; 957 var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for("react.portal") : 60106; 958 var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for("react.fragment") : 60107; 959 var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for("react.strict_mode") : 60108; 960 var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for("react.profiler") : 60114; 961 var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for("react.provider") : 60109; 962 var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for("react.context") : 60110; 963 var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for("react.async_mode") : 60111; 964 var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for("react.concurrent_mode") : 60111; 965 var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for("react.forward_ref") : 60112; 966 var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for("react.suspense") : 60113; 967 var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for("react.suspense_list") : 60120; 968 var REACT_MEMO_TYPE = hasSymbol ? Symbol.for("react.memo") : 60115; 969 var REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 60116; 970 var REACT_BLOCK_TYPE = hasSymbol ? Symbol.for("react.block") : 60121; 971 var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for("react.fundamental") : 60117; 972 var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for("react.responder") : 60118; 973 var REACT_SCOPE_TYPE = hasSymbol ? Symbol.for("react.scope") : 60119; 974 function isValidElementType(type) { 975 return typeof type === "string" || typeof type === "function" || // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill. 976 type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || typeof type === "object" && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_RESPONDER_TYPE || type.$$typeof === REACT_SCOPE_TYPE || type.$$typeof === REACT_BLOCK_TYPE); 977 } 978 function typeOf(object) { 979 if (typeof object === "object" && object !== null) { 980 var $$typeof = object.$$typeof; 981 switch ($$typeof) { 982 case REACT_ELEMENT_TYPE: 983 var type = object.type; 984 switch (type) { 985 case REACT_ASYNC_MODE_TYPE: 986 case REACT_CONCURRENT_MODE_TYPE: 987 case REACT_FRAGMENT_TYPE: 988 case REACT_PROFILER_TYPE: 989 case REACT_STRICT_MODE_TYPE: 990 case REACT_SUSPENSE_TYPE: 991 return type; 992 default: 993 var $$typeofType = type && type.$$typeof; 994 switch ($$typeofType) { 995 case REACT_CONTEXT_TYPE: 996 case REACT_FORWARD_REF_TYPE: 997 case REACT_LAZY_TYPE: 998 case REACT_MEMO_TYPE: 999 case REACT_PROVIDER_TYPE: 1000 return $$typeofType; 1001 default: 1002 return $$typeof; 1003 } 1004 } 1005 case REACT_PORTAL_TYPE: 1006 return $$typeof; 1007 } 1008 } 1009 return void 0; 1010 } 1011 var AsyncMode = REACT_ASYNC_MODE_TYPE; 1012 var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE; 1013 var ContextConsumer = REACT_CONTEXT_TYPE; 1014 var ContextProvider = REACT_PROVIDER_TYPE; 1015 var Element2 = REACT_ELEMENT_TYPE; 1016 var ForwardRef = REACT_FORWARD_REF_TYPE; 1017 var Fragment82 = REACT_FRAGMENT_TYPE; 1018 var Lazy = REACT_LAZY_TYPE; 1019 var Memo = REACT_MEMO_TYPE; 1020 var Portal = REACT_PORTAL_TYPE; 1021 var Profiler = REACT_PROFILER_TYPE; 1022 var StrictMode = REACT_STRICT_MODE_TYPE; 1023 var Suspense = REACT_SUSPENSE_TYPE; 1024 var hasWarnedAboutDeprecatedIsAsyncMode = false; 1025 function isAsyncMode(object) { 1026 { 1027 if (!hasWarnedAboutDeprecatedIsAsyncMode) { 1028 hasWarnedAboutDeprecatedIsAsyncMode = true; 1029 console["warn"]("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 17+. Update your code to use ReactIs.isConcurrentMode() instead. It has the exact same API."); 1030 } 1031 } 1032 return isConcurrentMode(object) || typeOf(object) === REACT_ASYNC_MODE_TYPE; 1033 } 1034 function isConcurrentMode(object) { 1035 return typeOf(object) === REACT_CONCURRENT_MODE_TYPE; 1036 } 1037 function isContextConsumer(object) { 1038 return typeOf(object) === REACT_CONTEXT_TYPE; 1039 } 1040 function isContextProvider(object) { 1041 return typeOf(object) === REACT_PROVIDER_TYPE; 1042 } 1043 function isElement2(object) { 1044 return typeof object === "object" && object !== null && object.$$typeof === REACT_ELEMENT_TYPE; 1045 } 1046 function isForwardRef(object) { 1047 return typeOf(object) === REACT_FORWARD_REF_TYPE; 1048 } 1049 function isFragment(object) { 1050 return typeOf(object) === REACT_FRAGMENT_TYPE; 1051 } 1052 function isLazy(object) { 1053 return typeOf(object) === REACT_LAZY_TYPE; 1054 } 1055 function isMemo(object) { 1056 return typeOf(object) === REACT_MEMO_TYPE; 1057 } 1058 function isPortal(object) { 1059 return typeOf(object) === REACT_PORTAL_TYPE; 1060 } 1061 function isProfiler(object) { 1062 return typeOf(object) === REACT_PROFILER_TYPE; 1063 } 1064 function isStrictMode(object) { 1065 return typeOf(object) === REACT_STRICT_MODE_TYPE; 1066 } 1067 function isSuspense(object) { 1068 return typeOf(object) === REACT_SUSPENSE_TYPE; 1069 } 1070 exports.AsyncMode = AsyncMode; 1071 exports.ConcurrentMode = ConcurrentMode; 1072 exports.ContextConsumer = ContextConsumer; 1073 exports.ContextProvider = ContextProvider; 1074 exports.Element = Element2; 1075 exports.ForwardRef = ForwardRef; 1076 exports.Fragment = Fragment82; 1077 exports.Lazy = Lazy; 1078 exports.Memo = Memo; 1079 exports.Portal = Portal; 1080 exports.Profiler = Profiler; 1081 exports.StrictMode = StrictMode; 1082 exports.Suspense = Suspense; 1083 exports.isAsyncMode = isAsyncMode; 1084 exports.isConcurrentMode = isConcurrentMode; 1085 exports.isContextConsumer = isContextConsumer; 1086 exports.isContextProvider = isContextProvider; 1087 exports.isElement = isElement2; 1088 exports.isForwardRef = isForwardRef; 1089 exports.isFragment = isFragment; 1090 exports.isLazy = isLazy; 1091 exports.isMemo = isMemo; 1092 exports.isPortal = isPortal; 1093 exports.isProfiler = isProfiler; 1094 exports.isStrictMode = isStrictMode; 1095 exports.isSuspense = isSuspense; 1096 exports.isValidElementType = isValidElementType; 1097 exports.typeOf = typeOf; 1098 })(); 1099 } 1100 } 1101 }); 1102 1103 // node_modules/react-is/index.js 1104 var require_react_is = __commonJS({ 1105 "node_modules/react-is/index.js"(exports, module) { 1106 "use strict"; 1107 if (false) { 1108 module.exports = null; 1109 } else { 1110 module.exports = require_react_is_development(); 1111 } 1112 } 1113 }); 1114 1115 // node_modules/object-assign/index.js 1116 var require_object_assign = __commonJS({ 1117 "node_modules/object-assign/index.js"(exports, module) { 1118 "use strict"; 1119 var getOwnPropertySymbols = Object.getOwnPropertySymbols; 1120 var hasOwnProperty = Object.prototype.hasOwnProperty; 1121 var propIsEnumerable = Object.prototype.propertyIsEnumerable; 1122 function toObject(val) { 1123 if (val === null || val === void 0) { 1124 throw new TypeError("Object.assign cannot be called with null or undefined"); 1125 } 1126 return Object(val); 1127 } 1128 function shouldUseNative() { 1129 try { 1130 if (!Object.assign) { 1131 return false; 1132 } 1133 var test1 = new String("abc"); 1134 test1[5] = "de"; 1135 if (Object.getOwnPropertyNames(test1)[0] === "5") { 1136 return false; 1137 } 1138 var test2 = {}; 1139 for (var i3 = 0; i3 < 10; i3++) { 1140 test2["_" + String.fromCharCode(i3)] = i3; 1141 } 1142 var order2 = Object.getOwnPropertyNames(test2).map(function(n3) { 1143 return test2[n3]; 1144 }); 1145 if (order2.join("") !== "0123456789") { 1146 return false; 1147 } 1148 var test3 = {}; 1149 "abcdefghijklmnopqrst".split("").forEach(function(letter) { 1150 test3[letter] = letter; 1151 }); 1152 if (Object.keys(Object.assign({}, test3)).join("") !== "abcdefghijklmnopqrst") { 1153 return false; 1154 } 1155 return true; 1156 } catch (err) { 1157 return false; 1158 } 1159 } 1160 module.exports = shouldUseNative() ? Object.assign : function(target, source) { 1161 var from; 1162 var to = toObject(target); 1163 var symbols; 1164 for (var s3 = 1; s3 < arguments.length; s3++) { 1165 from = Object(arguments[s3]); 1166 for (var key in from) { 1167 if (hasOwnProperty.call(from, key)) { 1168 to[key] = from[key]; 1169 } 1170 } 1171 if (getOwnPropertySymbols) { 1172 symbols = getOwnPropertySymbols(from); 1173 for (var i3 = 0; i3 < symbols.length; i3++) { 1174 if (propIsEnumerable.call(from, symbols[i3])) { 1175 to[symbols[i3]] = from[symbols[i3]]; 1176 } 1177 } 1178 } 1179 } 1180 return to; 1181 }; 1182 } 1183 }); 1184 1185 // node_modules/prop-types/lib/ReactPropTypesSecret.js 1186 var require_ReactPropTypesSecret = __commonJS({ 1187 "node_modules/prop-types/lib/ReactPropTypesSecret.js"(exports, module) { 1188 "use strict"; 1189 var ReactPropTypesSecret = "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"; 1190 module.exports = ReactPropTypesSecret; 1191 } 1192 }); 1193 1194 // node_modules/prop-types/lib/has.js 1195 var require_has = __commonJS({ 1196 "node_modules/prop-types/lib/has.js"(exports, module) { 1197 module.exports = Function.call.bind(Object.prototype.hasOwnProperty); 1198 } 1199 }); 1200 1201 // node_modules/prop-types/checkPropTypes.js 1202 var require_checkPropTypes = __commonJS({ 1203 "node_modules/prop-types/checkPropTypes.js"(exports, module) { 1204 "use strict"; 1205 var printWarning = function() { 1206 }; 1207 if (true) { 1208 ReactPropTypesSecret = require_ReactPropTypesSecret(); 1209 loggedTypeFailures = {}; 1210 has = require_has(); 1211 printWarning = function(text) { 1212 var message = "Warning: " + text; 1213 if (typeof console !== "undefined") { 1214 console.error(message); 1215 } 1216 try { 1217 throw new Error(message); 1218 } catch (x2) { 1219 } 1220 }; 1221 } 1222 var ReactPropTypesSecret; 1223 var loggedTypeFailures; 1224 var has; 1225 function checkPropTypes(typeSpecs, values, location, componentName, getStack) { 1226 if (true) { 1227 for (var typeSpecName in typeSpecs) { 1228 if (has(typeSpecs, typeSpecName)) { 1229 var error; 1230 try { 1231 if (typeof typeSpecs[typeSpecName] !== "function") { 1232 var err = Error( 1233 (componentName || "React class") + ": " + location + " type `" + typeSpecName + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof typeSpecs[typeSpecName] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`." 1234 ); 1235 err.name = "Invariant Violation"; 1236 throw err; 1237 } 1238 error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret); 1239 } catch (ex) { 1240 error = ex; 1241 } 1242 if (error && !(error instanceof Error)) { 1243 printWarning( 1244 (componentName || "React class") + ": type specification of " + location + " `" + typeSpecName + "` is invalid; the type checker function must return `null` or an `Error` but returned a " + typeof error + ". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)." 1245 ); 1246 } 1247 if (error instanceof Error && !(error.message in loggedTypeFailures)) { 1248 loggedTypeFailures[error.message] = true; 1249 var stack = getStack ? getStack() : ""; 1250 printWarning( 1251 "Failed " + location + " type: " + error.message + (stack != null ? stack : "") 1252 ); 1253 } 1254 } 1255 } 1256 } 1257 } 1258 checkPropTypes.resetWarningCache = function() { 1259 if (true) { 1260 loggedTypeFailures = {}; 1261 } 1262 }; 1263 module.exports = checkPropTypes; 1264 } 1265 }); 1266 1267 // node_modules/prop-types/factoryWithTypeCheckers.js 1268 var require_factoryWithTypeCheckers = __commonJS({ 1269 "node_modules/prop-types/factoryWithTypeCheckers.js"(exports, module) { 1270 "use strict"; 1271 var ReactIs = require_react_is(); 1272 var assign = require_object_assign(); 1273 var ReactPropTypesSecret = require_ReactPropTypesSecret(); 1274 var has = require_has(); 1275 var checkPropTypes = require_checkPropTypes(); 1276 var printWarning = function() { 1277 }; 1278 if (true) { 1279 printWarning = function(text) { 1280 var message = "Warning: " + text; 1281 if (typeof console !== "undefined") { 1282 console.error(message); 1283 } 1284 try { 1285 throw new Error(message); 1286 } catch (x2) { 1287 } 1288 }; 1289 } 1290 function emptyFunctionThatReturnsNull() { 1291 return null; 1292 } 1293 module.exports = function(isValidElement, throwOnDirectAccess) { 1294 var ITERATOR_SYMBOL = typeof Symbol === "function" && Symbol.iterator; 1295 var FAUX_ITERATOR_SYMBOL = "@@iterator"; 1296 function getIteratorFn(maybeIterable) { 1297 var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]); 1298 if (typeof iteratorFn === "function") { 1299 return iteratorFn; 1300 } 1301 } 1302 var ANONYMOUS = "<<anonymous>>"; 1303 var ReactPropTypes = { 1304 array: createPrimitiveTypeChecker("array"), 1305 bigint: createPrimitiveTypeChecker("bigint"), 1306 bool: createPrimitiveTypeChecker("boolean"), 1307 func: createPrimitiveTypeChecker("function"), 1308 number: createPrimitiveTypeChecker("number"), 1309 object: createPrimitiveTypeChecker("object"), 1310 string: createPrimitiveTypeChecker("string"), 1311 symbol: createPrimitiveTypeChecker("symbol"), 1312 any: createAnyTypeChecker(), 1313 arrayOf: createArrayOfTypeChecker, 1314 element: createElementTypeChecker(), 1315 elementType: createElementTypeTypeChecker(), 1316 instanceOf: createInstanceTypeChecker, 1317 node: createNodeChecker(), 1318 objectOf: createObjectOfTypeChecker, 1319 oneOf: createEnumTypeChecker, 1320 oneOfType: createUnionTypeChecker, 1321 shape: createShapeTypeChecker, 1322 exact: createStrictShapeTypeChecker 1323 }; 1324 function is(x2, y3) { 1325 if (x2 === y3) { 1326 return x2 !== 0 || 1 / x2 === 1 / y3; 1327 } else { 1328 return x2 !== x2 && y3 !== y3; 1329 } 1330 } 1331 function PropTypeError(message, data) { 1332 this.message = message; 1333 this.data = data && typeof data === "object" ? data : {}; 1334 this.stack = ""; 1335 } 1336 PropTypeError.prototype = Error.prototype; 1337 function createChainableTypeChecker(validate) { 1338 if (true) { 1339 var manualPropTypeCallCache = {}; 1340 var manualPropTypeWarningCount = 0; 1341 } 1342 function checkType(isRequired, props, propName, componentName, location, propFullName, secret) { 1343 componentName = componentName || ANONYMOUS; 1344 propFullName = propFullName || propName; 1345 if (secret !== ReactPropTypesSecret) { 1346 if (throwOnDirectAccess) { 1347 var err = new Error( 1348 "Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types" 1349 ); 1350 err.name = "Invariant Violation"; 1351 throw err; 1352 } else if (typeof console !== "undefined") { 1353 var cacheKey = componentName + ":" + propName; 1354 if (!manualPropTypeCallCache[cacheKey] && // Avoid spamming the console because they are often not actionable except for lib authors 1355 manualPropTypeWarningCount < 3) { 1356 printWarning( 1357 "You are manually calling a React.PropTypes validation function for the `" + propFullName + "` prop on `" + componentName + "`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details." 1358 ); 1359 manualPropTypeCallCache[cacheKey] = true; 1360 manualPropTypeWarningCount++; 1361 } 1362 } 1363 } 1364 if (props[propName] == null) { 1365 if (isRequired) { 1366 if (props[propName] === null) { 1367 return new PropTypeError("The " + location + " `" + propFullName + "` is marked as required " + ("in `" + componentName + "`, but its value is `null`.")); 1368 } 1369 return new PropTypeError("The " + location + " `" + propFullName + "` is marked as required in " + ("`" + componentName + "`, but its value is `undefined`.")); 1370 } 1371 return null; 1372 } else { 1373 return validate(props, propName, componentName, location, propFullName); 1374 } 1375 } 1376 var chainedCheckType = checkType.bind(null, false); 1377 chainedCheckType.isRequired = checkType.bind(null, true); 1378 return chainedCheckType; 1379 } 1380 function createPrimitiveTypeChecker(expectedType) { 1381 function validate(props, propName, componentName, location, propFullName, secret) { 1382 var propValue = props[propName]; 1383 var propType = getPropType(propValue); 1384 if (propType !== expectedType) { 1385 var preciseType = getPreciseType(propValue); 1386 return new PropTypeError( 1387 "Invalid " + location + " `" + propFullName + "` of type " + ("`" + preciseType + "` supplied to `" + componentName + "`, expected ") + ("`" + expectedType + "`."), 1388 { expectedType } 1389 ); 1390 } 1391 return null; 1392 } 1393 return createChainableTypeChecker(validate); 1394 } 1395 function createAnyTypeChecker() { 1396 return createChainableTypeChecker(emptyFunctionThatReturnsNull); 1397 } 1398 function createArrayOfTypeChecker(typeChecker) { 1399 function validate(props, propName, componentName, location, propFullName) { 1400 if (typeof typeChecker !== "function") { 1401 return new PropTypeError("Property `" + propFullName + "` of component `" + componentName + "` has invalid PropType notation inside arrayOf."); 1402 } 1403 var propValue = props[propName]; 1404 if (!Array.isArray(propValue)) { 1405 var propType = getPropType(propValue); 1406 return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type " + ("`" + propType + "` supplied to `" + componentName + "`, expected an array.")); 1407 } 1408 for (var i3 = 0; i3 < propValue.length; i3++) { 1409 var error = typeChecker(propValue, i3, componentName, location, propFullName + "[" + i3 + "]", ReactPropTypesSecret); 1410 if (error instanceof Error) { 1411 return error; 1412 } 1413 } 1414 return null; 1415 } 1416 return createChainableTypeChecker(validate); 1417 } 1418 function createElementTypeChecker() { 1419 function validate(props, propName, componentName, location, propFullName) { 1420 var propValue = props[propName]; 1421 if (!isValidElement(propValue)) { 1422 var propType = getPropType(propValue); 1423 return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type " + ("`" + propType + "` supplied to `" + componentName + "`, expected a single ReactElement.")); 1424 } 1425 return null; 1426 } 1427 return createChainableTypeChecker(validate); 1428 } 1429 function createElementTypeTypeChecker() { 1430 function validate(props, propName, componentName, location, propFullName) { 1431 var propValue = props[propName]; 1432 if (!ReactIs.isValidElementType(propValue)) { 1433 var propType = getPropType(propValue); 1434 return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type " + ("`" + propType + "` supplied to `" + componentName + "`, expected a single ReactElement type.")); 1435 } 1436 return null; 1437 } 1438 return createChainableTypeChecker(validate); 1439 } 1440 function createInstanceTypeChecker(expectedClass) { 1441 function validate(props, propName, componentName, location, propFullName) { 1442 if (!(props[propName] instanceof expectedClass)) { 1443 var expectedClassName = expectedClass.name || ANONYMOUS; 1444 var actualClassName = getClassName(props[propName]); 1445 return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type " + ("`" + actualClassName + "` supplied to `" + componentName + "`, expected ") + ("instance of `" + expectedClassName + "`.")); 1446 } 1447 return null; 1448 } 1449 return createChainableTypeChecker(validate); 1450 } 1451 function createEnumTypeChecker(expectedValues) { 1452 if (!Array.isArray(expectedValues)) { 1453 if (true) { 1454 if (arguments.length > 1) { 1455 printWarning( 1456 "Invalid arguments supplied to oneOf, expected an array, got " + arguments.length + " arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z])." 1457 ); 1458 } else { 1459 printWarning("Invalid argument supplied to oneOf, expected an array."); 1460 } 1461 } 1462 return emptyFunctionThatReturnsNull; 1463 } 1464 function validate(props, propName, componentName, location, propFullName) { 1465 var propValue = props[propName]; 1466 for (var i3 = 0; i3 < expectedValues.length; i3++) { 1467 if (is(propValue, expectedValues[i3])) { 1468 return null; 1469 } 1470 } 1471 var valuesString = JSON.stringify(expectedValues, function replacer(key, value) { 1472 var type = getPreciseType(value); 1473 if (type === "symbol") { 1474 return String(value); 1475 } 1476 return value; 1477 }); 1478 return new PropTypeError("Invalid " + location + " `" + propFullName + "` of value `" + String(propValue) + "` " + ("supplied to `" + componentName + "`, expected one of " + valuesString + ".")); 1479 } 1480 return createChainableTypeChecker(validate); 1481 } 1482 function createObjectOfTypeChecker(typeChecker) { 1483 function validate(props, propName, componentName, location, propFullName) { 1484 if (typeof typeChecker !== "function") { 1485 return new PropTypeError("Property `" + propFullName + "` of component `" + componentName + "` has invalid PropType notation inside objectOf."); 1486 } 1487 var propValue = props[propName]; 1488 var propType = getPropType(propValue); 1489 if (propType !== "object") { 1490 return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type " + ("`" + propType + "` supplied to `" + componentName + "`, expected an object.")); 1491 } 1492 for (var key in propValue) { 1493 if (has(propValue, key)) { 1494 var error = typeChecker(propValue, key, componentName, location, propFullName + "." + key, ReactPropTypesSecret); 1495 if (error instanceof Error) { 1496 return error; 1497 } 1498 } 1499 } 1500 return null; 1501 } 1502 return createChainableTypeChecker(validate); 1503 } 1504 function createUnionTypeChecker(arrayOfTypeCheckers) { 1505 if (!Array.isArray(arrayOfTypeCheckers)) { 1506 true ? printWarning("Invalid argument supplied to oneOfType, expected an instance of array.") : void 0; 1507 return emptyFunctionThatReturnsNull; 1508 } 1509 for (var i3 = 0; i3 < arrayOfTypeCheckers.length; i3++) { 1510 var checker = arrayOfTypeCheckers[i3]; 1511 if (typeof checker !== "function") { 1512 printWarning( 1513 "Invalid argument supplied to oneOfType. Expected an array of check functions, but received " + getPostfixForTypeWarning(checker) + " at index " + i3 + "." 1514 ); 1515 return emptyFunctionThatReturnsNull; 1516 } 1517 } 1518 function validate(props, propName, componentName, location, propFullName) { 1519 var expectedTypes = []; 1520 for (var i4 = 0; i4 < arrayOfTypeCheckers.length; i4++) { 1521 var checker2 = arrayOfTypeCheckers[i4]; 1522 var checkerResult = checker2(props, propName, componentName, location, propFullName, ReactPropTypesSecret); 1523 if (checkerResult == null) { 1524 return null; 1525 } 1526 if (checkerResult.data && has(checkerResult.data, "expectedType")) { 1527 expectedTypes.push(checkerResult.data.expectedType); 1528 } 1529 } 1530 var expectedTypesMessage = expectedTypes.length > 0 ? ", expected one of type [" + expectedTypes.join(", ") + "]" : ""; 1531 return new PropTypeError("Invalid " + location + " `" + propFullName + "` supplied to " + ("`" + componentName + "`" + expectedTypesMessage + ".")); 1532 } 1533 return createChainableTypeChecker(validate); 1534 } 1535 function createNodeChecker() { 1536 function validate(props, propName, componentName, location, propFullName) { 1537 if (!isNode2(props[propName])) { 1538 return new PropTypeError("Invalid " + location + " `" + propFullName + "` supplied to " + ("`" + componentName + "`, expected a ReactNode.")); 1539 } 1540 return null; 1541 } 1542 return createChainableTypeChecker(validate); 1543 } 1544 function invalidValidatorError(componentName, location, propFullName, key, type) { 1545 return new PropTypeError( 1546 (componentName || "React class") + ": " + location + " type `" + propFullName + "." + key + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + type + "`." 1547 ); 1548 } 1549 function createShapeTypeChecker(shapeTypes) { 1550 function validate(props, propName, componentName, location, propFullName) { 1551 var propValue = props[propName]; 1552 var propType = getPropType(propValue); 1553 if (propType !== "object") { 1554 return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type `" + propType + "` " + ("supplied to `" + componentName + "`, expected `object`.")); 1555 } 1556 for (var key in shapeTypes) { 1557 var checker = shapeTypes[key]; 1558 if (typeof checker !== "function") { 1559 return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker)); 1560 } 1561 var error = checker(propValue, key, componentName, location, propFullName + "." + key, ReactPropTypesSecret); 1562 if (error) { 1563 return error; 1564 } 1565 } 1566 return null; 1567 } 1568 return createChainableTypeChecker(validate); 1569 } 1570 function createStrictShapeTypeChecker(shapeTypes) { 1571 function validate(props, propName, componentName, location, propFullName) { 1572 var propValue = props[propName]; 1573 var propType = getPropType(propValue); 1574 if (propType !== "object") { 1575 return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type `" + propType + "` " + ("supplied to `" + componentName + "`, expected `object`.")); 1576 } 1577 var allKeys = assign({}, props[propName], shapeTypes); 1578 for (var key in allKeys) { 1579 var checker = shapeTypes[key]; 1580 if (has(shapeTypes, key) && typeof checker !== "function") { 1581 return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker)); 1582 } 1583 if (!checker) { 1584 return new PropTypeError( 1585 "Invalid " + location + " `" + propFullName + "` key `" + key + "` supplied to `" + componentName + "`.\nBad object: " + JSON.stringify(props[propName], null, " ") + "\nValid keys: " + JSON.stringify(Object.keys(shapeTypes), null, " ") 1586 ); 1587 } 1588 var error = checker(propValue, key, componentName, location, propFullName + "." + key, ReactPropTypesSecret); 1589 if (error) { 1590 return error; 1591 } 1592 } 1593 return null; 1594 } 1595 return createChainableTypeChecker(validate); 1596 } 1597 function isNode2(propValue) { 1598 switch (typeof propValue) { 1599 case "number": 1600 case "string": 1601 case "undefined": 1602 return true; 1603 case "boolean": 1604 return !propValue; 1605 case "object": 1606 if (Array.isArray(propValue)) { 1607 return propValue.every(isNode2); 1608 } 1609 if (propValue === null || isValidElement(propValue)) { 1610 return true; 1611 } 1612 var iteratorFn = getIteratorFn(propValue); 1613 if (iteratorFn) { 1614 var iterator = iteratorFn.call(propValue); 1615 var step; 1616 if (iteratorFn !== propValue.entries) { 1617 while (!(step = iterator.next()).done) { 1618 if (!isNode2(step.value)) { 1619 return false; 1620 } 1621 } 1622 } else { 1623 while (!(step = iterator.next()).done) { 1624 var entry = step.value; 1625 if (entry) { 1626 if (!isNode2(entry[1])) { 1627 return false; 1628 } 1629 } 1630 } 1631 } 1632 } else { 1633 return false; 1634 } 1635 return true; 1636 default: 1637 return false; 1638 } 1639 } 1640 function isSymbol(propType, propValue) { 1641 if (propType === "symbol") { 1642 return true; 1643 } 1644 if (!propValue) { 1645 return false; 1646 } 1647 if (propValue["@@toStringTag"] === "Symbol") { 1648 return true; 1649 } 1650 if (typeof Symbol === "function" && propValue instanceof Symbol) { 1651 return true; 1652 } 1653 return false; 1654 } 1655 function getPropType(propValue) { 1656 var propType = typeof propValue; 1657 if (Array.isArray(propValue)) { 1658 return "array"; 1659 } 1660 if (propValue instanceof RegExp) { 1661 return "object"; 1662 } 1663 if (isSymbol(propType, propValue)) { 1664 return "symbol"; 1665 } 1666 return propType; 1667 } 1668 function getPreciseType(propValue) { 1669 if (typeof propValue === "undefined" || propValue === null) { 1670 return "" + propValue; 1671 } 1672 var propType = getPropType(propValue); 1673 if (propType === "object") { 1674 if (propValue instanceof Date) { 1675 return "date"; 1676 } else if (propValue instanceof RegExp) { 1677 return "regexp"; 1678 } 1679 } 1680 return propType; 1681 } 1682 function getPostfixForTypeWarning(value) { 1683 var type = getPreciseType(value); 1684 switch (type) { 1685 case "array": 1686 case "object": 1687 return "an " + type; 1688 case "boolean": 1689 case "date": 1690 case "regexp": 1691 return "a " + type; 1692 default: 1693 return type; 1694 } 1695 } 1696 function getClassName(propValue) { 1697 if (!propValue.constructor || !propValue.constructor.name) { 1698 return ANONYMOUS; 1699 } 1700 return propValue.constructor.name; 1701 } 1702 ReactPropTypes.checkPropTypes = checkPropTypes; 1703 ReactPropTypes.resetWarningCache = checkPropTypes.resetWarningCache; 1704 ReactPropTypes.PropTypes = ReactPropTypes; 1705 return ReactPropTypes; 1706 }; 1707 } 1708 }); 1709 1710 // node_modules/prop-types/index.js 1711 var require_prop_types = __commonJS({ 1712 "node_modules/prop-types/index.js"(exports, module) { 1713 if (true) { 1714 ReactIs = require_react_is(); 1715 throwOnDirectAccess = true; 1716 module.exports = require_factoryWithTypeCheckers()(ReactIs.isElement, throwOnDirectAccess); 1717 } else { 1718 module.exports = null(); 1719 } 1720 var ReactIs; 1721 var throwOnDirectAccess; 1722 } 1723 }); 1724 1725 // node_modules/autosize/dist/autosize.js 1726 var require_autosize = __commonJS({ 1727 "node_modules/autosize/dist/autosize.js"(exports, module) { 1728 (function(global2, factory) { 1729 if (typeof define === "function" && define.amd) { 1730 define(["module", "exports"], factory); 1731 } else if (typeof exports !== "undefined") { 1732 factory(module, exports); 1733 } else { 1734 var mod = { 1735 exports: {} 1736 }; 1737 factory(mod, mod.exports); 1738 global2.autosize = mod.exports; 1739 } 1740 })(exports, function(module2, exports2) { 1741 "use strict"; 1742 var map = typeof Map === "function" ? /* @__PURE__ */ new Map() : /* @__PURE__ */ (function() { 1743 var keys = []; 1744 var values = []; 1745 return { 1746 has: function has(key) { 1747 return keys.indexOf(key) > -1; 1748 }, 1749 get: function get(key) { 1750 return values[keys.indexOf(key)]; 1751 }, 1752 set: function set(key, value) { 1753 if (keys.indexOf(key) === -1) { 1754 keys.push(key); 1755 values.push(value); 1756 } 1757 }, 1758 delete: function _delete(key) { 1759 var index2 = keys.indexOf(key); 1760 if (index2 > -1) { 1761 keys.splice(index2, 1); 1762 values.splice(index2, 1); 1763 } 1764 } 1765 }; 1766 })(); 1767 var createEvent = function createEvent2(name2) { 1768 return new Event(name2, { bubbles: true }); 1769 }; 1770 try { 1771 new Event("test"); 1772 } catch (e3) { 1773 createEvent = function createEvent2(name2) { 1774 var evt = document.createEvent("Event"); 1775 evt.initEvent(name2, true, false); 1776 return evt; 1777 }; 1778 } 1779 function assign(ta) { 1780 if (!ta || !ta.nodeName || ta.nodeName !== "TEXTAREA" || map.has(ta)) return; 1781 var heightOffset = null; 1782 var clientWidth = null; 1783 var cachedHeight = null; 1784 function init() { 1785 var style = window.getComputedStyle(ta, null); 1786 if (style.resize === "vertical") { 1787 ta.style.resize = "none"; 1788 } else if (style.resize === "both") { 1789 ta.style.resize = "horizontal"; 1790 } 1791 if (style.boxSizing === "content-box") { 1792 heightOffset = -(parseFloat(style.paddingTop) + parseFloat(style.paddingBottom)); 1793 } else { 1794 heightOffset = parseFloat(style.borderTopWidth) + parseFloat(style.borderBottomWidth); 1795 } 1796 if (isNaN(heightOffset)) { 1797 heightOffset = 0; 1798 } 1799 update2(); 1800 } 1801 function changeOverflow(value) { 1802 { 1803 var width = ta.style.width; 1804 ta.style.width = "0px"; 1805 ta.offsetWidth; 1806 ta.style.width = width; 1807 } 1808 ta.style.overflowY = value; 1809 } 1810 function getParentOverflows(el) { 1811 var arr = []; 1812 while (el && el.parentNode && el.parentNode instanceof Element) { 1813 if (el.parentNode.scrollTop) { 1814 arr.push({ 1815 node: el.parentNode, 1816 scrollTop: el.parentNode.scrollTop 1817 }); 1818 } 1819 el = el.parentNode; 1820 } 1821 return arr; 1822 } 1823 function resize() { 1824 if (ta.scrollHeight === 0) { 1825 return; 1826 } 1827 var overflows = getParentOverflows(ta); 1828 var docTop = document.documentElement && document.documentElement.scrollTop; 1829 ta.style.height = ""; 1830 ta.style.height = ta.scrollHeight + heightOffset + "px"; 1831 clientWidth = ta.clientWidth; 1832 overflows.forEach(function(el) { 1833 el.node.scrollTop = el.scrollTop; 1834 }); 1835 if (docTop) { 1836 document.documentElement.scrollTop = docTop; 1837 } 1838 } 1839 function update2() { 1840 resize(); 1841 var styleHeight = Math.round(parseFloat(ta.style.height)); 1842 var computed = window.getComputedStyle(ta, null); 1843 var actualHeight = computed.boxSizing === "content-box" ? Math.round(parseFloat(computed.height)) : ta.offsetHeight; 1844 if (actualHeight < styleHeight) { 1845 if (computed.overflowY === "hidden") { 1846 changeOverflow("scroll"); 1847 resize(); 1848 actualHeight = computed.boxSizing === "content-box" ? Math.round(parseFloat(window.getComputedStyle(ta, null).height)) : ta.offsetHeight; 1849 } 1850 } else { 1851 if (computed.overflowY !== "hidden") { 1852 changeOverflow("hidden"); 1853 resize(); 1854 actualHeight = computed.boxSizing === "content-box" ? Math.round(parseFloat(window.getComputedStyle(ta, null).height)) : ta.offsetHeight; 1855 } 1856 } 1857 if (cachedHeight !== actualHeight) { 1858 cachedHeight = actualHeight; 1859 var evt = createEvent("autosize:resized"); 1860 try { 1861 ta.dispatchEvent(evt); 1862 } catch (err) { 1863 } 1864 } 1865 } 1866 var pageResize = function pageResize2() { 1867 if (ta.clientWidth !== clientWidth) { 1868 update2(); 1869 } 1870 }; 1871 var destroy2 = function(style) { 1872 window.removeEventListener("resize", pageResize, false); 1873 ta.removeEventListener("input", update2, false); 1874 ta.removeEventListener("keyup", update2, false); 1875 ta.removeEventListener("autosize:destroy", destroy2, false); 1876 ta.removeEventListener("autosize:update", update2, false); 1877 Object.keys(style).forEach(function(key) { 1878 ta.style[key] = style[key]; 1879 }); 1880 map.delete(ta); 1881 }.bind(ta, { 1882 height: ta.style.height, 1883 resize: ta.style.resize, 1884 overflowY: ta.style.overflowY, 1885 overflowX: ta.style.overflowX, 1886 wordWrap: ta.style.wordWrap 1887 }); 1888 ta.addEventListener("autosize:destroy", destroy2, false); 1889 if ("onpropertychange" in ta && "oninput" in ta) { 1890 ta.addEventListener("keyup", update2, false); 1891 } 1892 window.addEventListener("resize", pageResize, false); 1893 ta.addEventListener("input", update2, false); 1894 ta.addEventListener("autosize:update", update2, false); 1895 ta.style.overflowX = "hidden"; 1896 ta.style.wordWrap = "break-word"; 1897 map.set(ta, { 1898 destroy: destroy2, 1899 update: update2 1900 }); 1901 init(); 1902 } 1903 function destroy(ta) { 1904 var methods = map.get(ta); 1905 if (methods) { 1906 methods.destroy(); 1907 } 1908 } 1909 function update(ta) { 1910 var methods = map.get(ta); 1911 if (methods) { 1912 methods.update(); 1913 } 1914 } 1915 var autosize = null; 1916 if (typeof window === "undefined" || typeof window.getComputedStyle !== "function") { 1917 autosize = function autosize2(el) { 1918 return el; 1919 }; 1920 autosize.destroy = function(el) { 1921 return el; 1922 }; 1923 autosize.update = function(el) { 1924 return el; 1925 }; 1926 } else { 1927 autosize = function autosize2(el, options) { 1928 if (el) { 1929 Array.prototype.forEach.call(el.length ? el : [el], function(x2) { 1930 return assign(x2, options); 1931 }); 1932 } 1933 return el; 1934 }; 1935 autosize.destroy = function(el) { 1936 if (el) { 1937 Array.prototype.forEach.call(el.length ? el : [el], destroy); 1938 } 1939 return el; 1940 }; 1941 autosize.update = function(el) { 1942 if (el) { 1943 Array.prototype.forEach.call(el.length ? el : [el], update); 1944 } 1945 return el; 1946 }; 1947 } 1948 exports2.default = autosize; 1949 module2.exports = exports2["default"]; 1950 }); 1951 } 1952 }); 1953 1954 // node_modules/computed-style/dist/computedStyle.commonjs.js 1955 var require_computedStyle_commonjs = __commonJS({ 1956 "node_modules/computed-style/dist/computedStyle.commonjs.js"(exports, module) { 1957 var computedStyle = function(el, prop, getComputedStyle2) { 1958 getComputedStyle2 = window.getComputedStyle; 1959 return ( 1960 // If we have getComputedStyle 1961 (getComputedStyle2 ? ( 1962 // Query it 1963 // TODO: From CSS-Query notes, we might need (node, null) for FF 1964 getComputedStyle2(el) 1965 ) : ( 1966 // Otherwise, we are in IE and use currentStyle 1967 el.currentStyle 1968 ))[ 1969 // Switch to camelCase for CSSOM 1970 // DEV: Grabbed from jQuery 1971 // https://github.com/jquery/jquery/blob/1.9-stable/src/css.js#L191-L194 1972 // https://github.com/jquery/jquery/blob/1.9-stable/src/core.js#L593-L597 1973 prop.replace(/-(\w)/gi, function(word, letter) { 1974 return letter.toUpperCase(); 1975 }) 1976 ] 1977 ); 1978 }; 1979 module.exports = computedStyle; 1980 } 1981 }); 1982 1983 // node_modules/line-height/lib/line-height.js 1984 var require_line_height = __commonJS({ 1985 "node_modules/line-height/lib/line-height.js"(exports, module) { 1986 var computedStyle = require_computedStyle_commonjs(); 1987 function lineHeight(node) { 1988 var lnHeightStr = computedStyle(node, "line-height"); 1989 var lnHeight = parseFloat(lnHeightStr, 10); 1990 if (lnHeightStr === lnHeight + "") { 1991 var _lnHeightStyle = node.style.lineHeight; 1992 node.style.lineHeight = lnHeightStr + "em"; 1993 lnHeightStr = computedStyle(node, "line-height"); 1994 lnHeight = parseFloat(lnHeightStr, 10); 1995 if (_lnHeightStyle) { 1996 node.style.lineHeight = _lnHeightStyle; 1997 } else { 1998 delete node.style.lineHeight; 1999 } 2000 } 2001 if (lnHeightStr.indexOf("pt") !== -1) { 2002 lnHeight *= 4; 2003 lnHeight /= 3; 2004 } else if (lnHeightStr.indexOf("mm") !== -1) { 2005 lnHeight *= 96; 2006 lnHeight /= 25.4; 2007 } else if (lnHeightStr.indexOf("cm") !== -1) { 2008 lnHeight *= 96; 2009 lnHeight /= 2.54; 2010 } else if (lnHeightStr.indexOf("in") !== -1) { 2011 lnHeight *= 96; 2012 } else if (lnHeightStr.indexOf("pc") !== -1) { 2013 lnHeight *= 16; 2014 } 2015 lnHeight = Math.round(lnHeight); 2016 if (lnHeightStr === "normal") { 2017 var nodeName = node.nodeName; 2018 var _node = document.createElement(nodeName); 2019 _node.innerHTML = " "; 2020 if (nodeName.toUpperCase() === "TEXTAREA") { 2021 _node.setAttribute("rows", "1"); 2022 } 2023 var fontSizeStr = computedStyle(node, "font-size"); 2024 _node.style.fontSize = fontSizeStr; 2025 _node.style.padding = "0px"; 2026 _node.style.border = "0px"; 2027 var body = document.body; 2028 body.appendChild(_node); 2029 var height = _node.offsetHeight; 2030 lnHeight = height; 2031 body.removeChild(_node); 2032 } 2033 return lnHeight; 2034 } 2035 module.exports = lineHeight; 2036 } 2037 }); 2038 2039 // node_modules/react-autosize-textarea/lib/TextareaAutosize.js 2040 var require_TextareaAutosize = __commonJS({ 2041 "node_modules/react-autosize-textarea/lib/TextareaAutosize.js"(exports) { 2042 "use strict"; 2043 var __extends = exports && exports.__extends || (function() { 2044 var extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d3, b3) { 2045 d3.__proto__ = b3; 2046 } || function(d3, b3) { 2047 for (var p4 in b3) if (b3.hasOwnProperty(p4)) d3[p4] = b3[p4]; 2048 }; 2049 return function(d3, b3) { 2050 extendStatics(d3, b3); 2051 function __218() { 2052 this.constructor = d3; 2053 } 2054 d3.prototype = b3 === null ? Object.create(b3) : (__218.prototype = b3.prototype, new __218()); 2055 }; 2056 })(); 2057 var __assign2 = exports && exports.__assign || Object.assign || function(t4) { 2058 for (var s3, i3 = 1, n3 = arguments.length; i3 < n3; i3++) { 2059 s3 = arguments[i3]; 2060 for (var p4 in s3) if (Object.prototype.hasOwnProperty.call(s3, p4)) 2061 t4[p4] = s3[p4]; 2062 } 2063 return t4; 2064 }; 2065 var __rest = exports && exports.__rest || function(s3, e3) { 2066 var t4 = {}; 2067 for (var p4 in s3) if (Object.prototype.hasOwnProperty.call(s3, p4) && e3.indexOf(p4) < 0) 2068 t4[p4] = s3[p4]; 2069 if (s3 != null && typeof Object.getOwnPropertySymbols === "function") { 2070 for (var i3 = 0, p4 = Object.getOwnPropertySymbols(s3); i3 < p4.length; i3++) if (e3.indexOf(p4[i3]) < 0) 2071 t4[p4[i3]] = s3[p4[i3]]; 2072 } 2073 return t4; 2074 }; 2075 exports.__esModule = true; 2076 var React2 = require_react(); 2077 var PropTypes = require_prop_types(); 2078 var autosize = require_autosize(); 2079 var _getLineHeight = require_line_height(); 2080 var getLineHeight = _getLineHeight; 2081 var RESIZED = "autosize:resized"; 2082 var TextareaAutosizeClass = ( 2083 /** @class */ 2084 (function(_super) { 2085 __extends(TextareaAutosizeClass2, _super); 2086 function TextareaAutosizeClass2() { 2087 var _this = _super !== null && _super.apply(this, arguments) || this; 2088 _this.state = { 2089 lineHeight: null 2090 }; 2091 _this.textarea = null; 2092 _this.onResize = function(e3) { 2093 if (_this.props.onResize) { 2094 _this.props.onResize(e3); 2095 } 2096 }; 2097 _this.updateLineHeight = function() { 2098 if (_this.textarea) { 2099 _this.setState({ 2100 lineHeight: getLineHeight(_this.textarea) 2101 }); 2102 } 2103 }; 2104 _this.onChange = function(e3) { 2105 var onChange = _this.props.onChange; 2106 _this.currentValue = e3.currentTarget.value; 2107 onChange && onChange(e3); 2108 }; 2109 return _this; 2110 } 2111 TextareaAutosizeClass2.prototype.componentDidMount = function() { 2112 var _this = this; 2113 var _a = this.props, maxRows = _a.maxRows, async = _a.async; 2114 if (typeof maxRows === "number") { 2115 this.updateLineHeight(); 2116 } 2117 if (typeof maxRows === "number" || async) { 2118 setTimeout(function() { 2119 return _this.textarea && autosize(_this.textarea); 2120 }); 2121 } else { 2122 this.textarea && autosize(this.textarea); 2123 } 2124 if (this.textarea) { 2125 this.textarea.addEventListener(RESIZED, this.onResize); 2126 } 2127 }; 2128 TextareaAutosizeClass2.prototype.componentWillUnmount = function() { 2129 if (this.textarea) { 2130 this.textarea.removeEventListener(RESIZED, this.onResize); 2131 autosize.destroy(this.textarea); 2132 } 2133 }; 2134 TextareaAutosizeClass2.prototype.render = function() { 2135 var _this = this; 2136 var _a = this, _b = _a.props, onResize = _b.onResize, maxRows = _b.maxRows, onChange = _b.onChange, style = _b.style, innerRef = _b.innerRef, children = _b.children, props = __rest(_b, ["onResize", "maxRows", "onChange", "style", "innerRef", "children"]), lineHeight = _a.state.lineHeight; 2137 var maxHeight = maxRows && lineHeight ? lineHeight * maxRows : null; 2138 return React2.createElement("textarea", __assign2({}, props, { onChange: this.onChange, style: maxHeight ? __assign2({}, style, { maxHeight }) : style, ref: function(element) { 2139 _this.textarea = element; 2140 if (typeof _this.props.innerRef === "function") { 2141 _this.props.innerRef(element); 2142 } else if (_this.props.innerRef) { 2143 _this.props.innerRef.current = element; 2144 } 2145 } }), children); 2146 }; 2147 TextareaAutosizeClass2.prototype.componentDidUpdate = function() { 2148 this.textarea && autosize.update(this.textarea); 2149 }; 2150 TextareaAutosizeClass2.defaultProps = { 2151 rows: 1, 2152 async: false 2153 }; 2154 TextareaAutosizeClass2.propTypes = { 2155 rows: PropTypes.number, 2156 maxRows: PropTypes.number, 2157 onResize: PropTypes.func, 2158 innerRef: PropTypes.any, 2159 async: PropTypes.bool 2160 }; 2161 return TextareaAutosizeClass2; 2162 })(React2.Component) 2163 ); 2164 exports.TextareaAutosize = React2.forwardRef(function(props, ref) { 2165 return React2.createElement(TextareaAutosizeClass, __assign2({}, props, { innerRef: ref })); 2166 }); 2167 } 2168 }); 2169 2170 // node_modules/react-autosize-textarea/lib/index.js 2171 var require_lib = __commonJS({ 2172 "node_modules/react-autosize-textarea/lib/index.js"(exports) { 2173 "use strict"; 2174 exports.__esModule = true; 2175 var TextareaAutosize_1 = require_TextareaAutosize(); 2176 exports["default"] = TextareaAutosize_1.TextareaAutosize; 2177 } 2178 }); 2179 2180 // package-external:@wordpress/wordcount 2181 var require_wordcount = __commonJS({ 2182 "package-external:@wordpress/wordcount"(exports, module) { 2183 module.exports = window.wp.wordcount; 2184 } 2185 }); 2186 2187 // package-external:@wordpress/server-side-render 2188 var require_server_side_render = __commonJS({ 2189 "package-external:@wordpress/server-side-render"(exports, module) { 2190 module.exports = window.wp.serverSideRender; 2191 } 2192 }); 2193 2194 // vendor-external:react-dom 2195 var require_react_dom = __commonJS({ 2196 "vendor-external:react-dom"(exports, module) { 2197 module.exports = window.ReactDOM; 2198 } 2199 }); 2200 2201 // packages/editor/build-module/index.js 2202 var index_exports = {}; 2203 __export(index_exports, { 2204 AlignmentToolbar: () => AlignmentToolbar, 2205 Autocomplete: () => Autocomplete, 2206 AutosaveMonitor: () => autosave_monitor_default, 2207 BlockAlignmentToolbar: () => BlockAlignmentToolbar, 2208 BlockControls: () => BlockControls, 2209 BlockEdit: () => BlockEdit, 2210 BlockEditorKeyboardShortcuts: () => BlockEditorKeyboardShortcuts2, 2211 BlockFormatControls: () => BlockFormatControls, 2212 BlockIcon: () => BlockIcon3, 2213 BlockInspector: () => BlockInspector, 2214 BlockList: () => BlockList4, 2215 BlockMover: () => BlockMover, 2216 BlockNavigationDropdown: () => BlockNavigationDropdown, 2217 BlockSelectionClearer: () => BlockSelectionClearer, 2218 BlockSettingsMenu: () => BlockSettingsMenu, 2219 BlockTitle: () => BlockTitle, 2220 BlockToolbar: () => BlockToolbar, 2221 CharacterCount: () => CharacterCount, 2222 ColorPalette: () => ColorPalette2, 2223 ContrastChecker: () => ContrastChecker, 2224 CopyHandler: () => CopyHandler, 2225 DefaultBlockAppender: () => DefaultBlockAppender, 2226 DocumentBar: () => DocumentBar, 2227 DocumentOutline: () => DocumentOutline, 2228 DocumentOutlineCheck: () => DocumentOutlineCheck, 2229 EditorHistoryRedo: () => redo_default2, 2230 EditorHistoryUndo: () => undo_default2, 2231 EditorKeyboardShortcuts: () => EditorKeyboardShortcuts, 2232 EditorKeyboardShortcutsRegister: () => register_shortcuts_default, 2233 EditorNotices: () => editor_notices_default, 2234 EditorProvider: () => provider_default, 2235 EditorSnackbars: () => EditorSnackbars, 2236 EntitiesSavedStates: () => EntitiesSavedStates, 2237 ErrorBoundary: () => error_boundary_default, 2238 FontSizePicker: () => FontSizePicker, 2239 InnerBlocks: () => InnerBlocks, 2240 Inserter: () => Inserter, 2241 InspectorAdvancedControls: () => InspectorAdvancedControls, 2242 InspectorControls: () => InspectorControls, 2243 LocalAutosaveMonitor: () => local_autosave_monitor_default, 2244 MediaPlaceholder: () => MediaPlaceholder, 2245 MediaUpload: () => MediaUpload3, 2246 MediaUploadCheck: () => MediaUploadCheck2, 2247 MultiSelectScrollIntoView: () => MultiSelectScrollIntoView, 2248 NavigableToolbar: () => NavigableToolbar, 2249 ObserveTyping: () => ObserveTyping, 2250 PageAttributesCheck: () => check_default2, 2251 PageAttributesOrder: () => PageAttributesOrderWithChecks, 2252 PageAttributesPanel: () => PageAttributesPanel, 2253 PageAttributesParent: () => parent_default2, 2254 PageTemplate: () => classic_theme_default, 2255 PanelColorSettings: () => PanelColorSettings, 2256 PlainText: () => PlainText, 2257 PluginBlockSettingsMenuItem: () => plugin_block_settings_menu_item_default, 2258 PluginDocumentSettingPanel: () => plugin_document_setting_panel_default, 2259 PluginMoreMenuItem: () => PluginMoreMenuItem, 2260 PluginPostPublishPanel: () => plugin_post_publish_panel_default, 2261 PluginPostStatusInfo: () => plugin_post_status_info_default, 2262 PluginPrePublishPanel: () => plugin_pre_publish_panel_default, 2263 PluginPreviewMenuItem: () => PluginPreviewMenuItem, 2264 PluginSidebar: () => PluginSidebar, 2265 PluginSidebarMoreMenuItem: () => PluginSidebarMoreMenuItem, 2266 PostAuthor: () => post_author_default, 2267 PostAuthorCheck: () => PostAuthorCheck, 2268 PostAuthorPanel: () => panel_default, 2269 PostComments: () => post_comments_default, 2270 PostDiscussionPanel: () => PostDiscussionPanel, 2271 PostExcerpt: () => PostExcerpt, 2272 PostExcerptCheck: () => check_default3, 2273 PostExcerptPanel: () => PostExcerptPanel, 2274 PostFeaturedImage: () => post_featured_image_default, 2275 PostFeaturedImageCheck: () => check_default4, 2276 PostFeaturedImagePanel: () => PostFeaturedImagePanel, 2277 PostFormat: () => PostFormat, 2278 PostFormatCheck: () => PostFormatCheck, 2279 PostLastRevision: () => post_last_revision_default, 2280 PostLastRevisionCheck: () => check_default5, 2281 PostLastRevisionPanel: () => panel_default2, 2282 PostLockedModal: () => post_locked_modal_default, 2283 PostPendingStatus: () => post_pending_status_default, 2284 PostPendingStatusCheck: () => check_default6, 2285 PostPingbacks: () => post_pingbacks_default, 2286 PostPreviewButton: () => PostPreviewButton, 2287 PostPublishButton: () => post_publish_button_default, 2288 PostPublishButtonLabel: () => PublishButtonLabel, 2289 PostPublishPanel: () => post_publish_panel_default, 2290 PostSavedState: () => PostSavedState, 2291 PostSchedule: () => PostSchedule, 2292 PostScheduleCheck: () => PostScheduleCheck, 2293 PostScheduleLabel: () => PostScheduleLabel, 2294 PostSchedulePanel: () => PostSchedulePanel, 2295 PostSticky: () => PostSticky, 2296 PostStickyCheck: () => PostStickyCheck, 2297 PostSwitchToDraftButton: () => PostSwitchToDraftButton, 2298 PostSyncStatus: () => PostSyncStatus, 2299 PostTaxonomies: () => post_taxonomies_default, 2300 PostTaxonomiesCheck: () => PostTaxonomiesCheck, 2301 PostTaxonomiesFlatTermSelector: () => FlatTermSelector, 2302 PostTaxonomiesHierarchicalTermSelector: () => HierarchicalTermSelector, 2303 PostTaxonomiesPanel: () => PostTaxonomies2, 2304 PostTemplatePanel: () => PostTemplatePanel, 2305 PostTextEditor: () => PostTextEditor, 2306 PostTitle: () => post_title_default, 2307 PostTitleRaw: () => post_title_raw_default, 2308 PostTrash: () => PostTrash, 2309 PostTrashCheck: () => PostTrashCheck, 2310 PostTypeSupportCheck: () => post_type_support_check_default, 2311 PostURL: () => PostURL, 2312 PostURLCheck: () => PostURLCheck, 2313 PostURLLabel: () => PostURLLabel, 2314 PostURLPanel: () => PostURLPanel, 2315 PostVisibility: () => PostVisibility, 2316 PostVisibilityCheck: () => PostVisibilityCheck, 2317 PostVisibilityLabel: () => PostVisibilityLabel, 2318 RichText: () => RichText, 2319 RichTextShortcut: () => RichTextShortcut, 2320 RichTextToolbarButton: () => RichTextToolbarButton, 2321 ServerSideRender: () => import_server_side_render.default, 2322 SkipToSelectedBlock: () => SkipToSelectedBlock, 2323 TableOfContents: () => table_of_contents_default, 2324 TextEditorGlobalKeyboardShortcuts: () => TextEditorGlobalKeyboardShortcuts, 2325 ThemeSupportCheck: () => ThemeSupportCheck, 2326 TimeToRead: () => TimeToRead, 2327 URLInput: () => URLInput, 2328 URLInputButton: () => URLInputButton, 2329 URLPopover: () => URLPopover, 2330 UnsavedChangesWarning: () => UnsavedChangesWarning, 2331 VisualEditorGlobalKeyboardShortcuts: () => VisualEditorGlobalKeyboardShortcuts, 2332 Warning: () => Warning, 2333 WordCount: () => WordCount, 2334 WritingFlow: () => WritingFlow, 2335 __unstableRichTextInputEvent: () => __unstableRichTextInputEvent, 2336 cleanForSlug: () => cleanForSlug3, 2337 createCustomColorsHOC: () => createCustomColorsHOC, 2338 getColorClassName: () => getColorClassName2, 2339 getColorObjectByAttributeValues: () => getColorObjectByAttributeValues, 2340 getColorObjectByColorValue: () => getColorObjectByColorValue, 2341 getFontSize: () => getFontSize, 2342 getFontSizeClass: () => getFontSizeClass, 2343 getTemplatePartIcon: () => getTemplatePartIcon, 2344 mediaUpload: () => mediaUpload, 2345 privateApis: () => privateApis3, 2346 registerEntityAction: () => registerEntityAction2, 2347 registerEntityField: () => registerEntityField2, 2348 store: () => store, 2349 storeConfig: () => storeConfig, 2350 transformStyles: () => import_block_editor103.transformStyles, 2351 unregisterEntityAction: () => unregisterEntityAction2, 2352 unregisterEntityField: () => unregisterEntityField2, 2353 useEntitiesSavedStatesIsDirty: () => useIsDirty, 2354 usePostScheduleLabel: () => usePostScheduleLabel, 2355 usePostURLLabel: () => usePostURLLabel, 2356 usePostVisibilityLabel: () => usePostVisibilityLabel, 2357 userAutocompleter: () => user_default, 2358 withColorContext: () => withColorContext, 2359 withColors: () => withColors, 2360 withFontSizes: () => withFontSizes 2361 }); 2362 2363 // packages/editor/build-module/hooks/custom-sources-backwards-compatibility.js 2364 var import_data67 = __toESM(require_data()); 2365 var import_core_data48 = __toESM(require_core_data()); 2366 var import_element72 = __toESM(require_element()); 2367 var import_compose16 = __toESM(require_compose()); 2368 var import_hooks37 = __toESM(require_hooks()); 2369 2370 // packages/editor/build-module/store/index.js 2371 var import_data66 = __toESM(require_data()); 2372 2373 // packages/editor/build-module/store/reducer.js 2374 var import_data2 = __toESM(require_data()); 2375 2376 // packages/editor/build-module/store/defaults.js 2377 var import_block_editor = __toESM(require_block_editor()); 2378 var EDITOR_SETTINGS_DEFAULTS = { 2379 ...import_block_editor.SETTINGS_DEFAULTS, 2380 richEditingEnabled: true, 2381 codeEditingEnabled: true, 2382 fontLibraryEnabled: true, 2383 enableCustomFields: void 0, 2384 defaultRenderingMode: "post-only" 2385 }; 2386 2387 // packages/editor/build-module/dataviews/store/reducer.js 2388 var import_data = __toESM(require_data()); 2389 function isReady(state = {}, action) { 2390 switch (action.type) { 2391 case "SET_IS_READY": 2392 return { 2393 ...state, 2394 [action.kind]: { 2395 ...state[action.kind], 2396 [action.name]: true 2397 } 2398 }; 2399 } 2400 return state; 2401 } 2402 function actions(state = {}, action) { 2403 switch (action.type) { 2404 case "REGISTER_ENTITY_ACTION": 2405 return { 2406 ...state, 2407 [action.kind]: { 2408 ...state[action.kind], 2409 [action.name]: [ 2410 ...(state[action.kind]?.[action.name] ?? []).filter( 2411 (_action) => _action.id !== action.config.id 2412 ), 2413 action.config 2414 ] 2415 } 2416 }; 2417 case "UNREGISTER_ENTITY_ACTION": { 2418 return { 2419 ...state, 2420 [action.kind]: { 2421 ...state[action.kind], 2422 [action.name]: (state[action.kind]?.[action.name] ?? []).filter((_action) => _action.id !== action.actionId) 2423 } 2424 }; 2425 } 2426 } 2427 return state; 2428 } 2429 function fields(state = {}, action) { 2430 switch (action.type) { 2431 case "REGISTER_ENTITY_FIELD": 2432 return { 2433 ...state, 2434 [action.kind]: { 2435 ...state[action.kind], 2436 [action.name]: [ 2437 ...(state[action.kind]?.[action.name] ?? []).filter( 2438 (_field) => _field.id !== action.config.id 2439 ), 2440 action.config 2441 ] 2442 } 2443 }; 2444 case "UNREGISTER_ENTITY_FIELD": 2445 return { 2446 ...state, 2447 [action.kind]: { 2448 ...state[action.kind], 2449 [action.name]: (state[action.kind]?.[action.name] ?? []).filter((_field) => _field.id !== action.fieldId) 2450 } 2451 }; 2452 } 2453 return state; 2454 } 2455 var reducer_default = (0, import_data.combineReducers)({ 2456 actions, 2457 fields, 2458 isReady 2459 }); 2460 2461 // packages/editor/build-module/store/reducer.js 2462 function getPostRawValue(value) { 2463 if (value && "object" === typeof value && "raw" in value) { 2464 return value.raw; 2465 } 2466 return value; 2467 } 2468 function postId(state = null, action) { 2469 switch (action.type) { 2470 case "SET_EDITED_POST": 2471 return action.postId; 2472 } 2473 return state; 2474 } 2475 function templateId(state = null, action) { 2476 switch (action.type) { 2477 case "SET_CURRENT_TEMPLATE_ID": 2478 return action.id; 2479 } 2480 return state; 2481 } 2482 function postType(state = null, action) { 2483 switch (action.type) { 2484 case "SET_EDITED_POST": 2485 return action.postType; 2486 } 2487 return state; 2488 } 2489 function template(state = { isValid: true }, action) { 2490 switch (action.type) { 2491 case "SET_TEMPLATE_VALIDITY": 2492 return { 2493 ...state, 2494 isValid: action.isValid 2495 }; 2496 } 2497 return state; 2498 } 2499 function saving(state = {}, action) { 2500 switch (action.type) { 2501 case "REQUEST_POST_UPDATE_START": 2502 case "REQUEST_POST_UPDATE_FINISH": 2503 return { 2504 pending: action.type === "REQUEST_POST_UPDATE_START", 2505 options: action.options || {} 2506 }; 2507 } 2508 return state; 2509 } 2510 function deleting(state = {}, action) { 2511 switch (action.type) { 2512 case "REQUEST_POST_DELETE_START": 2513 case "REQUEST_POST_DELETE_FINISH": 2514 return { 2515 pending: action.type === "REQUEST_POST_DELETE_START" 2516 }; 2517 } 2518 return state; 2519 } 2520 function postLock(state = { isLocked: false }, action) { 2521 switch (action.type) { 2522 case "UPDATE_POST_LOCK": 2523 return action.lock; 2524 } 2525 return state; 2526 } 2527 function postSavingLock(state = {}, action) { 2528 switch (action.type) { 2529 case "LOCK_POST_SAVING": 2530 return { ...state, [action.lockName]: true }; 2531 case "UNLOCK_POST_SAVING": { 2532 const { [action.lockName]: removedLockName, ...restState } = state; 2533 return restState; 2534 } 2535 } 2536 return state; 2537 } 2538 function postAutosavingLock(state = {}, action) { 2539 switch (action.type) { 2540 case "LOCK_POST_AUTOSAVING": 2541 return { ...state, [action.lockName]: true }; 2542 case "UNLOCK_POST_AUTOSAVING": { 2543 const { [action.lockName]: removedLockName, ...restState } = state; 2544 return restState; 2545 } 2546 } 2547 return state; 2548 } 2549 function editorSettings(state = EDITOR_SETTINGS_DEFAULTS, action) { 2550 switch (action.type) { 2551 case "UPDATE_EDITOR_SETTINGS": 2552 return { 2553 ...state, 2554 ...action.settings 2555 }; 2556 } 2557 return state; 2558 } 2559 function renderingMode(state = "post-only", action) { 2560 switch (action.type) { 2561 case "SET_RENDERING_MODE": 2562 return action.mode; 2563 } 2564 return state; 2565 } 2566 function deviceType(state = "Desktop", action) { 2567 switch (action.type) { 2568 case "SET_DEVICE_TYPE": 2569 return action.deviceType; 2570 } 2571 return state; 2572 } 2573 function removedPanels(state = [], action) { 2574 switch (action.type) { 2575 case "REMOVE_PANEL": 2576 if (!state.includes(action.panelName)) { 2577 return [...state, action.panelName]; 2578 } 2579 } 2580 return state; 2581 } 2582 function blockInserterPanel(state = false, action) { 2583 switch (action.type) { 2584 case "SET_IS_LIST_VIEW_OPENED": 2585 return action.isOpen ? false : state; 2586 case "SET_IS_INSERTER_OPENED": 2587 return action.value; 2588 } 2589 return state; 2590 } 2591 function listViewPanel(state = false, action) { 2592 switch (action.type) { 2593 case "SET_IS_INSERTER_OPENED": 2594 return action.value ? false : state; 2595 case "SET_IS_LIST_VIEW_OPENED": 2596 return action.isOpen; 2597 } 2598 return state; 2599 } 2600 function listViewToggleRef(state = { current: null }) { 2601 return state; 2602 } 2603 function inserterSidebarToggleRef(state = { current: null }) { 2604 return state; 2605 } 2606 function publishSidebarActive(state = false, action) { 2607 switch (action.type) { 2608 case "OPEN_PUBLISH_SIDEBAR": 2609 return true; 2610 case "CLOSE_PUBLISH_SIDEBAR": 2611 return false; 2612 case "TOGGLE_PUBLISH_SIDEBAR": 2613 return !state; 2614 } 2615 return state; 2616 } 2617 function stylesPath(state = "/", action) { 2618 switch (action.type) { 2619 case "SET_STYLES_PATH": 2620 return action.path; 2621 case "RESET_STYLES_NAVIGATION": 2622 return "/"; 2623 } 2624 return state; 2625 } 2626 function showStylebook(state = false, action) { 2627 switch (action.type) { 2628 case "SET_SHOW_STYLEBOOK": 2629 return action.show; 2630 case "RESET_STYLES_NAVIGATION": 2631 return false; 2632 } 2633 return state; 2634 } 2635 function canvasMinHeight(state = 0, action) { 2636 switch (action.type) { 2637 case "SET_CANVAS_MIN_HEIGHT": 2638 return action.minHeight; 2639 } 2640 return state; 2641 } 2642 var reducer_default2 = (0, import_data2.combineReducers)({ 2643 postId, 2644 postType, 2645 templateId, 2646 saving, 2647 deleting, 2648 postLock, 2649 template, 2650 postSavingLock, 2651 editorSettings, 2652 postAutosavingLock, 2653 renderingMode, 2654 deviceType, 2655 removedPanels, 2656 blockInserterPanel, 2657 inserterSidebarToggleRef, 2658 listViewPanel, 2659 listViewToggleRef, 2660 publishSidebarActive, 2661 stylesPath, 2662 showStylebook, 2663 canvasMinHeight, 2664 dataviews: reducer_default 2665 }); 2666 2667 // packages/editor/build-module/store/selectors.js 2668 var selectors_exports = {}; 2669 __export(selectors_exports, { 2670 __experimentalGetDefaultTemplatePartAreas: () => __experimentalGetDefaultTemplatePartAreas, 2671 __experimentalGetDefaultTemplateType: () => __experimentalGetDefaultTemplateType, 2672 __experimentalGetDefaultTemplateTypes: () => __experimentalGetDefaultTemplateTypes, 2673 __experimentalGetTemplateInfo: () => __experimentalGetTemplateInfo, 2674 __unstableIsEditorReady: () => __unstableIsEditorReady, 2675 canInsertBlockType: () => canInsertBlockType, 2676 canUserUseUnfilteredHTML: () => canUserUseUnfilteredHTML, 2677 didPostSaveRequestFail: () => didPostSaveRequestFail, 2678 didPostSaveRequestSucceed: () => didPostSaveRequestSucceed, 2679 getActivePostLock: () => getActivePostLock, 2680 getAdjacentBlockClientId: () => getAdjacentBlockClientId, 2681 getAutosaveAttribute: () => getAutosaveAttribute, 2682 getBlock: () => getBlock, 2683 getBlockAttributes: () => getBlockAttributes, 2684 getBlockCount: () => getBlockCount, 2685 getBlockHierarchyRootClientId: () => getBlockHierarchyRootClientId, 2686 getBlockIndex: () => getBlockIndex, 2687 getBlockInsertionPoint: () => getBlockInsertionPoint, 2688 getBlockListSettings: () => getBlockListSettings, 2689 getBlockMode: () => getBlockMode, 2690 getBlockName: () => getBlockName, 2691 getBlockOrder: () => getBlockOrder, 2692 getBlockRootClientId: () => getBlockRootClientId, 2693 getBlockSelectionEnd: () => getBlockSelectionEnd, 2694 getBlockSelectionStart: () => getBlockSelectionStart, 2695 getBlocks: () => getBlocks, 2696 getBlocksByClientId: () => getBlocksByClientId, 2697 getClientIdsOfDescendants: () => getClientIdsOfDescendants, 2698 getClientIdsWithDescendants: () => getClientIdsWithDescendants, 2699 getCurrentPost: () => getCurrentPost, 2700 getCurrentPostAttribute: () => getCurrentPostAttribute, 2701 getCurrentPostId: () => getCurrentPostId, 2702 getCurrentPostLastRevisionId: () => getCurrentPostLastRevisionId, 2703 getCurrentPostRevisionsCount: () => getCurrentPostRevisionsCount, 2704 getCurrentPostType: () => getCurrentPostType, 2705 getCurrentTemplateId: () => getCurrentTemplateId, 2706 getDeviceType: () => getDeviceType, 2707 getEditedPostAttribute: () => getEditedPostAttribute, 2708 getEditedPostContent: () => getEditedPostContent, 2709 getEditedPostPreviewLink: () => getEditedPostPreviewLink, 2710 getEditedPostSlug: () => getEditedPostSlug, 2711 getEditedPostVisibility: () => getEditedPostVisibility, 2712 getEditorBlocks: () => getEditorBlocks, 2713 getEditorMode: () => getEditorMode, 2714 getEditorSelection: () => getEditorSelection, 2715 getEditorSelectionEnd: () => getEditorSelectionEnd, 2716 getEditorSelectionStart: () => getEditorSelectionStart, 2717 getEditorSettings: () => getEditorSettings, 2718 getFirstMultiSelectedBlockClientId: () => getFirstMultiSelectedBlockClientId, 2719 getGlobalBlockCount: () => getGlobalBlockCount, 2720 getInserterItems: () => getInserterItems, 2721 getLastMultiSelectedBlockClientId: () => getLastMultiSelectedBlockClientId, 2722 getMultiSelectedBlockClientIds: () => getMultiSelectedBlockClientIds, 2723 getMultiSelectedBlocks: () => getMultiSelectedBlocks, 2724 getMultiSelectedBlocksEndClientId: () => getMultiSelectedBlocksEndClientId, 2725 getMultiSelectedBlocksStartClientId: () => getMultiSelectedBlocksStartClientId, 2726 getNextBlockClientId: () => getNextBlockClientId, 2727 getPermalink: () => getPermalink, 2728 getPermalinkParts: () => getPermalinkParts, 2729 getPostEdits: () => getPostEdits, 2730 getPostLockUser: () => getPostLockUser, 2731 getPostTypeLabel: () => getPostTypeLabel, 2732 getPreviousBlockClientId: () => getPreviousBlockClientId, 2733 getRenderingMode: () => getRenderingMode, 2734 getSelectedBlock: () => getSelectedBlock, 2735 getSelectedBlockClientId: () => getSelectedBlockClientId, 2736 getSelectedBlockCount: () => getSelectedBlockCount, 2737 getSelectedBlocksInitialCaretPosition: () => getSelectedBlocksInitialCaretPosition, 2738 getStateBeforeOptimisticTransaction: () => getStateBeforeOptimisticTransaction, 2739 getSuggestedPostFormat: () => getSuggestedPostFormat, 2740 getTemplate: () => getTemplate, 2741 getTemplateLock: () => getTemplateLock, 2742 hasChangedContent: () => hasChangedContent, 2743 hasEditorRedo: () => hasEditorRedo, 2744 hasEditorUndo: () => hasEditorUndo, 2745 hasInserterItems: () => hasInserterItems, 2746 hasMultiSelection: () => hasMultiSelection, 2747 hasNonPostEntityChanges: () => hasNonPostEntityChanges, 2748 hasSelectedBlock: () => hasSelectedBlock, 2749 hasSelectedInnerBlock: () => hasSelectedInnerBlock, 2750 inSomeHistory: () => inSomeHistory, 2751 isAncestorMultiSelected: () => isAncestorMultiSelected, 2752 isAutosavingPost: () => isAutosavingPost, 2753 isBlockInsertionPointVisible: () => isBlockInsertionPointVisible, 2754 isBlockMultiSelected: () => isBlockMultiSelected, 2755 isBlockSelected: () => isBlockSelected, 2756 isBlockValid: () => isBlockValid, 2757 isBlockWithinSelection: () => isBlockWithinSelection, 2758 isCaretWithinFormattedText: () => isCaretWithinFormattedText, 2759 isCleanNewPost: () => isCleanNewPost, 2760 isCurrentPostPending: () => isCurrentPostPending, 2761 isCurrentPostPublished: () => isCurrentPostPublished, 2762 isCurrentPostScheduled: () => isCurrentPostScheduled, 2763 isDeletingPost: () => isDeletingPost, 2764 isEditedPostAutosaveable: () => isEditedPostAutosaveable, 2765 isEditedPostBeingScheduled: () => isEditedPostBeingScheduled, 2766 isEditedPostDateFloating: () => isEditedPostDateFloating, 2767 isEditedPostDirty: () => isEditedPostDirty, 2768 isEditedPostEmpty: () => isEditedPostEmpty, 2769 isEditedPostNew: () => isEditedPostNew, 2770 isEditedPostPublishable: () => isEditedPostPublishable, 2771 isEditedPostSaveable: () => isEditedPostSaveable, 2772 isEditorPanelEnabled: () => isEditorPanelEnabled, 2773 isEditorPanelOpened: () => isEditorPanelOpened, 2774 isEditorPanelRemoved: () => isEditorPanelRemoved, 2775 isFirstMultiSelectedBlock: () => isFirstMultiSelectedBlock, 2776 isInserterOpened: () => isInserterOpened, 2777 isListViewOpened: () => isListViewOpened, 2778 isMultiSelecting: () => isMultiSelecting, 2779 isPermalinkEditable: () => isPermalinkEditable, 2780 isPostAutosavingLocked: () => isPostAutosavingLocked, 2781 isPostLockTakeover: () => isPostLockTakeover, 2782 isPostLocked: () => isPostLocked, 2783 isPostSavingLocked: () => isPostSavingLocked, 2784 isPreviewingPost: () => isPreviewingPost, 2785 isPublishSidebarEnabled: () => isPublishSidebarEnabled, 2786 isPublishSidebarOpened: () => isPublishSidebarOpened, 2787 isPublishingPost: () => isPublishingPost, 2788 isSavingNonPostEntityChanges: () => isSavingNonPostEntityChanges, 2789 isSavingPost: () => isSavingPost, 2790 isSelectionEnabled: () => isSelectionEnabled, 2791 isTyping: () => isTyping, 2792 isValidTemplate: () => isValidTemplate 2793 }); 2794 var import_blocks = __toESM(require_blocks()); 2795 var import_date = __toESM(require_date()); 2796 var import_url = __toESM(require_url()); 2797 var import_data3 = __toESM(require_data()); 2798 var import_deprecated = __toESM(require_deprecated()); 2799 var import_element2 = __toESM(require_element()); 2800 var import_block_editor2 = __toESM(require_block_editor()); 2801 var import_core_data = __toESM(require_core_data()); 2802 var import_preferences = __toESM(require_preferences()); 2803 2804 // packages/editor/build-module/store/constants.js 2805 var EDIT_MERGE_PROPERTIES = /* @__PURE__ */ new Set(["meta"]); 2806 var STORE_NAME = "core/editor"; 2807 var PERMALINK_POSTNAME_REGEX = /%(?:postname|pagename)%/; 2808 var ONE_MINUTE_IN_MS = 60 * 1e3; 2809 var AUTOSAVE_PROPERTIES = ["title", "excerpt", "content"]; 2810 var TEMPLATE_POST_TYPE = "wp_template"; 2811 var TEMPLATE_PART_POST_TYPE = "wp_template_part"; 2812 var PATTERN_POST_TYPE = "wp_block"; 2813 var NAVIGATION_POST_TYPE = "wp_navigation"; 2814 var TEMPLATE_ORIGINS = { 2815 custom: "custom", 2816 theme: "theme", 2817 plugin: "plugin" 2818 }; 2819 var TEMPLATE_POST_TYPES = ["wp_template", "wp_template_part"]; 2820 var GLOBAL_POST_TYPES = [ 2821 ...TEMPLATE_POST_TYPES, 2822 "wp_block", 2823 "wp_navigation" 2824 ]; 2825 var DESIGN_POST_TYPES = [ 2826 TEMPLATE_POST_TYPE, 2827 TEMPLATE_PART_POST_TYPE, 2828 PATTERN_POST_TYPE, 2829 NAVIGATION_POST_TYPE 2830 ]; 2831 2832 // packages/icons/build-module/icon/index.js 2833 var import_element = __toESM(require_element()); 2834 var icon_default = (0, import_element.forwardRef)( 2835 ({ icon, size: size3 = 24, ...props }, ref) => { 2836 return (0, import_element.cloneElement)(icon, { 2837 width: size3, 2838 height: size3, 2839 ...props, 2840 ref 2841 }); 2842 } 2843 ); 2844 2845 // packages/icons/build-module/library/add-template.js 2846 var import_primitives = __toESM(require_primitives()); 2847 var import_jsx_runtime = __toESM(require_jsx_runtime()); 2848 var add_template_default = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_primitives.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)( 2849 import_primitives.Path, 2850 { 2851 fillRule: "evenodd", 2852 clipRule: "evenodd", 2853 d: "M18.5 5.5V8H20V5.5H22.5V4H20V1.5H18.5V4H16V5.5H18.5ZM13.9624 4H6C4.89543 4 4 4.89543 4 6V18C4 19.1046 4.89543 20 6 20H18C19.1046 20 20 19.1046 20 18V10.0391H18.5V18C18.5 18.2761 18.2761 18.5 18 18.5H10L10 10.4917L16.4589 10.5139L16.4641 9.01389L5.5 8.97618V6C5.5 5.72386 5.72386 5.5 6 5.5H13.9624V4ZM5.5 10.4762V18C5.5 18.2761 5.72386 18.5 6 18.5H8.5L8.5 10.4865L5.5 10.4762Z" 2854 } 2855 ) }); 2856 2857 // packages/icons/build-module/library/background.js 2858 var import_primitives2 = __toESM(require_primitives()); 2859 var import_jsx_runtime2 = __toESM(require_jsx_runtime()); 2860 var background_default = /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_primitives2.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)( 2861 import_primitives2.Path, 2862 { 2863 fillRule: "evenodd", 2864 clipRule: "evenodd", 2865 d: "M11.53 4.47a.75.75 0 1 0-1.06 1.06l8 8a.75.75 0 1 0 1.06-1.06l-8-8Zm5 1a.75.75 0 1 0-1.06 1.06l2 2a.75.75 0 1 0 1.06-1.06l-2-2Zm-11.06 10a.75.75 0 0 1 1.06 0l2 2a.75.75 0 1 1-1.06 1.06l-2-2a.75.75 0 0 1 0-1.06Zm.06-5a.75.75 0 0 0-1.06 1.06l8 8a.75.75 0 1 0 1.06-1.06l-8-8Zm-.06-3a.75.75 0 0 1 1.06 0l10 10a.75.75 0 1 1-1.06 1.06l-10-10a.75.75 0 0 1 0-1.06Zm3.06-2a.75.75 0 0 0-1.06 1.06l10 10a.75.75 0 1 0 1.06-1.06l-10-10Z" 2866 } 2867 ) }); 2868 2869 // packages/icons/build-module/library/backup.js 2870 var import_primitives3 = __toESM(require_primitives()); 2871 var import_jsx_runtime3 = __toESM(require_jsx_runtime()); 2872 var backup_default = /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_primitives3.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_primitives3.Path, { d: "M5.5 12h1.75l-2.5 3-2.5-3H4a8 8 0 113.134 6.35l.907-1.194A6.5 6.5 0 105.5 12zm9.53 1.97l-2.28-2.28V8.5a.75.75 0 00-1.5 0V12a.747.747 0 00.218.529l1.282-.84-1.28.842 2.5 2.5a.75.75 0 101.06-1.061z" }) }); 2873 2874 // packages/icons/build-module/library/block-default.js 2875 var import_primitives4 = __toESM(require_primitives()); 2876 var import_jsx_runtime4 = __toESM(require_jsx_runtime()); 2877 var block_default_default = /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_primitives4.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_primitives4.Path, { d: "M19 8h-1V6h-5v2h-2V6H6v2H5c-1.1 0-2 .9-2 2v8c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2v-8c0-1.1-.9-2-2-2zm.5 10c0 .3-.2.5-.5.5H5c-.3 0-.5-.2-.5-.5v-8c0-.3.2-.5.5-.5h14c.3 0 .5.2.5.5v8z" }) }); 2878 2879 // packages/icons/build-module/library/check.js 2880 var import_primitives5 = __toESM(require_primitives()); 2881 var import_jsx_runtime5 = __toESM(require_jsx_runtime()); 2882 var check_default = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_primitives5.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_primitives5.Path, { d: "M16.5 7.5 10 13.9l-2.5-2.4-1 1 3.5 3.6 7.5-7.6z" }) }); 2883 2884 // packages/icons/build-module/library/chevron-left-small.js 2885 var import_primitives6 = __toESM(require_primitives()); 2886 var import_jsx_runtime6 = __toESM(require_jsx_runtime()); 2887 var chevron_left_small_default = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_primitives6.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_primitives6.Path, { d: "m13.1 16-3.4-4 3.4-4 1.1 1-2.6 3 2.6 3-1.1 1z" }) }); 2888 2889 // packages/icons/build-module/library/chevron-left.js 2890 var import_primitives7 = __toESM(require_primitives()); 2891 var import_jsx_runtime7 = __toESM(require_jsx_runtime()); 2892 var chevron_left_default = /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_primitives7.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_primitives7.Path, { d: "M14.6 7l-1.2-1L8 12l5.4 6 1.2-1-4.6-5z" }) }); 2893 2894 // packages/icons/build-module/library/chevron-right-small.js 2895 var import_primitives8 = __toESM(require_primitives()); 2896 var import_jsx_runtime8 = __toESM(require_jsx_runtime()); 2897 var chevron_right_small_default = /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_primitives8.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_primitives8.Path, { d: "M10.8622 8.04053L14.2805 12.0286L10.8622 16.0167L9.72327 15.0405L12.3049 12.0286L9.72327 9.01672L10.8622 8.04053Z" }) }); 2898 2899 // packages/icons/build-module/library/chevron-right.js 2900 var import_primitives9 = __toESM(require_primitives()); 2901 var import_jsx_runtime9 = __toESM(require_jsx_runtime()); 2902 var chevron_right_default = /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_primitives9.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_primitives9.Path, { d: "M10.6 6L9.4 7l4.6 5-4.6 5 1.2 1 5.4-6z" }) }); 2903 2904 // packages/icons/build-module/library/close-small.js 2905 var import_primitives10 = __toESM(require_primitives()); 2906 var import_jsx_runtime10 = __toESM(require_jsx_runtime()); 2907 var close_small_default = /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_primitives10.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_primitives10.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" }) }); 2908 2909 // packages/icons/build-module/library/cloud-upload.js 2910 var import_primitives11 = __toESM(require_primitives()); 2911 var import_jsx_runtime11 = __toESM(require_jsx_runtime()); 2912 var cloud_upload_default = /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_primitives11.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_primitives11.Path, { d: "M17.3 10.1C17.3 7.60001 15.2 5.70001 12.5 5.70001C10.3 5.70001 8.4 7.10001 7.9 9.00001H7.7C5.7 9.00001 4 10.7 4 12.8C4 14.9 5.7 16.6 7.7 16.6H9.5V15.2H7.7C6.5 15.2 5.5 14.1 5.5 12.9C5.5 11.7 6.5 10.5 7.7 10.5H9L9.3 9.40001C9.7 8.10001 11 7.20001 12.5 7.20001C14.3 7.20001 15.8 8.50001 15.8 10.1V11.4L17.1 11.6C17.9 11.7 18.5 12.5 18.5 13.4C18.5 14.4 17.7 15.2 16.8 15.2H14.5V16.6H16.7C18.5 16.6 19.9 15.1 19.9 13.3C20 11.7 18.8 10.4 17.3 10.1Z M14.1245 14.2426L15.1852 13.182L12.0032 10L8.82007 13.1831L9.88072 14.2438L11.25 12.8745V18H12.75V12.8681L14.1245 14.2426Z" }) }); 2913 2914 // packages/icons/build-module/library/cloud.js 2915 var import_primitives12 = __toESM(require_primitives()); 2916 var import_jsx_runtime12 = __toESM(require_jsx_runtime()); 2917 var cloud_default = /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_primitives12.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_primitives12.Path, { d: "M17.3 10.1c0-2.5-2.1-4.4-4.8-4.4-2.2 0-4.1 1.4-4.6 3.3h-.2C5.7 9 4 10.7 4 12.8c0 2.1 1.7 3.8 3.7 3.8h9c1.8 0 3.2-1.5 3.2-3.3.1-1.6-1.1-2.9-2.6-3.2zm-.5 5.1h-9c-1.2 0-2.2-1.1-2.2-2.3s1-2.4 2.2-2.4h1.3l.3-1.1c.4-1.3 1.7-2.2 3.2-2.2 1.8 0 3.3 1.3 3.3 2.9v1.3l1.3.2c.8.1 1.4.9 1.4 1.8-.1 1-.9 1.8-1.8 1.8z" }) }); 2918 2919 // packages/icons/build-module/library/code.js 2920 var import_primitives13 = __toESM(require_primitives()); 2921 var import_jsx_runtime13 = __toESM(require_jsx_runtime()); 2922 var code_default = /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_primitives13.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_primitives13.Path, { d: "M20.8 10.7l-4.3-4.3-1.1 1.1 4.3 4.3c.1.1.1.3 0 .4l-4.3 4.3 1.1 1.1 4.3-4.3c.7-.8.7-1.9 0-2.6zM4.2 11.8l4.3-4.3-1-1-4.3 4.3c-.7.7-.7 1.8 0 2.5l4.3 4.3 1.1-1.1-4.3-4.3c-.2-.1-.2-.3-.1-.4z" }) }); 2923 2924 // packages/icons/build-module/library/color.js 2925 var import_primitives14 = __toESM(require_primitives()); 2926 var import_jsx_runtime14 = __toESM(require_jsx_runtime()); 2927 var color_default = /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_primitives14.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_primitives14.Path, { d: "M17.2 10.9c-.5-1-1.2-2.1-2.1-3.2-.6-.9-1.3-1.7-2.1-2.6L12 4l-1 1.1c-.6.9-1.3 1.7-2 2.6-.8 1.2-1.5 2.3-2 3.2-.6 1.2-1 2.2-1 3 0 3.4 2.7 6.1 6.1 6.1s6.1-2.7 6.1-6.1c0-.8-.3-1.8-1-3zm-5.1 7.6c-2.5 0-4.6-2.1-4.6-4.6 0-.3.1-1 .8-2.3.5-.9 1.1-1.9 2-3.1.7-.9 1.3-1.7 1.8-2.3.7.8 1.3 1.6 1.8 2.3.8 1.1 1.5 2.2 2 3.1.7 1.3.8 2 .8 2.3 0 2.5-2.1 4.6-4.6 4.6z" }) }); 2928 2929 // packages/icons/build-module/library/comment-author-avatar.js 2930 var import_primitives15 = __toESM(require_primitives()); 2931 var import_jsx_runtime15 = __toESM(require_jsx_runtime()); 2932 var comment_author_avatar_default = /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_primitives15.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)( 2933 import_primitives15.Path, 2934 { 2935 fillRule: "evenodd", 2936 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", 2937 clipRule: "evenodd" 2938 } 2939 ) }); 2940 2941 // packages/icons/build-module/library/comment.js 2942 var import_primitives16 = __toESM(require_primitives()); 2943 var import_jsx_runtime16 = __toESM(require_jsx_runtime()); 2944 var comment_default = /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_primitives16.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_primitives16.Path, { d: "M18 4H6c-1.1 0-2 .9-2 2v12.9c0 .6.5 1.1 1.1 1.1.3 0 .5-.1.8-.3L8.5 17H18c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm.5 11c0 .3-.2.5-.5.5H7.9l-2.4 2.4V6c0-.3.2-.5.5-.5h12c.3 0 .5.2.5.5v9z" }) }); 2945 2946 // packages/icons/build-module/library/copy-small.js 2947 var import_primitives17 = __toESM(require_primitives()); 2948 var import_jsx_runtime17 = __toESM(require_jsx_runtime()); 2949 var copy_small_default = /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_primitives17.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)( 2950 import_primitives17.Path, 2951 { 2952 fillRule: "evenodd", 2953 clipRule: "evenodd", 2954 d: "M5.625 5.5h9.75c.069 0 .125.056.125.125v9.75a.125.125 0 0 1-.125.125h-9.75a.125.125 0 0 1-.125-.125v-9.75c0-.069.056-.125.125-.125ZM4 5.625C4 4.728 4.728 4 5.625 4h9.75C16.273 4 17 4.728 17 5.625v9.75c0 .898-.727 1.625-1.625 1.625h-9.75A1.625 1.625 0 0 1 4 15.375v-9.75Zm14.5 11.656v-9H20v9C20 18.8 18.77 20 17.251 20H6.25v-1.5h11.001c.69 0 1.249-.528 1.249-1.219Z" 2955 } 2956 ) }); 2957 2958 // packages/icons/build-module/library/desktop.js 2959 var import_primitives18 = __toESM(require_primitives()); 2960 var import_jsx_runtime18 = __toESM(require_jsx_runtime()); 2961 var desktop_default = /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_primitives18.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_primitives18.Path, { d: "M20.5 16h-.7V8c0-1.1-.9-2-2-2H6.2c-1.1 0-2 .9-2 2v8h-.7c-.8 0-1.5.7-1.5 1.5h20c0-.8-.7-1.5-1.5-1.5zM5.7 8c0-.3.2-.5.5-.5h11.6c.3 0 .5.2.5.5v7.6H5.7V8z" }) }); 2962 2963 // packages/icons/build-module/library/download.js 2964 var import_primitives19 = __toESM(require_primitives()); 2965 var import_jsx_runtime19 = __toESM(require_jsx_runtime()); 2966 var download_default = /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_primitives19.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_primitives19.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" }) }); 2967 2968 // packages/icons/build-module/library/drafts.js 2969 var import_primitives20 = __toESM(require_primitives()); 2970 var import_jsx_runtime20 = __toESM(require_jsx_runtime()); 2971 var drafts_default = /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_primitives20.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)( 2972 import_primitives20.Path, 2973 { 2974 fillRule: "evenodd", 2975 clipRule: "evenodd", 2976 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" 2977 } 2978 ) }); 2979 2980 // packages/icons/build-module/library/drawer-left.js 2981 var import_primitives21 = __toESM(require_primitives()); 2982 var import_jsx_runtime21 = __toESM(require_jsx_runtime()); 2983 var drawer_left_default = /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_primitives21.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)( 2984 import_primitives21.Path, 2985 { 2986 fillRule: "evenodd", 2987 clipRule: "evenodd", 2988 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-2zM8.5 18.5H6c-.3 0-.5-.2-.5-.5V6c0-.3.2-.5.5-.5h2.5v13zm10-.5c0 .3-.2.5-.5.5h-8v-13h8c.3 0 .5.2.5.5v12z" 2989 } 2990 ) }); 2991 2992 // packages/icons/build-module/library/drawer-right.js 2993 var import_primitives22 = __toESM(require_primitives()); 2994 var import_jsx_runtime22 = __toESM(require_jsx_runtime()); 2995 var drawer_right_default = /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_primitives22.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)( 2996 import_primitives22.Path, 2997 { 2998 fillRule: "evenodd", 2999 clipRule: "evenodd", 3000 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" 3001 } 3002 ) }); 3003 3004 // packages/icons/build-module/library/external.js 3005 var import_primitives23 = __toESM(require_primitives()); 3006 var import_jsx_runtime23 = __toESM(require_jsx_runtime()); 3007 var external_default = /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_primitives23.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_primitives23.Path, { d: "M19.5 4.5h-7V6h4.44l-5.97 5.97 1.06 1.06L18 7.06v4.44h1.5v-7Zm-13 1a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-3H17v3a.5.5 0 0 1-.5.5h-10a.5.5 0 0 1-.5-.5v-10a.5.5 0 0 1 .5-.5h3V5.5h-3Z" }) }); 3008 3009 // packages/icons/build-module/library/footer.js 3010 var import_primitives24 = __toESM(require_primitives()); 3011 var import_jsx_runtime24 = __toESM(require_jsx_runtime()); 3012 var footer_default = /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_primitives24.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)( 3013 import_primitives24.Path, 3014 { 3015 fillRule: "evenodd", 3016 d: "M18 5.5h-8v8h8.5V6a.5.5 0 00-.5-.5zm-9.5 8h-3V6a.5.5 0 01.5-.5h2.5v8zM6 4h12a2 2 0 012 2v12a2 2 0 01-2 2H6a2 2 0 01-2-2V6a2 2 0 012-2z" 3017 } 3018 ) }); 3019 3020 // packages/icons/build-module/library/format-list-bullets.js 3021 var import_primitives25 = __toESM(require_primitives()); 3022 var import_jsx_runtime25 = __toESM(require_jsx_runtime()); 3023 var format_list_bullets_default = /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_primitives25.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_primitives25.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" }) }); 3024 3025 // packages/icons/build-module/library/header.js 3026 var import_primitives26 = __toESM(require_primitives()); 3027 var import_jsx_runtime26 = __toESM(require_jsx_runtime()); 3028 var header_default = /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_primitives26.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_primitives26.Path, { d: "M18.5 10.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" }) }); 3029 3030 // packages/icons/build-module/library/info.js 3031 var import_primitives27 = __toESM(require_primitives()); 3032 var import_jsx_runtime27 = __toESM(require_jsx_runtime()); 3033 var info_default = /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_primitives27.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)( 3034 import_primitives27.Path, 3035 { 3036 fillRule: "evenodd", 3037 clipRule: "evenodd", 3038 d: "M5.5 12a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0ZM12 4a8 8 0 1 0 0 16 8 8 0 0 0 0-16Zm.75 4v1.5h-1.5V8h1.5Zm0 8v-5h-1.5v5h1.5Z" 3039 } 3040 ) }); 3041 3042 // packages/icons/build-module/library/keyboard.js 3043 var import_primitives28 = __toESM(require_primitives()); 3044 var import_jsx_runtime28 = __toESM(require_jsx_runtime()); 3045 var keyboard_default = /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(import_primitives28.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: [ 3046 /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_primitives28.Path, { d: "m16 15.5h-8v-1.5h8zm-7.5-2.5h-2v-2h2zm3 0h-2v-2h2zm3 0h-2v-2h2zm3 0h-2v-2h2zm-9-3h-2v-2h2zm3 0h-2v-2h2zm3 0h-2v-2h2zm3 0h-2v-2h2z" }), 3047 /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_primitives28.Path, { d: "m18.5 6.5h-13a.5.5 0 0 0 -.5.5v9.5a.5.5 0 0 0 .5.5h13a.5.5 0 0 0 .5-.5v-9.5a.5.5 0 0 0 -.5-.5zm-13-1.5h13a2 2 0 0 1 2 2v9.5a2 2 0 0 1 -2 2h-13a2 2 0 0 1 -2-2v-9.5a2 2 0 0 1 2-2z" }) 3048 ] }); 3049 3050 // packages/icons/build-module/library/layout.js 3051 var import_primitives29 = __toESM(require_primitives()); 3052 var import_jsx_runtime29 = __toESM(require_jsx_runtime()); 3053 var layout_default = /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_primitives29.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_primitives29.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" }) }); 3054 3055 // packages/icons/build-module/library/line-solid.js 3056 var import_primitives30 = __toESM(require_primitives()); 3057 var import_jsx_runtime30 = __toESM(require_jsx_runtime()); 3058 var line_solid_default = /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_primitives30.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_primitives30.Path, { d: "M5 11.25h14v1.5H5z" }) }); 3059 3060 // packages/icons/build-module/library/list-view.js 3061 var import_primitives31 = __toESM(require_primitives()); 3062 var import_jsx_runtime31 = __toESM(require_jsx_runtime()); 3063 var list_view_default = /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_primitives31.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_primitives31.Path, { d: "M3 6h11v1.5H3V6Zm3.5 5.5h11V13h-11v-1.5ZM21 17H10v1.5h11V17Z" }) }); 3064 3065 // packages/icons/build-module/library/lock-small.js 3066 var import_primitives32 = __toESM(require_primitives()); 3067 var import_jsx_runtime32 = __toESM(require_jsx_runtime()); 3068 var lock_small_default = /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_primitives32.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)( 3069 import_primitives32.Path, 3070 { 3071 fillRule: "evenodd", 3072 clipRule: "evenodd", 3073 d: "M15 11h-.2V9c0-1.5-1.2-2.8-2.8-2.8S9.2 7.5 9.2 9v2H9c-.6 0-1 .4-1 1v4c0 .6.4 1 1 1h6c.6 0 1-.4 1-1v-4c0-.6-.4-1-1-1zm-1.8 0h-2.5V9c0-.7.6-1.2 1.2-1.2s1.2.6 1.2 1.2v2z" 3074 } 3075 ) }); 3076 3077 // packages/icons/build-module/library/mobile.js 3078 var import_primitives33 = __toESM(require_primitives()); 3079 var import_jsx_runtime33 = __toESM(require_jsx_runtime()); 3080 var mobile_default = /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_primitives33.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_primitives33.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" }) }); 3081 3082 // packages/icons/build-module/library/more-vertical.js 3083 var import_primitives34 = __toESM(require_primitives()); 3084 var import_jsx_runtime34 = __toESM(require_jsx_runtime()); 3085 var more_vertical_default = /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_primitives34.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_primitives34.Path, { d: "M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z" }) }); 3086 3087 // packages/icons/build-module/library/navigation.js 3088 var import_primitives35 = __toESM(require_primitives()); 3089 var import_jsx_runtime35 = __toESM(require_jsx_runtime()); 3090 var navigation_default = /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_primitives35.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_primitives35.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" }) }); 3091 3092 // packages/icons/build-module/library/next.js 3093 var import_primitives36 = __toESM(require_primitives()); 3094 var import_jsx_runtime36 = __toESM(require_jsx_runtime()); 3095 var next_default = /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_primitives36.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_primitives36.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" }) }); 3096 3097 // packages/icons/build-module/library/not-allowed.js 3098 var import_primitives37 = __toESM(require_primitives()); 3099 var import_jsx_runtime37 = __toESM(require_jsx_runtime()); 3100 var not_allowed_default = /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_primitives37.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)( 3101 import_primitives37.Path, 3102 { 3103 fillRule: "evenodd", 3104 clipRule: "evenodd", 3105 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" 3106 } 3107 ) }); 3108 3109 // packages/icons/build-module/library/page.js 3110 var import_primitives38 = __toESM(require_primitives()); 3111 var import_jsx_runtime38 = __toESM(require_jsx_runtime()); 3112 var page_default = /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(import_primitives38.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: [ 3113 /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_primitives38.Path, { d: "M15.5 7.5h-7V9h7V7.5Zm-7 3.5h7v1.5h-7V11Zm7 3.5h-7V16h7v-1.5Z" }), 3114 /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_primitives38.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" }) 3115 ] }); 3116 3117 // packages/icons/build-module/library/pencil.js 3118 var import_primitives39 = __toESM(require_primitives()); 3119 var import_jsx_runtime39 = __toESM(require_jsx_runtime()); 3120 var pencil_default = /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_primitives39.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_primitives39.Path, { d: "m19 7-3-3-8.5 8.5-1 4 4-1L19 7Zm-7 11.5H5V20h7v-1.5Z" }) }); 3121 3122 // packages/icons/build-module/library/pending.js 3123 var import_primitives40 = __toESM(require_primitives()); 3124 var import_jsx_runtime40 = __toESM(require_jsx_runtime()); 3125 var pending_default = /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_primitives40.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)( 3126 import_primitives40.Path, 3127 { 3128 fillRule: "evenodd", 3129 clipRule: "evenodd", 3130 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" 3131 } 3132 ) }); 3133 3134 // packages/icons/build-module/library/plus.js 3135 var import_primitives41 = __toESM(require_primitives()); 3136 var import_jsx_runtime41 = __toESM(require_jsx_runtime()); 3137 var plus_default = /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(import_primitives41.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(import_primitives41.Path, { d: "M11 12.5V17.5H12.5V12.5H17.5V11H12.5V6H11V11H6V12.5H11Z" }) }); 3138 3139 // packages/icons/build-module/library/previous.js 3140 var import_primitives42 = __toESM(require_primitives()); 3141 var import_jsx_runtime42 = __toESM(require_jsx_runtime()); 3142 var previous_default = /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_primitives42.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_primitives42.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" }) }); 3143 3144 // packages/icons/build-module/library/published.js 3145 var import_primitives43 = __toESM(require_primitives()); 3146 var import_jsx_runtime43 = __toESM(require_jsx_runtime()); 3147 var published_default = /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_primitives43.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)( 3148 import_primitives43.Path, 3149 { 3150 fillRule: "evenodd", 3151 clipRule: "evenodd", 3152 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" 3153 } 3154 ) }); 3155 3156 // packages/icons/build-module/library/redo.js 3157 var import_primitives44 = __toESM(require_primitives()); 3158 var import_jsx_runtime44 = __toESM(require_jsx_runtime()); 3159 var redo_default = /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_primitives44.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_primitives44.Path, { d: "M15.6 6.5l-1.1 1 2.9 3.3H8c-.9 0-1.7.3-2.3.9-1.4 1.5-1.4 4.2-1.4 5.6v.2h1.5v-.3c0-1.1 0-3.5 1-4.5.3-.3.7-.5 1.3-.5h9.2L14.5 15l1.1 1.1 4.6-4.6-4.6-5z" }) }); 3160 3161 // packages/icons/build-module/library/reset.js 3162 var import_primitives45 = __toESM(require_primitives()); 3163 var import_jsx_runtime45 = __toESM(require_jsx_runtime()); 3164 var reset_default = /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_primitives45.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_primitives45.Path, { d: "M7 11.5h10V13H7z" }) }); 3165 3166 // packages/icons/build-module/library/rotate-left.js 3167 var import_primitives46 = __toESM(require_primitives()); 3168 var import_jsx_runtime46 = __toESM(require_jsx_runtime()); 3169 var rotate_left_default = /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_primitives46.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_primitives46.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" }) }); 3170 3171 // packages/icons/build-module/library/rotate-right.js 3172 var import_primitives47 = __toESM(require_primitives()); 3173 var import_jsx_runtime47 = __toESM(require_jsx_runtime()); 3174 var rotate_right_default = /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(import_primitives47.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(import_primitives47.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" }) }); 3175 3176 // packages/icons/build-module/library/scheduled.js 3177 var import_primitives48 = __toESM(require_primitives()); 3178 var import_jsx_runtime48 = __toESM(require_jsx_runtime()); 3179 var scheduled_default = /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_primitives48.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)( 3180 import_primitives48.Path, 3181 { 3182 fillRule: "evenodd", 3183 clipRule: "evenodd", 3184 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" 3185 } 3186 ) }); 3187 3188 // packages/icons/build-module/library/seen.js 3189 var import_primitives49 = __toESM(require_primitives()); 3190 var import_jsx_runtime49 = __toESM(require_jsx_runtime()); 3191 var seen_default = /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(import_primitives49.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(import_primitives49.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" }) }); 3192 3193 // packages/icons/build-module/library/settings.js 3194 var import_primitives50 = __toESM(require_primitives()); 3195 var import_jsx_runtime50 = __toESM(require_jsx_runtime()); 3196 var settings_default = /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(import_primitives50.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: [ 3197 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_primitives50.Path, { d: "m19 7.5h-7.628c-.3089-.87389-1.1423-1.5-2.122-1.5-.97966 0-1.81309.62611-2.12197 1.5h-2.12803v1.5h2.12803c.30888.87389 1.14231 1.5 2.12197 1.5.9797 0 1.8131-.62611 2.122-1.5h7.628z" }), 3198 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_primitives50.Path, { d: "m19 15h-2.128c-.3089-.8739-1.1423-1.5-2.122-1.5s-1.8131.6261-2.122 1.5h-7.628v1.5h7.628c.3089.8739 1.1423 1.5 2.122 1.5s1.8131-.6261 2.122-1.5h2.128z" }) 3199 ] }); 3200 3201 // packages/icons/build-module/library/shadow.js 3202 var import_primitives51 = __toESM(require_primitives()); 3203 var import_jsx_runtime51 = __toESM(require_jsx_runtime()); 3204 var shadow_default = /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_primitives51.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_primitives51.Path, { d: "M12 8c-2.2 0-4 1.8-4 4s1.8 4 4 4 4-1.8 4-4-1.8-4-4-4zm0 6.5c-1.4 0-2.5-1.1-2.5-2.5s1.1-2.5 2.5-2.5 2.5 1.1 2.5 2.5-1.1 2.5-2.5 2.5zM12.8 3h-1.5v3h1.5V3zm-1.6 18h1.5v-3h-1.5v3zm6.8-9.8v1.5h3v-1.5h-3zm-12 0H3v1.5h3v-1.5zm9.7 5.6 2.1 2.1 1.1-1.1-2.1-2.1-1.1 1.1zM8.3 7.2 6.2 5.1 5.1 6.2l2.1 2.1 1.1-1.1zM5.1 17.8l1.1 1.1 2.1-2.1-1.1-1.1-2.1 2.1zM18.9 6.2l-1.1-1.1-2.1 2.1 1.1 1.1 2.1-2.1z" }) }); 3205 3206 // packages/icons/build-module/library/shuffle.js 3207 var import_primitives52 = __toESM(require_primitives()); 3208 var import_jsx_runtime52 = __toESM(require_jsx_runtime()); 3209 var shuffle_default = /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_primitives52.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/SVG", children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_primitives52.Path, { d: "M17.192 6.75L15.47 5.03l1.06-1.06 3.537 3.53-3.537 3.53-1.06-1.06 1.723-1.72h-3.19c-.602 0-.993.202-1.28.498-.309.319-.538.792-.695 1.383-.13.488-.222 1.023-.296 1.508-.034.664-.116 1.413-.303 2.117-.193.721-.513 1.467-1.068 2.04-.575.594-1.359.954-2.357.954H4v-1.5h4.003c.601 0 .993-.202 1.28-.498.308-.319.538-.792.695-1.383.149-.557.216-1.093.288-1.662l.039-.31a9.653 9.653 0 0 1 .272-1.653c.193-.722.513-1.467 1.067-2.04.576-.594 1.36-.954 2.358-.954h3.19zM8.004 6.75c.8 0 1.46.23 1.988.628a6.24 6.24 0 0 0-.684 1.396 1.725 1.725 0 0 0-.024-.026c-.287-.296-.679-.498-1.28-.498H4v-1.5h4.003zM12.699 14.726c-.161.459-.38.94-.684 1.396.527.397 1.188.628 1.988.628h3.19l-1.722 1.72 1.06 1.06L20.067 16l-3.537-3.53-1.06 1.06 1.723 1.72h-3.19c-.602 0-.993-.202-1.28-.498a1.96 1.96 0 0 1-.024-.026z" }) }); 3210 3211 // packages/icons/build-module/library/sidebar.js 3212 var import_primitives53 = __toESM(require_primitives()); 3213 var import_jsx_runtime53 = __toESM(require_jsx_runtime()); 3214 var sidebar_default = /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_primitives53.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_primitives53.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.5zM6 4h12a2 2 0 012 2v12a2 2 0 01-2 2H6a2 2 0 01-2-2V6a2 2 0 012-2z" }) }); 3215 3216 // packages/icons/build-module/library/square.js 3217 var import_primitives54 = __toESM(require_primitives()); 3218 var import_jsx_runtime54 = __toESM(require_jsx_runtime()); 3219 var square_default = /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_primitives54.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)( 3220 import_primitives54.Path, 3221 { 3222 fill: "none", 3223 d: "M5.75 12.75V18.25H11.25M12.75 5.75H18.25V11.25", 3224 stroke: "currentColor", 3225 strokeWidth: "1.5", 3226 strokeLinecap: "square" 3227 } 3228 ) }); 3229 3230 // packages/icons/build-module/library/star-empty.js 3231 var import_primitives55 = __toESM(require_primitives()); 3232 var import_jsx_runtime55 = __toESM(require_jsx_runtime()); 3233 var star_empty_default = /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(import_primitives55.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)( 3234 import_primitives55.Path, 3235 { 3236 fillRule: "evenodd", 3237 d: "M9.706 8.646a.25.25 0 01-.188.137l-4.626.672a.25.25 0 00-.139.427l3.348 3.262a.25.25 0 01.072.222l-.79 4.607a.25.25 0 00.362.264l4.138-2.176a.25.25 0 01.233 0l4.137 2.175a.25.25 0 00.363-.263l-.79-4.607a.25.25 0 01.072-.222l3.347-3.262a.25.25 0 00-.139-.427l-4.626-.672a.25.25 0 01-.188-.137l-2.069-4.192a.25.25 0 00-.448 0L9.706 8.646zM12 7.39l-.948 1.921a1.75 1.75 0 01-1.317.957l-2.12.308 1.534 1.495c.412.402.6.982.503 1.55l-.362 2.11 1.896-.997a1.75 1.75 0 011.629 0l1.895.997-.362-2.11a1.75 1.75 0 01.504-1.55l1.533-1.495-2.12-.308a1.75 1.75 0 01-1.317-.957L12 7.39z", 3238 clipRule: "evenodd" 3239 } 3240 ) }); 3241 3242 // packages/icons/build-module/library/star-filled.js 3243 var import_primitives56 = __toESM(require_primitives()); 3244 var import_jsx_runtime56 = __toESM(require_jsx_runtime()); 3245 var star_filled_default = /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(import_primitives56.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(import_primitives56.Path, { d: "M11.776 4.454a.25.25 0 01.448 0l2.069 4.192a.25.25 0 00.188.137l4.626.672a.25.25 0 01.139.426l-3.348 3.263a.25.25 0 00-.072.222l.79 4.607a.25.25 0 01-.362.263l-4.138-2.175a.25.25 0 00-.232 0l-4.138 2.175a.25.25 0 01-.363-.263l.79-4.607a.25.25 0 00-.071-.222L4.754 9.881a.25.25 0 01.139-.426l4.626-.672a.25.25 0 00.188-.137l2.069-4.192z" }) }); 3246 3247 // packages/icons/build-module/library/styles.js 3248 var import_primitives57 = __toESM(require_primitives()); 3249 var import_jsx_runtime57 = __toESM(require_jsx_runtime()); 3250 var styles_default = /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(import_primitives57.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)( 3251 import_primitives57.Path, 3252 { 3253 fillRule: "evenodd", 3254 clipRule: "evenodd", 3255 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" 3256 } 3257 ) }); 3258 3259 // packages/icons/build-module/library/symbol-filled.js 3260 var import_primitives58 = __toESM(require_primitives()); 3261 var import_jsx_runtime58 = __toESM(require_jsx_runtime()); 3262 var symbol_filled_default = /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_primitives58.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_primitives58.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" }) }); 3263 3264 // packages/icons/build-module/library/symbol.js 3265 var import_primitives59 = __toESM(require_primitives()); 3266 var import_jsx_runtime59 = __toESM(require_jsx_runtime()); 3267 var symbol_default = /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_primitives59.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_primitives59.Path, { d: "M21.3 10.8l-5.6-5.6c-.7-.7-1.8-.7-2.5 0l-5.6 5.6c-.7.7-.7 1.8 0 2.5l5.6 5.6c.3.3.8.5 1.2.5s.9-.2 1.2-.5l5.6-5.6c.8-.7.8-1.9.1-2.5zm-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" }) }); 3268 3269 // packages/icons/build-module/library/table-column-after.js 3270 var import_primitives60 = __toESM(require_primitives()); 3271 var import_jsx_runtime60 = __toESM(require_jsx_runtime()); 3272 var table_column_after_default = /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(import_primitives60.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(import_primitives60.Path, { d: "M19 3H5c-1.1 0-2 .9-2 2v14.2c.1.9.9 1.7 1.8 1.8H19.2c1-.1 1.8-1 1.8-2V5c0-1.1-.9-2-2-2ZM8.5 19.5H5c-.3 0-.5-.2-.5-.5v-3.5h4v4Zm0-5.5h-4v-4h4v4Zm0-5.5h-4V5c0-.3.2-.5.5-.5h3.5v4Zm11 10.5c0 .3-.2.5-.5.5h-9v-15h9c.3 0 .5.2.5.5v14Zm-4-10.8H14v3h-3v1.5h3v3h1.5v-3h3v-1.5h-3v-3Z" }) }); 3273 3274 // packages/icons/build-module/library/tablet.js 3275 var import_primitives61 = __toESM(require_primitives()); 3276 var import_jsx_runtime61 = __toESM(require_jsx_runtime()); 3277 var tablet_default = /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(import_primitives61.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(import_primitives61.Path, { d: "M17 4H7c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h10c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm.5 14c0 .3-.2.5-.5.5H7c-.3 0-.5-.2-.5-.5V6c0-.3.2-.5.5-.5h10c.3 0 .5.2.5.5v12zm-7.5-.5h4V16h-4v1.5z" }) }); 3278 3279 // packages/icons/build-module/library/trash.js 3280 var import_primitives62 = __toESM(require_primitives()); 3281 var import_jsx_runtime62 = __toESM(require_jsx_runtime()); 3282 var trash_default = /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(import_primitives62.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)( 3283 import_primitives62.Path, 3284 { 3285 fillRule: "evenodd", 3286 clipRule: "evenodd", 3287 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" 3288 } 3289 ) }); 3290 3291 // packages/icons/build-module/library/typography.js 3292 var import_primitives63 = __toESM(require_primitives()); 3293 var import_jsx_runtime63 = __toESM(require_jsx_runtime()); 3294 var typography_default = /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(import_primitives63.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(import_primitives63.Path, { d: "m8.6 7 3.9 10.8h-1.7l-1-2.8H5.7l-1 2.8H3L6.9 7h1.7Zm-2.4 6.6h3L7.7 9.3l-1.5 4.3ZM17.691 8.879c.473 0 .88.055 1.221.165.352.1.643.264.875.495.274.253.456.572.544.957.088.374.132.83.132 1.37v4.554c0 .274.033.472.099.593.077.11.198.166.363.166.11 0 .215-.028.313-.083.11-.055.237-.137.38-.247l.165.28a3.304 3.304 0 0 1-.71.446c-.23.11-.527.165-.89.165-.352 0-.639-.055-.858-.165-.22-.11-.386-.27-.495-.479-.1-.209-.149-.468-.149-.775-.286.462-.627.814-1.023 1.056-.396.242-.858.363-1.386.363-.462 0-.858-.088-1.188-.264a1.752 1.752 0 0 1-.742-.726 2.201 2.201 0 0 1-.248-1.056c0-.484.11-.875.33-1.172.22-.308.5-.556.841-.742.352-.187.721-.341 1.106-.462.396-.132.765-.253 1.106-.363.351-.121.637-.259.857-.413.232-.154.347-.357.347-.61V10.81c0-.396-.066-.71-.198-.941a1.05 1.05 0 0 0-.511-.511 1.763 1.763 0 0 0-.76-.149c-.253 0-.522.039-.808.116a1.165 1.165 0 0 0-.677.412 1.1 1.1 0 0 1 .595.396c.165.187.247.424.247.71 0 .307-.104.55-.313.726-.198.176-.451.263-.76.263-.34 0-.594-.104-.758-.313a1.231 1.231 0 0 1-.248-.759c0-.297.072-.539.214-.726.154-.187.352-.363.595-.528.264-.176.6-.324 1.006-.445.418-.121.88-.182 1.386-.182Zm.99 3.729a1.57 1.57 0 0 1-.528.462c-.231.121-.479.248-.742.38a5.377 5.377 0 0 0-.76.462c-.23.165-.423.38-.577.643-.154.264-.231.6-.231 1.007 0 .429.11.77.33 1.023.22.242.517.363.891.363.308 0 .594-.088.858-.264.275-.176.528-.44.759-.792v-3.284Z" }) }); 3295 3296 // packages/icons/build-module/library/undo.js 3297 var import_primitives64 = __toESM(require_primitives()); 3298 var import_jsx_runtime64 = __toESM(require_jsx_runtime()); 3299 var undo_default = /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(import_primitives64.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(import_primitives64.Path, { d: "M18.3 11.7c-.6-.6-1.4-.9-2.3-.9H6.7l2.9-3.3-1.1-1-4.5 5L8.5 16l1-1-2.7-2.7H16c.5 0 .9.2 1.3.5 1 1 1 3.4 1 4.5v.3h1.5v-.2c0-1.5 0-4.3-1.5-5.7z" }) }); 3300 3301 // packages/icons/build-module/library/verse.js 3302 var import_primitives65 = __toESM(require_primitives()); 3303 var import_jsx_runtime65 = __toESM(require_jsx_runtime()); 3304 var verse_default = /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(import_primitives65.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(import_primitives65.Path, { d: "M17.8 2l-.9.3c-.1 0-3.6 1-5.2 2.1C10 5.5 9.3 6.5 8.9 7.1c-.6.9-1.7 4.7-1.7 6.3l-.9 2.3c-.2.4 0 .8.4 1 .1 0 .2.1.3.1.3 0 .6-.2.7-.5l.6-1.5c.3 0 .7-.1 1.2-.2.7-.1 1.4-.3 2.2-.5.8-.2 1.6-.5 2.4-.8.7-.3 1.4-.7 1.9-1.2s.8-1.2 1-1.9c.2-.7.3-1.6.4-2.4.1-.8.1-1.7.2-2.5 0-.8.1-1.5.2-2.1V2zm-1.9 5.6c-.1.8-.2 1.5-.3 2.1-.2.6-.4 1-.6 1.3-.3.3-.8.6-1.4.9-.7.3-1.4.5-2.2.8-.6.2-1.3.3-1.8.4L15 7.5c.3-.3.6-.7 1-1.1 0 .4 0 .8-.1 1.2zM6 20h8v-1.5H6V20z" }) }); 3305 3306 // packages/icons/build-module/library/wordpress.js 3307 var import_primitives66 = __toESM(require_primitives()); 3308 var import_jsx_runtime66 = __toESM(require_jsx_runtime()); 3309 var wordpress_default = /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_primitives66.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "-2 -2 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_primitives66.Path, { d: "M20 10c0-5.51-4.49-10-10-10C4.48 0 0 4.49 0 10c0 5.52 4.48 10 10 10 5.51 0 10-4.48 10-10zM7.78 15.37L4.37 6.22c.55-.02 1.17-.08 1.17-.08.5-.06.44-1.13-.06-1.11 0 0-1.45.11-2.37.11-.18 0-.37 0-.58-.01C4.12 2.69 6.87 1.11 10 1.11c2.33 0 4.45.87 6.05 2.34-.68-.11-1.65.39-1.65 1.58 0 .74.45 1.36.9 2.1.35.61.55 1.36.55 2.46 0 1.49-1.4 5-1.4 5l-3.03-8.37c.54-.02.82-.17.82-.17.5-.05.44-1.25-.06-1.22 0 0-1.44.12-2.38.12-.87 0-2.33-.12-2.33-.12-.5-.03-.56 1.2-.06 1.22l.92.08 1.26 3.41zM17.41 10c.24-.64.74-1.87.43-4.25.7 1.29 1.05 2.71 1.05 4.25 0 3.29-1.73 6.24-4.4 7.78.97-2.59 1.94-5.2 2.92-7.78zM6.1 18.09C3.12 16.65 1.11 13.53 1.11 10c0-1.3.23-2.48.72-3.59C3.25 10.3 4.67 14.2 6.1 18.09zm4.03-6.63l2.58 6.98c-.86.29-1.76.45-2.71.45-.79 0-1.57-.11-2.29-.33.81-2.38 1.62-4.74 2.42-7.1z" }) }); 3310 3311 // packages/editor/build-module/utils/get-template-part-icon.js 3312 function getTemplatePartIcon(areaOrIconName) { 3313 if ("header" === areaOrIconName) { 3314 return header_default; 3315 } else if ("footer" === areaOrIconName) { 3316 return footer_default; 3317 } else if ("sidebar" === areaOrIconName) { 3318 return sidebar_default; 3319 } else if ("overlay" === areaOrIconName) { 3320 return table_column_after_default; 3321 } 3322 if ("menu" === areaOrIconName) { 3323 return table_column_after_default; 3324 } 3325 return symbol_filled_default; 3326 } 3327 3328 // packages/editor/build-module/lock-unlock.js 3329 var import_private_apis = __toESM(require_private_apis()); 3330 var { lock, unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)( 3331 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.", 3332 "@wordpress/editor" 3333 ); 3334 3335 // packages/editor/build-module/utils/get-template-info.js 3336 var EMPTY_OBJECT = {}; 3337 var getTemplateInfo = (params) => { 3338 if (!params) { 3339 return EMPTY_OBJECT; 3340 } 3341 const { templateTypes, templateAreas, template: template2 } = params; 3342 const { description, slug, title, area } = template2; 3343 const { title: defaultTitle, description: defaultDescription } = Object.values(templateTypes).find((type) => type.slug === slug) ?? EMPTY_OBJECT; 3344 const templateTitle = typeof title === "string" ? title : title?.rendered; 3345 const templateDescription = typeof description === "string" ? description : description?.raw; 3346 const templateAreasWithIcon = templateAreas?.map((item) => ({ 3347 ...item, 3348 icon: getTemplatePartIcon(item.icon) 3349 })); 3350 const templateIcon = templateAreasWithIcon?.find((item) => area === item.area)?.icon || layout_default; 3351 return { 3352 title: templateTitle && templateTitle !== slug ? templateTitle : defaultTitle || slug, 3353 description: templateDescription || defaultDescription, 3354 icon: templateIcon 3355 }; 3356 }; 3357 3358 // packages/editor/build-module/store/selectors.js 3359 var EMPTY_OBJECT2 = {}; 3360 var hasEditorUndo = (0, import_data3.createRegistrySelector)((select5) => () => { 3361 return select5(import_core_data.store).hasUndo(); 3362 }); 3363 var hasEditorRedo = (0, import_data3.createRegistrySelector)((select5) => () => { 3364 return select5(import_core_data.store).hasRedo(); 3365 }); 3366 function isEditedPostNew(state) { 3367 return getCurrentPost(state).status === "auto-draft"; 3368 } 3369 function hasChangedContent(state) { 3370 const edits = getPostEdits(state); 3371 return "content" in edits; 3372 } 3373 var isEditedPostDirty = (0, import_data3.createRegistrySelector)( 3374 (select5) => (state) => { 3375 const postType2 = getCurrentPostType(state); 3376 const postId2 = getCurrentPostId(state); 3377 return select5(import_core_data.store).hasEditsForEntityRecord( 3378 "postType", 3379 postType2, 3380 postId2 3381 ); 3382 } 3383 ); 3384 var hasNonPostEntityChanges = (0, import_data3.createRegistrySelector)( 3385 (select5) => (state) => { 3386 const dirtyEntityRecords = select5(import_core_data.store).__experimentalGetDirtyEntityRecords(); 3387 const { type, id } = getCurrentPost(state); 3388 return dirtyEntityRecords.some( 3389 (entityRecord) => entityRecord.kind !== "postType" || entityRecord.name !== type || entityRecord.key !== id 3390 ); 3391 } 3392 ); 3393 function isCleanNewPost(state) { 3394 return !isEditedPostDirty(state) && isEditedPostNew(state); 3395 } 3396 var getCurrentPost = (0, import_data3.createRegistrySelector)( 3397 (select5) => (state) => { 3398 const postId2 = getCurrentPostId(state); 3399 const postType2 = getCurrentPostType(state); 3400 const post2 = select5(import_core_data.store).getRawEntityRecord( 3401 "postType", 3402 postType2, 3403 postId2 3404 ); 3405 if (post2) { 3406 return post2; 3407 } 3408 return EMPTY_OBJECT2; 3409 } 3410 ); 3411 function getCurrentPostType(state) { 3412 return state.postType; 3413 } 3414 function getCurrentPostId(state) { 3415 return state.postId; 3416 } 3417 function getCurrentTemplateId(state) { 3418 return state.templateId; 3419 } 3420 function getCurrentPostRevisionsCount(state) { 3421 return getCurrentPost(state)._links?.["version-history"]?.[0]?.count ?? 0; 3422 } 3423 function getCurrentPostLastRevisionId(state) { 3424 return getCurrentPost(state)._links?.["predecessor-version"]?.[0]?.id ?? null; 3425 } 3426 var getPostEdits = (0, import_data3.createRegistrySelector)((select5) => (state) => { 3427 const postType2 = getCurrentPostType(state); 3428 const postId2 = getCurrentPostId(state); 3429 return select5(import_core_data.store).getEntityRecordEdits( 3430 "postType", 3431 postType2, 3432 postId2 3433 ) || EMPTY_OBJECT2; 3434 }); 3435 function getCurrentPostAttribute(state, attributeName) { 3436 switch (attributeName) { 3437 case "type": 3438 return getCurrentPostType(state); 3439 case "id": 3440 return getCurrentPostId(state); 3441 default: 3442 const post2 = getCurrentPost(state); 3443 if (!post2.hasOwnProperty(attributeName)) { 3444 break; 3445 } 3446 return getPostRawValue(post2[attributeName]); 3447 } 3448 } 3449 var getNestedEditedPostProperty = (0, import_data3.createSelector)( 3450 (state, attributeName) => { 3451 const edits = getPostEdits(state); 3452 if (!edits.hasOwnProperty(attributeName)) { 3453 return getCurrentPostAttribute(state, attributeName); 3454 } 3455 return { 3456 ...getCurrentPostAttribute(state, attributeName), 3457 ...edits[attributeName] 3458 }; 3459 }, 3460 (state, attributeName) => [ 3461 getCurrentPostAttribute(state, attributeName), 3462 getPostEdits(state)[attributeName] 3463 ] 3464 ); 3465 function getEditedPostAttribute(state, attributeName) { 3466 switch (attributeName) { 3467 case "content": 3468 return getEditedPostContent(state); 3469 } 3470 const edits = getPostEdits(state); 3471 if (!edits.hasOwnProperty(attributeName)) { 3472 return getCurrentPostAttribute(state, attributeName); 3473 } 3474 if (EDIT_MERGE_PROPERTIES.has(attributeName)) { 3475 return getNestedEditedPostProperty(state, attributeName); 3476 } 3477 return edits[attributeName]; 3478 } 3479 var getAutosaveAttribute = (0, import_data3.createRegistrySelector)( 3480 (select5) => (state, attributeName) => { 3481 if (!AUTOSAVE_PROPERTIES.includes(attributeName) && attributeName !== "preview_link") { 3482 return; 3483 } 3484 const postType2 = getCurrentPostType(state); 3485 if (postType2 === "wp_template") { 3486 return false; 3487 } 3488 const postId2 = getCurrentPostId(state); 3489 const currentUserId = select5(import_core_data.store).getCurrentUser()?.id; 3490 const autosave2 = select5(import_core_data.store).getAutosave( 3491 postType2, 3492 postId2, 3493 currentUserId 3494 ); 3495 if (autosave2) { 3496 return getPostRawValue(autosave2[attributeName]); 3497 } 3498 } 3499 ); 3500 function getEditedPostVisibility(state) { 3501 const status = getEditedPostAttribute(state, "status"); 3502 if (status === "private") { 3503 return "private"; 3504 } 3505 const password = getEditedPostAttribute(state, "password"); 3506 if (password) { 3507 return "password"; 3508 } 3509 return "public"; 3510 } 3511 function isCurrentPostPending(state) { 3512 return getCurrentPost(state).status === "pending"; 3513 } 3514 function isCurrentPostPublished(state, currentPost) { 3515 const post2 = currentPost || getCurrentPost(state); 3516 return ["publish", "private"].indexOf(post2.status) !== -1 || post2.status === "future" && !(0, import_date.isInTheFuture)( 3517 new Date(Number((0, import_date.getDate)(post2.date)) - ONE_MINUTE_IN_MS) 3518 ); 3519 } 3520 function isCurrentPostScheduled(state) { 3521 return getCurrentPost(state).status === "future" && !isCurrentPostPublished(state); 3522 } 3523 function isEditedPostPublishable(state) { 3524 const post2 = getCurrentPost(state); 3525 return isEditedPostDirty(state) || ["publish", "private", "future"].indexOf(post2.status) === -1; 3526 } 3527 function isEditedPostSaveable(state) { 3528 if (isSavingPost(state)) { 3529 return false; 3530 } 3531 return !!getEditedPostAttribute(state, "title") || !!getEditedPostAttribute(state, "excerpt") || !isEditedPostEmpty(state) || import_element2.Platform.OS === "native"; 3532 } 3533 var isEditedPostEmpty = (0, import_data3.createRegistrySelector)( 3534 (select5) => (state) => { 3535 const postId2 = getCurrentPostId(state); 3536 const postType2 = getCurrentPostType(state); 3537 const record = select5(import_core_data.store).getEditedEntityRecord( 3538 "postType", 3539 postType2, 3540 postId2 3541 ); 3542 if (typeof record.content !== "function") { 3543 return !record.content; 3544 } 3545 const blocks = getEditedPostAttribute(state, "blocks"); 3546 if (blocks.length === 0) { 3547 return true; 3548 } 3549 if (blocks.length > 1) { 3550 return false; 3551 } 3552 const blockName = blocks[0].name; 3553 if (blockName !== (0, import_blocks.getDefaultBlockName)() && blockName !== (0, import_blocks.getFreeformContentHandlerName)()) { 3554 return false; 3555 } 3556 return !getEditedPostContent(state); 3557 } 3558 ); 3559 var isEditedPostAutosaveable = (0, import_data3.createRegistrySelector)( 3560 (select5) => (state) => { 3561 if (!isEditedPostSaveable(state)) { 3562 return false; 3563 } 3564 if (isPostAutosavingLocked(state)) { 3565 return false; 3566 } 3567 const postType2 = getCurrentPostType(state); 3568 const postTypeObject = select5(import_core_data.store).getPostType(postType2); 3569 if (postType2 === "wp_template" || !postTypeObject?.supports?.autosave) { 3570 return false; 3571 } 3572 const postId2 = getCurrentPostId(state); 3573 const hasFetchedAutosave = select5(import_core_data.store).hasFetchedAutosaves( 3574 postType2, 3575 postId2 3576 ); 3577 const currentUserId = select5(import_core_data.store).getCurrentUser()?.id; 3578 const autosave2 = select5(import_core_data.store).getAutosave( 3579 postType2, 3580 postId2, 3581 currentUserId 3582 ); 3583 if (!hasFetchedAutosave) { 3584 return false; 3585 } 3586 if (!autosave2) { 3587 return true; 3588 } 3589 if (hasChangedContent(state)) { 3590 return true; 3591 } 3592 return ["title", "excerpt", "meta"].some( 3593 (field) => getPostRawValue(autosave2[field]) !== getEditedPostAttribute(state, field) 3594 ); 3595 } 3596 ); 3597 function isEditedPostBeingScheduled(state) { 3598 const date = getEditedPostAttribute(state, "date"); 3599 const checkedDate = new Date( 3600 Number((0, import_date.getDate)(date)) - ONE_MINUTE_IN_MS 3601 ); 3602 return (0, import_date.isInTheFuture)(checkedDate); 3603 } 3604 function isEditedPostDateFloating(state) { 3605 const date = getEditedPostAttribute(state, "date"); 3606 const modified = getEditedPostAttribute(state, "modified"); 3607 const status = getCurrentPost(state).status; 3608 if (status === "draft" || status === "auto-draft" || status === "pending") { 3609 return date === modified || date === null; 3610 } 3611 return false; 3612 } 3613 function isDeletingPost(state) { 3614 return !!state.deleting.pending; 3615 } 3616 function isSavingPost(state) { 3617 return !!state.saving.pending; 3618 } 3619 var isSavingNonPostEntityChanges = (0, import_data3.createRegistrySelector)( 3620 (select5) => (state) => { 3621 const entitiesBeingSaved = select5(import_core_data.store).__experimentalGetEntitiesBeingSaved(); 3622 const { type, id } = getCurrentPost(state); 3623 return entitiesBeingSaved.some( 3624 (entityRecord) => entityRecord.kind !== "postType" || entityRecord.name !== type || entityRecord.key !== id 3625 ); 3626 } 3627 ); 3628 var didPostSaveRequestSucceed = (0, import_data3.createRegistrySelector)( 3629 (select5) => (state) => { 3630 const postType2 = getCurrentPostType(state); 3631 const postId2 = getCurrentPostId(state); 3632 return !select5(import_core_data.store).getLastEntitySaveError( 3633 "postType", 3634 postType2, 3635 postId2 3636 ); 3637 } 3638 ); 3639 var didPostSaveRequestFail = (0, import_data3.createRegistrySelector)( 3640 (select5) => (state) => { 3641 const postType2 = getCurrentPostType(state); 3642 const postId2 = getCurrentPostId(state); 3643 return !!select5(import_core_data.store).getLastEntitySaveError( 3644 "postType", 3645 postType2, 3646 postId2 3647 ); 3648 } 3649 ); 3650 function isAutosavingPost(state) { 3651 return isSavingPost(state) && Boolean(state.saving.options?.isAutosave); 3652 } 3653 function isPreviewingPost(state) { 3654 return isSavingPost(state) && Boolean(state.saving.options?.isPreview); 3655 } 3656 function getEditedPostPreviewLink(state) { 3657 if (state.saving.pending || isSavingPost(state)) { 3658 return; 3659 } 3660 let previewLink = getAutosaveAttribute(state, "preview_link"); 3661 if (!previewLink || "draft" === getCurrentPost(state).status) { 3662 previewLink = getEditedPostAttribute(state, "link"); 3663 if (previewLink) { 3664 previewLink = (0, import_url.addQueryArgs)(previewLink, { preview: true }); 3665 } 3666 } 3667 const featuredImageId = getEditedPostAttribute(state, "featured_media"); 3668 if (previewLink && featuredImageId) { 3669 return (0, import_url.addQueryArgs)(previewLink, { _thumbnail_id: featuredImageId }); 3670 } 3671 return previewLink; 3672 } 3673 var getSuggestedPostFormat = (0, import_data3.createRegistrySelector)( 3674 (select5) => () => { 3675 const blocks = select5(import_block_editor2.store).getBlocks(); 3676 if (blocks.length > 2) { 3677 return null; 3678 } 3679 let name2; 3680 if (blocks.length === 1) { 3681 name2 = blocks[0].name; 3682 if (name2 === "core/embed") { 3683 const provider = blocks[0].attributes?.providerNameSlug; 3684 if (["youtube", "vimeo"].includes(provider)) { 3685 name2 = "core/video"; 3686 } else if (["spotify", "soundcloud"].includes(provider)) { 3687 name2 = "core/audio"; 3688 } 3689 } 3690 } 3691 if (blocks.length === 2 && blocks[1].name === "core/paragraph") { 3692 name2 = blocks[0].name; 3693 } 3694 switch (name2) { 3695 case "core/image": 3696 return "image"; 3697 case "core/quote": 3698 case "core/pullquote": 3699 return "quote"; 3700 case "core/gallery": 3701 return "gallery"; 3702 case "core/video": 3703 return "video"; 3704 case "core/audio": 3705 return "audio"; 3706 default: 3707 return null; 3708 } 3709 } 3710 ); 3711 var getEditedPostContent = (0, import_data3.createRegistrySelector)( 3712 (select5) => (state) => { 3713 const postId2 = getCurrentPostId(state); 3714 const postType2 = getCurrentPostType(state); 3715 const record = select5(import_core_data.store).getEditedEntityRecord( 3716 "postType", 3717 postType2, 3718 postId2 3719 ); 3720 if (record) { 3721 if (typeof record.content === "function") { 3722 return record.content(record); 3723 } else if (record.blocks) { 3724 return (0, import_blocks.__unstableSerializeAndClean)(record.blocks); 3725 } else if (record.content) { 3726 return record.content; 3727 } 3728 } 3729 return ""; 3730 } 3731 ); 3732 function isPublishingPost(state) { 3733 return isSavingPost(state) && !isCurrentPostPublished(state) && getEditedPostAttribute(state, "status") === "publish"; 3734 } 3735 function isPermalinkEditable(state) { 3736 const permalinkTemplate = getEditedPostAttribute( 3737 state, 3738 "permalink_template" 3739 ); 3740 return PERMALINK_POSTNAME_REGEX.test(permalinkTemplate); 3741 } 3742 function getPermalink(state) { 3743 const permalinkParts = getPermalinkParts(state); 3744 if (!permalinkParts) { 3745 return null; 3746 } 3747 const { prefix, postName, suffix } = permalinkParts; 3748 if (isPermalinkEditable(state)) { 3749 return prefix + postName + suffix; 3750 } 3751 return prefix; 3752 } 3753 function getEditedPostSlug(state) { 3754 return getEditedPostAttribute(state, "slug") || (0, import_url.cleanForSlug)(getEditedPostAttribute(state, "title")) || getCurrentPostId(state); 3755 } 3756 function getPermalinkParts(state) { 3757 const permalinkTemplate = getEditedPostAttribute( 3758 state, 3759 "permalink_template" 3760 ); 3761 if (!permalinkTemplate) { 3762 return null; 3763 } 3764 const postName = getEditedPostAttribute(state, "slug") || getEditedPostAttribute(state, "generated_slug"); 3765 const [prefix, suffix] = permalinkTemplate.split( 3766 PERMALINK_POSTNAME_REGEX 3767 ); 3768 return { 3769 prefix, 3770 postName, 3771 suffix 3772 }; 3773 } 3774 function isPostLocked(state) { 3775 return state.postLock.isLocked; 3776 } 3777 function isPostSavingLocked(state) { 3778 return Object.keys(state.postSavingLock).length > 0; 3779 } 3780 function isPostAutosavingLocked(state) { 3781 return Object.keys(state.postAutosavingLock).length > 0; 3782 } 3783 function isPostLockTakeover(state) { 3784 return state.postLock.isTakeover; 3785 } 3786 function getPostLockUser(state) { 3787 return state.postLock.user; 3788 } 3789 function getActivePostLock(state) { 3790 return state.postLock.activePostLock; 3791 } 3792 function canUserUseUnfilteredHTML(state) { 3793 return Boolean( 3794 getCurrentPost(state)._links?.hasOwnProperty( 3795 "wp:action-unfiltered-html" 3796 ) 3797 ); 3798 } 3799 var isPublishSidebarEnabled = (0, import_data3.createRegistrySelector)( 3800 (select5) => () => !!select5(import_preferences.store).get("core", "isPublishSidebarEnabled") 3801 ); 3802 var getEditorBlocks = (0, import_data3.createSelector)( 3803 (state) => { 3804 return getEditedPostAttribute(state, "blocks") || (0, import_blocks.parse)(getEditedPostContent(state)); 3805 }, 3806 (state) => [ 3807 getEditedPostAttribute(state, "blocks"), 3808 getEditedPostContent(state) 3809 ] 3810 ); 3811 function isEditorPanelRemoved(state, panelName) { 3812 return state.removedPanels.includes(panelName); 3813 } 3814 var isEditorPanelEnabled = (0, import_data3.createRegistrySelector)( 3815 (select5) => (state, panelName) => { 3816 const inactivePanels = select5(import_preferences.store).get( 3817 "core", 3818 "inactivePanels" 3819 ); 3820 return !isEditorPanelRemoved(state, panelName) && !inactivePanels?.includes(panelName); 3821 } 3822 ); 3823 var isEditorPanelOpened = (0, import_data3.createRegistrySelector)( 3824 (select5) => (state, panelName) => { 3825 const openPanels = select5(import_preferences.store).get( 3826 "core", 3827 "openPanels" 3828 ); 3829 return !!openPanels?.includes(panelName); 3830 } 3831 ); 3832 function getEditorSelectionStart(state) { 3833 (0, import_deprecated.default)("select('core/editor').getEditorSelectionStart", { 3834 since: "5.8", 3835 alternative: "select('core/editor').getEditorSelection" 3836 }); 3837 return getEditedPostAttribute(state, "selection")?.selectionStart; 3838 } 3839 function getEditorSelectionEnd(state) { 3840 (0, import_deprecated.default)("select('core/editor').getEditorSelectionStart", { 3841 since: "5.8", 3842 alternative: "select('core/editor').getEditorSelection" 3843 }); 3844 return getEditedPostAttribute(state, "selection")?.selectionEnd; 3845 } 3846 function getEditorSelection(state) { 3847 return getEditedPostAttribute(state, "selection"); 3848 } 3849 function __unstableIsEditorReady(state) { 3850 return !!state.postId; 3851 } 3852 function getEditorSettings(state) { 3853 return state.editorSettings; 3854 } 3855 function getRenderingMode(state) { 3856 return state.renderingMode; 3857 } 3858 var getDeviceType = (0, import_data3.createRegistrySelector)( 3859 (select5) => (state) => { 3860 const isZoomOut = unlock(select5(import_block_editor2.store)).isZoomOut(); 3861 if (isZoomOut) { 3862 return "Desktop"; 3863 } 3864 return state.deviceType; 3865 } 3866 ); 3867 function isListViewOpened(state) { 3868 return state.listViewPanel; 3869 } 3870 function isInserterOpened(state) { 3871 return !!state.blockInserterPanel; 3872 } 3873 var getEditorMode = (0, import_data3.createRegistrySelector)( 3874 (select5) => () => select5(import_preferences.store).get("core", "editorMode") ?? "visual" 3875 ); 3876 function getStateBeforeOptimisticTransaction() { 3877 (0, import_deprecated.default)("select('core/editor').getStateBeforeOptimisticTransaction", { 3878 since: "5.7", 3879 hint: "No state history is kept on this store anymore" 3880 }); 3881 return null; 3882 } 3883 function inSomeHistory() { 3884 (0, import_deprecated.default)("select('core/editor').inSomeHistory", { 3885 since: "5.7", 3886 hint: "No state history is kept on this store anymore" 3887 }); 3888 return false; 3889 } 3890 function getBlockEditorSelector(name2) { 3891 return (0, import_data3.createRegistrySelector)((select5) => (state, ...args) => { 3892 (0, import_deprecated.default)("`wp.data.select( 'core/editor' )." + name2 + "`", { 3893 since: "5.3", 3894 alternative: "`wp.data.select( 'core/block-editor' )." + name2 + "`", 3895 version: "6.2" 3896 }); 3897 return select5(import_block_editor2.store)[name2](...args); 3898 }); 3899 } 3900 var getBlockName = getBlockEditorSelector("getBlockName"); 3901 var isBlockValid = getBlockEditorSelector("isBlockValid"); 3902 var getBlockAttributes = getBlockEditorSelector("getBlockAttributes"); 3903 var getBlock = getBlockEditorSelector("getBlock"); 3904 var getBlocks = getBlockEditorSelector("getBlocks"); 3905 var getClientIdsOfDescendants = getBlockEditorSelector( 3906 "getClientIdsOfDescendants" 3907 ); 3908 var getClientIdsWithDescendants = getBlockEditorSelector( 3909 "getClientIdsWithDescendants" 3910 ); 3911 var getGlobalBlockCount = getBlockEditorSelector( 3912 "getGlobalBlockCount" 3913 ); 3914 var getBlocksByClientId = getBlockEditorSelector( 3915 "getBlocksByClientId" 3916 ); 3917 var getBlockCount = getBlockEditorSelector("getBlockCount"); 3918 var getBlockSelectionStart = getBlockEditorSelector( 3919 "getBlockSelectionStart" 3920 ); 3921 var getBlockSelectionEnd = getBlockEditorSelector( 3922 "getBlockSelectionEnd" 3923 ); 3924 var getSelectedBlockCount = getBlockEditorSelector( 3925 "getSelectedBlockCount" 3926 ); 3927 var hasSelectedBlock = getBlockEditorSelector("hasSelectedBlock"); 3928 var getSelectedBlockClientId = getBlockEditorSelector( 3929 "getSelectedBlockClientId" 3930 ); 3931 var getSelectedBlock = getBlockEditorSelector("getSelectedBlock"); 3932 var getBlockRootClientId = getBlockEditorSelector( 3933 "getBlockRootClientId" 3934 ); 3935 var getBlockHierarchyRootClientId = getBlockEditorSelector( 3936 "getBlockHierarchyRootClientId" 3937 ); 3938 var getAdjacentBlockClientId = getBlockEditorSelector( 3939 "getAdjacentBlockClientId" 3940 ); 3941 var getPreviousBlockClientId = getBlockEditorSelector( 3942 "getPreviousBlockClientId" 3943 ); 3944 var getNextBlockClientId = getBlockEditorSelector( 3945 "getNextBlockClientId" 3946 ); 3947 var getSelectedBlocksInitialCaretPosition = getBlockEditorSelector( 3948 "getSelectedBlocksInitialCaretPosition" 3949 ); 3950 var getMultiSelectedBlockClientIds = getBlockEditorSelector( 3951 "getMultiSelectedBlockClientIds" 3952 ); 3953 var getMultiSelectedBlocks = getBlockEditorSelector( 3954 "getMultiSelectedBlocks" 3955 ); 3956 var getFirstMultiSelectedBlockClientId = getBlockEditorSelector( 3957 "getFirstMultiSelectedBlockClientId" 3958 ); 3959 var getLastMultiSelectedBlockClientId = getBlockEditorSelector( 3960 "getLastMultiSelectedBlockClientId" 3961 ); 3962 var isFirstMultiSelectedBlock = getBlockEditorSelector( 3963 "isFirstMultiSelectedBlock" 3964 ); 3965 var isBlockMultiSelected = getBlockEditorSelector( 3966 "isBlockMultiSelected" 3967 ); 3968 var isAncestorMultiSelected = getBlockEditorSelector( 3969 "isAncestorMultiSelected" 3970 ); 3971 var getMultiSelectedBlocksStartClientId = getBlockEditorSelector( 3972 "getMultiSelectedBlocksStartClientId" 3973 ); 3974 var getMultiSelectedBlocksEndClientId = getBlockEditorSelector( 3975 "getMultiSelectedBlocksEndClientId" 3976 ); 3977 var getBlockOrder = getBlockEditorSelector("getBlockOrder"); 3978 var getBlockIndex = getBlockEditorSelector("getBlockIndex"); 3979 var isBlockSelected = getBlockEditorSelector("isBlockSelected"); 3980 var hasSelectedInnerBlock = getBlockEditorSelector( 3981 "hasSelectedInnerBlock" 3982 ); 3983 var isBlockWithinSelection = getBlockEditorSelector( 3984 "isBlockWithinSelection" 3985 ); 3986 var hasMultiSelection = getBlockEditorSelector("hasMultiSelection"); 3987 var isMultiSelecting = getBlockEditorSelector("isMultiSelecting"); 3988 var isSelectionEnabled = getBlockEditorSelector("isSelectionEnabled"); 3989 var getBlockMode = getBlockEditorSelector("getBlockMode"); 3990 var isTyping = getBlockEditorSelector("isTyping"); 3991 var isCaretWithinFormattedText = getBlockEditorSelector( 3992 "isCaretWithinFormattedText" 3993 ); 3994 var getBlockInsertionPoint = getBlockEditorSelector( 3995 "getBlockInsertionPoint" 3996 ); 3997 var isBlockInsertionPointVisible = getBlockEditorSelector( 3998 "isBlockInsertionPointVisible" 3999 ); 4000 var isValidTemplate = getBlockEditorSelector("isValidTemplate"); 4001 var getTemplate = getBlockEditorSelector("getTemplate"); 4002 var getTemplateLock = getBlockEditorSelector("getTemplateLock"); 4003 var canInsertBlockType = getBlockEditorSelector("canInsertBlockType"); 4004 var getInserterItems = getBlockEditorSelector("getInserterItems"); 4005 var hasInserterItems = getBlockEditorSelector("hasInserterItems"); 4006 var getBlockListSettings = getBlockEditorSelector( 4007 "getBlockListSettings" 4008 ); 4009 var __experimentalGetDefaultTemplateTypes = (0, import_data3.createRegistrySelector)( 4010 (select5) => () => { 4011 (0, import_deprecated.default)( 4012 "select('core/editor').__experimentalGetDefaultTemplateTypes", 4013 { 4014 since: "6.8", 4015 alternative: "select('core/core-data').getCurrentTheme()?.default_template_types" 4016 } 4017 ); 4018 return select5(import_core_data.store).getCurrentTheme()?.default_template_types; 4019 } 4020 ); 4021 var __experimentalGetDefaultTemplatePartAreas = (0, import_data3.createRegistrySelector)( 4022 (select5) => (0, import_data3.createSelector)(() => { 4023 (0, import_deprecated.default)( 4024 "select('core/editor').__experimentalGetDefaultTemplatePartAreas", 4025 { 4026 since: "6.8", 4027 alternative: "select('core/core-data').getCurrentTheme()?.default_template_part_areas" 4028 } 4029 ); 4030 const areas = select5(import_core_data.store).getCurrentTheme()?.default_template_part_areas || []; 4031 return areas.map((item) => { 4032 return { ...item, icon: getTemplatePartIcon(item.icon) }; 4033 }); 4034 }) 4035 ); 4036 var __experimentalGetDefaultTemplateType = (0, import_data3.createRegistrySelector)( 4037 (select5) => (0, import_data3.createSelector)((state, slug) => { 4038 (0, import_deprecated.default)( 4039 "select('core/editor').__experimentalGetDefaultTemplateType", 4040 { 4041 since: "6.8" 4042 } 4043 ); 4044 const templateTypes = select5(import_core_data.store).getCurrentTheme()?.default_template_types; 4045 if (!templateTypes) { 4046 return EMPTY_OBJECT2; 4047 } 4048 return Object.values(templateTypes).find( 4049 (type) => type.slug === slug 4050 ) ?? EMPTY_OBJECT2; 4051 }) 4052 ); 4053 var __experimentalGetTemplateInfo = (0, import_data3.createRegistrySelector)( 4054 (select5) => (0, import_data3.createSelector)((state, template2) => { 4055 (0, import_deprecated.default)("select('core/editor').__experimentalGetTemplateInfo", { 4056 since: "6.8" 4057 }); 4058 if (!template2) { 4059 return EMPTY_OBJECT2; 4060 } 4061 const currentTheme = select5(import_core_data.store).getCurrentTheme(); 4062 const templateTypes = currentTheme?.default_template_types || []; 4063 const templateAreas = currentTheme?.default_template_part_areas || []; 4064 return getTemplateInfo({ 4065 template: template2, 4066 templateAreas, 4067 templateTypes 4068 }); 4069 }) 4070 ); 4071 var getPostTypeLabel = (0, import_data3.createRegistrySelector)( 4072 (select5) => (state) => { 4073 const currentPostType = getCurrentPostType(state); 4074 const postType2 = select5(import_core_data.store).getPostType(currentPostType); 4075 return postType2?.labels?.singular_name; 4076 } 4077 ); 4078 function isPublishSidebarOpened(state) { 4079 return state.publishSidebarActive; 4080 } 4081 4082 // packages/editor/build-module/store/actions.js 4083 var actions_exports = {}; 4084 __export(actions_exports, { 4085 __experimentalTearDownEditor: () => __experimentalTearDownEditor, 4086 __unstableSaveForPreview: () => __unstableSaveForPreview, 4087 autosave: () => autosave, 4088 clearSelectedBlock: () => clearSelectedBlock, 4089 closePublishSidebar: () => closePublishSidebar, 4090 createUndoLevel: () => createUndoLevel, 4091 disablePublishSidebar: () => disablePublishSidebar, 4092 editPost: () => editPost, 4093 enablePublishSidebar: () => enablePublishSidebar, 4094 enterFormattedText: () => enterFormattedText, 4095 exitFormattedText: () => exitFormattedText, 4096 hideInsertionPoint: () => hideInsertionPoint, 4097 insertBlock: () => insertBlock, 4098 insertBlocks: () => insertBlocks, 4099 insertDefaultBlock: () => insertDefaultBlock, 4100 lockPostAutosaving: () => lockPostAutosaving, 4101 lockPostSaving: () => lockPostSaving, 4102 mergeBlocks: () => mergeBlocks, 4103 moveBlockToPosition: () => moveBlockToPosition, 4104 moveBlocksDown: () => moveBlocksDown, 4105 moveBlocksUp: () => moveBlocksUp, 4106 multiSelect: () => multiSelect, 4107 openPublishSidebar: () => openPublishSidebar, 4108 receiveBlocks: () => receiveBlocks, 4109 redo: () => redo, 4110 refreshPost: () => refreshPost, 4111 removeBlock: () => removeBlock, 4112 removeBlocks: () => removeBlocks, 4113 removeEditorPanel: () => removeEditorPanel, 4114 replaceBlock: () => replaceBlock, 4115 replaceBlocks: () => replaceBlocks, 4116 resetBlocks: () => resetBlocks, 4117 resetEditorBlocks: () => resetEditorBlocks, 4118 resetPost: () => resetPost, 4119 savePost: () => savePost, 4120 selectBlock: () => selectBlock, 4121 setDeviceType: () => setDeviceType, 4122 setEditedPost: () => setEditedPost, 4123 setIsInserterOpened: () => setIsInserterOpened, 4124 setIsListViewOpened: () => setIsListViewOpened, 4125 setRenderingMode: () => setRenderingMode, 4126 setTemplateValidity: () => setTemplateValidity, 4127 setupEditor: () => setupEditor, 4128 setupEditorState: () => setupEditorState, 4129 showInsertionPoint: () => showInsertionPoint, 4130 startMultiSelect: () => startMultiSelect, 4131 startTyping: () => startTyping, 4132 stopMultiSelect: () => stopMultiSelect, 4133 stopTyping: () => stopTyping, 4134 switchEditorMode: () => switchEditorMode, 4135 synchronizeTemplate: () => synchronizeTemplate, 4136 toggleBlockMode: () => toggleBlockMode, 4137 toggleDistractionFree: () => toggleDistractionFree, 4138 toggleEditorPanelEnabled: () => toggleEditorPanelEnabled, 4139 toggleEditorPanelOpened: () => toggleEditorPanelOpened, 4140 togglePublishSidebar: () => togglePublishSidebar, 4141 toggleSelection: () => toggleSelection, 4142 toggleSpotlightMode: () => toggleSpotlightMode, 4143 toggleTopToolbar: () => toggleTopToolbar, 4144 trashPost: () => trashPost, 4145 undo: () => undo, 4146 unlockPostAutosaving: () => unlockPostAutosaving, 4147 unlockPostSaving: () => unlockPostSaving, 4148 updateBlock: () => updateBlock, 4149 updateBlockAttributes: () => updateBlockAttributes, 4150 updateBlockListSettings: () => updateBlockListSettings, 4151 updateEditorSettings: () => updateEditorSettings, 4152 updatePost: () => updatePost, 4153 updatePostLock: () => updatePostLock 4154 }); 4155 var import_a11y = __toESM(require_a11y()); 4156 var import_api_fetch = __toESM(require_api_fetch()); 4157 var import_deprecated2 = __toESM(require_deprecated()); 4158 var import_blocks2 = __toESM(require_blocks()); 4159 var import_notices = __toESM(require_notices()); 4160 var import_core_data2 = __toESM(require_core_data()); 4161 var import_block_editor3 = __toESM(require_block_editor()); 4162 var import_hooks = __toESM(require_hooks()); 4163 var import_preferences2 = __toESM(require_preferences()); 4164 var import_i18n2 = __toESM(require_i18n()); 4165 4166 // packages/editor/build-module/store/local-autosave.js 4167 function postKey(postId2, isPostNew) { 4168 return `wp-autosave-block-editor-post-$isPostNew ? "auto-draft" : postId2}`; 4169 } 4170 function localAutosaveGet(postId2, isPostNew) { 4171 return window.sessionStorage.getItem(postKey(postId2, isPostNew)); 4172 } 4173 function localAutosaveSet(postId2, isPostNew, title, content, excerpt) { 4174 window.sessionStorage.setItem( 4175 postKey(postId2, isPostNew), 4176 JSON.stringify({ 4177 post_title: title, 4178 content, 4179 excerpt 4180 }) 4181 ); 4182 } 4183 function localAutosaveClear(postId2, isPostNew) { 4184 window.sessionStorage.removeItem(postKey(postId2, isPostNew)); 4185 } 4186 4187 // packages/editor/build-module/store/utils/notice-builder.js 4188 var import_i18n = __toESM(require_i18n()); 4189 function getNotificationArgumentsForSaveSuccess(data) { 4190 const { previousPost, post: post2, postType: postType2 } = data; 4191 if (data.options?.isAutosave) { 4192 return []; 4193 } 4194 const publishStatus = ["publish", "private", "future"]; 4195 const isPublished = publishStatus.includes(previousPost.status); 4196 const willPublish = publishStatus.includes(post2.status); 4197 const willTrash = post2.status === "trash" && previousPost.status !== "trash"; 4198 let noticeMessage; 4199 let shouldShowLink = postType2?.viewable ?? false; 4200 let isDraft; 4201 if (willTrash) { 4202 noticeMessage = postType2.labels.item_trashed; 4203 shouldShowLink = false; 4204 } else if (!isPublished && !willPublish) { 4205 noticeMessage = (0, import_i18n.__)("Draft saved."); 4206 isDraft = true; 4207 } else if (isPublished && !willPublish) { 4208 noticeMessage = postType2.labels.item_reverted_to_draft; 4209 shouldShowLink = false; 4210 } else if (!isPublished && willPublish) { 4211 noticeMessage = { 4212 publish: postType2.labels.item_published, 4213 private: postType2.labels.item_published_privately, 4214 future: postType2.labels.item_scheduled 4215 }[post2.status]; 4216 } else { 4217 noticeMessage = postType2.labels.item_updated; 4218 } 4219 const actions2 = []; 4220 if (shouldShowLink) { 4221 actions2.push({ 4222 label: isDraft ? (0, import_i18n.__)("View Preview") : postType2.labels.view_item, 4223 url: post2.link, 4224 openInNewTab: true 4225 }); 4226 } 4227 return [ 4228 noticeMessage, 4229 { 4230 id: "editor-save", 4231 type: "snackbar", 4232 actions: actions2 4233 } 4234 ]; 4235 } 4236 function getNotificationArgumentsForSaveFail(data) { 4237 const { post: post2, edits, error } = data; 4238 if (error && "rest_autosave_no_changes" === error.code) { 4239 return []; 4240 } 4241 const publishStatus = ["publish", "private", "future"]; 4242 const isPublished = publishStatus.indexOf(post2.status) !== -1; 4243 if (error.code === "offline_error") { 4244 const messages2 = { 4245 publish: (0, import_i18n.__)( 4246 "Publishing failed because you were offline. Please verify your connection and try again." 4247 ), 4248 private: (0, import_i18n.__)( 4249 "Publishing failed because you were offline. Please verify your connection and try again." 4250 ), 4251 future: (0, import_i18n.__)( 4252 "Scheduling failed because you were offline. Please verify your connection and try again." 4253 ), 4254 default: (0, import_i18n.__)( 4255 "Updating failed because you were offline. Please verify your connection and try again." 4256 ) 4257 }; 4258 const noticeMessage2 = !isPublished && edits.status in messages2 ? messages2[edits.status] : messages2.default; 4259 return [noticeMessage2, { id: "editor-save" }]; 4260 } 4261 const messages = { 4262 publish: (0, import_i18n.__)("Publishing failed."), 4263 private: (0, import_i18n.__)("Publishing failed."), 4264 future: (0, import_i18n.__)("Scheduling failed."), 4265 default: (0, import_i18n.__)("Updating failed.") 4266 }; 4267 let noticeMessage = !isPublished && edits.status in messages ? messages[edits.status] : messages.default; 4268 if (error.message && !/<\/?[^>]*>/.test(error.message)) { 4269 noticeMessage = [noticeMessage, error.message].join(" "); 4270 } 4271 return [ 4272 noticeMessage, 4273 { 4274 id: "editor-save" 4275 } 4276 ]; 4277 } 4278 function getNotificationArgumentsForTrashFail(data) { 4279 return [ 4280 data.error.message && data.error.code !== "unknown_error" ? data.error.message : (0, import_i18n.__)("Trashing failed"), 4281 { 4282 id: "editor-trash-fail" 4283 } 4284 ]; 4285 } 4286 4287 // packages/editor/build-module/store/actions.js 4288 var setupEditor = (post2, edits, template2) => ({ dispatch: dispatch6 }) => { 4289 dispatch6.setEditedPost(post2.type, post2.id); 4290 const isNewPost = post2.status === "auto-draft"; 4291 if (isNewPost && template2) { 4292 let content; 4293 if ("content" in edits) { 4294 content = edits.content; 4295 } else { 4296 content = post2.content.raw; 4297 } 4298 let blocks = (0, import_blocks2.parse)(content); 4299 blocks = (0, import_blocks2.synchronizeBlocksWithTemplate)(blocks, template2); 4300 dispatch6.resetEditorBlocks(blocks, { 4301 __unstableShouldCreateUndoLevel: false 4302 }); 4303 } 4304 if (edits && Object.entries(edits).some( 4305 ([key, edit]) => edit !== (post2[key]?.raw ?? post2[key]) 4306 )) { 4307 dispatch6.editPost(edits); 4308 } 4309 }; 4310 function __experimentalTearDownEditor() { 4311 (0, import_deprecated2.default)( 4312 "wp.data.dispatch( 'core/editor' ).__experimentalTearDownEditor", 4313 { 4314 since: "6.5" 4315 } 4316 ); 4317 return { type: "DO_NOTHING" }; 4318 } 4319 function resetPost() { 4320 (0, import_deprecated2.default)("wp.data.dispatch( 'core/editor' ).resetPost", { 4321 since: "6.0", 4322 version: "6.3", 4323 alternative: "Initialize the editor with the setupEditorState action" 4324 }); 4325 return { type: "DO_NOTHING" }; 4326 } 4327 function updatePost() { 4328 (0, import_deprecated2.default)("wp.data.dispatch( 'core/editor' ).updatePost", { 4329 since: "5.7", 4330 alternative: "Use the core entities store instead" 4331 }); 4332 return { 4333 type: "DO_NOTHING" 4334 }; 4335 } 4336 function setupEditorState(post2) { 4337 (0, import_deprecated2.default)("wp.data.dispatch( 'core/editor' ).setupEditorState", { 4338 since: "6.5", 4339 alternative: "wp.data.dispatch( 'core/editor' ).setEditedPost" 4340 }); 4341 return setEditedPost(post2.type, post2.id); 4342 } 4343 function setEditedPost(postType2, postId2) { 4344 return { 4345 type: "SET_EDITED_POST", 4346 postType: postType2, 4347 postId: postId2 4348 }; 4349 } 4350 var editPost = (edits, options) => ({ select: select5, registry }) => { 4351 const { id, type } = select5.getCurrentPost(); 4352 registry.dispatch(import_core_data2.store).editEntityRecord("postType", type, id, edits, options); 4353 }; 4354 var savePost = (options = {}) => async ({ select: select5, dispatch: dispatch6, registry }) => { 4355 if (!select5.isEditedPostSaveable()) { 4356 return; 4357 } 4358 const content = select5.getEditedPostContent(); 4359 if (!options.isAutosave) { 4360 dispatch6.editPost({ content }, { undoIgnore: true }); 4361 } 4362 const previousRecord = select5.getCurrentPost(); 4363 let edits = { 4364 id: previousRecord.id, 4365 ...registry.select(import_core_data2.store).getEntityRecordNonTransientEdits( 4366 "postType", 4367 previousRecord.type, 4368 previousRecord.id 4369 ), 4370 content 4371 }; 4372 dispatch6({ type: "REQUEST_POST_UPDATE_START", options }); 4373 let error = false; 4374 try { 4375 edits = await (0, import_hooks.applyFiltersAsync)( 4376 "editor.preSavePost", 4377 edits, 4378 options 4379 ); 4380 } catch (err) { 4381 error = err; 4382 } 4383 if (!error) { 4384 try { 4385 await registry.dispatch(import_core_data2.store).saveEntityRecord( 4386 "postType", 4387 previousRecord.type, 4388 edits, 4389 options 4390 ); 4391 } catch (err) { 4392 error = err.message && err.code !== "unknown_error" ? err.message : (0, import_i18n2.__)("An error occurred while updating."); 4393 } 4394 } 4395 if (!error) { 4396 error = registry.select(import_core_data2.store).getLastEntitySaveError( 4397 "postType", 4398 previousRecord.type, 4399 previousRecord.id 4400 ); 4401 } 4402 if (!error) { 4403 try { 4404 await (0, import_hooks.applyFilters)( 4405 "editor.__unstableSavePost", 4406 Promise.resolve(), 4407 options 4408 ); 4409 } catch (err) { 4410 error = err; 4411 } 4412 } 4413 if (!error) { 4414 try { 4415 await (0, import_hooks.doActionAsync)( 4416 "editor.savePost", 4417 { id: previousRecord.id, type: previousRecord.type }, 4418 options 4419 ); 4420 } catch (err) { 4421 error = err; 4422 } 4423 } 4424 dispatch6({ type: "REQUEST_POST_UPDATE_FINISH", options }); 4425 if (typeof window !== "undefined" && window.__experimentalTemplateActivate && !options.isAutosave && previousRecord.type === "wp_template" && (typeof previousRecord.id === "number" || /^\d+$/.test(previousRecord.id))) { 4426 templateActivationNotice({ select: select5, dispatch: dispatch6, registry }); 4427 } 4428 if (error) { 4429 const args = getNotificationArgumentsForSaveFail({ 4430 post: previousRecord, 4431 edits, 4432 error 4433 }); 4434 if (args.length) { 4435 registry.dispatch(import_notices.store).createErrorNotice(...args); 4436 } 4437 } else { 4438 const updatedRecord = select5.getCurrentPost(); 4439 const args = getNotificationArgumentsForSaveSuccess({ 4440 previousPost: previousRecord, 4441 post: updatedRecord, 4442 postType: await registry.resolveSelect(import_core_data2.store).getPostType(updatedRecord.type), 4443 options 4444 }); 4445 if (args.length) { 4446 registry.dispatch(import_notices.store).createSuccessNotice(...args); 4447 } 4448 if (!options.isAutosave) { 4449 registry.dispatch(import_block_editor3.store).__unstableMarkLastChangeAsPersistent(); 4450 } 4451 } 4452 }; 4453 async function templateActivationNotice({ select: select5, registry }) { 4454 const editorSettings2 = select5.getEditorSettings(); 4455 if (editorSettings2.onNavigateToPreviousEntityRecord) { 4456 return; 4457 } 4458 const { id, slug } = select5.getCurrentPost(); 4459 const site = await registry.select(import_core_data2.store).getEntityRecord("root", "site"); 4460 if (site.active_templates[slug] === id) { 4461 return; 4462 } 4463 const currentTheme = await registry.resolveSelect(import_core_data2.store).getCurrentTheme(); 4464 const templateType = currentTheme?.default_template_types.find( 4465 (type) => type.slug === slug 4466 ); 4467 await registry.dispatch(import_notices.store).createNotice( 4468 "info", 4469 (0, import_i18n2.sprintf)( 4470 // translators: %s: The name (or slug) of the type of template. 4471 (0, import_i18n2.__)('Do you want to activate this "%s" template?'), 4472 templateType?.title ?? slug 4473 ), 4474 { 4475 id: "template-activate-notice", 4476 actions: [ 4477 { 4478 label: (0, import_i18n2.__)("Activate"), 4479 onClick: async () => { 4480 await registry.dispatch(import_notices.store).createNotice( 4481 "info", 4482 (0, import_i18n2.__)("Activating template\u2026"), 4483 { id: "template-activate-notice" } 4484 ); 4485 try { 4486 const currentSite = await registry.select(import_core_data2.store).getEntityRecord("root", "site"); 4487 await registry.dispatch(import_core_data2.store).saveEntityRecord( 4488 "root", 4489 "site", 4490 { 4491 active_templates: { 4492 ...currentSite.active_templates, 4493 [slug]: id 4494 } 4495 }, 4496 { throwOnError: true } 4497 ); 4498 await registry.dispatch(import_notices.store).createSuccessNotice( 4499 (0, import_i18n2.__)("Template activated."), 4500 { id: "template-activate-notice" } 4501 ); 4502 } catch (error) { 4503 await registry.dispatch(import_notices.store).createErrorNotice( 4504 (0, import_i18n2.__)("Template activation failed."), 4505 { id: "template-activate-notice" } 4506 ); 4507 throw error; 4508 } 4509 } 4510 } 4511 ] 4512 } 4513 ); 4514 } 4515 function refreshPost() { 4516 (0, import_deprecated2.default)("wp.data.dispatch( 'core/editor' ).refreshPost", { 4517 since: "6.0", 4518 version: "6.3", 4519 alternative: "Use the core entities store instead" 4520 }); 4521 return { type: "DO_NOTHING" }; 4522 } 4523 var trashPost = () => async ({ select: select5, dispatch: dispatch6, registry }) => { 4524 const postTypeSlug = select5.getCurrentPostType(); 4525 const postType2 = await registry.resolveSelect(import_core_data2.store).getPostType(postTypeSlug); 4526 const { rest_base: restBase, rest_namespace: restNamespace = "wp/v2" } = postType2; 4527 dispatch6({ type: "REQUEST_POST_DELETE_START" }); 4528 try { 4529 const post2 = select5.getCurrentPost(); 4530 await (0, import_api_fetch.default)({ 4531 path: `/$restNamespace}/$restBase}/$post2.id}`, 4532 method: "DELETE" 4533 }); 4534 await dispatch6.savePost(); 4535 } catch (error) { 4536 registry.dispatch(import_notices.store).createErrorNotice( 4537 ...getNotificationArgumentsForTrashFail({ error }) 4538 ); 4539 } 4540 dispatch6({ type: "REQUEST_POST_DELETE_FINISH" }); 4541 }; 4542 var autosave = ({ local = false, ...options } = {}) => async ({ select: select5, dispatch: dispatch6 }) => { 4543 const post2 = select5.getCurrentPost(); 4544 if (post2.type === "wp_template") { 4545 return; 4546 } 4547 if (local) { 4548 const isPostNew = select5.isEditedPostNew(); 4549 const title = select5.getEditedPostAttribute("title"); 4550 const content = select5.getEditedPostAttribute("content"); 4551 const excerpt = select5.getEditedPostAttribute("excerpt"); 4552 localAutosaveSet(post2.id, isPostNew, title, content, excerpt); 4553 } else { 4554 await dispatch6.savePost({ isAutosave: true, ...options }); 4555 } 4556 }; 4557 var __unstableSaveForPreview = ({ forceIsAutosaveable } = {}) => async ({ select: select5, dispatch: dispatch6 }) => { 4558 if ((forceIsAutosaveable || select5.isEditedPostAutosaveable()) && !select5.isPostLocked()) { 4559 const isDraft = ["draft", "auto-draft"].includes( 4560 select5.getEditedPostAttribute("status") 4561 ); 4562 if (isDraft) { 4563 await dispatch6.savePost({ isPreview: true }); 4564 } else { 4565 await dispatch6.autosave({ isPreview: true }); 4566 } 4567 } 4568 return select5.getEditedPostPreviewLink(); 4569 }; 4570 var redo = () => ({ registry }) => { 4571 registry.dispatch(import_core_data2.store).redo(); 4572 }; 4573 var undo = () => ({ registry }) => { 4574 registry.dispatch(import_core_data2.store).undo(); 4575 }; 4576 function createUndoLevel() { 4577 (0, import_deprecated2.default)("wp.data.dispatch( 'core/editor' ).createUndoLevel", { 4578 since: "6.0", 4579 version: "6.3", 4580 alternative: "Use the core entities store instead" 4581 }); 4582 return { type: "DO_NOTHING" }; 4583 } 4584 function updatePostLock(lock4) { 4585 return { 4586 type: "UPDATE_POST_LOCK", 4587 lock: lock4 4588 }; 4589 } 4590 var enablePublishSidebar = () => ({ registry }) => { 4591 registry.dispatch(import_preferences2.store).set("core", "isPublishSidebarEnabled", true); 4592 }; 4593 var disablePublishSidebar = () => ({ registry }) => { 4594 registry.dispatch(import_preferences2.store).set("core", "isPublishSidebarEnabled", false); 4595 }; 4596 function lockPostSaving(lockName) { 4597 return { 4598 type: "LOCK_POST_SAVING", 4599 lockName 4600 }; 4601 } 4602 function unlockPostSaving(lockName) { 4603 return { 4604 type: "UNLOCK_POST_SAVING", 4605 lockName 4606 }; 4607 } 4608 function lockPostAutosaving(lockName) { 4609 return { 4610 type: "LOCK_POST_AUTOSAVING", 4611 lockName 4612 }; 4613 } 4614 function unlockPostAutosaving(lockName) { 4615 return { 4616 type: "UNLOCK_POST_AUTOSAVING", 4617 lockName 4618 }; 4619 } 4620 var resetEditorBlocks = (blocks, options = {}) => ({ select: select5, dispatch: dispatch6, registry }) => { 4621 const { __unstableShouldCreateUndoLevel, selection } = options; 4622 const edits = { blocks, selection }; 4623 if (__unstableShouldCreateUndoLevel !== false) { 4624 const { id, type } = select5.getCurrentPost(); 4625 const noChange = registry.select(import_core_data2.store).getEditedEntityRecord("postType", type, id).blocks === edits.blocks; 4626 if (noChange) { 4627 registry.dispatch(import_core_data2.store).__unstableCreateUndoLevel("postType", type, id); 4628 return; 4629 } 4630 edits.content = ({ blocks: blocksForSerialization = [] }) => (0, import_blocks2.__unstableSerializeAndClean)(blocksForSerialization); 4631 } 4632 dispatch6.editPost(edits); 4633 }; 4634 function updateEditorSettings(settings) { 4635 return { 4636 type: "UPDATE_EDITOR_SETTINGS", 4637 settings 4638 }; 4639 } 4640 var setRenderingMode = (mode) => ({ dispatch: dispatch6, registry, select: select5 }) => { 4641 if (select5.__unstableIsEditorReady() && !select5.getEditorSettings().isPreviewMode) { 4642 registry.dispatch(import_block_editor3.store).clearSelectedBlock(); 4643 dispatch6.editPost({ selection: void 0 }, { undoIgnore: true }); 4644 } 4645 dispatch6({ 4646 type: "SET_RENDERING_MODE", 4647 mode 4648 }); 4649 }; 4650 function setDeviceType(deviceType2) { 4651 return { 4652 type: "SET_DEVICE_TYPE", 4653 deviceType: deviceType2 4654 }; 4655 } 4656 var toggleEditorPanelEnabled = (panelName) => ({ registry }) => { 4657 const inactivePanels = registry.select(import_preferences2.store).get("core", "inactivePanels") ?? []; 4658 const isPanelInactive = !!inactivePanels?.includes(panelName); 4659 let updatedInactivePanels; 4660 if (isPanelInactive) { 4661 updatedInactivePanels = inactivePanels.filter( 4662 (invactivePanelName) => invactivePanelName !== panelName 4663 ); 4664 } else { 4665 updatedInactivePanels = [...inactivePanels, panelName]; 4666 } 4667 registry.dispatch(import_preferences2.store).set("core", "inactivePanels", updatedInactivePanels); 4668 }; 4669 var toggleEditorPanelOpened = (panelName) => ({ registry }) => { 4670 const openPanels = registry.select(import_preferences2.store).get("core", "openPanels") ?? []; 4671 const isPanelOpen = !!openPanels?.includes(panelName); 4672 let updatedOpenPanels; 4673 if (isPanelOpen) { 4674 updatedOpenPanels = openPanels.filter( 4675 (openPanelName) => openPanelName !== panelName 4676 ); 4677 } else { 4678 updatedOpenPanels = [...openPanels, panelName]; 4679 } 4680 registry.dispatch(import_preferences2.store).set("core", "openPanels", updatedOpenPanels); 4681 }; 4682 function removeEditorPanel(panelName) { 4683 return { 4684 type: "REMOVE_PANEL", 4685 panelName 4686 }; 4687 } 4688 var setIsInserterOpened = (value) => ({ dispatch: dispatch6, registry }) => { 4689 if (typeof value === "object" && value.hasOwnProperty("rootClientId") && value.hasOwnProperty("insertionIndex")) { 4690 unlock(registry.dispatch(import_block_editor3.store)).setInsertionPoint({ 4691 rootClientId: value.rootClientId, 4692 index: value.insertionIndex 4693 }); 4694 } 4695 dispatch6({ 4696 type: "SET_IS_INSERTER_OPENED", 4697 value 4698 }); 4699 }; 4700 function setIsListViewOpened(isOpen) { 4701 return { 4702 type: "SET_IS_LIST_VIEW_OPENED", 4703 isOpen 4704 }; 4705 } 4706 var toggleDistractionFree = ({ createNotice = true } = {}) => ({ dispatch: dispatch6, registry }) => { 4707 const isDistractionFree = registry.select(import_preferences2.store).get("core", "distractionFree"); 4708 if (isDistractionFree) { 4709 registry.dispatch(import_preferences2.store).set("core", "fixedToolbar", false); 4710 } 4711 if (!isDistractionFree) { 4712 registry.batch(() => { 4713 registry.dispatch(import_preferences2.store).set("core", "fixedToolbar", true); 4714 dispatch6.setIsInserterOpened(false); 4715 dispatch6.setIsListViewOpened(false); 4716 unlock( 4717 registry.dispatch(import_block_editor3.store) 4718 ).resetZoomLevel(); 4719 }); 4720 } 4721 registry.batch(() => { 4722 registry.dispatch(import_preferences2.store).set("core", "distractionFree", !isDistractionFree); 4723 if (createNotice) { 4724 registry.dispatch(import_notices.store).createInfoNotice( 4725 isDistractionFree ? (0, import_i18n2.__)("Distraction free mode deactivated.") : (0, import_i18n2.__)("Distraction free mode activated."), 4726 { 4727 id: "core/editor/distraction-free-mode/notice", 4728 type: "snackbar", 4729 actions: [ 4730 { 4731 label: (0, import_i18n2.__)("Undo"), 4732 onClick: () => { 4733 registry.batch(() => { 4734 registry.dispatch(import_preferences2.store).set( 4735 "core", 4736 "fixedToolbar", 4737 isDistractionFree 4738 ); 4739 registry.dispatch(import_preferences2.store).toggle( 4740 "core", 4741 "distractionFree" 4742 ); 4743 }); 4744 } 4745 } 4746 ] 4747 } 4748 ); 4749 } 4750 }); 4751 }; 4752 var toggleSpotlightMode = () => ({ registry }) => { 4753 registry.dispatch(import_preferences2.store).toggle("core", "focusMode"); 4754 const isFocusMode = registry.select(import_preferences2.store).get("core", "focusMode"); 4755 registry.dispatch(import_notices.store).createInfoNotice( 4756 isFocusMode ? (0, import_i18n2.__)("Spotlight mode activated.") : (0, import_i18n2.__)("Spotlight mode deactivated."), 4757 { 4758 id: "core/editor/toggle-spotlight-mode/notice", 4759 type: "snackbar", 4760 actions: [ 4761 { 4762 label: (0, import_i18n2.__)("Undo"), 4763 onClick: () => { 4764 registry.dispatch(import_preferences2.store).toggle("core", "focusMode"); 4765 } 4766 } 4767 ] 4768 } 4769 ); 4770 }; 4771 var toggleTopToolbar = () => ({ registry }) => { 4772 registry.dispatch(import_preferences2.store).toggle("core", "fixedToolbar"); 4773 const isTopToolbar = registry.select(import_preferences2.store).get("core", "fixedToolbar"); 4774 registry.dispatch(import_notices.store).createInfoNotice( 4775 isTopToolbar ? (0, import_i18n2.__)("Top toolbar activated.") : (0, import_i18n2.__)("Top toolbar deactivated."), 4776 { 4777 id: "core/editor/toggle-top-toolbar/notice", 4778 type: "snackbar", 4779 actions: [ 4780 { 4781 label: (0, import_i18n2.__)("Undo"), 4782 onClick: () => { 4783 registry.dispatch(import_preferences2.store).toggle("core", "fixedToolbar"); 4784 } 4785 } 4786 ] 4787 } 4788 ); 4789 }; 4790 var switchEditorMode = (mode) => ({ dispatch: dispatch6, registry }) => { 4791 registry.dispatch(import_preferences2.store).set("core", "editorMode", mode); 4792 if (mode !== "visual") { 4793 registry.dispatch(import_block_editor3.store).clearSelectedBlock(); 4794 unlock(registry.dispatch(import_block_editor3.store)).resetZoomLevel(); 4795 } 4796 if (mode === "visual") { 4797 (0, import_a11y.speak)((0, import_i18n2.__)("Visual editor selected"), "assertive"); 4798 } else if (mode === "text") { 4799 const isDistractionFree = registry.select(import_preferences2.store).get("core", "distractionFree"); 4800 if (isDistractionFree) { 4801 dispatch6.toggleDistractionFree(); 4802 } 4803 (0, import_a11y.speak)((0, import_i18n2.__)("Code editor selected"), "assertive"); 4804 } 4805 }; 4806 function openPublishSidebar() { 4807 return { 4808 type: "OPEN_PUBLISH_SIDEBAR" 4809 }; 4810 } 4811 function closePublishSidebar() { 4812 return { 4813 type: "CLOSE_PUBLISH_SIDEBAR" 4814 }; 4815 } 4816 function togglePublishSidebar() { 4817 return { 4818 type: "TOGGLE_PUBLISH_SIDEBAR" 4819 }; 4820 } 4821 var getBlockEditorAction = (name2) => (...args) => ({ registry }) => { 4822 (0, import_deprecated2.default)("`wp.data.dispatch( 'core/editor' )." + name2 + "`", { 4823 since: "5.3", 4824 alternative: "`wp.data.dispatch( 'core/block-editor' )." + name2 + "`", 4825 version: "6.2" 4826 }); 4827 registry.dispatch(import_block_editor3.store)[name2](...args); 4828 }; 4829 var resetBlocks = getBlockEditorAction("resetBlocks"); 4830 var receiveBlocks = getBlockEditorAction("receiveBlocks"); 4831 var updateBlock = getBlockEditorAction("updateBlock"); 4832 var updateBlockAttributes = getBlockEditorAction( 4833 "updateBlockAttributes" 4834 ); 4835 var selectBlock = getBlockEditorAction("selectBlock"); 4836 var startMultiSelect = getBlockEditorAction("startMultiSelect"); 4837 var stopMultiSelect = getBlockEditorAction("stopMultiSelect"); 4838 var multiSelect = getBlockEditorAction("multiSelect"); 4839 var clearSelectedBlock = getBlockEditorAction("clearSelectedBlock"); 4840 var toggleSelection = getBlockEditorAction("toggleSelection"); 4841 var replaceBlocks = getBlockEditorAction("replaceBlocks"); 4842 var replaceBlock = getBlockEditorAction("replaceBlock"); 4843 var moveBlocksDown = getBlockEditorAction("moveBlocksDown"); 4844 var moveBlocksUp = getBlockEditorAction("moveBlocksUp"); 4845 var moveBlockToPosition = getBlockEditorAction( 4846 "moveBlockToPosition" 4847 ); 4848 var insertBlock = getBlockEditorAction("insertBlock"); 4849 var insertBlocks = getBlockEditorAction("insertBlocks"); 4850 var showInsertionPoint = getBlockEditorAction("showInsertionPoint"); 4851 var hideInsertionPoint = getBlockEditorAction("hideInsertionPoint"); 4852 var setTemplateValidity = getBlockEditorAction( 4853 "setTemplateValidity" 4854 ); 4855 var synchronizeTemplate = getBlockEditorAction( 4856 "synchronizeTemplate" 4857 ); 4858 var mergeBlocks = getBlockEditorAction("mergeBlocks"); 4859 var removeBlocks = getBlockEditorAction("removeBlocks"); 4860 var removeBlock = getBlockEditorAction("removeBlock"); 4861 var toggleBlockMode = getBlockEditorAction("toggleBlockMode"); 4862 var startTyping = getBlockEditorAction("startTyping"); 4863 var stopTyping = getBlockEditorAction("stopTyping"); 4864 var enterFormattedText = getBlockEditorAction("enterFormattedText"); 4865 var exitFormattedText = getBlockEditorAction("exitFormattedText"); 4866 var insertDefaultBlock = getBlockEditorAction("insertDefaultBlock"); 4867 var updateBlockListSettings = getBlockEditorAction( 4868 "updateBlockListSettings" 4869 ); 4870 4871 // packages/editor/build-module/store/private-actions.js 4872 var private_actions_exports = {}; 4873 __export(private_actions_exports, { 4874 createTemplate: () => createTemplate, 4875 hideBlockTypes: () => hideBlockTypes, 4876 registerEntityAction: () => registerEntityAction, 4877 registerEntityField: () => registerEntityField, 4878 registerPostTypeSchema: () => registerPostTypeSchema, 4879 removeTemplates: () => removeTemplates, 4880 resetStylesNavigation: () => resetStylesNavigation, 4881 revertTemplate: () => revertTemplate2, 4882 saveDirtyEntities: () => saveDirtyEntities, 4883 setCanvasMinHeight: () => setCanvasMinHeight, 4884 setCurrentTemplateId: () => setCurrentTemplateId, 4885 setDefaultRenderingMode: () => setDefaultRenderingMode, 4886 setIsReady: () => setIsReady, 4887 setShowStylebook: () => setShowStylebook, 4888 setStylesPath: () => setStylesPath, 4889 showBlockTypes: () => showBlockTypes, 4890 unregisterEntityAction: () => unregisterEntityAction, 4891 unregisterEntityField: () => unregisterEntityField 4892 }); 4893 var import_core_data46 = __toESM(require_core_data()); 4894 var import_i18n108 = __toESM(require_i18n()); 4895 var import_notices16 = __toESM(require_notices()); 4896 var import_block_editor35 = __toESM(require_block_editor()); 4897 var import_preferences9 = __toESM(require_preferences()); 4898 var import_url9 = __toESM(require_url()); 4899 var import_api_fetch4 = __toESM(require_api_fetch()); 4900 var import_blocks19 = __toESM(require_blocks()); 4901 var import_html_entities9 = __toESM(require_html_entities()); 4902 4903 // packages/editor/build-module/store/utils/is-template-revertable.js 4904 function isTemplateRevertable(templateOrTemplatePart) { 4905 if (!templateOrTemplatePart) { 4906 return false; 4907 } 4908 return templateOrTemplatePart.source === TEMPLATE_ORIGINS.custom && (Boolean(templateOrTemplatePart?.plugin) || templateOrTemplatePart?.has_theme_file); 4909 } 4910 4911 // packages/editor/build-module/dataviews/store/private-actions.js 4912 var import_core_data45 = __toESM(require_core_data()); 4913 var import_hooks36 = __toESM(require_hooks()); 4914 4915 // packages/fields/build-module/fields/slug/index.js 4916 var import_i18n5 = __toESM(require_i18n()); 4917 4918 // packages/fields/build-module/fields/slug/slug-edit.js 4919 var import_components = __toESM(require_components()); 4920 var import_compose = __toESM(require_compose()); 4921 var import_data4 = __toESM(require_data()); 4922 var import_element3 = __toESM(require_element()); 4923 var import_notices2 = __toESM(require_notices()); 4924 var import_url3 = __toESM(require_url()); 4925 var import_i18n4 = __toESM(require_i18n()); 4926 4927 // packages/fields/build-module/fields/slug/utils.js 4928 var import_url2 = __toESM(require_url()); 4929 4930 // packages/fields/build-module/actions/utils.js 4931 var import_html_entities = __toESM(require_html_entities()); 4932 var import_i18n3 = __toESM(require_i18n()); 4933 function isTemplate(post2) { 4934 return post2.type === "wp_template"; 4935 } 4936 function isTemplatePart(post2) { 4937 return post2.type === "wp_template_part"; 4938 } 4939 function isTemplateOrTemplatePart(p4) { 4940 return p4.type === "wp_template" || p4.type === "wp_template_part"; 4941 } 4942 function getItemTitle(item, fallback = (0, import_i18n3.__)("(no title)")) { 4943 let title = ""; 4944 if (typeof item.title === "string") { 4945 title = (0, import_html_entities.decodeEntities)(item.title); 4946 } else if (item.title && "rendered" in item.title) { 4947 title = (0, import_html_entities.decodeEntities)(item.title.rendered); 4948 } else if (item.title && "raw" in item.title) { 4949 title = (0, import_html_entities.decodeEntities)(item.title.raw); 4950 } 4951 return title || fallback; 4952 } 4953 function isTemplateRemovable(template2) { 4954 if (!template2) { 4955 return false; 4956 } 4957 return [template2.source, template2.source].includes("custom") && !Boolean(template2.type === "wp_template" && template2?.plugin) && !template2.has_theme_file; 4958 } 4959 4960 // packages/fields/build-module/fields/slug/utils.js 4961 var getSlug = (item) => { 4962 if (typeof item !== "object") { 4963 return ""; 4964 } 4965 return item.slug || (0, import_url2.cleanForSlug)(getItemTitle(item)) || item.id.toString(); 4966 }; 4967 4968 // packages/fields/build-module/fields/slug/slug-edit.js 4969 var import_jsx_runtime67 = __toESM(require_jsx_runtime()); 4970 var SlugEdit = ({ 4971 field, 4972 onChange, 4973 data 4974 }) => { 4975 const { id } = field; 4976 const slug = field.getValue({ item: data }) || getSlug(data); 4977 const permalinkTemplate = data.permalink_template || ""; 4978 const PERMALINK_POSTNAME_REGEX2 = /%(?:postname|pagename)%/; 4979 const [prefix, suffix] = permalinkTemplate.split( 4980 PERMALINK_POSTNAME_REGEX2 4981 ); 4982 const permalinkPrefix = prefix; 4983 const permalinkSuffix = suffix; 4984 const isEditable = PERMALINK_POSTNAME_REGEX2.test(permalinkTemplate); 4985 const originalSlugRef = (0, import_element3.useRef)(slug); 4986 const slugToDisplay = slug || originalSlugRef.current; 4987 const permalink = isEditable ? `$permalinkPrefix}$slugToDisplay}$permalinkSuffix}` : (0, import_url3.safeDecodeURIComponent)(data.link || ""); 4988 (0, import_element3.useEffect)(() => { 4989 if (slug && originalSlugRef.current === void 0) { 4990 originalSlugRef.current = slug; 4991 } 4992 }, [slug]); 4993 const onChangeControl = (0, import_element3.useCallback)( 4994 (newValue) => onChange({ 4995 [id]: newValue 4996 }), 4997 [id, onChange] 4998 ); 4999 const { createNotice } = (0, import_data4.useDispatch)(import_notices2.store); 5000 const copyButtonRef = (0, import_compose.useCopyToClipboard)(permalink, () => { 5001 createNotice("info", (0, import_i18n4.__)("Copied Permalink to clipboard."), { 5002 isDismissible: true, 5003 type: "snackbar" 5004 }); 5005 }); 5006 const postUrlSlugDescriptionId = "editor-post-url__slug-description-" + (0, import_compose.useInstanceId)(SlugEdit); 5007 return /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)("fieldset", { className: "fields-controls__slug", children: [ 5008 isEditable && /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(import_components.__experimentalVStack, { children: [ 5009 /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(import_components.__experimentalVStack, { spacing: "0px", children: [ 5010 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("span", { children: (0, import_i18n4.__)( 5011 "Customize the last part of the Permalink." 5012 ) }), 5013 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(import_components.ExternalLink, { href: "https://wordpress.org/documentation/article/page-post-settings-sidebar/#permalink", children: (0, import_i18n4.__)("Learn more") }) 5014 ] }), 5015 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)( 5016 import_components.__experimentalInputControl, 5017 { 5018 __next40pxDefaultSize: true, 5019 prefix: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(import_components.__experimentalInputControlPrefixWrapper, { children: "/" }), 5020 suffix: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(import_components.__experimentalInputControlSuffixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)( 5021 import_components.Button, 5022 { 5023 size: "small", 5024 icon: copy_small_default, 5025 ref: copyButtonRef, 5026 label: (0, import_i18n4.__)("Copy") 5027 } 5028 ) }), 5029 label: (0, import_i18n4.__)("Link"), 5030 hideLabelFromVision: true, 5031 value: slug, 5032 autoComplete: "off", 5033 spellCheck: "false", 5034 type: "text", 5035 className: "fields-controls__slug-input", 5036 onChange: (newValue) => { 5037 onChangeControl(newValue); 5038 }, 5039 onBlur: () => { 5040 if (slug === "") { 5041 onChangeControl(originalSlugRef.current); 5042 } 5043 }, 5044 "aria-describedby": postUrlSlugDescriptionId 5045 } 5046 ), 5047 /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)("div", { className: "fields-controls__slug-help", children: [ 5048 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("span", { className: "fields-controls__slug-help-visual-label", children: (0, import_i18n4.__)("Permalink:") }), 5049 /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)( 5050 import_components.ExternalLink, 5051 { 5052 className: "fields-controls__slug-help-link", 5053 href: permalink, 5054 children: [ 5055 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("span", { className: "fields-controls__slug-help-prefix", children: permalinkPrefix }), 5056 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("span", { className: "fields-controls__slug-help-slug", children: slugToDisplay }), 5057 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("span", { className: "fields-controls__slug-help-suffix", children: permalinkSuffix }) 5058 ] 5059 } 5060 ) 5061 ] }) 5062 ] }), 5063 !isEditable && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)( 5064 import_components.ExternalLink, 5065 { 5066 className: "fields-controls__slug-help", 5067 href: permalink, 5068 children: permalink 5069 } 5070 ) 5071 ] }); 5072 }; 5073 var slug_edit_default = SlugEdit; 5074 5075 // packages/fields/build-module/fields/slug/slug-view.js 5076 var import_element4 = __toESM(require_element()); 5077 var SlugView = ({ item }) => { 5078 const slug = getSlug(item); 5079 const originalSlugRef = (0, import_element4.useRef)(slug); 5080 (0, import_element4.useEffect)(() => { 5081 if (slug && originalSlugRef.current === void 0) { 5082 originalSlugRef.current = slug; 5083 } 5084 }, [slug]); 5085 const slugToDisplay = slug || originalSlugRef.current; 5086 return `$slugToDisplay}`; 5087 }; 5088 var slug_view_default = SlugView; 5089 5090 // packages/fields/build-module/fields/slug/index.js 5091 var slugField = { 5092 id: "slug", 5093 type: "text", 5094 label: (0, import_i18n5.__)("Slug"), 5095 Edit: slug_edit_default, 5096 render: slug_view_default, 5097 filterBy: false 5098 }; 5099 var slug_default = slugField; 5100 5101 // packages/fields/build-module/fields/title/index.js 5102 var import_i18n7 = __toESM(require_i18n()); 5103 5104 // node_modules/clsx/dist/clsx.mjs 5105 function r(e3) { 5106 var t4, f3, n3 = ""; 5107 if ("string" == typeof e3 || "number" == typeof e3) n3 += e3; 5108 else if ("object" == typeof e3) if (Array.isArray(e3)) { 5109 var o4 = e3.length; 5110 for (t4 = 0; t4 < o4; t4++) e3[t4] && (f3 = r(e3[t4])) && (n3 && (n3 += " "), n3 += f3); 5111 } else for (f3 in e3) e3[f3] && (n3 && (n3 += " "), n3 += f3); 5112 return n3; 5113 } 5114 function clsx() { 5115 for (var e3, t4, f3 = 0, n3 = "", o4 = arguments.length; f3 < o4; f3++) (e3 = arguments[f3]) && (t4 = r(e3)) && (n3 && (n3 += " "), n3 += t4); 5116 return n3; 5117 } 5118 var clsx_default = clsx; 5119 5120 // packages/fields/build-module/fields/title/view.js 5121 var import_components2 = __toESM(require_components()); 5122 var import_i18n6 = __toESM(require_i18n()); 5123 var import_jsx_runtime68 = __toESM(require_jsx_runtime()); 5124 function BaseTitleView({ 5125 item, 5126 className, 5127 children 5128 }) { 5129 const renderedTitle = getItemTitle(item); 5130 return /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)( 5131 import_components2.__experimentalHStack, 5132 { 5133 className: clsx_default("fields-field__title", className), 5134 alignment: "center", 5135 justify: "flex-start", 5136 children: [ 5137 /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("span", { children: renderedTitle || (0, import_i18n6.__)("(no title)") }), 5138 children 5139 ] 5140 } 5141 ); 5142 } 5143 function TitleView({ item }) { 5144 return /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(BaseTitleView, { item }); 5145 } 5146 5147 // packages/fields/build-module/fields/title/index.js 5148 var titleField = { 5149 type: "text", 5150 id: "title", 5151 label: (0, import_i18n7.__)("Title"), 5152 placeholder: (0, import_i18n7.__)("No title"), 5153 getValue: ({ item }) => getItemTitle(item), 5154 render: TitleView, 5155 enableHiding: true, 5156 enableGlobalSearch: true, 5157 filterBy: false 5158 }; 5159 var title_default = titleField; 5160 5161 // packages/fields/build-module/fields/page-title/index.js 5162 var import_i18n9 = __toESM(require_i18n()); 5163 5164 // packages/fields/build-module/fields/page-title/view.js 5165 var import_i18n8 = __toESM(require_i18n()); 5166 var import_data5 = __toESM(require_data()); 5167 var import_core_data3 = __toESM(require_core_data()); 5168 var import_components3 = __toESM(require_components()); 5169 5170 // packages/fields/build-module/lock-unlock.js 5171 var import_private_apis2 = __toESM(require_private_apis()); 5172 var { lock: lock2, unlock: unlock2 } = (0, import_private_apis2.__dangerousOptInToUnstableAPIsOnlyForCoreModules)( 5173 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.", 5174 "@wordpress/fields" 5175 ); 5176 5177 // packages/fields/build-module/fields/page-title/view.js 5178 var import_jsx_runtime69 = __toESM(require_jsx_runtime()); 5179 var { Badge } = unlock2(import_components3.privateApis); 5180 function PageTitleView({ item }) { 5181 const { frontPageId, postsPageId } = (0, import_data5.useSelect)((select5) => { 5182 const { getEntityRecord } = select5(import_core_data3.store); 5183 const siteSettings = getEntityRecord( 5184 "root", 5185 "site" 5186 ); 5187 return { 5188 frontPageId: siteSettings?.page_on_front, 5189 postsPageId: siteSettings?.page_for_posts 5190 }; 5191 }, []); 5192 return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(BaseTitleView, { item, className: "fields-field__page-title", children: [frontPageId, postsPageId].includes(item.id) && /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(Badge, { children: item.id === frontPageId ? (0, import_i18n8.__)("Homepage") : (0, import_i18n8.__)("Posts Page") }) }); 5193 } 5194 5195 // packages/fields/build-module/fields/page-title/index.js 5196 var pageTitleField = { 5197 type: "text", 5198 id: "title", 5199 label: (0, import_i18n9.__)("Title"), 5200 placeholder: (0, import_i18n9.__)("No title"), 5201 getValue: ({ item }) => getItemTitle(item), 5202 render: PageTitleView, 5203 enableHiding: false, 5204 enableGlobalSearch: true, 5205 filterBy: false 5206 }; 5207 var page_title_default = pageTitleField; 5208 5209 // packages/fields/build-module/fields/template-title/index.js 5210 var import_i18n10 = __toESM(require_i18n()); 5211 var templateTitleField = { 5212 type: "text", 5213 label: (0, import_i18n10.__)("Template"), 5214 placeholder: (0, import_i18n10.__)("No title"), 5215 id: "title", 5216 getValue: ({ item }) => getItemTitle(item), 5217 render: TitleView, 5218 enableHiding: false, 5219 enableGlobalSearch: true, 5220 filterBy: false 5221 }; 5222 var template_title_default = templateTitleField; 5223 5224 // packages/fields/build-module/fields/pattern-title/index.js 5225 var import_i18n12 = __toESM(require_i18n()); 5226 5227 // packages/fields/build-module/fields/pattern-title/view.js 5228 var import_i18n11 = __toESM(require_i18n()); 5229 var import_components4 = __toESM(require_components()); 5230 var import_patterns = __toESM(require_patterns()); 5231 var import_jsx_runtime70 = __toESM(require_jsx_runtime()); 5232 var { PATTERN_TYPES } = unlock2(import_patterns.privateApis); 5233 function PatternTitleView({ item }) { 5234 return /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(BaseTitleView, { item, className: "fields-field__pattern-title", children: item.type === PATTERN_TYPES.theme && /* @__PURE__ */ (0, import_jsx_runtime70.jsx)( 5235 import_components4.Tooltip, 5236 { 5237 placement: "top", 5238 text: (0, import_i18n11.__)("This pattern cannot be edited."), 5239 children: /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(icon_default, { icon: lock_small_default, size: 24 }) 5240 } 5241 ) }); 5242 } 5243 5244 // packages/fields/build-module/fields/pattern-title/index.js 5245 var patternTitleField = { 5246 type: "text", 5247 id: "title", 5248 label: (0, import_i18n12.__)("Title"), 5249 placeholder: (0, import_i18n12.__)("No title"), 5250 getValue: ({ item }) => getItemTitle(item), 5251 render: PatternTitleView, 5252 enableHiding: false, 5253 enableGlobalSearch: true, 5254 filterBy: false 5255 }; 5256 var pattern_title_default = patternTitleField; 5257 5258 // packages/fields/build-module/fields/featured-image/index.js 5259 var import_i18n14 = __toESM(require_i18n()); 5260 5261 // packages/fields/build-module/fields/featured-image/featured-image-edit.js 5262 var import_components5 = __toESM(require_components()); 5263 var import_data6 = __toESM(require_data()); 5264 var import_element5 = __toESM(require_element()); 5265 var import_media_utils = __toESM(require_media_utils()); 5266 var import_core_data4 = __toESM(require_core_data()); 5267 var import_i18n13 = __toESM(require_i18n()); 5268 var import_jsx_runtime71 = __toESM(require_jsx_runtime()); 5269 var { MediaUploadModal } = unlock2(import_media_utils.privateApis); 5270 function ConditionalMediaUpload({ render, ...props }) { 5271 const [isModalOpen, setIsModalOpen] = (0, import_element5.useState)(false); 5272 if (window.__experimentalDataViewsMediaModal) { 5273 return /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(import_jsx_runtime71.Fragment, { children: [ 5274 render && render({ open: () => setIsModalOpen(true) }), 5275 /* @__PURE__ */ (0, import_jsx_runtime71.jsx)( 5276 MediaUploadModal, 5277 { 5278 ...props, 5279 isOpen: isModalOpen, 5280 onClose: () => { 5281 setIsModalOpen(false); 5282 props.onClose?.(); 5283 }, 5284 onSelect: (media) => { 5285 setIsModalOpen(false); 5286 props.onSelect?.(media); 5287 } 5288 } 5289 ) 5290 ] }); 5291 } 5292 return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(import_media_utils.MediaUpload, { ...props, render }); 5293 } 5294 var FeaturedImageEdit = ({ 5295 data, 5296 field, 5297 onChange 5298 }) => { 5299 const { id } = field; 5300 const value = field.getValue({ item: data }); 5301 const media = (0, import_data6.useSelect)( 5302 (select5) => { 5303 const { getEntityRecord } = select5(import_core_data4.store); 5304 return getEntityRecord("postType", "attachment", value); 5305 }, 5306 [value] 5307 ); 5308 const onChangeControl = (0, import_element5.useCallback)( 5309 (newValue) => onChange({ 5310 [id]: newValue 5311 }), 5312 [id, onChange] 5313 ); 5314 const url = media?.source_url; 5315 const title = media?.title?.rendered; 5316 const ref = (0, import_element5.useRef)(null); 5317 return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("fieldset", { className: "fields-controls__featured-image", children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("div", { className: "fields-controls__featured-image-container", children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)( 5318 ConditionalMediaUpload, 5319 { 5320 onSelect: (selectedMedia) => { 5321 onChangeControl(selectedMedia.id); 5322 }, 5323 allowedTypes: ["image"], 5324 value, 5325 title: (0, import_i18n13.__)("Select Featured Image"), 5326 render: ({ open }) => /* @__PURE__ */ (0, import_jsx_runtime71.jsx)( 5327 "div", 5328 { 5329 ref, 5330 role: "button", 5331 tabIndex: -1, 5332 onClick: open, 5333 onKeyDown: (event) => { 5334 if (event.key === "Enter" || event.key === " ") { 5335 event.preventDefault(); 5336 open(); 5337 } 5338 }, 5339 children: /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)( 5340 import_components5.__experimentalGrid, 5341 { 5342 rowGap: 0, 5343 columnGap: 8, 5344 templateColumns: "24px 1fr 24px", 5345 children: [ 5346 url && /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(import_jsx_runtime71.Fragment, { children: [ 5347 /* @__PURE__ */ (0, import_jsx_runtime71.jsx)( 5348 "img", 5349 { 5350 className: "fields-controls__featured-image-image", 5351 alt: "", 5352 width: 24, 5353 height: 24, 5354 src: url 5355 } 5356 ), 5357 /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("span", { className: "fields-controls__featured-image-title", children: title }) 5358 ] }), 5359 !url && /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(import_jsx_runtime71.Fragment, { children: [ 5360 /* @__PURE__ */ (0, import_jsx_runtime71.jsx)( 5361 "span", 5362 { 5363 className: "fields-controls__featured-image-placeholder", 5364 style: { 5365 width: "24px", 5366 height: "24px" 5367 } 5368 } 5369 ), 5370 /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("span", { className: "fields-controls__featured-image-title", children: (0, import_i18n13.__)("Choose an image\u2026") }) 5371 ] }), 5372 url && /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(import_jsx_runtime71.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)( 5373 import_components5.Button, 5374 { 5375 size: "small", 5376 className: "fields-controls__featured-image-remove-button", 5377 icon: line_solid_default, 5378 onClick: (event) => { 5379 event.stopPropagation(); 5380 onChangeControl(0); 5381 } 5382 } 5383 ) }) 5384 ] 5385 } 5386 ) 5387 } 5388 ) 5389 } 5390 ) }) }); 5391 }; 5392 5393 // packages/fields/build-module/fields/featured-image/featured-image-view.js 5394 var import_jsx_runtime72 = __toESM(require_jsx_runtime()); 5395 var FeaturedImageView = ({ 5396 item, 5397 config 5398 }) => { 5399 const media = item?._embedded?.["wp:featuredmedia"]?.[0]; 5400 const url = media?.source_url; 5401 if (url) { 5402 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)( 5403 "img", 5404 { 5405 className: "fields-controls__featured-image-image", 5406 src: url, 5407 alt: "", 5408 srcSet: media?.media_details?.sizes ? Object.values(media.media_details.sizes).map( 5409 (size3) => `$size3.source_url} $size3.width}w` 5410 ).join(", ") : void 0, 5411 sizes: config?.sizes || "100vw" 5412 } 5413 ); 5414 } 5415 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("span", { className: "fields-controls__featured-image-placeholder" }); 5416 }; 5417 5418 // packages/fields/build-module/fields/featured-image/index.js 5419 var featuredImageField = { 5420 id: "featured_media", 5421 type: "media", 5422 label: (0, import_i18n14.__)("Featured Image"), 5423 Edit: FeaturedImageEdit, 5424 render: FeaturedImageView, 5425 enableSorting: false, 5426 filterBy: false 5427 }; 5428 var featured_image_default = featuredImageField; 5429 5430 // packages/fields/build-module/fields/template/index.js 5431 var import_i18n16 = __toESM(require_i18n()); 5432 5433 // packages/fields/build-module/fields/template/template-edit.js 5434 var import_element6 = __toESM(require_element()); 5435 var import_blocks3 = __toESM(require_blocks()); 5436 var import_core_data5 = __toESM(require_core_data()); 5437 var import_block_editor4 = __toESM(require_block_editor()); 5438 var import_components6 = __toESM(require_components()); 5439 var import_compose2 = __toESM(require_compose()); 5440 var import_data7 = __toESM(require_data()); 5441 var import_html_entities2 = __toESM(require_html_entities()); 5442 var import_i18n15 = __toESM(require_i18n()); 5443 var import_jsx_runtime73 = __toESM(require_jsx_runtime()); 5444 var EMPTY_ARRAY = []; 5445 var TemplateEdit = ({ 5446 data, 5447 field, 5448 onChange 5449 }) => { 5450 const { id } = field; 5451 const postType2 = data.type; 5452 const postId2 = typeof data.id === "number" ? data.id : parseInt(data.id, 10); 5453 const slug = data.slug; 5454 const { canSwitchTemplate, templates } = (0, import_data7.useSelect)( 5455 (select5) => { 5456 const allTemplates = select5(import_core_data5.store).getEntityRecords( 5457 "postType", 5458 "wp_template", 5459 { 5460 per_page: -1, 5461 post_type: postType2 5462 } 5463 ) ?? EMPTY_ARRAY; 5464 const { getHomePage, getPostsPageId } = unlock2( 5465 select5(import_core_data5.store) 5466 ); 5467 const isPostsPage = getPostsPageId() === +postId2; 5468 const isFrontPage = postType2 === "page" && getHomePage()?.postId === +postId2; 5469 const allowSwitchingTemplate = !isPostsPage && !isFrontPage; 5470 return { 5471 templates: allTemplates, 5472 canSwitchTemplate: allowSwitchingTemplate 5473 }; 5474 }, 5475 [postId2, postType2] 5476 ); 5477 const templatesAsPatterns = (0, import_element6.useMemo)(() => { 5478 if (!canSwitchTemplate) { 5479 return []; 5480 } 5481 return templates.filter( 5482 (template2) => template2.is_custom && template2.slug !== data.template && // Skip empty templates. 5483 !!template2.content.raw 5484 ).map((template2) => ({ 5485 name: template2.slug, 5486 blocks: (0, import_blocks3.parse)(template2.content.raw), 5487 title: (0, import_html_entities2.decodeEntities)(template2.title.rendered), 5488 id: template2.id 5489 })); 5490 }, [canSwitchTemplate, data.template, templates]); 5491 const shownTemplates = (0, import_compose2.useAsyncList)(templatesAsPatterns); 5492 const value = field.getValue({ item: data }); 5493 const foundTemplate = templates.find( 5494 (template2) => template2.slug === value 5495 ); 5496 const currentTemplate = (0, import_data7.useSelect)( 5497 (select5) => { 5498 if (foundTemplate) { 5499 return foundTemplate; 5500 } 5501 let slugToCheck; 5502 if (slug) { 5503 slugToCheck = postType2 === "page" ? `$postType2}-$slug}` : `single-$postType2}-$slug}`; 5504 } else { 5505 slugToCheck = postType2 === "page" ? "page" : `single-$postType2}`; 5506 } 5507 if (postType2) { 5508 const templateId2 = select5(import_core_data5.store).getDefaultTemplateId({ 5509 slug: slugToCheck 5510 }); 5511 return select5(import_core_data5.store).getEntityRecord( 5512 "postType", 5513 "wp_template", 5514 templateId2 5515 ); 5516 } 5517 }, 5518 [foundTemplate, postType2, slug] 5519 ); 5520 const [showModal, setShowModal] = (0, import_element6.useState)(false); 5521 const onChangeControl = (0, import_element6.useCallback)( 5522 (newValue) => onChange({ 5523 [id]: newValue 5524 }), 5525 [id, onChange] 5526 ); 5527 return /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("fieldset", { className: "fields-controls__template", children: [ 5528 /* @__PURE__ */ (0, import_jsx_runtime73.jsx)( 5529 import_components6.Dropdown, 5530 { 5531 popoverProps: { placement: "bottom-start" }, 5532 renderToggle: ({ onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime73.jsx)( 5533 import_components6.Button, 5534 { 5535 __next40pxDefaultSize: true, 5536 variant: "tertiary", 5537 size: "compact", 5538 onClick: onToggle, 5539 children: currentTemplate ? getItemTitle(currentTemplate) : "" 5540 } 5541 ), 5542 renderContent: ({ onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)(import_components6.MenuGroup, { children: [ 5543 /* @__PURE__ */ (0, import_jsx_runtime73.jsx)( 5544 import_components6.MenuItem, 5545 { 5546 onClick: () => { 5547 setShowModal(true); 5548 onToggle(); 5549 }, 5550 children: (0, import_i18n15.__)("Change template") 5551 } 5552 ), 5553 // The default template in a post is indicated by an empty string 5554 value !== "" && /* @__PURE__ */ (0, import_jsx_runtime73.jsx)( 5555 import_components6.MenuItem, 5556 { 5557 onClick: () => { 5558 onChangeControl(""); 5559 onToggle(); 5560 }, 5561 children: (0, import_i18n15.__)("Use default template") 5562 } 5563 ) 5564 ] }) 5565 } 5566 ), 5567 showModal && /* @__PURE__ */ (0, import_jsx_runtime73.jsx)( 5568 import_components6.Modal, 5569 { 5570 title: (0, import_i18n15.__)("Choose a template"), 5571 onRequestClose: () => setShowModal(false), 5572 overlayClassName: "fields-controls__template-modal", 5573 isFullScreen: true, 5574 children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)("div", { className: "fields-controls__template-content", children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)( 5575 import_block_editor4.__experimentalBlockPatternsList, 5576 { 5577 label: (0, import_i18n15.__)("Templates"), 5578 blockPatterns: templatesAsPatterns, 5579 shownPatterns: shownTemplates, 5580 onClickPattern: (template2) => { 5581 onChangeControl(template2.name); 5582 setShowModal(false); 5583 } 5584 } 5585 ) }) 5586 } 5587 ) 5588 ] }); 5589 }; 5590 5591 // packages/fields/build-module/fields/template/index.js 5592 var templateField = { 5593 id: "template", 5594 type: "text", 5595 label: (0, import_i18n16.__)("Template"), 5596 Edit: TemplateEdit, 5597 enableSorting: false, 5598 filterBy: false 5599 }; 5600 var template_default = templateField; 5601 5602 // packages/fields/build-module/fields/parent/index.js 5603 var import_i18n20 = __toESM(require_i18n()); 5604 5605 // packages/fields/build-module/fields/parent/parent-edit.js 5606 var import_remove_accents = __toESM(require_remove_accents()); 5607 var import_components7 = __toESM(require_components()); 5608 var import_data8 = __toESM(require_data()); 5609 var import_element7 = __toESM(require_element()); 5610 var import_core_data6 = __toESM(require_core_data()); 5611 var import_compose3 = __toESM(require_compose()); 5612 var import_html_entities4 = __toESM(require_html_entities()); 5613 var import_i18n18 = __toESM(require_i18n()); 5614 var import_url4 = __toESM(require_url()); 5615 5616 // packages/fields/build-module/fields/parent/utils.js 5617 var import_html_entities3 = __toESM(require_html_entities()); 5618 var import_i18n17 = __toESM(require_i18n()); 5619 function getTitleWithFallbackName(post2) { 5620 return typeof post2.title === "object" && "rendered" in post2.title && post2.title.rendered ? (0, import_html_entities3.decodeEntities)(post2.title.rendered) : `#$post2?.id} (${(0, import_i18n17.__)("no title")})`; 5621 } 5622 5623 // packages/fields/build-module/fields/parent/parent-edit.js 5624 var import_jsx_runtime74 = __toESM(require_jsx_runtime()); 5625 function buildTermsTree(flatTerms) { 5626 const flatTermsWithParentAndChildren = flatTerms.map((term) => { 5627 return { 5628 children: [], 5629 ...term 5630 }; 5631 }); 5632 if (flatTermsWithParentAndChildren.some( 5633 ({ parent }) => parent === null || parent === void 0 5634 )) { 5635 return flatTermsWithParentAndChildren; 5636 } 5637 const termsByParent = flatTermsWithParentAndChildren.reduce( 5638 (acc, term) => { 5639 const { parent } = term; 5640 if (!acc[parent]) { 5641 acc[parent] = []; 5642 } 5643 acc[parent].push(term); 5644 return acc; 5645 }, 5646 {} 5647 ); 5648 const fillWithChildren = (terms) => { 5649 return terms.map((term) => { 5650 const children = termsByParent[term.id]; 5651 return { 5652 ...term, 5653 children: children && children.length ? fillWithChildren(children) : [] 5654 }; 5655 }); 5656 }; 5657 return fillWithChildren(termsByParent["0"] || []); 5658 } 5659 var getItemPriority = (name2, searchValue) => { 5660 const normalizedName = (0, import_remove_accents.default)(name2 || "").toLowerCase(); 5661 const normalizedSearch = (0, import_remove_accents.default)(searchValue || "").toLowerCase(); 5662 if (normalizedName === normalizedSearch) { 5663 return 0; 5664 } 5665 if (normalizedName.startsWith(normalizedSearch)) { 5666 return normalizedName.length; 5667 } 5668 return Infinity; 5669 }; 5670 function PageAttributesParent({ 5671 data, 5672 onChangeControl 5673 }) { 5674 const [fieldValue, setFieldValue] = (0, import_element7.useState)(null); 5675 const pageId = data.parent; 5676 const postId2 = data.id; 5677 const postTypeSlug = data.type; 5678 const { parentPostTitle, pageItems, isHierarchical } = (0, import_data8.useSelect)( 5679 (select5) => { 5680 const { getEntityRecord, getEntityRecords, getPostType } = select5(import_core_data6.store); 5681 const postTypeInfo = getPostType(postTypeSlug); 5682 const postIsHierarchical = postTypeInfo?.hierarchical && postTypeInfo.viewable; 5683 const parentPost = pageId ? getEntityRecord( 5684 "postType", 5685 postTypeSlug, 5686 pageId 5687 ) : null; 5688 const query = { 5689 per_page: 100, 5690 exclude: postId2, 5691 parent_exclude: postId2, 5692 orderby: "menu_order", 5693 order: "asc", 5694 _fields: "id,title,parent", 5695 ...fieldValue !== null && { 5696 // Perform a search by relevance when the field is changed. 5697 search: fieldValue, 5698 orderby: "relevance" 5699 } 5700 }; 5701 return { 5702 isHierarchical: postIsHierarchical, 5703 parentPostTitle: parentPost ? getTitleWithFallbackName(parentPost) : "", 5704 pageItems: postIsHierarchical ? getEntityRecords( 5705 "postType", 5706 postTypeSlug, 5707 query 5708 ) : null 5709 }; 5710 }, 5711 [fieldValue, pageId, postId2, postTypeSlug] 5712 ); 5713 const parentOptions = (0, import_element7.useMemo)(() => { 5714 const getOptionsFromTree = (tree2, level = 0) => { 5715 const mappedNodes = tree2.map((treeNode) => [ 5716 { 5717 value: treeNode.id, 5718 label: "\u2014 ".repeat(level) + (0, import_html_entities4.decodeEntities)(treeNode.name), 5719 rawName: treeNode.name 5720 }, 5721 ...getOptionsFromTree(treeNode.children || [], level + 1) 5722 ]); 5723 const sortedNodes = mappedNodes.sort(([a3], [b3]) => { 5724 const priorityA = getItemPriority( 5725 a3.rawName, 5726 fieldValue ?? "" 5727 ); 5728 const priorityB = getItemPriority( 5729 b3.rawName, 5730 fieldValue ?? "" 5731 ); 5732 return priorityA >= priorityB ? 1 : -1; 5733 }); 5734 return sortedNodes.flat(); 5735 }; 5736 if (!pageItems) { 5737 return []; 5738 } 5739 let tree = pageItems.map((item) => ({ 5740 id: item.id, 5741 parent: item.parent ?? null, 5742 name: getTitleWithFallbackName(item) 5743 })); 5744 if (!fieldValue) { 5745 tree = buildTermsTree(tree); 5746 } 5747 const opts = getOptionsFromTree(tree); 5748 const optsHasParent = opts.find((item) => item.value === pageId); 5749 if (pageId && parentPostTitle && !optsHasParent) { 5750 opts.unshift({ 5751 value: pageId, 5752 label: parentPostTitle, 5753 rawName: "" 5754 }); 5755 } 5756 return opts.map((option) => ({ 5757 ...option, 5758 value: option.value.toString() 5759 })); 5760 }, [pageItems, fieldValue, parentPostTitle, pageId]); 5761 if (!isHierarchical) { 5762 return null; 5763 } 5764 const handleKeydown = (inputValue) => { 5765 setFieldValue(inputValue); 5766 }; 5767 const handleChange = (selectedPostId) => { 5768 if (selectedPostId) { 5769 return onChangeControl(parseInt(selectedPostId, 10) ?? 0); 5770 } 5771 onChangeControl(0); 5772 }; 5773 return /* @__PURE__ */ (0, import_jsx_runtime74.jsx)( 5774 import_components7.ComboboxControl, 5775 { 5776 __next40pxDefaultSize: true, 5777 label: (0, import_i18n18.__)("Parent"), 5778 help: (0, import_i18n18.__)("Choose a parent page."), 5779 value: pageId?.toString(), 5780 options: parentOptions, 5781 onFilterValueChange: (0, import_compose3.debounce)( 5782 (value) => handleKeydown(value), 5783 300 5784 ), 5785 onChange: handleChange, 5786 hideLabelFromVision: true 5787 } 5788 ); 5789 } 5790 var ParentEdit = ({ 5791 data, 5792 field, 5793 onChange 5794 }) => { 5795 const { id } = field; 5796 const homeUrl = (0, import_data8.useSelect)((select5) => { 5797 return select5(import_core_data6.store).getEntityRecord("root", "__unstableBase")?.home; 5798 }, []); 5799 const onChangeControl = (0, import_element7.useCallback)( 5800 (newValue) => onChange({ 5801 [id]: newValue 5802 }), 5803 [id, onChange] 5804 ); 5805 return /* @__PURE__ */ (0, import_jsx_runtime74.jsx)("fieldset", { className: "fields-controls__parent", children: /* @__PURE__ */ (0, import_jsx_runtime74.jsxs)("div", { children: [ 5806 (0, import_element7.createInterpolateElement)( 5807 (0, import_i18n18.sprintf)( 5808 /* translators: %1$s The home URL of the WordPress installation without the scheme. */ 5809 (0, import_i18n18.__)( 5810 'Child pages inherit characteristics from their parent, such as URL structure. For instance, if "Pricing" is a child of "Services", its URL would be %1$s<wbr />/services<wbr />/pricing.' 5811 ), 5812 (0, import_url4.filterURLForDisplay)(homeUrl).replace( 5813 /([/.])/g, 5814 "<wbr />$1" 5815 ) 5816 ), 5817 { 5818 wbr: /* @__PURE__ */ (0, import_jsx_runtime74.jsx)("wbr", {}) 5819 } 5820 ), 5821 /* @__PURE__ */ (0, import_jsx_runtime74.jsx)("p", { children: (0, import_element7.createInterpolateElement)( 5822 (0, import_i18n18.__)( 5823 "They also show up as sub-items in the default navigation menu. <a>Learn more.</a>" 5824 ), 5825 { 5826 a: /* @__PURE__ */ (0, import_jsx_runtime74.jsx)( 5827 import_components7.ExternalLink, 5828 { 5829 href: (0, import_i18n18.__)( 5830 "https://wordpress.org/documentation/article/page-post-settings-sidebar/#page-attributes" 5831 ), 5832 children: void 0 5833 } 5834 ) 5835 } 5836 ) }), 5837 /* @__PURE__ */ (0, import_jsx_runtime74.jsx)( 5838 PageAttributesParent, 5839 { 5840 data, 5841 onChangeControl 5842 } 5843 ) 5844 ] }) }); 5845 }; 5846 5847 // packages/fields/build-module/fields/parent/parent-view.js 5848 var import_data9 = __toESM(require_data()); 5849 var import_core_data7 = __toESM(require_core_data()); 5850 var import_i18n19 = __toESM(require_i18n()); 5851 var import_jsx_runtime75 = __toESM(require_jsx_runtime()); 5852 var ParentView = ({ 5853 item 5854 }) => { 5855 const parent = (0, import_data9.useSelect)( 5856 (select5) => { 5857 const { getEntityRecord } = select5(import_core_data7.store); 5858 return item?.parent ? getEntityRecord("postType", item.type, item.parent) : null; 5859 }, 5860 [item.parent, item.type] 5861 ); 5862 if (parent) { 5863 return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(import_jsx_runtime75.Fragment, { children: getTitleWithFallbackName(parent) }); 5864 } 5865 return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(import_jsx_runtime75.Fragment, { children: (0, import_i18n19.__)("None") }); 5866 }; 5867 5868 // packages/fields/build-module/fields/parent/index.js 5869 var parentField = { 5870 id: "parent", 5871 type: "text", 5872 label: (0, import_i18n20.__)("Parent"), 5873 Edit: ParentEdit, 5874 render: ParentView, 5875 enableSorting: true, 5876 filterBy: false 5877 }; 5878 var parent_default = parentField; 5879 5880 // packages/fields/build-module/fields/password/index.js 5881 var import_i18n22 = __toESM(require_i18n()); 5882 5883 // packages/fields/build-module/fields/password/edit.js 5884 var import_components8 = __toESM(require_components()); 5885 var import_element8 = __toESM(require_element()); 5886 var import_i18n21 = __toESM(require_i18n()); 5887 var import_jsx_runtime76 = __toESM(require_jsx_runtime()); 5888 function PasswordEdit({ 5889 data, 5890 onChange, 5891 field 5892 }) { 5893 const [showPassword, setShowPassword] = (0, import_element8.useState)( 5894 !!field.getValue({ item: data }) 5895 ); 5896 const handleTogglePassword = (value) => { 5897 setShowPassword(value); 5898 if (!value) { 5899 onChange({ password: "" }); 5900 } 5901 }; 5902 return /* @__PURE__ */ (0, import_jsx_runtime76.jsxs)( 5903 import_components8.__experimentalVStack, 5904 { 5905 as: "fieldset", 5906 spacing: 4, 5907 className: "fields-controls__password", 5908 children: [ 5909 /* @__PURE__ */ (0, import_jsx_runtime76.jsx)( 5910 import_components8.CheckboxControl, 5911 { 5912 label: (0, import_i18n21.__)("Password protected"), 5913 help: (0, import_i18n21.__)("Only visible to those who know the password"), 5914 checked: showPassword, 5915 onChange: handleTogglePassword 5916 } 5917 ), 5918 showPassword && /* @__PURE__ */ (0, import_jsx_runtime76.jsx)("div", { className: "fields-controls__password-input", children: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)( 5919 import_components8.TextControl, 5920 { 5921 label: (0, import_i18n21.__)("Password"), 5922 onChange: (value) => onChange({ 5923 password: value 5924 }), 5925 value: field.getValue({ item: data }) || "", 5926 placeholder: (0, import_i18n21.__)("Use a secure password"), 5927 type: "text", 5928 __next40pxDefaultSize: true, 5929 maxLength: 255 5930 } 5931 ) }) 5932 ] 5933 } 5934 ); 5935 } 5936 var edit_default = PasswordEdit; 5937 5938 // packages/fields/build-module/fields/password/index.js 5939 var passwordField = { 5940 id: "password", 5941 type: "text", 5942 label: (0, import_i18n22.__)("Password"), 5943 Edit: edit_default, 5944 enableSorting: false, 5945 enableHiding: false, 5946 isVisible: (item) => item.status !== "private", 5947 filterBy: false 5948 }; 5949 var password_default = passwordField; 5950 5951 // packages/fields/build-module/fields/status/index.js 5952 var import_i18n24 = __toESM(require_i18n()); 5953 5954 // packages/fields/build-module/fields/status/status-view.js 5955 var import_components9 = __toESM(require_components()); 5956 5957 // packages/fields/build-module/fields/status/status-elements.js 5958 var import_i18n23 = __toESM(require_i18n()); 5959 var STATUSES = [ 5960 { 5961 value: "draft", 5962 label: (0, import_i18n23.__)("Draft"), 5963 icon: drafts_default, 5964 description: (0, import_i18n23.__)("Not ready to publish.") 5965 }, 5966 { 5967 value: "future", 5968 label: (0, import_i18n23.__)("Scheduled"), 5969 icon: scheduled_default, 5970 description: (0, import_i18n23.__)("Publish automatically on a chosen date.") 5971 }, 5972 { 5973 value: "pending", 5974 label: (0, import_i18n23.__)("Pending Review"), 5975 icon: pending_default, 5976 description: (0, import_i18n23.__)("Waiting for review before publishing.") 5977 }, 5978 { 5979 value: "private", 5980 label: (0, import_i18n23.__)("Private"), 5981 icon: not_allowed_default, 5982 description: (0, import_i18n23.__)("Only visible to site admins and editors.") 5983 }, 5984 { 5985 value: "publish", 5986 label: (0, import_i18n23.__)("Published"), 5987 icon: published_default, 5988 description: (0, import_i18n23.__)("Visible to everyone.") 5989 }, 5990 { value: "trash", label: (0, import_i18n23.__)("Trash"), icon: trash_default } 5991 ]; 5992 var status_elements_default = STATUSES; 5993 5994 // packages/fields/build-module/fields/status/status-view.js 5995 var import_jsx_runtime77 = __toESM(require_jsx_runtime()); 5996 function StatusView({ item }) { 5997 const status = status_elements_default.find(({ value }) => value === item.status); 5998 const label = status?.label || item.status; 5999 const icon = status?.icon; 6000 return /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(import_components9.__experimentalHStack, { alignment: "left", spacing: 0, children: [ 6001 icon && /* @__PURE__ */ (0, import_jsx_runtime77.jsx)("div", { className: "edit-site-post-list__status-icon", children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(import_components9.Icon, { icon }) }), 6002 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)("span", { children: label }) 6003 ] }); 6004 } 6005 var status_view_default = StatusView; 6006 6007 // packages/fields/build-module/fields/status/index.js 6008 var OPERATOR_IS_ANY = "isAny"; 6009 var statusField = { 6010 label: (0, import_i18n24.__)("Status"), 6011 id: "status", 6012 type: "text", 6013 elements: status_elements_default, 6014 render: status_view_default, 6015 Edit: "radio", 6016 enableSorting: false, 6017 filterBy: { 6018 operators: [OPERATOR_IS_ANY] 6019 } 6020 }; 6021 var status_default = statusField; 6022 6023 // packages/fields/build-module/fields/comment-status/index.js 6024 var import_i18n25 = __toESM(require_i18n()); 6025 var commentStatusField = { 6026 id: "comment_status", 6027 label: (0, import_i18n25.__)("Comments"), 6028 type: "text", 6029 Edit: "radio", 6030 enableSorting: false, 6031 enableHiding: false, 6032 filterBy: false, 6033 elements: [ 6034 { 6035 value: "open", 6036 label: (0, import_i18n25.__)("Open"), 6037 description: (0, import_i18n25.__)("Visitors can add new comments and replies.") 6038 }, 6039 { 6040 value: "closed", 6041 label: (0, import_i18n25.__)("Closed"), 6042 description: (0, import_i18n25.__)( 6043 "Visitors cannot add new comments or replies. Existing comments remain visible." 6044 ) 6045 } 6046 ] 6047 }; 6048 var comment_status_default = commentStatusField; 6049 6050 // packages/fields/build-module/fields/ping-status/index.js 6051 var import_i18n26 = __toESM(require_i18n()); 6052 var import_components10 = __toESM(require_components()); 6053 var import_jsx_runtime78 = __toESM(require_jsx_runtime()); 6054 function PingStatusEdit({ 6055 data, 6056 onChange 6057 }) { 6058 const pingStatus = data?.ping_status ?? "open"; 6059 const onTogglePingback = (checked) => { 6060 onChange({ 6061 ...data, 6062 ping_status: checked ? "open" : "closed" 6063 }); 6064 }; 6065 return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)( 6066 import_components10.CheckboxControl, 6067 { 6068 label: (0, import_i18n26.__)("Enable pingbacks & trackbacks"), 6069 checked: pingStatus === "open", 6070 onChange: onTogglePingback, 6071 help: /* @__PURE__ */ (0, import_jsx_runtime78.jsx)( 6072 import_components10.ExternalLink, 6073 { 6074 href: (0, import_i18n26.__)( 6075 "https://wordpress.org/documentation/article/trackbacks-and-pingbacks/" 6076 ), 6077 children: (0, import_i18n26.__)("Learn more about pingbacks & trackbacks") 6078 } 6079 ) 6080 } 6081 ); 6082 } 6083 var pingStatusField = { 6084 id: "ping_status", 6085 label: (0, import_i18n26.__)("Trackbacks & Pingbacks"), 6086 type: "text", 6087 Edit: PingStatusEdit, 6088 enableSorting: false, 6089 enableHiding: false, 6090 filterBy: false, 6091 elements: [ 6092 { 6093 value: "open", 6094 label: (0, import_i18n26.__)("Allow"), 6095 description: (0, import_i18n26.__)( 6096 "Allow link notifications from other blogs (pingbacks and trackbacks) on new articles." 6097 ) 6098 }, 6099 { 6100 value: "closed", 6101 label: (0, import_i18n26.__)("Don't allow"), 6102 description: (0, import_i18n26.__)( 6103 "Don't allow link notifications from other blogs (pingbacks and trackbacks) on new articles." 6104 ) 6105 } 6106 ] 6107 }; 6108 var ping_status_default = pingStatusField; 6109 6110 // packages/fields/build-module/fields/discussion/index.js 6111 var import_i18n27 = __toESM(require_i18n()); 6112 var discussionField = { 6113 id: "discussion", 6114 label: (0, import_i18n27.__)("Discussion"), 6115 type: "text", 6116 render: ({ item }) => { 6117 const commentsOpen = item.comment_status === "open"; 6118 const pingsOpen = item.ping_status === "open"; 6119 if (commentsOpen && pingsOpen) { 6120 return (0, import_i18n27.__)("Open"); 6121 } 6122 if (commentsOpen && !pingsOpen) { 6123 return (0, import_i18n27.__)("Comments only"); 6124 } 6125 if (!commentsOpen && pingsOpen) { 6126 return (0, import_i18n27.__)("Pings only"); 6127 } 6128 return (0, import_i18n27.__)("Closed"); 6129 }, 6130 filterBy: false 6131 }; 6132 var discussion_default = discussionField; 6133 6134 // packages/fields/build-module/fields/date/index.js 6135 var import_i18n29 = __toESM(require_i18n()); 6136 6137 // packages/fields/build-module/fields/date/date-view.js 6138 var import_i18n28 = __toESM(require_i18n()); 6139 var import_element9 = __toESM(require_element()); 6140 var import_date2 = __toESM(require_date()); 6141 var import_jsx_runtime79 = __toESM(require_jsx_runtime()); 6142 var getFormattedDate = (dateToDisplay) => (0, import_date2.dateI18n)( 6143 (0, import_date2.getSettings)().formats.datetimeAbbreviated, 6144 (0, import_date2.getDate)(dateToDisplay) 6145 ); 6146 var DateView = ({ item }) => { 6147 const isDraftOrPrivate = ["draft", "private"].includes( 6148 item.status ?? "" 6149 ); 6150 if (isDraftOrPrivate) { 6151 return (0, import_element9.createInterpolateElement)( 6152 (0, import_i18n28.sprintf)( 6153 /* translators: %s: page creation or modification date. */ 6154 (0, import_i18n28.__)("<span>Modified: <time>%s</time></span>"), 6155 getFormattedDate(item.date ?? null) 6156 ), 6157 { 6158 span: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("span", {}), 6159 time: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("time", {}) 6160 } 6161 ); 6162 } 6163 const isScheduled = item.status === "future"; 6164 if (isScheduled) { 6165 return (0, import_element9.createInterpolateElement)( 6166 (0, import_i18n28.sprintf)( 6167 /* translators: %s: page creation date */ 6168 (0, import_i18n28.__)("<span>Scheduled: <time>%s</time></span>"), 6169 getFormattedDate(item.date ?? null) 6170 ), 6171 { 6172 span: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("span", {}), 6173 time: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("time", {}) 6174 } 6175 ); 6176 } 6177 const isPublished = item.status === "publish"; 6178 if (isPublished) { 6179 return (0, import_element9.createInterpolateElement)( 6180 (0, import_i18n28.sprintf)( 6181 /* translators: %s: page creation time */ 6182 (0, import_i18n28.__)("<span>Published: <time>%s</time></span>"), 6183 getFormattedDate(item.date ?? null) 6184 ), 6185 { 6186 span: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("span", {}), 6187 time: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("time", {}) 6188 } 6189 ); 6190 } 6191 const dateToDisplay = (0, import_date2.getDate)(item.modified ?? null) > (0, import_date2.getDate)(item.date ?? null) ? item.modified : item.date; 6192 const isPending = item.status === "pending"; 6193 if (isPending) { 6194 return (0, import_element9.createInterpolateElement)( 6195 (0, import_i18n28.sprintf)( 6196 /* translators: %s: page creation or modification date. */ 6197 (0, import_i18n28.__)("<span>Modified: <time>%s</time></span>"), 6198 getFormattedDate(dateToDisplay ?? null) 6199 ), 6200 { 6201 span: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("span", {}), 6202 time: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("time", {}) 6203 } 6204 ); 6205 } 6206 return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("time", { children: getFormattedDate(item.date ?? null) }); 6207 }; 6208 var date_view_default = DateView; 6209 6210 // packages/fields/build-module/fields/date/index.js 6211 var dateField = { 6212 id: "date", 6213 type: "datetime", 6214 label: (0, import_i18n29.__)("Date"), 6215 render: date_view_default, 6216 filterBy: { 6217 operators: ["before", "after"] 6218 } 6219 }; 6220 var date_default = dateField; 6221 6222 // packages/fields/build-module/fields/author/index.js 6223 var import_i18n31 = __toESM(require_i18n()); 6224 var import_data11 = __toESM(require_data()); 6225 var import_core_data9 = __toESM(require_core_data()); 6226 6227 // packages/fields/build-module/fields/author/author-view.js 6228 var import_i18n30 = __toESM(require_i18n()); 6229 var import_element10 = __toESM(require_element()); 6230 var import_components11 = __toESM(require_components()); 6231 var import_data10 = __toESM(require_data()); 6232 var import_core_data8 = __toESM(require_core_data()); 6233 var import_jsx_runtime80 = __toESM(require_jsx_runtime()); 6234 function AuthorView({ item }) { 6235 const authorId = item?.author; 6236 const embeddedAuthorId = item?._embedded?.author?.[0]?.id; 6237 const shouldFetch = Boolean( 6238 authorId && embeddedAuthorId && authorId !== embeddedAuthorId 6239 ); 6240 const author = (0, import_data10.useSelect)( 6241 (select5) => { 6242 if (!shouldFetch) { 6243 return null; 6244 } 6245 const { getEntityRecord } = select5(import_core_data8.store); 6246 return authorId ? getEntityRecord("root", "user", authorId) : null; 6247 }, 6248 [authorId, shouldFetch] 6249 ); 6250 const text = author?.name || item?._embedded?.author?.[0]?.name; 6251 const imageUrl = author?.avatar_urls?.[48] || item?._embedded?.author?.[0]?.avatar_urls?.[48]; 6252 const [isImageLoaded, setIsImageLoaded] = (0, import_element10.useState)(false); 6253 return /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)(import_components11.__experimentalHStack, { alignment: "left", spacing: 0, children: [ 6254 !!imageUrl && /* @__PURE__ */ (0, import_jsx_runtime80.jsx)( 6255 "div", 6256 { 6257 className: clsx_default("page-templates-author-field__avatar", { 6258 "is-loaded": isImageLoaded 6259 }), 6260 children: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)( 6261 "img", 6262 { 6263 onLoad: () => setIsImageLoaded(true), 6264 alt: (0, import_i18n30.__)("Author avatar"), 6265 src: imageUrl 6266 } 6267 ) 6268 } 6269 ), 6270 !imageUrl && /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("div", { className: "page-templates-author-field__icon", children: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(import_components11.Icon, { icon: comment_author_avatar_default }) }), 6271 /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("span", { className: "page-templates-author-field__name", children: text }) 6272 ] }); 6273 } 6274 var author_view_default = AuthorView; 6275 6276 // packages/fields/build-module/fields/author/index.js 6277 var authorField = { 6278 label: (0, import_i18n31.__)("Author"), 6279 id: "author", 6280 type: "integer", 6281 getElements: async () => { 6282 const authors = await (0, import_data11.resolveSelect)(import_core_data9.store).getEntityRecords( 6283 "root", 6284 "user", 6285 { 6286 per_page: -1 6287 } 6288 ) ?? []; 6289 return authors.map(({ id, name: name2 }) => ({ 6290 value: id, 6291 label: name2 6292 })); 6293 }, 6294 setValue: ({ value }) => ({ author: Number(value) }), 6295 render: author_view_default, 6296 sort: (a3, b3, direction) => { 6297 const nameA = a3._embedded?.author?.[0]?.name || ""; 6298 const nameB = b3._embedded?.author?.[0]?.name || ""; 6299 return direction === "asc" ? nameA.localeCompare(nameB) : nameB.localeCompare(nameA); 6300 }, 6301 filterBy: { 6302 operators: ["isAny", "isNone"] 6303 } 6304 }; 6305 var author_default = authorField; 6306 6307 // packages/fields/build-module/fields/notes/index.js 6308 var import_i18n32 = __toESM(require_i18n()); 6309 var notesField = { 6310 id: "notesCount", 6311 label: (0, import_i18n32.__)("Notes"), 6312 type: "integer", 6313 enableSorting: false, 6314 filterBy: false 6315 }; 6316 var notes_default = notesField; 6317 6318 // packages/fields/build-module/actions/view-post.js 6319 var import_i18n33 = __toESM(require_i18n()); 6320 var viewPost = { 6321 id: "view-post", 6322 label: (0, import_i18n33._x)("View", "verb"), 6323 isPrimary: true, 6324 icon: external_default, 6325 isEligible(post2) { 6326 return post2.status !== "trash"; 6327 }, 6328 callback(posts, { onActionPerformed }) { 6329 const post2 = posts[0]; 6330 window.open(post2?.link, "_blank"); 6331 if (onActionPerformed) { 6332 onActionPerformed(posts); 6333 } 6334 } 6335 }; 6336 var view_post_default = viewPost; 6337 6338 // packages/fields/build-module/actions/reorder-page.js 6339 var import_data12 = __toESM(require_data()); 6340 var import_core_data10 = __toESM(require_core_data()); 6341 var import_i18n34 = __toESM(require_i18n()); 6342 var import_notices3 = __toESM(require_notices()); 6343 var import_element11 = __toESM(require_element()); 6344 var import_components12 = __toESM(require_components()); 6345 var import_jsx_runtime81 = __toESM(require_jsx_runtime()); 6346 function isItemValid(item) { 6347 return typeof item.menu_order === "number" && Number.isInteger(item.menu_order) && item.menu_order > 0; 6348 } 6349 function ReorderModal({ 6350 items, 6351 closeModal: closeModal2, 6352 onActionPerformed 6353 }) { 6354 const [item, setItem] = (0, import_element11.useState)(items[0]); 6355 const { editEntityRecord, saveEditedEntityRecord } = (0, import_data12.useDispatch)(import_core_data10.store); 6356 const { createSuccessNotice, createErrorNotice } = (0, import_data12.useDispatch)(import_notices3.store); 6357 const isValid = isItemValid(item); 6358 async function onOrder(event) { 6359 event.preventDefault(); 6360 if (!isValid) { 6361 return; 6362 } 6363 try { 6364 await editEntityRecord("postType", item.type, item.id, { 6365 menu_order: item.menu_order 6366 }); 6367 closeModal2?.(); 6368 await saveEditedEntityRecord("postType", item.type, item.id, { 6369 throwOnError: true 6370 }); 6371 createSuccessNotice((0, import_i18n34.__)("Order updated."), { 6372 type: "snackbar" 6373 }); 6374 onActionPerformed?.(items); 6375 } catch (error) { 6376 const typedError = error; 6377 const errorMessage = typedError.message && typedError.code !== "unknown_error" ? typedError.message : (0, import_i18n34.__)("An error occurred while updating the order"); 6378 createErrorNotice(errorMessage, { 6379 type: "snackbar" 6380 }); 6381 } 6382 } 6383 return /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("form", { onSubmit: onOrder, children: /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)(import_components12.__experimentalVStack, { spacing: "5", children: [ 6384 /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("div", { children: (0, import_i18n34.__)( 6385 "Determines the order of pages. Pages with the same order value are sorted alphabetically. Negative order values are supported." 6386 ) }), 6387 /* @__PURE__ */ (0, import_jsx_runtime81.jsx)( 6388 import_components12.__experimentalInputControl, 6389 { 6390 __next40pxDefaultSize: true, 6391 label: (0, import_i18n34.__)("Order"), 6392 type: "number", 6393 value: typeof item.menu_order === "number" && Number.isInteger(item.menu_order) ? String(item.menu_order) : "", 6394 onChange: (value) => { 6395 const parsed = parseInt(value, 10); 6396 setItem({ 6397 ...item, 6398 menu_order: isNaN(parsed) ? void 0 : parsed 6399 }); 6400 } 6401 } 6402 ), 6403 /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)(import_components12.__experimentalHStack, { justify: "right", children: [ 6404 /* @__PURE__ */ (0, import_jsx_runtime81.jsx)( 6405 import_components12.Button, 6406 { 6407 __next40pxDefaultSize: true, 6408 variant: "tertiary", 6409 onClick: () => { 6410 closeModal2?.(); 6411 }, 6412 children: (0, import_i18n34.__)("Cancel") 6413 } 6414 ), 6415 /* @__PURE__ */ (0, import_jsx_runtime81.jsx)( 6416 import_components12.Button, 6417 { 6418 __next40pxDefaultSize: true, 6419 variant: "primary", 6420 type: "submit", 6421 accessibleWhenDisabled: true, 6422 disabled: !isValid, 6423 children: (0, import_i18n34.__)("Save") 6424 } 6425 ) 6426 ] }) 6427 ] }) }); 6428 } 6429 var reorderPage = { 6430 id: "order-pages", 6431 label: (0, import_i18n34.__)("Order"), 6432 isEligible({ status }) { 6433 return status !== "trash"; 6434 }, 6435 modalFocusOnMount: "firstContentElement", 6436 RenderModal: ReorderModal 6437 }; 6438 var reorder_page_default = reorderPage; 6439 6440 // packages/fields/build-module/actions/duplicate-post.js 6441 var import_data13 = __toESM(require_data()); 6442 var import_core_data11 = __toESM(require_core_data()); 6443 var import_i18n35 = __toESM(require_i18n()); 6444 var import_notices4 = __toESM(require_notices()); 6445 var import_element12 = __toESM(require_element()); 6446 var import_components13 = __toESM(require_components()); 6447 var import_jsx_runtime82 = __toESM(require_jsx_runtime()); 6448 var duplicatePost = { 6449 id: "duplicate-post", 6450 label: (0, import_i18n35._x)("Duplicate", "action label"), 6451 isEligible({ status }) { 6452 return status !== "trash"; 6453 }, 6454 modalFocusOnMount: "firstContentElement", 6455 RenderModal: ({ items, closeModal: closeModal2, onActionPerformed }) => { 6456 const [item, setItem] = (0, import_element12.useState)({ 6457 ...items[0], 6458 title: (0, import_i18n35.sprintf)( 6459 /* translators: %s: Existing post title */ 6460 (0, import_i18n35._x)("%s (Copy)", "post"), 6461 getItemTitle(items[0]) 6462 ) 6463 }); 6464 const [isCreatingPage, setIsCreatingPage] = (0, import_element12.useState)(false); 6465 const { saveEntityRecord } = (0, import_data13.useDispatch)(import_core_data11.store); 6466 const { createSuccessNotice, createErrorNotice } = (0, import_data13.useDispatch)(import_notices4.store); 6467 async function createPage(event) { 6468 event.preventDefault(); 6469 if (isCreatingPage) { 6470 return; 6471 } 6472 const isTemplate2 = item.type === "wp_template"; 6473 const newItemObject = { 6474 status: isTemplate2 ? "publish" : "draft", 6475 title: item.title, 6476 slug: isTemplate2 ? item.slug : item.title || (0, import_i18n35.__)("No title"), 6477 comment_status: item.comment_status, 6478 content: typeof item.content === "string" ? item.content : item.content.raw, 6479 excerpt: typeof item.excerpt === "string" ? item.excerpt : item.excerpt?.raw, 6480 meta: item.meta, 6481 parent: item.parent, 6482 password: item.password, 6483 template: item.template, 6484 format: item.format, 6485 featured_media: item.featured_media, 6486 menu_order: item.menu_order, 6487 ping_status: item.ping_status 6488 }; 6489 const assignablePropertiesPrefix = "wp:action-assign-"; 6490 const assignableProperties = Object.keys(item?._links || {}).filter( 6491 (property) => property.startsWith(assignablePropertiesPrefix) 6492 ).map( 6493 (property) => property.slice(assignablePropertiesPrefix.length) 6494 ); 6495 assignableProperties.forEach((property) => { 6496 if (item.hasOwnProperty(property)) { 6497 newItemObject[property] = item[property]; 6498 } 6499 }); 6500 setIsCreatingPage(true); 6501 try { 6502 const newItem = await saveEntityRecord( 6503 "postType", 6504 item.type, 6505 newItemObject, 6506 { throwOnError: true } 6507 ); 6508 createSuccessNotice( 6509 (0, import_i18n35.sprintf)( 6510 // translators: %s: Title of the created post, e.g: "Hello world". 6511 (0, import_i18n35.__)('"%s" successfully created.'), 6512 getItemTitle(newItem) 6513 ), 6514 { 6515 id: "duplicate-post-action", 6516 type: "snackbar" 6517 } 6518 ); 6519 if (onActionPerformed) { 6520 onActionPerformed([newItem]); 6521 } 6522 } catch (error) { 6523 const typedError = error; 6524 const errorMessage = typedError.message && typedError.code !== "unknown_error" ? typedError.message : (0, import_i18n35.__)("An error occurred while duplicating the page."); 6525 createErrorNotice(errorMessage, { 6526 type: "snackbar" 6527 }); 6528 } finally { 6529 setIsCreatingPage(false); 6530 closeModal2?.(); 6531 } 6532 } 6533 return /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("form", { onSubmit: createPage, children: /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)(import_components13.__experimentalVStack, { spacing: 3, children: [ 6534 typeof item.id === "string" && /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("div", { children: (0, import_i18n35.__)( 6535 "You are about to duplicate a bundled template. Changes will not be live until you activate the new template." 6536 ) }), 6537 /* @__PURE__ */ (0, import_jsx_runtime82.jsx)( 6538 import_components13.__experimentalInputControl, 6539 { 6540 __next40pxDefaultSize: true, 6541 label: (0, import_i18n35.__)("Title"), 6542 placeholder: (0, import_i18n35.__)("No title"), 6543 value: getItemTitle(item), 6544 onChange: (value) => setItem((prev) => ({ 6545 ...prev, 6546 title: value || (0, import_i18n35.__)("No title") 6547 })) 6548 } 6549 ), 6550 /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)(import_components13.__experimentalHStack, { spacing: 2, justify: "end", children: [ 6551 /* @__PURE__ */ (0, import_jsx_runtime82.jsx)( 6552 import_components13.Button, 6553 { 6554 variant: "tertiary", 6555 onClick: closeModal2, 6556 __next40pxDefaultSize: true, 6557 children: (0, import_i18n35.__)("Cancel") 6558 } 6559 ), 6560 /* @__PURE__ */ (0, import_jsx_runtime82.jsx)( 6561 import_components13.Button, 6562 { 6563 variant: "primary", 6564 type: "submit", 6565 isBusy: isCreatingPage, 6566 "aria-disabled": isCreatingPage, 6567 __next40pxDefaultSize: true, 6568 children: (0, import_i18n35._x)("Duplicate", "action label") 6569 } 6570 ) 6571 ] }) 6572 ] }) }); 6573 } 6574 }; 6575 var duplicate_post_default = duplicatePost; 6576 6577 // packages/fields/build-module/actions/rename-post.js 6578 var import_data14 = __toESM(require_data()); 6579 var import_core_data12 = __toESM(require_core_data()); 6580 var import_i18n36 = __toESM(require_i18n()); 6581 var import_element13 = __toESM(require_element()); 6582 var import_patterns2 = __toESM(require_patterns()); 6583 var import_components14 = __toESM(require_components()); 6584 var import_notices5 = __toESM(require_notices()); 6585 var import_jsx_runtime83 = __toESM(require_jsx_runtime()); 6586 var { PATTERN_TYPES: PATTERN_TYPES2 } = unlock2(import_patterns2.privateApis); 6587 var renamePost = { 6588 id: "rename-post", 6589 label: (0, import_i18n36.__)("Rename"), 6590 modalFocusOnMount: "firstContentElement", 6591 isEligible(post2) { 6592 if (post2.status === "trash") { 6593 return false; 6594 } 6595 if (post2.type === "wp_template" && typeof post2.id === "string" && window?.__experimentalTemplateActivate) { 6596 return false; 6597 } 6598 const specialChecks = ["wp_template", "wp_template_part"]; 6599 if (!window?.__experimentalTemplateActivate) { 6600 specialChecks.push("wp_template"); 6601 } 6602 if (!specialChecks.includes(post2.type)) { 6603 return post2.permissions?.update; 6604 } 6605 if (isTemplate(post2) && !window?.__experimentalTemplateActivate) { 6606 return isTemplateRemovable(post2) && post2.is_custom && post2.permissions?.update; 6607 } 6608 if (isTemplatePart(post2)) { 6609 return post2.source === "custom" && !post2?.has_theme_file && post2.permissions?.update; 6610 } 6611 return post2.type === PATTERN_TYPES2.user && post2.permissions?.update; 6612 }, 6613 RenderModal: ({ items, closeModal: closeModal2, onActionPerformed }) => { 6614 const [item] = items; 6615 const [title, setTitle] = (0, import_element13.useState)(() => getItemTitle(item, "")); 6616 const { editEntityRecord, saveEditedEntityRecord } = (0, import_data14.useDispatch)(import_core_data12.store); 6617 const { createSuccessNotice, createErrorNotice } = (0, import_data14.useDispatch)(import_notices5.store); 6618 async function onRename(event) { 6619 event.preventDefault(); 6620 try { 6621 await editEntityRecord("postType", item.type, item.id, { 6622 title 6623 }); 6624 setTitle(""); 6625 closeModal2?.(); 6626 await saveEditedEntityRecord("postType", item.type, item.id, { 6627 throwOnError: true 6628 }); 6629 createSuccessNotice((0, import_i18n36.__)("Name updated"), { 6630 type: "snackbar" 6631 }); 6632 onActionPerformed?.(items); 6633 } catch (error) { 6634 const typedError = error; 6635 const errorMessage = typedError.message && typedError.code !== "unknown_error" ? typedError.message : (0, import_i18n36.__)("An error occurred while updating the name"); 6636 createErrorNotice(errorMessage, { type: "snackbar" }); 6637 } 6638 } 6639 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)("form", { onSubmit: onRename, children: /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(import_components14.__experimentalVStack, { spacing: "5", children: [ 6640 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)( 6641 import_components14.TextControl, 6642 { 6643 __next40pxDefaultSize: true, 6644 label: (0, import_i18n36.__)("Name"), 6645 value: title, 6646 onChange: setTitle, 6647 required: true 6648 } 6649 ), 6650 /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(import_components14.__experimentalHStack, { justify: "right", children: [ 6651 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)( 6652 import_components14.Button, 6653 { 6654 __next40pxDefaultSize: true, 6655 variant: "tertiary", 6656 onClick: () => { 6657 closeModal2?.(); 6658 }, 6659 children: (0, import_i18n36.__)("Cancel") 6660 } 6661 ), 6662 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)( 6663 import_components14.Button, 6664 { 6665 __next40pxDefaultSize: true, 6666 variant: "primary", 6667 type: "submit", 6668 children: (0, import_i18n36.__)("Save") 6669 } 6670 ) 6671 ] }) 6672 ] }) }); 6673 } 6674 }; 6675 var rename_post_default = renamePost; 6676 6677 // packages/fields/build-module/actions/reset-post.js 6678 var import_data15 = __toESM(require_data()); 6679 var import_core_data13 = __toESM(require_core_data()); 6680 var import_i18n37 = __toESM(require_i18n()); 6681 var import_notices6 = __toESM(require_notices()); 6682 var import_element14 = __toESM(require_element()); 6683 var import_blocks4 = __toESM(require_blocks()); 6684 var import_components15 = __toESM(require_components()); 6685 var import_url5 = __toESM(require_url()); 6686 var import_api_fetch2 = __toESM(require_api_fetch()); 6687 var import_jsx_runtime84 = __toESM(require_jsx_runtime()); 6688 var isTemplateRevertable2 = (templateOrTemplatePart) => { 6689 if (!templateOrTemplatePart) { 6690 return false; 6691 } 6692 return templateOrTemplatePart.source === "custom" && (Boolean(templateOrTemplatePart?.plugin) || templateOrTemplatePart?.has_theme_file); 6693 }; 6694 var revertTemplate = async (template2, { allowUndo = true } = {}) => { 6695 const noticeId = "edit-site-template-reverted"; 6696 (0, import_data15.dispatch)(import_notices6.store).removeNotice(noticeId); 6697 if (!isTemplateRevertable2(template2)) { 6698 (0, import_data15.dispatch)(import_notices6.store).createErrorNotice( 6699 (0, import_i18n37.__)("This template is not revertable."), 6700 { 6701 type: "snackbar" 6702 } 6703 ); 6704 return; 6705 } 6706 try { 6707 const templateEntityConfig = (0, import_data15.select)(import_core_data13.store).getEntityConfig( 6708 "postType", 6709 template2.type 6710 ); 6711 if (!templateEntityConfig) { 6712 (0, import_data15.dispatch)(import_notices6.store).createErrorNotice( 6713 (0, import_i18n37.__)( 6714 "The editor has encountered an unexpected error. Please reload." 6715 ), 6716 { type: "snackbar" } 6717 ); 6718 return; 6719 } 6720 const fileTemplatePath = (0, import_url5.addQueryArgs)( 6721 `$templateEntityConfig.baseURL}/$template2.id}`, 6722 { context: "edit", source: template2.origin } 6723 ); 6724 const fileTemplate = await (0, import_api_fetch2.default)({ 6725 path: fileTemplatePath 6726 }); 6727 if (!fileTemplate) { 6728 (0, import_data15.dispatch)(import_notices6.store).createErrorNotice( 6729 (0, import_i18n37.__)( 6730 "The editor has encountered an unexpected error. Please reload." 6731 ), 6732 { type: "snackbar" } 6733 ); 6734 return; 6735 } 6736 const serializeBlocks = ({ blocks: blocksForSerialization = [] }) => (0, import_blocks4.__unstableSerializeAndClean)(blocksForSerialization); 6737 const edited = (0, import_data15.select)(import_core_data13.store).getEditedEntityRecord( 6738 "postType", 6739 template2.type, 6740 template2.id 6741 ); 6742 (0, import_data15.dispatch)(import_core_data13.store).editEntityRecord( 6743 "postType", 6744 template2.type, 6745 template2.id, 6746 { 6747 content: serializeBlocks, 6748 // Required to make the `undo` behave correctly. 6749 blocks: edited.blocks, 6750 // Required to revert the blocks in the editor. 6751 source: "custom" 6752 // required to avoid turning the editor into a dirty state 6753 }, 6754 { 6755 undoIgnore: true 6756 // Required to merge this edit with the last undo level. 6757 } 6758 ); 6759 const blocks = (0, import_blocks4.parse)(fileTemplate?.content?.raw); 6760 (0, import_data15.dispatch)(import_core_data13.store).editEntityRecord( 6761 "postType", 6762 template2.type, 6763 fileTemplate.id, 6764 { 6765 content: serializeBlocks, 6766 blocks, 6767 source: "theme" 6768 } 6769 ); 6770 if (allowUndo) { 6771 const undoRevert = () => { 6772 (0, import_data15.dispatch)(import_core_data13.store).editEntityRecord( 6773 "postType", 6774 template2.type, 6775 edited.id, 6776 { 6777 content: serializeBlocks, 6778 blocks: edited.blocks, 6779 source: "custom" 6780 } 6781 ); 6782 }; 6783 (0, import_data15.dispatch)(import_notices6.store).createSuccessNotice( 6784 (0, import_i18n37.__)("Template reset."), 6785 { 6786 type: "snackbar", 6787 id: noticeId, 6788 actions: [ 6789 { 6790 label: (0, import_i18n37.__)("Undo"), 6791 onClick: undoRevert 6792 } 6793 ] 6794 } 6795 ); 6796 } 6797 } catch (error) { 6798 const errorMessage = error.message && error.code !== "unknown_error" ? error.message : (0, import_i18n37.__)("Template revert failed. Please reload."); 6799 (0, import_data15.dispatch)(import_notices6.store).createErrorNotice(errorMessage, { 6800 type: "snackbar" 6801 }); 6802 } 6803 }; 6804 var resetPostAction = { 6805 id: "reset-post", 6806 label: (0, import_i18n37.__)("Reset"), 6807 isEligible: (item) => { 6808 if (window?.__experimentalTemplateActivate) { 6809 return item.type === "wp_template_part" && item?.source === "custom" && item?.has_theme_file; 6810 } 6811 return isTemplateOrTemplatePart(item) && item?.source === "custom" && (Boolean(item.type === "wp_template" && item?.plugin) || item?.has_theme_file); 6812 }, 6813 icon: backup_default, 6814 supportsBulk: true, 6815 hideModalHeader: true, 6816 modalFocusOnMount: "firstContentElement", 6817 RenderModal: ({ items, closeModal: closeModal2, onActionPerformed }) => { 6818 const [isBusy, setIsBusy] = (0, import_element14.useState)(false); 6819 const { saveEditedEntityRecord } = (0, import_data15.useDispatch)(import_core_data13.store); 6820 const { createSuccessNotice, createErrorNotice } = (0, import_data15.useDispatch)(import_notices6.store); 6821 const onConfirm = async () => { 6822 try { 6823 for (const template2 of items) { 6824 await revertTemplate(template2, { 6825 allowUndo: false 6826 }); 6827 await saveEditedEntityRecord( 6828 "postType", 6829 template2.type, 6830 template2.id 6831 ); 6832 } 6833 createSuccessNotice( 6834 items.length > 1 ? (0, import_i18n37.sprintf)( 6835 /* translators: %d: The number of items. */ 6836 (0, import_i18n37.__)("%d items reset."), 6837 items.length 6838 ) : (0, import_i18n37.sprintf)( 6839 /* translators: %s: The template/part's name. */ 6840 (0, import_i18n37.__)('"%s" reset.'), 6841 getItemTitle(items[0]) 6842 ), 6843 { 6844 type: "snackbar", 6845 id: "revert-template-action" 6846 } 6847 ); 6848 } catch (error) { 6849 let fallbackErrorMessage; 6850 if (items[0].type === "wp_template") { 6851 fallbackErrorMessage = items.length === 1 ? (0, import_i18n37.__)( 6852 "An error occurred while reverting the template." 6853 ) : (0, import_i18n37.__)( 6854 "An error occurred while reverting the templates." 6855 ); 6856 } else { 6857 fallbackErrorMessage = items.length === 1 ? (0, import_i18n37.__)( 6858 "An error occurred while reverting the template part." 6859 ) : (0, import_i18n37.__)( 6860 "An error occurred while reverting the template parts." 6861 ); 6862 } 6863 const typedError = error; 6864 const errorMessage = typedError.message && typedError.code !== "unknown_error" ? typedError.message : fallbackErrorMessage; 6865 createErrorNotice(errorMessage, { type: "snackbar" }); 6866 } 6867 }; 6868 return /* @__PURE__ */ (0, import_jsx_runtime84.jsxs)(import_components15.__experimentalVStack, { spacing: "5", children: [ 6869 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(import_components15.__experimentalText, { children: (0, import_i18n37.__)("Reset to default and clear all customizations?") }), 6870 /* @__PURE__ */ (0, import_jsx_runtime84.jsxs)(import_components15.__experimentalHStack, { justify: "right", children: [ 6871 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)( 6872 import_components15.Button, 6873 { 6874 __next40pxDefaultSize: true, 6875 variant: "tertiary", 6876 onClick: closeModal2, 6877 disabled: isBusy, 6878 accessibleWhenDisabled: true, 6879 children: (0, import_i18n37.__)("Cancel") 6880 } 6881 ), 6882 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)( 6883 import_components15.Button, 6884 { 6885 __next40pxDefaultSize: true, 6886 variant: "primary", 6887 onClick: async () => { 6888 setIsBusy(true); 6889 await onConfirm(); 6890 onActionPerformed?.(items); 6891 setIsBusy(false); 6892 closeModal2?.(); 6893 }, 6894 isBusy, 6895 disabled: isBusy, 6896 accessibleWhenDisabled: true, 6897 children: (0, import_i18n37.__)("Reset") 6898 } 6899 ) 6900 ] }) 6901 ] }); 6902 } 6903 }; 6904 var reset_post_default = resetPostAction; 6905 6906 // packages/fields/build-module/actions/duplicate-pattern.js 6907 var import_i18n38 = __toESM(require_i18n()); 6908 var import_patterns3 = __toESM(require_patterns()); 6909 var import_jsx_runtime85 = __toESM(require_jsx_runtime()); 6910 var { CreatePatternModalContents, useDuplicatePatternProps } = unlock2(import_patterns3.privateApis); 6911 var duplicatePattern = { 6912 id: "duplicate-pattern", 6913 label: (0, import_i18n38._x)("Duplicate", "action label"), 6914 isEligible: (item) => item.type !== "wp_template_part", 6915 modalHeader: (0, import_i18n38._x)("Duplicate pattern", "action label"), 6916 modalFocusOnMount: "firstContentElement", 6917 RenderModal: ({ items, closeModal: closeModal2 }) => { 6918 const [item] = items; 6919 const duplicatedProps = useDuplicatePatternProps({ 6920 pattern: item, 6921 onSuccess: () => closeModal2?.() 6922 }); 6923 return /* @__PURE__ */ (0, import_jsx_runtime85.jsx)( 6924 CreatePatternModalContents, 6925 { 6926 onClose: closeModal2, 6927 confirmLabel: (0, import_i18n38._x)("Duplicate", "action label"), 6928 ...duplicatedProps 6929 } 6930 ); 6931 } 6932 }; 6933 var duplicate_pattern_default = duplicatePattern; 6934 6935 // node_modules/tslib/tslib.es6.mjs 6936 var __assign = function() { 6937 __assign = Object.assign || function __assign2(t4) { 6938 for (var s3, i3 = 1, n3 = arguments.length; i3 < n3; i3++) { 6939 s3 = arguments[i3]; 6940 for (var p4 in s3) if (Object.prototype.hasOwnProperty.call(s3, p4)) t4[p4] = s3[p4]; 6941 } 6942 return t4; 6943 }; 6944 return __assign.apply(this, arguments); 6945 }; 6946 6947 // node_modules/lower-case/dist.es2015/index.js 6948 function lowerCase(str) { 6949 return str.toLowerCase(); 6950 } 6951 6952 // node_modules/no-case/dist.es2015/index.js 6953 var DEFAULT_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g]; 6954 var DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi; 6955 function noCase(input, options) { 6956 if (options === void 0) { 6957 options = {}; 6958 } 6959 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; 6960 var result = replace(replace(input, splitRegexp, "$1\0$2"), stripRegexp, "\0"); 6961 var start = 0; 6962 var end = result.length; 6963 while (result.charAt(start) === "\0") 6964 start++; 6965 while (result.charAt(end - 1) === "\0") 6966 end--; 6967 return result.slice(start, end).split("\0").map(transform).join(delimiter); 6968 } 6969 function replace(input, re, value) { 6970 if (re instanceof RegExp) 6971 return input.replace(re, value); 6972 return re.reduce(function(input2, re2) { 6973 return input2.replace(re2, value); 6974 }, input); 6975 } 6976 6977 // node_modules/dot-case/dist.es2015/index.js 6978 function dotCase(input, options) { 6979 if (options === void 0) { 6980 options = {}; 6981 } 6982 return noCase(input, __assign({ delimiter: "." }, options)); 6983 } 6984 6985 // node_modules/param-case/dist.es2015/index.js 6986 function paramCase(input, options) { 6987 if (options === void 0) { 6988 options = {}; 6989 } 6990 return dotCase(input, __assign({ delimiter: "-" }, options)); 6991 } 6992 6993 // node_modules/client-zip/index.js 6994 "stream" in Blob.prototype || Object.defineProperty(Blob.prototype, "stream", { value() { 6995 return new Response(this).body; 6996 } }), "setBigUint64" in DataView.prototype || Object.defineProperty(DataView.prototype, "setBigUint64", { value(e3, n3, t4) { 6997 const i3 = Number(0xffffffffn & n3), r4 = Number(n3 >> 32n); 6998 this.setUint32(e3 + (t4 ? 0 : 4), i3, t4), this.setUint32(e3 + (t4 ? 4 : 0), r4, t4); 6999 } }); 7000 var e = (e3) => new DataView(new ArrayBuffer(e3)); 7001 var n = (e3) => new Uint8Array(e3.buffer || e3); 7002 var t = (e3) => new TextEncoder().encode(String(e3)); 7003 var i = (e3) => Math.min(4294967295, Number(e3)); 7004 var r2 = (e3) => Math.min(65535, Number(e3)); 7005 function f(e3, i3) { 7006 if (void 0 === i3 || i3 instanceof Date || (i3 = new Date(i3)), e3 instanceof File) return { isFile: 1, t: i3 || new Date(e3.lastModified), i: e3.stream() }; 7007 if (e3 instanceof Response) return { isFile: 1, t: i3 || new Date(e3.headers.get("Last-Modified") || Date.now()), i: e3.body }; 7008 if (void 0 === i3) i3 = /* @__PURE__ */ new Date(); 7009 else if (isNaN(i3)) throw new Error("Invalid modification date."); 7010 if (void 0 === e3) return { isFile: 0, t: i3 }; 7011 if ("string" == typeof e3) return { isFile: 1, t: i3, i: t(e3) }; 7012 if (e3 instanceof Blob) return { isFile: 1, t: i3, i: e3.stream() }; 7013 if (e3 instanceof Uint8Array || e3 instanceof ReadableStream) return { isFile: 1, t: i3, i: e3 }; 7014 if (e3 instanceof ArrayBuffer || ArrayBuffer.isView(e3)) return { isFile: 1, t: i3, i: n(e3) }; 7015 if (Symbol.asyncIterator in e3) return { isFile: 1, t: i3, i: o(e3[Symbol.asyncIterator]()) }; 7016 throw new TypeError("Unsupported input format."); 7017 } 7018 function o(e3, n3 = e3) { 7019 return new ReadableStream({ async pull(n4) { 7020 let t4 = 0; 7021 for (; n4.desiredSize > t4; ) { 7022 const i3 = await e3.next(); 7023 if (!i3.value) { 7024 n4.close(); 7025 break; 7026 } 7027 { 7028 const e4 = a(i3.value); 7029 n4.enqueue(e4), t4 += e4.byteLength; 7030 } 7031 } 7032 }, cancel(e4) { 7033 n3.throw?.(e4); 7034 } }); 7035 } 7036 function a(e3) { 7037 return "string" == typeof e3 ? t(e3) : e3 instanceof Uint8Array ? e3 : n(e3); 7038 } 7039 function s(e3, i3, r4) { 7040 let [f3, o4] = (function(e4) { 7041 return e4 ? e4 instanceof Uint8Array ? [e4, 1] : ArrayBuffer.isView(e4) || e4 instanceof ArrayBuffer ? [n(e4), 1] : [t(e4), 0] : [void 0, 0]; 7042 })(i3); 7043 if (e3 instanceof File) return { o: d(f3 || t(e3.name)), u: BigInt(e3.size), l: o4 }; 7044 if (e3 instanceof Response) { 7045 const n3 = e3.headers.get("content-disposition"), i4 = n3 && n3.match(/;\s*filename\*?=["']?(.*?)["']?$/i), a3 = i4 && i4[1] || e3.url && new URL(e3.url).pathname.split("/").findLast(Boolean), s3 = a3 && decodeURIComponent(a3), u3 = r4 || +e3.headers.get("content-length"); 7046 return { o: d(f3 || t(s3)), u: BigInt(u3), l: o4 }; 7047 } 7048 return f3 = d(f3, void 0 !== e3 || void 0 !== r4), "string" == typeof e3 ? { o: f3, u: BigInt(t(e3).length), l: o4 } : e3 instanceof Blob ? { o: f3, u: BigInt(e3.size), l: o4 } : e3 instanceof ArrayBuffer || ArrayBuffer.isView(e3) ? { o: f3, u: BigInt(e3.byteLength), l: o4 } : { o: f3, u: u(e3, r4), l: o4 }; 7049 } 7050 function u(e3, n3) { 7051 return n3 > -1 ? BigInt(n3) : e3 ? void 0 : 0n; 7052 } 7053 function d(e3, n3 = 1) { 7054 if (!e3 || e3.every(((c2) => 47 === c2))) throw new Error("The file must have a name."); 7055 if (n3) for (; 47 === e3[e3.length - 1]; ) e3 = e3.subarray(0, -1); 7056 else 47 !== e3[e3.length - 1] && (e3 = new Uint8Array([...e3, 47])); 7057 return e3; 7058 } 7059 var l = new Uint32Array(256); 7060 for (let e3 = 0; e3 < 256; ++e3) { 7061 let n3 = e3; 7062 for (let e4 = 0; e4 < 8; ++e4) n3 = n3 >>> 1 ^ (1 & n3 && 3988292384); 7063 l[e3] = n3; 7064 } 7065 function y(e3, n3 = 0) { 7066 n3 ^= -1; 7067 for (var t4 = 0, i3 = e3.length; t4 < i3; t4++) n3 = n3 >>> 8 ^ l[255 & n3 ^ e3[t4]]; 7068 return (-1 ^ n3) >>> 0; 7069 } 7070 function w(e3, n3, t4 = 0) { 7071 const i3 = e3.getSeconds() >> 1 | e3.getMinutes() << 5 | e3.getHours() << 11, r4 = e3.getDate() | e3.getMonth() + 1 << 5 | e3.getFullYear() - 1980 << 9; 7072 n3.setUint16(t4, i3, 1), n3.setUint16(t4 + 2, r4, 1); 7073 } 7074 function B({ o: e3, l: n3 }, t4) { 7075 return 8 * (!n3 || (t4 ?? (function(e4) { 7076 try { 7077 b.decode(e4); 7078 } catch { 7079 return 0; 7080 } 7081 return 1; 7082 })(e3))); 7083 } 7084 var b = new TextDecoder("utf8", { fatal: 1 }); 7085 function p2(t4, i3 = 0) { 7086 const r4 = e(30); 7087 return r4.setUint32(0, 1347093252), r4.setUint32(4, 754976768 | i3), w(t4.t, r4, 10), r4.setUint16(26, t4.o.length, 1), n(r4); 7088 } 7089 async function* g(e3) { 7090 let { i: n3 } = e3; 7091 if ("then" in n3 && (n3 = await n3), n3 instanceof Uint8Array) yield n3, e3.m = y(n3, 0), e3.u = BigInt(n3.length); 7092 else { 7093 e3.u = 0n; 7094 const t4 = n3.getReader(); 7095 for (; ; ) { 7096 const { value: n4, done: i3 } = await t4.read(); 7097 if (i3) break; 7098 e3.m = y(n4, e3.m), e3.u += BigInt(n4.length), yield n4; 7099 } 7100 } 7101 } 7102 function I(t4, r4) { 7103 const f3 = e(16 + (r4 ? 8 : 0)); 7104 return f3.setUint32(0, 1347094280), f3.setUint32(4, t4.isFile ? t4.m : 0, 1), r4 ? (f3.setBigUint64(8, t4.u, 1), f3.setBigUint64(16, t4.u, 1)) : (f3.setUint32(8, i(t4.u), 1), f3.setUint32(12, i(t4.u), 1)), n(f3); 7105 } 7106 function v(t4, r4, f3 = 0, o4 = 0) { 7107 const a3 = e(46); 7108 return a3.setUint32(0, 1347092738), a3.setUint32(4, 755182848), a3.setUint16(8, 2048 | f3), w(t4.t, a3, 12), a3.setUint32(16, t4.isFile ? t4.m : 0, 1), a3.setUint32(20, i(t4.u), 1), a3.setUint32(24, i(t4.u), 1), a3.setUint16(28, t4.o.length, 1), a3.setUint16(30, o4, 1), a3.setUint16(40, t4.isFile ? 33204 : 16893, 1), a3.setUint32(42, i(r4), 1), n(a3); 7109 } 7110 function h(t4, i3, r4) { 7111 const f3 = e(r4); 7112 return f3.setUint16(0, 1, 1), f3.setUint16(2, r4 - 4, 1), 16 & r4 && (f3.setBigUint64(4, t4.u, 1), f3.setBigUint64(12, t4.u, 1)), f3.setBigUint64(r4 - 8, i3, 1), n(f3); 7113 } 7114 function D(e3) { 7115 return e3 instanceof File || e3 instanceof Response ? [[e3], [e3]] : [[e3.input, e3.name, e3.size], [e3.input, e3.lastModified]]; 7116 } 7117 var S = (e3) => (function(e4) { 7118 let n3 = BigInt(22), t4 = 0n, i3 = 0; 7119 for (const r4 of e4) { 7120 if (!r4.o) throw new Error("Every file must have a non-empty name."); 7121 if (void 0 === r4.u) throw new Error(`Missing size for file "$new TextDecoder().decode(r4.o)}".`); 7122 const e5 = r4.u >= 0xffffffffn, f3 = t4 >= 0xffffffffn; 7123 t4 += BigInt(46 + r4.o.length + (e5 && 8)) + r4.u, n3 += BigInt(r4.o.length + 46 + (12 * f3 | 28 * e5)), i3 || (i3 = e5); 7124 } 7125 return (i3 || t4 >= 0xffffffffn) && (n3 += BigInt(76)), n3 + t4; 7126 })((function* (e4) { 7127 for (const n3 of e4) yield s(...D(n3)[0]); 7128 })(e3)); 7129 function A(e3, n3 = {}) { 7130 const t4 = { "Content-Type": "application/zip", "Content-Disposition": "attachment" }; 7131 return ("bigint" == typeof n3.length || Number.isInteger(n3.length)) && n3.length > 0 && (t4["Content-Length"] = String(n3.length)), n3.metadata && (t4["Content-Length"] = String(S(n3.metadata))), new Response(N(e3, n3), { headers: t4 }); 7132 } 7133 function N(t4, a3 = {}) { 7134 const u3 = (function(e3) { 7135 const n3 = e3[Symbol.iterator in e3 ? Symbol.iterator : Symbol.asyncIterator](); 7136 return { async next() { 7137 const e4 = await n3.next(); 7138 if (e4.done) return e4; 7139 const [t5, i3] = D(e4.value); 7140 return { done: 0, value: Object.assign(f(...i3), s(...t5)) }; 7141 }, throw: n3.throw?.bind(n3), [Symbol.asyncIterator]() { 7142 return this; 7143 } }; 7144 })(t4); 7145 return o((async function* (t5, f3) { 7146 const o4 = []; 7147 let a4 = 0n, s3 = 0n, u4 = 0; 7148 for await (const e3 of t5) { 7149 const n3 = B(e3, f3.buffersAreUTF8); 7150 yield p2(e3, n3), yield new Uint8Array(e3.o), e3.isFile && (yield* g(e3)); 7151 const t6 = e3.u >= 0xffffffffn, i3 = 12 * (a4 >= 0xffffffffn) | 28 * t6; 7152 yield I(e3, t6), o4.push(v(e3, a4, n3, i3)), o4.push(e3.o), i3 && o4.push(h(e3, a4, i3)), t6 && (a4 += 8n), s3++, a4 += BigInt(46 + e3.o.length) + e3.u, u4 || (u4 = t6); 7153 } 7154 let d3 = 0n; 7155 for (const e3 of o4) yield e3, d3 += BigInt(e3.length); 7156 if (u4 || a4 >= 0xffffffffn) { 7157 const t6 = e(76); 7158 t6.setUint32(0, 1347094022), t6.setBigUint64(4, BigInt(44), 1), t6.setUint32(12, 755182848), t6.setBigUint64(24, s3, 1), t6.setBigUint64(32, s3, 1), t6.setBigUint64(40, d3, 1), t6.setBigUint64(48, a4, 1), t6.setUint32(56, 1347094023), t6.setBigUint64(64, a4 + d3, 1), t6.setUint32(72, 1, 1), yield n(t6); 7159 } 7160 const l3 = e(22); 7161 l3.setUint32(0, 1347093766), l3.setUint16(8, r2(s3), 1), l3.setUint16(10, r2(s3), 1), l3.setUint32(12, i(d3), 1), l3.setUint32(16, i(a4), 1), yield n(l3); 7162 })(u3, a3), u3); 7163 } 7164 7165 // packages/fields/build-module/actions/export-pattern.js 7166 var import_blob = __toESM(require_blob()); 7167 var import_i18n39 = __toESM(require_i18n()); 7168 function getJsonFromItem(item) { 7169 return JSON.stringify( 7170 { 7171 __file: item.type, 7172 title: getItemTitle(item), 7173 content: typeof item.content === "string" ? item.content : item.content?.raw, 7174 syncStatus: item.wp_pattern_sync_status 7175 }, 7176 null, 7177 2 7178 ); 7179 } 7180 var exportPattern = { 7181 id: "export-pattern", 7182 label: (0, import_i18n39.__)("Export as JSON"), 7183 icon: download_default, 7184 supportsBulk: true, 7185 isEligible: (item) => item.type === "wp_block", 7186 callback: async (items) => { 7187 if (items.length === 1) { 7188 return (0, import_blob.downloadBlob)( 7189 `$paramCase( 7190 getItemTitle(items[0]) || items[0].slug 7191 )}.json`, 7192 getJsonFromItem(items[0]), 7193 "application/json" 7194 ); 7195 } 7196 const nameCount = {}; 7197 const filesToZip = items.map((item) => { 7198 const name2 = paramCase(getItemTitle(item) || item.slug); 7199 nameCount[name2] = (nameCount[name2] || 0) + 1; 7200 return { 7201 name: `$name2 + (nameCount[name2] > 1 ? "-" + (nameCount[name2] - 1) : "")}.json`, 7202 lastModified: /* @__PURE__ */ new Date(), 7203 input: getJsonFromItem(item) 7204 }; 7205 }); 7206 return (0, import_blob.downloadBlob)( 7207 (0, import_i18n39.__)("patterns-export") + ".zip", 7208 await A(filesToZip).blob(), 7209 "application/zip" 7210 ); 7211 } 7212 }; 7213 var export_pattern_default = exportPattern; 7214 7215 // packages/fields/build-module/actions/view-post-revisions.js 7216 var import_url6 = __toESM(require_url()); 7217 var import_i18n40 = __toESM(require_i18n()); 7218 var viewPostRevisions = { 7219 id: "view-post-revisions", 7220 context: "list", 7221 label(items) { 7222 const revisionsCount = items[0]._links?.["version-history"]?.[0]?.count ?? 0; 7223 return (0, import_i18n40.sprintf)( 7224 /* translators: %d: number of revisions. */ 7225 (0, import_i18n40.__)("View revisions (%d)"), 7226 revisionsCount 7227 ); 7228 }, 7229 isEligible(post2) { 7230 if (post2.status === "trash") { 7231 return false; 7232 } 7233 const lastRevisionId = post2?._links?.["predecessor-version"]?.[0]?.id ?? null; 7234 const revisionsCount = post2?._links?.["version-history"]?.[0]?.count ?? 0; 7235 return !!lastRevisionId && revisionsCount > 1; 7236 }, 7237 callback(posts, { onActionPerformed }) { 7238 const post2 = posts[0]; 7239 const href = (0, import_url6.addQueryArgs)("revision.php", { 7240 revision: post2?._links?.["predecessor-version"]?.[0]?.id 7241 }); 7242 document.location.href = href; 7243 if (onActionPerformed) { 7244 onActionPerformed(posts); 7245 } 7246 } 7247 }; 7248 var view_post_revisions_default = viewPostRevisions; 7249 7250 // packages/fields/build-module/actions/permanently-delete-post.js 7251 var import_core_data14 = __toESM(require_core_data()); 7252 var import_i18n41 = __toESM(require_i18n()); 7253 var import_notices7 = __toESM(require_notices()); 7254 var import_element15 = __toESM(require_element()); 7255 var import_data16 = __toESM(require_data()); 7256 var import_components16 = __toESM(require_components()); 7257 var import_html_entities5 = __toESM(require_html_entities()); 7258 var import_jsx_runtime86 = __toESM(require_jsx_runtime()); 7259 var permanentlyDeletePost = { 7260 id: "permanently-delete", 7261 label: (0, import_i18n41.__)("Permanently delete"), 7262 supportsBulk: true, 7263 icon: trash_default, 7264 isEligible(item) { 7265 if (isTemplateOrTemplatePart(item) || item.type === "wp_block") { 7266 return false; 7267 } 7268 const { status, permissions } = item; 7269 return status === "trash" && permissions?.delete; 7270 }, 7271 hideModalHeader: true, 7272 modalFocusOnMount: "firstContentElement", 7273 RenderModal: ({ items, closeModal: closeModal2, onActionPerformed }) => { 7274 const [isBusy, setIsBusy] = (0, import_element15.useState)(false); 7275 const { createSuccessNotice, createErrorNotice } = (0, import_data16.useDispatch)(import_notices7.store); 7276 const { deleteEntityRecord } = (0, import_data16.useDispatch)(import_core_data14.store); 7277 return /* @__PURE__ */ (0, import_jsx_runtime86.jsxs)(import_components16.__experimentalVStack, { spacing: "5", children: [ 7278 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(import_components16.__experimentalText, { children: items.length > 1 ? (0, import_i18n41.sprintf)( 7279 // translators: %d: number of items to delete. 7280 (0, import_i18n41._n)( 7281 "Are you sure you want to permanently delete %d item?", 7282 "Are you sure you want to permanently delete %d items?", 7283 items.length 7284 ), 7285 items.length 7286 ) : (0, import_i18n41.sprintf)( 7287 // translators: %s: The post's title 7288 (0, import_i18n41.__)( 7289 'Are you sure you want to permanently delete "%s"?' 7290 ), 7291 (0, import_html_entities5.decodeEntities)(getItemTitle(items[0])) 7292 ) }), 7293 /* @__PURE__ */ (0, import_jsx_runtime86.jsxs)(import_components16.__experimentalHStack, { justify: "right", children: [ 7294 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)( 7295 import_components16.Button, 7296 { 7297 variant: "tertiary", 7298 onClick: closeModal2, 7299 disabled: isBusy, 7300 accessibleWhenDisabled: true, 7301 __next40pxDefaultSize: true, 7302 children: (0, import_i18n41.__)("Cancel") 7303 } 7304 ), 7305 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)( 7306 import_components16.Button, 7307 { 7308 variant: "primary", 7309 onClick: async () => { 7310 setIsBusy(true); 7311 const promiseResult = await Promise.allSettled( 7312 items.map( 7313 (post2) => deleteEntityRecord( 7314 "postType", 7315 post2.type, 7316 post2.id, 7317 { force: true }, 7318 { throwOnError: true } 7319 ) 7320 ) 7321 ); 7322 if (promiseResult.every( 7323 ({ status }) => status === "fulfilled" 7324 )) { 7325 let successMessage; 7326 if (promiseResult.length === 1) { 7327 successMessage = (0, import_i18n41.sprintf)( 7328 /* translators: %s: The posts's title. */ 7329 (0, import_i18n41.__)('"%s" permanently deleted.'), 7330 getItemTitle(items[0]) 7331 ); 7332 } else { 7333 successMessage = (0, import_i18n41.__)( 7334 "The items were permanently deleted." 7335 ); 7336 } 7337 createSuccessNotice(successMessage, { 7338 type: "snackbar", 7339 id: "permanently-delete-post-action" 7340 }); 7341 onActionPerformed?.(items); 7342 } else { 7343 let errorMessage; 7344 if (promiseResult.length === 1) { 7345 const typedError = promiseResult[0]; 7346 if (typedError.reason?.message) { 7347 errorMessage = typedError.reason.message; 7348 } else { 7349 errorMessage = (0, import_i18n41.__)( 7350 "An error occurred while permanently deleting the item." 7351 ); 7352 } 7353 } else { 7354 const errorMessages = /* @__PURE__ */ new Set(); 7355 const failedPromises = promiseResult.filter( 7356 ({ status }) => status === "rejected" 7357 ); 7358 for (const failedPromise of failedPromises) { 7359 const typedError = failedPromise; 7360 if (typedError.reason?.message) { 7361 errorMessages.add( 7362 typedError.reason.message 7363 ); 7364 } 7365 } 7366 if (errorMessages.size === 0) { 7367 errorMessage = (0, import_i18n41.__)( 7368 "An error occurred while permanently deleting the items." 7369 ); 7370 } else if (errorMessages.size === 1) { 7371 errorMessage = (0, import_i18n41.sprintf)( 7372 /* translators: %s: an error message */ 7373 (0, import_i18n41.__)( 7374 "An error occurred while permanently deleting the items: %s" 7375 ), 7376 [...errorMessages][0] 7377 ); 7378 } else { 7379 errorMessage = (0, import_i18n41.sprintf)( 7380 /* translators: %s: a list of comma separated error messages */ 7381 (0, import_i18n41.__)( 7382 "Some errors occurred while permanently deleting the items: %s" 7383 ), 7384 [...errorMessages].join(",") 7385 ); 7386 } 7387 } 7388 createErrorNotice(errorMessage, { 7389 type: "snackbar" 7390 }); 7391 } 7392 setIsBusy(false); 7393 closeModal2?.(); 7394 }, 7395 isBusy, 7396 disabled: isBusy, 7397 accessibleWhenDisabled: true, 7398 __next40pxDefaultSize: true, 7399 children: (0, import_i18n41.__)("Delete permanently") 7400 } 7401 ) 7402 ] }) 7403 ] }); 7404 } 7405 }; 7406 var permanently_delete_post_default = permanentlyDeletePost; 7407 7408 // packages/fields/build-module/actions/restore-post.js 7409 var import_core_data15 = __toESM(require_core_data()); 7410 var import_i18n42 = __toESM(require_i18n()); 7411 var import_notices8 = __toESM(require_notices()); 7412 var restorePost = { 7413 id: "restore", 7414 label: (0, import_i18n42.__)("Restore"), 7415 isPrimary: true, 7416 icon: backup_default, 7417 supportsBulk: true, 7418 isEligible(item) { 7419 return !isTemplateOrTemplatePart(item) && item.type !== "wp_block" && item.status === "trash" && item.permissions?.update; 7420 }, 7421 async callback(posts, { registry, onActionPerformed }) { 7422 const { createSuccessNotice, createErrorNotice } = registry.dispatch(import_notices8.store); 7423 const { editEntityRecord, saveEditedEntityRecord } = registry.dispatch(import_core_data15.store); 7424 await Promise.allSettled( 7425 posts.map((post2) => { 7426 return editEntityRecord("postType", post2.type, post2.id, { 7427 status: "draft" 7428 }); 7429 }) 7430 ); 7431 const promiseResult = await Promise.allSettled( 7432 posts.map((post2) => { 7433 return saveEditedEntityRecord("postType", post2.type, post2.id, { 7434 throwOnError: true 7435 }); 7436 }) 7437 ); 7438 if (promiseResult.every(({ status }) => status === "fulfilled")) { 7439 let successMessage; 7440 if (posts.length === 1) { 7441 successMessage = (0, import_i18n42.sprintf)( 7442 /* translators: %s: The number of posts. */ 7443 (0, import_i18n42.__)('"%s" has been restored.'), 7444 getItemTitle(posts[0]) 7445 ); 7446 } else if (posts[0].type === "page") { 7447 successMessage = (0, import_i18n42.sprintf)( 7448 /* translators: %d: The number of posts. */ 7449 (0, import_i18n42.__)("%d pages have been restored."), 7450 posts.length 7451 ); 7452 } else { 7453 successMessage = (0, import_i18n42.sprintf)( 7454 /* translators: %d: The number of posts. */ 7455 (0, import_i18n42.__)("%d posts have been restored."), 7456 posts.length 7457 ); 7458 } 7459 createSuccessNotice(successMessage, { 7460 type: "snackbar", 7461 id: "restore-post-action" 7462 }); 7463 if (onActionPerformed) { 7464 onActionPerformed(posts); 7465 } 7466 } else { 7467 let errorMessage; 7468 if (promiseResult.length === 1) { 7469 const typedError = promiseResult[0]; 7470 if (typedError.reason?.message) { 7471 errorMessage = typedError.reason.message; 7472 } else { 7473 errorMessage = (0, import_i18n42.__)( 7474 "An error occurred while restoring the post." 7475 ); 7476 } 7477 } else { 7478 const errorMessages = /* @__PURE__ */ new Set(); 7479 const failedPromises = promiseResult.filter( 7480 ({ status }) => status === "rejected" 7481 ); 7482 for (const failedPromise of failedPromises) { 7483 const typedError = failedPromise; 7484 if (typedError.reason?.message) { 7485 errorMessages.add(typedError.reason.message); 7486 } 7487 } 7488 if (errorMessages.size === 0) { 7489 errorMessage = (0, import_i18n42.__)( 7490 "An error occurred while restoring the posts." 7491 ); 7492 } else if (errorMessages.size === 1) { 7493 errorMessage = (0, import_i18n42.sprintf)( 7494 /* translators: %s: an error message */ 7495 (0, import_i18n42.__)("An error occurred while restoring the posts: %s"), 7496 [...errorMessages][0] 7497 ); 7498 } else { 7499 errorMessage = (0, import_i18n42.sprintf)( 7500 /* translators: %s: a list of comma separated error messages */ 7501 (0, import_i18n42.__)( 7502 "Some errors occurred while restoring the posts: %s" 7503 ), 7504 [...errorMessages].join(",") 7505 ); 7506 } 7507 } 7508 createErrorNotice(errorMessage, { 7509 type: "snackbar" 7510 }); 7511 } 7512 } 7513 }; 7514 var restore_post_default = restorePost; 7515 7516 // packages/fields/build-module/actions/trash-post.js 7517 var import_data17 = __toESM(require_data()); 7518 var import_core_data16 = __toESM(require_core_data()); 7519 var import_i18n43 = __toESM(require_i18n()); 7520 var import_notices9 = __toESM(require_notices()); 7521 var import_element16 = __toESM(require_element()); 7522 var import_components17 = __toESM(require_components()); 7523 var import_jsx_runtime87 = __toESM(require_jsx_runtime()); 7524 var trashPost2 = { 7525 id: "move-to-trash", 7526 label: (0, import_i18n43._x)("Trash", "verb"), 7527 isPrimary: true, 7528 icon: trash_default, 7529 isEligible(item) { 7530 if (item.type === "wp_template_part" || item.type === "wp_block") { 7531 return false; 7532 } 7533 if (item.type === "wp_template" && typeof item.id === "string") { 7534 return false; 7535 } 7536 return !!item.status && !["auto-draft", "trash"].includes(item.status) && item.permissions?.delete; 7537 }, 7538 supportsBulk: true, 7539 hideModalHeader: true, 7540 modalFocusOnMount: "firstContentElement", 7541 RenderModal: ({ items, closeModal: closeModal2, onActionPerformed }) => { 7542 const [isBusy, setIsBusy] = (0, import_element16.useState)(false); 7543 const { createSuccessNotice, createErrorNotice } = (0, import_data17.useDispatch)(import_notices9.store); 7544 const { deleteEntityRecord } = (0, import_data17.useDispatch)(import_core_data16.store); 7545 return /* @__PURE__ */ (0, import_jsx_runtime87.jsxs)(import_components17.__experimentalVStack, { spacing: "5", children: [ 7546 /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(import_components17.__experimentalText, { children: items.length === 1 ? (0, import_i18n43.sprintf)( 7547 // translators: %s: The item's title. 7548 (0, import_i18n43.__)( 7549 'Are you sure you want to move "%s" to the trash?' 7550 ), 7551 getItemTitle(items[0]) 7552 ) : (0, import_i18n43.sprintf)( 7553 // translators: %d: The number of items (2 or more). 7554 (0, import_i18n43._n)( 7555 "Are you sure you want to move %d item to the trash ?", 7556 "Are you sure you want to move %d items to the trash ?", 7557 items.length 7558 ), 7559 items.length 7560 ) }), 7561 /* @__PURE__ */ (0, import_jsx_runtime87.jsxs)(import_components17.__experimentalHStack, { justify: "right", children: [ 7562 /* @__PURE__ */ (0, import_jsx_runtime87.jsx)( 7563 import_components17.Button, 7564 { 7565 __next40pxDefaultSize: true, 7566 variant: "tertiary", 7567 onClick: closeModal2, 7568 disabled: isBusy, 7569 accessibleWhenDisabled: true, 7570 children: (0, import_i18n43.__)("Cancel") 7571 } 7572 ), 7573 /* @__PURE__ */ (0, import_jsx_runtime87.jsx)( 7574 import_components17.Button, 7575 { 7576 __next40pxDefaultSize: true, 7577 variant: "primary", 7578 onClick: async () => { 7579 setIsBusy(true); 7580 const promiseResult = await Promise.allSettled( 7581 items.map( 7582 (item) => deleteEntityRecord( 7583 "postType", 7584 item.type, 7585 item.id.toString(), 7586 {}, 7587 { throwOnError: true } 7588 ) 7589 ) 7590 ); 7591 if (promiseResult.every( 7592 ({ status }) => status === "fulfilled" 7593 )) { 7594 let successMessage; 7595 if (promiseResult.length === 1) { 7596 successMessage = (0, import_i18n43.sprintf)( 7597 /* translators: %s: The item's title. */ 7598 (0, import_i18n43.__)('"%s" moved to the trash.'), 7599 getItemTitle(items[0]) 7600 ); 7601 } else { 7602 successMessage = (0, import_i18n43.sprintf)( 7603 /* translators: %d: The number of items. */ 7604 (0, import_i18n43._n)( 7605 "%d item moved to the trash.", 7606 "%d items moved to the trash.", 7607 items.length 7608 ), 7609 items.length 7610 ); 7611 } 7612 createSuccessNotice(successMessage, { 7613 type: "snackbar", 7614 id: "move-to-trash-action" 7615 }); 7616 } else { 7617 let errorMessage; 7618 if (promiseResult.length === 1) { 7619 const typedError = promiseResult[0]; 7620 if (typedError.reason?.message) { 7621 errorMessage = typedError.reason.message; 7622 } else { 7623 errorMessage = (0, import_i18n43.__)( 7624 "An error occurred while moving the item to the trash." 7625 ); 7626 } 7627 } else { 7628 const errorMessages = /* @__PURE__ */ new Set(); 7629 const failedPromises = promiseResult.filter( 7630 ({ status }) => status === "rejected" 7631 ); 7632 for (const failedPromise of failedPromises) { 7633 const typedError = failedPromise; 7634 if (typedError.reason?.message) { 7635 errorMessages.add( 7636 typedError.reason.message 7637 ); 7638 } 7639 } 7640 if (errorMessages.size === 0) { 7641 errorMessage = (0, import_i18n43.__)( 7642 "An error occurred while moving the items to the trash." 7643 ); 7644 } else if (errorMessages.size === 1) { 7645 errorMessage = (0, import_i18n43.sprintf)( 7646 /* translators: %s: an error message */ 7647 (0, import_i18n43.__)( 7648 "An error occurred while moving the item to the trash: %s" 7649 ), 7650 [...errorMessages][0] 7651 ); 7652 } else { 7653 errorMessage = (0, import_i18n43.sprintf)( 7654 /* translators: %s: a list of comma separated error messages */ 7655 (0, import_i18n43.__)( 7656 "Some errors occurred while moving the items to the trash: %s" 7657 ), 7658 [...errorMessages].join(",") 7659 ); 7660 } 7661 } 7662 createErrorNotice(errorMessage, { 7663 type: "snackbar" 7664 }); 7665 } 7666 if (onActionPerformed) { 7667 onActionPerformed(items); 7668 } 7669 setIsBusy(false); 7670 closeModal2?.(); 7671 }, 7672 isBusy, 7673 disabled: isBusy, 7674 accessibleWhenDisabled: true, 7675 children: (0, import_i18n43._x)("Trash", "verb") 7676 } 7677 ) 7678 ] }) 7679 ] }); 7680 } 7681 }; 7682 var trash_post_default = trashPost2; 7683 7684 // packages/fields/build-module/actions/delete-post.js 7685 var import_i18n44 = __toESM(require_i18n()); 7686 var import_element17 = __toESM(require_element()); 7687 var import_components18 = __toESM(require_components()); 7688 var import_patterns4 = __toESM(require_patterns()); 7689 var import_html_entities6 = __toESM(require_html_entities()); 7690 7691 // packages/fields/build-module/mutation/index.js 7692 var import_notices10 = __toESM(require_notices()); 7693 var import_core_data17 = __toESM(require_core_data()); 7694 var import_data18 = __toESM(require_data()); 7695 function getErrorMessagesFromPromises(allSettledResults) { 7696 const errorMessages = /* @__PURE__ */ new Set(); 7697 if (allSettledResults.length === 1) { 7698 const typedError = allSettledResults[0]; 7699 if (typedError.reason?.message) { 7700 errorMessages.add(typedError.reason.message); 7701 } 7702 } else { 7703 const failedPromises = allSettledResults.filter( 7704 ({ status }) => status === "rejected" 7705 ); 7706 for (const failedPromise of failedPromises) { 7707 const typedError = failedPromise; 7708 if (typedError.reason?.message) { 7709 errorMessages.add(typedError.reason.message); 7710 } 7711 } 7712 } 7713 return errorMessages; 7714 } 7715 var deletePostWithNotices = async (posts, notice, callbacks) => { 7716 const { createSuccessNotice, createErrorNotice } = (0, import_data18.dispatch)(import_notices10.store); 7717 const { deleteEntityRecord } = (0, import_data18.dispatch)(import_core_data17.store); 7718 const allSettledResults = await Promise.allSettled( 7719 posts.map((post2) => { 7720 return deleteEntityRecord( 7721 "postType", 7722 post2.type, 7723 post2.id, 7724 { force: true }, 7725 { throwOnError: true } 7726 ); 7727 }) 7728 ); 7729 if (allSettledResults.every(({ status }) => status === "fulfilled")) { 7730 let successMessage; 7731 if (allSettledResults.length === 1) { 7732 successMessage = notice.success.messages.getMessage(posts[0]); 7733 } else { 7734 successMessage = notice.success.messages.getBatchMessage(posts); 7735 } 7736 createSuccessNotice(successMessage, { 7737 type: notice.success.type ?? "snackbar", 7738 id: notice.success.id 7739 }); 7740 callbacks.onActionPerformed?.(posts); 7741 } else { 7742 const errorMessages = getErrorMessagesFromPromises(allSettledResults); 7743 let errorMessage = ""; 7744 if (allSettledResults.length === 1) { 7745 errorMessage = notice.error.messages.getMessage(errorMessages); 7746 } else { 7747 errorMessage = notice.error.messages.getBatchMessage(errorMessages); 7748 } 7749 createErrorNotice(errorMessage, { 7750 type: notice.error.type ?? "snackbar", 7751 id: notice.error.id 7752 }); 7753 callbacks.onActionError?.(); 7754 } 7755 }; 7756 7757 // packages/fields/build-module/actions/delete-post.js 7758 var import_jsx_runtime88 = __toESM(require_jsx_runtime()); 7759 var { PATTERN_TYPES: PATTERN_TYPES3 } = unlock2(import_patterns4.privateApis); 7760 var deletePostAction = { 7761 id: "delete-post", 7762 label: (0, import_i18n44.__)("Delete"), 7763 isPrimary: true, 7764 icon: trash_default, 7765 isEligible(post2) { 7766 if (isTemplateOrTemplatePart(post2)) { 7767 return isTemplateRemovable(post2); 7768 } 7769 return post2.type === PATTERN_TYPES3.user; 7770 }, 7771 supportsBulk: true, 7772 hideModalHeader: true, 7773 modalFocusOnMount: "firstContentElement", 7774 RenderModal: ({ items, closeModal: closeModal2, onActionPerformed }) => { 7775 const [isBusy, setIsBusy] = (0, import_element17.useState)(false); 7776 const isResetting = items.every( 7777 (item) => isTemplateOrTemplatePart(item) && item?.has_theme_file 7778 ); 7779 return /* @__PURE__ */ (0, import_jsx_runtime88.jsxs)(import_components18.__experimentalVStack, { spacing: "5", children: [ 7780 /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(import_components18.__experimentalText, { children: items.length > 1 ? (0, import_i18n44.sprintf)( 7781 // translators: %d: number of items to delete. 7782 (0, import_i18n44._n)( 7783 "Delete %d item?", 7784 "Delete %d items?", 7785 items.length 7786 ), 7787 items.length 7788 ) : (0, import_i18n44.sprintf)( 7789 // translators: %s: The template or template part's title 7790 (0, import_i18n44._x)('Delete "%s"?', "template part"), 7791 getItemTitle(items[0]) 7792 ) }), 7793 /* @__PURE__ */ (0, import_jsx_runtime88.jsxs)(import_components18.__experimentalHStack, { justify: "right", children: [ 7794 /* @__PURE__ */ (0, import_jsx_runtime88.jsx)( 7795 import_components18.Button, 7796 { 7797 variant: "tertiary", 7798 onClick: closeModal2, 7799 disabled: isBusy, 7800 accessibleWhenDisabled: true, 7801 __next40pxDefaultSize: true, 7802 children: (0, import_i18n44.__)("Cancel") 7803 } 7804 ), 7805 /* @__PURE__ */ (0, import_jsx_runtime88.jsx)( 7806 import_components18.Button, 7807 { 7808 variant: "primary", 7809 onClick: async () => { 7810 setIsBusy(true); 7811 const notice = { 7812 success: { 7813 messages: { 7814 getMessage: (item) => { 7815 return isResetting ? (0, import_i18n44.sprintf)( 7816 /* translators: %s: The template/part's name. */ 7817 (0, import_i18n44.__)('"%s" reset.'), 7818 (0, import_html_entities6.decodeEntities)( 7819 getItemTitle(item) 7820 ) 7821 ) : (0, import_i18n44.sprintf)( 7822 /* translators: %s: The template/part's name. */ 7823 (0, import_i18n44._x)( 7824 '"%s" deleted.', 7825 "template part" 7826 ), 7827 (0, import_html_entities6.decodeEntities)( 7828 getItemTitle(item) 7829 ) 7830 ); 7831 }, 7832 getBatchMessage: () => { 7833 return isResetting ? (0, import_i18n44.__)("Items reset.") : (0, import_i18n44.__)("Items deleted."); 7834 } 7835 } 7836 }, 7837 error: { 7838 messages: { 7839 getMessage: (error) => { 7840 if (error.size === 1) { 7841 return [...error][0]; 7842 } 7843 return isResetting ? (0, import_i18n44.__)( 7844 "An error occurred while reverting the item." 7845 ) : (0, import_i18n44.__)( 7846 "An error occurred while deleting the item." 7847 ); 7848 }, 7849 getBatchMessage: (errors) => { 7850 if (errors.size === 0) { 7851 return isResetting ? (0, import_i18n44.__)( 7852 "An error occurred while reverting the items." 7853 ) : (0, import_i18n44.__)( 7854 "An error occurred while deleting the items." 7855 ); 7856 } 7857 if (errors.size === 1) { 7858 return isResetting ? (0, import_i18n44.sprintf)( 7859 /* translators: %s: an error message */ 7860 (0, import_i18n44.__)( 7861 "An error occurred while reverting the items: %s" 7862 ), 7863 [...errors][0] 7864 ) : (0, import_i18n44.sprintf)( 7865 /* translators: %s: an error message */ 7866 (0, import_i18n44.__)( 7867 "An error occurred while deleting the items: %s" 7868 ), 7869 [...errors][0] 7870 ); 7871 } 7872 return isResetting ? (0, import_i18n44.sprintf)( 7873 /* translators: %s: a list of comma separated error messages */ 7874 (0, import_i18n44.__)( 7875 "Some errors occurred while reverting the items: %s" 7876 ), 7877 [...errors].join( 7878 "," 7879 ) 7880 ) : (0, import_i18n44.sprintf)( 7881 /* translators: %s: a list of comma separated error messages */ 7882 (0, import_i18n44.__)( 7883 "Some errors occurred while deleting the items: %s" 7884 ), 7885 [...errors].join( 7886 "," 7887 ) 7888 ); 7889 } 7890 } 7891 } 7892 }; 7893 await deletePostWithNotices(items, notice, { 7894 onActionPerformed 7895 }); 7896 setIsBusy(false); 7897 closeModal2?.(); 7898 }, 7899 isBusy, 7900 disabled: isBusy, 7901 accessibleWhenDisabled: true, 7902 __next40pxDefaultSize: true, 7903 children: (0, import_i18n44.__)("Delete") 7904 } 7905 ) 7906 ] }) 7907 ] }); 7908 } 7909 }; 7910 var delete_post_default = deletePostAction; 7911 7912 // packages/fields/build-module/actions/duplicate-template-part.js 7913 var import_data21 = __toESM(require_data()); 7914 var import_i18n46 = __toESM(require_i18n()); 7915 var import_notices12 = __toESM(require_notices()); 7916 var import_element19 = __toESM(require_element()); 7917 var import_blocks6 = __toESM(require_blocks()); 7918 7919 // packages/fields/build-module/components/create-template-part-modal/index.js 7920 var import_components19 = __toESM(require_components()); 7921 var import_compose4 = __toESM(require_compose()); 7922 var import_core_data19 = __toESM(require_core_data()); 7923 var import_data20 = __toESM(require_data()); 7924 var import_element18 = __toESM(require_element()); 7925 var import_i18n45 = __toESM(require_i18n()); 7926 var import_notices11 = __toESM(require_notices()); 7927 var import_blocks5 = __toESM(require_blocks()); 7928 7929 // packages/fields/build-module/components/create-template-part-modal/utils.js 7930 var import_data19 = __toESM(require_data()); 7931 var import_core_data18 = __toESM(require_core_data()); 7932 var useExistingTemplateParts = () => { 7933 return (0, import_data19.useSelect)( 7934 (select5) => select5(import_core_data18.store).getEntityRecords( 7935 "postType", 7936 "wp_template_part", 7937 { 7938 per_page: -1 7939 } 7940 ), 7941 [] 7942 ) ?? []; 7943 }; 7944 var getUniqueTemplatePartTitle = (title, templateParts) => { 7945 const lowercaseTitle = title.toLowerCase(); 7946 const existingTitles = templateParts.map( 7947 (templatePart) => templatePart.title.rendered.toLowerCase() 7948 ); 7949 if (!existingTitles.includes(lowercaseTitle)) { 7950 return title; 7951 } 7952 let suffix = 2; 7953 while (existingTitles.includes(`$lowercaseTitle} $suffix}`)) { 7954 suffix++; 7955 } 7956 return `$title} $suffix}`; 7957 }; 7958 var getCleanTemplatePartSlug = (title) => { 7959 return paramCase(title).replace(/[^\w-]+/g, "") || "wp-custom-part"; 7960 }; 7961 7962 // packages/fields/build-module/components/create-template-part-modal/index.js 7963 var import_jsx_runtime89 = __toESM(require_jsx_runtime()); 7964 function getAreaRadioId(value, instanceId) { 7965 return `fields-create-template-part-modal__area-option-$value}-$instanceId}`; 7966 } 7967 function getAreaRadioDescriptionId(value, instanceId) { 7968 return `fields-create-template-part-modal__area-option-description-$value}-$instanceId}`; 7969 } 7970 function CreateTemplatePartModal({ 7971 modalTitle, 7972 ...restProps 7973 }) { 7974 const defaultModalTitle = (0, import_data20.useSelect)( 7975 (select5) => select5(import_core_data19.store).getPostType("wp_template_part")?.labels?.add_new_item, 7976 [] 7977 ); 7978 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)( 7979 import_components19.Modal, 7980 { 7981 title: modalTitle || defaultModalTitle, 7982 onRequestClose: restProps.closeModal, 7983 overlayClassName: "fields-create-template-part-modal", 7984 focusOnMount: "firstContentElement", 7985 size: "medium", 7986 children: /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(CreateTemplatePartModalContents, { ...restProps }) 7987 } 7988 ); 7989 } 7990 var getTemplatePartIcon2 = (areaOrIconName) => { 7991 if ("header" === areaOrIconName) { 7992 return header_default; 7993 } else if ("footer" === areaOrIconName) { 7994 return footer_default; 7995 } else if ("sidebar" === areaOrIconName) { 7996 return sidebar_default; 7997 } else if ("overlay" === areaOrIconName) { 7998 return table_column_after_default; 7999 } 8000 if ("menu" === areaOrIconName) { 8001 return table_column_after_default; 8002 } 8003 return symbol_filled_default; 8004 }; 8005 function CreateTemplatePartModalContents({ 8006 defaultArea = "uncategorized", 8007 blocks = [], 8008 confirmLabel = (0, import_i18n45.__)("Add"), 8009 closeModal: closeModal2, 8010 onCreate, 8011 onError, 8012 defaultTitle = "" 8013 }) { 8014 const { createErrorNotice } = (0, import_data20.useDispatch)(import_notices11.store); 8015 const { saveEntityRecord } = (0, import_data20.useDispatch)(import_core_data19.store); 8016 const existingTemplateParts = useExistingTemplateParts(); 8017 const [title, setTitle] = (0, import_element18.useState)(defaultTitle); 8018 const [area, setArea] = (0, import_element18.useState)(defaultArea); 8019 const [isSubmitting, setIsSubmitting] = (0, import_element18.useState)(false); 8020 const instanceId = (0, import_compose4.useInstanceId)(CreateTemplatePartModal); 8021 const defaultTemplatePartAreas = (0, import_data20.useSelect)( 8022 (select5) => select5(import_core_data19.store).getCurrentTheme()?.default_template_part_areas, 8023 [] 8024 ); 8025 async function createTemplatePart() { 8026 if (!title || isSubmitting) { 8027 return; 8028 } 8029 try { 8030 setIsSubmitting(true); 8031 const uniqueTitle = getUniqueTemplatePartTitle( 8032 title, 8033 existingTemplateParts 8034 ); 8035 const cleanSlug = getCleanTemplatePartSlug(uniqueTitle); 8036 const templatePart = await saveEntityRecord( 8037 "postType", 8038 "wp_template_part", 8039 { 8040 slug: cleanSlug, 8041 title: uniqueTitle, 8042 content: (0, import_blocks5.serialize)(blocks), 8043 area 8044 }, 8045 { throwOnError: true } 8046 ); 8047 await onCreate(templatePart); 8048 } catch (error) { 8049 const errorMessage = error instanceof Error && "code" in error && error.message && error.code !== "unknown_error" ? error.message : (0, import_i18n45.__)( 8050 "An error occurred while creating the template part." 8051 ); 8052 createErrorNotice(errorMessage, { type: "snackbar" }); 8053 onError?.(); 8054 } finally { 8055 setIsSubmitting(false); 8056 } 8057 } 8058 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)( 8059 "form", 8060 { 8061 onSubmit: async (event) => { 8062 event.preventDefault(); 8063 await createTemplatePart(); 8064 }, 8065 children: /* @__PURE__ */ (0, import_jsx_runtime89.jsxs)(import_components19.__experimentalVStack, { spacing: "4", children: [ 8066 /* @__PURE__ */ (0, import_jsx_runtime89.jsx)( 8067 import_components19.TextControl, 8068 { 8069 __next40pxDefaultSize: true, 8070 label: (0, import_i18n45.__)("Name"), 8071 value: title, 8072 onChange: setTitle, 8073 required: true 8074 } 8075 ), 8076 /* @__PURE__ */ (0, import_jsx_runtime89.jsxs)("fieldset", { className: "fields-create-template-part-modal__area-fieldset", children: [ 8077 /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(import_components19.BaseControl.VisualLabel, { as: "legend", children: (0, import_i18n45.__)("Area") }), 8078 /* @__PURE__ */ (0, import_jsx_runtime89.jsx)("div", { className: "fields-create-template-part-modal__area-radio-group", children: (defaultTemplatePartAreas ?? []).map( 8079 (item) => { 8080 const icon = getTemplatePartIcon2(item.icon); 8081 return /* @__PURE__ */ (0, import_jsx_runtime89.jsxs)( 8082 "div", 8083 { 8084 className: "fields-create-template-part-modal__area-radio-wrapper", 8085 children: [ 8086 /* @__PURE__ */ (0, import_jsx_runtime89.jsx)( 8087 "input", 8088 { 8089 type: "radio", 8090 id: getAreaRadioId( 8091 item.area, 8092 instanceId 8093 ), 8094 name: `fields-create-template-part-modal__area-$instanceId}`, 8095 value: item.area, 8096 checked: area === item.area, 8097 onChange: () => { 8098 setArea(item.area); 8099 }, 8100 "aria-describedby": getAreaRadioDescriptionId( 8101 item.area, 8102 instanceId 8103 ) 8104 } 8105 ), 8106 /* @__PURE__ */ (0, import_jsx_runtime89.jsx)( 8107 import_components19.Icon, 8108 { 8109 icon, 8110 className: "fields-create-template-part-modal__area-radio-icon" 8111 } 8112 ), 8113 /* @__PURE__ */ (0, import_jsx_runtime89.jsx)( 8114 "label", 8115 { 8116 htmlFor: getAreaRadioId( 8117 item.area, 8118 instanceId 8119 ), 8120 className: "fields-create-template-part-modal__area-radio-label", 8121 children: item.label 8122 } 8123 ), 8124 /* @__PURE__ */ (0, import_jsx_runtime89.jsx)( 8125 import_components19.Icon, 8126 { 8127 icon: check_default, 8128 className: "fields-create-template-part-modal__area-radio-checkmark" 8129 } 8130 ), 8131 /* @__PURE__ */ (0, import_jsx_runtime89.jsx)( 8132 "p", 8133 { 8134 className: "fields-create-template-part-modal__area-radio-description", 8135 id: getAreaRadioDescriptionId( 8136 item.area, 8137 instanceId 8138 ), 8139 children: item.description 8140 } 8141 ) 8142 ] 8143 }, 8144 item.area 8145 ); 8146 } 8147 ) }) 8148 ] }), 8149 /* @__PURE__ */ (0, import_jsx_runtime89.jsxs)(import_components19.__experimentalHStack, { justify: "right", children: [ 8150 /* @__PURE__ */ (0, import_jsx_runtime89.jsx)( 8151 import_components19.Button, 8152 { 8153 __next40pxDefaultSize: true, 8154 variant: "tertiary", 8155 onClick: () => { 8156 closeModal2(); 8157 }, 8158 children: (0, import_i18n45.__)("Cancel") 8159 } 8160 ), 8161 /* @__PURE__ */ (0, import_jsx_runtime89.jsx)( 8162 import_components19.Button, 8163 { 8164 __next40pxDefaultSize: true, 8165 variant: "primary", 8166 type: "submit", 8167 "aria-disabled": !title || isSubmitting, 8168 isBusy: isSubmitting, 8169 children: confirmLabel 8170 } 8171 ) 8172 ] }) 8173 ] }) 8174 } 8175 ); 8176 } 8177 8178 // packages/fields/build-module/actions/duplicate-template-part.js 8179 var import_jsx_runtime90 = __toESM(require_jsx_runtime()); 8180 var duplicateTemplatePart = { 8181 id: "duplicate-template-part", 8182 label: (0, import_i18n46._x)("Duplicate", "action label"), 8183 isEligible: (item) => item.type === "wp_template_part", 8184 modalHeader: (0, import_i18n46._x)("Duplicate template part", "action label"), 8185 modalFocusOnMount: "firstContentElement", 8186 RenderModal: ({ items, closeModal: closeModal2 }) => { 8187 const [item] = items; 8188 const blocks = (0, import_element19.useMemo)(() => { 8189 return item.blocks ?? (0, import_blocks6.parse)( 8190 typeof item.content === "string" ? item.content : item.content.raw, 8191 { 8192 __unstableSkipMigrationLogs: true 8193 } 8194 ); 8195 }, [item.content, item.blocks]); 8196 const { createSuccessNotice } = (0, import_data21.useDispatch)(import_notices12.store); 8197 function onTemplatePartSuccess(templatePart) { 8198 createSuccessNotice( 8199 (0, import_i18n46.sprintf)( 8200 // translators: %s: The new template part's title e.g. 'Call to action (copy)'. 8201 (0, import_i18n46._x)('"%s" duplicated.', "template part"), 8202 getItemTitle(templatePart) 8203 ), 8204 { type: "snackbar", id: "edit-site-patterns-success" } 8205 ); 8206 closeModal2?.(); 8207 } 8208 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)( 8209 CreateTemplatePartModalContents, 8210 { 8211 blocks, 8212 defaultArea: item.area, 8213 defaultTitle: (0, import_i18n46.sprintf)( 8214 /* translators: %s: Existing template part title */ 8215 (0, import_i18n46._x)("%s (Copy)", "template part"), 8216 getItemTitle(item) 8217 ), 8218 onCreate: onTemplatePartSuccess, 8219 onError: closeModal2, 8220 confirmLabel: (0, import_i18n46._x)("Duplicate", "action label"), 8221 closeModal: closeModal2 ?? (() => { 8222 }) 8223 } 8224 ); 8225 } 8226 }; 8227 var duplicate_template_part_default = duplicateTemplatePart; 8228 8229 // packages/editor/build-module/dataviews/fields/content-preview/index.js 8230 var import_i18n107 = __toESM(require_i18n()); 8231 8232 // packages/editor/build-module/dataviews/fields/content-preview/content-preview-view.js 8233 var import_i18n106 = __toESM(require_i18n()); 8234 var import_block_editor34 = __toESM(require_block_editor()); 8235 var import_data64 = __toESM(require_data()); 8236 var import_core_data44 = __toESM(require_core_data()); 8237 8238 // packages/editor/build-module/components/provider/index.js 8239 var import_element37 = __toESM(require_element()); 8240 var import_data48 = __toESM(require_data()); 8241 var import_i18n60 = __toESM(require_i18n()); 8242 var import_core_data30 = __toESM(require_core_data()); 8243 var import_block_editor18 = __toESM(require_block_editor()); 8244 var import_notices15 = __toESM(require_notices()); 8245 var import_patterns7 = __toESM(require_patterns()); 8246 var import_blocks13 = __toESM(require_blocks()); 8247 8248 // packages/editor/build-module/components/provider/with-registry-provider.js 8249 var import_element20 = __toESM(require_element()); 8250 var import_data22 = __toESM(require_data()); 8251 var import_compose5 = __toESM(require_compose()); 8252 var import_block_editor5 = __toESM(require_block_editor()); 8253 var import_jsx_runtime91 = __toESM(require_jsx_runtime()); 8254 function getSubRegistry(subRegistries, registry, useSubRegistry) { 8255 if (!useSubRegistry) { 8256 return registry; 8257 } 8258 let subRegistry = subRegistries.get(registry); 8259 if (!subRegistry) { 8260 subRegistry = (0, import_data22.createRegistry)( 8261 { 8262 "core/block-editor": import_block_editor5.storeConfig 8263 }, 8264 registry 8265 ); 8266 subRegistry.registerStore("core/editor", storeConfig); 8267 subRegistries.set(registry, subRegistry); 8268 } 8269 return subRegistry; 8270 } 8271 var withRegistryProvider = (0, import_compose5.createHigherOrderComponent)( 8272 (WrappedComponent) => ({ useSubRegistry = true, ...props }) => { 8273 const registry = (0, import_data22.useRegistry)(); 8274 const [subRegistries] = (0, import_element20.useState)(() => /* @__PURE__ */ new WeakMap()); 8275 const subRegistry = getSubRegistry( 8276 subRegistries, 8277 registry, 8278 useSubRegistry 8279 ); 8280 if (subRegistry === registry) { 8281 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(WrappedComponent, { registry, ...props }); 8282 } 8283 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(import_data22.RegistryProvider, { value: subRegistry, children: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(WrappedComponent, { registry: subRegistry, ...props }) }); 8284 }, 8285 "withRegistryProvider" 8286 ); 8287 var with_registry_provider_default = withRegistryProvider; 8288 8289 // packages/editor/build-module/components/provider/use-block-editor-settings.js 8290 var import_element22 = __toESM(require_element()); 8291 var import_data27 = __toESM(require_data()); 8292 var import_core_data23 = __toESM(require_core_data()); 8293 var import_i18n49 = __toESM(require_i18n()); 8294 var import_preferences3 = __toESM(require_preferences()); 8295 var import_compose6 = __toESM(require_compose()); 8296 var import_blocks9 = __toESM(require_blocks()); 8297 var import_block_editor7 = __toESM(require_block_editor()); 8298 8299 // packages/editor/build-module/components/media-categories/index.js 8300 var import_i18n47 = __toESM(require_i18n()); 8301 var import_data23 = __toESM(require_data()); 8302 var import_html_entities7 = __toESM(require_html_entities()); 8303 var import_core_data20 = __toESM(require_core_data()); 8304 var getExternalLink = (url, text) => `<a $getExternalLinkAttributes(url)}>$text}</a>`; 8305 var getExternalLinkAttributes = (url) => `href="$url}" target="_blank" rel="noreferrer noopener"`; 8306 var getOpenverseLicense = (license, licenseVersion) => { 8307 let licenseName = license.trim(); 8308 if (license !== "pdm") { 8309 licenseName = license.toUpperCase().replace("SAMPLING", "Sampling"); 8310 } 8311 if (licenseVersion) { 8312 licenseName += ` $licenseVersion}`; 8313 } 8314 if (!["pdm", "cc0"].includes(license)) { 8315 licenseName = `CC $licenseName}`; 8316 } 8317 return licenseName; 8318 }; 8319 var getOpenverseCaption = (item) => { 8320 const { 8321 title, 8322 foreign_landing_url: foreignLandingUrl, 8323 creator, 8324 creator_url: creatorUrl, 8325 license, 8326 license_version: licenseVersion, 8327 license_url: licenseUrl 8328 } = item; 8329 const fullLicense = getOpenverseLicense(license, licenseVersion); 8330 const _creator = (0, import_html_entities7.decodeEntities)(creator); 8331 let _caption; 8332 if (_creator) { 8333 _caption = title ? (0, import_i18n47.sprintf)( 8334 // translators: %1s: Title of a media work from Openverse; %2$s: Name of the work's creator; %3s: Work's licence e.g: "CC0 1.0". 8335 (0, import_i18n47._x)('"%1$s" by %2$s/ %3$s', "caption"), 8336 getExternalLink( 8337 foreignLandingUrl, 8338 (0, import_html_entities7.decodeEntities)(title) 8339 ), 8340 creatorUrl ? getExternalLink(creatorUrl, _creator) : _creator, 8341 licenseUrl ? getExternalLink( 8342 `$licenseUrl}?ref=openverse`, 8343 fullLicense 8344 ) : fullLicense 8345 ) : (0, import_i18n47.sprintf)( 8346 // translators: %1s: Link attributes for a given Openverse media work; %2s: Name of the work's creator; %3s: Works's licence e.g: "CC0 1.0". 8347 (0, import_i18n47._x)("<a %1$s>Work</a> by %2$s/ %3$s", "caption"), 8348 getExternalLinkAttributes(foreignLandingUrl), 8349 creatorUrl ? getExternalLink(creatorUrl, _creator) : _creator, 8350 licenseUrl ? getExternalLink( 8351 `$licenseUrl}?ref=openverse`, 8352 fullLicense 8353 ) : fullLicense 8354 ); 8355 } else { 8356 _caption = title ? (0, import_i18n47.sprintf)( 8357 // translators: %1s: Title of a media work from Openverse; %2s: Work's licence e.g: "CC0 1.0". 8358 (0, import_i18n47._x)('"%1$s"/ %2$s', "caption"), 8359 getExternalLink( 8360 foreignLandingUrl, 8361 (0, import_html_entities7.decodeEntities)(title) 8362 ), 8363 licenseUrl ? getExternalLink( 8364 `$licenseUrl}?ref=openverse`, 8365 fullLicense 8366 ) : fullLicense 8367 ) : (0, import_i18n47.sprintf)( 8368 // translators: %1s: Link attributes for a given Openverse media work; %2s: Works's licence e.g: "CC0 1.0". 8369 (0, import_i18n47._x)("<a %1$s>Work</a>/ %2$s", "caption"), 8370 getExternalLinkAttributes(foreignLandingUrl), 8371 licenseUrl ? getExternalLink( 8372 `$licenseUrl}?ref=openverse`, 8373 fullLicense 8374 ) : fullLicense 8375 ); 8376 } 8377 return _caption.replace(/\s{2}/g, " "); 8378 }; 8379 var coreMediaFetch = async (query = {}) => { 8380 const mediaItems = await (0, import_data23.resolveSelect)(import_core_data20.store).getEntityRecords( 8381 "postType", 8382 "attachment", 8383 { 8384 ...query, 8385 orderBy: !!query?.search ? "relevance" : "date" 8386 } 8387 ); 8388 return mediaItems.map((mediaItem) => ({ 8389 ...mediaItem, 8390 alt: mediaItem.alt_text, 8391 url: mediaItem.source_url, 8392 previewUrl: mediaItem.media_details?.sizes?.medium?.source_url, 8393 caption: mediaItem.caption?.raw 8394 })); 8395 }; 8396 var inserterMediaCategories = [ 8397 { 8398 name: "images", 8399 labels: { 8400 name: (0, import_i18n47.__)("Images"), 8401 search_items: (0, import_i18n47.__)("Search images") 8402 }, 8403 mediaType: "image", 8404 async fetch(query = {}) { 8405 return coreMediaFetch({ ...query, media_type: "image" }); 8406 } 8407 }, 8408 { 8409 name: "videos", 8410 labels: { 8411 name: (0, import_i18n47.__)("Videos"), 8412 search_items: (0, import_i18n47.__)("Search videos") 8413 }, 8414 mediaType: "video", 8415 async fetch(query = {}) { 8416 return coreMediaFetch({ ...query, media_type: "video" }); 8417 } 8418 }, 8419 { 8420 name: "audio", 8421 labels: { 8422 name: (0, import_i18n47.__)("Audio"), 8423 search_items: (0, import_i18n47.__)("Search audio") 8424 }, 8425 mediaType: "audio", 8426 async fetch(query = {}) { 8427 return coreMediaFetch({ ...query, media_type: "audio" }); 8428 } 8429 }, 8430 { 8431 name: "openverse", 8432 labels: { 8433 name: (0, import_i18n47.__)("Openverse"), 8434 search_items: (0, import_i18n47.__)("Search Openverse") 8435 }, 8436 mediaType: "image", 8437 async fetch(query = {}) { 8438 const defaultArgs = { 8439 mature: false, 8440 excluded_source: "flickr,inaturalist,wikimedia", 8441 license: "pdm,cc0" 8442 }; 8443 const finalQuery = { ...query, ...defaultArgs }; 8444 const mapFromInserterMediaRequest = { 8445 per_page: "page_size", 8446 search: "q" 8447 }; 8448 const url = new URL("https://api.openverse.org/v1/images/"); 8449 Object.entries(finalQuery).forEach(([key, value]) => { 8450 const queryKey = mapFromInserterMediaRequest[key] || key; 8451 url.searchParams.set(queryKey, value); 8452 }); 8453 const response = await window.fetch(url, { 8454 headers: { 8455 "User-Agent": "WordPress/inserter-media-fetch" 8456 } 8457 }); 8458 const jsonResponse = await response.json(); 8459 const results = jsonResponse.results; 8460 return results.map((result) => ({ 8461 ...result, 8462 // This is a temp solution for better titles, until Openverse API 8463 // completes the cleaning up of some titles of their upstream data. 8464 title: result.title?.toLowerCase().startsWith("file:") ? result.title.slice(5) : result.title, 8465 sourceId: result.id, 8466 id: void 0, 8467 caption: getOpenverseCaption(result), 8468 previewUrl: result.thumbnail 8469 })); 8470 }, 8471 getReportUrl: ({ sourceId }) => `https://wordpress.org/openverse/image/$sourceId}/report/`, 8472 isExternalResource: true 8473 } 8474 ]; 8475 var media_categories_default = inserterMediaCategories; 8476 8477 // node_modules/uuid/dist/esm-browser/rng.js 8478 var getRandomValues; 8479 var rnds8 = new Uint8Array(16); 8480 function rng() { 8481 if (!getRandomValues) { 8482 getRandomValues = typeof crypto !== "undefined" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto); 8483 if (!getRandomValues) { 8484 throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported"); 8485 } 8486 } 8487 return getRandomValues(rnds8); 8488 } 8489 8490 // node_modules/uuid/dist/esm-browser/stringify.js 8491 var byteToHex = []; 8492 for (let i3 = 0; i3 < 256; ++i3) { 8493 byteToHex.push((i3 + 256).toString(16).slice(1)); 8494 } 8495 function unsafeStringify(arr, offset3 = 0) { 8496 return byteToHex[arr[offset3 + 0]] + byteToHex[arr[offset3 + 1]] + byteToHex[arr[offset3 + 2]] + byteToHex[arr[offset3 + 3]] + "-" + byteToHex[arr[offset3 + 4]] + byteToHex[arr[offset3 + 5]] + "-" + byteToHex[arr[offset3 + 6]] + byteToHex[arr[offset3 + 7]] + "-" + byteToHex[arr[offset3 + 8]] + byteToHex[arr[offset3 + 9]] + "-" + byteToHex[arr[offset3 + 10]] + byteToHex[arr[offset3 + 11]] + byteToHex[arr[offset3 + 12]] + byteToHex[arr[offset3 + 13]] + byteToHex[arr[offset3 + 14]] + byteToHex[arr[offset3 + 15]]; 8497 } 8498 8499 // node_modules/uuid/dist/esm-browser/native.js 8500 var randomUUID = typeof crypto !== "undefined" && crypto.randomUUID && crypto.randomUUID.bind(crypto); 8501 var native_default = { 8502 randomUUID 8503 }; 8504 8505 // node_modules/uuid/dist/esm-browser/v4.js 8506 function v4(options, buf, offset3) { 8507 if (native_default.randomUUID && !buf && !options) { 8508 return native_default.randomUUID(); 8509 } 8510 options = options || {}; 8511 const rnds = options.random || (options.rng || rng)(); 8512 rnds[6] = rnds[6] & 15 | 64; 8513 rnds[8] = rnds[8] & 63 | 128; 8514 if (buf) { 8515 offset3 = offset3 || 0; 8516 for (let i3 = 0; i3 < 16; ++i3) { 8517 buf[offset3 + i3] = rnds[i3]; 8518 } 8519 return buf; 8520 } 8521 return unsafeStringify(rnds); 8522 } 8523 var v4_default = v4; 8524 8525 // packages/editor/build-module/utils/media-upload/index.js 8526 var import_data24 = __toESM(require_data()); 8527 var import_core_data21 = __toESM(require_core_data()); 8528 var import_media_utils2 = __toESM(require_media_utils()); 8529 var noop = () => { 8530 }; 8531 function mediaUpload({ 8532 additionalData = {}, 8533 allowedTypes, 8534 filesList, 8535 maxUploadFileSize, 8536 onError = noop, 8537 onFileChange, 8538 onSuccess, 8539 multiple = true 8540 }) { 8541 const { receiveEntityRecords } = (0, import_data24.dispatch)(import_core_data21.store); 8542 const { getCurrentPost: getCurrentPost2, getEditorSettings: getEditorSettings2 } = (0, import_data24.select)(store); 8543 const { 8544 lockPostAutosaving: lockPostAutosaving2, 8545 unlockPostAutosaving: unlockPostAutosaving2, 8546 lockPostSaving: lockPostSaving2, 8547 unlockPostSaving: unlockPostSaving2 8548 } = (0, import_data24.dispatch)(store); 8549 const wpAllowedMimeTypes = getEditorSettings2().allowedMimeTypes; 8550 const lockKey = `image-upload-$v4_default()}`; 8551 let imageIsUploading = false; 8552 maxUploadFileSize = maxUploadFileSize || getEditorSettings2().maxUploadFileSize; 8553 const currentPost = getCurrentPost2(); 8554 const currentPostId = typeof currentPost?.id === "number" ? currentPost.id : currentPost?.wp_id; 8555 const setSaveLock = () => { 8556 lockPostSaving2(lockKey); 8557 lockPostAutosaving2(lockKey); 8558 imageIsUploading = true; 8559 }; 8560 const postData = currentPostId ? { post: currentPostId } : {}; 8561 const clearSaveLock = () => { 8562 unlockPostSaving2(lockKey); 8563 unlockPostAutosaving2(lockKey); 8564 imageIsUploading = false; 8565 }; 8566 (0, import_media_utils2.uploadMedia)({ 8567 allowedTypes, 8568 filesList, 8569 onFileChange: (file) => { 8570 if (!imageIsUploading) { 8571 setSaveLock(); 8572 } else { 8573 clearSaveLock(); 8574 } 8575 onFileChange?.(file); 8576 const entityFiles = file.filter((_file) => _file?.id); 8577 if (entityFiles?.length) { 8578 const invalidateCache = true; 8579 receiveEntityRecords( 8580 "postType", 8581 "attachment", 8582 entityFiles, 8583 void 0, 8584 invalidateCache 8585 ); 8586 } 8587 }, 8588 onSuccess, 8589 additionalData: { 8590 ...postData, 8591 ...additionalData 8592 }, 8593 maxUploadFileSize, 8594 onError: ({ message }) => { 8595 clearSaveLock(); 8596 onError(message); 8597 }, 8598 wpAllowedMimeTypes, 8599 multiple 8600 }); 8601 } 8602 8603 // packages/editor/build-module/utils/url.js 8604 var import_url7 = __toESM(require_url()); 8605 var import_deprecated3 = __toESM(require_deprecated()); 8606 function cleanForSlug3(string) { 8607 (0, import_deprecated3.default)("wp.editor.cleanForSlug", { 8608 since: "12.7", 8609 plugin: "Gutenberg", 8610 alternative: "wp.url.cleanForSlug" 8611 }); 8612 return (0, import_url7.cleanForSlug)(string); 8613 } 8614 8615 // packages/editor/build-module/utils/media-sideload/index.js 8616 var import_media_utils3 = __toESM(require_media_utils()); 8617 var { sideloadMedia: mediaSideload } = unlock(import_media_utils3.privateApis); 8618 var media_sideload_default = mediaSideload; 8619 8620 // packages/editor/build-module/components/global-styles-provider/index.js 8621 var import_block_editor6 = __toESM(require_block_editor()); 8622 var import_core_data22 = __toESM(require_core_data()); 8623 var import_data26 = __toESM(require_data()); 8624 var import_element21 = __toESM(require_element()); 8625 8626 // packages/global-styles-engine/build-module/utils/object.js 8627 function setImmutably(object, path, value) { 8628 path = Array.isArray(path) ? [...path] : [path]; 8629 object = Array.isArray(object) ? [...object] : { ...object }; 8630 const leaf = path.pop(); 8631 let prev = object; 8632 for (const key of path) { 8633 const lvl = prev[key]; 8634 prev = prev[key] = Array.isArray(lvl) ? [...lvl] : { ...lvl }; 8635 } 8636 prev[leaf] = value; 8637 return object; 8638 } 8639 var getValueFromObjectPath = (object, path, defaultValue) => { 8640 const arrayPath = Array.isArray(path) ? path : path.split("."); 8641 let value = object; 8642 arrayPath.forEach((fieldName) => { 8643 value = value?.[fieldName]; 8644 }); 8645 return value ?? defaultValue; 8646 }; 8647 8648 // packages/global-styles-engine/build-module/settings/get-setting.js 8649 var VALID_SETTINGS = [ 8650 "appearanceTools", 8651 "useRootPaddingAwareAlignments", 8652 "background.backgroundImage", 8653 "background.backgroundRepeat", 8654 "background.backgroundSize", 8655 "background.backgroundPosition", 8656 "border.color", 8657 "border.radius", 8658 "border.radiusSizes", 8659 "border.style", 8660 "border.width", 8661 "shadow.presets", 8662 "shadow.defaultPresets", 8663 "color.background", 8664 "color.button", 8665 "color.caption", 8666 "color.custom", 8667 "color.customDuotone", 8668 "color.customGradient", 8669 "color.defaultDuotone", 8670 "color.defaultGradients", 8671 "color.defaultPalette", 8672 "color.duotone", 8673 "color.gradients", 8674 "color.heading", 8675 "color.link", 8676 "color.palette", 8677 "color.text", 8678 "custom", 8679 "dimensions.aspectRatio", 8680 "dimensions.height", 8681 "dimensions.minHeight", 8682 "dimensions.width", 8683 "dimensions.dimensionSizes", 8684 "layout.contentSize", 8685 "layout.definitions", 8686 "layout.wideSize", 8687 "lightbox.enabled", 8688 "lightbox.allowEditing", 8689 "position.fixed", 8690 "position.sticky", 8691 "spacing.customSpacingSize", 8692 "spacing.defaultSpacingSizes", 8693 "spacing.spacingSizes", 8694 "spacing.spacingScale", 8695 "spacing.blockGap", 8696 "spacing.margin", 8697 "spacing.padding", 8698 "spacing.units", 8699 "typography.fluid", 8700 "typography.customFontSize", 8701 "typography.defaultFontSizes", 8702 "typography.dropCap", 8703 "typography.fontFamilies", 8704 "typography.fontSizes", 8705 "typography.fontStyle", 8706 "typography.fontWeight", 8707 "typography.letterSpacing", 8708 "typography.lineHeight", 8709 "typography.textAlign", 8710 "typography.textColumns", 8711 "typography.textDecoration", 8712 "typography.textTransform", 8713 "typography.writingMode" 8714 ]; 8715 function getSetting(globalStyles, path, blockName) { 8716 const appendedBlockPath = blockName ? ".blocks." + blockName : ""; 8717 const appendedPropertyPath = path ? "." + path : ""; 8718 const contextualPath = `settings$appendedBlockPath}$appendedPropertyPath}`; 8719 const globalPath = `settings$appendedPropertyPath}`; 8720 if (path) { 8721 return getValueFromObjectPath(globalStyles, contextualPath) ?? getValueFromObjectPath(globalStyles, globalPath); 8722 } 8723 let result = {}; 8724 VALID_SETTINGS.forEach((setting) => { 8725 const value = getValueFromObjectPath( 8726 globalStyles, 8727 `settings$appendedBlockPath}.$setting}` 8728 ) ?? getValueFromObjectPath(globalStyles, `settings.$setting}`); 8729 if (value !== void 0) { 8730 result = setImmutably(result, setting.split("."), value); 8731 } 8732 }); 8733 return result; 8734 } 8735 8736 // packages/global-styles-engine/build-module/settings/set-setting.js 8737 function setSetting(globalStyles, path, newValue, blockName) { 8738 const appendedBlockPath = blockName ? ".blocks." + blockName : ""; 8739 const appendedPropertyPath = path ? "." + path : ""; 8740 const finalPath = `settings$appendedBlockPath}$appendedPropertyPath}`; 8741 return setImmutably( 8742 globalStyles, 8743 finalPath.split("."), 8744 newValue 8745 ); 8746 } 8747 8748 // packages/global-styles-engine/build-module/utils/common.js 8749 var import_style_engine = __toESM(require_style_engine()); 8750 8751 // packages/global-styles-engine/build-module/utils/fluid.js 8752 var DEFAULT_MAXIMUM_VIEWPORT_WIDTH = "1600px"; 8753 var DEFAULT_MINIMUM_VIEWPORT_WIDTH = "320px"; 8754 var DEFAULT_SCALE_FACTOR = 1; 8755 var DEFAULT_MINIMUM_FONT_SIZE_FACTOR_MIN = 0.25; 8756 var DEFAULT_MINIMUM_FONT_SIZE_FACTOR_MAX = 0.75; 8757 var DEFAULT_MINIMUM_FONT_SIZE_LIMIT = "14px"; 8758 function getComputedFluidTypographyValue({ 8759 minimumFontSize, 8760 maximumFontSize, 8761 fontSize, 8762 minimumViewportWidth = DEFAULT_MINIMUM_VIEWPORT_WIDTH, 8763 maximumViewportWidth = DEFAULT_MAXIMUM_VIEWPORT_WIDTH, 8764 scaleFactor = DEFAULT_SCALE_FACTOR, 8765 minimumFontSizeLimit 8766 }) { 8767 minimumFontSizeLimit = !!getTypographyValueAndUnit(minimumFontSizeLimit) ? minimumFontSizeLimit : DEFAULT_MINIMUM_FONT_SIZE_LIMIT; 8768 if (fontSize) { 8769 const fontSizeParsed = getTypographyValueAndUnit(fontSize); 8770 if (!fontSizeParsed?.unit || !fontSizeParsed?.value) { 8771 return null; 8772 } 8773 const minimumFontSizeLimitParsed = getTypographyValueAndUnit( 8774 minimumFontSizeLimit, 8775 { 8776 coerceTo: fontSizeParsed.unit 8777 } 8778 ); 8779 if (!!minimumFontSizeLimitParsed?.value && !minimumFontSize && !maximumFontSize) { 8780 if (fontSizeParsed?.value <= minimumFontSizeLimitParsed?.value) { 8781 return null; 8782 } 8783 } 8784 if (!maximumFontSize) { 8785 maximumFontSize = `$fontSizeParsed.value}$fontSizeParsed.unit}`; 8786 } 8787 if (!minimumFontSize) { 8788 const fontSizeValueInPx = fontSizeParsed.unit === "px" ? fontSizeParsed.value : fontSizeParsed.value * 16; 8789 const minimumFontSizeFactor = Math.min( 8790 Math.max( 8791 1 - 0.075 * Math.log2(fontSizeValueInPx), 8792 DEFAULT_MINIMUM_FONT_SIZE_FACTOR_MIN 8793 ), 8794 DEFAULT_MINIMUM_FONT_SIZE_FACTOR_MAX 8795 ); 8796 const calculatedMinimumFontSize = roundToPrecision( 8797 fontSizeParsed.value * minimumFontSizeFactor, 8798 3 8799 ); 8800 if (!!minimumFontSizeLimitParsed?.value && calculatedMinimumFontSize < minimumFontSizeLimitParsed?.value) { 8801 minimumFontSize = `$minimumFontSizeLimitParsed.value}$minimumFontSizeLimitParsed.unit}`; 8802 } else { 8803 minimumFontSize = `$calculatedMinimumFontSize}$fontSizeParsed.unit}`; 8804 } 8805 } 8806 } 8807 const minimumFontSizeParsed = getTypographyValueAndUnit(minimumFontSize); 8808 const fontSizeUnit = minimumFontSizeParsed?.unit || "rem"; 8809 const maximumFontSizeParsed = getTypographyValueAndUnit(maximumFontSize, { 8810 coerceTo: fontSizeUnit 8811 }); 8812 if (!minimumFontSizeParsed || !maximumFontSizeParsed) { 8813 return null; 8814 } 8815 const minimumFontSizeRem = getTypographyValueAndUnit(minimumFontSize, { 8816 coerceTo: "rem" 8817 }); 8818 const maximumViewportWidthParsed = getTypographyValueAndUnit( 8819 maximumViewportWidth, 8820 { coerceTo: fontSizeUnit } 8821 ); 8822 const minimumViewportWidthParsed = getTypographyValueAndUnit( 8823 minimumViewportWidth, 8824 { coerceTo: fontSizeUnit } 8825 ); 8826 if (!maximumViewportWidthParsed || !minimumViewportWidthParsed || !minimumFontSizeRem) { 8827 return null; 8828 } 8829 const linearDenominator = maximumViewportWidthParsed.value - minimumViewportWidthParsed.value; 8830 if (!linearDenominator) { 8831 return null; 8832 } 8833 const minViewportWidthOffsetValue = roundToPrecision( 8834 minimumViewportWidthParsed.value / 100, 8835 3 8836 ); 8837 const viewportWidthOffset = roundToPrecision(minViewportWidthOffsetValue, 3) + fontSizeUnit; 8838 const linearFactor = 100 * ((maximumFontSizeParsed.value - minimumFontSizeParsed.value) / linearDenominator); 8839 const linearFactorScaled = roundToPrecision( 8840 (linearFactor || 1) * scaleFactor, 8841 3 8842 ); 8843 const fluidTargetFontSize = `$minimumFontSizeRem.value}$minimumFontSizeRem.unit} + ((1vw - $viewportWidthOffset}) * $linearFactorScaled})`; 8844 return `clamp($minimumFontSize}, $fluidTargetFontSize}, $maximumFontSize})`; 8845 } 8846 function getTypographyValueAndUnit(rawValue, options = {}) { 8847 if (typeof rawValue !== "string" && typeof rawValue !== "number") { 8848 return null; 8849 } 8850 if (isFinite(rawValue)) { 8851 rawValue = `$rawValue}px`; 8852 } 8853 const { coerceTo, rootSizeValue, acceptableUnits } = { 8854 coerceTo: "", 8855 // Default browser font size. Later we could inject some JS to compute this `getComputedStyle( document.querySelector( "html" ) ).fontSize`. 8856 rootSizeValue: 16, 8857 acceptableUnits: ["rem", "px", "em"], 8858 ...options 8859 }; 8860 const acceptableUnitsGroup = acceptableUnits?.join("|"); 8861 const regexUnits = new RegExp( 8862 `^(\\d*\\.?\\d+)($acceptableUnitsGroup}){1,1}$` 8863 ); 8864 const matches = rawValue.toString().match(regexUnits); 8865 if (!matches || matches.length < 3) { 8866 return null; 8867 } 8868 let [, value, unit] = matches; 8869 let returnValue = parseFloat(value); 8870 if ("px" === coerceTo && ("em" === unit || "rem" === unit)) { 8871 returnValue = returnValue * rootSizeValue; 8872 unit = coerceTo; 8873 } 8874 if ("px" === unit && ("em" === coerceTo || "rem" === coerceTo)) { 8875 returnValue = returnValue / rootSizeValue; 8876 unit = coerceTo; 8877 } 8878 if (("em" === coerceTo || "rem" === coerceTo) && ("em" === unit || "rem" === unit)) { 8879 unit = coerceTo; 8880 } 8881 if (!unit) { 8882 return null; 8883 } 8884 return { 8885 value: roundToPrecision(returnValue, 3), 8886 unit 8887 }; 8888 } 8889 function roundToPrecision(value, digits = 3) { 8890 const base = Math.pow(10, digits); 8891 return Math.round(value * base) / base; 8892 } 8893 8894 // packages/global-styles-engine/build-module/utils/typography.js 8895 function isFluidTypographyEnabled(typographySettings) { 8896 const fluidSettings = typographySettings?.fluid; 8897 return true === fluidSettings || fluidSettings && typeof fluidSettings === "object" && Object.keys(fluidSettings).length > 0; 8898 } 8899 function getFluidTypographyOptionsFromSettings(settings) { 8900 const typographySettings = settings?.typography ?? {}; 8901 const layoutSettings = settings?.layout; 8902 const defaultMaxViewportWidth = getTypographyValueAndUnit( 8903 layoutSettings?.wideSize 8904 ) ? layoutSettings?.wideSize : null; 8905 return isFluidTypographyEnabled(typographySettings) && defaultMaxViewportWidth ? { 8906 fluid: { 8907 maxViewportWidth: defaultMaxViewportWidth, 8908 ...typeof typographySettings.fluid === "object" ? typographySettings.fluid : {} 8909 } 8910 } : { 8911 fluid: typographySettings?.fluid 8912 }; 8913 } 8914 function getTypographyFontSizeValue(preset, settings) { 8915 const { size: defaultSize } = preset; 8916 if (!defaultSize || "0" === defaultSize || false === preset?.fluid) { 8917 return defaultSize; 8918 } 8919 if (!isFluidTypographyEnabled(settings?.typography) && !isFluidTypographyEnabled(preset)) { 8920 return defaultSize; 8921 } 8922 const fluidTypographySettings = getFluidTypographyOptionsFromSettings(settings)?.fluid ?? {}; 8923 const fluidFontSizeValue = getComputedFluidTypographyValue({ 8924 minimumFontSize: typeof preset?.fluid === "boolean" ? void 0 : preset?.fluid?.min, 8925 maximumFontSize: typeof preset?.fluid === "boolean" ? void 0 : preset?.fluid?.max, 8926 fontSize: defaultSize, 8927 minimumFontSizeLimit: typeof fluidTypographySettings === "object" ? fluidTypographySettings?.minFontSize : void 0, 8928 maximumViewportWidth: typeof fluidTypographySettings === "object" ? fluidTypographySettings?.maxViewportWidth : void 0, 8929 minimumViewportWidth: typeof fluidTypographySettings === "object" ? fluidTypographySettings?.minViewportWidth : void 0 8930 }); 8931 if (!!fluidFontSizeValue) { 8932 return fluidFontSizeValue; 8933 } 8934 return defaultSize; 8935 } 8936 8937 // packages/global-styles-engine/build-module/utils/common.js 8938 var ROOT_BLOCK_SELECTOR = "body"; 8939 var ROOT_CSS_PROPERTIES_SELECTOR = ":root"; 8940 var PRESET_METADATA = [ 8941 { 8942 path: ["color", "palette"], 8943 valueKey: "color", 8944 cssVarInfix: "color", 8945 classes: [ 8946 { classSuffix: "color", propertyName: "color" }, 8947 { 8948 classSuffix: "background-color", 8949 propertyName: "background-color" 8950 }, 8951 { 8952 classSuffix: "border-color", 8953 propertyName: "border-color" 8954 } 8955 ] 8956 }, 8957 { 8958 path: ["color", "gradients"], 8959 valueKey: "gradient", 8960 cssVarInfix: "gradient", 8961 classes: [ 8962 { 8963 classSuffix: "gradient-background", 8964 propertyName: "background" 8965 } 8966 ] 8967 }, 8968 { 8969 path: ["color", "duotone"], 8970 valueKey: "colors", 8971 cssVarInfix: "duotone", 8972 valueFunc: ({ slug }) => `url( '#wp-duotone-$slug}' )`, 8973 classes: [] 8974 }, 8975 { 8976 path: ["shadow", "presets"], 8977 valueKey: "shadow", 8978 cssVarInfix: "shadow", 8979 classes: [] 8980 }, 8981 { 8982 path: ["typography", "fontSizes"], 8983 valueFunc: (preset, settings) => getTypographyFontSizeValue(preset, settings), 8984 valueKey: "size", 8985 cssVarInfix: "font-size", 8986 classes: [{ classSuffix: "font-size", propertyName: "font-size" }] 8987 }, 8988 { 8989 path: ["typography", "fontFamilies"], 8990 valueKey: "fontFamily", 8991 cssVarInfix: "font-family", 8992 classes: [ 8993 { classSuffix: "font-family", propertyName: "font-family" } 8994 ] 8995 }, 8996 { 8997 path: ["spacing", "spacingSizes"], 8998 valueKey: "size", 8999 cssVarInfix: "spacing", 9000 valueFunc: ({ size: size3 }) => size3, 9001 classes: [] 9002 }, 9003 { 9004 path: ["border", "radiusSizes"], 9005 valueKey: "size", 9006 cssVarInfix: "border-radius", 9007 classes: [] 9008 }, 9009 { 9010 path: ["dimensions", "dimensionSizes"], 9011 valueKey: "size", 9012 cssVarInfix: "dimension", 9013 classes: [] 9014 } 9015 ]; 9016 function scopeSelector(scope, selector) { 9017 if (!scope || !selector) { 9018 return selector; 9019 } 9020 const scopes = scope.split(","); 9021 const selectors = selector.split(","); 9022 const selectorsScoped = []; 9023 scopes.forEach((outer) => { 9024 selectors.forEach((inner) => { 9025 selectorsScoped.push(`$outer.trim()} $inner.trim()}`); 9026 }); 9027 }); 9028 return selectorsScoped.join(", "); 9029 } 9030 function scopeFeatureSelectors(scope, selectors) { 9031 if (!scope || !selectors) { 9032 return; 9033 } 9034 const featureSelectors = {}; 9035 Object.entries(selectors).forEach(([feature, selector]) => { 9036 if (typeof selector === "string") { 9037 featureSelectors[feature] = scopeSelector(scope, selector); 9038 } 9039 if (typeof selector === "object") { 9040 featureSelectors[feature] = {}; 9041 Object.entries(selector).forEach( 9042 ([subfeature, subfeatureSelector]) => { 9043 featureSelectors[feature][subfeature] = scopeSelector( 9044 scope, 9045 subfeatureSelector 9046 ); 9047 } 9048 ); 9049 } 9050 }); 9051 return featureSelectors; 9052 } 9053 function appendToSelector(selector, toAppend) { 9054 if (!selector.includes(",")) { 9055 return selector + toAppend; 9056 } 9057 const selectors = selector.split(","); 9058 const newSelectors = selectors.map((sel) => sel + toAppend); 9059 return newSelectors.join(","); 9060 } 9061 function getBlockStyleVariationSelector(variation, blockSelector) { 9062 const variationClass = `.is-style-$variation}`; 9063 if (!blockSelector) { 9064 return variationClass; 9065 } 9066 const ancestorRegex = /((?::\([^)]+\))?\s*)([^\s:]+)/; 9067 const addVariationClass = (_match, group1, group2) => { 9068 return group1 + group2 + variationClass; 9069 }; 9070 const result = blockSelector.split(",").map((part) => part.replace(ancestorRegex, addVariationClass)); 9071 return result.join(","); 9072 } 9073 function getResolvedRefValue(ruleValue, tree) { 9074 if (!ruleValue || !tree) { 9075 return ruleValue; 9076 } 9077 if (typeof ruleValue === "object" && "ref" in ruleValue && ruleValue?.ref) { 9078 const resolvedRuleValue = (0, import_style_engine.getCSSValueFromRawStyle)( 9079 getValueFromObjectPath(tree, ruleValue.ref) 9080 ); 9081 if (typeof resolvedRuleValue === "object" && resolvedRuleValue !== null && "ref" in resolvedRuleValue && resolvedRuleValue?.ref) { 9082 return void 0; 9083 } 9084 if (resolvedRuleValue === void 0) { 9085 return ruleValue; 9086 } 9087 return resolvedRuleValue; 9088 } 9089 return ruleValue; 9090 } 9091 function getResolvedThemeFilePath(file, themeFileURIs) { 9092 if (!file || !themeFileURIs || !Array.isArray(themeFileURIs)) { 9093 return file; 9094 } 9095 const uri = themeFileURIs.find( 9096 (themeFileUri) => themeFileUri?.name === file 9097 ); 9098 if (!uri?.href) { 9099 return file; 9100 } 9101 return uri?.href; 9102 } 9103 function getResolvedValue(ruleValue, tree) { 9104 if (!ruleValue || !tree) { 9105 return ruleValue; 9106 } 9107 const resolvedValue = getResolvedRefValue(ruleValue, tree); 9108 if (typeof resolvedValue === "object" && resolvedValue !== null && "url" in resolvedValue && resolvedValue?.url) { 9109 resolvedValue.url = getResolvedThemeFilePath( 9110 resolvedValue.url, 9111 tree?._links?.["wp:theme-file"] 9112 ); 9113 } 9114 return resolvedValue; 9115 } 9116 function findInPresetsBy(settings, blockName, presetPath = [], presetProperty = "slug", presetValueValue) { 9117 const orderedPresetsByOrigin = [ 9118 blockName ? getValueFromObjectPath(settings, [ 9119 "blocks", 9120 blockName, 9121 ...presetPath 9122 ]) : void 0, 9123 getValueFromObjectPath(settings, presetPath) 9124 ].filter(Boolean); 9125 for (const presetByOrigin of orderedPresetsByOrigin) { 9126 if (presetByOrigin) { 9127 const origins = ["custom", "theme", "default"]; 9128 for (const origin of origins) { 9129 const presets = presetByOrigin[origin]; 9130 if (presets) { 9131 const presetObject = presets.find( 9132 (preset) => preset[presetProperty] === presetValueValue 9133 ); 9134 if (presetObject) { 9135 if (presetProperty === "slug") { 9136 return presetObject; 9137 } 9138 const highestPresetObjectWithSameSlug = findInPresetsBy( 9139 settings, 9140 blockName, 9141 presetPath, 9142 "slug", 9143 presetObject.slug 9144 ); 9145 if (highestPresetObjectWithSameSlug[presetProperty] === presetObject[presetProperty]) { 9146 return presetObject; 9147 } 9148 return void 0; 9149 } 9150 } 9151 } 9152 } 9153 } 9154 } 9155 function getValueFromPresetVariable(features, blockName, variable, [presetType, slug] = []) { 9156 const metadata = PRESET_METADATA.find( 9157 (data) => data.cssVarInfix === presetType 9158 ); 9159 if (!metadata || !features.settings) { 9160 return variable; 9161 } 9162 const presetObject = findInPresetsBy( 9163 features.settings, 9164 blockName, 9165 metadata.path, 9166 "slug", 9167 slug 9168 ); 9169 if (presetObject) { 9170 const { valueKey } = metadata; 9171 const result = presetObject[valueKey]; 9172 return getValueFromVariable(features, blockName, result); 9173 } 9174 return variable; 9175 } 9176 function getValueFromCustomVariable(features, blockName, variable, path = []) { 9177 const result = (blockName ? getValueFromObjectPath(features?.settings ?? {}, [ 9178 "blocks", 9179 blockName, 9180 "custom", 9181 ...path 9182 ]) : void 0) ?? getValueFromObjectPath(features?.settings ?? {}, [ 9183 "custom", 9184 ...path 9185 ]); 9186 if (!result) { 9187 return variable; 9188 } 9189 return getValueFromVariable(features, blockName, result); 9190 } 9191 function getValueFromVariable(features, blockName, variable) { 9192 if (!variable || typeof variable !== "string") { 9193 if (typeof variable === "object" && variable !== null && "ref" in variable && typeof variable.ref === "string") { 9194 const resolvedVariable = getValueFromObjectPath( 9195 features, 9196 variable.ref 9197 ); 9198 if (!resolvedVariable || typeof resolvedVariable === "object" && "ref" in resolvedVariable) { 9199 return resolvedVariable; 9200 } 9201 variable = resolvedVariable; 9202 } else { 9203 return variable; 9204 } 9205 } 9206 const USER_VALUE_PREFIX = "var:"; 9207 const THEME_VALUE_PREFIX = "var(--wp--"; 9208 const THEME_VALUE_SUFFIX = ")"; 9209 let parsedVar; 9210 if (variable.startsWith(USER_VALUE_PREFIX)) { 9211 parsedVar = variable.slice(USER_VALUE_PREFIX.length).split("|"); 9212 } else if (variable.startsWith(THEME_VALUE_PREFIX) && variable.endsWith(THEME_VALUE_SUFFIX)) { 9213 parsedVar = variable.slice(THEME_VALUE_PREFIX.length, -THEME_VALUE_SUFFIX.length).split("--"); 9214 } else { 9215 return variable; 9216 } 9217 const [type, ...path] = parsedVar; 9218 if (type === "preset") { 9219 return getValueFromPresetVariable( 9220 features, 9221 blockName, 9222 variable, 9223 path 9224 ); 9225 } 9226 if (type === "custom") { 9227 return getValueFromCustomVariable( 9228 features, 9229 blockName, 9230 variable, 9231 path 9232 ); 9233 } 9234 return variable; 9235 } 9236 9237 // packages/global-styles-engine/build-module/settings/get-style.js 9238 function getStyle(globalStyles, path, blockName, shouldDecodeEncode = true) { 9239 const appendedPath = path ? "." + path : ""; 9240 const finalPath = !blockName ? `styles$appendedPath}` : `styles.blocks.$blockName}$appendedPath}`; 9241 if (!globalStyles) { 9242 return void 0; 9243 } 9244 const rawResult = getValueFromObjectPath(globalStyles, finalPath); 9245 const result = shouldDecodeEncode ? getValueFromVariable(globalStyles, blockName, rawResult) : rawResult; 9246 return result; 9247 } 9248 9249 // packages/global-styles-engine/build-module/settings/set-style.js 9250 function setStyle(globalStyles, path, newValue, blockName) { 9251 const appendedPath = path ? "." + path : ""; 9252 const finalPath = !blockName ? `styles$appendedPath}` : `styles.blocks.$blockName}$appendedPath}`; 9253 return setImmutably( 9254 globalStyles, 9255 finalPath.split("."), 9256 newValue 9257 ); 9258 } 9259 9260 // packages/global-styles-engine/build-module/core/equal.js 9261 var import_es6 = __toESM(require_es6()); 9262 function areGlobalStylesEqual(original, variation) { 9263 if (typeof original !== "object" || typeof variation !== "object") { 9264 return original === variation; 9265 } 9266 return (0, import_es6.default)(original?.styles, variation?.styles) && (0, import_es6.default)(original?.settings, variation?.settings); 9267 } 9268 9269 // packages/global-styles-engine/build-module/core/merge.js 9270 var import_deepmerge = __toESM(require_cjs()); 9271 9272 // node_modules/is-plain-object/dist/is-plain-object.mjs 9273 function isObject(o4) { 9274 return Object.prototype.toString.call(o4) === "[object Object]"; 9275 } 9276 function isPlainObject(o4) { 9277 var ctor, prot; 9278 if (isObject(o4) === false) return false; 9279 ctor = o4.constructor; 9280 if (ctor === void 0) return true; 9281 prot = ctor.prototype; 9282 if (isObject(prot) === false) return false; 9283 if (prot.hasOwnProperty("isPrototypeOf") === false) { 9284 return false; 9285 } 9286 return true; 9287 } 9288 9289 // packages/global-styles-engine/build-module/core/merge.js 9290 function mergeGlobalStyles(base, user) { 9291 return (0, import_deepmerge.default)(base, user, { 9292 /* 9293 * We only pass as arrays the presets, 9294 * in which case we want the new array of values 9295 * to override the old array (no merging). 9296 */ 9297 isMergeableObject: isPlainObject, 9298 /* 9299 * Exceptions to the above rule. 9300 * Background images should be replaced, not merged, 9301 * as they themselves are specific object definitions for the style. 9302 */ 9303 customMerge: (key) => { 9304 if (key === "backgroundImage") { 9305 return (baseConfig, userConfig) => userConfig ?? baseConfig; 9306 } 9307 return void 0; 9308 } 9309 }); 9310 } 9311 9312 // node_modules/memize/dist/index.js 9313 function memize(fn, options) { 9314 var size3 = 0; 9315 var head2; 9316 var tail; 9317 options = options || {}; 9318 function memoized() { 9319 var node = head2, len = arguments.length, args, i3; 9320 searchCache: while (node) { 9321 if (node.args.length !== arguments.length) { 9322 node = node.next; 9323 continue; 9324 } 9325 for (i3 = 0; i3 < len; i3++) { 9326 if (node.args[i3] !== arguments[i3]) { 9327 node = node.next; 9328 continue searchCache; 9329 } 9330 } 9331 if (node !== head2) { 9332 if (node === tail) { 9333 tail = node.prev; 9334 } 9335 node.prev.next = node.next; 9336 if (node.next) { 9337 node.next.prev = node.prev; 9338 } 9339 node.next = head2; 9340 node.prev = null; 9341 head2.prev = node; 9342 head2 = node; 9343 } 9344 return node.val; 9345 } 9346 args = new Array(len); 9347 for (i3 = 0; i3 < len; i3++) { 9348 args[i3] = arguments[i3]; 9349 } 9350 node = { 9351 args, 9352 // Generate the result from original function 9353 val: fn.apply(null, args) 9354 }; 9355 if (head2) { 9356 head2.prev = node; 9357 node.next = head2; 9358 } else { 9359 tail = node; 9360 } 9361 if (size3 === /** @type {MemizeOptions} */ 9362 options.maxSize) { 9363 tail = /** @type {MemizeCacheNode} */ 9364 tail.prev; 9365 tail.next = null; 9366 } else { 9367 size3++; 9368 } 9369 head2 = node; 9370 return node.val; 9371 } 9372 memoized.clear = function() { 9373 head2 = null; 9374 tail = null; 9375 size3 = 0; 9376 }; 9377 return memoized; 9378 } 9379 9380 // packages/global-styles-engine/build-module/utils/get-global-styles-changes.js 9381 var import_i18n48 = __toESM(require_i18n()); 9382 var import_blocks7 = __toESM(require_blocks()); 9383 var globalStylesChangesCache = /* @__PURE__ */ new Map(); 9384 var EMPTY_ARRAY2 = []; 9385 var translationMap = { 9386 caption: (0, import_i18n48.__)("Caption"), 9387 link: (0, import_i18n48.__)("Link"), 9388 button: (0, import_i18n48.__)("Button"), 9389 heading: (0, import_i18n48.__)("Heading"), 9390 h1: (0, import_i18n48.__)("H1"), 9391 h2: (0, import_i18n48.__)("H2"), 9392 h3: (0, import_i18n48.__)("H3"), 9393 h4: (0, import_i18n48.__)("H4"), 9394 h5: (0, import_i18n48.__)("H5"), 9395 h6: (0, import_i18n48.__)("H6"), 9396 "settings.color": (0, import_i18n48.__)("Color"), 9397 "settings.typography": (0, import_i18n48.__)("Typography"), 9398 "settings.shadow": (0, import_i18n48.__)("Shadow"), 9399 "settings.layout": (0, import_i18n48.__)("Layout"), 9400 "styles.color": (0, import_i18n48.__)("Colors"), 9401 "styles.spacing": (0, import_i18n48.__)("Spacing"), 9402 "styles.background": (0, import_i18n48.__)("Background"), 9403 "styles.typography": (0, import_i18n48.__)("Typography") 9404 }; 9405 var getBlockNames = memize( 9406 () => (0, import_blocks7.getBlockTypes)().reduce( 9407 (accumulator, { 9408 name: name2, 9409 title 9410 }) => { 9411 accumulator[name2] = title; 9412 return accumulator; 9413 }, 9414 {} 9415 ) 9416 ); 9417 var isObject2 = (obj) => obj !== null && typeof obj === "object"; 9418 function getTranslation(key) { 9419 if (translationMap[key]) { 9420 return translationMap[key]; 9421 } 9422 const keyArray = key.split("."); 9423 if (keyArray?.[0] === "blocks") { 9424 const blockName = getBlockNames()?.[keyArray[1]]; 9425 return blockName || keyArray[1]; 9426 } 9427 if (keyArray?.[0] === "elements") { 9428 return translationMap[keyArray[1]] || keyArray[1]; 9429 } 9430 return void 0; 9431 } 9432 function deepCompare(changedObject, originalObject, parentPath = "") { 9433 if (!isObject2(changedObject) && !isObject2(originalObject)) { 9434 return changedObject !== originalObject ? parentPath.split(".").slice(0, 2).join(".") : void 0; 9435 } 9436 changedObject = isObject2(changedObject) ? changedObject : {}; 9437 originalObject = isObject2(originalObject) ? originalObject : {}; 9438 const allKeys = /* @__PURE__ */ new Set([ 9439 ...Object.keys(changedObject), 9440 ...Object.keys(originalObject) 9441 ]); 9442 let diffs = []; 9443 for (const key of allKeys) { 9444 const path = parentPath ? parentPath + "." + key : key; 9445 const changedPath = deepCompare( 9446 changedObject[key], 9447 originalObject[key], 9448 path 9449 ); 9450 if (changedPath) { 9451 diffs = diffs.concat(changedPath); 9452 } 9453 } 9454 return diffs; 9455 } 9456 function getGlobalStylesChangelist(next, previous) { 9457 const cacheKey = JSON.stringify({ next, previous }); 9458 if (globalStylesChangesCache.has(cacheKey)) { 9459 return globalStylesChangesCache.get(cacheKey); 9460 } 9461 const changedValueTree = deepCompare( 9462 { 9463 styles: { 9464 background: next?.styles?.background, 9465 color: next?.styles?.color, 9466 typography: next?.styles?.typography, 9467 spacing: next?.styles?.spacing 9468 }, 9469 blocks: next?.styles?.blocks, 9470 elements: next?.styles?.elements, 9471 settings: next?.settings 9472 }, 9473 { 9474 styles: { 9475 background: previous?.styles?.background, 9476 color: previous?.styles?.color, 9477 typography: previous?.styles?.typography, 9478 spacing: previous?.styles?.spacing 9479 }, 9480 blocks: previous?.styles?.blocks, 9481 elements: previous?.styles?.elements, 9482 settings: previous?.settings 9483 } 9484 ); 9485 if (!changedValueTree || Array.isArray(changedValueTree) && !changedValueTree.length) { 9486 globalStylesChangesCache.set(cacheKey, []); 9487 return []; 9488 } 9489 const changedValueArray = Array.isArray(changedValueTree) ? changedValueTree : [changedValueTree]; 9490 const result = [...new Set(changedValueArray)].reduce((acc, curr) => { 9491 const translation = getTranslation(curr); 9492 if (translation) { 9493 acc.push([curr.split(".")[0], translation]); 9494 } 9495 return acc; 9496 }, []); 9497 globalStylesChangesCache.set(cacheKey, result); 9498 return result; 9499 } 9500 function getGlobalStylesChanges(next, previous, options = {}) { 9501 let changeList = getGlobalStylesChangelist(next, previous); 9502 const changesLength = changeList.length; 9503 const { maxResults } = options; 9504 if (changesLength) { 9505 if (!!maxResults && changesLength > maxResults) { 9506 changeList = changeList.slice(0, maxResults); 9507 } 9508 return Object.entries( 9509 changeList.reduce((acc, curr) => { 9510 const group = acc[curr[0]] || []; 9511 if (!group.includes(curr[1])) { 9512 acc[curr[0]] = [...group, curr[1]]; 9513 } 9514 return acc; 9515 }, {}) 9516 ).map(([key, changeValues]) => { 9517 const changeValuesLength = changeValues.length; 9518 const joinedChangesValue = changeValues.join( 9519 /* translators: Used between list items, there is a space after the comma. */ 9520 (0, import_i18n48.__)(", ") 9521 // eslint-disable-line @wordpress/i18n-no-flanking-whitespace 9522 ); 9523 switch (key) { 9524 case "blocks": { 9525 return (0, import_i18n48.sprintf)( 9526 // translators: %s: a list of block names separated by a comma. 9527 (0, import_i18n48._n)("%s block.", "%s blocks.", changeValuesLength), 9528 joinedChangesValue 9529 ); 9530 } 9531 case "elements": { 9532 return (0, import_i18n48.sprintf)( 9533 // translators: %s: a list of element names separated by a comma. 9534 (0, import_i18n48._n)("%s element.", "%s elements.", changeValuesLength), 9535 joinedChangesValue 9536 ); 9537 } 9538 case "settings": { 9539 return (0, import_i18n48.sprintf)( 9540 // translators: %s: a list of theme.json setting labels separated by a comma. 9541 (0, import_i18n48.__)("%s settings."), 9542 joinedChangesValue 9543 ); 9544 } 9545 case "styles": { 9546 return (0, import_i18n48.sprintf)( 9547 // translators: %s: a list of theme.json top-level styles labels separated by a comma. 9548 (0, import_i18n48.__)("%s styles."), 9549 joinedChangesValue 9550 ); 9551 } 9552 default: { 9553 return (0, import_i18n48.sprintf)( 9554 // translators: %s: a list of global styles changes separated by a comma. 9555 (0, import_i18n48.__)("%s."), 9556 joinedChangesValue 9557 ); 9558 } 9559 } 9560 }); 9561 } 9562 return EMPTY_ARRAY2; 9563 } 9564 9565 // packages/global-styles-engine/build-module/core/render.js 9566 var import_blocks8 = __toESM(require_blocks()); 9567 var import_style_engine2 = __toESM(require_style_engine()); 9568 var import_data25 = __toESM(require_data()); 9569 9570 // packages/global-styles-engine/build-module/core/selectors.js 9571 function getBlockSelector(blockType, target = "root", options = {}) { 9572 if (!target) { 9573 return null; 9574 } 9575 const { fallback = false } = options; 9576 const { name: name2, selectors, supports } = blockType; 9577 const hasSelectors = selectors && Object.keys(selectors).length > 0; 9578 const path = Array.isArray(target) ? target.join(".") : target; 9579 let rootSelector = null; 9580 if (hasSelectors && selectors.root) { 9581 rootSelector = selectors?.root; 9582 } else if (supports?.__experimentalSelector) { 9583 rootSelector = supports.__experimentalSelector; 9584 } else { 9585 rootSelector = ".wp-block-" + name2.replace("core/", "").replace("/", "-"); 9586 } 9587 if (path === "root") { 9588 return rootSelector; 9589 } 9590 const pathArray = Array.isArray(target) ? target : target.split("."); 9591 if (pathArray.length === 1) { 9592 const fallbackSelector = fallback ? rootSelector : null; 9593 if (hasSelectors) { 9594 const featureSelector2 = getValueFromObjectPath( 9595 selectors, 9596 `$path}.root`, 9597 null 9598 ) || getValueFromObjectPath(selectors, path, null); 9599 return featureSelector2 || fallbackSelector; 9600 } 9601 const featureSelector = supports ? getValueFromObjectPath( 9602 supports, 9603 `$path}.__experimentalSelector`, 9604 null 9605 ) : void 0; 9606 if (!featureSelector) { 9607 return fallbackSelector; 9608 } 9609 return scopeSelector(rootSelector, featureSelector); 9610 } 9611 let subfeatureSelector; 9612 if (hasSelectors) { 9613 subfeatureSelector = getValueFromObjectPath(selectors, path, null); 9614 } 9615 if (subfeatureSelector) { 9616 return subfeatureSelector; 9617 } 9618 if (fallback) { 9619 return getBlockSelector(blockType, pathArray[0], options); 9620 } 9621 return null; 9622 } 9623 9624 // node_modules/colord/index.mjs 9625 var r3 = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }; 9626 var t2 = function(r4) { 9627 return "string" == typeof r4 ? r4.length > 0 : "number" == typeof r4; 9628 }; 9629 var n2 = function(r4, t4, n3) { 9630 return void 0 === t4 && (t4 = 0), void 0 === n3 && (n3 = Math.pow(10, t4)), Math.round(n3 * r4) / n3 + 0; 9631 }; 9632 var e2 = function(r4, t4, n3) { 9633 return void 0 === t4 && (t4 = 0), void 0 === n3 && (n3 = 1), r4 > n3 ? n3 : r4 > t4 ? r4 : t4; 9634 }; 9635 var u2 = function(r4) { 9636 return (r4 = isFinite(r4) ? r4 % 360 : 0) > 0 ? r4 : r4 + 360; 9637 }; 9638 var a2 = function(r4) { 9639 return { r: e2(r4.r, 0, 255), g: e2(r4.g, 0, 255), b: e2(r4.b, 0, 255), a: e2(r4.a) }; 9640 }; 9641 var o2 = function(r4) { 9642 return { r: n2(r4.r), g: n2(r4.g), b: n2(r4.b), a: n2(r4.a, 3) }; 9643 }; 9644 var i2 = /^#([0-9a-f]{3,8})$/i; 9645 var s2 = function(r4) { 9646 var t4 = r4.toString(16); 9647 return t4.length < 2 ? "0" + t4 : t4; 9648 }; 9649 var h2 = function(r4) { 9650 var t4 = r4.r, n3 = r4.g, e3 = r4.b, u3 = r4.a, a3 = Math.max(t4, n3, e3), o4 = a3 - Math.min(t4, n3, e3), i3 = o4 ? a3 === t4 ? (n3 - e3) / o4 : a3 === n3 ? 2 + (e3 - t4) / o4 : 4 + (t4 - n3) / o4 : 0; 9651 return { h: 60 * (i3 < 0 ? i3 + 6 : i3), s: a3 ? o4 / a3 * 100 : 0, v: a3 / 255 * 100, a: u3 }; 9652 }; 9653 var b2 = function(r4) { 9654 var t4 = r4.h, n3 = r4.s, e3 = r4.v, u3 = r4.a; 9655 t4 = t4 / 360 * 6, n3 /= 100, e3 /= 100; 9656 var a3 = Math.floor(t4), o4 = e3 * (1 - n3), i3 = e3 * (1 - (t4 - a3) * n3), s3 = e3 * (1 - (1 - t4 + a3) * n3), h3 = a3 % 6; 9657 return { r: 255 * [e3, i3, o4, o4, s3, e3][h3], g: 255 * [s3, e3, e3, i3, o4, o4][h3], b: 255 * [o4, o4, s3, e3, e3, i3][h3], a: u3 }; 9658 }; 9659 var g2 = function(r4) { 9660 return { h: u2(r4.h), s: e2(r4.s, 0, 100), l: e2(r4.l, 0, 100), a: e2(r4.a) }; 9661 }; 9662 var d2 = function(r4) { 9663 return { h: n2(r4.h), s: n2(r4.s), l: n2(r4.l), a: n2(r4.a, 3) }; 9664 }; 9665 var f2 = function(r4) { 9666 return b2((n3 = (t4 = r4).s, { h: t4.h, s: (n3 *= ((e3 = t4.l) < 50 ? e3 : 100 - e3) / 100) > 0 ? 2 * n3 / (e3 + n3) * 100 : 0, v: e3 + n3, a: t4.a })); 9667 var t4, n3, e3; 9668 }; 9669 var c = function(r4) { 9670 return { h: (t4 = h2(r4)).h, s: (u3 = (200 - (n3 = t4.s)) * (e3 = t4.v) / 100) > 0 && u3 < 200 ? n3 * e3 / 100 / (u3 <= 100 ? u3 : 200 - u3) * 100 : 0, l: u3 / 2, a: t4.a }; 9671 var t4, n3, e3, u3; 9672 }; 9673 var l2 = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i; 9674 var p3 = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i; 9675 var v2 = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i; 9676 var m = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i; 9677 var y2 = { string: [[function(r4) { 9678 var t4 = i2.exec(r4); 9679 return t4 ? (r4 = t4[1]).length <= 4 ? { r: parseInt(r4[0] + r4[0], 16), g: parseInt(r4[1] + r4[1], 16), b: parseInt(r4[2] + r4[2], 16), a: 4 === r4.length ? n2(parseInt(r4[3] + r4[3], 16) / 255, 2) : 1 } : 6 === r4.length || 8 === r4.length ? { r: parseInt(r4.substr(0, 2), 16), g: parseInt(r4.substr(2, 2), 16), b: parseInt(r4.substr(4, 2), 16), a: 8 === r4.length ? n2(parseInt(r4.substr(6, 2), 16) / 255, 2) : 1 } : null : null; 9680 }, "hex"], [function(r4) { 9681 var t4 = v2.exec(r4) || m.exec(r4); 9682 return t4 ? t4[2] !== t4[4] || t4[4] !== t4[6] ? null : a2({ r: Number(t4[1]) / (t4[2] ? 100 / 255 : 1), g: Number(t4[3]) / (t4[4] ? 100 / 255 : 1), b: Number(t4[5]) / (t4[6] ? 100 / 255 : 1), a: void 0 === t4[7] ? 1 : Number(t4[7]) / (t4[8] ? 100 : 1) }) : null; 9683 }, "rgb"], [function(t4) { 9684 var n3 = l2.exec(t4) || p3.exec(t4); 9685 if (!n3) return null; 9686 var e3, u3, a3 = g2({ h: (e3 = n3[1], u3 = n3[2], void 0 === u3 && (u3 = "deg"), Number(e3) * (r3[u3] || 1)), s: Number(n3[3]), l: Number(n3[4]), a: void 0 === n3[5] ? 1 : Number(n3[5]) / (n3[6] ? 100 : 1) }); 9687 return f2(a3); 9688 }, "hsl"]], object: [[function(r4) { 9689 var n3 = r4.r, e3 = r4.g, u3 = r4.b, o4 = r4.a, i3 = void 0 === o4 ? 1 : o4; 9690 return t2(n3) && t2(e3) && t2(u3) ? a2({ r: Number(n3), g: Number(e3), b: Number(u3), a: Number(i3) }) : null; 9691 }, "rgb"], [function(r4) { 9692 var n3 = r4.h, e3 = r4.s, u3 = r4.l, a3 = r4.a, o4 = void 0 === a3 ? 1 : a3; 9693 if (!t2(n3) || !t2(e3) || !t2(u3)) return null; 9694 var i3 = g2({ h: Number(n3), s: Number(e3), l: Number(u3), a: Number(o4) }); 9695 return f2(i3); 9696 }, "hsl"], [function(r4) { 9697 var n3 = r4.h, a3 = r4.s, o4 = r4.v, i3 = r4.a, s3 = void 0 === i3 ? 1 : i3; 9698 if (!t2(n3) || !t2(a3) || !t2(o4)) return null; 9699 var h3 = (function(r5) { 9700 return { h: u2(r5.h), s: e2(r5.s, 0, 100), v: e2(r5.v, 0, 100), a: e2(r5.a) }; 9701 })({ h: Number(n3), s: Number(a3), v: Number(o4), a: Number(s3) }); 9702 return b2(h3); 9703 }, "hsv"]] }; 9704 var N2 = function(r4, t4) { 9705 for (var n3 = 0; n3 < t4.length; n3++) { 9706 var e3 = t4[n3][0](r4); 9707 if (e3) return [e3, t4[n3][1]]; 9708 } 9709 return [null, void 0]; 9710 }; 9711 var x = function(r4) { 9712 return "string" == typeof r4 ? N2(r4.trim(), y2.string) : "object" == typeof r4 && null !== r4 ? N2(r4, y2.object) : [null, void 0]; 9713 }; 9714 var M = function(r4, t4) { 9715 var n3 = c(r4); 9716 return { h: n3.h, s: e2(n3.s + 100 * t4, 0, 100), l: n3.l, a: n3.a }; 9717 }; 9718 var H = function(r4) { 9719 return (299 * r4.r + 587 * r4.g + 114 * r4.b) / 1e3 / 255; 9720 }; 9721 var $ = function(r4, t4) { 9722 var n3 = c(r4); 9723 return { h: n3.h, s: n3.s, l: e2(n3.l + 100 * t4, 0, 100), a: n3.a }; 9724 }; 9725 var j = (function() { 9726 function r4(r5) { 9727 this.parsed = x(r5)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 }; 9728 } 9729 return r4.prototype.isValid = function() { 9730 return null !== this.parsed; 9731 }, r4.prototype.brightness = function() { 9732 return n2(H(this.rgba), 2); 9733 }, r4.prototype.isDark = function() { 9734 return H(this.rgba) < 0.5; 9735 }, r4.prototype.isLight = function() { 9736 return H(this.rgba) >= 0.5; 9737 }, r4.prototype.toHex = function() { 9738 return r5 = o2(this.rgba), t4 = r5.r, e3 = r5.g, u3 = r5.b, i3 = (a3 = r5.a) < 1 ? s2(n2(255 * a3)) : "", "#" + s2(t4) + s2(e3) + s2(u3) + i3; 9739 var r5, t4, e3, u3, a3, i3; 9740 }, r4.prototype.toRgb = function() { 9741 return o2(this.rgba); 9742 }, r4.prototype.toRgbString = function() { 9743 return r5 = o2(this.rgba), t4 = r5.r, n3 = r5.g, e3 = r5.b, (u3 = r5.a) < 1 ? "rgba(" + t4 + ", " + n3 + ", " + e3 + ", " + u3 + ")" : "rgb(" + t4 + ", " + n3 + ", " + e3 + ")"; 9744 var r5, t4, n3, e3, u3; 9745 }, r4.prototype.toHsl = function() { 9746 return d2(c(this.rgba)); 9747 }, r4.prototype.toHslString = function() { 9748 return r5 = d2(c(this.rgba)), t4 = r5.h, n3 = r5.s, e3 = r5.l, (u3 = r5.a) < 1 ? "hsla(" + t4 + ", " + n3 + "%, " + e3 + "%, " + u3 + ")" : "hsl(" + t4 + ", " + n3 + "%, " + e3 + "%)"; 9749 var r5, t4, n3, e3, u3; 9750 }, r4.prototype.toHsv = function() { 9751 return r5 = h2(this.rgba), { h: n2(r5.h), s: n2(r5.s), v: n2(r5.v), a: n2(r5.a, 3) }; 9752 var r5; 9753 }, r4.prototype.invert = function() { 9754 return w2({ r: 255 - (r5 = this.rgba).r, g: 255 - r5.g, b: 255 - r5.b, a: r5.a }); 9755 var r5; 9756 }, r4.prototype.saturate = function(r5) { 9757 return void 0 === r5 && (r5 = 0.1), w2(M(this.rgba, r5)); 9758 }, r4.prototype.desaturate = function(r5) { 9759 return void 0 === r5 && (r5 = 0.1), w2(M(this.rgba, -r5)); 9760 }, r4.prototype.grayscale = function() { 9761 return w2(M(this.rgba, -1)); 9762 }, r4.prototype.lighten = function(r5) { 9763 return void 0 === r5 && (r5 = 0.1), w2($(this.rgba, r5)); 9764 }, r4.prototype.darken = function(r5) { 9765 return void 0 === r5 && (r5 = 0.1), w2($(this.rgba, -r5)); 9766 }, r4.prototype.rotate = function(r5) { 9767 return void 0 === r5 && (r5 = 15), this.hue(this.hue() + r5); 9768 }, r4.prototype.alpha = function(r5) { 9769 return "number" == typeof r5 ? w2({ r: (t4 = this.rgba).r, g: t4.g, b: t4.b, a: r5 }) : n2(this.rgba.a, 3); 9770 var t4; 9771 }, r4.prototype.hue = function(r5) { 9772 var t4 = c(this.rgba); 9773 return "number" == typeof r5 ? w2({ h: r5, s: t4.s, l: t4.l, a: t4.a }) : n2(t4.h); 9774 }, r4.prototype.isEqual = function(r5) { 9775 return this.toHex() === w2(r5).toHex(); 9776 }, r4; 9777 })(); 9778 var w2 = function(r4) { 9779 return r4 instanceof j ? r4 : new j(r4); 9780 }; 9781 var S2 = []; 9782 var k = function(r4) { 9783 r4.forEach(function(r5) { 9784 S2.indexOf(r5) < 0 && (r5(j, y2), S2.push(r5)); 9785 }); 9786 }; 9787 9788 // packages/global-styles-engine/build-module/utils/duotone.js 9789 function getValuesFromColors(colors = []) { 9790 const values = { 9791 r: [], 9792 g: [], 9793 b: [], 9794 a: [] 9795 }; 9796 colors.forEach((color) => { 9797 const rgbColor = w2(color).toRgb(); 9798 values.r.push(rgbColor.r / 255); 9799 values.g.push(rgbColor.g / 255); 9800 values.b.push(rgbColor.b / 255); 9801 values.a.push(rgbColor.a); 9802 }); 9803 return values; 9804 } 9805 function getDuotoneFilter(id, colors) { 9806 const values = getValuesFromColors(colors); 9807 return ` 9808 <svg 9809 xmlns:xlink="http://www.w3.org/1999/xlink" 9810 viewBox="0 0 0 0" 9811 width="0" 9812 height="0" 9813 focusable="false" 9814 role="none" 9815 aria-hidden="true" 9816 style="visibility: hidden; position: absolute; left: -9999px; overflow: hidden;" 9817 > 9818 <defs> 9819 <filter id="$id}"> 9820 <!-- 9821 Use sRGB instead of linearRGB so transparency looks correct. 9822 Use perceptual brightness to convert to grayscale. 9823 --> 9824 <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> 9825 <!-- Use sRGB instead of linearRGB to be consistent with how CSS gradients work. --> 9826 <feComponentTransfer color-interpolation-filters="sRGB"> 9827 <feFuncR type="table" tableValues="$values.r.join(" ")}"></feFuncR> 9828 <feFuncG type="table" tableValues="$values.g.join(" ")}"></feFuncG> 9829 <feFuncB type="table" tableValues="$values.b.join(" ")}"></feFuncB> 9830 <feFuncA type="table" tableValues="$values.a.join(" ")}"></feFuncA> 9831 </feComponentTransfer> 9832 <!-- Re-mask the image with the original transparency since the feColorMatrix above loses that information. --> 9833 <feComposite in2="SourceGraphic" operator="in"></feComposite> 9834 </filter> 9835 </defs> 9836 </svg>`; 9837 } 9838 9839 // packages/global-styles-engine/build-module/utils/string.js 9840 function kebabCase(str) { 9841 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(); 9842 } 9843 9844 // packages/global-styles-engine/build-module/utils/spacing.js 9845 function getSpacingPresetCssVar(value) { 9846 if (!value) { 9847 return; 9848 } 9849 const slug = value.match(/var:preset\|spacing\|(.+)/); 9850 if (!slug) { 9851 return value; 9852 } 9853 return `var(--wp--preset--spacing--$slug[1]})`; 9854 } 9855 9856 // packages/global-styles-engine/build-module/utils/gap.js 9857 function getGapBoxControlValueFromStyle(blockGapValue) { 9858 if (!blockGapValue) { 9859 return null; 9860 } 9861 const isValueString = typeof blockGapValue === "string"; 9862 return { 9863 top: isValueString ? blockGapValue : blockGapValue?.top, 9864 left: isValueString ? blockGapValue : blockGapValue?.left 9865 }; 9866 } 9867 function getGapCSSValue(blockGapValue, defaultValue = "0") { 9868 const blockGapBoxControlValue = getGapBoxControlValueFromStyle(blockGapValue); 9869 if (!blockGapBoxControlValue) { 9870 return null; 9871 } 9872 const row = getSpacingPresetCssVar(blockGapBoxControlValue?.top) || defaultValue; 9873 const column = getSpacingPresetCssVar(blockGapBoxControlValue?.left) || defaultValue; 9874 return row === column ? row : `$row} $column}`; 9875 } 9876 9877 // packages/global-styles-engine/build-module/utils/background.js 9878 var BACKGROUND_BLOCK_DEFAULT_VALUES = { 9879 backgroundSize: "cover", 9880 backgroundPosition: "50% 50%" 9881 // used only when backgroundSize is 'contain'. 9882 }; 9883 function setBackgroundStyleDefaults(backgroundStyle) { 9884 if (!backgroundStyle || // @ts-expect-error 9885 !backgroundStyle?.backgroundImage?.url) { 9886 return; 9887 } 9888 let backgroundStylesWithDefaults; 9889 if (!backgroundStyle?.backgroundSize) { 9890 backgroundStylesWithDefaults = { 9891 backgroundSize: BACKGROUND_BLOCK_DEFAULT_VALUES.backgroundSize 9892 }; 9893 } 9894 if ("contain" === backgroundStyle?.backgroundSize && !backgroundStyle?.backgroundPosition) { 9895 backgroundStylesWithDefaults = { 9896 backgroundPosition: BACKGROUND_BLOCK_DEFAULT_VALUES.backgroundPosition 9897 }; 9898 } 9899 return backgroundStylesWithDefaults; 9900 } 9901 9902 // packages/global-styles-engine/build-module/utils/layout.js 9903 var LAYOUT_DEFINITIONS = { 9904 default: { 9905 name: "default", 9906 slug: "flow", 9907 className: "is-layout-flow", 9908 baseStyles: [ 9909 { 9910 selector: " > .alignleft", 9911 rules: { 9912 float: "left", 9913 "margin-inline-start": "0", 9914 "margin-inline-end": "2em" 9915 } 9916 }, 9917 { 9918 selector: " > .alignright", 9919 rules: { 9920 float: "right", 9921 "margin-inline-start": "2em", 9922 "margin-inline-end": "0" 9923 } 9924 }, 9925 { 9926 selector: " > .aligncenter", 9927 rules: { 9928 "margin-left": "auto !important", 9929 "margin-right": "auto !important" 9930 } 9931 } 9932 ], 9933 spacingStyles: [ 9934 { 9935 selector: " > :first-child", 9936 rules: { 9937 "margin-block-start": "0" 9938 } 9939 }, 9940 { 9941 selector: " > :last-child", 9942 rules: { 9943 "margin-block-end": "0" 9944 } 9945 }, 9946 { 9947 selector: " > *", 9948 rules: { 9949 "margin-block-start": null, 9950 "margin-block-end": "0" 9951 } 9952 } 9953 ] 9954 }, 9955 constrained: { 9956 name: "constrained", 9957 slug: "constrained", 9958 className: "is-layout-constrained", 9959 baseStyles: [ 9960 { 9961 selector: " > .alignleft", 9962 rules: { 9963 float: "left", 9964 "margin-inline-start": "0", 9965 "margin-inline-end": "2em" 9966 } 9967 }, 9968 { 9969 selector: " > .alignright", 9970 rules: { 9971 float: "right", 9972 "margin-inline-start": "2em", 9973 "margin-inline-end": "0" 9974 } 9975 }, 9976 { 9977 selector: " > .aligncenter", 9978 rules: { 9979 "margin-left": "auto !important", 9980 "margin-right": "auto !important" 9981 } 9982 }, 9983 { 9984 selector: " > :where(:not(.alignleft):not(.alignright):not(.alignfull))", 9985 rules: { 9986 "max-width": "var(--wp--style--global--content-size)", 9987 "margin-left": "auto !important", 9988 "margin-right": "auto !important" 9989 } 9990 }, 9991 { 9992 selector: " > .alignwide", 9993 rules: { 9994 "max-width": "var(--wp--style--global--wide-size)" 9995 } 9996 } 9997 ], 9998 spacingStyles: [ 9999 { 10000 selector: " > :first-child", 10001 rules: { 10002 "margin-block-start": "0" 10003 } 10004 }, 10005 { 10006 selector: " > :last-child", 10007 rules: { 10008 "margin-block-end": "0" 10009 } 10010 }, 10011 { 10012 selector: " > *", 10013 rules: { 10014 "margin-block-start": null, 10015 "margin-block-end": "0" 10016 } 10017 } 10018 ] 10019 }, 10020 flex: { 10021 name: "flex", 10022 slug: "flex", 10023 className: "is-layout-flex", 10024 displayMode: "flex", 10025 baseStyles: [ 10026 { 10027 selector: "", 10028 rules: { 10029 "flex-wrap": "wrap", 10030 "align-items": "center" 10031 } 10032 }, 10033 { 10034 selector: " > :is(*, div)", 10035 // :is(*, div) instead of just * increases the specificity by 001. 10036 rules: { 10037 margin: "0" 10038 } 10039 } 10040 ], 10041 spacingStyles: [ 10042 { 10043 selector: "", 10044 rules: { 10045 gap: null 10046 } 10047 } 10048 ] 10049 }, 10050 grid: { 10051 name: "grid", 10052 slug: "grid", 10053 className: "is-layout-grid", 10054 displayMode: "grid", 10055 baseStyles: [ 10056 { 10057 selector: " > :is(*, div)", 10058 // :is(*, div) instead of just * increases the specificity by 001. 10059 rules: { 10060 margin: "0" 10061 } 10062 } 10063 ], 10064 spacingStyles: [ 10065 { 10066 selector: "", 10067 rules: { 10068 gap: null 10069 } 10070 } 10071 ] 10072 } 10073 }; 10074 10075 // packages/global-styles-engine/build-module/core/render.js 10076 var ELEMENT_CLASS_NAMES = { 10077 button: "wp-element-button", 10078 caption: "wp-element-caption" 10079 }; 10080 var BLOCK_SUPPORT_FEATURE_LEVEL_SELECTORS = { 10081 __experimentalBorder: "border", 10082 color: "color", 10083 dimensions: "dimensions", 10084 spacing: "spacing", 10085 typography: "typography" 10086 }; 10087 function getPresetsDeclarations(blockPresets = {}, mergedSettings) { 10088 return PRESET_METADATA.reduce( 10089 (declarations, { path, valueKey, valueFunc, cssVarInfix }) => { 10090 const presetByOrigin = getValueFromObjectPath( 10091 blockPresets, 10092 path, 10093 [] 10094 ); 10095 ["default", "theme", "custom"].forEach((origin) => { 10096 if (presetByOrigin[origin]) { 10097 presetByOrigin[origin].forEach((value) => { 10098 if (valueKey && !valueFunc) { 10099 declarations.push( 10100 `--wp--preset--$cssVarInfix}--$kebabCase( 10101 value.slug 10102 )}: $value[valueKey]}` 10103 ); 10104 } else if (valueFunc && typeof valueFunc === "function") { 10105 declarations.push( 10106 `--wp--preset--$cssVarInfix}--$kebabCase( 10107 value.slug 10108 )}: $valueFunc(value, mergedSettings)}` 10109 ); 10110 } 10111 }); 10112 } 10113 }); 10114 return declarations; 10115 }, 10116 [] 10117 ); 10118 } 10119 function getPresetsClasses(blockSelector = "*", blockPresets = {}) { 10120 return PRESET_METADATA.reduce( 10121 (declarations, { path, cssVarInfix, classes }) => { 10122 if (!classes) { 10123 return declarations; 10124 } 10125 const presetByOrigin = getValueFromObjectPath( 10126 blockPresets, 10127 path, 10128 [] 10129 ); 10130 ["default", "theme", "custom"].forEach((origin) => { 10131 if (presetByOrigin[origin]) { 10132 presetByOrigin[origin].forEach( 10133 ({ slug }) => { 10134 classes.forEach( 10135 ({ 10136 classSuffix, 10137 propertyName 10138 }) => { 10139 const classSelectorToUse = `.has-$kebabCase( 10140 slug 10141 )}-$classSuffix}`; 10142 const selectorToUse = blockSelector.split(",").map( 10143 (selector) => `$selector}$classSelectorToUse}` 10144 ).join(","); 10145 const value = `var(--wp--preset--$cssVarInfix}--$kebabCase( 10146 slug 10147 )})`; 10148 declarations += `$selectorToUse}{$propertyName}: $value} !important;}`; 10149 } 10150 ); 10151 } 10152 ); 10153 } 10154 }); 10155 return declarations; 10156 }, 10157 "" 10158 ); 10159 } 10160 function getPresetsSvgFilters(blockPresets = {}) { 10161 return PRESET_METADATA.filter( 10162 // Duotone are the only type of filters for now. 10163 (metadata) => metadata.path.at(-1) === "duotone" 10164 ).flatMap((metadata) => { 10165 const presetByOrigin = getValueFromObjectPath( 10166 blockPresets, 10167 metadata.path, 10168 {} 10169 ); 10170 return ["default", "theme"].filter((origin) => presetByOrigin[origin]).flatMap( 10171 (origin) => presetByOrigin[origin].map( 10172 (preset) => getDuotoneFilter( 10173 `wp-duotone-$preset.slug}`, 10174 preset.colors 10175 ) 10176 ) 10177 ).join(""); 10178 }); 10179 } 10180 function flattenTree(input = {}, prefix, token) { 10181 let result = []; 10182 Object.keys(input).forEach((key) => { 10183 const newKey = prefix + kebabCase(key.replace("/", "-")); 10184 const newLeaf = input[key]; 10185 if (newLeaf instanceof Object) { 10186 const newPrefix = newKey + token; 10187 result = [...result, ...flattenTree(newLeaf, newPrefix, token)]; 10188 } else { 10189 result.push(`$newKey}: $newLeaf}`); 10190 } 10191 }); 10192 return result; 10193 } 10194 function concatFeatureVariationSelectorString(featureSelector, styleVariationSelector) { 10195 const featureSelectors = featureSelector.split(","); 10196 const combinedSelectors = []; 10197 featureSelectors.forEach((selector) => { 10198 combinedSelectors.push( 10199 `$styleVariationSelector.trim()}$selector.trim()}` 10200 ); 10201 }); 10202 return combinedSelectors.join(", "); 10203 } 10204 var getFeatureDeclarations = (selectors, styles) => { 10205 const declarations = {}; 10206 Object.entries(selectors).forEach(([feature, selector]) => { 10207 if (feature === "root" || !styles?.[feature]) { 10208 return; 10209 } 10210 const isShorthand = typeof selector === "string"; 10211 if (!isShorthand && typeof selector === "object" && selector !== null) { 10212 Object.entries(selector).forEach( 10213 ([subfeature, subfeatureSelector]) => { 10214 if (subfeature === "root" || !styles?.[feature][subfeature]) { 10215 return; 10216 } 10217 const subfeatureStyles = { 10218 [feature]: { 10219 [subfeature]: styles[feature][subfeature] 10220 } 10221 }; 10222 const newDeclarations = getStylesDeclarations(subfeatureStyles); 10223 declarations[subfeatureSelector] = [ 10224 ...declarations[subfeatureSelector] || [], 10225 ...newDeclarations 10226 ]; 10227 delete styles[feature][subfeature]; 10228 } 10229 ); 10230 } 10231 if (isShorthand || typeof selector === "object" && selector !== null && "root" in selector) { 10232 const featureSelector = isShorthand ? selector : selector.root; 10233 const featureStyles = { [feature]: styles[feature] }; 10234 const newDeclarations = getStylesDeclarations(featureStyles); 10235 declarations[featureSelector] = [ 10236 ...declarations[featureSelector] || [], 10237 ...newDeclarations 10238 ]; 10239 delete styles[feature]; 10240 } 10241 }); 10242 return declarations; 10243 }; 10244 function getStylesDeclarations(blockStyles = {}, selector = "", useRootPaddingAlign, tree = {}, disableRootPadding = false) { 10245 const isRoot = ROOT_BLOCK_SELECTOR === selector; 10246 const output = Object.entries( 10247 import_blocks8.__EXPERIMENTAL_STYLE_PROPERTY 10248 ).reduce( 10249 (declarations, [key, { value, properties, useEngine, rootOnly }]) => { 10250 if (rootOnly && !isRoot) { 10251 return declarations; 10252 } 10253 const pathToValue = value; 10254 if (pathToValue[0] === "elements" || useEngine) { 10255 return declarations; 10256 } 10257 const styleValue = getValueFromObjectPath( 10258 blockStyles, 10259 pathToValue 10260 ); 10261 if (key === "--wp--style--root--padding" && (typeof styleValue === "string" || !useRootPaddingAlign)) { 10262 return declarations; 10263 } 10264 if (properties && typeof styleValue !== "string") { 10265 Object.entries(properties).forEach((entry) => { 10266 const [name2, prop] = entry; 10267 if (!getValueFromObjectPath(styleValue, [prop], false)) { 10268 return; 10269 } 10270 const cssProperty = name2.startsWith("--") ? name2 : kebabCase(name2); 10271 declarations.push( 10272 `$cssProperty}: ${(0, import_style_engine2.getCSSValueFromRawStyle)( 10273 getValueFromObjectPath(styleValue, [prop]) 10274 )}` 10275 ); 10276 }); 10277 } else if (getValueFromObjectPath(blockStyles, pathToValue, false)) { 10278 const cssProperty = key.startsWith("--") ? key : kebabCase(key); 10279 declarations.push( 10280 `$cssProperty}: ${(0, import_style_engine2.getCSSValueFromRawStyle)( 10281 getValueFromObjectPath(blockStyles, pathToValue) 10282 )}` 10283 ); 10284 } 10285 return declarations; 10286 }, 10287 [] 10288 ); 10289 if (!!blockStyles.background) { 10290 if (blockStyles.background?.backgroundImage) { 10291 blockStyles.background.backgroundImage = getResolvedValue( 10292 blockStyles.background.backgroundImage, 10293 tree 10294 ); 10295 } 10296 if (!isRoot && !!blockStyles.background?.backgroundImage?.id) { 10297 blockStyles = { 10298 ...blockStyles, 10299 background: { 10300 ...blockStyles.background, 10301 ...setBackgroundStyleDefaults(blockStyles.background) 10302 } 10303 }; 10304 } 10305 } 10306 const extraRules = (0, import_style_engine2.getCSSRules)(blockStyles); 10307 extraRules.forEach((rule) => { 10308 if (isRoot && (useRootPaddingAlign || disableRootPadding) && rule.key.startsWith("padding")) { 10309 return; 10310 } 10311 const cssProperty = rule.key.startsWith("--") ? rule.key : kebabCase(rule.key); 10312 let ruleValue = getResolvedValue(rule.value, tree); 10313 if (cssProperty === "font-size") { 10314 ruleValue = getTypographyFontSizeValue( 10315 { name: "", slug: "", size: ruleValue }, 10316 tree?.settings 10317 ); 10318 } 10319 if (cssProperty === "aspect-ratio") { 10320 output.push("min-height: unset"); 10321 } 10322 output.push(`$cssProperty}: $ruleValue}`); 10323 }); 10324 return output; 10325 } 10326 function getLayoutStyles({ 10327 layoutDefinitions = LAYOUT_DEFINITIONS, 10328 style, 10329 selector, 10330 hasBlockGapSupport, 10331 hasFallbackGapSupport, 10332 fallbackGapValue 10333 }) { 10334 let ruleset = ""; 10335 let gapValue = hasBlockGapSupport ? getGapCSSValue(style?.spacing?.blockGap) : ""; 10336 if (hasFallbackGapSupport) { 10337 if (selector === ROOT_BLOCK_SELECTOR) { 10338 gapValue = !gapValue ? "0.5em" : gapValue; 10339 } else if (!hasBlockGapSupport && fallbackGapValue) { 10340 gapValue = fallbackGapValue; 10341 } 10342 } 10343 if (gapValue && layoutDefinitions) { 10344 Object.values(layoutDefinitions).forEach( 10345 ({ className, name: name2, spacingStyles }) => { 10346 if (!hasBlockGapSupport && "flex" !== name2 && "grid" !== name2) { 10347 return; 10348 } 10349 if (spacingStyles?.length) { 10350 spacingStyles.forEach((spacingStyle) => { 10351 const declarations = []; 10352 if (spacingStyle.rules) { 10353 Object.entries(spacingStyle.rules).forEach( 10354 ([cssProperty, cssValue]) => { 10355 declarations.push( 10356 `$cssProperty}: $cssValue ? cssValue : gapValue}` 10357 ); 10358 } 10359 ); 10360 } 10361 if (declarations.length) { 10362 let combinedSelector = ""; 10363 if (!hasBlockGapSupport) { 10364 combinedSelector = selector === ROOT_BLOCK_SELECTOR ? `:where(.$className}$spacingStyle?.selector || ""})` : `:where($selector}.$className}$spacingStyle?.selector || ""})`; 10365 } else { 10366 combinedSelector = selector === ROOT_BLOCK_SELECTOR ? `:root :where(.$className})$spacingStyle?.selector || ""}` : `:root :where($selector}-$className})$spacingStyle?.selector || ""}`; 10367 } 10368 ruleset += `$combinedSelector} { $declarations.join( 10369 "; " 10370 )}; }`; 10371 } 10372 }); 10373 } 10374 } 10375 ); 10376 if (selector === ROOT_BLOCK_SELECTOR && hasBlockGapSupport) { 10377 ruleset += `$ROOT_CSS_PROPERTIES_SELECTOR} { --wp--style--block-gap: $gapValue}; }`; 10378 } 10379 } 10380 if (selector === ROOT_BLOCK_SELECTOR && layoutDefinitions) { 10381 const validDisplayModes = ["block", "flex", "grid"]; 10382 Object.values(layoutDefinitions).forEach( 10383 ({ className, displayMode, baseStyles }) => { 10384 if (displayMode && validDisplayModes.includes(displayMode)) { 10385 ruleset += `$selector} .$className} { display:$displayMode}; }`; 10386 } 10387 if (baseStyles?.length) { 10388 baseStyles.forEach((baseStyle) => { 10389 const declarations = []; 10390 if (baseStyle.rules) { 10391 Object.entries(baseStyle.rules).forEach( 10392 ([cssProperty, cssValue]) => { 10393 declarations.push( 10394 `$cssProperty}: $cssValue}` 10395 ); 10396 } 10397 ); 10398 } 10399 if (declarations.length) { 10400 const combinedSelector = `.$className}$baseStyle?.selector || ""}`; 10401 ruleset += `$combinedSelector} { $declarations.join( 10402 "; " 10403 )}; }`; 10404 } 10405 }); 10406 } 10407 } 10408 ); 10409 } 10410 return ruleset; 10411 } 10412 var STYLE_KEYS = [ 10413 "border", 10414 "color", 10415 "dimensions", 10416 "spacing", 10417 "typography", 10418 "filter", 10419 "outline", 10420 "shadow", 10421 "background" 10422 ]; 10423 function pickStyleKeys(treeToPickFrom) { 10424 if (!treeToPickFrom) { 10425 return {}; 10426 } 10427 const entries = Object.entries(treeToPickFrom); 10428 const pickedEntries = entries.filter( 10429 ([key]) => STYLE_KEYS.includes(key) 10430 ); 10431 const clonedEntries = pickedEntries.map(([key, style]) => [ 10432 key, 10433 JSON.parse(JSON.stringify(style)) 10434 ]); 10435 return Object.fromEntries(clonedEntries); 10436 } 10437 var getNodesWithStyles = (tree, blockSelectors) => { 10438 const nodes = []; 10439 if (!tree?.styles) { 10440 return nodes; 10441 } 10442 const styles = pickStyleKeys(tree.styles); 10443 if (styles) { 10444 nodes.push({ 10445 styles, 10446 selector: ROOT_BLOCK_SELECTOR, 10447 // Root selector (body) styles should not be wrapped in `:root where()` to keep 10448 // specificity at (0,0,1) and maintain backwards compatibility. 10449 skipSelectorWrapper: true 10450 }); 10451 } 10452 Object.entries(import_blocks8.__EXPERIMENTAL_ELEMENTS).forEach(([name2, selector]) => { 10453 if (tree.styles?.elements?.[name2]) { 10454 nodes.push({ 10455 styles: tree.styles?.elements?.[name2] ?? {}, 10456 selector, 10457 // Top level elements that don't use a class name should not receive the 10458 // `:root :where()` wrapper to maintain backwards compatibility. 10459 skipSelectorWrapper: !ELEMENT_CLASS_NAMES[name2] 10460 }); 10461 } 10462 }); 10463 Object.entries(tree.styles?.blocks ?? {}).forEach( 10464 ([blockName, node]) => { 10465 const blockStyles = pickStyleKeys(node); 10466 const typedNode = node; 10467 if (typedNode?.variations) { 10468 const variations = {}; 10469 Object.entries(typedNode.variations).forEach( 10470 ([variationName, variation]) => { 10471 const typedVariation = variation; 10472 variations[variationName] = pickStyleKeys(typedVariation); 10473 if (typedVariation?.css) { 10474 variations[variationName].css = typedVariation.css; 10475 } 10476 const variationSelector = typeof blockSelectors !== "string" ? blockSelectors[blockName]?.styleVariationSelectors?.[variationName] : void 0; 10477 Object.entries( 10478 typedVariation?.elements ?? {} 10479 ).forEach(([element, elementStyles]) => { 10480 if (elementStyles && import_blocks8.__EXPERIMENTAL_ELEMENTS[element]) { 10481 nodes.push({ 10482 styles: elementStyles, 10483 selector: scopeSelector( 10484 variationSelector, 10485 import_blocks8.__EXPERIMENTAL_ELEMENTS[element] 10486 ) 10487 }); 10488 } 10489 }); 10490 Object.entries(typedVariation?.blocks ?? {}).forEach( 10491 ([ 10492 variationBlockName, 10493 variationBlockStyles 10494 ]) => { 10495 const variationBlockSelector = typeof blockSelectors !== "string" ? scopeSelector( 10496 variationSelector, 10497 blockSelectors[variationBlockName]?.selector 10498 ) : void 0; 10499 const variationDuotoneSelector = typeof blockSelectors !== "string" ? scopeSelector( 10500 variationSelector, 10501 blockSelectors[variationBlockName]?.duotoneSelector 10502 ) : void 0; 10503 const variationFeatureSelectors = typeof blockSelectors !== "string" ? scopeFeatureSelectors( 10504 variationSelector, 10505 blockSelectors[variationBlockName]?.featureSelectors ?? {} 10506 ) : void 0; 10507 const variationBlockStyleNodes = pickStyleKeys(variationBlockStyles); 10508 if (variationBlockStyles?.css) { 10509 variationBlockStyleNodes.css = variationBlockStyles.css; 10510 } 10511 if (!variationBlockSelector || typeof blockSelectors === "string") { 10512 return; 10513 } 10514 nodes.push({ 10515 selector: variationBlockSelector, 10516 duotoneSelector: variationDuotoneSelector, 10517 featureSelectors: variationFeatureSelectors, 10518 fallbackGapValue: blockSelectors[variationBlockName]?.fallbackGapValue, 10519 hasLayoutSupport: blockSelectors[variationBlockName]?.hasLayoutSupport, 10520 styles: variationBlockStyleNodes 10521 }); 10522 Object.entries( 10523 variationBlockStyles.elements ?? {} 10524 ).forEach( 10525 ([ 10526 variationBlockElement, 10527 variationBlockElementStyles 10528 ]) => { 10529 if (variationBlockElementStyles && import_blocks8.__EXPERIMENTAL_ELEMENTS[variationBlockElement]) { 10530 nodes.push({ 10531 styles: variationBlockElementStyles, 10532 selector: scopeSelector( 10533 variationBlockSelector, 10534 import_blocks8.__EXPERIMENTAL_ELEMENTS[variationBlockElement] 10535 ) 10536 }); 10537 } 10538 } 10539 ); 10540 } 10541 ); 10542 } 10543 ); 10544 blockStyles.variations = variations; 10545 } 10546 if (typeof blockSelectors !== "string" && blockSelectors?.[blockName]?.selector) { 10547 nodes.push({ 10548 duotoneSelector: blockSelectors[blockName].duotoneSelector, 10549 fallbackGapValue: blockSelectors[blockName].fallbackGapValue, 10550 hasLayoutSupport: blockSelectors[blockName].hasLayoutSupport, 10551 selector: blockSelectors[blockName].selector, 10552 styles: blockStyles, 10553 featureSelectors: blockSelectors[blockName].featureSelectors, 10554 styleVariationSelectors: blockSelectors[blockName].styleVariationSelectors 10555 }); 10556 } 10557 Object.entries(typedNode?.elements ?? {}).forEach( 10558 ([elementName, value]) => { 10559 if (typeof blockSelectors !== "string" && value && blockSelectors?.[blockName] && import_blocks8.__EXPERIMENTAL_ELEMENTS[elementName]) { 10560 nodes.push({ 10561 styles: value, 10562 selector: blockSelectors[blockName]?.selector.split(",").map((sel) => { 10563 const elementSelectors = import_blocks8.__EXPERIMENTAL_ELEMENTS[elementName].split(","); 10564 return elementSelectors.map( 10565 (elementSelector) => sel + " " + elementSelector 10566 ); 10567 }).join(",") 10568 }); 10569 } 10570 } 10571 ); 10572 } 10573 ); 10574 return nodes; 10575 }; 10576 var getNodesWithSettings = (tree, blockSelectors) => { 10577 const nodes = []; 10578 if (!tree?.settings) { 10579 return nodes; 10580 } 10581 const pickPresets = (treeToPickFrom) => { 10582 let presets2 = {}; 10583 PRESET_METADATA.forEach(({ path }) => { 10584 const value = getValueFromObjectPath(treeToPickFrom, path, false); 10585 if (value !== false) { 10586 presets2 = setImmutably(presets2, path, value); 10587 } 10588 }); 10589 return presets2; 10590 }; 10591 const presets = pickPresets(tree.settings); 10592 const custom = tree.settings?.custom; 10593 if (Object.keys(presets).length > 0 || custom) { 10594 nodes.push({ 10595 presets, 10596 custom, 10597 selector: ROOT_CSS_PROPERTIES_SELECTOR 10598 }); 10599 } 10600 Object.entries(tree.settings?.blocks ?? {}).forEach( 10601 ([blockName, node]) => { 10602 const blockCustom = node.custom; 10603 if (typeof blockSelectors === "string" || !blockSelectors[blockName]) { 10604 return; 10605 } 10606 const blockPresets = pickPresets(node); 10607 if (Object.keys(blockPresets).length > 0 || blockCustom) { 10608 nodes.push({ 10609 presets: blockPresets, 10610 custom: blockCustom, 10611 selector: blockSelectors[blockName]?.selector 10612 }); 10613 } 10614 } 10615 ); 10616 return nodes; 10617 }; 10618 var generateCustomProperties = (tree, blockSelectors) => { 10619 const settings = getNodesWithSettings(tree, blockSelectors); 10620 let ruleset = ""; 10621 settings.forEach(({ presets, custom, selector }) => { 10622 const declarations = tree?.settings ? getPresetsDeclarations(presets, tree?.settings) : []; 10623 const customProps = flattenTree(custom, "--wp--custom--", "--"); 10624 if (customProps.length > 0) { 10625 declarations.push(...customProps); 10626 } 10627 if (declarations.length > 0) { 10628 ruleset += `$selector}{$declarations.join(";")};}`; 10629 } 10630 }); 10631 return ruleset; 10632 }; 10633 var transformToStyles = (tree, blockSelectors, hasBlockGapSupport, hasFallbackGapSupport, disableLayoutStyles = false, disableRootPadding = false, styleOptions = {}) => { 10634 const options = { 10635 blockGap: true, 10636 blockStyles: true, 10637 layoutStyles: true, 10638 marginReset: true, 10639 presets: true, 10640 rootPadding: true, 10641 variationStyles: false, 10642 ...styleOptions 10643 }; 10644 const nodesWithStyles = getNodesWithStyles(tree, blockSelectors); 10645 const nodesWithSettings = getNodesWithSettings(tree, blockSelectors); 10646 const useRootPaddingAlign = tree?.settings?.useRootPaddingAwareAlignments; 10647 const { contentSize, wideSize } = tree?.settings?.layout || {}; 10648 const hasBodyStyles = options.marginReset || options.rootPadding || options.layoutStyles; 10649 let ruleset = ""; 10650 if (options.presets && (contentSize || wideSize)) { 10651 ruleset += `$ROOT_CSS_PROPERTIES_SELECTOR} {`; 10652 ruleset = contentSize ? ruleset + ` --wp--style--global--content-size: $contentSize};` : ruleset; 10653 ruleset = wideSize ? ruleset + ` --wp--style--global--wide-size: $wideSize};` : ruleset; 10654 ruleset += "}"; 10655 } 10656 if (hasBodyStyles) { 10657 ruleset += ":where(body) {margin: 0;"; 10658 if (options.rootPadding && useRootPaddingAlign) { 10659 ruleset += `padding-right: 0; padding-left: 0; padding-top: var(--wp--style--root--padding-top); padding-bottom: var(--wp--style--root--padding-bottom) } 10660 .has-global-padding { padding-right: var(--wp--style--root--padding-right); padding-left: var(--wp--style--root--padding-left); } 10661 .has-global-padding > .alignfull { margin-right: calc(var(--wp--style--root--padding-right) * -1); margin-left: calc(var(--wp--style--root--padding-left) * -1); } 10662 .has-global-padding :where(:not(.alignfull.is-layout-flow) > .has-global-padding:not(.wp-block-block, .alignfull)) { padding-right: 0; padding-left: 0; } 10663 .has-global-padding :where(:not(.alignfull.is-layout-flow) > .has-global-padding:not(.wp-block-block, .alignfull)) > .alignfull { margin-left: 0; margin-right: 0; 10664 `; 10665 } 10666 ruleset += "}"; 10667 } 10668 if (options.blockStyles) { 10669 nodesWithStyles.forEach( 10670 ({ 10671 selector, 10672 duotoneSelector, 10673 styles, 10674 fallbackGapValue, 10675 hasLayoutSupport, 10676 featureSelectors, 10677 styleVariationSelectors, 10678 skipSelectorWrapper 10679 }) => { 10680 if (featureSelectors) { 10681 const featureDeclarations = getFeatureDeclarations( 10682 featureSelectors, 10683 styles 10684 ); 10685 Object.entries(featureDeclarations).forEach( 10686 ([cssSelector, declarations]) => { 10687 if (declarations.length) { 10688 const rules = declarations.join(";"); 10689 ruleset += `:root :where($cssSelector}){$rules};}`; 10690 } 10691 } 10692 ); 10693 } 10694 if (duotoneSelector) { 10695 const duotoneStyles = {}; 10696 if (styles?.filter) { 10697 duotoneStyles.filter = styles.filter; 10698 delete styles.filter; 10699 } 10700 const duotoneDeclarations = getStylesDeclarations(duotoneStyles); 10701 if (duotoneDeclarations.length) { 10702 ruleset += `$duotoneSelector}{$duotoneDeclarations.join( 10703 ";" 10704 )};}`; 10705 } 10706 } 10707 if (!disableLayoutStyles && (ROOT_BLOCK_SELECTOR === selector || hasLayoutSupport)) { 10708 ruleset += getLayoutStyles({ 10709 style: styles, 10710 selector, 10711 hasBlockGapSupport, 10712 hasFallbackGapSupport, 10713 fallbackGapValue 10714 }); 10715 } 10716 const styleDeclarations = getStylesDeclarations( 10717 styles, 10718 selector, 10719 useRootPaddingAlign, 10720 tree, 10721 disableRootPadding 10722 ); 10723 if (styleDeclarations?.length) { 10724 const generalSelector = skipSelectorWrapper ? selector : `:root :where($selector})`; 10725 ruleset += `$generalSelector}{$styleDeclarations.join( 10726 ";" 10727 )};}`; 10728 } 10729 if (styles?.css) { 10730 ruleset += processCSSNesting( 10731 styles.css, 10732 `:root :where($selector})` 10733 ); 10734 } 10735 if (options.variationStyles && styleVariationSelectors) { 10736 Object.entries(styleVariationSelectors).forEach( 10737 ([styleVariationName, styleVariationSelector]) => { 10738 const styleVariations = styles?.variations?.[styleVariationName]; 10739 if (styleVariations) { 10740 if (featureSelectors) { 10741 const featureDeclarations = getFeatureDeclarations( 10742 featureSelectors, 10743 styleVariations 10744 ); 10745 Object.entries( 10746 featureDeclarations 10747 ).forEach( 10748 ([baseSelector, declarations]) => { 10749 if (declarations.length) { 10750 const cssSelector = concatFeatureVariationSelectorString( 10751 baseSelector, 10752 styleVariationSelector 10753 ); 10754 const rules = declarations.join(";"); 10755 ruleset += `:root :where($cssSelector}){$rules};}`; 10756 } 10757 } 10758 ); 10759 } 10760 const styleVariationDeclarations = getStylesDeclarations( 10761 styleVariations, 10762 styleVariationSelector, 10763 useRootPaddingAlign, 10764 tree 10765 ); 10766 if (styleVariationDeclarations.length) { 10767 ruleset += `:root :where($styleVariationSelector}){$styleVariationDeclarations.join( 10768 ";" 10769 )};}`; 10770 } 10771 if (styleVariations?.css) { 10772 ruleset += processCSSNesting( 10773 styleVariations.css, 10774 `:root :where($styleVariationSelector})` 10775 ); 10776 } 10777 } 10778 } 10779 ); 10780 } 10781 const pseudoSelectorStyles = Object.entries(styles).filter( 10782 ([key]) => key.startsWith(":") 10783 ); 10784 if (pseudoSelectorStyles?.length) { 10785 pseudoSelectorStyles.forEach( 10786 ([pseudoKey, pseudoStyle]) => { 10787 const pseudoDeclarations = getStylesDeclarations(pseudoStyle); 10788 if (!pseudoDeclarations?.length) { 10789 return; 10790 } 10791 const _selector = selector.split(",").map((sel) => sel + pseudoKey).join(","); 10792 const pseudoRule = `:root :where($_selector}){$pseudoDeclarations.join( 10793 ";" 10794 )};}`; 10795 ruleset += pseudoRule; 10796 } 10797 ); 10798 } 10799 } 10800 ); 10801 } 10802 if (options.layoutStyles) { 10803 ruleset = ruleset + ".wp-site-blocks > .alignleft { float: left; margin-right: 2em; }"; 10804 ruleset = ruleset + ".wp-site-blocks > .alignright { float: right; margin-left: 2em; }"; 10805 ruleset = ruleset + ".wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }"; 10806 } 10807 if (options.blockGap && hasBlockGapSupport) { 10808 const gapValue = getGapCSSValue(tree?.styles?.spacing?.blockGap) || "0.5em"; 10809 ruleset = ruleset + `:root :where(.wp-site-blocks) > * { margin-block-start: $gapValue}; margin-block-end: 0; }`; 10810 ruleset = ruleset + ":root :where(.wp-site-blocks) > :first-child { margin-block-start: 0; }"; 10811 ruleset = ruleset + ":root :where(.wp-site-blocks) > :last-child { margin-block-end: 0; }"; 10812 } 10813 if (options.presets) { 10814 nodesWithSettings.forEach(({ selector, presets }) => { 10815 if (ROOT_BLOCK_SELECTOR === selector || ROOT_CSS_PROPERTIES_SELECTOR === selector) { 10816 selector = ""; 10817 } 10818 const classes = getPresetsClasses(selector, presets); 10819 if (classes.length > 0) { 10820 ruleset += classes; 10821 } 10822 }); 10823 } 10824 return ruleset; 10825 }; 10826 function generateSvgFilters(tree, blockSelectors) { 10827 const nodesWithSettings = getNodesWithSettings(tree, blockSelectors); 10828 return nodesWithSettings.flatMap(({ presets }) => { 10829 return getPresetsSvgFilters(presets); 10830 }); 10831 } 10832 var getSelectorsConfig = (blockType, rootSelector) => { 10833 if (blockType?.selectors && Object.keys(blockType.selectors).length > 0) { 10834 return blockType.selectors; 10835 } 10836 const config = { 10837 root: rootSelector 10838 }; 10839 Object.entries(BLOCK_SUPPORT_FEATURE_LEVEL_SELECTORS).forEach( 10840 ([featureKey, featureName]) => { 10841 const featureSelector = getBlockSelector(blockType, featureKey); 10842 if (featureSelector) { 10843 config[featureName] = featureSelector; 10844 } 10845 } 10846 ); 10847 return config; 10848 }; 10849 var getBlockSelectors = (blockTypes, variationInstanceId) => { 10850 const { getBlockStyles } = (0, import_data25.select)(import_blocks8.store); 10851 const result = {}; 10852 blockTypes.forEach((blockType) => { 10853 const name2 = blockType.name; 10854 const selector = getBlockSelector(blockType); 10855 if (!selector) { 10856 return; 10857 } 10858 let duotoneSelector = getBlockSelector(blockType, "filter.duotone"); 10859 if (!duotoneSelector) { 10860 const rootSelector = getBlockSelector(blockType); 10861 const duotoneSupport = (0, import_blocks8.getBlockSupport)( 10862 blockType, 10863 "color.__experimentalDuotone", 10864 false 10865 ); 10866 duotoneSelector = duotoneSupport && rootSelector && scopeSelector(rootSelector, duotoneSupport); 10867 } 10868 const hasLayoutSupport = !!blockType?.supports?.layout || !!blockType?.supports?.__experimentalLayout; 10869 const fallbackGapValue = ( 10870 // @ts-expect-error 10871 blockType?.supports?.spacing?.blockGap?.__experimentalDefault 10872 ); 10873 const blockStyleVariations = getBlockStyles(name2); 10874 const styleVariationSelectors = {}; 10875 blockStyleVariations?.forEach((variation) => { 10876 const variationSuffix = variationInstanceId ? `-$variationInstanceId}` : ""; 10877 const variationName = `$variation.name}$variationSuffix}`; 10878 const styleVariationSelector = getBlockStyleVariationSelector( 10879 variationName, 10880 selector 10881 ); 10882 styleVariationSelectors[variationName] = styleVariationSelector; 10883 }); 10884 const featureSelectors = getSelectorsConfig(blockType, selector); 10885 result[name2] = { 10886 duotoneSelector: duotoneSelector ?? void 0, 10887 fallbackGapValue, 10888 featureSelectors: Object.keys(featureSelectors).length ? featureSelectors : void 0, 10889 hasLayoutSupport, 10890 name: name2, 10891 selector, 10892 styleVariationSelectors: blockStyleVariations?.length ? styleVariationSelectors : void 0 10893 }; 10894 }); 10895 return result; 10896 }; 10897 function updateConfigWithSeparator(config) { 10898 const blocks = config.styles?.blocks; 10899 const separatorBlock = blocks?.["core/separator"]; 10900 const needsSeparatorStyleUpdate = separatorBlock && separatorBlock.color?.background && !separatorBlock.color?.text && !separatorBlock.border?.color; 10901 if (needsSeparatorStyleUpdate) { 10902 return { 10903 ...config, 10904 styles: { 10905 ...config.styles, 10906 blocks: { 10907 ...blocks, 10908 "core/separator": { 10909 ...separatorBlock, 10910 color: { 10911 ...separatorBlock.color, 10912 text: separatorBlock.color?.background 10913 } 10914 } 10915 } 10916 } 10917 }; 10918 } 10919 return config; 10920 } 10921 function processCSSNesting(css, blockSelector) { 10922 let processedCSS = ""; 10923 if (!css || css.trim() === "") { 10924 return processedCSS; 10925 } 10926 const parts = css.split("&"); 10927 parts.forEach((part) => { 10928 if (!part || part.trim() === "") { 10929 return; 10930 } 10931 const isRootCss = !part.includes("{"); 10932 if (isRootCss) { 10933 processedCSS += `:root :where($blockSelector}){$part.trim()}}`; 10934 } else { 10935 const splitPart = part.replace("}", "").split("{"); 10936 if (splitPart.length !== 2) { 10937 return; 10938 } 10939 const [nestedSelector, cssValue] = splitPart; 10940 const matches = nestedSelector.match(/([>+~\s]*::[a-zA-Z-]+)/); 10941 const pseudoPart = matches ? matches[1] : ""; 10942 const withoutPseudoElement = matches ? nestedSelector.replace(pseudoPart, "").trim() : nestedSelector.trim(); 10943 let combinedSelector; 10944 if (withoutPseudoElement === "") { 10945 combinedSelector = blockSelector; 10946 } else { 10947 combinedSelector = nestedSelector.startsWith(" ") ? scopeSelector(blockSelector, withoutPseudoElement) : appendToSelector(blockSelector, withoutPseudoElement); 10948 } 10949 processedCSS += `:root :where($combinedSelector})$pseudoPart}{$cssValue.trim()}}`; 10950 } 10951 }); 10952 return processedCSS; 10953 } 10954 function generateGlobalStyles(config = {}, blockTypes = [], options = {}) { 10955 const { 10956 hasBlockGapSupport: hasBlockGapSupportOption, 10957 hasFallbackGapSupport: hasFallbackGapSupportOption, 10958 disableLayoutStyles = false, 10959 disableRootPadding = false, 10960 styleOptions = {} 10961 } = options; 10962 const blocks = blockTypes.length > 0 ? blockTypes : (0, import_blocks8.getBlockTypes)(); 10963 const blockGap = getSetting(config, "spacing.blockGap"); 10964 const hasBlockGapSupport = hasBlockGapSupportOption ?? blockGap !== null; 10965 const hasFallbackGapSupport = hasFallbackGapSupportOption ?? !hasBlockGapSupport; 10966 if (!config?.styles || !config?.settings) { 10967 return [[], {}]; 10968 } 10969 const updatedConfig = updateConfigWithSeparator(config); 10970 const blockSelectors = getBlockSelectors(blocks); 10971 const customProperties = generateCustomProperties( 10972 updatedConfig, 10973 blockSelectors 10974 ); 10975 const globalStyles = transformToStyles( 10976 updatedConfig, 10977 blockSelectors, 10978 hasBlockGapSupport, 10979 hasFallbackGapSupport, 10980 disableLayoutStyles, 10981 disableRootPadding, 10982 styleOptions 10983 ); 10984 const svgs = generateSvgFilters(updatedConfig, blockSelectors); 10985 const styles = [ 10986 { 10987 css: customProperties, 10988 isGlobalStyles: true 10989 }, 10990 { 10991 css: globalStyles, 10992 isGlobalStyles: true 10993 }, 10994 // 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. 10995 { 10996 css: updatedConfig?.styles?.css ?? "", 10997 isGlobalStyles: true 10998 }, 10999 { 11000 assets: svgs, 11001 __unstableType: "svg", 11002 isGlobalStyles: true 11003 } 11004 ]; 11005 blocks.forEach((blockType) => { 11006 const blockStyles = updatedConfig?.styles?.blocks?.[blockType.name]; 11007 if (blockStyles?.css) { 11008 const selector = blockSelectors[blockType.name].selector; 11009 styles.push({ 11010 css: processCSSNesting(blockStyles.css, selector), 11011 isGlobalStyles: true 11012 }); 11013 } 11014 }); 11015 return [styles, updatedConfig.settings]; 11016 } 11017 11018 // packages/editor/build-module/components/global-styles-provider/index.js 11019 var { cleanEmptyObject } = unlock(import_block_editor6.privateApis); 11020 function useGlobalStylesUserConfig() { 11021 const { globalStylesId, isReady: isReady2, settings, styles, _links } = (0, import_data26.useSelect)( 11022 (select5) => { 11023 const { 11024 getEntityRecord, 11025 getEditedEntityRecord: getEditedEntityRecord2, 11026 hasFinishedResolution, 11027 canUser 11028 } = select5(import_core_data22.store); 11029 const _globalStylesId = select5(import_core_data22.store).__experimentalGetCurrentGlobalStylesId(); 11030 let record; 11031 const userCanEditGlobalStyles = _globalStylesId ? canUser("update", { 11032 kind: "root", 11033 name: "globalStyles", 11034 id: _globalStylesId 11035 }) : null; 11036 if (_globalStylesId && /* 11037 * Test that the OPTIONS request for user capabilities is complete 11038 * before fetching the global styles entity record. 11039 * This is to avoid fetching the global styles entity unnecessarily. 11040 */ 11041 typeof userCanEditGlobalStyles === "boolean") { 11042 if (userCanEditGlobalStyles) { 11043 record = getEditedEntityRecord2( 11044 "root", 11045 "globalStyles", 11046 _globalStylesId 11047 ); 11048 } else { 11049 record = getEntityRecord( 11050 "root", 11051 "globalStyles", 11052 _globalStylesId, 11053 { context: "view" } 11054 ); 11055 } 11056 } 11057 let hasResolved = false; 11058 if (hasFinishedResolution( 11059 "__experimentalGetCurrentGlobalStylesId" 11060 )) { 11061 if (_globalStylesId) { 11062 hasResolved = userCanEditGlobalStyles ? hasFinishedResolution("getEditedEntityRecord", [ 11063 "root", 11064 "globalStyles", 11065 _globalStylesId 11066 ]) : hasFinishedResolution("getEntityRecord", [ 11067 "root", 11068 "globalStyles", 11069 _globalStylesId, 11070 { context: "view" } 11071 ]); 11072 } else { 11073 hasResolved = true; 11074 } 11075 } 11076 return { 11077 globalStylesId: _globalStylesId, 11078 isReady: hasResolved, 11079 settings: record?.settings, 11080 styles: record?.styles, 11081 _links: record?._links 11082 }; 11083 }, 11084 [] 11085 ); 11086 const { getEditedEntityRecord } = (0, import_data26.useSelect)(import_core_data22.store); 11087 const { editEntityRecord } = (0, import_data26.useDispatch)(import_core_data22.store); 11088 const config = (0, import_element21.useMemo)(() => { 11089 return { 11090 settings: settings ?? {}, 11091 styles: styles ?? {}, 11092 _links: _links ?? {} 11093 }; 11094 }, [settings, styles, _links]); 11095 const setConfig = (0, import_element21.useCallback)( 11096 /** 11097 * Set the global styles config. 11098 * @param {Function|Object} callbackOrObject If the callbackOrObject is a function, pass the current config to the callback so the consumer can merge values. 11099 * Otherwise, overwrite the current config with the incoming object. 11100 * @param {Object} options Options for editEntityRecord Core selector. 11101 */ 11102 (callbackOrObject, options = {}) => { 11103 const record = getEditedEntityRecord( 11104 "root", 11105 "globalStyles", 11106 globalStylesId 11107 ); 11108 const currentConfig = { 11109 styles: record?.styles ?? {}, 11110 settings: record?.settings ?? {}, 11111 _links: record?._links ?? {} 11112 }; 11113 const updatedConfig = typeof callbackOrObject === "function" ? callbackOrObject(currentConfig) : callbackOrObject; 11114 editEntityRecord( 11115 "root", 11116 "globalStyles", 11117 globalStylesId, 11118 { 11119 styles: cleanEmptyObject(updatedConfig.styles) || {}, 11120 settings: cleanEmptyObject(updatedConfig.settings) || {}, 11121 _links: cleanEmptyObject(updatedConfig._links) || {} 11122 }, 11123 options 11124 ); 11125 }, 11126 [globalStylesId, editEntityRecord, getEditedEntityRecord] 11127 ); 11128 return [isReady2, config, setConfig]; 11129 } 11130 function useGlobalStylesBaseConfig() { 11131 const baseConfig = (0, import_data26.useSelect)( 11132 (select5) => select5(import_core_data22.store).__experimentalGetCurrentThemeBaseGlobalStyles(), 11133 [] 11134 ); 11135 return [!!baseConfig, baseConfig]; 11136 } 11137 function useGlobalStylesContext() { 11138 const [isUserConfigReady, userConfig, setUserConfig] = useGlobalStylesUserConfig(); 11139 const [isBaseConfigReady, baseConfig] = useGlobalStylesBaseConfig(); 11140 const mergedConfig = (0, import_element21.useMemo)(() => { 11141 if (!baseConfig || !userConfig) { 11142 return {}; 11143 } 11144 return mergeGlobalStyles(baseConfig, userConfig); 11145 }, [userConfig, baseConfig]); 11146 const context = (0, import_element21.useMemo)(() => { 11147 return { 11148 isReady: isUserConfigReady && isBaseConfigReady, 11149 user: userConfig, 11150 base: baseConfig, 11151 merged: mergedConfig, 11152 setUserConfig 11153 }; 11154 }, [ 11155 mergedConfig, 11156 userConfig, 11157 baseConfig, 11158 setUserConfig, 11159 isUserConfigReady, 11160 isBaseConfigReady 11161 ]); 11162 return context; 11163 } 11164 11165 // packages/editor/build-module/components/provider/use-block-editor-settings.js 11166 var EMPTY_OBJECT3 = {}; 11167 function __experimentalReusableBlocksSelect(select5) { 11168 const { RECEIVE_INTERMEDIATE_RESULTS: RECEIVE_INTERMEDIATE_RESULTS2 } = unlock(import_core_data23.privateApis); 11169 const { getEntityRecords } = select5(import_core_data23.store); 11170 return getEntityRecords("postType", "wp_block", { 11171 per_page: -1, 11172 [RECEIVE_INTERMEDIATE_RESULTS2]: true 11173 }); 11174 } 11175 var BLOCK_EDITOR_SETTINGS = [ 11176 "__experimentalBlockBindingsSupportedAttributes", 11177 "__experimentalBlockDirectory", 11178 "__experimentalDiscussionSettings", 11179 "__experimentalFeatures", 11180 "__experimentalGlobalStylesBaseStyles", 11181 "alignWide", 11182 "blockInspectorTabs", 11183 "maxUploadFileSize", 11184 "allowedMimeTypes", 11185 "bodyPlaceholder", 11186 "canLockBlocks", 11187 "canUpdateBlockBindings", 11188 "capabilities", 11189 "clearBlockSelection", 11190 "codeEditingEnabled", 11191 "colors", 11192 "disableCustomColors", 11193 "disableCustomFontSizes", 11194 "disableCustomSpacingSizes", 11195 "disableCustomGradients", 11196 "disableLayoutStyles", 11197 "enableCustomLineHeight", 11198 "enableCustomSpacing", 11199 "enableCustomUnits", 11200 "enableOpenverseMediaCategory", 11201 "fontSizes", 11202 "gradients", 11203 "generateAnchors", 11204 "onNavigateToEntityRecord", 11205 "imageDefaultSize", 11206 "imageDimensions", 11207 "imageEditing", 11208 "imageSizes", 11209 "isPreviewMode", 11210 "isRTL", 11211 "locale", 11212 "maxWidth", 11213 "postContentAttributes", 11214 "postsPerPage", 11215 "readOnly", 11216 "styles", 11217 "titlePlaceholder", 11218 "supportsLayout", 11219 "widgetTypesToHideFromLegacyWidgetBlock", 11220 "__unstableHasCustomAppender", 11221 "__unstableResolvedAssets", 11222 "__unstableIsBlockBasedTheme" 11223 ]; 11224 var { 11225 globalStylesDataKey, 11226 globalStylesLinksDataKey, 11227 selectBlockPatternsKey, 11228 reusableBlocksSelectKey, 11229 sectionRootClientIdKey, 11230 mediaEditKey, 11231 getMediaSelectKey, 11232 isIsolatedEditorKey 11233 } = unlock(import_block_editor7.privateApis); 11234 function useBlockEditorSettings(settings, postType2, postId2, renderingMode2) { 11235 const isLargeViewport = (0, import_compose6.useViewportMatch)("medium"); 11236 const { 11237 allowRightClickOverrides, 11238 blockTypes, 11239 focusMode, 11240 hasFixedToolbar, 11241 isDistractionFree, 11242 keepCaretInsideBlock, 11243 hasUploadPermissions, 11244 hiddenBlockTypes, 11245 canUseUnfilteredHTML, 11246 userCanCreatePages, 11247 pageOnFront, 11248 pageForPosts, 11249 userPatternCategories, 11250 restBlockPatternCategories, 11251 sectionRootClientId 11252 } = (0, import_data27.useSelect)( 11253 (select5) => { 11254 const { 11255 canUser, 11256 getRawEntityRecord, 11257 getEntityRecord, 11258 getUserPatternCategories, 11259 getBlockPatternCategories 11260 } = select5(import_core_data23.store); 11261 const { get } = select5(import_preferences3.store); 11262 const { getBlockTypes: getBlockTypes6 } = select5(import_blocks9.store); 11263 const { getBlocksByName, getBlockAttributes: getBlockAttributes2 } = select5(import_block_editor7.store); 11264 const siteSettings = canUser("read", { 11265 kind: "root", 11266 name: "site" 11267 }) ? getEntityRecord("root", "site") : void 0; 11268 function getSectionRootBlock() { 11269 if (renderingMode2 === "template-locked") { 11270 return getBlocksByName("core/post-content")?.[0] ?? ""; 11271 } 11272 return getBlocksByName("core/group").find( 11273 (clientId) => getBlockAttributes2(clientId)?.tagName === "main" 11274 ) ?? ""; 11275 } 11276 return { 11277 allowRightClickOverrides: get( 11278 "core", 11279 "allowRightClickOverrides" 11280 ), 11281 blockTypes: getBlockTypes6(), 11282 canUseUnfilteredHTML: getRawEntityRecord( 11283 "postType", 11284 postType2, 11285 postId2 11286 )?._links?.hasOwnProperty("wp:action-unfiltered-html"), 11287 focusMode: get("core", "focusMode"), 11288 hasFixedToolbar: get("core", "fixedToolbar") || !isLargeViewport, 11289 hiddenBlockTypes: get("core", "hiddenBlockTypes"), 11290 isDistractionFree: get("core", "distractionFree"), 11291 keepCaretInsideBlock: get("core", "keepCaretInsideBlock"), 11292 hasUploadPermissions: canUser("create", { 11293 kind: "postType", 11294 name: "attachment" 11295 }) ?? true, 11296 userCanCreatePages: canUser("create", { 11297 kind: "postType", 11298 name: "page" 11299 }), 11300 pageOnFront: siteSettings?.page_on_front, 11301 pageForPosts: siteSettings?.page_for_posts, 11302 userPatternCategories: getUserPatternCategories(), 11303 restBlockPatternCategories: getBlockPatternCategories(), 11304 sectionRootClientId: getSectionRootBlock() 11305 }; 11306 }, 11307 [postType2, postId2, isLargeViewport, renderingMode2] 11308 ); 11309 const { merged: mergedGlobalStyles } = useGlobalStylesContext(); 11310 const globalStylesData = mergedGlobalStyles.styles ?? EMPTY_OBJECT3; 11311 const globalStylesLinksData = mergedGlobalStyles._links ?? EMPTY_OBJECT3; 11312 const settingsBlockPatterns = settings.__experimentalAdditionalBlockPatterns ?? // WP 6.0 11313 settings.__experimentalBlockPatterns; 11314 const settingsBlockPatternCategories = settings.__experimentalAdditionalBlockPatternCategories ?? // WP 6.0 11315 settings.__experimentalBlockPatternCategories; 11316 const blockPatterns = (0, import_element22.useMemo)( 11317 () => [...settingsBlockPatterns || []].filter( 11318 ({ postTypes }) => { 11319 return !postTypes || Array.isArray(postTypes) && postTypes.includes(postType2); 11320 } 11321 ), 11322 [settingsBlockPatterns, postType2] 11323 ); 11324 const blockPatternCategories = (0, import_element22.useMemo)( 11325 () => [ 11326 ...settingsBlockPatternCategories || [], 11327 ...restBlockPatternCategories || [] 11328 ].filter( 11329 (x2, index2, arr) => index2 === arr.findIndex((y3) => x2.name === y3.name) 11330 ), 11331 [settingsBlockPatternCategories, restBlockPatternCategories] 11332 ); 11333 const { undo: undo2, setIsInserterOpened: setIsInserterOpened2 } = (0, import_data27.useDispatch)(store); 11334 const { editMediaEntity } = unlock((0, import_data27.useDispatch)(import_core_data23.store)); 11335 const { saveEntityRecord } = (0, import_data27.useDispatch)(import_core_data23.store); 11336 const createPageEntity = (0, import_element22.useCallback)( 11337 (options) => { 11338 if (!userCanCreatePages) { 11339 return Promise.reject({ 11340 message: (0, import_i18n49.__)( 11341 "You do not have permission to create Pages." 11342 ) 11343 }); 11344 } 11345 return saveEntityRecord("postType", "page", options); 11346 }, 11347 [saveEntityRecord, userCanCreatePages] 11348 ); 11349 const { getSelectedBlockClientId: getSelectedBlockClientId2 } = (0, import_data27.useSelect)(import_block_editor7.store); 11350 const wrappedOnNavigateToEntityRecord = (0, import_element22.useCallback)( 11351 (params) => { 11352 if (!settings.onNavigateToEntityRecord) { 11353 return; 11354 } 11355 const selectedBlockClientId = getSelectedBlockClientId2(); 11356 return settings.onNavigateToEntityRecord({ 11357 ...params, 11358 selectedBlockClientId 11359 }); 11360 }, 11361 [settings, getSelectedBlockClientId2] 11362 ); 11363 const allowedBlockTypes = (0, import_element22.useMemo)(() => { 11364 if (hiddenBlockTypes && hiddenBlockTypes.length > 0) { 11365 const defaultAllowedBlockTypes = true === settings.allowedBlockTypes ? blockTypes.map(({ name: name2 }) => name2) : settings.allowedBlockTypes || []; 11366 return defaultAllowedBlockTypes.filter( 11367 (type) => !hiddenBlockTypes.includes(type) 11368 ); 11369 } 11370 return settings.allowedBlockTypes; 11371 }, [settings.allowedBlockTypes, hiddenBlockTypes, blockTypes]); 11372 const forceDisableFocusMode = settings.focusMode === false; 11373 return (0, import_element22.useMemo)(() => { 11374 const blockEditorSettings = { 11375 ...Object.fromEntries( 11376 Object.entries(settings).filter( 11377 ([key]) => BLOCK_EDITOR_SETTINGS.includes(key) 11378 ).filter(([key]) => key !== "onNavigateToEntityRecord") 11379 ), 11380 [globalStylesDataKey]: globalStylesData, 11381 [globalStylesLinksDataKey]: globalStylesLinksData, 11382 allowedBlockTypes, 11383 allowRightClickOverrides, 11384 focusMode: focusMode && !forceDisableFocusMode, 11385 hasFixedToolbar, 11386 isDistractionFree, 11387 keepCaretInsideBlock, 11388 onNavigateToEntityRecord: settings.onNavigateToEntityRecord ? wrappedOnNavigateToEntityRecord : void 0, 11389 [getMediaSelectKey]: (select5, attachmentId) => { 11390 return select5(import_core_data23.store).getEntityRecord( 11391 "postType", 11392 "attachment", 11393 attachmentId 11394 ); 11395 }, 11396 [mediaEditKey]: hasUploadPermissions ? editMediaEntity : void 0, 11397 mediaUpload: hasUploadPermissions ? mediaUpload : void 0, 11398 mediaSideload: hasUploadPermissions ? media_sideload_default : void 0, 11399 __experimentalBlockPatterns: blockPatterns, 11400 [selectBlockPatternsKey]: (select5) => { 11401 const { hasFinishedResolution, getBlockPatternsForPostType } = unlock(select5(import_core_data23.store)); 11402 const patterns2 = getBlockPatternsForPostType(postType2); 11403 return hasFinishedResolution("getBlockPatterns") ? patterns2 : void 0; 11404 }, 11405 [reusableBlocksSelectKey]: __experimentalReusableBlocksSelect, 11406 __experimentalBlockPatternCategories: blockPatternCategories, 11407 __experimentalUserPatternCategories: userPatternCategories, 11408 __experimentalFetchLinkSuggestions: (search, searchOptions) => (0, import_core_data23.__experimentalFetchLinkSuggestions)(search, searchOptions, settings), 11409 inserterMediaCategories: media_categories_default, 11410 __experimentalFetchRichUrlData: import_core_data23.__experimentalFetchUrlData, 11411 // Todo: This only checks the top level post, not the post within a template or any other entity that can be edited. 11412 // This might be better as a generic "canUser" selector. 11413 __experimentalCanUserUseUnfilteredHTML: canUseUnfilteredHTML, 11414 //Todo: this is only needed for native and should probably be removed. 11415 __experimentalUndo: undo2, 11416 // Check whether we want all site editor frames to have outlines 11417 // including the navigation / pattern / parts editors. 11418 outlineMode: !isDistractionFree && postType2 === "wp_template", 11419 // Check these two properties: they were not present in the site editor. 11420 __experimentalCreatePageEntity: createPageEntity, 11421 __experimentalUserCanCreatePages: userCanCreatePages, 11422 pageOnFront, 11423 pageForPosts, 11424 __experimentalPreferPatternsOnRoot: postType2 === "wp_template", 11425 templateLock: postType2 === "wp_navigation" ? "insert" : settings.templateLock, 11426 template: postType2 === "wp_navigation" ? [["core/navigation", {}, []]] : settings.template, 11427 __experimentalSetIsInserterOpened: setIsInserterOpened2, 11428 [sectionRootClientIdKey]: sectionRootClientId, 11429 editorTool: renderingMode2 === "post-only" && postType2 !== "wp_template" ? "edit" : void 0, 11430 // When editing template parts, patterns, or navigation directly, 11431 // we're in an isolated editing context (focused on that entity alone). 11432 [isIsolatedEditorKey]: [ 11433 "wp_template_part", 11434 "wp_block", 11435 "wp_navigation" 11436 ].includes(postType2) 11437 }; 11438 return blockEditorSettings; 11439 }, [ 11440 allowedBlockTypes, 11441 allowRightClickOverrides, 11442 focusMode, 11443 forceDisableFocusMode, 11444 hasFixedToolbar, 11445 isDistractionFree, 11446 keepCaretInsideBlock, 11447 settings, 11448 hasUploadPermissions, 11449 userPatternCategories, 11450 blockPatterns, 11451 blockPatternCategories, 11452 canUseUnfilteredHTML, 11453 undo2, 11454 createPageEntity, 11455 userCanCreatePages, 11456 pageOnFront, 11457 pageForPosts, 11458 postType2, 11459 setIsInserterOpened2, 11460 sectionRootClientId, 11461 globalStylesData, 11462 globalStylesLinksData, 11463 renderingMode2, 11464 editMediaEntity, 11465 wrappedOnNavigateToEntityRecord 11466 ]); 11467 } 11468 var use_block_editor_settings_default = useBlockEditorSettings; 11469 11470 // packages/editor/build-module/components/provider/disable-non-page-content-blocks.js 11471 var import_data29 = __toESM(require_data()); 11472 var import_block_editor8 = __toESM(require_block_editor()); 11473 var import_element24 = __toESM(require_element()); 11474 11475 // packages/editor/build-module/components/provider/use-post-content-blocks.js 11476 var import_data28 = __toESM(require_data()); 11477 var import_element23 = __toESM(require_element()); 11478 var import_hooks2 = __toESM(require_hooks()); 11479 var POST_CONTENT_BLOCK_TYPES = [ 11480 "core/post-title", 11481 "core/post-featured-image", 11482 "core/post-content" 11483 ]; 11484 function usePostContentBlocks() { 11485 const contentOnlyBlockTypes = (0, import_element23.useMemo)( 11486 () => [ 11487 ...(0, import_hooks2.applyFilters)( 11488 "editor.postContentBlockTypes", 11489 POST_CONTENT_BLOCK_TYPES 11490 ) 11491 ], 11492 [] 11493 ); 11494 const contentOnlyIds = (0, import_data28.useSelect)( 11495 (select5) => { 11496 const { getPostBlocksByName: getPostBlocksByName2 } = unlock(select5(store)); 11497 return getPostBlocksByName2(contentOnlyBlockTypes); 11498 }, 11499 [contentOnlyBlockTypes] 11500 ); 11501 return contentOnlyIds; 11502 } 11503 11504 // packages/editor/build-module/components/provider/disable-non-page-content-blocks.js 11505 function DisableNonPageContentBlocks() { 11506 const contentOnlyIds = usePostContentBlocks(); 11507 const { templateParts } = (0, import_data29.useSelect)((select5) => { 11508 const { getBlocksByName } = select5(import_block_editor8.store); 11509 return { 11510 templateParts: getBlocksByName("core/template-part") 11511 }; 11512 }, []); 11513 const disabledIds = (0, import_data29.useSelect)( 11514 (select5) => { 11515 const { getBlockOrder: getBlockOrder2 } = select5(import_block_editor8.store); 11516 return templateParts.flatMap( 11517 (clientId) => getBlockOrder2(clientId) 11518 ); 11519 }, 11520 [templateParts] 11521 ); 11522 const registry = (0, import_data29.useRegistry)(); 11523 (0, import_element24.useEffect)(() => { 11524 const { setBlockEditingMode, unsetBlockEditingMode } = registry.dispatch(import_block_editor8.store); 11525 setBlockEditingMode("", "disabled"); 11526 return () => { 11527 unsetBlockEditingMode(""); 11528 }; 11529 }, [registry]); 11530 (0, import_element24.useEffect)(() => { 11531 const { setBlockEditingMode, unsetBlockEditingMode } = registry.dispatch(import_block_editor8.store); 11532 registry.batch(() => { 11533 for (const clientId of contentOnlyIds) { 11534 setBlockEditingMode(clientId, "contentOnly"); 11535 } 11536 }); 11537 return () => { 11538 registry.batch(() => { 11539 for (const clientId of contentOnlyIds) { 11540 unsetBlockEditingMode(clientId); 11541 } 11542 }); 11543 }; 11544 }, [contentOnlyIds, registry]); 11545 (0, import_element24.useEffect)(() => { 11546 const { setBlockEditingMode, unsetBlockEditingMode } = registry.dispatch(import_block_editor8.store); 11547 registry.batch(() => { 11548 for (const clientId of templateParts) { 11549 setBlockEditingMode(clientId, "contentOnly"); 11550 } 11551 }); 11552 return () => { 11553 registry.batch(() => { 11554 for (const clientId of templateParts) { 11555 unsetBlockEditingMode(clientId); 11556 } 11557 }); 11558 }; 11559 }, [templateParts, registry]); 11560 (0, import_element24.useEffect)(() => { 11561 const { setBlockEditingMode, unsetBlockEditingMode } = registry.dispatch(import_block_editor8.store); 11562 registry.batch(() => { 11563 for (const clientId of disabledIds) { 11564 setBlockEditingMode(clientId, "disabled"); 11565 } 11566 }); 11567 return () => { 11568 registry.batch(() => { 11569 for (const clientId of disabledIds) { 11570 unsetBlockEditingMode(clientId); 11571 } 11572 }); 11573 }; 11574 }, [disabledIds, registry]); 11575 return null; 11576 } 11577 11578 // packages/editor/build-module/components/provider/navigation-block-editing-mode.js 11579 var import_element25 = __toESM(require_element()); 11580 var import_data30 = __toESM(require_data()); 11581 var import_block_editor9 = __toESM(require_block_editor()); 11582 function NavigationBlockEditingMode() { 11583 const blockClientId = (0, import_data30.useSelect)( 11584 (select5) => select5(import_block_editor9.store).getBlockOrder()?.[0], 11585 [] 11586 ); 11587 const { setBlockEditingMode, unsetBlockEditingMode } = (0, import_data30.useDispatch)(import_block_editor9.store); 11588 (0, import_element25.useEffect)(() => { 11589 if (!blockClientId) { 11590 return; 11591 } 11592 setBlockEditingMode(blockClientId, "contentOnly"); 11593 return () => { 11594 unsetBlockEditingMode(blockClientId); 11595 }; 11596 }, [blockClientId, unsetBlockEditingMode, setBlockEditingMode]); 11597 } 11598 11599 // packages/editor/build-module/components/provider/use-hide-blocks-from-inserter.js 11600 var import_element26 = __toESM(require_element()); 11601 var import_hooks3 = __toESM(require_hooks()); 11602 var POST_TYPES_ALLOWING_POST_CONTENT_TEMPLATE_PART = [ 11603 "wp_block", 11604 "wp_template", 11605 "wp_template_part" 11606 ]; 11607 function useHideBlocksFromInserter(postType2, mode) { 11608 (0, import_element26.useEffect)(() => { 11609 (0, import_hooks3.addFilter)( 11610 "blockEditor.__unstableCanInsertBlockType", 11611 "removeTemplatePartsFromInserter", 11612 (canInsert, blockType) => { 11613 if (!POST_TYPES_ALLOWING_POST_CONTENT_TEMPLATE_PART.includes( 11614 postType2 11615 ) && blockType.name === "core/template-part" && mode === "post-only") { 11616 return false; 11617 } 11618 return canInsert; 11619 } 11620 ); 11621 (0, import_hooks3.addFilter)( 11622 "blockEditor.__unstableCanInsertBlockType", 11623 "removePostContentFromInserter", 11624 (canInsert, blockType, rootClientId, { getBlockParentsByBlockName }) => { 11625 if (!POST_TYPES_ALLOWING_POST_CONTENT_TEMPLATE_PART.includes( 11626 postType2 11627 ) && blockType.name === "core/post-content") { 11628 return getBlockParentsByBlockName(rootClientId, "core/query").length > 0; 11629 } 11630 return canInsert; 11631 } 11632 ); 11633 return () => { 11634 (0, import_hooks3.removeFilter)( 11635 "blockEditor.__unstableCanInsertBlockType", 11636 "removeTemplatePartsFromInserter" 11637 ); 11638 (0, import_hooks3.removeFilter)( 11639 "blockEditor.__unstableCanInsertBlockType", 11640 "removePostContentFromInserter" 11641 ); 11642 }; 11643 }, [postType2, mode]); 11644 } 11645 11646 // packages/editor/build-module/components/commands/index.js 11647 var import_data38 = __toESM(require_data()); 11648 var import_i18n52 = __toESM(require_i18n()); 11649 var import_commands = __toESM(require_commands()); 11650 var import_preferences7 = __toESM(require_preferences()); 11651 var import_notices13 = __toESM(require_notices()); 11652 var import_block_editor10 = __toESM(require_block_editor()); 11653 var import_core_data26 = __toESM(require_core_data()); 11654 11655 // packages/interface/build-module/index.js 11656 var build_module_exports = {}; 11657 __export(build_module_exports, { 11658 ActionItem: () => action_item_default, 11659 ComplementaryArea: () => complementary_area_default, 11660 ComplementaryAreaMoreMenuItem: () => ComplementaryAreaMoreMenuItem, 11661 FullscreenMode: () => fullscreen_mode_default, 11662 InterfaceSkeleton: () => interface_skeleton_default, 11663 PinnedItems: () => pinned_items_default, 11664 store: () => store2 11665 }); 11666 11667 // packages/interface/build-module/components/complementary-area/index.js 11668 var import_components24 = __toESM(require_components()); 11669 var import_data35 = __toESM(require_data()); 11670 var import_i18n50 = __toESM(require_i18n()); 11671 var import_element28 = __toESM(require_element()); 11672 var import_viewport = __toESM(require_viewport()); 11673 var import_preferences6 = __toESM(require_preferences()); 11674 var import_compose7 = __toESM(require_compose()); 11675 var import_plugins2 = __toESM(require_plugins()); 11676 11677 // packages/interface/build-module/components/complementary-area-toggle/index.js 11678 var import_components20 = __toESM(require_components()); 11679 var import_data34 = __toESM(require_data()); 11680 var import_plugins = __toESM(require_plugins()); 11681 11682 // packages/interface/build-module/store/index.js 11683 var import_data33 = __toESM(require_data()); 11684 11685 // packages/interface/build-module/store/actions.js 11686 var actions_exports2 = {}; 11687 __export(actions_exports2, { 11688 closeModal: () => closeModal, 11689 disableComplementaryArea: () => disableComplementaryArea, 11690 enableComplementaryArea: () => enableComplementaryArea, 11691 openModal: () => openModal, 11692 pinItem: () => pinItem, 11693 setDefaultComplementaryArea: () => setDefaultComplementaryArea, 11694 setFeatureDefaults: () => setFeatureDefaults, 11695 setFeatureValue: () => setFeatureValue, 11696 toggleFeature: () => toggleFeature, 11697 unpinItem: () => unpinItem 11698 }); 11699 var import_deprecated5 = __toESM(require_deprecated()); 11700 var import_preferences4 = __toESM(require_preferences()); 11701 11702 // packages/interface/build-module/store/deprecated.js 11703 var import_deprecated4 = __toESM(require_deprecated()); 11704 function normalizeComplementaryAreaScope(scope) { 11705 if (["core/edit-post", "core/edit-site"].includes(scope)) { 11706 (0, import_deprecated4.default)(`$scope} interface scope`, { 11707 alternative: "core interface scope", 11708 hint: "core/edit-post and core/edit-site are merging.", 11709 version: "6.6" 11710 }); 11711 return "core"; 11712 } 11713 return scope; 11714 } 11715 function normalizeComplementaryAreaName(scope, name2) { 11716 if (scope === "core" && name2 === "edit-site/template") { 11717 (0, import_deprecated4.default)(`edit-site/template sidebar`, { 11718 alternative: "edit-post/document", 11719 version: "6.6" 11720 }); 11721 return "edit-post/document"; 11722 } 11723 if (scope === "core" && name2 === "edit-site/block-inspector") { 11724 (0, import_deprecated4.default)(`edit-site/block-inspector sidebar`, { 11725 alternative: "edit-post/block", 11726 version: "6.6" 11727 }); 11728 return "edit-post/block"; 11729 } 11730 return name2; 11731 } 11732 11733 // packages/interface/build-module/store/actions.js 11734 var setDefaultComplementaryArea = (scope, area) => { 11735 scope = normalizeComplementaryAreaScope(scope); 11736 area = normalizeComplementaryAreaName(scope, area); 11737 return { 11738 type: "SET_DEFAULT_COMPLEMENTARY_AREA", 11739 scope, 11740 area 11741 }; 11742 }; 11743 var enableComplementaryArea = (scope, area) => ({ registry, dispatch: dispatch6 }) => { 11744 if (!area) { 11745 return; 11746 } 11747 scope = normalizeComplementaryAreaScope(scope); 11748 area = normalizeComplementaryAreaName(scope, area); 11749 const isComplementaryAreaVisible = registry.select(import_preferences4.store).get(scope, "isComplementaryAreaVisible"); 11750 if (!isComplementaryAreaVisible) { 11751 registry.dispatch(import_preferences4.store).set(scope, "isComplementaryAreaVisible", true); 11752 } 11753 dispatch6({ 11754 type: "ENABLE_COMPLEMENTARY_AREA", 11755 scope, 11756 area 11757 }); 11758 }; 11759 var disableComplementaryArea = (scope) => ({ registry }) => { 11760 scope = normalizeComplementaryAreaScope(scope); 11761 const isComplementaryAreaVisible = registry.select(import_preferences4.store).get(scope, "isComplementaryAreaVisible"); 11762 if (isComplementaryAreaVisible) { 11763 registry.dispatch(import_preferences4.store).set(scope, "isComplementaryAreaVisible", false); 11764 } 11765 }; 11766 var pinItem = (scope, item) => ({ registry }) => { 11767 if (!item) { 11768 return; 11769 } 11770 scope = normalizeComplementaryAreaScope(scope); 11771 item = normalizeComplementaryAreaName(scope, item); 11772 const pinnedItems = registry.select(import_preferences4.store).get(scope, "pinnedItems"); 11773 if (pinnedItems?.[item] === true) { 11774 return; 11775 } 11776 registry.dispatch(import_preferences4.store).set(scope, "pinnedItems", { 11777 ...pinnedItems, 11778 [item]: true 11779 }); 11780 }; 11781 var unpinItem = (scope, item) => ({ registry }) => { 11782 if (!item) { 11783 return; 11784 } 11785 scope = normalizeComplementaryAreaScope(scope); 11786 item = normalizeComplementaryAreaName(scope, item); 11787 const pinnedItems = registry.select(import_preferences4.store).get(scope, "pinnedItems"); 11788 registry.dispatch(import_preferences4.store).set(scope, "pinnedItems", { 11789 ...pinnedItems, 11790 [item]: false 11791 }); 11792 }; 11793 function toggleFeature(scope, featureName) { 11794 return function({ registry }) { 11795 (0, import_deprecated5.default)(`dispatch( 'core/interface' ).toggleFeature`, { 11796 since: "6.0", 11797 alternative: `dispatch( 'core/preferences' ).toggle` 11798 }); 11799 registry.dispatch(import_preferences4.store).toggle(scope, featureName); 11800 }; 11801 } 11802 function setFeatureValue(scope, featureName, value) { 11803 return function({ registry }) { 11804 (0, import_deprecated5.default)(`dispatch( 'core/interface' ).setFeatureValue`, { 11805 since: "6.0", 11806 alternative: `dispatch( 'core/preferences' ).set` 11807 }); 11808 registry.dispatch(import_preferences4.store).set(scope, featureName, !!value); 11809 }; 11810 } 11811 function setFeatureDefaults(scope, defaults) { 11812 return function({ registry }) { 11813 (0, import_deprecated5.default)(`dispatch( 'core/interface' ).setFeatureDefaults`, { 11814 since: "6.0", 11815 alternative: `dispatch( 'core/preferences' ).setDefaults` 11816 }); 11817 registry.dispatch(import_preferences4.store).setDefaults(scope, defaults); 11818 }; 11819 } 11820 function openModal(name2) { 11821 return { 11822 type: "OPEN_MODAL", 11823 name: name2 11824 }; 11825 } 11826 function closeModal() { 11827 return { 11828 type: "CLOSE_MODAL" 11829 }; 11830 } 11831 11832 // packages/interface/build-module/store/selectors.js 11833 var selectors_exports2 = {}; 11834 __export(selectors_exports2, { 11835 getActiveComplementaryArea: () => getActiveComplementaryArea, 11836 isComplementaryAreaLoading: () => isComplementaryAreaLoading, 11837 isFeatureActive: () => isFeatureActive, 11838 isItemPinned: () => isItemPinned, 11839 isModalActive: () => isModalActive 11840 }); 11841 var import_data31 = __toESM(require_data()); 11842 var import_deprecated7 = __toESM(require_deprecated()); 11843 var import_preferences5 = __toESM(require_preferences()); 11844 var getActiveComplementaryArea = (0, import_data31.createRegistrySelector)( 11845 (select5) => (state, scope) => { 11846 scope = normalizeComplementaryAreaScope(scope); 11847 const isComplementaryAreaVisible = select5(import_preferences5.store).get( 11848 scope, 11849 "isComplementaryAreaVisible" 11850 ); 11851 if (isComplementaryAreaVisible === void 0) { 11852 return void 0; 11853 } 11854 if (isComplementaryAreaVisible === false) { 11855 return null; 11856 } 11857 return state?.complementaryAreas?.[scope]; 11858 } 11859 ); 11860 var isComplementaryAreaLoading = (0, import_data31.createRegistrySelector)( 11861 (select5) => (state, scope) => { 11862 scope = normalizeComplementaryAreaScope(scope); 11863 const isVisible = select5(import_preferences5.store).get( 11864 scope, 11865 "isComplementaryAreaVisible" 11866 ); 11867 const identifier = state?.complementaryAreas?.[scope]; 11868 return isVisible && identifier === void 0; 11869 } 11870 ); 11871 var isItemPinned = (0, import_data31.createRegistrySelector)( 11872 (select5) => (state, scope, item) => { 11873 scope = normalizeComplementaryAreaScope(scope); 11874 item = normalizeComplementaryAreaName(scope, item); 11875 const pinnedItems = select5(import_preferences5.store).get( 11876 scope, 11877 "pinnedItems" 11878 ); 11879 return pinnedItems?.[item] ?? true; 11880 } 11881 ); 11882 var isFeatureActive = (0, import_data31.createRegistrySelector)( 11883 (select5) => (state, scope, featureName) => { 11884 (0, import_deprecated7.default)( 11885 `select( 'core/interface' ).isFeatureActive( scope, featureName )`, 11886 { 11887 since: "6.0", 11888 alternative: `select( 'core/preferences' ).get( scope, featureName )` 11889 } 11890 ); 11891 return !!select5(import_preferences5.store).get(scope, featureName); 11892 } 11893 ); 11894 function isModalActive(state, modalName3) { 11895 return state.activeModal === modalName3; 11896 } 11897 11898 // packages/interface/build-module/store/reducer.js 11899 var import_data32 = __toESM(require_data()); 11900 function complementaryAreas(state = {}, action) { 11901 switch (action.type) { 11902 case "SET_DEFAULT_COMPLEMENTARY_AREA": { 11903 const { scope, area } = action; 11904 if (state[scope]) { 11905 return state; 11906 } 11907 return { 11908 ...state, 11909 [scope]: area 11910 }; 11911 } 11912 case "ENABLE_COMPLEMENTARY_AREA": { 11913 const { scope, area } = action; 11914 return { 11915 ...state, 11916 [scope]: area 11917 }; 11918 } 11919 } 11920 return state; 11921 } 11922 function activeModal(state = null, action) { 11923 switch (action.type) { 11924 case "OPEN_MODAL": 11925 return action.name; 11926 case "CLOSE_MODAL": 11927 return null; 11928 } 11929 return state; 11930 } 11931 var reducer_default3 = (0, import_data32.combineReducers)({ 11932 complementaryAreas, 11933 activeModal 11934 }); 11935 11936 // packages/interface/build-module/store/constants.js 11937 var STORE_NAME2 = "core/interface"; 11938 11939 // packages/interface/build-module/store/index.js 11940 var store2 = (0, import_data33.createReduxStore)(STORE_NAME2, { 11941 reducer: reducer_default3, 11942 actions: actions_exports2, 11943 selectors: selectors_exports2 11944 }); 11945 (0, import_data33.register)(store2); 11946 11947 // packages/interface/build-module/components/complementary-area-toggle/index.js 11948 var import_jsx_runtime92 = __toESM(require_jsx_runtime()); 11949 function roleSupportsCheckedState(role) { 11950 return [ 11951 "checkbox", 11952 "option", 11953 "radio", 11954 "switch", 11955 "menuitemcheckbox", 11956 "menuitemradio", 11957 "treeitem" 11958 ].includes(role); 11959 } 11960 function ComplementaryAreaToggle({ 11961 as = import_components20.Button, 11962 scope, 11963 identifier: identifierProp, 11964 icon: iconProp, 11965 selectedIcon, 11966 name: name2, 11967 shortcut, 11968 ...props 11969 }) { 11970 const ComponentToUse = as; 11971 const context = (0, import_plugins.usePluginContext)(); 11972 const icon = iconProp || context.icon; 11973 const identifier = identifierProp || `$context.name}/$name2}`; 11974 const isSelected = (0, import_data34.useSelect)( 11975 (select5) => select5(store2).getActiveComplementaryArea(scope) === identifier, 11976 [identifier, scope] 11977 ); 11978 const { enableComplementaryArea: enableComplementaryArea2, disableComplementaryArea: disableComplementaryArea2 } = (0, import_data34.useDispatch)(store2); 11979 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)( 11980 ComponentToUse, 11981 { 11982 icon: selectedIcon && isSelected ? selectedIcon : icon, 11983 "aria-controls": identifier.replace("/", ":"), 11984 "aria-checked": roleSupportsCheckedState(props.role) ? isSelected : void 0, 11985 onClick: () => { 11986 if (isSelected) { 11987 disableComplementaryArea2(scope); 11988 } else { 11989 enableComplementaryArea2(scope, identifier); 11990 } 11991 }, 11992 shortcut, 11993 ...props 11994 } 11995 ); 11996 } 11997 11998 // packages/interface/build-module/components/complementary-area-header/index.js 11999 var import_jsx_runtime93 = __toESM(require_jsx_runtime()); 12000 var ComplementaryAreaHeader = ({ 12001 children, 12002 className, 12003 toggleButtonProps 12004 }) => { 12005 const toggleButton = /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(ComplementaryAreaToggle, { icon: close_small_default, ...toggleButtonProps }); 12006 return /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)( 12007 "div", 12008 { 12009 className: clsx_default( 12010 "components-panel__header", 12011 "interface-complementary-area-header", 12012 className 12013 ), 12014 tabIndex: -1, 12015 children: [ 12016 children, 12017 toggleButton 12018 ] 12019 } 12020 ); 12021 }; 12022 var complementary_area_header_default = ComplementaryAreaHeader; 12023 12024 // packages/interface/build-module/components/complementary-area-more-menu-item/index.js 12025 var import_components22 = __toESM(require_components()); 12026 12027 // packages/interface/build-module/components/action-item/index.js 12028 var import_components21 = __toESM(require_components()); 12029 var import_element27 = __toESM(require_element()); 12030 var import_jsx_runtime94 = __toESM(require_jsx_runtime()); 12031 var noop2 = () => { 12032 }; 12033 function ActionItemSlot({ 12034 name: name2, 12035 as: Component6 = import_components21.MenuGroup, 12036 fillProps = {}, 12037 bubblesVirtually, 12038 ...props 12039 }) { 12040 return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)( 12041 import_components21.Slot, 12042 { 12043 name: name2, 12044 bubblesVirtually, 12045 fillProps, 12046 children: (fills) => { 12047 if (!import_element27.Children.toArray(fills).length) { 12048 return null; 12049 } 12050 const initializedByPlugins = []; 12051 import_element27.Children.forEach( 12052 fills, 12053 ({ 12054 props: { __unstableExplicitMenuItem, __unstableTarget } 12055 }) => { 12056 if (__unstableTarget && __unstableExplicitMenuItem) { 12057 initializedByPlugins.push(__unstableTarget); 12058 } 12059 } 12060 ); 12061 const children = import_element27.Children.map(fills, (child) => { 12062 if (!child.props.__unstableExplicitMenuItem && initializedByPlugins.includes( 12063 child.props.__unstableTarget 12064 )) { 12065 return null; 12066 } 12067 return child; 12068 }); 12069 return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(Component6, { ...props, children }); 12070 } 12071 } 12072 ); 12073 } 12074 function ActionItem({ name: name2, as: Component6 = import_components21.Button, onClick, ...props }) { 12075 return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(import_components21.Fill, { name: name2, children: ({ onClick: fpOnClick }) => { 12076 return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)( 12077 Component6, 12078 { 12079 onClick: onClick || fpOnClick ? (...args) => { 12080 (onClick || noop2)(...args); 12081 (fpOnClick || noop2)(...args); 12082 } : void 0, 12083 ...props 12084 } 12085 ); 12086 } }); 12087 } 12088 ActionItem.Slot = ActionItemSlot; 12089 var action_item_default = ActionItem; 12090 12091 // packages/interface/build-module/components/complementary-area-more-menu-item/index.js 12092 var import_jsx_runtime95 = __toESM(require_jsx_runtime()); 12093 var PluginsMenuItem = ({ 12094 // Menu item is marked with unstable prop for backward compatibility. 12095 // They are removed so they don't leak to DOM elements. 12096 // @see https://github.com/WordPress/gutenberg/issues/14457 12097 __unstableExplicitMenuItem, 12098 __unstableTarget, 12099 ...restProps 12100 }) => /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(import_components22.MenuItem, { ...restProps }); 12101 function ComplementaryAreaMoreMenuItem({ 12102 scope, 12103 target, 12104 __unstableExplicitMenuItem, 12105 ...props 12106 }) { 12107 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)( 12108 ComplementaryAreaToggle, 12109 { 12110 as: (toggleProps) => { 12111 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)( 12112 action_item_default, 12113 { 12114 __unstableExplicitMenuItem, 12115 __unstableTarget: `$scope}/$target}`, 12116 as: PluginsMenuItem, 12117 name: `$scope}/plugin-more-menu`, 12118 ...toggleProps 12119 } 12120 ); 12121 }, 12122 role: "menuitemcheckbox", 12123 selectedIcon: check_default, 12124 name: target, 12125 scope, 12126 ...props 12127 } 12128 ); 12129 } 12130 12131 // packages/interface/build-module/components/pinned-items/index.js 12132 var import_components23 = __toESM(require_components()); 12133 var import_jsx_runtime96 = __toESM(require_jsx_runtime()); 12134 function PinnedItems({ scope, ...props }) { 12135 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(import_components23.Fill, { name: `PinnedItems/$scope}`, ...props }); 12136 } 12137 function PinnedItemsSlot({ scope, className, ...props }) { 12138 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(import_components23.Slot, { name: `PinnedItems/$scope}`, ...props, children: (fills) => fills?.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime96.jsx)( 12139 "div", 12140 { 12141 className: clsx_default( 12142 className, 12143 "interface-pinned-items" 12144 ), 12145 children: fills 12146 } 12147 ) }); 12148 } 12149 PinnedItems.Slot = PinnedItemsSlot; 12150 var pinned_items_default = PinnedItems; 12151 12152 // packages/interface/build-module/components/complementary-area/index.js 12153 var import_jsx_runtime97 = __toESM(require_jsx_runtime()); 12154 var ANIMATION_DURATION = 0.3; 12155 function ComplementaryAreaSlot({ scope, ...props }) { 12156 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(import_components24.Slot, { name: `ComplementaryArea/$scope}`, ...props }); 12157 } 12158 var SIDEBAR_WIDTH = 280; 12159 var variants = { 12160 open: { width: SIDEBAR_WIDTH }, 12161 closed: { width: 0 }, 12162 mobileOpen: { width: "100vw" } 12163 }; 12164 function ComplementaryAreaFill({ 12165 activeArea, 12166 isActive, 12167 scope, 12168 children, 12169 className, 12170 id 12171 }) { 12172 const disableMotion = (0, import_compose7.useReducedMotion)(); 12173 const isMobileViewport = (0, import_compose7.useViewportMatch)("medium", "<"); 12174 const previousActiveArea = (0, import_compose7.usePrevious)(activeArea); 12175 const previousIsActive = (0, import_compose7.usePrevious)(isActive); 12176 const [, setState] = (0, import_element28.useState)({}); 12177 (0, import_element28.useEffect)(() => { 12178 setState({}); 12179 }, [isActive]); 12180 const transition = { 12181 type: "tween", 12182 duration: disableMotion || isMobileViewport || !!previousActiveArea && !!activeArea && activeArea !== previousActiveArea ? 0 : ANIMATION_DURATION, 12183 ease: [0.6, 0, 0.4, 1] 12184 }; 12185 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(import_components24.Fill, { name: `ComplementaryArea/$scope}`, children: /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(import_components24.__unstableAnimatePresence, { initial: false, children: (previousIsActive || isActive) && /* @__PURE__ */ (0, import_jsx_runtime97.jsx)( 12186 import_components24.__unstableMotion.div, 12187 { 12188 variants, 12189 initial: "closed", 12190 animate: isMobileViewport ? "mobileOpen" : "open", 12191 exit: "closed", 12192 transition, 12193 className: "interface-complementary-area__fill", 12194 children: /* @__PURE__ */ (0, import_jsx_runtime97.jsx)( 12195 "div", 12196 { 12197 id, 12198 className, 12199 style: { 12200 width: isMobileViewport ? "100vw" : SIDEBAR_WIDTH 12201 }, 12202 children 12203 } 12204 ) 12205 } 12206 ) }) }); 12207 } 12208 function useAdjustComplementaryListener(scope, identifier, activeArea, isActive, isSmall) { 12209 const previousIsSmallRef = (0, import_element28.useRef)(false); 12210 const shouldOpenWhenNotSmallRef = (0, import_element28.useRef)(false); 12211 const { enableComplementaryArea: enableComplementaryArea2, disableComplementaryArea: disableComplementaryArea2 } = (0, import_data35.useDispatch)(store2); 12212 (0, import_element28.useEffect)(() => { 12213 if (isActive && isSmall && !previousIsSmallRef.current) { 12214 disableComplementaryArea2(scope); 12215 shouldOpenWhenNotSmallRef.current = true; 12216 } else if ( 12217 // If there is a flag indicating the complementary area should be 12218 // enabled when we go from small to big window size and we are going 12219 // from a small to big window size. 12220 shouldOpenWhenNotSmallRef.current && !isSmall && previousIsSmallRef.current 12221 ) { 12222 shouldOpenWhenNotSmallRef.current = false; 12223 enableComplementaryArea2(scope, identifier); 12224 } else if ( 12225 // If the flag is indicating the current complementary should be 12226 // reopened but another complementary area becomes active, remove 12227 // the flag. 12228 shouldOpenWhenNotSmallRef.current && activeArea && activeArea !== identifier 12229 ) { 12230 shouldOpenWhenNotSmallRef.current = false; 12231 } 12232 if (isSmall !== previousIsSmallRef.current) { 12233 previousIsSmallRef.current = isSmall; 12234 } 12235 }, [ 12236 isActive, 12237 isSmall, 12238 scope, 12239 identifier, 12240 activeArea, 12241 disableComplementaryArea2, 12242 enableComplementaryArea2 12243 ]); 12244 } 12245 function ComplementaryArea({ 12246 children, 12247 className, 12248 closeLabel = (0, import_i18n50.__)("Close plugin"), 12249 identifier: identifierProp, 12250 header, 12251 headerClassName, 12252 icon: iconProp, 12253 isPinnable = true, 12254 panelClassName, 12255 scope, 12256 name: name2, 12257 title, 12258 toggleShortcut, 12259 isActiveByDefault 12260 }) { 12261 const context = (0, import_plugins2.usePluginContext)(); 12262 const icon = iconProp || context.icon; 12263 const identifier = identifierProp || `$context.name}/$name2}`; 12264 const [isReady2, setIsReady2] = (0, import_element28.useState)(false); 12265 const { 12266 isLoading, 12267 isActive, 12268 isPinned, 12269 activeArea, 12270 isSmall, 12271 isLarge, 12272 showIconLabels 12273 } = (0, import_data35.useSelect)( 12274 (select5) => { 12275 const { 12276 getActiveComplementaryArea: getActiveComplementaryArea2, 12277 isComplementaryAreaLoading: isComplementaryAreaLoading2, 12278 isItemPinned: isItemPinned2 12279 } = select5(store2); 12280 const { get } = select5(import_preferences6.store); 12281 const _activeArea = getActiveComplementaryArea2(scope); 12282 return { 12283 isLoading: isComplementaryAreaLoading2(scope), 12284 isActive: _activeArea === identifier, 12285 isPinned: isItemPinned2(scope, identifier), 12286 activeArea: _activeArea, 12287 isSmall: select5(import_viewport.store).isViewportMatch("< medium"), 12288 isLarge: select5(import_viewport.store).isViewportMatch("large"), 12289 showIconLabels: get("core", "showIconLabels") 12290 }; 12291 }, 12292 [identifier, scope] 12293 ); 12294 const isMobileViewport = (0, import_compose7.useViewportMatch)("medium", "<"); 12295 useAdjustComplementaryListener( 12296 scope, 12297 identifier, 12298 activeArea, 12299 isActive, 12300 isSmall 12301 ); 12302 const { 12303 enableComplementaryArea: enableComplementaryArea2, 12304 disableComplementaryArea: disableComplementaryArea2, 12305 pinItem: pinItem2, 12306 unpinItem: unpinItem2 12307 } = (0, import_data35.useDispatch)(store2); 12308 (0, import_element28.useEffect)(() => { 12309 if (isActiveByDefault && activeArea === void 0 && !isSmall) { 12310 enableComplementaryArea2(scope, identifier); 12311 } else if (activeArea === void 0 && isSmall) { 12312 disableComplementaryArea2(scope, identifier); 12313 } 12314 setIsReady2(true); 12315 }, [ 12316 activeArea, 12317 isActiveByDefault, 12318 scope, 12319 identifier, 12320 isSmall, 12321 enableComplementaryArea2, 12322 disableComplementaryArea2 12323 ]); 12324 if (!isReady2) { 12325 return; 12326 } 12327 return /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)(import_jsx_runtime97.Fragment, { children: [ 12328 isPinnable && /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(pinned_items_default, { scope, children: isPinned && /* @__PURE__ */ (0, import_jsx_runtime97.jsx)( 12329 ComplementaryAreaToggle, 12330 { 12331 scope, 12332 identifier, 12333 isPressed: isActive && (!showIconLabels || isLarge), 12334 "aria-expanded": isActive, 12335 "aria-disabled": isLoading, 12336 label: title, 12337 icon: showIconLabels ? check_default : icon, 12338 showTooltip: !showIconLabels, 12339 variant: showIconLabels ? "tertiary" : void 0, 12340 size: "compact", 12341 shortcut: toggleShortcut 12342 } 12343 ) }), 12344 name2 && isPinnable && /* @__PURE__ */ (0, import_jsx_runtime97.jsx)( 12345 ComplementaryAreaMoreMenuItem, 12346 { 12347 target: name2, 12348 scope, 12349 icon, 12350 identifier, 12351 children: title 12352 } 12353 ), 12354 /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)( 12355 ComplementaryAreaFill, 12356 { 12357 activeArea, 12358 isActive, 12359 className: clsx_default("interface-complementary-area", className), 12360 scope, 12361 id: identifier.replace("/", ":"), 12362 children: [ 12363 /* @__PURE__ */ (0, import_jsx_runtime97.jsx)( 12364 complementary_area_header_default, 12365 { 12366 className: headerClassName, 12367 closeLabel, 12368 onClose: () => disableComplementaryArea2(scope), 12369 toggleButtonProps: { 12370 label: closeLabel, 12371 size: "compact", 12372 shortcut: toggleShortcut, 12373 scope, 12374 identifier 12375 }, 12376 children: header || /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)(import_jsx_runtime97.Fragment, { children: [ 12377 /* @__PURE__ */ (0, import_jsx_runtime97.jsx)("h2", { className: "interface-complementary-area-header__title", children: title }), 12378 isPinnable && !isMobileViewport && /* @__PURE__ */ (0, import_jsx_runtime97.jsx)( 12379 import_components24.Button, 12380 { 12381 className: "interface-complementary-area__pin-unpin-item", 12382 icon: isPinned ? star_filled_default : star_empty_default, 12383 label: isPinned ? (0, import_i18n50.__)("Unpin from toolbar") : (0, import_i18n50.__)("Pin to toolbar"), 12384 onClick: () => (isPinned ? unpinItem2 : pinItem2)( 12385 scope, 12386 identifier 12387 ), 12388 isPressed: isPinned, 12389 "aria-expanded": isPinned, 12390 size: "compact" 12391 } 12392 ) 12393 ] }) 12394 } 12395 ), 12396 /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(import_components24.Panel, { className: panelClassName, children }) 12397 ] 12398 } 12399 ) 12400 ] }); 12401 } 12402 ComplementaryArea.Slot = ComplementaryAreaSlot; 12403 var complementary_area_default = ComplementaryArea; 12404 12405 // packages/interface/build-module/components/fullscreen-mode/index.js 12406 var import_element29 = __toESM(require_element()); 12407 var FullscreenMode = ({ isActive }) => { 12408 (0, import_element29.useEffect)(() => { 12409 let isSticky = false; 12410 if (document.body.classList.contains("sticky-menu")) { 12411 isSticky = true; 12412 document.body.classList.remove("sticky-menu"); 12413 } 12414 return () => { 12415 if (isSticky) { 12416 document.body.classList.add("sticky-menu"); 12417 } 12418 }; 12419 }, []); 12420 (0, import_element29.useEffect)(() => { 12421 if (isActive) { 12422 document.body.classList.add("is-fullscreen-mode"); 12423 } else { 12424 document.body.classList.remove("is-fullscreen-mode"); 12425 } 12426 return () => { 12427 if (isActive) { 12428 document.body.classList.remove("is-fullscreen-mode"); 12429 } 12430 }; 12431 }, [isActive]); 12432 return null; 12433 }; 12434 var fullscreen_mode_default = FullscreenMode; 12435 12436 // packages/admin-ui/build-module/navigable-region/index.js 12437 var import_element30 = __toESM(require_element()); 12438 var import_jsx_runtime98 = __toESM(require_jsx_runtime()); 12439 var NavigableRegion = (0, import_element30.forwardRef)( 12440 ({ children, className, ariaLabel, as: Tag = "div", ...props }, ref) => { 12441 return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)( 12442 Tag, 12443 { 12444 ref, 12445 className: clsx_default("admin-ui-navigable-region", className), 12446 "aria-label": ariaLabel, 12447 role: "region", 12448 tabIndex: "-1", 12449 ...props, 12450 children 12451 } 12452 ); 12453 } 12454 ); 12455 NavigableRegion.displayName = "NavigableRegion"; 12456 var navigable_region_default = NavigableRegion; 12457 12458 // packages/interface/build-module/components/interface-skeleton/index.js 12459 var import_element31 = __toESM(require_element()); 12460 var import_components25 = __toESM(require_components()); 12461 var import_i18n51 = __toESM(require_i18n()); 12462 var import_compose8 = __toESM(require_compose()); 12463 var import_jsx_runtime99 = __toESM(require_jsx_runtime()); 12464 var ANIMATION_DURATION2 = 0.25; 12465 var commonTransition = { 12466 type: "tween", 12467 duration: ANIMATION_DURATION2, 12468 ease: [0.6, 0, 0.4, 1] 12469 }; 12470 function useHTMLClass(className) { 12471 (0, import_element31.useEffect)(() => { 12472 const element = document && document.querySelector(`html:not(.$className})`); 12473 if (!element) { 12474 return; 12475 } 12476 element.classList.toggle(className); 12477 return () => { 12478 element.classList.toggle(className); 12479 }; 12480 }, [className]); 12481 } 12482 var headerVariants = { 12483 hidden: { opacity: 1, marginTop: -60 }, 12484 visible: { opacity: 1, marginTop: 0 }, 12485 distractionFreeHover: { 12486 opacity: 1, 12487 marginTop: 0, 12488 transition: { 12489 ...commonTransition, 12490 delay: 0.2, 12491 delayChildren: 0.2 12492 } 12493 }, 12494 distractionFreeHidden: { 12495 opacity: 0, 12496 marginTop: -60 12497 }, 12498 distractionFreeDisabled: { 12499 opacity: 0, 12500 marginTop: 0, 12501 transition: { 12502 ...commonTransition, 12503 delay: 0.8, 12504 delayChildren: 0.8 12505 } 12506 } 12507 }; 12508 function InterfaceSkeleton({ 12509 isDistractionFree, 12510 footer, 12511 header, 12512 editorNotices, 12513 sidebar, 12514 secondarySidebar, 12515 content, 12516 actions: actions2, 12517 labels, 12518 className 12519 }, ref) { 12520 const [secondarySidebarResizeListener, secondarySidebarSize] = (0, import_compose8.useResizeObserver)(); 12521 const isMobileViewport = (0, import_compose8.useViewportMatch)("medium", "<"); 12522 const disableMotion = (0, import_compose8.useReducedMotion)(); 12523 const defaultTransition = { 12524 type: "tween", 12525 duration: disableMotion ? 0 : ANIMATION_DURATION2, 12526 ease: [0.6, 0, 0.4, 1] 12527 }; 12528 useHTMLClass("interface-interface-skeleton__html-container"); 12529 const defaultLabels = { 12530 /* translators: accessibility text for the top bar landmark region. */ 12531 header: (0, import_i18n51._x)("Header", "header landmark area"), 12532 /* translators: accessibility text for the content landmark region. */ 12533 body: (0, import_i18n51.__)("Content"), 12534 /* translators: accessibility text for the secondary sidebar landmark region. */ 12535 secondarySidebar: (0, import_i18n51.__)("Block Library"), 12536 /* translators: accessibility text for the settings landmark region. */ 12537 sidebar: (0, import_i18n51._x)("Settings", "settings landmark area"), 12538 /* translators: accessibility text for the publish landmark region. */ 12539 actions: (0, import_i18n51.__)("Publish"), 12540 /* translators: accessibility text for the footer landmark region. */ 12541 footer: (0, import_i18n51.__)("Footer") 12542 }; 12543 const mergedLabels = { ...defaultLabels, ...labels }; 12544 return /* @__PURE__ */ (0, import_jsx_runtime99.jsxs)( 12545 "div", 12546 { 12547 ref, 12548 className: clsx_default( 12549 className, 12550 "interface-interface-skeleton", 12551 !!footer && "has-footer" 12552 ), 12553 children: [ 12554 /* @__PURE__ */ (0, import_jsx_runtime99.jsxs)("div", { className: "interface-interface-skeleton__editor", children: [ 12555 /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(import_components25.__unstableAnimatePresence, { initial: false, children: !!header && /* @__PURE__ */ (0, import_jsx_runtime99.jsx)( 12556 navigable_region_default, 12557 { 12558 as: import_components25.__unstableMotion.div, 12559 className: "interface-interface-skeleton__header", 12560 "aria-label": mergedLabels.header, 12561 initial: isDistractionFree && !isMobileViewport ? "distractionFreeHidden" : "hidden", 12562 whileHover: isDistractionFree && !isMobileViewport ? "distractionFreeHover" : "visible", 12563 animate: isDistractionFree && !isMobileViewport ? "distractionFreeDisabled" : "visible", 12564 exit: isDistractionFree && !isMobileViewport ? "distractionFreeHidden" : "hidden", 12565 variants: headerVariants, 12566 transition: defaultTransition, 12567 children: header 12568 } 12569 ) }), 12570 isDistractionFree && /* @__PURE__ */ (0, import_jsx_runtime99.jsx)("div", { className: "interface-interface-skeleton__header", children: editorNotices }), 12571 /* @__PURE__ */ (0, import_jsx_runtime99.jsxs)("div", { className: "interface-interface-skeleton__body", children: [ 12572 /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(import_components25.__unstableAnimatePresence, { initial: false, children: !!secondarySidebar && /* @__PURE__ */ (0, import_jsx_runtime99.jsx)( 12573 navigable_region_default, 12574 { 12575 className: "interface-interface-skeleton__secondary-sidebar", 12576 ariaLabel: mergedLabels.secondarySidebar, 12577 as: import_components25.__unstableMotion.div, 12578 initial: "closed", 12579 animate: "open", 12580 exit: "closed", 12581 variants: { 12582 open: { width: secondarySidebarSize.width }, 12583 closed: { width: 0 } 12584 }, 12585 transition: defaultTransition, 12586 children: /* @__PURE__ */ (0, import_jsx_runtime99.jsxs)( 12587 import_components25.__unstableMotion.div, 12588 { 12589 style: { 12590 position: "absolute", 12591 width: isMobileViewport ? "100vw" : "fit-content", 12592 height: "100%", 12593 left: 0 12594 }, 12595 variants: { 12596 open: { x: 0 }, 12597 closed: { x: "-100%" } 12598 }, 12599 transition: defaultTransition, 12600 children: [ 12601 secondarySidebarResizeListener, 12602 secondarySidebar 12603 ] 12604 } 12605 ) 12606 } 12607 ) }), 12608 /* @__PURE__ */ (0, import_jsx_runtime99.jsx)( 12609 navigable_region_default, 12610 { 12611 className: "interface-interface-skeleton__content", 12612 ariaLabel: mergedLabels.body, 12613 children: content 12614 } 12615 ), 12616 !!sidebar && /* @__PURE__ */ (0, import_jsx_runtime99.jsx)( 12617 navigable_region_default, 12618 { 12619 className: "interface-interface-skeleton__sidebar", 12620 ariaLabel: mergedLabels.sidebar, 12621 children: sidebar 12622 } 12623 ), 12624 !!actions2 && /* @__PURE__ */ (0, import_jsx_runtime99.jsx)( 12625 navigable_region_default, 12626 { 12627 className: "interface-interface-skeleton__actions", 12628 ariaLabel: mergedLabels.actions, 12629 children: actions2 12630 } 12631 ) 12632 ] }) 12633 ] }), 12634 !!footer && /* @__PURE__ */ (0, import_jsx_runtime99.jsx)( 12635 navigable_region_default, 12636 { 12637 className: "interface-interface-skeleton__footer", 12638 ariaLabel: mergedLabels.footer, 12639 children: footer 12640 } 12641 ) 12642 ] 12643 } 12644 ); 12645 } 12646 var interface_skeleton_default = (0, import_element31.forwardRef)(InterfaceSkeleton); 12647 12648 // packages/editor/build-module/components/commands/index.js 12649 var import_html_entities8 = __toESM(require_html_entities()); 12650 12651 // packages/editor/build-module/components/pattern-rename-modal/index.js 12652 var import_data36 = __toESM(require_data()); 12653 var import_patterns5 = __toESM(require_patterns()); 12654 var import_core_data24 = __toESM(require_core_data()); 12655 var import_jsx_runtime100 = __toESM(require_jsx_runtime()); 12656 var { RenamePatternModal } = unlock(import_patterns5.privateApis); 12657 var modalName = "editor/pattern-rename"; 12658 function PatternRenameModal() { 12659 const isActive = (0, import_data36.useSelect)( 12660 (select5) => select5(store2).isModalActive(modalName) 12661 ); 12662 const { record, postType: postType2 } = (0, import_data36.useSelect)( 12663 (select5) => { 12664 if (!isActive) { 12665 return {}; 12666 } 12667 const { getCurrentPostType: getCurrentPostType2, getCurrentPostId: getCurrentPostId2 } = select5(store); 12668 const { getEditedEntityRecord } = select5(import_core_data24.store); 12669 const _postType = getCurrentPostType2(); 12670 return { 12671 record: getEditedEntityRecord( 12672 "postType", 12673 _postType, 12674 getCurrentPostId2() 12675 ), 12676 postType: _postType 12677 }; 12678 }, 12679 [isActive] 12680 ); 12681 const { closeModal: closeModal2 } = (0, import_data36.useDispatch)(store2); 12682 if (!isActive || postType2 !== PATTERN_POST_TYPE) { 12683 return null; 12684 } 12685 return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(RenamePatternModal, { onClose: closeModal2, pattern: record }); 12686 } 12687 12688 // packages/editor/build-module/components/pattern-duplicate-modal/index.js 12689 var import_data37 = __toESM(require_data()); 12690 var import_patterns6 = __toESM(require_patterns()); 12691 var import_core_data25 = __toESM(require_core_data()); 12692 var import_jsx_runtime101 = __toESM(require_jsx_runtime()); 12693 var { DuplicatePatternModal } = unlock(import_patterns6.privateApis); 12694 var modalName2 = "editor/pattern-duplicate"; 12695 function PatternDuplicateModal() { 12696 const isActive = (0, import_data37.useSelect)( 12697 (select5) => select5(store2).isModalActive(modalName2) 12698 ); 12699 const { record, postType: postType2 } = (0, import_data37.useSelect)( 12700 (select5) => { 12701 if (!isActive) { 12702 return {}; 12703 } 12704 const { getCurrentPostType: getCurrentPostType2, getCurrentPostId: getCurrentPostId2 } = select5(store); 12705 const { getEditedEntityRecord } = select5(import_core_data25.store); 12706 const _postType = getCurrentPostType2(); 12707 return { 12708 record: getEditedEntityRecord( 12709 "postType", 12710 _postType, 12711 getCurrentPostId2() 12712 ), 12713 postType: _postType 12714 }; 12715 }, 12716 [isActive] 12717 ); 12718 const { closeModal: closeModal2 } = (0, import_data37.useDispatch)(store2); 12719 if (!isActive || postType2 !== PATTERN_POST_TYPE) { 12720 return null; 12721 } 12722 return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)( 12723 DuplicatePatternModal, 12724 { 12725 onClose: closeModal2, 12726 onSuccess: () => closeModal2(), 12727 pattern: record 12728 } 12729 ); 12730 } 12731 12732 // packages/editor/build-module/components/commands/index.js 12733 var getEditorCommandLoader = () => function useEditorCommandLoader() { 12734 const { 12735 editorMode, 12736 isListViewOpen, 12737 showBlockBreadcrumbs, 12738 isDistractionFree, 12739 isFocusMode, 12740 isPreviewMode, 12741 isViewable, 12742 isCodeEditingEnabled, 12743 isRichEditingEnabled, 12744 isPublishSidebarEnabled: isPublishSidebarEnabled2 12745 } = (0, import_data38.useSelect)((select5) => { 12746 const { get } = select5(import_preferences7.store); 12747 const { isListViewOpened: isListViewOpened2, getCurrentPostType: getCurrentPostType2, getEditorSettings: getEditorSettings2 } = select5(store); 12748 const { getSettings: getSettings5 } = select5(import_block_editor10.store); 12749 const { getPostType } = select5(import_core_data26.store); 12750 return { 12751 editorMode: get("core", "editorMode") ?? "visual", 12752 isListViewOpen: isListViewOpened2(), 12753 showBlockBreadcrumbs: get("core", "showBlockBreadcrumbs"), 12754 isDistractionFree: get("core", "distractionFree"), 12755 isFocusMode: get("core", "focusMode"), 12756 isPreviewMode: getSettings5().isPreviewMode, 12757 isViewable: getPostType(getCurrentPostType2())?.viewable ?? false, 12758 isCodeEditingEnabled: getEditorSettings2().codeEditingEnabled, 12759 isRichEditingEnabled: getEditorSettings2().richEditingEnabled, 12760 isPublishSidebarEnabled: select5(store).isPublishSidebarEnabled() 12761 }; 12762 }, []); 12763 const { getActiveComplementaryArea: getActiveComplementaryArea2 } = (0, import_data38.useSelect)(store2); 12764 const { toggle } = (0, import_data38.useDispatch)(import_preferences7.store); 12765 const { createInfoNotice } = (0, import_data38.useDispatch)(import_notices13.store); 12766 const { 12767 __unstableSaveForPreview: __unstableSaveForPreview2, 12768 setIsListViewOpened: setIsListViewOpened2, 12769 switchEditorMode: switchEditorMode2, 12770 toggleDistractionFree: toggleDistractionFree2, 12771 toggleSpotlightMode: toggleSpotlightMode2, 12772 toggleTopToolbar: toggleTopToolbar2 12773 } = (0, import_data38.useDispatch)(store); 12774 const { openModal: openModal2, enableComplementaryArea: enableComplementaryArea2, disableComplementaryArea: disableComplementaryArea2 } = (0, import_data38.useDispatch)(store2); 12775 const { getCurrentPostId: getCurrentPostId2 } = (0, import_data38.useSelect)(store); 12776 const allowSwitchEditorMode = isCodeEditingEnabled && isRichEditingEnabled; 12777 if (isPreviewMode) { 12778 return { commands: [], isLoading: false }; 12779 } 12780 const commands = []; 12781 commands.push({ 12782 name: "core/open-shortcut-help", 12783 label: (0, import_i18n52.__)("Keyboard shortcuts"), 12784 icon: keyboard_default, 12785 callback: ({ close }) => { 12786 close(); 12787 openModal2("editor/keyboard-shortcut-help"); 12788 } 12789 }); 12790 commands.push({ 12791 name: "core/toggle-distraction-free", 12792 label: isDistractionFree ? (0, import_i18n52.__)("Exit Distraction free") : (0, import_i18n52.__)("Enter Distraction free"), 12793 callback: ({ close }) => { 12794 toggleDistractionFree2(); 12795 close(); 12796 } 12797 }); 12798 commands.push({ 12799 name: "core/open-preferences", 12800 label: (0, import_i18n52.__)("Editor preferences"), 12801 callback: ({ close }) => { 12802 close(); 12803 openModal2("editor/preferences"); 12804 } 12805 }); 12806 commands.push({ 12807 name: "core/toggle-spotlight-mode", 12808 label: isFocusMode ? (0, import_i18n52.__)("Exit Spotlight mode") : (0, import_i18n52.__)("Enter Spotlight mode"), 12809 callback: ({ close }) => { 12810 toggleSpotlightMode2(); 12811 close(); 12812 } 12813 }); 12814 commands.push({ 12815 name: "core/toggle-list-view", 12816 label: isListViewOpen ? (0, import_i18n52.__)("Close List View") : (0, import_i18n52.__)("Open List View"), 12817 icon: list_view_default, 12818 callback: ({ close }) => { 12819 setIsListViewOpened2(!isListViewOpen); 12820 close(); 12821 createInfoNotice( 12822 isListViewOpen ? (0, import_i18n52.__)("List View off.") : (0, import_i18n52.__)("List View on."), 12823 { 12824 id: "core/editor/toggle-list-view/notice", 12825 type: "snackbar" 12826 } 12827 ); 12828 } 12829 }); 12830 commands.push({ 12831 name: "core/toggle-top-toolbar", 12832 label: (0, import_i18n52.__)("Top toolbar"), 12833 callback: ({ close }) => { 12834 toggleTopToolbar2(); 12835 close(); 12836 } 12837 }); 12838 if (allowSwitchEditorMode) { 12839 commands.push({ 12840 name: "core/toggle-code-editor", 12841 label: editorMode === "visual" ? (0, import_i18n52.__)("Open code editor") : (0, import_i18n52.__)("Exit code editor"), 12842 icon: code_default, 12843 callback: ({ close }) => { 12844 switchEditorMode2( 12845 editorMode === "visual" ? "text" : "visual" 12846 ); 12847 close(); 12848 } 12849 }); 12850 } 12851 commands.push({ 12852 name: "core/toggle-breadcrumbs", 12853 label: showBlockBreadcrumbs ? (0, import_i18n52.__)("Hide block breadcrumbs") : (0, import_i18n52.__)("Show block breadcrumbs"), 12854 callback: ({ close }) => { 12855 toggle("core", "showBlockBreadcrumbs"); 12856 close(); 12857 createInfoNotice( 12858 showBlockBreadcrumbs ? (0, import_i18n52.__)("Breadcrumbs hidden.") : (0, import_i18n52.__)("Breadcrumbs visible."), 12859 { 12860 id: "core/editor/toggle-breadcrumbs/notice", 12861 type: "snackbar" 12862 } 12863 ); 12864 } 12865 }); 12866 commands.push({ 12867 name: "core/open-settings-sidebar", 12868 label: (0, import_i18n52.__)("Show or hide the Settings panel"), 12869 icon: (0, import_i18n52.isRTL)() ? drawer_left_default : drawer_right_default, 12870 callback: ({ close }) => { 12871 const activeSidebar = getActiveComplementaryArea2("core"); 12872 close(); 12873 if (activeSidebar === "edit-post/document") { 12874 disableComplementaryArea2("core"); 12875 } else { 12876 enableComplementaryArea2("core", "edit-post/document"); 12877 } 12878 } 12879 }); 12880 commands.push({ 12881 name: "core/open-block-inspector", 12882 label: (0, import_i18n52.__)("Show or hide the Block settings panel"), 12883 icon: block_default_default, 12884 callback: ({ close }) => { 12885 const activeSidebar = getActiveComplementaryArea2("core"); 12886 close(); 12887 if (activeSidebar === "edit-post/block") { 12888 disableComplementaryArea2("core"); 12889 } else { 12890 enableComplementaryArea2("core", "edit-post/block"); 12891 } 12892 } 12893 }); 12894 commands.push({ 12895 name: "core/toggle-publish-sidebar", 12896 label: isPublishSidebarEnabled2 ? (0, import_i18n52.__)("Disable pre-publish checks") : (0, import_i18n52.__)("Enable pre-publish checks"), 12897 icon: format_list_bullets_default, 12898 callback: ({ close }) => { 12899 close(); 12900 toggle("core", "isPublishSidebarEnabled"); 12901 createInfoNotice( 12902 isPublishSidebarEnabled2 ? (0, import_i18n52.__)("Pre-publish checks disabled.") : (0, import_i18n52.__)("Pre-publish checks enabled."), 12903 { 12904 id: "core/editor/publish-sidebar/notice", 12905 type: "snackbar" 12906 } 12907 ); 12908 } 12909 }); 12910 if (isViewable) { 12911 commands.push({ 12912 name: "core/preview-link", 12913 label: (0, import_i18n52.__)("Preview in a new tab"), 12914 icon: external_default, 12915 callback: async ({ close }) => { 12916 close(); 12917 const postId2 = getCurrentPostId2(); 12918 const link = await __unstableSaveForPreview2(); 12919 window.open(link, `wp-preview-$postId2}`); 12920 } 12921 }); 12922 } 12923 return { 12924 commands, 12925 isLoading: false 12926 }; 12927 }; 12928 var getEditedEntityContextualCommands = () => function useEditedEntityContextualCommands() { 12929 const { postType: postType2 } = (0, import_data38.useSelect)((select5) => { 12930 const { getCurrentPostType: getCurrentPostType2 } = select5(store); 12931 return { 12932 postType: getCurrentPostType2() 12933 }; 12934 }, []); 12935 const { openModal: openModal2 } = (0, import_data38.useDispatch)(store2); 12936 const commands = []; 12937 if (postType2 === PATTERN_POST_TYPE) { 12938 commands.push({ 12939 name: "core/rename-pattern", 12940 label: (0, import_i18n52.__)("Rename pattern"), 12941 icon: pencil_default, 12942 callback: ({ close }) => { 12943 openModal2(modalName); 12944 close(); 12945 } 12946 }); 12947 commands.push({ 12948 name: "core/duplicate-pattern", 12949 label: (0, import_i18n52.__)("Duplicate pattern"), 12950 icon: symbol_default, 12951 callback: ({ close }) => { 12952 openModal2(modalName2); 12953 close(); 12954 } 12955 }); 12956 } 12957 return { isLoading: false, commands }; 12958 }; 12959 var getPageContentFocusCommands = () => function usePageContentFocusCommands() { 12960 const { 12961 onNavigateToEntityRecord, 12962 goBack, 12963 templateId: templateId2, 12964 isPreviewMode, 12965 canEditTemplate 12966 } = (0, import_data38.useSelect)((select5) => { 12967 const { 12968 getRenderingMode: getRenderingMode2, 12969 getEditorSettings: _getEditorSettings, 12970 getCurrentTemplateId: getCurrentTemplateId2 12971 } = unlock(select5(store)); 12972 const editorSettings2 = _getEditorSettings(); 12973 const _templateId = getCurrentTemplateId2(); 12974 return { 12975 isTemplateHidden: getRenderingMode2() === "post-only", 12976 onNavigateToEntityRecord: editorSettings2.onNavigateToEntityRecord, 12977 getEditorSettings: _getEditorSettings, 12978 goBack: editorSettings2.onNavigateToPreviousEntityRecord, 12979 templateId: _templateId, 12980 isPreviewMode: editorSettings2.isPreviewMode, 12981 canEditTemplate: !!_templateId && select5(import_core_data26.store).canUser("update", { 12982 kind: "postType", 12983 name: "wp_template", 12984 id: _templateId 12985 }) 12986 }; 12987 }, []); 12988 const { editedRecord: template2, hasResolved } = (0, import_core_data26.useEntityRecord)( 12989 "postType", 12990 "wp_template", 12991 templateId2 12992 ); 12993 if (isPreviewMode) { 12994 return { isLoading: false, commands: [] }; 12995 } 12996 const commands = []; 12997 if (templateId2 && hasResolved && canEditTemplate) { 12998 commands.push({ 12999 name: "core/switch-to-template-focus", 13000 label: (0, import_i18n52.sprintf)( 13001 /* translators: %s: template title */ 13002 (0, import_i18n52.__)("Edit template: %s"), 13003 (0, import_html_entities8.decodeEntities)(template2.title) 13004 ), 13005 icon: layout_default, 13006 callback: ({ close }) => { 13007 onNavigateToEntityRecord({ 13008 postId: templateId2, 13009 postType: "wp_template" 13010 }); 13011 close(); 13012 } 13013 }); 13014 } 13015 if (!!goBack) { 13016 commands.push({ 13017 name: "core/switch-to-previous-entity", 13018 label: (0, import_i18n52.__)("Go back"), 13019 icon: page_default, 13020 callback: ({ close }) => { 13021 goBack(); 13022 close(); 13023 } 13024 }); 13025 } 13026 return { isLoading: false, commands }; 13027 }; 13028 var getManipulateDocumentCommands = () => function useManipulateDocumentCommands() { 13029 const { postType: postType2, postId: postId2 } = (0, import_data38.useSelect)((select5) => { 13030 const { getCurrentPostId: getCurrentPostId2, getCurrentPostType: getCurrentPostType2 } = select5(store); 13031 return { 13032 postType: getCurrentPostType2(), 13033 postId: getCurrentPostId2() 13034 }; 13035 }, []); 13036 const { editedRecord: template2, hasResolved } = (0, import_core_data26.useEntityRecord)( 13037 "postType", 13038 postType2, 13039 postId2 13040 ); 13041 const { revertTemplate: revertTemplate3 } = unlock((0, import_data38.useDispatch)(store)); 13042 if (!hasResolved || ![TEMPLATE_PART_POST_TYPE, TEMPLATE_POST_TYPE].includes( 13043 postType2 13044 )) { 13045 return { isLoading: true, commands: [] }; 13046 } 13047 const commands = []; 13048 if (isTemplateRevertable(template2)) { 13049 const label = template2.type === TEMPLATE_POST_TYPE ? (0, import_i18n52.sprintf)( 13050 /* translators: %s: template title */ 13051 (0, import_i18n52.__)("Reset template: %s"), 13052 (0, import_html_entities8.decodeEntities)(template2.title) 13053 ) : (0, import_i18n52.sprintf)( 13054 /* translators: %s: template part title */ 13055 (0, import_i18n52.__)("Reset template part: %s"), 13056 (0, import_html_entities8.decodeEntities)(template2.title) 13057 ); 13058 commands.push({ 13059 name: "core/reset-template", 13060 label, 13061 icon: (0, import_i18n52.isRTL)() ? rotate_right_default : rotate_left_default, 13062 callback: ({ close }) => { 13063 revertTemplate3(template2); 13064 close(); 13065 } 13066 }); 13067 } 13068 return { 13069 isLoading: !hasResolved, 13070 commands 13071 }; 13072 }; 13073 function useCommands() { 13074 (0, import_commands.useCommandLoader)({ 13075 name: "core/editor/edit-ui", 13076 hook: getEditorCommandLoader() 13077 }); 13078 (0, import_commands.useCommandLoader)({ 13079 name: "core/editor/contextual-commands", 13080 hook: getEditedEntityContextualCommands(), 13081 context: "entity-edit" 13082 }); 13083 (0, import_commands.useCommandLoader)({ 13084 name: "core/editor/page-content-focus", 13085 hook: getPageContentFocusCommands(), 13086 context: "entity-edit" 13087 }); 13088 (0, import_commands.useCommandLoader)({ 13089 name: "core/edit-site/manipulate-document", 13090 hook: getManipulateDocumentCommands() 13091 }); 13092 } 13093 13094 // packages/editor/build-module/components/block-removal-warnings/index.js 13095 var import_i18n53 = __toESM(require_i18n()); 13096 var import_block_editor11 = __toESM(require_block_editor()); 13097 var import_data39 = __toESM(require_data()); 13098 var import_element32 = __toESM(require_element()); 13099 var import_jsx_runtime102 = __toESM(require_jsx_runtime()); 13100 var { BlockRemovalWarningModal } = unlock(import_block_editor11.privateApis); 13101 var TEMPLATE_BLOCKS = [ 13102 "core/post-content", 13103 "core/post-template", 13104 "core/query" 13105 ]; 13106 var BLOCK_REMOVAL_RULES = [ 13107 { 13108 // Template blocks. 13109 // The warning is only shown when a user manipulates templates or template parts. 13110 postTypes: ["wp_template", "wp_template_part"], 13111 callback(removedBlocks) { 13112 const removedTemplateBlocks = removedBlocks.filter( 13113 ({ name: name2 }) => TEMPLATE_BLOCKS.includes(name2) 13114 ); 13115 if (removedTemplateBlocks.length) { 13116 return (0, import_i18n53._n)( 13117 "Deleting this block will stop your post or page content from displaying on this template. It is not recommended.", 13118 "Some of the deleted blocks will stop your post or page content from displaying on this template. It is not recommended.", 13119 removedBlocks.length 13120 ); 13121 } 13122 } 13123 }, 13124 { 13125 // Pattern overrides. 13126 // The warning is only shown when the user edits a pattern. 13127 postTypes: ["wp_block"], 13128 callback(removedBlocks) { 13129 const removedBlocksWithOverrides = removedBlocks.filter( 13130 ({ attributes }) => attributes?.metadata?.bindings && Object.values(attributes.metadata.bindings).some( 13131 (binding) => binding.source === "core/pattern-overrides" 13132 ) 13133 ); 13134 if (removedBlocksWithOverrides.length) { 13135 return (0, import_i18n53._n)( 13136 "The deleted block allows instance overrides. Removing it may result in content not displaying where this pattern is used. Are you sure you want to proceed?", 13137 "Some of the deleted blocks allow instance overrides. Removing them may result in content not displaying where this pattern is used. Are you sure you want to proceed?", 13138 removedBlocks.length 13139 ); 13140 } 13141 } 13142 } 13143 ]; 13144 function BlockRemovalWarnings() { 13145 const currentPostType = (0, import_data39.useSelect)( 13146 (select5) => select5(store).getCurrentPostType(), 13147 [] 13148 ); 13149 const removalRulesForPostType = (0, import_element32.useMemo)( 13150 () => BLOCK_REMOVAL_RULES.filter( 13151 (rule) => rule.postTypes.includes(currentPostType) 13152 ), 13153 [currentPostType] 13154 ); 13155 if (!BlockRemovalWarningModal) { 13156 return null; 13157 } 13158 if (!removalRulesForPostType) { 13159 return null; 13160 } 13161 return /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(BlockRemovalWarningModal, { rules: removalRulesForPostType }); 13162 } 13163 13164 // packages/editor/build-module/components/start-page-options/index.js 13165 var import_components26 = __toESM(require_components()); 13166 var import_i18n54 = __toESM(require_i18n()); 13167 var import_element33 = __toESM(require_element()); 13168 var import_block_editor12 = __toESM(require_block_editor()); 13169 var import_data40 = __toESM(require_data()); 13170 var import_core_data27 = __toESM(require_core_data()); 13171 var import_blocks10 = __toESM(require_blocks()); 13172 var import_preferences8 = __toESM(require_preferences()); 13173 var import_jsx_runtime103 = __toESM(require_jsx_runtime()); 13174 function useStartPatterns() { 13175 const { blockPatternsWithPostContentBlockType, postType: postType2 } = (0, import_data40.useSelect)( 13176 (select5) => { 13177 const { getPatternsByBlockTypes, getBlocksByName } = select5(import_block_editor12.store); 13178 const { getCurrentPostType: getCurrentPostType2, getRenderingMode: getRenderingMode2 } = select5(store); 13179 const rootClientId = getRenderingMode2() === "post-only" ? "" : getBlocksByName("core/post-content")?.[0]; 13180 return { 13181 blockPatternsWithPostContentBlockType: getPatternsByBlockTypes( 13182 "core/post-content", 13183 rootClientId 13184 ), 13185 postType: getCurrentPostType2() 13186 }; 13187 }, 13188 [] 13189 ); 13190 return (0, import_element33.useMemo)(() => { 13191 if (!blockPatternsWithPostContentBlockType?.length) { 13192 return []; 13193 } 13194 return blockPatternsWithPostContentBlockType.filter((pattern) => { 13195 return postType2 === "page" && !pattern.postTypes || Array.isArray(pattern.postTypes) && pattern.postTypes.includes(postType2); 13196 }); 13197 }, [postType2, blockPatternsWithPostContentBlockType]); 13198 } 13199 function PatternSelection({ blockPatterns, onChoosePattern }) { 13200 const { editEntityRecord } = (0, import_data40.useDispatch)(import_core_data27.store); 13201 const { postType: postType2, postId: postId2 } = (0, import_data40.useSelect)((select5) => { 13202 const { getCurrentPostType: getCurrentPostType2, getCurrentPostId: getCurrentPostId2 } = select5(store); 13203 return { 13204 postType: getCurrentPostType2(), 13205 postId: getCurrentPostId2() 13206 }; 13207 }, []); 13208 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)( 13209 import_block_editor12.__experimentalBlockPatternsList, 13210 { 13211 blockPatterns, 13212 onClickPattern: (_pattern, blocks) => { 13213 editEntityRecord("postType", postType2, postId2, { 13214 blocks, 13215 content: ({ blocks: blocksForSerialization = [] }) => (0, import_blocks10.__unstableSerializeAndClean)(blocksForSerialization) 13216 }); 13217 onChoosePattern(); 13218 } 13219 } 13220 ); 13221 } 13222 function StartPageOptionsModal({ onClose }) { 13223 const [showStartPatterns, setShowStartPatterns] = (0, import_element33.useState)(true); 13224 const { set: setPreference } = (0, import_data40.useDispatch)(import_preferences8.store); 13225 const startPatterns = useStartPatterns(); 13226 const hasStartPattern = startPatterns.length > 0; 13227 if (!hasStartPattern) { 13228 return null; 13229 } 13230 function handleClose() { 13231 onClose(); 13232 setPreference("core", "enableChoosePatternModal", showStartPatterns); 13233 } 13234 return /* @__PURE__ */ (0, import_jsx_runtime103.jsxs)( 13235 import_components26.Modal, 13236 { 13237 className: "editor-start-page-options__modal", 13238 title: (0, import_i18n54.__)("Choose a pattern"), 13239 isFullScreen: true, 13240 onRequestClose: handleClose, 13241 children: [ 13242 /* @__PURE__ */ (0, import_jsx_runtime103.jsx)("div", { className: "editor-start-page-options__modal-content", children: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)( 13243 PatternSelection, 13244 { 13245 blockPatterns: startPatterns, 13246 onChoosePattern: handleClose 13247 } 13248 ) }), 13249 /* @__PURE__ */ (0, import_jsx_runtime103.jsx)( 13250 import_components26.Flex, 13251 { 13252 className: "editor-start-page-options__modal__actions", 13253 justify: "flex-start", 13254 expanded: false, 13255 children: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(import_components26.FlexItem, { children: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)( 13256 import_components26.CheckboxControl, 13257 { 13258 checked: showStartPatterns, 13259 label: (0, import_i18n54.__)( 13260 "Always show starter patterns for new pages" 13261 ), 13262 onChange: (newValue) => { 13263 setShowStartPatterns(newValue); 13264 } 13265 } 13266 ) }) 13267 } 13268 ) 13269 ] 13270 } 13271 ); 13272 } 13273 function StartPageOptions() { 13274 const [isOpen, setIsOpen] = (0, import_element33.useState)(false); 13275 const { isEditedPostDirty: isEditedPostDirty2, isEditedPostEmpty: isEditedPostEmpty2 } = (0, import_data40.useSelect)(store); 13276 const { isModalActive: isModalActive2 } = (0, import_data40.useSelect)(store2); 13277 const { enabled, postId: postId2 } = (0, import_data40.useSelect)((select5) => { 13278 const { getCurrentPostId: getCurrentPostId2, getCurrentPostType: getCurrentPostType2 } = select5(store); 13279 const choosePatternModalEnabled = select5(import_preferences8.store).get( 13280 "core", 13281 "enableChoosePatternModal" 13282 ); 13283 const currentPostType = getCurrentPostType2(); 13284 return { 13285 postId: getCurrentPostId2(), 13286 enabled: choosePatternModalEnabled && TEMPLATE_POST_TYPE !== currentPostType && TEMPLATE_PART_POST_TYPE !== currentPostType 13287 }; 13288 }, []); 13289 (0, import_element33.useEffect)(() => { 13290 const isFreshPage = !isEditedPostDirty2() && isEditedPostEmpty2(); 13291 const isPreferencesModalActive = isModalActive2("editor/preferences"); 13292 if (!enabled || !isFreshPage || isPreferencesModalActive) { 13293 return; 13294 } 13295 setIsOpen(true); 13296 }, [ 13297 enabled, 13298 postId2, 13299 isEditedPostDirty2, 13300 isEditedPostEmpty2, 13301 isModalActive2 13302 ]); 13303 if (!isOpen) { 13304 return null; 13305 } 13306 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(StartPageOptionsModal, { onClose: () => setIsOpen(false) }); 13307 } 13308 13309 // packages/editor/build-module/components/keyboard-shortcut-help-modal/index.js 13310 var import_components27 = __toESM(require_components()); 13311 var import_i18n56 = __toESM(require_i18n()); 13312 var import_keyboard_shortcuts2 = __toESM(require_keyboard_shortcuts()); 13313 var import_data42 = __toESM(require_data()); 13314 13315 // packages/editor/build-module/components/keyboard-shortcut-help-modal/config.js 13316 var import_i18n55 = __toESM(require_i18n()); 13317 var textFormattingShortcuts = [ 13318 { 13319 keyCombination: { modifier: "primary", character: "b" }, 13320 description: (0, import_i18n55.__)("Make the selected text bold.") 13321 }, 13322 { 13323 keyCombination: { modifier: "primary", character: "i" }, 13324 description: (0, import_i18n55.__)("Make the selected text italic.") 13325 }, 13326 { 13327 keyCombination: { modifier: "primary", character: "k" }, 13328 description: (0, import_i18n55.__)("Convert the selected text into a link.") 13329 }, 13330 { 13331 keyCombination: { modifier: "primaryShift", character: "k" }, 13332 description: (0, import_i18n55.__)("Remove a link.") 13333 }, 13334 { 13335 keyCombination: { character: "[[" }, 13336 description: (0, import_i18n55.__)("Insert a link to a post or page.") 13337 }, 13338 { 13339 keyCombination: { modifier: "primary", character: "u" }, 13340 description: (0, import_i18n55.__)("Underline the selected text.") 13341 }, 13342 { 13343 keyCombination: { modifier: "access", character: "d" }, 13344 description: (0, import_i18n55.__)("Strikethrough the selected text.") 13345 }, 13346 { 13347 keyCombination: { modifier: "access", character: "x" }, 13348 description: (0, import_i18n55.__)("Make the selected text inline code.") 13349 }, 13350 { 13351 keyCombination: { 13352 modifier: "access", 13353 character: "0" 13354 }, 13355 aliases: [ 13356 { 13357 modifier: "access", 13358 character: "7" 13359 } 13360 ], 13361 description: (0, import_i18n55.__)("Convert the current heading to a paragraph.") 13362 }, 13363 { 13364 keyCombination: { modifier: "access", character: "1-6" }, 13365 description: (0, import_i18n55.__)( 13366 "Convert the current paragraph or heading to a heading of level 1 to 6." 13367 ) 13368 }, 13369 { 13370 keyCombination: { modifier: "primaryShift", character: "SPACE" }, 13371 description: (0, import_i18n55.__)("Add non breaking space.") 13372 } 13373 ]; 13374 13375 // packages/editor/build-module/components/keyboard-shortcut-help-modal/shortcut.js 13376 var import_element34 = __toESM(require_element()); 13377 var import_keycodes = __toESM(require_keycodes()); 13378 var import_jsx_runtime104 = __toESM(require_jsx_runtime()); 13379 function KeyCombination({ keyCombination, forceAriaLabel }) { 13380 const shortcut = keyCombination.modifier ? import_keycodes.displayShortcutList[keyCombination.modifier]( 13381 keyCombination.character 13382 ) : keyCombination.character; 13383 const ariaLabel = keyCombination.modifier ? import_keycodes.shortcutAriaLabel[keyCombination.modifier]( 13384 keyCombination.character 13385 ) : keyCombination.character; 13386 return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)( 13387 "kbd", 13388 { 13389 className: "editor-keyboard-shortcut-help-modal__shortcut-key-combination", 13390 "aria-label": forceAriaLabel || ariaLabel, 13391 children: (Array.isArray(shortcut) ? shortcut : [shortcut]).map( 13392 (character, index2) => { 13393 if (character === "+") { 13394 return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(import_element34.Fragment, { children: character }, index2); 13395 } 13396 return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)( 13397 "kbd", 13398 { 13399 className: "editor-keyboard-shortcut-help-modal__shortcut-key", 13400 children: character 13401 }, 13402 index2 13403 ); 13404 } 13405 ) 13406 } 13407 ); 13408 } 13409 function Shortcut({ description, keyCombination, aliases = [], ariaLabel }) { 13410 return /* @__PURE__ */ (0, import_jsx_runtime104.jsxs)(import_jsx_runtime104.Fragment, { children: [ 13411 /* @__PURE__ */ (0, import_jsx_runtime104.jsx)("div", { className: "editor-keyboard-shortcut-help-modal__shortcut-description", children: description }), 13412 /* @__PURE__ */ (0, import_jsx_runtime104.jsxs)("div", { className: "editor-keyboard-shortcut-help-modal__shortcut-term", children: [ 13413 /* @__PURE__ */ (0, import_jsx_runtime104.jsx)( 13414 KeyCombination, 13415 { 13416 keyCombination, 13417 forceAriaLabel: ariaLabel 13418 } 13419 ), 13420 aliases.map((alias, index2) => /* @__PURE__ */ (0, import_jsx_runtime104.jsx)( 13421 KeyCombination, 13422 { 13423 keyCombination: alias, 13424 forceAriaLabel: ariaLabel 13425 }, 13426 index2 13427 )) 13428 ] }) 13429 ] }); 13430 } 13431 var shortcut_default = Shortcut; 13432 13433 // packages/editor/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js 13434 var import_data41 = __toESM(require_data()); 13435 var import_keyboard_shortcuts = __toESM(require_keyboard_shortcuts()); 13436 var import_jsx_runtime105 = __toESM(require_jsx_runtime()); 13437 function DynamicShortcut({ name: name2 }) { 13438 const { keyCombination, description, aliases } = (0, import_data41.useSelect)( 13439 (select5) => { 13440 const { 13441 getShortcutKeyCombination, 13442 getShortcutDescription, 13443 getShortcutAliases 13444 } = select5(import_keyboard_shortcuts.store); 13445 return { 13446 keyCombination: getShortcutKeyCombination(name2), 13447 aliases: getShortcutAliases(name2), 13448 description: getShortcutDescription(name2) 13449 }; 13450 }, 13451 [name2] 13452 ); 13453 if (!keyCombination) { 13454 return null; 13455 } 13456 return /* @__PURE__ */ (0, import_jsx_runtime105.jsx)( 13457 shortcut_default, 13458 { 13459 keyCombination, 13460 description, 13461 aliases 13462 } 13463 ); 13464 } 13465 var dynamic_shortcut_default = DynamicShortcut; 13466 13467 // packages/editor/build-module/components/keyboard-shortcut-help-modal/index.js 13468 var import_jsx_runtime106 = __toESM(require_jsx_runtime()); 13469 var KEYBOARD_SHORTCUT_HELP_MODAL_NAME = "editor/keyboard-shortcut-help"; 13470 var ShortcutList = ({ shortcuts }) => ( 13471 /* 13472 * Disable reason: The `list` ARIA role is redundant but 13473 * Safari+VoiceOver won't announce the list otherwise. 13474 */ 13475 /* eslint-disable jsx-a11y/no-redundant-roles */ 13476 /* @__PURE__ */ (0, import_jsx_runtime106.jsx)( 13477 "ul", 13478 { 13479 className: "editor-keyboard-shortcut-help-modal__shortcut-list", 13480 role: "list", 13481 children: shortcuts.map((shortcut, index2) => /* @__PURE__ */ (0, import_jsx_runtime106.jsx)( 13482 "li", 13483 { 13484 className: "editor-keyboard-shortcut-help-modal__shortcut", 13485 children: typeof shortcut === "string" ? /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(dynamic_shortcut_default, { name: shortcut }) : /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(shortcut_default, { ...shortcut }) 13486 }, 13487 index2 13488 )) 13489 } 13490 ) 13491 ); 13492 var ShortcutSection = ({ title, shortcuts, className }) => /* @__PURE__ */ (0, import_jsx_runtime106.jsxs)( 13493 "section", 13494 { 13495 className: clsx_default( 13496 "editor-keyboard-shortcut-help-modal__section", 13497 className 13498 ), 13499 children: [ 13500 !!title && /* @__PURE__ */ (0, import_jsx_runtime106.jsx)("h2", { className: "editor-keyboard-shortcut-help-modal__section-title", children: title }), 13501 /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(ShortcutList, { shortcuts }) 13502 ] 13503 } 13504 ); 13505 var ShortcutCategorySection = ({ 13506 title, 13507 categoryName, 13508 additionalShortcuts = [] 13509 }) => { 13510 const categoryShortcuts = (0, import_data42.useSelect)( 13511 (select5) => { 13512 return select5(import_keyboard_shortcuts2.store).getCategoryShortcuts( 13513 categoryName 13514 ); 13515 }, 13516 [categoryName] 13517 ); 13518 return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)( 13519 ShortcutSection, 13520 { 13521 title, 13522 shortcuts: categoryShortcuts.concat(additionalShortcuts) 13523 } 13524 ); 13525 }; 13526 function KeyboardShortcutHelpModal() { 13527 const isModalActive2 = (0, import_data42.useSelect)( 13528 (select5) => select5(store2).isModalActive( 13529 KEYBOARD_SHORTCUT_HELP_MODAL_NAME 13530 ), 13531 [] 13532 ); 13533 const { openModal: openModal2, closeModal: closeModal2 } = (0, import_data42.useDispatch)(store2); 13534 const toggleModal = () => { 13535 if (isModalActive2) { 13536 closeModal2(); 13537 } else { 13538 openModal2(KEYBOARD_SHORTCUT_HELP_MODAL_NAME); 13539 } 13540 }; 13541 (0, import_keyboard_shortcuts2.useShortcut)("core/editor/keyboard-shortcuts", toggleModal); 13542 if (!isModalActive2) { 13543 return null; 13544 } 13545 return /* @__PURE__ */ (0, import_jsx_runtime106.jsxs)( 13546 import_components27.Modal, 13547 { 13548 className: "editor-keyboard-shortcut-help-modal", 13549 title: (0, import_i18n56.__)("Keyboard shortcuts"), 13550 closeButtonLabel: (0, import_i18n56.__)("Close"), 13551 onRequestClose: toggleModal, 13552 children: [ 13553 /* @__PURE__ */ (0, import_jsx_runtime106.jsx)( 13554 ShortcutSection, 13555 { 13556 className: "editor-keyboard-shortcut-help-modal__main-shortcuts", 13557 shortcuts: ["core/editor/keyboard-shortcuts"] 13558 } 13559 ), 13560 /* @__PURE__ */ (0, import_jsx_runtime106.jsx)( 13561 ShortcutCategorySection, 13562 { 13563 title: (0, import_i18n56.__)("Global shortcuts"), 13564 categoryName: "global" 13565 } 13566 ), 13567 /* @__PURE__ */ (0, import_jsx_runtime106.jsx)( 13568 ShortcutCategorySection, 13569 { 13570 title: (0, import_i18n56.__)("Selection shortcuts"), 13571 categoryName: "selection" 13572 } 13573 ), 13574 /* @__PURE__ */ (0, import_jsx_runtime106.jsx)( 13575 ShortcutCategorySection, 13576 { 13577 title: (0, import_i18n56.__)("Block shortcuts"), 13578 categoryName: "block", 13579 additionalShortcuts: [ 13580 { 13581 keyCombination: { character: "/" }, 13582 description: (0, import_i18n56.__)( 13583 "Change the block type after adding a new paragraph." 13584 ), 13585 /* translators: The forward-slash character. e.g. '/'. */ 13586 ariaLabel: (0, import_i18n56.__)("Forward-slash") 13587 } 13588 ] 13589 } 13590 ), 13591 /* @__PURE__ */ (0, import_jsx_runtime106.jsx)( 13592 ShortcutSection, 13593 { 13594 title: (0, import_i18n56.__)("Text formatting"), 13595 shortcuts: textFormattingShortcuts 13596 } 13597 ), 13598 /* @__PURE__ */ (0, import_jsx_runtime106.jsx)( 13599 ShortcutCategorySection, 13600 { 13601 title: (0, import_i18n56.__)("List View shortcuts"), 13602 categoryName: "list-view" 13603 } 13604 ) 13605 ] 13606 } 13607 ); 13608 } 13609 var keyboard_shortcut_help_modal_default = KeyboardShortcutHelpModal; 13610 13611 // packages/editor/build-module/components/start-template-options/index.js 13612 var import_components28 = __toESM(require_components()); 13613 var import_i18n57 = __toESM(require_i18n()); 13614 var import_element35 = __toESM(require_element()); 13615 var import_block_editor13 = __toESM(require_block_editor()); 13616 var import_data43 = __toESM(require_data()); 13617 var import_blocks11 = __toESM(require_blocks()); 13618 var import_core_data28 = __toESM(require_core_data()); 13619 var import_jsx_runtime107 = __toESM(require_jsx_runtime()); 13620 function useFallbackTemplateContent(slug, isCustom = false) { 13621 return (0, import_data43.useSelect)( 13622 (select5) => { 13623 const { getEntityRecord, getDefaultTemplateId } = select5(import_core_data28.store); 13624 const templateId2 = getDefaultTemplateId({ 13625 slug, 13626 is_custom: isCustom, 13627 ignore_empty: true 13628 }); 13629 return templateId2 ? getEntityRecord("postType", TEMPLATE_POST_TYPE, templateId2)?.content?.raw : void 0; 13630 }, 13631 [slug, isCustom] 13632 ); 13633 } 13634 function useStartPatterns2(fallbackContent) { 13635 const { slug, patterns: patterns2 } = (0, import_data43.useSelect)((select5) => { 13636 const { getCurrentPostType: getCurrentPostType2, getCurrentPostId: getCurrentPostId2 } = select5(store); 13637 const { getEntityRecord, getBlockPatterns } = select5(import_core_data28.store); 13638 const postId2 = getCurrentPostId2(); 13639 const postType2 = getCurrentPostType2(); 13640 const record = getEntityRecord("postType", postType2, postId2); 13641 return { 13642 slug: record.slug, 13643 patterns: getBlockPatterns() 13644 }; 13645 }, []); 13646 const currentThemeStylesheet = (0, import_data43.useSelect)( 13647 (select5) => select5(import_core_data28.store).getCurrentTheme().stylesheet 13648 ); 13649 function injectThemeAttributeInBlockTemplateContent2(block) { 13650 if (block.innerBlocks.find( 13651 (innerBlock) => innerBlock.name === "core/template-part" 13652 )) { 13653 block.innerBlocks = block.innerBlocks.map((innerBlock) => { 13654 if (innerBlock.name === "core/template-part" && innerBlock.attributes.theme === void 0) { 13655 innerBlock.attributes.theme = currentThemeStylesheet; 13656 } 13657 return innerBlock; 13658 }); 13659 } 13660 if (block.name === "core/template-part" && block.attributes.theme === void 0) { 13661 block.attributes.theme = currentThemeStylesheet; 13662 } 13663 return block; 13664 } 13665 return (0, import_element35.useMemo)(() => { 13666 return [ 13667 { 13668 name: "fallback", 13669 blocks: (0, import_blocks11.parse)(fallbackContent), 13670 title: (0, import_i18n57.__)("Fallback content") 13671 }, 13672 ...patterns2.filter((pattern) => { 13673 return Array.isArray(pattern.templateTypes) && pattern.templateTypes.some( 13674 (templateType) => slug.startsWith(templateType) 13675 ); 13676 }).map((pattern) => { 13677 return { 13678 ...pattern, 13679 blocks: (0, import_blocks11.parse)(pattern.content).map( 13680 (block) => injectThemeAttributeInBlockTemplateContent2(block) 13681 ) 13682 }; 13683 }) 13684 ]; 13685 }, [fallbackContent, slug, patterns2]); 13686 } 13687 function PatternSelection2({ fallbackContent, onChoosePattern, postType: postType2 }) { 13688 const [, , onChange] = (0, import_core_data28.useEntityBlockEditor)("postType", postType2); 13689 const blockPatterns = useStartPatterns2(fallbackContent); 13690 return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)( 13691 import_block_editor13.__experimentalBlockPatternsList, 13692 { 13693 blockPatterns, 13694 onClickPattern: (pattern, blocks) => { 13695 onChange(blocks, { selection: void 0 }); 13696 onChoosePattern(); 13697 } 13698 } 13699 ); 13700 } 13701 function StartModal({ slug, isCustom, onClose, postType: postType2 }) { 13702 const fallbackContent = useFallbackTemplateContent(slug, isCustom); 13703 if (!fallbackContent) { 13704 return null; 13705 } 13706 return /* @__PURE__ */ (0, import_jsx_runtime107.jsxs)( 13707 import_components28.Modal, 13708 { 13709 className: "editor-start-template-options__modal", 13710 title: (0, import_i18n57.__)("Choose a pattern"), 13711 closeLabel: (0, import_i18n57.__)("Cancel"), 13712 focusOnMount: "firstElement", 13713 onRequestClose: onClose, 13714 isFullScreen: true, 13715 children: [ 13716 /* @__PURE__ */ (0, import_jsx_runtime107.jsx)("div", { className: "editor-start-template-options__modal-content", children: /* @__PURE__ */ (0, import_jsx_runtime107.jsx)( 13717 PatternSelection2, 13718 { 13719 fallbackContent, 13720 slug, 13721 isCustom, 13722 postType: postType2, 13723 onChoosePattern: () => { 13724 onClose(); 13725 } 13726 } 13727 ) }), 13728 /* @__PURE__ */ (0, import_jsx_runtime107.jsx)( 13729 import_components28.Flex, 13730 { 13731 className: "editor-start-template-options__modal__actions", 13732 justify: "flex-end", 13733 expanded: false, 13734 children: /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(import_components28.FlexItem, { children: /* @__PURE__ */ (0, import_jsx_runtime107.jsx)( 13735 import_components28.Button, 13736 { 13737 __next40pxDefaultSize: true, 13738 variant: "tertiary", 13739 onClick: onClose, 13740 children: (0, import_i18n57.__)("Skip") 13741 } 13742 ) }) 13743 } 13744 ) 13745 ] 13746 } 13747 ); 13748 } 13749 function StartTemplateOptions() { 13750 const [isClosed, setIsClosed] = (0, import_element35.useState)(false); 13751 const { shouldOpenModal, slug, isCustom, postType: postType2, postId: postId2 } = (0, import_data43.useSelect)( 13752 (select5) => { 13753 const { getCurrentPostType: getCurrentPostType2, getCurrentPostId: getCurrentPostId2 } = select5(store); 13754 const _postType = getCurrentPostType2(); 13755 const _postId = getCurrentPostId2(); 13756 const { getEditedEntityRecord, hasEditsForEntityRecord } = select5(import_core_data28.store); 13757 const templateRecord = getEditedEntityRecord( 13758 "postType", 13759 _postType, 13760 _postId 13761 ); 13762 const hasEdits = hasEditsForEntityRecord( 13763 "postType", 13764 _postType, 13765 _postId 13766 ); 13767 return { 13768 shouldOpenModal: !hasEdits && "" === templateRecord.content && TEMPLATE_POST_TYPE === _postType, 13769 slug: templateRecord.slug, 13770 isCustom: templateRecord.is_custom, 13771 postType: _postType, 13772 postId: _postId 13773 }; 13774 }, 13775 [] 13776 ); 13777 (0, import_element35.useEffect)(() => { 13778 setIsClosed(false); 13779 }, [postType2, postId2]); 13780 if (!shouldOpenModal || isClosed) { 13781 return null; 13782 } 13783 return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)( 13784 StartModal, 13785 { 13786 slug, 13787 isCustom, 13788 postType: postType2, 13789 onClose: () => setIsClosed(true) 13790 } 13791 ); 13792 } 13793 13794 // packages/editor/build-module/components/global-keyboard-shortcuts/index.js 13795 var import_keyboard_shortcuts3 = __toESM(require_keyboard_shortcuts()); 13796 var import_data44 = __toESM(require_data()); 13797 var import_block_editor14 = __toESM(require_block_editor()); 13798 function EditorKeyboardShortcuts() { 13799 const isModeToggleDisabled = (0, import_data44.useSelect)((select5) => { 13800 const { richEditingEnabled, codeEditingEnabled } = select5(store).getEditorSettings(); 13801 return !richEditingEnabled || !codeEditingEnabled; 13802 }, []); 13803 const { getBlockSelectionStart: getBlockSelectionStart2 } = (0, import_data44.useSelect)(import_block_editor14.store); 13804 const { getActiveComplementaryArea: getActiveComplementaryArea2 } = (0, import_data44.useSelect)(store2); 13805 const { enableComplementaryArea: enableComplementaryArea2, disableComplementaryArea: disableComplementaryArea2 } = (0, import_data44.useDispatch)(store2); 13806 const { 13807 redo: redo2, 13808 undo: undo2, 13809 savePost: savePost2, 13810 setIsListViewOpened: setIsListViewOpened2, 13811 switchEditorMode: switchEditorMode2, 13812 toggleDistractionFree: toggleDistractionFree2 13813 } = (0, import_data44.useDispatch)(store); 13814 const { 13815 isEditedPostDirty: isEditedPostDirty2, 13816 isPostSavingLocked: isPostSavingLocked2, 13817 isListViewOpened: isListViewOpened2, 13818 getEditorMode: getEditorMode2 13819 } = (0, import_data44.useSelect)(store); 13820 (0, import_keyboard_shortcuts3.useShortcut)( 13821 "core/editor/toggle-mode", 13822 () => { 13823 switchEditorMode2( 13824 getEditorMode2() === "visual" ? "text" : "visual" 13825 ); 13826 }, 13827 { 13828 isDisabled: isModeToggleDisabled 13829 } 13830 ); 13831 (0, import_keyboard_shortcuts3.useShortcut)("core/editor/toggle-distraction-free", () => { 13832 toggleDistractionFree2(); 13833 }); 13834 (0, import_keyboard_shortcuts3.useShortcut)("core/editor/undo", (event) => { 13835 undo2(); 13836 event.preventDefault(); 13837 }); 13838 (0, import_keyboard_shortcuts3.useShortcut)("core/editor/redo", (event) => { 13839 redo2(); 13840 event.preventDefault(); 13841 }); 13842 (0, import_keyboard_shortcuts3.useShortcut)("core/editor/save", (event) => { 13843 event.preventDefault(); 13844 if (isPostSavingLocked2()) { 13845 return; 13846 } 13847 if (!isEditedPostDirty2()) { 13848 return; 13849 } 13850 savePost2(); 13851 }); 13852 (0, import_keyboard_shortcuts3.useShortcut)("core/editor/toggle-list-view", (event) => { 13853 if (!isListViewOpened2()) { 13854 event.preventDefault(); 13855 setIsListViewOpened2(true); 13856 } 13857 }); 13858 (0, import_keyboard_shortcuts3.useShortcut)("core/editor/toggle-sidebar", (event) => { 13859 event.preventDefault(); 13860 const isEditorSidebarOpened = [ 13861 "edit-post/document", 13862 "edit-post/block" 13863 ].includes(getActiveComplementaryArea2("core")); 13864 if (isEditorSidebarOpened) { 13865 disableComplementaryArea2("core"); 13866 } else { 13867 const sidebarToOpen = getBlockSelectionStart2() ? "edit-post/block" : "edit-post/document"; 13868 enableComplementaryArea2("core", sidebarToOpen); 13869 } 13870 }); 13871 return null; 13872 } 13873 13874 // packages/editor/build-module/components/template-part-menu-items/index.js 13875 var import_data47 = __toESM(require_data()); 13876 var import_block_editor17 = __toESM(require_block_editor()); 13877 13878 // packages/editor/build-module/components/template-part-menu-items/convert-to-regular.js 13879 var import_data45 = __toESM(require_data()); 13880 var import_block_editor15 = __toESM(require_block_editor()); 13881 var import_components29 = __toESM(require_components()); 13882 var import_i18n58 = __toESM(require_i18n()); 13883 var import_jsx_runtime108 = __toESM(require_jsx_runtime()); 13884 function ConvertToRegularBlocks({ clientId, onClose }) { 13885 const { getBlocks: getBlocks2 } = (0, import_data45.useSelect)(import_block_editor15.store); 13886 const { replaceBlocks: replaceBlocks2 } = (0, import_data45.useDispatch)(import_block_editor15.store); 13887 const canRemove = (0, import_data45.useSelect)( 13888 (select5) => select5(import_block_editor15.store).canRemoveBlock(clientId), 13889 [clientId] 13890 ); 13891 if (!canRemove) { 13892 return null; 13893 } 13894 return /* @__PURE__ */ (0, import_jsx_runtime108.jsx)( 13895 import_components29.MenuItem, 13896 { 13897 onClick: () => { 13898 replaceBlocks2(clientId, getBlocks2(clientId)); 13899 onClose(); 13900 }, 13901 children: (0, import_i18n58.__)("Detach") 13902 } 13903 ); 13904 } 13905 13906 // packages/editor/build-module/components/template-part-menu-items/convert-to-template-part.js 13907 var import_data46 = __toESM(require_data()); 13908 var import_block_editor16 = __toESM(require_block_editor()); 13909 var import_components30 = __toESM(require_components()); 13910 var import_blocks12 = __toESM(require_blocks()); 13911 var import_i18n59 = __toESM(require_i18n()); 13912 var import_element36 = __toESM(require_element()); 13913 var import_notices14 = __toESM(require_notices()); 13914 var import_core_data29 = __toESM(require_core_data()); 13915 var import_jsx_runtime109 = __toESM(require_jsx_runtime()); 13916 function ConvertToTemplatePart({ clientIds, blocks }) { 13917 const [isModalOpen, setIsModalOpen] = (0, import_element36.useState)(false); 13918 const { replaceBlocks: replaceBlocks2 } = (0, import_data46.useDispatch)(import_block_editor16.store); 13919 const { createSuccessNotice } = (0, import_data46.useDispatch)(import_notices14.store); 13920 const { isBlockBasedTheme, canCreate } = (0, import_data46.useSelect)((select5) => { 13921 return { 13922 isBlockBasedTheme: select5(import_core_data29.store).getCurrentTheme()?.is_block_theme, 13923 canCreate: select5(import_block_editor16.store).canInsertBlockType( 13924 "core/template-part" 13925 ) 13926 }; 13927 }, []); 13928 if (!isBlockBasedTheme || !canCreate) { 13929 return null; 13930 } 13931 const onConvert = async (templatePart) => { 13932 replaceBlocks2( 13933 clientIds, 13934 (0, import_blocks12.createBlock)("core/template-part", { 13935 slug: templatePart.slug, 13936 theme: templatePart.theme 13937 }) 13938 ); 13939 createSuccessNotice((0, import_i18n59.__)("Template part created."), { 13940 type: "snackbar" 13941 }); 13942 }; 13943 return /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(import_jsx_runtime109.Fragment, { children: [ 13944 /* @__PURE__ */ (0, import_jsx_runtime109.jsx)( 13945 import_components30.MenuItem, 13946 { 13947 icon: symbol_filled_default, 13948 onClick: () => { 13949 setIsModalOpen(true); 13950 }, 13951 "aria-expanded": isModalOpen, 13952 "aria-haspopup": "dialog", 13953 children: (0, import_i18n59.__)("Create template part") 13954 } 13955 ), 13956 isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime109.jsx)( 13957 CreateTemplatePartModal, 13958 { 13959 closeModal: () => { 13960 setIsModalOpen(false); 13961 }, 13962 blocks, 13963 onCreate: onConvert 13964 } 13965 ) 13966 ] }); 13967 } 13968 13969 // packages/editor/build-module/components/template-part-menu-items/index.js 13970 var import_jsx_runtime110 = __toESM(require_jsx_runtime()); 13971 function TemplatePartMenuItems() { 13972 return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(import_block_editor17.BlockSettingsMenuControls, { children: ({ selectedClientIds, onClose }) => /* @__PURE__ */ (0, import_jsx_runtime110.jsx)( 13973 TemplatePartConverterMenuItem, 13974 { 13975 clientIds: selectedClientIds, 13976 onClose 13977 } 13978 ) }); 13979 } 13980 function TemplatePartConverterMenuItem({ clientIds, onClose }) { 13981 const { blocks } = (0, import_data47.useSelect)( 13982 (select5) => { 13983 const { getBlocksByClientId: getBlocksByClientId2 } = select5(import_block_editor17.store); 13984 return { 13985 blocks: getBlocksByClientId2(clientIds) 13986 }; 13987 }, 13988 [clientIds] 13989 ); 13990 if (blocks.length === 1 && blocks[0]?.name === "core/template-part") { 13991 return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)( 13992 ConvertToRegularBlocks, 13993 { 13994 clientId: clientIds[0], 13995 onClose 13996 } 13997 ); 13998 } 13999 return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(ConvertToTemplatePart, { clientIds, blocks }); 14000 } 14001 14002 // packages/editor/build-module/components/provider/index.js 14003 var import_jsx_runtime111 = __toESM(require_jsx_runtime()); 14004 var { ExperimentalBlockEditorProvider } = unlock(import_block_editor18.privateApis); 14005 var { PatternsMenuItems } = unlock(import_patterns7.privateApis); 14006 var noop3 = () => { 14007 }; 14008 var NON_CONTEXTUAL_POST_TYPES = [ 14009 "wp_block", 14010 "wp_navigation", 14011 "wp_template_part" 14012 ]; 14013 function useBlockEditorProps(post2, template2, mode) { 14014 const rootLevelPost = mode === "template-locked" ? "template" : "post"; 14015 const [postBlocks, onInput, onChange] = (0, import_core_data30.useEntityBlockEditor)( 14016 "postType", 14017 post2.type, 14018 { id: post2.id } 14019 ); 14020 const [templateBlocks, onInputTemplate, onChangeTemplate] = (0, import_core_data30.useEntityBlockEditor)("postType", template2?.type, { 14021 id: template2?.id 14022 }); 14023 const maybeNavigationBlocks = (0, import_element37.useMemo)(() => { 14024 if (post2.type === "wp_navigation") { 14025 return [ 14026 (0, import_blocks13.createBlock)("core/navigation", { 14027 ref: post2.id, 14028 // As the parent editor is locked with `templateLock`, the template locking 14029 // must be explicitly "unset" on the block itself to allow the user to modify 14030 // the block's content. 14031 templateLock: false 14032 }) 14033 ]; 14034 } 14035 }, [post2.type, post2.id]); 14036 const blocks = (0, import_element37.useMemo)(() => { 14037 if (maybeNavigationBlocks) { 14038 return maybeNavigationBlocks; 14039 } 14040 if (rootLevelPost === "template") { 14041 return templateBlocks; 14042 } 14043 return postBlocks; 14044 }, [maybeNavigationBlocks, rootLevelPost, templateBlocks, postBlocks]); 14045 const disableRootLevelChanges = !!template2 && mode === "template-locked" || post2.type === "wp_navigation"; 14046 if (disableRootLevelChanges) { 14047 return [blocks, noop3, noop3]; 14048 } 14049 return [ 14050 blocks, 14051 rootLevelPost === "post" ? onInput : onInputTemplate, 14052 rootLevelPost === "post" ? onChange : onChangeTemplate 14053 ]; 14054 } 14055 var ExperimentalEditorProvider = with_registry_provider_default( 14056 ({ 14057 post: post2, 14058 settings, 14059 recovery, 14060 initialEdits, 14061 children, 14062 BlockEditorProviderComponent = ExperimentalBlockEditorProvider, 14063 __unstableTemplate: template2 14064 }) => { 14065 const hasTemplate = !!template2; 14066 const { 14067 editorSettings: editorSettings2, 14068 selection, 14069 isReady: isReady2, 14070 mode, 14071 defaultMode, 14072 postTypeEntities 14073 } = (0, import_data48.useSelect)( 14074 (select5) => { 14075 const { 14076 getEditorSettings: getEditorSettings2, 14077 getEditorSelection: getEditorSelection2, 14078 getRenderingMode: getRenderingMode2, 14079 __unstableIsEditorReady: __unstableIsEditorReady2, 14080 getDefaultRenderingMode: getDefaultRenderingMode2 14081 } = unlock(select5(store)); 14082 const { getEntitiesConfig } = select5(import_core_data30.store); 14083 const _mode = getRenderingMode2(); 14084 const _defaultMode = getDefaultRenderingMode2(post2.type); 14085 const hasResolvedDefaultMode = _defaultMode === "template-locked" ? hasTemplate : _defaultMode !== void 0; 14086 const isRenderingModeReady = _defaultMode !== void 0; 14087 return { 14088 editorSettings: getEditorSettings2(), 14089 isReady: __unstableIsEditorReady2(), 14090 mode: isRenderingModeReady ? _mode : void 0, 14091 defaultMode: hasResolvedDefaultMode ? _defaultMode : void 0, 14092 selection: getEditorSelection2(), 14093 postTypeEntities: post2.type === "wp_template" ? getEntitiesConfig("postType") : null 14094 }; 14095 }, 14096 [post2.type, hasTemplate] 14097 ); 14098 const shouldRenderTemplate = hasTemplate && mode !== "post-only"; 14099 const rootLevelPost = shouldRenderTemplate ? template2 : post2; 14100 const defaultBlockContext = (0, import_element37.useMemo)(() => { 14101 const postContext = {}; 14102 if (post2.type === "wp_template") { 14103 if (post2.slug === "page") { 14104 postContext.postType = "page"; 14105 } else if (post2.slug === "single") { 14106 postContext.postType = "post"; 14107 } else if (post2.slug.split("-")[0] === "single") { 14108 const postTypeNames = postTypeEntities?.map((entity) => entity.name) || []; 14109 const match2 = post2.slug.match( 14110 `^single-($postTypeNames.join("|")})(?:-.+)?$` 14111 ); 14112 if (match2) { 14113 postContext.postType = match2[1]; 14114 } 14115 } 14116 } else if (!NON_CONTEXTUAL_POST_TYPES.includes(rootLevelPost.type) || shouldRenderTemplate) { 14117 postContext.postId = post2.id; 14118 postContext.postType = post2.type; 14119 } 14120 return { 14121 ...postContext, 14122 templateSlug: rootLevelPost.type === "wp_template" ? rootLevelPost.slug : void 0 14123 }; 14124 }, [ 14125 shouldRenderTemplate, 14126 post2.id, 14127 post2.type, 14128 post2.slug, 14129 rootLevelPost.type, 14130 rootLevelPost.slug, 14131 postTypeEntities 14132 ]); 14133 const { id, type } = rootLevelPost; 14134 const blockEditorSettings = use_block_editor_settings_default( 14135 editorSettings2, 14136 type, 14137 id, 14138 mode 14139 ); 14140 const [blocks, onInput, onChange] = useBlockEditorProps( 14141 post2, 14142 template2, 14143 mode 14144 ); 14145 const { 14146 updatePostLock: updatePostLock2, 14147 setupEditor: setupEditor2, 14148 updateEditorSettings: updateEditorSettings2, 14149 setCurrentTemplateId: setCurrentTemplateId2, 14150 setEditedPost: setEditedPost2, 14151 setRenderingMode: setRenderingMode2 14152 } = unlock((0, import_data48.useDispatch)(store)); 14153 const { createWarningNotice, removeNotice } = (0, import_data48.useDispatch)(import_notices15.store); 14154 (0, import_element37.useLayoutEffect)(() => { 14155 if (recovery) { 14156 return; 14157 } 14158 updatePostLock2(settings.postLock); 14159 setupEditor2(post2, initialEdits, settings.template); 14160 if (settings.autosave) { 14161 createWarningNotice( 14162 (0, import_i18n60.__)( 14163 "There is an autosave of this post that is more recent than the version below." 14164 ), 14165 { 14166 id: "autosave-exists", 14167 actions: [ 14168 { 14169 label: (0, import_i18n60.__)("View the autosave"), 14170 url: settings.autosave.editLink 14171 } 14172 ] 14173 } 14174 ); 14175 } 14176 }, []); 14177 (0, import_element37.useEffect)(() => { 14178 setEditedPost2(post2.type, post2.id); 14179 if (typeof window !== "undefined" && window.__experimentalTemplateActivate) { 14180 removeNotice("template-activate-notice"); 14181 } 14182 }, [post2.type, post2.id, setEditedPost2, removeNotice]); 14183 (0, import_element37.useEffect)(() => { 14184 updateEditorSettings2(settings); 14185 }, [settings, updateEditorSettings2]); 14186 (0, import_element37.useEffect)(() => { 14187 setCurrentTemplateId2(template2?.id); 14188 }, [template2?.id, setCurrentTemplateId2]); 14189 (0, import_element37.useEffect)(() => { 14190 if (defaultMode) { 14191 setRenderingMode2(defaultMode); 14192 } 14193 }, [defaultMode, setRenderingMode2]); 14194 useHideBlocksFromInserter(post2.type, mode); 14195 useCommands(); 14196 if (!isReady2 || !mode) { 14197 return null; 14198 } 14199 return /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(import_core_data30.EntityProvider, { kind: "root", type: "site", children: /* @__PURE__ */ (0, import_jsx_runtime111.jsx)( 14200 import_core_data30.EntityProvider, 14201 { 14202 kind: "postType", 14203 type: post2.type, 14204 id: post2.id, 14205 children: /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(import_block_editor18.BlockContextProvider, { value: defaultBlockContext, children: /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)( 14206 BlockEditorProviderComponent, 14207 { 14208 value: blocks, 14209 onChange, 14210 onInput, 14211 selection, 14212 settings: blockEditorSettings, 14213 useSubRegistry: false, 14214 children: [ 14215 children, 14216 !settings.isPreviewMode && /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)(import_jsx_runtime111.Fragment, { children: [ 14217 /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(PatternsMenuItems, {}), 14218 /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(TemplatePartMenuItems, {}), 14219 mode === "template-locked" && /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(DisableNonPageContentBlocks, {}), 14220 type === "wp_navigation" && /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(NavigationBlockEditingMode, {}), 14221 /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(EditorKeyboardShortcuts, {}), 14222 /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(keyboard_shortcut_help_modal_default, {}), 14223 /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(BlockRemovalWarnings, {}), 14224 /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(StartPageOptions, {}), 14225 /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(StartTemplateOptions, {}), 14226 /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(PatternRenameModal, {}), 14227 /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(PatternDuplicateModal, {}) 14228 ] }) 14229 ] 14230 } 14231 ) }) 14232 } 14233 ) }); 14234 } 14235 ); 14236 function EditorProvider(props) { 14237 return /* @__PURE__ */ (0, import_jsx_runtime111.jsx)( 14238 ExperimentalEditorProvider, 14239 { 14240 ...props, 14241 BlockEditorProviderComponent: import_block_editor18.BlockEditorProvider, 14242 children: props.children 14243 } 14244 ); 14245 } 14246 var provider_default = EditorProvider; 14247 14248 // packages/editor/build-module/components/global-styles/index.js 14249 var import_core_data43 = __toESM(require_core_data()); 14250 var import_data63 = __toESM(require_data()); 14251 var import_element71 = __toESM(require_element()); 14252 14253 // packages/global-styles-ui/build-module/global-styles-ui.js 14254 var import_components90 = __toESM(require_components()); 14255 var import_blocks18 = __toESM(require_blocks()); 14256 var import_data60 = __toESM(require_data()); 14257 var import_block_editor31 = __toESM(require_block_editor()); 14258 var import_element68 = __toESM(require_element()); 14259 var import_compose14 = __toESM(require_compose()); 14260 14261 // packages/global-styles-ui/build-module/provider.js 14262 var import_element39 = __toESM(require_element()); 14263 14264 // packages/global-styles-ui/build-module/context.js 14265 var import_element38 = __toESM(require_element()); 14266 var GlobalStylesContext = (0, import_element38.createContext)({ 14267 user: { styles: {}, settings: {} }, 14268 base: { styles: {}, settings: {} }, 14269 merged: { styles: {}, settings: {} }, 14270 onChange: () => { 14271 }, 14272 fontLibraryEnabled: false 14273 }); 14274 14275 // packages/global-styles-ui/build-module/provider.js 14276 var import_jsx_runtime112 = __toESM(require_jsx_runtime()); 14277 function GlobalStylesProvider({ 14278 children, 14279 value, 14280 baseValue, 14281 onChange, 14282 fontLibraryEnabled 14283 }) { 14284 const merged = (0, import_element39.useMemo)(() => { 14285 return mergeGlobalStyles(baseValue, value); 14286 }, [baseValue, value]); 14287 const contextValue = (0, import_element39.useMemo)( 14288 () => ({ 14289 user: value, 14290 base: baseValue, 14291 merged, 14292 onChange, 14293 fontLibraryEnabled 14294 }), 14295 [value, baseValue, merged, onChange, fontLibraryEnabled] 14296 ); 14297 return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(GlobalStylesContext.Provider, { value: contextValue, children }); 14298 } 14299 14300 // packages/global-styles-ui/build-module/screen-root.js 14301 var import_components37 = __toESM(require_components()); 14302 var import_i18n64 = __toESM(require_i18n()); 14303 var import_data50 = __toESM(require_data()); 14304 var import_core_data32 = __toESM(require_core_data()); 14305 14306 // packages/global-styles-ui/build-module/icon-with-current-color.js 14307 var import_jsx_runtime113 = __toESM(require_jsx_runtime()); 14308 function IconWithCurrentColor({ 14309 className, 14310 ...props 14311 }) { 14312 return /* @__PURE__ */ (0, import_jsx_runtime113.jsx)( 14313 icon_default, 14314 { 14315 className: clsx_default( 14316 className, 14317 "global-styles-ui-icon-with-current-color" 14318 ), 14319 ...props 14320 } 14321 ); 14322 } 14323 14324 // packages/global-styles-ui/build-module/navigation-button.js 14325 var import_components31 = __toESM(require_components()); 14326 var import_jsx_runtime114 = __toESM(require_jsx_runtime()); 14327 function GenericNavigationButton({ 14328 icon, 14329 children, 14330 ...props 14331 }) { 14332 return /* @__PURE__ */ (0, import_jsx_runtime114.jsxs)(import_components31.__experimentalItem, { ...props, children: [ 14333 icon && /* @__PURE__ */ (0, import_jsx_runtime114.jsxs)(import_components31.__experimentalHStack, { justify: "flex-start", children: [ 14334 /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(IconWithCurrentColor, { icon, size: 24 }), 14335 /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(import_components31.FlexItem, { children }) 14336 ] }), 14337 !icon && children 14338 ] }); 14339 } 14340 function NavigationButtonAsItem(props) { 14341 return /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(import_components31.Navigator.Button, { as: GenericNavigationButton, ...props }); 14342 } 14343 14344 // packages/global-styles-ui/build-module/root-menu.js 14345 var import_components32 = __toESM(require_components()); 14346 var import_i18n62 = __toESM(require_i18n()); 14347 var import_block_editor19 = __toESM(require_block_editor()); 14348 14349 // node_modules/colord/plugins/a11y.mjs 14350 var o3 = function(o4) { 14351 var t4 = o4 / 255; 14352 return t4 < 0.04045 ? t4 / 12.92 : Math.pow((t4 + 0.055) / 1.055, 2.4); 14353 }; 14354 var t3 = function(t4) { 14355 return 0.2126 * o3(t4.r) + 0.7152 * o3(t4.g) + 0.0722 * o3(t4.b); 14356 }; 14357 function a11y_default(o4) { 14358 o4.prototype.luminance = function() { 14359 return o5 = t3(this.rgba), void 0 === (r4 = 2) && (r4 = 0), void 0 === n3 && (n3 = Math.pow(10, r4)), Math.round(n3 * o5) / n3 + 0; 14360 var o5, r4, n3; 14361 }, o4.prototype.contrast = function(r4) { 14362 void 0 === r4 && (r4 = "#FFF"); 14363 var n3, a3, i3, e3, v3, u3, d3, c2 = r4 instanceof o4 ? r4 : new o4(r4); 14364 return e3 = this.rgba, v3 = c2.toRgb(), u3 = t3(e3), d3 = t3(v3), n3 = u3 > d3 ? (u3 + 0.05) / (d3 + 0.05) : (d3 + 0.05) / (u3 + 0.05), void 0 === (a3 = 2) && (a3 = 0), void 0 === i3 && (i3 = Math.pow(10, a3)), Math.floor(i3 * n3) / i3 + 0; 14365 }, o4.prototype.isReadable = function(o5, t4) { 14366 return void 0 === o5 && (o5 = "#FFF"), void 0 === t4 && (t4 = {}), this.contrast(o5) >= (e3 = void 0 === (i3 = (r4 = t4).size) ? "normal" : i3, "AAA" === (a3 = void 0 === (n3 = r4.level) ? "AA" : n3) && "normal" === e3 ? 7 : "AA" === a3 && "large" === e3 ? 3 : 4.5); 14367 var r4, n3, a3, i3, e3; 14368 }; 14369 } 14370 14371 // packages/global-styles-ui/build-module/hooks.js 14372 var import_element40 = __toESM(require_element()); 14373 var import_data49 = __toESM(require_data()); 14374 var import_core_data31 = __toESM(require_core_data()); 14375 var import_i18n61 = __toESM(require_i18n()); 14376 14377 // packages/global-styles-ui/build-module/utils.js 14378 function removePropertiesFromObject(object, properties) { 14379 if (!properties?.length) { 14380 return object; 14381 } 14382 if (typeof object !== "object" || !object || !Object.keys(object).length) { 14383 return object; 14384 } 14385 for (const key in object) { 14386 if (properties.includes(key)) { 14387 delete object[key]; 14388 } else if (typeof object[key] === "object") { 14389 removePropertiesFromObject(object[key], properties); 14390 } 14391 } 14392 return object; 14393 } 14394 var filterObjectByProperties = (object, properties) => { 14395 if (!object || !properties?.length) { 14396 return {}; 14397 } 14398 const newObject = {}; 14399 Object.keys(object).forEach((key) => { 14400 if (properties.includes(key)) { 14401 newObject[key] = object[key]; 14402 } else if (typeof object[key] === "object") { 14403 const newFilter = filterObjectByProperties( 14404 object[key], 14405 properties 14406 ); 14407 if (Object.keys(newFilter).length) { 14408 newObject[key] = newFilter; 14409 } 14410 } 14411 }); 14412 return newObject; 14413 }; 14414 function isVariationWithProperties(variation, properties) { 14415 const variationWithProperties = filterObjectByProperties( 14416 structuredClone(variation), 14417 properties 14418 ); 14419 return areGlobalStylesEqual(variationWithProperties, variation); 14420 } 14421 function getFontFamilyFromSetting(fontFamilies, setting) { 14422 if (!Array.isArray(fontFamilies) || !setting) { 14423 return null; 14424 } 14425 const fontFamilyVariable = setting.replace("var(", "").replace(")", ""); 14426 const fontFamilySlug = fontFamilyVariable?.split("--").slice(-1)[0]; 14427 return fontFamilies.find( 14428 (fontFamily) => fontFamily.slug === fontFamilySlug 14429 ); 14430 } 14431 function getFontFamilies(themeJson) { 14432 const themeFontFamilies = themeJson?.settings?.typography?.fontFamilies?.theme; 14433 const customFontFamilies = themeJson?.settings?.typography?.fontFamilies?.custom; 14434 let fontFamilies = []; 14435 if (themeFontFamilies && customFontFamilies) { 14436 fontFamilies = [...themeFontFamilies, ...customFontFamilies]; 14437 } else if (themeFontFamilies) { 14438 fontFamilies = themeFontFamilies; 14439 } else if (customFontFamilies) { 14440 fontFamilies = customFontFamilies; 14441 } 14442 const bodyFontFamilySetting = themeJson?.styles?.typography?.fontFamily; 14443 const bodyFontFamily = getFontFamilyFromSetting( 14444 fontFamilies, 14445 bodyFontFamilySetting 14446 ); 14447 const headingFontFamilySetting = themeJson?.styles?.elements?.heading?.typography?.fontFamily; 14448 let headingFontFamily; 14449 if (!headingFontFamilySetting) { 14450 headingFontFamily = bodyFontFamily; 14451 } else { 14452 headingFontFamily = getFontFamilyFromSetting( 14453 fontFamilies, 14454 themeJson?.styles?.elements?.heading?.typography?.fontFamily 14455 ); 14456 } 14457 return [bodyFontFamily, headingFontFamily]; 14458 } 14459 function getVariationClassName(variation) { 14460 if (!variation) { 14461 return ""; 14462 } 14463 return `is-style-$variation}`; 14464 } 14465 function getNewIndexFromPresets(presets, slugPrefix) { 14466 const nameRegex = new RegExp(`^$slugPrefix}([\\d]+)$`); 14467 const highestPresetValue = presets.reduce((currentHighest, preset) => { 14468 if (typeof preset?.slug === "string") { 14469 const matches = preset?.slug.match(nameRegex); 14470 if (matches) { 14471 const id = parseInt(matches[1], 10); 14472 if (id > currentHighest) { 14473 return id; 14474 } 14475 } 14476 } 14477 return currentHighest; 14478 }, 0); 14479 return highestPresetValue + 1; 14480 } 14481 14482 // packages/global-styles-ui/build-module/hooks.js 14483 k([a11y_default]); 14484 function useStyle(path, blockName, readFrom = "merged", shouldDecodeEncode = true) { 14485 const { user, base, merged, onChange } = (0, import_element40.useContext)(GlobalStylesContext); 14486 let sourceValue = merged; 14487 if (readFrom === "base") { 14488 sourceValue = base; 14489 } else if (readFrom === "user") { 14490 sourceValue = user; 14491 } 14492 const styleValue = (0, import_element40.useMemo)( 14493 () => getStyle(sourceValue, path, blockName, shouldDecodeEncode), 14494 [sourceValue, path, blockName, shouldDecodeEncode] 14495 ); 14496 const setStyleValue = (0, import_element40.useCallback)( 14497 (newValue) => { 14498 const newGlobalStyles = setStyle( 14499 user, 14500 path, 14501 newValue, 14502 blockName 14503 ); 14504 onChange(newGlobalStyles); 14505 }, 14506 [user, onChange, path, blockName] 14507 ); 14508 return [styleValue, setStyleValue]; 14509 } 14510 function useSetting(path, blockName, readFrom = "merged") { 14511 const { user, base, merged, onChange } = (0, import_element40.useContext)(GlobalStylesContext); 14512 let sourceValue = merged; 14513 if (readFrom === "base") { 14514 sourceValue = base; 14515 } else if (readFrom === "user") { 14516 sourceValue = user; 14517 } 14518 const settingValue = (0, import_element40.useMemo)( 14519 () => getSetting(sourceValue, path, blockName), 14520 [sourceValue, path, blockName] 14521 ); 14522 const setSettingValue = (0, import_element40.useCallback)( 14523 (newValue) => { 14524 const newGlobalStyles = setSetting( 14525 user, 14526 path, 14527 newValue, 14528 blockName 14529 ); 14530 onChange(newGlobalStyles); 14531 }, 14532 [user, onChange, path, blockName] 14533 ); 14534 return [settingValue, setSettingValue]; 14535 } 14536 var EMPTY_ARRAY3 = []; 14537 function hasThemeVariation({ 14538 title, 14539 settings, 14540 styles 14541 }) { 14542 return title === (0, import_i18n61.__)("Default") || Object.keys(settings || {}).length > 0 || Object.keys(styles || {}).length > 0; 14543 } 14544 function useCurrentMergeThemeStyleVariationsWithUserConfig(properties = []) { 14545 const { variationsFromTheme } = (0, import_data49.useSelect)((select5) => { 14546 const _variationsFromTheme = select5( 14547 import_core_data31.store 14548 ).__experimentalGetCurrentThemeGlobalStylesVariations?.(); 14549 return { 14550 variationsFromTheme: _variationsFromTheme || EMPTY_ARRAY3 14551 }; 14552 }, []); 14553 const { user: userVariation } = (0, import_element40.useContext)(GlobalStylesContext); 14554 return (0, import_element40.useMemo)(() => { 14555 const clonedUserVariation = structuredClone(userVariation); 14556 const userVariationWithoutProperties = removePropertiesFromObject( 14557 clonedUserVariation, 14558 properties 14559 ); 14560 userVariationWithoutProperties.title = (0, import_i18n61.__)("Default"); 14561 const variationsWithPropertiesAndBase = variationsFromTheme.filter((variation) => { 14562 return isVariationWithProperties(variation, properties); 14563 }).map((variation) => { 14564 return mergeGlobalStyles( 14565 userVariationWithoutProperties, 14566 variation 14567 ); 14568 }); 14569 const variationsByProperties = [ 14570 userVariationWithoutProperties, 14571 ...variationsWithPropertiesAndBase 14572 ]; 14573 return variationsByProperties?.length ? variationsByProperties.filter(hasThemeVariation) : []; 14574 }, [properties, userVariation, variationsFromTheme]); 14575 } 14576 function useColorRandomizer(blockName) { 14577 const [themeColors, setThemeColors] = useSetting( 14578 "color.palette.theme", 14579 blockName 14580 ); 14581 const randomizeColors = (0, import_element40.useCallback)(() => { 14582 if (!themeColors || !themeColors.length) { 14583 return; 14584 } 14585 const randomRotationValue = Math.floor(Math.random() * 225); 14586 const newColors = themeColors.map((colorObject) => { 14587 const { color } = colorObject; 14588 const newColor = w2(color).rotate(randomRotationValue).toHex(); 14589 return { 14590 ...colorObject, 14591 color: newColor 14592 }; 14593 }); 14594 setThemeColors(newColors); 14595 }, [themeColors, setThemeColors]); 14596 return window.__experimentalEnableColorRandomizer ? [randomizeColors] : []; 14597 } 14598 14599 // packages/global-styles-ui/build-module/lock-unlock.js 14600 var import_private_apis3 = __toESM(require_private_apis()); 14601 var { lock: lock3, unlock: unlock3 } = (0, import_private_apis3.__dangerousOptInToUnstableAPIsOnlyForCoreModules)( 14602 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.", 14603 "@wordpress/global-styles-ui" 14604 ); 14605 14606 // packages/global-styles-ui/build-module/root-menu.js 14607 var import_jsx_runtime115 = __toESM(require_jsx_runtime()); 14608 var { 14609 useHasDimensionsPanel, 14610 useHasTypographyPanel, 14611 useHasColorPanel, 14612 useSettingsForBlockElement, 14613 useHasBackgroundPanel 14614 } = unlock3(import_block_editor19.privateApis); 14615 function RootMenu() { 14616 const [rawSettings] = useSetting(""); 14617 const settings = useSettingsForBlockElement(rawSettings); 14618 const hasBackgroundPanel = useHasBackgroundPanel(rawSettings); 14619 const hasTypographyPanel = useHasTypographyPanel(settings); 14620 const hasColorPanel = useHasColorPanel(settings); 14621 const hasShadowPanel = true; 14622 const hasDimensionsPanel = useHasDimensionsPanel(settings); 14623 const hasLayoutPanel = hasDimensionsPanel; 14624 return /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(import_jsx_runtime115.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime115.jsxs)(import_components32.__experimentalItemGroup, { children: [ 14625 hasTypographyPanel && /* @__PURE__ */ (0, import_jsx_runtime115.jsx)( 14626 NavigationButtonAsItem, 14627 { 14628 icon: typography_default, 14629 path: "/typography", 14630 children: (0, import_i18n62.__)("Typography") 14631 } 14632 ), 14633 hasColorPanel && /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(NavigationButtonAsItem, { icon: color_default, path: "/colors", children: (0, import_i18n62.__)("Colors") }), 14634 hasBackgroundPanel && /* @__PURE__ */ (0, import_jsx_runtime115.jsx)( 14635 NavigationButtonAsItem, 14636 { 14637 icon: background_default, 14638 path: "/background", 14639 "aria-label": (0, import_i18n62.__)("Background styles"), 14640 children: (0, import_i18n62.__)("Background") 14641 } 14642 ), 14643 hasShadowPanel && /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(NavigationButtonAsItem, { icon: shadow_default, path: "/shadows", children: (0, import_i18n62.__)("Shadows") }), 14644 hasLayoutPanel && /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(NavigationButtonAsItem, { icon: layout_default, path: "/layout", children: (0, import_i18n62.__)("Layout") }) 14645 ] }) }); 14646 } 14647 var root_menu_default = RootMenu; 14648 14649 // packages/global-styles-ui/build-module/preview-styles.js 14650 var import_components36 = __toESM(require_components()); 14651 14652 // packages/global-styles-ui/build-module/preview-hooks.js 14653 function useStylesPreviewColors() { 14654 const [textColor = "black"] = useStyle("color.text"); 14655 const [backgroundColor = "white"] = useStyle("color.background"); 14656 const [headingColor = textColor] = useStyle( 14657 "elements.h1.color.text" 14658 ); 14659 const [linkColor = headingColor] = useStyle( 14660 "elements.link.color.text" 14661 ); 14662 const [buttonBackgroundColor = linkColor] = useStyle( 14663 "elements.button.color.background" 14664 ); 14665 const [coreColors] = useSetting("color.palette.core") || []; 14666 const [themeColors] = useSetting("color.palette.theme") || []; 14667 const [customColors] = useSetting("color.palette.custom") || []; 14668 const paletteColors = (themeColors ?? []).concat(customColors ?? []).concat(coreColors ?? []); 14669 const textColorObject = paletteColors.filter( 14670 ({ color }) => color === textColor 14671 ); 14672 const buttonBackgroundColorObject = paletteColors.filter( 14673 ({ color }) => color === buttonBackgroundColor 14674 ); 14675 const highlightedColors = textColorObject.concat(buttonBackgroundColorObject).concat(paletteColors).filter( 14676 // we exclude these background color because it is already visible in the preview. 14677 ({ color }) => color !== backgroundColor 14678 ).slice(0, 2); 14679 return { 14680 paletteColors, 14681 highlightedColors 14682 }; 14683 } 14684 14685 // packages/global-styles-ui/build-module/typography-example.js 14686 var import_element41 = __toESM(require_element()); 14687 var import_components33 = __toESM(require_components()); 14688 var import_i18n63 = __toESM(require_i18n()); 14689 14690 // packages/global-styles-ui/build-module/font-library/utils/preview-styles.js 14691 function findNearest(input, numbers) { 14692 if (numbers.length === 0) { 14693 return null; 14694 } 14695 numbers.sort((a3, b3) => Math.abs(input - a3) - Math.abs(input - b3)); 14696 return numbers[0]; 14697 } 14698 function extractFontWeights(fontFaces) { 14699 const result = []; 14700 fontFaces.forEach((face) => { 14701 const weights = String(face.fontWeight).split(" "); 14702 if (weights.length === 2) { 14703 const start = parseInt(weights[0]); 14704 const end = parseInt(weights[1]); 14705 for (let i3 = start; i3 <= end; i3 += 100) { 14706 result.push(i3); 14707 } 14708 } else if (weights.length === 1) { 14709 result.push(parseInt(weights[0])); 14710 } 14711 }); 14712 return result; 14713 } 14714 function formatFontFamily(input) { 14715 const regex = /^(?!generic\([ a-zA-Z\-]+\)$)(?!^[a-zA-Z\-]+$).+/; 14716 const output = input.trim(); 14717 const formatItem = (item) => { 14718 item = item.trim(); 14719 if (item.match(regex)) { 14720 item = item.replace(/^["']|["']$/g, ""); 14721 return `"$item}"`; 14722 } 14723 return item; 14724 }; 14725 if (output.includes(",")) { 14726 return output.split(",").map(formatItem).filter((item) => item !== "").join(", "); 14727 } 14728 return formatItem(output); 14729 } 14730 function formatFontFaceName(input) { 14731 if (!input) { 14732 return ""; 14733 } 14734 let output = input.trim(); 14735 if (output.includes(",")) { 14736 output = (output.split(",").find((item) => item.trim() !== "") ?? "").trim(); 14737 } 14738 output = output.replace(/^["']|["']$/g, ""); 14739 if (window.navigator.userAgent.toLowerCase().includes("firefox")) { 14740 output = `"$output}"`; 14741 } 14742 return output; 14743 } 14744 function getFamilyPreviewStyle(family) { 14745 const style = { 14746 fontFamily: formatFontFamily(family.fontFamily) 14747 }; 14748 if (!("fontFace" in family) || !Array.isArray(family.fontFace)) { 14749 style.fontWeight = "400"; 14750 style.fontStyle = "normal"; 14751 return style; 14752 } 14753 if (family.fontFace) { 14754 const normalFaces = family.fontFace.filter( 14755 (face) => face?.fontStyle && face.fontStyle.toLowerCase() === "normal" 14756 ); 14757 if (normalFaces.length > 0) { 14758 style.fontStyle = "normal"; 14759 const normalWeights = extractFontWeights(normalFaces); 14760 const nearestWeight = findNearest(400, normalWeights); 14761 style.fontWeight = String(nearestWeight) || "400"; 14762 } else { 14763 style.fontStyle = family.fontFace.length && family.fontFace[0].fontStyle || "normal"; 14764 style.fontWeight = family.fontFace.length && String(family.fontFace[0].fontWeight) || "400"; 14765 } 14766 } 14767 return style; 14768 } 14769 function getFacePreviewStyle(face) { 14770 return { 14771 fontFamily: formatFontFamily(face.fontFamily), 14772 fontStyle: face.fontStyle || "normal", 14773 fontWeight: face.fontWeight || "400" 14774 }; 14775 } 14776 14777 // packages/global-styles-ui/build-module/typography-example.js 14778 var import_jsx_runtime116 = __toESM(require_jsx_runtime()); 14779 function PreviewTypography({ 14780 fontSize, 14781 variation 14782 }) { 14783 const { base } = (0, import_element41.useContext)(GlobalStylesContext); 14784 let config = base; 14785 if (variation) { 14786 config = { ...base, ...variation }; 14787 } 14788 const [textColor] = useStyle("color.text"); 14789 const [bodyFontFamilies, headingFontFamilies] = getFontFamilies(config); 14790 const bodyPreviewStyle = bodyFontFamilies ? getFamilyPreviewStyle(bodyFontFamilies) : {}; 14791 const headingPreviewStyle = headingFontFamilies ? getFamilyPreviewStyle(headingFontFamilies) : {}; 14792 if (textColor) { 14793 bodyPreviewStyle.color = textColor; 14794 headingPreviewStyle.color = textColor; 14795 } 14796 if (fontSize) { 14797 bodyPreviewStyle.fontSize = fontSize; 14798 headingPreviewStyle.fontSize = fontSize; 14799 } 14800 return /* @__PURE__ */ (0, import_jsx_runtime116.jsxs)( 14801 import_components33.__unstableMotion.div, 14802 { 14803 animate: { 14804 scale: 1, 14805 opacity: 1 14806 }, 14807 initial: { 14808 scale: 0.1, 14809 opacity: 0 14810 }, 14811 transition: { 14812 delay: 0.3, 14813 type: "tween" 14814 }, 14815 style: { 14816 textAlign: "center", 14817 lineHeight: 1 14818 }, 14819 children: [ 14820 /* @__PURE__ */ (0, import_jsx_runtime116.jsx)("span", { style: headingPreviewStyle, children: (0, import_i18n63._x)("A", "Uppercase letter A") }), 14821 /* @__PURE__ */ (0, import_jsx_runtime116.jsx)("span", { style: bodyPreviewStyle, children: (0, import_i18n63._x)("a", "Lowercase letter A") }) 14822 ] 14823 } 14824 ); 14825 } 14826 14827 // packages/global-styles-ui/build-module/highlighted-colors.js 14828 var import_components34 = __toESM(require_components()); 14829 var import_jsx_runtime117 = __toESM(require_jsx_runtime()); 14830 function HighlightedColors({ 14831 normalizedColorSwatchSize, 14832 ratio 14833 }) { 14834 const { highlightedColors } = useStylesPreviewColors(); 14835 const scaledSwatchSize = normalizedColorSwatchSize * ratio; 14836 return highlightedColors.map(({ slug, color }, index2) => /* @__PURE__ */ (0, import_jsx_runtime117.jsx)( 14837 import_components34.__unstableMotion.div, 14838 { 14839 style: { 14840 height: scaledSwatchSize, 14841 width: scaledSwatchSize, 14842 background: color, 14843 borderRadius: scaledSwatchSize / 2 14844 }, 14845 animate: { 14846 scale: 1, 14847 opacity: 1 14848 }, 14849 initial: { 14850 scale: 0.1, 14851 opacity: 0 14852 }, 14853 transition: { 14854 delay: index2 === 1 ? 0.2 : 0.1 14855 } 14856 }, 14857 `$slug}-$index2}` 14858 )); 14859 } 14860 14861 // packages/global-styles-ui/build-module/preview-wrapper.js 14862 var import_components35 = __toESM(require_components()); 14863 var import_compose9 = __toESM(require_compose()); 14864 var import_element42 = __toESM(require_element()); 14865 var import_jsx_runtime118 = __toESM(require_jsx_runtime()); 14866 var normalizedWidth = 248; 14867 var normalizedHeight = 152; 14868 var THROTTLE_OPTIONS = { 14869 leading: true, 14870 trailing: true 14871 }; 14872 function PreviewWrapper({ 14873 children, 14874 label, 14875 isFocused, 14876 withHoverView 14877 }) { 14878 const [backgroundColor = "white"] = useStyle("color.background"); 14879 const [gradientValue] = useStyle("color.gradient"); 14880 const disableMotion = (0, import_compose9.useReducedMotion)(); 14881 const [isHovered, setIsHovered] = (0, import_element42.useState)(false); 14882 const [containerResizeListener, { width }] = (0, import_compose9.useResizeObserver)(); 14883 const [throttledWidth, setThrottledWidthState] = (0, import_element42.useState)(width); 14884 const [ratioState, setRatioState] = (0, import_element42.useState)(); 14885 const setThrottledWidth = (0, import_compose9.useThrottle)( 14886 setThrottledWidthState, 14887 250, 14888 THROTTLE_OPTIONS 14889 ); 14890 (0, import_element42.useLayoutEffect)(() => { 14891 if (width) { 14892 setThrottledWidth(width); 14893 } 14894 }, [width, setThrottledWidth]); 14895 (0, import_element42.useLayoutEffect)(() => { 14896 const newRatio = throttledWidth ? throttledWidth / normalizedWidth : 1; 14897 const ratioDiff = newRatio - (ratioState || 0); 14898 const isRatioDiffBigEnough = Math.abs(ratioDiff) > 0.1; 14899 if (isRatioDiffBigEnough || !ratioState) { 14900 setRatioState(newRatio); 14901 } 14902 }, [throttledWidth, ratioState]); 14903 const fallbackRatio = width ? width / normalizedWidth : 1; 14904 const ratio = ratioState ? ratioState : fallbackRatio; 14905 const isReady2 = !!width; 14906 return /* @__PURE__ */ (0, import_jsx_runtime118.jsxs)(import_jsx_runtime118.Fragment, { children: [ 14907 /* @__PURE__ */ (0, import_jsx_runtime118.jsx)("div", { style: { position: "relative" }, children: containerResizeListener }), 14908 isReady2 && /* @__PURE__ */ (0, import_jsx_runtime118.jsx)( 14909 "div", 14910 { 14911 className: "global-styles-ui-preview__wrapper", 14912 style: { 14913 height: normalizedHeight * ratio 14914 }, 14915 onMouseEnter: () => setIsHovered(true), 14916 onMouseLeave: () => setIsHovered(false), 14917 tabIndex: -1, 14918 children: /* @__PURE__ */ (0, import_jsx_runtime118.jsx)( 14919 import_components35.__unstableMotion.div, 14920 { 14921 style: { 14922 height: normalizedHeight * ratio, 14923 width: "100%", 14924 background: gradientValue ?? backgroundColor, 14925 cursor: withHoverView ? "pointer" : void 0 14926 }, 14927 initial: "start", 14928 animate: (isHovered || isFocused) && !disableMotion && label ? "hover" : "start", 14929 children: [].concat(children).map( 14930 (child, key) => child({ ratio, key }) 14931 ) 14932 } 14933 ) 14934 } 14935 ) 14936 ] }); 14937 } 14938 var preview_wrapper_default = PreviewWrapper; 14939 14940 // packages/global-styles-ui/build-module/preview-styles.js 14941 var import_jsx_runtime119 = __toESM(require_jsx_runtime()); 14942 var firstFrameVariants = { 14943 start: { 14944 scale: 1, 14945 opacity: 1 14946 }, 14947 hover: { 14948 scale: 0, 14949 opacity: 0 14950 } 14951 }; 14952 var midFrameVariants = { 14953 hover: { 14954 opacity: 1 14955 }, 14956 start: { 14957 opacity: 0.5 14958 } 14959 }; 14960 var secondFrameVariants = { 14961 hover: { 14962 scale: 1, 14963 opacity: 1 14964 }, 14965 start: { 14966 scale: 0, 14967 opacity: 0 14968 } 14969 }; 14970 function PreviewStyles({ 14971 label, 14972 isFocused, 14973 withHoverView, 14974 variation 14975 }) { 14976 const [fontWeight] = useStyle("typography.fontWeight"); 14977 const [fontFamily = "serif"] = useStyle( 14978 "typography.fontFamily" 14979 ); 14980 const [headingFontFamily = fontFamily] = useStyle( 14981 "elements.h1.typography.fontFamily" 14982 ); 14983 const [headingFontWeight = fontWeight] = useStyle( 14984 "elements.h1.typography.fontWeight" 14985 ); 14986 const [textColor = "black"] = useStyle("color.text"); 14987 const [headingColor = textColor] = useStyle( 14988 "elements.h1.color.text" 14989 ); 14990 const { paletteColors } = useStylesPreviewColors(); 14991 return /* @__PURE__ */ (0, import_jsx_runtime119.jsxs)( 14992 preview_wrapper_default, 14993 { 14994 label, 14995 isFocused, 14996 withHoverView, 14997 children: [ 14998 ({ ratio, key }) => /* @__PURE__ */ (0, import_jsx_runtime119.jsx)( 14999 import_components36.__unstableMotion.div, 15000 { 15001 variants: firstFrameVariants, 15002 style: { 15003 height: "100%", 15004 overflow: "hidden" 15005 }, 15006 children: /* @__PURE__ */ (0, import_jsx_runtime119.jsxs)( 15007 import_components36.__experimentalHStack, 15008 { 15009 spacing: 10 * ratio, 15010 justify: "center", 15011 style: { 15012 height: "100%", 15013 overflow: "hidden" 15014 }, 15015 children: [ 15016 /* @__PURE__ */ (0, import_jsx_runtime119.jsx)( 15017 PreviewTypography, 15018 { 15019 fontSize: 65 * ratio, 15020 variation 15021 } 15022 ), 15023 /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(import_components36.__experimentalVStack, { spacing: 4 * ratio, children: /* @__PURE__ */ (0, import_jsx_runtime119.jsx)( 15024 HighlightedColors, 15025 { 15026 normalizedColorSwatchSize: 32, 15027 ratio 15028 } 15029 ) }) 15030 ] 15031 } 15032 ) 15033 }, 15034 key 15035 ), 15036 ({ key }) => /* @__PURE__ */ (0, import_jsx_runtime119.jsx)( 15037 import_components36.__unstableMotion.div, 15038 { 15039 variants: withHoverView ? midFrameVariants : void 0, 15040 style: { 15041 height: "100%", 15042 width: "100%", 15043 position: "absolute", 15044 top: 0, 15045 overflow: "hidden", 15046 filter: "blur(60px)", 15047 opacity: 0.1 15048 }, 15049 children: /* @__PURE__ */ (0, import_jsx_runtime119.jsx)( 15050 import_components36.__experimentalHStack, 15051 { 15052 spacing: 0, 15053 justify: "flex-start", 15054 style: { 15055 height: "100%", 15056 overflow: "hidden" 15057 }, 15058 children: paletteColors.slice(0, 4).map(({ color }, index2) => /* @__PURE__ */ (0, import_jsx_runtime119.jsx)( 15059 "div", 15060 { 15061 style: { 15062 height: "100%", 15063 background: color, 15064 flexGrow: 1 15065 } 15066 }, 15067 index2 15068 )) 15069 } 15070 ) 15071 }, 15072 key 15073 ), 15074 ({ ratio, key }) => /* @__PURE__ */ (0, import_jsx_runtime119.jsx)( 15075 import_components36.__unstableMotion.div, 15076 { 15077 variants: secondFrameVariants, 15078 style: { 15079 height: "100%", 15080 width: "100%", 15081 overflow: "hidden", 15082 position: "absolute", 15083 top: 0 15084 }, 15085 children: /* @__PURE__ */ (0, import_jsx_runtime119.jsx)( 15086 import_components36.__experimentalVStack, 15087 { 15088 spacing: 3 * ratio, 15089 justify: "center", 15090 style: { 15091 height: "100%", 15092 overflow: "hidden", 15093 padding: 10 * ratio, 15094 boxSizing: "border-box" 15095 }, 15096 children: label && /* @__PURE__ */ (0, import_jsx_runtime119.jsx)( 15097 "div", 15098 { 15099 style: { 15100 fontSize: 40 * ratio, 15101 fontFamily: headingFontFamily, 15102 color: headingColor, 15103 fontWeight: headingFontWeight, 15104 lineHeight: "1em", 15105 textAlign: "center" 15106 }, 15107 children: label 15108 } 15109 ) 15110 } 15111 ) 15112 }, 15113 key 15114 ) 15115 ] 15116 } 15117 ); 15118 } 15119 var preview_styles_default = PreviewStyles; 15120 15121 // packages/global-styles-ui/build-module/screen-root.js 15122 var import_jsx_runtime120 = __toESM(require_jsx_runtime()); 15123 function ScreenRoot() { 15124 const hasVariations = (0, import_data50.useSelect)((select5) => { 15125 const { __experimentalGetCurrentThemeGlobalStylesVariations } = select5(import_core_data32.store); 15126 return !!__experimentalGetCurrentThemeGlobalStylesVariations()?.length; 15127 }, []); 15128 return /* @__PURE__ */ (0, import_jsx_runtime120.jsxs)( 15129 import_components37.Card, 15130 { 15131 size: "small", 15132 isBorderless: true, 15133 className: "global-styles-ui-screen-root", 15134 isRounded: false, 15135 children: [ 15136 /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(import_components37.CardBody, { children: /* @__PURE__ */ (0, import_jsx_runtime120.jsxs)(import_components37.__experimentalVStack, { spacing: 4, children: [ 15137 /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(import_components37.Card, { className: "global-styles-ui-screen-root__active-style-tile", children: /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(import_components37.CardMedia, { className: "global-styles-ui-screen-root__active-style-tile-preview", children: /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(preview_styles_default, {}) }) }), 15138 hasVariations && /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(import_components37.__experimentalItemGroup, { children: /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(NavigationButtonAsItem, { path: "/variations", children: /* @__PURE__ */ (0, import_jsx_runtime120.jsxs)(import_components37.__experimentalHStack, { justify: "space-between", children: [ 15139 /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(import_components37.FlexItem, { children: (0, import_i18n64.__)("Browse styles") }), 15140 /* @__PURE__ */ (0, import_jsx_runtime120.jsx)( 15141 IconWithCurrentColor, 15142 { 15143 icon: (0, import_i18n64.isRTL)() ? chevron_left_default : chevron_right_default 15144 } 15145 ) 15146 ] }) }) }), 15147 /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(root_menu_default, {}) 15148 ] }) }), 15149 /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(import_components37.CardDivider, {}), 15150 /* @__PURE__ */ (0, import_jsx_runtime120.jsxs)(import_components37.CardBody, { children: [ 15151 /* @__PURE__ */ (0, import_jsx_runtime120.jsx)( 15152 import_components37.__experimentalSpacer, 15153 { 15154 as: "p", 15155 paddingTop: 2, 15156 paddingX: "13px", 15157 marginBottom: 4, 15158 children: (0, import_i18n64.__)( 15159 "Customize the appearance of specific blocks for the whole site." 15160 ) 15161 } 15162 ), 15163 /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(import_components37.__experimentalItemGroup, { children: /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(NavigationButtonAsItem, { path: "/blocks", children: /* @__PURE__ */ (0, import_jsx_runtime120.jsxs)(import_components37.__experimentalHStack, { justify: "space-between", children: [ 15164 /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(import_components37.FlexItem, { children: (0, import_i18n64.__)("Blocks") }), 15165 /* @__PURE__ */ (0, import_jsx_runtime120.jsx)( 15166 IconWithCurrentColor, 15167 { 15168 icon: (0, import_i18n64.isRTL)() ? chevron_left_default : chevron_right_default 15169 } 15170 ) 15171 ] }) }) }) 15172 ] }) 15173 ] 15174 } 15175 ); 15176 } 15177 var screen_root_default = ScreenRoot; 15178 15179 // packages/global-styles-ui/build-module/screen-block-list.js 15180 var import_blocks15 = __toESM(require_blocks()); 15181 var import_i18n66 = __toESM(require_i18n()); 15182 var import_components40 = __toESM(require_components()); 15183 var import_data52 = __toESM(require_data()); 15184 var import_element43 = __toESM(require_element()); 15185 var import_block_editor20 = __toESM(require_block_editor()); 15186 var import_compose10 = __toESM(require_compose()); 15187 var import_a11y3 = __toESM(require_a11y()); 15188 15189 // packages/global-styles-ui/build-module/variations/variations-panel.js 15190 var import_blocks14 = __toESM(require_blocks()); 15191 var import_data51 = __toESM(require_data()); 15192 var import_components38 = __toESM(require_components()); 15193 var import_jsx_runtime121 = __toESM(require_jsx_runtime()); 15194 function getFilteredBlockStyles(blockStyles, variations) { 15195 return blockStyles?.filter( 15196 (style) => style.source === "block" || variations.includes(style.name) 15197 ) || []; 15198 } 15199 function useBlockVariations(name2) { 15200 const blockStyles = (0, import_data51.useSelect)( 15201 (select5) => { 15202 const { getBlockStyles } = select5(import_blocks14.store); 15203 return getBlockStyles(name2); 15204 }, 15205 [name2] 15206 ); 15207 const [variations] = useStyle("variations", name2); 15208 const variationNames = Object.keys(variations ?? {}); 15209 return getFilteredBlockStyles(blockStyles, variationNames); 15210 } 15211 function VariationsPanel({ name: name2 }) { 15212 const coreBlockStyles = useBlockVariations(name2); 15213 return /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(import_components38.__experimentalItemGroup, { isBordered: true, isSeparated: true, children: coreBlockStyles.map((style, index2) => { 15214 if (style?.isDefault) { 15215 return null; 15216 } 15217 return /* @__PURE__ */ (0, import_jsx_runtime121.jsx)( 15218 NavigationButtonAsItem, 15219 { 15220 path: "/blocks/" + encodeURIComponent(name2) + "/variations/" + encodeURIComponent(style.name), 15221 children: style.label 15222 }, 15223 index2 15224 ); 15225 }) }); 15226 } 15227 15228 // packages/global-styles-ui/build-module/screen-header.js 15229 var import_components39 = __toESM(require_components()); 15230 var import_i18n65 = __toESM(require_i18n()); 15231 var import_jsx_runtime122 = __toESM(require_jsx_runtime()); 15232 function ScreenHeader({ 15233 title, 15234 description, 15235 onBack 15236 }) { 15237 return /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(import_components39.__experimentalVStack, { spacing: 0, children: /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(import_components39.__experimentalView, { children: /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(import_components39.__experimentalSpacer, { marginBottom: 0, paddingX: 4, paddingY: 3, children: /* @__PURE__ */ (0, import_jsx_runtime122.jsxs)(import_components39.__experimentalVStack, { spacing: 2, children: [ 15238 /* @__PURE__ */ (0, import_jsx_runtime122.jsxs)(import_components39.__experimentalHStack, { spacing: 2, children: [ 15239 /* @__PURE__ */ (0, import_jsx_runtime122.jsx)( 15240 import_components39.Navigator.BackButton, 15241 { 15242 icon: (0, import_i18n65.isRTL)() ? chevron_right_default : chevron_left_default, 15243 size: "small", 15244 label: (0, import_i18n65.__)("Back"), 15245 onClick: onBack 15246 } 15247 ), 15248 /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(import_components39.__experimentalSpacer, { children: /* @__PURE__ */ (0, import_jsx_runtime122.jsx)( 15249 import_components39.__experimentalHeading, 15250 { 15251 className: "global-styles-ui-header", 15252 level: 2, 15253 size: 13, 15254 children: title 15255 } 15256 ) }) 15257 ] }), 15258 description && /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(import_components39.__experimentalText, { className: "global-styles-ui-header__description", children: description }) 15259 ] }) }) }) }); 15260 } 15261 15262 // packages/global-styles-ui/build-module/screen-block-list.js 15263 var import_jsx_runtime123 = __toESM(require_jsx_runtime()); 15264 var { 15265 useHasDimensionsPanel: useHasDimensionsPanel2, 15266 useHasTypographyPanel: useHasTypographyPanel2, 15267 useHasBorderPanel, 15268 useSettingsForBlockElement: useSettingsForBlockElement2, 15269 useHasColorPanel: useHasColorPanel2 15270 } = unlock3(import_block_editor20.privateApis); 15271 function useSortedBlockTypes() { 15272 const blockItems = (0, import_data52.useSelect)( 15273 (select5) => select5(import_blocks15.store).getBlockTypes(), 15274 [] 15275 ); 15276 const groupByType = (blocks, block) => { 15277 const { core, noncore } = blocks; 15278 const type = block.name.startsWith("core/") ? core : noncore; 15279 type.push(block); 15280 return blocks; 15281 }; 15282 const { core: coreItems, noncore: nonCoreItems } = blockItems.reduce( 15283 groupByType, 15284 { core: [], noncore: [] } 15285 ); 15286 return [...coreItems, ...nonCoreItems]; 15287 } 15288 function useBlockHasGlobalStyles(blockName) { 15289 const [rawSettings] = useSetting("", blockName); 15290 const settings = useSettingsForBlockElement2(rawSettings, blockName); 15291 const hasTypographyPanel = useHasTypographyPanel2(settings); 15292 const hasColorPanel = useHasColorPanel2(settings); 15293 const hasBorderPanel = useHasBorderPanel(settings); 15294 const hasDimensionsPanel = useHasDimensionsPanel2(settings); 15295 const hasLayoutPanel = hasBorderPanel || hasDimensionsPanel; 15296 const hasVariationsPanel = !!useBlockVariations(blockName)?.length; 15297 const hasGlobalStyles = hasTypographyPanel || hasColorPanel || hasLayoutPanel || hasVariationsPanel; 15298 return hasGlobalStyles; 15299 } 15300 function BlockMenuItem({ block }) { 15301 const hasBlockMenuItem = useBlockHasGlobalStyles(block.name); 15302 if (!hasBlockMenuItem) { 15303 return null; 15304 } 15305 return /* @__PURE__ */ (0, import_jsx_runtime123.jsx)( 15306 NavigationButtonAsItem, 15307 { 15308 path: "/blocks/" + encodeURIComponent(block.name), 15309 children: /* @__PURE__ */ (0, import_jsx_runtime123.jsxs)(import_components40.__experimentalHStack, { justify: "flex-start", children: [ 15310 /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(import_block_editor20.BlockIcon, { icon: block.icon }), 15311 /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(import_components40.FlexItem, { children: block.title }) 15312 ] }) 15313 } 15314 ); 15315 } 15316 function BlockList({ filterValue }) { 15317 const sortedBlockTypes = useSortedBlockTypes(); 15318 const debouncedSpeak = (0, import_compose10.useDebounce)(import_a11y3.speak, 500); 15319 const { isMatchingSearchTerm } = (0, import_data52.useSelect)(import_blocks15.store); 15320 const filteredBlockTypes = !filterValue ? sortedBlockTypes : sortedBlockTypes.filter( 15321 (blockType) => isMatchingSearchTerm(blockType, filterValue) 15322 ); 15323 const blockTypesListRef = (0, import_element43.useRef)(null); 15324 (0, import_element43.useEffect)(() => { 15325 if (!filterValue) { 15326 return; 15327 } 15328 const count = blockTypesListRef.current?.childElementCount || 0; 15329 const resultsFoundMessage = (0, import_i18n66.sprintf)( 15330 /* translators: %d: number of results. */ 15331 (0, import_i18n66._n)("%d result found.", "%d results found.", count), 15332 count 15333 ); 15334 debouncedSpeak(resultsFoundMessage, "polite"); 15335 }, [filterValue, debouncedSpeak]); 15336 return /* @__PURE__ */ (0, import_jsx_runtime123.jsx)( 15337 "div", 15338 { 15339 ref: blockTypesListRef, 15340 className: "global-styles-ui-block-types-item-list", 15341 role: "list", 15342 children: filteredBlockTypes.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(import_components40.__experimentalText, { align: "center", as: "p", children: (0, import_i18n66.__)("No blocks found.") }) : filteredBlockTypes.map((block) => /* @__PURE__ */ (0, import_jsx_runtime123.jsx)( 15343 BlockMenuItem, 15344 { 15345 block 15346 }, 15347 "menu-itemblock-" + block.name 15348 )) 15349 } 15350 ); 15351 } 15352 var MemoizedBlockList = (0, import_element43.memo)(BlockList); 15353 function ScreenBlockList() { 15354 const [filterValue, setFilterValue] = (0, import_element43.useState)(""); 15355 const deferredFilterValue = (0, import_element43.useDeferredValue)(filterValue); 15356 return /* @__PURE__ */ (0, import_jsx_runtime123.jsxs)(import_jsx_runtime123.Fragment, { children: [ 15357 /* @__PURE__ */ (0, import_jsx_runtime123.jsx)( 15358 ScreenHeader, 15359 { 15360 title: (0, import_i18n66.__)("Blocks"), 15361 description: (0, import_i18n66.__)( 15362 "Customize the appearance of specific blocks and for the whole site." 15363 ) 15364 } 15365 ), 15366 /* @__PURE__ */ (0, import_jsx_runtime123.jsx)( 15367 import_components40.SearchControl, 15368 { 15369 className: "global-styles-ui-block-types-search", 15370 onChange: setFilterValue, 15371 value: filterValue, 15372 label: (0, import_i18n66.__)("Search"), 15373 placeholder: (0, import_i18n66.__)("Search") 15374 } 15375 ), 15376 /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(MemoizedBlockList, { filterValue: deferredFilterValue }) 15377 ] }); 15378 } 15379 var screen_block_list_default = ScreenBlockList; 15380 15381 // packages/global-styles-ui/build-module/screen-block.js 15382 var import_blocks17 = __toESM(require_blocks()); 15383 var import_block_editor22 = __toESM(require_block_editor()); 15384 var import_element45 = __toESM(require_element()); 15385 var import_data53 = __toESM(require_data()); 15386 var import_core_data33 = __toESM(require_core_data()); 15387 var import_components43 = __toESM(require_components()); 15388 var import_i18n67 = __toESM(require_i18n()); 15389 15390 // packages/global-styles-ui/build-module/block-preview-panel.js 15391 var import_block_editor21 = __toESM(require_block_editor()); 15392 var import_blocks16 = __toESM(require_blocks()); 15393 var import_components41 = __toESM(require_components()); 15394 var import_element44 = __toESM(require_element()); 15395 var import_jsx_runtime124 = __toESM(require_jsx_runtime()); 15396 var BlockPreviewPanel = ({ 15397 name: name2, 15398 variation = "" 15399 }) => { 15400 const blockExample = (0, import_blocks16.getBlockType)(name2)?.example; 15401 const blocks = (0, import_element44.useMemo)(() => { 15402 if (!blockExample) { 15403 return null; 15404 } 15405 const example = { 15406 ...blockExample, 15407 attributes: { 15408 ...blockExample.attributes, 15409 style: void 0, 15410 className: variation ? getVariationClassName(variation) : blockExample.attributes?.className 15411 } 15412 }; 15413 return (0, import_blocks16.getBlockFromExample)(name2, example); 15414 }, [name2, blockExample, variation]); 15415 const viewportWidth = blockExample?.viewportWidth ?? 500; 15416 const previewHeight = 144; 15417 const sidebarWidth = 235; 15418 const scale = sidebarWidth / viewportWidth; 15419 const minHeight = scale !== 0 && scale < 1 && previewHeight ? previewHeight / scale : previewHeight; 15420 if (!blockExample) { 15421 return null; 15422 } 15423 return /* @__PURE__ */ (0, import_jsx_runtime124.jsx)(import_components41.__experimentalSpacer, { marginX: 4, marginBottom: 4, children: /* @__PURE__ */ (0, import_jsx_runtime124.jsx)( 15424 "div", 15425 { 15426 className: "global-styles-ui__block-preview-panel", 15427 style: { maxHeight: previewHeight, boxSizing: "initial" }, 15428 children: /* @__PURE__ */ (0, import_jsx_runtime124.jsx)( 15429 import_block_editor21.BlockPreview, 15430 { 15431 blocks, 15432 viewportWidth, 15433 minHeight: previewHeight, 15434 additionalStyles: ( 15435 //We want this CSS to be in sync with the one in InserterPreviewPanel. 15436 [ 15437 { 15438 css: ` 15439 body{ 15440 padding: 24px; 15441 min-height:$Math.round(minHeight)}px; 15442 display:flex; 15443 align-items:center; 15444 } 15445 .is-root-container { width: 100%; } 15446 ` 15447 } 15448 ] 15449 ) 15450 } 15451 ) 15452 } 15453 ) }); 15454 }; 15455 var block_preview_panel_default = BlockPreviewPanel; 15456 15457 // packages/global-styles-ui/build-module/subtitle.js 15458 var import_components42 = __toESM(require_components()); 15459 var import_jsx_runtime125 = __toESM(require_jsx_runtime()); 15460 function Subtitle({ children, level = 2 }) { 15461 return /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(import_components42.__experimentalHeading, { className: "global-styles-ui-subtitle", level, children }); 15462 } 15463 15464 // packages/global-styles-ui/build-module/screen-block.js 15465 var import_jsx_runtime126 = __toESM(require_jsx_runtime()); 15466 var BACKGROUND_BLOCK_DEFAULT_VALUES2 = { 15467 backgroundSize: "cover", 15468 backgroundPosition: "50% 50%" 15469 // used only when backgroundSize is 'contain'. 15470 }; 15471 function applyFallbackStyle(border) { 15472 if (!border) { 15473 return border; 15474 } 15475 const hasColorOrWidth = border.color || border.width; 15476 if (!border.style && hasColorOrWidth) { 15477 return { ...border, style: "solid" }; 15478 } 15479 if (border.style && !hasColorOrWidth) { 15480 return void 0; 15481 } 15482 return border; 15483 } 15484 function applyAllFallbackStyles(border) { 15485 if (!border) { 15486 return border; 15487 } 15488 if ((0, import_components43.__experimentalHasSplitBorders)(border)) { 15489 return { 15490 top: applyFallbackStyle(border.top), 15491 right: applyFallbackStyle(border.right), 15492 bottom: applyFallbackStyle(border.bottom), 15493 left: applyFallbackStyle(border.left) 15494 }; 15495 } 15496 return applyFallbackStyle(border); 15497 } 15498 var { 15499 useHasDimensionsPanel: useHasDimensionsPanel3, 15500 useHasTypographyPanel: useHasTypographyPanel3, 15501 useHasBorderPanel: useHasBorderPanel2, 15502 useSettingsForBlockElement: useSettingsForBlockElement3, 15503 useHasColorPanel: useHasColorPanel3, 15504 useHasFiltersPanel, 15505 useHasImageSettingsPanel, 15506 useHasBackgroundPanel: useHasBackgroundPanel2, 15507 BackgroundPanel: StylesBackgroundPanel, 15508 BorderPanel: StylesBorderPanel, 15509 ColorPanel: StylesColorPanel, 15510 TypographyPanel: StylesTypographyPanel, 15511 DimensionsPanel: StylesDimensionsPanel, 15512 FiltersPanel: StylesFiltersPanel, 15513 ImageSettingsPanel, 15514 AdvancedPanel: StylesAdvancedPanel 15515 } = unlock3(import_block_editor22.privateApis); 15516 function ScreenBlock({ name: name2, variation }) { 15517 let prefixParts = []; 15518 if (variation) { 15519 prefixParts = ["variations", variation].concat(prefixParts); 15520 } 15521 const prefix = prefixParts.join("."); 15522 const [style] = useStyle(prefix, name2, "user", false); 15523 const [inheritedStyle, setStyle2] = useStyle( 15524 prefix, 15525 name2, 15526 "merged", 15527 false 15528 ); 15529 const [userSettings] = useSetting("", name2, "user"); 15530 const [rawSettings, setSettings] = useSetting("", name2); 15531 const settingsForBlockElement = useSettingsForBlockElement3( 15532 rawSettings, 15533 name2 15534 ); 15535 const blockType = (0, import_blocks17.getBlockType)(name2); 15536 let disableBlockGap = false; 15537 if (settingsForBlockElement?.spacing?.blockGap && blockType?.supports?.spacing?.blockGap && (blockType?.supports?.spacing?.__experimentalSkipSerialization === true || blockType?.supports?.spacing?.__experimentalSkipSerialization?.some?.( 15538 (spacingType) => spacingType === "blockGap" 15539 ))) { 15540 disableBlockGap = true; 15541 } 15542 let disableAspectRatio = false; 15543 if (settingsForBlockElement?.dimensions?.aspectRatio && name2 === "core/group") { 15544 disableAspectRatio = true; 15545 } 15546 const settings = (0, import_element45.useMemo)(() => { 15547 const updatedSettings = structuredClone(settingsForBlockElement); 15548 if (disableBlockGap) { 15549 updatedSettings.spacing.blockGap = false; 15550 } 15551 if (disableAspectRatio) { 15552 updatedSettings.dimensions.aspectRatio = false; 15553 } 15554 return updatedSettings; 15555 }, [settingsForBlockElement, disableBlockGap, disableAspectRatio]); 15556 const blockVariations = useBlockVariations(name2); 15557 const hasBackgroundPanel = useHasBackgroundPanel2(settings); 15558 const hasTypographyPanel = useHasTypographyPanel3(settings); 15559 const hasColorPanel = useHasColorPanel3(settings); 15560 const hasBorderPanel = useHasBorderPanel2(settings); 15561 const hasDimensionsPanel = useHasDimensionsPanel3(settings); 15562 const hasFiltersPanel = useHasFiltersPanel(settings); 15563 const hasImageSettingsPanel = useHasImageSettingsPanel( 15564 name2, 15565 userSettings, 15566 settings 15567 ); 15568 const hasVariationsPanel = !!blockVariations?.length && !variation; 15569 const { canEditCSS } = (0, import_data53.useSelect)((select5) => { 15570 const { getEntityRecord, __experimentalGetCurrentGlobalStylesId } = select5(import_core_data33.store); 15571 const globalStylesId = __experimentalGetCurrentGlobalStylesId(); 15572 const globalStyles = globalStylesId ? getEntityRecord("root", "globalStyles", globalStylesId) : void 0; 15573 return { 15574 canEditCSS: !!globalStyles?._links?.["wp:action-edit-css"] 15575 }; 15576 }, []); 15577 const currentBlockStyle = variation ? blockVariations.find((s3) => s3.name === variation) : null; 15578 const inheritedStyleWithLayout = (0, import_element45.useMemo)(() => { 15579 return { 15580 ...inheritedStyle, 15581 layout: settings.layout 15582 }; 15583 }, [inheritedStyle, settings.layout]); 15584 const styleWithLayout = (0, import_element45.useMemo)(() => { 15585 return { 15586 ...style, 15587 layout: userSettings.layout 15588 }; 15589 }, [style, userSettings.layout]); 15590 const onChangeDimensions = (newStyle) => { 15591 const updatedStyle = { ...newStyle }; 15592 delete updatedStyle.layout; 15593 setStyle2(updatedStyle); 15594 if (newStyle.layout !== userSettings.layout) { 15595 setSettings({ 15596 ...userSettings, 15597 layout: newStyle.layout 15598 }); 15599 } 15600 }; 15601 const onChangeLightbox = (newSetting) => { 15602 if (newSetting === void 0) { 15603 setSettings({ 15604 ...rawSettings, 15605 lightbox: void 0 15606 }); 15607 } else { 15608 setSettings({ 15609 ...rawSettings, 15610 lightbox: { 15611 ...rawSettings.lightbox, 15612 ...newSetting 15613 } 15614 }); 15615 } 15616 }; 15617 const onChangeBorders = (newStyle) => { 15618 if (!newStyle?.border) { 15619 setStyle2(newStyle); 15620 return; 15621 } 15622 const { radius, ...newBorder } = newStyle.border; 15623 const border = applyAllFallbackStyles(newBorder); 15624 const updatedBorder = !(0, import_components43.__experimentalHasSplitBorders)(border) ? { 15625 top: border, 15626 right: border, 15627 bottom: border, 15628 left: border 15629 } : { 15630 color: null, 15631 style: null, 15632 width: null, 15633 ...border 15634 }; 15635 setStyle2({ ...newStyle, border: { ...updatedBorder, radius } }); 15636 }; 15637 return /* @__PURE__ */ (0, import_jsx_runtime126.jsxs)(import_jsx_runtime126.Fragment, { children: [ 15638 /* @__PURE__ */ (0, import_jsx_runtime126.jsx)( 15639 ScreenHeader, 15640 { 15641 title: variation ? currentBlockStyle?.label : blockType?.title 15642 } 15643 ), 15644 /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(block_preview_panel_default, { name: name2, variation }), 15645 hasVariationsPanel && /* @__PURE__ */ (0, import_jsx_runtime126.jsx)("div", { className: "global-styles-ui-screen-variations", children: /* @__PURE__ */ (0, import_jsx_runtime126.jsxs)(import_components43.__experimentalVStack, { spacing: 3, children: [ 15646 /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(Subtitle, { children: (0, import_i18n67.__)("Style Variations") }), 15647 /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(VariationsPanel, { name: name2 }) 15648 ] }) }), 15649 hasColorPanel && /* @__PURE__ */ (0, import_jsx_runtime126.jsx)( 15650 StylesColorPanel, 15651 { 15652 inheritedValue: inheritedStyle, 15653 value: style, 15654 onChange: setStyle2, 15655 settings 15656 } 15657 ), 15658 hasBackgroundPanel && /* @__PURE__ */ (0, import_jsx_runtime126.jsx)( 15659 StylesBackgroundPanel, 15660 { 15661 inheritedValue: inheritedStyle, 15662 value: style, 15663 onChange: setStyle2, 15664 settings, 15665 defaultValues: BACKGROUND_BLOCK_DEFAULT_VALUES2 15666 } 15667 ), 15668 hasTypographyPanel && /* @__PURE__ */ (0, import_jsx_runtime126.jsx)( 15669 StylesTypographyPanel, 15670 { 15671 inheritedValue: inheritedStyle, 15672 value: style, 15673 onChange: setStyle2, 15674 settings 15675 } 15676 ), 15677 hasDimensionsPanel && /* @__PURE__ */ (0, import_jsx_runtime126.jsx)( 15678 StylesDimensionsPanel, 15679 { 15680 inheritedValue: inheritedStyleWithLayout, 15681 value: styleWithLayout, 15682 onChange: onChangeDimensions, 15683 settings, 15684 includeLayoutControls: true 15685 } 15686 ), 15687 hasBorderPanel && /* @__PURE__ */ (0, import_jsx_runtime126.jsx)( 15688 StylesBorderPanel, 15689 { 15690 inheritedValue: inheritedStyle, 15691 value: style, 15692 onChange: onChangeBorders, 15693 settings 15694 } 15695 ), 15696 hasFiltersPanel && /* @__PURE__ */ (0, import_jsx_runtime126.jsx)( 15697 StylesFiltersPanel, 15698 { 15699 inheritedValue: inheritedStyleWithLayout, 15700 value: styleWithLayout, 15701 onChange: setStyle2, 15702 settings, 15703 includeLayoutControls: true 15704 } 15705 ), 15706 hasImageSettingsPanel && /* @__PURE__ */ (0, import_jsx_runtime126.jsx)( 15707 ImageSettingsPanel, 15708 { 15709 onChange: onChangeLightbox, 15710 value: userSettings, 15711 inheritedValue: settings 15712 } 15713 ), 15714 canEditCSS && /* @__PURE__ */ (0, import_jsx_runtime126.jsxs)(import_components43.PanelBody, { title: (0, import_i18n67.__)("Advanced"), initialOpen: false, children: [ 15715 /* @__PURE__ */ (0, import_jsx_runtime126.jsx)("p", { children: (0, import_i18n67.sprintf)( 15716 // translators: %s: is the name of a block e.g., 'Image' or 'Table'. 15717 (0, import_i18n67.__)( 15718 "Add your own CSS to customize the appearance of the %s block. You do not need to include a CSS selector, just add the property and value." 15719 ), 15720 blockType?.title 15721 ) }), 15722 /* @__PURE__ */ (0, import_jsx_runtime126.jsx)( 15723 StylesAdvancedPanel, 15724 { 15725 value: style, 15726 onChange: setStyle2, 15727 inheritedValue: inheritedStyle 15728 } 15729 ) 15730 ] }) 15731 ] }); 15732 } 15733 var screen_block_default = ScreenBlock; 15734 15735 // packages/global-styles-ui/build-module/screen-typography.js 15736 var import_i18n81 = __toESM(require_i18n()); 15737 var import_components63 = __toESM(require_components()); 15738 var import_element56 = __toESM(require_element()); 15739 15740 // packages/global-styles-ui/build-module/screen-body.js 15741 var import_components44 = __toESM(require_components()); 15742 var import_jsx_runtime127 = __toESM(require_jsx_runtime()); 15743 function ScreenBody({ children, className }) { 15744 return /* @__PURE__ */ (0, import_jsx_runtime127.jsx)( 15745 import_components44.__experimentalSpacer, 15746 { 15747 className: clsx_default("global-styles-ui-screen-body", className), 15748 padding: 4, 15749 children 15750 } 15751 ); 15752 } 15753 15754 // packages/global-styles-ui/build-module/typography-elements.js 15755 var import_i18n68 = __toESM(require_i18n()); 15756 var import_components45 = __toESM(require_components()); 15757 var import_jsx_runtime128 = __toESM(require_jsx_runtime()); 15758 function ElementItem({ parentMenu, element, label }) { 15759 const prefix = element === "text" || !element ? "" : `elements.$element}.`; 15760 const extraStyles = element === "link" ? { 15761 textDecoration: "underline" 15762 } : {}; 15763 const [fontFamily] = useStyle( 15764 prefix + "typography.fontFamily" 15765 ); 15766 const [fontStyle] = useStyle(prefix + "typography.fontStyle"); 15767 const [fontWeight] = useStyle( 15768 prefix + "typography.fontWeight" 15769 ); 15770 const [backgroundColor] = useStyle( 15771 prefix + "color.background" 15772 ); 15773 const [fallbackBackgroundColor] = useStyle("color.background"); 15774 const [gradientValue] = useStyle(prefix + "color.gradient"); 15775 const [color] = useStyle(prefix + "color.text"); 15776 return /* @__PURE__ */ (0, import_jsx_runtime128.jsx)(NavigationButtonAsItem, { path: parentMenu + "/typography/" + element, children: /* @__PURE__ */ (0, import_jsx_runtime128.jsxs)(import_components45.__experimentalHStack, { justify: "flex-start", children: [ 15777 /* @__PURE__ */ (0, import_jsx_runtime128.jsx)( 15778 import_components45.FlexItem, 15779 { 15780 className: "global-styles-ui-screen-typography__indicator", 15781 "aria-hidden": "true", 15782 style: { 15783 fontFamily: fontFamily ?? "serif", 15784 background: gradientValue ?? backgroundColor ?? fallbackBackgroundColor, 15785 color, 15786 fontStyle, 15787 fontWeight, 15788 ...extraStyles 15789 }, 15790 children: (0, import_i18n68.__)("Aa") 15791 } 15792 ), 15793 /* @__PURE__ */ (0, import_jsx_runtime128.jsx)(import_components45.FlexItem, { children: label }) 15794 ] }) }); 15795 } 15796 function TypographyElements() { 15797 const parentMenu = ""; 15798 return /* @__PURE__ */ (0, import_jsx_runtime128.jsxs)(import_components45.__experimentalVStack, { spacing: 3, children: [ 15799 /* @__PURE__ */ (0, import_jsx_runtime128.jsx)(Subtitle, { level: 3, children: (0, import_i18n68.__)("Elements") }), 15800 /* @__PURE__ */ (0, import_jsx_runtime128.jsxs)(import_components45.__experimentalItemGroup, { isBordered: true, isSeparated: true, children: [ 15801 /* @__PURE__ */ (0, import_jsx_runtime128.jsx)( 15802 ElementItem, 15803 { 15804 parentMenu, 15805 element: "text", 15806 label: (0, import_i18n68.__)("Text") 15807 } 15808 ), 15809 /* @__PURE__ */ (0, import_jsx_runtime128.jsx)( 15810 ElementItem, 15811 { 15812 parentMenu, 15813 element: "link", 15814 label: (0, import_i18n68.__)("Links") 15815 } 15816 ), 15817 /* @__PURE__ */ (0, import_jsx_runtime128.jsx)( 15818 ElementItem, 15819 { 15820 parentMenu, 15821 element: "heading", 15822 label: (0, import_i18n68.__)("Headings") 15823 } 15824 ), 15825 /* @__PURE__ */ (0, import_jsx_runtime128.jsx)( 15826 ElementItem, 15827 { 15828 parentMenu, 15829 element: "caption", 15830 label: (0, import_i18n68.__)("Captions") 15831 } 15832 ), 15833 /* @__PURE__ */ (0, import_jsx_runtime128.jsx)( 15834 ElementItem, 15835 { 15836 parentMenu, 15837 element: "button", 15838 label: (0, import_i18n68.__)("Buttons") 15839 } 15840 ) 15841 ] }) 15842 ] }); 15843 } 15844 var typography_elements_default = TypographyElements; 15845 15846 // packages/global-styles-ui/build-module/variations/variations-typography.js 15847 var import_components48 = __toESM(require_components()); 15848 15849 // packages/global-styles-ui/build-module/preview-typography.js 15850 var import_components46 = __toESM(require_components()); 15851 var import_jsx_runtime129 = __toESM(require_jsx_runtime()); 15852 var StylesPreviewTypography = ({ 15853 variation, 15854 isFocused, 15855 withHoverView 15856 }) => { 15857 return /* @__PURE__ */ (0, import_jsx_runtime129.jsx)( 15858 preview_wrapper_default, 15859 { 15860 label: variation.title, 15861 isFocused, 15862 withHoverView, 15863 children: ({ ratio, key }) => /* @__PURE__ */ (0, import_jsx_runtime129.jsx)( 15864 import_components46.__experimentalHStack, 15865 { 15866 spacing: 10 * ratio, 15867 justify: "center", 15868 style: { 15869 height: "100%", 15870 overflow: "hidden" 15871 }, 15872 children: /* @__PURE__ */ (0, import_jsx_runtime129.jsx)( 15873 PreviewTypography, 15874 { 15875 variation, 15876 fontSize: 85 * ratio 15877 } 15878 ) 15879 }, 15880 key 15881 ) 15882 } 15883 ); 15884 }; 15885 var preview_typography_default = StylesPreviewTypography; 15886 15887 // packages/global-styles-ui/build-module/variations/variation.js 15888 var import_components47 = __toESM(require_components()); 15889 var import_element46 = __toESM(require_element()); 15890 var import_keycodes2 = __toESM(require_keycodes()); 15891 var import_i18n69 = __toESM(require_i18n()); 15892 var import_jsx_runtime130 = __toESM(require_jsx_runtime()); 15893 function Variation({ 15894 variation, 15895 children, 15896 isPill = false, 15897 properties, 15898 showTooltip = false 15899 }) { 15900 const [isFocused, setIsFocused] = (0, import_element46.useState)(false); 15901 const { 15902 base, 15903 user, 15904 onChange: setUserConfig 15905 } = (0, import_element46.useContext)(GlobalStylesContext); 15906 const context = (0, import_element46.useMemo)(() => { 15907 let merged = mergeGlobalStyles(base, variation); 15908 if (properties) { 15909 merged = filterObjectByProperties(merged, properties); 15910 } 15911 return { 15912 user: variation, 15913 base, 15914 merged, 15915 onChange: () => { 15916 } 15917 }; 15918 }, [variation, base, properties]); 15919 const selectVariation = () => setUserConfig(variation); 15920 const selectOnEnter = (event) => { 15921 if (event.keyCode === import_keycodes2.ENTER) { 15922 event.preventDefault(); 15923 selectVariation(); 15924 } 15925 }; 15926 const isActive = (0, import_element46.useMemo)( 15927 () => areGlobalStylesEqual(user, variation), 15928 [user, variation] 15929 ); 15930 let label = variation?.title; 15931 if (variation?.description) { 15932 label = (0, import_i18n69.sprintf)( 15933 /* translators: 1: variation title. 2: variation description. */ 15934 (0, import_i18n69._x)("%1$s (%2$s)", "variation label"), 15935 variation?.title, 15936 variation?.description 15937 ); 15938 } 15939 const content = /* @__PURE__ */ (0, import_jsx_runtime130.jsx)( 15940 "div", 15941 { 15942 className: clsx_default("global-styles-ui-variations_item", { 15943 "is-active": isActive 15944 }), 15945 role: "button", 15946 onClick: selectVariation, 15947 onKeyDown: selectOnEnter, 15948 tabIndex: 0, 15949 "aria-label": label, 15950 "aria-current": isActive, 15951 onFocus: () => setIsFocused(true), 15952 onBlur: () => setIsFocused(false), 15953 children: /* @__PURE__ */ (0, import_jsx_runtime130.jsx)( 15954 "div", 15955 { 15956 className: clsx_default("global-styles-ui-variations_item-preview", { 15957 "is-pill": isPill 15958 }), 15959 children: children(isFocused) 15960 } 15961 ) 15962 } 15963 ); 15964 return /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(GlobalStylesContext.Provider, { value: context, children: showTooltip ? /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(import_components47.Tooltip, { text: variation?.title, children: content }) : content }); 15965 } 15966 15967 // packages/global-styles-ui/build-module/variations/variations-typography.js 15968 var import_jsx_runtime131 = __toESM(require_jsx_runtime()); 15969 var propertiesToFilter = ["typography"]; 15970 function TypographyVariations({ 15971 title, 15972 gap = 2 15973 }) { 15974 const typographyVariations = useCurrentMergeThemeStyleVariationsWithUserConfig(propertiesToFilter); 15975 if (typographyVariations?.length <= 1) { 15976 return null; 15977 } 15978 return /* @__PURE__ */ (0, import_jsx_runtime131.jsxs)(import_components48.__experimentalVStack, { spacing: 3, children: [ 15979 title && /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(Subtitle, { level: 3, children: title }), 15980 /* @__PURE__ */ (0, import_jsx_runtime131.jsx)( 15981 import_components48.__experimentalGrid, 15982 { 15983 columns: 3, 15984 gap, 15985 className: "global-styles-ui-style-variations-container", 15986 children: typographyVariations.map( 15987 (variation, index2) => { 15988 return /* @__PURE__ */ (0, import_jsx_runtime131.jsx)( 15989 Variation, 15990 { 15991 variation, 15992 properties: propertiesToFilter, 15993 showTooltip: true, 15994 children: () => /* @__PURE__ */ (0, import_jsx_runtime131.jsx)( 15995 preview_typography_default, 15996 { 15997 variation 15998 } 15999 ) 16000 }, 16001 index2 16002 ); 16003 } 16004 ) 16005 } 16006 ) 16007 ] }); 16008 } 16009 16010 // packages/global-styles-ui/build-module/font-families.js 16011 var import_i18n79 = __toESM(require_i18n()); 16012 var import_components61 = __toESM(require_components()); 16013 var import_element55 = __toESM(require_element()); 16014 16015 // packages/global-styles-ui/build-module/font-library/context.js 16016 var import_element47 = __toESM(require_element()); 16017 var import_data54 = __toESM(require_data()); 16018 var import_core_data35 = __toESM(require_core_data()); 16019 var import_i18n71 = __toESM(require_i18n()); 16020 16021 // packages/global-styles-ui/build-module/font-library/api.js 16022 var import_api_fetch3 = __toESM(require_api_fetch()); 16023 var import_core_data34 = __toESM(require_core_data()); 16024 var FONT_FAMILIES_URL = "/wp/v2/font-families"; 16025 function invalidateFontFamilyCache(registry) { 16026 const { receiveEntityRecords } = registry.dispatch(import_core_data34.store); 16027 receiveEntityRecords( 16028 "postType", 16029 "wp_font_family", 16030 [], 16031 void 0, 16032 true 16033 // invalidateCache 16034 ); 16035 } 16036 async function fetchInstallFontFamily(data, registry) { 16037 const config = { 16038 path: FONT_FAMILIES_URL, 16039 method: "POST", 16040 body: data 16041 }; 16042 const response = await (0, import_api_fetch3.default)(config); 16043 invalidateFontFamilyCache(registry); 16044 return { 16045 id: response.id, 16046 ...response.font_family_settings, 16047 fontFace: [] 16048 }; 16049 } 16050 async function fetchInstallFontFace(fontFamilyId, data, registry) { 16051 const config = { 16052 path: `$FONT_FAMILIES_URL}/$fontFamilyId}/font-faces`, 16053 method: "POST", 16054 body: data 16055 }; 16056 const response = await (0, import_api_fetch3.default)(config); 16057 invalidateFontFamilyCache(registry); 16058 return { 16059 id: response.id, 16060 ...response.font_face_settings 16061 }; 16062 } 16063 16064 // packages/global-styles-ui/build-module/font-library/utils/index.js 16065 var import_components49 = __toESM(require_components()); 16066 16067 // packages/global-styles-ui/build-module/font-library/utils/constants.js 16068 var import_i18n70 = __toESM(require_i18n()); 16069 var ALLOWED_FILE_EXTENSIONS = ["otf", "ttf", "woff", "woff2"]; 16070 var FONT_WEIGHTS = { 16071 100: (0, import_i18n70._x)("Thin", "font weight"), 16072 200: (0, import_i18n70._x)("Extra-light", "font weight"), 16073 300: (0, import_i18n70._x)("Light", "font weight"), 16074 400: (0, import_i18n70._x)("Normal", "font weight"), 16075 500: (0, import_i18n70._x)("Medium", "font weight"), 16076 600: (0, import_i18n70._x)("Semi-bold", "font weight"), 16077 700: (0, import_i18n70._x)("Bold", "font weight"), 16078 800: (0, import_i18n70._x)("Extra-bold", "font weight"), 16079 900: (0, import_i18n70._x)("Black", "font weight") 16080 }; 16081 var FONT_STYLES = { 16082 normal: (0, import_i18n70._x)("Normal", "font style"), 16083 italic: (0, import_i18n70._x)("Italic", "font style") 16084 }; 16085 16086 // packages/global-styles-ui/build-module/font-library/utils/index.js 16087 var { File: File2 } = window; 16088 var { kebabCase: kebabCase2 } = unlock3(import_components49.privateApis); 16089 function setUIValuesNeeded(font2, extraValues = {}) { 16090 if (!font2.name && (font2.fontFamily || font2.slug)) { 16091 font2.name = font2.fontFamily || font2.slug; 16092 } 16093 return { 16094 ...font2, 16095 ...extraValues 16096 }; 16097 } 16098 function isUrlEncoded(url) { 16099 if (typeof url !== "string") { 16100 return false; 16101 } 16102 return url !== decodeURIComponent(url); 16103 } 16104 function getFontFaceVariantName(face) { 16105 const weightName = FONT_WEIGHTS[face.fontWeight ?? ""] || face.fontWeight; 16106 const styleName = face.fontStyle === "normal" ? "" : FONT_STYLES[face.fontStyle ?? ""] || face.fontStyle; 16107 return `$weightName} $styleName}`; 16108 } 16109 function mergeFontFaces(existing = [], incoming = []) { 16110 const map = /* @__PURE__ */ new Map(); 16111 for (const face of existing) { 16112 map.set(`$face.fontWeight}$face.fontStyle}`, face); 16113 } 16114 for (const face of incoming) { 16115 map.set(`$face.fontWeight}$face.fontStyle}`, face); 16116 } 16117 return Array.from(map.values()); 16118 } 16119 function mergeFontFamilies(existing = [], incoming = []) { 16120 const map = /* @__PURE__ */ new Map(); 16121 for (const font2 of existing) { 16122 map.set(font2.slug, { ...font2 }); 16123 } 16124 for (const font2 of incoming) { 16125 if (map.has(font2.slug)) { 16126 const { fontFace: incomingFontFaces, ...restIncoming } = font2; 16127 const existingFont = map.get(font2.slug); 16128 const mergedFontFaces = mergeFontFaces( 16129 existingFont.fontFace, 16130 incomingFontFaces 16131 ); 16132 map.set(font2.slug, { 16133 ...restIncoming, 16134 fontFace: mergedFontFaces 16135 }); 16136 } else { 16137 map.set(font2.slug, { ...font2 }); 16138 } 16139 } 16140 return Array.from(map.values()); 16141 } 16142 async function loadFontFaceInBrowser(fontFace, source, addTo = "all") { 16143 let dataSource; 16144 if (typeof source === "string") { 16145 dataSource = `url($source})`; 16146 } else if (source instanceof File2) { 16147 dataSource = await source.arrayBuffer(); 16148 } else { 16149 return; 16150 } 16151 const newFont = new window.FontFace( 16152 formatFontFaceName(fontFace.fontFamily), 16153 dataSource, 16154 { 16155 style: fontFace.fontStyle, 16156 weight: String(fontFace.fontWeight) 16157 } 16158 ); 16159 const loadedFace = await newFont.load(); 16160 if (addTo === "document" || addTo === "all") { 16161 document.fonts.add(loadedFace); 16162 } 16163 if (addTo === "iframe" || addTo === "all") { 16164 const iframe = document.querySelector( 16165 'iframe[name="editor-canvas"]' 16166 ); 16167 if (iframe?.contentDocument) { 16168 iframe.contentDocument.fonts.add(loadedFace); 16169 } 16170 } 16171 } 16172 function unloadFontFaceInBrowser(fontFace, removeFrom = "all") { 16173 const unloadFontFace = (fonts) => { 16174 fonts.forEach((f3) => { 16175 if (f3.family === formatFontFaceName(fontFace?.fontFamily) && f3.weight === fontFace?.fontWeight && f3.style === fontFace?.fontStyle) { 16176 fonts.delete(f3); 16177 } 16178 }); 16179 }; 16180 if (removeFrom === "document" || removeFrom === "all") { 16181 unloadFontFace(document.fonts); 16182 } 16183 if (removeFrom === "iframe" || removeFrom === "all") { 16184 const iframe = document.querySelector( 16185 'iframe[name="editor-canvas"]' 16186 ); 16187 if (iframe?.contentDocument) { 16188 unloadFontFace(iframe.contentDocument.fonts); 16189 } 16190 } 16191 } 16192 function getDisplaySrcFromFontFace(input) { 16193 if (!input) { 16194 return; 16195 } 16196 let src; 16197 if (Array.isArray(input)) { 16198 src = input[0]; 16199 } else { 16200 src = input; 16201 } 16202 if (src.startsWith("file:.")) { 16203 return; 16204 } 16205 if (!isUrlEncoded(src)) { 16206 src = encodeURI(src); 16207 } 16208 return src; 16209 } 16210 function makeFontFamilyFormData(fontFamily) { 16211 const formData = new FormData(); 16212 const { fontFace, category, ...familyWithValidParameters } = fontFamily; 16213 const fontFamilySettings = { 16214 ...familyWithValidParameters, 16215 slug: kebabCase2(fontFamily.slug) 16216 }; 16217 formData.append( 16218 "font_family_settings", 16219 JSON.stringify(fontFamilySettings) 16220 ); 16221 return formData; 16222 } 16223 function makeFontFacesFormData(font2) { 16224 const fontFacesFormData = (font2?.fontFace ?? []).map( 16225 (item, faceIndex) => { 16226 const face = { ...item }; 16227 const formData = new FormData(); 16228 if (face.file) { 16229 const files = Array.isArray(face.file) ? face.file : [face.file]; 16230 const src = []; 16231 files.forEach((file, key) => { 16232 const fileId = `file-$faceIndex}-$key}`; 16233 formData.append(fileId, file, file.name); 16234 src.push(fileId); 16235 }); 16236 face.src = src.length === 1 ? src[0] : src; 16237 delete face.file; 16238 formData.append("font_face_settings", JSON.stringify(face)); 16239 } else { 16240 formData.append("font_face_settings", JSON.stringify(face)); 16241 } 16242 return formData; 16243 } 16244 ); 16245 return fontFacesFormData; 16246 } 16247 async function batchInstallFontFaces(fontFamilyId, fontFacesData, registry) { 16248 const responses = []; 16249 for (const faceData of fontFacesData) { 16250 try { 16251 const response = await fetchInstallFontFace( 16252 fontFamilyId, 16253 faceData, 16254 registry 16255 ); 16256 responses.push({ status: "fulfilled", value: response }); 16257 } catch (error) { 16258 responses.push({ status: "rejected", reason: error }); 16259 } 16260 } 16261 const results = { 16262 errors: [], 16263 successes: [] 16264 }; 16265 responses.forEach((result, index2) => { 16266 if (result.status === "fulfilled" && result.value) { 16267 const response = result.value; 16268 results.successes.push(response); 16269 } else if (result.reason) { 16270 results.errors.push({ 16271 data: fontFacesData[index2], 16272 message: result.reason.message 16273 }); 16274 } 16275 }); 16276 return results; 16277 } 16278 async function downloadFontFaceAssets(src) { 16279 src = Array.isArray(src) ? src : [src]; 16280 const files = await Promise.all( 16281 src.map(async (url) => { 16282 return fetch(new Request(url)).then((response) => { 16283 if (!response.ok) { 16284 throw new Error( 16285 `Error downloading font face asset from $url}. Server responded with status: $response.status}` 16286 ); 16287 } 16288 return response.blob(); 16289 }).then((blob) => { 16290 const filename = url.split("/").pop(); 16291 const file = new File2([blob], filename, { 16292 type: blob.type 16293 }); 16294 return file; 16295 }); 16296 }) 16297 ); 16298 return files.length === 1 ? files[0] : files; 16299 } 16300 function checkFontFaceInstalled(fontFace, collection) { 16301 return -1 !== collection.findIndex((collectionFontFace) => { 16302 return collectionFontFace.fontWeight === fontFace.fontWeight && collectionFontFace.fontStyle === fontFace.fontStyle; 16303 }); 16304 } 16305 16306 // packages/global-styles-ui/build-module/font-library/utils/set-immutably.js 16307 function setImmutably2(object, path, value) { 16308 path = Array.isArray(path) ? [...path] : [path]; 16309 object = Array.isArray(object) ? [...object] : { ...object }; 16310 const leaf = path.pop(); 16311 let prev = object; 16312 for (const key of path) { 16313 const lvl = prev[key]; 16314 prev = prev[key] = Array.isArray(lvl) ? [...lvl] : { ...lvl }; 16315 } 16316 prev[leaf] = value; 16317 return object; 16318 } 16319 16320 // packages/global-styles-ui/build-module/font-library/utils/toggleFont.js 16321 function toggleFont(font2, face, initialfonts = []) { 16322 const isFontActivated = (f3) => f3.slug === font2.slug; 16323 const getActivatedFont = (fonts) => fonts.find(isFontActivated); 16324 const toggleEntireFontFamily = (activatedFont2) => { 16325 if (!activatedFont2) { 16326 return [...initialfonts, font2]; 16327 } 16328 return initialfonts.filter( 16329 (f3) => !isFontActivated(f3) 16330 ); 16331 }; 16332 const toggleFontVariant = (activatedFont2) => { 16333 const isFaceActivated = (f3) => f3.fontWeight === face.fontWeight && f3.fontStyle === face.fontStyle; 16334 if (!activatedFont2) { 16335 return [...initialfonts, { ...font2, fontFace: [face] }]; 16336 } 16337 let newFontFaces = activatedFont2.fontFace || []; 16338 if (newFontFaces.find(isFaceActivated)) { 16339 newFontFaces = newFontFaces.filter( 16340 (f3) => !isFaceActivated(f3) 16341 ); 16342 } else { 16343 newFontFaces = [...newFontFaces, face]; 16344 } 16345 if (newFontFaces.length === 0) { 16346 return initialfonts.filter( 16347 (f3) => !isFontActivated(f3) 16348 ); 16349 } 16350 return initialfonts.map( 16351 (f3) => isFontActivated(f3) ? { ...f3, fontFace: newFontFaces } : f3 16352 ); 16353 }; 16354 const activatedFont = getActivatedFont(initialfonts); 16355 if (!face) { 16356 return toggleEntireFontFamily(activatedFont); 16357 } 16358 return toggleFontVariant(activatedFont); 16359 } 16360 16361 // packages/global-styles-ui/build-module/font-library/context.js 16362 var import_jsx_runtime132 = __toESM(require_jsx_runtime()); 16363 var FontLibraryContext = (0, import_element47.createContext)( 16364 {} 16365 ); 16366 FontLibraryContext.displayName = "FontLibraryContext"; 16367 function FontLibraryProvider({ children }) { 16368 const registry = (0, import_data54.useRegistry)(); 16369 const { saveEntityRecord, deleteEntityRecord } = (0, import_data54.useDispatch)(import_core_data35.store); 16370 const { globalStylesId } = (0, import_data54.useSelect)((select5) => { 16371 const { __experimentalGetCurrentGlobalStylesId } = select5(import_core_data35.store); 16372 return { globalStylesId: __experimentalGetCurrentGlobalStylesId() }; 16373 }, []); 16374 const globalStyles = (0, import_core_data35.useEntityRecord)( 16375 "root", 16376 "globalStyles", 16377 globalStylesId 16378 ); 16379 const [isInstalling, setIsInstalling] = (0, import_element47.useState)(false); 16380 const { records: libraryPosts = [], isResolving: isResolvingLibrary } = (0, import_core_data35.useEntityRecords)( 16381 "postType", 16382 "wp_font_family", 16383 { 16384 _embed: true 16385 } 16386 ); 16387 const libraryFonts = (libraryPosts || []).map((fontFamilyPost) => { 16388 return { 16389 id: fontFamilyPost.id, 16390 ...fontFamilyPost.font_family_settings || {}, 16391 fontFace: fontFamilyPost?._embedded?.font_faces?.map( 16392 (face) => face.font_face_settings 16393 ) || [] 16394 }; 16395 }) || []; 16396 const [fontFamilies, setFontFamilies] = useSetting("typography.fontFamilies"); 16397 const saveFontFamilies = async (fonts) => { 16398 if (!globalStyles.record) { 16399 return; 16400 } 16401 const updatedGlobalStyles = globalStyles.record; 16402 const finalGlobalStyles = setImmutably2( 16403 updatedGlobalStyles ?? {}, 16404 ["settings", "typography", "fontFamilies"], 16405 fonts 16406 ); 16407 await saveEntityRecord("root", "globalStyles", finalGlobalStyles); 16408 }; 16409 const [modalTabOpen, setModalTabOpen] = (0, import_element47.useState)(""); 16410 const [libraryFontSelected, setLibraryFontSelected] = (0, import_element47.useState)(void 0); 16411 const themeFonts = fontFamilies?.theme ? fontFamilies.theme.map((f3) => setUIValuesNeeded(f3, { source: "theme" })).sort((a3, b3) => a3.name.localeCompare(b3.name)) : []; 16412 const customFonts = fontFamilies?.custom ? fontFamilies.custom.map((f3) => setUIValuesNeeded(f3, { source: "custom" })).sort((a3, b3) => a3.name.localeCompare(b3.name)) : []; 16413 const baseCustomFonts = libraryFonts ? libraryFonts.map((f3) => setUIValuesNeeded(f3, { source: "custom" })).sort((a3, b3) => a3.name.localeCompare(b3.name)) : []; 16414 (0, import_element47.useEffect)(() => { 16415 if (!modalTabOpen) { 16416 setLibraryFontSelected(void 0); 16417 } 16418 }, [modalTabOpen]); 16419 const handleSetLibraryFontSelected = (font2) => { 16420 if (!font2) { 16421 setLibraryFontSelected(void 0); 16422 return; 16423 } 16424 const fonts = font2.source === "theme" ? themeFonts : baseCustomFonts; 16425 const fontSelected = fonts.find((f3) => f3.slug === font2.slug); 16426 setLibraryFontSelected({ 16427 ...fontSelected || font2, 16428 source: font2.source 16429 }); 16430 }; 16431 const [loadedFontUrls] = (0, import_element47.useState)(/* @__PURE__ */ new Set()); 16432 const getAvailableFontsOutline = (availableFontFamilies) => { 16433 const outline = availableFontFamilies.reduce( 16434 (acc, font2) => { 16435 const availableFontFaces = font2?.fontFace && font2.fontFace?.length > 0 ? font2?.fontFace.map( 16436 (face) => `$face.fontStyle ?? ""}$face.fontWeight ?? ""}` 16437 ) : ["normal400"]; 16438 acc[font2.slug] = availableFontFaces; 16439 return acc; 16440 }, 16441 {} 16442 ); 16443 return outline; 16444 }; 16445 const getActivatedFontsOutline = (source) => { 16446 switch (source) { 16447 case "theme": 16448 return getAvailableFontsOutline(themeFonts); 16449 case "custom": 16450 default: 16451 return getAvailableFontsOutline(customFonts); 16452 } 16453 }; 16454 const isFontActivated = (slug, style, weight, source) => { 16455 if (!style && !weight) { 16456 return !!getActivatedFontsOutline(source)[slug]; 16457 } 16458 return !!getActivatedFontsOutline(source)[slug]?.includes( 16459 (style ?? "") + (weight ?? "") 16460 ); 16461 }; 16462 const getFontFacesActivated = (slug, source) => { 16463 return getActivatedFontsOutline(source)[slug] || []; 16464 }; 16465 async function installFonts(fontFamiliesToInstall) { 16466 setIsInstalling(true); 16467 try { 16468 const fontFamiliesToActivate = []; 16469 let installationErrors = []; 16470 for (const fontFamilyToInstall of fontFamiliesToInstall) { 16471 let isANewFontFamily = false; 16472 const fontFamilyRecords = await (0, import_data54.resolveSelect)( 16473 import_core_data35.store 16474 ).getEntityRecords("postType", "wp_font_family", { 16475 slug: fontFamilyToInstall.slug, 16476 per_page: 1, 16477 _embed: true 16478 }); 16479 const fontFamilyPost = fontFamilyRecords && fontFamilyRecords.length > 0 ? fontFamilyRecords[0] : null; 16480 let installedFontFamily = fontFamilyPost ? { 16481 id: fontFamilyPost.id, 16482 ...fontFamilyPost.font_family_settings, 16483 fontFace: (fontFamilyPost?._embedded?.font_faces ?? []).map( 16484 (face) => face.font_face_settings 16485 ) || [] 16486 } : null; 16487 if (!installedFontFamily) { 16488 isANewFontFamily = true; 16489 installedFontFamily = await fetchInstallFontFamily( 16490 makeFontFamilyFormData(fontFamilyToInstall), 16491 registry 16492 ); 16493 } 16494 const alreadyInstalledFontFaces = installedFontFamily.fontFace && fontFamilyToInstall.fontFace ? installedFontFamily.fontFace.filter( 16495 (fontFaceToInstall) => fontFaceToInstall && fontFamilyToInstall.fontFace && checkFontFaceInstalled( 16496 fontFaceToInstall, 16497 fontFamilyToInstall.fontFace 16498 ) 16499 ) : []; 16500 if (installedFontFamily.fontFace && fontFamilyToInstall.fontFace) { 16501 fontFamilyToInstall.fontFace = fontFamilyToInstall.fontFace.filter( 16502 (fontFaceToInstall) => !checkFontFaceInstalled( 16503 fontFaceToInstall, 16504 installedFontFamily.fontFace 16505 ) 16506 ); 16507 } 16508 let successfullyInstalledFontFaces = []; 16509 let unsuccessfullyInstalledFontFaces = []; 16510 if (fontFamilyToInstall?.fontFace?.length ?? 0 > 0) { 16511 const response = await batchInstallFontFaces( 16512 installedFontFamily.id, 16513 makeFontFacesFormData( 16514 fontFamilyToInstall 16515 ), 16516 registry 16517 ); 16518 successfullyInstalledFontFaces = response?.successes; 16519 unsuccessfullyInstalledFontFaces = response?.errors; 16520 } 16521 if (successfullyInstalledFontFaces?.length > 0 || alreadyInstalledFontFaces?.length > 0) { 16522 installedFontFamily.fontFace = [ 16523 ...successfullyInstalledFontFaces 16524 ]; 16525 fontFamiliesToActivate.push(installedFontFamily); 16526 } 16527 if (installedFontFamily && !fontFamilyToInstall?.fontFace?.length) { 16528 fontFamiliesToActivate.push(installedFontFamily); 16529 } 16530 if (isANewFontFamily && (fontFamilyToInstall?.fontFace?.length ?? 0) > 0 && successfullyInstalledFontFaces?.length === 0) { 16531 await deleteEntityRecord( 16532 "postType", 16533 "wp_font_family", 16534 installedFontFamily.id, 16535 { force: true } 16536 ); 16537 } 16538 installationErrors = installationErrors.concat( 16539 unsuccessfullyInstalledFontFaces 16540 ); 16541 } 16542 const installationErrorMessages = installationErrors.reduce( 16543 (unique, item) => unique.includes(item.message) ? unique : [...unique, item.message], 16544 [] 16545 ); 16546 if (fontFamiliesToActivate.length > 0) { 16547 const activeFonts = activateCustomFontFamilies( 16548 fontFamiliesToActivate 16549 ); 16550 await saveFontFamilies(activeFonts); 16551 } 16552 if (installationErrorMessages.length > 0) { 16553 const installError = new Error((0, import_i18n71.__)("There was an error installing fonts.")); 16554 installError.installationErrors = installationErrorMessages; 16555 throw installError; 16556 } 16557 } finally { 16558 setIsInstalling(false); 16559 } 16560 } 16561 async function uninstallFontFamily(fontFamilyToUninstall) { 16562 if (!fontFamilyToUninstall?.id) { 16563 throw new Error((0, import_i18n71.__)("Font family to uninstall is not defined.")); 16564 } 16565 try { 16566 await deleteEntityRecord( 16567 "postType", 16568 "wp_font_family", 16569 fontFamilyToUninstall.id, 16570 { force: true } 16571 ); 16572 const activeFonts = deactivateFontFamily(fontFamilyToUninstall); 16573 await saveFontFamilies(activeFonts); 16574 return { deleted: true }; 16575 } catch (error) { 16576 console.error( 16577 `There was an error uninstalling the font family:`, 16578 error 16579 ); 16580 throw error; 16581 } 16582 } 16583 const deactivateFontFamily = (font2) => { 16584 const initialCustomFonts = fontFamilies?.[font2.source ?? ""] ?? []; 16585 const newCustomFonts = initialCustomFonts.filter( 16586 (f3) => f3.slug !== font2.slug 16587 ); 16588 const activeFonts = { 16589 ...fontFamilies, 16590 [font2.source ?? ""]: newCustomFonts 16591 }; 16592 setFontFamilies(activeFonts); 16593 if (font2.fontFace) { 16594 font2.fontFace.forEach((face) => { 16595 unloadFontFaceInBrowser(face, "all"); 16596 }); 16597 } 16598 return activeFonts; 16599 }; 16600 const activateCustomFontFamilies = (fontsToAdd) => { 16601 const fontsToActivate = cleanFontsForSave(fontsToAdd); 16602 const activeFonts = { 16603 ...fontFamilies, 16604 // Merge the existing custom fonts with the new fonts. 16605 custom: mergeFontFamilies(fontFamilies?.custom, fontsToActivate) 16606 }; 16607 setFontFamilies(activeFonts); 16608 loadFontsInBrowser(fontsToActivate); 16609 return activeFonts; 16610 }; 16611 const cleanFontsForSave = (fonts) => { 16612 return fonts.map(({ id: _familyDbId, fontFace, ...font2 }) => ({ 16613 ...font2, 16614 ...fontFace && fontFace.length > 0 ? { 16615 fontFace: fontFace.map( 16616 ({ id: _faceDbId, ...face }) => face 16617 ) 16618 } : {} 16619 })); 16620 }; 16621 const loadFontsInBrowser = (fonts) => { 16622 fonts.forEach((font2) => { 16623 if (font2.fontFace) { 16624 font2.fontFace.forEach((face) => { 16625 const displaySrc = getDisplaySrcFromFontFace( 16626 face?.src ?? "" 16627 ); 16628 if (displaySrc) { 16629 loadFontFaceInBrowser(face, displaySrc, "all"); 16630 } 16631 }); 16632 } 16633 }); 16634 }; 16635 const toggleActivateFont = (font2, face) => { 16636 const initialFonts = fontFamilies?.[font2.source ?? ""] ?? []; 16637 const newFonts = toggleFont(font2, face, initialFonts); 16638 setFontFamilies({ 16639 ...fontFamilies, 16640 [font2.source ?? ""]: newFonts 16641 }); 16642 const isFaceActivated = isFontActivated( 16643 font2.slug, 16644 face?.fontStyle ?? "", 16645 face?.fontWeight ?? "", 16646 font2.source ?? "custom" 16647 ); 16648 if (face && isFaceActivated) { 16649 unloadFontFaceInBrowser(face, "all"); 16650 } else { 16651 const displaySrc = getDisplaySrcFromFontFace(face?.src ?? ""); 16652 if (face && displaySrc) { 16653 loadFontFaceInBrowser(face, displaySrc, "all"); 16654 } 16655 } 16656 }; 16657 const loadFontFaceAsset = async (fontFace) => { 16658 if (!fontFace.src) { 16659 return; 16660 } 16661 const src = getDisplaySrcFromFontFace(fontFace.src); 16662 if (!src || loadedFontUrls.has(src)) { 16663 return; 16664 } 16665 loadFontFaceInBrowser(fontFace, src, "document"); 16666 loadedFontUrls.add(src); 16667 }; 16668 return /* @__PURE__ */ (0, import_jsx_runtime132.jsx)( 16669 FontLibraryContext.Provider, 16670 { 16671 value: { 16672 libraryFontSelected, 16673 handleSetLibraryFontSelected, 16674 fontFamilies: fontFamilies ?? {}, 16675 baseCustomFonts, 16676 isFontActivated, 16677 getFontFacesActivated, 16678 loadFontFaceAsset, 16679 installFonts, 16680 uninstallFontFamily, 16681 toggleActivateFont, 16682 getAvailableFontsOutline, 16683 modalTabOpen, 16684 setModalTabOpen, 16685 saveFontFamilies, 16686 isResolvingLibrary, 16687 isInstalling 16688 }, 16689 children 16690 } 16691 ); 16692 } 16693 var context_default = FontLibraryProvider; 16694 16695 // packages/global-styles-ui/build-module/font-library/modal.js 16696 var import_i18n77 = __toESM(require_i18n()); 16697 var import_components59 = __toESM(require_components()); 16698 var import_core_data38 = __toESM(require_core_data()); 16699 var import_data56 = __toESM(require_data()); 16700 16701 // packages/global-styles-ui/build-module/font-library/installed-fonts.js 16702 var import_components53 = __toESM(require_components()); 16703 var import_core_data36 = __toESM(require_core_data()); 16704 var import_data55 = __toESM(require_data()); 16705 var import_element50 = __toESM(require_element()); 16706 var import_i18n73 = __toESM(require_i18n()); 16707 16708 // packages/global-styles-ui/build-module/font-library/font-card.js 16709 var import_i18n72 = __toESM(require_i18n()); 16710 var import_components51 = __toESM(require_components()); 16711 16712 // packages/global-styles-ui/build-module/font-library/font-demo.js 16713 var import_components50 = __toESM(require_components()); 16714 var import_element48 = __toESM(require_element()); 16715 var import_jsx_runtime133 = __toESM(require_jsx_runtime()); 16716 function getPreviewUrl(fontFace) { 16717 if (fontFace.preview) { 16718 return fontFace.preview; 16719 } 16720 if (fontFace.src) { 16721 return Array.isArray(fontFace.src) ? fontFace.src[0] : fontFace.src; 16722 } 16723 return void 0; 16724 } 16725 function getDisplayFontFace(font2) { 16726 if ("fontStyle" in font2 && font2.fontStyle || "fontWeight" in font2 && font2.fontWeight) { 16727 return font2; 16728 } 16729 if ("fontFace" in font2 && font2.fontFace && font2.fontFace.length) { 16730 return font2.fontFace.find( 16731 (face) => face.fontStyle === "normal" && face.fontWeight === "400" 16732 ) || font2.fontFace[0]; 16733 } 16734 return { 16735 fontStyle: "normal", 16736 fontWeight: "400", 16737 fontFamily: font2.fontFamily 16738 }; 16739 } 16740 function FontDemo({ font: font2, text }) { 16741 const ref = (0, import_element48.useRef)(null); 16742 const fontFace = getDisplayFontFace(font2); 16743 const style = getFamilyPreviewStyle(font2); 16744 text = text || ("name" in font2 ? font2.name : ""); 16745 const customPreviewUrl = font2.preview; 16746 const [isIntersecting, setIsIntersecting] = (0, import_element48.useState)(false); 16747 const [isAssetLoaded, setIsAssetLoaded] = (0, import_element48.useState)(false); 16748 const { loadFontFaceAsset } = (0, import_element48.useContext)(FontLibraryContext); 16749 const previewUrl = customPreviewUrl ?? getPreviewUrl(fontFace); 16750 const isPreviewImage = previewUrl && previewUrl.match(/\.(png|jpg|jpeg|gif|svg)$/i); 16751 const faceStyles = getFacePreviewStyle(fontFace); 16752 const textDemoStyle = { 16753 fontSize: "18px", 16754 lineHeight: 1, 16755 opacity: isAssetLoaded ? "1" : "0", 16756 ...style, 16757 ...faceStyles 16758 }; 16759 (0, import_element48.useEffect)(() => { 16760 const observer = new window.IntersectionObserver(([entry]) => { 16761 setIsIntersecting(entry.isIntersecting); 16762 }, {}); 16763 if (ref.current) { 16764 observer.observe(ref.current); 16765 } 16766 return () => observer.disconnect(); 16767 }, [ref]); 16768 (0, import_element48.useEffect)(() => { 16769 const loadAsset = async () => { 16770 if (isIntersecting) { 16771 if (!isPreviewImage && fontFace.src) { 16772 await loadFontFaceAsset(fontFace); 16773 } 16774 setIsAssetLoaded(true); 16775 } 16776 }; 16777 loadAsset(); 16778 }, [fontFace, isIntersecting, loadFontFaceAsset, isPreviewImage]); 16779 return /* @__PURE__ */ (0, import_jsx_runtime133.jsx)("div", { ref, children: isPreviewImage ? /* @__PURE__ */ (0, import_jsx_runtime133.jsx)( 16780 "img", 16781 { 16782 src: previewUrl, 16783 loading: "lazy", 16784 alt: text, 16785 className: "font-library__font-variant_demo-image" 16786 } 16787 ) : /* @__PURE__ */ (0, import_jsx_runtime133.jsx)( 16788 import_components50.__experimentalText, 16789 { 16790 style: textDemoStyle, 16791 className: "font-library__font-variant_demo-text", 16792 children: text 16793 } 16794 ) }); 16795 } 16796 var font_demo_default = FontDemo; 16797 16798 // packages/global-styles-ui/build-module/font-library/font-card.js 16799 var import_jsx_runtime134 = __toESM(require_jsx_runtime()); 16800 function FontCard({ 16801 font: font2, 16802 onClick, 16803 variantsText, 16804 navigatorPath 16805 }) { 16806 const variantsCount = font2.fontFace?.length || 1; 16807 const style = { 16808 cursor: !!onClick ? "pointer" : "default" 16809 }; 16810 const navigator = (0, import_components51.useNavigator)(); 16811 return /* @__PURE__ */ (0, import_jsx_runtime134.jsx)( 16812 import_components51.Button, 16813 { 16814 __next40pxDefaultSize: true, 16815 onClick: () => { 16816 onClick(); 16817 if (navigatorPath) { 16818 navigator.goTo(navigatorPath); 16819 } 16820 }, 16821 style, 16822 className: "font-library__font-card", 16823 children: /* @__PURE__ */ (0, import_jsx_runtime134.jsxs)(import_components51.Flex, { justify: "space-between", wrap: false, children: [ 16824 /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(font_demo_default, { font: font2 }), 16825 /* @__PURE__ */ (0, import_jsx_runtime134.jsxs)(import_components51.Flex, { justify: "flex-end", children: [ 16826 /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(import_components51.FlexItem, { children: /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(import_components51.__experimentalText, { className: "font-library__font-card__count", children: variantsText || (0, import_i18n72.sprintf)( 16827 /* translators: %d: Number of font variants. */ 16828 (0, import_i18n72._n)( 16829 "%d variant", 16830 "%d variants", 16831 variantsCount 16832 ), 16833 variantsCount 16834 ) }) }), 16835 /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(import_components51.FlexItem, { children: /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(icon_default, { icon: (0, import_i18n72.isRTL)() ? chevron_left_default : chevron_right_default }) }) 16836 ] }) 16837 ] }) 16838 } 16839 ); 16840 } 16841 var font_card_default = FontCard; 16842 16843 // packages/global-styles-ui/build-module/font-library/library-font-variant.js 16844 var import_element49 = __toESM(require_element()); 16845 var import_components52 = __toESM(require_components()); 16846 var import_jsx_runtime135 = __toESM(require_jsx_runtime()); 16847 function LibraryFontVariant({ 16848 face, 16849 font: font2 16850 }) { 16851 const { isFontActivated, toggleActivateFont } = (0, import_element49.useContext)(FontLibraryContext); 16852 const isInstalled = (font2?.fontFace?.length ?? 0) > 0 ? isFontActivated( 16853 font2.slug, 16854 face.fontStyle, 16855 face.fontWeight, 16856 font2.source 16857 ) : isFontActivated(font2.slug, void 0, void 0, font2.source); 16858 const handleToggleActivation = () => { 16859 if ((font2?.fontFace?.length ?? 0) > 0) { 16860 toggleActivateFont(font2, face); 16861 return; 16862 } 16863 toggleActivateFont(font2); 16864 }; 16865 const displayName = font2.name + " " + getFontFaceVariantName(face); 16866 const checkboxId = (0, import_element49.useId)(); 16867 return /* @__PURE__ */ (0, import_jsx_runtime135.jsx)("div", { className: "font-library__font-card", children: /* @__PURE__ */ (0, import_jsx_runtime135.jsxs)(import_components52.Flex, { justify: "flex-start", align: "center", gap: "1rem", children: [ 16868 /* @__PURE__ */ (0, import_jsx_runtime135.jsx)( 16869 import_components52.CheckboxControl, 16870 { 16871 checked: isInstalled, 16872 onChange: handleToggleActivation, 16873 id: checkboxId 16874 } 16875 ), 16876 /* @__PURE__ */ (0, import_jsx_runtime135.jsx)("label", { htmlFor: checkboxId, children: /* @__PURE__ */ (0, import_jsx_runtime135.jsx)( 16877 font_demo_default, 16878 { 16879 font: face, 16880 text: displayName, 16881 onClick: handleToggleActivation 16882 } 16883 ) }) 16884 ] }) }); 16885 } 16886 var library_font_variant_default = LibraryFontVariant; 16887 16888 // packages/global-styles-ui/build-module/font-library/utils/sort-font-faces.js 16889 function getNumericFontWeight(value) { 16890 switch (value) { 16891 case "normal": 16892 return 400; 16893 case "bold": 16894 return 700; 16895 case "bolder": 16896 return 500; 16897 case "lighter": 16898 return 300; 16899 default: 16900 return parseInt(value, 10); 16901 } 16902 } 16903 function sortFontFaces(faces) { 16904 return faces.sort((a3, b3) => { 16905 if (a3.fontStyle === "normal" && b3.fontStyle !== "normal") { 16906 return -1; 16907 } 16908 if (b3.fontStyle === "normal" && a3.fontStyle !== "normal") { 16909 return 1; 16910 } 16911 if (a3.fontStyle === b3.fontStyle) { 16912 return getNumericFontWeight(a3.fontWeight?.toString() ?? "normal") - getNumericFontWeight(b3.fontWeight?.toString() ?? "normal"); 16913 } 16914 if (!a3.fontStyle || !b3.fontStyle) { 16915 return !a3.fontStyle ? 1 : -1; 16916 } 16917 return a3.fontStyle.localeCompare(b3.fontStyle); 16918 }); 16919 } 16920 16921 // packages/global-styles-ui/build-module/font-library/installed-fonts.js 16922 var import_jsx_runtime136 = __toESM(require_jsx_runtime()); 16923 function InstalledFonts() { 16924 const { 16925 baseCustomFonts, 16926 libraryFontSelected, 16927 handleSetLibraryFontSelected, 16928 uninstallFontFamily, 16929 isResolvingLibrary, 16930 isInstalling, 16931 saveFontFamilies, 16932 getFontFacesActivated 16933 } = (0, import_element50.useContext)(FontLibraryContext); 16934 const [fontFamilies, setFontFamilies] = useSetting("typography.fontFamilies"); 16935 const [isConfirmDeleteOpen, setIsConfirmDeleteOpen] = (0, import_element50.useState)(false); 16936 const [notice, setNotice] = (0, import_element50.useState)(null); 16937 const [baseFontFamilies] = useSetting("typography.fontFamilies", void 0, "base"); 16938 const globalStylesId = (0, import_data55.useSelect)((select5) => { 16939 const { __experimentalGetCurrentGlobalStylesId } = select5(import_core_data36.store); 16940 return __experimentalGetCurrentGlobalStylesId(); 16941 }, []); 16942 const globalStyles = (0, import_core_data36.useEntityRecord)( 16943 "root", 16944 "globalStyles", 16945 globalStylesId 16946 ); 16947 const fontFamiliesHasChanges = !!globalStyles?.edits?.settings?.typography?.fontFamilies; 16948 const themeFonts = fontFamilies?.theme ? fontFamilies.theme.map((f3) => setUIValuesNeeded(f3, { source: "theme" })).sort((a3, b3) => a3.name.localeCompare(b3.name)) : []; 16949 const themeFontsSlugs = new Set(themeFonts.map((f3) => f3.slug)); 16950 const baseThemeFonts = baseFontFamilies?.theme ? themeFonts.concat( 16951 baseFontFamilies.theme.filter((f3) => !themeFontsSlugs.has(f3.slug)).map((f3) => setUIValuesNeeded(f3, { source: "theme" })).sort((a3, b3) => a3.name.localeCompare(b3.name)) 16952 ) : []; 16953 const customFontFamilyId = libraryFontSelected?.source === "custom" && libraryFontSelected?.id; 16954 const canUserDelete = (0, import_data55.useSelect)( 16955 (select5) => { 16956 const { canUser } = select5(import_core_data36.store); 16957 return customFontFamilyId && canUser("delete", { 16958 kind: "postType", 16959 name: "wp_font_family", 16960 id: customFontFamilyId 16961 }); 16962 }, 16963 [customFontFamilyId] 16964 ); 16965 const shouldDisplayDeleteButton = !!libraryFontSelected && libraryFontSelected?.source !== "theme" && canUserDelete; 16966 const handleUninstallClick = () => { 16967 setIsConfirmDeleteOpen(true); 16968 }; 16969 const handleUpdate = async () => { 16970 setNotice(null); 16971 try { 16972 await saveFontFamilies(fontFamilies); 16973 setNotice({ 16974 type: "success", 16975 message: (0, import_i18n73.__)("Font family updated successfully.") 16976 }); 16977 } catch (error) { 16978 setNotice({ 16979 type: "error", 16980 message: (0, import_i18n73.sprintf)( 16981 /* translators: %s: error message */ 16982 (0, import_i18n73.__)("There was an error updating the font family. %s"), 16983 error.message 16984 ) 16985 }); 16986 } 16987 }; 16988 const getFontFacesToDisplay = (font2) => { 16989 if (!font2) { 16990 return []; 16991 } 16992 if (!font2.fontFace || !font2.fontFace.length) { 16993 return [ 16994 { 16995 fontFamily: font2.fontFamily, 16996 fontStyle: "normal", 16997 fontWeight: "400" 16998 } 16999 ]; 17000 } 17001 return sortFontFaces(font2.fontFace); 17002 }; 17003 const getFontCardVariantsText = (font2) => { 17004 const variantsInstalled = font2?.fontFace && (font2?.fontFace?.length ?? 0) > 0 ? font2.fontFace.length : 1; 17005 const variantsActive = getFontFacesActivated( 17006 font2.slug, 17007 font2.source 17008 ).length; 17009 return (0, import_i18n73.sprintf)( 17010 /* translators: 1: Active font variants, 2: Total font variants. */ 17011 (0, import_i18n73.__)("%1$d/%2$d variants active"), 17012 variantsActive, 17013 variantsInstalled 17014 ); 17015 }; 17016 (0, import_element50.useEffect)(() => { 17017 handleSetLibraryFontSelected(libraryFontSelected); 17018 }, []); 17019 const activeFontsCount = libraryFontSelected ? getFontFacesActivated( 17020 libraryFontSelected.slug, 17021 libraryFontSelected.source 17022 ).length : 0; 17023 const selectedFontsCount = libraryFontSelected?.fontFace?.length ?? (libraryFontSelected?.fontFamily ? 1 : 0); 17024 const isIndeterminate = activeFontsCount > 0 && activeFontsCount !== selectedFontsCount; 17025 const isSelectAllChecked = activeFontsCount === selectedFontsCount; 17026 const toggleSelectAll = () => { 17027 if (!libraryFontSelected || !libraryFontSelected?.source) { 17028 return; 17029 } 17030 const initialFonts = fontFamilies?.[libraryFontSelected.source]?.filter( 17031 (f3) => f3.slug !== libraryFontSelected.slug 17032 ) ?? []; 17033 const newFonts = isSelectAllChecked ? initialFonts : [...initialFonts, libraryFontSelected]; 17034 setFontFamilies({ 17035 ...fontFamilies, 17036 [libraryFontSelected.source]: newFonts 17037 }); 17038 if (libraryFontSelected.fontFace) { 17039 libraryFontSelected.fontFace.forEach((face) => { 17040 if (isSelectAllChecked) { 17041 unloadFontFaceInBrowser(face, "all"); 17042 } else { 17043 const displaySrc = getDisplaySrcFromFontFace( 17044 face?.src ?? "" 17045 ); 17046 if (displaySrc) { 17047 loadFontFaceInBrowser(face, displaySrc, "all"); 17048 } 17049 } 17050 }); 17051 } 17052 }; 17053 const hasFonts = baseThemeFonts.length > 0 || baseCustomFonts.length > 0; 17054 return /* @__PURE__ */ (0, import_jsx_runtime136.jsxs)("div", { className: "font-library__tabpanel-layout", children: [ 17055 isResolvingLibrary && /* @__PURE__ */ (0, import_jsx_runtime136.jsx)("div", { className: "font-library__loading", children: /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(import_components53.ProgressBar, {}) }), 17056 !isResolvingLibrary && /* @__PURE__ */ (0, import_jsx_runtime136.jsxs)(import_jsx_runtime136.Fragment, { children: [ 17057 /* @__PURE__ */ (0, import_jsx_runtime136.jsxs)( 17058 import_components53.Navigator, 17059 { 17060 initialPath: libraryFontSelected ? "/fontFamily" : "/", 17061 children: [ 17062 /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(import_components53.Navigator.Screen, { path: "/", children: /* @__PURE__ */ (0, import_jsx_runtime136.jsxs)(import_components53.__experimentalVStack, { spacing: "8", children: [ 17063 notice && /* @__PURE__ */ (0, import_jsx_runtime136.jsx)( 17064 import_components53.Notice, 17065 { 17066 status: notice.type, 17067 onRemove: () => setNotice(null), 17068 children: notice.message 17069 } 17070 ), 17071 !hasFonts && /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(import_components53.__experimentalText, { as: "p", children: (0, import_i18n73.__)("No fonts installed.") }), 17072 baseThemeFonts.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime136.jsxs)(import_components53.__experimentalVStack, { children: [ 17073 /* @__PURE__ */ (0, import_jsx_runtime136.jsx)("h2", { 17074 className: "font-library__fonts-title", 17075 /* translators: Heading for a list of fonts provided by the theme. */ 17076 children: (0, import_i18n73._x)("Theme", "font source") 17077 }), 17078 /* @__PURE__ */ (0, import_jsx_runtime136.jsx)( 17079 "ul", 17080 { 17081 role: "list", 17082 className: "font-library__fonts-list", 17083 children: baseThemeFonts.map((font2) => /* @__PURE__ */ (0, import_jsx_runtime136.jsx)( 17084 "li", 17085 { 17086 className: "font-library__fonts-list-item", 17087 children: /* @__PURE__ */ (0, import_jsx_runtime136.jsx)( 17088 font_card_default, 17089 { 17090 font: font2, 17091 navigatorPath: "/fontFamily", 17092 variantsText: getFontCardVariantsText( 17093 font2 17094 ), 17095 onClick: () => { 17096 setNotice(null); 17097 handleSetLibraryFontSelected( 17098 font2 17099 ); 17100 } 17101 } 17102 ) 17103 }, 17104 font2.slug 17105 )) 17106 } 17107 ) 17108 ] }), 17109 baseCustomFonts.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime136.jsxs)(import_components53.__experimentalVStack, { children: [ 17110 /* @__PURE__ */ (0, import_jsx_runtime136.jsx)("h2", { 17111 className: "font-library__fonts-title", 17112 /* translators: Heading for a list of fonts installed by the user. */ 17113 children: (0, import_i18n73._x)("Custom", "font source") 17114 }), 17115 /* @__PURE__ */ (0, import_jsx_runtime136.jsx)( 17116 "ul", 17117 { 17118 role: "list", 17119 className: "font-library__fonts-list", 17120 children: baseCustomFonts.map((font2) => /* @__PURE__ */ (0, import_jsx_runtime136.jsx)( 17121 "li", 17122 { 17123 className: "font-library__fonts-list-item", 17124 children: /* @__PURE__ */ (0, import_jsx_runtime136.jsx)( 17125 font_card_default, 17126 { 17127 font: font2, 17128 navigatorPath: "/fontFamily", 17129 variantsText: getFontCardVariantsText( 17130 font2 17131 ), 17132 onClick: () => { 17133 setNotice(null); 17134 handleSetLibraryFontSelected( 17135 font2 17136 ); 17137 } 17138 } 17139 ) 17140 }, 17141 font2.slug 17142 )) 17143 } 17144 ) 17145 ] }) 17146 ] }) }), 17147 /* @__PURE__ */ (0, import_jsx_runtime136.jsxs)(import_components53.Navigator.Screen, { path: "/fontFamily", children: [ 17148 libraryFontSelected && /* @__PURE__ */ (0, import_jsx_runtime136.jsx)( 17149 ConfirmDeleteDialog, 17150 { 17151 font: libraryFontSelected, 17152 isOpen: isConfirmDeleteOpen, 17153 setIsOpen: setIsConfirmDeleteOpen, 17154 setNotice, 17155 uninstallFontFamily, 17156 handleSetLibraryFontSelected 17157 } 17158 ), 17159 /* @__PURE__ */ (0, import_jsx_runtime136.jsxs)(import_components53.Flex, { justify: "flex-start", children: [ 17160 /* @__PURE__ */ (0, import_jsx_runtime136.jsx)( 17161 import_components53.Navigator.BackButton, 17162 { 17163 icon: (0, import_i18n73.isRTL)() ? chevron_right_default : chevron_left_default, 17164 size: "small", 17165 onClick: () => { 17166 handleSetLibraryFontSelected( 17167 void 0 17168 ); 17169 setNotice(null); 17170 }, 17171 label: (0, import_i18n73.__)("Back") 17172 } 17173 ), 17174 /* @__PURE__ */ (0, import_jsx_runtime136.jsx)( 17175 import_components53.__experimentalHeading, 17176 { 17177 level: 2, 17178 size: 13, 17179 className: "global-styles-ui-header", 17180 children: libraryFontSelected?.name 17181 } 17182 ) 17183 ] }), 17184 notice && /* @__PURE__ */ (0, import_jsx_runtime136.jsxs)(import_jsx_runtime136.Fragment, { children: [ 17185 /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(import_components53.__experimentalSpacer, { margin: 1 }), 17186 /* @__PURE__ */ (0, import_jsx_runtime136.jsx)( 17187 import_components53.Notice, 17188 { 17189 status: notice.type, 17190 onRemove: () => setNotice(null), 17191 children: notice.message 17192 } 17193 ), 17194 /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(import_components53.__experimentalSpacer, { margin: 1 }) 17195 ] }), 17196 /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(import_components53.__experimentalSpacer, { margin: 4 }), 17197 /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(import_components53.__experimentalText, { children: (0, import_i18n73.__)( 17198 "Choose font variants. Keep in mind that too many variants could make your site slower." 17199 ) }), 17200 /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(import_components53.__experimentalSpacer, { margin: 4 }), 17201 /* @__PURE__ */ (0, import_jsx_runtime136.jsxs)(import_components53.__experimentalVStack, { spacing: 0, children: [ 17202 /* @__PURE__ */ (0, import_jsx_runtime136.jsx)( 17203 import_components53.CheckboxControl, 17204 { 17205 className: "font-library__select-all", 17206 label: (0, import_i18n73.__)("Select all"), 17207 checked: isSelectAllChecked, 17208 onChange: toggleSelectAll, 17209 indeterminate: isIndeterminate 17210 } 17211 ), 17212 /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(import_components53.__experimentalSpacer, { margin: 8 }), 17213 /* @__PURE__ */ (0, import_jsx_runtime136.jsx)( 17214 "ul", 17215 { 17216 role: "list", 17217 className: "font-library__fonts-list", 17218 children: libraryFontSelected && getFontFacesToDisplay( 17219 libraryFontSelected 17220 ).map((face, i3) => /* @__PURE__ */ (0, import_jsx_runtime136.jsx)( 17221 "li", 17222 { 17223 className: "font-library__fonts-list-item", 17224 children: /* @__PURE__ */ (0, import_jsx_runtime136.jsx)( 17225 library_font_variant_default, 17226 { 17227 font: libraryFontSelected, 17228 face 17229 }, 17230 `face$i3}` 17231 ) 17232 }, 17233 `face$i3}` 17234 )) 17235 } 17236 ) 17237 ] }) 17238 ] }) 17239 ] 17240 } 17241 ), 17242 /* @__PURE__ */ (0, import_jsx_runtime136.jsxs)(import_components53.__experimentalHStack, { justify: "flex-end", className: "font-library__footer", children: [ 17243 isInstalling && /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(import_components53.ProgressBar, {}), 17244 shouldDisplayDeleteButton && /* @__PURE__ */ (0, import_jsx_runtime136.jsx)( 17245 import_components53.Button, 17246 { 17247 __next40pxDefaultSize: true, 17248 isDestructive: true, 17249 variant: "tertiary", 17250 onClick: handleUninstallClick, 17251 children: (0, import_i18n73.__)("Delete") 17252 } 17253 ), 17254 /* @__PURE__ */ (0, import_jsx_runtime136.jsx)( 17255 import_components53.Button, 17256 { 17257 __next40pxDefaultSize: true, 17258 variant: "primary", 17259 onClick: handleUpdate, 17260 disabled: !fontFamiliesHasChanges, 17261 accessibleWhenDisabled: true, 17262 children: (0, import_i18n73.__)("Update") 17263 } 17264 ) 17265 ] }) 17266 ] }) 17267 ] }); 17268 } 17269 function ConfirmDeleteDialog({ 17270 font: font2, 17271 isOpen, 17272 setIsOpen, 17273 setNotice, 17274 uninstallFontFamily, 17275 handleSetLibraryFontSelected 17276 }) { 17277 const navigator = (0, import_components53.useNavigator)(); 17278 const handleConfirmUninstall = async () => { 17279 setNotice(null); 17280 setIsOpen(false); 17281 try { 17282 await uninstallFontFamily(font2); 17283 navigator.goBack(); 17284 handleSetLibraryFontSelected(void 0); 17285 setNotice({ 17286 type: "success", 17287 message: (0, import_i18n73.__)("Font family uninstalled successfully.") 17288 }); 17289 } catch (error) { 17290 setNotice({ 17291 type: "error", 17292 message: (0, import_i18n73.__)("There was an error uninstalling the font family.") + error.message 17293 }); 17294 } 17295 }; 17296 const handleCancelUninstall = () => { 17297 setIsOpen(false); 17298 }; 17299 return /* @__PURE__ */ (0, import_jsx_runtime136.jsx)( 17300 import_components53.__experimentalConfirmDialog, 17301 { 17302 isOpen, 17303 cancelButtonText: (0, import_i18n73.__)("Cancel"), 17304 confirmButtonText: (0, import_i18n73.__)("Delete"), 17305 onCancel: handleCancelUninstall, 17306 onConfirm: handleConfirmUninstall, 17307 size: "medium", 17308 children: font2 && (0, import_i18n73.sprintf)( 17309 /* translators: %s: Name of the font. */ 17310 (0, import_i18n73.__)( 17311 'Are you sure you want to delete "%s" font and all its variants and assets?' 17312 ), 17313 font2.name 17314 ) 17315 } 17316 ); 17317 } 17318 var installed_fonts_default = InstalledFonts; 17319 17320 // packages/global-styles-ui/build-module/font-library/font-collection.js 17321 var import_element52 = __toESM(require_element()); 17322 var import_components56 = __toESM(require_components()); 17323 var import_compose11 = __toESM(require_compose()); 17324 var import_i18n75 = __toESM(require_i18n()); 17325 var import_core_data37 = __toESM(require_core_data()); 17326 17327 // packages/global-styles-ui/build-module/font-library/utils/filter-fonts.js 17328 function filterFonts(fonts, filters) { 17329 const { category, search } = filters; 17330 let filteredFonts = fonts || []; 17331 if (category && category !== "all") { 17332 filteredFonts = filteredFonts.filter( 17333 (font2) => font2.categories && font2.categories.indexOf(category) !== -1 17334 ); 17335 } 17336 if (search) { 17337 filteredFonts = filteredFonts.filter( 17338 (font2) => font2.font_family_settings && font2.font_family_settings.name.toLowerCase().includes(search.toLowerCase()) 17339 ); 17340 } 17341 return filteredFonts; 17342 } 17343 17344 // packages/global-styles-ui/build-module/font-library/utils/fonts-outline.js 17345 function getFontsOutline(fonts) { 17346 return fonts.reduce( 17347 (acc, font2) => ({ 17348 ...acc, 17349 [font2.slug]: (font2?.fontFace || []).reduce( 17350 (faces, face) => ({ 17351 ...faces, 17352 [`$face.fontStyle}-$face.fontWeight}`]: true 17353 }), 17354 {} 17355 ) 17356 }), 17357 {} 17358 ); 17359 } 17360 function isFontFontFaceInOutline(slug, face, outline) { 17361 if (!face) { 17362 return !!outline[slug]; 17363 } 17364 return !!outline[slug]?.[`$face.fontStyle}-$face.fontWeight}`]; 17365 } 17366 17367 // packages/global-styles-ui/build-module/font-library/google-fonts-confirm-dialog.js 17368 var import_i18n74 = __toESM(require_i18n()); 17369 var import_components54 = __toESM(require_components()); 17370 var import_jsx_runtime137 = __toESM(require_jsx_runtime()); 17371 function GoogleFontsConfirmDialog() { 17372 const handleConfirm = () => { 17373 window.localStorage.setItem( 17374 "wp-font-library-google-fonts-permission", 17375 "true" 17376 ); 17377 window.dispatchEvent(new Event("storage")); 17378 }; 17379 return /* @__PURE__ */ (0, import_jsx_runtime137.jsx)("div", { className: "font-library__google-fonts-confirm", children: /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(import_components54.Card, { children: /* @__PURE__ */ (0, import_jsx_runtime137.jsxs)(import_components54.CardBody, { children: [ 17380 /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(import_components54.__experimentalHeading, { level: 2, children: (0, import_i18n74.__)("Connect to Google Fonts") }), 17381 /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(import_components54.__experimentalSpacer, { margin: 6 }), 17382 /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(import_components54.__experimentalText, { as: "p", children: (0, import_i18n74.__)( 17383 "To install fonts from Google you must give permission to connect directly to Google servers. The fonts you install will be downloaded from Google and stored on your site. Your site will then use these locally-hosted fonts." 17384 ) }), 17385 /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(import_components54.__experimentalSpacer, { margin: 3 }), 17386 /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(import_components54.__experimentalText, { as: "p", children: (0, import_i18n74.__)( 17387 "You can alternatively upload files directly on the Upload tab." 17388 ) }), 17389 /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(import_components54.__experimentalSpacer, { margin: 6 }), 17390 /* @__PURE__ */ (0, import_jsx_runtime137.jsx)( 17391 import_components54.Button, 17392 { 17393 __next40pxDefaultSize: true, 17394 variant: "primary", 17395 onClick: handleConfirm, 17396 children: (0, import_i18n74.__)("Allow access to Google Fonts") 17397 } 17398 ) 17399 ] }) }) }); 17400 } 17401 var google_fonts_confirm_dialog_default = GoogleFontsConfirmDialog; 17402 17403 // packages/global-styles-ui/build-module/font-library/collection-font-variant.js 17404 var import_element51 = __toESM(require_element()); 17405 var import_components55 = __toESM(require_components()); 17406 var import_jsx_runtime138 = __toESM(require_jsx_runtime()); 17407 function CollectionFontVariant({ 17408 face, 17409 font: font2, 17410 handleToggleVariant, 17411 selected 17412 }) { 17413 const handleToggleActivation = () => { 17414 if (font2?.fontFace) { 17415 handleToggleVariant(font2, face); 17416 return; 17417 } 17418 handleToggleVariant(font2); 17419 }; 17420 const displayName = font2.name + " " + getFontFaceVariantName(face); 17421 const checkboxId = (0, import_element51.useId)(); 17422 return /* @__PURE__ */ (0, import_jsx_runtime138.jsx)("div", { className: "font-library__font-card", children: /* @__PURE__ */ (0, import_jsx_runtime138.jsxs)(import_components55.Flex, { justify: "flex-start", align: "center", gap: "1rem", children: [ 17423 /* @__PURE__ */ (0, import_jsx_runtime138.jsx)( 17424 import_components55.CheckboxControl, 17425 { 17426 checked: selected, 17427 onChange: handleToggleActivation, 17428 id: checkboxId 17429 } 17430 ), 17431 /* @__PURE__ */ (0, import_jsx_runtime138.jsx)("label", { htmlFor: checkboxId, children: /* @__PURE__ */ (0, import_jsx_runtime138.jsx)( 17432 font_demo_default, 17433 { 17434 font: face, 17435 text: displayName, 17436 onClick: handleToggleActivation 17437 } 17438 ) }) 17439 ] }) }); 17440 } 17441 var collection_font_variant_default = CollectionFontVariant; 17442 17443 // packages/global-styles-ui/build-module/font-library/font-collection.js 17444 var import_jsx_runtime139 = __toESM(require_jsx_runtime()); 17445 var DEFAULT_CATEGORY = { 17446 slug: "all", 17447 name: (0, import_i18n75._x)("All", "font categories") 17448 }; 17449 var LOCAL_STORAGE_ITEM = "wp-font-library-google-fonts-permission"; 17450 var MIN_WINDOW_HEIGHT = 500; 17451 function FontCollection({ slug }) { 17452 const requiresPermission = slug === "google-fonts"; 17453 const getGoogleFontsPermissionFromStorage = () => { 17454 return window.localStorage.getItem(LOCAL_STORAGE_ITEM) === "true"; 17455 }; 17456 const [selectedFont, setSelectedFont] = (0, import_element52.useState)( 17457 null 17458 ); 17459 const [notice, setNotice] = (0, import_element52.useState)(null); 17460 const [fontsToInstall, setFontsToInstall] = (0, import_element52.useState)( 17461 [] 17462 ); 17463 const [page, setPage] = (0, import_element52.useState)(1); 17464 const [filters, setFilters] = (0, import_element52.useState)({}); 17465 const [renderConfirmDialog, setRenderConfirmDialog] = (0, import_element52.useState)( 17466 requiresPermission && !getGoogleFontsPermissionFromStorage() 17467 ); 17468 const { installFonts, isInstalling } = (0, import_element52.useContext)(FontLibraryContext); 17469 const { record: selectedCollection, isResolving: isLoading } = (0, import_core_data37.useEntityRecord)("root", "fontCollection", slug); 17470 (0, import_element52.useEffect)(() => { 17471 const handleStorage = () => { 17472 setRenderConfirmDialog( 17473 requiresPermission && !getGoogleFontsPermissionFromStorage() 17474 ); 17475 }; 17476 handleStorage(); 17477 window.addEventListener("storage", handleStorage); 17478 return () => window.removeEventListener("storage", handleStorage); 17479 }, [slug, requiresPermission]); 17480 const revokeAccess = () => { 17481 window.localStorage.setItem(LOCAL_STORAGE_ITEM, "false"); 17482 window.dispatchEvent(new Event("storage")); 17483 }; 17484 (0, import_element52.useEffect)(() => { 17485 setSelectedFont(null); 17486 }, [slug]); 17487 (0, import_element52.useEffect)(() => { 17488 setFontsToInstall([]); 17489 }, [selectedFont]); 17490 const collectionFonts = (0, import_element52.useMemo)( 17491 () => selectedCollection?.font_families ?? [], 17492 [selectedCollection] 17493 ); 17494 const collectionCategories = selectedCollection?.categories ?? []; 17495 const categories = [DEFAULT_CATEGORY, ...collectionCategories]; 17496 const fonts = (0, import_element52.useMemo)( 17497 () => filterFonts(collectionFonts, filters), 17498 [collectionFonts, filters] 17499 ); 17500 const windowHeight = Math.max(window.innerHeight, MIN_WINDOW_HEIGHT); 17501 const pageSize = Math.floor((windowHeight - 417) / 61); 17502 const totalPages = Math.ceil(fonts.length / pageSize); 17503 const itemsStart = (page - 1) * pageSize; 17504 const itemsLimit = page * pageSize; 17505 const items = fonts.slice(itemsStart, itemsLimit); 17506 const handleCategoryFilter = (category) => { 17507 setFilters({ ...filters, category }); 17508 setPage(1); 17509 }; 17510 const handleUpdateSearchInput = (value) => { 17511 setFilters({ ...filters, search: value }); 17512 setPage(1); 17513 }; 17514 const debouncedUpdateSearchInput = (0, import_compose11.debounce)(handleUpdateSearchInput, 300); 17515 const handleToggleVariant = (font2, face) => { 17516 const newFontsToInstall = toggleFont(font2, face, fontsToInstall); 17517 setFontsToInstall(newFontsToInstall); 17518 }; 17519 const fontToInstallOutline = getFontsOutline(fontsToInstall); 17520 const resetFontsToInstall = () => { 17521 setFontsToInstall([]); 17522 }; 17523 const selectFontCount = fontsToInstall.length > 0 ? fontsToInstall[0]?.fontFace?.length ?? 0 : 0; 17524 const isIndeterminate = selectFontCount > 0 && selectFontCount !== selectedFont?.fontFace?.length; 17525 const isSelectAllChecked = selectFontCount === selectedFont?.fontFace?.length; 17526 const toggleSelectAll = () => { 17527 const newFonts = []; 17528 if (!isSelectAllChecked && selectedFont) { 17529 newFonts.push(selectedFont); 17530 } 17531 setFontsToInstall(newFonts); 17532 }; 17533 const handleInstall = async () => { 17534 setNotice(null); 17535 const fontFamily = fontsToInstall[0]; 17536 try { 17537 if (fontFamily?.fontFace) { 17538 await Promise.all( 17539 fontFamily.fontFace.map(async (fontFace) => { 17540 if (fontFace.src) { 17541 fontFace.file = await downloadFontFaceAssets( 17542 fontFace.src 17543 ); 17544 } 17545 }) 17546 ); 17547 } 17548 } catch (error) { 17549 setNotice({ 17550 type: "error", 17551 message: (0, import_i18n75.__)( 17552 "Error installing the fonts, could not be downloaded." 17553 ) 17554 }); 17555 return; 17556 } 17557 try { 17558 await installFonts([fontFamily]); 17559 setNotice({ 17560 type: "success", 17561 message: (0, import_i18n75.__)("Fonts were installed successfully.") 17562 }); 17563 } catch (error) { 17564 setNotice({ 17565 type: "error", 17566 message: error.message 17567 }); 17568 } 17569 resetFontsToInstall(); 17570 }; 17571 const getSortedFontFaces = (fontFamily) => { 17572 if (!fontFamily) { 17573 return []; 17574 } 17575 if (!fontFamily.fontFace || !fontFamily.fontFace.length) { 17576 return [ 17577 { 17578 fontFamily: fontFamily.fontFamily, 17579 fontStyle: "normal", 17580 fontWeight: "400" 17581 } 17582 ]; 17583 } 17584 return sortFontFaces(fontFamily.fontFace); 17585 }; 17586 if (renderConfirmDialog) { 17587 return /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(google_fonts_confirm_dialog_default, {}); 17588 } 17589 const ActionsComponent = () => { 17590 if (slug !== "google-fonts" || renderConfirmDialog || selectedFont) { 17591 return null; 17592 } 17593 return /* @__PURE__ */ (0, import_jsx_runtime139.jsx)( 17594 import_components56.DropdownMenu, 17595 { 17596 icon: more_vertical_default, 17597 label: (0, import_i18n75.__)("Actions"), 17598 popoverProps: { 17599 position: "bottom left" 17600 }, 17601 controls: [ 17602 { 17603 title: (0, import_i18n75.__)("Revoke access to Google Fonts"), 17604 onClick: revokeAccess 17605 } 17606 ] 17607 } 17608 ); 17609 }; 17610 return /* @__PURE__ */ (0, import_jsx_runtime139.jsxs)("div", { className: "font-library__tabpanel-layout", children: [ 17611 isLoading && /* @__PURE__ */ (0, import_jsx_runtime139.jsx)("div", { className: "font-library__loading", children: /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(import_components56.ProgressBar, {}) }), 17612 !isLoading && selectedCollection && /* @__PURE__ */ (0, import_jsx_runtime139.jsxs)(import_jsx_runtime139.Fragment, { children: [ 17613 /* @__PURE__ */ (0, import_jsx_runtime139.jsxs)( 17614 import_components56.Navigator, 17615 { 17616 initialPath: "/", 17617 className: "font-library__tabpanel-layout", 17618 children: [ 17619 /* @__PURE__ */ (0, import_jsx_runtime139.jsxs)(import_components56.Navigator.Screen, { path: "/", children: [ 17620 /* @__PURE__ */ (0, import_jsx_runtime139.jsxs)(import_components56.__experimentalHStack, { justify: "space-between", children: [ 17621 /* @__PURE__ */ (0, import_jsx_runtime139.jsxs)(import_components56.__experimentalVStack, { children: [ 17622 /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(import_components56.__experimentalHeading, { level: 2, size: 13, children: selectedCollection.name }), 17623 /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(import_components56.__experimentalText, { children: selectedCollection.description }) 17624 ] }), 17625 /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(ActionsComponent, {}) 17626 ] }), 17627 /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(import_components56.__experimentalSpacer, { margin: 4 }), 17628 /* @__PURE__ */ (0, import_jsx_runtime139.jsxs)(import_components56.__experimentalHStack, { spacing: 4, justify: "space-between", children: [ 17629 /* @__PURE__ */ (0, import_jsx_runtime139.jsx)( 17630 import_components56.SearchControl, 17631 { 17632 value: filters.search, 17633 placeholder: (0, import_i18n75.__)("Font name\u2026"), 17634 label: (0, import_i18n75.__)("Search"), 17635 onChange: debouncedUpdateSearchInput, 17636 hideLabelFromVision: false 17637 } 17638 ), 17639 /* @__PURE__ */ (0, import_jsx_runtime139.jsx)( 17640 import_components56.SelectControl, 17641 { 17642 __next40pxDefaultSize: true, 17643 label: (0, import_i18n75.__)("Category"), 17644 value: filters.category, 17645 onChange: handleCategoryFilter, 17646 children: categories && categories.map((category) => /* @__PURE__ */ (0, import_jsx_runtime139.jsx)( 17647 "option", 17648 { 17649 value: category.slug, 17650 children: category.name 17651 }, 17652 category.slug 17653 )) 17654 } 17655 ) 17656 ] }), 17657 /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(import_components56.__experimentalSpacer, { margin: 4 }), 17658 !!selectedCollection?.font_families?.length && !fonts.length && /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(import_components56.__experimentalText, { children: (0, import_i18n75.__)( 17659 "No fonts found. Try with a different search term." 17660 ) }), 17661 /* @__PURE__ */ (0, import_jsx_runtime139.jsx)("div", { className: "font-library__fonts-grid__main", children: /* @__PURE__ */ (0, import_jsx_runtime139.jsx)( 17662 "ul", 17663 { 17664 role: "list", 17665 className: "font-library__fonts-list", 17666 children: items.map((font2) => /* @__PURE__ */ (0, import_jsx_runtime139.jsx)( 17667 "li", 17668 { 17669 className: "font-library__fonts-list-item", 17670 children: /* @__PURE__ */ (0, import_jsx_runtime139.jsx)( 17671 font_card_default, 17672 { 17673 font: font2.font_family_settings, 17674 navigatorPath: "/fontFamily", 17675 onClick: () => { 17676 setSelectedFont( 17677 font2.font_family_settings 17678 ); 17679 } 17680 } 17681 ) 17682 }, 17683 font2.font_family_settings.slug 17684 )) 17685 } 17686 ) }) 17687 ] }), 17688 /* @__PURE__ */ (0, import_jsx_runtime139.jsxs)(import_components56.Navigator.Screen, { path: "/fontFamily", children: [ 17689 /* @__PURE__ */ (0, import_jsx_runtime139.jsxs)(import_components56.Flex, { justify: "flex-start", children: [ 17690 /* @__PURE__ */ (0, import_jsx_runtime139.jsx)( 17691 import_components56.Navigator.BackButton, 17692 { 17693 icon: (0, import_i18n75.isRTL)() ? chevron_right_default : chevron_left_default, 17694 size: "small", 17695 onClick: () => { 17696 setSelectedFont(null); 17697 setNotice(null); 17698 }, 17699 label: (0, import_i18n75.__)("Back") 17700 } 17701 ), 17702 /* @__PURE__ */ (0, import_jsx_runtime139.jsx)( 17703 import_components56.__experimentalHeading, 17704 { 17705 level: 2, 17706 size: 13, 17707 className: "global-styles-ui-header", 17708 children: selectedFont?.name 17709 } 17710 ) 17711 ] }), 17712 notice && /* @__PURE__ */ (0, import_jsx_runtime139.jsxs)(import_jsx_runtime139.Fragment, { children: [ 17713 /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(import_components56.__experimentalSpacer, { margin: 1 }), 17714 /* @__PURE__ */ (0, import_jsx_runtime139.jsx)( 17715 import_components56.Notice, 17716 { 17717 status: notice.type, 17718 onRemove: () => setNotice(null), 17719 children: notice.message 17720 } 17721 ), 17722 /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(import_components56.__experimentalSpacer, { margin: 1 }) 17723 ] }), 17724 /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(import_components56.__experimentalSpacer, { margin: 4 }), 17725 /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(import_components56.__experimentalText, { children: (0, import_i18n75.__)("Select font variants to install.") }), 17726 /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(import_components56.__experimentalSpacer, { margin: 4 }), 17727 /* @__PURE__ */ (0, import_jsx_runtime139.jsx)( 17728 import_components56.CheckboxControl, 17729 { 17730 className: "font-library__select-all", 17731 label: (0, import_i18n75.__)("Select all"), 17732 checked: isSelectAllChecked, 17733 onChange: toggleSelectAll, 17734 indeterminate: isIndeterminate 17735 } 17736 ), 17737 /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(import_components56.__experimentalVStack, { spacing: 0, children: /* @__PURE__ */ (0, import_jsx_runtime139.jsx)( 17738 "ul", 17739 { 17740 role: "list", 17741 className: "font-library__fonts-list", 17742 children: selectedFont && getSortedFontFaces(selectedFont).map( 17743 (face, i3) => /* @__PURE__ */ (0, import_jsx_runtime139.jsx)( 17744 "li", 17745 { 17746 className: "font-library__fonts-list-item", 17747 children: /* @__PURE__ */ (0, import_jsx_runtime139.jsx)( 17748 collection_font_variant_default, 17749 { 17750 font: selectedFont, 17751 face, 17752 handleToggleVariant, 17753 selected: isFontFontFaceInOutline( 17754 selectedFont.slug, 17755 selectedFont.fontFace ? face : null, 17756 // If the font has no fontFace, we want to check if the font is in the outline 17757 fontToInstallOutline 17758 ) 17759 } 17760 ) 17761 }, 17762 `face$i3}` 17763 ) 17764 ) 17765 } 17766 ) }), 17767 /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(import_components56.__experimentalSpacer, { margin: 16 }) 17768 ] }) 17769 ] 17770 } 17771 ), 17772 selectedFont && /* @__PURE__ */ (0, import_jsx_runtime139.jsx)( 17773 import_components56.Flex, 17774 { 17775 justify: "flex-end", 17776 className: "font-library__footer", 17777 children: /* @__PURE__ */ (0, import_jsx_runtime139.jsx)( 17778 import_components56.Button, 17779 { 17780 __next40pxDefaultSize: true, 17781 variant: "primary", 17782 onClick: handleInstall, 17783 isBusy: isInstalling, 17784 disabled: fontsToInstall.length === 0 || isInstalling, 17785 accessibleWhenDisabled: true, 17786 children: (0, import_i18n75.__)("Install") 17787 } 17788 ) 17789 } 17790 ), 17791 !selectedFont && /* @__PURE__ */ (0, import_jsx_runtime139.jsxs)( 17792 import_components56.__experimentalHStack, 17793 { 17794 expanded: false, 17795 className: "font-library__footer", 17796 justify: "end", 17797 spacing: 6, 17798 children: [ 17799 /* @__PURE__ */ (0, import_jsx_runtime139.jsx)( 17800 import_components56.__experimentalHStack, 17801 { 17802 justify: "flex-start", 17803 expanded: false, 17804 spacing: 1, 17805 className: "font-library__page-selection", 17806 children: (0, import_element52.createInterpolateElement)( 17807 (0, import_i18n75.sprintf)( 17808 // translators: 1: Current page number, 2: Total number of pages. 17809 (0, import_i18n75._x)( 17810 "<div>Page</div>%1$s<div>of %2$d</div>", 17811 "paging" 17812 ), 17813 "<CurrentPage />", 17814 totalPages 17815 ), 17816 { 17817 div: /* @__PURE__ */ (0, import_jsx_runtime139.jsx)("div", { "aria-hidden": true }), 17818 CurrentPage: /* @__PURE__ */ (0, import_jsx_runtime139.jsx)( 17819 import_components56.SelectControl, 17820 { 17821 "aria-label": (0, import_i18n75.__)( 17822 "Current page" 17823 ), 17824 value: page.toString(), 17825 options: [ 17826 ...Array(totalPages) 17827 ].map((e3, i3) => { 17828 return { 17829 label: (i3 + 1).toString(), 17830 value: (i3 + 1).toString() 17831 }; 17832 }), 17833 onChange: (newPage) => setPage( 17834 parseInt(newPage) 17835 ), 17836 size: "small", 17837 variant: "minimal" 17838 } 17839 ) 17840 } 17841 ) 17842 } 17843 ), 17844 /* @__PURE__ */ (0, import_jsx_runtime139.jsxs)(import_components56.__experimentalHStack, { expanded: false, spacing: 1, children: [ 17845 /* @__PURE__ */ (0, import_jsx_runtime139.jsx)( 17846 import_components56.Button, 17847 { 17848 onClick: () => setPage(page - 1), 17849 disabled: page === 1, 17850 accessibleWhenDisabled: true, 17851 label: (0, import_i18n75.__)("Previous page"), 17852 icon: (0, import_i18n75.isRTL)() ? next_default : previous_default, 17853 showTooltip: true, 17854 size: "compact", 17855 tooltipPosition: "top" 17856 } 17857 ), 17858 /* @__PURE__ */ (0, import_jsx_runtime139.jsx)( 17859 import_components56.Button, 17860 { 17861 onClick: () => setPage(page + 1), 17862 disabled: page === totalPages, 17863 accessibleWhenDisabled: true, 17864 label: (0, import_i18n75.__)("Next page"), 17865 icon: (0, import_i18n75.isRTL)() ? previous_default : next_default, 17866 showTooltip: true, 17867 size: "compact", 17868 tooltipPosition: "top" 17869 } 17870 ) 17871 ] }) 17872 ] 17873 } 17874 ) 17875 ] }) 17876 ] }); 17877 } 17878 var font_collection_default = FontCollection; 17879 17880 // packages/global-styles-ui/build-module/font-library/upload-fonts.js 17881 var import_i18n76 = __toESM(require_i18n()); 17882 var import_components58 = __toESM(require_components()); 17883 var import_element53 = __toESM(require_element()); 17884 17885 // packages/global-styles-ui/build-module/font-library/lib/unbrotli.js 17886 var __getOwnPropNames2 = Object.getOwnPropertyNames; 17887 var __require2 = /* @__PURE__ */ ((x2) => typeof __require !== "undefined" ? __require : typeof Proxy !== "undefined" ? new Proxy(x2, { 17888 get: (a3, b3) => (typeof __require !== "undefined" ? __require : a3)[b3] 17889 }) : x2)(function(x2) { 17890 if (typeof __require !== "undefined") return __require.apply(this, arguments); 17891 throw Error('Dynamic require of "' + x2 + '" is not supported'); 17892 }); 17893 var __commonJS2 = (cb, mod) => function __require22() { 17894 return mod || (0, cb[__getOwnPropNames2(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; 17895 }; 17896 var require_unbrotli = __commonJS2({ 17897 "packages/global-styles-ui/src/font-library/lib/unbrotli.js"(exports, module) { 17898 (function(f3) { 17899 if (typeof exports === "object" && typeof module !== "undefined") { 17900 module.exports = f3(); 17901 } else if (typeof define === "function" && define.amd) { 17902 define([], f3); 17903 } else { 17904 var g3; 17905 if (typeof window !== "undefined") { 17906 g3 = window; 17907 } else if (typeof global !== "undefined") { 17908 g3 = global; 17909 } else if (typeof self !== "undefined") { 17910 g3 = self; 17911 } else { 17912 g3 = this; 17913 } 17914 g3.unbrotli = f3(); 17915 } 17916 })(function() { 17917 var define2, module2, exports2; 17918 return (/* @__PURE__ */ (function() { 17919 function r4(e3, n3, t4) { 17920 function o4(i22, f3) { 17921 if (!n3[i22]) { 17922 if (!e3[i22]) { 17923 var c2 = "function" == typeof __require2 && __require2; 17924 if (!f3 && c2) return c2(i22, true); 17925 if (u3) return u3(i22, true); 17926 var a3 = new Error("Cannot find module '" + i22 + "'"); 17927 throw a3.code = "MODULE_NOT_FOUND", a3; 17928 } 17929 var p4 = n3[i22] = { exports: {} }; 17930 e3[i22][0].call( 17931 p4.exports, 17932 function(r22) { 17933 var n22 = e3[i22][1][r22]; 17934 return o4(n22 || r22); 17935 }, 17936 p4, 17937 p4.exports, 17938 r4, 17939 e3, 17940 n3, 17941 t4 17942 ); 17943 } 17944 return n3[i22].exports; 17945 } 17946 for (var u3 = "function" == typeof __require2 && __require2, i3 = 0; i3 < t4.length; i3++) 17947 o4(t4[i3]); 17948 return o4; 17949 } 17950 return r4; 17951 })())( 17952 { 17953 1: [ 17954 function(require2, module3, exports3) { 17955 var BROTLI_READ_SIZE = 4096; 17956 var BROTLI_IBUF_SIZE = 2 * BROTLI_READ_SIZE + 32; 17957 var BROTLI_IBUF_MASK = 2 * BROTLI_READ_SIZE - 1; 17958 var kBitMask = new Uint32Array([ 17959 0, 17960 1, 17961 3, 17962 7, 17963 15, 17964 31, 17965 63, 17966 127, 17967 255, 17968 511, 17969 1023, 17970 2047, 17971 4095, 17972 8191, 17973 16383, 17974 32767, 17975 65535, 17976 131071, 17977 262143, 17978 524287, 17979 1048575, 17980 2097151, 17981 4194303, 17982 8388607, 17983 16777215 17984 ]); 17985 function BrotliBitReader(input) { 17986 this.buf_ = new Uint8Array(BROTLI_IBUF_SIZE); 17987 this.input_ = input; 17988 this.reset(); 17989 } 17990 BrotliBitReader.READ_SIZE = BROTLI_READ_SIZE; 17991 BrotliBitReader.IBUF_MASK = BROTLI_IBUF_MASK; 17992 BrotliBitReader.prototype.reset = function() { 17993 this.buf_ptr_ = 0; 17994 this.val_ = 0; 17995 this.pos_ = 0; 17996 this.bit_pos_ = 0; 17997 this.bit_end_pos_ = 0; 17998 this.eos_ = 0; 17999 this.readMoreInput(); 18000 for (var i3 = 0; i3 < 4; i3++) { 18001 this.val_ |= this.buf_[this.pos_] << 8 * i3; 18002 ++this.pos_; 18003 } 18004 return this.bit_end_pos_ > 0; 18005 }; 18006 BrotliBitReader.prototype.readMoreInput = function() { 18007 if (this.bit_end_pos_ > 256) { 18008 return; 18009 } else if (this.eos_) { 18010 if (this.bit_pos_ > this.bit_end_pos_) 18011 throw new Error( 18012 "Unexpected end of input " + this.bit_pos_ + " " + this.bit_end_pos_ 18013 ); 18014 } else { 18015 var dst = this.buf_ptr_; 18016 var bytes_read = this.input_.read( 18017 this.buf_, 18018 dst, 18019 BROTLI_READ_SIZE 18020 ); 18021 if (bytes_read < 0) { 18022 throw new Error("Unexpected end of input"); 18023 } 18024 if (bytes_read < BROTLI_READ_SIZE) { 18025 this.eos_ = 1; 18026 for (var p4 = 0; p4 < 32; p4++) 18027 this.buf_[dst + bytes_read + p4] = 0; 18028 } 18029 if (dst === 0) { 18030 for (var p4 = 0; p4 < 32; p4++) 18031 this.buf_[(BROTLI_READ_SIZE << 1) + p4] = this.buf_[p4]; 18032 this.buf_ptr_ = BROTLI_READ_SIZE; 18033 } else { 18034 this.buf_ptr_ = 0; 18035 } 18036 this.bit_end_pos_ += bytes_read << 3; 18037 } 18038 }; 18039 BrotliBitReader.prototype.fillBitWindow = function() { 18040 while (this.bit_pos_ >= 8) { 18041 this.val_ >>>= 8; 18042 this.val_ |= this.buf_[this.pos_ & BROTLI_IBUF_MASK] << 24; 18043 ++this.pos_; 18044 this.bit_pos_ = this.bit_pos_ - 8 >>> 0; 18045 this.bit_end_pos_ = this.bit_end_pos_ - 8 >>> 0; 18046 } 18047 }; 18048 BrotliBitReader.prototype.readBits = function(n_bits) { 18049 if (32 - this.bit_pos_ < n_bits) { 18050 this.fillBitWindow(); 18051 } 18052 var val = this.val_ >>> this.bit_pos_ & kBitMask[n_bits]; 18053 this.bit_pos_ += n_bits; 18054 return val; 18055 }; 18056 module3.exports = BrotliBitReader; 18057 }, 18058 {} 18059 ], 18060 2: [ 18061 function(require2, module3, exports3) { 18062 var CONTEXT_LSB6 = 0; 18063 var CONTEXT_MSB6 = 1; 18064 var CONTEXT_UTF8 = 2; 18065 var CONTEXT_SIGNED = 3; 18066 exports3.lookup = new Uint8Array([ 18067 /* CONTEXT_UTF8, last byte. */ 18068 /* ASCII range. */ 18069 0, 18070 0, 18071 0, 18072 0, 18073 0, 18074 0, 18075 0, 18076 0, 18077 0, 18078 4, 18079 4, 18080 0, 18081 0, 18082 4, 18083 0, 18084 0, 18085 0, 18086 0, 18087 0, 18088 0, 18089 0, 18090 0, 18091 0, 18092 0, 18093 0, 18094 0, 18095 0, 18096 0, 18097 0, 18098 0, 18099 0, 18100 0, 18101 8, 18102 12, 18103 16, 18104 12, 18105 12, 18106 20, 18107 12, 18108 16, 18109 24, 18110 28, 18111 12, 18112 12, 18113 32, 18114 12, 18115 36, 18116 12, 18117 44, 18118 44, 18119 44, 18120 44, 18121 44, 18122 44, 18123 44, 18124 44, 18125 44, 18126 44, 18127 32, 18128 32, 18129 24, 18130 40, 18131 28, 18132 12, 18133 12, 18134 48, 18135 52, 18136 52, 18137 52, 18138 48, 18139 52, 18140 52, 18141 52, 18142 48, 18143 52, 18144 52, 18145 52, 18146 52, 18147 52, 18148 48, 18149 52, 18150 52, 18151 52, 18152 52, 18153 52, 18154 48, 18155 52, 18156 52, 18157 52, 18158 52, 18159 52, 18160 24, 18161 12, 18162 28, 18163 12, 18164 12, 18165 12, 18166 56, 18167 60, 18168 60, 18169 60, 18170 56, 18171 60, 18172 60, 18173 60, 18174 56, 18175 60, 18176 60, 18177 60, 18178 60, 18179 60, 18180 56, 18181 60, 18182 60, 18183 60, 18184 60, 18185 60, 18186 56, 18187 60, 18188 60, 18189 60, 18190 60, 18191 60, 18192 24, 18193 12, 18194 28, 18195 12, 18196 0, 18197 /* UTF8 continuation byte range. */ 18198 0, 18199 1, 18200 0, 18201 1, 18202 0, 18203 1, 18204 0, 18205 1, 18206 0, 18207 1, 18208 0, 18209 1, 18210 0, 18211 1, 18212 0, 18213 1, 18214 0, 18215 1, 18216 0, 18217 1, 18218 0, 18219 1, 18220 0, 18221 1, 18222 0, 18223 1, 18224 0, 18225 1, 18226 0, 18227 1, 18228 0, 18229 1, 18230 0, 18231 1, 18232 0, 18233 1, 18234 0, 18235 1, 18236 0, 18237 1, 18238 0, 18239 1, 18240 0, 18241 1, 18242 0, 18243 1, 18244 0, 18245 1, 18246 0, 18247 1, 18248 0, 18249 1, 18250 0, 18251 1, 18252 0, 18253 1, 18254 0, 18255 1, 18256 0, 18257 1, 18258 0, 18259 1, 18260 0, 18261 1, 18262 2, 18263 3, 18264 2, 18265 3, 18266 2, 18267 3, 18268 2, 18269 3, 18270 2, 18271 3, 18272 2, 18273 3, 18274 2, 18275 3, 18276 2, 18277 3, 18278 2, 18279 3, 18280 2, 18281 3, 18282 2, 18283 3, 18284 2, 18285 3, 18286 2, 18287 3, 18288 2, 18289 3, 18290 2, 18291 3, 18292 2, 18293 3, 18294 2, 18295 3, 18296 2, 18297 3, 18298 2, 18299 3, 18300 2, 18301 3, 18302 2, 18303 3, 18304 2, 18305 3, 18306 2, 18307 3, 18308 2, 18309 3, 18310 2, 18311 3, 18312 2, 18313 3, 18314 2, 18315 3, 18316 2, 18317 3, 18318 2, 18319 3, 18320 2, 18321 3, 18322 2, 18323 3, 18324 2, 18325 3, 18326 /* ASCII range. */ 18327 0, 18328 0, 18329 0, 18330 0, 18331 0, 18332 0, 18333 0, 18334 0, 18335 0, 18336 0, 18337 0, 18338 0, 18339 0, 18340 0, 18341 0, 18342 0, 18343 0, 18344 0, 18345 0, 18346 0, 18347 0, 18348 0, 18349 0, 18350 0, 18351 0, 18352 0, 18353 0, 18354 0, 18355 0, 18356 0, 18357 0, 18358 0, 18359 0, 18360 1, 18361 1, 18362 1, 18363 1, 18364 1, 18365 1, 18366 1, 18367 1, 18368 1, 18369 1, 18370 1, 18371 1, 18372 1, 18373 1, 18374 1, 18375 2, 18376 2, 18377 2, 18378 2, 18379 2, 18380 2, 18381 2, 18382 2, 18383 2, 18384 2, 18385 1, 18386 1, 18387 1, 18388 1, 18389 1, 18390 1, 18391 1, 18392 2, 18393 2, 18394 2, 18395 2, 18396 2, 18397 2, 18398 2, 18399 2, 18400 2, 18401 2, 18402 2, 18403 2, 18404 2, 18405 2, 18406 2, 18407 2, 18408 2, 18409 2, 18410 2, 18411 2, 18412 2, 18413 2, 18414 2, 18415 2, 18416 2, 18417 2, 18418 1, 18419 1, 18420 1, 18421 1, 18422 1, 18423 1, 18424 3, 18425 3, 18426 3, 18427 3, 18428 3, 18429 3, 18430 3, 18431 3, 18432 3, 18433 3, 18434 3, 18435 3, 18436 3, 18437 3, 18438 3, 18439 3, 18440 3, 18441 3, 18442 3, 18443 3, 18444 3, 18445 3, 18446 3, 18447 3, 18448 3, 18449 3, 18450 1, 18451 1, 18452 1, 18453 1, 18454 0, 18455 /* UTF8 continuation byte range. */ 18456 0, 18457 0, 18458 0, 18459 0, 18460 0, 18461 0, 18462 0, 18463 0, 18464 0, 18465 0, 18466 0, 18467 0, 18468 0, 18469 0, 18470 0, 18471 0, 18472 0, 18473 0, 18474 0, 18475 0, 18476 0, 18477 0, 18478 0, 18479 0, 18480 0, 18481 0, 18482 0, 18483 0, 18484 0, 18485 0, 18486 0, 18487 0, 18488 0, 18489 0, 18490 0, 18491 0, 18492 0, 18493 0, 18494 0, 18495 0, 18496 0, 18497 0, 18498 0, 18499 0, 18500 0, 18501 0, 18502 0, 18503 0, 18504 0, 18505 0, 18506 0, 18507 0, 18508 0, 18509 0, 18510 0, 18511 0, 18512 0, 18513 0, 18514 0, 18515 0, 18516 0, 18517 0, 18518 0, 18519 0, 18520 0, 18521 0, 18522 0, 18523 0, 18524 0, 18525 0, 18526 0, 18527 0, 18528 0, 18529 0, 18530 0, 18531 0, 18532 0, 18533 0, 18534 0, 18535 0, 18536 0, 18537 0, 18538 0, 18539 0, 18540 0, 18541 0, 18542 0, 18543 0, 18544 0, 18545 0, 18546 0, 18547 0, 18548 0, 18549 0, 18550 0, 18551 0, 18552 2, 18553 2, 18554 2, 18555 2, 18556 2, 18557 2, 18558 2, 18559 2, 18560 2, 18561 2, 18562 2, 18563 2, 18564 2, 18565 2, 18566 2, 18567 2, 18568 2, 18569 2, 18570 2, 18571 2, 18572 2, 18573 2, 18574 2, 18575 2, 18576 2, 18577 2, 18578 2, 18579 2, 18580 2, 18581 2, 18582 2, 18583 2, 18584 0, 18585 1, 18586 1, 18587 1, 18588 1, 18589 1, 18590 1, 18591 1, 18592 1, 18593 1, 18594 1, 18595 1, 18596 1, 18597 1, 18598 1, 18599 1, 18600 2, 18601 2, 18602 2, 18603 2, 18604 2, 18605 2, 18606 2, 18607 2, 18608 2, 18609 2, 18610 2, 18611 2, 18612 2, 18613 2, 18614 2, 18615 2, 18616 2, 18617 2, 18618 2, 18619 2, 18620 2, 18621 2, 18622 2, 18623 2, 18624 2, 18625 2, 18626 2, 18627 2, 18628 2, 18629 2, 18630 2, 18631 2, 18632 2, 18633 2, 18634 2, 18635 2, 18636 2, 18637 2, 18638 2, 18639 2, 18640 2, 18641 2, 18642 2, 18643 2, 18644 2, 18645 2, 18646 2, 18647 2, 18648 3, 18649 3, 18650 3, 18651 3, 18652 3, 18653 3, 18654 3, 18655 3, 18656 3, 18657 3, 18658 3, 18659 3, 18660 3, 18661 3, 18662 3, 18663 3, 18664 3, 18665 3, 18666 3, 18667 3, 18668 3, 18669 3, 18670 3, 18671 3, 18672 3, 18673 3, 18674 3, 18675 3, 18676 3, 18677 3, 18678 3, 18679 3, 18680 3, 18681 3, 18682 3, 18683 3, 18684 3, 18685 3, 18686 3, 18687 3, 18688 3, 18689 3, 18690 3, 18691 3, 18692 3, 18693 3, 18694 3, 18695 3, 18696 3, 18697 3, 18698 3, 18699 3, 18700 3, 18701 3, 18702 3, 18703 3, 18704 3, 18705 3, 18706 3, 18707 3, 18708 3, 18709 3, 18710 3, 18711 3, 18712 4, 18713 4, 18714 4, 18715 4, 18716 4, 18717 4, 18718 4, 18719 4, 18720 4, 18721 4, 18722 4, 18723 4, 18724 4, 18725 4, 18726 4, 18727 4, 18728 4, 18729 4, 18730 4, 18731 4, 18732 4, 18733 4, 18734 4, 18735 4, 18736 4, 18737 4, 18738 4, 18739 4, 18740 4, 18741 4, 18742 4, 18743 4, 18744 4, 18745 4, 18746 4, 18747 4, 18748 4, 18749 4, 18750 4, 18751 4, 18752 4, 18753 4, 18754 4, 18755 4, 18756 4, 18757 4, 18758 4, 18759 4, 18760 4, 18761 4, 18762 4, 18763 4, 18764 4, 18765 4, 18766 4, 18767 4, 18768 4, 18769 4, 18770 4, 18771 4, 18772 4, 18773 4, 18774 4, 18775 4, 18776 5, 18777 5, 18778 5, 18779 5, 18780 5, 18781 5, 18782 5, 18783 5, 18784 5, 18785 5, 18786 5, 18787 5, 18788 5, 18789 5, 18790 5, 18791 5, 18792 5, 18793 5, 18794 5, 18795 5, 18796 5, 18797 5, 18798 5, 18799 5, 18800 5, 18801 5, 18802 5, 18803 5, 18804 5, 18805 5, 18806 5, 18807 5, 18808 5, 18809 5, 18810 5, 18811 5, 18812 5, 18813 5, 18814 5, 18815 5, 18816 5, 18817 5, 18818 5, 18819 5, 18820 5, 18821 5, 18822 5, 18823 5, 18824 6, 18825 6, 18826 6, 18827 6, 18828 6, 18829 6, 18830 6, 18831 6, 18832 6, 18833 6, 18834 6, 18835 6, 18836 6, 18837 6, 18838 6, 18839 7, 18840 /* CONTEXT_SIGNED, last byte, same as the above values shifted by 3 bits. */ 18841 0, 18842 8, 18843 8, 18844 8, 18845 8, 18846 8, 18847 8, 18848 8, 18849 8, 18850 8, 18851 8, 18852 8, 18853 8, 18854 8, 18855 8, 18856 8, 18857 16, 18858 16, 18859 16, 18860 16, 18861 16, 18862 16, 18863 16, 18864 16, 18865 16, 18866 16, 18867 16, 18868 16, 18869 16, 18870 16, 18871 16, 18872 16, 18873 16, 18874 16, 18875 16, 18876 16, 18877 16, 18878 16, 18879 16, 18880 16, 18881 16, 18882 16, 18883 16, 18884 16, 18885 16, 18886 16, 18887 16, 18888 16, 18889 16, 18890 16, 18891 16, 18892 16, 18893 16, 18894 16, 18895 16, 18896 16, 18897 16, 18898 16, 18899 16, 18900 16, 18901 16, 18902 16, 18903 16, 18904 16, 18905 24, 18906 24, 18907 24, 18908 24, 18909 24, 18910 24, 18911 24, 18912 24, 18913 24, 18914 24, 18915 24, 18916 24, 18917 24, 18918 24, 18919 24, 18920 24, 18921 24, 18922 24, 18923 24, 18924 24, 18925 24, 18926 24, 18927 24, 18928 24, 18929 24, 18930 24, 18931 24, 18932 24, 18933 24, 18934 24, 18935 24, 18936 24, 18937 24, 18938 24, 18939 24, 18940 24, 18941 24, 18942 24, 18943 24, 18944 24, 18945 24, 18946 24, 18947 24, 18948 24, 18949 24, 18950 24, 18951 24, 18952 24, 18953 24, 18954 24, 18955 24, 18956 24, 18957 24, 18958 24, 18959 24, 18960 24, 18961 24, 18962 24, 18963 24, 18964 24, 18965 24, 18966 24, 18967 24, 18968 24, 18969 32, 18970 32, 18971 32, 18972 32, 18973 32, 18974 32, 18975 32, 18976 32, 18977 32, 18978 32, 18979 32, 18980 32, 18981 32, 18982 32, 18983 32, 18984 32, 18985 32, 18986 32, 18987 32, 18988 32, 18989 32, 18990 32, 18991 32, 18992 32, 18993 32, 18994 32, 18995 32, 18996 32, 18997 32, 18998 32, 18999 32, 19000 32, 19001 32, 19002 32, 19003 32, 19004 32, 19005 32, 19006 32, 19007 32, 19008 32, 19009 32, 19010 32, 19011 32, 19012 32, 19013 32, 19014 32, 19015 32, 19016 32, 19017 32, 19018 32, 19019 32, 19020 32, 19021 32, 19022 32, 19023 32, 19024 32, 19025 32, 19026 32, 19027 32, 19028 32, 19029 32, 19030 32, 19031 32, 19032 32, 19033 40, 19034 40, 19035 40, 19036 40, 19037 40, 19038 40, 19039 40, 19040 40, 19041 40, 19042 40, 19043 40, 19044 40, 19045 40, 19046 40, 19047 40, 19048 40, 19049 40, 19050 40, 19051 40, 19052 40, 19053 40, 19054 40, 19055 40, 19056 40, 19057 40, 19058 40, 19059 40, 19060 40, 19061 40, 19062 40, 19063 40, 19064 40, 19065 40, 19066 40, 19067 40, 19068 40, 19069 40, 19070 40, 19071 40, 19072 40, 19073 40, 19074 40, 19075 40, 19076 40, 19077 40, 19078 40, 19079 40, 19080 40, 19081 48, 19082 48, 19083 48, 19084 48, 19085 48, 19086 48, 19087 48, 19088 48, 19089 48, 19090 48, 19091 48, 19092 48, 19093 48, 19094 48, 19095 48, 19096 56, 19097 /* CONTEXT_LSB6, last byte. */ 19098 0, 19099 1, 19100 2, 19101 3, 19102 4, 19103 5, 19104 6, 19105 7, 19106 8, 19107 9, 19108 10, 19109 11, 19110 12, 19111 13, 19112 14, 19113 15, 19114 16, 19115 17, 19116 18, 19117 19, 19118 20, 19119 21, 19120 22, 19121 23, 19122 24, 19123 25, 19124 26, 19125 27, 19126 28, 19127 29, 19128 30, 19129 31, 19130 32, 19131 33, 19132 34, 19133 35, 19134 36, 19135 37, 19136 38, 19137 39, 19138 40, 19139 41, 19140 42, 19141 43, 19142 44, 19143 45, 19144 46, 19145 47, 19146 48, 19147 49, 19148 50, 19149 51, 19150 52, 19151 53, 19152 54, 19153 55, 19154 56, 19155 57, 19156 58, 19157 59, 19158 60, 19159 61, 19160 62, 19161 63, 19162 0, 19163 1, 19164 2, 19165 3, 19166 4, 19167 5, 19168 6, 19169 7, 19170 8, 19171 9, 19172 10, 19173 11, 19174 12, 19175 13, 19176 14, 19177 15, 19178 16, 19179 17, 19180 18, 19181 19, 19182 20, 19183 21, 19184 22, 19185 23, 19186 24, 19187 25, 19188 26, 19189 27, 19190 28, 19191 29, 19192 30, 19193 31, 19194 32, 19195 33, 19196 34, 19197 35, 19198 36, 19199 37, 19200 38, 19201 39, 19202 40, 19203 41, 19204 42, 19205 43, 19206 44, 19207 45, 19208 46, 19209 47, 19210 48, 19211 49, 19212 50, 19213 51, 19214 52, 19215 53, 19216 54, 19217 55, 19218 56, 19219 57, 19220 58, 19221 59, 19222 60, 19223 61, 19224 62, 19225 63, 19226 0, 19227 1, 19228 2, 19229 3, 19230 4, 19231 5, 19232 6, 19233 7, 19234 8, 19235 9, 19236 10, 19237 11, 19238 12, 19239 13, 19240 14, 19241 15, 19242 16, 19243 17, 19244 18, 19245 19, 19246 20, 19247 21, 19248 22, 19249 23, 19250 24, 19251 25, 19252 26, 19253 27, 19254 28, 19255 29, 19256 30, 19257 31, 19258 32, 19259 33, 19260 34, 19261 35, 19262 36, 19263 37, 19264 38, 19265 39, 19266 40, 19267 41, 19268 42, 19269 43, 19270 44, 19271 45, 19272 46, 19273 47, 19274 48, 19275 49, 19276 50, 19277 51, 19278 52, 19279 53, 19280 54, 19281 55, 19282 56, 19283 57, 19284 58, 19285 59, 19286 60, 19287 61, 19288 62, 19289 63, 19290 0, 19291 1, 19292 2, 19293 3, 19294 4, 19295 5, 19296 6, 19297 7, 19298 8, 19299 9, 19300 10, 19301 11, 19302 12, 19303 13, 19304 14, 19305 15, 19306 16, 19307 17, 19308 18, 19309 19, 19310 20, 19311 21, 19312 22, 19313 23, 19314 24, 19315 25, 19316 26, 19317 27, 19318 28, 19319 29, 19320 30, 19321 31, 19322 32, 19323 33, 19324 34, 19325 35, 19326 36, 19327 37, 19328 38, 19329 39, 19330 40, 19331 41, 19332 42, 19333 43, 19334 44, 19335 45, 19336 46, 19337 47, 19338 48, 19339 49, 19340 50, 19341 51, 19342 52, 19343 53, 19344 54, 19345 55, 19346 56, 19347 57, 19348 58, 19349 59, 19350 60, 19351 61, 19352 62, 19353 63, 19354 /* CONTEXT_MSB6, last byte. */ 19355 0, 19356 0, 19357 0, 19358 0, 19359 1, 19360 1, 19361 1, 19362 1, 19363 2, 19364 2, 19365 2, 19366 2, 19367 3, 19368 3, 19369 3, 19370 3, 19371 4, 19372 4, 19373 4, 19374 4, 19375 5, 19376 5, 19377 5, 19378 5, 19379 6, 19380 6, 19381 6, 19382 6, 19383 7, 19384 7, 19385 7, 19386 7, 19387 8, 19388 8, 19389 8, 19390 8, 19391 9, 19392 9, 19393 9, 19394 9, 19395 10, 19396 10, 19397 10, 19398 10, 19399 11, 19400 11, 19401 11, 19402 11, 19403 12, 19404 12, 19405 12, 19406 12, 19407 13, 19408 13, 19409 13, 19410 13, 19411 14, 19412 14, 19413 14, 19414 14, 19415 15, 19416 15, 19417 15, 19418 15, 19419 16, 19420 16, 19421 16, 19422 16, 19423 17, 19424 17, 19425 17, 19426 17, 19427 18, 19428 18, 19429 18, 19430 18, 19431 19, 19432 19, 19433 19, 19434 19, 19435 20, 19436 20, 19437 20, 19438 20, 19439 21, 19440 21, 19441 21, 19442 21, 19443 22, 19444 22, 19445 22, 19446 22, 19447 23, 19448 23, 19449 23, 19450 23, 19451 24, 19452 24, 19453 24, 19454 24, 19455 25, 19456 25, 19457 25, 19458 25, 19459 26, 19460 26, 19461 26, 19462 26, 19463 27, 19464 27, 19465 27, 19466 27, 19467 28, 19468 28, 19469 28, 19470 28, 19471 29, 19472 29, 19473 29, 19474 29, 19475 30, 19476 30, 19477 30, 19478 30, 19479 31, 19480 31, 19481 31, 19482 31, 19483 32, 19484 32, 19485 32, 19486 32, 19487 33, 19488 33, 19489 33, 19490 33, 19491 34, 19492 34, 19493 34, 19494 34, 19495 35, 19496 35, 19497 35, 19498 35, 19499 36, 19500 36, 19501 36, 19502 36, 19503 37, 19504 37, 19505 37, 19506 37, 19507 38, 19508 38, 19509 38, 19510 38, 19511 39, 19512 39, 19513 39, 19514 39, 19515 40, 19516 40, 19517 40, 19518 40, 19519 41, 19520 41, 19521 41, 19522 41, 19523 42, 19524 42, 19525 42, 19526 42, 19527 43, 19528 43, 19529 43, 19530 43, 19531 44, 19532 44, 19533 44, 19534 44, 19535 45, 19536 45, 19537 45, 19538 45, 19539 46, 19540 46, 19541 46, 19542 46, 19543 47, 19544 47, 19545 47, 19546 47, 19547 48, 19548 48, 19549 48, 19550 48, 19551 49, 19552 49, 19553 49, 19554 49, 19555 50, 19556 50, 19557 50, 19558 50, 19559 51, 19560 51, 19561 51, 19562 51, 19563 52, 19564 52, 19565 52, 19566 52, 19567 53, 19568 53, 19569 53, 19570 53, 19571 54, 19572 54, 19573 54, 19574 54, 19575 55, 19576 55, 19577 55, 19578 55, 19579 56, 19580 56, 19581 56, 19582 56, 19583 57, 19584 57, 19585 57, 19586 57, 19587 58, 19588 58, 19589 58, 19590 58, 19591 59, 19592 59, 19593 59, 19594 59, 19595 60, 19596 60, 19597 60, 19598 60, 19599 61, 19600 61, 19601 61, 19602 61, 19603 62, 19604 62, 19605 62, 19606 62, 19607 63, 19608 63, 19609 63, 19610 63, 19611 /* CONTEXT_{M,L}SB6, second last byte, */ 19612 0, 19613 0, 19614 0, 19615 0, 19616 0, 19617 0, 19618 0, 19619 0, 19620 0, 19621 0, 19622 0, 19623 0, 19624 0, 19625 0, 19626 0, 19627 0, 19628 0, 19629 0, 19630 0, 19631 0, 19632 0, 19633 0, 19634 0, 19635 0, 19636 0, 19637 0, 19638 0, 19639 0, 19640 0, 19641 0, 19642 0, 19643 0, 19644 0, 19645 0, 19646 0, 19647 0, 19648 0, 19649 0, 19650 0, 19651 0, 19652 0, 19653 0, 19654 0, 19655 0, 19656 0, 19657 0, 19658 0, 19659 0, 19660 0, 19661 0, 19662 0, 19663 0, 19664 0, 19665 0, 19666 0, 19667 0, 19668 0, 19669 0, 19670 0, 19671 0, 19672 0, 19673 0, 19674 0, 19675 0, 19676 0, 19677 0, 19678 0, 19679 0, 19680 0, 19681 0, 19682 0, 19683 0, 19684 0, 19685 0, 19686 0, 19687 0, 19688 0, 19689 0, 19690 0, 19691 0, 19692 0, 19693 0, 19694 0, 19695 0, 19696 0, 19697 0, 19698 0, 19699 0, 19700 0, 19701 0, 19702 0, 19703 0, 19704 0, 19705 0, 19706 0, 19707 0, 19708 0, 19709 0, 19710 0, 19711 0, 19712 0, 19713 0, 19714 0, 19715 0, 19716 0, 19717 0, 19718 0, 19719 0, 19720 0, 19721 0, 19722 0, 19723 0, 19724 0, 19725 0, 19726 0, 19727 0, 19728 0, 19729 0, 19730 0, 19731 0, 19732 0, 19733 0, 19734 0, 19735 0, 19736 0, 19737 0, 19738 0, 19739 0, 19740 0, 19741 0, 19742 0, 19743 0, 19744 0, 19745 0, 19746 0, 19747 0, 19748 0, 19749 0, 19750 0, 19751 0, 19752 0, 19753 0, 19754 0, 19755 0, 19756 0, 19757 0, 19758 0, 19759 0, 19760 0, 19761 0, 19762 0, 19763 0, 19764 0, 19765 0, 19766 0, 19767 0, 19768 0, 19769 0, 19770 0, 19771 0, 19772 0, 19773 0, 19774 0, 19775 0, 19776 0, 19777 0, 19778 0, 19779 0, 19780 0, 19781 0, 19782 0, 19783 0, 19784 0, 19785 0, 19786 0, 19787 0, 19788 0, 19789 0, 19790 0, 19791 0, 19792 0, 19793 0, 19794 0, 19795 0, 19796 0, 19797 0, 19798 0, 19799 0, 19800 0, 19801 0, 19802 0, 19803 0, 19804 0, 19805 0, 19806 0, 19807 0, 19808 0, 19809 0, 19810 0, 19811 0, 19812 0, 19813 0, 19814 0, 19815 0, 19816 0, 19817 0, 19818 0, 19819 0, 19820 0, 19821 0, 19822 0, 19823 0, 19824 0, 19825 0, 19826 0, 19827 0, 19828 0, 19829 0, 19830 0, 19831 0, 19832 0, 19833 0, 19834 0, 19835 0, 19836 0, 19837 0, 19838 0, 19839 0, 19840 0, 19841 0, 19842 0, 19843 0, 19844 0, 19845 0, 19846 0, 19847 0, 19848 0, 19849 0, 19850 0, 19851 0, 19852 0, 19853 0, 19854 0, 19855 0, 19856 0, 19857 0, 19858 0, 19859 0, 19860 0, 19861 0, 19862 0, 19863 0, 19864 0, 19865 0, 19866 0, 19867 0 19868 ]); 19869 exports3.lookupOffsets = new Uint16Array([ 19870 /* CONTEXT_LSB6 */ 19871 1024, 19872 1536, 19873 1280, 19874 1536, 19875 0, 19876 256, 19877 768, 19878 512 19879 ]); 19880 }, 19881 {} 19882 ], 19883 3: [ 19884 function(require2, module3, exports3) { 19885 var BrotliInput = require2("./streams").BrotliInput; 19886 var BrotliOutput = require2("./streams").BrotliOutput; 19887 var BrotliBitReader = require2("./bit_reader"); 19888 var BrotliDictionary = require2("./dictionary"); 19889 var HuffmanCode = require2("./huffman").HuffmanCode; 19890 var BrotliBuildHuffmanTable = require2("./huffman").BrotliBuildHuffmanTable; 19891 var Context = require2("./context"); 19892 var Prefix = require2("./prefix"); 19893 var Transform = require2("./transform"); 19894 var kDefaultCodeLength = 8; 19895 var kCodeLengthRepeatCode = 16; 19896 var kNumLiteralCodes = 256; 19897 var kNumInsertAndCopyCodes = 704; 19898 var kNumBlockLengthCodes = 26; 19899 var kLiteralContextBits = 6; 19900 var kDistanceContextBits = 2; 19901 var HUFFMAN_TABLE_BITS = 8; 19902 var HUFFMAN_TABLE_MASK = 255; 19903 var HUFFMAN_MAX_TABLE_SIZE = 1080; 19904 var CODE_LENGTH_CODES = 18; 19905 var kCodeLengthCodeOrder = new Uint8Array([ 19906 1, 19907 2, 19908 3, 19909 4, 19910 0, 19911 5, 19912 17, 19913 6, 19914 16, 19915 7, 19916 8, 19917 9, 19918 10, 19919 11, 19920 12, 19921 13, 19922 14, 19923 15 19924 ]); 19925 var NUM_DISTANCE_SHORT_CODES = 16; 19926 var kDistanceShortCodeIndexOffset = new Uint8Array([ 19927 3, 19928 2, 19929 1, 19930 0, 19931 3, 19932 3, 19933 3, 19934 3, 19935 3, 19936 3, 19937 2, 19938 2, 19939 2, 19940 2, 19941 2, 19942 2 19943 ]); 19944 var kDistanceShortCodeValueOffset = new Int8Array([ 19945 0, 19946 0, 19947 0, 19948 0, 19949 -1, 19950 1, 19951 -2, 19952 2, 19953 -3, 19954 3, 19955 -1, 19956 1, 19957 -2, 19958 2, 19959 -3, 19960 3 19961 ]); 19962 var kMaxHuffmanTableSize = new Uint16Array([ 19963 256, 19964 402, 19965 436, 19966 468, 19967 500, 19968 534, 19969 566, 19970 598, 19971 630, 19972 662, 19973 694, 19974 726, 19975 758, 19976 790, 19977 822, 19978 854, 19979 886, 19980 920, 19981 952, 19982 984, 19983 1016, 19984 1048, 19985 1080 19986 ]); 19987 function DecodeWindowBits(br) { 19988 var n3; 19989 if (br.readBits(1) === 0) { 19990 return 16; 19991 } 19992 n3 = br.readBits(3); 19993 if (n3 > 0) { 19994 return 17 + n3; 19995 } 19996 n3 = br.readBits(3); 19997 if (n3 > 0) { 19998 return 8 + n3; 19999 } 20000 return 17; 20001 } 20002 function DecodeVarLenUint8(br) { 20003 if (br.readBits(1)) { 20004 var nbits = br.readBits(3); 20005 if (nbits === 0) { 20006 return 1; 20007 } else { 20008 return br.readBits(nbits) + (1 << nbits); 20009 } 20010 } 20011 return 0; 20012 } 20013 function MetaBlockLength() { 20014 this.meta_block_length = 0; 20015 this.input_end = 0; 20016 this.is_uncompressed = 0; 20017 this.is_metadata = false; 20018 } 20019 function DecodeMetaBlockLength(br) { 20020 var out = new MetaBlockLength(); 20021 var size_nibbles; 20022 var size_bytes; 20023 var i3; 20024 out.input_end = br.readBits(1); 20025 if (out.input_end && br.readBits(1)) { 20026 return out; 20027 } 20028 size_nibbles = br.readBits(2) + 4; 20029 if (size_nibbles === 7) { 20030 out.is_metadata = true; 20031 if (br.readBits(1) !== 0) 20032 throw new Error("Invalid reserved bit"); 20033 size_bytes = br.readBits(2); 20034 if (size_bytes === 0) return out; 20035 for (i3 = 0; i3 < size_bytes; i3++) { 20036 var next_byte = br.readBits(8); 20037 if (i3 + 1 === size_bytes && size_bytes > 1 && next_byte === 0) 20038 throw new Error("Invalid size byte"); 20039 out.meta_block_length |= next_byte << i3 * 8; 20040 } 20041 } else { 20042 for (i3 = 0; i3 < size_nibbles; ++i3) { 20043 var next_nibble = br.readBits(4); 20044 if (i3 + 1 === size_nibbles && size_nibbles > 4 && next_nibble === 0) 20045 throw new Error("Invalid size nibble"); 20046 out.meta_block_length |= next_nibble << i3 * 4; 20047 } 20048 } 20049 ++out.meta_block_length; 20050 if (!out.input_end && !out.is_metadata) { 20051 out.is_uncompressed = br.readBits(1); 20052 } 20053 return out; 20054 } 20055 function ReadSymbol(table, index2, br) { 20056 var start_index = index2; 20057 var nbits; 20058 br.fillBitWindow(); 20059 index2 += br.val_ >>> br.bit_pos_ & HUFFMAN_TABLE_MASK; 20060 nbits = table[index2].bits - HUFFMAN_TABLE_BITS; 20061 if (nbits > 0) { 20062 br.bit_pos_ += HUFFMAN_TABLE_BITS; 20063 index2 += table[index2].value; 20064 index2 += br.val_ >>> br.bit_pos_ & (1 << nbits) - 1; 20065 } 20066 br.bit_pos_ += table[index2].bits; 20067 return table[index2].value; 20068 } 20069 function ReadHuffmanCodeLengths(code_length_code_lengths, num_symbols, code_lengths, br) { 20070 var symbol = 0; 20071 var prev_code_len = kDefaultCodeLength; 20072 var repeat = 0; 20073 var repeat_code_len = 0; 20074 var space = 32768; 20075 var table = []; 20076 for (var i3 = 0; i3 < 32; i3++) 20077 table.push(new HuffmanCode(0, 0)); 20078 BrotliBuildHuffmanTable( 20079 table, 20080 0, 20081 5, 20082 code_length_code_lengths, 20083 CODE_LENGTH_CODES 20084 ); 20085 while (symbol < num_symbols && space > 0) { 20086 var p4 = 0; 20087 var code_len; 20088 br.readMoreInput(); 20089 br.fillBitWindow(); 20090 p4 += br.val_ >>> br.bit_pos_ & 31; 20091 br.bit_pos_ += table[p4].bits; 20092 code_len = table[p4].value & 255; 20093 if (code_len < kCodeLengthRepeatCode) { 20094 repeat = 0; 20095 code_lengths[symbol++] = code_len; 20096 if (code_len !== 0) { 20097 prev_code_len = code_len; 20098 space -= 32768 >> code_len; 20099 } 20100 } else { 20101 var extra_bits = code_len - 14; 20102 var old_repeat; 20103 var repeat_delta; 20104 var new_len = 0; 20105 if (code_len === kCodeLengthRepeatCode) { 20106 new_len = prev_code_len; 20107 } 20108 if (repeat_code_len !== new_len) { 20109 repeat = 0; 20110 repeat_code_len = new_len; 20111 } 20112 old_repeat = repeat; 20113 if (repeat > 0) { 20114 repeat -= 2; 20115 repeat <<= extra_bits; 20116 } 20117 repeat += br.readBits(extra_bits) + 3; 20118 repeat_delta = repeat - old_repeat; 20119 if (symbol + repeat_delta > num_symbols) { 20120 throw new Error( 20121 "[ReadHuffmanCodeLengths] symbol + repeat_delta > num_symbols" 20122 ); 20123 } 20124 for (var x2 = 0; x2 < repeat_delta; x2++) 20125 code_lengths[symbol + x2] = repeat_code_len; 20126 symbol += repeat_delta; 20127 if (repeat_code_len !== 0) { 20128 space -= repeat_delta << 15 - repeat_code_len; 20129 } 20130 } 20131 } 20132 if (space !== 0) { 20133 throw new Error( 20134 "[ReadHuffmanCodeLengths] space = " + space 20135 ); 20136 } 20137 for (; symbol < num_symbols; symbol++) 20138 code_lengths[symbol] = 0; 20139 } 20140 function ReadHuffmanCode(alphabet_size, tables, table, br) { 20141 var table_size = 0; 20142 var simple_code_or_skip; 20143 var code_lengths = new Uint8Array(alphabet_size); 20144 br.readMoreInput(); 20145 simple_code_or_skip = br.readBits(2); 20146 if (simple_code_or_skip === 1) { 20147 var i3; 20148 var max_bits_counter = alphabet_size - 1; 20149 var max_bits = 0; 20150 var symbols = new Int32Array(4); 20151 var num_symbols = br.readBits(2) + 1; 20152 while (max_bits_counter) { 20153 max_bits_counter >>= 1; 20154 ++max_bits; 20155 } 20156 for (i3 = 0; i3 < num_symbols; ++i3) { 20157 symbols[i3] = br.readBits(max_bits) % alphabet_size; 20158 code_lengths[symbols[i3]] = 2; 20159 } 20160 code_lengths[symbols[0]] = 1; 20161 switch (num_symbols) { 20162 case 1: 20163 break; 20164 case 3: 20165 if (symbols[0] === symbols[1] || symbols[0] === symbols[2] || symbols[1] === symbols[2]) { 20166 throw new Error( 20167 "[ReadHuffmanCode] invalid symbols" 20168 ); 20169 } 20170 break; 20171 case 2: 20172 if (symbols[0] === symbols[1]) { 20173 throw new Error( 20174 "[ReadHuffmanCode] invalid symbols" 20175 ); 20176 } 20177 code_lengths[symbols[1]] = 1; 20178 break; 20179 case 4: 20180 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]) { 20181 throw new Error( 20182 "[ReadHuffmanCode] invalid symbols" 20183 ); 20184 } 20185 if (br.readBits(1)) { 20186 code_lengths[symbols[2]] = 3; 20187 code_lengths[symbols[3]] = 3; 20188 } else { 20189 code_lengths[symbols[0]] = 2; 20190 } 20191 break; 20192 } 20193 } else { 20194 var i3; 20195 var code_length_code_lengths = new Uint8Array( 20196 CODE_LENGTH_CODES 20197 ); 20198 var space = 32; 20199 var num_codes = 0; 20200 var huff = [ 20201 new HuffmanCode(2, 0), 20202 new HuffmanCode(2, 4), 20203 new HuffmanCode(2, 3), 20204 new HuffmanCode(3, 2), 20205 new HuffmanCode(2, 0), 20206 new HuffmanCode(2, 4), 20207 new HuffmanCode(2, 3), 20208 new HuffmanCode(4, 1), 20209 new HuffmanCode(2, 0), 20210 new HuffmanCode(2, 4), 20211 new HuffmanCode(2, 3), 20212 new HuffmanCode(3, 2), 20213 new HuffmanCode(2, 0), 20214 new HuffmanCode(2, 4), 20215 new HuffmanCode(2, 3), 20216 new HuffmanCode(4, 5) 20217 ]; 20218 for (i3 = simple_code_or_skip; i3 < CODE_LENGTH_CODES && space > 0; ++i3) { 20219 var code_len_idx = kCodeLengthCodeOrder[i3]; 20220 var p4 = 0; 20221 var v3; 20222 br.fillBitWindow(); 20223 p4 += br.val_ >>> br.bit_pos_ & 15; 20224 br.bit_pos_ += huff[p4].bits; 20225 v3 = huff[p4].value; 20226 code_length_code_lengths[code_len_idx] = v3; 20227 if (v3 !== 0) { 20228 space -= 32 >> v3; 20229 ++num_codes; 20230 } 20231 } 20232 if (!(num_codes === 1 || space === 0)) 20233 throw new Error( 20234 "[ReadHuffmanCode] invalid num_codes or space" 20235 ); 20236 ReadHuffmanCodeLengths( 20237 code_length_code_lengths, 20238 alphabet_size, 20239 code_lengths, 20240 br 20241 ); 20242 } 20243 table_size = BrotliBuildHuffmanTable( 20244 tables, 20245 table, 20246 HUFFMAN_TABLE_BITS, 20247 code_lengths, 20248 alphabet_size 20249 ); 20250 if (table_size === 0) { 20251 throw new Error( 20252 "[ReadHuffmanCode] BuildHuffmanTable failed: " 20253 ); 20254 } 20255 return table_size; 20256 } 20257 function ReadBlockLength(table, index2, br) { 20258 var code; 20259 var nbits; 20260 code = ReadSymbol(table, index2, br); 20261 nbits = Prefix.kBlockLengthPrefixCode[code].nbits; 20262 return Prefix.kBlockLengthPrefixCode[code].offset + br.readBits(nbits); 20263 } 20264 function TranslateShortCodes(code, ringbuffer, index2) { 20265 var val; 20266 if (code < NUM_DISTANCE_SHORT_CODES) { 20267 index2 += kDistanceShortCodeIndexOffset[code]; 20268 index2 &= 3; 20269 val = ringbuffer[index2] + kDistanceShortCodeValueOffset[code]; 20270 } else { 20271 val = code - NUM_DISTANCE_SHORT_CODES + 1; 20272 } 20273 return val; 20274 } 20275 function MoveToFront(v3, index2) { 20276 var value = v3[index2]; 20277 var i3 = index2; 20278 for (; i3; --i3) v3[i3] = v3[i3 - 1]; 20279 v3[0] = value; 20280 } 20281 function InverseMoveToFrontTransform(v3, v_len) { 20282 var mtf = new Uint8Array(256); 20283 var i3; 20284 for (i3 = 0; i3 < 256; ++i3) { 20285 mtf[i3] = i3; 20286 } 20287 for (i3 = 0; i3 < v_len; ++i3) { 20288 var index2 = v3[i3]; 20289 v3[i3] = mtf[index2]; 20290 if (index2) MoveToFront(mtf, index2); 20291 } 20292 } 20293 function HuffmanTreeGroup(alphabet_size, num_htrees) { 20294 this.alphabet_size = alphabet_size; 20295 this.num_htrees = num_htrees; 20296 this.codes = new Array( 20297 num_htrees + num_htrees * kMaxHuffmanTableSize[alphabet_size + 31 >>> 5] 20298 ); 20299 this.htrees = new Uint32Array(num_htrees); 20300 } 20301 HuffmanTreeGroup.prototype.decode = function(br) { 20302 var i3; 20303 var table_size; 20304 var next = 0; 20305 for (i3 = 0; i3 < this.num_htrees; ++i3) { 20306 this.htrees[i3] = next; 20307 table_size = ReadHuffmanCode( 20308 this.alphabet_size, 20309 this.codes, 20310 next, 20311 br 20312 ); 20313 next += table_size; 20314 } 20315 }; 20316 function DecodeContextMap(context_map_size, br) { 20317 var out = { num_htrees: null, context_map: null }; 20318 var use_rle_for_zeros; 20319 var max_run_length_prefix = 0; 20320 var table; 20321 var i3; 20322 br.readMoreInput(); 20323 var num_htrees = out.num_htrees = DecodeVarLenUint8(br) + 1; 20324 var context_map = out.context_map = new Uint8Array( 20325 context_map_size 20326 ); 20327 if (num_htrees <= 1) { 20328 return out; 20329 } 20330 use_rle_for_zeros = br.readBits(1); 20331 if (use_rle_for_zeros) { 20332 max_run_length_prefix = br.readBits(4) + 1; 20333 } 20334 table = []; 20335 for (i3 = 0; i3 < HUFFMAN_MAX_TABLE_SIZE; i3++) { 20336 table[i3] = new HuffmanCode(0, 0); 20337 } 20338 ReadHuffmanCode( 20339 num_htrees + max_run_length_prefix, 20340 table, 20341 0, 20342 br 20343 ); 20344 for (i3 = 0; i3 < context_map_size; ) { 20345 var code; 20346 br.readMoreInput(); 20347 code = ReadSymbol(table, 0, br); 20348 if (code === 0) { 20349 context_map[i3] = 0; 20350 ++i3; 20351 } else if (code <= max_run_length_prefix) { 20352 var reps = 1 + (1 << code) + br.readBits(code); 20353 while (--reps) { 20354 if (i3 >= context_map_size) { 20355 throw new Error( 20356 "[DecodeContextMap] i >= context_map_size" 20357 ); 20358 } 20359 context_map[i3] = 0; 20360 ++i3; 20361 } 20362 } else { 20363 context_map[i3] = code - max_run_length_prefix; 20364 ++i3; 20365 } 20366 } 20367 if (br.readBits(1)) { 20368 InverseMoveToFrontTransform( 20369 context_map, 20370 context_map_size 20371 ); 20372 } 20373 return out; 20374 } 20375 function DecodeBlockType(max_block_type, trees, tree_type, block_types, ringbuffers, indexes, br) { 20376 var ringbuffer = tree_type * 2; 20377 var index2 = tree_type; 20378 var type_code = ReadSymbol( 20379 trees, 20380 tree_type * HUFFMAN_MAX_TABLE_SIZE, 20381 br 20382 ); 20383 var block_type; 20384 if (type_code === 0) { 20385 block_type = ringbuffers[ringbuffer + (indexes[index2] & 1)]; 20386 } else if (type_code === 1) { 20387 block_type = ringbuffers[ringbuffer + (indexes[index2] - 1 & 1)] + 1; 20388 } else { 20389 block_type = type_code - 2; 20390 } 20391 if (block_type >= max_block_type) { 20392 block_type -= max_block_type; 20393 } 20394 block_types[tree_type] = block_type; 20395 ringbuffers[ringbuffer + (indexes[index2] & 1)] = block_type; 20396 ++indexes[index2]; 20397 } 20398 function CopyUncompressedBlockToOutput(output, len, pos, ringbuffer, ringbuffer_mask, br) { 20399 var rb_size = ringbuffer_mask + 1; 20400 var rb_pos = pos & ringbuffer_mask; 20401 var br_pos = br.pos_ & BrotliBitReader.IBUF_MASK; 20402 var nbytes; 20403 if (len < 8 || br.bit_pos_ + (len << 3) < br.bit_end_pos_) { 20404 while (len-- > 0) { 20405 br.readMoreInput(); 20406 ringbuffer[rb_pos++] = br.readBits(8); 20407 if (rb_pos === rb_size) { 20408 output.write(ringbuffer, rb_size); 20409 rb_pos = 0; 20410 } 20411 } 20412 return; 20413 } 20414 if (br.bit_end_pos_ < 32) { 20415 throw new Error( 20416 "[CopyUncompressedBlockToOutput] br.bit_end_pos_ < 32" 20417 ); 20418 } 20419 while (br.bit_pos_ < 32) { 20420 ringbuffer[rb_pos] = br.val_ >>> br.bit_pos_; 20421 br.bit_pos_ += 8; 20422 ++rb_pos; 20423 --len; 20424 } 20425 nbytes = br.bit_end_pos_ - br.bit_pos_ >> 3; 20426 if (br_pos + nbytes > BrotliBitReader.IBUF_MASK) { 20427 var tail = BrotliBitReader.IBUF_MASK + 1 - br_pos; 20428 for (var x2 = 0; x2 < tail; x2++) 20429 ringbuffer[rb_pos + x2] = br.buf_[br_pos + x2]; 20430 nbytes -= tail; 20431 rb_pos += tail; 20432 len -= tail; 20433 br_pos = 0; 20434 } 20435 for (var x2 = 0; x2 < nbytes; x2++) 20436 ringbuffer[rb_pos + x2] = br.buf_[br_pos + x2]; 20437 rb_pos += nbytes; 20438 len -= nbytes; 20439 if (rb_pos >= rb_size) { 20440 output.write(ringbuffer, rb_size); 20441 rb_pos -= rb_size; 20442 for (var x2 = 0; x2 < rb_pos; x2++) 20443 ringbuffer[x2] = ringbuffer[rb_size + x2]; 20444 } 20445 while (rb_pos + len >= rb_size) { 20446 nbytes = rb_size - rb_pos; 20447 if (br.input_.read(ringbuffer, rb_pos, nbytes) < nbytes) { 20448 throw new Error( 20449 "[CopyUncompressedBlockToOutput] not enough bytes" 20450 ); 20451 } 20452 output.write(ringbuffer, rb_size); 20453 len -= nbytes; 20454 rb_pos = 0; 20455 } 20456 if (br.input_.read(ringbuffer, rb_pos, len) < len) { 20457 throw new Error( 20458 "[CopyUncompressedBlockToOutput] not enough bytes" 20459 ); 20460 } 20461 br.reset(); 20462 } 20463 function JumpToByteBoundary(br) { 20464 var new_bit_pos = br.bit_pos_ + 7 & ~7; 20465 var pad_bits = br.readBits(new_bit_pos - br.bit_pos_); 20466 return pad_bits == 0; 20467 } 20468 function BrotliDecompressedSize(buffer) { 20469 var input = new BrotliInput(buffer); 20470 var br = new BrotliBitReader(input); 20471 DecodeWindowBits(br); 20472 var out = DecodeMetaBlockLength(br); 20473 return out.meta_block_length; 20474 } 20475 exports3.BrotliDecompressedSize = BrotliDecompressedSize; 20476 function BrotliDecompressBuffer(buffer, output_size) { 20477 var input = new BrotliInput(buffer); 20478 if (output_size == null) { 20479 output_size = BrotliDecompressedSize(buffer); 20480 } 20481 var output_buffer = new Uint8Array(output_size); 20482 var output = new BrotliOutput(output_buffer); 20483 BrotliDecompress(input, output); 20484 if (output.pos < output.buffer.length) { 20485 output.buffer = output.buffer.subarray( 20486 0, 20487 output.pos 20488 ); 20489 } 20490 return output.buffer; 20491 } 20492 exports3.BrotliDecompressBuffer = BrotliDecompressBuffer; 20493 function BrotliDecompress(input, output) { 20494 var i3; 20495 var pos = 0; 20496 var input_end = 0; 20497 var window_bits = 0; 20498 var max_backward_distance; 20499 var max_distance = 0; 20500 var ringbuffer_size; 20501 var ringbuffer_mask; 20502 var ringbuffer; 20503 var ringbuffer_end; 20504 var dist_rb = [16, 15, 11, 4]; 20505 var dist_rb_idx = 0; 20506 var prev_byte1 = 0; 20507 var prev_byte2 = 0; 20508 var hgroup = [ 20509 new HuffmanTreeGroup(0, 0), 20510 new HuffmanTreeGroup(0, 0), 20511 new HuffmanTreeGroup(0, 0) 20512 ]; 20513 var block_type_trees; 20514 var block_len_trees; 20515 var br; 20516 var kRingBufferWriteAheadSlack = 128 + BrotliBitReader.READ_SIZE; 20517 br = new BrotliBitReader(input); 20518 window_bits = DecodeWindowBits(br); 20519 max_backward_distance = (1 << window_bits) - 16; 20520 ringbuffer_size = 1 << window_bits; 20521 ringbuffer_mask = ringbuffer_size - 1; 20522 ringbuffer = new Uint8Array( 20523 ringbuffer_size + kRingBufferWriteAheadSlack + BrotliDictionary.maxDictionaryWordLength 20524 ); 20525 ringbuffer_end = ringbuffer_size; 20526 block_type_trees = []; 20527 block_len_trees = []; 20528 for (var x2 = 0; x2 < 3 * HUFFMAN_MAX_TABLE_SIZE; x2++) { 20529 block_type_trees[x2] = new HuffmanCode(0, 0); 20530 block_len_trees[x2] = new HuffmanCode(0, 0); 20531 } 20532 while (!input_end) { 20533 var meta_block_remaining_len = 0; 20534 var is_uncompressed; 20535 var block_length = [1 << 28, 1 << 28, 1 << 28]; 20536 var block_type = [0]; 20537 var num_block_types = [1, 1, 1]; 20538 var block_type_rb = [0, 1, 0, 1, 0, 1]; 20539 var block_type_rb_index = [0]; 20540 var distance_postfix_bits; 20541 var num_direct_distance_codes; 20542 var distance_postfix_mask; 20543 var num_distance_codes; 20544 var context_map = null; 20545 var context_modes = null; 20546 var num_literal_htrees; 20547 var dist_context_map = null; 20548 var num_dist_htrees; 20549 var context_offset = 0; 20550 var context_map_slice = null; 20551 var literal_htree_index = 0; 20552 var dist_context_offset = 0; 20553 var dist_context_map_slice = null; 20554 var dist_htree_index = 0; 20555 var context_lookup_offset1 = 0; 20556 var context_lookup_offset2 = 0; 20557 var context_mode; 20558 var htree_command; 20559 for (i3 = 0; i3 < 3; ++i3) { 20560 hgroup[i3].codes = null; 20561 hgroup[i3].htrees = null; 20562 } 20563 br.readMoreInput(); 20564 var _out = DecodeMetaBlockLength(br); 20565 meta_block_remaining_len = _out.meta_block_length; 20566 if (pos + meta_block_remaining_len > output.buffer.length) { 20567 var tmp = new Uint8Array( 20568 pos + meta_block_remaining_len 20569 ); 20570 tmp.set(output.buffer); 20571 output.buffer = tmp; 20572 } 20573 input_end = _out.input_end; 20574 is_uncompressed = _out.is_uncompressed; 20575 if (_out.is_metadata) { 20576 JumpToByteBoundary(br); 20577 for (; meta_block_remaining_len > 0; --meta_block_remaining_len) { 20578 br.readMoreInput(); 20579 br.readBits(8); 20580 } 20581 continue; 20582 } 20583 if (meta_block_remaining_len === 0) { 20584 continue; 20585 } 20586 if (is_uncompressed) { 20587 br.bit_pos_ = br.bit_pos_ + 7 & ~7; 20588 CopyUncompressedBlockToOutput( 20589 output, 20590 meta_block_remaining_len, 20591 pos, 20592 ringbuffer, 20593 ringbuffer_mask, 20594 br 20595 ); 20596 pos += meta_block_remaining_len; 20597 continue; 20598 } 20599 for (i3 = 0; i3 < 3; ++i3) { 20600 num_block_types[i3] = DecodeVarLenUint8(br) + 1; 20601 if (num_block_types[i3] >= 2) { 20602 ReadHuffmanCode( 20603 num_block_types[i3] + 2, 20604 block_type_trees, 20605 i3 * HUFFMAN_MAX_TABLE_SIZE, 20606 br 20607 ); 20608 ReadHuffmanCode( 20609 kNumBlockLengthCodes, 20610 block_len_trees, 20611 i3 * HUFFMAN_MAX_TABLE_SIZE, 20612 br 20613 ); 20614 block_length[i3] = ReadBlockLength( 20615 block_len_trees, 20616 i3 * HUFFMAN_MAX_TABLE_SIZE, 20617 br 20618 ); 20619 block_type_rb_index[i3] = 1; 20620 } 20621 } 20622 br.readMoreInput(); 20623 distance_postfix_bits = br.readBits(2); 20624 num_direct_distance_codes = NUM_DISTANCE_SHORT_CODES + (br.readBits(4) << distance_postfix_bits); 20625 distance_postfix_mask = (1 << distance_postfix_bits) - 1; 20626 num_distance_codes = num_direct_distance_codes + (48 << distance_postfix_bits); 20627 context_modes = new Uint8Array( 20628 num_block_types[0] 20629 ); 20630 for (i3 = 0; i3 < num_block_types[0]; ++i3) { 20631 br.readMoreInput(); 20632 context_modes[i3] = br.readBits(2) << 1; 20633 } 20634 var _o1 = DecodeContextMap( 20635 num_block_types[0] << kLiteralContextBits, 20636 br 20637 ); 20638 num_literal_htrees = _o1.num_htrees; 20639 context_map = _o1.context_map; 20640 var _o2 = DecodeContextMap( 20641 num_block_types[2] << kDistanceContextBits, 20642 br 20643 ); 20644 num_dist_htrees = _o2.num_htrees; 20645 dist_context_map = _o2.context_map; 20646 hgroup[0] = new HuffmanTreeGroup( 20647 kNumLiteralCodes, 20648 num_literal_htrees 20649 ); 20650 hgroup[1] = new HuffmanTreeGroup( 20651 kNumInsertAndCopyCodes, 20652 num_block_types[1] 20653 ); 20654 hgroup[2] = new HuffmanTreeGroup( 20655 num_distance_codes, 20656 num_dist_htrees 20657 ); 20658 for (i3 = 0; i3 < 3; ++i3) { 20659 hgroup[i3].decode(br); 20660 } 20661 context_map_slice = 0; 20662 dist_context_map_slice = 0; 20663 context_mode = context_modes[block_type[0]]; 20664 context_lookup_offset1 = Context.lookupOffsets[context_mode]; 20665 context_lookup_offset2 = Context.lookupOffsets[context_mode + 1]; 20666 htree_command = hgroup[1].htrees[0]; 20667 while (meta_block_remaining_len > 0) { 20668 var cmd_code; 20669 var range_idx; 20670 var insert_code; 20671 var copy_code; 20672 var insert_length; 20673 var copy_length; 20674 var distance_code; 20675 var distance; 20676 var context; 20677 var j2; 20678 var copy_dst; 20679 br.readMoreInput(); 20680 if (block_length[1] === 0) { 20681 DecodeBlockType( 20682 num_block_types[1], 20683 block_type_trees, 20684 1, 20685 block_type, 20686 block_type_rb, 20687 block_type_rb_index, 20688 br 20689 ); 20690 block_length[1] = ReadBlockLength( 20691 block_len_trees, 20692 HUFFMAN_MAX_TABLE_SIZE, 20693 br 20694 ); 20695 htree_command = hgroup[1].htrees[block_type[1]]; 20696 } 20697 --block_length[1]; 20698 cmd_code = ReadSymbol( 20699 hgroup[1].codes, 20700 htree_command, 20701 br 20702 ); 20703 range_idx = cmd_code >> 6; 20704 if (range_idx >= 2) { 20705 range_idx -= 2; 20706 distance_code = -1; 20707 } else { 20708 distance_code = 0; 20709 } 20710 insert_code = Prefix.kInsertRangeLut[range_idx] + (cmd_code >> 3 & 7); 20711 copy_code = Prefix.kCopyRangeLut[range_idx] + (cmd_code & 7); 20712 insert_length = Prefix.kInsertLengthPrefixCode[insert_code].offset + br.readBits( 20713 Prefix.kInsertLengthPrefixCode[insert_code].nbits 20714 ); 20715 copy_length = Prefix.kCopyLengthPrefixCode[copy_code].offset + br.readBits( 20716 Prefix.kCopyLengthPrefixCode[copy_code].nbits 20717 ); 20718 prev_byte1 = ringbuffer[pos - 1 & ringbuffer_mask]; 20719 prev_byte2 = ringbuffer[pos - 2 & ringbuffer_mask]; 20720 for (j2 = 0; j2 < insert_length; ++j2) { 20721 br.readMoreInput(); 20722 if (block_length[0] === 0) { 20723 DecodeBlockType( 20724 num_block_types[0], 20725 block_type_trees, 20726 0, 20727 block_type, 20728 block_type_rb, 20729 block_type_rb_index, 20730 br 20731 ); 20732 block_length[0] = ReadBlockLength( 20733 block_len_trees, 20734 0, 20735 br 20736 ); 20737 context_offset = block_type[0] << kLiteralContextBits; 20738 context_map_slice = context_offset; 20739 context_mode = context_modes[block_type[0]]; 20740 context_lookup_offset1 = Context.lookupOffsets[context_mode]; 20741 context_lookup_offset2 = Context.lookupOffsets[context_mode + 1]; 20742 } 20743 context = Context.lookup[context_lookup_offset1 + prev_byte1] | Context.lookup[context_lookup_offset2 + prev_byte2]; 20744 literal_htree_index = context_map[context_map_slice + context]; 20745 --block_length[0]; 20746 prev_byte2 = prev_byte1; 20747 prev_byte1 = ReadSymbol( 20748 hgroup[0].codes, 20749 hgroup[0].htrees[literal_htree_index], 20750 br 20751 ); 20752 ringbuffer[pos & ringbuffer_mask] = prev_byte1; 20753 if ((pos & ringbuffer_mask) === ringbuffer_mask) { 20754 output.write( 20755 ringbuffer, 20756 ringbuffer_size 20757 ); 20758 } 20759 ++pos; 20760 } 20761 meta_block_remaining_len -= insert_length; 20762 if (meta_block_remaining_len <= 0) break; 20763 if (distance_code < 0) { 20764 var context; 20765 br.readMoreInput(); 20766 if (block_length[2] === 0) { 20767 DecodeBlockType( 20768 num_block_types[2], 20769 block_type_trees, 20770 2, 20771 block_type, 20772 block_type_rb, 20773 block_type_rb_index, 20774 br 20775 ); 20776 block_length[2] = ReadBlockLength( 20777 block_len_trees, 20778 2 * HUFFMAN_MAX_TABLE_SIZE, 20779 br 20780 ); 20781 dist_context_offset = block_type[2] << kDistanceContextBits; 20782 dist_context_map_slice = dist_context_offset; 20783 } 20784 --block_length[2]; 20785 context = (copy_length > 4 ? 3 : copy_length - 2) & 255; 20786 dist_htree_index = dist_context_map[dist_context_map_slice + context]; 20787 distance_code = ReadSymbol( 20788 hgroup[2].codes, 20789 hgroup[2].htrees[dist_htree_index], 20790 br 20791 ); 20792 if (distance_code >= num_direct_distance_codes) { 20793 var nbits; 20794 var postfix; 20795 var offset3; 20796 distance_code -= num_direct_distance_codes; 20797 postfix = distance_code & distance_postfix_mask; 20798 distance_code >>= distance_postfix_bits; 20799 nbits = (distance_code >> 1) + 1; 20800 offset3 = (2 + (distance_code & 1) << nbits) - 4; 20801 distance_code = num_direct_distance_codes + (offset3 + br.readBits(nbits) << distance_postfix_bits) + postfix; 20802 } 20803 } 20804 distance = TranslateShortCodes( 20805 distance_code, 20806 dist_rb, 20807 dist_rb_idx 20808 ); 20809 if (distance < 0) { 20810 throw new Error( 20811 "[BrotliDecompress] invalid distance" 20812 ); 20813 } 20814 if (pos < max_backward_distance && max_distance !== max_backward_distance) { 20815 max_distance = pos; 20816 } else { 20817 max_distance = max_backward_distance; 20818 } 20819 copy_dst = pos & ringbuffer_mask; 20820 if (distance > max_distance) { 20821 if (copy_length >= BrotliDictionary.minDictionaryWordLength && copy_length <= BrotliDictionary.maxDictionaryWordLength) { 20822 var offset3 = BrotliDictionary.offsetsByLength[copy_length]; 20823 var word_id = distance - max_distance - 1; 20824 var shift3 = BrotliDictionary.sizeBitsByLength[copy_length]; 20825 var mask = (1 << shift3) - 1; 20826 var word_idx = word_id & mask; 20827 var transform_idx = word_id >> shift3; 20828 offset3 += word_idx * copy_length; 20829 if (transform_idx < Transform.kNumTransforms) { 20830 var len = Transform.transformDictionaryWord( 20831 ringbuffer, 20832 copy_dst, 20833 offset3, 20834 copy_length, 20835 transform_idx 20836 ); 20837 copy_dst += len; 20838 pos += len; 20839 meta_block_remaining_len -= len; 20840 if (copy_dst >= ringbuffer_end) { 20841 output.write( 20842 ringbuffer, 20843 ringbuffer_size 20844 ); 20845 for (var _x40 = 0; _x40 < copy_dst - ringbuffer_end; _x40++) 20846 ringbuffer[_x40] = ringbuffer[ringbuffer_end + _x40]; 20847 } 20848 } else { 20849 throw new Error( 20850 "Invalid backward reference. pos: " + pos + " distance: " + distance + " len: " + copy_length + " bytes left: " + meta_block_remaining_len 20851 ); 20852 } 20853 } else { 20854 throw new Error( 20855 "Invalid backward reference. pos: " + pos + " distance: " + distance + " len: " + copy_length + " bytes left: " + meta_block_remaining_len 20856 ); 20857 } 20858 } else { 20859 if (distance_code > 0) { 20860 dist_rb[dist_rb_idx & 3] = distance; 20861 ++dist_rb_idx; 20862 } 20863 if (copy_length > meta_block_remaining_len) { 20864 throw new Error( 20865 "Invalid backward reference. pos: " + pos + " distance: " + distance + " len: " + copy_length + " bytes left: " + meta_block_remaining_len 20866 ); 20867 } 20868 for (j2 = 0; j2 < copy_length; ++j2) { 20869 ringbuffer[pos & ringbuffer_mask] = ringbuffer[pos - distance & ringbuffer_mask]; 20870 if ((pos & ringbuffer_mask) === ringbuffer_mask) { 20871 output.write( 20872 ringbuffer, 20873 ringbuffer_size 20874 ); 20875 } 20876 ++pos; 20877 --meta_block_remaining_len; 20878 } 20879 } 20880 prev_byte1 = ringbuffer[pos - 1 & ringbuffer_mask]; 20881 prev_byte2 = ringbuffer[pos - 2 & ringbuffer_mask]; 20882 } 20883 pos &= 1073741823; 20884 } 20885 output.write(ringbuffer, pos & ringbuffer_mask); 20886 } 20887 exports3.BrotliDecompress = BrotliDecompress; 20888 BrotliDictionary.init(); 20889 }, 20890 { 20891 "./bit_reader": 1, 20892 "./context": 2, 20893 "./dictionary": 6, 20894 "./huffman": 7, 20895 "./prefix": 9, 20896 "./streams": 10, 20897 "./transform": 11 20898 } 20899 ], 20900 4: [ 20901 function(require2, module3, exports3) { 20902 var base64 = require2("base64-js"); 20903 exports3.init = function() { 20904 var BrotliDecompressBuffer = require2("./decode").BrotliDecompressBuffer; 20905 var compressed = base64.toByteArray( 20906 require2("./dictionary.bin.js") 20907 ); 20908 return BrotliDecompressBuffer(compressed); 20909 }; 20910 }, 20911 { "./decode": 3, "./dictionary.bin.js": 5, "base64-js": 8 } 20912 ], 20913 5: [ 20914 function(require2, module3, exports3) { 20915 module3.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="; 20916 }, 20917 {} 20918 ], 20919 6: [ 20920 function(require2, module3, exports3) { 20921 var data = require2("./dictionary-browser"); 20922 exports3.init = function() { 20923 exports3.dictionary = data.init(); 20924 }; 20925 exports3.offsetsByLength = new Uint32Array([ 20926 0, 20927 0, 20928 0, 20929 0, 20930 0, 20931 4096, 20932 9216, 20933 21504, 20934 35840, 20935 44032, 20936 53248, 20937 63488, 20938 74752, 20939 87040, 20940 93696, 20941 100864, 20942 104704, 20943 106752, 20944 108928, 20945 113536, 20946 115968, 20947 118528, 20948 119872, 20949 121280, 20950 122016 20951 ]); 20952 exports3.sizeBitsByLength = new Uint8Array([ 20953 0, 20954 0, 20955 0, 20956 0, 20957 10, 20958 10, 20959 11, 20960 11, 20961 10, 20962 10, 20963 10, 20964 10, 20965 10, 20966 9, 20967 9, 20968 8, 20969 7, 20970 7, 20971 8, 20972 7, 20973 7, 20974 6, 20975 6, 20976 5, 20977 5 20978 ]); 20979 exports3.minDictionaryWordLength = 4; 20980 exports3.maxDictionaryWordLength = 24; 20981 }, 20982 { "./dictionary-browser": 4 } 20983 ], 20984 7: [ 20985 function(require2, module3, exports3) { 20986 function HuffmanCode(bits, value) { 20987 this.bits = bits; 20988 this.value = value; 20989 } 20990 exports3.HuffmanCode = HuffmanCode; 20991 var MAX_LENGTH = 15; 20992 function GetNextKey(key, len) { 20993 var step = 1 << len - 1; 20994 while (key & step) { 20995 step >>= 1; 20996 } 20997 return (key & step - 1) + step; 20998 } 20999 function ReplicateValue(table, i3, step, end, code) { 21000 do { 21001 end -= step; 21002 table[i3 + end] = new HuffmanCode( 21003 code.bits, 21004 code.value 21005 ); 21006 } while (end > 0); 21007 } 21008 function NextTableBitSize(count, len, root_bits) { 21009 var left = 1 << len - root_bits; 21010 while (len < MAX_LENGTH) { 21011 left -= count[len]; 21012 if (left <= 0) break; 21013 ++len; 21014 left <<= 1; 21015 } 21016 return len - root_bits; 21017 } 21018 exports3.BrotliBuildHuffmanTable = function(root_table, table, root_bits, code_lengths, code_lengths_size) { 21019 var start_table = table; 21020 var code; 21021 var len; 21022 var symbol; 21023 var key; 21024 var step; 21025 var low; 21026 var mask; 21027 var table_bits; 21028 var table_size; 21029 var total_size; 21030 var sorted; 21031 var count = new Int32Array( 21032 MAX_LENGTH + 1 21033 ); 21034 var offset3 = new Int32Array( 21035 MAX_LENGTH + 1 21036 ); 21037 sorted = new Int32Array(code_lengths_size); 21038 for (symbol = 0; symbol < code_lengths_size; symbol++) { 21039 count[code_lengths[symbol]]++; 21040 } 21041 offset3[1] = 0; 21042 for (len = 1; len < MAX_LENGTH; len++) { 21043 offset3[len + 1] = offset3[len] + count[len]; 21044 } 21045 for (symbol = 0; symbol < code_lengths_size; symbol++) { 21046 if (code_lengths[symbol] !== 0) { 21047 sorted[offset3[code_lengths[symbol]]++] = symbol; 21048 } 21049 } 21050 table_bits = root_bits; 21051 table_size = 1 << table_bits; 21052 total_size = table_size; 21053 if (offset3[MAX_LENGTH] === 1) { 21054 for (key = 0; key < total_size; ++key) { 21055 root_table[table + key] = new HuffmanCode( 21056 0, 21057 sorted[0] & 65535 21058 ); 21059 } 21060 return total_size; 21061 } 21062 key = 0; 21063 symbol = 0; 21064 for (len = 1, step = 2; len <= root_bits; ++len, step <<= 1) { 21065 for (; count[len] > 0; --count[len]) { 21066 code = new HuffmanCode( 21067 len & 255, 21068 sorted[symbol++] & 65535 21069 ); 21070 ReplicateValue( 21071 root_table, 21072 table + key, 21073 step, 21074 table_size, 21075 code 21076 ); 21077 key = GetNextKey(key, len); 21078 } 21079 } 21080 mask = total_size - 1; 21081 low = -1; 21082 for (len = root_bits + 1, step = 2; len <= MAX_LENGTH; ++len, step <<= 1) { 21083 for (; count[len] > 0; --count[len]) { 21084 if ((key & mask) !== low) { 21085 table += table_size; 21086 table_bits = NextTableBitSize( 21087 count, 21088 len, 21089 root_bits 21090 ); 21091 table_size = 1 << table_bits; 21092 total_size += table_size; 21093 low = key & mask; 21094 root_table[start_table + low] = new HuffmanCode( 21095 table_bits + root_bits & 255, 21096 table - start_table - low & 65535 21097 ); 21098 } 21099 code = new HuffmanCode( 21100 len - root_bits & 255, 21101 sorted[symbol++] & 65535 21102 ); 21103 ReplicateValue( 21104 root_table, 21105 table + (key >> root_bits), 21106 step, 21107 table_size, 21108 code 21109 ); 21110 key = GetNextKey(key, len); 21111 } 21112 } 21113 return total_size; 21114 }; 21115 }, 21116 {} 21117 ], 21118 8: [ 21119 function(require2, module3, exports3) { 21120 "use strict"; 21121 exports3.byteLength = byteLength; 21122 exports3.toByteArray = toByteArray; 21123 exports3.fromByteArray = fromByteArray; 21124 var lookup = []; 21125 var revLookup = []; 21126 var Arr = typeof Uint8Array !== "undefined" ? Uint8Array : Array; 21127 var code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; 21128 for (var i3 = 0, len = code.length; i3 < len; ++i3) { 21129 lookup[i3] = code[i3]; 21130 revLookup[code.charCodeAt(i3)] = i3; 21131 } 21132 revLookup["-".charCodeAt(0)] = 62; 21133 revLookup["_".charCodeAt(0)] = 63; 21134 function getLens(b64) { 21135 var len2 = b64.length; 21136 if (len2 % 4 > 0) { 21137 throw new Error( 21138 "Invalid string. Length must be a multiple of 4" 21139 ); 21140 } 21141 var validLen = b64.indexOf("="); 21142 if (validLen === -1) validLen = len2; 21143 var placeHoldersLen = validLen === len2 ? 0 : 4 - validLen % 4; 21144 return [validLen, placeHoldersLen]; 21145 } 21146 function byteLength(b64) { 21147 var lens = getLens(b64); 21148 var validLen = lens[0]; 21149 var placeHoldersLen = lens[1]; 21150 return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen; 21151 } 21152 function _byteLength(b64, validLen, placeHoldersLen) { 21153 return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen; 21154 } 21155 function toByteArray(b64) { 21156 var tmp; 21157 var lens = getLens(b64); 21158 var validLen = lens[0]; 21159 var placeHoldersLen = lens[1]; 21160 var arr = new Arr( 21161 _byteLength(b64, validLen, placeHoldersLen) 21162 ); 21163 var curByte = 0; 21164 var len2 = placeHoldersLen > 0 ? validLen - 4 : validLen; 21165 for (var i22 = 0; i22 < len2; i22 += 4) { 21166 tmp = revLookup[b64.charCodeAt(i22)] << 18 | revLookup[b64.charCodeAt(i22 + 1)] << 12 | revLookup[b64.charCodeAt(i22 + 2)] << 6 | revLookup[b64.charCodeAt(i22 + 3)]; 21167 arr[curByte++] = tmp >> 16 & 255; 21168 arr[curByte++] = tmp >> 8 & 255; 21169 arr[curByte++] = tmp & 255; 21170 } 21171 if (placeHoldersLen === 2) { 21172 tmp = revLookup[b64.charCodeAt(i22)] << 2 | revLookup[b64.charCodeAt(i22 + 1)] >> 4; 21173 arr[curByte++] = tmp & 255; 21174 } 21175 if (placeHoldersLen === 1) { 21176 tmp = revLookup[b64.charCodeAt(i22)] << 10 | revLookup[b64.charCodeAt(i22 + 1)] << 4 | revLookup[b64.charCodeAt(i22 + 2)] >> 2; 21177 arr[curByte++] = tmp >> 8 & 255; 21178 arr[curByte++] = tmp & 255; 21179 } 21180 return arr; 21181 } 21182 function tripletToBase64(num) { 21183 return lookup[num >> 18 & 63] + lookup[num >> 12 & 63] + lookup[num >> 6 & 63] + lookup[num & 63]; 21184 } 21185 function encodeChunk(uint8, start, end) { 21186 var tmp; 21187 var output = []; 21188 for (var i22 = start; i22 < end; i22 += 3) { 21189 tmp = (uint8[i22] << 16 & 16711680) + (uint8[i22 + 1] << 8 & 65280) + (uint8[i22 + 2] & 255); 21190 output.push(tripletToBase64(tmp)); 21191 } 21192 return output.join(""); 21193 } 21194 function fromByteArray(uint8) { 21195 var tmp; 21196 var len2 = uint8.length; 21197 var extraBytes = len2 % 3; 21198 var parts = []; 21199 var maxChunkLength = 16383; 21200 for (var i22 = 0, len22 = len2 - extraBytes; i22 < len22; i22 += maxChunkLength) { 21201 parts.push( 21202 encodeChunk( 21203 uint8, 21204 i22, 21205 i22 + maxChunkLength > len22 ? len22 : i22 + maxChunkLength 21206 ) 21207 ); 21208 } 21209 if (extraBytes === 1) { 21210 tmp = uint8[len2 - 1]; 21211 parts.push( 21212 lookup[tmp >> 2] + lookup[tmp << 4 & 63] + "==" 21213 ); 21214 } else if (extraBytes === 2) { 21215 tmp = (uint8[len2 - 2] << 8) + uint8[len2 - 1]; 21216 parts.push( 21217 lookup[tmp >> 10] + lookup[tmp >> 4 & 63] + lookup[tmp << 2 & 63] + "=" 21218 ); 21219 } 21220 return parts.join(""); 21221 } 21222 }, 21223 {} 21224 ], 21225 9: [ 21226 function(require2, module3, exports3) { 21227 function PrefixCodeRange(offset3, nbits) { 21228 this.offset = offset3; 21229 this.nbits = nbits; 21230 } 21231 exports3.kBlockLengthPrefixCode = [ 21232 new PrefixCodeRange(1, 2), 21233 new PrefixCodeRange(5, 2), 21234 new PrefixCodeRange(9, 2), 21235 new PrefixCodeRange(13, 2), 21236 new PrefixCodeRange(17, 3), 21237 new PrefixCodeRange(25, 3), 21238 new PrefixCodeRange(33, 3), 21239 new PrefixCodeRange(41, 3), 21240 new PrefixCodeRange(49, 4), 21241 new PrefixCodeRange(65, 4), 21242 new PrefixCodeRange(81, 4), 21243 new PrefixCodeRange(97, 4), 21244 new PrefixCodeRange(113, 5), 21245 new PrefixCodeRange(145, 5), 21246 new PrefixCodeRange(177, 5), 21247 new PrefixCodeRange(209, 5), 21248 new PrefixCodeRange(241, 6), 21249 new PrefixCodeRange(305, 6), 21250 new PrefixCodeRange(369, 7), 21251 new PrefixCodeRange(497, 8), 21252 new PrefixCodeRange(753, 9), 21253 new PrefixCodeRange(1265, 10), 21254 new PrefixCodeRange(2289, 11), 21255 new PrefixCodeRange(4337, 12), 21256 new PrefixCodeRange(8433, 13), 21257 new PrefixCodeRange(16625, 24) 21258 ]; 21259 exports3.kInsertLengthPrefixCode = [ 21260 new PrefixCodeRange(0, 0), 21261 new PrefixCodeRange(1, 0), 21262 new PrefixCodeRange(2, 0), 21263 new PrefixCodeRange(3, 0), 21264 new PrefixCodeRange(4, 0), 21265 new PrefixCodeRange(5, 0), 21266 new PrefixCodeRange(6, 1), 21267 new PrefixCodeRange(8, 1), 21268 new PrefixCodeRange(10, 2), 21269 new PrefixCodeRange(14, 2), 21270 new PrefixCodeRange(18, 3), 21271 new PrefixCodeRange(26, 3), 21272 new PrefixCodeRange(34, 4), 21273 new PrefixCodeRange(50, 4), 21274 new PrefixCodeRange(66, 5), 21275 new PrefixCodeRange(98, 5), 21276 new PrefixCodeRange(130, 6), 21277 new PrefixCodeRange(194, 7), 21278 new PrefixCodeRange(322, 8), 21279 new PrefixCodeRange(578, 9), 21280 new PrefixCodeRange(1090, 10), 21281 new PrefixCodeRange(2114, 12), 21282 new PrefixCodeRange(6210, 14), 21283 new PrefixCodeRange(22594, 24) 21284 ]; 21285 exports3.kCopyLengthPrefixCode = [ 21286 new PrefixCodeRange(2, 0), 21287 new PrefixCodeRange(3, 0), 21288 new PrefixCodeRange(4, 0), 21289 new PrefixCodeRange(5, 0), 21290 new PrefixCodeRange(6, 0), 21291 new PrefixCodeRange(7, 0), 21292 new PrefixCodeRange(8, 0), 21293 new PrefixCodeRange(9, 0), 21294 new PrefixCodeRange(10, 1), 21295 new PrefixCodeRange(12, 1), 21296 new PrefixCodeRange(14, 2), 21297 new PrefixCodeRange(18, 2), 21298 new PrefixCodeRange(22, 3), 21299 new PrefixCodeRange(30, 3), 21300 new PrefixCodeRange(38, 4), 21301 new PrefixCodeRange(54, 4), 21302 new PrefixCodeRange(70, 5), 21303 new PrefixCodeRange(102, 5), 21304 new PrefixCodeRange(134, 6), 21305 new PrefixCodeRange(198, 7), 21306 new PrefixCodeRange(326, 8), 21307 new PrefixCodeRange(582, 9), 21308 new PrefixCodeRange(1094, 10), 21309 new PrefixCodeRange(2118, 24) 21310 ]; 21311 exports3.kInsertRangeLut = [0, 0, 8, 8, 0, 16, 8, 16, 16]; 21312 exports3.kCopyRangeLut = [0, 8, 0, 8, 16, 0, 16, 8, 16]; 21313 }, 21314 {} 21315 ], 21316 10: [ 21317 function(require2, module3, exports3) { 21318 function BrotliInput(buffer) { 21319 this.buffer = buffer; 21320 this.pos = 0; 21321 } 21322 BrotliInput.prototype.read = function(buf, i3, count) { 21323 if (this.pos + count > this.buffer.length) { 21324 count = this.buffer.length - this.pos; 21325 } 21326 for (var p4 = 0; p4 < count; p4++) 21327 buf[i3 + p4] = this.buffer[this.pos + p4]; 21328 this.pos += count; 21329 return count; 21330 }; 21331 exports3.BrotliInput = BrotliInput; 21332 function BrotliOutput(buf) { 21333 this.buffer = buf; 21334 this.pos = 0; 21335 } 21336 BrotliOutput.prototype.write = function(buf, count) { 21337 if (this.pos + count > this.buffer.length) 21338 throw new Error( 21339 "Output buffer is not large enough" 21340 ); 21341 this.buffer.set(buf.subarray(0, count), this.pos); 21342 this.pos += count; 21343 return count; 21344 }; 21345 exports3.BrotliOutput = BrotliOutput; 21346 }, 21347 {} 21348 ], 21349 11: [ 21350 function(require2, module3, exports3) { 21351 var BrotliDictionary = require2("./dictionary"); 21352 var kIdentity = 0; 21353 var kOmitLast1 = 1; 21354 var kOmitLast2 = 2; 21355 var kOmitLast3 = 3; 21356 var kOmitLast4 = 4; 21357 var kOmitLast5 = 5; 21358 var kOmitLast6 = 6; 21359 var kOmitLast7 = 7; 21360 var kOmitLast8 = 8; 21361 var kOmitLast9 = 9; 21362 var kUppercaseFirst = 10; 21363 var kUppercaseAll = 11; 21364 var kOmitFirst1 = 12; 21365 var kOmitFirst2 = 13; 21366 var kOmitFirst3 = 14; 21367 var kOmitFirst4 = 15; 21368 var kOmitFirst5 = 16; 21369 var kOmitFirst6 = 17; 21370 var kOmitFirst7 = 18; 21371 var kOmitFirst8 = 19; 21372 var kOmitFirst9 = 20; 21373 function Transform(prefix, transform, suffix) { 21374 this.prefix = new Uint8Array(prefix.length); 21375 this.transform = transform; 21376 this.suffix = new Uint8Array(suffix.length); 21377 for (var i3 = 0; i3 < prefix.length; i3++) 21378 this.prefix[i3] = prefix.charCodeAt(i3); 21379 for (var i3 = 0; i3 < suffix.length; i3++) 21380 this.suffix[i3] = suffix.charCodeAt(i3); 21381 } 21382 var kTransforms = [ 21383 new Transform("", kIdentity, ""), 21384 new Transform("", kIdentity, " "), 21385 new Transform(" ", kIdentity, " "), 21386 new Transform("", kOmitFirst1, ""), 21387 new Transform("", kUppercaseFirst, " "), 21388 new Transform("", kIdentity, " the "), 21389 new Transform(" ", kIdentity, ""), 21390 new Transform("s ", kIdentity, " "), 21391 new Transform("", kIdentity, " of "), 21392 new Transform("", kUppercaseFirst, ""), 21393 new Transform("", kIdentity, " and "), 21394 new Transform("", kOmitFirst2, ""), 21395 new Transform("", kOmitLast1, ""), 21396 new Transform(", ", kIdentity, " "), 21397 new Transform("", kIdentity, ", "), 21398 new Transform(" ", kUppercaseFirst, " "), 21399 new Transform("", kIdentity, " in "), 21400 new Transform("", kIdentity, " to "), 21401 new Transform("e ", kIdentity, " "), 21402 new Transform("", kIdentity, '"'), 21403 new Transform("", kIdentity, "."), 21404 new Transform("", kIdentity, '">'), 21405 new Transform("", kIdentity, "\n"), 21406 new Transform("", kOmitLast3, ""), 21407 new Transform("", kIdentity, "]"), 21408 new Transform("", kIdentity, " for "), 21409 new Transform("", kOmitFirst3, ""), 21410 new Transform("", kOmitLast2, ""), 21411 new Transform("", kIdentity, " a "), 21412 new Transform("", kIdentity, " that "), 21413 new Transform(" ", kUppercaseFirst, ""), 21414 new Transform("", kIdentity, ". "), 21415 new Transform(".", kIdentity, ""), 21416 new Transform(" ", kIdentity, ", "), 21417 new Transform("", kOmitFirst4, ""), 21418 new Transform("", kIdentity, " with "), 21419 new Transform("", kIdentity, "'"), 21420 new Transform("", kIdentity, " from "), 21421 new Transform("", kIdentity, " by "), 21422 new Transform("", kOmitFirst5, ""), 21423 new Transform("", kOmitFirst6, ""), 21424 new Transform(" the ", kIdentity, ""), 21425 new Transform("", kOmitLast4, ""), 21426 new Transform("", kIdentity, ". The "), 21427 new Transform("", kUppercaseAll, ""), 21428 new Transform("", kIdentity, " on "), 21429 new Transform("", kIdentity, " as "), 21430 new Transform("", kIdentity, " is "), 21431 new Transform("", kOmitLast7, ""), 21432 new Transform("", kOmitLast1, "ing "), 21433 new Transform("", kIdentity, "\n "), 21434 new Transform("", kIdentity, ":"), 21435 new Transform(" ", kIdentity, ". "), 21436 new Transform("", kIdentity, "ed "), 21437 new Transform("", kOmitFirst9, ""), 21438 new Transform("", kOmitFirst7, ""), 21439 new Transform("", kOmitLast6, ""), 21440 new Transform("", kIdentity, "("), 21441 new Transform("", kUppercaseFirst, ", "), 21442 new Transform("", kOmitLast8, ""), 21443 new Transform("", kIdentity, " at "), 21444 new Transform("", kIdentity, "ly "), 21445 new Transform(" the ", kIdentity, " of "), 21446 new Transform("", kOmitLast5, ""), 21447 new Transform("", kOmitLast9, ""), 21448 new Transform(" ", kUppercaseFirst, ", "), 21449 new Transform("", kUppercaseFirst, '"'), 21450 new Transform(".", kIdentity, "("), 21451 new Transform("", kUppercaseAll, " "), 21452 new Transform("", kUppercaseFirst, '">'), 21453 new Transform("", kIdentity, '="'), 21454 new Transform(" ", kIdentity, "."), 21455 new Transform(".com/", kIdentity, ""), 21456 new Transform(" the ", kIdentity, " of the "), 21457 new Transform("", kUppercaseFirst, "'"), 21458 new Transform("", kIdentity, ". This "), 21459 new Transform("", kIdentity, ","), 21460 new Transform(".", kIdentity, " "), 21461 new Transform("", kUppercaseFirst, "("), 21462 new Transform("", kUppercaseFirst, "."), 21463 new Transform("", kIdentity, " not "), 21464 new Transform(" ", kIdentity, '="'), 21465 new Transform("", kIdentity, "er "), 21466 new Transform(" ", kUppercaseAll, " "), 21467 new Transform("", kIdentity, "al "), 21468 new Transform(" ", kUppercaseAll, ""), 21469 new Transform("", kIdentity, "='"), 21470 new Transform("", kUppercaseAll, '"'), 21471 new Transform("", kUppercaseFirst, ". "), 21472 new Transform(" ", kIdentity, "("), 21473 new Transform("", kIdentity, "ful "), 21474 new Transform(" ", kUppercaseFirst, ". "), 21475 new Transform("", kIdentity, "ive "), 21476 new Transform("", kIdentity, "less "), 21477 new Transform("", kUppercaseAll, "'"), 21478 new Transform("", kIdentity, "est "), 21479 new Transform(" ", kUppercaseFirst, "."), 21480 new Transform("", kUppercaseAll, '">'), 21481 new Transform(" ", kIdentity, "='"), 21482 new Transform("", kUppercaseFirst, ","), 21483 new Transform("", kIdentity, "ize "), 21484 new Transform("", kUppercaseAll, "."), 21485 new Transform("\xC2\xA0", kIdentity, ""), 21486 new Transform(" ", kIdentity, ","), 21487 new Transform("", kUppercaseFirst, '="'), 21488 new Transform("", kUppercaseAll, '="'), 21489 new Transform("", kIdentity, "ous "), 21490 new Transform("", kUppercaseAll, ", "), 21491 new Transform("", kUppercaseFirst, "='"), 21492 new Transform(" ", kUppercaseFirst, ","), 21493 new Transform(" ", kUppercaseAll, '="'), 21494 new Transform(" ", kUppercaseAll, ", "), 21495 new Transform("", kUppercaseAll, ","), 21496 new Transform("", kUppercaseAll, "("), 21497 new Transform("", kUppercaseAll, ". "), 21498 new Transform(" ", kUppercaseAll, "."), 21499 new Transform("", kUppercaseAll, "='"), 21500 new Transform(" ", kUppercaseAll, ". "), 21501 new Transform(" ", kUppercaseFirst, '="'), 21502 new Transform(" ", kUppercaseAll, "='"), 21503 new Transform(" ", kUppercaseFirst, "='") 21504 ]; 21505 exports3.kTransforms = kTransforms; 21506 exports3.kNumTransforms = kTransforms.length; 21507 function ToUpperCase(p4, i3) { 21508 if (p4[i3] < 192) { 21509 if (p4[i3] >= 97 && p4[i3] <= 122) { 21510 p4[i3] ^= 32; 21511 } 21512 return 1; 21513 } 21514 if (p4[i3] < 224) { 21515 p4[i3 + 1] ^= 32; 21516 return 2; 21517 } 21518 p4[i3 + 2] ^= 5; 21519 return 3; 21520 } 21521 exports3.transformDictionaryWord = function(dst, idx, word, len, transform) { 21522 var prefix = kTransforms[transform].prefix; 21523 var suffix = kTransforms[transform].suffix; 21524 var t4 = kTransforms[transform].transform; 21525 var skip = t4 < kOmitFirst1 ? 0 : t4 - (kOmitFirst1 - 1); 21526 var i3 = 0; 21527 var start_idx = idx; 21528 var uppercase; 21529 if (skip > len) { 21530 skip = len; 21531 } 21532 var prefix_pos = 0; 21533 while (prefix_pos < prefix.length) { 21534 dst[idx++] = prefix[prefix_pos++]; 21535 } 21536 word += skip; 21537 len -= skip; 21538 if (t4 <= kOmitLast9) { 21539 len -= t4; 21540 } 21541 for (i3 = 0; i3 < len; i3++) { 21542 dst[idx++] = BrotliDictionary.dictionary[word + i3]; 21543 } 21544 uppercase = idx - len; 21545 if (t4 === kUppercaseFirst) { 21546 ToUpperCase(dst, uppercase); 21547 } else if (t4 === kUppercaseAll) { 21548 while (len > 0) { 21549 var step = ToUpperCase(dst, uppercase); 21550 uppercase += step; 21551 len -= step; 21552 } 21553 } 21554 var suffix_pos = 0; 21555 while (suffix_pos < suffix.length) { 21556 dst[idx++] = suffix[suffix_pos++]; 21557 } 21558 return idx - start_idx; 21559 }; 21560 }, 21561 { "./dictionary": 6 } 21562 ], 21563 12: [ 21564 function(require2, module3, exports3) { 21565 module3.exports = require2("./dec/decode").BrotliDecompressBuffer; 21566 }, 21567 { "./dec/decode": 3 } 21568 ] 21569 }, 21570 {}, 21571 [12] 21572 )(12); 21573 }); 21574 } 21575 }); 21576 var unbrotli_default = require_unbrotli(); 21577 21578 // packages/global-styles-ui/build-module/font-library/lib/inflate.js 21579 var __getOwnPropNames3 = Object.getOwnPropertyNames; 21580 var __require3 = /* @__PURE__ */ ((x2) => typeof __require !== "undefined" ? __require : typeof Proxy !== "undefined" ? new Proxy(x2, { 21581 get: (a3, b3) => (typeof __require !== "undefined" ? __require : a3)[b3] 21582 }) : x2)(function(x2) { 21583 if (typeof __require !== "undefined") return __require.apply(this, arguments); 21584 throw Error('Dynamic require of "' + x2 + '" is not supported'); 21585 }); 21586 var __commonJS3 = (cb, mod) => function __require22() { 21587 return mod || (0, cb[__getOwnPropNames3(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; 21588 }; 21589 var require_inflate = __commonJS3({ 21590 "packages/global-styles-ui/src/font-library/lib/inflate.js"(exports, module) { 21591 (function(f3) { 21592 if (typeof exports === "object" && typeof module !== "undefined") { 21593 module.exports = f3(); 21594 } else if (typeof define === "function" && define.amd) { 21595 define([], f3); 21596 } else { 21597 var g3; 21598 if (typeof window !== "undefined") { 21599 g3 = window; 21600 } else if (typeof global !== "undefined") { 21601 g3 = global; 21602 } else if (typeof self !== "undefined") { 21603 g3 = self; 21604 } else { 21605 g3 = this; 21606 } 21607 g3.pako = f3(); 21608 } 21609 })(function() { 21610 var define2, module2, exports2; 21611 return (/* @__PURE__ */ (function() { 21612 function r4(e3, n3, t4) { 21613 function o4(i22, f3) { 21614 if (!n3[i22]) { 21615 if (!e3[i22]) { 21616 var c2 = "function" == typeof __require3 && __require3; 21617 if (!f3 && c2) return c2(i22, true); 21618 if (u3) return u3(i22, true); 21619 var a3 = new Error("Cannot find module '" + i22 + "'"); 21620 throw a3.code = "MODULE_NOT_FOUND", a3; 21621 } 21622 var p4 = n3[i22] = { exports: {} }; 21623 e3[i22][0].call( 21624 p4.exports, 21625 function(r22) { 21626 var n22 = e3[i22][1][r22]; 21627 return o4(n22 || r22); 21628 }, 21629 p4, 21630 p4.exports, 21631 r4, 21632 e3, 21633 n3, 21634 t4 21635 ); 21636 } 21637 return n3[i22].exports; 21638 } 21639 for (var u3 = "function" == typeof __require3 && __require3, i3 = 0; i3 < t4.length; i3++) 21640 o4(t4[i3]); 21641 return o4; 21642 } 21643 return r4; 21644 })())( 21645 { 21646 1: [ 21647 function(require2, module3, exports3) { 21648 "use strict"; 21649 var TYPED_OK = typeof Uint8Array !== "undefined" && typeof Uint16Array !== "undefined" && typeof Int32Array !== "undefined"; 21650 function _has(obj, key) { 21651 return Object.prototype.hasOwnProperty.call(obj, key); 21652 } 21653 exports3.assign = function(obj) { 21654 var sources = Array.prototype.slice.call( 21655 arguments, 21656 1 21657 ); 21658 while (sources.length) { 21659 var source = sources.shift(); 21660 if (!source) { 21661 continue; 21662 } 21663 if (typeof source !== "object") { 21664 throw new TypeError( 21665 source + "must be non-object" 21666 ); 21667 } 21668 for (var p4 in source) { 21669 if (_has(source, p4)) { 21670 obj[p4] = source[p4]; 21671 } 21672 } 21673 } 21674 return obj; 21675 }; 21676 exports3.shrinkBuf = function(buf, size3) { 21677 if (buf.length === size3) { 21678 return buf; 21679 } 21680 if (buf.subarray) { 21681 return buf.subarray(0, size3); 21682 } 21683 buf.length = size3; 21684 return buf; 21685 }; 21686 var fnTyped = { 21687 arraySet: function(dest, src, src_offs, len, dest_offs) { 21688 if (src.subarray && dest.subarray) { 21689 dest.set( 21690 src.subarray(src_offs, src_offs + len), 21691 dest_offs 21692 ); 21693 return; 21694 } 21695 for (var i3 = 0; i3 < len; i3++) { 21696 dest[dest_offs + i3] = src[src_offs + i3]; 21697 } 21698 }, 21699 // Join array of chunks to single array. 21700 flattenChunks: function(chunks) { 21701 var i3, l3, len, pos, chunk, result; 21702 len = 0; 21703 for (i3 = 0, l3 = chunks.length; i3 < l3; i3++) { 21704 len += chunks[i3].length; 21705 } 21706 result = new Uint8Array(len); 21707 pos = 0; 21708 for (i3 = 0, l3 = chunks.length; i3 < l3; i3++) { 21709 chunk = chunks[i3]; 21710 result.set(chunk, pos); 21711 pos += chunk.length; 21712 } 21713 return result; 21714 } 21715 }; 21716 var fnUntyped = { 21717 arraySet: function(dest, src, src_offs, len, dest_offs) { 21718 for (var i3 = 0; i3 < len; i3++) { 21719 dest[dest_offs + i3] = src[src_offs + i3]; 21720 } 21721 }, 21722 // Join array of chunks to single array. 21723 flattenChunks: function(chunks) { 21724 return [].concat.apply([], chunks); 21725 } 21726 }; 21727 exports3.setTyped = function(on) { 21728 if (on) { 21729 exports3.Buf8 = Uint8Array; 21730 exports3.Buf16 = Uint16Array; 21731 exports3.Buf32 = Int32Array; 21732 exports3.assign(exports3, fnTyped); 21733 } else { 21734 exports3.Buf8 = Array; 21735 exports3.Buf16 = Array; 21736 exports3.Buf32 = Array; 21737 exports3.assign(exports3, fnUntyped); 21738 } 21739 }; 21740 exports3.setTyped(TYPED_OK); 21741 }, 21742 {} 21743 ], 21744 2: [ 21745 function(require2, module3, exports3) { 21746 "use strict"; 21747 var utils = require2("./common"); 21748 var STR_APPLY_OK = true; 21749 var STR_APPLY_UIA_OK = true; 21750 try { 21751 String.fromCharCode.apply(null, [0]); 21752 } catch (__218) { 21753 STR_APPLY_OK = false; 21754 } 21755 try { 21756 String.fromCharCode.apply(null, new Uint8Array(1)); 21757 } catch (__218) { 21758 STR_APPLY_UIA_OK = false; 21759 } 21760 var _utf8len = new utils.Buf8(256); 21761 for (var q = 0; q < 256; q++) { 21762 _utf8len[q] = q >= 252 ? 6 : q >= 248 ? 5 : q >= 240 ? 4 : q >= 224 ? 3 : q >= 192 ? 2 : 1; 21763 } 21764 _utf8len[254] = _utf8len[254] = 1; 21765 exports3.string2buf = function(str) { 21766 var buf, c2, c22, m_pos, i3, str_len = str.length, buf_len = 0; 21767 for (m_pos = 0; m_pos < str_len; m_pos++) { 21768 c2 = str.charCodeAt(m_pos); 21769 if ((c2 & 64512) === 55296 && m_pos + 1 < str_len) { 21770 c22 = str.charCodeAt(m_pos + 1); 21771 if ((c22 & 64512) === 56320) { 21772 c2 = 65536 + (c2 - 55296 << 10) + (c22 - 56320); 21773 m_pos++; 21774 } 21775 } 21776 buf_len += c2 < 128 ? 1 : c2 < 2048 ? 2 : c2 < 65536 ? 3 : 4; 21777 } 21778 buf = new utils.Buf8(buf_len); 21779 for (i3 = 0, m_pos = 0; i3 < buf_len; m_pos++) { 21780 c2 = str.charCodeAt(m_pos); 21781 if ((c2 & 64512) === 55296 && m_pos + 1 < str_len) { 21782 c22 = str.charCodeAt(m_pos + 1); 21783 if ((c22 & 64512) === 56320) { 21784 c2 = 65536 + (c2 - 55296 << 10) + (c22 - 56320); 21785 m_pos++; 21786 } 21787 } 21788 if (c2 < 128) { 21789 buf[i3++] = c2; 21790 } else if (c2 < 2048) { 21791 buf[i3++] = 192 | c2 >>> 6; 21792 buf[i3++] = 128 | c2 & 63; 21793 } else if (c2 < 65536) { 21794 buf[i3++] = 224 | c2 >>> 12; 21795 buf[i3++] = 128 | c2 >>> 6 & 63; 21796 buf[i3++] = 128 | c2 & 63; 21797 } else { 21798 buf[i3++] = 240 | c2 >>> 18; 21799 buf[i3++] = 128 | c2 >>> 12 & 63; 21800 buf[i3++] = 128 | c2 >>> 6 & 63; 21801 buf[i3++] = 128 | c2 & 63; 21802 } 21803 } 21804 return buf; 21805 }; 21806 function buf2binstring(buf, len) { 21807 if (len < 65534) { 21808 if (buf.subarray && STR_APPLY_UIA_OK || !buf.subarray && STR_APPLY_OK) { 21809 return String.fromCharCode.apply( 21810 null, 21811 utils.shrinkBuf(buf, len) 21812 ); 21813 } 21814 } 21815 var result = ""; 21816 for (var i3 = 0; i3 < len; i3++) { 21817 result += String.fromCharCode(buf[i3]); 21818 } 21819 return result; 21820 } 21821 exports3.buf2binstring = function(buf) { 21822 return buf2binstring(buf, buf.length); 21823 }; 21824 exports3.binstring2buf = function(str) { 21825 var buf = new utils.Buf8(str.length); 21826 for (var i3 = 0, len = buf.length; i3 < len; i3++) { 21827 buf[i3] = str.charCodeAt(i3); 21828 } 21829 return buf; 21830 }; 21831 exports3.buf2string = function(buf, max2) { 21832 var i3, out, c2, c_len; 21833 var len = max2 || buf.length; 21834 var utf16buf = new Array(len * 2); 21835 for (out = 0, i3 = 0; i3 < len; ) { 21836 c2 = buf[i3++]; 21837 if (c2 < 128) { 21838 utf16buf[out++] = c2; 21839 continue; 21840 } 21841 c_len = _utf8len[c2]; 21842 if (c_len > 4) { 21843 utf16buf[out++] = 65533; 21844 i3 += c_len - 1; 21845 continue; 21846 } 21847 c2 &= c_len === 2 ? 31 : c_len === 3 ? 15 : 7; 21848 while (c_len > 1 && i3 < len) { 21849 c2 = c2 << 6 | buf[i3++] & 63; 21850 c_len--; 21851 } 21852 if (c_len > 1) { 21853 utf16buf[out++] = 65533; 21854 continue; 21855 } 21856 if (c2 < 65536) { 21857 utf16buf[out++] = c2; 21858 } else { 21859 c2 -= 65536; 21860 utf16buf[out++] = 55296 | c2 >> 10 & 1023; 21861 utf16buf[out++] = 56320 | c2 & 1023; 21862 } 21863 } 21864 return buf2binstring(utf16buf, out); 21865 }; 21866 exports3.utf8border = function(buf, max2) { 21867 var pos; 21868 max2 = max2 || buf.length; 21869 if (max2 > buf.length) { 21870 max2 = buf.length; 21871 } 21872 pos = max2 - 1; 21873 while (pos >= 0 && (buf[pos] & 192) === 128) { 21874 pos--; 21875 } 21876 if (pos < 0) { 21877 return max2; 21878 } 21879 if (pos === 0) { 21880 return max2; 21881 } 21882 return pos + _utf8len[buf[pos]] > max2 ? pos : max2; 21883 }; 21884 }, 21885 { "./common": 1 } 21886 ], 21887 3: [ 21888 function(require2, module3, exports3) { 21889 "use strict"; 21890 function adler32(adler, buf, len, pos) { 21891 var s1 = adler & 65535 | 0, s22 = adler >>> 16 & 65535 | 0, n3 = 0; 21892 while (len !== 0) { 21893 n3 = len > 2e3 ? 2e3 : len; 21894 len -= n3; 21895 do { 21896 s1 = s1 + buf[pos++] | 0; 21897 s22 = s22 + s1 | 0; 21898 } while (--n3); 21899 s1 %= 65521; 21900 s22 %= 65521; 21901 } 21902 return s1 | s22 << 16 | 0; 21903 } 21904 module3.exports = adler32; 21905 }, 21906 {} 21907 ], 21908 4: [ 21909 function(require2, module3, exports3) { 21910 "use strict"; 21911 module3.exports = { 21912 /* Allowed flush values; see deflate() and inflate() below for details */ 21913 Z_NO_FLUSH: 0, 21914 Z_PARTIAL_FLUSH: 1, 21915 Z_SYNC_FLUSH: 2, 21916 Z_FULL_FLUSH: 3, 21917 Z_FINISH: 4, 21918 Z_BLOCK: 5, 21919 Z_TREES: 6, 21920 /* Return codes for the compression/decompression functions. Negative values 21921 * are errors, positive values are used for special but normal events. 21922 */ 21923 Z_OK: 0, 21924 Z_STREAM_END: 1, 21925 Z_NEED_DICT: 2, 21926 Z_ERRNO: -1, 21927 Z_STREAM_ERROR: -2, 21928 Z_DATA_ERROR: -3, 21929 //Z_MEM_ERROR: -4, 21930 Z_BUF_ERROR: -5, 21931 //Z_VERSION_ERROR: -6, 21932 /* compression levels */ 21933 Z_NO_COMPRESSION: 0, 21934 Z_BEST_SPEED: 1, 21935 Z_BEST_COMPRESSION: 9, 21936 Z_DEFAULT_COMPRESSION: -1, 21937 Z_FILTERED: 1, 21938 Z_HUFFMAN_ONLY: 2, 21939 Z_RLE: 3, 21940 Z_FIXED: 4, 21941 Z_DEFAULT_STRATEGY: 0, 21942 /* Possible values of the data_type field (though see inflate()) */ 21943 Z_BINARY: 0, 21944 Z_TEXT: 1, 21945 //Z_ASCII: 1, // = Z_TEXT (deprecated) 21946 Z_UNKNOWN: 2, 21947 /* The deflate compression method */ 21948 Z_DEFLATED: 8 21949 //Z_NULL: null // Use -1 or null inline, depending on var type 21950 }; 21951 }, 21952 {} 21953 ], 21954 5: [ 21955 function(require2, module3, exports3) { 21956 "use strict"; 21957 function makeTable() { 21958 var c2, table = []; 21959 for (var n3 = 0; n3 < 256; n3++) { 21960 c2 = n3; 21961 for (var k2 = 0; k2 < 8; k2++) { 21962 c2 = c2 & 1 ? 3988292384 ^ c2 >>> 1 : c2 >>> 1; 21963 } 21964 table[n3] = c2; 21965 } 21966 return table; 21967 } 21968 var crcTable = makeTable(); 21969 function crc32(crc, buf, len, pos) { 21970 var t4 = crcTable, end = pos + len; 21971 crc ^= -1; 21972 for (var i3 = pos; i3 < end; i3++) { 21973 crc = crc >>> 8 ^ t4[(crc ^ buf[i3]) & 255]; 21974 } 21975 return crc ^ -1; 21976 } 21977 module3.exports = crc32; 21978 }, 21979 {} 21980 ], 21981 6: [ 21982 function(require2, module3, exports3) { 21983 "use strict"; 21984 function GZheader() { 21985 this.text = 0; 21986 this.time = 0; 21987 this.xflags = 0; 21988 this.os = 0; 21989 this.extra = null; 21990 this.extra_len = 0; 21991 this.name = ""; 21992 this.comment = ""; 21993 this.hcrc = 0; 21994 this.done = false; 21995 } 21996 module3.exports = GZheader; 21997 }, 21998 {} 21999 ], 22000 7: [ 22001 function(require2, module3, exports3) { 22002 "use strict"; 22003 var BAD = 30; 22004 var TYPE = 12; 22005 module3.exports = function inflate_fast(strm, start) { 22006 var state; 22007 var _in; 22008 var last; 22009 var _out; 22010 var beg; 22011 var end; 22012 var dmax; 22013 var wsize; 22014 var whave; 22015 var wnext; 22016 var s_window; 22017 var hold; 22018 var bits; 22019 var lcode; 22020 var dcode; 22021 var lmask; 22022 var dmask; 22023 var here; 22024 var op; 22025 var len; 22026 var dist; 22027 var from; 22028 var from_source; 22029 var input, output; 22030 state = strm.state; 22031 _in = strm.next_in; 22032 input = strm.input; 22033 last = _in + (strm.avail_in - 5); 22034 _out = strm.next_out; 22035 output = strm.output; 22036 beg = _out - (start - strm.avail_out); 22037 end = _out + (strm.avail_out - 257); 22038 dmax = state.dmax; 22039 wsize = state.wsize; 22040 whave = state.whave; 22041 wnext = state.wnext; 22042 s_window = state.window; 22043 hold = state.hold; 22044 bits = state.bits; 22045 lcode = state.lencode; 22046 dcode = state.distcode; 22047 lmask = (1 << state.lenbits) - 1; 22048 dmask = (1 << state.distbits) - 1; 22049 top: do { 22050 if (bits < 15) { 22051 hold += input[_in++] << bits; 22052 bits += 8; 22053 hold += input[_in++] << bits; 22054 bits += 8; 22055 } 22056 here = lcode[hold & lmask]; 22057 dolen: for (; ; ) { 22058 op = here >>> 24; 22059 hold >>>= op; 22060 bits -= op; 22061 op = here >>> 16 & 255; 22062 if (op === 0) { 22063 output[_out++] = here & 65535; 22064 } else if (op & 16) { 22065 len = here & 65535; 22066 op &= 15; 22067 if (op) { 22068 if (bits < op) { 22069 hold += input[_in++] << bits; 22070 bits += 8; 22071 } 22072 len += hold & (1 << op) - 1; 22073 hold >>>= op; 22074 bits -= op; 22075 } 22076 if (bits < 15) { 22077 hold += input[_in++] << bits; 22078 bits += 8; 22079 hold += input[_in++] << bits; 22080 bits += 8; 22081 } 22082 here = dcode[hold & dmask]; 22083 dodist: for (; ; ) { 22084 op = here >>> 24; 22085 hold >>>= op; 22086 bits -= op; 22087 op = here >>> 16 & 255; 22088 if (op & 16) { 22089 dist = here & 65535; 22090 op &= 15; 22091 if (bits < op) { 22092 hold += input[_in++] << bits; 22093 bits += 8; 22094 if (bits < op) { 22095 hold += input[_in++] << bits; 22096 bits += 8; 22097 } 22098 } 22099 dist += hold & (1 << op) - 1; 22100 if (dist > dmax) { 22101 strm.msg = "invalid distance too far back"; 22102 state.mode = BAD; 22103 break top; 22104 } 22105 hold >>>= op; 22106 bits -= op; 22107 op = _out - beg; 22108 if (dist > op) { 22109 op = dist - op; 22110 if (op > whave) { 22111 if (state.sane) { 22112 strm.msg = "invalid distance too far back"; 22113 state.mode = BAD; 22114 break top; 22115 } 22116 } 22117 from = 0; 22118 from_source = s_window; 22119 if (wnext === 0) { 22120 from += wsize - op; 22121 if (op < len) { 22122 len -= op; 22123 do { 22124 output[_out++] = s_window[from++]; 22125 } while (--op); 22126 from = _out - dist; 22127 from_source = output; 22128 } 22129 } else if (wnext < op) { 22130 from += wsize + wnext - op; 22131 op -= wnext; 22132 if (op < len) { 22133 len -= op; 22134 do { 22135 output[_out++] = s_window[from++]; 22136 } while (--op); 22137 from = 0; 22138 if (wnext < len) { 22139 op = wnext; 22140 len -= op; 22141 do { 22142 output[_out++] = s_window[from++]; 22143 } while (--op); 22144 from = _out - dist; 22145 from_source = output; 22146 } 22147 } 22148 } else { 22149 from += wnext - op; 22150 if (op < len) { 22151 len -= op; 22152 do { 22153 output[_out++] = s_window[from++]; 22154 } while (--op); 22155 from = _out - dist; 22156 from_source = output; 22157 } 22158 } 22159 while (len > 2) { 22160 output[_out++] = from_source[from++]; 22161 output[_out++] = from_source[from++]; 22162 output[_out++] = from_source[from++]; 22163 len -= 3; 22164 } 22165 if (len) { 22166 output[_out++] = from_source[from++]; 22167 if (len > 1) { 22168 output[_out++] = from_source[from++]; 22169 } 22170 } 22171 } else { 22172 from = _out - dist; 22173 do { 22174 output[_out++] = output[from++]; 22175 output[_out++] = output[from++]; 22176 output[_out++] = output[from++]; 22177 len -= 3; 22178 } while (len > 2); 22179 if (len) { 22180 output[_out++] = output[from++]; 22181 if (len > 1) { 22182 output[_out++] = output[from++]; 22183 } 22184 } 22185 } 22186 } else if ((op & 64) === 0) { 22187 here = dcode[(here & 65535) + (hold & (1 << op) - 1)]; 22188 continue dodist; 22189 } else { 22190 strm.msg = "invalid distance code"; 22191 state.mode = BAD; 22192 break top; 22193 } 22194 break; 22195 } 22196 } else if ((op & 64) === 0) { 22197 here = lcode[(here & 65535) + (hold & (1 << op) - 1)]; 22198 continue dolen; 22199 } else if (op & 32) { 22200 state.mode = TYPE; 22201 break top; 22202 } else { 22203 strm.msg = "invalid literal/length code"; 22204 state.mode = BAD; 22205 break top; 22206 } 22207 break; 22208 } 22209 } while (_in < last && _out < end); 22210 len = bits >> 3; 22211 _in -= len; 22212 bits -= len << 3; 22213 hold &= (1 << bits) - 1; 22214 strm.next_in = _in; 22215 strm.next_out = _out; 22216 strm.avail_in = _in < last ? 5 + (last - _in) : 5 - (_in - last); 22217 strm.avail_out = _out < end ? 257 + (end - _out) : 257 - (_out - end); 22218 state.hold = hold; 22219 state.bits = bits; 22220 return; 22221 }; 22222 }, 22223 {} 22224 ], 22225 8: [ 22226 function(require2, module3, exports3) { 22227 "use strict"; 22228 var utils = require2("../utils/common"); 22229 var adler32 = require2("./adler32"); 22230 var crc32 = require2("./crc32"); 22231 var inflate_fast = require2("./inffast"); 22232 var inflate_table = require2("./inftrees"); 22233 var CODES = 0; 22234 var LENS = 1; 22235 var DISTS = 2; 22236 var Z_FINISH = 4; 22237 var Z_BLOCK = 5; 22238 var Z_TREES = 6; 22239 var Z_OK = 0; 22240 var Z_STREAM_END = 1; 22241 var Z_NEED_DICT = 2; 22242 var Z_STREAM_ERROR = -2; 22243 var Z_DATA_ERROR = -3; 22244 var Z_MEM_ERROR = -4; 22245 var Z_BUF_ERROR = -5; 22246 var Z_DEFLATED = 8; 22247 var HEAD = 1; 22248 var FLAGS = 2; 22249 var TIME = 3; 22250 var OS = 4; 22251 var EXLEN = 5; 22252 var EXTRA = 6; 22253 var NAME = 7; 22254 var COMMENT = 8; 22255 var HCRC = 9; 22256 var DICTID = 10; 22257 var DICT = 11; 22258 var TYPE = 12; 22259 var TYPEDO = 13; 22260 var STORED = 14; 22261 var COPY_ = 15; 22262 var COPY = 16; 22263 var TABLE = 17; 22264 var LENLENS = 18; 22265 var CODELENS = 19; 22266 var LEN_ = 20; 22267 var LEN = 21; 22268 var LENEXT = 22; 22269 var DIST = 23; 22270 var DISTEXT = 24; 22271 var MATCH = 25; 22272 var LIT = 26; 22273 var CHECK = 27; 22274 var LENGTH = 28; 22275 var DONE = 29; 22276 var BAD = 30; 22277 var MEM = 31; 22278 var SYNC = 32; 22279 var ENOUGH_LENS = 852; 22280 var ENOUGH_DISTS = 592; 22281 var MAX_WBITS = 15; 22282 var DEF_WBITS = MAX_WBITS; 22283 function zswap32(q) { 22284 return (q >>> 24 & 255) + (q >>> 8 & 65280) + ((q & 65280) << 8) + ((q & 255) << 24); 22285 } 22286 function InflateState() { 22287 this.mode = 0; 22288 this.last = false; 22289 this.wrap = 0; 22290 this.havedict = false; 22291 this.flags = 0; 22292 this.dmax = 0; 22293 this.check = 0; 22294 this.total = 0; 22295 this.head = null; 22296 this.wbits = 0; 22297 this.wsize = 0; 22298 this.whave = 0; 22299 this.wnext = 0; 22300 this.window = null; 22301 this.hold = 0; 22302 this.bits = 0; 22303 this.length = 0; 22304 this.offset = 0; 22305 this.extra = 0; 22306 this.lencode = null; 22307 this.distcode = null; 22308 this.lenbits = 0; 22309 this.distbits = 0; 22310 this.ncode = 0; 22311 this.nlen = 0; 22312 this.ndist = 0; 22313 this.have = 0; 22314 this.next = null; 22315 this.lens = new utils.Buf16( 22316 320 22317 ); 22318 this.work = new utils.Buf16( 22319 288 22320 ); 22321 this.lendyn = null; 22322 this.distdyn = null; 22323 this.sane = 0; 22324 this.back = 0; 22325 this.was = 0; 22326 } 22327 function inflateResetKeep(strm) { 22328 var state; 22329 if (!strm || !strm.state) { 22330 return Z_STREAM_ERROR; 22331 } 22332 state = strm.state; 22333 strm.total_in = strm.total_out = state.total = 0; 22334 strm.msg = ""; 22335 if (state.wrap) { 22336 strm.adler = state.wrap & 1; 22337 } 22338 state.mode = HEAD; 22339 state.last = 0; 22340 state.havedict = 0; 22341 state.dmax = 32768; 22342 state.head = null; 22343 state.hold = 0; 22344 state.bits = 0; 22345 state.lencode = state.lendyn = new utils.Buf32( 22346 ENOUGH_LENS 22347 ); 22348 state.distcode = state.distdyn = new utils.Buf32( 22349 ENOUGH_DISTS 22350 ); 22351 state.sane = 1; 22352 state.back = -1; 22353 return Z_OK; 22354 } 22355 function inflateReset(strm) { 22356 var state; 22357 if (!strm || !strm.state) { 22358 return Z_STREAM_ERROR; 22359 } 22360 state = strm.state; 22361 state.wsize = 0; 22362 state.whave = 0; 22363 state.wnext = 0; 22364 return inflateResetKeep(strm); 22365 } 22366 function inflateReset2(strm, windowBits) { 22367 var wrap; 22368 var state; 22369 if (!strm || !strm.state) { 22370 return Z_STREAM_ERROR; 22371 } 22372 state = strm.state; 22373 if (windowBits < 0) { 22374 wrap = 0; 22375 windowBits = -windowBits; 22376 } else { 22377 wrap = (windowBits >> 4) + 1; 22378 if (windowBits < 48) { 22379 windowBits &= 15; 22380 } 22381 } 22382 if (windowBits && (windowBits < 8 || windowBits > 15)) { 22383 return Z_STREAM_ERROR; 22384 } 22385 if (state.window !== null && state.wbits !== windowBits) { 22386 state.window = null; 22387 } 22388 state.wrap = wrap; 22389 state.wbits = windowBits; 22390 return inflateReset(strm); 22391 } 22392 function inflateInit2(strm, windowBits) { 22393 var ret; 22394 var state; 22395 if (!strm) { 22396 return Z_STREAM_ERROR; 22397 } 22398 state = new InflateState(); 22399 strm.state = state; 22400 state.window = null; 22401 ret = inflateReset2(strm, windowBits); 22402 if (ret !== Z_OK) { 22403 strm.state = null; 22404 } 22405 return ret; 22406 } 22407 function inflateInit(strm) { 22408 return inflateInit2(strm, DEF_WBITS); 22409 } 22410 var virgin = true; 22411 var lenfix, distfix; 22412 function fixedtables(state) { 22413 if (virgin) { 22414 var sym; 22415 lenfix = new utils.Buf32(512); 22416 distfix = new utils.Buf32(32); 22417 sym = 0; 22418 while (sym < 144) { 22419 state.lens[sym++] = 8; 22420 } 22421 while (sym < 256) { 22422 state.lens[sym++] = 9; 22423 } 22424 while (sym < 280) { 22425 state.lens[sym++] = 7; 22426 } 22427 while (sym < 288) { 22428 state.lens[sym++] = 8; 22429 } 22430 inflate_table( 22431 LENS, 22432 state.lens, 22433 0, 22434 288, 22435 lenfix, 22436 0, 22437 state.work, 22438 { bits: 9 } 22439 ); 22440 sym = 0; 22441 while (sym < 32) { 22442 state.lens[sym++] = 5; 22443 } 22444 inflate_table( 22445 DISTS, 22446 state.lens, 22447 0, 22448 32, 22449 distfix, 22450 0, 22451 state.work, 22452 { bits: 5 } 22453 ); 22454 virgin = false; 22455 } 22456 state.lencode = lenfix; 22457 state.lenbits = 9; 22458 state.distcode = distfix; 22459 state.distbits = 5; 22460 } 22461 function updatewindow(strm, src, end, copy) { 22462 var dist; 22463 var state = strm.state; 22464 if (state.window === null) { 22465 state.wsize = 1 << state.wbits; 22466 state.wnext = 0; 22467 state.whave = 0; 22468 state.window = new utils.Buf8(state.wsize); 22469 } 22470 if (copy >= state.wsize) { 22471 utils.arraySet( 22472 state.window, 22473 src, 22474 end - state.wsize, 22475 state.wsize, 22476 0 22477 ); 22478 state.wnext = 0; 22479 state.whave = state.wsize; 22480 } else { 22481 dist = state.wsize - state.wnext; 22482 if (dist > copy) { 22483 dist = copy; 22484 } 22485 utils.arraySet( 22486 state.window, 22487 src, 22488 end - copy, 22489 dist, 22490 state.wnext 22491 ); 22492 copy -= dist; 22493 if (copy) { 22494 utils.arraySet( 22495 state.window, 22496 src, 22497 end - copy, 22498 copy, 22499 0 22500 ); 22501 state.wnext = copy; 22502 state.whave = state.wsize; 22503 } else { 22504 state.wnext += dist; 22505 if (state.wnext === state.wsize) { 22506 state.wnext = 0; 22507 } 22508 if (state.whave < state.wsize) { 22509 state.whave += dist; 22510 } 22511 } 22512 } 22513 return 0; 22514 } 22515 function inflate(strm, flush) { 22516 var state; 22517 var input, output; 22518 var next; 22519 var put; 22520 var have, left; 22521 var hold; 22522 var bits; 22523 var _in, _out; 22524 var copy; 22525 var from; 22526 var from_source; 22527 var here = 0; 22528 var here_bits, here_op, here_val; 22529 var last_bits, last_op, last_val; 22530 var len; 22531 var ret; 22532 var hbuf = new utils.Buf8( 22533 4 22534 ); 22535 var opts; 22536 var n3; 22537 var order = ( 22538 /* permutation of code lengths */ 22539 [ 22540 16, 22541 17, 22542 18, 22543 0, 22544 8, 22545 7, 22546 9, 22547 6, 22548 10, 22549 5, 22550 11, 22551 4, 22552 12, 22553 3, 22554 13, 22555 2, 22556 14, 22557 1, 22558 15 22559 ] 22560 ); 22561 if (!strm || !strm.state || !strm.output || !strm.input && strm.avail_in !== 0) { 22562 return Z_STREAM_ERROR; 22563 } 22564 state = strm.state; 22565 if (state.mode === TYPE) { 22566 state.mode = TYPEDO; 22567 } 22568 put = strm.next_out; 22569 output = strm.output; 22570 left = strm.avail_out; 22571 next = strm.next_in; 22572 input = strm.input; 22573 have = strm.avail_in; 22574 hold = state.hold; 22575 bits = state.bits; 22576 _in = have; 22577 _out = left; 22578 ret = Z_OK; 22579 inf_leave: for (; ; ) { 22580 switch (state.mode) { 22581 case HEAD: 22582 if (state.wrap === 0) { 22583 state.mode = TYPEDO; 22584 break; 22585 } 22586 while (bits < 16) { 22587 if (have === 0) { 22588 break inf_leave; 22589 } 22590 have--; 22591 hold += input[next++] << bits; 22592 bits += 8; 22593 } 22594 if (state.wrap & 2 && hold === 35615) { 22595 state.check = 0; 22596 hbuf[0] = hold & 255; 22597 hbuf[1] = hold >>> 8 & 255; 22598 state.check = crc32( 22599 state.check, 22600 hbuf, 22601 2, 22602 0 22603 ); 22604 hold = 0; 22605 bits = 0; 22606 state.mode = FLAGS; 22607 break; 22608 } 22609 state.flags = 0; 22610 if (state.head) { 22611 state.head.done = false; 22612 } 22613 if (!(state.wrap & 1) || (((hold & 255) << 8) + (hold >> 8)) % 31) { 22614 strm.msg = "incorrect header check"; 22615 state.mode = BAD; 22616 break; 22617 } 22618 if ((hold & 15) !== Z_DEFLATED) { 22619 strm.msg = "unknown compression method"; 22620 state.mode = BAD; 22621 break; 22622 } 22623 hold >>>= 4; 22624 bits -= 4; 22625 len = (hold & 15) + 8; 22626 if (state.wbits === 0) { 22627 state.wbits = len; 22628 } else if (len > state.wbits) { 22629 strm.msg = "invalid window size"; 22630 state.mode = BAD; 22631 break; 22632 } 22633 state.dmax = 1 << len; 22634 strm.adler = state.check = 1; 22635 state.mode = hold & 512 ? DICTID : TYPE; 22636 hold = 0; 22637 bits = 0; 22638 break; 22639 case FLAGS: 22640 while (bits < 16) { 22641 if (have === 0) { 22642 break inf_leave; 22643 } 22644 have--; 22645 hold += input[next++] << bits; 22646 bits += 8; 22647 } 22648 state.flags = hold; 22649 if ((state.flags & 255) !== Z_DEFLATED) { 22650 strm.msg = "unknown compression method"; 22651 state.mode = BAD; 22652 break; 22653 } 22654 if (state.flags & 57344) { 22655 strm.msg = "unknown header flags set"; 22656 state.mode = BAD; 22657 break; 22658 } 22659 if (state.head) { 22660 state.head.text = hold >> 8 & 1; 22661 } 22662 if (state.flags & 512) { 22663 hbuf[0] = hold & 255; 22664 hbuf[1] = hold >>> 8 & 255; 22665 state.check = crc32( 22666 state.check, 22667 hbuf, 22668 2, 22669 0 22670 ); 22671 } 22672 hold = 0; 22673 bits = 0; 22674 state.mode = TIME; 22675 /* falls through */ 22676 case TIME: 22677 while (bits < 32) { 22678 if (have === 0) { 22679 break inf_leave; 22680 } 22681 have--; 22682 hold += input[next++] << bits; 22683 bits += 8; 22684 } 22685 if (state.head) { 22686 state.head.time = hold; 22687 } 22688 if (state.flags & 512) { 22689 hbuf[0] = hold & 255; 22690 hbuf[1] = hold >>> 8 & 255; 22691 hbuf[2] = hold >>> 16 & 255; 22692 hbuf[3] = hold >>> 24 & 255; 22693 state.check = crc32( 22694 state.check, 22695 hbuf, 22696 4, 22697 0 22698 ); 22699 } 22700 hold = 0; 22701 bits = 0; 22702 state.mode = OS; 22703 /* falls through */ 22704 case OS: 22705 while (bits < 16) { 22706 if (have === 0) { 22707 break inf_leave; 22708 } 22709 have--; 22710 hold += input[next++] << bits; 22711 bits += 8; 22712 } 22713 if (state.head) { 22714 state.head.xflags = hold & 255; 22715 state.head.os = hold >> 8; 22716 } 22717 if (state.flags & 512) { 22718 hbuf[0] = hold & 255; 22719 hbuf[1] = hold >>> 8 & 255; 22720 state.check = crc32( 22721 state.check, 22722 hbuf, 22723 2, 22724 0 22725 ); 22726 } 22727 hold = 0; 22728 bits = 0; 22729 state.mode = EXLEN; 22730 /* falls through */ 22731 case EXLEN: 22732 if (state.flags & 1024) { 22733 while (bits < 16) { 22734 if (have === 0) { 22735 break inf_leave; 22736 } 22737 have--; 22738 hold += input[next++] << bits; 22739 bits += 8; 22740 } 22741 state.length = hold; 22742 if (state.head) { 22743 state.head.extra_len = hold; 22744 } 22745 if (state.flags & 512) { 22746 hbuf[0] = hold & 255; 22747 hbuf[1] = hold >>> 8 & 255; 22748 state.check = crc32( 22749 state.check, 22750 hbuf, 22751 2, 22752 0 22753 ); 22754 } 22755 hold = 0; 22756 bits = 0; 22757 } else if (state.head) { 22758 state.head.extra = null; 22759 } 22760 state.mode = EXTRA; 22761 /* falls through */ 22762 case EXTRA: 22763 if (state.flags & 1024) { 22764 copy = state.length; 22765 if (copy > have) { 22766 copy = have; 22767 } 22768 if (copy) { 22769 if (state.head) { 22770 len = state.head.extra_len - state.length; 22771 if (!state.head.extra) { 22772 state.head.extra = new Array( 22773 state.head.extra_len 22774 ); 22775 } 22776 utils.arraySet( 22777 state.head.extra, 22778 input, 22779 next, 22780 // extra field is limited to 65536 bytes 22781 // - no need for additional size check 22782 copy, 22783 /*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/ 22784 len 22785 ); 22786 } 22787 if (state.flags & 512) { 22788 state.check = crc32( 22789 state.check, 22790 input, 22791 copy, 22792 next 22793 ); 22794 } 22795 have -= copy; 22796 next += copy; 22797 state.length -= copy; 22798 } 22799 if (state.length) { 22800 break inf_leave; 22801 } 22802 } 22803 state.length = 0; 22804 state.mode = NAME; 22805 /* falls through */ 22806 case NAME: 22807 if (state.flags & 2048) { 22808 if (have === 0) { 22809 break inf_leave; 22810 } 22811 copy = 0; 22812 do { 22813 len = input[next + copy++]; 22814 if (state.head && len && state.length < 65536) { 22815 state.head.name += String.fromCharCode(len); 22816 } 22817 } while (len && copy < have); 22818 if (state.flags & 512) { 22819 state.check = crc32( 22820 state.check, 22821 input, 22822 copy, 22823 next 22824 ); 22825 } 22826 have -= copy; 22827 next += copy; 22828 if (len) { 22829 break inf_leave; 22830 } 22831 } else if (state.head) { 22832 state.head.name = null; 22833 } 22834 state.length = 0; 22835 state.mode = COMMENT; 22836 /* falls through */ 22837 case COMMENT: 22838 if (state.flags & 4096) { 22839 if (have === 0) { 22840 break inf_leave; 22841 } 22842 copy = 0; 22843 do { 22844 len = input[next + copy++]; 22845 if (state.head && len && state.length < 65536) { 22846 state.head.comment += String.fromCharCode(len); 22847 } 22848 } while (len && copy < have); 22849 if (state.flags & 512) { 22850 state.check = crc32( 22851 state.check, 22852 input, 22853 copy, 22854 next 22855 ); 22856 } 22857 have -= copy; 22858 next += copy; 22859 if (len) { 22860 break inf_leave; 22861 } 22862 } else if (state.head) { 22863 state.head.comment = null; 22864 } 22865 state.mode = HCRC; 22866 /* falls through */ 22867 case HCRC: 22868 if (state.flags & 512) { 22869 while (bits < 16) { 22870 if (have === 0) { 22871 break inf_leave; 22872 } 22873 have--; 22874 hold += input[next++] << bits; 22875 bits += 8; 22876 } 22877 if (hold !== (state.check & 65535)) { 22878 strm.msg = "header crc mismatch"; 22879 state.mode = BAD; 22880 break; 22881 } 22882 hold = 0; 22883 bits = 0; 22884 } 22885 if (state.head) { 22886 state.head.hcrc = state.flags >> 9 & 1; 22887 state.head.done = true; 22888 } 22889 strm.adler = state.check = 0; 22890 state.mode = TYPE; 22891 break; 22892 case DICTID: 22893 while (bits < 32) { 22894 if (have === 0) { 22895 break inf_leave; 22896 } 22897 have--; 22898 hold += input[next++] << bits; 22899 bits += 8; 22900 } 22901 strm.adler = state.check = zswap32(hold); 22902 hold = 0; 22903 bits = 0; 22904 state.mode = DICT; 22905 /* falls through */ 22906 case DICT: 22907 if (state.havedict === 0) { 22908 strm.next_out = put; 22909 strm.avail_out = left; 22910 strm.next_in = next; 22911 strm.avail_in = have; 22912 state.hold = hold; 22913 state.bits = bits; 22914 return Z_NEED_DICT; 22915 } 22916 strm.adler = state.check = 1; 22917 state.mode = TYPE; 22918 /* falls through */ 22919 case TYPE: 22920 if (flush === Z_BLOCK || flush === Z_TREES) { 22921 break inf_leave; 22922 } 22923 /* falls through */ 22924 case TYPEDO: 22925 if (state.last) { 22926 hold >>>= bits & 7; 22927 bits -= bits & 7; 22928 state.mode = CHECK; 22929 break; 22930 } 22931 while (bits < 3) { 22932 if (have === 0) { 22933 break inf_leave; 22934 } 22935 have--; 22936 hold += input[next++] << bits; 22937 bits += 8; 22938 } 22939 state.last = hold & 1; 22940 hold >>>= 1; 22941 bits -= 1; 22942 switch (hold & 3) { 22943 case 0: 22944 state.mode = STORED; 22945 break; 22946 case 1: 22947 fixedtables(state); 22948 state.mode = LEN_; 22949 if (flush === Z_TREES) { 22950 hold >>>= 2; 22951 bits -= 2; 22952 break inf_leave; 22953 } 22954 break; 22955 case 2: 22956 state.mode = TABLE; 22957 break; 22958 case 3: 22959 strm.msg = "invalid block type"; 22960 state.mode = BAD; 22961 } 22962 hold >>>= 2; 22963 bits -= 2; 22964 break; 22965 case STORED: 22966 hold >>>= bits & 7; 22967 bits -= bits & 7; 22968 while (bits < 32) { 22969 if (have === 0) { 22970 break inf_leave; 22971 } 22972 have--; 22973 hold += input[next++] << bits; 22974 bits += 8; 22975 } 22976 if ((hold & 65535) !== (hold >>> 16 ^ 65535)) { 22977 strm.msg = "invalid stored block lengths"; 22978 state.mode = BAD; 22979 break; 22980 } 22981 state.length = hold & 65535; 22982 hold = 0; 22983 bits = 0; 22984 state.mode = COPY_; 22985 if (flush === Z_TREES) { 22986 break inf_leave; 22987 } 22988 /* falls through */ 22989 case COPY_: 22990 state.mode = COPY; 22991 /* falls through */ 22992 case COPY: 22993 copy = state.length; 22994 if (copy) { 22995 if (copy > have) { 22996 copy = have; 22997 } 22998 if (copy > left) { 22999 copy = left; 23000 } 23001 if (copy === 0) { 23002 break inf_leave; 23003 } 23004 utils.arraySet( 23005 output, 23006 input, 23007 next, 23008 copy, 23009 put 23010 ); 23011 have -= copy; 23012 next += copy; 23013 left -= copy; 23014 put += copy; 23015 state.length -= copy; 23016 break; 23017 } 23018 state.mode = TYPE; 23019 break; 23020 case TABLE: 23021 while (bits < 14) { 23022 if (have === 0) { 23023 break inf_leave; 23024 } 23025 have--; 23026 hold += input[next++] << bits; 23027 bits += 8; 23028 } 23029 state.nlen = (hold & 31) + 257; 23030 hold >>>= 5; 23031 bits -= 5; 23032 state.ndist = (hold & 31) + 1; 23033 hold >>>= 5; 23034 bits -= 5; 23035 state.ncode = (hold & 15) + 4; 23036 hold >>>= 4; 23037 bits -= 4; 23038 if (state.nlen > 286 || state.ndist > 30) { 23039 strm.msg = "too many length or distance symbols"; 23040 state.mode = BAD; 23041 break; 23042 } 23043 state.have = 0; 23044 state.mode = LENLENS; 23045 /* falls through */ 23046 case LENLENS: 23047 while (state.have < state.ncode) { 23048 while (bits < 3) { 23049 if (have === 0) { 23050 break inf_leave; 23051 } 23052 have--; 23053 hold += input[next++] << bits; 23054 bits += 8; 23055 } 23056 state.lens[order[state.have++]] = hold & 7; 23057 hold >>>= 3; 23058 bits -= 3; 23059 } 23060 while (state.have < 19) { 23061 state.lens[order[state.have++]] = 0; 23062 } 23063 state.lencode = state.lendyn; 23064 state.lenbits = 7; 23065 opts = { bits: state.lenbits }; 23066 ret = inflate_table( 23067 CODES, 23068 state.lens, 23069 0, 23070 19, 23071 state.lencode, 23072 0, 23073 state.work, 23074 opts 23075 ); 23076 state.lenbits = opts.bits; 23077 if (ret) { 23078 strm.msg = "invalid code lengths set"; 23079 state.mode = BAD; 23080 break; 23081 } 23082 state.have = 0; 23083 state.mode = CODELENS; 23084 /* falls through */ 23085 case CODELENS: 23086 while (state.have < state.nlen + state.ndist) { 23087 for (; ; ) { 23088 here = state.lencode[hold & (1 << state.lenbits) - 1]; 23089 here_bits = here >>> 24; 23090 here_op = here >>> 16 & 255; 23091 here_val = here & 65535; 23092 if (here_bits <= bits) { 23093 break; 23094 } 23095 if (have === 0) { 23096 break inf_leave; 23097 } 23098 have--; 23099 hold += input[next++] << bits; 23100 bits += 8; 23101 } 23102 if (here_val < 16) { 23103 hold >>>= here_bits; 23104 bits -= here_bits; 23105 state.lens[state.have++] = here_val; 23106 } else { 23107 if (here_val === 16) { 23108 n3 = here_bits + 2; 23109 while (bits < n3) { 23110 if (have === 0) { 23111 break inf_leave; 23112 } 23113 have--; 23114 hold += input[next++] << bits; 23115 bits += 8; 23116 } 23117 hold >>>= here_bits; 23118 bits -= here_bits; 23119 if (state.have === 0) { 23120 strm.msg = "invalid bit length repeat"; 23121 state.mode = BAD; 23122 break; 23123 } 23124 len = state.lens[state.have - 1]; 23125 copy = 3 + (hold & 3); 23126 hold >>>= 2; 23127 bits -= 2; 23128 } else if (here_val === 17) { 23129 n3 = here_bits + 3; 23130 while (bits < n3) { 23131 if (have === 0) { 23132 break inf_leave; 23133 } 23134 have--; 23135 hold += input[next++] << bits; 23136 bits += 8; 23137 } 23138 hold >>>= here_bits; 23139 bits -= here_bits; 23140 len = 0; 23141 copy = 3 + (hold & 7); 23142 hold >>>= 3; 23143 bits -= 3; 23144 } else { 23145 n3 = here_bits + 7; 23146 while (bits < n3) { 23147 if (have === 0) { 23148 break inf_leave; 23149 } 23150 have--; 23151 hold += input[next++] << bits; 23152 bits += 8; 23153 } 23154 hold >>>= here_bits; 23155 bits -= here_bits; 23156 len = 0; 23157 copy = 11 + (hold & 127); 23158 hold >>>= 7; 23159 bits -= 7; 23160 } 23161 if (state.have + copy > state.nlen + state.ndist) { 23162 strm.msg = "invalid bit length repeat"; 23163 state.mode = BAD; 23164 break; 23165 } 23166 while (copy--) { 23167 state.lens[state.have++] = len; 23168 } 23169 } 23170 } 23171 if (state.mode === BAD) { 23172 break; 23173 } 23174 if (state.lens[256] === 0) { 23175 strm.msg = "invalid code -- missing end-of-block"; 23176 state.mode = BAD; 23177 break; 23178 } 23179 state.lenbits = 9; 23180 opts = { bits: state.lenbits }; 23181 ret = inflate_table( 23182 LENS, 23183 state.lens, 23184 0, 23185 state.nlen, 23186 state.lencode, 23187 0, 23188 state.work, 23189 opts 23190 ); 23191 state.lenbits = opts.bits; 23192 if (ret) { 23193 strm.msg = "invalid literal/lengths set"; 23194 state.mode = BAD; 23195 break; 23196 } 23197 state.distbits = 6; 23198 state.distcode = state.distdyn; 23199 opts = { bits: state.distbits }; 23200 ret = inflate_table( 23201 DISTS, 23202 state.lens, 23203 state.nlen, 23204 state.ndist, 23205 state.distcode, 23206 0, 23207 state.work, 23208 opts 23209 ); 23210 state.distbits = opts.bits; 23211 if (ret) { 23212 strm.msg = "invalid distances set"; 23213 state.mode = BAD; 23214 break; 23215 } 23216 state.mode = LEN_; 23217 if (flush === Z_TREES) { 23218 break inf_leave; 23219 } 23220 /* falls through */ 23221 case LEN_: 23222 state.mode = LEN; 23223 /* falls through */ 23224 case LEN: 23225 if (have >= 6 && left >= 258) { 23226 strm.next_out = put; 23227 strm.avail_out = left; 23228 strm.next_in = next; 23229 strm.avail_in = have; 23230 state.hold = hold; 23231 state.bits = bits; 23232 inflate_fast(strm, _out); 23233 put = strm.next_out; 23234 output = strm.output; 23235 left = strm.avail_out; 23236 next = strm.next_in; 23237 input = strm.input; 23238 have = strm.avail_in; 23239 hold = state.hold; 23240 bits = state.bits; 23241 if (state.mode === TYPE) { 23242 state.back = -1; 23243 } 23244 break; 23245 } 23246 state.back = 0; 23247 for (; ; ) { 23248 here = state.lencode[hold & (1 << state.lenbits) - 1]; 23249 here_bits = here >>> 24; 23250 here_op = here >>> 16 & 255; 23251 here_val = here & 65535; 23252 if (here_bits <= bits) { 23253 break; 23254 } 23255 if (have === 0) { 23256 break inf_leave; 23257 } 23258 have--; 23259 hold += input[next++] << bits; 23260 bits += 8; 23261 } 23262 if (here_op && (here_op & 240) === 0) { 23263 last_bits = here_bits; 23264 last_op = here_op; 23265 last_val = here_val; 23266 for (; ; ) { 23267 here = state.lencode[last_val + ((hold & (1 << last_bits + last_op) - 1) >> last_bits)]; 23268 here_bits = here >>> 24; 23269 here_op = here >>> 16 & 255; 23270 here_val = here & 65535; 23271 if (last_bits + here_bits <= bits) { 23272 break; 23273 } 23274 if (have === 0) { 23275 break inf_leave; 23276 } 23277 have--; 23278 hold += input[next++] << bits; 23279 bits += 8; 23280 } 23281 hold >>>= last_bits; 23282 bits -= last_bits; 23283 state.back += last_bits; 23284 } 23285 hold >>>= here_bits; 23286 bits -= here_bits; 23287 state.back += here_bits; 23288 state.length = here_val; 23289 if (here_op === 0) { 23290 state.mode = LIT; 23291 break; 23292 } 23293 if (here_op & 32) { 23294 state.back = -1; 23295 state.mode = TYPE; 23296 break; 23297 } 23298 if (here_op & 64) { 23299 strm.msg = "invalid literal/length code"; 23300 state.mode = BAD; 23301 break; 23302 } 23303 state.extra = here_op & 15; 23304 state.mode = LENEXT; 23305 /* falls through */ 23306 case LENEXT: 23307 if (state.extra) { 23308 n3 = state.extra; 23309 while (bits < n3) { 23310 if (have === 0) { 23311 break inf_leave; 23312 } 23313 have--; 23314 hold += input[next++] << bits; 23315 bits += 8; 23316 } 23317 state.length += hold & (1 << state.extra) - 1; 23318 hold >>>= state.extra; 23319 bits -= state.extra; 23320 state.back += state.extra; 23321 } 23322 state.was = state.length; 23323 state.mode = DIST; 23324 /* falls through */ 23325 case DIST: 23326 for (; ; ) { 23327 here = state.distcode[hold & (1 << state.distbits) - 1]; 23328 here_bits = here >>> 24; 23329 here_op = here >>> 16 & 255; 23330 here_val = here & 65535; 23331 if (here_bits <= bits) { 23332 break; 23333 } 23334 if (have === 0) { 23335 break inf_leave; 23336 } 23337 have--; 23338 hold += input[next++] << bits; 23339 bits += 8; 23340 } 23341 if ((here_op & 240) === 0) { 23342 last_bits = here_bits; 23343 last_op = here_op; 23344 last_val = here_val; 23345 for (; ; ) { 23346 here = state.distcode[last_val + ((hold & (1 << last_bits + last_op) - 1) >> last_bits)]; 23347 here_bits = here >>> 24; 23348 here_op = here >>> 16 & 255; 23349 here_val = here & 65535; 23350 if (last_bits + here_bits <= bits) { 23351 break; 23352 } 23353 if (have === 0) { 23354 break inf_leave; 23355 } 23356 have--; 23357 hold += input[next++] << bits; 23358 bits += 8; 23359 } 23360 hold >>>= last_bits; 23361 bits -= last_bits; 23362 state.back += last_bits; 23363 } 23364 hold >>>= here_bits; 23365 bits -= here_bits; 23366 state.back += here_bits; 23367 if (here_op & 64) { 23368 strm.msg = "invalid distance code"; 23369 state.mode = BAD; 23370 break; 23371 } 23372 state.offset = here_val; 23373 state.extra = here_op & 15; 23374 state.mode = DISTEXT; 23375 /* falls through */ 23376 case DISTEXT: 23377 if (state.extra) { 23378 n3 = state.extra; 23379 while (bits < n3) { 23380 if (have === 0) { 23381 break inf_leave; 23382 } 23383 have--; 23384 hold += input[next++] << bits; 23385 bits += 8; 23386 } 23387 state.offset += hold & (1 << state.extra) - 1; 23388 hold >>>= state.extra; 23389 bits -= state.extra; 23390 state.back += state.extra; 23391 } 23392 if (state.offset > state.dmax) { 23393 strm.msg = "invalid distance too far back"; 23394 state.mode = BAD; 23395 break; 23396 } 23397 state.mode = MATCH; 23398 /* falls through */ 23399 case MATCH: 23400 if (left === 0) { 23401 break inf_leave; 23402 } 23403 copy = _out - left; 23404 if (state.offset > copy) { 23405 copy = state.offset - copy; 23406 if (copy > state.whave) { 23407 if (state.sane) { 23408 strm.msg = "invalid distance too far back"; 23409 state.mode = BAD; 23410 break; 23411 } 23412 } 23413 if (copy > state.wnext) { 23414 copy -= state.wnext; 23415 from = state.wsize - copy; 23416 } else { 23417 from = state.wnext - copy; 23418 } 23419 if (copy > state.length) { 23420 copy = state.length; 23421 } 23422 from_source = state.window; 23423 } else { 23424 from_source = output; 23425 from = put - state.offset; 23426 copy = state.length; 23427 } 23428 if (copy > left) { 23429 copy = left; 23430 } 23431 left -= copy; 23432 state.length -= copy; 23433 do { 23434 output[put++] = from_source[from++]; 23435 } while (--copy); 23436 if (state.length === 0) { 23437 state.mode = LEN; 23438 } 23439 break; 23440 case LIT: 23441 if (left === 0) { 23442 break inf_leave; 23443 } 23444 output[put++] = state.length; 23445 left--; 23446 state.mode = LEN; 23447 break; 23448 case CHECK: 23449 if (state.wrap) { 23450 while (bits < 32) { 23451 if (have === 0) { 23452 break inf_leave; 23453 } 23454 have--; 23455 hold |= input[next++] << bits; 23456 bits += 8; 23457 } 23458 _out -= left; 23459 strm.total_out += _out; 23460 state.total += _out; 23461 if (_out) { 23462 strm.adler = state.check = /*UPDATE(state.check, put - _out, _out);*/ 23463 state.flags ? crc32( 23464 state.check, 23465 output, 23466 _out, 23467 put - _out 23468 ) : adler32( 23469 state.check, 23470 output, 23471 _out, 23472 put - _out 23473 ); 23474 } 23475 _out = left; 23476 if ((state.flags ? hold : zswap32(hold)) !== state.check) { 23477 strm.msg = "incorrect data check"; 23478 state.mode = BAD; 23479 break; 23480 } 23481 hold = 0; 23482 bits = 0; 23483 } 23484 state.mode = LENGTH; 23485 /* falls through */ 23486 case LENGTH: 23487 if (state.wrap && state.flags) { 23488 while (bits < 32) { 23489 if (have === 0) { 23490 break inf_leave; 23491 } 23492 have--; 23493 hold += input[next++] << bits; 23494 bits += 8; 23495 } 23496 if (hold !== (state.total & 4294967295)) { 23497 strm.msg = "incorrect length check"; 23498 state.mode = BAD; 23499 break; 23500 } 23501 hold = 0; 23502 bits = 0; 23503 } 23504 state.mode = DONE; 23505 /* falls through */ 23506 case DONE: 23507 ret = Z_STREAM_END; 23508 break inf_leave; 23509 case BAD: 23510 ret = Z_DATA_ERROR; 23511 break inf_leave; 23512 case MEM: 23513 return Z_MEM_ERROR; 23514 case SYNC: 23515 /* falls through */ 23516 default: 23517 return Z_STREAM_ERROR; 23518 } 23519 } 23520 strm.next_out = put; 23521 strm.avail_out = left; 23522 strm.next_in = next; 23523 strm.avail_in = have; 23524 state.hold = hold; 23525 state.bits = bits; 23526 if (state.wsize || _out !== strm.avail_out && state.mode < BAD && (state.mode < CHECK || flush !== Z_FINISH)) { 23527 if (updatewindow( 23528 strm, 23529 strm.output, 23530 strm.next_out, 23531 _out - strm.avail_out 23532 )) { 23533 state.mode = MEM; 23534 return Z_MEM_ERROR; 23535 } 23536 } 23537 _in -= strm.avail_in; 23538 _out -= strm.avail_out; 23539 strm.total_in += _in; 23540 strm.total_out += _out; 23541 state.total += _out; 23542 if (state.wrap && _out) { 23543 strm.adler = state.check = /*UPDATE(state.check, strm.next_out - _out, _out);*/ 23544 state.flags ? crc32( 23545 state.check, 23546 output, 23547 _out, 23548 strm.next_out - _out 23549 ) : adler32( 23550 state.check, 23551 output, 23552 _out, 23553 strm.next_out - _out 23554 ); 23555 } 23556 strm.data_type = state.bits + (state.last ? 64 : 0) + (state.mode === TYPE ? 128 : 0) + (state.mode === LEN_ || state.mode === COPY_ ? 256 : 0); 23557 if ((_in === 0 && _out === 0 || flush === Z_FINISH) && ret === Z_OK) { 23558 ret = Z_BUF_ERROR; 23559 } 23560 return ret; 23561 } 23562 function inflateEnd(strm) { 23563 if (!strm || !strm.state) { 23564 return Z_STREAM_ERROR; 23565 } 23566 var state = strm.state; 23567 if (state.window) { 23568 state.window = null; 23569 } 23570 strm.state = null; 23571 return Z_OK; 23572 } 23573 function inflateGetHeader(strm, head2) { 23574 var state; 23575 if (!strm || !strm.state) { 23576 return Z_STREAM_ERROR; 23577 } 23578 state = strm.state; 23579 if ((state.wrap & 2) === 0) { 23580 return Z_STREAM_ERROR; 23581 } 23582 state.head = head2; 23583 head2.done = false; 23584 return Z_OK; 23585 } 23586 function inflateSetDictionary(strm, dictionary) { 23587 var dictLength = dictionary.length; 23588 var state; 23589 var dictid; 23590 var ret; 23591 if (!strm || !strm.state) { 23592 return Z_STREAM_ERROR; 23593 } 23594 state = strm.state; 23595 if (state.wrap !== 0 && state.mode !== DICT) { 23596 return Z_STREAM_ERROR; 23597 } 23598 if (state.mode === DICT) { 23599 dictid = 1; 23600 dictid = adler32( 23601 dictid, 23602 dictionary, 23603 dictLength, 23604 0 23605 ); 23606 if (dictid !== state.check) { 23607 return Z_DATA_ERROR; 23608 } 23609 } 23610 ret = updatewindow( 23611 strm, 23612 dictionary, 23613 dictLength, 23614 dictLength 23615 ); 23616 if (ret) { 23617 state.mode = MEM; 23618 return Z_MEM_ERROR; 23619 } 23620 state.havedict = 1; 23621 return Z_OK; 23622 } 23623 exports3.inflateReset = inflateReset; 23624 exports3.inflateReset2 = inflateReset2; 23625 exports3.inflateResetKeep = inflateResetKeep; 23626 exports3.inflateInit = inflateInit; 23627 exports3.inflateInit2 = inflateInit2; 23628 exports3.inflate = inflate; 23629 exports3.inflateEnd = inflateEnd; 23630 exports3.inflateGetHeader = inflateGetHeader; 23631 exports3.inflateSetDictionary = inflateSetDictionary; 23632 exports3.inflateInfo = "pako inflate (from Nodeca project)"; 23633 }, 23634 { 23635 "../utils/common": 1, 23636 "./adler32": 3, 23637 "./crc32": 5, 23638 "./inffast": 7, 23639 "./inftrees": 9 23640 } 23641 ], 23642 9: [ 23643 function(require2, module3, exports3) { 23644 "use strict"; 23645 var utils = require2("../utils/common"); 23646 var MAXBITS = 15; 23647 var ENOUGH_LENS = 852; 23648 var ENOUGH_DISTS = 592; 23649 var CODES = 0; 23650 var LENS = 1; 23651 var DISTS = 2; 23652 var lbase = [ 23653 /* Length codes 257..285 base */ 23654 3, 23655 4, 23656 5, 23657 6, 23658 7, 23659 8, 23660 9, 23661 10, 23662 11, 23663 13, 23664 15, 23665 17, 23666 19, 23667 23, 23668 27, 23669 31, 23670 35, 23671 43, 23672 51, 23673 59, 23674 67, 23675 83, 23676 99, 23677 115, 23678 131, 23679 163, 23680 195, 23681 227, 23682 258, 23683 0, 23684 0 23685 ]; 23686 var lext = [ 23687 /* Length codes 257..285 extra */ 23688 16, 23689 16, 23690 16, 23691 16, 23692 16, 23693 16, 23694 16, 23695 16, 23696 17, 23697 17, 23698 17, 23699 17, 23700 18, 23701 18, 23702 18, 23703 18, 23704 19, 23705 19, 23706 19, 23707 19, 23708 20, 23709 20, 23710 20, 23711 20, 23712 21, 23713 21, 23714 21, 23715 21, 23716 16, 23717 72, 23718 78 23719 ]; 23720 var dbase = [ 23721 /* Distance codes 0..29 base */ 23722 1, 23723 2, 23724 3, 23725 4, 23726 5, 23727 7, 23728 9, 23729 13, 23730 17, 23731 25, 23732 33, 23733 49, 23734 65, 23735 97, 23736 129, 23737 193, 23738 257, 23739 385, 23740 513, 23741 769, 23742 1025, 23743 1537, 23744 2049, 23745 3073, 23746 4097, 23747 6145, 23748 8193, 23749 12289, 23750 16385, 23751 24577, 23752 0, 23753 0 23754 ]; 23755 var dext = [ 23756 /* Distance codes 0..29 extra */ 23757 16, 23758 16, 23759 16, 23760 16, 23761 17, 23762 17, 23763 18, 23764 18, 23765 19, 23766 19, 23767 20, 23768 20, 23769 21, 23770 21, 23771 22, 23772 22, 23773 23, 23774 23, 23775 24, 23776 24, 23777 25, 23778 25, 23779 26, 23780 26, 23781 27, 23782 27, 23783 28, 23784 28, 23785 29, 23786 29, 23787 64, 23788 64 23789 ]; 23790 module3.exports = function inflate_table(type, lens, lens_index, codes, table, table_index, work, opts) { 23791 var bits = opts.bits; 23792 var len = 0; 23793 var sym = 0; 23794 var min2 = 0, max2 = 0; 23795 var root = 0; 23796 var curr = 0; 23797 var drop = 0; 23798 var left = 0; 23799 var used = 0; 23800 var huff = 0; 23801 var incr; 23802 var fill; 23803 var low; 23804 var mask; 23805 var next; 23806 var base = null; 23807 var base_index = 0; 23808 var end; 23809 var count = new utils.Buf16(MAXBITS + 1); 23810 var offs = new utils.Buf16(MAXBITS + 1); 23811 var extra = null; 23812 var extra_index = 0; 23813 var here_bits, here_op, here_val; 23814 for (len = 0; len <= MAXBITS; len++) { 23815 count[len] = 0; 23816 } 23817 for (sym = 0; sym < codes; sym++) { 23818 count[lens[lens_index + sym]]++; 23819 } 23820 root = bits; 23821 for (max2 = MAXBITS; max2 >= 1; max2--) { 23822 if (count[max2] !== 0) { 23823 break; 23824 } 23825 } 23826 if (root > max2) { 23827 root = max2; 23828 } 23829 if (max2 === 0) { 23830 table[table_index++] = 1 << 24 | 64 << 16 | 0; 23831 table[table_index++] = 1 << 24 | 64 << 16 | 0; 23832 opts.bits = 1; 23833 return 0; 23834 } 23835 for (min2 = 1; min2 < max2; min2++) { 23836 if (count[min2] !== 0) { 23837 break; 23838 } 23839 } 23840 if (root < min2) { 23841 root = min2; 23842 } 23843 left = 1; 23844 for (len = 1; len <= MAXBITS; len++) { 23845 left <<= 1; 23846 left -= count[len]; 23847 if (left < 0) { 23848 return -1; 23849 } 23850 } 23851 if (left > 0 && (type === CODES || max2 !== 1)) { 23852 return -1; 23853 } 23854 offs[1] = 0; 23855 for (len = 1; len < MAXBITS; len++) { 23856 offs[len + 1] = offs[len] + count[len]; 23857 } 23858 for (sym = 0; sym < codes; sym++) { 23859 if (lens[lens_index + sym] !== 0) { 23860 work[offs[lens[lens_index + sym]]++] = sym; 23861 } 23862 } 23863 if (type === CODES) { 23864 base = extra = work; 23865 end = 19; 23866 } else if (type === LENS) { 23867 base = lbase; 23868 base_index -= 257; 23869 extra = lext; 23870 extra_index -= 257; 23871 end = 256; 23872 } else { 23873 base = dbase; 23874 extra = dext; 23875 end = -1; 23876 } 23877 huff = 0; 23878 sym = 0; 23879 len = min2; 23880 next = table_index; 23881 curr = root; 23882 drop = 0; 23883 low = -1; 23884 used = 1 << root; 23885 mask = used - 1; 23886 if (type === LENS && used > ENOUGH_LENS || type === DISTS && used > ENOUGH_DISTS) { 23887 return 1; 23888 } 23889 for (; ; ) { 23890 here_bits = len - drop; 23891 if (work[sym] < end) { 23892 here_op = 0; 23893 here_val = work[sym]; 23894 } else if (work[sym] > end) { 23895 here_op = extra[extra_index + work[sym]]; 23896 here_val = base[base_index + work[sym]]; 23897 } else { 23898 here_op = 32 + 64; 23899 here_val = 0; 23900 } 23901 incr = 1 << len - drop; 23902 fill = 1 << curr; 23903 min2 = fill; 23904 do { 23905 fill -= incr; 23906 table[next + (huff >> drop) + fill] = here_bits << 24 | here_op << 16 | here_val | 0; 23907 } while (fill !== 0); 23908 incr = 1 << len - 1; 23909 while (huff & incr) { 23910 incr >>= 1; 23911 } 23912 if (incr !== 0) { 23913 huff &= incr - 1; 23914 huff += incr; 23915 } else { 23916 huff = 0; 23917 } 23918 sym++; 23919 if (--count[len] === 0) { 23920 if (len === max2) { 23921 break; 23922 } 23923 len = lens[lens_index + work[sym]]; 23924 } 23925 if (len > root && (huff & mask) !== low) { 23926 if (drop === 0) { 23927 drop = root; 23928 } 23929 next += min2; 23930 curr = len - drop; 23931 left = 1 << curr; 23932 while (curr + drop < max2) { 23933 left -= count[curr + drop]; 23934 if (left <= 0) { 23935 break; 23936 } 23937 curr++; 23938 left <<= 1; 23939 } 23940 used += 1 << curr; 23941 if (type === LENS && used > ENOUGH_LENS || type === DISTS && used > ENOUGH_DISTS) { 23942 return 1; 23943 } 23944 low = huff & mask; 23945 table[low] = root << 24 | curr << 16 | next - table_index | 0; 23946 } 23947 } 23948 if (huff !== 0) { 23949 table[next + huff] = len - drop << 24 | 64 << 16 | 0; 23950 } 23951 opts.bits = root; 23952 return 0; 23953 }; 23954 }, 23955 { "../utils/common": 1 } 23956 ], 23957 10: [ 23958 function(require2, module3, exports3) { 23959 "use strict"; 23960 module3.exports = { 23961 2: "need dictionary", 23962 1: "stream end", 23963 0: "", 23964 "-1": "file error", 23965 "-2": "stream error", 23966 "-3": "data error", 23967 "-4": "insufficient memory", 23968 "-5": "buffer error", 23969 "-6": "incompatible version" 23970 }; 23971 }, 23972 {} 23973 ], 23974 11: [ 23975 function(require2, module3, exports3) { 23976 "use strict"; 23977 function ZStream() { 23978 this.input = null; 23979 this.next_in = 0; 23980 this.avail_in = 0; 23981 this.total_in = 0; 23982 this.output = null; 23983 this.next_out = 0; 23984 this.avail_out = 0; 23985 this.total_out = 0; 23986 this.msg = ""; 23987 this.state = null; 23988 this.data_type = 2; 23989 this.adler = 0; 23990 } 23991 module3.exports = ZStream; 23992 }, 23993 {} 23994 ], 23995 "/lib/inflate.js": [ 23996 function(require2, module3, exports3) { 23997 "use strict"; 23998 var zlib_inflate = require2("./zlib/inflate"); 23999 var utils = require2("./utils/common"); 24000 var strings = require2("./utils/strings"); 24001 var c2 = require2("./zlib/constants"); 24002 var msg = require2("./zlib/messages"); 24003 var ZStream = require2("./zlib/zstream"); 24004 var GZheader = require2("./zlib/gzheader"); 24005 var toString = Object.prototype.toString; 24006 function Inflate(options) { 24007 if (!(this instanceof Inflate)) 24008 return new Inflate(options); 24009 this.options = utils.assign( 24010 { 24011 chunkSize: 16384, 24012 windowBits: 0, 24013 to: "" 24014 }, 24015 options || {} 24016 ); 24017 var opt = this.options; 24018 if (opt.raw && opt.windowBits >= 0 && opt.windowBits < 16) { 24019 opt.windowBits = -opt.windowBits; 24020 if (opt.windowBits === 0) { 24021 opt.windowBits = -15; 24022 } 24023 } 24024 if (opt.windowBits >= 0 && opt.windowBits < 16 && !(options && options.windowBits)) { 24025 opt.windowBits += 32; 24026 } 24027 if (opt.windowBits > 15 && opt.windowBits < 48) { 24028 if ((opt.windowBits & 15) === 0) { 24029 opt.windowBits |= 15; 24030 } 24031 } 24032 this.err = 0; 24033 this.msg = ""; 24034 this.ended = false; 24035 this.chunks = []; 24036 this.strm = new ZStream(); 24037 this.strm.avail_out = 0; 24038 var status = zlib_inflate.inflateInit2( 24039 this.strm, 24040 opt.windowBits 24041 ); 24042 if (status !== c2.Z_OK) { 24043 throw new Error(msg[status]); 24044 } 24045 this.header = new GZheader(); 24046 zlib_inflate.inflateGetHeader(this.strm, this.header); 24047 if (opt.dictionary) { 24048 if (typeof opt.dictionary === "string") { 24049 opt.dictionary = strings.string2buf( 24050 opt.dictionary 24051 ); 24052 } else if (toString.call(opt.dictionary) === "[object ArrayBuffer]") { 24053 opt.dictionary = new Uint8Array( 24054 opt.dictionary 24055 ); 24056 } 24057 if (opt.raw) { 24058 status = zlib_inflate.inflateSetDictionary( 24059 this.strm, 24060 opt.dictionary 24061 ); 24062 if (status !== c2.Z_OK) { 24063 throw new Error(msg[status]); 24064 } 24065 } 24066 } 24067 } 24068 Inflate.prototype.push = function(data, mode) { 24069 var strm = this.strm; 24070 var chunkSize = this.options.chunkSize; 24071 var dictionary = this.options.dictionary; 24072 var status, _mode; 24073 var next_out_utf8, tail, utf8str; 24074 var allowBufError = false; 24075 if (this.ended) { 24076 return false; 24077 } 24078 _mode = mode === ~~mode ? mode : mode === true ? c2.Z_FINISH : c2.Z_NO_FLUSH; 24079 if (typeof data === "string") { 24080 strm.input = strings.binstring2buf(data); 24081 } else if (toString.call(data) === "[object ArrayBuffer]") { 24082 strm.input = new Uint8Array(data); 24083 } else { 24084 strm.input = data; 24085 } 24086 strm.next_in = 0; 24087 strm.avail_in = strm.input.length; 24088 do { 24089 if (strm.avail_out === 0) { 24090 strm.output = new utils.Buf8(chunkSize); 24091 strm.next_out = 0; 24092 strm.avail_out = chunkSize; 24093 } 24094 status = zlib_inflate.inflate( 24095 strm, 24096 c2.Z_NO_FLUSH 24097 ); 24098 if (status === c2.Z_NEED_DICT && dictionary) { 24099 status = zlib_inflate.inflateSetDictionary( 24100 this.strm, 24101 dictionary 24102 ); 24103 } 24104 if (status === c2.Z_BUF_ERROR && allowBufError === true) { 24105 status = c2.Z_OK; 24106 allowBufError = false; 24107 } 24108 if (status !== c2.Z_STREAM_END && status !== c2.Z_OK) { 24109 this.onEnd(status); 24110 this.ended = true; 24111 return false; 24112 } 24113 if (strm.next_out) { 24114 if (strm.avail_out === 0 || status === c2.Z_STREAM_END || strm.avail_in === 0 && (_mode === c2.Z_FINISH || _mode === c2.Z_SYNC_FLUSH)) { 24115 if (this.options.to === "string") { 24116 next_out_utf8 = strings.utf8border( 24117 strm.output, 24118 strm.next_out 24119 ); 24120 tail = strm.next_out - next_out_utf8; 24121 utf8str = strings.buf2string( 24122 strm.output, 24123 next_out_utf8 24124 ); 24125 strm.next_out = tail; 24126 strm.avail_out = chunkSize - tail; 24127 if (tail) { 24128 utils.arraySet( 24129 strm.output, 24130 strm.output, 24131 next_out_utf8, 24132 tail, 24133 0 24134 ); 24135 } 24136 this.onData(utf8str); 24137 } else { 24138 this.onData( 24139 utils.shrinkBuf( 24140 strm.output, 24141 strm.next_out 24142 ) 24143 ); 24144 } 24145 } 24146 } 24147 if (strm.avail_in === 0 && strm.avail_out === 0) { 24148 allowBufError = true; 24149 } 24150 } while ((strm.avail_in > 0 || strm.avail_out === 0) && status !== c2.Z_STREAM_END); 24151 if (status === c2.Z_STREAM_END) { 24152 _mode = c2.Z_FINISH; 24153 } 24154 if (_mode === c2.Z_FINISH) { 24155 status = zlib_inflate.inflateEnd(this.strm); 24156 this.onEnd(status); 24157 this.ended = true; 24158 return status === c2.Z_OK; 24159 } 24160 if (_mode === c2.Z_SYNC_FLUSH) { 24161 this.onEnd(c2.Z_OK); 24162 strm.avail_out = 0; 24163 return true; 24164 } 24165 return true; 24166 }; 24167 Inflate.prototype.onData = function(chunk) { 24168 this.chunks.push(chunk); 24169 }; 24170 Inflate.prototype.onEnd = function(status) { 24171 if (status === c2.Z_OK) { 24172 if (this.options.to === "string") { 24173 this.result = this.chunks.join(""); 24174 } else { 24175 this.result = utils.flattenChunks( 24176 this.chunks 24177 ); 24178 } 24179 } 24180 this.chunks = []; 24181 this.err = status; 24182 this.msg = this.strm.msg; 24183 }; 24184 function inflate(input, options) { 24185 var inflator = new Inflate(options); 24186 inflator.push(input, true); 24187 if (inflator.err) { 24188 throw inflator.msg || msg[inflator.err]; 24189 } 24190 return inflator.result; 24191 } 24192 function inflateRaw(input, options) { 24193 options = options || {}; 24194 options.raw = true; 24195 return inflate(input, options); 24196 } 24197 exports3.Inflate = Inflate; 24198 exports3.inflate = inflate; 24199 exports3.inflateRaw = inflateRaw; 24200 exports3.ungzip = inflate; 24201 }, 24202 { 24203 "./utils/common": 1, 24204 "./utils/strings": 2, 24205 "./zlib/constants": 4, 24206 "./zlib/gzheader": 6, 24207 "./zlib/inflate": 8, 24208 "./zlib/messages": 10, 24209 "./zlib/zstream": 11 24210 } 24211 ] 24212 }, 24213 {}, 24214 [] 24215 )("/lib/inflate.js"); 24216 }); 24217 } 24218 }); 24219 var inflate_default = require_inflate(); 24220 24221 // packages/global-styles-ui/build-module/font-library/lib/lib-font.browser.js 24222 var fetchFunction = globalThis.fetch; 24223 var Event2 = class { 24224 constructor(type, detail = {}, msg) { 24225 this.type = type; 24226 this.detail = detail; 24227 this.msg = msg; 24228 Object.defineProperty(this, `__mayPropagate`, { 24229 enumerable: false, 24230 writable: true 24231 }); 24232 this.__mayPropagate = true; 24233 } 24234 preventDefault() { 24235 } 24236 stopPropagation() { 24237 this.__mayPropagate = false; 24238 } 24239 valueOf() { 24240 return this; 24241 } 24242 toString() { 24243 return this.msg ? `[$this.type} event]: $this.msg}` : `[$this.type} event]`; 24244 } 24245 }; 24246 var EventManager = class { 24247 constructor() { 24248 this.listeners = {}; 24249 } 24250 addEventListener(type, listener, useCapture) { 24251 let bin = this.listeners[type] || []; 24252 if (useCapture) bin.unshift(listener); 24253 else bin.push(listener); 24254 this.listeners[type] = bin; 24255 } 24256 removeEventListener(type, listener) { 24257 let bin = this.listeners[type] || []; 24258 let pos = bin.findIndex((e3) => e3 === listener); 24259 if (pos > -1) { 24260 bin.splice(pos, 1); 24261 this.listeners[type] = bin; 24262 } 24263 } 24264 dispatch(event) { 24265 let bin = this.listeners[event.type]; 24266 if (bin) { 24267 for (let l3 = 0, e3 = bin.length; l3 < e3; l3++) { 24268 if (!event.__mayPropagate) break; 24269 bin[l3](event); 24270 } 24271 } 24272 } 24273 }; 24274 var startDate = (/* @__PURE__ */ new Date(`1904-01-01T00:00:00+0000`)).getTime(); 24275 function asText(data) { 24276 return Array.from(data).map((v3) => String.fromCharCode(v3)).join(``); 24277 } 24278 var Parser = class { 24279 constructor(dict, dataview, name2) { 24280 this.name = (name2 || dict.tag || ``).trim(); 24281 this.length = dict.length; 24282 this.start = dict.offset; 24283 this.offset = 0; 24284 this.data = dataview; 24285 [ 24286 `getInt8`, 24287 `getUint8`, 24288 `getInt16`, 24289 `getUint16`, 24290 `getInt32`, 24291 `getUint32`, 24292 `getBigInt64`, 24293 `getBigUint64` 24294 ].forEach((name3) => { 24295 let fn = name3.replace(/get(Big)?/, "").toLowerCase(); 24296 let increment = parseInt(name3.replace(/[^\d]/g, "")) / 8; 24297 Object.defineProperty(this, fn, { 24298 get: () => this.getValue(name3, increment) 24299 }); 24300 }); 24301 } 24302 get currentPosition() { 24303 return this.start + this.offset; 24304 } 24305 set currentPosition(position) { 24306 this.start = position; 24307 this.offset = 0; 24308 } 24309 skip(n3 = 0, bits = 8) { 24310 this.offset += n3 * bits / 8; 24311 } 24312 getValue(type, increment) { 24313 let pos = this.start + this.offset; 24314 this.offset += increment; 24315 try { 24316 return this.data[type](pos); 24317 } catch (e3) { 24318 console.error(`parser`, type, increment, this); 24319 console.error(`parser`, this.start, this.offset); 24320 throw e3; 24321 } 24322 } 24323 flags(n3) { 24324 if (n3 === 8 || n3 === 16 || n3 === 32 || n3 === 64) { 24325 return this[`uint$n3}`].toString(2).padStart(n3, 0).split(``).map((v3) => v3 === "1"); 24326 } 24327 console.error( 24328 `Error parsing flags: flag types can only be 1, 2, 4, or 8 bytes long` 24329 ); 24330 console.trace(); 24331 } 24332 get tag() { 24333 const t4 = this.uint32; 24334 return asText([ 24335 t4 >> 24 & 255, 24336 t4 >> 16 & 255, 24337 t4 >> 8 & 255, 24338 t4 & 255 24339 ]); 24340 } 24341 get fixed() { 24342 let major = this.int16; 24343 let minor = Math.round(1e3 * this.uint16 / 65356); 24344 return major + minor / 1e3; 24345 } 24346 get legacyFixed() { 24347 let major = this.uint16; 24348 let minor = this.uint16.toString(16).padStart(4, 0); 24349 return parseFloat(`$major}.$minor}`); 24350 } 24351 get uint24() { 24352 return (this.uint8 << 16) + (this.uint8 << 8) + this.uint8; 24353 } 24354 get uint128() { 24355 let value = 0; 24356 for (let i3 = 0; i3 < 5; i3++) { 24357 let byte = this.uint8; 24358 value = value * 128 + (byte & 127); 24359 if (byte < 128) break; 24360 } 24361 return value; 24362 } 24363 get longdatetime() { 24364 return new Date(startDate + 1e3 * parseInt(this.int64.toString())); 24365 } 24366 get fword() { 24367 return this.int16; 24368 } 24369 get ufword() { 24370 return this.uint16; 24371 } 24372 get Offset16() { 24373 return this.uint16; 24374 } 24375 get Offset32() { 24376 return this.uint32; 24377 } 24378 get F2DOT14() { 24379 const bits = p.uint16; 24380 const integer = [0, 1, -2, -1][bits >> 14]; 24381 const fraction = bits & 16383; 24382 return integer + fraction / 16384; 24383 } 24384 verifyLength() { 24385 if (this.offset != this.length) { 24386 console.error( 24387 `unexpected parsed table size ($this.offset}) for "$this.name}" (expected $this.length})` 24388 ); 24389 } 24390 } 24391 readBytes(n3 = 0, position = 0, bits = 8, signed = false) { 24392 n3 = n3 || this.length; 24393 if (n3 === 0) return []; 24394 if (position) this.currentPosition = position; 24395 const fn = `$signed ? `` : `u`}int$bits}`, slice = []; 24396 while (n3--) slice.push(this[fn]); 24397 return slice; 24398 } 24399 }; 24400 var ParsedData = class { 24401 constructor(parser) { 24402 const pGetter = { enumerable: false, get: () => parser }; 24403 Object.defineProperty(this, `parser`, pGetter); 24404 const start = parser.currentPosition; 24405 const startGetter = { enumerable: false, get: () => start }; 24406 Object.defineProperty(this, `start`, startGetter); 24407 } 24408 load(struct) { 24409 Object.keys(struct).forEach((p22) => { 24410 let props = Object.getOwnPropertyDescriptor(struct, p22); 24411 if (props.get) { 24412 this[p22] = props.get.bind(this); 24413 } else if (props.value !== void 0) { 24414 this[p22] = props.value; 24415 } 24416 }); 24417 if (this.parser.length) { 24418 this.parser.verifyLength(); 24419 } 24420 } 24421 }; 24422 var SimpleTable = class extends ParsedData { 24423 constructor(dict, dataview, name2) { 24424 const { parser, start } = super( 24425 new Parser(dict, dataview, name2) 24426 ); 24427 const pGetter = { enumerable: false, get: () => parser }; 24428 Object.defineProperty(this, `p`, pGetter); 24429 const startGetter = { enumerable: false, get: () => start }; 24430 Object.defineProperty(this, `tableStart`, startGetter); 24431 } 24432 }; 24433 function lazy$1(object, property, getter) { 24434 let val; 24435 Object.defineProperty(object, property, { 24436 get: () => { 24437 if (val) return val; 24438 val = getter(); 24439 return val; 24440 }, 24441 enumerable: true 24442 }); 24443 } 24444 var SFNT = class extends SimpleTable { 24445 constructor(font2, dataview, createTable2) { 24446 const { p: p22 } = super({ offset: 0, length: 12 }, dataview, `sfnt`); 24447 this.version = p22.uint32; 24448 this.numTables = p22.uint16; 24449 this.searchRange = p22.uint16; 24450 this.entrySelector = p22.uint16; 24451 this.rangeShift = p22.uint16; 24452 p22.verifyLength(); 24453 this.directory = [...new Array(this.numTables)].map( 24454 (_) => new TableRecord(p22) 24455 ); 24456 this.tables = {}; 24457 this.directory.forEach((entry) => { 24458 const getter = () => createTable2( 24459 this.tables, 24460 { 24461 tag: entry.tag, 24462 offset: entry.offset, 24463 length: entry.length 24464 }, 24465 dataview 24466 ); 24467 lazy$1(this.tables, entry.tag.trim(), getter); 24468 }); 24469 } 24470 }; 24471 var TableRecord = class { 24472 constructor(p22) { 24473 this.tag = p22.tag; 24474 this.checksum = p22.uint32; 24475 this.offset = p22.uint32; 24476 this.length = p22.uint32; 24477 } 24478 }; 24479 var gzipDecode = inflate_default.inflate || void 0; 24480 var nativeGzipDecode = void 0; 24481 var WOFF$1 = class extends SimpleTable { 24482 constructor(font2, dataview, createTable2) { 24483 const { p: p22 } = super({ offset: 0, length: 44 }, dataview, `woff`); 24484 this.signature = p22.tag; 24485 this.flavor = p22.uint32; 24486 this.length = p22.uint32; 24487 this.numTables = p22.uint16; 24488 p22.uint16; 24489 this.totalSfntSize = p22.uint32; 24490 this.majorVersion = p22.uint16; 24491 this.minorVersion = p22.uint16; 24492 this.metaOffset = p22.uint32; 24493 this.metaLength = p22.uint32; 24494 this.metaOrigLength = p22.uint32; 24495 this.privOffset = p22.uint32; 24496 this.privLength = p22.uint32; 24497 p22.verifyLength(); 24498 this.directory = [...new Array(this.numTables)].map( 24499 (_) => new WoffTableDirectoryEntry(p22) 24500 ); 24501 buildWoffLazyLookups(this, dataview, createTable2); 24502 } 24503 }; 24504 var WoffTableDirectoryEntry = class { 24505 constructor(p22) { 24506 this.tag = p22.tag; 24507 this.offset = p22.uint32; 24508 this.compLength = p22.uint32; 24509 this.origLength = p22.uint32; 24510 this.origChecksum = p22.uint32; 24511 } 24512 }; 24513 function buildWoffLazyLookups(woff, dataview, createTable2) { 24514 woff.tables = {}; 24515 woff.directory.forEach((entry) => { 24516 lazy$1(woff.tables, entry.tag.trim(), () => { 24517 let offset3 = 0; 24518 let view = dataview; 24519 if (entry.compLength !== entry.origLength) { 24520 const data = dataview.buffer.slice( 24521 entry.offset, 24522 entry.offset + entry.compLength 24523 ); 24524 let unpacked; 24525 if (gzipDecode) { 24526 unpacked = gzipDecode(new Uint8Array(data)); 24527 } else if (nativeGzipDecode) { 24528 unpacked = nativeGzipDecode(new Uint8Array(data)); 24529 } else { 24530 const msg = `no brotli decoder available to decode WOFF2 font`; 24531 if (font.onerror) font.onerror(msg); 24532 throw new Error(msg); 24533 } 24534 view = new DataView(unpacked.buffer); 24535 } else { 24536 offset3 = entry.offset; 24537 } 24538 return createTable2( 24539 woff.tables, 24540 { tag: entry.tag, offset: offset3, length: entry.origLength }, 24541 view 24542 ); 24543 }); 24544 }); 24545 } 24546 var brotliDecode = unbrotli_default; 24547 var nativeBrotliDecode = void 0; 24548 var WOFF2$1 = class extends SimpleTable { 24549 constructor(font2, dataview, createTable2) { 24550 const { p: p22 } = super({ offset: 0, length: 48 }, dataview, `woff2`); 24551 this.signature = p22.tag; 24552 this.flavor = p22.uint32; 24553 this.length = p22.uint32; 24554 this.numTables = p22.uint16; 24555 p22.uint16; 24556 this.totalSfntSize = p22.uint32; 24557 this.totalCompressedSize = p22.uint32; 24558 this.majorVersion = p22.uint16; 24559 this.minorVersion = p22.uint16; 24560 this.metaOffset = p22.uint32; 24561 this.metaLength = p22.uint32; 24562 this.metaOrigLength = p22.uint32; 24563 this.privOffset = p22.uint32; 24564 this.privLength = p22.uint32; 24565 p22.verifyLength(); 24566 this.directory = [...new Array(this.numTables)].map( 24567 (_) => new Woff2TableDirectoryEntry(p22) 24568 ); 24569 let dictOffset = p22.currentPosition; 24570 this.directory[0].offset = 0; 24571 this.directory.forEach((e3, i3) => { 24572 let next = this.directory[i3 + 1]; 24573 if (next) { 24574 next.offset = e3.offset + (e3.transformLength !== void 0 ? e3.transformLength : e3.origLength); 24575 } 24576 }); 24577 let decoded; 24578 let buffer = dataview.buffer.slice(dictOffset); 24579 if (brotliDecode) { 24580 decoded = brotliDecode(new Uint8Array(buffer)); 24581 } else if (nativeBrotliDecode) { 24582 decoded = new Uint8Array(nativeBrotliDecode(buffer)); 24583 } else { 24584 const msg = `no brotli decoder available to decode WOFF2 font`; 24585 if (font2.onerror) font2.onerror(msg); 24586 throw new Error(msg); 24587 } 24588 buildWoff2LazyLookups(this, decoded, createTable2); 24589 } 24590 }; 24591 var Woff2TableDirectoryEntry = class { 24592 constructor(p22) { 24593 this.flags = p22.uint8; 24594 const tagNumber = this.tagNumber = this.flags & 63; 24595 if (tagNumber === 63) { 24596 this.tag = p22.tag; 24597 } else { 24598 this.tag = getWOFF2Tag(tagNumber); 24599 } 24600 const transformVersion = this.transformVersion = (this.flags & 192) >> 6; 24601 let hasTransforms = transformVersion !== 0; 24602 if (this.tag === `glyf` || this.tag === `loca`) { 24603 hasTransforms = this.transformVersion !== 3; 24604 } 24605 this.origLength = p22.uint128; 24606 if (hasTransforms) { 24607 this.transformLength = p22.uint128; 24608 } 24609 } 24610 }; 24611 function buildWoff2LazyLookups(woff2, decoded, createTable2) { 24612 woff2.tables = {}; 24613 woff2.directory.forEach((entry) => { 24614 lazy$1(woff2.tables, entry.tag.trim(), () => { 24615 const start = entry.offset; 24616 const end = start + (entry.transformLength ? entry.transformLength : entry.origLength); 24617 const data = new DataView(decoded.slice(start, end).buffer); 24618 try { 24619 return createTable2( 24620 woff2.tables, 24621 { tag: entry.tag, offset: 0, length: entry.origLength }, 24622 data 24623 ); 24624 } catch (e3) { 24625 console.error(e3); 24626 } 24627 }); 24628 }); 24629 } 24630 function getWOFF2Tag(flag) { 24631 return [ 24632 `cmap`, 24633 `head`, 24634 `hhea`, 24635 `hmtx`, 24636 `maxp`, 24637 `name`, 24638 `OS/2`, 24639 `post`, 24640 `cvt `, 24641 `fpgm`, 24642 `glyf`, 24643 `loca`, 24644 `prep`, 24645 `CFF `, 24646 `VORG`, 24647 `EBDT`, 24648 `EBLC`, 24649 `gasp`, 24650 `hdmx`, 24651 `kern`, 24652 `LTSH`, 24653 `PCLT`, 24654 `VDMX`, 24655 `vhea`, 24656 `vmtx`, 24657 `BASE`, 24658 `GDEF`, 24659 `GPOS`, 24660 `GSUB`, 24661 `EBSC`, 24662 `JSTF`, 24663 `MATH`, 24664 `CBDT`, 24665 `CBLC`, 24666 `COLR`, 24667 `CPAL`, 24668 `SVG `, 24669 `sbix`, 24670 `acnt`, 24671 `avar`, 24672 `bdat`, 24673 `bloc`, 24674 `bsln`, 24675 `cvar`, 24676 `fdsc`, 24677 `feat`, 24678 `fmtx`, 24679 `fvar`, 24680 `gvar`, 24681 `hsty`, 24682 `just`, 24683 `lcar`, 24684 `mort`, 24685 `morx`, 24686 `opbd`, 24687 `prop`, 24688 `trak`, 24689 `Zapf`, 24690 `Silf`, 24691 `Glat`, 24692 `Gloc`, 24693 `Feat`, 24694 `Sill` 24695 ][flag & 63]; 24696 } 24697 var tableClasses = {}; 24698 var tableClassesLoaded = false; 24699 Promise.all([ 24700 Promise.resolve().then(function() { 24701 return cmap$1; 24702 }), 24703 Promise.resolve().then(function() { 24704 return head$1; 24705 }), 24706 Promise.resolve().then(function() { 24707 return hhea$1; 24708 }), 24709 Promise.resolve().then(function() { 24710 return hmtx$1; 24711 }), 24712 Promise.resolve().then(function() { 24713 return maxp$1; 24714 }), 24715 Promise.resolve().then(function() { 24716 return name$1; 24717 }), 24718 Promise.resolve().then(function() { 24719 return OS2$1; 24720 }), 24721 Promise.resolve().then(function() { 24722 return post$1; 24723 }), 24724 Promise.resolve().then(function() { 24725 return BASE$1; 24726 }), 24727 Promise.resolve().then(function() { 24728 return GDEF$1; 24729 }), 24730 Promise.resolve().then(function() { 24731 return GSUB$1; 24732 }), 24733 Promise.resolve().then(function() { 24734 return GPOS$1; 24735 }), 24736 Promise.resolve().then(function() { 24737 return SVG$1; 24738 }), 24739 Promise.resolve().then(function() { 24740 return fvar$1; 24741 }), 24742 Promise.resolve().then(function() { 24743 return cvt$1; 24744 }), 24745 Promise.resolve().then(function() { 24746 return fpgm$1; 24747 }), 24748 Promise.resolve().then(function() { 24749 return gasp$1; 24750 }), 24751 Promise.resolve().then(function() { 24752 return glyf$1; 24753 }), 24754 Promise.resolve().then(function() { 24755 return loca$1; 24756 }), 24757 Promise.resolve().then(function() { 24758 return prep$1; 24759 }), 24760 Promise.resolve().then(function() { 24761 return CFF$1; 24762 }), 24763 Promise.resolve().then(function() { 24764 return CFF2$1; 24765 }), 24766 Promise.resolve().then(function() { 24767 return VORG$1; 24768 }), 24769 Promise.resolve().then(function() { 24770 return EBLC$1; 24771 }), 24772 Promise.resolve().then(function() { 24773 return EBDT$1; 24774 }), 24775 Promise.resolve().then(function() { 24776 return EBSC$1; 24777 }), 24778 Promise.resolve().then(function() { 24779 return CBLC$1; 24780 }), 24781 Promise.resolve().then(function() { 24782 return CBDT$1; 24783 }), 24784 Promise.resolve().then(function() { 24785 return sbix$1; 24786 }), 24787 Promise.resolve().then(function() { 24788 return COLR$1; 24789 }), 24790 Promise.resolve().then(function() { 24791 return CPAL$1; 24792 }), 24793 Promise.resolve().then(function() { 24794 return DSIG$1; 24795 }), 24796 Promise.resolve().then(function() { 24797 return hdmx$1; 24798 }), 24799 Promise.resolve().then(function() { 24800 return kern$1; 24801 }), 24802 Promise.resolve().then(function() { 24803 return LTSH$1; 24804 }), 24805 Promise.resolve().then(function() { 24806 return MERG$1; 24807 }), 24808 Promise.resolve().then(function() { 24809 return meta$1; 24810 }), 24811 Promise.resolve().then(function() { 24812 return PCLT$1; 24813 }), 24814 Promise.resolve().then(function() { 24815 return VDMX$1; 24816 }), 24817 Promise.resolve().then(function() { 24818 return vhea$1; 24819 }), 24820 Promise.resolve().then(function() { 24821 return vmtx$1; 24822 }) 24823 ]).then((data) => { 24824 data.forEach((e3) => { 24825 let name2 = Object.keys(e3)[0]; 24826 tableClasses[name2] = e3[name2]; 24827 }); 24828 tableClassesLoaded = true; 24829 }); 24830 function createTable(tables, dict, dataview) { 24831 let name2 = dict.tag.replace(/[^\w\d]/g, ``); 24832 let Type = tableClasses[name2]; 24833 if (Type) return new Type(dict, dataview, tables); 24834 console.warn( 24835 `lib-font has no definition for $name2}. The table was skipped.` 24836 ); 24837 return {}; 24838 } 24839 function loadTableClasses() { 24840 let count = 0; 24841 function checkLoaded(resolve, reject) { 24842 if (!tableClassesLoaded) { 24843 if (count > 10) { 24844 return reject(new Error(`loading took too long`)); 24845 } 24846 count++; 24847 return setTimeout(() => checkLoaded(resolve), 250); 24848 } 24849 resolve(createTable); 24850 } 24851 return new Promise((resolve, reject) => checkLoaded(resolve)); 24852 } 24853 function getFontCSSFormat(path, errorOnStyle) { 24854 let pos = path.lastIndexOf(`.`); 24855 let ext = (path.substring(pos + 1) || ``).toLowerCase(); 24856 let format = { 24857 ttf: `truetype`, 24858 otf: `opentype`, 24859 woff: `woff`, 24860 woff2: `woff2` 24861 }[ext]; 24862 if (format) return format; 24863 let msg = { 24864 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.`, 24865 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.`, 24866 fon: `The .fon format is not supported: this is an ancient Windows bitmap font format.`, 24867 ttc: `Based on the current CSS specification, font collections are not (yet?) supported.` 24868 }[ext]; 24869 if (!msg) msg = `$path} is not a known webfont format.`; 24870 if (errorOnStyle) { 24871 throw new Error(msg); 24872 } else { 24873 console.warn(`Could not load font: $msg}`); 24874 } 24875 } 24876 async function setupFontFace(name2, url, options = {}) { 24877 if (!globalThis.document) return; 24878 let format = getFontCSSFormat(url, options.errorOnStyle); 24879 if (!format) return; 24880 let style = document.createElement(`style`); 24881 style.className = `injected-by-Font-js`; 24882 let rules = []; 24883 if (options.styleRules) { 24884 rules = Object.entries(options.styleRules).map( 24885 ([key, value]) => `$key}: $value};` 24886 ); 24887 } 24888 style.textContent = ` 24889 @font-face { 24890 font-family: "$name2}"; 24891 $rules.join( 24892 ` 24893 ` 24894 )} 24895 src: url("$url}") format("$format}"); 24896 }`; 24897 globalThis.document.head.appendChild(style); 24898 return style; 24899 } 24900 var TTF = [0, 1, 0, 0]; 24901 var OTF = [79, 84, 84, 79]; 24902 var WOFF = [119, 79, 70, 70]; 24903 var WOFF2 = [119, 79, 70, 50]; 24904 function match(ar1, ar2) { 24905 if (ar1.length !== ar2.length) return; 24906 for (let i3 = 0; i3 < ar1.length; i3++) { 24907 if (ar1[i3] !== ar2[i3]) return; 24908 } 24909 return true; 24910 } 24911 function validFontFormat(dataview) { 24912 const LEAD_BYTES = [ 24913 dataview.getUint8(0), 24914 dataview.getUint8(1), 24915 dataview.getUint8(2), 24916 dataview.getUint8(3) 24917 ]; 24918 if (match(LEAD_BYTES, TTF) || match(LEAD_BYTES, OTF)) return `SFNT`; 24919 if (match(LEAD_BYTES, WOFF)) return `WOFF`; 24920 if (match(LEAD_BYTES, WOFF2)) return `WOFF2`; 24921 } 24922 function checkFetchResponseStatus(response) { 24923 if (!response.ok) { 24924 throw new Error( 24925 `HTTP $response.status} - $response.statusText}` 24926 ); 24927 } 24928 return response; 24929 } 24930 var Font = class extends EventManager { 24931 constructor(name2, options = {}) { 24932 super(); 24933 this.name = name2; 24934 this.options = options; 24935 this.metrics = false; 24936 } 24937 get src() { 24938 return this.__src; 24939 } 24940 set src(src) { 24941 this.__src = src; 24942 (async () => { 24943 if (globalThis.document && !this.options.skipStyleSheet) { 24944 await setupFontFace(this.name, src, this.options); 24945 } 24946 this.loadFont(src); 24947 })(); 24948 } 24949 async loadFont(url, filename) { 24950 fetch(url).then( 24951 (response) => checkFetchResponseStatus(response) && response.arrayBuffer() 24952 ).then( 24953 (buffer) => this.fromDataBuffer(buffer, filename || url) 24954 ).catch((err) => { 24955 const evt = new Event2( 24956 `error`, 24957 err, 24958 `Failed to load font at $filename || url}` 24959 ); 24960 this.dispatch(evt); 24961 if (this.onerror) this.onerror(evt); 24962 }); 24963 } 24964 async fromDataBuffer(buffer, filenameOrUrL) { 24965 this.fontData = new DataView(buffer); 24966 let type = validFontFormat(this.fontData); 24967 if (!type) { 24968 throw new Error( 24969 `$filenameOrUrL} is either an unsupported font format, or not a font at all.` 24970 ); 24971 } 24972 await this.parseBasicData(type); 24973 const evt = new Event2("load", { font: this }); 24974 this.dispatch(evt); 24975 if (this.onload) this.onload(evt); 24976 } 24977 async parseBasicData(type) { 24978 return loadTableClasses().then((createTable2) => { 24979 if (type === `SFNT`) { 24980 this.opentype = new SFNT(this, this.fontData, createTable2); 24981 } 24982 if (type === `WOFF`) { 24983 this.opentype = new WOFF$1(this, this.fontData, createTable2); 24984 } 24985 if (type === `WOFF2`) { 24986 this.opentype = new WOFF2$1(this, this.fontData, createTable2); 24987 } 24988 return this.opentype; 24989 }); 24990 } 24991 getGlyphId(char) { 24992 return this.opentype.tables.cmap.getGlyphId(char); 24993 } 24994 reverse(glyphid) { 24995 return this.opentype.tables.cmap.reverse(glyphid); 24996 } 24997 supports(char) { 24998 return this.getGlyphId(char) !== 0; 24999 } 25000 supportsVariation(variation) { 25001 return this.opentype.tables.cmap.supportsVariation(variation) !== false; 25002 } 25003 measureText(text, size3 = 16) { 25004 if (this.__unloaded) 25005 throw new Error( 25006 "Cannot measure text: font was unloaded. Please reload before calling measureText()" 25007 ); 25008 let d3 = document.createElement("div"); 25009 d3.textContent = text; 25010 d3.style.fontFamily = this.name; 25011 d3.style.fontSize = `$size3}px`; 25012 d3.style.color = `transparent`; 25013 d3.style.background = `transparent`; 25014 d3.style.top = `0`; 25015 d3.style.left = `0`; 25016 d3.style.position = `absolute`; 25017 document.body.appendChild(d3); 25018 let bbox = d3.getBoundingClientRect(); 25019 document.body.removeChild(d3); 25020 const OS22 = this.opentype.tables["OS/2"]; 25021 bbox.fontSize = size3; 25022 bbox.ascender = OS22.sTypoAscender; 25023 bbox.descender = OS22.sTypoDescender; 25024 return bbox; 25025 } 25026 unload() { 25027 if (this.styleElement.parentNode) { 25028 this.styleElement.parentNode.removeElement(this.styleElement); 25029 const evt = new Event2("unload", { font: this }); 25030 this.dispatch(evt); 25031 if (this.onunload) this.onunload(evt); 25032 } 25033 this._unloaded = true; 25034 } 25035 load() { 25036 if (this.__unloaded) { 25037 delete this.__unloaded; 25038 document.head.appendChild(this.styleElement); 25039 const evt = new Event2("load", { font: this }); 25040 this.dispatch(evt); 25041 if (this.onload) this.onload(evt); 25042 } 25043 } 25044 }; 25045 globalThis.Font = Font; 25046 var Subtable = class extends ParsedData { 25047 constructor(p22, plaformID, encodingID) { 25048 super(p22); 25049 this.plaformID = plaformID; 25050 this.encodingID = encodingID; 25051 } 25052 }; 25053 var Format0 = class extends Subtable { 25054 constructor(p22, platformID, encodingID) { 25055 super(p22, platformID, encodingID); 25056 this.format = 0; 25057 this.length = p22.uint16; 25058 this.language = p22.uint16; 25059 this.glyphIdArray = [...new Array(256)].map((_) => p22.uint8); 25060 } 25061 supports(charCode) { 25062 if (charCode.charCodeAt) { 25063 charCode = -1; 25064 console.warn( 25065 `supports(character) not implemented for cmap subtable format 0. only supports(id) is implemented.` 25066 ); 25067 } 25068 return 0 <= charCode && charCode <= 255; 25069 } 25070 reverse(glyphID) { 25071 console.warn(`reverse not implemented for cmap subtable format 0`); 25072 return {}; 25073 } 25074 getSupportedCharCodes() { 25075 return [{ start: 1, end: 256 }]; 25076 } 25077 }; 25078 var Format2 = class extends Subtable { 25079 constructor(p22, platformID, encodingID) { 25080 super(p22, platformID, encodingID); 25081 this.format = 2; 25082 this.length = p22.uint16; 25083 this.language = p22.uint16; 25084 this.subHeaderKeys = [...new Array(256)].map((_) => p22.uint16); 25085 const subHeaderCount = Math.max(...this.subHeaderKeys); 25086 const subHeaderOffset = p22.currentPosition; 25087 lazy$1(this, `subHeaders`, () => { 25088 p22.currentPosition = subHeaderOffset; 25089 return [...new Array(subHeaderCount)].map( 25090 (_) => new SubHeader(p22) 25091 ); 25092 }); 25093 const glyphIndexOffset = subHeaderOffset + subHeaderCount * 8; 25094 lazy$1(this, `glyphIndexArray`, () => { 25095 p22.currentPosition = glyphIndexOffset; 25096 return [...new Array(subHeaderCount)].map((_) => p22.uint16); 25097 }); 25098 } 25099 supports(charCode) { 25100 if (charCode.charCodeAt) { 25101 charCode = -1; 25102 console.warn( 25103 `supports(character) not implemented for cmap subtable format 2. only supports(id) is implemented.` 25104 ); 25105 } 25106 const low = charCode && 255; 25107 const high = charCode && 65280; 25108 const subHeaderKey = this.subHeaders[high]; 25109 const subheader = this.subHeaders[subHeaderKey]; 25110 const first = subheader.firstCode; 25111 const last = first + subheader.entryCount; 25112 return first <= low && low <= last; 25113 } 25114 reverse(glyphID) { 25115 console.warn(`reverse not implemented for cmap subtable format 2`); 25116 return {}; 25117 } 25118 getSupportedCharCodes(preservePropNames = false) { 25119 if (preservePropNames) { 25120 return this.subHeaders.map((h3) => ({ 25121 firstCode: h3.firstCode, 25122 lastCode: h3.lastCode 25123 })); 25124 } 25125 return this.subHeaders.map((h3) => ({ 25126 start: h3.firstCode, 25127 end: h3.lastCode 25128 })); 25129 } 25130 }; 25131 var SubHeader = class { 25132 constructor(p22) { 25133 this.firstCode = p22.uint16; 25134 this.entryCount = p22.uint16; 25135 this.lastCode = this.first + this.entryCount; 25136 this.idDelta = p22.int16; 25137 this.idRangeOffset = p22.uint16; 25138 } 25139 }; 25140 var Format4 = class extends Subtable { 25141 constructor(p22, platformID, encodingID) { 25142 super(p22, platformID, encodingID); 25143 this.format = 4; 25144 this.length = p22.uint16; 25145 this.language = p22.uint16; 25146 this.segCountX2 = p22.uint16; 25147 this.segCount = this.segCountX2 / 2; 25148 this.searchRange = p22.uint16; 25149 this.entrySelector = p22.uint16; 25150 this.rangeShift = p22.uint16; 25151 const endCodePosition = p22.currentPosition; 25152 lazy$1( 25153 this, 25154 `endCode`, 25155 () => p22.readBytes(this.segCount, endCodePosition, 16) 25156 ); 25157 const startCodePosition = endCodePosition + 2 + this.segCountX2; 25158 lazy$1( 25159 this, 25160 `startCode`, 25161 () => p22.readBytes(this.segCount, startCodePosition, 16) 25162 ); 25163 const idDeltaPosition = startCodePosition + this.segCountX2; 25164 lazy$1( 25165 this, 25166 `idDelta`, 25167 () => p22.readBytes(this.segCount, idDeltaPosition, 16, true) 25168 ); 25169 const idRangePosition = idDeltaPosition + this.segCountX2; 25170 lazy$1( 25171 this, 25172 `idRangeOffset`, 25173 () => p22.readBytes(this.segCount, idRangePosition, 16) 25174 ); 25175 const glyphIdArrayPosition = idRangePosition + this.segCountX2; 25176 const glyphIdArrayLength = this.length - (glyphIdArrayPosition - this.tableStart); 25177 lazy$1( 25178 this, 25179 `glyphIdArray`, 25180 () => p22.readBytes(glyphIdArrayLength, glyphIdArrayPosition, 16) 25181 ); 25182 lazy$1( 25183 this, 25184 `segments`, 25185 () => this.buildSegments(idRangePosition, glyphIdArrayPosition, p22) 25186 ); 25187 } 25188 buildSegments(idRangePosition, glyphIdArrayPosition, p22) { 25189 const build = (_, i3) => { 25190 let startCode = this.startCode[i3], endCode = this.endCode[i3], idDelta = this.idDelta[i3], idRangeOffset = this.idRangeOffset[i3], idRangeOffsetPointer = idRangePosition + 2 * i3, glyphIDs = []; 25191 if (idRangeOffset === 0) { 25192 for (let i22 = startCode + idDelta, e3 = endCode + idDelta; i22 <= e3; i22++) { 25193 glyphIDs.push(i22); 25194 } 25195 } else { 25196 for (let i22 = 0, e3 = endCode - startCode; i22 <= e3; i22++) { 25197 p22.currentPosition = idRangeOffsetPointer + idRangeOffset + i22 * 2; 25198 glyphIDs.push(p22.uint16); 25199 } 25200 } 25201 return { 25202 startCode, 25203 endCode, 25204 idDelta, 25205 idRangeOffset, 25206 glyphIDs 25207 }; 25208 }; 25209 return [...new Array(this.segCount)].map(build); 25210 } 25211 reverse(glyphID) { 25212 let s3 = this.segments.find((v3) => v3.glyphIDs.includes(glyphID)); 25213 if (!s3) return {}; 25214 const code = s3.startCode + s3.glyphIDs.indexOf(glyphID); 25215 return { code, unicode: String.fromCodePoint(code) }; 25216 } 25217 getGlyphId(charCode) { 25218 if (charCode.charCodeAt) charCode = charCode.charCodeAt(0); 25219 if (55296 <= charCode && charCode <= 57343) return 0; 25220 if ((charCode & 65534) === 65534 || (charCode & 65535) === 65535) 25221 return 0; 25222 let segment = this.segments.find( 25223 (s3) => s3.startCode <= charCode && charCode <= s3.endCode 25224 ); 25225 if (!segment) return 0; 25226 return segment.glyphIDs[charCode - segment.startCode]; 25227 } 25228 supports(charCode) { 25229 return this.getGlyphId(charCode) !== 0; 25230 } 25231 getSupportedCharCodes(preservePropNames = false) { 25232 if (preservePropNames) return this.segments; 25233 return this.segments.map((v3) => ({ 25234 start: v3.startCode, 25235 end: v3.endCode 25236 })); 25237 } 25238 }; 25239 var Format6 = class extends Subtable { 25240 constructor(p22, platformID, encodingID) { 25241 super(p22, platformID, encodingID); 25242 this.format = 6; 25243 this.length = p22.uint16; 25244 this.language = p22.uint16; 25245 this.firstCode = p22.uint16; 25246 this.entryCount = p22.uint16; 25247 this.lastCode = this.firstCode + this.entryCount - 1; 25248 const getter = () => [...new Array(this.entryCount)].map((_) => p22.uint16); 25249 lazy$1(this, `glyphIdArray`, getter); 25250 } 25251 supports(charCode) { 25252 if (charCode.charCodeAt) { 25253 charCode = -1; 25254 console.warn( 25255 `supports(character) not implemented for cmap subtable format 6. only supports(id) is implemented.` 25256 ); 25257 } 25258 if (charCode < this.firstCode) return {}; 25259 if (charCode > this.firstCode + this.entryCount) return {}; 25260 const code = charCode - this.firstCode; 25261 return { code, unicode: String.fromCodePoint(code) }; 25262 } 25263 reverse(glyphID) { 25264 let pos = this.glyphIdArray.indexOf(glyphID); 25265 if (pos > -1) return this.firstCode + pos; 25266 } 25267 getSupportedCharCodes(preservePropNames = false) { 25268 if (preservePropNames) { 25269 return [{ firstCode: this.firstCode, lastCode: this.lastCode }]; 25270 } 25271 return [{ start: this.firstCode, end: this.lastCode }]; 25272 } 25273 }; 25274 var Format8 = class extends Subtable { 25275 constructor(p22, platformID, encodingID) { 25276 super(p22, platformID, encodingID); 25277 this.format = 8; 25278 p22.uint16; 25279 this.length = p22.uint32; 25280 this.language = p22.uint32; 25281 this.is32 = [...new Array(8192)].map((_) => p22.uint8); 25282 this.numGroups = p22.uint32; 25283 const getter = () => [...new Array(this.numGroups)].map( 25284 (_) => new SequentialMapGroup$1(p22) 25285 ); 25286 lazy$1(this, `groups`, getter); 25287 } 25288 supports(charCode) { 25289 if (charCode.charCodeAt) { 25290 charCode = -1; 25291 console.warn( 25292 `supports(character) not implemented for cmap subtable format 8. only supports(id) is implemented.` 25293 ); 25294 } 25295 return this.groups.findIndex( 25296 (s3) => s3.startcharCode <= charCode && charCode <= s3.endcharCode 25297 ) !== -1; 25298 } 25299 reverse(glyphID) { 25300 console.warn(`reverse not implemented for cmap subtable format 8`); 25301 return {}; 25302 } 25303 getSupportedCharCodes(preservePropNames = false) { 25304 if (preservePropNames) return this.groups; 25305 return this.groups.map((v3) => ({ 25306 start: v3.startcharCode, 25307 end: v3.endcharCode 25308 })); 25309 } 25310 }; 25311 var SequentialMapGroup$1 = class { 25312 constructor(p22) { 25313 this.startcharCode = p22.uint32; 25314 this.endcharCode = p22.uint32; 25315 this.startGlyphID = p22.uint32; 25316 } 25317 }; 25318 var Format10 = class extends Subtable { 25319 constructor(p22, platformID, encodingID) { 25320 super(p22, platformID, encodingID); 25321 this.format = 10; 25322 p22.uint16; 25323 this.length = p22.uint32; 25324 this.language = p22.uint32; 25325 this.startCharCode = p22.uint32; 25326 this.numChars = p22.uint32; 25327 this.endCharCode = this.startCharCode + this.numChars; 25328 const getter = () => [...new Array(this.numChars)].map((_) => p22.uint16); 25329 lazy$1(this, `glyphs`, getter); 25330 } 25331 supports(charCode) { 25332 if (charCode.charCodeAt) { 25333 charCode = -1; 25334 console.warn( 25335 `supports(character) not implemented for cmap subtable format 10. only supports(id) is implemented.` 25336 ); 25337 } 25338 if (charCode < this.startCharCode) return false; 25339 if (charCode > this.startCharCode + this.numChars) return false; 25340 return charCode - this.startCharCode; 25341 } 25342 reverse(glyphID) { 25343 console.warn(`reverse not implemented for cmap subtable format 10`); 25344 return {}; 25345 } 25346 getSupportedCharCodes(preservePropNames = false) { 25347 if (preservePropNames) { 25348 return [ 25349 { 25350 startCharCode: this.startCharCode, 25351 endCharCode: this.endCharCode 25352 } 25353 ]; 25354 } 25355 return [{ start: this.startCharCode, end: this.endCharCode }]; 25356 } 25357 }; 25358 var Format12 = class extends Subtable { 25359 constructor(p22, platformID, encodingID) { 25360 super(p22, platformID, encodingID); 25361 this.format = 12; 25362 p22.uint16; 25363 this.length = p22.uint32; 25364 this.language = p22.uint32; 25365 this.numGroups = p22.uint32; 25366 const getter = () => [...new Array(this.numGroups)].map( 25367 (_) => new SequentialMapGroup(p22) 25368 ); 25369 lazy$1(this, `groups`, getter); 25370 } 25371 supports(charCode) { 25372 if (charCode.charCodeAt) charCode = charCode.charCodeAt(0); 25373 if (55296 <= charCode && charCode <= 57343) return 0; 25374 if ((charCode & 65534) === 65534 || (charCode & 65535) === 65535) 25375 return 0; 25376 return this.groups.findIndex( 25377 (s3) => s3.startCharCode <= charCode && charCode <= s3.endCharCode 25378 ) !== -1; 25379 } 25380 reverse(glyphID) { 25381 for (let group of this.groups) { 25382 let start = group.startGlyphID; 25383 if (start > glyphID) continue; 25384 if (start === glyphID) return group.startCharCode; 25385 let end = start + (group.endCharCode - group.startCharCode); 25386 if (end < glyphID) continue; 25387 const code = group.startCharCode + (glyphID - start); 25388 return { code, unicode: String.fromCodePoint(code) }; 25389 } 25390 return {}; 25391 } 25392 getSupportedCharCodes(preservePropNames = false) { 25393 if (preservePropNames) return this.groups; 25394 return this.groups.map((v3) => ({ 25395 start: v3.startCharCode, 25396 end: v3.endCharCode 25397 })); 25398 } 25399 }; 25400 var SequentialMapGroup = class { 25401 constructor(p22) { 25402 this.startCharCode = p22.uint32; 25403 this.endCharCode = p22.uint32; 25404 this.startGlyphID = p22.uint32; 25405 } 25406 }; 25407 var Format13 = class extends Subtable { 25408 constructor(p22, platformID, encodingID) { 25409 super(p22, platformID, encodingID); 25410 this.format = 13; 25411 p22.uint16; 25412 this.length = p22.uint32; 25413 this.language = p22.uint32; 25414 this.numGroups = p22.uint32; 25415 const getter = [...new Array(this.numGroups)].map( 25416 (_) => new ConstantMapGroup(p22) 25417 ); 25418 lazy$1(this, `groups`, getter); 25419 } 25420 supports(charCode) { 25421 if (charCode.charCodeAt) charCode = charCode.charCodeAt(0); 25422 return this.groups.findIndex( 25423 (s3) => s3.startCharCode <= charCode && charCode <= s3.endCharCode 25424 ) !== -1; 25425 } 25426 reverse(glyphID) { 25427 console.warn(`reverse not implemented for cmap subtable format 13`); 25428 return {}; 25429 } 25430 getSupportedCharCodes(preservePropNames = false) { 25431 if (preservePropNames) return this.groups; 25432 return this.groups.map((v3) => ({ 25433 start: v3.startCharCode, 25434 end: v3.endCharCode 25435 })); 25436 } 25437 }; 25438 var ConstantMapGroup = class { 25439 constructor(p22) { 25440 this.startCharCode = p22.uint32; 25441 this.endCharCode = p22.uint32; 25442 this.glyphID = p22.uint32; 25443 } 25444 }; 25445 var Format14 = class extends Subtable { 25446 constructor(p22, platformID, encodingID) { 25447 super(p22, platformID, encodingID); 25448 this.subTableStart = p22.currentPosition; 25449 this.format = 14; 25450 this.length = p22.uint32; 25451 this.numVarSelectorRecords = p22.uint32; 25452 lazy$1( 25453 this, 25454 `varSelectors`, 25455 () => [...new Array(this.numVarSelectorRecords)].map( 25456 (_) => new VariationSelector(p22) 25457 ) 25458 ); 25459 } 25460 supports() { 25461 console.warn(`supports not implemented for cmap subtable format 14`); 25462 return 0; 25463 } 25464 getSupportedCharCodes() { 25465 console.warn( 25466 `getSupportedCharCodes not implemented for cmap subtable format 14` 25467 ); 25468 return []; 25469 } 25470 reverse(glyphID) { 25471 console.warn(`reverse not implemented for cmap subtable format 14`); 25472 return {}; 25473 } 25474 supportsVariation(variation) { 25475 let v3 = this.varSelector.find( 25476 (uvs) => uvs.varSelector === variation 25477 ); 25478 return v3 ? v3 : false; 25479 } 25480 getSupportedVariations() { 25481 return this.varSelectors.map((v3) => v3.varSelector); 25482 } 25483 }; 25484 var VariationSelector = class { 25485 constructor(p22) { 25486 this.varSelector = p22.uint24; 25487 this.defaultUVSOffset = p22.Offset32; 25488 this.nonDefaultUVSOffset = p22.Offset32; 25489 } 25490 }; 25491 function createSubTable(parser, platformID, encodingID) { 25492 const format = parser.uint16; 25493 if (format === 0) return new Format0(parser, platformID, encodingID); 25494 if (format === 2) return new Format2(parser, platformID, encodingID); 25495 if (format === 4) return new Format4(parser, platformID, encodingID); 25496 if (format === 6) return new Format6(parser, platformID, encodingID); 25497 if (format === 8) return new Format8(parser, platformID, encodingID); 25498 if (format === 10) return new Format10(parser, platformID, encodingID); 25499 if (format === 12) return new Format12(parser, platformID, encodingID); 25500 if (format === 13) return new Format13(parser, platformID, encodingID); 25501 if (format === 14) return new Format14(parser, platformID, encodingID); 25502 return {}; 25503 } 25504 var cmap = class extends SimpleTable { 25505 constructor(dict, dataview) { 25506 const { p: p22 } = super(dict, dataview); 25507 this.version = p22.uint16; 25508 this.numTables = p22.uint16; 25509 this.encodingRecords = [...new Array(this.numTables)].map( 25510 (_) => new EncodingRecord(p22, this.tableStart) 25511 ); 25512 } 25513 getSubTable(tableID) { 25514 return this.encodingRecords[tableID].table; 25515 } 25516 getSupportedEncodings() { 25517 return this.encodingRecords.map((r4) => ({ 25518 platformID: r4.platformID, 25519 encodingId: r4.encodingID 25520 })); 25521 } 25522 getSupportedCharCodes(platformID, encodingID) { 25523 const recordID = this.encodingRecords.findIndex( 25524 (r4) => r4.platformID === platformID && r4.encodingID === encodingID 25525 ); 25526 if (recordID === -1) return false; 25527 const subtable = this.getSubTable(recordID); 25528 return subtable.getSupportedCharCodes(); 25529 } 25530 reverse(glyphid) { 25531 for (let i3 = 0; i3 < this.numTables; i3++) { 25532 let code = this.getSubTable(i3).reverse(glyphid); 25533 if (code) return code; 25534 } 25535 } 25536 getGlyphId(char) { 25537 let last = 0; 25538 this.encodingRecords.some((_, tableID) => { 25539 let t4 = this.getSubTable(tableID); 25540 if (!t4.getGlyphId) return false; 25541 last = t4.getGlyphId(char); 25542 return last !== 0; 25543 }); 25544 return last; 25545 } 25546 supports(char) { 25547 return this.encodingRecords.some((_, tableID) => { 25548 const t4 = this.getSubTable(tableID); 25549 return t4.supports && t4.supports(char) !== false; 25550 }); 25551 } 25552 supportsVariation(variation) { 25553 return this.encodingRecords.some((_, tableID) => { 25554 const t4 = this.getSubTable(tableID); 25555 return t4.supportsVariation && t4.supportsVariation(variation) !== false; 25556 }); 25557 } 25558 }; 25559 var EncodingRecord = class { 25560 constructor(p22, tableStart) { 25561 const platformID = this.platformID = p22.uint16; 25562 const encodingID = this.encodingID = p22.uint16; 25563 const offset3 = this.offset = p22.Offset32; 25564 lazy$1(this, `table`, () => { 25565 p22.currentPosition = tableStart + offset3; 25566 return createSubTable(p22, platformID, encodingID); 25567 }); 25568 } 25569 }; 25570 var cmap$1 = Object.freeze({ __proto__: null, cmap }); 25571 var head = class extends SimpleTable { 25572 constructor(dict, dataview) { 25573 const { p: p22 } = super(dict, dataview); 25574 this.load({ 25575 majorVersion: p22.uint16, 25576 minorVersion: p22.uint16, 25577 fontRevision: p22.fixed, 25578 checkSumAdjustment: p22.uint32, 25579 magicNumber: p22.uint32, 25580 flags: p22.flags(16), 25581 unitsPerEm: p22.uint16, 25582 created: p22.longdatetime, 25583 modified: p22.longdatetime, 25584 xMin: p22.int16, 25585 yMin: p22.int16, 25586 xMax: p22.int16, 25587 yMax: p22.int16, 25588 macStyle: p22.flags(16), 25589 lowestRecPPEM: p22.uint16, 25590 fontDirectionHint: p22.uint16, 25591 indexToLocFormat: p22.uint16, 25592 glyphDataFormat: p22.uint16 25593 }); 25594 } 25595 }; 25596 var head$1 = Object.freeze({ __proto__: null, head }); 25597 var hhea = class extends SimpleTable { 25598 constructor(dict, dataview) { 25599 const { p: p22 } = super(dict, dataview); 25600 this.majorVersion = p22.uint16; 25601 this.minorVersion = p22.uint16; 25602 this.ascender = p22.fword; 25603 this.descender = p22.fword; 25604 this.lineGap = p22.fword; 25605 this.advanceWidthMax = p22.ufword; 25606 this.minLeftSideBearing = p22.fword; 25607 this.minRightSideBearing = p22.fword; 25608 this.xMaxExtent = p22.fword; 25609 this.caretSlopeRise = p22.int16; 25610 this.caretSlopeRun = p22.int16; 25611 this.caretOffset = p22.int16; 25612 p22.int16; 25613 p22.int16; 25614 p22.int16; 25615 p22.int16; 25616 this.metricDataFormat = p22.int16; 25617 this.numberOfHMetrics = p22.uint16; 25618 p22.verifyLength(); 25619 } 25620 }; 25621 var hhea$1 = Object.freeze({ __proto__: null, hhea }); 25622 var hmtx = class extends SimpleTable { 25623 constructor(dict, dataview, tables) { 25624 const { p: p22 } = super(dict, dataview); 25625 const numberOfHMetrics = tables.hhea.numberOfHMetrics; 25626 const numGlyphs = tables.maxp.numGlyphs; 25627 const metricsStart = p22.currentPosition; 25628 lazy$1(this, `hMetrics`, () => { 25629 p22.currentPosition = metricsStart; 25630 return [...new Array(numberOfHMetrics)].map( 25631 (_) => new LongHorMetric(p22.uint16, p22.int16) 25632 ); 25633 }); 25634 if (numberOfHMetrics < numGlyphs) { 25635 const lsbStart = metricsStart + numberOfHMetrics * 4; 25636 lazy$1(this, `leftSideBearings`, () => { 25637 p22.currentPosition = lsbStart; 25638 return [...new Array(numGlyphs - numberOfHMetrics)].map( 25639 (_) => p22.int16 25640 ); 25641 }); 25642 } 25643 } 25644 }; 25645 var LongHorMetric = class { 25646 constructor(w3, b3) { 25647 this.advanceWidth = w3; 25648 this.lsb = b3; 25649 } 25650 }; 25651 var hmtx$1 = Object.freeze({ __proto__: null, hmtx }); 25652 var maxp = class extends SimpleTable { 25653 constructor(dict, dataview) { 25654 const { p: p22 } = super(dict, dataview); 25655 this.version = p22.legacyFixed; 25656 this.numGlyphs = p22.uint16; 25657 if (this.version === 1) { 25658 this.maxPoints = p22.uint16; 25659 this.maxContours = p22.uint16; 25660 this.maxCompositePoints = p22.uint16; 25661 this.maxCompositeContours = p22.uint16; 25662 this.maxZones = p22.uint16; 25663 this.maxTwilightPoints = p22.uint16; 25664 this.maxStorage = p22.uint16; 25665 this.maxFunctionDefs = p22.uint16; 25666 this.maxInstructionDefs = p22.uint16; 25667 this.maxStackElements = p22.uint16; 25668 this.maxSizeOfInstructions = p22.uint16; 25669 this.maxComponentElements = p22.uint16; 25670 this.maxComponentDepth = p22.uint16; 25671 } 25672 p22.verifyLength(); 25673 } 25674 }; 25675 var maxp$1 = Object.freeze({ __proto__: null, maxp }); 25676 var name = class extends SimpleTable { 25677 constructor(dict, dataview) { 25678 const { p: p22 } = super(dict, dataview); 25679 this.format = p22.uint16; 25680 this.count = p22.uint16; 25681 this.stringOffset = p22.Offset16; 25682 this.nameRecords = [...new Array(this.count)].map( 25683 (_) => new NameRecord(p22, this) 25684 ); 25685 if (this.format === 1) { 25686 this.langTagCount = p22.uint16; 25687 this.langTagRecords = [...new Array(this.langTagCount)].map( 25688 (_) => new LangTagRecord(p22.uint16, p22.Offset16) 25689 ); 25690 } 25691 this.stringStart = this.tableStart + this.stringOffset; 25692 } 25693 get(nameID) { 25694 let record = this.nameRecords.find( 25695 (record2) => record2.nameID === nameID 25696 ); 25697 if (record) return record.string; 25698 } 25699 }; 25700 var LangTagRecord = class { 25701 constructor(length, offset3) { 25702 this.length = length; 25703 this.offset = offset3; 25704 } 25705 }; 25706 var NameRecord = class { 25707 constructor(p22, nameTable) { 25708 this.platformID = p22.uint16; 25709 this.encodingID = p22.uint16; 25710 this.languageID = p22.uint16; 25711 this.nameID = p22.uint16; 25712 this.length = p22.uint16; 25713 this.offset = p22.Offset16; 25714 lazy$1(this, `string`, () => { 25715 p22.currentPosition = nameTable.stringStart + this.offset; 25716 return decodeString(p22, this); 25717 }); 25718 } 25719 }; 25720 function decodeString(p22, record) { 25721 const { platformID, length } = record; 25722 if (length === 0) return ``; 25723 if (platformID === 0 || platformID === 3) { 25724 const str2 = []; 25725 for (let i3 = 0, e3 = length / 2; i3 < e3; i3++) 25726 str2[i3] = String.fromCharCode(p22.uint16); 25727 return str2.join(``); 25728 } 25729 const bytes = p22.readBytes(length); 25730 const str = []; 25731 bytes.forEach(function(b3, i3) { 25732 str[i3] = String.fromCharCode(b3); 25733 }); 25734 return str.join(``); 25735 } 25736 var name$1 = Object.freeze({ __proto__: null, name }); 25737 var OS2 = class extends SimpleTable { 25738 constructor(dict, dataview) { 25739 const { p: p22 } = super(dict, dataview); 25740 this.version = p22.uint16; 25741 this.xAvgCharWidth = p22.int16; 25742 this.usWeightClass = p22.uint16; 25743 this.usWidthClass = p22.uint16; 25744 this.fsType = p22.uint16; 25745 this.ySubscriptXSize = p22.int16; 25746 this.ySubscriptYSize = p22.int16; 25747 this.ySubscriptXOffset = p22.int16; 25748 this.ySubscriptYOffset = p22.int16; 25749 this.ySuperscriptXSize = p22.int16; 25750 this.ySuperscriptYSize = p22.int16; 25751 this.ySuperscriptXOffset = p22.int16; 25752 this.ySuperscriptYOffset = p22.int16; 25753 this.yStrikeoutSize = p22.int16; 25754 this.yStrikeoutPosition = p22.int16; 25755 this.sFamilyClass = p22.int16; 25756 this.panose = [...new Array(10)].map((_) => p22.uint8); 25757 this.ulUnicodeRange1 = p22.flags(32); 25758 this.ulUnicodeRange2 = p22.flags(32); 25759 this.ulUnicodeRange3 = p22.flags(32); 25760 this.ulUnicodeRange4 = p22.flags(32); 25761 this.achVendID = p22.tag; 25762 this.fsSelection = p22.uint16; 25763 this.usFirstCharIndex = p22.uint16; 25764 this.usLastCharIndex = p22.uint16; 25765 this.sTypoAscender = p22.int16; 25766 this.sTypoDescender = p22.int16; 25767 this.sTypoLineGap = p22.int16; 25768 this.usWinAscent = p22.uint16; 25769 this.usWinDescent = p22.uint16; 25770 if (this.version === 0) return p22.verifyLength(); 25771 this.ulCodePageRange1 = p22.flags(32); 25772 this.ulCodePageRange2 = p22.flags(32); 25773 if (this.version === 1) return p22.verifyLength(); 25774 this.sxHeight = p22.int16; 25775 this.sCapHeight = p22.int16; 25776 this.usDefaultChar = p22.uint16; 25777 this.usBreakChar = p22.uint16; 25778 this.usMaxContext = p22.uint16; 25779 if (this.version <= 4) return p22.verifyLength(); 25780 this.usLowerOpticalPointSize = p22.uint16; 25781 this.usUpperOpticalPointSize = p22.uint16; 25782 if (this.version === 5) return p22.verifyLength(); 25783 } 25784 }; 25785 var OS2$1 = Object.freeze({ __proto__: null, OS2 }); 25786 var post = class extends SimpleTable { 25787 constructor(dict, dataview) { 25788 const { p: p22 } = super(dict, dataview); 25789 this.version = p22.legacyFixed; 25790 this.italicAngle = p22.fixed; 25791 this.underlinePosition = p22.fword; 25792 this.underlineThickness = p22.fword; 25793 this.isFixedPitch = p22.uint32; 25794 this.minMemType42 = p22.uint32; 25795 this.maxMemType42 = p22.uint32; 25796 this.minMemType1 = p22.uint32; 25797 this.maxMemType1 = p22.uint32; 25798 if (this.version === 1 || this.version === 3) return p22.verifyLength(); 25799 this.numGlyphs = p22.uint16; 25800 if (this.version === 2) { 25801 this.glyphNameIndex = [...new Array(this.numGlyphs)].map( 25802 (_) => p22.uint16 25803 ); 25804 this.namesOffset = p22.currentPosition; 25805 this.glyphNameOffsets = [1]; 25806 for (let i3 = 0; i3 < this.numGlyphs; i3++) { 25807 let index2 = this.glyphNameIndex[i3]; 25808 if (index2 < macStrings.length) { 25809 this.glyphNameOffsets.push(this.glyphNameOffsets[i3]); 25810 continue; 25811 } 25812 let bytelength = p22.int8; 25813 p22.skip(bytelength); 25814 this.glyphNameOffsets.push( 25815 this.glyphNameOffsets[i3] + bytelength + 1 25816 ); 25817 } 25818 } 25819 if (this.version === 2.5) { 25820 this.offset = [...new Array(this.numGlyphs)].map( 25821 (_) => p22.int8 25822 ); 25823 } 25824 } 25825 getGlyphName(glyphid) { 25826 if (this.version !== 2) { 25827 console.warn( 25828 `post table version $this.version} does not support glyph name lookups` 25829 ); 25830 return ``; 25831 } 25832 let index2 = this.glyphNameIndex[glyphid]; 25833 if (index2 < 258) return macStrings[index2]; 25834 let offset3 = this.glyphNameOffsets[glyphid]; 25835 let next = this.glyphNameOffsets[glyphid + 1]; 25836 let len = next - offset3 - 1; 25837 if (len === 0) return `.notdef.`; 25838 this.parser.currentPosition = this.namesOffset + offset3; 25839 const data = this.parser.readBytes( 25840 len, 25841 this.namesOffset + offset3, 25842 8, 25843 true 25844 ); 25845 return data.map((b3) => String.fromCharCode(b3)).join(``); 25846 } 25847 }; 25848 var macStrings = [ 25849 `.notdef`, 25850 `.null`, 25851 `nonmarkingreturn`, 25852 `space`, 25853 `exclam`, 25854 `quotedbl`, 25855 `numbersign`, 25856 `dollar`, 25857 `percent`, 25858 `ampersand`, 25859 `quotesingle`, 25860 `parenleft`, 25861 `parenright`, 25862 `asterisk`, 25863 `plus`, 25864 `comma`, 25865 `hyphen`, 25866 `period`, 25867 `slash`, 25868 `zero`, 25869 `one`, 25870 `two`, 25871 `three`, 25872 `four`, 25873 `five`, 25874 `six`, 25875 `seven`, 25876 `eight`, 25877 `nine`, 25878 `colon`, 25879 `semicolon`, 25880 `less`, 25881 `equal`, 25882 `greater`, 25883 `question`, 25884 `at`, 25885 `A`, 25886 `B`, 25887 `C`, 25888 `D`, 25889 `E`, 25890 `F`, 25891 `G`, 25892 `H`, 25893 `I`, 25894 `J`, 25895 `K`, 25896 `L`, 25897 `M`, 25898 `N`, 25899 `O`, 25900 `P`, 25901 `Q`, 25902 `R`, 25903 `S`, 25904 `T`, 25905 `U`, 25906 `V`, 25907 `W`, 25908 `X`, 25909 `Y`, 25910 `Z`, 25911 `bracketleft`, 25912 `backslash`, 25913 `bracketright`, 25914 `asciicircum`, 25915 `underscore`, 25916 `grave`, 25917 `a`, 25918 `b`, 25919 `c`, 25920 `d`, 25921 `e`, 25922 `f`, 25923 `g`, 25924 `h`, 25925 `i`, 25926 `j`, 25927 `k`, 25928 `l`, 25929 `m`, 25930 `n`, 25931 `o`, 25932 `p`, 25933 `q`, 25934 `r`, 25935 `s`, 25936 `t`, 25937 `u`, 25938 `v`, 25939 `w`, 25940 `x`, 25941 `y`, 25942 `z`, 25943 `braceleft`, 25944 `bar`, 25945 `braceright`, 25946 `asciitilde`, 25947 `Adieresis`, 25948 `Aring`, 25949 `Ccedilla`, 25950 `Eacute`, 25951 `Ntilde`, 25952 `Odieresis`, 25953 `Udieresis`, 25954 `aacute`, 25955 `agrave`, 25956 `acircumflex`, 25957 `adieresis`, 25958 `atilde`, 25959 `aring`, 25960 `ccedilla`, 25961 `eacute`, 25962 `egrave`, 25963 `ecircumflex`, 25964 `edieresis`, 25965 `iacute`, 25966 `igrave`, 25967 `icircumflex`, 25968 `idieresis`, 25969 `ntilde`, 25970 `oacute`, 25971 `ograve`, 25972 `ocircumflex`, 25973 `odieresis`, 25974 `otilde`, 25975 `uacute`, 25976 `ugrave`, 25977 `ucircumflex`, 25978 `udieresis`, 25979 `dagger`, 25980 `degree`, 25981 `cent`, 25982 `sterling`, 25983 `section`, 25984 `bullet`, 25985 `paragraph`, 25986 `germandbls`, 25987 `registered`, 25988 `copyright`, 25989 `trademark`, 25990 `acute`, 25991 `dieresis`, 25992 `notequal`, 25993 `AE`, 25994 `Oslash`, 25995 `infinity`, 25996 `plusminus`, 25997 `lessequal`, 25998 `greaterequal`, 25999 `yen`, 26000 `mu`, 26001 `partialdiff`, 26002 `summation`, 26003 `product`, 26004 `pi`, 26005 `integral`, 26006 `ordfeminine`, 26007 `ordmasculine`, 26008 `Omega`, 26009 `ae`, 26010 `oslash`, 26011 `questiondown`, 26012 `exclamdown`, 26013 `logicalnot`, 26014 `radical`, 26015 `florin`, 26016 `approxequal`, 26017 `Delta`, 26018 `guillemotleft`, 26019 `guillemotright`, 26020 `ellipsis`, 26021 `nonbreakingspace`, 26022 `Agrave`, 26023 `Atilde`, 26024 `Otilde`, 26025 `OE`, 26026 `oe`, 26027 `endash`, 26028 `emdash`, 26029 `quotedblleft`, 26030 `quotedblright`, 26031 `quoteleft`, 26032 `quoteright`, 26033 `divide`, 26034 `lozenge`, 26035 `ydieresis`, 26036 `Ydieresis`, 26037 `fraction`, 26038 `currency`, 26039 `guilsinglleft`, 26040 `guilsinglright`, 26041 `fi`, 26042 `fl`, 26043 `daggerdbl`, 26044 `periodcentered`, 26045 `quotesinglbase`, 26046 `quotedblbase`, 26047 `perthousand`, 26048 `Acircumflex`, 26049 `Ecircumflex`, 26050 `Aacute`, 26051 `Edieresis`, 26052 `Egrave`, 26053 `Iacute`, 26054 `Icircumflex`, 26055 `Idieresis`, 26056 `Igrave`, 26057 `Oacute`, 26058 `Ocircumflex`, 26059 `apple`, 26060 `Ograve`, 26061 `Uacute`, 26062 `Ucircumflex`, 26063 `Ugrave`, 26064 `dotlessi`, 26065 `circumflex`, 26066 `tilde`, 26067 `macron`, 26068 `breve`, 26069 `dotaccent`, 26070 `ring`, 26071 `cedilla`, 26072 `hungarumlaut`, 26073 `ogonek`, 26074 `caron`, 26075 `Lslash`, 26076 `lslash`, 26077 `Scaron`, 26078 `scaron`, 26079 `Zcaron`, 26080 `zcaron`, 26081 `brokenbar`, 26082 `Eth`, 26083 `eth`, 26084 `Yacute`, 26085 `yacute`, 26086 `Thorn`, 26087 `thorn`, 26088 `minus`, 26089 `multiply`, 26090 `onesuperior`, 26091 `twosuperior`, 26092 `threesuperior`, 26093 `onehalf`, 26094 `onequarter`, 26095 `threequarters`, 26096 `franc`, 26097 `Gbreve`, 26098 `gbreve`, 26099 `Idotaccent`, 26100 `Scedilla`, 26101 `scedilla`, 26102 `Cacute`, 26103 `cacute`, 26104 `Ccaron`, 26105 `ccaron`, 26106 `dcroat` 26107 ]; 26108 var post$1 = Object.freeze({ __proto__: null, post }); 26109 var BASE = class extends SimpleTable { 26110 constructor(dict, dataview) { 26111 const { p: p22 } = super(dict, dataview); 26112 this.majorVersion = p22.uint16; 26113 this.minorVersion = p22.uint16; 26114 this.horizAxisOffset = p22.Offset16; 26115 this.vertAxisOffset = p22.Offset16; 26116 lazy$1( 26117 this, 26118 `horizAxis`, 26119 () => new AxisTable( 26120 { offset: dict.offset + this.horizAxisOffset }, 26121 dataview 26122 ) 26123 ); 26124 lazy$1( 26125 this, 26126 `vertAxis`, 26127 () => new AxisTable( 26128 { offset: dict.offset + this.vertAxisOffset }, 26129 dataview 26130 ) 26131 ); 26132 if (this.majorVersion === 1 && this.minorVersion === 1) { 26133 this.itemVarStoreOffset = p22.Offset32; 26134 lazy$1( 26135 this, 26136 `itemVarStore`, 26137 () => new AxisTable( 26138 { offset: dict.offset + this.itemVarStoreOffset }, 26139 dataview 26140 ) 26141 ); 26142 } 26143 } 26144 }; 26145 var AxisTable = class extends SimpleTable { 26146 constructor(dict, dataview) { 26147 const { p: p22 } = super(dict, dataview, `AxisTable`); 26148 this.baseTagListOffset = p22.Offset16; 26149 this.baseScriptListOffset = p22.Offset16; 26150 lazy$1( 26151 this, 26152 `baseTagList`, 26153 () => new BaseTagListTable( 26154 { offset: dict.offset + this.baseTagListOffset }, 26155 dataview 26156 ) 26157 ); 26158 lazy$1( 26159 this, 26160 `baseScriptList`, 26161 () => new BaseScriptListTable( 26162 { offset: dict.offset + this.baseScriptListOffset }, 26163 dataview 26164 ) 26165 ); 26166 } 26167 }; 26168 var BaseTagListTable = class extends SimpleTable { 26169 constructor(dict, dataview) { 26170 const { p: p22 } = super(dict, dataview, `BaseTagListTable`); 26171 this.baseTagCount = p22.uint16; 26172 this.baselineTags = [...new Array(this.baseTagCount)].map( 26173 (_) => p22.tag 26174 ); 26175 } 26176 }; 26177 var BaseScriptListTable = class extends SimpleTable { 26178 constructor(dict, dataview) { 26179 const { p: p22 } = super(dict, dataview, `BaseScriptListTable`); 26180 this.baseScriptCount = p22.uint16; 26181 const recordStart = p22.currentPosition; 26182 lazy$1(this, `baseScriptRecords`, () => { 26183 p22.currentPosition = recordStart; 26184 return [...new Array(this.baseScriptCount)].map( 26185 (_) => new BaseScriptRecord(this.start, p22) 26186 ); 26187 }); 26188 } 26189 }; 26190 var BaseScriptRecord = class { 26191 constructor(baseScriptListTableStart, p22) { 26192 this.baseScriptTag = p22.tag; 26193 this.baseScriptOffset = p22.Offset16; 26194 lazy$1(this, `baseScriptTable`, () => { 26195 p22.currentPosition = baseScriptListTableStart + this.baseScriptOffset; 26196 return new BaseScriptTable(p22); 26197 }); 26198 } 26199 }; 26200 var BaseScriptTable = class { 26201 constructor(p22) { 26202 this.start = p22.currentPosition; 26203 this.baseValuesOffset = p22.Offset16; 26204 this.defaultMinMaxOffset = p22.Offset16; 26205 this.baseLangSysCount = p22.uint16; 26206 this.baseLangSysRecords = [...new Array(this.baseLangSysCount)].map( 26207 (_) => new BaseLangSysRecord(this.start, p22) 26208 ); 26209 lazy$1(this, `baseValues`, () => { 26210 p22.currentPosition = this.start + this.baseValuesOffset; 26211 return new BaseValuesTable(p22); 26212 }); 26213 lazy$1(this, `defaultMinMax`, () => { 26214 p22.currentPosition = this.start + this.defaultMinMaxOffset; 26215 return new MinMaxTable(p22); 26216 }); 26217 } 26218 }; 26219 var BaseLangSysRecord = class { 26220 constructor(baseScriptTableStart, p22) { 26221 this.baseLangSysTag = p22.tag; 26222 this.minMaxOffset = p22.Offset16; 26223 lazy$1(this, `minMax`, () => { 26224 p22.currentPosition = baseScriptTableStart + this.minMaxOffset; 26225 return new MinMaxTable(p22); 26226 }); 26227 } 26228 }; 26229 var BaseValuesTable = class { 26230 constructor(p22) { 26231 this.parser = p22; 26232 this.start = p22.currentPosition; 26233 this.defaultBaselineIndex = p22.uint16; 26234 this.baseCoordCount = p22.uint16; 26235 this.baseCoords = [...new Array(this.baseCoordCount)].map( 26236 (_) => p22.Offset16 26237 ); 26238 } 26239 getTable(id) { 26240 this.parser.currentPosition = this.start + this.baseCoords[id]; 26241 return new BaseCoordTable(this.parser); 26242 } 26243 }; 26244 var MinMaxTable = class { 26245 constructor(p22) { 26246 this.minCoord = p22.Offset16; 26247 this.maxCoord = p22.Offset16; 26248 this.featMinMaxCount = p22.uint16; 26249 const recordStart = p22.currentPosition; 26250 lazy$1(this, `featMinMaxRecords`, () => { 26251 p22.currentPosition = recordStart; 26252 return [...new Array(this.featMinMaxCount)].map( 26253 (_) => new FeatMinMaxRecord(p22) 26254 ); 26255 }); 26256 } 26257 }; 26258 var FeatMinMaxRecord = class { 26259 constructor(p22) { 26260 this.featureTableTag = p22.tag; 26261 this.minCoord = p22.Offset16; 26262 this.maxCoord = p22.Offset16; 26263 } 26264 }; 26265 var BaseCoordTable = class { 26266 constructor(p22) { 26267 this.baseCoordFormat = p22.uint16; 26268 this.coordinate = p22.int16; 26269 if (this.baseCoordFormat === 2) { 26270 this.referenceGlyph = p22.uint16; 26271 this.baseCoordPoint = p22.uint16; 26272 } 26273 if (this.baseCoordFormat === 3) { 26274 this.deviceTable = p22.Offset16; 26275 } 26276 } 26277 }; 26278 var BASE$1 = Object.freeze({ __proto__: null, BASE }); 26279 var ClassDefinition = class { 26280 constructor(p22) { 26281 this.classFormat = p22.uint16; 26282 if (this.classFormat === 1) { 26283 this.startGlyphID = p22.uint16; 26284 this.glyphCount = p22.uint16; 26285 this.classValueArray = [...new Array(this.glyphCount)].map( 26286 (_) => p22.uint16 26287 ); 26288 } 26289 if (this.classFormat === 2) { 26290 this.classRangeCount = p22.uint16; 26291 this.classRangeRecords = [ 26292 ...new Array(this.classRangeCount) 26293 ].map((_) => new ClassRangeRecord(p22)); 26294 } 26295 } 26296 }; 26297 var ClassRangeRecord = class { 26298 constructor(p22) { 26299 this.startGlyphID = p22.uint16; 26300 this.endGlyphID = p22.uint16; 26301 this.class = p22.uint16; 26302 } 26303 }; 26304 var CoverageTable = class extends ParsedData { 26305 constructor(p22) { 26306 super(p22); 26307 this.coverageFormat = p22.uint16; 26308 if (this.coverageFormat === 1) { 26309 this.glyphCount = p22.uint16; 26310 this.glyphArray = [...new Array(this.glyphCount)].map( 26311 (_) => p22.uint16 26312 ); 26313 } 26314 if (this.coverageFormat === 2) { 26315 this.rangeCount = p22.uint16; 26316 this.rangeRecords = [...new Array(this.rangeCount)].map( 26317 (_) => new CoverageRangeRecord(p22) 26318 ); 26319 } 26320 } 26321 }; 26322 var CoverageRangeRecord = class { 26323 constructor(p22) { 26324 this.startGlyphID = p22.uint16; 26325 this.endGlyphID = p22.uint16; 26326 this.startCoverageIndex = p22.uint16; 26327 } 26328 }; 26329 var ItemVariationStoreTable = class { 26330 constructor(table, p22) { 26331 this.table = table; 26332 this.parser = p22; 26333 this.start = p22.currentPosition; 26334 this.format = p22.uint16; 26335 this.variationRegionListOffset = p22.Offset32; 26336 this.itemVariationDataCount = p22.uint16; 26337 this.itemVariationDataOffsets = [ 26338 ...new Array(this.itemVariationDataCount) 26339 ].map((_) => p22.Offset32); 26340 } 26341 }; 26342 var GDEF = class extends SimpleTable { 26343 constructor(dict, dataview) { 26344 const { p: p22 } = super(dict, dataview); 26345 this.majorVersion = p22.uint16; 26346 this.minorVersion = p22.uint16; 26347 this.glyphClassDefOffset = p22.Offset16; 26348 lazy$1(this, `glyphClassDefs`, () => { 26349 if (this.glyphClassDefOffset === 0) return void 0; 26350 p22.currentPosition = this.tableStart + this.glyphClassDefOffset; 26351 return new ClassDefinition(p22); 26352 }); 26353 this.attachListOffset = p22.Offset16; 26354 lazy$1(this, `attachList`, () => { 26355 if (this.attachListOffset === 0) return void 0; 26356 p22.currentPosition = this.tableStart + this.attachListOffset; 26357 return new AttachList(p22); 26358 }); 26359 this.ligCaretListOffset = p22.Offset16; 26360 lazy$1(this, `ligCaretList`, () => { 26361 if (this.ligCaretListOffset === 0) return void 0; 26362 p22.currentPosition = this.tableStart + this.ligCaretListOffset; 26363 return new LigCaretList(p22); 26364 }); 26365 this.markAttachClassDefOffset = p22.Offset16; 26366 lazy$1(this, `markAttachClassDef`, () => { 26367 if (this.markAttachClassDefOffset === 0) return void 0; 26368 p22.currentPosition = this.tableStart + this.markAttachClassDefOffset; 26369 return new ClassDefinition(p22); 26370 }); 26371 if (this.minorVersion >= 2) { 26372 this.markGlyphSetsDefOffset = p22.Offset16; 26373 lazy$1(this, `markGlyphSetsDef`, () => { 26374 if (this.markGlyphSetsDefOffset === 0) return void 0; 26375 p22.currentPosition = this.tableStart + this.markGlyphSetsDefOffset; 26376 return new MarkGlyphSetsTable(p22); 26377 }); 26378 } 26379 if (this.minorVersion === 3) { 26380 this.itemVarStoreOffset = p22.Offset32; 26381 lazy$1(this, `itemVarStore`, () => { 26382 if (this.itemVarStoreOffset === 0) return void 0; 26383 p22.currentPosition = this.tableStart + this.itemVarStoreOffset; 26384 return new ItemVariationStoreTable(p22); 26385 }); 26386 } 26387 } 26388 }; 26389 var AttachList = class extends ParsedData { 26390 constructor(p22) { 26391 super(p22); 26392 this.coverageOffset = p22.Offset16; 26393 this.glyphCount = p22.uint16; 26394 this.attachPointOffsets = [...new Array(this.glyphCount)].map( 26395 (_) => p22.Offset16 26396 ); 26397 } 26398 getPoint(pointID) { 26399 this.parser.currentPosition = this.start + this.attachPointOffsets[pointID]; 26400 return new AttachPoint(this.parser); 26401 } 26402 }; 26403 var AttachPoint = class { 26404 constructor(p22) { 26405 this.pointCount = p22.uint16; 26406 this.pointIndices = [...new Array(this.pointCount)].map( 26407 (_) => p22.uint16 26408 ); 26409 } 26410 }; 26411 var LigCaretList = class extends ParsedData { 26412 constructor(p22) { 26413 super(p22); 26414 this.coverageOffset = p22.Offset16; 26415 lazy$1(this, `coverage`, () => { 26416 p22.currentPosition = this.start + this.coverageOffset; 26417 return new CoverageTable(p22); 26418 }); 26419 this.ligGlyphCount = p22.uint16; 26420 this.ligGlyphOffsets = [...new Array(this.ligGlyphCount)].map( 26421 (_) => p22.Offset16 26422 ); 26423 } 26424 getLigGlyph(ligGlyphID) { 26425 this.parser.currentPosition = this.start + this.ligGlyphOffsets[ligGlyphID]; 26426 return new LigGlyph(this.parser); 26427 } 26428 }; 26429 var LigGlyph = class extends ParsedData { 26430 constructor(p22) { 26431 super(p22); 26432 this.caretCount = p22.uint16; 26433 this.caretValueOffsets = [...new Array(this.caretCount)].map( 26434 (_) => p22.Offset16 26435 ); 26436 } 26437 getCaretValue(caretID) { 26438 this.parser.currentPosition = this.start + this.caretValueOffsets[caretID]; 26439 return new CaretValue(this.parser); 26440 } 26441 }; 26442 var CaretValue = class { 26443 constructor(p22) { 26444 this.caretValueFormat = p22.uint16; 26445 if (this.caretValueFormat === 1) { 26446 this.coordinate = p22.int16; 26447 } 26448 if (this.caretValueFormat === 2) { 26449 this.caretValuePointIndex = p22.uint16; 26450 } 26451 if (this.caretValueFormat === 3) { 26452 this.coordinate = p22.int16; 26453 this.deviceOffset = p22.Offset16; 26454 } 26455 } 26456 }; 26457 var MarkGlyphSetsTable = class extends ParsedData { 26458 constructor(p22) { 26459 super(p22); 26460 this.markGlyphSetTableFormat = p22.uint16; 26461 this.markGlyphSetCount = p22.uint16; 26462 this.coverageOffsets = [...new Array(this.markGlyphSetCount)].map( 26463 (_) => p22.Offset32 26464 ); 26465 } 26466 getMarkGlyphSet(markGlyphSetID) { 26467 this.parser.currentPosition = this.start + this.coverageOffsets[markGlyphSetID]; 26468 return new CoverageTable(this.parser); 26469 } 26470 }; 26471 var GDEF$1 = Object.freeze({ __proto__: null, GDEF }); 26472 var ScriptList = class extends ParsedData { 26473 static EMPTY = { scriptCount: 0, scriptRecords: [] }; 26474 constructor(p22) { 26475 super(p22); 26476 this.scriptCount = p22.uint16; 26477 this.scriptRecords = [...new Array(this.scriptCount)].map( 26478 (_) => new ScriptRecord(p22) 26479 ); 26480 } 26481 }; 26482 var ScriptRecord = class { 26483 constructor(p22) { 26484 this.scriptTag = p22.tag; 26485 this.scriptOffset = p22.Offset16; 26486 } 26487 }; 26488 var ScriptTable = class extends ParsedData { 26489 constructor(p22) { 26490 super(p22); 26491 this.defaultLangSys = p22.Offset16; 26492 this.langSysCount = p22.uint16; 26493 this.langSysRecords = [...new Array(this.langSysCount)].map( 26494 (_) => new LangSysRecord(p22) 26495 ); 26496 } 26497 }; 26498 var LangSysRecord = class { 26499 constructor(p22) { 26500 this.langSysTag = p22.tag; 26501 this.langSysOffset = p22.Offset16; 26502 } 26503 }; 26504 var LangSysTable = class { 26505 constructor(p22) { 26506 this.lookupOrder = p22.Offset16; 26507 this.requiredFeatureIndex = p22.uint16; 26508 this.featureIndexCount = p22.uint16; 26509 this.featureIndices = [...new Array(this.featureIndexCount)].map( 26510 (_) => p22.uint16 26511 ); 26512 } 26513 }; 26514 var FeatureList = class extends ParsedData { 26515 static EMPTY = { featureCount: 0, featureRecords: [] }; 26516 constructor(p22) { 26517 super(p22); 26518 this.featureCount = p22.uint16; 26519 this.featureRecords = [...new Array(this.featureCount)].map( 26520 (_) => new FeatureRecord(p22) 26521 ); 26522 } 26523 }; 26524 var FeatureRecord = class { 26525 constructor(p22) { 26526 this.featureTag = p22.tag; 26527 this.featureOffset = p22.Offset16; 26528 } 26529 }; 26530 var FeatureTable = class extends ParsedData { 26531 constructor(p22) { 26532 super(p22); 26533 this.featureParams = p22.Offset16; 26534 this.lookupIndexCount = p22.uint16; 26535 this.lookupListIndices = [...new Array(this.lookupIndexCount)].map( 26536 (_) => p22.uint16 26537 ); 26538 } 26539 getFeatureParams() { 26540 if (this.featureParams > 0) { 26541 const p22 = this.parser; 26542 p22.currentPosition = this.start + this.featureParams; 26543 const tag = this.featureTag; 26544 if (tag === `size`) return new Size(p22); 26545 if (tag.startsWith(`cc`)) return new CharacterVariant(p22); 26546 if (tag.startsWith(`ss`)) return new StylisticSet(p22); 26547 } 26548 } 26549 }; 26550 var CharacterVariant = class { 26551 constructor(p22) { 26552 this.format = p22.uint16; 26553 this.featUiLabelNameId = p22.uint16; 26554 this.featUiTooltipTextNameId = p22.uint16; 26555 this.sampleTextNameId = p22.uint16; 26556 this.numNamedParameters = p22.uint16; 26557 this.firstParamUiLabelNameId = p22.uint16; 26558 this.charCount = p22.uint16; 26559 this.character = [...new Array(this.charCount)].map( 26560 (_) => p22.uint24 26561 ); 26562 } 26563 }; 26564 var Size = class { 26565 constructor(p22) { 26566 this.designSize = p22.uint16; 26567 this.subfamilyIdentifier = p22.uint16; 26568 this.subfamilyNameID = p22.uint16; 26569 this.smallEnd = p22.uint16; 26570 this.largeEnd = p22.uint16; 26571 } 26572 }; 26573 var StylisticSet = class { 26574 constructor(p22) { 26575 this.version = p22.uint16; 26576 this.UINameID = p22.uint16; 26577 } 26578 }; 26579 function undoCoverageOffsetParsing(instance) { 26580 instance.parser.currentPosition -= 2; 26581 delete instance.coverageOffset; 26582 delete instance.getCoverageTable; 26583 } 26584 var LookupType$1 = class extends ParsedData { 26585 constructor(p22) { 26586 super(p22); 26587 this.substFormat = p22.uint16; 26588 this.coverageOffset = p22.Offset16; 26589 } 26590 getCoverageTable() { 26591 let p22 = this.parser; 26592 p22.currentPosition = this.start + this.coverageOffset; 26593 return new CoverageTable(p22); 26594 } 26595 }; 26596 var SubstLookupRecord = class { 26597 constructor(p22) { 26598 this.glyphSequenceIndex = p22.uint16; 26599 this.lookupListIndex = p22.uint16; 26600 } 26601 }; 26602 var LookupType1$1 = class extends LookupType$1 { 26603 constructor(p22) { 26604 super(p22); 26605 this.deltaGlyphID = p22.int16; 26606 } 26607 }; 26608 var LookupType2$1 = class extends LookupType$1 { 26609 constructor(p22) { 26610 super(p22); 26611 this.sequenceCount = p22.uint16; 26612 this.sequenceOffsets = [...new Array(this.sequenceCount)].map( 26613 (_) => p22.Offset16 26614 ); 26615 } 26616 getSequence(index2) { 26617 let p22 = this.parser; 26618 p22.currentPosition = this.start + this.sequenceOffsets[index2]; 26619 return new SequenceTable(p22); 26620 } 26621 }; 26622 var SequenceTable = class { 26623 constructor(p22) { 26624 this.glyphCount = p22.uint16; 26625 this.substituteGlyphIDs = [...new Array(this.glyphCount)].map( 26626 (_) => p22.uint16 26627 ); 26628 } 26629 }; 26630 var LookupType3$1 = class extends LookupType$1 { 26631 constructor(p22) { 26632 super(p22); 26633 this.alternateSetCount = p22.uint16; 26634 this.alternateSetOffsets = [ 26635 ...new Array(this.alternateSetCount) 26636 ].map((_) => p22.Offset16); 26637 } 26638 getAlternateSet(index2) { 26639 let p22 = this.parser; 26640 p22.currentPosition = this.start + this.alternateSetOffsets[index2]; 26641 return new AlternateSetTable(p22); 26642 } 26643 }; 26644 var AlternateSetTable = class { 26645 constructor(p22) { 26646 this.glyphCount = p22.uint16; 26647 this.alternateGlyphIDs = [...new Array(this.glyphCount)].map( 26648 (_) => p22.uint16 26649 ); 26650 } 26651 }; 26652 var LookupType4$1 = class extends LookupType$1 { 26653 constructor(p22) { 26654 super(p22); 26655 this.ligatureSetCount = p22.uint16; 26656 this.ligatureSetOffsets = [...new Array(this.ligatureSetCount)].map( 26657 (_) => p22.Offset16 26658 ); 26659 } 26660 getLigatureSet(index2) { 26661 let p22 = this.parser; 26662 p22.currentPosition = this.start + this.ligatureSetOffsets[index2]; 26663 return new LigatureSetTable(p22); 26664 } 26665 }; 26666 var LigatureSetTable = class extends ParsedData { 26667 constructor(p22) { 26668 super(p22); 26669 this.ligatureCount = p22.uint16; 26670 this.ligatureOffsets = [...new Array(this.ligatureCount)].map( 26671 (_) => p22.Offset16 26672 ); 26673 } 26674 getLigature(index2) { 26675 let p22 = this.parser; 26676 p22.currentPosition = this.start + this.ligatureOffsets[index2]; 26677 return new LigatureTable(p22); 26678 } 26679 }; 26680 var LigatureTable = class { 26681 constructor(p22) { 26682 this.ligatureGlyph = p22.uint16; 26683 this.componentCount = p22.uint16; 26684 this.componentGlyphIDs = [ 26685 ...new Array(this.componentCount - 1) 26686 ].map((_) => p22.uint16); 26687 } 26688 }; 26689 var LookupType5$1 = class extends LookupType$1 { 26690 constructor(p22) { 26691 super(p22); 26692 if (this.substFormat === 1) { 26693 this.subRuleSetCount = p22.uint16; 26694 this.subRuleSetOffsets = [ 26695 ...new Array(this.subRuleSetCount) 26696 ].map((_) => p22.Offset16); 26697 } 26698 if (this.substFormat === 2) { 26699 this.classDefOffset = p22.Offset16; 26700 this.subClassSetCount = p22.uint16; 26701 this.subClassSetOffsets = [ 26702 ...new Array(this.subClassSetCount) 26703 ].map((_) => p22.Offset16); 26704 } 26705 if (this.substFormat === 3) { 26706 undoCoverageOffsetParsing(this); 26707 this.glyphCount = p22.uint16; 26708 this.substitutionCount = p22.uint16; 26709 this.coverageOffsets = [...new Array(this.glyphCount)].map( 26710 (_) => p22.Offset16 26711 ); 26712 this.substLookupRecords = [ 26713 ...new Array(this.substitutionCount) 26714 ].map((_) => new SubstLookupRecord(p22)); 26715 } 26716 } 26717 getSubRuleSet(index2) { 26718 if (this.substFormat !== 1) 26719 throw new Error( 26720 `lookup type 5.$this.substFormat} has no subrule sets.` 26721 ); 26722 let p22 = this.parser; 26723 p22.currentPosition = this.start + this.subRuleSetOffsets[index2]; 26724 return new SubRuleSetTable(p22); 26725 } 26726 getSubClassSet(index2) { 26727 if (this.substFormat !== 2) 26728 throw new Error( 26729 `lookup type 5.$this.substFormat} has no subclass sets.` 26730 ); 26731 let p22 = this.parser; 26732 p22.currentPosition = this.start + this.subClassSetOffsets[index2]; 26733 return new SubClassSetTable(p22); 26734 } 26735 getCoverageTable(index2) { 26736 if (this.substFormat !== 3 && !index2) 26737 return super.getCoverageTable(); 26738 if (!index2) 26739 throw new Error( 26740 `lookup type 5.$this.substFormat} requires an coverage table index.` 26741 ); 26742 let p22 = this.parser; 26743 p22.currentPosition = this.start + this.coverageOffsets[index2]; 26744 return new CoverageTable(p22); 26745 } 26746 }; 26747 var SubRuleSetTable = class extends ParsedData { 26748 constructor(p22) { 26749 super(p22); 26750 this.subRuleCount = p22.uint16; 26751 this.subRuleOffsets = [...new Array(this.subRuleCount)].map( 26752 (_) => p22.Offset16 26753 ); 26754 } 26755 getSubRule(index2) { 26756 let p22 = this.parser; 26757 p22.currentPosition = this.start + this.subRuleOffsets[index2]; 26758 return new SubRuleTable(p22); 26759 } 26760 }; 26761 var SubRuleTable = class { 26762 constructor(p22) { 26763 this.glyphCount = p22.uint16; 26764 this.substitutionCount = p22.uint16; 26765 this.inputSequence = [...new Array(this.glyphCount - 1)].map( 26766 (_) => p22.uint16 26767 ); 26768 this.substLookupRecords = [ 26769 ...new Array(this.substitutionCount) 26770 ].map((_) => new SubstLookupRecord(p22)); 26771 } 26772 }; 26773 var SubClassSetTable = class extends ParsedData { 26774 constructor(p22) { 26775 super(p22); 26776 this.subClassRuleCount = p22.uint16; 26777 this.subClassRuleOffsets = [ 26778 ...new Array(this.subClassRuleCount) 26779 ].map((_) => p22.Offset16); 26780 } 26781 getSubClass(index2) { 26782 let p22 = this.parser; 26783 p22.currentPosition = this.start + this.subClassRuleOffsets[index2]; 26784 return new SubClassRuleTable(p22); 26785 } 26786 }; 26787 var SubClassRuleTable = class extends SubRuleTable { 26788 constructor(p22) { 26789 super(p22); 26790 } 26791 }; 26792 var LookupType6$1 = class extends LookupType$1 { 26793 constructor(p22) { 26794 super(p22); 26795 if (this.substFormat === 1) { 26796 this.chainSubRuleSetCount = p22.uint16; 26797 this.chainSubRuleSetOffsets = [ 26798 ...new Array(this.chainSubRuleSetCount) 26799 ].map((_) => p22.Offset16); 26800 } 26801 if (this.substFormat === 2) { 26802 this.backtrackClassDefOffset = p22.Offset16; 26803 this.inputClassDefOffset = p22.Offset16; 26804 this.lookaheadClassDefOffset = p22.Offset16; 26805 this.chainSubClassSetCount = p22.uint16; 26806 this.chainSubClassSetOffsets = [ 26807 ...new Array(this.chainSubClassSetCount) 26808 ].map((_) => p22.Offset16); 26809 } 26810 if (this.substFormat === 3) { 26811 undoCoverageOffsetParsing(this); 26812 this.backtrackGlyphCount = p22.uint16; 26813 this.backtrackCoverageOffsets = [ 26814 ...new Array(this.backtrackGlyphCount) 26815 ].map((_) => p22.Offset16); 26816 this.inputGlyphCount = p22.uint16; 26817 this.inputCoverageOffsets = [ 26818 ...new Array(this.inputGlyphCount) 26819 ].map((_) => p22.Offset16); 26820 this.lookaheadGlyphCount = p22.uint16; 26821 this.lookaheadCoverageOffsets = [ 26822 ...new Array(this.lookaheadGlyphCount) 26823 ].map((_) => p22.Offset16); 26824 this.seqLookupCount = p22.uint16; 26825 this.seqLookupRecords = [ 26826 ...new Array(this.substitutionCount) 26827 ].map((_) => new SequenceLookupRecord(p22)); 26828 } 26829 } 26830 getChainSubRuleSet(index2) { 26831 if (this.substFormat !== 1) 26832 throw new Error( 26833 `lookup type 6.$this.substFormat} has no chainsubrule sets.` 26834 ); 26835 let p22 = this.parser; 26836 p22.currentPosition = this.start + this.chainSubRuleSetOffsets[index2]; 26837 return new ChainSubRuleSetTable(p22); 26838 } 26839 getChainSubClassSet(index2) { 26840 if (this.substFormat !== 2) 26841 throw new Error( 26842 `lookup type 6.$this.substFormat} has no chainsubclass sets.` 26843 ); 26844 let p22 = this.parser; 26845 p22.currentPosition = this.start + this.chainSubClassSetOffsets[index2]; 26846 return new ChainSubClassSetTable(p22); 26847 } 26848 getCoverageFromOffset(offset3) { 26849 if (this.substFormat !== 3) 26850 throw new Error( 26851 `lookup type 6.$this.substFormat} does not use contextual coverage offsets.` 26852 ); 26853 let p22 = this.parser; 26854 p22.currentPosition = this.start + offset3; 26855 return new CoverageTable(p22); 26856 } 26857 }; 26858 var ChainSubRuleSetTable = class extends ParsedData { 26859 constructor(p22) { 26860 super(p22); 26861 this.chainSubRuleCount = p22.uint16; 26862 this.chainSubRuleOffsets = [ 26863 ...new Array(this.chainSubRuleCount) 26864 ].map((_) => p22.Offset16); 26865 } 26866 getSubRule(index2) { 26867 let p22 = this.parser; 26868 p22.currentPosition = this.start + this.chainSubRuleOffsets[index2]; 26869 return new ChainSubRuleTable(p22); 26870 } 26871 }; 26872 var ChainSubRuleTable = class { 26873 constructor(p22) { 26874 this.backtrackGlyphCount = p22.uint16; 26875 this.backtrackSequence = [ 26876 ...new Array(this.backtrackGlyphCount) 26877 ].map((_) => p22.uint16); 26878 this.inputGlyphCount = p22.uint16; 26879 this.inputSequence = [...new Array(this.inputGlyphCount - 1)].map( 26880 (_) => p22.uint16 26881 ); 26882 this.lookaheadGlyphCount = p22.uint16; 26883 this.lookAheadSequence = [ 26884 ...new Array(this.lookAheadGlyphCount) 26885 ].map((_) => p22.uint16); 26886 this.substitutionCount = p22.uint16; 26887 this.substLookupRecords = [...new Array(this.SubstCount)].map( 26888 (_) => new SubstLookupRecord(p22) 26889 ); 26890 } 26891 }; 26892 var ChainSubClassSetTable = class extends ParsedData { 26893 constructor(p22) { 26894 super(p22); 26895 this.chainSubClassRuleCount = p22.uint16; 26896 this.chainSubClassRuleOffsets = [ 26897 ...new Array(this.chainSubClassRuleCount) 26898 ].map((_) => p22.Offset16); 26899 } 26900 getSubClass(index2) { 26901 let p22 = this.parser; 26902 p22.currentPosition = this.start + this.chainSubRuleOffsets[index2]; 26903 return new ChainSubClassRuleTable(p22); 26904 } 26905 }; 26906 var ChainSubClassRuleTable = class { 26907 constructor(p22) { 26908 this.backtrackGlyphCount = p22.uint16; 26909 this.backtrackSequence = [ 26910 ...new Array(this.backtrackGlyphCount) 26911 ].map((_) => p22.uint16); 26912 this.inputGlyphCount = p22.uint16; 26913 this.inputSequence = [...new Array(this.inputGlyphCount - 1)].map( 26914 (_) => p22.uint16 26915 ); 26916 this.lookaheadGlyphCount = p22.uint16; 26917 this.lookAheadSequence = [ 26918 ...new Array(this.lookAheadGlyphCount) 26919 ].map((_) => p22.uint16); 26920 this.substitutionCount = p22.uint16; 26921 this.substLookupRecords = [ 26922 ...new Array(this.substitutionCount) 26923 ].map((_) => new SequenceLookupRecord(p22)); 26924 } 26925 }; 26926 var SequenceLookupRecord = class extends ParsedData { 26927 constructor(p22) { 26928 super(p22); 26929 this.sequenceIndex = p22.uint16; 26930 this.lookupListIndex = p22.uint16; 26931 } 26932 }; 26933 var LookupType7$1 = class extends ParsedData { 26934 constructor(p22) { 26935 super(p22); 26936 this.substFormat = p22.uint16; 26937 this.extensionLookupType = p22.uint16; 26938 this.extensionOffset = p22.Offset32; 26939 } 26940 }; 26941 var LookupType8$1 = class extends LookupType$1 { 26942 constructor(p22) { 26943 super(p22); 26944 this.backtrackGlyphCount = p22.uint16; 26945 this.backtrackCoverageOffsets = [ 26946 ...new Array(this.backtrackGlyphCount) 26947 ].map((_) => p22.Offset16); 26948 this.lookaheadGlyphCount = p22.uint16; 26949 this.lookaheadCoverageOffsets = [ 26950 new Array(this.lookaheadGlyphCount) 26951 ].map((_) => p22.Offset16); 26952 this.glyphCount = p22.uint16; 26953 this.substituteGlyphIDs = [...new Array(this.glyphCount)].map( 26954 (_) => p22.uint16 26955 ); 26956 } 26957 }; 26958 var GSUBtables = { 26959 buildSubtable: function(type, p22) { 26960 const subtable = new [ 26961 void 0, 26962 LookupType1$1, 26963 LookupType2$1, 26964 LookupType3$1, 26965 LookupType4$1, 26966 LookupType5$1, 26967 LookupType6$1, 26968 LookupType7$1, 26969 LookupType8$1 26970 ][type](p22); 26971 subtable.type = type; 26972 return subtable; 26973 } 26974 }; 26975 var LookupType = class extends ParsedData { 26976 constructor(p22) { 26977 super(p22); 26978 } 26979 }; 26980 var LookupType1 = class extends LookupType { 26981 constructor(p22) { 26982 super(p22); 26983 console.log(`lookup type 1`); 26984 } 26985 }; 26986 var LookupType2 = class extends LookupType { 26987 constructor(p22) { 26988 super(p22); 26989 console.log(`lookup type 2`); 26990 } 26991 }; 26992 var LookupType3 = class extends LookupType { 26993 constructor(p22) { 26994 super(p22); 26995 console.log(`lookup type 3`); 26996 } 26997 }; 26998 var LookupType4 = class extends LookupType { 26999 constructor(p22) { 27000 super(p22); 27001 console.log(`lookup type 4`); 27002 } 27003 }; 27004 var LookupType5 = class extends LookupType { 27005 constructor(p22) { 27006 super(p22); 27007 console.log(`lookup type 5`); 27008 } 27009 }; 27010 var LookupType6 = class extends LookupType { 27011 constructor(p22) { 27012 super(p22); 27013 console.log(`lookup type 6`); 27014 } 27015 }; 27016 var LookupType7 = class extends LookupType { 27017 constructor(p22) { 27018 super(p22); 27019 console.log(`lookup type 7`); 27020 } 27021 }; 27022 var LookupType8 = class extends LookupType { 27023 constructor(p22) { 27024 super(p22); 27025 console.log(`lookup type 8`); 27026 } 27027 }; 27028 var LookupType9 = class extends LookupType { 27029 constructor(p22) { 27030 super(p22); 27031 console.log(`lookup type 9`); 27032 } 27033 }; 27034 var GPOStables = { 27035 buildSubtable: function(type, p22) { 27036 const subtable = new [ 27037 void 0, 27038 LookupType1, 27039 LookupType2, 27040 LookupType3, 27041 LookupType4, 27042 LookupType5, 27043 LookupType6, 27044 LookupType7, 27045 LookupType8, 27046 LookupType9 27047 ][type](p22); 27048 subtable.type = type; 27049 return subtable; 27050 } 27051 }; 27052 var LookupList = class extends ParsedData { 27053 static EMPTY = { lookupCount: 0, lookups: [] }; 27054 constructor(p22) { 27055 super(p22); 27056 this.lookupCount = p22.uint16; 27057 this.lookups = [...new Array(this.lookupCount)].map( 27058 (_) => p22.Offset16 27059 ); 27060 } 27061 }; 27062 var LookupTable = class extends ParsedData { 27063 constructor(p22, type) { 27064 super(p22); 27065 this.ctType = type; 27066 this.lookupType = p22.uint16; 27067 this.lookupFlag = p22.uint16; 27068 this.subTableCount = p22.uint16; 27069 this.subtableOffsets = [...new Array(this.subTableCount)].map( 27070 (_) => p22.Offset16 27071 ); 27072 this.markFilteringSet = p22.uint16; 27073 } 27074 get rightToLeft() { 27075 return this.lookupFlag & true; 27076 } 27077 get ignoreBaseGlyphs() { 27078 return this.lookupFlag & true; 27079 } 27080 get ignoreLigatures() { 27081 return this.lookupFlag & true; 27082 } 27083 get ignoreMarks() { 27084 return this.lookupFlag & true; 27085 } 27086 get useMarkFilteringSet() { 27087 return this.lookupFlag & true; 27088 } 27089 get markAttachmentType() { 27090 return this.lookupFlag & true; 27091 } 27092 getSubTable(index2) { 27093 const builder = this.ctType === `GSUB` ? GSUBtables : GPOStables; 27094 this.parser.currentPosition = this.start + this.subtableOffsets[index2]; 27095 return builder.buildSubtable(this.lookupType, this.parser); 27096 } 27097 }; 27098 var CommonLayoutTable = class extends SimpleTable { 27099 constructor(dict, dataview, name2) { 27100 const { p: p22, tableStart } = super(dict, dataview, name2); 27101 this.majorVersion = p22.uint16; 27102 this.minorVersion = p22.uint16; 27103 this.scriptListOffset = p22.Offset16; 27104 this.featureListOffset = p22.Offset16; 27105 this.lookupListOffset = p22.Offset16; 27106 if (this.majorVersion === 1 && this.minorVersion === 1) { 27107 this.featureVariationsOffset = p22.Offset32; 27108 } 27109 const no_content = !(this.scriptListOffset || this.featureListOffset || this.lookupListOffset); 27110 lazy$1(this, `scriptList`, () => { 27111 if (no_content) return ScriptList.EMPTY; 27112 p22.currentPosition = tableStart + this.scriptListOffset; 27113 return new ScriptList(p22); 27114 }); 27115 lazy$1(this, `featureList`, () => { 27116 if (no_content) return FeatureList.EMPTY; 27117 p22.currentPosition = tableStart + this.featureListOffset; 27118 return new FeatureList(p22); 27119 }); 27120 lazy$1(this, `lookupList`, () => { 27121 if (no_content) return LookupList.EMPTY; 27122 p22.currentPosition = tableStart + this.lookupListOffset; 27123 return new LookupList(p22); 27124 }); 27125 if (this.featureVariationsOffset) { 27126 lazy$1(this, `featureVariations`, () => { 27127 if (no_content) return FeatureVariations.EMPTY; 27128 p22.currentPosition = tableStart + this.featureVariationsOffset; 27129 return new FeatureVariations(p22); 27130 }); 27131 } 27132 } 27133 getSupportedScripts() { 27134 return this.scriptList.scriptRecords.map((r4) => r4.scriptTag); 27135 } 27136 getScriptTable(scriptTag) { 27137 let record = this.scriptList.scriptRecords.find( 27138 (r4) => r4.scriptTag === scriptTag 27139 ); 27140 this.parser.currentPosition = this.scriptList.start + record.scriptOffset; 27141 let table = new ScriptTable(this.parser); 27142 table.scriptTag = scriptTag; 27143 return table; 27144 } 27145 ensureScriptTable(arg) { 27146 if (typeof arg === "string") { 27147 return this.getScriptTable(arg); 27148 } 27149 return arg; 27150 } 27151 getSupportedLangSys(scriptTable) { 27152 scriptTable = this.ensureScriptTable(scriptTable); 27153 const hasDefault = scriptTable.defaultLangSys !== 0; 27154 const supported = scriptTable.langSysRecords.map( 27155 (l3) => l3.langSysTag 27156 ); 27157 if (hasDefault) supported.unshift(`dflt`); 27158 return supported; 27159 } 27160 getDefaultLangSysTable(scriptTable) { 27161 scriptTable = this.ensureScriptTable(scriptTable); 27162 let offset3 = scriptTable.defaultLangSys; 27163 if (offset3 !== 0) { 27164 this.parser.currentPosition = scriptTable.start + offset3; 27165 let table = new LangSysTable(this.parser); 27166 table.langSysTag = ``; 27167 table.defaultForScript = scriptTable.scriptTag; 27168 return table; 27169 } 27170 } 27171 getLangSysTable(scriptTable, langSysTag = `dflt`) { 27172 if (langSysTag === `dflt`) 27173 return this.getDefaultLangSysTable(scriptTable); 27174 scriptTable = this.ensureScriptTable(scriptTable); 27175 let record = scriptTable.langSysRecords.find( 27176 (l3) => l3.langSysTag === langSysTag 27177 ); 27178 this.parser.currentPosition = scriptTable.start + record.langSysOffset; 27179 let table = new LangSysTable(this.parser); 27180 table.langSysTag = langSysTag; 27181 return table; 27182 } 27183 getFeatures(langSysTable) { 27184 return langSysTable.featureIndices.map( 27185 (index2) => this.getFeature(index2) 27186 ); 27187 } 27188 getFeature(indexOrTag) { 27189 let record; 27190 if (parseInt(indexOrTag) == indexOrTag) { 27191 record = this.featureList.featureRecords[indexOrTag]; 27192 } else { 27193 record = this.featureList.featureRecords.find( 27194 (f3) => f3.featureTag === indexOrTag 27195 ); 27196 } 27197 if (!record) return; 27198 this.parser.currentPosition = this.featureList.start + record.featureOffset; 27199 let table = new FeatureTable(this.parser); 27200 table.featureTag = record.featureTag; 27201 return table; 27202 } 27203 getLookups(featureTable) { 27204 return featureTable.lookupListIndices.map( 27205 (index2) => this.getLookup(index2) 27206 ); 27207 } 27208 getLookup(lookupIndex, type) { 27209 let lookupOffset = this.lookupList.lookups[lookupIndex]; 27210 this.parser.currentPosition = this.lookupList.start + lookupOffset; 27211 return new LookupTable(this.parser, type); 27212 } 27213 }; 27214 var GSUB = class extends CommonLayoutTable { 27215 constructor(dict, dataview) { 27216 super(dict, dataview, `GSUB`); 27217 } 27218 getLookup(lookupIndex) { 27219 return super.getLookup(lookupIndex, `GSUB`); 27220 } 27221 }; 27222 var GSUB$1 = Object.freeze({ __proto__: null, GSUB }); 27223 var GPOS = class extends CommonLayoutTable { 27224 constructor(dict, dataview) { 27225 super(dict, dataview, `GPOS`); 27226 } 27227 getLookup(lookupIndex) { 27228 return super.getLookup(lookupIndex, `GPOS`); 27229 } 27230 }; 27231 var GPOS$1 = Object.freeze({ __proto__: null, GPOS }); 27232 var SVG67 = class extends SimpleTable { 27233 constructor(dict, dataview) { 27234 const { p: p22 } = super(dict, dataview); 27235 this.version = p22.uint16; 27236 this.offsetToSVGDocumentList = p22.Offset32; 27237 p22.currentPosition = this.tableStart + this.offsetToSVGDocumentList; 27238 this.documentList = new SVGDocumentList(p22); 27239 } 27240 }; 27241 var SVGDocumentList = class extends ParsedData { 27242 constructor(p22) { 27243 super(p22); 27244 this.numEntries = p22.uint16; 27245 this.documentRecords = [...new Array(this.numEntries)].map( 27246 (_) => new SVGDocumentRecord(p22) 27247 ); 27248 } 27249 getDocument(documentID) { 27250 let record = this.documentRecords[documentID]; 27251 if (!record) return ""; 27252 let offset3 = this.start + record.svgDocOffset; 27253 this.parser.currentPosition = offset3; 27254 return this.parser.readBytes(record.svgDocLength); 27255 } 27256 getDocumentForGlyph(glyphID) { 27257 let id = this.documentRecords.findIndex( 27258 (d3) => d3.startGlyphID <= glyphID && glyphID <= d3.endGlyphID 27259 ); 27260 if (id === -1) return ""; 27261 return this.getDocument(id); 27262 } 27263 }; 27264 var SVGDocumentRecord = class { 27265 constructor(p22) { 27266 this.startGlyphID = p22.uint16; 27267 this.endGlyphID = p22.uint16; 27268 this.svgDocOffset = p22.Offset32; 27269 this.svgDocLength = p22.uint32; 27270 } 27271 }; 27272 var SVG$1 = Object.freeze({ __proto__: null, SVG: SVG67 }); 27273 var fvar = class extends SimpleTable { 27274 constructor(dict, dataview) { 27275 const { p: p22 } = super(dict, dataview); 27276 this.majorVersion = p22.uint16; 27277 this.minorVersion = p22.uint16; 27278 this.axesArrayOffset = p22.Offset16; 27279 p22.uint16; 27280 this.axisCount = p22.uint16; 27281 this.axisSize = p22.uint16; 27282 this.instanceCount = p22.uint16; 27283 this.instanceSize = p22.uint16; 27284 const axisStart = this.tableStart + this.axesArrayOffset; 27285 lazy$1(this, `axes`, () => { 27286 p22.currentPosition = axisStart; 27287 return [...new Array(this.axisCount)].map( 27288 (_) => new VariationAxisRecord(p22) 27289 ); 27290 }); 27291 const instanceStart = axisStart + this.axisCount * this.axisSize; 27292 lazy$1(this, `instances`, () => { 27293 let instances = []; 27294 for (let i3 = 0; i3 < this.instanceCount; i3++) { 27295 p22.currentPosition = instanceStart + i3 * this.instanceSize; 27296 instances.push( 27297 new InstanceRecord(p22, this.axisCount, this.instanceSize) 27298 ); 27299 } 27300 return instances; 27301 }); 27302 } 27303 getSupportedAxes() { 27304 return this.axes.map((a3) => a3.tag); 27305 } 27306 getAxis(name2) { 27307 return this.axes.find((a3) => a3.tag === name2); 27308 } 27309 }; 27310 var VariationAxisRecord = class { 27311 constructor(p22) { 27312 this.tag = p22.tag; 27313 this.minValue = p22.fixed; 27314 this.defaultValue = p22.fixed; 27315 this.maxValue = p22.fixed; 27316 this.flags = p22.flags(16); 27317 this.axisNameID = p22.uint16; 27318 } 27319 }; 27320 var InstanceRecord = class { 27321 constructor(p22, axisCount, size3) { 27322 let start = p22.currentPosition; 27323 this.subfamilyNameID = p22.uint16; 27324 p22.uint16; 27325 this.coordinates = [...new Array(axisCount)].map( 27326 (_) => p22.fixed 27327 ); 27328 if (p22.currentPosition - start < size3) { 27329 this.postScriptNameID = p22.uint16; 27330 } 27331 } 27332 }; 27333 var fvar$1 = Object.freeze({ __proto__: null, fvar }); 27334 var cvt = class extends SimpleTable { 27335 constructor(dict, dataview) { 27336 const { p: p22 } = super(dict, dataview); 27337 const n3 = dict.length / 2; 27338 lazy$1( 27339 this, 27340 `items`, 27341 () => [...new Array(n3)].map((_) => p22.fword) 27342 ); 27343 } 27344 }; 27345 var cvt$1 = Object.freeze({ __proto__: null, cvt }); 27346 var fpgm = class extends SimpleTable { 27347 constructor(dict, dataview) { 27348 const { p: p22 } = super(dict, dataview); 27349 lazy$1( 27350 this, 27351 `instructions`, 27352 () => [...new Array(dict.length)].map((_) => p22.uint8) 27353 ); 27354 } 27355 }; 27356 var fpgm$1 = Object.freeze({ __proto__: null, fpgm }); 27357 var gasp = class extends SimpleTable { 27358 constructor(dict, dataview) { 27359 const { p: p22 } = super(dict, dataview); 27360 this.version = p22.uint16; 27361 this.numRanges = p22.uint16; 27362 const getter = () => [...new Array(this.numRanges)].map( 27363 (_) => new GASPRange(p22) 27364 ); 27365 lazy$1(this, `gaspRanges`, getter); 27366 } 27367 }; 27368 var GASPRange = class { 27369 constructor(p22) { 27370 this.rangeMaxPPEM = p22.uint16; 27371 this.rangeGaspBehavior = p22.uint16; 27372 } 27373 }; 27374 var gasp$1 = Object.freeze({ __proto__: null, gasp }); 27375 var glyf = class extends SimpleTable { 27376 constructor(dict, dataview) { 27377 super(dict, dataview); 27378 } 27379 getGlyphData(offset3, length) { 27380 this.parser.currentPosition = this.tableStart + offset3; 27381 return this.parser.readBytes(length); 27382 } 27383 }; 27384 var glyf$1 = Object.freeze({ __proto__: null, glyf }); 27385 var loca = class extends SimpleTable { 27386 constructor(dict, dataview, tables) { 27387 const { p: p22 } = super(dict, dataview); 27388 const n3 = tables.maxp.numGlyphs + 1; 27389 if (tables.head.indexToLocFormat === 0) { 27390 this.x2 = true; 27391 lazy$1( 27392 this, 27393 `offsets`, 27394 () => [...new Array(n3)].map((_) => p22.Offset16) 27395 ); 27396 } else { 27397 lazy$1( 27398 this, 27399 `offsets`, 27400 () => [...new Array(n3)].map((_) => p22.Offset32) 27401 ); 27402 } 27403 } 27404 getGlyphDataOffsetAndLength(glyphID) { 27405 let offset3 = this.offsets[glyphID] * this.x2 ? 2 : 1; 27406 let nextOffset = this.offsets[glyphID + 1] * this.x2 ? 2 : 1; 27407 return { offset: offset3, length: nextOffset - offset3 }; 27408 } 27409 }; 27410 var loca$1 = Object.freeze({ __proto__: null, loca }); 27411 var prep = class extends SimpleTable { 27412 constructor(dict, dataview) { 27413 const { p: p22 } = super(dict, dataview); 27414 lazy$1( 27415 this, 27416 `instructions`, 27417 () => [...new Array(dict.length)].map((_) => p22.uint8) 27418 ); 27419 } 27420 }; 27421 var prep$1 = Object.freeze({ __proto__: null, prep }); 27422 var CFF = class extends SimpleTable { 27423 constructor(dict, dataview) { 27424 const { p: p22 } = super(dict, dataview); 27425 lazy$1(this, `data`, () => p22.readBytes()); 27426 } 27427 }; 27428 var CFF$1 = Object.freeze({ __proto__: null, CFF }); 27429 var CFF2 = class extends SimpleTable { 27430 constructor(dict, dataview) { 27431 const { p: p22 } = super(dict, dataview); 27432 lazy$1(this, `data`, () => p22.readBytes()); 27433 } 27434 }; 27435 var CFF2$1 = Object.freeze({ __proto__: null, CFF2 }); 27436 var VORG = class extends SimpleTable { 27437 constructor(dict, dataview) { 27438 const { p: p22 } = super(dict, dataview); 27439 this.majorVersion = p22.uint16; 27440 this.minorVersion = p22.uint16; 27441 this.defaultVertOriginY = p22.int16; 27442 this.numVertOriginYMetrics = p22.uint16; 27443 lazy$1( 27444 this, 27445 `vertORiginYMetrics`, 27446 () => [...new Array(this.numVertOriginYMetrics)].map( 27447 (_) => new VertOriginYMetric(p22) 27448 ) 27449 ); 27450 } 27451 }; 27452 var VertOriginYMetric = class { 27453 constructor(p22) { 27454 this.glyphIndex = p22.uint16; 27455 this.vertOriginY = p22.int16; 27456 } 27457 }; 27458 var VORG$1 = Object.freeze({ __proto__: null, VORG }); 27459 var BitmapSize = class { 27460 constructor(p22) { 27461 this.indexSubTableArrayOffset = p22.Offset32; 27462 this.indexTablesSize = p22.uint32; 27463 this.numberofIndexSubTables = p22.uint32; 27464 this.colorRef = p22.uint32; 27465 this.hori = new SbitLineMetrics(p22); 27466 this.vert = new SbitLineMetrics(p22); 27467 this.startGlyphIndex = p22.uint16; 27468 this.endGlyphIndex = p22.uint16; 27469 this.ppemX = p22.uint8; 27470 this.ppemY = p22.uint8; 27471 this.bitDepth = p22.uint8; 27472 this.flags = p22.int8; 27473 } 27474 }; 27475 var BitmapScale = class { 27476 constructor(p22) { 27477 this.hori = new SbitLineMetrics(p22); 27478 this.vert = new SbitLineMetrics(p22); 27479 this.ppemX = p22.uint8; 27480 this.ppemY = p22.uint8; 27481 this.substitutePpemX = p22.uint8; 27482 this.substitutePpemY = p22.uint8; 27483 } 27484 }; 27485 var SbitLineMetrics = class { 27486 constructor(p22) { 27487 this.ascender = p22.int8; 27488 this.descender = p22.int8; 27489 this.widthMax = p22.uint8; 27490 this.caretSlopeNumerator = p22.int8; 27491 this.caretSlopeDenominator = p22.int8; 27492 this.caretOffset = p22.int8; 27493 this.minOriginSB = p22.int8; 27494 this.minAdvanceSB = p22.int8; 27495 this.maxBeforeBL = p22.int8; 27496 this.minAfterBL = p22.int8; 27497 this.pad1 = p22.int8; 27498 this.pad2 = p22.int8; 27499 } 27500 }; 27501 var EBLC = class extends SimpleTable { 27502 constructor(dict, dataview, name2) { 27503 const { p: p22 } = super(dict, dataview, name2); 27504 this.majorVersion = p22.uint16; 27505 this.minorVersion = p22.uint16; 27506 this.numSizes = p22.uint32; 27507 lazy$1( 27508 this, 27509 `bitMapSizes`, 27510 () => [...new Array(this.numSizes)].map( 27511 (_) => new BitmapSize(p22) 27512 ) 27513 ); 27514 } 27515 }; 27516 var EBLC$1 = Object.freeze({ __proto__: null, EBLC }); 27517 var EBDT = class extends SimpleTable { 27518 constructor(dict, dataview, name2) { 27519 const { p: p22 } = super(dict, dataview, name2); 27520 this.majorVersion = p22.uint16; 27521 this.minorVersion = p22.uint16; 27522 } 27523 }; 27524 var EBDT$1 = Object.freeze({ __proto__: null, EBDT }); 27525 var EBSC = class extends SimpleTable { 27526 constructor(dict, dataview) { 27527 const { p: p22 } = super(dict, dataview); 27528 this.majorVersion = p22.uint16; 27529 this.minorVersion = p22.uint16; 27530 this.numSizes = p22.uint32; 27531 lazy$1( 27532 this, 27533 `bitmapScales`, 27534 () => [...new Array(this.numSizes)].map( 27535 (_) => new BitmapScale(p22) 27536 ) 27537 ); 27538 } 27539 }; 27540 var EBSC$1 = Object.freeze({ __proto__: null, EBSC }); 27541 var CBLC = class extends EBLC { 27542 constructor(dict, dataview) { 27543 super(dict, dataview, `CBLC`); 27544 } 27545 }; 27546 var CBLC$1 = Object.freeze({ __proto__: null, CBLC }); 27547 var CBDT = class extends EBDT { 27548 constructor(dict, dataview) { 27549 super(dict, dataview, `CBDT`); 27550 } 27551 }; 27552 var CBDT$1 = Object.freeze({ __proto__: null, CBDT }); 27553 var sbix = class extends SimpleTable { 27554 constructor(dict, dataview) { 27555 const { p: p22 } = super(dict, dataview); 27556 this.version = p22.uint16; 27557 this.flags = p22.flags(16); 27558 this.numStrikes = p22.uint32; 27559 lazy$1( 27560 this, 27561 `strikeOffsets`, 27562 () => [...new Array(this.numStrikes)].map((_) => p22.Offset32) 27563 ); 27564 } 27565 }; 27566 var sbix$1 = Object.freeze({ __proto__: null, sbix }); 27567 var COLR = class extends SimpleTable { 27568 constructor(dict, dataview) { 27569 const { p: p22 } = super(dict, dataview); 27570 this.version = p22.uint16; 27571 this.numBaseGlyphRecords = p22.uint16; 27572 this.baseGlyphRecordsOffset = p22.Offset32; 27573 this.layerRecordsOffset = p22.Offset32; 27574 this.numLayerRecords = p22.uint16; 27575 } 27576 getBaseGlyphRecord(glyphID) { 27577 let start = this.tableStart + this.baseGlyphRecordsOffset; 27578 this.parser.currentPosition = start; 27579 let first = new BaseGlyphRecord(this.parser); 27580 let firstID = first.gID; 27581 let end = this.tableStart + this.layerRecordsOffset - 6; 27582 this.parser.currentPosition = end; 27583 let last = new BaseGlyphRecord(this.parser); 27584 let lastID = last.gID; 27585 if (firstID === glyphID) return first; 27586 if (lastID === glyphID) return last; 27587 while (true) { 27588 if (start === end) break; 27589 let mid = start + (end - start) / 12; 27590 this.parser.currentPosition = mid; 27591 let middle = new BaseGlyphRecord(this.parser); 27592 let midID = middle.gID; 27593 if (midID === glyphID) return middle; 27594 else if (midID > glyphID) { 27595 end = mid; 27596 } else if (midID < glyphID) { 27597 start = mid; 27598 } 27599 } 27600 return false; 27601 } 27602 getLayers(glyphID) { 27603 let record = this.getBaseGlyphRecord(glyphID); 27604 this.parser.currentPosition = this.tableStart + this.layerRecordsOffset + 4 * record.firstLayerIndex; 27605 return [...new Array(record.numLayers)].map( 27606 (_) => new LayerRecord(p) 27607 ); 27608 } 27609 }; 27610 var BaseGlyphRecord = class { 27611 constructor(p22) { 27612 this.gID = p22.uint16; 27613 this.firstLayerIndex = p22.uint16; 27614 this.numLayers = p22.uint16; 27615 } 27616 }; 27617 var LayerRecord = class { 27618 constructor(p22) { 27619 this.gID = p22.uint16; 27620 this.paletteIndex = p22.uint16; 27621 } 27622 }; 27623 var COLR$1 = Object.freeze({ __proto__: null, COLR }); 27624 var CPAL = class extends SimpleTable { 27625 constructor(dict, dataview) { 27626 const { p: p22 } = super(dict, dataview); 27627 this.version = p22.uint16; 27628 this.numPaletteEntries = p22.uint16; 27629 const numPalettes = this.numPalettes = p22.uint16; 27630 this.numColorRecords = p22.uint16; 27631 this.offsetFirstColorRecord = p22.Offset32; 27632 this.colorRecordIndices = [...new Array(this.numPalettes)].map( 27633 (_) => p22.uint16 27634 ); 27635 lazy$1(this, `colorRecords`, () => { 27636 p22.currentPosition = this.tableStart + this.offsetFirstColorRecord; 27637 return [...new Array(this.numColorRecords)].map( 27638 (_) => new ColorRecord(p22) 27639 ); 27640 }); 27641 if (this.version === 1) { 27642 this.offsetPaletteTypeArray = p22.Offset32; 27643 this.offsetPaletteLabelArray = p22.Offset32; 27644 this.offsetPaletteEntryLabelArray = p22.Offset32; 27645 lazy$1(this, `paletteTypeArray`, () => { 27646 p22.currentPosition = this.tableStart + this.offsetPaletteTypeArray; 27647 return new PaletteTypeArray(p22, numPalettes); 27648 }); 27649 lazy$1(this, `paletteLabelArray`, () => { 27650 p22.currentPosition = this.tableStart + this.offsetPaletteLabelArray; 27651 return new PaletteLabelsArray(p22, numPalettes); 27652 }); 27653 lazy$1(this, `paletteEntryLabelArray`, () => { 27654 p22.currentPosition = this.tableStart + this.offsetPaletteEntryLabelArray; 27655 return new PaletteEntryLabelArray(p22, numPalettes); 27656 }); 27657 } 27658 } 27659 }; 27660 var ColorRecord = class { 27661 constructor(p22) { 27662 this.blue = p22.uint8; 27663 this.green = p22.uint8; 27664 this.red = p22.uint8; 27665 this.alpha = p22.uint8; 27666 } 27667 }; 27668 var PaletteTypeArray = class { 27669 constructor(p22, numPalettes) { 27670 this.paletteTypes = [...new Array(numPalettes)].map( 27671 (_) => p22.uint32 27672 ); 27673 } 27674 }; 27675 var PaletteLabelsArray = class { 27676 constructor(p22, numPalettes) { 27677 this.paletteLabels = [...new Array(numPalettes)].map( 27678 (_) => p22.uint16 27679 ); 27680 } 27681 }; 27682 var PaletteEntryLabelArray = class { 27683 constructor(p22, numPalettes) { 27684 this.paletteEntryLabels = [...new Array(numPalettes)].map( 27685 (_) => p22.uint16 27686 ); 27687 } 27688 }; 27689 var CPAL$1 = Object.freeze({ __proto__: null, CPAL }); 27690 var DSIG = class extends SimpleTable { 27691 constructor(dict, dataview) { 27692 const { p: p22 } = super(dict, dataview); 27693 this.version = p22.uint32; 27694 this.numSignatures = p22.uint16; 27695 this.flags = p22.uint16; 27696 this.signatureRecords = [...new Array(this.numSignatures)].map( 27697 (_) => new SignatureRecord(p22) 27698 ); 27699 } 27700 getData(signatureID) { 27701 const record = this.signatureRecords[signatureID]; 27702 this.parser.currentPosition = this.tableStart + record.offset; 27703 return new SignatureBlockFormat1(this.parser); 27704 } 27705 }; 27706 var SignatureRecord = class { 27707 constructor(p22) { 27708 this.format = p22.uint32; 27709 this.length = p22.uint32; 27710 this.offset = p22.Offset32; 27711 } 27712 }; 27713 var SignatureBlockFormat1 = class { 27714 constructor(p22) { 27715 p22.uint16; 27716 p22.uint16; 27717 this.signatureLength = p22.uint32; 27718 this.signature = p22.readBytes(this.signatureLength); 27719 } 27720 }; 27721 var DSIG$1 = Object.freeze({ __proto__: null, DSIG }); 27722 var hdmx = class extends SimpleTable { 27723 constructor(dict, dataview, tables) { 27724 const { p: p22 } = super(dict, dataview); 27725 const numGlyphs = tables.hmtx.numGlyphs; 27726 this.version = p22.uint16; 27727 this.numRecords = p22.int16; 27728 this.sizeDeviceRecord = p22.int32; 27729 this.records = [...new Array(numRecords)].map( 27730 (_) => new DeviceRecord(p22, numGlyphs) 27731 ); 27732 } 27733 }; 27734 var DeviceRecord = class { 27735 constructor(p22, numGlyphs) { 27736 this.pixelSize = p22.uint8; 27737 this.maxWidth = p22.uint8; 27738 this.widths = p22.readBytes(numGlyphs); 27739 } 27740 }; 27741 var hdmx$1 = Object.freeze({ __proto__: null, hdmx }); 27742 var kern = class extends SimpleTable { 27743 constructor(dict, dataview) { 27744 const { p: p22 } = super(dict, dataview); 27745 this.version = p22.uint16; 27746 this.nTables = p22.uint16; 27747 lazy$1(this, `tables`, () => { 27748 let offset3 = this.tableStart + 4; 27749 const tables = []; 27750 for (let i3 = 0; i3 < this.nTables; i3++) { 27751 p22.currentPosition = offset3; 27752 let subtable = new KernSubTable(p22); 27753 tables.push(subtable); 27754 offset3 += subtable; 27755 } 27756 return tables; 27757 }); 27758 } 27759 }; 27760 var KernSubTable = class { 27761 constructor(p22) { 27762 this.version = p22.uint16; 27763 this.length = p22.uint16; 27764 this.coverage = p22.flags(8); 27765 this.format = p22.uint8; 27766 if (this.format === 0) { 27767 this.nPairs = p22.uint16; 27768 this.searchRange = p22.uint16; 27769 this.entrySelector = p22.uint16; 27770 this.rangeShift = p22.uint16; 27771 lazy$1( 27772 this, 27773 `pairs`, 27774 () => [...new Array(this.nPairs)].map((_) => new Pair(p22)) 27775 ); 27776 } 27777 if (this.format === 2) { 27778 console.warn( 27779 `Kern subtable format 2 is not supported: this parser currently only parses universal table data.` 27780 ); 27781 } 27782 } 27783 get horizontal() { 27784 return this.coverage[0]; 27785 } 27786 get minimum() { 27787 return this.coverage[1]; 27788 } 27789 get crossstream() { 27790 return this.coverage[2]; 27791 } 27792 get override() { 27793 return this.coverage[3]; 27794 } 27795 }; 27796 var Pair = class { 27797 constructor(p22) { 27798 this.left = p22.uint16; 27799 this.right = p22.uint16; 27800 this.value = p22.fword; 27801 } 27802 }; 27803 var kern$1 = Object.freeze({ __proto__: null, kern }); 27804 var LTSH = class extends SimpleTable { 27805 constructor(dict, dataview) { 27806 const { p: p22 } = super(dict, dataview); 27807 this.version = p22.uint16; 27808 this.numGlyphs = p22.uint16; 27809 this.yPels = p22.readBytes(this.numGlyphs); 27810 } 27811 }; 27812 var LTSH$1 = Object.freeze({ __proto__: null, LTSH }); 27813 var MERG = class extends SimpleTable { 27814 constructor(dict, dataview) { 27815 const { p: p22 } = super(dict, dataview); 27816 this.version = p22.uint16; 27817 this.mergeClassCount = p22.uint16; 27818 this.mergeDataOffset = p22.Offset16; 27819 this.classDefCount = p22.uint16; 27820 this.offsetToClassDefOffsets = p22.Offset16; 27821 lazy$1( 27822 this, 27823 `mergeEntryMatrix`, 27824 () => [...new Array(this.mergeClassCount)].map( 27825 (_) => p22.readBytes(this.mergeClassCount) 27826 ) 27827 ); 27828 console.warn(`Full MERG parsing is currently not supported.`); 27829 console.warn( 27830 `If you need this table parsed, please file an issue, or better yet, a PR.` 27831 ); 27832 } 27833 }; 27834 var MERG$1 = Object.freeze({ __proto__: null, MERG }); 27835 var meta = class extends SimpleTable { 27836 constructor(dict, dataview) { 27837 const { p: p22 } = super(dict, dataview); 27838 this.version = p22.uint32; 27839 this.flags = p22.uint32; 27840 p22.uint32; 27841 this.dataMapsCount = p22.uint32; 27842 this.dataMaps = [...new Array(this.dataMapsCount)].map( 27843 (_) => new DataMap(this.tableStart, p22) 27844 ); 27845 } 27846 }; 27847 var DataMap = class { 27848 constructor(tableStart, p22) { 27849 this.tableStart = tableStart; 27850 this.parser = p22; 27851 this.tag = p22.tag; 27852 this.dataOffset = p22.Offset32; 27853 this.dataLength = p22.uint32; 27854 } 27855 getData() { 27856 this.parser.currentField = this.tableStart + this.dataOffset; 27857 return this.parser.readBytes(this.dataLength); 27858 } 27859 }; 27860 var meta$1 = Object.freeze({ __proto__: null, meta }); 27861 var PCLT = class extends SimpleTable { 27862 constructor(dict, dataview) { 27863 super(dict, dataview); 27864 console.warn( 27865 `This font uses a PCLT table, which is currently not supported by this parser.` 27866 ); 27867 console.warn( 27868 `If you need this table parsed, please file an issue, or better yet, a PR.` 27869 ); 27870 } 27871 }; 27872 var PCLT$1 = Object.freeze({ __proto__: null, PCLT }); 27873 var VDMX = class extends SimpleTable { 27874 constructor(dict, dataview) { 27875 const { p: p22 } = super(dict, dataview); 27876 this.version = p22.uint16; 27877 this.numRecs = p22.uint16; 27878 this.numRatios = p22.uint16; 27879 this.ratRanges = [...new Array(this.numRatios)].map( 27880 (_) => new RatioRange(p22) 27881 ); 27882 this.offsets = [...new Array(this.numRatios)].map( 27883 (_) => p22.Offset16 27884 ); 27885 this.VDMXGroups = [...new Array(this.numRecs)].map( 27886 (_) => new VDMXGroup(p22) 27887 ); 27888 } 27889 }; 27890 var RatioRange = class { 27891 constructor(p22) { 27892 this.bCharSet = p22.uint8; 27893 this.xRatio = p22.uint8; 27894 this.yStartRatio = p22.uint8; 27895 this.yEndRatio = p22.uint8; 27896 } 27897 }; 27898 var VDMXGroup = class { 27899 constructor(p22) { 27900 this.recs = p22.uint16; 27901 this.startsz = p22.uint8; 27902 this.endsz = p22.uint8; 27903 this.records = [...new Array(this.recs)].map( 27904 (_) => new vTable(p22) 27905 ); 27906 } 27907 }; 27908 var vTable = class { 27909 constructor(p22) { 27910 this.yPelHeight = p22.uint16; 27911 this.yMax = p22.int16; 27912 this.yMin = p22.int16; 27913 } 27914 }; 27915 var VDMX$1 = Object.freeze({ __proto__: null, VDMX }); 27916 var vhea = class extends SimpleTable { 27917 constructor(dict, dataview) { 27918 const { p: p22 } = super(dict, dataview); 27919 this.version = p22.fixed; 27920 this.ascent = this.vertTypoAscender = p22.int16; 27921 this.descent = this.vertTypoDescender = p22.int16; 27922 this.lineGap = this.vertTypoLineGap = p22.int16; 27923 this.advanceHeightMax = p22.int16; 27924 this.minTopSideBearing = p22.int16; 27925 this.minBottomSideBearing = p22.int16; 27926 this.yMaxExtent = p22.int16; 27927 this.caretSlopeRise = p22.int16; 27928 this.caretSlopeRun = p22.int16; 27929 this.caretOffset = p22.int16; 27930 this.reserved = p22.int16; 27931 this.reserved = p22.int16; 27932 this.reserved = p22.int16; 27933 this.reserved = p22.int16; 27934 this.metricDataFormat = p22.int16; 27935 this.numOfLongVerMetrics = p22.uint16; 27936 p22.verifyLength(); 27937 } 27938 }; 27939 var vhea$1 = Object.freeze({ __proto__: null, vhea }); 27940 var vmtx = class extends SimpleTable { 27941 constructor(dict, dataview, tables) { 27942 super(dict, dataview); 27943 const numOfLongVerMetrics = tables.vhea.numOfLongVerMetrics; 27944 const numGlyphs = tables.maxp.numGlyphs; 27945 const metricsStart = p.currentPosition; 27946 lazy(this, `vMetrics`, () => { 27947 p.currentPosition = metricsStart; 27948 return [...new Array(numOfLongVerMetrics)].map( 27949 (_) => new LongVertMetric(p.uint16, p.int16) 27950 ); 27951 }); 27952 if (numOfLongVerMetrics < numGlyphs) { 27953 const tsbStart = metricsStart + numOfLongVerMetrics * 4; 27954 lazy(this, `topSideBearings`, () => { 27955 p.currentPosition = tsbStart; 27956 return [...new Array(numGlyphs - numOfLongVerMetrics)].map( 27957 (_) => p.int16 27958 ); 27959 }); 27960 } 27961 } 27962 }; 27963 var LongVertMetric = class { 27964 constructor(h3, b3) { 27965 this.advanceHeight = h3; 27966 this.topSideBearing = b3; 27967 } 27968 }; 27969 var vmtx$1 = Object.freeze({ __proto__: null, vmtx }); 27970 27971 // packages/global-styles-ui/build-module/font-library/utils/make-families-from-faces.js 27972 var import_components57 = __toESM(require_components()); 27973 var { kebabCase: kebabCase3 } = unlock3(import_components57.privateApis); 27974 function makeFamiliesFromFaces(fontFaces) { 27975 const fontFamiliesObject = fontFaces.reduce( 27976 (acc, item) => { 27977 if (!acc[item.fontFamily]) { 27978 acc[item.fontFamily] = { 27979 name: item.fontFamily, 27980 fontFamily: item.fontFamily, 27981 slug: kebabCase3(item.fontFamily.toLowerCase()), 27982 fontFace: [] 27983 }; 27984 } 27985 acc[item.fontFamily].fontFace.push(item); 27986 return acc; 27987 }, 27988 {} 27989 ); 27990 return Object.values(fontFamiliesObject); 27991 } 27992 27993 // packages/global-styles-ui/build-module/font-library/upload-fonts.js 27994 var import_jsx_runtime140 = __toESM(require_jsx_runtime()); 27995 function UploadFonts() { 27996 const { installFonts } = (0, import_element53.useContext)(FontLibraryContext); 27997 const [isUploading, setIsUploading] = (0, import_element53.useState)(false); 27998 const [notice, setNotice] = (0, import_element53.useState)(null); 27999 const handleDropZone = (files) => { 28000 handleFilesUpload(files); 28001 }; 28002 const onFilesUpload = (event) => { 28003 handleFilesUpload(event.target.files); 28004 }; 28005 const handleFilesUpload = async (files) => { 28006 if (!files) { 28007 return; 28008 } 28009 setNotice(null); 28010 setIsUploading(true); 28011 const uniqueFilenames = /* @__PURE__ */ new Set(); 28012 const selectedFiles = [...files]; 28013 let hasInvalidFiles = false; 28014 const checkFilesPromises = selectedFiles.map(async (file) => { 28015 const isFont = await isFontFile(file); 28016 if (!isFont) { 28017 hasInvalidFiles = true; 28018 return null; 28019 } 28020 if (uniqueFilenames.has(file.name)) { 28021 return null; 28022 } 28023 const fileExtension = (((file.name ?? "").split(".") ?? []).pop() ?? "").toLowerCase(); 28024 if (ALLOWED_FILE_EXTENSIONS.includes(fileExtension)) { 28025 uniqueFilenames.add(file.name); 28026 return file; 28027 } 28028 return null; 28029 }); 28030 const allowedFiles = (await Promise.all(checkFilesPromises)).filter((file) => null !== file); 28031 if (allowedFiles.length > 0) { 28032 loadFiles(allowedFiles); 28033 } else { 28034 const message = hasInvalidFiles ? (0, import_i18n76.__)("Sorry, you are not allowed to upload this file type.") : (0, import_i18n76.__)("No fonts found to install."); 28035 setNotice({ 28036 type: "error", 28037 message 28038 }); 28039 setIsUploading(false); 28040 } 28041 }; 28042 const loadFiles = async (files) => { 28043 const fontFacesLoaded = await Promise.all( 28044 files.map(async (fontFile) => { 28045 const fontFaceData = await getFontFaceMetadata(fontFile); 28046 await loadFontFaceInBrowser( 28047 fontFaceData, 28048 fontFaceData.file, 28049 "all" 28050 ); 28051 return fontFaceData; 28052 }) 28053 ); 28054 handleInstall(fontFacesLoaded); 28055 }; 28056 async function isFontFile(file) { 28057 const font2 = new Font("Uploaded Font"); 28058 try { 28059 const buffer = await readFileAsArrayBuffer(file); 28060 await font2.fromDataBuffer(buffer, "font"); 28061 return true; 28062 } catch (error) { 28063 return false; 28064 } 28065 } 28066 async function readFileAsArrayBuffer(file) { 28067 return new Promise((resolve, reject) => { 28068 const reader = new window.FileReader(); 28069 reader.readAsArrayBuffer(file); 28070 reader.onload = () => resolve(reader.result); 28071 reader.onerror = reject; 28072 }); 28073 } 28074 const getFontFaceMetadata = async (fontFile) => { 28075 const buffer = await readFileAsArrayBuffer(fontFile); 28076 const fontObj = new Font("Uploaded Font"); 28077 fontObj.fromDataBuffer(buffer, fontFile.name); 28078 const onloadEvent = await new Promise( 28079 (resolve) => fontObj.onload = resolve 28080 ); 28081 const font2 = onloadEvent.detail.font; 28082 const { name: name2 } = font2.opentype.tables; 28083 const fontName = name2.get(16) || name2.get(1); 28084 const isItalic = name2.get(2).toLowerCase().includes("italic"); 28085 const fontWeight = font2.opentype.tables["OS/2"].usWeightClass || "normal"; 28086 const isVariable = !!font2.opentype.tables.fvar; 28087 const weightAxis = isVariable && font2.opentype.tables.fvar.axes.find( 28088 ({ tag }) => tag === "wght" 28089 ); 28090 const weightRange = weightAxis ? `$weightAxis.minValue} $weightAxis.maxValue}` : null; 28091 return { 28092 file: fontFile, 28093 fontFamily: fontName, 28094 fontStyle: isItalic ? "italic" : "normal", 28095 fontWeight: weightRange || fontWeight 28096 }; 28097 }; 28098 const handleInstall = async (fontFaces) => { 28099 const fontFamilies = makeFamiliesFromFaces(fontFaces); 28100 try { 28101 await installFonts(fontFamilies); 28102 setNotice({ 28103 type: "success", 28104 message: (0, import_i18n76.__)("Fonts were installed successfully.") 28105 }); 28106 } catch (error) { 28107 const typedError = error; 28108 setNotice({ 28109 type: "error", 28110 message: typedError.message, 28111 errors: typedError?.installationErrors 28112 }); 28113 } 28114 setIsUploading(false); 28115 }; 28116 return /* @__PURE__ */ (0, import_jsx_runtime140.jsxs)("div", { className: "font-library__tabpanel-layout", children: [ 28117 /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(import_components58.DropZone, { onFilesDrop: handleDropZone }), 28118 /* @__PURE__ */ (0, import_jsx_runtime140.jsxs)(import_components58.__experimentalVStack, { className: "font-library__local-fonts", children: [ 28119 notice && /* @__PURE__ */ (0, import_jsx_runtime140.jsxs)( 28120 import_components58.Notice, 28121 { 28122 status: notice.type, 28123 __unstableHTML: true, 28124 onRemove: () => setNotice(null), 28125 children: [ 28126 notice.message, 28127 notice.errors && /* @__PURE__ */ (0, import_jsx_runtime140.jsx)("ul", { children: notice.errors.map((error, index2) => /* @__PURE__ */ (0, import_jsx_runtime140.jsx)("li", { children: error }, index2)) }) 28128 ] 28129 } 28130 ), 28131 isUploading && /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(import_components58.FlexItem, { children: /* @__PURE__ */ (0, import_jsx_runtime140.jsx)("div", { className: "font-library__upload-area", children: /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(import_components58.ProgressBar, {}) }) }), 28132 !isUploading && /* @__PURE__ */ (0, import_jsx_runtime140.jsx)( 28133 import_components58.FormFileUpload, 28134 { 28135 accept: ALLOWED_FILE_EXTENSIONS.map( 28136 (ext) => `.$ext}` 28137 ).join(","), 28138 multiple: true, 28139 onChange: onFilesUpload, 28140 render: ({ openFileDialog }) => /* @__PURE__ */ (0, import_jsx_runtime140.jsx)( 28141 import_components58.Button, 28142 { 28143 __next40pxDefaultSize: true, 28144 className: "font-library__upload-area", 28145 onClick: openFileDialog, 28146 children: (0, import_i18n76.__)("Upload font") 28147 } 28148 ) 28149 } 28150 ), 28151 /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(import_components58.__experimentalSpacer, { margin: 2 }), 28152 /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(import_components58.__experimentalText, { className: "font-library__upload-area__text", children: (0, import_i18n76.__)( 28153 "Uploaded fonts appear in your library and can be used in your theme. Supported formats: .ttf, .otf, .woff, and .woff2." 28154 ) }) 28155 ] }) 28156 ] }); 28157 } 28158 var upload_fonts_default = UploadFonts; 28159 28160 // packages/global-styles-ui/build-module/font-library/modal.js 28161 var import_jsx_runtime141 = __toESM(require_jsx_runtime()); 28162 var { Tabs } = unlock3(import_components59.privateApis); 28163 var DEFAULT_TAB = { 28164 id: "installed-fonts", 28165 title: (0, import_i18n77._x)("Library", "Font library") 28166 }; 28167 var UPLOAD_TAB = { 28168 id: "upload-fonts", 28169 title: (0, import_i18n77._x)("Upload", "noun") 28170 }; 28171 var tabsFromCollections = (collections) => collections.map(({ slug, name: name2 }) => ({ 28172 id: slug, 28173 title: collections.length === 1 && slug === "google-fonts" ? (0, import_i18n77.__)("Install Fonts") : name2 28174 })); 28175 function FontLibraryModal({ 28176 onRequestClose, 28177 defaultTabId = "installed-fonts" 28178 }) { 28179 const { records: collections = [] } = (0, import_core_data38.useEntityRecords)("root", "fontCollection", { 28180 _fields: "slug,name,description" 28181 }); 28182 const canUserCreate = (0, import_data56.useSelect)((select5) => { 28183 return select5(import_core_data38.store).canUser("create", { 28184 kind: "postType", 28185 name: "wp_font_family" 28186 }); 28187 }, []); 28188 const tabs = [DEFAULT_TAB]; 28189 if (canUserCreate) { 28190 tabs.push(UPLOAD_TAB); 28191 tabs.push(...tabsFromCollections(collections || [])); 28192 } 28193 return /* @__PURE__ */ (0, import_jsx_runtime141.jsx)( 28194 import_components59.Modal, 28195 { 28196 title: (0, import_i18n77.__)("Fonts"), 28197 onRequestClose, 28198 isFullScreen: true, 28199 className: "font-library-modal", 28200 children: /* @__PURE__ */ (0, import_jsx_runtime141.jsxs)(Tabs, { defaultTabId, children: [ 28201 /* @__PURE__ */ (0, import_jsx_runtime141.jsx)("div", { className: "font-library-modal__tablist-container", children: /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(Tabs.TabList, { children: tabs.map(({ id, title }) => /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(Tabs.Tab, { tabId: id, children: title }, id)) }) }), 28202 tabs.map(({ id }) => { 28203 let contents; 28204 switch (id) { 28205 case "upload-fonts": 28206 contents = /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(upload_fonts_default, {}); 28207 break; 28208 case "installed-fonts": 28209 contents = /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(installed_fonts_default, {}); 28210 break; 28211 default: 28212 contents = /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(font_collection_default, { slug: id }); 28213 } 28214 return /* @__PURE__ */ (0, import_jsx_runtime141.jsx)( 28215 Tabs.TabPanel, 28216 { 28217 tabId: id, 28218 focusable: false, 28219 className: "font-library-modal__tab-panel", 28220 children: contents 28221 }, 28222 id 28223 ); 28224 }) 28225 ] }) 28226 } 28227 ); 28228 } 28229 var modal_default = FontLibraryModal; 28230 28231 // packages/global-styles-ui/build-module/font-family-item.js 28232 var import_i18n78 = __toESM(require_i18n()); 28233 var import_components60 = __toESM(require_components()); 28234 var import_element54 = __toESM(require_element()); 28235 var import_jsx_runtime142 = __toESM(require_jsx_runtime()); 28236 function FontFamilyItem({ font: font2 }) { 28237 const { handleSetLibraryFontSelected, setModalTabOpen } = (0, import_element54.useContext)(FontLibraryContext); 28238 const variantsCount = font2?.fontFace?.length || 1; 28239 const handleClick = () => { 28240 handleSetLibraryFontSelected?.(font2); 28241 setModalTabOpen?.("installed-fonts"); 28242 }; 28243 const previewStyle = getFamilyPreviewStyle(font2); 28244 return /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(import_components60.__experimentalItem, { onClick: handleClick, children: /* @__PURE__ */ (0, import_jsx_runtime142.jsxs)(import_components60.__experimentalHStack, { justify: "space-between", children: [ 28245 /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(import_components60.FlexItem, { style: previewStyle, children: font2.name }), 28246 /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(import_components60.FlexItem, { className: "global-styles-ui-screen-typography__font-variants-count", children: (0, import_i18n78.sprintf)( 28247 /* translators: %d: Number of font variants. */ 28248 (0, import_i18n78._n)("%d variant", "%d variants", variantsCount), 28249 variantsCount 28250 ) }) 28251 ] }) }); 28252 } 28253 var font_family_item_default = FontFamilyItem; 28254 28255 // packages/global-styles-ui/build-module/font-families.js 28256 var import_jsx_runtime143 = __toESM(require_jsx_runtime()); 28257 function mapFontsWithSource(fonts, source) { 28258 return fonts ? fonts.map((f3) => setUIValuesNeeded(f3, { source })) : []; 28259 } 28260 function FontFamiliesInner() { 28261 const { baseCustomFonts, modalTabOpen, setModalTabOpen } = (0, import_element55.useContext)(FontLibraryContext); 28262 const [fontFamilies] = useSetting("typography.fontFamilies"); 28263 const [baseFontFamilies] = useSetting( 28264 "typography.fontFamilies", 28265 void 0, 28266 "base" 28267 ); 28268 const themeFonts = mapFontsWithSource(fontFamilies?.theme, "theme"); 28269 const customFonts = mapFontsWithSource(fontFamilies?.custom, "custom"); 28270 const activeFonts = [...themeFonts, ...customFonts].sort( 28271 (a3, b3) => a3.name.localeCompare(b3.name) 28272 ); 28273 const hasFonts = 0 < activeFonts.length; 28274 const hasInstalledFonts = hasFonts || baseFontFamilies?.theme?.length > 0 || (baseCustomFonts?.length ?? 0) > 0; 28275 return /* @__PURE__ */ (0, import_jsx_runtime143.jsxs)(import_jsx_runtime143.Fragment, { children: [ 28276 !!modalTabOpen && /* @__PURE__ */ (0, import_jsx_runtime143.jsx)( 28277 modal_default, 28278 { 28279 onRequestClose: () => setModalTabOpen?.(""), 28280 defaultTabId: modalTabOpen 28281 } 28282 ), 28283 /* @__PURE__ */ (0, import_jsx_runtime143.jsxs)(import_components61.__experimentalVStack, { spacing: 2, children: [ 28284 /* @__PURE__ */ (0, import_jsx_runtime143.jsxs)(import_components61.__experimentalHStack, { justify: "space-between", children: [ 28285 /* @__PURE__ */ (0, import_jsx_runtime143.jsx)(Subtitle, { level: 3, children: (0, import_i18n79.__)("Fonts") }), 28286 /* @__PURE__ */ (0, import_jsx_runtime143.jsx)( 28287 import_components61.Button, 28288 { 28289 onClick: () => setModalTabOpen?.("installed-fonts"), 28290 label: (0, import_i18n79.__)("Manage fonts"), 28291 icon: settings_default, 28292 size: "small" 28293 } 28294 ) 28295 ] }), 28296 activeFonts.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime143.jsx)(import_jsx_runtime143.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime143.jsx)(import_components61.__experimentalItemGroup, { size: "large", isBordered: true, isSeparated: true, children: activeFonts.map((font2) => /* @__PURE__ */ (0, import_jsx_runtime143.jsx)( 28297 font_family_item_default, 28298 { 28299 font: font2 28300 }, 28301 font2.slug 28302 )) }) }), 28303 !hasFonts && /* @__PURE__ */ (0, import_jsx_runtime143.jsxs)(import_jsx_runtime143.Fragment, { children: [ 28304 /* @__PURE__ */ (0, import_jsx_runtime143.jsx)(import_components61.__experimentalText, { as: "p", children: hasInstalledFonts ? (0, import_i18n79.__)("No fonts activated.") : (0, import_i18n79.__)("No fonts installed.") }), 28305 /* @__PURE__ */ (0, import_jsx_runtime143.jsx)( 28306 import_components61.Button, 28307 { 28308 className: "global-styles-ui-font-families__manage-fonts", 28309 variant: "secondary", 28310 __next40pxDefaultSize: true, 28311 onClick: () => { 28312 setModalTabOpen?.( 28313 hasInstalledFonts ? "installed-fonts" : "upload-fonts" 28314 ); 28315 }, 28316 children: hasInstalledFonts ? (0, import_i18n79.__)("Manage fonts") : (0, import_i18n79.__)("Add fonts") 28317 } 28318 ) 28319 ] }) 28320 ] }) 28321 ] }); 28322 } 28323 function FontFamilies({ ...props }) { 28324 return /* @__PURE__ */ (0, import_jsx_runtime143.jsx)(context_default, { children: /* @__PURE__ */ (0, import_jsx_runtime143.jsx)(FontFamiliesInner, { ...props }) }); 28325 } 28326 28327 // packages/global-styles-ui/build-module/font-sizes/font-sizes-count.js 28328 var import_i18n80 = __toESM(require_i18n()); 28329 var import_components62 = __toESM(require_components()); 28330 var import_jsx_runtime144 = __toESM(require_jsx_runtime()); 28331 function FontSizes() { 28332 return /* @__PURE__ */ (0, import_jsx_runtime144.jsxs)(import_components62.__experimentalVStack, { spacing: 2, children: [ 28333 /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(import_components62.__experimentalHStack, { justify: "space-between", children: /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(Subtitle, { level: 3, children: (0, import_i18n80.__)("Font Sizes") }) }), 28334 /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(import_components62.__experimentalItemGroup, { isBordered: true, isSeparated: true, children: /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(NavigationButtonAsItem, { path: "/typography/font-sizes", children: /* @__PURE__ */ (0, import_jsx_runtime144.jsxs)(import_components62.__experimentalHStack, { direction: "row", children: [ 28335 /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(import_components62.FlexItem, { children: (0, import_i18n80.__)("Font size presets") }), 28336 /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(icon_default, { icon: (0, import_i18n80.isRTL)() ? chevron_left_default : chevron_right_default }) 28337 ] }) }) }) 28338 ] }); 28339 } 28340 var font_sizes_count_default = FontSizes; 28341 28342 // packages/global-styles-ui/build-module/screen-typography.js 28343 var import_jsx_runtime145 = __toESM(require_jsx_runtime()); 28344 function ScreenTypography() { 28345 const { fontLibraryEnabled } = (0, import_element56.useContext)(GlobalStylesContext); 28346 return /* @__PURE__ */ (0, import_jsx_runtime145.jsxs)(import_jsx_runtime145.Fragment, { children: [ 28347 /* @__PURE__ */ (0, import_jsx_runtime145.jsx)( 28348 ScreenHeader, 28349 { 28350 title: (0, import_i18n81.__)("Typography"), 28351 description: (0, import_i18n81.__)( 28352 "Available fonts, typographic styles, and the application of those styles." 28353 ) 28354 } 28355 ), 28356 /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(ScreenBody, { children: /* @__PURE__ */ (0, import_jsx_runtime145.jsxs)(import_components63.__experimentalVStack, { spacing: 7, children: [ 28357 /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(TypographyVariations, { title: (0, import_i18n81.__)("Typesets") }), 28358 fontLibraryEnabled && /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(FontFamilies, {}), 28359 /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(typography_elements_default, {}), 28360 /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(font_sizes_count_default, {}) 28361 ] }) }) 28362 ] }); 28363 } 28364 var screen_typography_default = ScreenTypography; 28365 28366 // packages/global-styles-ui/build-module/screen-typography-element.js 28367 var import_i18n82 = __toESM(require_i18n()); 28368 var import_components64 = __toESM(require_components()); 28369 var import_element57 = __toESM(require_element()); 28370 28371 // packages/global-styles-ui/build-module/typography-panel.js 28372 var import_block_editor23 = __toESM(require_block_editor()); 28373 var import_jsx_runtime146 = __toESM(require_jsx_runtime()); 28374 var { useSettingsForBlockElement: useSettingsForBlockElement4, TypographyPanel: StylesTypographyPanel2 } = unlock3(import_block_editor23.privateApis); 28375 function TypographyPanel({ 28376 element, 28377 headingLevel 28378 }) { 28379 let prefixParts = []; 28380 if (element === "heading") { 28381 prefixParts = prefixParts.concat(["elements", headingLevel]); 28382 } else if (element && element !== "text") { 28383 prefixParts = prefixParts.concat(["elements", element]); 28384 } 28385 const prefix = prefixParts.join("."); 28386 const [style] = useStyle(prefix, "", "user", false); 28387 const [inheritedStyle, setStyle2] = useStyle( 28388 prefix, 28389 "", 28390 "merged", 28391 false 28392 ); 28393 const [rawSettings] = useSetting(""); 28394 const usedElement = element === "heading" ? headingLevel : element; 28395 const settings = useSettingsForBlockElement4( 28396 rawSettings, 28397 void 0, 28398 usedElement 28399 ); 28400 return /* @__PURE__ */ (0, import_jsx_runtime146.jsx)( 28401 StylesTypographyPanel2, 28402 { 28403 inheritedValue: inheritedStyle, 28404 value: style, 28405 onChange: setStyle2, 28406 settings 28407 } 28408 ); 28409 } 28410 28411 // packages/global-styles-ui/build-module/typography-preview.js 28412 var import_jsx_runtime147 = __toESM(require_jsx_runtime()); 28413 function TypographyPreview({ 28414 name: name2, 28415 element, 28416 headingLevel 28417 }) { 28418 let prefix = ""; 28419 if (element === "heading") { 28420 prefix = `elements.$headingLevel}.`; 28421 } else if (element && element !== "text") { 28422 prefix = `elements.$element}.`; 28423 } 28424 const [fontFamily] = useStyle(prefix + "typography.fontFamily", name2); 28425 const [gradientValue] = useStyle(prefix + "color.gradient", name2); 28426 const [backgroundColor] = useStyle(prefix + "color.background", name2); 28427 const [fallbackBackgroundColor] = useStyle("color.background"); 28428 const [color] = useStyle(prefix + "color.text", name2); 28429 const [fontSize] = useStyle(prefix + "typography.fontSize", name2); 28430 const [fontStyle] = useStyle(prefix + "typography.fontStyle", name2); 28431 const [fontWeight] = useStyle(prefix + "typography.fontWeight", name2); 28432 const [letterSpacing] = useStyle( 28433 prefix + "typography.letterSpacing", 28434 name2 28435 ); 28436 const extraStyles = element === "link" ? { 28437 textDecoration: "underline" 28438 } : {}; 28439 return /* @__PURE__ */ (0, import_jsx_runtime147.jsx)( 28440 "div", 28441 { 28442 className: "global-styles-ui-typography-preview", 28443 style: { 28444 fontFamily: fontFamily ?? "serif", 28445 background: gradientValue ?? backgroundColor ?? fallbackBackgroundColor, 28446 color, 28447 fontSize, 28448 fontStyle, 28449 fontWeight, 28450 letterSpacing, 28451 ...extraStyles 28452 }, 28453 children: "Aa" 28454 } 28455 ); 28456 } 28457 28458 // packages/global-styles-ui/build-module/screen-typography-element.js 28459 var import_jsx_runtime148 = __toESM(require_jsx_runtime()); 28460 var elements = { 28461 text: { 28462 description: (0, import_i18n82.__)("Manage the fonts used on the site."), 28463 title: (0, import_i18n82.__)("Text") 28464 }, 28465 link: { 28466 description: (0, import_i18n82.__)("Manage the fonts and typography used on the links."), 28467 title: (0, import_i18n82.__)("Links") 28468 }, 28469 heading: { 28470 description: (0, import_i18n82.__)("Manage the fonts and typography used on headings."), 28471 title: (0, import_i18n82.__)("Headings") 28472 }, 28473 caption: { 28474 description: (0, import_i18n82.__)("Manage the fonts and typography used on captions."), 28475 title: (0, import_i18n82.__)("Captions") 28476 }, 28477 button: { 28478 description: (0, import_i18n82.__)("Manage the fonts and typography used on buttons."), 28479 title: (0, import_i18n82.__)("Buttons") 28480 } 28481 }; 28482 function ScreenTypographyElement({ element }) { 28483 const [headingLevel, setHeadingLevel] = (0, import_element57.useState)("heading"); 28484 return /* @__PURE__ */ (0, import_jsx_runtime148.jsxs)(import_jsx_runtime148.Fragment, { children: [ 28485 /* @__PURE__ */ (0, import_jsx_runtime148.jsx)( 28486 ScreenHeader, 28487 { 28488 title: elements[element].title, 28489 description: elements[element].description 28490 } 28491 ), 28492 /* @__PURE__ */ (0, import_jsx_runtime148.jsx)(import_components64.__experimentalSpacer, { marginX: 4, children: /* @__PURE__ */ (0, import_jsx_runtime148.jsx)( 28493 TypographyPreview, 28494 { 28495 element, 28496 headingLevel 28497 } 28498 ) }), 28499 element === "heading" && /* @__PURE__ */ (0, import_jsx_runtime148.jsx)(import_components64.__experimentalSpacer, { marginX: 4, marginBottom: "1em", children: /* @__PURE__ */ (0, import_jsx_runtime148.jsxs)( 28500 import_components64.__experimentalToggleGroupControl, 28501 { 28502 label: (0, import_i18n82.__)("Select heading level"), 28503 hideLabelFromVision: true, 28504 value: headingLevel, 28505 onChange: (value) => setHeadingLevel(value), 28506 isBlock: true, 28507 size: "__unstable-large", 28508 children: [ 28509 /* @__PURE__ */ (0, import_jsx_runtime148.jsx)( 28510 import_components64.__experimentalToggleGroupControlOption, 28511 { 28512 value: "heading", 28513 showTooltip: true, 28514 "aria-label": (0, import_i18n82.__)("All headings"), 28515 label: (0, import_i18n82._x)("All", "heading levels") 28516 } 28517 ), 28518 /* @__PURE__ */ (0, import_jsx_runtime148.jsx)( 28519 import_components64.__experimentalToggleGroupControlOption, 28520 { 28521 value: "h1", 28522 showTooltip: true, 28523 "aria-label": (0, import_i18n82.__)("Heading 1"), 28524 label: (0, import_i18n82.__)("H1") 28525 } 28526 ), 28527 /* @__PURE__ */ (0, import_jsx_runtime148.jsx)( 28528 import_components64.__experimentalToggleGroupControlOption, 28529 { 28530 value: "h2", 28531 showTooltip: true, 28532 "aria-label": (0, import_i18n82.__)("Heading 2"), 28533 label: (0, import_i18n82.__)("H2") 28534 } 28535 ), 28536 /* @__PURE__ */ (0, import_jsx_runtime148.jsx)( 28537 import_components64.__experimentalToggleGroupControlOption, 28538 { 28539 value: "h3", 28540 showTooltip: true, 28541 "aria-label": (0, import_i18n82.__)("Heading 3"), 28542 label: (0, import_i18n82.__)("H3") 28543 } 28544 ), 28545 /* @__PURE__ */ (0, import_jsx_runtime148.jsx)( 28546 import_components64.__experimentalToggleGroupControlOption, 28547 { 28548 value: "h4", 28549 showTooltip: true, 28550 "aria-label": (0, import_i18n82.__)("Heading 4"), 28551 label: (0, import_i18n82.__)("H4") 28552 } 28553 ), 28554 /* @__PURE__ */ (0, import_jsx_runtime148.jsx)( 28555 import_components64.__experimentalToggleGroupControlOption, 28556 { 28557 value: "h5", 28558 showTooltip: true, 28559 "aria-label": (0, import_i18n82.__)("Heading 5"), 28560 label: (0, import_i18n82.__)("H5") 28561 } 28562 ), 28563 /* @__PURE__ */ (0, import_jsx_runtime148.jsx)( 28564 import_components64.__experimentalToggleGroupControlOption, 28565 { 28566 value: "h6", 28567 showTooltip: true, 28568 "aria-label": (0, import_i18n82.__)("Heading 6"), 28569 label: (0, import_i18n82.__)("H6") 28570 } 28571 ) 28572 ] 28573 } 28574 ) }), 28575 /* @__PURE__ */ (0, import_jsx_runtime148.jsx)( 28576 TypographyPanel, 28577 { 28578 element, 28579 headingLevel 28580 } 28581 ) 28582 ] }); 28583 } 28584 var screen_typography_element_default = ScreenTypographyElement; 28585 28586 // packages/global-styles-ui/build-module/screen-colors.js 28587 var import_i18n84 = __toESM(require_i18n()); 28588 var import_components67 = __toESM(require_components()); 28589 var import_block_editor24 = __toESM(require_block_editor()); 28590 28591 // packages/global-styles-ui/build-module/palette.js 28592 var import_components66 = __toESM(require_components()); 28593 var import_i18n83 = __toESM(require_i18n()); 28594 var import_element58 = __toESM(require_element()); 28595 28596 // packages/global-styles-ui/build-module/color-indicator-wrapper.js 28597 var import_components65 = __toESM(require_components()); 28598 var import_jsx_runtime149 = __toESM(require_jsx_runtime()); 28599 function ColorIndicatorWrapper({ 28600 className, 28601 children, 28602 ...props 28603 }) { 28604 return /* @__PURE__ */ (0, import_jsx_runtime149.jsx)( 28605 import_components65.Flex, 28606 { 28607 className: clsx_default( 28608 "global-styles-ui__color-indicator-wrapper", 28609 className 28610 ), 28611 ...props, 28612 children 28613 } 28614 ); 28615 } 28616 var color_indicator_wrapper_default = ColorIndicatorWrapper; 28617 28618 // packages/global-styles-ui/build-module/palette.js 28619 var import_jsx_runtime150 = __toESM(require_jsx_runtime()); 28620 var EMPTY_COLORS = []; 28621 function Palette({ name: name2 }) { 28622 const [customColors] = useSetting("color.palette.custom"); 28623 const [themeColors] = useSetting("color.palette.theme"); 28624 const [defaultColors] = useSetting("color.palette.default"); 28625 const [defaultPaletteEnabled] = useSetting( 28626 "color.defaultPalette", 28627 name2 28628 ); 28629 const safeCustomColors = customColors || EMPTY_COLORS; 28630 const safeThemeColors = themeColors || EMPTY_COLORS; 28631 const safeDefaultColors = defaultColors || EMPTY_COLORS; 28632 const safeDefaultPaletteEnabled = defaultPaletteEnabled ?? true; 28633 const colors = (0, import_element58.useMemo)( 28634 () => [ 28635 ...safeCustomColors, 28636 ...safeThemeColors, 28637 ...safeDefaultColors && safeDefaultPaletteEnabled ? safeDefaultColors : EMPTY_COLORS 28638 ], 28639 [ 28640 safeCustomColors, 28641 safeThemeColors, 28642 safeDefaultColors, 28643 safeDefaultPaletteEnabled 28644 ] 28645 ); 28646 const screenPath = !name2 ? "/colors/palette" : "/blocks/" + encodeURIComponent(name2) + "/colors/palette"; 28647 return /* @__PURE__ */ (0, import_jsx_runtime150.jsxs)(import_components66.__experimentalVStack, { spacing: 3, children: [ 28648 /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(Subtitle, { level: 3, children: (0, import_i18n83.__)("Palette") }), 28649 /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(import_components66.__experimentalItemGroup, { isBordered: true, isSeparated: true, children: /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(NavigationButtonAsItem, { path: screenPath, children: /* @__PURE__ */ (0, import_jsx_runtime150.jsxs)(import_components66.__experimentalHStack, { direction: "row", children: [ 28650 colors.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime150.jsxs)(import_jsx_runtime150.Fragment, { children: [ 28651 /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(import_components66.__experimentalZStack, { isLayered: false, offset: -8, children: colors.slice(0, 5).map(({ color }, index2) => /* @__PURE__ */ (0, import_jsx_runtime150.jsx)( 28652 color_indicator_wrapper_default, 28653 { 28654 children: /* @__PURE__ */ (0, import_jsx_runtime150.jsx)( 28655 import_components66.ColorIndicator, 28656 { 28657 colorValue: color 28658 } 28659 ) 28660 }, 28661 `$color}-$index2}` 28662 )) }), 28663 /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(import_components66.FlexItem, { isBlock: true, children: (0, import_i18n83.__)("Edit palette") }) 28664 ] }) : /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(import_components66.FlexItem, { children: (0, import_i18n83.__)("Add colors") }), 28665 /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(icon_default, { icon: (0, import_i18n83.isRTL)() ? chevron_left_default : chevron_right_default }) 28666 ] }) }) }) 28667 ] }); 28668 } 28669 var palette_default = Palette; 28670 28671 // packages/global-styles-ui/build-module/screen-colors.js 28672 var import_jsx_runtime151 = __toESM(require_jsx_runtime()); 28673 var { useSettingsForBlockElement: useSettingsForBlockElement5, ColorPanel: StylesColorPanel2 } = unlock3( 28674 import_block_editor24.privateApis 28675 ); 28676 function ScreenColors() { 28677 const [style, setStyle2] = useStyle( 28678 "", 28679 void 0, 28680 "user", 28681 false 28682 ); 28683 const [inheritedStyle] = useStyle( 28684 "", 28685 void 0, 28686 "merged", 28687 false 28688 ); 28689 const [rawSettings] = useSetting(""); 28690 const settings = useSettingsForBlockElement5(rawSettings); 28691 return /* @__PURE__ */ (0, import_jsx_runtime151.jsxs)(import_jsx_runtime151.Fragment, { children: [ 28692 /* @__PURE__ */ (0, import_jsx_runtime151.jsx)( 28693 ScreenHeader, 28694 { 28695 title: (0, import_i18n84.__)("Colors"), 28696 description: (0, import_i18n84.__)( 28697 "Palette colors and the application of those colors on site elements." 28698 ) 28699 } 28700 ), 28701 /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(ScreenBody, { children: /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_components67.__experimentalVStack, { spacing: 7, children: /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(palette_default, {}) }) }), 28702 /* @__PURE__ */ (0, import_jsx_runtime151.jsx)( 28703 StylesColorPanel2, 28704 { 28705 inheritedValue: inheritedStyle, 28706 value: style, 28707 onChange: setStyle2, 28708 settings 28709 } 28710 ) 28711 ] }); 28712 } 28713 var screen_colors_default = ScreenColors; 28714 28715 // packages/global-styles-ui/build-module/screen-color-palette.js 28716 var import_i18n87 = __toESM(require_i18n()); 28717 var import_components72 = __toESM(require_components()); 28718 28719 // packages/global-styles-ui/build-module/color-palette-panel.js 28720 var import_compose12 = __toESM(require_compose()); 28721 var import_components70 = __toESM(require_components()); 28722 var import_i18n85 = __toESM(require_i18n()); 28723 28724 // packages/global-styles-ui/build-module/variations/variations-color.js 28725 var import_components69 = __toESM(require_components()); 28726 28727 // packages/global-styles-ui/build-module/preview-colors.js 28728 var import_components68 = __toESM(require_components()); 28729 28730 // packages/global-styles-ui/build-module/preset-colors.js 28731 var import_jsx_runtime152 = __toESM(require_jsx_runtime()); 28732 function PresetColors() { 28733 const { paletteColors } = useStylesPreviewColors(); 28734 return paletteColors.slice(0, 4).map(({ slug, color }, index2) => /* @__PURE__ */ (0, import_jsx_runtime152.jsx)( 28735 "div", 28736 { 28737 style: { 28738 flexGrow: 1, 28739 height: "100%", 28740 background: color 28741 } 28742 }, 28743 `$slug}-$index2}` 28744 )); 28745 } 28746 28747 // packages/global-styles-ui/build-module/preview-colors.js 28748 var import_jsx_runtime153 = __toESM(require_jsx_runtime()); 28749 var firstFrameVariants2 = { 28750 start: { 28751 scale: 1, 28752 opacity: 1 28753 }, 28754 hover: { 28755 scale: 0, 28756 opacity: 0 28757 } 28758 }; 28759 var StylesPreviewColors = ({ 28760 label, 28761 isFocused, 28762 withHoverView 28763 }) => { 28764 return /* @__PURE__ */ (0, import_jsx_runtime153.jsx)( 28765 preview_wrapper_default, 28766 { 28767 label, 28768 isFocused, 28769 withHoverView, 28770 children: ({ key }) => /* @__PURE__ */ (0, import_jsx_runtime153.jsx)( 28771 import_components68.__unstableMotion.div, 28772 { 28773 variants: firstFrameVariants2, 28774 style: { 28775 height: "100%", 28776 overflow: "hidden" 28777 }, 28778 children: /* @__PURE__ */ (0, import_jsx_runtime153.jsx)( 28779 import_components68.__experimentalHStack, 28780 { 28781 spacing: 0, 28782 justify: "center", 28783 style: { 28784 height: "100%", 28785 overflow: "hidden" 28786 }, 28787 children: /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(PresetColors, {}) 28788 } 28789 ) 28790 }, 28791 key 28792 ) 28793 } 28794 ); 28795 }; 28796 var preview_colors_default = StylesPreviewColors; 28797 28798 // packages/global-styles-ui/build-module/variations/variations-color.js 28799 var import_jsx_runtime154 = __toESM(require_jsx_runtime()); 28800 var propertiesToFilter2 = ["color"]; 28801 function ColorVariations({ 28802 title, 28803 gap = 2 28804 }) { 28805 const colorVariations = useCurrentMergeThemeStyleVariationsWithUserConfig(propertiesToFilter2); 28806 if (colorVariations?.length <= 1) { 28807 return null; 28808 } 28809 return /* @__PURE__ */ (0, import_jsx_runtime154.jsxs)(import_components69.__experimentalVStack, { spacing: 3, children: [ 28810 title && /* @__PURE__ */ (0, import_jsx_runtime154.jsx)(Subtitle, { level: 3, children: title }), 28811 /* @__PURE__ */ (0, import_jsx_runtime154.jsx)(import_components69.__experimentalGrid, { gap, children: colorVariations.map((variation, index2) => /* @__PURE__ */ (0, import_jsx_runtime154.jsx)( 28812 Variation, 28813 { 28814 variation, 28815 isPill: true, 28816 properties: propertiesToFilter2, 28817 showTooltip: true, 28818 children: () => /* @__PURE__ */ (0, import_jsx_runtime154.jsx)(preview_colors_default, {}) 28819 }, 28820 index2 28821 )) }) 28822 ] }); 28823 } 28824 28825 // packages/global-styles-ui/build-module/color-palette-panel.js 28826 var import_jsx_runtime155 = __toESM(require_jsx_runtime()); 28827 var mobilePopoverProps = { placement: "bottom-start", offset: 8 }; 28828 function ColorPalettePanel({ name: name2 }) { 28829 const [themeColors, setThemeColors] = useSetting( 28830 "color.palette.theme", 28831 name2 28832 ); 28833 const [baseThemeColors] = useSetting( 28834 "color.palette.theme", 28835 name2, 28836 "base" 28837 ); 28838 const [defaultColors, setDefaultColors] = useSetting( 28839 "color.palette.default", 28840 name2 28841 ); 28842 const [baseDefaultColors] = useSetting( 28843 "color.palette.default", 28844 name2, 28845 "base" 28846 ); 28847 const [customColors, setCustomColors] = useSetting( 28848 "color.palette.custom", 28849 name2 28850 ); 28851 const [defaultPaletteEnabled] = useSetting( 28852 "color.defaultPalette", 28853 name2 28854 ); 28855 const isMobileViewport = (0, import_compose12.useViewportMatch)("small", "<"); 28856 const popoverProps = isMobileViewport ? mobilePopoverProps : void 0; 28857 const [randomizeThemeColors] = useColorRandomizer(name2); 28858 return /* @__PURE__ */ (0, import_jsx_runtime155.jsxs)(import_components70.__experimentalVStack, { className: "global-styles-ui-color-palette-panel", spacing: 8, children: [ 28859 /* @__PURE__ */ (0, import_jsx_runtime155.jsxs)(import_components70.__experimentalVStack, { spacing: 4, children: [ 28860 !!themeColors && !!themeColors.length && /* @__PURE__ */ (0, import_jsx_runtime155.jsx)( 28861 import_components70.__experimentalPaletteEdit, 28862 { 28863 canReset: themeColors !== baseThemeColors, 28864 canOnlyChangeValues: true, 28865 colors: themeColors, 28866 onChange: setThemeColors, 28867 paletteLabel: (0, import_i18n85.__)("Theme"), 28868 paletteLabelHeadingLevel: 3, 28869 popoverProps 28870 } 28871 ), 28872 window.__experimentalEnableColorRandomizer && themeColors?.length > 0 && randomizeThemeColors && /* @__PURE__ */ (0, import_jsx_runtime155.jsx)( 28873 import_components70.Button, 28874 { 28875 __next40pxDefaultSize: true, 28876 variant: "secondary", 28877 icon: shuffle_default, 28878 onClick: randomizeThemeColors, 28879 children: (0, import_i18n85.__)("Randomize colors") 28880 } 28881 ) 28882 ] }), 28883 !!defaultColors && !!defaultColors.length && !!defaultPaletteEnabled && /* @__PURE__ */ (0, import_jsx_runtime155.jsx)( 28884 import_components70.__experimentalPaletteEdit, 28885 { 28886 canReset: defaultColors !== baseDefaultColors, 28887 canOnlyChangeValues: true, 28888 colors: defaultColors, 28889 onChange: setDefaultColors, 28890 paletteLabel: (0, import_i18n85.__)("Default"), 28891 paletteLabelHeadingLevel: 3, 28892 popoverProps 28893 } 28894 ), 28895 /* @__PURE__ */ (0, import_jsx_runtime155.jsx)( 28896 import_components70.__experimentalPaletteEdit, 28897 { 28898 colors: customColors, 28899 onChange: setCustomColors, 28900 paletteLabel: (0, import_i18n85.__)("Custom"), 28901 paletteLabelHeadingLevel: 3, 28902 slugPrefix: "custom-", 28903 popoverProps 28904 } 28905 ), 28906 /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(ColorVariations, { title: (0, import_i18n85.__)("Palettes") }) 28907 ] }); 28908 } 28909 28910 // packages/global-styles-ui/build-module/gradients-palette-panel.js 28911 var import_compose13 = __toESM(require_compose()); 28912 var import_components71 = __toESM(require_components()); 28913 var import_i18n86 = __toESM(require_i18n()); 28914 var import_jsx_runtime156 = __toESM(require_jsx_runtime()); 28915 var mobilePopoverProps2 = { placement: "bottom-start", offset: 8 }; 28916 var noop4 = () => { 28917 }; 28918 function GradientPalettePanel({ 28919 name: name2 28920 }) { 28921 const [themeGradients, setThemeGradients] = useSetting( 28922 "color.gradients.theme", 28923 name2 28924 ); 28925 const [baseThemeGradients] = useSetting( 28926 "color.gradients.theme", 28927 name2, 28928 "base" 28929 ); 28930 const [defaultGradients, setDefaultGradients] = useSetting( 28931 "color.gradients.default", 28932 name2 28933 ); 28934 const [baseDefaultGradients] = useSetting( 28935 "color.gradients.default", 28936 name2, 28937 "base" 28938 ); 28939 const [customGradients, setCustomGradients] = useSetting( 28940 "color.gradients.custom", 28941 name2 28942 ); 28943 const [defaultPaletteEnabled] = useSetting( 28944 "color.defaultGradients", 28945 name2 28946 ); 28947 const [customDuotone] = useSetting("color.duotone.custom") || []; 28948 const [defaultDuotone] = useSetting("color.duotone.default") || []; 28949 const [themeDuotone] = useSetting("color.duotone.theme") || []; 28950 const [defaultDuotoneEnabled] = useSetting("color.defaultDuotone"); 28951 const duotonePalette = [ 28952 ...customDuotone || [], 28953 ...themeDuotone || [], 28954 ...defaultDuotone && defaultDuotoneEnabled ? defaultDuotone : [] 28955 ]; 28956 const isMobileViewport = (0, import_compose13.useViewportMatch)("small", "<"); 28957 const popoverProps = isMobileViewport ? mobilePopoverProps2 : void 0; 28958 return /* @__PURE__ */ (0, import_jsx_runtime156.jsxs)( 28959 import_components71.__experimentalVStack, 28960 { 28961 className: "global-styles-ui-gradient-palette-panel", 28962 spacing: 8, 28963 children: [ 28964 !!themeGradients && !!themeGradients.length && /* @__PURE__ */ (0, import_jsx_runtime156.jsx)( 28965 import_components71.__experimentalPaletteEdit, 28966 { 28967 canReset: themeGradients !== baseThemeGradients, 28968 canOnlyChangeValues: true, 28969 gradients: themeGradients, 28970 onChange: setThemeGradients, 28971 paletteLabel: (0, import_i18n86.__)("Theme"), 28972 paletteLabelHeadingLevel: 3, 28973 popoverProps 28974 } 28975 ), 28976 !!defaultGradients && !!defaultGradients.length && !!defaultPaletteEnabled && /* @__PURE__ */ (0, import_jsx_runtime156.jsx)( 28977 import_components71.__experimentalPaletteEdit, 28978 { 28979 canReset: defaultGradients !== baseDefaultGradients, 28980 canOnlyChangeValues: true, 28981 gradients: defaultGradients, 28982 onChange: setDefaultGradients, 28983 paletteLabel: (0, import_i18n86.__)("Default"), 28984 paletteLabelHeadingLevel: 3, 28985 popoverProps 28986 } 28987 ), 28988 /* @__PURE__ */ (0, import_jsx_runtime156.jsx)( 28989 import_components71.__experimentalPaletteEdit, 28990 { 28991 gradients: customGradients, 28992 onChange: setCustomGradients, 28993 paletteLabel: (0, import_i18n86.__)("Custom"), 28994 paletteLabelHeadingLevel: 3, 28995 slugPrefix: "custom-", 28996 popoverProps 28997 } 28998 ), 28999 !!duotonePalette && !!duotonePalette.length && /* @__PURE__ */ (0, import_jsx_runtime156.jsxs)("div", { children: [ 29000 /* @__PURE__ */ (0, import_jsx_runtime156.jsx)(Subtitle, { level: 3, children: (0, import_i18n86.__)("Duotone") }), 29001 /* @__PURE__ */ (0, import_jsx_runtime156.jsx)(import_components71.__experimentalSpacer, { margin: 3 }), 29002 /* @__PURE__ */ (0, import_jsx_runtime156.jsx)( 29003 import_components71.DuotonePicker, 29004 { 29005 duotonePalette, 29006 disableCustomDuotone: true, 29007 disableCustomColors: true, 29008 clearable: false, 29009 onChange: noop4, 29010 colorPalette: [] 29011 } 29012 ) 29013 ] }) 29014 ] 29015 } 29016 ); 29017 } 29018 29019 // packages/global-styles-ui/build-module/screen-color-palette.js 29020 var import_jsx_runtime157 = __toESM(require_jsx_runtime()); 29021 var { Tabs: Tabs2 } = unlock3(import_components72.privateApis); 29022 function ScreenColorPalette({ name: name2 }) { 29023 return /* @__PURE__ */ (0, import_jsx_runtime157.jsxs)(import_jsx_runtime157.Fragment, { children: [ 29024 /* @__PURE__ */ (0, import_jsx_runtime157.jsx)( 29025 ScreenHeader, 29026 { 29027 title: (0, import_i18n87.__)("Edit palette"), 29028 description: (0, import_i18n87.__)( 29029 "The combination of colors used across the site and in color pickers." 29030 ) 29031 } 29032 ), 29033 /* @__PURE__ */ (0, import_jsx_runtime157.jsxs)(Tabs2, { children: [ 29034 /* @__PURE__ */ (0, import_jsx_runtime157.jsxs)(Tabs2.TabList, { children: [ 29035 /* @__PURE__ */ (0, import_jsx_runtime157.jsx)(Tabs2.Tab, { tabId: "color", children: (0, import_i18n87.__)("Color") }), 29036 /* @__PURE__ */ (0, import_jsx_runtime157.jsx)(Tabs2.Tab, { tabId: "gradient", children: (0, import_i18n87.__)("Gradient") }) 29037 ] }), 29038 /* @__PURE__ */ (0, import_jsx_runtime157.jsx)(Tabs2.TabPanel, { tabId: "color", focusable: false, children: /* @__PURE__ */ (0, import_jsx_runtime157.jsx)(ColorPalettePanel, { name: name2 }) }), 29039 /* @__PURE__ */ (0, import_jsx_runtime157.jsx)(Tabs2.TabPanel, { tabId: "gradient", focusable: false, children: /* @__PURE__ */ (0, import_jsx_runtime157.jsx)(GradientPalettePanel, { name: name2 }) }) 29040 ] }) 29041 ] }); 29042 } 29043 var screen_color_palette_default = ScreenColorPalette; 29044 29045 // packages/global-styles-ui/build-module/screen-background.js 29046 var import_i18n88 = __toESM(require_i18n()); 29047 var import_block_editor26 = __toESM(require_block_editor()); 29048 var import_components73 = __toESM(require_components()); 29049 29050 // packages/global-styles-ui/build-module/background-panel.js 29051 var import_block_editor25 = __toESM(require_block_editor()); 29052 var import_jsx_runtime158 = __toESM(require_jsx_runtime()); 29053 var BACKGROUND_DEFAULT_VALUES = { 29054 backgroundSize: "auto" 29055 }; 29056 var { BackgroundPanel: StylesBackgroundPanel2 } = unlock3( 29057 import_block_editor25.privateApis 29058 ); 29059 function BackgroundPanel() { 29060 const [style] = useStyle("", void 0, "user", false); 29061 const [inheritedStyle, setStyle2] = useStyle( 29062 "", 29063 void 0, 29064 "merged", 29065 false 29066 ); 29067 const [settings] = useSetting(""); 29068 return /* @__PURE__ */ (0, import_jsx_runtime158.jsx)( 29069 StylesBackgroundPanel2, 29070 { 29071 inheritedValue: inheritedStyle, 29072 value: style, 29073 onChange: setStyle2, 29074 settings, 29075 defaultValues: BACKGROUND_DEFAULT_VALUES 29076 } 29077 ); 29078 } 29079 29080 // packages/global-styles-ui/build-module/screen-background.js 29081 var import_jsx_runtime159 = __toESM(require_jsx_runtime()); 29082 var { useHasBackgroundPanel: useHasBackgroundPanel3 } = unlock3(import_block_editor26.privateApis); 29083 function ScreenBackground() { 29084 const [settings] = useSetting(""); 29085 const hasBackgroundPanel = useHasBackgroundPanel3(settings); 29086 return /* @__PURE__ */ (0, import_jsx_runtime159.jsxs)(import_jsx_runtime159.Fragment, { children: [ 29087 /* @__PURE__ */ (0, import_jsx_runtime159.jsx)( 29088 ScreenHeader, 29089 { 29090 title: (0, import_i18n88.__)("Background"), 29091 description: /* @__PURE__ */ (0, import_jsx_runtime159.jsx)(import_components73.__experimentalText, { children: (0, import_i18n88.__)("Set styles for the site's background.") }) 29092 } 29093 ), 29094 hasBackgroundPanel && /* @__PURE__ */ (0, import_jsx_runtime159.jsx)(BackgroundPanel, {}) 29095 ] }); 29096 } 29097 var screen_background_default = ScreenBackground; 29098 29099 // packages/global-styles-ui/build-module/shadows-panel.js 29100 var import_components75 = __toESM(require_components()); 29101 var import_i18n90 = __toESM(require_i18n()); 29102 var import_element59 = __toESM(require_element()); 29103 29104 // packages/global-styles-ui/build-module/confirm-reset-shadow-dialog.js 29105 var import_components74 = __toESM(require_components()); 29106 var import_i18n89 = __toESM(require_i18n()); 29107 var import_jsx_runtime160 = __toESM(require_jsx_runtime()); 29108 function ConfirmResetShadowDialog({ 29109 text, 29110 confirmButtonText, 29111 isOpen, 29112 toggleOpen, 29113 onConfirm 29114 }) { 29115 const handleConfirm = async () => { 29116 toggleOpen(); 29117 onConfirm(); 29118 }; 29119 const handleCancel = () => { 29120 toggleOpen(); 29121 }; 29122 return /* @__PURE__ */ (0, import_jsx_runtime160.jsx)( 29123 import_components74.__experimentalConfirmDialog, 29124 { 29125 isOpen, 29126 cancelButtonText: (0, import_i18n89.__)("Cancel"), 29127 confirmButtonText, 29128 onCancel: handleCancel, 29129 onConfirm: handleConfirm, 29130 size: "medium", 29131 children: text 29132 } 29133 ); 29134 } 29135 var confirm_reset_shadow_dialog_default = ConfirmResetShadowDialog; 29136 29137 // packages/global-styles-ui/build-module/shadows-panel.js 29138 var import_jsx_runtime161 = __toESM(require_jsx_runtime()); 29139 var { Menu } = unlock3(import_components75.privateApis); 29140 var defaultShadow = "6px 6px 9px rgba(0, 0, 0, 0.2)"; 29141 function ShadowsPanel() { 29142 const [defaultShadows] = useSetting("shadow.presets.default"); 29143 const [defaultShadowsEnabled] = useSetting("shadow.defaultPresets"); 29144 const [themeShadows] = useSetting("shadow.presets.theme"); 29145 const [customShadows, setCustomShadows] = useSetting( 29146 "shadow.presets.custom" 29147 ); 29148 const onCreateShadow = (shadow) => { 29149 setCustomShadows([...customShadows || [], shadow]); 29150 }; 29151 const handleResetShadows = () => { 29152 setCustomShadows([]); 29153 }; 29154 const [isResetDialogOpen, setIsResetDialogOpen] = (0, import_element59.useState)(false); 29155 const toggleResetDialog = () => setIsResetDialogOpen(!isResetDialogOpen); 29156 return /* @__PURE__ */ (0, import_jsx_runtime161.jsxs)(import_jsx_runtime161.Fragment, { children: [ 29157 isResetDialogOpen && /* @__PURE__ */ (0, import_jsx_runtime161.jsx)( 29158 confirm_reset_shadow_dialog_default, 29159 { 29160 text: (0, import_i18n90.__)( 29161 "Are you sure you want to remove all custom shadows?" 29162 ), 29163 confirmButtonText: (0, import_i18n90.__)("Remove"), 29164 isOpen: isResetDialogOpen, 29165 toggleOpen: toggleResetDialog, 29166 onConfirm: handleResetShadows 29167 } 29168 ), 29169 /* @__PURE__ */ (0, import_jsx_runtime161.jsx)( 29170 ScreenHeader, 29171 { 29172 title: (0, import_i18n90.__)("Shadows"), 29173 description: (0, import_i18n90.__)( 29174 "Manage and create shadow styles for use across the site." 29175 ) 29176 } 29177 ), 29178 /* @__PURE__ */ (0, import_jsx_runtime161.jsx)(ScreenBody, { children: /* @__PURE__ */ (0, import_jsx_runtime161.jsxs)( 29179 import_components75.__experimentalVStack, 29180 { 29181 className: "global-styles-ui__shadows-panel", 29182 spacing: 7, 29183 children: [ 29184 defaultShadowsEnabled && /* @__PURE__ */ (0, import_jsx_runtime161.jsx)( 29185 ShadowList, 29186 { 29187 label: (0, import_i18n90.__)("Default"), 29188 shadows: defaultShadows || [], 29189 category: "default" 29190 } 29191 ), 29192 themeShadows && themeShadows.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime161.jsx)( 29193 ShadowList, 29194 { 29195 label: (0, import_i18n90.__)("Theme"), 29196 shadows: themeShadows || [], 29197 category: "theme" 29198 } 29199 ), 29200 /* @__PURE__ */ (0, import_jsx_runtime161.jsx)( 29201 ShadowList, 29202 { 29203 label: (0, import_i18n90.__)("Custom"), 29204 shadows: customShadows || [], 29205 category: "custom", 29206 canCreate: true, 29207 onCreate: onCreateShadow, 29208 onReset: toggleResetDialog 29209 } 29210 ) 29211 ] 29212 } 29213 ) }) 29214 ] }); 29215 } 29216 function ShadowList({ 29217 label, 29218 shadows, 29219 category, 29220 canCreate, 29221 onCreate, 29222 onReset 29223 }) { 29224 const handleAddShadow = () => { 29225 const newIndex = getNewIndexFromPresets(shadows, "shadow-"); 29226 onCreate?.({ 29227 name: (0, import_i18n90.sprintf)( 29228 /* translators: %d: is an index for a preset */ 29229 (0, import_i18n90.__)("Shadow %d"), 29230 newIndex 29231 ), 29232 shadow: defaultShadow, 29233 slug: `shadow-$newIndex}` 29234 }); 29235 }; 29236 return /* @__PURE__ */ (0, import_jsx_runtime161.jsxs)(import_components75.__experimentalVStack, { spacing: 2, children: [ 29237 /* @__PURE__ */ (0, import_jsx_runtime161.jsxs)(import_components75.__experimentalHStack, { justify: "space-between", children: [ 29238 /* @__PURE__ */ (0, import_jsx_runtime161.jsx)(Subtitle, { level: 3, children: label }), 29239 /* @__PURE__ */ (0, import_jsx_runtime161.jsxs)(import_components75.FlexItem, { className: "global-styles-ui__shadows-panel__options-container", children: [ 29240 canCreate && /* @__PURE__ */ (0, import_jsx_runtime161.jsx)( 29241 import_components75.Button, 29242 { 29243 size: "small", 29244 icon: plus_default, 29245 label: (0, import_i18n90.__)("Add shadow"), 29246 onClick: () => { 29247 handleAddShadow(); 29248 } 29249 } 29250 ), 29251 !!shadows?.length && category === "custom" && /* @__PURE__ */ (0, import_jsx_runtime161.jsxs)(Menu, { children: [ 29252 /* @__PURE__ */ (0, import_jsx_runtime161.jsx)( 29253 Menu.TriggerButton, 29254 { 29255 render: /* @__PURE__ */ (0, import_jsx_runtime161.jsx)( 29256 import_components75.Button, 29257 { 29258 size: "small", 29259 icon: more_vertical_default, 29260 label: (0, import_i18n90.__)("Shadow options") 29261 } 29262 ) 29263 } 29264 ), 29265 /* @__PURE__ */ (0, import_jsx_runtime161.jsx)(Menu.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime161.jsx)(Menu.Item, { onClick: onReset, children: /* @__PURE__ */ (0, import_jsx_runtime161.jsx)(Menu.ItemLabel, { children: (0, import_i18n90.__)("Remove all custom shadows") }) }) }) 29266 ] }) 29267 ] }) 29268 ] }), 29269 shadows.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime161.jsx)(import_components75.__experimentalItemGroup, { isBordered: true, isSeparated: true, children: shadows.map((shadow) => /* @__PURE__ */ (0, import_jsx_runtime161.jsx)( 29270 ShadowItem, 29271 { 29272 shadow, 29273 category 29274 }, 29275 shadow.slug 29276 )) }) 29277 ] }); 29278 } 29279 function ShadowItem({ shadow, category }) { 29280 return /* @__PURE__ */ (0, import_jsx_runtime161.jsx)( 29281 NavigationButtonAsItem, 29282 { 29283 path: `/shadows/edit/$category}/$shadow.slug}`, 29284 children: /* @__PURE__ */ (0, import_jsx_runtime161.jsxs)(import_components75.__experimentalHStack, { children: [ 29285 /* @__PURE__ */ (0, import_jsx_runtime161.jsx)(import_components75.FlexItem, { children: shadow.name }), 29286 /* @__PURE__ */ (0, import_jsx_runtime161.jsx)(icon_default, { icon: (0, import_i18n90.isRTL)() ? chevron_left_default : chevron_right_default }) 29287 ] }) 29288 } 29289 ); 29290 } 29291 29292 // packages/global-styles-ui/build-module/shadows-edit-panel.js 29293 var import_components76 = __toESM(require_components()); 29294 var import_i18n91 = __toESM(require_i18n()); 29295 var import_element60 = __toESM(require_element()); 29296 29297 // packages/global-styles-ui/build-module/shadow-utils.js 29298 function getShadowParts(shadow) { 29299 const shadowValues = shadow.match(/(?:[^,(]|\([^)]*\))+/g) || []; 29300 return shadowValues.map((value) => value.trim()); 29301 } 29302 function shadowStringToObject(shadowValue) { 29303 const defaultShadow2 = { 29304 x: "0", 29305 y: "0", 29306 blur: "0", 29307 spread: "0", 29308 color: "#000", 29309 inset: false 29310 }; 29311 if (!shadowValue) { 29312 return defaultShadow2; 29313 } 29314 if (shadowValue.includes("none")) { 29315 return defaultShadow2; 29316 } 29317 const lengthsRegex = /((?:^|\s+)(-?\d*\.?\d+(?:px|%|in|cm|mm|em|rem|ex|pt|pc|vh|vw|vmin|vmax|ch|lh)?)(?=\s|$)(?![^(]*\))){1,4}/g; 29318 const matches = shadowValue.match(lengthsRegex) || []; 29319 if (matches.length !== 1) { 29320 return defaultShadow2; 29321 } 29322 const lengths = matches[0].split(" ").map((value) => value.trim()).filter((value) => value); 29323 if (lengths.length < 2) { 29324 return defaultShadow2; 29325 } 29326 const insets = shadowValue.match(/inset/gi) || []; 29327 if (insets.length > 1) { 29328 return defaultShadow2; 29329 } 29330 const hasInset = insets.length === 1; 29331 let colorString = shadowValue.replace(lengthsRegex, "").trim(); 29332 if (hasInset) { 29333 colorString = colorString.replace("inset", "").replace("INSET", "").trim(); 29334 } 29335 const colorRegex = /^#([0-9a-f]{3}){1,2}$|^#([0-9a-f]{4}){1,2}$|^(?:rgb|hsl)a?\(?[\d*\.?\d+%?,?\/?\s]*\)$/gi; 29336 let colorMatches = (colorString.match(colorRegex) || []).map((value) => value?.trim()).filter((value) => value); 29337 if (colorMatches.length > 1) { 29338 return defaultShadow2; 29339 } else if (colorMatches.length === 0) { 29340 colorMatches = colorString.trim().split(" ").filter((value) => value); 29341 if (colorMatches.length > 1) { 29342 return defaultShadow2; 29343 } 29344 } 29345 const [x2, y3, blur, spread] = lengths; 29346 return { 29347 x: x2, 29348 y: y3, 29349 blur: blur || defaultShadow2.blur, 29350 spread: spread || defaultShadow2.spread, 29351 inset: hasInset, 29352 color: colorString || defaultShadow2.color 29353 }; 29354 } 29355 function shadowObjectToString(shadowObj) { 29356 const shadowString = `$shadowObj.x || "0px"} $shadowObj.y || "0px"} $shadowObj.blur || "0px"} $shadowObj.spread || "0px"}`; 29357 return `$shadowObj.inset ? "inset" : ""} $shadowString} $shadowObj.color || ""}`.trim(); 29358 } 29359 29360 // packages/global-styles-ui/build-module/shadows-edit-panel.js 29361 var import_jsx_runtime162 = __toESM(require_jsx_runtime()); 29362 var { Menu: Menu2 } = unlock3(import_components76.privateApis); 29363 var customShadowMenuItems = [ 29364 { 29365 label: (0, import_i18n91.__)("Rename"), 29366 action: "rename" 29367 }, 29368 { 29369 label: (0, import_i18n91.__)("Delete"), 29370 action: "delete" 29371 } 29372 ]; 29373 var presetShadowMenuItems = [ 29374 { 29375 label: (0, import_i18n91.__)("Reset"), 29376 action: "reset" 29377 } 29378 ]; 29379 function ShadowsEditPanel() { 29380 const { goBack, params } = (0, import_components76.useNavigator)(); 29381 const { category, slug } = params; 29382 const [shadows, setShadows] = useSetting( 29383 `shadow.presets.$category}` 29384 ); 29385 (0, import_element60.useEffect)(() => { 29386 const hasCurrentShadow = shadows?.some( 29387 (shadow) => shadow.slug === slug 29388 ); 29389 if (!!slug && !hasCurrentShadow) { 29390 goBack(); 29391 } 29392 }, [shadows, slug, goBack]); 29393 const [baseShadows] = useSetting( 29394 `shadow.presets.$category}`, 29395 void 0, 29396 "base" 29397 ); 29398 const [selectedShadow, setSelectedShadow] = (0, import_element60.useState)( 29399 () => (shadows || []).find((shadow) => shadow.slug === slug) 29400 ); 29401 const baseSelectedShadow = (0, import_element60.useMemo)( 29402 () => (baseShadows || []).find((b3) => b3.slug === slug), 29403 [baseShadows, slug] 29404 ); 29405 const [isConfirmDialogVisible, setIsConfirmDialogVisible] = (0, import_element60.useState)(false); 29406 const [isRenameModalVisible, setIsRenameModalVisible] = (0, import_element60.useState)(false); 29407 const [shadowName, setShadowName] = (0, import_element60.useState)( 29408 selectedShadow?.name 29409 ); 29410 if (!category || !slug) { 29411 return null; 29412 } 29413 const onShadowChange = (shadow) => { 29414 setSelectedShadow({ ...selectedShadow, shadow }); 29415 const updatedShadows = shadows.map( 29416 (s3) => s3.slug === slug ? { ...selectedShadow, shadow } : s3 29417 ); 29418 setShadows(updatedShadows); 29419 }; 29420 const onMenuClick = (action) => { 29421 if (action === "reset") { 29422 const updatedShadows = shadows.map( 29423 (s3) => s3.slug === slug ? baseSelectedShadow : s3 29424 ); 29425 setSelectedShadow(baseSelectedShadow); 29426 setShadows(updatedShadows); 29427 } else if (action === "delete") { 29428 setIsConfirmDialogVisible(true); 29429 } else if (action === "rename") { 29430 setIsRenameModalVisible(true); 29431 } 29432 }; 29433 const handleShadowDelete = () => { 29434 setShadows(shadows.filter((s3) => s3.slug !== slug)); 29435 }; 29436 const handleShadowRename = (newName) => { 29437 if (!newName) { 29438 return; 29439 } 29440 const updatedShadows = shadows.map( 29441 (s3) => s3.slug === slug ? { ...selectedShadow, name: newName } : s3 29442 ); 29443 setSelectedShadow({ ...selectedShadow, name: newName }); 29444 setShadows(updatedShadows); 29445 }; 29446 return !selectedShadow ? /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(ScreenHeader, { title: "" }) : /* @__PURE__ */ (0, import_jsx_runtime162.jsxs)(import_jsx_runtime162.Fragment, { children: [ 29447 /* @__PURE__ */ (0, import_jsx_runtime162.jsxs)(import_components76.__experimentalHStack, { justify: "space-between", children: [ 29448 /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(ScreenHeader, { title: selectedShadow.name }), 29449 /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(import_components76.FlexItem, { children: /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(import_components76.__experimentalSpacer, { marginTop: 2, marginBottom: 0, paddingX: 4, children: /* @__PURE__ */ (0, import_jsx_runtime162.jsxs)(Menu2, { children: [ 29450 /* @__PURE__ */ (0, import_jsx_runtime162.jsx)( 29451 Menu2.TriggerButton, 29452 { 29453 render: /* @__PURE__ */ (0, import_jsx_runtime162.jsx)( 29454 import_components76.Button, 29455 { 29456 size: "small", 29457 icon: more_vertical_default, 29458 label: (0, import_i18n91.__)("Menu") 29459 } 29460 ) 29461 } 29462 ), 29463 /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(Menu2.Popover, { children: (category === "custom" ? customShadowMenuItems : presetShadowMenuItems).map((item) => /* @__PURE__ */ (0, import_jsx_runtime162.jsx)( 29464 Menu2.Item, 29465 { 29466 onClick: () => onMenuClick(item.action), 29467 disabled: item.action === "reset" && selectedShadow.shadow === baseSelectedShadow?.shadow, 29468 children: /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(Menu2.ItemLabel, { children: item.label }) 29469 }, 29470 item.action 29471 )) }) 29472 ] }) }) }) 29473 ] }), 29474 /* @__PURE__ */ (0, import_jsx_runtime162.jsxs)(ScreenBody, { children: [ 29475 /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(ShadowsPreview, { shadow: selectedShadow.shadow }), 29476 /* @__PURE__ */ (0, import_jsx_runtime162.jsx)( 29477 ShadowEditor, 29478 { 29479 shadow: selectedShadow.shadow, 29480 onChange: onShadowChange 29481 } 29482 ) 29483 ] }), 29484 isConfirmDialogVisible && /* @__PURE__ */ (0, import_jsx_runtime162.jsx)( 29485 import_components76.__experimentalConfirmDialog, 29486 { 29487 isOpen: true, 29488 onConfirm: () => { 29489 handleShadowDelete(); 29490 setIsConfirmDialogVisible(false); 29491 }, 29492 onCancel: () => { 29493 setIsConfirmDialogVisible(false); 29494 }, 29495 confirmButtonText: (0, import_i18n91.__)("Delete"), 29496 size: "medium", 29497 children: (0, import_i18n91.sprintf)( 29498 /* translators: %s: Name of the shadow preset. */ 29499 (0, import_i18n91.__)( 29500 'Are you sure you want to delete "%s" shadow preset?' 29501 ), 29502 selectedShadow.name 29503 ) 29504 } 29505 ), 29506 isRenameModalVisible && /* @__PURE__ */ (0, import_jsx_runtime162.jsx)( 29507 import_components76.Modal, 29508 { 29509 title: (0, import_i18n91.__)("Rename"), 29510 onRequestClose: () => setIsRenameModalVisible(false), 29511 size: "small", 29512 children: /* @__PURE__ */ (0, import_jsx_runtime162.jsxs)( 29513 "form", 29514 { 29515 onSubmit: (event) => { 29516 event.preventDefault(); 29517 handleShadowRename(shadowName); 29518 setIsRenameModalVisible(false); 29519 }, 29520 children: [ 29521 /* @__PURE__ */ (0, import_jsx_runtime162.jsx)( 29522 import_components76.__experimentalInputControl, 29523 { 29524 __next40pxDefaultSize: true, 29525 autoComplete: "off", 29526 label: (0, import_i18n91.__)("Name"), 29527 placeholder: (0, import_i18n91.__)("Shadow name"), 29528 value: shadowName ?? "", 29529 onChange: setShadowName 29530 } 29531 ), 29532 /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(import_components76.__experimentalSpacer, { marginBottom: 6 }), 29533 /* @__PURE__ */ (0, import_jsx_runtime162.jsxs)( 29534 import_components76.Flex, 29535 { 29536 className: "block-editor-shadow-edit-modal__actions", 29537 justify: "flex-end", 29538 expanded: false, 29539 children: [ 29540 /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(import_components76.FlexItem, { children: /* @__PURE__ */ (0, import_jsx_runtime162.jsx)( 29541 import_components76.Button, 29542 { 29543 __next40pxDefaultSize: true, 29544 variant: "tertiary", 29545 onClick: () => setIsRenameModalVisible(false), 29546 children: (0, import_i18n91.__)("Cancel") 29547 } 29548 ) }), 29549 /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(import_components76.FlexItem, { children: /* @__PURE__ */ (0, import_jsx_runtime162.jsx)( 29550 import_components76.Button, 29551 { 29552 __next40pxDefaultSize: true, 29553 variant: "primary", 29554 type: "submit", 29555 children: (0, import_i18n91.__)("Save") 29556 } 29557 ) }) 29558 ] 29559 } 29560 ) 29561 ] 29562 } 29563 ) 29564 } 29565 ) 29566 ] }); 29567 } 29568 function ShadowsPreview({ shadow }) { 29569 const shadowStyle = { 29570 boxShadow: shadow 29571 }; 29572 return /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(import_components76.__experimentalSpacer, { marginBottom: 4, marginTop: -2, children: /* @__PURE__ */ (0, import_jsx_runtime162.jsx)( 29573 import_components76.__experimentalHStack, 29574 { 29575 alignment: "center", 29576 justify: "center", 29577 className: "global-styles-ui__shadow-preview-panel", 29578 children: /* @__PURE__ */ (0, import_jsx_runtime162.jsx)( 29579 "div", 29580 { 29581 className: "global-styles-ui__shadow-preview-block", 29582 style: shadowStyle 29583 } 29584 ) 29585 } 29586 ) }); 29587 } 29588 function ShadowEditor({ shadow, onChange }) { 29589 const addShadowButtonRef = (0, import_element60.useRef)(null); 29590 const shadowParts = (0, import_element60.useMemo)(() => getShadowParts(shadow), [shadow]); 29591 const onChangeShadowPart = (index2, part) => { 29592 const newShadowParts = [...shadowParts]; 29593 newShadowParts[index2] = part; 29594 onChange(newShadowParts.join(", ")); 29595 }; 29596 const onAddShadowPart = () => { 29597 onChange([...shadowParts, defaultShadow].join(", ")); 29598 }; 29599 const onRemoveShadowPart = (index2) => { 29600 onChange(shadowParts.filter((p4, i3) => i3 !== index2).join(", ")); 29601 addShadowButtonRef.current?.focus(); 29602 }; 29603 return /* @__PURE__ */ (0, import_jsx_runtime162.jsxs)(import_jsx_runtime162.Fragment, { children: [ 29604 /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(import_components76.__experimentalVStack, { spacing: 2, children: /* @__PURE__ */ (0, import_jsx_runtime162.jsxs)(import_components76.__experimentalHStack, { justify: "space-between", children: [ 29605 /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(Subtitle, { level: 3, children: (0, import_i18n91.__)("Shadows") }), 29606 /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(import_components76.FlexItem, { className: "global-styles-ui__shadows-panel__options-container", children: /* @__PURE__ */ (0, import_jsx_runtime162.jsx)( 29607 import_components76.Button, 29608 { 29609 size: "small", 29610 icon: plus_default, 29611 label: (0, import_i18n91.__)("Add shadow"), 29612 onClick: () => { 29613 onAddShadowPart(); 29614 }, 29615 ref: addShadowButtonRef 29616 } 29617 ) }) 29618 ] }) }), 29619 /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(import_components76.__experimentalSpacer, {}), 29620 /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(import_components76.__experimentalItemGroup, { isBordered: true, isSeparated: true, children: shadowParts.map((part, index2) => /* @__PURE__ */ (0, import_jsx_runtime162.jsx)( 29621 ShadowItem2, 29622 { 29623 shadow: part, 29624 onChange: (value) => onChangeShadowPart(index2, value), 29625 canRemove: shadowParts.length > 1, 29626 onRemove: () => onRemoveShadowPart(index2) 29627 }, 29628 index2 29629 )) }) 29630 ] }); 29631 } 29632 function ShadowItem2({ 29633 shadow, 29634 onChange, 29635 canRemove, 29636 onRemove 29637 }) { 29638 const popoverProps = { 29639 placement: "left-start", 29640 offset: 36, 29641 shift: true 29642 }; 29643 const shadowObj = (0, import_element60.useMemo)( 29644 () => shadowStringToObject(shadow), 29645 [shadow] 29646 ); 29647 const onShadowChange = (newShadow) => { 29648 onChange(shadowObjectToString(newShadow)); 29649 }; 29650 return /* @__PURE__ */ (0, import_jsx_runtime162.jsx)( 29651 import_components76.Dropdown, 29652 { 29653 popoverProps, 29654 className: "global-styles-ui__shadow-editor__dropdown", 29655 renderToggle: ({ onToggle, isOpen }) => { 29656 const toggleProps = { 29657 onClick: onToggle, 29658 className: clsx_default( 29659 "global-styles-ui__shadow-editor__dropdown-toggle", 29660 { "is-open": isOpen } 29661 ), 29662 "aria-expanded": isOpen 29663 }; 29664 const removeButtonProps = { 29665 onClick: () => { 29666 if (isOpen) { 29667 onToggle(); 29668 } 29669 onRemove(); 29670 }, 29671 className: clsx_default( 29672 "global-styles-ui__shadow-editor__remove-button", 29673 { "is-open": isOpen } 29674 ), 29675 label: (0, import_i18n91.__)("Remove shadow") 29676 }; 29677 return /* @__PURE__ */ (0, import_jsx_runtime162.jsxs)(import_jsx_runtime162.Fragment, { children: [ 29678 /* @__PURE__ */ (0, import_jsx_runtime162.jsx)( 29679 import_components76.Button, 29680 { 29681 __next40pxDefaultSize: true, 29682 icon: shadow_default, 29683 ...toggleProps, 29684 children: shadowObj.inset ? (0, import_i18n91.__)("Inner shadow") : (0, import_i18n91.__)("Drop shadow") 29685 } 29686 ), 29687 canRemove && /* @__PURE__ */ (0, import_jsx_runtime162.jsx)( 29688 import_components76.Button, 29689 { 29690 size: "small", 29691 icon: reset_default, 29692 ...removeButtonProps 29693 } 29694 ) 29695 ] }); 29696 }, 29697 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime162.jsx)( 29698 import_components76.__experimentalDropdownContentWrapper, 29699 { 29700 paddingSize: "medium", 29701 className: "global-styles-ui__shadow-editor__dropdown-content", 29702 children: /* @__PURE__ */ (0, import_jsx_runtime162.jsx)( 29703 ShadowPopover, 29704 { 29705 shadowObj, 29706 onChange: onShadowChange 29707 } 29708 ) 29709 } 29710 ) 29711 } 29712 ); 29713 } 29714 function ShadowPopover({ shadowObj, onChange }) { 29715 const __experimentalIsRenderedInSidebar = true; 29716 const enableAlpha = true; 29717 const onShadowChange = (key, value) => { 29718 const newShadow = { 29719 ...shadowObj, 29720 [key]: value 29721 }; 29722 onChange(newShadow); 29723 }; 29724 return /* @__PURE__ */ (0, import_jsx_runtime162.jsxs)(import_components76.__experimentalVStack, { spacing: 4, className: "global-styles-ui__shadow-editor-panel", children: [ 29725 /* @__PURE__ */ (0, import_jsx_runtime162.jsx)( 29726 import_components76.ColorPalette, 29727 { 29728 clearable: false, 29729 enableAlpha, 29730 __experimentalIsRenderedInSidebar, 29731 value: shadowObj.color, 29732 onChange: (value) => onShadowChange("color", value) 29733 } 29734 ), 29735 /* @__PURE__ */ (0, import_jsx_runtime162.jsxs)( 29736 import_components76.__experimentalToggleGroupControl, 29737 { 29738 label: (0, import_i18n91.__)("Shadow Type"), 29739 value: shadowObj.inset ? "inset" : "outset", 29740 isBlock: true, 29741 onChange: (value) => onShadowChange("inset", value === "inset"), 29742 hideLabelFromVision: true, 29743 __next40pxDefaultSize: true, 29744 children: [ 29745 /* @__PURE__ */ (0, import_jsx_runtime162.jsx)( 29746 import_components76.__experimentalToggleGroupControlOption, 29747 { 29748 value: "outset", 29749 label: (0, import_i18n91.__)("Outset") 29750 } 29751 ), 29752 /* @__PURE__ */ (0, import_jsx_runtime162.jsx)( 29753 import_components76.__experimentalToggleGroupControlOption, 29754 { 29755 value: "inset", 29756 label: (0, import_i18n91.__)("Inset") 29757 } 29758 ) 29759 ] 29760 } 29761 ), 29762 /* @__PURE__ */ (0, import_jsx_runtime162.jsxs)(import_components76.__experimentalGrid, { columns: 2, gap: 4, children: [ 29763 /* @__PURE__ */ (0, import_jsx_runtime162.jsx)( 29764 ShadowInputControl, 29765 { 29766 label: (0, import_i18n91.__)("X Position"), 29767 value: shadowObj.x, 29768 onChange: (value) => onShadowChange("x", value) 29769 } 29770 ), 29771 /* @__PURE__ */ (0, import_jsx_runtime162.jsx)( 29772 ShadowInputControl, 29773 { 29774 label: (0, import_i18n91.__)("Y Position"), 29775 value: shadowObj.y, 29776 onChange: (value) => onShadowChange("y", value) 29777 } 29778 ), 29779 /* @__PURE__ */ (0, import_jsx_runtime162.jsx)( 29780 ShadowInputControl, 29781 { 29782 label: (0, import_i18n91.__)("Blur"), 29783 value: shadowObj.blur, 29784 onChange: (value) => onShadowChange("blur", value) 29785 } 29786 ), 29787 /* @__PURE__ */ (0, import_jsx_runtime162.jsx)( 29788 ShadowInputControl, 29789 { 29790 label: (0, import_i18n91.__)("Spread"), 29791 value: shadowObj.spread, 29792 onChange: (value) => onShadowChange("spread", value) 29793 } 29794 ) 29795 ] }) 29796 ] }); 29797 } 29798 function ShadowInputControl({ 29799 label, 29800 value, 29801 onChange 29802 }) { 29803 const onValueChange = (next) => { 29804 const isNumeric = next !== void 0 && !isNaN(parseFloat(next)); 29805 const nextValue = isNumeric ? next : "0px"; 29806 onChange(nextValue); 29807 }; 29808 return /* @__PURE__ */ (0, import_jsx_runtime162.jsx)( 29809 import_components76.__experimentalUnitControl, 29810 { 29811 label, 29812 __next40pxDefaultSize: true, 29813 value, 29814 onChange: onValueChange 29815 } 29816 ); 29817 } 29818 29819 // packages/global-styles-ui/build-module/screen-shadows.js 29820 var import_jsx_runtime163 = __toESM(require_jsx_runtime()); 29821 function ScreenShadows() { 29822 return /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(ShadowsPanel, {}); 29823 } 29824 function ScreenShadowsEdit() { 29825 return /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(ShadowsEditPanel, {}); 29826 } 29827 29828 // packages/global-styles-ui/build-module/screen-layout.js 29829 var import_i18n92 = __toESM(require_i18n()); 29830 var import_block_editor28 = __toESM(require_block_editor()); 29831 29832 // packages/global-styles-ui/build-module/dimensions-panel.js 29833 var import_block_editor27 = __toESM(require_block_editor()); 29834 var import_element61 = __toESM(require_element()); 29835 var import_jsx_runtime164 = __toESM(require_jsx_runtime()); 29836 var { useSettingsForBlockElement: useSettingsForBlockElement6, DimensionsPanel: StylesDimensionsPanel2 } = unlock3(import_block_editor27.privateApis); 29837 var DEFAULT_CONTROLS = { 29838 contentSize: true, 29839 wideSize: true, 29840 padding: true, 29841 margin: true, 29842 blockGap: true, 29843 height: true, 29844 minHeight: true, 29845 width: true, 29846 childLayout: false 29847 }; 29848 function DimensionsPanel() { 29849 const [style] = useStyle("", void 0, "user", false); 29850 const [inheritedStyle, setStyle2] = useStyle( 29851 "", 29852 void 0, 29853 "merged", 29854 false 29855 ); 29856 const [userSettings] = useSetting("", void 0, "user"); 29857 const [rawSettings, setSettings] = useSetting(""); 29858 const settings = useSettingsForBlockElement6(rawSettings); 29859 const inheritedStyleWithLayout = (0, import_element61.useMemo)(() => { 29860 return { 29861 ...inheritedStyle, 29862 layout: settings.layout 29863 }; 29864 }, [inheritedStyle, settings.layout]); 29865 const styleWithLayout = (0, import_element61.useMemo)(() => { 29866 return { 29867 ...style, 29868 layout: userSettings.layout 29869 }; 29870 }, [style, userSettings.layout]); 29871 const onChange = (newStyle) => { 29872 const updatedStyle = { ...newStyle }; 29873 delete updatedStyle.layout; 29874 setStyle2(updatedStyle); 29875 if (newStyle.layout !== userSettings.layout) { 29876 const updatedSettings = { 29877 ...userSettings, 29878 layout: newStyle.layout 29879 }; 29880 if (updatedSettings.layout?.definitions) { 29881 delete updatedSettings.layout.definitions; 29882 } 29883 setSettings(updatedSettings); 29884 } 29885 }; 29886 return /* @__PURE__ */ (0, import_jsx_runtime164.jsx)( 29887 StylesDimensionsPanel2, 29888 { 29889 inheritedValue: inheritedStyleWithLayout, 29890 value: styleWithLayout, 29891 onChange, 29892 settings, 29893 includeLayoutControls: true, 29894 defaultControls: DEFAULT_CONTROLS 29895 } 29896 ); 29897 } 29898 29899 // packages/global-styles-ui/build-module/screen-layout.js 29900 var import_jsx_runtime165 = __toESM(require_jsx_runtime()); 29901 var { useHasDimensionsPanel: useHasDimensionsPanel4, useSettingsForBlockElement: useSettingsForBlockElement7 } = unlock3( 29902 import_block_editor28.privateApis 29903 ); 29904 function ScreenLayout() { 29905 const [rawSettings] = useSetting(""); 29906 const settings = useSettingsForBlockElement7(rawSettings); 29907 const hasDimensionsPanel = useHasDimensionsPanel4(settings); 29908 return /* @__PURE__ */ (0, import_jsx_runtime165.jsxs)(import_jsx_runtime165.Fragment, { children: [ 29909 /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(ScreenHeader, { title: (0, import_i18n92.__)("Layout") }), 29910 hasDimensionsPanel && /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(DimensionsPanel, {}) 29911 ] }); 29912 } 29913 var screen_layout_default = ScreenLayout; 29914 29915 // packages/global-styles-ui/build-module/screen-style-variations.js 29916 var import_components79 = __toESM(require_components()); 29917 var import_i18n95 = __toESM(require_i18n()); 29918 29919 // packages/global-styles-ui/build-module/style-variations-content.js 29920 var import_i18n94 = __toESM(require_i18n()); 29921 var import_components78 = __toESM(require_components()); 29922 29923 // packages/global-styles-ui/build-module/style-variations-container.js 29924 var import_core_data39 = __toESM(require_core_data()); 29925 var import_data57 = __toESM(require_data()); 29926 var import_element62 = __toESM(require_element()); 29927 var import_components77 = __toESM(require_components()); 29928 var import_i18n93 = __toESM(require_i18n()); 29929 var import_jsx_runtime166 = __toESM(require_jsx_runtime()); 29930 function StyleVariationsContainer({ 29931 gap = 2 29932 }) { 29933 const { user } = (0, import_element62.useContext)(GlobalStylesContext); 29934 const userStyles = user?.styles; 29935 const variations = (0, import_data57.useSelect)((select5) => { 29936 const result = select5( 29937 import_core_data39.store 29938 ).__experimentalGetCurrentThemeGlobalStylesVariations(); 29939 return Array.isArray(result) ? result : void 0; 29940 }, []); 29941 const fullStyleVariations = variations?.filter( 29942 (variation) => { 29943 return !isVariationWithProperties(variation, ["color"]) && !isVariationWithProperties(variation, [ 29944 "typography", 29945 "spacing" 29946 ]); 29947 } 29948 ); 29949 const themeVariations = (0, import_element62.useMemo)(() => { 29950 const withEmptyVariation = [ 29951 { 29952 title: (0, import_i18n93.__)("Default"), 29953 settings: {}, 29954 styles: {} 29955 }, 29956 ...fullStyleVariations ?? [] 29957 ]; 29958 return [ 29959 ...withEmptyVariation.map((variation) => { 29960 const blockStyles = variation?.styles?.blocks ? { ...variation.styles.blocks } : {}; 29961 if (userStyles?.blocks) { 29962 Object.keys(userStyles.blocks).forEach((blockName) => { 29963 if (userStyles.blocks?.[blockName]?.css) { 29964 const variationBlockStyles = blockStyles[blockName] || {}; 29965 const customCSS = { 29966 css: `$blockStyles[blockName]?.css || ""} $userStyles.blocks?.[blockName]?.css?.trim() || ""}` 29967 }; 29968 blockStyles[blockName] = { 29969 ...variationBlockStyles, 29970 ...customCSS 29971 }; 29972 } 29973 }); 29974 } 29975 const css = userStyles?.css || variation.styles?.css ? { 29976 css: `$variation.styles?.css || ""} $userStyles?.css || ""}` 29977 } : {}; 29978 const blocks = Object.keys(blockStyles).length > 0 ? { blocks: blockStyles } : {}; 29979 const styles = { 29980 ...variation.styles, 29981 ...css, 29982 ...blocks 29983 }; 29984 return { 29985 ...variation, 29986 settings: variation.settings ?? {}, 29987 styles 29988 }; 29989 }) 29990 ]; 29991 }, [fullStyleVariations, userStyles?.blocks, userStyles?.css]); 29992 if (!fullStyleVariations || fullStyleVariations.length < 1) { 29993 return null; 29994 } 29995 return /* @__PURE__ */ (0, import_jsx_runtime166.jsx)( 29996 import_components77.__experimentalGrid, 29997 { 29998 columns: 2, 29999 className: "global-styles-ui-style-variations-container", 30000 gap, 30001 children: themeVariations.map( 30002 (variation, index2) => /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(Variation, { variation, children: (isFocused) => /* @__PURE__ */ (0, import_jsx_runtime166.jsx)( 30003 preview_styles_default, 30004 { 30005 label: variation?.title, 30006 withHoverView: true, 30007 isFocused, 30008 variation 30009 } 30010 ) }, index2) 30011 ) 30012 } 30013 ); 30014 } 30015 var style_variations_container_default = StyleVariationsContainer; 30016 30017 // packages/global-styles-ui/build-module/style-variations-content.js 30018 var import_jsx_runtime167 = __toESM(require_jsx_runtime()); 30019 function StyleVariationsContent() { 30020 const gap = 3; 30021 return /* @__PURE__ */ (0, import_jsx_runtime167.jsxs)(import_components78.__experimentalVStack, { spacing: 10, className: "global-styles-ui-variation-container", children: [ 30022 /* @__PURE__ */ (0, import_jsx_runtime167.jsx)(style_variations_container_default, { gap }), 30023 /* @__PURE__ */ (0, import_jsx_runtime167.jsx)(ColorVariations, { title: (0, import_i18n94.__)("Color Variations"), gap }), 30024 /* @__PURE__ */ (0, import_jsx_runtime167.jsx)(TypographyVariations, { title: (0, import_i18n94.__)("Typography"), gap }) 30025 ] }); 30026 } 30027 30028 // packages/global-styles-ui/build-module/screen-style-variations.js 30029 var import_jsx_runtime168 = __toESM(require_jsx_runtime()); 30030 function ScreenStyleVariations() { 30031 return /* @__PURE__ */ (0, import_jsx_runtime168.jsxs)(import_jsx_runtime168.Fragment, { children: [ 30032 /* @__PURE__ */ (0, import_jsx_runtime168.jsx)( 30033 ScreenHeader, 30034 { 30035 title: (0, import_i18n95.__)("Browse styles"), 30036 description: (0, import_i18n95.__)( 30037 "Choose a variation to change the look of the site." 30038 ) 30039 } 30040 ), 30041 /* @__PURE__ */ (0, import_jsx_runtime168.jsx)( 30042 import_components79.Card, 30043 { 30044 size: "small", 30045 isBorderless: true, 30046 className: "global-styles-ui-screen-style-variations", 30047 children: /* @__PURE__ */ (0, import_jsx_runtime168.jsx)(import_components79.CardBody, { children: /* @__PURE__ */ (0, import_jsx_runtime168.jsx)(StyleVariationsContent, {}) }) 30048 } 30049 ) 30050 ] }); 30051 } 30052 var screen_style_variations_default = ScreenStyleVariations; 30053 30054 // packages/global-styles-ui/build-module/screen-css.js 30055 var import_i18n96 = __toESM(require_i18n()); 30056 var import_components80 = __toESM(require_components()); 30057 var import_block_editor29 = __toESM(require_block_editor()); 30058 var import_jsx_runtime169 = __toESM(require_jsx_runtime()); 30059 var { AdvancedPanel: StylesAdvancedPanel2 } = unlock3(import_block_editor29.privateApis); 30060 function ScreenCSS() { 30061 const [style] = useStyle("", void 0, "user", false); 30062 const [inheritedStyle, setStyle2] = useStyle( 30063 "", 30064 void 0, 30065 "merged", 30066 false 30067 ); 30068 return /* @__PURE__ */ (0, import_jsx_runtime169.jsxs)(import_jsx_runtime169.Fragment, { children: [ 30069 /* @__PURE__ */ (0, import_jsx_runtime169.jsx)( 30070 ScreenHeader, 30071 { 30072 title: (0, import_i18n96.__)("Additional CSS"), 30073 description: /* @__PURE__ */ (0, import_jsx_runtime169.jsxs)(import_jsx_runtime169.Fragment, { children: [ 30074 (0, import_i18n96.__)( 30075 "You can add custom CSS to further customize the appearance and layout of your site." 30076 ), 30077 /* @__PURE__ */ (0, import_jsx_runtime169.jsx)("br", {}), 30078 /* @__PURE__ */ (0, import_jsx_runtime169.jsx)( 30079 import_components80.ExternalLink, 30080 { 30081 href: (0, import_i18n96.__)( 30082 "https://developer.wordpress.org/advanced-administration/wordpress/css/" 30083 ), 30084 className: "global-styles-ui-screen-css-help-link", 30085 children: (0, import_i18n96.__)("Learn more about CSS") 30086 } 30087 ) 30088 ] }) 30089 } 30090 ), 30091 /* @__PURE__ */ (0, import_jsx_runtime169.jsx)("div", { className: "global-styles-ui-screen-css", children: /* @__PURE__ */ (0, import_jsx_runtime169.jsx)( 30092 StylesAdvancedPanel2, 30093 { 30094 value: style, 30095 onChange: setStyle2, 30096 inheritedValue: inheritedStyle 30097 } 30098 ) }) 30099 ] }); 30100 } 30101 var screen_css_default = ScreenCSS; 30102 30103 // packages/global-styles-ui/build-module/screen-revisions/index.js 30104 var import_i18n99 = __toESM(require_i18n()); 30105 var import_components83 = __toESM(require_components()); 30106 var import_element64 = __toESM(require_element()); 30107 30108 // packages/global-styles-ui/build-module/screen-revisions/use-global-styles-revisions.js 30109 var import_data58 = __toESM(require_data()); 30110 var import_core_data40 = __toESM(require_core_data()); 30111 var import_element63 = __toESM(require_element()); 30112 var SITE_EDITOR_AUTHORS_QUERY = { 30113 per_page: -1, 30114 _fields: "id,name,avatar_urls", 30115 context: "view", 30116 capabilities: ["edit_theme_options"] 30117 }; 30118 var DEFAULT_QUERY = { per_page: 100, page: 1 }; 30119 var EMPTY_ARRAY4 = []; 30120 function useGlobalStylesRevisions({ 30121 query 30122 } = {}) { 30123 const { user: userConfig } = (0, import_element63.useContext)(GlobalStylesContext); 30124 const _query = (0, import_element63.useMemo)( 30125 () => ({ ...DEFAULT_QUERY, ...query }), 30126 [query] 30127 ); 30128 const { 30129 authors, 30130 currentUser, 30131 isDirty, 30132 revisions, 30133 isLoadingGlobalStylesRevisions, 30134 revisionsCount 30135 } = (0, import_data58.useSelect)( 30136 (select5) => { 30137 const { 30138 __experimentalGetDirtyEntityRecords, 30139 getCurrentUser, 30140 getUsers, 30141 getRevisions, 30142 __experimentalGetCurrentGlobalStylesId, 30143 getEntityRecord, 30144 // @ts-expect-error 30145 isResolving 30146 } = select5(import_core_data40.store); 30147 const dirtyEntityRecords = __experimentalGetDirtyEntityRecords() || []; 30148 const _currentUser = getCurrentUser(); 30149 const _isDirty = dirtyEntityRecords.length > 0; 30150 const globalStylesId = __experimentalGetCurrentGlobalStylesId(); 30151 const globalStyles = globalStylesId ? getEntityRecord( 30152 "root", 30153 "globalStyles", 30154 globalStylesId 30155 ) : void 0; 30156 const _revisionsCount = ( 30157 // @ts-expect-error - _links is not typed in GlobalStylesRevision 30158 globalStyles?._links?.["version-history"]?.[0]?.count ?? 0 30159 ); 30160 const globalStylesRevisions = globalStylesId ? getRevisions( 30161 "root", 30162 "globalStyles", 30163 globalStylesId, 30164 _query 30165 ) || EMPTY_ARRAY4 : EMPTY_ARRAY4; 30166 const _authors = getUsers(SITE_EDITOR_AUTHORS_QUERY) || EMPTY_ARRAY4; 30167 const _isResolving = globalStylesId ? isResolving("getRevisions", [ 30168 "root", 30169 "globalStyles", 30170 globalStylesId, 30171 _query 30172 ]) : false; 30173 return { 30174 authors: _authors, 30175 currentUser: _currentUser, 30176 isDirty: _isDirty, 30177 revisions: globalStylesRevisions, 30178 isLoadingGlobalStylesRevisions: _isResolving, 30179 revisionsCount: _revisionsCount 30180 }; 30181 }, 30182 [_query] 30183 ); 30184 return (0, import_element63.useMemo)(() => { 30185 if (!authors.length || isLoadingGlobalStylesRevisions) { 30186 return { 30187 revisions: EMPTY_ARRAY4, 30188 hasUnsavedChanges: isDirty, 30189 isLoading: true, 30190 revisionsCount 30191 }; 30192 } 30193 const _modifiedRevisions = revisions.map((revision) => { 30194 return { 30195 ...revision, 30196 author: authors.find( 30197 (author) => author.id === revision.author 30198 ) 30199 }; 30200 }); 30201 const fetchedRevisionsCount = revisions.length; 30202 if (fetchedRevisionsCount) { 30203 if (_modifiedRevisions[0].id !== "unsaved" && _query.page === 1) { 30204 _modifiedRevisions[0].isLatest = true; 30205 } 30206 if (isDirty && userConfig && Object.keys(userConfig).length > 0 && currentUser && _query.page === 1) { 30207 const unsavedRevision = { 30208 id: "unsaved", 30209 styles: userConfig?.styles, 30210 settings: userConfig?.settings, 30211 _links: userConfig?._links, 30212 author: { 30213 name: currentUser?.name || "", 30214 // @ts-expect-error - avatar_urls is not typed in User 30215 avatar_urls: currentUser?.avatar_urls || {} 30216 }, 30217 modified: /* @__PURE__ */ new Date() 30218 }; 30219 _modifiedRevisions.unshift(unsavedRevision); 30220 } 30221 if (_query.per_page && _query.page === Math.ceil(revisionsCount / _query.per_page)) { 30222 _modifiedRevisions.push({ 30223 id: "parent", 30224 styles: {}, 30225 settings: {} 30226 }); 30227 } 30228 } 30229 return { 30230 revisions: _modifiedRevisions, 30231 hasUnsavedChanges: isDirty, 30232 isLoading: false, 30233 revisionsCount 30234 }; 30235 }, [ 30236 isDirty, 30237 revisions, 30238 currentUser, 30239 authors, 30240 userConfig, 30241 isLoadingGlobalStylesRevisions, 30242 revisionsCount, 30243 _query.page, 30244 _query.per_page 30245 ]); 30246 } 30247 30248 // packages/global-styles-ui/build-module/screen-revisions/revisions-buttons.js 30249 var import_i18n97 = __toESM(require_i18n()); 30250 var import_components81 = __toESM(require_components()); 30251 var import_date4 = __toESM(require_date()); 30252 var import_core_data41 = __toESM(require_core_data()); 30253 var import_data59 = __toESM(require_data()); 30254 var import_keycodes3 = __toESM(require_keycodes()); 30255 var import_jsx_runtime170 = __toESM(require_jsx_runtime()); 30256 var DAY_IN_MILLISECONDS = 60 * 60 * 1e3 * 24; 30257 function ChangesSummary({ revision, previousRevision }) { 30258 const changes = getGlobalStylesChanges( 30259 revision, 30260 previousRevision, 30261 { 30262 maxResults: 7 30263 } 30264 ); 30265 if (!changes.length) { 30266 return null; 30267 } 30268 return /* @__PURE__ */ (0, import_jsx_runtime170.jsx)( 30269 "ul", 30270 { 30271 "data-testid": "global-styles-revision-changes", 30272 className: "global-styles-ui-screen-revisions__changes", 30273 children: changes.map((change) => /* @__PURE__ */ (0, import_jsx_runtime170.jsx)("li", { children: change }, change)) 30274 } 30275 ); 30276 } 30277 function getRevisionLabel(id, authorDisplayName, formattedModifiedDate, areStylesEqual) { 30278 if ("parent" === id) { 30279 return (0, import_i18n97.__)("Reset the styles to the theme defaults"); 30280 } 30281 if ("unsaved" === id) { 30282 return (0, import_i18n97.sprintf)( 30283 /* translators: %s: author display name */ 30284 (0, import_i18n97.__)("Unsaved changes by %s"), 30285 authorDisplayName 30286 ); 30287 } 30288 return areStylesEqual ? (0, import_i18n97.sprintf)( 30289 // translators: 1: author display name. 2: revision creation date. 30290 (0, import_i18n97.__)( 30291 "Changes saved by %1$s on %2$s. This revision matches current editor styles." 30292 ), 30293 authorDisplayName, 30294 formattedModifiedDate 30295 ) : (0, import_i18n97.sprintf)( 30296 // translators: 1: author display name. 2: revision creation date. 30297 (0, import_i18n97.__)("Changes saved by %1$s on %2$s"), 30298 authorDisplayName, 30299 formattedModifiedDate 30300 ); 30301 } 30302 function RevisionsButtons({ 30303 userRevisions, 30304 selectedRevisionId, 30305 onChange, 30306 canApplyRevision, 30307 onApplyRevision 30308 }) { 30309 const { currentThemeName, currentUser } = (0, import_data59.useSelect)((select5) => { 30310 const { getCurrentTheme, getCurrentUser } = select5(import_core_data41.store); 30311 const currentTheme = getCurrentTheme(); 30312 return { 30313 currentThemeName: currentTheme?.name?.rendered || currentTheme?.stylesheet, 30314 currentUser: getCurrentUser() 30315 }; 30316 }, []); 30317 const dateNowInMs = (0, import_date4.getDate)(null).getTime(); 30318 const { datetimeAbbreviated } = (0, import_date4.getSettings)().formats; 30319 return /* @__PURE__ */ (0, import_jsx_runtime170.jsx)( 30320 import_components81.Composite, 30321 { 30322 orientation: "vertical", 30323 className: "global-styles-ui-screen-revisions__revisions-list", 30324 "aria-label": (0, import_i18n97.__)("Global styles revisions list"), 30325 role: "listbox", 30326 children: userRevisions.map((revision, index2) => { 30327 const { id, author, modified } = revision; 30328 const isUnsaved = "unsaved" === id; 30329 const revisionAuthor = isUnsaved ? currentUser : author; 30330 const authorDisplayName = revisionAuthor?.name || (0, import_i18n97.__)("User"); 30331 const authorAvatar = revisionAuthor?.avatar_urls?.["48"]; 30332 const isFirstItem = index2 === 0; 30333 const isSelected = selectedRevisionId ? selectedRevisionId === id : isFirstItem; 30334 const areStylesEqual = !canApplyRevision && isSelected; 30335 const isReset = "parent" === id; 30336 const modifiedString = modified instanceof Date ? modified.toISOString() : modified; 30337 const modifiedDate = (0, import_date4.getDate)(modifiedString ?? null); 30338 const displayDate = modifiedString && dateNowInMs - modifiedDate.getTime() > DAY_IN_MILLISECONDS ? (0, import_date4.dateI18n)(datetimeAbbreviated, modifiedDate) : (0, import_date4.humanTimeDiff)( 30339 modifiedString ?? modifiedDate, 30340 void 0 30341 ); 30342 const revisionLabel = getRevisionLabel( 30343 id, 30344 authorDisplayName, 30345 (0, import_date4.dateI18n)(datetimeAbbreviated, modifiedDate), 30346 areStylesEqual 30347 ); 30348 return /* @__PURE__ */ (0, import_jsx_runtime170.jsxs)( 30349 import_components81.Composite.Item, 30350 { 30351 className: "global-styles-ui-screen-revisions__revision-item", 30352 "aria-current": isSelected, 30353 role: "option", 30354 onKeyDown: (event) => { 30355 const { keyCode } = event; 30356 if (keyCode === import_keycodes3.ENTER || keyCode === import_keycodes3.SPACE) { 30357 onChange(revision); 30358 } 30359 }, 30360 onClick: (event) => { 30361 event.preventDefault(); 30362 onChange(revision); 30363 }, 30364 "aria-selected": isSelected, 30365 "aria-label": revisionLabel, 30366 render: /* @__PURE__ */ (0, import_jsx_runtime170.jsx)("div", {}), 30367 children: [ 30368 /* @__PURE__ */ (0, import_jsx_runtime170.jsx)("span", { className: "global-styles-ui-screen-revisions__revision-item-wrapper", children: isReset ? /* @__PURE__ */ (0, import_jsx_runtime170.jsxs)("span", { className: "global-styles-ui-screen-revisions__description", children: [ 30369 (0, import_i18n97.__)("Default styles"), 30370 /* @__PURE__ */ (0, import_jsx_runtime170.jsx)("span", { className: "global-styles-ui-screen-revisions__meta", children: currentThemeName }) 30371 ] }) : /* @__PURE__ */ (0, import_jsx_runtime170.jsxs)("span", { className: "global-styles-ui-screen-revisions__description", children: [ 30372 isUnsaved ? /* @__PURE__ */ (0, import_jsx_runtime170.jsx)("span", { className: "global-styles-ui-screen-revisions__date", children: (0, import_i18n97.__)("(Unsaved)") }) : /* @__PURE__ */ (0, import_jsx_runtime170.jsx)( 30373 "time", 30374 { 30375 className: "global-styles-ui-screen-revisions__date", 30376 dateTime: modifiedString, 30377 children: displayDate 30378 } 30379 ), 30380 /* @__PURE__ */ (0, import_jsx_runtime170.jsxs)("span", { className: "global-styles-ui-screen-revisions__meta", children: [ 30381 /* @__PURE__ */ (0, import_jsx_runtime170.jsx)( 30382 "img", 30383 { 30384 alt: authorDisplayName, 30385 src: authorAvatar 30386 } 30387 ), 30388 authorDisplayName 30389 ] }), 30390 isSelected && /* @__PURE__ */ (0, import_jsx_runtime170.jsx)( 30391 ChangesSummary, 30392 { 30393 revision, 30394 previousRevision: index2 < userRevisions.length ? userRevisions[index2 + 1] : void 0 30395 } 30396 ) 30397 ] }) }), 30398 isSelected && (areStylesEqual ? /* @__PURE__ */ (0, import_jsx_runtime170.jsx)("p", { className: "global-styles-ui-screen-revisions__applied-text", children: (0, import_i18n97.__)( 30399 "These styles are already applied to your site." 30400 ) }) : /* @__PURE__ */ (0, import_jsx_runtime170.jsx)( 30401 import_components81.Button, 30402 { 30403 size: "compact", 30404 variant: "primary", 30405 className: "global-styles-ui-screen-revisions__apply-button", 30406 onClick: onApplyRevision, 30407 "aria-label": (0, import_i18n97.__)( 30408 "Apply the selected revision to your site." 30409 ), 30410 children: isReset ? (0, import_i18n97.__)("Reset to defaults") : (0, import_i18n97.__)("Apply") 30411 } 30412 )) 30413 ] 30414 }, 30415 id 30416 ); 30417 }) 30418 } 30419 ); 30420 } 30421 var revisions_buttons_default = RevisionsButtons; 30422 30423 // packages/global-styles-ui/build-module/pagination/index.js 30424 var import_components82 = __toESM(require_components()); 30425 var import_i18n98 = __toESM(require_i18n()); 30426 var import_jsx_runtime171 = __toESM(require_jsx_runtime()); 30427 function Pagination({ 30428 currentPage, 30429 numPages, 30430 changePage, 30431 totalItems, 30432 className, 30433 disabled = false, 30434 buttonVariant = "tertiary", 30435 label = (0, import_i18n98.__)("Pagination") 30436 }) { 30437 return /* @__PURE__ */ (0, import_jsx_runtime171.jsxs)( 30438 import_components82.__experimentalHStack, 30439 { 30440 expanded: false, 30441 as: "nav", 30442 "aria-label": label, 30443 spacing: 3, 30444 justify: "flex-start", 30445 className: clsx_default("global-styles-ui-pagination", className), 30446 children: [ 30447 /* @__PURE__ */ (0, import_jsx_runtime171.jsx)( 30448 import_components82.__experimentalText, 30449 { 30450 variant: "muted", 30451 className: "global-styles-ui-pagination__total", 30452 children: (0, import_i18n98.sprintf)( 30453 // translators: %d: Total number of patterns. 30454 (0, import_i18n98._n)("%d item", "%d items", totalItems), 30455 totalItems 30456 ) 30457 } 30458 ), 30459 /* @__PURE__ */ (0, import_jsx_runtime171.jsxs)(import_components82.__experimentalHStack, { expanded: false, spacing: 1, children: [ 30460 /* @__PURE__ */ (0, import_jsx_runtime171.jsx)( 30461 import_components82.Button, 30462 { 30463 variant: buttonVariant, 30464 onClick: () => changePage(1), 30465 accessibleWhenDisabled: true, 30466 disabled: disabled || currentPage === 1, 30467 label: (0, import_i18n98.__)("First page"), 30468 icon: (0, import_i18n98.isRTL)() ? next_default : previous_default, 30469 size: "compact" 30470 } 30471 ), 30472 /* @__PURE__ */ (0, import_jsx_runtime171.jsx)( 30473 import_components82.Button, 30474 { 30475 variant: buttonVariant, 30476 onClick: () => changePage(currentPage - 1), 30477 accessibleWhenDisabled: true, 30478 disabled: disabled || currentPage === 1, 30479 label: (0, import_i18n98.__)("Previous page"), 30480 icon: (0, import_i18n98.isRTL)() ? chevron_right_default : chevron_left_default, 30481 size: "compact" 30482 } 30483 ) 30484 ] }), 30485 /* @__PURE__ */ (0, import_jsx_runtime171.jsx)(import_components82.__experimentalText, { variant: "muted", children: (0, import_i18n98.sprintf)( 30486 // translators: 1: Current page number. 2: Total number of pages. 30487 (0, import_i18n98._x)("%1$d of %2$d", "paging"), 30488 currentPage, 30489 numPages 30490 ) }), 30491 /* @__PURE__ */ (0, import_jsx_runtime171.jsxs)(import_components82.__experimentalHStack, { expanded: false, spacing: 1, children: [ 30492 /* @__PURE__ */ (0, import_jsx_runtime171.jsx)( 30493 import_components82.Button, 30494 { 30495 variant: buttonVariant, 30496 onClick: () => changePage(currentPage + 1), 30497 accessibleWhenDisabled: true, 30498 disabled: disabled || currentPage === numPages, 30499 label: (0, import_i18n98.__)("Next page"), 30500 icon: (0, import_i18n98.isRTL)() ? chevron_left_default : chevron_right_default, 30501 size: "compact" 30502 } 30503 ), 30504 /* @__PURE__ */ (0, import_jsx_runtime171.jsx)( 30505 import_components82.Button, 30506 { 30507 variant: buttonVariant, 30508 onClick: () => changePage(numPages), 30509 accessibleWhenDisabled: true, 30510 disabled: disabled || currentPage === numPages, 30511 label: (0, import_i18n98.__)("Last page"), 30512 icon: (0, import_i18n98.isRTL)() ? previous_default : next_default, 30513 size: "compact" 30514 } 30515 ) 30516 ] }) 30517 ] 30518 } 30519 ); 30520 } 30521 30522 // packages/global-styles-ui/build-module/screen-revisions/index.js 30523 var import_jsx_runtime172 = __toESM(require_jsx_runtime()); 30524 var PAGE_SIZE = 10; 30525 function ScreenRevisions({ onClose } = {}) { 30526 const { user: currentEditorGlobalStyles, onChange: setUserConfig } = (0, import_element64.useContext)(GlobalStylesContext); 30527 const { params, goTo } = (0, import_components83.useNavigator)(); 30528 const { revisionId } = params; 30529 const [currentPage, setCurrentPage] = (0, import_element64.useState)(1); 30530 const { revisions, isLoading, hasUnsavedChanges, revisionsCount } = useGlobalStylesRevisions({ 30531 query: { 30532 per_page: PAGE_SIZE, 30533 page: currentPage 30534 } 30535 }); 30536 const numPages = Math.ceil(revisionsCount / PAGE_SIZE); 30537 const [ 30538 isLoadingRevisionWithUnsavedChanges, 30539 setIsLoadingRevisionWithUnsavedChanges 30540 ] = (0, import_element64.useState)(false); 30541 const currentlySelectedRevision = (0, import_element64.useMemo)(() => { 30542 if (!revisionId) { 30543 return currentEditorGlobalStyles; 30544 } 30545 const revision = revisions.find( 30546 (rev) => String(rev.id) === String(revisionId) 30547 ); 30548 return revision || currentEditorGlobalStyles; 30549 }, [revisionId, revisions, currentEditorGlobalStyles]); 30550 const selectedRevisionMatchesEditorStyles = areGlobalStylesEqual( 30551 currentlySelectedRevision, 30552 currentEditorGlobalStyles 30553 ); 30554 const onCloseRevisions = () => { 30555 if (onClose) { 30556 onClose(); 30557 } 30558 }; 30559 const restoreRevision = (revision) => { 30560 setUserConfig(revision); 30561 setIsLoadingRevisionWithUnsavedChanges(false); 30562 onCloseRevisions(); 30563 }; 30564 const handleRevisionSelect = (revision) => { 30565 goTo(`/revisions/$revision.id}`); 30566 }; 30567 const currentlySelectedRevisionId = ( 30568 // @ts-expect-error: revision id is not present in the fallback (default object). 30569 currentlySelectedRevision?.id ?? revisions[0]?.id 30570 ); 30571 const isLoadButtonEnabled = !!currentlySelectedRevisionId && currentlySelectedRevisionId !== "unsaved" && !selectedRevisionMatchesEditorStyles; 30572 const hasRevisions = !!revisions.length; 30573 return /* @__PURE__ */ (0, import_jsx_runtime172.jsxs)(import_jsx_runtime172.Fragment, { children: [ 30574 /* @__PURE__ */ (0, import_jsx_runtime172.jsx)( 30575 ScreenHeader, 30576 { 30577 title: revisionsCount ? (0, import_i18n99.sprintf)( 30578 // translators: %d: number of revisions. 30579 (0, import_i18n99.__)("Revisions (%d)"), 30580 revisionsCount 30581 ) : (0, import_i18n99.__)("Revisions"), 30582 description: (0, import_i18n99.__)( 30583 `Click on previously saved styles to preview them. To restore a selected version to the editor, hit "Apply." When you're ready, use the Save button to save your changes.` 30584 ), 30585 onBack: onCloseRevisions 30586 } 30587 ), 30588 !hasRevisions && /* @__PURE__ */ (0, import_jsx_runtime172.jsx)(import_components83.Spinner, { className: "global-styles-ui-screen-revisions__loading" }), 30589 /* @__PURE__ */ (0, import_jsx_runtime172.jsx)( 30590 revisions_buttons_default, 30591 { 30592 onChange: handleRevisionSelect, 30593 selectedRevisionId: currentlySelectedRevisionId, 30594 userRevisions: revisions, 30595 canApplyRevision: isLoadButtonEnabled, 30596 onApplyRevision: () => hasUnsavedChanges ? setIsLoadingRevisionWithUnsavedChanges(true) : restoreRevision(currentlySelectedRevision) 30597 } 30598 ), 30599 numPages > 1 && /* @__PURE__ */ (0, import_jsx_runtime172.jsx)("div", { className: "global-styles-ui-screen-revisions__footer", children: /* @__PURE__ */ (0, import_jsx_runtime172.jsx)( 30600 Pagination, 30601 { 30602 className: "global-styles-ui-screen-revisions__pagination", 30603 currentPage, 30604 numPages, 30605 changePage: setCurrentPage, 30606 totalItems: revisionsCount, 30607 disabled: isLoading, 30608 label: (0, import_i18n99.__)("Global Styles pagination") 30609 } 30610 ) }), 30611 isLoadingRevisionWithUnsavedChanges && /* @__PURE__ */ (0, import_jsx_runtime172.jsx)( 30612 import_components83.__experimentalConfirmDialog, 30613 { 30614 isOpen: isLoadingRevisionWithUnsavedChanges, 30615 confirmButtonText: (0, import_i18n99.__)("Apply"), 30616 onConfirm: () => restoreRevision(currentlySelectedRevision), 30617 onCancel: () => setIsLoadingRevisionWithUnsavedChanges(false), 30618 size: "medium", 30619 children: (0, import_i18n99.__)( 30620 "Are you sure you want to apply this revision? Any unsaved changes will be lost." 30621 ) 30622 } 30623 ) 30624 ] }); 30625 } 30626 var screen_revisions_default = ScreenRevisions; 30627 30628 // packages/global-styles-ui/build-module/font-sizes/font-sizes.js 30629 var import_i18n101 = __toESM(require_i18n()); 30630 var import_components85 = __toESM(require_components()); 30631 var import_element65 = __toESM(require_element()); 30632 30633 // packages/global-styles-ui/build-module/font-sizes/confirm-reset-font-sizes-dialog.js 30634 var import_components84 = __toESM(require_components()); 30635 var import_i18n100 = __toESM(require_i18n()); 30636 var import_jsx_runtime173 = __toESM(require_jsx_runtime()); 30637 function ConfirmResetFontSizesDialog({ 30638 text, 30639 confirmButtonText, 30640 isOpen, 30641 toggleOpen, 30642 onConfirm 30643 }) { 30644 const handleConfirm = async () => { 30645 toggleOpen(); 30646 onConfirm(); 30647 }; 30648 const handleCancel = () => { 30649 toggleOpen(); 30650 }; 30651 return /* @__PURE__ */ (0, import_jsx_runtime173.jsx)( 30652 import_components84.__experimentalConfirmDialog, 30653 { 30654 isOpen, 30655 cancelButtonText: (0, import_i18n100.__)("Cancel"), 30656 confirmButtonText, 30657 onCancel: handleCancel, 30658 onConfirm: handleConfirm, 30659 size: "medium", 30660 children: text 30661 } 30662 ); 30663 } 30664 var confirm_reset_font_sizes_dialog_default = ConfirmResetFontSizesDialog; 30665 30666 // packages/global-styles-ui/build-module/font-sizes/font-sizes.js 30667 var import_jsx_runtime174 = __toESM(require_jsx_runtime()); 30668 var { Menu: Menu3 } = unlock3(import_components85.privateApis); 30669 function FontSizeGroup({ 30670 label, 30671 origin, 30672 sizes, 30673 handleAddFontSize, 30674 handleResetFontSizes 30675 }) { 30676 const [isResetDialogOpen, setIsResetDialogOpen] = (0, import_element65.useState)(false); 30677 const toggleResetDialog = () => setIsResetDialogOpen(!isResetDialogOpen); 30678 const resetDialogText = origin === "custom" ? (0, import_i18n101.__)( 30679 "Are you sure you want to remove all custom font size presets?" 30680 ) : (0, import_i18n101.__)( 30681 "Are you sure you want to reset all font size presets to their default values?" 30682 ); 30683 return /* @__PURE__ */ (0, import_jsx_runtime174.jsxs)(import_jsx_runtime174.Fragment, { children: [ 30684 handleResetFontSizes && isResetDialogOpen && /* @__PURE__ */ (0, import_jsx_runtime174.jsx)( 30685 confirm_reset_font_sizes_dialog_default, 30686 { 30687 text: resetDialogText, 30688 confirmButtonText: origin === "custom" ? (0, import_i18n101.__)("Remove") : (0, import_i18n101.__)("Reset"), 30689 isOpen: isResetDialogOpen, 30690 toggleOpen: toggleResetDialog, 30691 onConfirm: handleResetFontSizes 30692 } 30693 ), 30694 /* @__PURE__ */ (0, import_jsx_runtime174.jsxs)(import_components85.__experimentalVStack, { spacing: 4, children: [ 30695 /* @__PURE__ */ (0, import_jsx_runtime174.jsxs)(import_components85.__experimentalHStack, { children: [ 30696 /* @__PURE__ */ (0, import_jsx_runtime174.jsx)(Subtitle, { level: 3, children: label }), 30697 /* @__PURE__ */ (0, import_jsx_runtime174.jsxs)(import_components85.FlexItem, { className: "global-styles-ui__typography-panel__options-container", children: [ 30698 origin === "custom" && /* @__PURE__ */ (0, import_jsx_runtime174.jsx)( 30699 import_components85.Button, 30700 { 30701 label: (0, import_i18n101.__)("Add font size"), 30702 icon: plus_default, 30703 size: "small", 30704 onClick: handleAddFontSize 30705 } 30706 ), 30707 !!handleResetFontSizes && /* @__PURE__ */ (0, import_jsx_runtime174.jsxs)(Menu3, { children: [ 30708 /* @__PURE__ */ (0, import_jsx_runtime174.jsx)( 30709 Menu3.TriggerButton, 30710 { 30711 render: /* @__PURE__ */ (0, import_jsx_runtime174.jsx)( 30712 import_components85.Button, 30713 { 30714 size: "small", 30715 icon: more_vertical_default, 30716 label: (0, import_i18n101.__)( 30717 "Font size presets options" 30718 ) 30719 } 30720 ) 30721 } 30722 ), 30723 /* @__PURE__ */ (0, import_jsx_runtime174.jsx)(Menu3.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime174.jsx)(Menu3.Item, { onClick: toggleResetDialog, children: /* @__PURE__ */ (0, import_jsx_runtime174.jsx)(Menu3.ItemLabel, { children: origin === "custom" ? (0, import_i18n101.__)( 30724 "Remove font size presets" 30725 ) : (0, import_i18n101.__)( 30726 "Reset font size presets" 30727 ) }) }) }) 30728 ] }) 30729 ] }) 30730 ] }), 30731 !!sizes.length && /* @__PURE__ */ (0, import_jsx_runtime174.jsx)(import_components85.__experimentalItemGroup, { isBordered: true, isSeparated: true, children: sizes.map((size3) => /* @__PURE__ */ (0, import_jsx_runtime174.jsx)( 30732 NavigationButtonAsItem, 30733 { 30734 path: `/typography/font-sizes/$origin}/$size3.slug}`, 30735 children: /* @__PURE__ */ (0, import_jsx_runtime174.jsxs)(import_components85.__experimentalHStack, { children: [ 30736 /* @__PURE__ */ (0, import_jsx_runtime174.jsx)(import_components85.FlexItem, { className: "global-styles-ui-font-size__item", children: size3.name }), 30737 /* @__PURE__ */ (0, import_jsx_runtime174.jsx)(import_components85.FlexItem, { display: "flex", children: /* @__PURE__ */ (0, import_jsx_runtime174.jsx)( 30738 icon_default, 30739 { 30740 icon: (0, import_i18n101.isRTL)() ? chevron_left_default : chevron_right_default 30741 } 30742 ) }) 30743 ] }) 30744 }, 30745 size3.slug 30746 )) }) 30747 ] }) 30748 ] }); 30749 } 30750 function FontSizes2() { 30751 const [themeFontSizes, setThemeFontSizes] = useSetting( 30752 "typography.fontSizes.theme" 30753 ); 30754 const [baseThemeFontSizes] = useSetting( 30755 "typography.fontSizes.theme", 30756 "base" 30757 ); 30758 const [defaultFontSizes, setDefaultFontSizes] = useSetting( 30759 "typography.fontSizes.default" 30760 ); 30761 const [baseDefaultFontSizes] = useSetting( 30762 "typography.fontSizes.default", 30763 "base" 30764 ); 30765 const [customFontSizes = [], setCustomFontSizes] = useSetting( 30766 "typography.fontSizes.custom" 30767 ); 30768 const [defaultFontSizesEnabled] = useSetting( 30769 "typography.defaultFontSizes" 30770 ); 30771 const handleAddFontSize = () => { 30772 const index2 = getNewIndexFromPresets(customFontSizes, "custom-"); 30773 const newFontSize = { 30774 /* translators: %d: font size index */ 30775 name: (0, import_i18n101.sprintf)((0, import_i18n101.__)("New Font Size %d"), index2), 30776 size: "16px", 30777 slug: `custom-$index2}` 30778 }; 30779 setCustomFontSizes([...customFontSizes, newFontSize]); 30780 }; 30781 const hasSameSizeValues = (arr1, arr2) => arr1.map((item) => item.size).join("") === arr2.map((item) => item.size).join(""); 30782 return /* @__PURE__ */ (0, import_jsx_runtime174.jsxs)(import_components85.__experimentalVStack, { spacing: 2, children: [ 30783 /* @__PURE__ */ (0, import_jsx_runtime174.jsx)( 30784 ScreenHeader, 30785 { 30786 title: (0, import_i18n101.__)("Font size presets"), 30787 description: (0, import_i18n101.__)( 30788 "Create and edit the presets used for font sizes across the site." 30789 ) 30790 } 30791 ), 30792 /* @__PURE__ */ (0, import_jsx_runtime174.jsx)(import_components85.__experimentalView, { children: /* @__PURE__ */ (0, import_jsx_runtime174.jsx)(import_components85.__experimentalSpacer, { paddingX: 4, children: /* @__PURE__ */ (0, import_jsx_runtime174.jsxs)(import_components85.__experimentalVStack, { spacing: 8, children: [ 30793 !!themeFontSizes?.length && /* @__PURE__ */ (0, import_jsx_runtime174.jsx)( 30794 FontSizeGroup, 30795 { 30796 label: (0, import_i18n101.__)("Theme"), 30797 origin: "theme", 30798 sizes: themeFontSizes, 30799 handleAddFontSize, 30800 handleResetFontSizes: hasSameSizeValues( 30801 themeFontSizes, 30802 baseThemeFontSizes 30803 ) ? void 0 : () => setThemeFontSizes( 30804 baseThemeFontSizes 30805 ) 30806 } 30807 ), 30808 defaultFontSizesEnabled && !!defaultFontSizes?.length && /* @__PURE__ */ (0, import_jsx_runtime174.jsx)( 30809 FontSizeGroup, 30810 { 30811 label: (0, import_i18n101.__)("Default"), 30812 origin: "default", 30813 sizes: defaultFontSizes, 30814 handleAddFontSize, 30815 handleResetFontSizes: hasSameSizeValues( 30816 defaultFontSizes, 30817 baseDefaultFontSizes 30818 ) ? void 0 : () => setDefaultFontSizes( 30819 baseDefaultFontSizes 30820 ) 30821 } 30822 ), 30823 /* @__PURE__ */ (0, import_jsx_runtime174.jsx)( 30824 FontSizeGroup, 30825 { 30826 label: (0, import_i18n101.__)("Custom"), 30827 origin: "custom", 30828 sizes: customFontSizes, 30829 handleAddFontSize, 30830 handleResetFontSizes: customFontSizes.length > 0 ? () => setCustomFontSizes([]) : void 0 30831 } 30832 ) 30833 ] }) }) }) 30834 ] }); 30835 } 30836 var font_sizes_default = FontSizes2; 30837 30838 // packages/global-styles-ui/build-module/font-sizes/font-size.js 30839 var import_i18n105 = __toESM(require_i18n()); 30840 var import_components89 = __toESM(require_components()); 30841 var import_element67 = __toESM(require_element()); 30842 30843 // packages/global-styles-ui/build-module/font-sizes/font-size-preview.js 30844 var import_block_editor30 = __toESM(require_block_editor()); 30845 var import_i18n102 = __toESM(require_i18n()); 30846 var import_jsx_runtime175 = __toESM(require_jsx_runtime()); 30847 function FontSizePreview({ fontSize }) { 30848 const [font2] = useStyle("typography"); 30849 const input = typeof fontSize?.fluid === "object" && fontSize?.fluid?.min && fontSize?.fluid?.max ? { 30850 minimumFontSize: fontSize.fluid.min, 30851 maximumFontSize: fontSize.fluid.max 30852 } : { 30853 fontSize: fontSize.size 30854 }; 30855 const computedFontSize = (0, import_block_editor30.getComputedFluidTypographyValue)(input); 30856 return /* @__PURE__ */ (0, import_jsx_runtime175.jsx)( 30857 "div", 30858 { 30859 className: "global-styles-ui-typography-preview", 30860 style: { 30861 fontSize: computedFontSize, 30862 fontFamily: font2?.fontFamily ?? "serif" 30863 }, 30864 children: (0, import_i18n102.__)("Aa") 30865 } 30866 ); 30867 } 30868 var font_size_preview_default = FontSizePreview; 30869 30870 // packages/global-styles-ui/build-module/font-sizes/confirm-delete-font-size-dialog.js 30871 var import_components86 = __toESM(require_components()); 30872 var import_i18n103 = __toESM(require_i18n()); 30873 var import_jsx_runtime176 = __toESM(require_jsx_runtime()); 30874 function ConfirmDeleteFontSizeDialog({ 30875 fontSize, 30876 isOpen, 30877 toggleOpen, 30878 handleRemoveFontSize 30879 }) { 30880 const handleConfirm = async () => { 30881 toggleOpen(); 30882 handleRemoveFontSize(fontSize); 30883 }; 30884 const handleCancel = () => { 30885 toggleOpen(); 30886 }; 30887 return /* @__PURE__ */ (0, import_jsx_runtime176.jsx)( 30888 import_components86.__experimentalConfirmDialog, 30889 { 30890 isOpen, 30891 cancelButtonText: (0, import_i18n103.__)("Cancel"), 30892 confirmButtonText: (0, import_i18n103.__)("Delete"), 30893 onCancel: handleCancel, 30894 onConfirm: handleConfirm, 30895 size: "medium", 30896 children: fontSize && (0, import_i18n103.sprintf)( 30897 /* translators: %s: Name of the font size preset. */ 30898 (0, import_i18n103.__)( 30899 'Are you sure you want to delete "%s" font size preset?' 30900 ), 30901 fontSize.name 30902 ) 30903 } 30904 ); 30905 } 30906 var confirm_delete_font_size_dialog_default = ConfirmDeleteFontSizeDialog; 30907 30908 // packages/global-styles-ui/build-module/font-sizes/rename-font-size-dialog.js 30909 var import_components87 = __toESM(require_components()); 30910 var import_i18n104 = __toESM(require_i18n()); 30911 var import_element66 = __toESM(require_element()); 30912 var import_jsx_runtime177 = __toESM(require_jsx_runtime()); 30913 function RenameFontSizeDialog({ 30914 fontSize, 30915 toggleOpen, 30916 handleRename 30917 }) { 30918 const [newName, setNewName] = (0, import_element66.useState)( 30919 fontSize.name 30920 ); 30921 const handleConfirm = () => { 30922 if (newName && newName.trim()) { 30923 handleRename(newName); 30924 } 30925 toggleOpen(); 30926 }; 30927 return /* @__PURE__ */ (0, import_jsx_runtime177.jsx)( 30928 import_components87.Modal, 30929 { 30930 onRequestClose: toggleOpen, 30931 focusOnMount: "firstContentElement", 30932 title: (0, import_i18n104.__)("Rename"), 30933 size: "small", 30934 children: /* @__PURE__ */ (0, import_jsx_runtime177.jsx)( 30935 "form", 30936 { 30937 onSubmit: (event) => { 30938 event.preventDefault(); 30939 handleConfirm(); 30940 toggleOpen(); 30941 }, 30942 children: /* @__PURE__ */ (0, import_jsx_runtime177.jsxs)(import_components87.__experimentalVStack, { spacing: "3", children: [ 30943 /* @__PURE__ */ (0, import_jsx_runtime177.jsx)( 30944 import_components87.__experimentalInputControl, 30945 { 30946 __next40pxDefaultSize: true, 30947 autoComplete: "off", 30948 value: newName, 30949 onChange: setNewName, 30950 label: (0, import_i18n104.__)("Name"), 30951 placeholder: (0, import_i18n104.__)("Font size preset name") 30952 } 30953 ), 30954 /* @__PURE__ */ (0, import_jsx_runtime177.jsxs)(import_components87.__experimentalHStack, { justify: "right", children: [ 30955 /* @__PURE__ */ (0, import_jsx_runtime177.jsx)( 30956 import_components87.Button, 30957 { 30958 __next40pxDefaultSize: true, 30959 variant: "tertiary", 30960 onClick: toggleOpen, 30961 children: (0, import_i18n104.__)("Cancel") 30962 } 30963 ), 30964 /* @__PURE__ */ (0, import_jsx_runtime177.jsx)( 30965 import_components87.Button, 30966 { 30967 __next40pxDefaultSize: true, 30968 variant: "primary", 30969 type: "submit", 30970 children: (0, import_i18n104.__)("Save") 30971 } 30972 ) 30973 ] }) 30974 ] }) 30975 } 30976 ) 30977 } 30978 ); 30979 } 30980 var rename_font_size_dialog_default = RenameFontSizeDialog; 30981 30982 // packages/global-styles-ui/build-module/size-control/index.js 30983 var import_components88 = __toESM(require_components()); 30984 var import_jsx_runtime178 = __toESM(require_jsx_runtime()); 30985 var DEFAULT_UNITS = ["px", "em", "rem", "vw", "vh"]; 30986 function SizeControl(props) { 30987 const { baseControlProps } = (0, import_components88.useBaseControlProps)(props); 30988 const { value, onChange, fallbackValue, disabled, label } = props; 30989 const units = (0, import_components88.__experimentalUseCustomUnits)({ 30990 availableUnits: DEFAULT_UNITS 30991 }); 30992 const [valueQuantity, valueUnit = "px"] = (0, import_components88.__experimentalParseQuantityAndUnitFromRawValue)(value, units); 30993 const isValueUnitRelative = !!valueUnit && ["em", "rem", "vw", "vh"].includes(valueUnit); 30994 const handleUnitControlChange = (newValue) => { 30995 onChange?.(newValue); 30996 }; 30997 const handleRangeControlChange = (newValue) => { 30998 if (newValue !== void 0) { 30999 onChange?.(newValue + valueUnit); 31000 } else { 31001 onChange?.(void 0); 31002 } 31003 }; 31004 return /* @__PURE__ */ (0, import_jsx_runtime178.jsx)(import_components88.BaseControl, { ...baseControlProps, children: /* @__PURE__ */ (0, import_jsx_runtime178.jsxs)(import_components88.Flex, { children: [ 31005 /* @__PURE__ */ (0, import_jsx_runtime178.jsx)(import_components88.FlexItem, { isBlock: true, children: /* @__PURE__ */ (0, import_jsx_runtime178.jsx)( 31006 import_components88.__experimentalUnitControl, 31007 { 31008 __next40pxDefaultSize: true, 31009 label, 31010 hideLabelFromVision: true, 31011 value, 31012 onChange: handleUnitControlChange, 31013 units, 31014 min: 0, 31015 disabled 31016 } 31017 ) }), 31018 /* @__PURE__ */ (0, import_jsx_runtime178.jsx)(import_components88.FlexItem, { isBlock: true, children: /* @__PURE__ */ (0, import_jsx_runtime178.jsx)(import_components88.__experimentalSpacer, { marginX: 2, marginBottom: 0, children: /* @__PURE__ */ (0, import_jsx_runtime178.jsx)( 31019 import_components88.RangeControl, 31020 { 31021 __next40pxDefaultSize: true, 31022 label, 31023 hideLabelFromVision: true, 31024 value: valueQuantity, 31025 initialPosition: fallbackValue, 31026 withInputField: false, 31027 onChange: handleRangeControlChange, 31028 min: 0, 31029 max: isValueUnitRelative ? 10 : 100, 31030 step: isValueUnitRelative ? 0.1 : 1, 31031 disabled 31032 } 31033 ) }) }) 31034 ] }) }); 31035 } 31036 31037 // packages/global-styles-ui/build-module/font-sizes/font-size.js 31038 var import_jsx_runtime179 = __toESM(require_jsx_runtime()); 31039 var { Menu: Menu4 } = unlock3(import_components89.privateApis); 31040 function FontSize() { 31041 const [isDeleteConfirmOpen, setIsDeleteConfirmOpen] = (0, import_element67.useState)(false); 31042 const [isRenameDialogOpen, setIsRenameDialogOpen] = (0, import_element67.useState)(false); 31043 const { 31044 params: { origin, slug }, 31045 goBack 31046 } = (0, import_components89.useNavigator)(); 31047 const [fontSizes, setFontSizes] = useSetting("typography.fontSizes"); 31048 const [globalFluid] = useSetting("typography.fluid"); 31049 const sizes = fontSizes?.[origin] ?? []; 31050 const fontSize = sizes.find( 31051 (size3) => size3.slug === slug 31052 ); 31053 (0, import_element67.useEffect)(() => { 31054 if (!!slug && !fontSize) { 31055 goBack(); 31056 } 31057 }, [slug, fontSize, goBack]); 31058 if (!origin || !slug || !fontSize) { 31059 return null; 31060 } 31061 const isFluid = fontSize?.fluid !== void 0 ? !!fontSize.fluid : !!globalFluid; 31062 const isCustomFluid = typeof fontSize?.fluid === "object"; 31063 const handleNameChange = (value) => { 31064 updateFontSize("name", value); 31065 }; 31066 const handleFontSizeChange = (value) => { 31067 updateFontSize("size", value); 31068 }; 31069 const handleFluidChange = (value) => { 31070 updateFontSize("fluid", value); 31071 }; 31072 const handleCustomFluidValues = (value) => { 31073 if (value) { 31074 updateFontSize("fluid", { 31075 min: fontSize.size, 31076 max: fontSize.size 31077 }); 31078 } else { 31079 updateFontSize("fluid", true); 31080 } 31081 }; 31082 const handleMinChange = (value) => { 31083 const fluid = typeof fontSize.fluid === "object" ? fontSize.fluid : {}; 31084 updateFontSize("fluid", { ...fluid, min: value }); 31085 }; 31086 const handleMaxChange = (value) => { 31087 const fluid = typeof fontSize.fluid === "object" ? fontSize.fluid : {}; 31088 updateFontSize("fluid", { ...fluid, max: value }); 31089 }; 31090 const updateFontSize = (key, value) => { 31091 const newFontSizes = sizes.map((size3) => { 31092 if (size3.slug === slug) { 31093 return { ...size3, [key]: value }; 31094 } 31095 return size3; 31096 }); 31097 setFontSizes({ 31098 ...fontSizes, 31099 [origin]: newFontSizes 31100 }); 31101 }; 31102 const handleRemoveFontSize = () => { 31103 const newFontSizes = sizes.filter((size3) => size3.slug !== slug); 31104 setFontSizes({ 31105 ...fontSizes, 31106 [origin]: newFontSizes 31107 }); 31108 }; 31109 const toggleDeleteConfirm = () => { 31110 setIsDeleteConfirmOpen(!isDeleteConfirmOpen); 31111 }; 31112 const toggleRenameDialog = () => { 31113 setIsRenameDialogOpen(!isRenameDialogOpen); 31114 }; 31115 return /* @__PURE__ */ (0, import_jsx_runtime179.jsxs)(import_jsx_runtime179.Fragment, { children: [ 31116 /* @__PURE__ */ (0, import_jsx_runtime179.jsx)( 31117 confirm_delete_font_size_dialog_default, 31118 { 31119 fontSize, 31120 isOpen: isDeleteConfirmOpen, 31121 toggleOpen: toggleDeleteConfirm, 31122 handleRemoveFontSize 31123 } 31124 ), 31125 isRenameDialogOpen && /* @__PURE__ */ (0, import_jsx_runtime179.jsx)( 31126 rename_font_size_dialog_default, 31127 { 31128 fontSize, 31129 toggleOpen: toggleRenameDialog, 31130 handleRename: handleNameChange 31131 } 31132 ), 31133 /* @__PURE__ */ (0, import_jsx_runtime179.jsxs)(import_components89.__experimentalVStack, { spacing: 4, children: [ 31134 /* @__PURE__ */ (0, import_jsx_runtime179.jsxs)(import_components89.__experimentalHStack, { justify: "space-between", alignment: "flex-start", children: [ 31135 /* @__PURE__ */ (0, import_jsx_runtime179.jsx)( 31136 ScreenHeader, 31137 { 31138 title: fontSize.name, 31139 description: (0, import_i18n105.sprintf)( 31140 /* translators: %s: font size preset name. */ 31141 (0, import_i18n105.__)("Manage the font size %s."), 31142 fontSize.name 31143 ) 31144 } 31145 ), 31146 origin === "custom" && /* @__PURE__ */ (0, import_jsx_runtime179.jsx)(import_components89.FlexItem, { children: /* @__PURE__ */ (0, import_jsx_runtime179.jsx)( 31147 import_components89.__experimentalSpacer, 31148 { 31149 marginTop: 3, 31150 marginBottom: 0, 31151 paddingX: 4, 31152 children: /* @__PURE__ */ (0, import_jsx_runtime179.jsxs)(Menu4, { children: [ 31153 /* @__PURE__ */ (0, import_jsx_runtime179.jsx)( 31154 Menu4.TriggerButton, 31155 { 31156 render: /* @__PURE__ */ (0, import_jsx_runtime179.jsx)( 31157 import_components89.Button, 31158 { 31159 size: "small", 31160 icon: more_vertical_default, 31161 label: (0, import_i18n105.__)( 31162 "Font size options" 31163 ) 31164 } 31165 ) 31166 } 31167 ), 31168 /* @__PURE__ */ (0, import_jsx_runtime179.jsxs)(Menu4.Popover, { children: [ 31169 /* @__PURE__ */ (0, import_jsx_runtime179.jsx)( 31170 Menu4.Item, 31171 { 31172 onClick: toggleRenameDialog, 31173 children: /* @__PURE__ */ (0, import_jsx_runtime179.jsx)(Menu4.ItemLabel, { children: (0, import_i18n105.__)("Rename") }) 31174 } 31175 ), 31176 /* @__PURE__ */ (0, import_jsx_runtime179.jsx)( 31177 Menu4.Item, 31178 { 31179 onClick: toggleDeleteConfirm, 31180 children: /* @__PURE__ */ (0, import_jsx_runtime179.jsx)(Menu4.ItemLabel, { children: (0, import_i18n105.__)("Delete") }) 31181 } 31182 ) 31183 ] }) 31184 ] }) 31185 } 31186 ) }) 31187 ] }), 31188 /* @__PURE__ */ (0, import_jsx_runtime179.jsx)(import_components89.__experimentalView, { children: /* @__PURE__ */ (0, import_jsx_runtime179.jsx)( 31189 import_components89.__experimentalSpacer, 31190 { 31191 paddingX: 4, 31192 marginBottom: 0, 31193 paddingBottom: 6, 31194 children: /* @__PURE__ */ (0, import_jsx_runtime179.jsxs)(import_components89.__experimentalVStack, { spacing: 4, children: [ 31195 /* @__PURE__ */ (0, import_jsx_runtime179.jsx)(import_components89.FlexItem, { children: /* @__PURE__ */ (0, import_jsx_runtime179.jsx)(font_size_preview_default, { fontSize }) }), 31196 /* @__PURE__ */ (0, import_jsx_runtime179.jsx)( 31197 SizeControl, 31198 { 31199 label: (0, import_i18n105.__)("Size"), 31200 value: !isCustomFluid && fontSize.size ? String(fontSize.size) : "", 31201 onChange: handleFontSizeChange, 31202 disabled: isCustomFluid 31203 } 31204 ), 31205 /* @__PURE__ */ (0, import_jsx_runtime179.jsx)( 31206 import_components89.ToggleControl, 31207 { 31208 label: (0, import_i18n105.__)("Fluid typography"), 31209 help: (0, import_i18n105.__)( 31210 "Scale the font size dynamically to fit the screen or viewport." 31211 ), 31212 checked: isFluid, 31213 onChange: handleFluidChange 31214 } 31215 ), 31216 isFluid && /* @__PURE__ */ (0, import_jsx_runtime179.jsx)( 31217 import_components89.ToggleControl, 31218 { 31219 label: (0, import_i18n105.__)("Custom fluid values"), 31220 help: (0, import_i18n105.__)( 31221 "Set custom min and max values for the fluid font size." 31222 ), 31223 checked: isCustomFluid, 31224 onChange: handleCustomFluidValues 31225 } 31226 ), 31227 isCustomFluid && /* @__PURE__ */ (0, import_jsx_runtime179.jsxs)(import_jsx_runtime179.Fragment, { children: [ 31228 /* @__PURE__ */ (0, import_jsx_runtime179.jsx)( 31229 SizeControl, 31230 { 31231 label: (0, import_i18n105.__)("Minimum"), 31232 value: typeof fontSize?.fluid === "object" ? fontSize.fluid?.min : void 0, 31233 onChange: handleMinChange 31234 } 31235 ), 31236 /* @__PURE__ */ (0, import_jsx_runtime179.jsx)( 31237 SizeControl, 31238 { 31239 label: (0, import_i18n105.__)("Maximum"), 31240 value: typeof fontSize?.fluid === "object" ? fontSize.fluid?.max : void 0, 31241 onChange: handleMaxChange 31242 } 31243 ) 31244 ] }) 31245 ] }) 31246 } 31247 ) }) 31248 ] }) 31249 ] }); 31250 } 31251 var font_size_default = FontSize; 31252 31253 // packages/global-styles-ui/build-module/global-styles-ui.js 31254 var import_jsx_runtime180 = __toESM(require_jsx_runtime()); 31255 function BlockStylesNavigationScreens({ 31256 parentMenu, 31257 blockStyles, 31258 blockName 31259 }) { 31260 return /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(import_jsx_runtime180.Fragment, { children: blockStyles.map((style, index2) => /* @__PURE__ */ (0, import_jsx_runtime180.jsx)( 31261 import_components90.Navigator.Screen, 31262 { 31263 path: parentMenu + "/variations/" + style.name, 31264 children: /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(screen_block_default, { name: blockName, variation: style.name }) 31265 }, 31266 index2 31267 )) }); 31268 } 31269 function ContextScreens({ name: name2, parentMenu = "" }) { 31270 const blockStyleVariations = (0, import_data60.useSelect)( 31271 (select5) => { 31272 if (!name2) { 31273 return []; 31274 } 31275 const { getBlockStyles } = select5(import_blocks18.store); 31276 return getBlockStyles(name2); 31277 }, 31278 [name2] 31279 ); 31280 if (!blockStyleVariations?.length) { 31281 return null; 31282 } 31283 return /* @__PURE__ */ (0, import_jsx_runtime180.jsx)( 31284 BlockStylesNavigationScreens, 31285 { 31286 parentMenu, 31287 blockStyles: blockStyleVariations, 31288 blockName: name2 || "" 31289 } 31290 ); 31291 } 31292 function GlobalStylesUI({ 31293 value, 31294 baseValue, 31295 onChange, 31296 path, 31297 onPathChange, 31298 fontLibraryEnabled = false, 31299 serverCSS, 31300 serverSettings 31301 }) { 31302 const blocks = (0, import_blocks18.getBlockTypes)(); 31303 const mergedValue = (0, import_element68.useMemo)(() => { 31304 return mergeGlobalStyles(baseValue, value); 31305 }, [baseValue, value]); 31306 const [globalStylesCSS, globalSettings] = generateGlobalStyles( 31307 mergedValue, 31308 [], 31309 { 31310 styleOptions: { variationStyles: true } 31311 } 31312 ); 31313 const styles = (0, import_element68.useMemo)( 31314 () => [...serverCSS ?? [], ...globalStylesCSS ?? []], 31315 [serverCSS, globalStylesCSS] 31316 ); 31317 const settings = (0, import_element68.useMemo)(() => { 31318 return { 31319 ...serverSettings, 31320 __experimentalFeatures: globalSettings, 31321 styles 31322 }; 31323 }, [globalSettings, serverSettings, styles]); 31324 return /* @__PURE__ */ (0, import_jsx_runtime180.jsx)( 31325 GlobalStylesProvider, 31326 { 31327 value, 31328 baseValue, 31329 onChange, 31330 fontLibraryEnabled, 31331 children: /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(import_block_editor31.BlockEditorProvider, { settings, children: /* @__PURE__ */ (0, import_jsx_runtime180.jsxs)( 31332 import_components90.Navigator, 31333 { 31334 className: "global-styles-ui-sidebar__navigator-provider", 31335 initialPath: path || "/", 31336 children: [ 31337 (path || onPathChange) && /* @__PURE__ */ (0, import_jsx_runtime180.jsx)( 31338 PathSynchronizer, 31339 { 31340 path, 31341 onPathChange 31342 } 31343 ), 31344 /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(GlobalStylesNavigationScreen, { path: "/", children: /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(screen_root_default, {}) }), 31345 /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(GlobalStylesNavigationScreen, { path: "/colors", children: /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(screen_colors_default, {}) }), 31346 /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(GlobalStylesNavigationScreen, { path: "/typography", children: /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(screen_typography_default, {}) }), 31347 /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(GlobalStylesNavigationScreen, { path: "/typography/font-sizes", children: /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(font_sizes_default, {}) }), 31348 /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(GlobalStylesNavigationScreen, { path: "/typography/font-sizes/:origin/:slug", children: /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(font_size_default, {}) }), 31349 /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(GlobalStylesNavigationScreen, { path: "/layout", children: /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(screen_layout_default, {}) }), 31350 /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(GlobalStylesNavigationScreen, { path: "/colors/palette", children: /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(screen_color_palette_default, {}) }), 31351 /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(GlobalStylesNavigationScreen, { path: "/variations", children: /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(screen_style_variations_default, {}) }), 31352 /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(GlobalStylesNavigationScreen, { path: "/css", children: /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(screen_css_default, {}) }), 31353 /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(GlobalStylesNavigationScreen, { path: "/revisions/:revisionId?", children: /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(screen_revisions_default, {}) }), 31354 /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(GlobalStylesNavigationScreen, { path: "/shadows", children: /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(ScreenShadows, {}) }), 31355 /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(GlobalStylesNavigationScreen, { path: "/shadows/edit/:category/:slug", children: /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(ScreenShadowsEdit, {}) }), 31356 /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(GlobalStylesNavigationScreen, { path: "/background", children: /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(screen_background_default, {}) }), 31357 /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(GlobalStylesNavigationScreen, { path: "/typography/text", children: /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(screen_typography_element_default, { element: "text" }) }), 31358 /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(GlobalStylesNavigationScreen, { path: "/typography/link", children: /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(screen_typography_element_default, { element: "link" }) }), 31359 /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(GlobalStylesNavigationScreen, { path: "/typography/heading", children: /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(screen_typography_element_default, { element: "heading" }) }), 31360 /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(GlobalStylesNavigationScreen, { path: "/typography/caption", children: /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(screen_typography_element_default, { element: "caption" }) }), 31361 /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(GlobalStylesNavigationScreen, { path: "/typography/button", children: /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(screen_typography_element_default, { element: "button" }) }), 31362 /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(GlobalStylesNavigationScreen, { path: "/blocks", children: /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(screen_block_list_default, {}) }), 31363 blocks.map((block) => /* @__PURE__ */ (0, import_jsx_runtime180.jsxs)(import_element68.Fragment, { children: [ 31364 /* @__PURE__ */ (0, import_jsx_runtime180.jsx)( 31365 GlobalStylesNavigationScreen, 31366 { 31367 path: "/blocks/" + encodeURIComponent(block.name), 31368 children: /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(screen_block_default, { name: block.name }) 31369 } 31370 ), 31371 /* @__PURE__ */ (0, import_jsx_runtime180.jsx)( 31372 ContextScreens, 31373 { 31374 name: block.name, 31375 parentMenu: "/blocks/" + encodeURIComponent(block.name) 31376 } 31377 ) 31378 ] }, block.name)) 31379 ] 31380 } 31381 ) }) 31382 } 31383 ); 31384 } 31385 function GlobalStylesNavigationScreen({ 31386 path, 31387 children 31388 }) { 31389 return /* @__PURE__ */ (0, import_jsx_runtime180.jsx)( 31390 import_components90.Navigator.Screen, 31391 { 31392 className: "global-styles-ui-sidebar__navigator-screen", 31393 path, 31394 children 31395 } 31396 ); 31397 } 31398 function PathSynchronizer({ 31399 path, 31400 onPathChange 31401 }) { 31402 const navigator = (0, import_components90.useNavigator)(); 31403 const { path: childPath } = navigator.location; 31404 const previousParentPath = (0, import_compose14.usePrevious)(path); 31405 const previousChildPath = (0, import_compose14.usePrevious)(childPath); 31406 (0, import_element68.useEffect)(() => { 31407 if (path && path !== childPath) { 31408 if (path !== previousParentPath) { 31409 navigator.goTo(path); 31410 } else if (childPath !== previousChildPath && onPathChange) { 31411 onPathChange(childPath ?? "/"); 31412 } 31413 } 31414 }, [ 31415 onPathChange, 31416 path, 31417 previousChildPath, 31418 previousParentPath, 31419 childPath, 31420 navigator 31421 ]); 31422 return null; 31423 } 31424 31425 // packages/global-styles-ui/build-module/with-global-styles-provider.js 31426 var import_jsx_runtime181 = __toESM(require_jsx_runtime()); 31427 function withGlobalStylesProvider(Component6) { 31428 return function WrappedComponent({ 31429 value, 31430 baseValue, 31431 onChange, 31432 ...props 31433 }) { 31434 return /* @__PURE__ */ (0, import_jsx_runtime181.jsx)( 31435 GlobalStylesProvider, 31436 { 31437 value, 31438 baseValue, 31439 onChange, 31440 children: /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(Component6, { ...props }) 31441 } 31442 ); 31443 }; 31444 } 31445 31446 // packages/global-styles-ui/build-module/style-variations.js 31447 var StyleVariations = withGlobalStylesProvider(style_variations_container_default); 31448 31449 // packages/global-styles-ui/build-module/color-variations.js 31450 var ColorVariations2 = withGlobalStylesProvider(ColorVariations); 31451 31452 // packages/global-styles-ui/build-module/typography-variations.js 31453 var TypographyVariations2 = withGlobalStylesProvider(TypographyVariations); 31454 31455 // packages/global-styles-ui/build-module/font-library/font-library.js 31456 var import_jsx_runtime182 = __toESM(require_jsx_runtime()); 31457 31458 // packages/editor/build-module/components/global-styles/index.js 31459 var import_media_utils4 = __toESM(require_media_utils()); 31460 31461 // packages/editor/build-module/components/global-styles/block-link.js 31462 var import_data61 = __toESM(require_data()); 31463 var import_element69 = __toESM(require_element()); 31464 var import_block_editor32 = __toESM(require_block_editor()); 31465 var import_compose15 = __toESM(require_compose()); 31466 function GlobalStylesBlockLink({ path, onPathChange }) { 31467 const { selectedBlockName, selectedBlockClientId } = (0, import_data61.useSelect)( 31468 (select5) => { 31469 const { getSelectedBlockClientId: getSelectedBlockClientId2, getBlockName: getBlockName2 } = select5(import_block_editor32.store); 31470 const clientId = getSelectedBlockClientId2(); 31471 return { 31472 selectedBlockName: getBlockName2(clientId), 31473 selectedBlockClientId: clientId 31474 }; 31475 }, 31476 [] 31477 ); 31478 const blockHasGlobalStyles = true; 31479 const previousBlockClientId = (0, import_compose15.usePrevious)(selectedBlockClientId); 31480 (0, import_element69.useEffect)(() => { 31481 if (selectedBlockClientId === previousBlockClientId) { 31482 return; 31483 } 31484 if (!selectedBlockClientId || !blockHasGlobalStyles) { 31485 return; 31486 } 31487 if (!path || path !== "/blocks" && !path.startsWith("/blocks/")) { 31488 return; 31489 } 31490 const newPath = "/blocks/" + encodeURIComponent(selectedBlockName); 31491 if (newPath !== path) { 31492 onPathChange?.(newPath); 31493 } 31494 }, [ 31495 selectedBlockClientId, 31496 previousBlockClientId, 31497 selectedBlockName, 31498 blockHasGlobalStyles, 31499 path, 31500 onPathChange 31501 ]); 31502 return null; 31503 } 31504 31505 // packages/editor/build-module/components/global-styles/hooks.js 31506 var import_element70 = __toESM(require_element()); 31507 var import_core_data42 = __toESM(require_core_data()); 31508 var import_data62 = __toESM(require_data()); 31509 var import_block_editor33 = __toESM(require_block_editor()); 31510 var { cleanEmptyObject: cleanEmptyObject2 } = unlock(import_block_editor33.privateApis); 31511 function useGlobalStylesUserConfig2() { 31512 const { globalStylesId, isReady: isReady2, settings, styles, _links } = (0, import_data62.useSelect)( 31513 (select5) => { 31514 const { 31515 getEntityRecord, 31516 getEditedEntityRecord: getEditedEntityRecord2, 31517 hasFinishedResolution, 31518 canUser 31519 } = select5(import_core_data42.store); 31520 const _globalStylesId = select5(import_core_data42.store).__experimentalGetCurrentGlobalStylesId(); 31521 let record; 31522 const userCanEditGlobalStyles = _globalStylesId ? canUser("update", { 31523 kind: "root", 31524 name: "globalStyles", 31525 id: _globalStylesId 31526 }) : null; 31527 if (_globalStylesId && typeof userCanEditGlobalStyles === "boolean") { 31528 if (userCanEditGlobalStyles) { 31529 record = getEditedEntityRecord2( 31530 "root", 31531 "globalStyles", 31532 _globalStylesId 31533 ); 31534 } else { 31535 record = getEntityRecord( 31536 "root", 31537 "globalStyles", 31538 _globalStylesId, 31539 { context: "view" } 31540 ); 31541 } 31542 } 31543 let hasResolved = false; 31544 if (hasFinishedResolution( 31545 "__experimentalGetCurrentGlobalStylesId" 31546 )) { 31547 if (_globalStylesId) { 31548 hasResolved = userCanEditGlobalStyles ? hasFinishedResolution("getEditedEntityRecord", [ 31549 "root", 31550 "globalStyles", 31551 _globalStylesId 31552 ]) : hasFinishedResolution("getEntityRecord", [ 31553 "root", 31554 "globalStyles", 31555 _globalStylesId, 31556 { context: "view" } 31557 ]); 31558 } else { 31559 hasResolved = true; 31560 } 31561 } 31562 return { 31563 globalStylesId: _globalStylesId, 31564 isReady: hasResolved, 31565 settings: record?.settings, 31566 styles: record?.styles, 31567 _links: record?._links 31568 }; 31569 }, 31570 [] 31571 ); 31572 const { getEditedEntityRecord } = (0, import_data62.useSelect)(import_core_data42.store); 31573 const { editEntityRecord } = (0, import_data62.useDispatch)(import_core_data42.store); 31574 const config = (0, import_element70.useMemo)(() => { 31575 return { 31576 settings: settings ?? {}, 31577 styles: styles ?? {}, 31578 _links: _links ?? {} 31579 }; 31580 }, [settings, styles, _links]); 31581 const setConfig = (0, import_element70.useCallback)( 31582 (callbackOrObject, options = {}) => { 31583 const record = getEditedEntityRecord( 31584 "root", 31585 "globalStyles", 31586 globalStylesId 31587 ); 31588 const currentConfig = { 31589 styles: record?.styles ?? {}, 31590 settings: record?.settings ?? {}, 31591 _links: record?._links ?? {} 31592 }; 31593 const updatedConfig = typeof callbackOrObject === "function" ? callbackOrObject(currentConfig) : callbackOrObject; 31594 editEntityRecord( 31595 "root", 31596 "globalStyles", 31597 globalStylesId, 31598 { 31599 styles: cleanEmptyObject2(updatedConfig.styles) || {}, 31600 settings: cleanEmptyObject2(updatedConfig.settings) || {}, 31601 _links: cleanEmptyObject2(updatedConfig._links) || {} 31602 }, 31603 options 31604 ); 31605 }, 31606 [globalStylesId, editEntityRecord, getEditedEntityRecord] 31607 ); 31608 return [isReady2, config, setConfig]; 31609 } 31610 function useGlobalStylesBaseConfig2() { 31611 const baseConfig = (0, import_data62.useSelect)( 31612 (select5) => select5(import_core_data42.store).__experimentalGetCurrentThemeBaseGlobalStyles(), 31613 [] 31614 ); 31615 return [!!baseConfig, baseConfig]; 31616 } 31617 function useGlobalStyles() { 31618 const [isUserConfigReady, userConfig, setUserConfig] = useGlobalStylesUserConfig2(); 31619 const [isBaseConfigReady, baseConfig] = useGlobalStylesBaseConfig2(); 31620 const merged = (0, import_element70.useMemo)(() => { 31621 if (!isUserConfigReady || !isBaseConfigReady) { 31622 return {}; 31623 } 31624 return mergeGlobalStyles(baseConfig || {}, userConfig); 31625 }, [isUserConfigReady, isBaseConfigReady, baseConfig, userConfig]); 31626 return { 31627 merged, 31628 base: baseConfig || {}, 31629 user: userConfig, 31630 setUser: setUserConfig, 31631 isReady: isUserConfigReady && isBaseConfigReady 31632 }; 31633 } 31634 function useStyle2(path, blockName) { 31635 const { merged } = useGlobalStyles(); 31636 return (0, import_element70.useMemo)( 31637 () => getStyle(merged, path, blockName), 31638 [merged, path, blockName] 31639 ); 31640 } 31641 function useSetting2(path, blockName) { 31642 const { merged } = useGlobalStyles(); 31643 return (0, import_element70.useMemo)( 31644 () => getSetting(merged, path, blockName), 31645 [merged, path, blockName] 31646 ); 31647 } 31648 31649 // packages/editor/build-module/components/global-styles/index.js 31650 var import_jsx_runtime183 = __toESM(require_jsx_runtime()); 31651 function useServerData() { 31652 const { 31653 styles, 31654 __unstableResolvedAssets, 31655 colors, 31656 gradients, 31657 __experimentalDiscussionSettings, 31658 mediaUploadHandler, 31659 fontLibraryEnabled 31660 } = (0, import_data63.useSelect)((select5) => { 31661 const { getEditorSettings: getEditorSettings2 } = select5(store); 31662 const { canUser } = select5(import_core_data43.store); 31663 const editorSettings2 = getEditorSettings2(); 31664 const canUserUploadMedia = canUser("create", { 31665 kind: "postType", 31666 name: "attachment" 31667 }); 31668 return { 31669 styles: editorSettings2?.styles, 31670 __unstableResolvedAssets: editorSettings2?.__unstableResolvedAssets, 31671 colors: editorSettings2?.colors, 31672 gradients: editorSettings2?.gradients, 31673 __experimentalDiscussionSettings: editorSettings2?.__experimentalDiscussionSettings, 31674 mediaUploadHandler: canUserUploadMedia ? import_media_utils4.uploadMedia : void 0, 31675 fontLibraryEnabled: editorSettings2?.fontLibraryEnabled ?? true 31676 }; 31677 }, []); 31678 const serverCSS = (0, import_element71.useMemo)(() => { 31679 if (!styles) { 31680 return []; 31681 } 31682 return styles.filter((style) => !style.isGlobalStyles); 31683 }, [styles]); 31684 const serverSettings = (0, import_element71.useMemo)(() => { 31685 return { 31686 __unstableResolvedAssets, 31687 settings: { 31688 color: { 31689 palette: { 31690 theme: colors ?? [] 31691 }, 31692 gradients: { 31693 theme: gradients ?? [] 31694 }, 31695 duotone: { 31696 theme: [] 31697 } 31698 } 31699 }, 31700 __experimentalDiscussionSettings, 31701 mediaUpload: mediaUploadHandler 31702 }; 31703 }, [ 31704 __unstableResolvedAssets, 31705 colors, 31706 gradients, 31707 __experimentalDiscussionSettings, 31708 mediaUploadHandler 31709 ]); 31710 return { serverCSS, serverSettings, fontLibraryEnabled }; 31711 } 31712 function GlobalStylesUIWrapper({ path, onPathChange }) { 31713 const { 31714 user: userConfig, 31715 base: baseConfig, 31716 setUser: setUserConfig, 31717 isReady: isReady2 31718 } = useGlobalStyles(); 31719 const { serverCSS, serverSettings, fontLibraryEnabled } = useServerData(); 31720 if (!isReady2) { 31721 return null; 31722 } 31723 return /* @__PURE__ */ (0, import_jsx_runtime183.jsxs)(import_jsx_runtime183.Fragment, { children: [ 31724 /* @__PURE__ */ (0, import_jsx_runtime183.jsx)( 31725 GlobalStylesUI, 31726 { 31727 value: userConfig, 31728 baseValue: baseConfig || {}, 31729 onChange: setUserConfig, 31730 path, 31731 onPathChange, 31732 fontLibraryEnabled, 31733 serverCSS, 31734 serverSettings 31735 } 31736 ), 31737 /* @__PURE__ */ (0, import_jsx_runtime183.jsx)( 31738 GlobalStylesBlockLink, 31739 { 31740 path, 31741 onPathChange 31742 } 31743 ) 31744 ] }); 31745 } 31746 31747 // packages/editor/build-module/dataviews/fields/content-preview/content-preview-view.js 31748 var import_jsx_runtime184 = __toESM(require_jsx_runtime()); 31749 function PostPreviewContainer({ 31750 template: template2, 31751 post: post2 31752 }) { 31753 const [backgroundColor = "white"] = useStyle2("color.background"); 31754 const [postBlocks] = (0, import_core_data44.useEntityBlockEditor)("postType", post2.type, { 31755 id: post2.id 31756 }); 31757 const [templateBlocks] = (0, import_core_data44.useEntityBlockEditor)( 31758 "postType", 31759 template2?.type, 31760 { 31761 id: template2?.id 31762 } 31763 ); 31764 const blocks = template2 && templateBlocks ? templateBlocks : postBlocks; 31765 const isEmpty = !blocks?.length; 31766 return /* @__PURE__ */ (0, import_jsx_runtime184.jsxs)( 31767 "div", 31768 { 31769 className: "editor-fields-content-preview", 31770 style: { 31771 backgroundColor 31772 }, 31773 children: [ 31774 isEmpty && /* @__PURE__ */ (0, import_jsx_runtime184.jsx)("span", { className: "editor-fields-content-preview__empty", children: (0, import_i18n106.__)("Empty content") }), 31775 !isEmpty && /* @__PURE__ */ (0, import_jsx_runtime184.jsx)(import_block_editor34.BlockPreview.Async, { children: /* @__PURE__ */ (0, import_jsx_runtime184.jsx)(import_block_editor34.BlockPreview, { blocks }) }) 31776 ] 31777 } 31778 ); 31779 } 31780 function PostPreviewView({ item }) { 31781 const { settings, template: template2 } = (0, import_data64.useSelect)( 31782 (select5) => { 31783 const { canUser, getPostType, getTemplateId, getEntityRecord } = unlock(select5(import_core_data44.store)); 31784 const canViewTemplate = canUser("read", { 31785 kind: "postType", 31786 name: "wp_template" 31787 }); 31788 const _settings = select5(store).getEditorSettings(); 31789 const supportsTemplateMode = _settings.supportsTemplateMode; 31790 const isViewable = getPostType(item.type)?.viewable ?? false; 31791 const templateId2 = supportsTemplateMode && isViewable && canViewTemplate ? getTemplateId(item.type, item.id) : null; 31792 return { 31793 settings: _settings, 31794 template: templateId2 ? getEntityRecord("postType", "wp_template", templateId2) : void 0 31795 }; 31796 }, 31797 [item.type, item.id] 31798 ); 31799 return /* @__PURE__ */ (0, import_jsx_runtime184.jsx)( 31800 EditorProvider, 31801 { 31802 post: item, 31803 settings, 31804 __unstableTemplate: template2, 31805 children: /* @__PURE__ */ (0, import_jsx_runtime184.jsx)(PostPreviewContainer, { template: template2, post: item }) 31806 } 31807 ); 31808 } 31809 31810 // packages/editor/build-module/dataviews/fields/content-preview/index.js 31811 var postPreviewField = { 31812 type: "media", 31813 id: "content-preview", 31814 label: (0, import_i18n107.__)("Content preview"), 31815 render: PostPreviewView, 31816 enableSorting: false 31817 }; 31818 var content_preview_default = postPreviewField; 31819 31820 // packages/editor/build-module/dataviews/store/private-actions.js 31821 function hasEditorNotesSupport(supports) { 31822 const editor = supports?.editor; 31823 if (Array.isArray(editor)) { 31824 return !!editor[0]?.notes; 31825 } 31826 return false; 31827 } 31828 function registerEntityAction(kind, name2, config) { 31829 return { 31830 type: "REGISTER_ENTITY_ACTION", 31831 kind, 31832 name: name2, 31833 config 31834 }; 31835 } 31836 function unregisterEntityAction(kind, name2, actionId) { 31837 return { 31838 type: "UNREGISTER_ENTITY_ACTION", 31839 kind, 31840 name: name2, 31841 actionId 31842 }; 31843 } 31844 function registerEntityField(kind, name2, config) { 31845 return { 31846 type: "REGISTER_ENTITY_FIELD", 31847 kind, 31848 name: name2, 31849 config 31850 }; 31851 } 31852 function unregisterEntityField(kind, name2, fieldId) { 31853 return { 31854 type: "UNREGISTER_ENTITY_FIELD", 31855 kind, 31856 name: name2, 31857 fieldId 31858 }; 31859 } 31860 function setIsReady(kind, name2) { 31861 return { 31862 type: "SET_IS_READY", 31863 kind, 31864 name: name2 31865 }; 31866 } 31867 var registerPostTypeSchema = (postType2) => async ({ registry }) => { 31868 const isReady2 = unlock(registry.select(store)).isEntityReady( 31869 "postType", 31870 postType2 31871 ); 31872 if (isReady2) { 31873 return; 31874 } 31875 unlock(registry.dispatch(store)).setIsReady( 31876 "postType", 31877 postType2 31878 ); 31879 const postTypeConfig = await registry.resolveSelect(import_core_data45.store).getPostType(postType2); 31880 const canCreate = await registry.resolveSelect(import_core_data45.store).canUser("create", { 31881 kind: "postType", 31882 name: postType2 31883 }); 31884 const currentTheme = await registry.resolveSelect(import_core_data45.store).getCurrentTheme(); 31885 let canDuplicate = !["wp_block", "wp_template_part"].includes( 31886 postTypeConfig.slug 31887 ) && canCreate && duplicate_post_default; 31888 if (true) { 31889 if ("wp_template" !== postTypeConfig.slug) { 31890 canDuplicate = void 0; 31891 } 31892 } 31893 if (postTypeConfig.slug === "wp_template" && !window?.__experimentalTemplateActivate) { 31894 canDuplicate = void 0; 31895 } 31896 const actions2 = [ 31897 postTypeConfig.viewable ? view_post_default : void 0, 31898 !!postTypeConfig.supports?.revisions ? view_post_revisions_default : void 0, 31899 // @ts-ignore 31900 canDuplicate, 31901 postTypeConfig.slug === "wp_template_part" && canCreate && currentTheme?.is_block_theme ? duplicate_template_part_default : void 0, 31902 canCreate && postTypeConfig.slug === "wp_block" ? duplicate_pattern_default : void 0, 31903 postTypeConfig.supports?.title ? rename_post_default : void 0, 31904 postTypeConfig.supports?.["page-attributes"] ? reorder_page_default : void 0, 31905 postTypeConfig.slug === "wp_block" ? export_pattern_default : void 0, 31906 restore_post_default, 31907 reset_post_default, 31908 delete_post_default, 31909 trash_post_default, 31910 permanently_delete_post_default 31911 ].filter(Boolean); 31912 const fields2 = [ 31913 postTypeConfig.supports?.thumbnail && currentTheme?.theme_supports?.["post-thumbnails"] && featured_image_default, 31914 postTypeConfig.supports?.author && author_default, 31915 status_default, 31916 !DESIGN_POST_TYPES.includes(postTypeConfig.slug) && date_default, 31917 slug_default, 31918 postTypeConfig.supports?.["page-attributes"] && parent_default, 31919 postTypeConfig.supports?.comments && comment_status_default, 31920 postTypeConfig.supports?.trackbacks && ping_status_default, 31921 (postTypeConfig.supports?.comments || postTypeConfig.supports?.trackbacks) && discussion_default, 31922 template_default, 31923 password_default, 31924 postTypeConfig.supports?.editor && postTypeConfig.viewable && content_preview_default, 31925 hasEditorNotesSupport(postTypeConfig.supports) && notes_default 31926 ].filter(Boolean); 31927 if (postTypeConfig.supports?.title) { 31928 let _titleField; 31929 if (postType2 === "page") { 31930 _titleField = page_title_default; 31931 } else if (postType2 === "wp_template") { 31932 _titleField = template_title_default; 31933 } else if (postType2 === "wp_block") { 31934 _titleField = pattern_title_default; 31935 } else { 31936 _titleField = title_default; 31937 } 31938 fields2.push(_titleField); 31939 } 31940 registry.batch(() => { 31941 actions2.forEach((action) => { 31942 unlock(registry.dispatch(store)).registerEntityAction( 31943 "postType", 31944 postType2, 31945 action 31946 ); 31947 }); 31948 fields2.forEach((field) => { 31949 unlock(registry.dispatch(store)).registerEntityField( 31950 "postType", 31951 postType2, 31952 field 31953 ); 31954 }); 31955 }); 31956 (0, import_hooks36.doAction)("core.registerPostTypeSchema", postType2); 31957 }; 31958 31959 // packages/editor/build-module/store/private-actions.js 31960 function setCurrentTemplateId(id) { 31961 return { 31962 type: "SET_CURRENT_TEMPLATE_ID", 31963 id 31964 }; 31965 } 31966 var createTemplate = (template2) => async ({ select: select5, dispatch: dispatch6, registry }) => { 31967 const savedTemplate = await registry.dispatch(import_core_data46.store).saveEntityRecord("postType", "wp_template", template2); 31968 registry.dispatch(import_core_data46.store).editEntityRecord( 31969 "postType", 31970 select5.getCurrentPostType(), 31971 select5.getCurrentPostId(), 31972 { 31973 template: savedTemplate.slug 31974 } 31975 ); 31976 registry.dispatch(import_notices16.store).createSuccessNotice( 31977 (0, import_i18n108.__)("Custom template created. You're in template mode now."), 31978 { 31979 type: "snackbar", 31980 actions: [ 31981 { 31982 label: (0, import_i18n108.__)("Go back"), 31983 onClick: () => dispatch6.setRenderingMode( 31984 select5.getEditorSettings().defaultRenderingMode 31985 ) 31986 } 31987 ] 31988 } 31989 ); 31990 return savedTemplate; 31991 }; 31992 var showBlockTypes = (blockNames) => ({ registry }) => { 31993 const existingBlockNames = registry.select(import_preferences9.store).get("core", "hiddenBlockTypes") ?? []; 31994 const newBlockNames = existingBlockNames.filter( 31995 (type) => !(Array.isArray(blockNames) ? blockNames : [blockNames]).includes(type) 31996 ); 31997 registry.dispatch(import_preferences9.store).set("core", "hiddenBlockTypes", newBlockNames); 31998 }; 31999 var hideBlockTypes = (blockNames) => ({ registry }) => { 32000 const existingBlockNames = registry.select(import_preferences9.store).get("core", "hiddenBlockTypes") ?? []; 32001 const mergedBlockNames = /* @__PURE__ */ new Set([ 32002 ...existingBlockNames, 32003 ...Array.isArray(blockNames) ? blockNames : [blockNames] 32004 ]); 32005 registry.dispatch(import_preferences9.store).set("core", "hiddenBlockTypes", [...mergedBlockNames]); 32006 }; 32007 var saveDirtyEntities = ({ onSave, dirtyEntityRecords = [], entitiesToSkip = [], close } = {}) => ({ registry }) => { 32008 const PUBLISH_ON_SAVE_ENTITIES = [ 32009 { kind: "postType", name: "wp_navigation" } 32010 ]; 32011 const saveNoticeId = "site-editor-save-success"; 32012 const homeUrl = registry.select(import_core_data46.store).getEntityRecord("root", "__unstableBase")?.home; 32013 registry.dispatch(import_notices16.store).removeNotice(saveNoticeId); 32014 const entitiesToSave = dirtyEntityRecords.filter( 32015 ({ kind, name: name2, key, property }) => { 32016 return !entitiesToSkip.some( 32017 (elt) => elt.kind === kind && elt.name === name2 && elt.key === key && elt.property === property 32018 ); 32019 } 32020 ); 32021 close?.(entitiesToSave); 32022 const siteItemsToSave = []; 32023 const pendingSavedRecords = []; 32024 entitiesToSave.forEach(({ kind, name: name2, key, property }) => { 32025 if ("root" === kind && "site" === name2) { 32026 siteItemsToSave.push(property); 32027 } else { 32028 if (PUBLISH_ON_SAVE_ENTITIES.some( 32029 (typeToPublish) => typeToPublish.kind === kind && typeToPublish.name === name2 32030 )) { 32031 registry.dispatch(import_core_data46.store).editEntityRecord(kind, name2, key, { 32032 status: "publish" 32033 }); 32034 } 32035 pendingSavedRecords.push( 32036 registry.dispatch(import_core_data46.store).saveEditedEntityRecord(kind, name2, key) 32037 ); 32038 } 32039 }); 32040 if (siteItemsToSave.length) { 32041 pendingSavedRecords.push( 32042 registry.dispatch(import_core_data46.store).__experimentalSaveSpecifiedEntityEdits( 32043 "root", 32044 "site", 32045 void 0, 32046 siteItemsToSave 32047 ) 32048 ); 32049 } 32050 registry.dispatch(import_block_editor35.store).__unstableMarkLastChangeAsPersistent(); 32051 Promise.all(pendingSavedRecords).then((values) => { 32052 return onSave ? onSave(values) : values; 32053 }).then((values) => { 32054 if (values.some((value) => typeof value === "undefined")) { 32055 registry.dispatch(import_notices16.store).createErrorNotice((0, import_i18n108.__)("Saving failed.")); 32056 } else { 32057 registry.dispatch(import_notices16.store).createSuccessNotice((0, import_i18n108.__)("Site updated."), { 32058 type: "snackbar", 32059 id: saveNoticeId, 32060 actions: [ 32061 { 32062 label: (0, import_i18n108.__)("View site"), 32063 url: homeUrl, 32064 openInNewTab: true 32065 } 32066 ] 32067 }); 32068 } 32069 }).catch( 32070 (error) => registry.dispatch(import_notices16.store).createErrorNotice( 32071 `${(0, import_i18n108.__)("Saving failed.")} $error}` 32072 ) 32073 ); 32074 }; 32075 var revertTemplate2 = (template2, { allowUndo = true } = {}) => async ({ registry }) => { 32076 const noticeId = "edit-site-template-reverted"; 32077 registry.dispatch(import_notices16.store).removeNotice(noticeId); 32078 if (!isTemplateRevertable(template2)) { 32079 registry.dispatch(import_notices16.store).createErrorNotice((0, import_i18n108.__)("This template is not revertable."), { 32080 type: "snackbar" 32081 }); 32082 return; 32083 } 32084 try { 32085 const templateEntityConfig = registry.select(import_core_data46.store).getEntityConfig("postType", template2.type); 32086 if (!templateEntityConfig) { 32087 registry.dispatch(import_notices16.store).createErrorNotice( 32088 (0, import_i18n108.__)( 32089 "The editor has encountered an unexpected error. Please reload." 32090 ), 32091 { type: "snackbar" } 32092 ); 32093 return; 32094 } 32095 const fileTemplatePath = (0, import_url9.addQueryArgs)( 32096 `$templateEntityConfig.baseURL}/$template2.id}`, 32097 { context: "edit", source: template2.origin } 32098 ); 32099 const fileTemplate = await (0, import_api_fetch4.default)({ path: fileTemplatePath }); 32100 if (!fileTemplate) { 32101 registry.dispatch(import_notices16.store).createErrorNotice( 32102 (0, import_i18n108.__)( 32103 "The editor has encountered an unexpected error. Please reload." 32104 ), 32105 { type: "snackbar" } 32106 ); 32107 return; 32108 } 32109 const serializeBlocks = ({ 32110 blocks: blocksForSerialization = [] 32111 }) => (0, import_blocks19.__unstableSerializeAndClean)(blocksForSerialization); 32112 const edited = registry.select(import_core_data46.store).getEditedEntityRecord( 32113 "postType", 32114 template2.type, 32115 template2.id 32116 ); 32117 registry.dispatch(import_core_data46.store).editEntityRecord( 32118 "postType", 32119 template2.type, 32120 template2.id, 32121 { 32122 content: serializeBlocks, 32123 // Required to make the `undo` behave correctly. 32124 blocks: edited.blocks, 32125 // Required to revert the blocks in the editor. 32126 source: "custom" 32127 // required to avoid turning the editor into a dirty state 32128 }, 32129 { 32130 undoIgnore: true 32131 // Required to merge this edit with the last undo level. 32132 } 32133 ); 32134 const blocks = (0, import_blocks19.parse)(fileTemplate?.content?.raw); 32135 registry.dispatch(import_core_data46.store).editEntityRecord("postType", template2.type, fileTemplate.id, { 32136 content: serializeBlocks, 32137 blocks, 32138 source: "theme" 32139 }); 32140 if (allowUndo) { 32141 const undoRevert = () => { 32142 registry.dispatch(import_core_data46.store).editEntityRecord( 32143 "postType", 32144 template2.type, 32145 edited.id, 32146 { 32147 content: serializeBlocks, 32148 blocks: edited.blocks, 32149 source: "custom" 32150 } 32151 ); 32152 }; 32153 registry.dispatch(import_notices16.store).createSuccessNotice((0, import_i18n108.__)("Template reset."), { 32154 type: "snackbar", 32155 id: noticeId, 32156 actions: [ 32157 { 32158 label: (0, import_i18n108.__)("Undo"), 32159 onClick: undoRevert 32160 } 32161 ] 32162 }); 32163 } 32164 } catch (error) { 32165 const errorMessage = error.message && error.code !== "unknown_error" ? error.message : (0, import_i18n108.__)("Template revert failed. Please reload."); 32166 registry.dispatch(import_notices16.store).createErrorNotice(errorMessage, { type: "snackbar" }); 32167 } 32168 }; 32169 var removeTemplates = (items) => async ({ registry }) => { 32170 const isResetting = items.every((item) => item?.has_theme_file); 32171 const promiseResult = await Promise.allSettled( 32172 items.map((item) => { 32173 return registry.dispatch(import_core_data46.store).deleteEntityRecord( 32174 "postType", 32175 item.type, 32176 item.id, 32177 { force: true }, 32178 { throwOnError: true } 32179 ); 32180 }) 32181 ); 32182 if (promiseResult.every(({ status }) => status === "fulfilled")) { 32183 let successMessage; 32184 if (items.length === 1) { 32185 let title; 32186 if (typeof items[0].title === "string") { 32187 title = items[0].title; 32188 } else if (typeof items[0].title?.rendered === "string") { 32189 title = items[0].title?.rendered; 32190 } else if (typeof items[0].title?.raw === "string") { 32191 title = items[0].title?.raw; 32192 } 32193 successMessage = isResetting ? (0, import_i18n108.sprintf)( 32194 /* translators: %s: The template/part's name. */ 32195 (0, import_i18n108.__)('"%s" reset.'), 32196 (0, import_html_entities9.decodeEntities)(title) 32197 ) : (0, import_i18n108.sprintf)( 32198 /* translators: %s: The template/part's name. */ 32199 (0, import_i18n108._x)('"%s" deleted.', "template part"), 32200 (0, import_html_entities9.decodeEntities)(title) 32201 ); 32202 } else { 32203 successMessage = isResetting ? (0, import_i18n108.__)("Items reset.") : (0, import_i18n108.__)("Items deleted."); 32204 } 32205 registry.dispatch(import_notices16.store).createSuccessNotice(successMessage, { 32206 type: "snackbar", 32207 id: "editor-template-deleted-success" 32208 }); 32209 } else { 32210 let errorMessage; 32211 if (promiseResult.length === 1) { 32212 if (promiseResult[0].reason?.message) { 32213 errorMessage = promiseResult[0].reason.message; 32214 } else { 32215 errorMessage = isResetting ? (0, import_i18n108.__)("An error occurred while reverting the item.") : (0, import_i18n108.__)("An error occurred while deleting the item."); 32216 } 32217 } else { 32218 const errorMessages = /* @__PURE__ */ new Set(); 32219 const failedPromises = promiseResult.filter( 32220 ({ status }) => status === "rejected" 32221 ); 32222 for (const failedPromise of failedPromises) { 32223 if (failedPromise.reason?.message) { 32224 errorMessages.add(failedPromise.reason.message); 32225 } 32226 } 32227 if (errorMessages.size === 0) { 32228 errorMessage = (0, import_i18n108.__)( 32229 "An error occurred while deleting the items." 32230 ); 32231 } else if (errorMessages.size === 1) { 32232 errorMessage = isResetting ? (0, import_i18n108.sprintf)( 32233 /* translators: %s: an error message */ 32234 (0, import_i18n108.__)( 32235 "An error occurred while reverting the items: %s" 32236 ), 32237 [...errorMessages][0] 32238 ) : (0, import_i18n108.sprintf)( 32239 /* translators: %s: an error message */ 32240 (0, import_i18n108.__)( 32241 "An error occurred while deleting the items: %s" 32242 ), 32243 [...errorMessages][0] 32244 ); 32245 } else { 32246 errorMessage = isResetting ? (0, import_i18n108.sprintf)( 32247 /* translators: %s: a list of comma separated error messages */ 32248 (0, import_i18n108.__)( 32249 "Some errors occurred while reverting the items: %s" 32250 ), 32251 [...errorMessages].join(",") 32252 ) : (0, import_i18n108.sprintf)( 32253 /* translators: %s: a list of comma separated error messages */ 32254 (0, import_i18n108.__)( 32255 "Some errors occurred while deleting the items: %s" 32256 ), 32257 [...errorMessages].join(",") 32258 ); 32259 } 32260 } 32261 registry.dispatch(import_notices16.store).createErrorNotice(errorMessage, { type: "snackbar" }); 32262 } 32263 }; 32264 var setDefaultRenderingMode = (mode) => ({ select: select5, registry }) => { 32265 const postType2 = select5.getCurrentPostType(); 32266 const theme = registry.select(import_core_data46.store).getCurrentTheme()?.stylesheet; 32267 const renderingModes = registry.select(import_preferences9.store).get("core", "renderingModes")?.[theme] ?? {}; 32268 if (renderingModes[postType2] === mode) { 32269 return; 32270 } 32271 const newModes = { 32272 [theme]: { 32273 ...renderingModes, 32274 [postType2]: mode 32275 } 32276 }; 32277 registry.dispatch(import_preferences9.store).set("core", "renderingModes", newModes); 32278 }; 32279 function setStylesPath(path) { 32280 return { 32281 type: "SET_STYLES_PATH", 32282 path 32283 }; 32284 } 32285 function setShowStylebook(show) { 32286 return { 32287 type: "SET_SHOW_STYLEBOOK", 32288 show 32289 }; 32290 } 32291 function resetStylesNavigation() { 32292 return { 32293 type: "RESET_STYLES_NAVIGATION" 32294 }; 32295 } 32296 function setCanvasMinHeight(minHeight) { 32297 return { 32298 type: "SET_CANVAS_MIN_HEIGHT", 32299 minHeight 32300 }; 32301 } 32302 32303 // packages/editor/build-module/store/private-selectors.js 32304 var private_selectors_exports = {}; 32305 __export(private_selectors_exports, { 32306 getCanvasMinHeight: () => getCanvasMinHeight, 32307 getDefaultRenderingMode: () => getDefaultRenderingMode, 32308 getEntityActions: () => getEntityActions2, 32309 getEntityFields: () => getEntityFields2, 32310 getInserter: () => getInserter, 32311 getInserterSidebarToggleRef: () => getInserterSidebarToggleRef, 32312 getListViewToggleRef: () => getListViewToggleRef, 32313 getPostBlocksByName: () => getPostBlocksByName, 32314 getPostIcon: () => getPostIcon, 32315 getShowStylebook: () => getShowStylebook, 32316 getStylesPath: () => getStylesPath, 32317 hasPostMetaChanges: () => hasPostMetaChanges, 32318 isEntityReady: () => isEntityReady2 32319 }); 32320 var import_fast_deep_equal = __toESM(require_fast_deep_equal()); 32321 var import_block_editor36 = __toESM(require_block_editor()); 32322 var import_data65 = __toESM(require_data()); 32323 var import_core_data47 = __toESM(require_core_data()); 32324 var import_preferences10 = __toESM(require_preferences()); 32325 32326 // packages/editor/build-module/dataviews/store/private-selectors.js 32327 var EMPTY_ARRAY5 = []; 32328 function getEntityActions(state, kind, name2) { 32329 return state.actions[kind]?.[name2] ?? EMPTY_ARRAY5; 32330 } 32331 function getEntityFields(state, kind, name2) { 32332 return state.fields[kind]?.[name2] ?? EMPTY_ARRAY5; 32333 } 32334 function isEntityReady(state, kind, name2) { 32335 return state.isReady[kind]?.[name2]; 32336 } 32337 32338 // packages/editor/build-module/store/private-selectors.js 32339 var EMPTY_INSERTION_POINT = { 32340 rootClientId: void 0, 32341 insertionIndex: void 0, 32342 filterValue: void 0 32343 }; 32344 var RENDERING_MODES = ["post-only", "template-locked"]; 32345 var getInserter = (0, import_data65.createRegistrySelector)( 32346 (select5) => (0, import_data65.createSelector)( 32347 (state) => { 32348 if (typeof state.blockInserterPanel === "object") { 32349 return state.blockInserterPanel; 32350 } 32351 if (getRenderingMode(state) === "template-locked") { 32352 const [postContentClientId] = select5(import_block_editor36.store).getBlocksByName( 32353 "core/post-content" 32354 ); 32355 if (postContentClientId) { 32356 return { 32357 rootClientId: postContentClientId, 32358 insertionIndex: void 0, 32359 filterValue: void 0 32360 }; 32361 } 32362 } 32363 return EMPTY_INSERTION_POINT; 32364 }, 32365 (state) => { 32366 const [postContentClientId] = select5(import_block_editor36.store).getBlocksByName( 32367 "core/post-content" 32368 ); 32369 return [ 32370 state.blockInserterPanel, 32371 getRenderingMode(state), 32372 postContentClientId 32373 ]; 32374 } 32375 ) 32376 ); 32377 function getListViewToggleRef(state) { 32378 return state.listViewToggleRef; 32379 } 32380 function getInserterSidebarToggleRef(state) { 32381 return state.inserterSidebarToggleRef; 32382 } 32383 var CARD_ICONS = { 32384 wp_block: symbol_default, 32385 wp_navigation: navigation_default, 32386 page: page_default, 32387 post: verse_default 32388 }; 32389 var getPostIcon = (0, import_data65.createRegistrySelector)( 32390 (select5) => (state, postType2, options) => { 32391 { 32392 if (postType2 === "wp_template_part" || postType2 === "wp_template") { 32393 const templateAreas = select5(import_core_data47.store).getCurrentTheme()?.default_template_part_areas || []; 32394 const areaData = templateAreas.find( 32395 (item) => options.area === item.area 32396 ); 32397 if (areaData?.icon) { 32398 return getTemplatePartIcon(areaData.icon); 32399 } 32400 return layout_default; 32401 } 32402 if (CARD_ICONS[postType2]) { 32403 return CARD_ICONS[postType2]; 32404 } 32405 const postTypeEntity = select5(import_core_data47.store).getPostType(postType2); 32406 if (typeof postTypeEntity?.icon === "string" && postTypeEntity.icon.startsWith("dashicons-")) { 32407 return postTypeEntity.icon.slice(10); 32408 } 32409 return page_default; 32410 } 32411 } 32412 ); 32413 var hasPostMetaChanges = (0, import_data65.createRegistrySelector)( 32414 (select5) => (state, postType2, postId2) => { 32415 const { type: currentPostType, id: currentPostId } = getCurrentPost(state); 32416 const edits = select5(import_core_data47.store).getEntityRecordNonTransientEdits( 32417 "postType", 32418 postType2 || currentPostType, 32419 postId2 || currentPostId 32420 ); 32421 if (!edits?.meta) { 32422 return false; 32423 } 32424 const originalPostMeta = select5(import_core_data47.store).getEntityRecord( 32425 "postType", 32426 postType2 || currentPostType, 32427 postId2 || currentPostId 32428 )?.meta; 32429 return !(0, import_fast_deep_equal.default)( 32430 { ...originalPostMeta, footnotes: void 0 }, 32431 { ...edits.meta, footnotes: void 0 } 32432 ); 32433 } 32434 ); 32435 function getEntityActions2(state, ...args) { 32436 return getEntityActions(state.dataviews, ...args); 32437 } 32438 function isEntityReady2(state, ...args) { 32439 return isEntityReady(state.dataviews, ...args); 32440 } 32441 function getEntityFields2(state, ...args) { 32442 return getEntityFields(state.dataviews, ...args); 32443 } 32444 var getPostBlocksByName = (0, import_data65.createRegistrySelector)( 32445 (select5) => (0, import_data65.createSelector)( 32446 (state, blockNames) => { 32447 blockNames = Array.isArray(blockNames) ? blockNames : [blockNames]; 32448 const { getBlocksByName, getBlockParents, getBlockName: getBlockName2 } = select5(import_block_editor36.store); 32449 return getBlocksByName(blockNames).filter( 32450 (clientId) => getBlockParents(clientId).every((parentClientId) => { 32451 const parentBlockName = getBlockName2(parentClientId); 32452 return ( 32453 // Ignore descendents of the query block. 32454 parentBlockName !== "core/query" && // Enable only the top-most block. 32455 !blockNames.includes(parentBlockName) 32456 ); 32457 }) 32458 ); 32459 }, 32460 () => [select5(import_block_editor36.store).getBlocks()] 32461 ) 32462 ); 32463 var getDefaultRenderingMode = (0, import_data65.createRegistrySelector)( 32464 (select5) => (state, postType2) => { 32465 const { getPostType, getCurrentTheme, hasFinishedResolution } = select5(import_core_data47.store); 32466 const currentTheme = getCurrentTheme(); 32467 const postTypeEntity = getPostType(postType2); 32468 if (!hasFinishedResolution("getPostType", [postType2]) || !hasFinishedResolution("getCurrentTheme")) { 32469 return void 0; 32470 } 32471 const theme = currentTheme?.stylesheet; 32472 const defaultModePreference = select5(import_preferences10.store).get( 32473 "core", 32474 "renderingModes" 32475 )?.[theme]?.[postType2]; 32476 const postTypeDefaultMode = Array.isArray( 32477 postTypeEntity?.supports?.editor 32478 ) ? postTypeEntity.supports.editor.find( 32479 (features) => "default-mode" in features 32480 )?.["default-mode"] : void 0; 32481 const defaultMode = defaultModePreference || postTypeDefaultMode; 32482 if (!RENDERING_MODES.includes(defaultMode)) { 32483 return "post-only"; 32484 } 32485 return defaultMode; 32486 } 32487 ); 32488 function getStylesPath(state) { 32489 return state.stylesPath ?? "/"; 32490 } 32491 function getShowStylebook(state) { 32492 return state.showStylebook ?? false; 32493 } 32494 function getCanvasMinHeight(state) { 32495 return state.canvasMinHeight; 32496 } 32497 32498 // packages/editor/build-module/store/index.js 32499 var storeConfig = { 32500 reducer: reducer_default2, 32501 selectors: selectors_exports, 32502 actions: actions_exports 32503 }; 32504 var store = (0, import_data66.createReduxStore)(STORE_NAME, { 32505 ...storeConfig 32506 }); 32507 (0, import_data66.register)(store); 32508 unlock(store).registerPrivateActions(private_actions_exports); 32509 unlock(store).registerPrivateSelectors(private_selectors_exports); 32510 32511 // packages/editor/build-module/hooks/custom-sources-backwards-compatibility.js 32512 var import_jsx_runtime185 = __toESM(require_jsx_runtime()); 32513 var createWithMetaAttributeSource = (metaAttributes) => (0, import_compose16.createHigherOrderComponent)( 32514 (BlockEdit2) => ({ attributes, setAttributes, ...props }) => { 32515 const postType2 = (0, import_data67.useSelect)( 32516 (select5) => select5(store).getCurrentPostType(), 32517 [] 32518 ); 32519 const [meta2, setMeta] = (0, import_core_data48.useEntityProp)( 32520 "postType", 32521 postType2, 32522 "meta" 32523 ); 32524 const mergedAttributes = (0, import_element72.useMemo)( 32525 () => ({ 32526 ...attributes, 32527 ...Object.fromEntries( 32528 Object.entries(metaAttributes).map( 32529 ([attributeKey, metaKey]) => [ 32530 attributeKey, 32531 meta2[metaKey] 32532 ] 32533 ) 32534 ) 32535 }), 32536 [attributes, meta2] 32537 ); 32538 return /* @__PURE__ */ (0, import_jsx_runtime185.jsx)( 32539 BlockEdit2, 32540 { 32541 attributes: mergedAttributes, 32542 setAttributes: (nextAttributes) => { 32543 const nextMeta = Object.fromEntries( 32544 Object.entries(nextAttributes ?? {}).filter( 32545 // Filter to intersection of keys between the updated 32546 // attributes and those with an associated meta key. 32547 ([key]) => key in metaAttributes 32548 ).map(([attributeKey, value]) => [ 32549 // Rename the keys to the expected meta key name. 32550 metaAttributes[attributeKey], 32551 value 32552 ]) 32553 ); 32554 if (Object.entries(nextMeta).length) { 32555 setMeta(nextMeta); 32556 } 32557 setAttributes(nextAttributes); 32558 }, 32559 ...props 32560 } 32561 ); 32562 }, 32563 "withMetaAttributeSource" 32564 ); 32565 function shimAttributeSource(settings) { 32566 const metaAttributes = Object.fromEntries( 32567 Object.entries(settings.attributes ?? {}).filter(([, { source }]) => source === "meta").map(([attributeKey, { meta: meta2 }]) => [attributeKey, meta2]) 32568 ); 32569 if (Object.entries(metaAttributes).length) { 32570 settings.edit = createWithMetaAttributeSource(metaAttributes)( 32571 settings.edit 32572 ); 32573 } 32574 return settings; 32575 } 32576 (0, import_hooks37.addFilter)( 32577 "blocks.registerBlockType", 32578 "core/editor/custom-sources-backwards-compatibility/shim-attribute-source", 32579 shimAttributeSource 32580 ); 32581 32582 // packages/editor/build-module/hooks/default-autocompleters.js 32583 var import_hooks47 = __toESM(require_hooks()); 32584 32585 // packages/editor/build-module/components/autocompleters/user.js 32586 var import_element73 = __toESM(require_element()); 32587 var import_data68 = __toESM(require_data()); 32588 var import_core_data49 = __toESM(require_core_data()); 32589 var import_jsx_runtime186 = __toESM(require_jsx_runtime()); 32590 function getUserLabel(user) { 32591 const avatar = user.avatar_urls && user.avatar_urls[24] ? /* @__PURE__ */ (0, import_jsx_runtime186.jsx)( 32592 "img", 32593 { 32594 className: "editor-autocompleters__user-avatar", 32595 alt: "", 32596 src: user.avatar_urls[24] 32597 } 32598 ) : /* @__PURE__ */ (0, import_jsx_runtime186.jsx)("span", { className: "editor-autocompleters__no-avatar" }); 32599 return /* @__PURE__ */ (0, import_jsx_runtime186.jsxs)(import_jsx_runtime186.Fragment, { children: [ 32600 avatar, 32601 /* @__PURE__ */ (0, import_jsx_runtime186.jsx)("span", { className: "editor-autocompleters__user-name", children: user.name }), 32602 /* @__PURE__ */ (0, import_jsx_runtime186.jsx)("span", { className: "editor-autocompleters__user-slug", children: user.slug }) 32603 ] }); 32604 } 32605 var user_default = { 32606 name: "users", 32607 className: "editor-autocompleters__user", 32608 triggerPrefix: "@", 32609 useItems(filterValue) { 32610 const users = (0, import_data68.useSelect)( 32611 (select5) => { 32612 const { getUsers } = select5(import_core_data49.store); 32613 return getUsers({ 32614 context: "view", 32615 search: encodeURIComponent(filterValue) 32616 }); 32617 }, 32618 [filterValue] 32619 ); 32620 const options = (0, import_element73.useMemo)( 32621 () => users ? users.map((user) => ({ 32622 key: `user-$user.slug}`, 32623 value: user, 32624 label: getUserLabel(user) 32625 })) : [], 32626 [users] 32627 ); 32628 return [options]; 32629 }, 32630 getOptionCompletion(user) { 32631 return `@$user.slug}`; 32632 } 32633 }; 32634 32635 // packages/editor/build-module/components/autosave-monitor/index.js 32636 var import_element74 = __toESM(require_element()); 32637 var import_compose17 = __toESM(require_compose()); 32638 var import_data69 = __toESM(require_data()); 32639 var import_core_data50 = __toESM(require_core_data()); 32640 var AutosaveMonitor = class extends import_element74.Component { 32641 constructor(props) { 32642 super(props); 32643 this.needsAutosave = !!(props.isDirty && props.isAutosaveable); 32644 } 32645 componentDidMount() { 32646 if (!this.props.disableIntervalChecks) { 32647 this.setAutosaveTimer(); 32648 } 32649 } 32650 componentDidUpdate(prevProps) { 32651 if (this.props.disableIntervalChecks) { 32652 if (this.props.editsReference !== prevProps.editsReference) { 32653 this.props.autosave(); 32654 } 32655 return; 32656 } 32657 if (this.props.interval !== prevProps.interval) { 32658 clearTimeout(this.timerId); 32659 this.setAutosaveTimer(); 32660 } 32661 if (!this.props.isDirty) { 32662 this.needsAutosave = false; 32663 return; 32664 } 32665 if (this.props.isAutosaving && !prevProps.isAutosaving) { 32666 this.needsAutosave = false; 32667 return; 32668 } 32669 if (this.props.editsReference !== prevProps.editsReference) { 32670 this.needsAutosave = true; 32671 } 32672 } 32673 componentWillUnmount() { 32674 clearTimeout(this.timerId); 32675 } 32676 setAutosaveTimer(timeout = this.props.interval * 1e3) { 32677 this.timerId = setTimeout(() => { 32678 this.autosaveTimerHandler(); 32679 }, timeout); 32680 } 32681 autosaveTimerHandler() { 32682 if (!this.props.isAutosaveable) { 32683 this.setAutosaveTimer(1e3); 32684 return; 32685 } 32686 if (this.needsAutosave) { 32687 this.needsAutosave = false; 32688 this.props.autosave(); 32689 } 32690 this.setAutosaveTimer(); 32691 } 32692 render() { 32693 return null; 32694 } 32695 }; 32696 var autosave_monitor_default = (0, import_compose17.compose)([ 32697 (0, import_data69.withSelect)((select5, ownProps) => { 32698 const { getReferenceByDistinctEdits } = select5(import_core_data50.store); 32699 const { 32700 isEditedPostDirty: isEditedPostDirty2, 32701 isEditedPostAutosaveable: isEditedPostAutosaveable2, 32702 isAutosavingPost: isAutosavingPost2, 32703 getEditorSettings: getEditorSettings2 32704 } = select5(store); 32705 const { interval = getEditorSettings2().autosaveInterval } = ownProps; 32706 return { 32707 editsReference: getReferenceByDistinctEdits(), 32708 isDirty: isEditedPostDirty2(), 32709 isAutosaveable: isEditedPostAutosaveable2(), 32710 isAutosaving: isAutosavingPost2(), 32711 interval 32712 }; 32713 }), 32714 (0, import_data69.withDispatch)((dispatch6, ownProps) => ({ 32715 autosave() { 32716 const { autosave: autosave2 = dispatch6(store).autosave } = ownProps; 32717 autosave2(); 32718 } 32719 })) 32720 ])(AutosaveMonitor); 32721 32722 // packages/editor/build-module/components/document-bar/index.js 32723 var import_i18n115 = __toESM(require_i18n()); 32724 var import_data77 = __toESM(require_data()); 32725 var import_components98 = __toESM(require_components()); 32726 var import_block_editor41 = __toESM(require_block_editor()); 32727 var import_keycodes7 = __toESM(require_keycodes()); 32728 var import_core_data54 = __toESM(require_core_data()); 32729 var import_commands3 = __toESM(require_commands()); 32730 var import_element81 = __toESM(require_element()); 32731 var import_compose19 = __toESM(require_compose()); 32732 var import_html_entities11 = __toESM(require_html_entities()); 32733 var import_dom = __toESM(require_dom()); 32734 32735 // packages/editor/build-module/utils/pageTypeBadge.js 32736 var import_i18n109 = __toESM(require_i18n()); 32737 var import_data70 = __toESM(require_data()); 32738 var import_core_data51 = __toESM(require_core_data()); 32739 function usePageTypeBadge(postId2) { 32740 const { isFrontPage, isPostsPage } = (0, import_data70.useSelect)((select5) => { 32741 const { canUser, getEditedEntityRecord } = select5(import_core_data51.store); 32742 const siteSettings = canUser("read", { 32743 kind: "root", 32744 name: "site" 32745 }) ? getEditedEntityRecord("root", "site") : void 0; 32746 const _postId = parseInt(postId2, 10); 32747 return { 32748 isFrontPage: siteSettings?.page_on_front === _postId, 32749 isPostsPage: siteSettings?.page_for_posts === _postId 32750 }; 32751 }); 32752 if (isFrontPage) { 32753 return (0, import_i18n109.__)("Homepage"); 32754 } else if (isPostsPage) { 32755 return (0, import_i18n109.__)("Posts Page"); 32756 } 32757 return false; 32758 } 32759 32760 // packages/editor/build-module/components/styles-canvas/index.js 32761 var import_components97 = __toESM(require_components()); 32762 var import_keycodes6 = __toESM(require_keycodes()); 32763 var import_i18n114 = __toESM(require_i18n()); 32764 var import_data75 = __toESM(require_data()); 32765 var import_compose18 = __toESM(require_compose()); 32766 var import_preferences11 = __toESM(require_preferences()); 32767 32768 // packages/editor/build-module/components/styles-canvas/style-book.js 32769 var import_element78 = __toESM(require_element()); 32770 32771 // packages/editor/build-module/components/style-book/index.js 32772 var import_components93 = __toESM(require_components()); 32773 var import_i18n112 = __toESM(require_i18n()); 32774 var import_block_editor38 = __toESM(require_block_editor()); 32775 var import_data73 = __toESM(require_data()); 32776 var import_element77 = __toESM(require_element()); 32777 var import_keycodes4 = __toESM(require_keycodes()); 32778 var import_media_utils5 = __toESM(require_media_utils()); 32779 var import_core_data52 = __toESM(require_core_data()); 32780 32781 // packages/editor/build-module/components/style-book/constants.js 32782 var import_i18n110 = __toESM(require_i18n()); 32783 var STYLE_BOOK_COLOR_GROUPS = [ 32784 { 32785 slug: "theme-colors", 32786 title: (0, import_i18n110.__)("Theme Colors"), 32787 origin: "theme", 32788 type: "colors" 32789 }, 32790 { 32791 slug: "theme-gradients", 32792 title: (0, import_i18n110.__)("Theme Gradients"), 32793 origin: "theme", 32794 type: "gradients" 32795 }, 32796 { 32797 slug: "custom-colors", 32798 title: (0, import_i18n110.__)("Custom Colors"), 32799 origin: "custom", 32800 type: "colors" 32801 }, 32802 { 32803 slug: "custom-gradients", 32804 title: (0, import_i18n110.__)("Custom Gradients"), 32805 origin: "custom", 32806 // User. 32807 type: "gradients" 32808 }, 32809 { 32810 slug: "duotones", 32811 title: (0, import_i18n110.__)("Duotones"), 32812 origin: "theme", 32813 type: "duotones" 32814 }, 32815 { 32816 slug: "default-colors", 32817 title: (0, import_i18n110.__)("Default Colors"), 32818 origin: "default", 32819 type: "colors" 32820 }, 32821 { 32822 slug: "default-gradients", 32823 title: (0, import_i18n110.__)("Default Gradients"), 32824 origin: "default", 32825 type: "gradients" 32826 } 32827 ]; 32828 var STYLE_BOOK_THEME_SUBCATEGORIES = [ 32829 { 32830 slug: "site-identity", 32831 title: (0, import_i18n110.__)("Site Identity"), 32832 blocks: ["core/site-logo", "core/site-title", "core/site-tagline"] 32833 }, 32834 { 32835 slug: "design", 32836 title: (0, import_i18n110.__)("Design"), 32837 blocks: ["core/navigation", "core/avatar", "core/post-time-to-read"], 32838 exclude: ["core/home-link", "core/navigation-link"] 32839 }, 32840 { 32841 slug: "posts", 32842 title: (0, import_i18n110.__)("Posts"), 32843 blocks: [ 32844 "core/post-title", 32845 "core/post-excerpt", 32846 "core/post-author", 32847 "core/post-author-name", 32848 "core/post-author-biography", 32849 "core/post-date", 32850 "core/post-terms", 32851 "core/term-description", 32852 "core/query-title", 32853 "core/query-no-results", 32854 "core/query-pagination", 32855 "core/query-numbers" 32856 ] 32857 }, 32858 { 32859 slug: "comments", 32860 title: (0, import_i18n110.__)("Comments"), 32861 blocks: [ 32862 "core/comments-title", 32863 "core/comments-pagination", 32864 "core/comments-pagination-numbers", 32865 "core/comments", 32866 "core/comments-author-name", 32867 "core/comment-content", 32868 "core/comment-date", 32869 "core/comment-edit-link", 32870 "core/comment-reply-link", 32871 "core/comment-template", 32872 "core/post-comments-count", 32873 "core/post-comments-link" 32874 ] 32875 } 32876 ]; 32877 var STYLE_BOOK_CATEGORIES = [ 32878 { 32879 slug: "overview", 32880 title: (0, import_i18n110.__)("Overview"), 32881 blocks: [] 32882 }, 32883 { 32884 slug: "text", 32885 title: (0, import_i18n110.__)("Text"), 32886 blocks: [ 32887 "core/post-content", 32888 "core/home-link", 32889 "core/navigation-link" 32890 ] 32891 }, 32892 { 32893 slug: "colors", 32894 title: (0, import_i18n110.__)("Colors"), 32895 blocks: [] 32896 }, 32897 { 32898 slug: "theme", 32899 title: (0, import_i18n110.__)("Theme"), 32900 subcategories: STYLE_BOOK_THEME_SUBCATEGORIES 32901 }, 32902 { 32903 slug: "media", 32904 title: (0, import_i18n110.__)("Media"), 32905 blocks: ["core/post-featured-image"] 32906 }, 32907 { 32908 slug: "widgets", 32909 title: (0, import_i18n110.__)("Widgets"), 32910 blocks: [] 32911 }, 32912 { 32913 slug: "embed", 32914 title: (0, import_i18n110.__)("Embeds"), 32915 include: [] 32916 } 32917 ]; 32918 var STYLE_BOOK_ALL_BLOCKS_SUBCATEGORIES = [ 32919 ...STYLE_BOOK_THEME_SUBCATEGORIES, 32920 { 32921 slug: "media", 32922 title: (0, import_i18n110.__)("Media"), 32923 blocks: ["core/post-featured-image"] 32924 }, 32925 { 32926 slug: "widgets", 32927 title: (0, import_i18n110.__)("Widgets"), 32928 blocks: [] 32929 }, 32930 { 32931 slug: "embed", 32932 title: (0, import_i18n110.__)("Embeds"), 32933 include: [] 32934 } 32935 ]; 32936 var STYLE_BOOK_PREVIEW_CATEGORIES = [ 32937 { 32938 slug: "overview", 32939 title: (0, import_i18n110.__)("Overview"), 32940 blocks: [] 32941 }, 32942 { 32943 slug: "text", 32944 title: (0, import_i18n110.__)("Text"), 32945 blocks: [ 32946 "core/post-content", 32947 "core/home-link", 32948 "core/navigation-link" 32949 ] 32950 }, 32951 { 32952 slug: "colors", 32953 title: (0, import_i18n110.__)("Colors"), 32954 blocks: [] 32955 }, 32956 { 32957 slug: "blocks", 32958 title: (0, import_i18n110.__)("All Blocks"), 32959 blocks: [], 32960 subcategories: STYLE_BOOK_ALL_BLOCKS_SUBCATEGORIES 32961 } 32962 ]; 32963 var ROOT_CONTAINER = ` 32964 .is-root-container { 32965 display: flow-root; 32966 } 32967 `; 32968 var STYLE_BOOK_IFRAME_STYLES = ` 32969 body { 32970 position: relative; 32971 padding: 32px !important; 32972 } 32973 32974 $ROOT_CONTAINER} 32975 32976 .editor-style-book__examples { 32977 max-width: 1200px; 32978 margin: 0 auto; 32979 } 32980 32981 .editor-style-book__example { 32982 max-width: 900px; 32983 border-radius: 2px; 32984 cursor: pointer; 32985 display: flex; 32986 flex-direction: column; 32987 gap: 40px; 32988 padding: 16px; 32989 width: 100%; 32990 box-sizing: border-box; 32991 scroll-margin-top: 32px; 32992 scroll-margin-bottom: 32px; 32993 margin: 0 auto 40px auto; 32994 } 32995 32996 .editor-style-book__example.is-selected { 32997 box-shadow: 0 0 0 1px var(--wp-components-color-accent, var(--wp-admin-theme-color, #007cba)); 32998 } 32999 33000 .editor-style-book__example.is-disabled-example { 33001 pointer-events: none; 33002 } 33003 33004 .editor-style-book__example:focus:not(:disabled) { 33005 box-shadow: 0 0 0 var(--wp-admin-border-width-focus) var(--wp-components-color-accent, var(--wp-admin-theme-color, #007cba)); 33006 outline: 3px solid transparent; 33007 } 33008 33009 .editor-style-book__duotone-example > div:first-child { 33010 display: flex; 33011 aspect-ratio: 16 / 9; 33012 grid-row: span 1; 33013 grid-column: span 2; 33014 } 33015 .editor-style-book__duotone-example img { 33016 width: 100%; 33017 height: 100%; 33018 object-fit: cover; 33019 } 33020 .editor-style-book__duotone-example > div:not(:first-child) { 33021 height: 20px; 33022 border: 1px solid color-mix( in srgb, currentColor 10%, transparent ); 33023 } 33024 33025 .editor-style-book__color-example { 33026 border: 1px solid color-mix( in srgb, currentColor 10%, transparent ); 33027 } 33028 33029 .editor-style-book__subcategory-title, 33030 .editor-style-book__example-title { 33031 font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; 33032 font-size: 13px; 33033 font-weight: normal; 33034 line-height: normal; 33035 margin: 0; 33036 text-align: left; 33037 padding-top: 8px; 33038 border-top: 1px solid color-mix( in srgb, currentColor 10%, transparent ); 33039 color: color-mix( in srgb, currentColor 60%, transparent ); 33040 } 33041 33042 .editor-style-book__subcategory-title { 33043 font-size: 16px; 33044 margin-bottom: 40px; 33045 padding-bottom: 8px; 33046 } 33047 33048 .editor-style-book__example-preview { 33049 width: 100%; 33050 } 33051 33052 .editor-style-book__example-preview .block-editor-block-list__insertion-point, 33053 .editor-style-book__example-preview .block-list-appender { 33054 display: none; 33055 } 33056 :where(.is-root-container > .wp-block:first-child) { 33057 margin-top: 0; 33058 } 33059 :where(.is-root-container > .wp-block:last-child) { 33060 margin-bottom: 0; 33061 } 33062 `; 33063 33064 // packages/editor/build-module/components/style-book/categories.js 33065 var import_blocks20 = __toESM(require_blocks()); 33066 function getExamplesByCategory(categoryDefinition, examples) { 33067 if (!categoryDefinition?.slug || !examples?.length) { 33068 return; 33069 } 33070 const categories = categoryDefinition?.subcategories ?? []; 33071 if (categories.length) { 33072 return categories.reduce( 33073 (acc, subcategoryDefinition) => { 33074 const subcategoryExamples = getExamplesByCategory( 33075 subcategoryDefinition, 33076 examples 33077 ); 33078 if (subcategoryExamples) { 33079 if (!acc.subcategories) { 33080 acc.subcategories = []; 33081 } 33082 acc.subcategories = [ 33083 ...acc.subcategories, 33084 subcategoryExamples 33085 ]; 33086 } 33087 return acc; 33088 }, 33089 { 33090 title: categoryDefinition.title, 33091 slug: categoryDefinition.slug 33092 } 33093 ); 33094 } 33095 const blocksToInclude = categoryDefinition?.blocks || []; 33096 const blocksToExclude = categoryDefinition?.exclude || []; 33097 const categoryExamples = examples.filter((example) => { 33098 return !blocksToExclude.includes(example.name) && (example.category === categoryDefinition.slug || blocksToInclude.includes(example.name)); 33099 }); 33100 if (!categoryExamples.length) { 33101 return; 33102 } 33103 return { 33104 title: categoryDefinition.title, 33105 slug: categoryDefinition.slug, 33106 examples: categoryExamples 33107 }; 33108 } 33109 function getTopLevelStyleBookCategories() { 33110 const reservedCategories = [ 33111 ...STYLE_BOOK_THEME_SUBCATEGORIES, 33112 ...STYLE_BOOK_CATEGORIES 33113 ].map(({ slug }) => slug); 33114 const extraCategories = (0, import_blocks20.getCategories)(); 33115 const extraCategoriesFiltered = extraCategories.filter( 33116 ({ slug }) => !reservedCategories.includes(slug) 33117 ); 33118 return [...STYLE_BOOK_CATEGORIES, ...extraCategoriesFiltered]; 33119 } 33120 33121 // packages/editor/build-module/components/style-book/examples.js 33122 var import_i18n111 = __toESM(require_i18n()); 33123 var import_blocks21 = __toESM(require_blocks()); 33124 33125 // packages/editor/build-module/components/style-book/color-examples.js 33126 var import_components91 = __toESM(require_components()); 33127 var import_block_editor37 = __toESM(require_block_editor()); 33128 var import_jsx_runtime187 = __toESM(require_jsx_runtime()); 33129 var ColorExamples = ({ 33130 colors, 33131 type, 33132 templateColumns = "1fr 1fr", 33133 itemHeight = "52px" 33134 }) => { 33135 if (!colors) { 33136 return null; 33137 } 33138 return /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(import_components91.__experimentalGrid, { templateColumns, rowGap: 8, columnGap: 16, children: colors.map((color) => { 33139 const className = type === "gradients" ? (0, import_block_editor37.__experimentalGetGradientClass)(color.slug) : (0, import_block_editor37.getColorClassName)("background-color", color.slug); 33140 const classes = clsx_default( 33141 "editor-style-book__color-example", 33142 className 33143 ); 33144 return /* @__PURE__ */ (0, import_jsx_runtime187.jsx)( 33145 "div", 33146 { 33147 className: classes, 33148 style: { height: itemHeight } 33149 }, 33150 color.slug 33151 ); 33152 }) }); 33153 }; 33154 var color_examples_default = ColorExamples; 33155 33156 // packages/editor/build-module/components/style-book/duotone-examples.js 33157 var import_components92 = __toESM(require_components()); 33158 var import_jsx_runtime188 = __toESM(require_jsx_runtime()); 33159 var DuotoneExamples = ({ 33160 duotones 33161 }) => { 33162 if (!duotones) { 33163 return null; 33164 } 33165 return /* @__PURE__ */ (0, import_jsx_runtime188.jsx)(import_components92.__experimentalGrid, { columns: 2, rowGap: 16, columnGap: 16, children: duotones.map((duotone) => { 33166 return /* @__PURE__ */ (0, import_jsx_runtime188.jsxs)( 33167 import_components92.__experimentalGrid, 33168 { 33169 className: "editor-style-book__duotone-example", 33170 columns: 2, 33171 rowGap: 8, 33172 columnGap: 8, 33173 children: [ 33174 /* @__PURE__ */ (0, import_jsx_runtime188.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime188.jsx)( 33175 "img", 33176 { 33177 alt: `Duotone example: $duotone.slug}`, 33178 src: "https://s.w.org/images/core/5.3/MtBlanc1.jpg", 33179 style: { 33180 filter: `url(#wp-duotone-$duotone.slug})` 33181 } 33182 } 33183 ) }), 33184 duotone.colors.map((color) => { 33185 return /* @__PURE__ */ (0, import_jsx_runtime188.jsx)( 33186 "div", 33187 { 33188 className: "editor-style-book__color-example", 33189 style: { backgroundColor: color } 33190 }, 33191 color 33192 ); 33193 }) 33194 ] 33195 }, 33196 duotone.slug 33197 ); 33198 }) }); 33199 }; 33200 var duotone_examples_default = DuotoneExamples; 33201 33202 // packages/editor/build-module/components/style-book/examples.js 33203 var import_jsx_runtime189 = __toESM(require_jsx_runtime()); 33204 function getColorExamples(colors) { 33205 if (!colors) { 33206 return []; 33207 } 33208 const examples = []; 33209 STYLE_BOOK_COLOR_GROUPS.forEach((group) => { 33210 const palette = colors[group.type]; 33211 const paletteFiltered = Array.isArray(palette) ? palette.find( 33212 (origin) => origin.slug === group.origin 33213 ) : void 0; 33214 if (paletteFiltered?.[group.type]) { 33215 const example = { 33216 name: group.slug, 33217 title: group.title, 33218 category: "colors" 33219 }; 33220 if (group.type === "duotones") { 33221 example.content = /* @__PURE__ */ (0, import_jsx_runtime189.jsx)( 33222 duotone_examples_default, 33223 { 33224 duotones: paletteFiltered[group.type] 33225 } 33226 ); 33227 examples.push(example); 33228 } else { 33229 example.content = /* @__PURE__ */ (0, import_jsx_runtime189.jsx)( 33230 color_examples_default, 33231 { 33232 colors: paletteFiltered[group.type], 33233 type: group.type 33234 } 33235 ); 33236 examples.push(example); 33237 } 33238 } 33239 }); 33240 return examples; 33241 } 33242 function getOverviewBlockExamples(colors) { 33243 const examples = []; 33244 const themePalette = Array.isArray(colors?.colors) ? colors.colors.find( 33245 (origin) => origin.slug === "theme" 33246 ) : void 0; 33247 if (themePalette) { 33248 const themeColorexample = { 33249 name: "theme-colors", 33250 title: (0, import_i18n111.__)("Colors"), 33251 category: "overview", 33252 content: /* @__PURE__ */ (0, import_jsx_runtime189.jsx)( 33253 color_examples_default, 33254 { 33255 colors: themePalette.colors, 33256 type: "colors", 33257 templateColumns: "repeat(auto-fill, minmax( 200px, 1fr ))", 33258 itemHeight: "32px" 33259 } 33260 ) 33261 }; 33262 examples.push(themeColorexample); 33263 } 33264 const typographyBlockExamples = []; 33265 if ((0, import_blocks21.getBlockType)("core/heading")) { 33266 const headingBlock = (0, import_blocks21.createBlock)("core/heading", { 33267 // translators: Typography example. Your local alphabet, numbers and some common special characters. 33268 content: (0, import_i18n111.__)( 33269 `AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz0123456789X{(\u2026)},.-<>?!*&:/A@HELFO\u2122\xA9` 33270 ), 33271 level: 1 33272 }); 33273 typographyBlockExamples.push(headingBlock); 33274 } 33275 if ((0, import_blocks21.getBlockType)("core/paragraph")) { 33276 const firstParagraphBlock = (0, import_blocks21.createBlock)("core/paragraph", { 33277 content: (0, import_i18n111.__)( 33278 `A paragraph in a website refers to a distinct block of text that is used to present and organize information. It is a fundamental unit of content in web design and is typically composed of a group of related sentences or thoughts focused on a particular topic or idea. Paragraphs play a crucial role in improving the readability and user experience of a website. They break down the text into smaller, manageable chunks, allowing readers to scan the content more easily.` 33279 ) 33280 }); 33281 const secondParagraphBlock = (0, import_blocks21.createBlock)("core/paragraph", { 33282 content: (0, import_i18n111.__)( 33283 `Additionally, paragraphs help structure the flow of information and provide logical breaks between different concepts or pieces of information. In terms of formatting, paragraphs in websites are commonly denoted by a vertical gap or indentation between each block of text. This visual separation helps visually distinguish one paragraph from another, creating a clear and organized layout that guides the reader through the content smoothly.` 33284 ) 33285 }); 33286 if ((0, import_blocks21.getBlockType)("core/group")) { 33287 const groupBlock = (0, import_blocks21.createBlock)( 33288 "core/group", 33289 { 33290 layout: { 33291 type: "grid", 33292 columnCount: 2, 33293 minimumColumnWidth: "12rem" 33294 }, 33295 style: { 33296 spacing: { 33297 blockGap: "1.5rem" 33298 } 33299 } 33300 }, 33301 [firstParagraphBlock, secondParagraphBlock] 33302 ); 33303 typographyBlockExamples.push(groupBlock); 33304 } else { 33305 typographyBlockExamples.push(firstParagraphBlock); 33306 } 33307 } 33308 if (!!typographyBlockExamples.length) { 33309 examples.push({ 33310 name: "typography", 33311 title: (0, import_i18n111.__)("Typography"), 33312 category: "overview", 33313 blocks: typographyBlockExamples 33314 }); 33315 } 33316 const otherBlockExamples = [ 33317 "core/image", 33318 "core/separator", 33319 "core/buttons", 33320 "core/quote", 33321 "core/search" 33322 ]; 33323 otherBlockExamples.forEach((blockName) => { 33324 const blockType = (0, import_blocks21.getBlockType)(blockName); 33325 if (blockType && blockType.example) { 33326 const blockExample = { 33327 name: blockName, 33328 title: blockType.title, 33329 category: "overview", 33330 /* 33331 * CSS generated from style attributes will take precedence over global styles CSS, 33332 * so remove the style attribute from the example to ensure the example 33333 * demonstrates changes to global styles. 33334 */ 33335 blocks: (0, import_blocks21.getBlockFromExample)(blockName, { 33336 ...blockType.example, 33337 attributes: { 33338 ...blockType.example.attributes, 33339 style: void 0 33340 } 33341 }) 33342 }; 33343 examples.push(blockExample); 33344 } 33345 }); 33346 return examples; 33347 } 33348 function getExamples(colors) { 33349 const nonHeadingBlockExamples = (0, import_blocks21.getBlockTypes)().filter((blockType) => { 33350 const { name: name2, example, supports } = blockType; 33351 return name2 !== "core/heading" && !!example && supports?.inserter !== false; 33352 }).map((blockType) => ({ 33353 name: blockType.name, 33354 title: blockType.title, 33355 category: blockType.category, 33356 /* 33357 * CSS generated from style attributes will take precedence over global styles CSS, 33358 * so remove the style attribute from the example to ensure the example 33359 * demonstrates changes to global styles. 33360 */ 33361 blocks: (0, import_blocks21.getBlockFromExample)(blockType.name, { 33362 ...blockType.example, 33363 attributes: { 33364 ...blockType.example.attributes, 33365 style: void 0 33366 } 33367 }) 33368 })); 33369 const isHeadingBlockRegistered = !!(0, import_blocks21.getBlockType)("core/heading"); 33370 if (!isHeadingBlockRegistered) { 33371 return nonHeadingBlockExamples; 33372 } 33373 const headingsExample = { 33374 name: "core/heading", 33375 title: (0, import_i18n111.__)("Headings"), 33376 category: "text", 33377 blocks: [1, 2, 3, 4, 5, 6].map((level) => { 33378 return (0, import_blocks21.createBlock)("core/heading", { 33379 content: (0, import_i18n111.sprintf)( 33380 // translators: %d: heading level e.g: "1", "2", "3" 33381 (0, import_i18n111.__)("Heading %d"), 33382 level 33383 ), 33384 level 33385 }); 33386 }) 33387 }; 33388 const colorExamples = getColorExamples(colors); 33389 const overviewBlockExamples = getOverviewBlockExamples(colors); 33390 return [ 33391 headingsExample, 33392 ...colorExamples, 33393 ...nonHeadingBlockExamples, 33394 ...overviewBlockExamples 33395 ]; 33396 } 33397 33398 // packages/editor/build-module/components/global-styles-renderer/index.js 33399 var import_element76 = __toESM(require_element()); 33400 var import_data72 = __toESM(require_data()); 33401 33402 // packages/editor/build-module/hooks/use-global-styles-output.js 33403 var import_blocks22 = __toESM(require_blocks()); 33404 var import_data71 = __toESM(require_data()); 33405 var import_element75 = __toESM(require_element()); 33406 function useGlobalStylesOutputWithConfig(mergedConfig = {}, disableRootPadding = false) { 33407 const blockGap = useSetting2("spacing.blockGap"); 33408 const hasBlockGapSupport = blockGap !== null; 33409 const hasFallbackGapSupport = !hasBlockGapSupport; 33410 const { disableLayoutStyles, getBlockStyles } = (0, import_data71.useSelect)((select5) => { 33411 const { getEditorSettings: getEditorSettings2 } = select5(store); 33412 const { getBlockStyles: getBlockStylesSelector } = select5(import_blocks22.store); 33413 const settings = getEditorSettings2(); 33414 return { 33415 disableLayoutStyles: !!settings?.disableLayoutStyles, 33416 getBlockStyles: getBlockStylesSelector 33417 }; 33418 }, []); 33419 return (0, import_element75.useMemo)(() => { 33420 if (!mergedConfig?.styles || !mergedConfig?.settings) { 33421 return [[], {}]; 33422 } 33423 const blockTypes = (0, import_blocks22.getBlockTypes)(); 33424 return generateGlobalStyles(mergedConfig, blockTypes, { 33425 hasBlockGapSupport, 33426 hasFallbackGapSupport, 33427 disableLayoutStyles, 33428 disableRootPadding, 33429 getBlockStyles 33430 }); 33431 }, [ 33432 hasBlockGapSupport, 33433 hasFallbackGapSupport, 33434 mergedConfig, 33435 disableLayoutStyles, 33436 disableRootPadding, 33437 getBlockStyles 33438 ]); 33439 } 33440 function useGlobalStylesOutput(disableRootPadding = false) { 33441 const { merged: mergedConfig } = useGlobalStyles(); 33442 return useGlobalStylesOutputWithConfig(mergedConfig, disableRootPadding); 33443 } 33444 33445 // packages/editor/build-module/components/global-styles-renderer/index.js 33446 function useGlobalStylesRenderer(disableRootPadding) { 33447 const [styles, settings] = useGlobalStylesOutput(disableRootPadding); 33448 const { getEditorSettings: getEditorSettings2 } = (0, import_data72.useSelect)(store); 33449 const { updateEditorSettings: updateEditorSettings2 } = (0, import_data72.useDispatch)(store); 33450 (0, import_element76.useEffect)(() => { 33451 if (!styles || !settings) { 33452 return; 33453 } 33454 const currentStoreSettings = getEditorSettings2(); 33455 const nonGlobalStyles = Object.values( 33456 currentStoreSettings.styles ?? [] 33457 ).filter((style) => !style.isGlobalStyles); 33458 updateEditorSettings2({ 33459 ...currentStoreSettings, 33460 styles: [...nonGlobalStyles, ...styles], 33461 __experimentalFeatures: settings 33462 }); 33463 }, [styles, settings, updateEditorSettings2, getEditorSettings2]); 33464 } 33465 function GlobalStylesRenderer({ disableRootPadding }) { 33466 useGlobalStylesRenderer(disableRootPadding); 33467 return null; 33468 } 33469 33470 // packages/editor/build-module/components/style-book/index.js 33471 var import_jsx_runtime190 = __toESM(require_jsx_runtime()); 33472 var { ExperimentalBlockEditorProvider: ExperimentalBlockEditorProvider2 } = unlock(import_block_editor38.privateApis); 33473 var { Tabs: Tabs3 } = unlock(import_components93.privateApis); 33474 function isObjectEmpty(object) { 33475 return !object || Object.keys(object).length === 0; 33476 } 33477 var scrollToSection = (anchorId, iframe) => { 33478 if (!anchorId || !iframe || !iframe?.contentDocument) { 33479 return; 33480 } 33481 const element = anchorId === "top" ? iframe.contentDocument.body : iframe.contentDocument.getElementById(anchorId); 33482 if (element) { 33483 element.scrollIntoView({ 33484 behavior: "smooth" 33485 }); 33486 } 33487 }; 33488 var getStyleBookNavigationFromPath = (path) => { 33489 if (path && typeof path === "string") { 33490 if (path === "/" || path.startsWith("/typography") || path.startsWith("/colors") || path.startsWith("/blocks")) { 33491 return { 33492 top: true 33493 }; 33494 } 33495 } 33496 return null; 33497 }; 33498 function useMultiOriginPalettes() { 33499 const { colors, gradients } = (0, import_block_editor38.__experimentalUseMultipleOriginColorsAndGradients)(); 33500 const [ 33501 shouldDisplayDefaultDuotones, 33502 customDuotones, 33503 themeDuotones, 33504 defaultDuotones 33505 ] = (0, import_block_editor38.useSettings)( 33506 "color.defaultDuotone", 33507 "color.duotone.custom", 33508 "color.duotone.theme", 33509 "color.duotone.default" 33510 ); 33511 const palettes = (0, import_element77.useMemo)(() => { 33512 const result = { colors, gradients, duotones: [] }; 33513 if (themeDuotones && themeDuotones.length) { 33514 result.duotones.push({ 33515 name: (0, import_i18n112._x)( 33516 "Theme", 33517 "Indicates these duotone filters come from the theme." 33518 ), 33519 slug: "theme", 33520 duotones: themeDuotones 33521 }); 33522 } 33523 if (shouldDisplayDefaultDuotones && defaultDuotones && defaultDuotones.length) { 33524 result.duotones.push({ 33525 name: (0, import_i18n112._x)( 33526 "Default", 33527 "Indicates these duotone filters come from WordPress." 33528 ), 33529 slug: "default", 33530 duotones: defaultDuotones 33531 }); 33532 } 33533 if (customDuotones && customDuotones.length) { 33534 result.duotones.push({ 33535 name: (0, import_i18n112._x)( 33536 "Custom", 33537 "Indicates these doutone filters are created by the user." 33538 ), 33539 slug: "custom", 33540 duotones: customDuotones 33541 }); 33542 } 33543 return result; 33544 }, [ 33545 colors, 33546 gradients, 33547 customDuotones, 33548 themeDuotones, 33549 defaultDuotones, 33550 shouldDisplayDefaultDuotones 33551 ]); 33552 return palettes; 33553 } 33554 function getExamplesForSinglePageUse(examples) { 33555 const examplesForSinglePageUse = []; 33556 const overviewCategoryExamples = getExamplesByCategory( 33557 { slug: "overview" }, 33558 examples 33559 ); 33560 examplesForSinglePageUse.push(...overviewCategoryExamples.examples); 33561 const otherExamples = examples.filter((example) => { 33562 return example.category !== "overview" && !overviewCategoryExamples.examples.find( 33563 (overviewExample) => overviewExample.name === example.name 33564 ); 33565 }); 33566 examplesForSinglePageUse.push(...otherExamples); 33567 return examplesForSinglePageUse; 33568 } 33569 function applyBlockVariationsToExamples(examples, variation) { 33570 if (!variation) { 33571 return examples; 33572 } 33573 return examples.map((example) => { 33574 return { 33575 ...example, 33576 variation, 33577 blocks: Array.isArray(example.blocks) ? example.blocks.map((block) => ({ 33578 ...block, 33579 attributes: { 33580 ...block.attributes, 33581 style: void 0, 33582 className: `is-style-$variation}` 33583 } 33584 })) : { 33585 ...example.blocks, 33586 attributes: { 33587 ...example.blocks.attributes, 33588 style: void 0, 33589 className: `is-style-$variation}` 33590 } 33591 } 33592 }; 33593 }); 33594 } 33595 function StyleBook({ 33596 isSelected, 33597 onClick, 33598 onSelect, 33599 showTabs = true, 33600 userConfig = {}, 33601 path = "" 33602 }, ref) { 33603 const textColor = useStyle2("color.text"); 33604 const backgroundColor = useStyle2("color.background"); 33605 const colors = useMultiOriginPalettes(); 33606 const examples = (0, import_element77.useMemo)(() => getExamples(colors), [colors]); 33607 const tabs = (0, import_element77.useMemo)( 33608 () => getTopLevelStyleBookCategories().filter( 33609 (category) => examples.some( 33610 (example) => example.category === category.slug 33611 ) 33612 ), 33613 [examples] 33614 ); 33615 const examplesForSinglePageUse = getExamplesForSinglePageUse(examples); 33616 const { base: baseConfig } = useGlobalStyles(); 33617 const goTo = getStyleBookNavigationFromPath(path); 33618 const mergedConfig = (0, import_element77.useMemo)(() => { 33619 if (!isObjectEmpty(userConfig) && !isObjectEmpty(baseConfig)) { 33620 return mergeGlobalStyles(baseConfig, userConfig); 33621 } 33622 return {}; 33623 }, [baseConfig, userConfig]); 33624 const originalSettings = (0, import_data73.useSelect)( 33625 (select5) => select5(import_block_editor38.store).getSettings(), 33626 [] 33627 ); 33628 const [globalStyles] = useGlobalStylesOutputWithConfig(mergedConfig); 33629 const settings = (0, import_element77.useMemo)( 33630 () => ({ 33631 ...originalSettings, 33632 styles: !isObjectEmpty(globalStyles) && !isObjectEmpty(userConfig) ? globalStyles : originalSettings.styles, 33633 isPreviewMode: true 33634 }), 33635 [globalStyles, originalSettings, userConfig] 33636 ); 33637 return /* @__PURE__ */ (0, import_jsx_runtime190.jsx)( 33638 "div", 33639 { 33640 ref, 33641 className: clsx_default("editor-style-book", { 33642 "is-button": !!onClick 33643 }), 33644 style: { 33645 color: textColor, 33646 background: backgroundColor 33647 }, 33648 children: showTabs ? /* @__PURE__ */ (0, import_jsx_runtime190.jsxs)(Tabs3, { children: [ 33649 /* @__PURE__ */ (0, import_jsx_runtime190.jsx)("div", { className: "editor-style-book__tablist-container", children: /* @__PURE__ */ (0, import_jsx_runtime190.jsx)(Tabs3.TabList, { children: tabs.map((tab) => /* @__PURE__ */ (0, import_jsx_runtime190.jsx)(Tabs3.Tab, { tabId: tab.slug, children: tab.title }, tab.slug)) }) }), 33650 tabs.map((tab) => { 33651 const categoryDefinition = tab.slug ? getTopLevelStyleBookCategories().find( 33652 (_category) => _category.slug === tab.slug 33653 ) : null; 33654 const filteredExamples = categoryDefinition ? getExamplesByCategory( 33655 categoryDefinition, 33656 examples 33657 ) : { examples }; 33658 return /* @__PURE__ */ (0, import_jsx_runtime190.jsx)( 33659 Tabs3.TabPanel, 33660 { 33661 tabId: tab.slug, 33662 focusable: false, 33663 className: "editor-style-book__tabpanel", 33664 children: /* @__PURE__ */ (0, import_jsx_runtime190.jsx)( 33665 StyleBookBody, 33666 { 33667 category: tab.slug, 33668 examples: filteredExamples, 33669 isSelected, 33670 onSelect, 33671 settings, 33672 title: tab.title, 33673 goTo 33674 } 33675 ) 33676 }, 33677 tab.slug 33678 ); 33679 }) 33680 ] }) : /* @__PURE__ */ (0, import_jsx_runtime190.jsx)( 33681 StyleBookBody, 33682 { 33683 examples: { examples: examplesForSinglePageUse }, 33684 isSelected, 33685 onClick, 33686 onSelect, 33687 settings, 33688 goTo 33689 } 33690 ) 33691 } 33692 ); 33693 } 33694 var StyleBookPreview = ({ 33695 userConfig = {}, 33696 isStatic = false, 33697 path, 33698 onPathChange 33699 }) => { 33700 const editorSettings2 = (0, import_data73.useSelect)( 33701 (select5) => select5(store).getEditorSettings(), 33702 [] 33703 ); 33704 const canUserUploadMedia = (0, import_data73.useSelect)( 33705 (select5) => select5(import_core_data52.store).canUser("create", { 33706 kind: "postType", 33707 name: "attachment" 33708 }), 33709 [] 33710 ); 33711 (0, import_element77.useEffect)(() => { 33712 (0, import_data73.dispatch)(import_block_editor38.store).updateSettings({ 33713 ...editorSettings2, 33714 mediaUpload: canUserUploadMedia ? import_media_utils5.uploadMedia : void 0 33715 }); 33716 }, [editorSettings2, canUserUploadMedia]); 33717 const [internalPath, setInternalPath] = (0, import_element77.useState)("/"); 33718 const section = path ?? internalPath; 33719 const onChangeSection = onPathChange ?? setInternalPath; 33720 const isSelected = (blockName) => { 33721 return section === `/blocks/$encodeURIComponent(blockName)}` || section.startsWith( 33722 `/blocks/$encodeURIComponent(blockName)}/` 33723 ); 33724 }; 33725 const onSelect = (blockName, isBlockVariation = false) => { 33726 if (STYLE_BOOK_COLOR_GROUPS.find( 33727 (group) => group.slug === blockName 33728 )) { 33729 onChangeSection("/colors/palette"); 33730 return; 33731 } 33732 if (blockName === "typography") { 33733 onChangeSection("/typography"); 33734 return; 33735 } 33736 if (isBlockVariation) { 33737 return; 33738 } 33739 onChangeSection(`/blocks/$encodeURIComponent(blockName)}`); 33740 }; 33741 const colors = useMultiOriginPalettes(); 33742 const examples = getExamples(colors); 33743 const examplesForSinglePageUse = getExamplesForSinglePageUse(examples); 33744 let previewCategory = null; 33745 let blockVariation = null; 33746 if (section.includes("/colors")) { 33747 previewCategory = "colors"; 33748 } else if (section.includes("/typography")) { 33749 previewCategory = "text"; 33750 } else if (section.includes("/blocks")) { 33751 previewCategory = "blocks"; 33752 let blockName = decodeURIComponent(section).split("/blocks/")[1]; 33753 if (blockName?.includes("/variations")) { 33754 [blockName, blockVariation] = blockName.split("/variations/"); 33755 } 33756 if (blockName && examples.find((example) => example.name === blockName)) { 33757 previewCategory = blockName; 33758 } 33759 } else if (!isStatic) { 33760 previewCategory = "overview"; 33761 } 33762 const categoryDefinition = STYLE_BOOK_PREVIEW_CATEGORIES.find( 33763 (category) => category.slug === previewCategory 33764 ); 33765 const filteredExamples = (0, import_element77.useMemo)(() => { 33766 if (!categoryDefinition) { 33767 return { 33768 examples: [ 33769 examples.find( 33770 (example) => example.name === previewCategory 33771 ) 33772 ] 33773 }; 33774 } 33775 return getExamplesByCategory(categoryDefinition, examples); 33776 }, [categoryDefinition, examples, previewCategory]); 33777 const displayedExamples = (0, import_element77.useMemo)(() => { 33778 if (!previewCategory) { 33779 return { examples: examplesForSinglePageUse }; 33780 } 33781 if (blockVariation) { 33782 return { 33783 examples: applyBlockVariationsToExamples( 33784 filteredExamples.examples, 33785 blockVariation 33786 ) 33787 }; 33788 } 33789 return filteredExamples; 33790 }, [ 33791 previewCategory, 33792 examplesForSinglePageUse, 33793 blockVariation, 33794 filteredExamples 33795 ]); 33796 const { base: baseConfig } = useGlobalStyles(); 33797 const goTo = getStyleBookNavigationFromPath(section); 33798 const mergedConfig = (0, import_element77.useMemo)(() => { 33799 if (!isObjectEmpty(userConfig) && !isObjectEmpty(baseConfig)) { 33800 return mergeGlobalStyles(baseConfig, userConfig); 33801 } 33802 return {}; 33803 }, [baseConfig, userConfig]); 33804 const [globalStyles] = useGlobalStylesOutputWithConfig(mergedConfig); 33805 const settings = (0, import_element77.useMemo)( 33806 () => ({ 33807 ...editorSettings2, 33808 styles: !isObjectEmpty(globalStyles) && !isObjectEmpty(userConfig) ? globalStyles : editorSettings2.styles, 33809 isPreviewMode: true 33810 }), 33811 [globalStyles, editorSettings2, userConfig] 33812 ); 33813 return /* @__PURE__ */ (0, import_jsx_runtime190.jsx)("div", { className: "editor-style-book", children: /* @__PURE__ */ (0, import_jsx_runtime190.jsxs)(import_block_editor38.BlockEditorProvider, { settings, children: [ 33814 /* @__PURE__ */ (0, import_jsx_runtime190.jsx)(GlobalStylesRenderer, { disableRootPadding: true }), 33815 /* @__PURE__ */ (0, import_jsx_runtime190.jsx)( 33816 StyleBookBody, 33817 { 33818 examples: displayedExamples, 33819 settings, 33820 goTo, 33821 isSelected: !isStatic ? isSelected : null, 33822 onSelect: !isStatic ? onSelect : null 33823 } 33824 ) 33825 ] }) }); 33826 }; 33827 var StyleBookBody = ({ 33828 examples, 33829 isSelected, 33830 onClick, 33831 onSelect, 33832 settings, 33833 title, 33834 goTo 33835 }) => { 33836 const [isFocused, setIsFocused] = (0, import_element77.useState)(false); 33837 const [hasIframeLoaded, setHasIframeLoaded] = (0, import_element77.useState)(false); 33838 const iframeRef = (0, import_element77.useRef)(null); 33839 const buttonModeProps = { 33840 role: "button", 33841 onFocus: () => setIsFocused(true), 33842 onBlur: () => setIsFocused(false), 33843 onKeyDown: (event) => { 33844 if (event.defaultPrevented) { 33845 return; 33846 } 33847 const { keyCode } = event; 33848 if (onClick && (keyCode === import_keycodes4.ENTER || keyCode === import_keycodes4.SPACE)) { 33849 event.preventDefault(); 33850 onClick(event); 33851 } 33852 }, 33853 onClick: (event) => { 33854 if (event.defaultPrevented) { 33855 return; 33856 } 33857 if (onClick) { 33858 event.preventDefault(); 33859 onClick(event); 33860 } 33861 }, 33862 readonly: true 33863 }; 33864 const handleLoad = () => setHasIframeLoaded(true); 33865 (0, import_element77.useLayoutEffect)(() => { 33866 if (hasIframeLoaded && iframeRef.current && goTo?.top) { 33867 scrollToSection("top", iframeRef.current); 33868 } 33869 }, [goTo?.top, hasIframeLoaded]); 33870 return /* @__PURE__ */ (0, import_jsx_runtime190.jsxs)( 33871 import_block_editor38.__unstableIframe, 33872 { 33873 onLoad: handleLoad, 33874 ref: iframeRef, 33875 className: clsx_default("editor-style-book__iframe", { 33876 "is-focused": isFocused && !!onClick, 33877 "is-button": !!onClick 33878 }), 33879 name: "style-book-canvas", 33880 tabIndex: 0, 33881 ...onClick ? buttonModeProps : {}, 33882 children: [ 33883 /* @__PURE__ */ (0, import_jsx_runtime190.jsx)(import_block_editor38.__unstableEditorStyles, { styles: settings.styles }), 33884 /* @__PURE__ */ (0, import_jsx_runtime190.jsxs)("style", { children: [ 33885 STYLE_BOOK_IFRAME_STYLES, 33886 !!onClick && "body { cursor: pointer; } body * { pointer-events: none; }" 33887 ] }), 33888 /* @__PURE__ */ (0, import_jsx_runtime190.jsx)( 33889 Examples, 33890 { 33891 className: "editor-style-book__examples", 33892 filteredExamples: examples, 33893 label: title ? (0, import_i18n112.sprintf)( 33894 // translators: %s: Category of blocks, e.g. Text. 33895 (0, import_i18n112.__)("Examples of blocks in the %s category"), 33896 title 33897 ) : (0, import_i18n112.__)("Examples of blocks"), 33898 isSelected, 33899 onSelect 33900 }, 33901 title 33902 ) 33903 ] 33904 } 33905 ); 33906 }; 33907 var Examples = (0, import_element77.memo)( 33908 ({ className, filteredExamples, label, isSelected, onSelect }) => { 33909 return /* @__PURE__ */ (0, import_jsx_runtime190.jsxs)( 33910 import_components93.Composite, 33911 { 33912 orientation: "vertical", 33913 className, 33914 "aria-label": label, 33915 role: "grid", 33916 children: [ 33917 !!filteredExamples?.examples?.length && filteredExamples.examples.map((example) => /* @__PURE__ */ (0, import_jsx_runtime190.jsx)( 33918 Example, 33919 { 33920 id: `example-$example.name}`, 33921 title: example.title, 33922 content: example.content, 33923 blocks: example.blocks, 33924 isSelected: isSelected?.(example.name), 33925 onClick: !!onSelect ? () => onSelect( 33926 example.name, 33927 !!example.variation 33928 ) : null 33929 }, 33930 example.name 33931 )), 33932 !!filteredExamples?.subcategories?.length && filteredExamples.subcategories.map((subcategory) => /* @__PURE__ */ (0, import_jsx_runtime190.jsxs)( 33933 import_components93.Composite.Group, 33934 { 33935 className: "editor-style-book__subcategory", 33936 children: [ 33937 /* @__PURE__ */ (0, import_jsx_runtime190.jsx)(import_components93.Composite.GroupLabel, { children: /* @__PURE__ */ (0, import_jsx_runtime190.jsx)("h2", { className: "editor-style-book__subcategory-title", children: subcategory.title }) }), 33938 /* @__PURE__ */ (0, import_jsx_runtime190.jsx)( 33939 Subcategory, 33940 { 33941 examples: subcategory.examples, 33942 isSelected, 33943 onSelect 33944 } 33945 ) 33946 ] 33947 }, 33948 `subcategory-$subcategory.slug}` 33949 )) 33950 ] 33951 } 33952 ); 33953 } 33954 ); 33955 var Subcategory = ({ examples, isSelected, onSelect }) => { 33956 return !!examples?.length && examples.map((example) => /* @__PURE__ */ (0, import_jsx_runtime190.jsx)( 33957 Example, 33958 { 33959 id: `example-$example.name}`, 33960 title: example.title, 33961 content: example.content, 33962 blocks: example.blocks, 33963 isSelected: isSelected?.(example.name), 33964 onClick: !!onSelect ? () => onSelect(example.name) : null 33965 }, 33966 example.name 33967 )); 33968 }; 33969 var disabledExamples = ["example-duotones"]; 33970 var Example = ({ id, title, blocks, isSelected, onClick, content }) => { 33971 const originalSettings = (0, import_data73.useSelect)( 33972 (select5) => select5(import_block_editor38.store).getSettings(), 33973 [] 33974 ); 33975 const settings = (0, import_element77.useMemo)( 33976 () => ({ 33977 ...originalSettings, 33978 focusMode: false, 33979 // Disable "Spotlight mode". 33980 isPreviewMode: true 33981 }), 33982 [originalSettings] 33983 ); 33984 const renderedBlocks = (0, import_element77.useMemo)( 33985 () => Array.isArray(blocks) ? blocks : [blocks], 33986 [blocks] 33987 ); 33988 const disabledProps = disabledExamples.includes(id) || !onClick ? { 33989 disabled: true, 33990 accessibleWhenDisabled: !!onClick 33991 } : {}; 33992 return /* @__PURE__ */ (0, import_jsx_runtime190.jsx)("div", { role: "row", children: /* @__PURE__ */ (0, import_jsx_runtime190.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime190.jsxs)( 33993 import_components93.Composite.Item, 33994 { 33995 className: clsx_default("editor-style-book__example", { 33996 "is-selected": isSelected, 33997 "is-disabled-example": !!disabledProps?.disabled 33998 }), 33999 id, 34000 "aria-label": !!onClick ? (0, import_i18n112.sprintf)( 34001 // translators: %s: Title of a block, e.g. Heading. 34002 (0, import_i18n112.__)("Open %s styles in Styles panel"), 34003 title 34004 ) : void 0, 34005 render: /* @__PURE__ */ (0, import_jsx_runtime190.jsx)("div", {}), 34006 role: !!onClick ? "button" : null, 34007 onClick, 34008 ...disabledProps, 34009 children: [ 34010 /* @__PURE__ */ (0, import_jsx_runtime190.jsx)("span", { className: "editor-style-book__example-title", children: title }), 34011 /* @__PURE__ */ (0, import_jsx_runtime190.jsx)( 34012 "div", 34013 { 34014 className: "editor-style-book__example-preview", 34015 "aria-hidden": true, 34016 children: /* @__PURE__ */ (0, import_jsx_runtime190.jsx)(import_components93.Disabled, { className: "editor-style-book__example-preview__content", children: content ? content : /* @__PURE__ */ (0, import_jsx_runtime190.jsxs)( 34017 ExperimentalBlockEditorProvider2, 34018 { 34019 value: renderedBlocks, 34020 settings, 34021 children: [ 34022 /* @__PURE__ */ (0, import_jsx_runtime190.jsx)(import_block_editor38.__unstableEditorStyles, {}), 34023 /* @__PURE__ */ (0, import_jsx_runtime190.jsx)(import_block_editor38.BlockList, { renderAppender: false }) 34024 ] 34025 } 34026 ) }) 34027 } 34028 ) 34029 ] 34030 } 34031 ) }) }); 34032 }; 34033 var style_book_default = (0, import_element77.forwardRef)(StyleBook); 34034 34035 // packages/editor/build-module/components/styles-canvas/style-book.js 34036 var import_jsx_runtime191 = __toESM(require_jsx_runtime()); 34037 function StylesCanvasStyleBook({ path, onPathChange }, ref) { 34038 return /* @__PURE__ */ (0, import_jsx_runtime191.jsx)( 34039 style_book_default, 34040 { 34041 ref, 34042 isSelected: (blockName) => ( 34043 // Match '/blocks/core%2Fbutton' and 34044 // '/blocks/core%2Fbutton/typography', but not 34045 // '/blocks/core%2Fbuttons'. 34046 path === `/blocks/$encodeURIComponent(blockName)}` || path?.startsWith( 34047 `/blocks/$encodeURIComponent(blockName)}/` 34048 ) 34049 ), 34050 onSelect: (blockName) => { 34051 if (STYLE_BOOK_COLOR_GROUPS.find( 34052 (group) => group.slug === blockName 34053 )) { 34054 onPathChange?.("/colors/palette"); 34055 return; 34056 } 34057 if (blockName === "typography") { 34058 onPathChange?.("/typography"); 34059 return; 34060 } 34061 onPathChange?.("/blocks/" + encodeURIComponent(blockName)); 34062 } 34063 } 34064 ); 34065 } 34066 var style_book_default2 = (0, import_element78.forwardRef)(StylesCanvasStyleBook); 34067 34068 // packages/editor/build-module/components/styles-canvas/revisions.js 34069 var import_components94 = __toESM(require_components()); 34070 var import_block_editor39 = __toESM(require_block_editor()); 34071 var import_data74 = __toESM(require_data()); 34072 var import_element79 = __toESM(require_element()); 34073 var import_jsx_runtime192 = __toESM(require_jsx_runtime()); 34074 var { 34075 ExperimentalBlockEditorProvider: ExperimentalBlockEditorProvider3, 34076 __unstableBlockStyleVariationOverridesWithConfig 34077 } = unlock(import_block_editor39.privateApis); 34078 function isObjectEmpty2(object) { 34079 return !object || Object.keys(object).length === 0; 34080 } 34081 function StylesCanvasRevisions({ path }, ref) { 34082 const blocks = (0, import_data74.useSelect)((select5) => { 34083 return select5(import_block_editor39.store).getBlocks(); 34084 }, []); 34085 const { user: userConfig, base: baseConfig } = useGlobalStyles(); 34086 const { revisions, isLoading } = useGlobalStylesRevisions(); 34087 const revisionId = (0, import_element79.useMemo)(() => { 34088 const match2 = path?.match(/^\/revisions\/(.+)$/); 34089 return match2 ? match2[1] : null; 34090 }, [path]); 34091 const selectedRevision = (0, import_element79.useMemo)(() => { 34092 if (!revisionId || !revisions.length) { 34093 return null; 34094 } 34095 return revisions.find( 34096 (rev) => String(rev.id) === String(revisionId) 34097 ); 34098 }, [revisionId, revisions]); 34099 const displayConfig = selectedRevision || userConfig; 34100 const mergedConfig = (0, import_element79.useMemo)(() => { 34101 if (!isObjectEmpty2(displayConfig) && !isObjectEmpty2(baseConfig)) { 34102 return mergeGlobalStyles(baseConfig, displayConfig); 34103 } 34104 return {}; 34105 }, [baseConfig, displayConfig]); 34106 const renderedBlocksArray = (0, import_element79.useMemo)( 34107 () => Array.isArray(blocks) ? blocks : [blocks], 34108 [blocks] 34109 ); 34110 const originalSettings = (0, import_data74.useSelect)( 34111 (select5) => select5(import_block_editor39.store).getSettings(), 34112 [] 34113 ); 34114 const settings = (0, import_element79.useMemo)( 34115 () => ({ 34116 ...originalSettings, 34117 isPreviewMode: true 34118 }), 34119 [originalSettings] 34120 ); 34121 const [globalStyles] = useGlobalStylesOutputWithConfig(mergedConfig); 34122 const editorStyles = !isObjectEmpty2(globalStyles) && !isObjectEmpty2(displayConfig) ? globalStyles : settings.styles; 34123 if (isLoading) { 34124 return null; 34125 } 34126 return /* @__PURE__ */ (0, import_jsx_runtime192.jsxs)( 34127 import_block_editor39.__unstableIframe, 34128 { 34129 ref, 34130 className: "editor-revisions__iframe", 34131 name: "revisions", 34132 tabIndex: 0, 34133 children: [ 34134 /* @__PURE__ */ (0, import_jsx_runtime192.jsx)("style", { 34135 // Forming a "block formatting context" to prevent margin collapsing. 34136 // @see https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Block_formatting_context 34137 children: `.is-root-container { display: flow-root; }` 34138 }), 34139 /* @__PURE__ */ (0, import_jsx_runtime192.jsx)(import_components94.Disabled, { className: "editor-revisions__example-preview__content", children: /* @__PURE__ */ (0, import_jsx_runtime192.jsxs)( 34140 ExperimentalBlockEditorProvider3, 34141 { 34142 value: renderedBlocksArray, 34143 settings, 34144 children: [ 34145 /* @__PURE__ */ (0, import_jsx_runtime192.jsx)(import_block_editor39.BlockList, { renderAppender: false }), 34146 /* @__PURE__ */ (0, import_jsx_runtime192.jsx)(import_block_editor39.__unstableEditorStyles, { styles: editorStyles }), 34147 /* @__PURE__ */ (0, import_jsx_runtime192.jsx)( 34148 __unstableBlockStyleVariationOverridesWithConfig, 34149 { 34150 config: mergedConfig 34151 } 34152 ) 34153 ] 34154 } 34155 ) }) 34156 ] 34157 } 34158 ); 34159 } 34160 var revisions_default = (0, import_element79.forwardRef)(StylesCanvasRevisions); 34161 34162 // packages/editor/build-module/components/resizable-editor/index.js 34163 var import_element80 = __toESM(require_element()); 34164 var import_components96 = __toESM(require_components()); 34165 34166 // packages/editor/build-module/components/resizable-editor/resize-handle.js 34167 var import_i18n113 = __toESM(require_i18n()); 34168 var import_keycodes5 = __toESM(require_keycodes()); 34169 var import_components95 = __toESM(require_components()); 34170 var import_jsx_runtime193 = __toESM(require_jsx_runtime()); 34171 var DELTA_DISTANCE = 20; 34172 function ResizeHandle({ direction, resizeWidthBy }) { 34173 function handleKeyDown(event) { 34174 const { keyCode } = event; 34175 if (keyCode !== import_keycodes5.LEFT && keyCode !== import_keycodes5.RIGHT) { 34176 return; 34177 } 34178 event.preventDefault(); 34179 if (direction === "left" && keyCode === import_keycodes5.LEFT || direction === "right" && keyCode === import_keycodes5.RIGHT) { 34180 resizeWidthBy(DELTA_DISTANCE); 34181 } else if (direction === "left" && keyCode === import_keycodes5.RIGHT || direction === "right" && keyCode === import_keycodes5.LEFT) { 34182 resizeWidthBy(-DELTA_DISTANCE); 34183 } 34184 } 34185 const resizeHandleVariants = { 34186 active: { 34187 opacity: 1, 34188 scaleY: 1.3 34189 } 34190 }; 34191 const resizableHandleHelpId = `resizable-editor__resize-help-$direction}`; 34192 return /* @__PURE__ */ (0, import_jsx_runtime193.jsxs)(import_jsx_runtime193.Fragment, { children: [ 34193 /* @__PURE__ */ (0, import_jsx_runtime193.jsx)(import_components95.Tooltip, { text: (0, import_i18n113.__)("Drag to resize"), children: /* @__PURE__ */ (0, import_jsx_runtime193.jsx)( 34194 import_components95.__unstableMotion.button, 34195 { 34196 className: `editor-resizable-editor__resize-handle is-$direction}`, 34197 "aria-label": (0, import_i18n113.__)("Drag to resize"), 34198 "aria-describedby": resizableHandleHelpId, 34199 onKeyDown: handleKeyDown, 34200 variants: resizeHandleVariants, 34201 whileFocus: "active", 34202 whileHover: "active", 34203 whileTap: "active", 34204 role: "separator", 34205 "aria-orientation": "vertical" 34206 }, 34207 "handle" 34208 ) }), 34209 /* @__PURE__ */ (0, import_jsx_runtime193.jsx)(import_components95.VisuallyHidden, { id: resizableHandleHelpId, children: (0, import_i18n113.__)("Use left and right arrow keys to resize the canvas.") }) 34210 ] }); 34211 } 34212 34213 // packages/editor/build-module/components/resizable-editor/index.js 34214 var import_jsx_runtime194 = __toESM(require_jsx_runtime()); 34215 var HANDLE_STYLES_OVERRIDE = { 34216 position: void 0, 34217 userSelect: void 0, 34218 cursor: void 0, 34219 width: void 0, 34220 height: void 0, 34221 top: void 0, 34222 right: void 0, 34223 bottom: void 0, 34224 left: void 0 34225 }; 34226 function ResizableEditor({ className, enableResizing, height, children }) { 34227 const [width, setWidth] = (0, import_element80.useState)("100%"); 34228 const resizableRef = (0, import_element80.useRef)(); 34229 const resizeWidthBy = (0, import_element80.useCallback)((deltaPixels) => { 34230 if (resizableRef.current) { 34231 setWidth(resizableRef.current.offsetWidth + deltaPixels); 34232 } 34233 }, []); 34234 return /* @__PURE__ */ (0, import_jsx_runtime194.jsx)( 34235 import_components96.ResizableBox, 34236 { 34237 className: clsx_default("editor-resizable-editor", className, { 34238 "is-resizable": enableResizing 34239 }), 34240 ref: (api) => { 34241 resizableRef.current = api?.resizable; 34242 }, 34243 size: { 34244 width: enableResizing ? width : "100%", 34245 height: enableResizing && height ? height : "100%" 34246 }, 34247 onResizeStop: (event, direction, element) => { 34248 setWidth(element.style.width); 34249 }, 34250 minWidth: 300, 34251 maxWidth: "100%", 34252 maxHeight: "100%", 34253 enable: { 34254 left: enableResizing, 34255 right: enableResizing 34256 }, 34257 showHandle: enableResizing, 34258 resizeRatio: 2, 34259 handleComponent: { 34260 left: /* @__PURE__ */ (0, import_jsx_runtime194.jsx)( 34261 ResizeHandle, 34262 { 34263 direction: "left", 34264 resizeWidthBy 34265 } 34266 ), 34267 right: /* @__PURE__ */ (0, import_jsx_runtime194.jsx)( 34268 ResizeHandle, 34269 { 34270 direction: "right", 34271 resizeWidthBy 34272 } 34273 ) 34274 }, 34275 handleClasses: void 0, 34276 handleStyles: { 34277 left: HANDLE_STYLES_OVERRIDE, 34278 right: HANDLE_STYLES_OVERRIDE 34279 }, 34280 children 34281 } 34282 ); 34283 } 34284 var resizable_editor_default = ResizableEditor; 34285 34286 // packages/editor/build-module/components/styles-canvas/index.js 34287 var import_jsx_runtime195 = __toESM(require_jsx_runtime()); 34288 function getStylesCanvasTitle(path, showStylebook2) { 34289 if (showStylebook2) { 34290 return (0, import_i18n114.__)("Style Book"); 34291 } 34292 if (path?.startsWith("/revisions")) { 34293 return (0, import_i18n114.__)("Style Revisions"); 34294 } 34295 return ""; 34296 } 34297 function StylesCanvas() { 34298 const { stylesPath: stylesPath2, showStylebook: showStylebook2, showListViewByDefault } = (0, import_data75.useSelect)( 34299 (select5) => { 34300 const { getStylesPath: getStylesPath2, getShowStylebook: getShowStylebook2 } = unlock( 34301 select5(store) 34302 ); 34303 const _showListViewByDefault = select5(import_preferences11.store).get( 34304 "core", 34305 "showListViewByDefault" 34306 ); 34307 return { 34308 stylesPath: getStylesPath2(), 34309 showStylebook: getShowStylebook2(), 34310 showListViewByDefault: _showListViewByDefault 34311 }; 34312 }, 34313 [] 34314 ); 34315 const { resetStylesNavigation: resetStylesNavigation2, setStylesPath: setStylesPath2 } = unlock( 34316 (0, import_data75.useDispatch)(store) 34317 ); 34318 const { setIsListViewOpened: setIsListViewOpened2 } = (0, import_data75.useDispatch)(store); 34319 const focusOnMountRef = (0, import_compose18.useFocusOnMount)("firstElement"); 34320 const sectionFocusReturnRef = (0, import_compose18.useFocusReturn)(); 34321 let content = null; 34322 if (showStylebook2) { 34323 content = /* @__PURE__ */ (0, import_jsx_runtime195.jsx)( 34324 style_book_default2, 34325 { 34326 path: stylesPath2, 34327 onPathChange: setStylesPath2, 34328 ref: sectionFocusReturnRef 34329 } 34330 ); 34331 } else if (stylesPath2?.startsWith("/revisions")) { 34332 content = /* @__PURE__ */ (0, import_jsx_runtime195.jsx)( 34333 revisions_default, 34334 { 34335 path: stylesPath2, 34336 ref: sectionFocusReturnRef 34337 } 34338 ); 34339 } 34340 const title = getStylesCanvasTitle(stylesPath2, showStylebook2); 34341 const onCloseCanvas = () => { 34342 setIsListViewOpened2(showListViewByDefault); 34343 resetStylesNavigation2(); 34344 }; 34345 const closeOnEscape = (event) => { 34346 if (event.keyCode === import_keycodes6.ESCAPE && !event.defaultPrevented) { 34347 event.preventDefault(); 34348 onCloseCanvas(); 34349 } 34350 }; 34351 return /* @__PURE__ */ (0, import_jsx_runtime195.jsx)("div", { className: "editor-styles-canvas", children: /* @__PURE__ */ (0, import_jsx_runtime195.jsx)(resizable_editor_default, { enableResizing: false, children: /* @__PURE__ */ (0, import_jsx_runtime195.jsxs)( 34352 "section", 34353 { 34354 className: "editor-styles-canvas__section", 34355 ref: focusOnMountRef, 34356 onKeyDown: closeOnEscape, 34357 "aria-label": title, 34358 children: [ 34359 /* @__PURE__ */ (0, import_jsx_runtime195.jsx)( 34360 import_components97.Button, 34361 { 34362 size: "compact", 34363 className: "editor-styles-canvas__close-button", 34364 icon: close_small_default, 34365 label: (0, import_i18n114.__)("Close"), 34366 onClick: onCloseCanvas 34367 } 34368 ), 34369 content 34370 ] 34371 } 34372 ) }) }); 34373 } 34374 34375 // packages/editor/build-module/components/document-bar/useEditedSectionDetails.js 34376 var import_data76 = __toESM(require_data()); 34377 var import_html_entities10 = __toESM(require_html_entities()); 34378 var import_block_editor40 = __toESM(require_block_editor()); 34379 var import_core_data53 = __toESM(require_core_data()); 34380 function useEditedSectionDetails() { 34381 return (0, import_data76.useSelect)((select5) => { 34382 if (!window?.__experimentalContentOnlyPatternInsertion) { 34383 return null; 34384 } 34385 const { 34386 getBlockAttributes: getBlockAttributes2, 34387 getBlockName: getBlockName2, 34388 __experimentalGetParsedPattern 34389 } = select5(import_block_editor40.store); 34390 const { getEditedEntityRecord, getCurrentTheme } = select5(import_core_data53.store); 34391 const { getEditedContentOnlySection } = unlock( 34392 select5(import_block_editor40.store) 34393 ); 34394 const editedSectionId = getEditedContentOnlySection(); 34395 if (!editedSectionId) { 34396 return null; 34397 } 34398 const attributes = getBlockAttributes2(editedSectionId); 34399 const patternName = attributes?.metadata?.patternName; 34400 if (patternName) { 34401 const pattern = typeof __experimentalGetParsedPattern === "function" ? __experimentalGetParsedPattern(patternName) : null; 34402 return { 34403 patternName, 34404 patternTitle: pattern?.title || attributes?.metadata?.name, 34405 type: "pattern" 34406 }; 34407 } 34408 const blockName = getBlockName2(editedSectionId); 34409 if (blockName === "core/block" && !!attributes?.ref) { 34410 const entity = getEditedEntityRecord( 34411 "postType", 34412 "wp_block", 34413 attributes.ref 34414 ); 34415 if (entity?.title) { 34416 return { 34417 patternName: attributes.ref, 34418 patternTitle: (0, import_html_entities10.decodeEntities)(entity.title), 34419 type: "synced-pattern" 34420 }; 34421 } 34422 } 34423 if (blockName === "core/template-part" && !!attributes?.slug) { 34424 const theme = attributes.theme || getCurrentTheme()?.stylesheet; 34425 const templatePartId = theme ? `$theme}//${attributes.slug}` : null; 34426 if (templatePartId) { 34427 const entity = getEditedEntityRecord( 34428 "postType", 34429 "wp_template_part", 34430 templatePartId 34431 ); 34432 if (entity?.title) { 34433 return { 34434 patternName: attributes.slug, 34435 patternTitle: (0, import_html_entities10.decodeEntities)(entity.title), 34436 type: "template-part" 34437 }; 34438 } 34439 } 34440 } 34441 return null; 34442 }, []); 34443 } 34444 34445 // packages/editor/build-module/components/document-bar/index.js 34446 var import_jsx_runtime196 = __toESM(require_jsx_runtime()); 34447 var MotionButton = import_components98.__unstableMotion.create(import_components98.Button); 34448 function DocumentBar(props) { 34449 const { stopEditingContentOnlySection } = unlock( 34450 (0, import_data77.useDispatch)(import_block_editor41.store) 34451 ); 34452 const unlockedPatternInfo = useEditedSectionDetails(); 34453 const { 34454 postId: postId2, 34455 postType: postType2, 34456 postTypeLabel, 34457 documentTitle, 34458 isNotFound, 34459 templateTitle, 34460 onNavigateToPreviousEntityRecord, 34461 isTemplatePreview, 34462 stylesCanvasTitle 34463 } = (0, import_data77.useSelect)((select5) => { 34464 const { 34465 getCurrentPostType: getCurrentPostType2, 34466 getCurrentPostId: getCurrentPostId2, 34467 getEditorSettings: getEditorSettings2, 34468 getRenderingMode: getRenderingMode2 34469 } = select5(store); 34470 const { 34471 getEditedEntityRecord, 34472 getPostType, 34473 getCurrentTheme, 34474 isResolving: isResolvingSelector 34475 } = select5(import_core_data54.store); 34476 const _postType = getCurrentPostType2(); 34477 const _postId = getCurrentPostId2(); 34478 const _document = getEditedEntityRecord( 34479 "postType", 34480 _postType, 34481 _postId 34482 ); 34483 const { default_template_types: templateTypes = [] } = getCurrentTheme() ?? {}; 34484 const _templateInfo = getTemplateInfo({ 34485 templateTypes, 34486 template: _document 34487 }); 34488 const _postTypeLabel = getPostType(_postType)?.labels?.singular_name; 34489 const { getStylesPath: getStylesPath2, getShowStylebook: getShowStylebook2 } = unlock( 34490 select5(store) 34491 ); 34492 const _stylesPath = getStylesPath2(); 34493 const _showStylebook = getShowStylebook2(); 34494 const _stylesCanvasTitle = getStylesCanvasTitle( 34495 _stylesPath, 34496 _showStylebook 34497 ); 34498 return { 34499 postId: _postId, 34500 postType: _postType, 34501 postTypeLabel: _postTypeLabel, 34502 documentTitle: _document.title, 34503 isNotFound: !_document && !isResolvingSelector( 34504 "getEditedEntityRecord", 34505 "postType", 34506 _postType, 34507 _postId 34508 ), 34509 templateTitle: _templateInfo.title, 34510 onNavigateToPreviousEntityRecord: getEditorSettings2().onNavigateToPreviousEntityRecord, 34511 isTemplatePreview: getRenderingMode2() === "template-locked", 34512 stylesCanvasTitle: _stylesCanvasTitle 34513 }; 34514 }, []); 34515 const { open: openCommandCenter } = (0, import_data77.useDispatch)(import_commands3.store); 34516 const isReducedMotion = (0, import_compose19.useReducedMotion)(); 34517 const isTemplate2 = TEMPLATE_POST_TYPES.includes(postType2); 34518 const hasBackButton = !!onNavigateToPreviousEntityRecord || !!unlockedPatternInfo; 34519 const entityTitle = isTemplate2 ? templateTitle : documentTitle; 34520 const title = unlockedPatternInfo?.patternTitle || props.title || stylesCanvasTitle || entityTitle; 34521 const icon = props.icon; 34522 const handleBackClick = (event) => { 34523 event.stopPropagation(); 34524 if (unlockedPatternInfo) { 34525 stopEditingContentOnlySection(); 34526 } else if (onNavigateToPreviousEntityRecord) { 34527 onNavigateToPreviousEntityRecord(); 34528 } 34529 }; 34530 const pageTypeBadge = usePageTypeBadge(postId2); 34531 const mountedRef = (0, import_element81.useRef)(false); 34532 (0, import_element81.useEffect)(() => { 34533 mountedRef.current = true; 34534 }, []); 34535 return /* @__PURE__ */ (0, import_jsx_runtime196.jsxs)( 34536 "div", 34537 { 34538 className: clsx_default("editor-document-bar", { 34539 "has-back-button": hasBackButton 34540 }), 34541 children: [ 34542 /* @__PURE__ */ (0, import_jsx_runtime196.jsx)(import_components98.__unstableAnimatePresence, { children: hasBackButton && /* @__PURE__ */ (0, import_jsx_runtime196.jsx)( 34543 MotionButton, 34544 { 34545 className: "editor-document-bar__back", 34546 icon: (0, import_i18n115.isRTL)() ? chevron_right_small_default : chevron_left_small_default, 34547 onClick: handleBackClick, 34548 size: "compact", 34549 initial: mountedRef.current ? { opacity: 0, transform: "translateX(15%)" } : false, 34550 animate: { opacity: 1, transform: "translateX(0%)" }, 34551 exit: { opacity: 0, transform: "translateX(15%)" }, 34552 transition: isReducedMotion ? { duration: 0 } : void 0, 34553 children: (0, import_i18n115.__)("Back") 34554 } 34555 ) }), 34556 !isTemplate2 && isTemplatePreview && !hasBackButton && /* @__PURE__ */ (0, import_jsx_runtime196.jsx)( 34557 import_block_editor41.BlockIcon, 34558 { 34559 icon: layout_default, 34560 className: "editor-document-bar__icon-layout" 34561 } 34562 ), 34563 isNotFound ? /* @__PURE__ */ (0, import_jsx_runtime196.jsx)(import_components98.__experimentalText, { children: (0, import_i18n115.__)("Document not found") }) : /* @__PURE__ */ (0, import_jsx_runtime196.jsxs)( 34564 import_components98.Button, 34565 { 34566 className: "editor-document-bar__command", 34567 onClick: () => openCommandCenter(), 34568 size: "compact", 34569 children: [ 34570 /* @__PURE__ */ (0, import_jsx_runtime196.jsxs)( 34571 import_components98.__unstableMotion.div, 34572 { 34573 className: "editor-document-bar__title", 34574 initial: mountedRef.current ? { 34575 opacity: 0, 34576 transform: hasBackButton ? "translateX(15%)" : "translateX(-15%)" 34577 } : false, 34578 animate: { 34579 opacity: 1, 34580 transform: "translateX(0%)" 34581 }, 34582 transition: isReducedMotion ? { duration: 0 } : void 0, 34583 children: [ 34584 icon && /* @__PURE__ */ (0, import_jsx_runtime196.jsx)(import_block_editor41.BlockIcon, { icon }), 34585 /* @__PURE__ */ (0, import_jsx_runtime196.jsxs)(import_components98.__experimentalText, { size: "body", as: "h1", children: [ 34586 /* @__PURE__ */ (0, import_jsx_runtime196.jsx)("span", { className: "editor-document-bar__post-title", children: title ? (0, import_dom.__unstableStripHTML)(title) : (0, import_i18n115.__)("No title") }), 34587 unlockedPatternInfo && /* @__PURE__ */ (0, import_jsx_runtime196.jsx)("span", { className: "editor-document-bar__post-type-label", children: unlockedPatternInfo.type === "template-part" ? `\xB7 ${(0, import_i18n115.__)("Template Part")}` : `\xB7 ${(0, import_i18n115.__)("Pattern")}` }), 34588 !unlockedPatternInfo && pageTypeBadge && /* @__PURE__ */ (0, import_jsx_runtime196.jsx)("span", { className: "editor-document-bar__post-type-label", children: `\xB7 $pageTypeBadge}` }), 34589 !unlockedPatternInfo && postTypeLabel && !props.title && !pageTypeBadge && /* @__PURE__ */ (0, import_jsx_runtime196.jsx)("span", { className: "editor-document-bar__post-type-label", children: `\xB7 ${(0, import_html_entities11.decodeEntities)( 34590 postTypeLabel 34591 )}` }) 34592 ] }) 34593 ] 34594 }, 34595 hasBackButton 34596 ), 34597 /* @__PURE__ */ (0, import_jsx_runtime196.jsx)("span", { className: "editor-document-bar__shortcut", children: import_keycodes7.displayShortcut.primary("k") }) 34598 ] 34599 } 34600 ) 34601 ] 34602 } 34603 ); 34604 } 34605 34606 // packages/editor/build-module/components/document-outline/index.js 34607 var import_i18n116 = __toESM(require_i18n()); 34608 var import_data78 = __toESM(require_data()); 34609 var import_element82 = __toESM(require_element()); 34610 var import_rich_text = __toESM(require_rich_text()); 34611 var import_block_editor42 = __toESM(require_block_editor()); 34612 var import_core_data55 = __toESM(require_core_data()); 34613 var import_components99 = __toESM(require_components()); 34614 34615 // packages/editor/build-module/components/document-outline/item.js 34616 var import_jsx_runtime197 = __toESM(require_jsx_runtime()); 34617 var TableOfContentsItem = ({ 34618 children, 34619 isValid, 34620 isDisabled, 34621 level, 34622 href, 34623 onSelect 34624 }) => { 34625 function handleClick(event) { 34626 if (isDisabled) { 34627 event.preventDefault(); 34628 return; 34629 } 34630 onSelect(); 34631 } 34632 return /* @__PURE__ */ (0, import_jsx_runtime197.jsx)( 34633 "li", 34634 { 34635 className: clsx_default( 34636 "document-outline__item", 34637 `is-$level.toLowerCase()}`, 34638 { 34639 "is-invalid": !isValid, 34640 "is-disabled": isDisabled 34641 } 34642 ), 34643 children: /* @__PURE__ */ (0, import_jsx_runtime197.jsxs)( 34644 "a", 34645 { 34646 href, 34647 className: "document-outline__button", 34648 "aria-disabled": isDisabled, 34649 onClick: handleClick, 34650 children: [ 34651 /* @__PURE__ */ (0, import_jsx_runtime197.jsx)( 34652 "span", 34653 { 34654 className: "document-outline__emdash", 34655 "aria-hidden": "true" 34656 } 34657 ), 34658 /* @__PURE__ */ (0, import_jsx_runtime197.jsx)("strong", { className: "document-outline__level", children: level }), 34659 /* @__PURE__ */ (0, import_jsx_runtime197.jsx)("span", { className: "document-outline__item-content", children }) 34660 ] 34661 } 34662 ) 34663 } 34664 ); 34665 }; 34666 var item_default = TableOfContentsItem; 34667 34668 // packages/editor/build-module/components/document-outline/index.js 34669 var import_jsx_runtime198 = __toESM(require_jsx_runtime()); 34670 var emptyHeadingContent = /* @__PURE__ */ (0, import_jsx_runtime198.jsx)("em", { children: (0, import_i18n116.__)("(Empty heading)") }); 34671 var incorrectLevelContent = [ 34672 /* @__PURE__ */ (0, import_jsx_runtime198.jsx)("br", {}, "incorrect-break"), 34673 /* @__PURE__ */ (0, import_jsx_runtime198.jsx)("em", { children: (0, import_i18n116.__)("(Incorrect heading level)") }, "incorrect-message") 34674 ]; 34675 var singleH1Headings = [ 34676 /* @__PURE__ */ (0, import_jsx_runtime198.jsx)("br", {}, "incorrect-break-h1"), 34677 /* @__PURE__ */ (0, import_jsx_runtime198.jsx)("em", { children: (0, import_i18n116.__)("(Your theme may already use a H1 for the post title)") }, "incorrect-message-h1") 34678 ]; 34679 var multipleH1Headings = [ 34680 /* @__PURE__ */ (0, import_jsx_runtime198.jsx)("br", {}, "incorrect-break-multiple-h1"), 34681 /* @__PURE__ */ (0, import_jsx_runtime198.jsx)("em", { children: (0, import_i18n116.__)("(Multiple H1 headings are not recommended)") }, "incorrect-message-multiple-h1") 34682 ]; 34683 function EmptyOutlineIllustration() { 34684 return /* @__PURE__ */ (0, import_jsx_runtime198.jsxs)( 34685 import_components99.SVG, 34686 { 34687 width: "138", 34688 height: "148", 34689 viewBox: "0 0 138 148", 34690 fill: "none", 34691 xmlns: "http://www.w3.org/2000/svg", 34692 children: [ 34693 /* @__PURE__ */ (0, import_jsx_runtime198.jsx)(import_components99.Rect, { width: "138", height: "148", rx: "4", fill: "#F0F6FC" }), 34694 /* @__PURE__ */ (0, import_jsx_runtime198.jsx)(import_components99.Line, { x1: "44", y1: "28", x2: "24", y2: "28", stroke: "#DDDDDD" }), 34695 /* @__PURE__ */ (0, import_jsx_runtime198.jsx)(import_components99.Rect, { x: "48", y: "16", width: "27", height: "23", rx: "4", fill: "#DDDDDD" }), 34696 /* @__PURE__ */ (0, import_jsx_runtime198.jsx)( 34697 import_components99.Path, 34698 { 34699 d: "M54.7585 32V23.2727H56.6037V26.8736H60.3494V23.2727H62.1903V32H60.3494V28.3949H56.6037V32H54.7585ZM67.4574 23.2727V32H65.6122V25.0241H65.5611L63.5625 26.277V24.6406L65.723 23.2727H67.4574Z", 34700 fill: "black" 34701 } 34702 ), 34703 /* @__PURE__ */ (0, import_jsx_runtime198.jsx)(import_components99.Line, { x1: "55", y1: "59", x2: "24", y2: "59", stroke: "#DDDDDD" }), 34704 /* @__PURE__ */ (0, import_jsx_runtime198.jsx)(import_components99.Rect, { x: "59", y: "47", width: "29", height: "23", rx: "4", fill: "#DDDDDD" }), 34705 /* @__PURE__ */ (0, import_jsx_runtime198.jsx)( 34706 import_components99.Path, 34707 { 34708 d: "M65.7585 63V54.2727H67.6037V57.8736H71.3494V54.2727H73.1903V63H71.3494V59.3949H67.6037V63H65.7585ZM74.6605 63V61.6705L77.767 58.794C78.0313 58.5384 78.2528 58.3082 78.4318 58.1037C78.6136 57.8991 78.7514 57.6989 78.8452 57.5028C78.9389 57.304 78.9858 57.0895 78.9858 56.8594C78.9858 56.6037 78.9276 56.3835 78.8111 56.1989C78.6946 56.0114 78.5355 55.8679 78.3338 55.7685C78.1321 55.6662 77.9034 55.6151 77.6477 55.6151C77.3807 55.6151 77.1477 55.669 76.9489 55.777C76.75 55.8849 76.5966 56.0398 76.4886 56.2415C76.3807 56.4432 76.3267 56.6832 76.3267 56.9616H74.5753C74.5753 56.3906 74.7045 55.8949 74.9631 55.4744C75.2216 55.054 75.5838 54.7287 76.0497 54.4986C76.5156 54.2685 77.0526 54.1534 77.6605 54.1534C78.2855 54.1534 78.8295 54.2642 79.2926 54.4858C79.7585 54.7045 80.1207 55.0085 80.3793 55.3977C80.6378 55.7869 80.767 56.233 80.767 56.7358C80.767 57.0653 80.7017 57.3906 80.571 57.7116C80.4432 58.0327 80.2145 58.3892 79.8849 58.7812C79.5554 59.1705 79.0909 59.6378 78.4915 60.1832L77.2173 61.4318V61.4915H80.8821V63H74.6605Z", 34709 fill: "black" 34710 } 34711 ), 34712 /* @__PURE__ */ (0, import_jsx_runtime198.jsx)(import_components99.Line, { x1: "80", y1: "90", x2: "24", y2: "90", stroke: "#DDDDDD" }), 34713 /* @__PURE__ */ (0, import_jsx_runtime198.jsx)(import_components99.Rect, { x: "84", y: "78", width: "30", height: "23", rx: "4", fill: "#F0B849" }), 34714 /* @__PURE__ */ (0, import_jsx_runtime198.jsx)( 34715 import_components99.Path, 34716 { 34717 d: "M90.7585 94V85.2727H92.6037V88.8736H96.3494V85.2727H98.1903V94H96.3494V90.3949H92.6037V94H90.7585ZM99.5284 92.4659V91.0128L103.172 85.2727H104.425V87.2841H103.683L101.386 90.919V90.9872H106.564V92.4659H99.5284ZM103.717 94V92.0227L103.751 91.3793V85.2727H105.482V94H103.717Z", 34718 fill: "black" 34719 } 34720 ), 34721 /* @__PURE__ */ (0, import_jsx_runtime198.jsx)(import_components99.Line, { x1: "66", y1: "121", x2: "24", y2: "121", stroke: "#DDDDDD" }), 34722 /* @__PURE__ */ (0, import_jsx_runtime198.jsx)(import_components99.Rect, { x: "70", y: "109", width: "29", height: "23", rx: "4", fill: "#DDDDDD" }), 34723 /* @__PURE__ */ (0, import_jsx_runtime198.jsx)( 34724 import_components99.Path, 34725 { 34726 d: "M76.7585 125V116.273H78.6037V119.874H82.3494V116.273H84.1903V125H82.3494V121.395H78.6037V125H76.7585ZM88.8864 125.119C88.25 125.119 87.6832 125.01 87.1861 124.791C86.6918 124.57 86.3011 124.266 86.0142 123.879C85.7301 123.49 85.5838 123.041 85.5753 122.533H87.4332C87.4446 122.746 87.5142 122.933 87.642 123.095C87.7727 123.254 87.946 123.378 88.1619 123.466C88.3778 123.554 88.6207 123.598 88.8906 123.598C89.1719 123.598 89.4205 123.548 89.6364 123.449C89.8523 123.349 90.0213 123.212 90.1435 123.036C90.2656 122.859 90.3267 122.656 90.3267 122.426C90.3267 122.193 90.2614 121.987 90.1307 121.808C90.0028 121.626 89.8182 121.484 89.5767 121.382C89.3381 121.28 89.054 121.229 88.7244 121.229H87.9105V119.874H88.7244C89.0028 119.874 89.2486 119.825 89.4616 119.729C89.6776 119.632 89.8452 119.499 89.9645 119.328C90.0838 119.155 90.1435 118.953 90.1435 118.723C90.1435 118.504 90.0909 118.312 89.9858 118.148C89.8835 117.98 89.7386 117.849 89.5511 117.756C89.3665 117.662 89.1506 117.615 88.9034 117.615C88.6534 117.615 88.4247 117.661 88.2173 117.751C88.0099 117.839 87.8438 117.966 87.7188 118.131C87.5938 118.295 87.527 118.489 87.5185 118.71H85.75C85.7585 118.207 85.902 117.764 86.1804 117.381C86.4588 116.997 86.8338 116.697 87.3054 116.482C87.7798 116.263 88.3153 116.153 88.9119 116.153C89.5142 116.153 90.0412 116.263 90.4929 116.482C90.9446 116.7 91.2955 116.996 91.5455 117.368C91.7983 117.737 91.9233 118.152 91.9205 118.612C91.9233 119.101 91.7713 119.509 91.4645 119.835C91.1605 120.162 90.7642 120.369 90.2756 120.457V120.526C90.9176 120.608 91.4063 120.831 91.7415 121.195C92.0795 121.555 92.2472 122.007 92.2443 122.55C92.2472 123.047 92.1037 123.489 91.8139 123.875C91.527 124.261 91.1307 124.565 90.625 124.787C90.1193 125.009 89.5398 125.119 88.8864 125.119Z", 34727 fill: "black" 34728 } 34729 ) 34730 ] 34731 } 34732 ); 34733 } 34734 var computeOutlineHeadings = (blocks = []) => { 34735 return blocks.filter((block) => block.name === "core/heading").map((block) => ({ 34736 ...block, 34737 level: block.attributes.level, 34738 isEmpty: isEmptyHeading(block) 34739 })); 34740 }; 34741 var isEmptyHeading = (heading) => !heading.attributes.content || heading.attributes.content.trim().length === 0; 34742 function DocumentOutline({ 34743 onSelect, 34744 hasOutlineItemsDisabled 34745 }) { 34746 const { selectBlock: selectBlock2 } = (0, import_data78.useDispatch)(import_block_editor42.store); 34747 const { title, isTitleSupported } = (0, import_data78.useSelect)((select5) => { 34748 const { getEditedPostAttribute: getEditedPostAttribute2 } = select5(store); 34749 const { getPostType } = select5(import_core_data55.store); 34750 const postType2 = getPostType(getEditedPostAttribute2("type")); 34751 return { 34752 title: getEditedPostAttribute2("title"), 34753 isTitleSupported: postType2?.supports?.title ?? false 34754 }; 34755 }); 34756 const blocks = (0, import_data78.useSelect)((select5) => { 34757 const { getClientIdsWithDescendants: getClientIdsWithDescendants2, getBlock: getBlock2 } = select5(import_block_editor42.store); 34758 const clientIds = getClientIdsWithDescendants2(); 34759 return clientIds.map((id) => getBlock2(id)); 34760 }); 34761 const contentBlocks = (0, import_data78.useSelect)((select5) => { 34762 if (select5(store).getRenderingMode() === "post-only") { 34763 return void 0; 34764 } 34765 const { getBlocksByName, getClientIdsOfDescendants: getClientIdsOfDescendants2 } = select5(import_block_editor42.store); 34766 const [postContentClientId] = getBlocksByName("core/post-content"); 34767 if (!postContentClientId) { 34768 return void 0; 34769 } 34770 return getClientIdsOfDescendants2(postContentClientId); 34771 }, []); 34772 const prevHeadingLevelRef = (0, import_element82.useRef)(1); 34773 const headings = (0, import_element82.useMemo)( 34774 () => computeOutlineHeadings(blocks), 34775 [blocks] 34776 ); 34777 if (headings.length < 1) { 34778 return /* @__PURE__ */ (0, import_jsx_runtime198.jsxs)("div", { className: "editor-document-outline has-no-headings", children: [ 34779 /* @__PURE__ */ (0, import_jsx_runtime198.jsx)(EmptyOutlineIllustration, {}), 34780 /* @__PURE__ */ (0, import_jsx_runtime198.jsx)("p", { children: (0, import_i18n116.__)( 34781 "Navigate the structure of your document and address issues like empty or incorrect heading levels." 34782 ) }) 34783 ] }); 34784 } 34785 const titleNode = document.querySelector(".editor-post-title__input"); 34786 const hasTitle = isTitleSupported && title && titleNode; 34787 const countByLevel = headings.reduce( 34788 (acc, heading) => ({ 34789 ...acc, 34790 [heading.level]: (acc[heading.level] || 0) + 1 34791 }), 34792 {} 34793 ); 34794 const hasMultipleH1 = countByLevel[1] > 1; 34795 function isContentBlock(clientId) { 34796 return Array.isArray(contentBlocks) ? contentBlocks.includes(clientId) : true; 34797 } 34798 return /* @__PURE__ */ (0, import_jsx_runtime198.jsx)("div", { className: "document-outline", children: /* @__PURE__ */ (0, import_jsx_runtime198.jsxs)("ul", { children: [ 34799 hasTitle && /* @__PURE__ */ (0, import_jsx_runtime198.jsx)( 34800 item_default, 34801 { 34802 level: (0, import_i18n116.__)("Title"), 34803 isValid: true, 34804 onSelect, 34805 href: `#$titleNode.id}`, 34806 isDisabled: hasOutlineItemsDisabled, 34807 children: title 34808 } 34809 ), 34810 headings.map((item) => { 34811 const isIncorrectLevel = item.level > prevHeadingLevelRef.current + 1; 34812 const isValid = !item.isEmpty && !isIncorrectLevel && !!item.level && (item.level !== 1 || !hasMultipleH1 && !hasTitle); 34813 prevHeadingLevelRef.current = item.level; 34814 return /* @__PURE__ */ (0, import_jsx_runtime198.jsxs)( 34815 item_default, 34816 { 34817 level: `H$item.level}`, 34818 isValid, 34819 isDisabled: hasOutlineItemsDisabled || !isContentBlock(item.clientId), 34820 href: `#block-$item.clientId}`, 34821 onSelect: () => { 34822 selectBlock2(item.clientId); 34823 onSelect?.(); 34824 }, 34825 children: [ 34826 item.isEmpty ? emptyHeadingContent : (0, import_rich_text.getTextContent)( 34827 (0, import_rich_text.create)({ 34828 html: item.attributes.content 34829 }) 34830 ), 34831 isIncorrectLevel && incorrectLevelContent, 34832 item.level === 1 && hasMultipleH1 && multipleH1Headings, 34833 hasTitle && item.level === 1 && !hasMultipleH1 && singleH1Headings 34834 ] 34835 }, 34836 item.clientId 34837 ); 34838 }) 34839 ] }) }); 34840 } 34841 34842 // packages/editor/build-module/components/document-outline/check.js 34843 var import_data79 = __toESM(require_data()); 34844 var import_block_editor43 = __toESM(require_block_editor()); 34845 function DocumentOutlineCheck({ children }) { 34846 const hasHeadings = (0, import_data79.useSelect)((select5) => { 34847 const { getGlobalBlockCount: getGlobalBlockCount2 } = select5(import_block_editor43.store); 34848 return getGlobalBlockCount2("core/heading") > 0; 34849 }); 34850 if (!hasHeadings) { 34851 return null; 34852 } 34853 return children; 34854 } 34855 34856 // packages/editor/build-module/components/global-keyboard-shortcuts/register-shortcuts.js 34857 var import_element83 = __toESM(require_element()); 34858 var import_data80 = __toESM(require_data()); 34859 var import_i18n117 = __toESM(require_i18n()); 34860 var import_block_editor44 = __toESM(require_block_editor()); 34861 var import_keyboard_shortcuts4 = __toESM(require_keyboard_shortcuts()); 34862 var import_keycodes8 = __toESM(require_keycodes()); 34863 var import_jsx_runtime199 = __toESM(require_jsx_runtime()); 34864 function EditorKeyboardShortcutsRegister() { 34865 const { registerShortcut } = (0, import_data80.useDispatch)(import_keyboard_shortcuts4.store); 34866 (0, import_element83.useEffect)(() => { 34867 registerShortcut({ 34868 name: "core/editor/toggle-mode", 34869 category: "global", 34870 description: (0, import_i18n117.__)("Switch between visual editor and code editor."), 34871 keyCombination: { 34872 modifier: "secondary", 34873 character: "m" 34874 } 34875 }); 34876 registerShortcut({ 34877 name: "core/editor/save", 34878 category: "global", 34879 description: (0, import_i18n117.__)("Save your changes."), 34880 keyCombination: { 34881 modifier: "primary", 34882 character: "s" 34883 } 34884 }); 34885 registerShortcut({ 34886 name: "core/editor/undo", 34887 category: "global", 34888 description: (0, import_i18n117.__)("Undo your last changes."), 34889 keyCombination: { 34890 modifier: "primary", 34891 character: "z" 34892 } 34893 }); 34894 registerShortcut({ 34895 name: "core/editor/redo", 34896 category: "global", 34897 description: (0, import_i18n117.__)("Redo your last undo."), 34898 keyCombination: { 34899 modifier: "primaryShift", 34900 character: "z" 34901 }, 34902 // Disable on Apple OS because it conflicts with the browser's 34903 // history shortcut. It's a fine alias for both Windows and Linux. 34904 // Since there's no conflict for Ctrl+Shift+Z on both Windows and 34905 // Linux, we keep it as the default for consistency. 34906 aliases: (0, import_keycodes8.isAppleOS)() ? [] : [ 34907 { 34908 modifier: "primary", 34909 character: "y" 34910 } 34911 ] 34912 }); 34913 registerShortcut({ 34914 name: "core/editor/toggle-list-view", 34915 category: "global", 34916 description: (0, import_i18n117.__)("Show or hide the List View."), 34917 keyCombination: { 34918 modifier: "access", 34919 character: "o" 34920 } 34921 }); 34922 registerShortcut({ 34923 name: "core/editor/toggle-distraction-free", 34924 category: "global", 34925 description: (0, import_i18n117.__)("Enter or exit distraction free mode."), 34926 keyCombination: { 34927 modifier: "primaryShift", 34928 character: "\\" 34929 } 34930 }); 34931 registerShortcut({ 34932 name: "core/editor/toggle-sidebar", 34933 category: "global", 34934 description: (0, import_i18n117.__)("Show or hide the Settings panel."), 34935 keyCombination: { 34936 modifier: "primaryShift", 34937 character: "," 34938 } 34939 }); 34940 registerShortcut({ 34941 name: "core/editor/keyboard-shortcuts", 34942 category: "main", 34943 description: (0, import_i18n117.__)("Display these keyboard shortcuts."), 34944 keyCombination: { 34945 modifier: "access", 34946 character: "h" 34947 } 34948 }); 34949 registerShortcut({ 34950 name: "core/editor/next-region", 34951 category: "global", 34952 description: (0, import_i18n117.__)("Navigate to the next part of the editor."), 34953 keyCombination: { 34954 modifier: "ctrl", 34955 character: "`" 34956 }, 34957 aliases: [ 34958 { 34959 modifier: "access", 34960 character: "n" 34961 } 34962 ] 34963 }); 34964 registerShortcut({ 34965 name: "core/editor/previous-region", 34966 category: "global", 34967 description: (0, import_i18n117.__)("Navigate to the previous part of the editor."), 34968 keyCombination: { 34969 modifier: "ctrlShift", 34970 character: "`" 34971 }, 34972 aliases: [ 34973 { 34974 modifier: "access", 34975 character: "p" 34976 }, 34977 { 34978 modifier: "ctrlShift", 34979 character: "~" 34980 } 34981 ] 34982 }); 34983 }, [registerShortcut]); 34984 return /* @__PURE__ */ (0, import_jsx_runtime199.jsx)(import_block_editor44.BlockEditorKeyboardShortcuts.Register, {}); 34985 } 34986 var register_shortcuts_default = EditorKeyboardShortcutsRegister; 34987 34988 // packages/editor/build-module/components/editor-history/redo.js 34989 var import_i18n118 = __toESM(require_i18n()); 34990 var import_components100 = __toESM(require_components()); 34991 var import_data81 = __toESM(require_data()); 34992 var import_keycodes9 = __toESM(require_keycodes()); 34993 var import_element84 = __toESM(require_element()); 34994 var import_jsx_runtime200 = __toESM(require_jsx_runtime()); 34995 function EditorHistoryRedo(props, ref) { 34996 const shortcut = (0, import_keycodes9.isAppleOS)() ? import_keycodes9.displayShortcut.primaryShift("z") : import_keycodes9.displayShortcut.primary("y"); 34997 const hasRedo = (0, import_data81.useSelect)( 34998 (select5) => select5(store).hasEditorRedo(), 34999 [] 35000 ); 35001 const { redo: redo2 } = (0, import_data81.useDispatch)(store); 35002 return /* @__PURE__ */ (0, import_jsx_runtime200.jsx)( 35003 import_components100.Button, 35004 { 35005 __next40pxDefaultSize: true, 35006 ...props, 35007 ref, 35008 icon: !(0, import_i18n118.isRTL)() ? redo_default : undo_default, 35009 label: (0, import_i18n118.__)("Redo"), 35010 shortcut, 35011 "aria-disabled": !hasRedo, 35012 onClick: hasRedo ? redo2 : void 0, 35013 className: "editor-history__redo" 35014 } 35015 ); 35016 } 35017 var redo_default2 = (0, import_element84.forwardRef)(EditorHistoryRedo); 35018 35019 // packages/editor/build-module/components/editor-history/undo.js 35020 var import_i18n119 = __toESM(require_i18n()); 35021 var import_components101 = __toESM(require_components()); 35022 var import_data82 = __toESM(require_data()); 35023 var import_keycodes10 = __toESM(require_keycodes()); 35024 var import_element85 = __toESM(require_element()); 35025 var import_jsx_runtime201 = __toESM(require_jsx_runtime()); 35026 function EditorHistoryUndo(props, ref) { 35027 const hasUndo = (0, import_data82.useSelect)( 35028 (select5) => select5(store).hasEditorUndo(), 35029 [] 35030 ); 35031 const { undo: undo2 } = (0, import_data82.useDispatch)(store); 35032 return /* @__PURE__ */ (0, import_jsx_runtime201.jsx)( 35033 import_components101.Button, 35034 { 35035 __next40pxDefaultSize: true, 35036 ...props, 35037 ref, 35038 icon: !(0, import_i18n119.isRTL)() ? undo_default : redo_default, 35039 label: (0, import_i18n119.__)("Undo"), 35040 shortcut: import_keycodes10.displayShortcut.primary("z"), 35041 "aria-disabled": !hasUndo, 35042 onClick: hasUndo ? undo2 : void 0, 35043 className: "editor-history__undo" 35044 } 35045 ); 35046 } 35047 var undo_default2 = (0, import_element85.forwardRef)(EditorHistoryUndo); 35048 35049 // packages/editor/build-module/components/editor-notices/index.js 35050 var import_components103 = __toESM(require_components()); 35051 var import_data84 = __toESM(require_data()); 35052 var import_notices17 = __toESM(require_notices()); 35053 35054 // packages/editor/build-module/components/template-validation-notice/index.js 35055 var import_components102 = __toESM(require_components()); 35056 var import_i18n120 = __toESM(require_i18n()); 35057 var import_data83 = __toESM(require_data()); 35058 var import_element86 = __toESM(require_element()); 35059 var import_block_editor45 = __toESM(require_block_editor()); 35060 var import_jsx_runtime202 = __toESM(require_jsx_runtime()); 35061 function TemplateValidationNotice() { 35062 const [showConfirmDialog, setShowConfirmDialog] = (0, import_element86.useState)(false); 35063 const isValid = (0, import_data83.useSelect)((select5) => { 35064 return select5(import_block_editor45.store).isValidTemplate(); 35065 }, []); 35066 const { setTemplateValidity: setTemplateValidity2, synchronizeTemplate: synchronizeTemplate2 } = (0, import_data83.useDispatch)(import_block_editor45.store); 35067 if (isValid) { 35068 return null; 35069 } 35070 return /* @__PURE__ */ (0, import_jsx_runtime202.jsxs)(import_jsx_runtime202.Fragment, { children: [ 35071 /* @__PURE__ */ (0, import_jsx_runtime202.jsx)( 35072 import_components102.Notice, 35073 { 35074 className: "editor-template-validation-notice", 35075 isDismissible: false, 35076 status: "warning", 35077 actions: [ 35078 { 35079 label: (0, import_i18n120.__)("Keep it as is"), 35080 onClick: () => setTemplateValidity2(true) 35081 }, 35082 { 35083 label: (0, import_i18n120.__)("Reset the template"), 35084 onClick: () => setShowConfirmDialog(true) 35085 } 35086 ], 35087 children: (0, import_i18n120.__)( 35088 "The content of your post doesn\u2019t match the template assigned to your post type." 35089 ) 35090 } 35091 ), 35092 /* @__PURE__ */ (0, import_jsx_runtime202.jsx)( 35093 import_components102.__experimentalConfirmDialog, 35094 { 35095 isOpen: showConfirmDialog, 35096 confirmButtonText: (0, import_i18n120.__)("Reset"), 35097 onConfirm: () => { 35098 setShowConfirmDialog(false); 35099 synchronizeTemplate2(); 35100 }, 35101 onCancel: () => setShowConfirmDialog(false), 35102 size: "medium", 35103 children: (0, import_i18n120.__)( 35104 "Resetting the template may result in loss of content, do you want to continue?" 35105 ) 35106 } 35107 ) 35108 ] }); 35109 } 35110 35111 // packages/editor/build-module/components/editor-notices/index.js 35112 var import_jsx_runtime203 = __toESM(require_jsx_runtime()); 35113 function EditorNotices() { 35114 const { notices } = (0, import_data84.useSelect)( 35115 (select5) => ({ 35116 notices: select5(import_notices17.store).getNotices() 35117 }), 35118 [] 35119 ); 35120 const { removeNotice } = (0, import_data84.useDispatch)(import_notices17.store); 35121 const dismissibleNotices = notices.filter( 35122 ({ isDismissible, type }) => isDismissible && type === "default" 35123 ); 35124 const nonDismissibleNotices = notices.filter( 35125 ({ isDismissible, type }) => !isDismissible && type === "default" 35126 ); 35127 return /* @__PURE__ */ (0, import_jsx_runtime203.jsxs)(import_jsx_runtime203.Fragment, { children: [ 35128 /* @__PURE__ */ (0, import_jsx_runtime203.jsx)( 35129 import_components103.NoticeList, 35130 { 35131 notices: nonDismissibleNotices, 35132 className: "components-editor-notices__pinned" 35133 } 35134 ), 35135 /* @__PURE__ */ (0, import_jsx_runtime203.jsx)( 35136 import_components103.NoticeList, 35137 { 35138 notices: dismissibleNotices, 35139 className: "components-editor-notices__dismissible", 35140 onRemove: removeNotice, 35141 children: /* @__PURE__ */ (0, import_jsx_runtime203.jsx)(TemplateValidationNotice, {}) 35142 } 35143 ) 35144 ] }); 35145 } 35146 var editor_notices_default = EditorNotices; 35147 35148 // packages/editor/build-module/components/editor-snackbars/index.js 35149 var import_components104 = __toESM(require_components()); 35150 var import_data85 = __toESM(require_data()); 35151 var import_notices18 = __toESM(require_notices()); 35152 var import_jsx_runtime204 = __toESM(require_jsx_runtime()); 35153 var MAX_VISIBLE_NOTICES = -3; 35154 function EditorSnackbars() { 35155 const notices = (0, import_data85.useSelect)( 35156 (select5) => select5(import_notices18.store).getNotices(), 35157 [] 35158 ); 35159 const { removeNotice } = (0, import_data85.useDispatch)(import_notices18.store); 35160 const snackbarNotices = notices.filter(({ type }) => type === "snackbar").slice(MAX_VISIBLE_NOTICES); 35161 return /* @__PURE__ */ (0, import_jsx_runtime204.jsx)( 35162 import_components104.SnackbarList, 35163 { 35164 notices: snackbarNotices, 35165 className: "components-editor-notices__snackbar", 35166 onRemove: removeNotice 35167 } 35168 ); 35169 } 35170 35171 // packages/editor/build-module/components/entities-saved-states/index.js 35172 var import_components107 = __toESM(require_components()); 35173 var import_i18n123 = __toESM(require_i18n()); 35174 var import_element88 = __toESM(require_element()); 35175 var import_compose20 = __toESM(require_compose()); 35176 var import_data89 = __toESM(require_data()); 35177 35178 // packages/editor/build-module/components/entities-saved-states/entity-type-list.js 35179 var import_i18n122 = __toESM(require_i18n()); 35180 var import_data87 = __toESM(require_data()); 35181 var import_components106 = __toESM(require_components()); 35182 var import_core_data57 = __toESM(require_core_data()); 35183 35184 // packages/editor/build-module/components/entities-saved-states/entity-record-item.js 35185 var import_components105 = __toESM(require_components()); 35186 var import_i18n121 = __toESM(require_i18n()); 35187 var import_data86 = __toESM(require_data()); 35188 var import_core_data56 = __toESM(require_core_data()); 35189 var import_html_entities12 = __toESM(require_html_entities()); 35190 var import_jsx_runtime205 = __toESM(require_jsx_runtime()); 35191 function EntityRecordItem({ record, checked, onChange }) { 35192 const { name: name2, kind, title, key } = record; 35193 const { entityRecordTitle, hasPostMetaChanges: hasPostMetaChanges2 } = (0, import_data86.useSelect)( 35194 (select5) => { 35195 if ("postType" !== kind || "wp_template" !== name2) { 35196 return { 35197 entityRecordTitle: title, 35198 hasPostMetaChanges: unlock( 35199 select5(store) 35200 ).hasPostMetaChanges(name2, key) 35201 }; 35202 } 35203 const template2 = select5(import_core_data56.store).getEditedEntityRecord( 35204 kind, 35205 name2, 35206 key 35207 ); 35208 const { default_template_types: templateTypes = [] } = select5(import_core_data56.store).getCurrentTheme() ?? {}; 35209 return { 35210 entityRecordTitle: getTemplateInfo({ 35211 template: template2, 35212 templateTypes 35213 }).title, 35214 hasPostMetaChanges: unlock( 35215 select5(store) 35216 ).hasPostMetaChanges(name2, key) 35217 }; 35218 }, 35219 [name2, kind, title, key] 35220 ); 35221 return /* @__PURE__ */ (0, import_jsx_runtime205.jsxs)(import_jsx_runtime205.Fragment, { children: [ 35222 /* @__PURE__ */ (0, import_jsx_runtime205.jsx)(import_components105.PanelRow, { children: /* @__PURE__ */ (0, import_jsx_runtime205.jsx)( 35223 import_components105.CheckboxControl, 35224 { 35225 label: (0, import_html_entities12.decodeEntities)(entityRecordTitle) || (0, import_i18n121.__)("Untitled"), 35226 checked, 35227 onChange, 35228 className: "entities-saved-states__change-control" 35229 } 35230 ) }), 35231 hasPostMetaChanges2 && /* @__PURE__ */ (0, import_jsx_runtime205.jsx)("ul", { className: "entities-saved-states__changes", children: /* @__PURE__ */ (0, import_jsx_runtime205.jsx)("li", { children: (0, import_i18n121.__)("Post Meta.") }) }) 35232 ] }); 35233 } 35234 35235 // packages/editor/build-module/components/entities-saved-states/entity-type-list.js 35236 var import_jsx_runtime206 = __toESM(require_jsx_runtime()); 35237 function getEntityDescription(entity, count) { 35238 switch (entity) { 35239 case "site": 35240 return 1 === count ? (0, import_i18n122.__)("This change will affect your whole site.") : (0, import_i18n122.__)("These changes will affect your whole site."); 35241 case "wp_template": 35242 return (0, import_i18n122.__)( 35243 "This change will affect other parts of your site that use this template." 35244 ); 35245 case "page": 35246 case "post": 35247 return (0, import_i18n122.__)("The following has been modified."); 35248 } 35249 } 35250 function GlobalStylesDescription({ record }) { 35251 const { editedRecord, savedRecord } = (0, import_data87.useSelect)( 35252 (select5) => { 35253 const { getEditedEntityRecord, getEntityRecord } = select5(import_core_data57.store); 35254 return { 35255 editedRecord: getEditedEntityRecord( 35256 record.kind, 35257 record.name, 35258 record.key 35259 ), 35260 savedRecord: getEntityRecord( 35261 record.kind, 35262 record.name, 35263 record.key 35264 ) 35265 }; 35266 }, 35267 [record.kind, record.name, record.key] 35268 ); 35269 const globalStylesChanges = getGlobalStylesChanges( 35270 editedRecord, 35271 savedRecord, 35272 { 35273 maxResults: 10 35274 } 35275 ); 35276 return globalStylesChanges.length ? /* @__PURE__ */ (0, import_jsx_runtime206.jsx)("ul", { className: "entities-saved-states__changes", children: globalStylesChanges.map((change) => /* @__PURE__ */ (0, import_jsx_runtime206.jsx)("li", { children: change }, change)) }) : null; 35277 } 35278 function EntityDescription({ record, count }) { 35279 if ("globalStyles" === record?.name) { 35280 return null; 35281 } 35282 const description = getEntityDescription(record?.name, count); 35283 return description ? /* @__PURE__ */ (0, import_jsx_runtime206.jsx)(import_components106.PanelRow, { children: description }) : null; 35284 } 35285 function EntityTypeList({ 35286 list, 35287 unselectedEntities, 35288 setUnselectedEntities 35289 }) { 35290 const count = list.length; 35291 const firstRecord = list[0]; 35292 const entityConfig = (0, import_data87.useSelect)( 35293 (select5) => select5(import_core_data57.store).getEntityConfig( 35294 firstRecord.kind, 35295 firstRecord.name 35296 ), 35297 [firstRecord.kind, firstRecord.name] 35298 ); 35299 let entityLabel = entityConfig.label; 35300 if (firstRecord?.name === "wp_template_part") { 35301 entityLabel = 1 === count ? (0, import_i18n122.__)("Template Part") : (0, import_i18n122.__)("Template Parts"); 35302 } 35303 return /* @__PURE__ */ (0, import_jsx_runtime206.jsxs)( 35304 import_components106.PanelBody, 35305 { 35306 title: entityLabel, 35307 initialOpen: true, 35308 className: "entities-saved-states__panel-body", 35309 children: [ 35310 /* @__PURE__ */ (0, import_jsx_runtime206.jsx)(EntityDescription, { record: firstRecord, count }), 35311 list.map((record) => { 35312 return /* @__PURE__ */ (0, import_jsx_runtime206.jsx)( 35313 EntityRecordItem, 35314 { 35315 record, 35316 checked: !unselectedEntities.some( 35317 (elt) => elt.kind === record.kind && elt.name === record.name && elt.key === record.key && elt.property === record.property 35318 ), 35319 onChange: (value) => setUnselectedEntities(record, value) 35320 }, 35321 record.key || record.property 35322 ); 35323 }), 35324 "globalStyles" === firstRecord?.name && /* @__PURE__ */ (0, import_jsx_runtime206.jsx)(GlobalStylesDescription, { record: firstRecord }) 35325 ] 35326 } 35327 ); 35328 } 35329 35330 // packages/editor/build-module/components/entities-saved-states/hooks/use-is-dirty.js 35331 var import_data88 = __toESM(require_data()); 35332 var import_core_data58 = __toESM(require_core_data()); 35333 var import_element87 = __toESM(require_element()); 35334 var useIsDirty = () => { 35335 const { editedEntities, siteEdits, siteEntityConfig } = (0, import_data88.useSelect)( 35336 (select5) => { 35337 const { 35338 __experimentalGetDirtyEntityRecords, 35339 getEntityRecordEdits, 35340 getEntityConfig 35341 } = select5(import_core_data58.store); 35342 return { 35343 editedEntities: __experimentalGetDirtyEntityRecords(), 35344 siteEdits: getEntityRecordEdits("root", "site"), 35345 siteEntityConfig: getEntityConfig("root", "site") 35346 }; 35347 }, 35348 [] 35349 ); 35350 const dirtyEntityRecords = (0, import_element87.useMemo)(() => { 35351 const editedEntitiesWithoutSite = editedEntities.filter( 35352 (record) => !(record.kind === "root" && record.name === "site") 35353 ); 35354 const siteEntityLabels = siteEntityConfig?.meta?.labels ?? {}; 35355 const editedSiteEntities = []; 35356 for (const property in siteEdits) { 35357 editedSiteEntities.push({ 35358 kind: "root", 35359 name: "site", 35360 title: siteEntityLabels[property] || property, 35361 property 35362 }); 35363 } 35364 return [...editedEntitiesWithoutSite, ...editedSiteEntities]; 35365 }, [editedEntities, siteEdits, siteEntityConfig]); 35366 const [unselectedEntities, _setUnselectedEntities] = (0, import_element87.useState)([]); 35367 const setUnselectedEntities = ({ kind, name: name2, key, property }, checked) => { 35368 if (checked) { 35369 _setUnselectedEntities( 35370 unselectedEntities.filter( 35371 (elt) => elt.kind !== kind || elt.name !== name2 || elt.key !== key || elt.property !== property 35372 ) 35373 ); 35374 } else { 35375 _setUnselectedEntities([ 35376 ...unselectedEntities, 35377 { kind, name: name2, key, property } 35378 ]); 35379 } 35380 }; 35381 const isDirty = dirtyEntityRecords.length - unselectedEntities.length > 0; 35382 return { 35383 dirtyEntityRecords, 35384 isDirty, 35385 setUnselectedEntities, 35386 unselectedEntities 35387 }; 35388 }; 35389 35390 // packages/editor/build-module/components/entities-saved-states/index.js 35391 var import_jsx_runtime207 = __toESM(require_jsx_runtime()); 35392 function identity(values) { 35393 return values; 35394 } 35395 function EntitiesSavedStates({ 35396 close, 35397 renderDialog, 35398 variant 35399 }) { 35400 const isDirtyProps = useIsDirty(); 35401 return /* @__PURE__ */ (0, import_jsx_runtime207.jsx)( 35402 EntitiesSavedStatesExtensible, 35403 { 35404 close, 35405 renderDialog, 35406 variant, 35407 ...isDirtyProps 35408 } 35409 ); 35410 } 35411 function EntitiesSavedStatesExtensible({ 35412 additionalPrompt = void 0, 35413 close, 35414 onSave = identity, 35415 saveEnabled: saveEnabledProp = void 0, 35416 saveLabel = (0, import_i18n123.__)("Save"), 35417 renderDialog, 35418 dirtyEntityRecords, 35419 isDirty, 35420 setUnselectedEntities, 35421 unselectedEntities, 35422 variant = "default" 35423 }) { 35424 const saveButtonRef = (0, import_element88.useRef)(); 35425 const { saveDirtyEntities: saveDirtyEntities2 } = unlock((0, import_data89.useDispatch)(store)); 35426 const partitionedSavables = dirtyEntityRecords.reduce((acc, record) => { 35427 const { name: name2 } = record; 35428 if (!acc[name2]) { 35429 acc[name2] = []; 35430 } 35431 acc[name2].push(record); 35432 return acc; 35433 }, {}); 35434 const { 35435 site: siteSavables, 35436 wp_template: templateSavables, 35437 wp_template_part: templatePartSavables, 35438 ...contentSavables 35439 } = partitionedSavables; 35440 const sortedPartitionedSavables = [ 35441 siteSavables, 35442 templateSavables, 35443 templatePartSavables, 35444 ...Object.values(contentSavables) 35445 ].filter(Array.isArray); 35446 const saveEnabled = saveEnabledProp ?? isDirty; 35447 const dismissPanel = (0, import_element88.useCallback)(() => close(), [close]); 35448 const [saveDialogRef, saveDialogProps] = (0, import_compose20.__experimentalUseDialog)({ 35449 onClose: () => dismissPanel() 35450 }); 35451 const dialogLabelId = (0, import_compose20.useInstanceId)( 35452 EntitiesSavedStatesExtensible, 35453 "entities-saved-states__panel-label" 35454 ); 35455 const dialogDescriptionId = (0, import_compose20.useInstanceId)( 35456 EntitiesSavedStatesExtensible, 35457 "entities-saved-states__panel-description" 35458 ); 35459 const selectItemsToSaveDescription = !!dirtyEntityRecords.length ? (0, import_i18n123.__)("Select the items you want to save.") : void 0; 35460 const isInline = variant === "inline"; 35461 const actionButtons = /* @__PURE__ */ (0, import_jsx_runtime207.jsxs)(import_jsx_runtime207.Fragment, { children: [ 35462 /* @__PURE__ */ (0, import_jsx_runtime207.jsx)( 35463 import_components107.FlexItem, 35464 { 35465 isBlock: isInline ? false : true, 35466 as: import_components107.Button, 35467 variant: isInline ? "tertiary" : "secondary", 35468 size: isInline ? void 0 : "compact", 35469 onClick: dismissPanel, 35470 children: (0, import_i18n123.__)("Cancel") 35471 } 35472 ), 35473 /* @__PURE__ */ (0, import_jsx_runtime207.jsx)( 35474 import_components107.FlexItem, 35475 { 35476 isBlock: isInline ? false : true, 35477 as: import_components107.Button, 35478 ref: saveButtonRef, 35479 variant: "primary", 35480 size: isInline ? void 0 : "compact", 35481 disabled: !saveEnabled, 35482 accessibleWhenDisabled: true, 35483 onClick: () => saveDirtyEntities2({ 35484 onSave, 35485 dirtyEntityRecords, 35486 entitiesToSkip: unselectedEntities, 35487 close 35488 }), 35489 className: "editor-entities-saved-states__save-button", 35490 children: saveLabel 35491 } 35492 ) 35493 ] }); 35494 return /* @__PURE__ */ (0, import_jsx_runtime207.jsxs)( 35495 "div", 35496 { 35497 ref: renderDialog ? saveDialogRef : void 0, 35498 ...renderDialog && saveDialogProps, 35499 className: clsx_default("entities-saved-states__panel", { 35500 "is-inline": isInline 35501 }), 35502 role: renderDialog ? "dialog" : void 0, 35503 "aria-labelledby": renderDialog ? dialogLabelId : void 0, 35504 "aria-describedby": renderDialog ? dialogDescriptionId : void 0, 35505 children: [ 35506 !isInline && /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(import_components107.Flex, { className: "entities-saved-states__panel-header", gap: 2, children: actionButtons }), 35507 /* @__PURE__ */ (0, import_jsx_runtime207.jsxs)("div", { className: "entities-saved-states__text-prompt", children: [ 35508 /* @__PURE__ */ (0, import_jsx_runtime207.jsx)("div", { className: "entities-saved-states__text-prompt--header-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime207.jsx)( 35509 "strong", 35510 { 35511 id: renderDialog ? dialogLabelId : void 0, 35512 className: "entities-saved-states__text-prompt--header", 35513 children: (0, import_i18n123.__)("Are you ready to save?") 35514 } 35515 ) }), 35516 /* @__PURE__ */ (0, import_jsx_runtime207.jsxs)("div", { id: renderDialog ? dialogDescriptionId : void 0, children: [ 35517 additionalPrompt, 35518 /* @__PURE__ */ (0, import_jsx_runtime207.jsx)("p", { className: "entities-saved-states__text-prompt--changes-count", children: isDirty ? (0, import_element88.createInterpolateElement)( 35519 (0, import_i18n123.sprintf)( 35520 /* translators: %d: number of site changes waiting to be saved. */ 35521 (0, import_i18n123._n)( 35522 "There is <strong>%d site change</strong> waiting to be saved.", 35523 "There are <strong>%d site changes</strong> waiting to be saved.", 35524 dirtyEntityRecords.length 35525 ), 35526 dirtyEntityRecords.length 35527 ), 35528 { strong: /* @__PURE__ */ (0, import_jsx_runtime207.jsx)("strong", {}) } 35529 ) : selectItemsToSaveDescription }) 35530 ] }) 35531 ] }), 35532 sortedPartitionedSavables.map((list) => { 35533 return /* @__PURE__ */ (0, import_jsx_runtime207.jsx)( 35534 EntityTypeList, 35535 { 35536 list, 35537 unselectedEntities, 35538 setUnselectedEntities 35539 }, 35540 list[0].name 35541 ); 35542 }), 35543 isInline && /* @__PURE__ */ (0, import_jsx_runtime207.jsx)( 35544 import_components107.Flex, 35545 { 35546 direction: "row", 35547 justify: "flex-end", 35548 className: "entities-saved-states__panel-footer", 35549 children: actionButtons 35550 } 35551 ) 35552 ] 35553 } 35554 ); 35555 } 35556 35557 // packages/editor/build-module/components/error-boundary/index.js 35558 var import_element89 = __toESM(require_element()); 35559 var import_i18n124 = __toESM(require_i18n()); 35560 var import_components108 = __toESM(require_components()); 35561 var import_data90 = __toESM(require_data()); 35562 var import_compose21 = __toESM(require_compose()); 35563 var import_hooks39 = __toESM(require_hooks()); 35564 var import_jsx_runtime208 = __toESM(require_jsx_runtime()); 35565 function getContent() { 35566 try { 35567 return (0, import_data90.select)(store).getEditedPostContent(); 35568 } catch (error) { 35569 } 35570 } 35571 function CopyButton({ text, children, variant = "secondary" }) { 35572 const ref = (0, import_compose21.useCopyToClipboard)(text); 35573 return /* @__PURE__ */ (0, import_jsx_runtime208.jsx)(import_components108.Button, { __next40pxDefaultSize: true, variant, ref, children }); 35574 } 35575 var ErrorBoundary = class extends import_element89.Component { 35576 constructor() { 35577 super(...arguments); 35578 this.state = { 35579 error: null 35580 }; 35581 } 35582 componentDidCatch(error) { 35583 (0, import_hooks39.doAction)("editor.ErrorBoundary.errorLogged", error); 35584 } 35585 static getDerivedStateFromError(error) { 35586 return { error }; 35587 } 35588 render() { 35589 const { error } = this.state; 35590 const { canCopyContent = false } = this.props; 35591 if (!error) { 35592 return this.props.children; 35593 } 35594 return /* @__PURE__ */ (0, import_jsx_runtime208.jsxs)( 35595 import_components108.__experimentalHStack, 35596 { 35597 className: "editor-error-boundary", 35598 alignment: "baseline", 35599 spacing: 4, 35600 justify: "space-between", 35601 expanded: false, 35602 wrap: true, 35603 children: [ 35604 /* @__PURE__ */ (0, import_jsx_runtime208.jsx)(import_components108.__experimentalText, { as: "p", children: (0, import_i18n124.__)("The editor has encountered an unexpected error.") }), 35605 /* @__PURE__ */ (0, import_jsx_runtime208.jsxs)(import_components108.__experimentalHStack, { expanded: false, children: [ 35606 canCopyContent && /* @__PURE__ */ (0, import_jsx_runtime208.jsx)(CopyButton, { text: getContent, children: (0, import_i18n124.__)("Copy contents") }), 35607 /* @__PURE__ */ (0, import_jsx_runtime208.jsx)(CopyButton, { variant: "primary", text: error?.stack, children: (0, import_i18n124.__)("Copy error") }) 35608 ] }) 35609 ] 35610 } 35611 ); 35612 } 35613 }; 35614 var error_boundary_default = ErrorBoundary; 35615 35616 // packages/editor/build-module/components/local-autosave-monitor/index.js 35617 var import_element90 = __toESM(require_element()); 35618 var import_compose22 = __toESM(require_compose()); 35619 var import_data91 = __toESM(require_data()); 35620 var import_i18n125 = __toESM(require_i18n()); 35621 var import_blocks23 = __toESM(require_blocks()); 35622 var import_notices19 = __toESM(require_notices()); 35623 var import_jsx_runtime209 = __toESM(require_jsx_runtime()); 35624 var requestIdleCallback = window.requestIdleCallback ? window.requestIdleCallback : window.requestAnimationFrame; 35625 var hasStorageSupport; 35626 var hasSessionStorageSupport = () => { 35627 if (hasStorageSupport !== void 0) { 35628 return hasStorageSupport; 35629 } 35630 try { 35631 window.sessionStorage.setItem("__wpEditorTestSessionStorage", ""); 35632 window.sessionStorage.removeItem("__wpEditorTestSessionStorage"); 35633 hasStorageSupport = true; 35634 } catch { 35635 hasStorageSupport = false; 35636 } 35637 return hasStorageSupport; 35638 }; 35639 function useAutosaveNotice() { 35640 const { postId: postId2, isEditedPostNew: isEditedPostNew2, hasRemoteAutosave } = (0, import_data91.useSelect)( 35641 (select5) => ({ 35642 postId: select5(store).getCurrentPostId(), 35643 isEditedPostNew: select5(store).isEditedPostNew(), 35644 hasRemoteAutosave: !!select5(store).getEditorSettings().autosave 35645 }), 35646 [] 35647 ); 35648 const { getEditedPostAttribute: getEditedPostAttribute2 } = (0, import_data91.useSelect)(store); 35649 const { createWarningNotice, removeNotice } = (0, import_data91.useDispatch)(import_notices19.store); 35650 const { editPost: editPost2, resetEditorBlocks: resetEditorBlocks2 } = (0, import_data91.useDispatch)(store); 35651 (0, import_element90.useEffect)(() => { 35652 let localAutosave = localAutosaveGet(postId2, isEditedPostNew2); 35653 if (!localAutosave) { 35654 return; 35655 } 35656 try { 35657 localAutosave = JSON.parse(localAutosave); 35658 } catch { 35659 return; 35660 } 35661 const { post_title: title, content, excerpt } = localAutosave; 35662 const edits = { title, content, excerpt }; 35663 { 35664 const hasDifference = Object.keys(edits).some((key) => { 35665 return edits[key] !== getEditedPostAttribute2(key); 35666 }); 35667 if (!hasDifference) { 35668 localAutosaveClear(postId2, isEditedPostNew2); 35669 return; 35670 } 35671 } 35672 if (hasRemoteAutosave) { 35673 return; 35674 } 35675 const id = "wpEditorAutosaveRestore"; 35676 createWarningNotice( 35677 (0, import_i18n125.__)( 35678 "The backup of this post in your browser is different from the version below." 35679 ), 35680 { 35681 id, 35682 actions: [ 35683 { 35684 label: (0, import_i18n125.__)("Restore the backup"), 35685 onClick() { 35686 const { 35687 content: editsContent, 35688 ...editsWithoutContent 35689 } = edits; 35690 editPost2(editsWithoutContent); 35691 resetEditorBlocks2((0, import_blocks23.parse)(edits.content)); 35692 removeNotice(id); 35693 } 35694 } 35695 ] 35696 } 35697 ); 35698 }, [isEditedPostNew2, postId2]); 35699 } 35700 function useAutosavePurge() { 35701 const { postId: postId2, isEditedPostNew: isEditedPostNew2, isDirty, isAutosaving, didError } = (0, import_data91.useSelect)( 35702 (select5) => ({ 35703 postId: select5(store).getCurrentPostId(), 35704 isEditedPostNew: select5(store).isEditedPostNew(), 35705 isDirty: select5(store).isEditedPostDirty(), 35706 isAutosaving: select5(store).isAutosavingPost(), 35707 didError: select5(store).didPostSaveRequestFail() 35708 }), 35709 [] 35710 ); 35711 const lastIsDirtyRef = (0, import_element90.useRef)(isDirty); 35712 const lastIsAutosavingRef = (0, import_element90.useRef)(isAutosaving); 35713 (0, import_element90.useEffect)(() => { 35714 if (!didError && (lastIsAutosavingRef.current && !isAutosaving || lastIsDirtyRef.current && !isDirty)) { 35715 localAutosaveClear(postId2, isEditedPostNew2); 35716 } 35717 lastIsDirtyRef.current = isDirty; 35718 lastIsAutosavingRef.current = isAutosaving; 35719 }, [isDirty, isAutosaving, didError]); 35720 const wasEditedPostNew = (0, import_compose22.usePrevious)(isEditedPostNew2); 35721 const prevPostId = (0, import_compose22.usePrevious)(postId2); 35722 (0, import_element90.useEffect)(() => { 35723 if (prevPostId === postId2 && wasEditedPostNew && !isEditedPostNew2) { 35724 localAutosaveClear(postId2, true); 35725 } 35726 }, [isEditedPostNew2, postId2]); 35727 } 35728 function LocalAutosaveMonitor() { 35729 const { autosave: autosave2 } = (0, import_data91.useDispatch)(store); 35730 const deferredAutosave = (0, import_element90.useCallback)(() => { 35731 requestIdleCallback(() => autosave2({ local: true })); 35732 }, []); 35733 useAutosaveNotice(); 35734 useAutosavePurge(); 35735 const localAutosaveInterval = (0, import_data91.useSelect)( 35736 (select5) => select5(store).getEditorSettings().localAutosaveInterval, 35737 [] 35738 ); 35739 return /* @__PURE__ */ (0, import_jsx_runtime209.jsx)( 35740 autosave_monitor_default, 35741 { 35742 interval: localAutosaveInterval, 35743 autosave: deferredAutosave 35744 } 35745 ); 35746 } 35747 var local_autosave_monitor_default = (0, import_compose22.ifCondition)(hasSessionStorageSupport)(LocalAutosaveMonitor); 35748 35749 // packages/editor/build-module/components/page-attributes/check.js 35750 var import_data92 = __toESM(require_data()); 35751 var import_core_data59 = __toESM(require_core_data()); 35752 function PageAttributesCheck({ children }) { 35753 const supportsPageAttributes = (0, import_data92.useSelect)((select5) => { 35754 const { getEditedPostAttribute: getEditedPostAttribute2 } = select5(store); 35755 const { getPostType } = select5(import_core_data59.store); 35756 const postType2 = getPostType(getEditedPostAttribute2("type")); 35757 return !!postType2?.supports?.["page-attributes"]; 35758 }, []); 35759 if (!supportsPageAttributes) { 35760 return null; 35761 } 35762 return children; 35763 } 35764 var check_default2 = PageAttributesCheck; 35765 35766 // packages/editor/build-module/components/page-attributes/order.js 35767 var import_i18n126 = __toESM(require_i18n()); 35768 var import_components109 = __toESM(require_components()); 35769 var import_data94 = __toESM(require_data()); 35770 var import_element91 = __toESM(require_element()); 35771 35772 // packages/editor/build-module/components/post-type-support-check/index.js 35773 var import_data93 = __toESM(require_data()); 35774 var import_core_data60 = __toESM(require_core_data()); 35775 function checkSupport(supports = {}, key) { 35776 if (supports[key] !== void 0) { 35777 return !!supports[key]; 35778 } 35779 const [topKey, subKey] = key.split("."); 35780 const [subProperties] = Array.isArray(supports[topKey]) ? supports[topKey] : []; 35781 return Array.isArray(subProperties) ? subProperties.includes(subKey) : !!subProperties?.[subKey]; 35782 } 35783 function PostTypeSupportCheck({ children, supportKeys }) { 35784 const postType2 = (0, import_data93.useSelect)((select5) => { 35785 const { getEditedPostAttribute: getEditedPostAttribute2 } = select5(store); 35786 const { getPostType } = select5(import_core_data60.store); 35787 return getPostType(getEditedPostAttribute2("type")); 35788 }, []); 35789 let isSupported = !!postType2; 35790 if (postType2) { 35791 isSupported = (Array.isArray(supportKeys) ? supportKeys : [supportKeys]).some((key) => checkSupport(postType2.supports, key)); 35792 } 35793 if (!isSupported) { 35794 return null; 35795 } 35796 return children; 35797 } 35798 var post_type_support_check_default = PostTypeSupportCheck; 35799 35800 // packages/editor/build-module/components/page-attributes/order.js 35801 var import_jsx_runtime210 = __toESM(require_jsx_runtime()); 35802 function PageAttributesOrder() { 35803 const order = (0, import_data94.useSelect)( 35804 (select5) => select5(store).getEditedPostAttribute("menu_order") ?? 0, 35805 [] 35806 ); 35807 const { editPost: editPost2 } = (0, import_data94.useDispatch)(store); 35808 const [orderInput, setOrderInput] = (0, import_element91.useState)(null); 35809 const setUpdatedOrder = (value2) => { 35810 setOrderInput(value2); 35811 const newOrder = Number(value2); 35812 if (Number.isInteger(newOrder) && value2.trim?.() !== "") { 35813 editPost2({ menu_order: newOrder }); 35814 } 35815 }; 35816 const value = orderInput ?? order; 35817 return /* @__PURE__ */ (0, import_jsx_runtime210.jsx)(import_components109.Flex, { children: /* @__PURE__ */ (0, import_jsx_runtime210.jsx)(import_components109.FlexBlock, { children: /* @__PURE__ */ (0, import_jsx_runtime210.jsx)( 35818 import_components109.__experimentalNumberControl, 35819 { 35820 __next40pxDefaultSize: true, 35821 label: (0, import_i18n126.__)("Order"), 35822 help: (0, import_i18n126.__)("Set the page order."), 35823 value, 35824 onChange: setUpdatedOrder, 35825 hideLabelFromVision: true, 35826 onBlur: () => { 35827 setOrderInput(null); 35828 } 35829 } 35830 ) }) }); 35831 } 35832 function PageAttributesOrderWithChecks() { 35833 return /* @__PURE__ */ (0, import_jsx_runtime210.jsx)(post_type_support_check_default, { supportKeys: "page-attributes", children: /* @__PURE__ */ (0, import_jsx_runtime210.jsx)(PageAttributesOrder, {}) }); 35834 } 35835 35836 // packages/editor/build-module/components/page-attributes/panel.js 35837 var import_data96 = __toESM(require_data()); 35838 var import_core_data62 = __toESM(require_core_data()); 35839 35840 // packages/editor/build-module/components/page-attributes/parent.js 35841 var import_remove_accents2 = __toESM(require_remove_accents()); 35842 var import_i18n127 = __toESM(require_i18n()); 35843 var import_components111 = __toESM(require_components()); 35844 var import_compose23 = __toESM(require_compose()); 35845 var import_element93 = __toESM(require_element()); 35846 var import_data95 = __toESM(require_data()); 35847 var import_html_entities14 = __toESM(require_html_entities()); 35848 var import_core_data61 = __toESM(require_core_data()); 35849 var import_block_editor46 = __toESM(require_block_editor()); 35850 var import_url10 = __toESM(require_url()); 35851 35852 // packages/editor/build-module/components/post-panel-row/index.js 35853 var import_components110 = __toESM(require_components()); 35854 var import_element92 = __toESM(require_element()); 35855 var import_jsx_runtime211 = __toESM(require_jsx_runtime()); 35856 var PostPanelRow = (0, import_element92.forwardRef)(({ className, label, children }, ref) => { 35857 return /* @__PURE__ */ (0, import_jsx_runtime211.jsxs)( 35858 import_components110.__experimentalHStack, 35859 { 35860 className: clsx_default("editor-post-panel__row", className), 35861 ref, 35862 children: [ 35863 label && /* @__PURE__ */ (0, import_jsx_runtime211.jsx)("div", { className: "editor-post-panel__row-label", children: label }), 35864 /* @__PURE__ */ (0, import_jsx_runtime211.jsx)("div", { className: "editor-post-panel__row-control", children }) 35865 ] 35866 } 35867 ); 35868 }); 35869 var post_panel_row_default = PostPanelRow; 35870 35871 // packages/editor/build-module/utils/terms.js 35872 var import_html_entities13 = __toESM(require_html_entities()); 35873 function buildTermsTree2(flatTerms) { 35874 const flatTermsWithParentAndChildren = flatTerms.map((term) => { 35875 return { 35876 children: [], 35877 parent: void 0, 35878 ...term 35879 }; 35880 }); 35881 if (flatTermsWithParentAndChildren.some( 35882 ({ parent }) => parent === void 0 35883 )) { 35884 return flatTermsWithParentAndChildren; 35885 } 35886 const termsByParent = flatTermsWithParentAndChildren.reduce( 35887 (acc, term) => { 35888 const { parent } = term; 35889 if (!acc[parent]) { 35890 acc[parent] = []; 35891 } 35892 acc[parent].push(term); 35893 return acc; 35894 }, 35895 {} 35896 ); 35897 const fillWithChildren = (terms) => { 35898 return terms.map((term) => { 35899 const children = termsByParent[term.id]; 35900 return { 35901 ...term, 35902 children: children && children.length ? fillWithChildren(children) : [] 35903 }; 35904 }); 35905 }; 35906 return fillWithChildren(termsByParent["0"] || []); 35907 } 35908 var unescapeString = (arg) => { 35909 return (0, import_html_entities13.decodeEntities)(arg); 35910 }; 35911 var unescapeTerm = (term) => { 35912 return { 35913 ...term, 35914 name: unescapeString(term.name) 35915 }; 35916 }; 35917 var unescapeTerms = (terms) => { 35918 return (terms ?? []).map(unescapeTerm); 35919 }; 35920 35921 // packages/editor/build-module/components/page-attributes/parent.js 35922 var import_jsx_runtime212 = __toESM(require_jsx_runtime()); 35923 function getTitle(post2) { 35924 return post2?.title?.rendered ? (0, import_html_entities14.decodeEntities)(post2.title.rendered) : `#$post2.id} (${(0, import_i18n127.__)("no title")})`; 35925 } 35926 var getItemPriority2 = (name2, searchValue) => { 35927 const normalizedName = (0, import_remove_accents2.default)(name2 || "").toLowerCase(); 35928 const normalizedSearch = (0, import_remove_accents2.default)(searchValue || "").toLowerCase(); 35929 if (normalizedName === normalizedSearch) { 35930 return 0; 35931 } 35932 if (normalizedName.startsWith(normalizedSearch)) { 35933 return normalizedName.length; 35934 } 35935 return Infinity; 35936 }; 35937 function PageAttributesParent2() { 35938 const { editPost: editPost2 } = (0, import_data95.useDispatch)(store); 35939 const [fieldValue, setFieldValue] = (0, import_element93.useState)(false); 35940 const { 35941 isHierarchical, 35942 parentPostId, 35943 parentPostTitle, 35944 pageItems, 35945 isLoading 35946 } = (0, import_data95.useSelect)( 35947 (select5) => { 35948 const { 35949 getPostType, 35950 getEntityRecords, 35951 getEntityRecord, 35952 isResolving 35953 } = select5(import_core_data61.store); 35954 const { getCurrentPostId: getCurrentPostId2, getEditedPostAttribute: getEditedPostAttribute2 } = select5(store); 35955 const postTypeSlug = getEditedPostAttribute2("type"); 35956 const pageId = getEditedPostAttribute2("parent"); 35957 const pType = getPostType(postTypeSlug); 35958 const postId2 = getCurrentPostId2(); 35959 const postIsHierarchical = pType?.hierarchical ?? false; 35960 const query = { 35961 per_page: 100, 35962 exclude: postId2, 35963 parent_exclude: postId2, 35964 orderby: "menu_order", 35965 order: "asc", 35966 _fields: "id,title,parent" 35967 }; 35968 if (!!fieldValue) { 35969 query.search = fieldValue; 35970 query.orderby = "relevance"; 35971 } 35972 const parentPost = pageId ? getEntityRecord("postType", postTypeSlug, pageId) : null; 35973 return { 35974 isHierarchical: postIsHierarchical, 35975 parentPostId: pageId, 35976 parentPostTitle: parentPost ? getTitle(parentPost) : "", 35977 pageItems: postIsHierarchical ? getEntityRecords("postType", postTypeSlug, query) : null, 35978 isLoading: postIsHierarchical ? isResolving("getEntityRecords", [ 35979 "postType", 35980 postTypeSlug, 35981 query 35982 ]) : false 35983 }; 35984 }, 35985 [fieldValue] 35986 ); 35987 const parentOptions = (0, import_element93.useMemo)(() => { 35988 const getOptionsFromTree = (tree2, level = 0) => { 35989 const mappedNodes = tree2.map((treeNode) => [ 35990 { 35991 value: treeNode.id, 35992 label: "\u2014 ".repeat(level) + (0, import_html_entities14.decodeEntities)(treeNode.name), 35993 rawName: treeNode.name 35994 }, 35995 ...getOptionsFromTree(treeNode.children || [], level + 1) 35996 ]); 35997 const sortedNodes = mappedNodes.sort(([a3], [b3]) => { 35998 const priorityA = getItemPriority2(a3.rawName, fieldValue); 35999 const priorityB = getItemPriority2(b3.rawName, fieldValue); 36000 return priorityA >= priorityB ? 1 : -1; 36001 }); 36002 return sortedNodes.flat(); 36003 }; 36004 if (!pageItems) { 36005 return []; 36006 } 36007 let tree = pageItems.map((item) => ({ 36008 id: item.id, 36009 parent: item.parent, 36010 name: getTitle(item) 36011 })); 36012 if (!fieldValue) { 36013 tree = buildTermsTree2(tree); 36014 } 36015 const opts = getOptionsFromTree(tree); 36016 const optsHasParent = opts.find( 36017 (item) => item.value === parentPostId 36018 ); 36019 if (parentPostTitle && !optsHasParent) { 36020 opts.unshift({ 36021 value: parentPostId, 36022 label: parentPostTitle 36023 }); 36024 } 36025 return opts; 36026 }, [pageItems, fieldValue, parentPostTitle, parentPostId]); 36027 if (!isHierarchical) { 36028 return null; 36029 } 36030 const handleKeydown = (inputValue) => { 36031 setFieldValue(inputValue); 36032 }; 36033 const handleChange = (selectedPostId) => { 36034 editPost2({ parent: selectedPostId }); 36035 }; 36036 return /* @__PURE__ */ (0, import_jsx_runtime212.jsx)( 36037 import_components111.ComboboxControl, 36038 { 36039 __next40pxDefaultSize: true, 36040 className: "editor-page-attributes__parent", 36041 label: (0, import_i18n127.__)("Parent"), 36042 help: (0, import_i18n127.__)("Choose a parent page."), 36043 value: parentPostId, 36044 options: parentOptions, 36045 onFilterValueChange: (0, import_compose23.debounce)(handleKeydown, 300), 36046 onChange: handleChange, 36047 hideLabelFromVision: true, 36048 isLoading 36049 } 36050 ); 36051 } 36052 function PostParentToggle({ isOpen, onClick }) { 36053 const parentPost = (0, import_data95.useSelect)((select5) => { 36054 const { getEditedPostAttribute: getEditedPostAttribute2 } = select5(store); 36055 const parentPostId = getEditedPostAttribute2("parent"); 36056 if (!parentPostId) { 36057 return null; 36058 } 36059 const { getEntityRecord } = select5(import_core_data61.store); 36060 const postTypeSlug = getEditedPostAttribute2("type"); 36061 return getEntityRecord("postType", postTypeSlug, parentPostId); 36062 }, []); 36063 const parentTitle = (0, import_element93.useMemo)( 36064 () => !parentPost ? (0, import_i18n127.__)("None") : getTitle(parentPost), 36065 [parentPost] 36066 ); 36067 return /* @__PURE__ */ (0, import_jsx_runtime212.jsx)( 36068 import_components111.Button, 36069 { 36070 size: "compact", 36071 className: "editor-post-parent__panel-toggle", 36072 variant: "tertiary", 36073 "aria-expanded": isOpen, 36074 "aria-label": ( 36075 // translators: %s: Current post parent. 36076 (0, import_i18n127.sprintf)((0, import_i18n127.__)("Change parent: %s"), parentTitle) 36077 ), 36078 onClick, 36079 children: parentTitle 36080 } 36081 ); 36082 } 36083 function ParentRow() { 36084 const homeUrl = (0, import_data95.useSelect)((select5) => { 36085 return select5(import_core_data61.store).getEntityRecord("root", "__unstableBase")?.home; 36086 }, []); 36087 const [popoverAnchor, setPopoverAnchor] = (0, import_element93.useState)(null); 36088 const popoverProps = (0, import_element93.useMemo)( 36089 () => ({ 36090 // Anchor the popover to the middle of the entire row so that it doesn't 36091 // move around when the label changes. 36092 anchor: popoverAnchor, 36093 placement: "left-start", 36094 offset: 36, 36095 shift: true 36096 }), 36097 [popoverAnchor] 36098 ); 36099 return /* @__PURE__ */ (0, import_jsx_runtime212.jsx)(post_panel_row_default, { label: (0, import_i18n127.__)("Parent"), ref: setPopoverAnchor, children: /* @__PURE__ */ (0, import_jsx_runtime212.jsx)( 36100 import_components111.Dropdown, 36101 { 36102 popoverProps, 36103 className: "editor-post-parent__panel-dropdown", 36104 contentClassName: "editor-post-parent__panel-dialog", 36105 focusOnMount: true, 36106 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime212.jsx)(PostParentToggle, { isOpen, onClick: onToggle }), 36107 renderContent: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime212.jsxs)("div", { className: "editor-post-parent", children: [ 36108 /* @__PURE__ */ (0, import_jsx_runtime212.jsx)( 36109 import_block_editor46.__experimentalInspectorPopoverHeader, 36110 { 36111 title: (0, import_i18n127.__)("Parent"), 36112 onClose 36113 } 36114 ), 36115 /* @__PURE__ */ (0, import_jsx_runtime212.jsxs)("div", { children: [ 36116 (0, import_element93.createInterpolateElement)( 36117 (0, import_i18n127.sprintf)( 36118 /* translators: %s: The home URL of the WordPress installation without the scheme. */ 36119 (0, import_i18n127.__)( 36120 'Child pages inherit characteristics from their parent, such as URL structure. For instance, if "Pricing" is a child of "Services", its URL would be %s<wbr />/services<wbr />/pricing.' 36121 ), 36122 (0, import_url10.filterURLForDisplay)(homeUrl).replace( 36123 /([/.])/g, 36124 "<wbr />$1" 36125 ) 36126 ), 36127 { 36128 wbr: /* @__PURE__ */ (0, import_jsx_runtime212.jsx)("wbr", {}) 36129 } 36130 ), 36131 /* @__PURE__ */ (0, import_jsx_runtime212.jsx)("p", { children: (0, import_element93.createInterpolateElement)( 36132 (0, import_i18n127.__)( 36133 "They also show up as sub-items in the default navigation menu. <a>Learn more.</a>" 36134 ), 36135 { 36136 a: /* @__PURE__ */ (0, import_jsx_runtime212.jsx)( 36137 import_components111.ExternalLink, 36138 { 36139 href: (0, import_i18n127.__)( 36140 "https://wordpress.org/documentation/article/page-post-settings-sidebar/#page-attributes" 36141 ) 36142 } 36143 ) 36144 } 36145 ) }) 36146 ] }), 36147 /* @__PURE__ */ (0, import_jsx_runtime212.jsx)(PageAttributesParent2, {}) 36148 ] }) 36149 } 36150 ) }); 36151 } 36152 var parent_default2 = PageAttributesParent2; 36153 36154 // packages/editor/build-module/components/page-attributes/panel.js 36155 var import_jsx_runtime213 = __toESM(require_jsx_runtime()); 36156 var PANEL_NAME = "page-attributes"; 36157 function AttributesPanel() { 36158 const { isEnabled, postType: postType2 } = (0, import_data96.useSelect)((select5) => { 36159 const { getEditedPostAttribute: getEditedPostAttribute2, isEditorPanelEnabled: isEditorPanelEnabled2 } = select5(store); 36160 const { getPostType } = select5(import_core_data62.store); 36161 return { 36162 isEnabled: isEditorPanelEnabled2(PANEL_NAME), 36163 postType: getPostType(getEditedPostAttribute2("type")) 36164 }; 36165 }, []); 36166 if (!isEnabled || !postType2) { 36167 return null; 36168 } 36169 return /* @__PURE__ */ (0, import_jsx_runtime213.jsx)(ParentRow, {}); 36170 } 36171 function PageAttributesPanel() { 36172 return /* @__PURE__ */ (0, import_jsx_runtime213.jsx)(check_default2, { children: /* @__PURE__ */ (0, import_jsx_runtime213.jsx)(AttributesPanel, {}) }); 36173 } 36174 36175 // packages/editor/build-module/components/post-template/classic-theme.js 36176 var import_i18n129 = __toESM(require_i18n()); 36177 var import_components113 = __toESM(require_components()); 36178 var import_data99 = __toESM(require_data()); 36179 var import_core_data64 = __toESM(require_core_data()); 36180 var import_block_editor47 = __toESM(require_block_editor()); 36181 var import_element96 = __toESM(require_element()); 36182 var import_notices20 = __toESM(require_notices()); 36183 36184 // packages/editor/build-module/components/post-template/create-new-template-modal.js 36185 var import_data97 = __toESM(require_data()); 36186 var import_element94 = __toESM(require_element()); 36187 var import_blocks24 = __toESM(require_blocks()); 36188 var import_components112 = __toESM(require_components()); 36189 var import_i18n128 = __toESM(require_i18n()); 36190 var import_jsx_runtime214 = __toESM(require_jsx_runtime()); 36191 var DEFAULT_TITLE = (0, import_i18n128.__)("Custom Template"); 36192 function CreateNewTemplateModal({ onClose }) { 36193 const { defaultBlockTemplate, onNavigateToEntityRecord } = (0, import_data97.useSelect)( 36194 (select5) => { 36195 const { getEditorSettings: getEditorSettings2, getCurrentTemplateId: getCurrentTemplateId2 } = select5(store); 36196 return { 36197 defaultBlockTemplate: getEditorSettings2().defaultBlockTemplate, 36198 onNavigateToEntityRecord: getEditorSettings2().onNavigateToEntityRecord, 36199 getTemplateId: getCurrentTemplateId2 36200 }; 36201 } 36202 ); 36203 const { createTemplate: createTemplate2 } = unlock((0, import_data97.useDispatch)(store)); 36204 const [title, setTitle] = (0, import_element94.useState)(""); 36205 const [isBusy, setIsBusy] = (0, import_element94.useState)(false); 36206 const cancel = () => { 36207 setTitle(""); 36208 onClose(); 36209 }; 36210 const submit = async (event) => { 36211 event.preventDefault(); 36212 if (isBusy) { 36213 return; 36214 } 36215 setIsBusy(true); 36216 const newTemplateContent = defaultBlockTemplate ?? (0, import_blocks24.serialize)([ 36217 (0, import_blocks24.createBlock)( 36218 "core/group", 36219 { 36220 tagName: "header", 36221 layout: { inherit: true } 36222 }, 36223 [ 36224 (0, import_blocks24.createBlock)("core/site-title"), 36225 (0, import_blocks24.createBlock)("core/site-tagline") 36226 ] 36227 ), 36228 (0, import_blocks24.createBlock)("core/separator"), 36229 (0, import_blocks24.createBlock)( 36230 "core/group", 36231 { 36232 tagName: "main" 36233 }, 36234 [ 36235 (0, import_blocks24.createBlock)( 36236 "core/group", 36237 { 36238 layout: { inherit: true } 36239 }, 36240 [(0, import_blocks24.createBlock)("core/post-title")] 36241 ), 36242 (0, import_blocks24.createBlock)("core/post-content", { 36243 layout: { inherit: true } 36244 }) 36245 ] 36246 ) 36247 ]); 36248 const newTemplate = await createTemplate2({ 36249 slug: paramCase(title || DEFAULT_TITLE) || "wp-custom-template", 36250 content: newTemplateContent, 36251 title: title || DEFAULT_TITLE, 36252 status: "publish" 36253 }); 36254 setIsBusy(false); 36255 onNavigateToEntityRecord({ 36256 postId: newTemplate.id, 36257 postType: "wp_template" 36258 }); 36259 cancel(); 36260 }; 36261 return /* @__PURE__ */ (0, import_jsx_runtime214.jsx)( 36262 import_components112.Modal, 36263 { 36264 title: (0, import_i18n128.__)("Create custom template"), 36265 onRequestClose: cancel, 36266 focusOnMount: "firstContentElement", 36267 size: "small", 36268 overlayClassName: "editor-post-template__create-template-modal", 36269 children: /* @__PURE__ */ (0, import_jsx_runtime214.jsx)( 36270 "form", 36271 { 36272 className: "editor-post-template__create-form", 36273 onSubmit: submit, 36274 children: /* @__PURE__ */ (0, import_jsx_runtime214.jsxs)(import_components112.__experimentalVStack, { spacing: "3", children: [ 36275 /* @__PURE__ */ (0, import_jsx_runtime214.jsx)( 36276 import_components112.TextControl, 36277 { 36278 __next40pxDefaultSize: true, 36279 label: (0, import_i18n128.__)("Name"), 36280 value: title, 36281 onChange: setTitle, 36282 placeholder: DEFAULT_TITLE, 36283 disabled: isBusy, 36284 help: (0, import_i18n128.__)( 36285 // eslint-disable-next-line no-restricted-syntax -- 'sidebar' is a common web design term for layouts 36286 'Describe the template, e.g. "Post with sidebar". A custom template can be manually applied to any post or page.' 36287 ) 36288 } 36289 ), 36290 /* @__PURE__ */ (0, import_jsx_runtime214.jsxs)(import_components112.__experimentalHStack, { justify: "right", children: [ 36291 /* @__PURE__ */ (0, import_jsx_runtime214.jsx)( 36292 import_components112.Button, 36293 { 36294 __next40pxDefaultSize: true, 36295 variant: "tertiary", 36296 onClick: cancel, 36297 children: (0, import_i18n128.__)("Cancel") 36298 } 36299 ), 36300 /* @__PURE__ */ (0, import_jsx_runtime214.jsx)( 36301 import_components112.Button, 36302 { 36303 __next40pxDefaultSize: true, 36304 variant: "primary", 36305 type: "submit", 36306 isBusy, 36307 "aria-disabled": isBusy, 36308 children: (0, import_i18n128.__)("Create") 36309 } 36310 ) 36311 ] }) 36312 ] }) 36313 } 36314 ) 36315 } 36316 ); 36317 } 36318 36319 // packages/editor/build-module/components/post-template/hooks.js 36320 var import_data98 = __toESM(require_data()); 36321 var import_element95 = __toESM(require_element()); 36322 var import_core_data63 = __toESM(require_core_data()); 36323 function useEditedPostContext() { 36324 return (0, import_data98.useSelect)((select5) => { 36325 const { getCurrentPostId: getCurrentPostId2, getCurrentPostType: getCurrentPostType2 } = select5(store); 36326 return { 36327 postId: getCurrentPostId2(), 36328 postType: getCurrentPostType2() 36329 }; 36330 }, []); 36331 } 36332 function useAllowSwitchingTemplates() { 36333 const { postType: postType2, postId: postId2 } = useEditedPostContext(); 36334 return (0, import_data98.useSelect)( 36335 (select5) => { 36336 const { canUser, getEntityRecord, getEntityRecords } = select5(import_core_data63.store); 36337 const siteSettings = canUser("read", { 36338 kind: "root", 36339 name: "site" 36340 }) ? getEntityRecord("root", "site") : void 0; 36341 const isPostsPage = +postId2 === siteSettings?.page_for_posts; 36342 const isFrontPage = postType2 === "page" && +postId2 === siteSettings?.page_on_front; 36343 const templates = isFrontPage ? getEntityRecords("postType", "wp_template", { 36344 per_page: -1 36345 }) : []; 36346 const hasFrontPage = isFrontPage && !!templates?.some(({ slug }) => slug === "front-page"); 36347 return !isPostsPage && !hasFrontPage; 36348 }, 36349 [postId2, postType2] 36350 ); 36351 } 36352 function useTemplates(postType2) { 36353 return (0, import_data98.useSelect)( 36354 (select5) => select5(import_core_data63.store).getEntityRecords("postType", "wp_template", { 36355 per_page: -1, 36356 post_type: postType2 36357 // We look at the combined templates for now (old endpoint) 36358 // because posts only accept slugs for templates, not IDs. 36359 }), 36360 [postType2] 36361 ); 36362 } 36363 function useAvailableTemplates(postType2) { 36364 const currentTemplateSlug = useCurrentTemplateSlug(); 36365 const allowSwitchingTemplate = useAllowSwitchingTemplates(); 36366 const templates = useTemplates(postType2); 36367 return (0, import_element95.useMemo)( 36368 () => allowSwitchingTemplate && templates?.filter( 36369 (template2) => template2.is_custom && template2.slug !== currentTemplateSlug && !!template2.content.raw 36370 // Skip empty templates. 36371 ), 36372 [templates, currentTemplateSlug, allowSwitchingTemplate] 36373 ); 36374 } 36375 function useCurrentTemplateSlug() { 36376 const { postType: postType2, postId: postId2 } = useEditedPostContext(); 36377 const templates = useTemplates(postType2); 36378 const entityTemplate = (0, import_data98.useSelect)( 36379 (select5) => { 36380 const post2 = select5(import_core_data63.store).getEditedEntityRecord( 36381 "postType", 36382 postType2, 36383 postId2 36384 ); 36385 return post2?.template; 36386 }, 36387 [postType2, postId2] 36388 ); 36389 if (!entityTemplate) { 36390 return; 36391 } 36392 return templates?.find((template2) => template2.slug === entityTemplate)?.slug; 36393 } 36394 36395 // packages/editor/build-module/components/post-template/classic-theme.js 36396 var import_jsx_runtime215 = __toESM(require_jsx_runtime()); 36397 function PostTemplateToggle({ isOpen, onClick }) { 36398 const templateTitle = (0, import_data99.useSelect)((select5) => { 36399 const templateSlug = select5(store).getEditedPostAttribute("template"); 36400 const { supportsTemplateMode, availableTemplates } = select5(store).getEditorSettings(); 36401 if (!supportsTemplateMode && availableTemplates[templateSlug]) { 36402 return availableTemplates[templateSlug]; 36403 } 36404 const template2 = select5(import_core_data64.store).canUser("create", { 36405 kind: "postType", 36406 name: "wp_template" 36407 }) && select5(store).getCurrentTemplateId(); 36408 return template2?.title || template2?.slug || availableTemplates?.[templateSlug]; 36409 }, []); 36410 return /* @__PURE__ */ (0, import_jsx_runtime215.jsx)( 36411 import_components113.Button, 36412 { 36413 __next40pxDefaultSize: true, 36414 variant: "tertiary", 36415 "aria-expanded": isOpen, 36416 "aria-label": (0, import_i18n129.__)("Template options"), 36417 onClick, 36418 children: templateTitle ?? (0, import_i18n129.__)("Default template") 36419 } 36420 ); 36421 } 36422 function PostTemplateDropdownContent({ onClose }) { 36423 const allowSwitchingTemplate = useAllowSwitchingTemplates(); 36424 const { 36425 availableTemplates, 36426 fetchedTemplates, 36427 selectedTemplateSlug, 36428 canCreate, 36429 canEdit, 36430 currentTemplateId, 36431 onNavigateToEntityRecord, 36432 getEditorSettings: getEditorSettings2 36433 } = (0, import_data99.useSelect)( 36434 (select5) => { 36435 const { canUser, getEntityRecords } = select5(import_core_data64.store); 36436 const editorSettings2 = select5(store).getEditorSettings(); 36437 const canCreateTemplates = canUser("create", { 36438 kind: "postType", 36439 name: "wp_template" 36440 }); 36441 const _currentTemplateId = select5(store).getCurrentTemplateId(); 36442 return { 36443 availableTemplates: editorSettings2.availableTemplates, 36444 fetchedTemplates: canCreateTemplates ? getEntityRecords("postType", "wp_template", { 36445 post_type: select5(store).getCurrentPostType(), 36446 per_page: -1 36447 }) : void 0, 36448 selectedTemplateSlug: select5(store).getEditedPostAttribute("template"), 36449 canCreate: allowSwitchingTemplate && canCreateTemplates && editorSettings2.supportsTemplateMode, 36450 canEdit: allowSwitchingTemplate && canCreateTemplates && editorSettings2.supportsTemplateMode && !!_currentTemplateId, 36451 currentTemplateId: _currentTemplateId, 36452 onNavigateToEntityRecord: editorSettings2.onNavigateToEntityRecord, 36453 getEditorSettings: select5(store).getEditorSettings 36454 }; 36455 }, 36456 [allowSwitchingTemplate] 36457 ); 36458 const options = (0, import_element96.useMemo)( 36459 () => Object.entries({ 36460 ...availableTemplates, 36461 ...Object.fromEntries( 36462 (fetchedTemplates ?? []).map(({ slug, title }) => [ 36463 slug, 36464 title.rendered 36465 ]) 36466 ) 36467 }).map(([slug, title]) => ({ value: slug, label: title })), 36468 [availableTemplates, fetchedTemplates] 36469 ); 36470 const selectedOption = options.find((option) => option.value === selectedTemplateSlug) ?? options.find((option) => !option.value); 36471 const { editPost: editPost2 } = (0, import_data99.useDispatch)(store); 36472 const { createSuccessNotice } = (0, import_data99.useDispatch)(import_notices20.store); 36473 const [isCreateModalOpen, setIsCreateModalOpen] = (0, import_element96.useState)(false); 36474 return /* @__PURE__ */ (0, import_jsx_runtime215.jsxs)("div", { className: "editor-post-template__classic-theme-dropdown", children: [ 36475 /* @__PURE__ */ (0, import_jsx_runtime215.jsx)( 36476 import_block_editor47.__experimentalInspectorPopoverHeader, 36477 { 36478 title: (0, import_i18n129.__)("Template"), 36479 help: (0, import_i18n129.__)( 36480 "Templates define the way content is displayed when viewing your site." 36481 ), 36482 actions: canCreate ? [ 36483 { 36484 icon: add_template_default, 36485 label: (0, import_i18n129.__)("Add template"), 36486 onClick: () => setIsCreateModalOpen(true) 36487 } 36488 ] : [], 36489 onClose 36490 } 36491 ), 36492 !allowSwitchingTemplate ? /* @__PURE__ */ (0, import_jsx_runtime215.jsx)(import_components113.Notice, { status: "warning", isDismissible: false, children: (0, import_i18n129.__)("The posts page template cannot be changed.") }) : /* @__PURE__ */ (0, import_jsx_runtime215.jsx)( 36493 import_components113.SelectControl, 36494 { 36495 __next40pxDefaultSize: true, 36496 hideLabelFromVision: true, 36497 label: (0, import_i18n129.__)("Template"), 36498 value: selectedOption?.value ?? "", 36499 options, 36500 onChange: (slug) => editPost2({ template: slug || "" }) 36501 } 36502 ), 36503 canEdit && onNavigateToEntityRecord && /* @__PURE__ */ (0, import_jsx_runtime215.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime215.jsx)( 36504 import_components113.Button, 36505 { 36506 __next40pxDefaultSize: true, 36507 variant: "link", 36508 onClick: () => { 36509 onNavigateToEntityRecord({ 36510 postId: currentTemplateId, 36511 postType: "wp_template" 36512 }); 36513 onClose(); 36514 createSuccessNotice( 36515 (0, import_i18n129.__)( 36516 "Editing template. Changes made here affect all posts and pages that use the template." 36517 ), 36518 { 36519 type: "snackbar", 36520 actions: [ 36521 { 36522 label: (0, import_i18n129.__)("Go back"), 36523 onClick: () => getEditorSettings2().onNavigateToPreviousEntityRecord() 36524 } 36525 ] 36526 } 36527 ); 36528 }, 36529 children: (0, import_i18n129.__)("Edit template") 36530 } 36531 ) }), 36532 isCreateModalOpen && /* @__PURE__ */ (0, import_jsx_runtime215.jsx)( 36533 CreateNewTemplateModal, 36534 { 36535 onClose: () => setIsCreateModalOpen(false) 36536 } 36537 ) 36538 ] }); 36539 } 36540 function ClassicThemeControl() { 36541 const [popoverAnchor, setPopoverAnchor] = (0, import_element96.useState)(null); 36542 const popoverProps = (0, import_element96.useMemo)( 36543 () => ({ 36544 // Anchor the popover to the middle of the entire row so that it doesn't 36545 // move around when the label changes. 36546 anchor: popoverAnchor, 36547 className: "editor-post-template__dropdown", 36548 placement: "left-start", 36549 offset: 36, 36550 shift: true 36551 }), 36552 [popoverAnchor] 36553 ); 36554 return /* @__PURE__ */ (0, import_jsx_runtime215.jsx)(post_panel_row_default, { label: (0, import_i18n129.__)("Template"), ref: setPopoverAnchor, children: /* @__PURE__ */ (0, import_jsx_runtime215.jsx)( 36555 import_components113.Dropdown, 36556 { 36557 popoverProps, 36558 focusOnMount: true, 36559 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime215.jsx)( 36560 PostTemplateToggle, 36561 { 36562 isOpen, 36563 onClick: onToggle 36564 } 36565 ), 36566 renderContent: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime215.jsx)(PostTemplateDropdownContent, { onClose }) 36567 } 36568 ) }); 36569 } 36570 var classic_theme_default = ClassicThemeControl; 36571 36572 // packages/editor/build-module/components/plugin-document-setting-panel/index.js 36573 var import_components115 = __toESM(require_components()); 36574 var import_plugins3 = __toESM(require_plugins()); 36575 var import_data101 = __toESM(require_data()); 36576 var import_warning = __toESM(require_warning()); 36577 36578 // packages/editor/build-module/components/preferences-modal/enable-plugin-document-setting-panel.js 36579 var import_components114 = __toESM(require_components()); 36580 36581 // packages/editor/build-module/components/preferences-modal/enable-panel.js 36582 var import_data100 = __toESM(require_data()); 36583 var import_preferences12 = __toESM(require_preferences()); 36584 var import_jsx_runtime216 = __toESM(require_jsx_runtime()); 36585 var { PreferenceBaseOption } = unlock(import_preferences12.privateApis); 36586 function EnablePanelOption(props) { 36587 const { toggleEditorPanelEnabled: toggleEditorPanelEnabled2 } = (0, import_data100.useDispatch)(store); 36588 const { isChecked, isRemoved } = (0, import_data100.useSelect)( 36589 (select5) => { 36590 const { isEditorPanelEnabled: isEditorPanelEnabled2, isEditorPanelRemoved: isEditorPanelRemoved2 } = select5(store); 36591 return { 36592 isChecked: isEditorPanelEnabled2(props.panelName), 36593 isRemoved: isEditorPanelRemoved2(props.panelName) 36594 }; 36595 }, 36596 [props.panelName] 36597 ); 36598 if (isRemoved) { 36599 return null; 36600 } 36601 return /* @__PURE__ */ (0, import_jsx_runtime216.jsx)( 36602 PreferenceBaseOption, 36603 { 36604 isChecked, 36605 onChange: () => toggleEditorPanelEnabled2(props.panelName), 36606 ...props 36607 } 36608 ); 36609 } 36610 36611 // packages/editor/build-module/components/preferences-modal/enable-plugin-document-setting-panel.js 36612 var import_jsx_runtime217 = __toESM(require_jsx_runtime()); 36613 var { Fill: Fill4, Slot: Slot4 } = (0, import_components114.createSlotFill)( 36614 "EnablePluginDocumentSettingPanelOption" 36615 ); 36616 var EnablePluginDocumentSettingPanelOption = ({ label, panelName }) => /* @__PURE__ */ (0, import_jsx_runtime217.jsx)(Fill4, { children: /* @__PURE__ */ (0, import_jsx_runtime217.jsx)(EnablePanelOption, { label, panelName }) }); 36617 EnablePluginDocumentSettingPanelOption.Slot = Slot4; 36618 var enable_plugin_document_setting_panel_default = EnablePluginDocumentSettingPanelOption; 36619 36620 // packages/editor/build-module/components/plugin-document-setting-panel/index.js 36621 var import_jsx_runtime218 = __toESM(require_jsx_runtime()); 36622 var { Fill: Fill5, Slot: Slot5 } = (0, import_components115.createSlotFill)("PluginDocumentSettingPanel"); 36623 var PluginDocumentSettingPanel = ({ 36624 name: name2, 36625 className, 36626 title, 36627 icon, 36628 children 36629 }) => { 36630 const { name: pluginName } = (0, import_plugins3.usePluginContext)(); 36631 const panelName = `$pluginName}/$name2}`; 36632 const { opened, isEnabled } = (0, import_data101.useSelect)( 36633 (select5) => { 36634 const { isEditorPanelOpened: isEditorPanelOpened2, isEditorPanelEnabled: isEditorPanelEnabled2 } = select5(store); 36635 return { 36636 opened: isEditorPanelOpened2(panelName), 36637 isEnabled: isEditorPanelEnabled2(panelName) 36638 }; 36639 }, 36640 [panelName] 36641 ); 36642 const { toggleEditorPanelOpened: toggleEditorPanelOpened2 } = (0, import_data101.useDispatch)(store); 36643 if (void 0 === name2) { 36644 (0, import_warning.default)("PluginDocumentSettingPanel requires a name property."); 36645 } 36646 return /* @__PURE__ */ (0, import_jsx_runtime218.jsxs)(import_jsx_runtime218.Fragment, { children: [ 36647 /* @__PURE__ */ (0, import_jsx_runtime218.jsx)( 36648 enable_plugin_document_setting_panel_default, 36649 { 36650 label: title, 36651 panelName 36652 } 36653 ), 36654 /* @__PURE__ */ (0, import_jsx_runtime218.jsx)(Fill5, { children: isEnabled && /* @__PURE__ */ (0, import_jsx_runtime218.jsx)( 36655 import_components115.PanelBody, 36656 { 36657 className, 36658 title, 36659 icon, 36660 opened, 36661 onToggle: () => toggleEditorPanelOpened2(panelName), 36662 children 36663 } 36664 ) }) 36665 ] }); 36666 }; 36667 PluginDocumentSettingPanel.Slot = Slot5; 36668 var plugin_document_setting_panel_default = PluginDocumentSettingPanel; 36669 36670 // packages/editor/build-module/components/block-settings-menu/plugin-block-settings-menu-item.js 36671 var import_block_editor48 = __toESM(require_block_editor()); 36672 var import_components116 = __toESM(require_components()); 36673 var import_compose24 = __toESM(require_compose()); 36674 var import_jsx_runtime219 = __toESM(require_jsx_runtime()); 36675 var isEverySelectedBlockAllowed = (selected, allowed) => selected.filter((id) => !allowed.includes(id)).length === 0; 36676 var shouldRenderItem = (selectedBlocks, allowedBlocks) => !Array.isArray(allowedBlocks) || isEverySelectedBlockAllowed(selectedBlocks, allowedBlocks); 36677 var PluginBlockSettingsMenuItem = ({ 36678 allowedBlocks, 36679 icon, 36680 label, 36681 onClick, 36682 small, 36683 role 36684 }) => /* @__PURE__ */ (0, import_jsx_runtime219.jsx)(import_block_editor48.BlockSettingsMenuControls, { children: ({ selectedBlocks, onClose }) => { 36685 if (!shouldRenderItem(selectedBlocks, allowedBlocks)) { 36686 return null; 36687 } 36688 return /* @__PURE__ */ (0, import_jsx_runtime219.jsx)( 36689 import_components116.MenuItem, 36690 { 36691 onClick: (0, import_compose24.compose)(onClick, onClose), 36692 icon, 36693 label: small ? label : void 0, 36694 role, 36695 children: !small && label 36696 } 36697 ); 36698 } }); 36699 var plugin_block_settings_menu_item_default = PluginBlockSettingsMenuItem; 36700 36701 // packages/editor/build-module/components/plugin-more-menu-item/index.js 36702 var import_components117 = __toESM(require_components()); 36703 var import_plugins4 = __toESM(require_plugins()); 36704 var import_jsx_runtime220 = __toESM(require_jsx_runtime()); 36705 function PluginMoreMenuItem(props) { 36706 const context = (0, import_plugins4.usePluginContext)(); 36707 return /* @__PURE__ */ (0, import_jsx_runtime220.jsx)( 36708 action_item_default, 36709 { 36710 name: "core/plugin-more-menu", 36711 as: props.as ?? import_components117.MenuItem, 36712 icon: props.icon || context.icon, 36713 ...props 36714 } 36715 ); 36716 } 36717 36718 // packages/editor/build-module/components/plugin-post-publish-panel/index.js 36719 var import_plugins5 = __toESM(require_plugins()); 36720 var import_components118 = __toESM(require_components()); 36721 var import_jsx_runtime221 = __toESM(require_jsx_runtime()); 36722 var { Fill: Fill6, Slot: Slot6 } = (0, import_components118.createSlotFill)("PluginPostPublishPanel"); 36723 var PluginPostPublishPanel = ({ 36724 children, 36725 className, 36726 title, 36727 initialOpen = false, 36728 icon 36729 }) => { 36730 const { icon: pluginIcon } = (0, import_plugins5.usePluginContext)(); 36731 return /* @__PURE__ */ (0, import_jsx_runtime221.jsx)(Fill6, { children: /* @__PURE__ */ (0, import_jsx_runtime221.jsx)( 36732 import_components118.PanelBody, 36733 { 36734 className, 36735 initialOpen: initialOpen || !title, 36736 title, 36737 icon: icon ?? pluginIcon, 36738 children 36739 } 36740 ) }); 36741 }; 36742 PluginPostPublishPanel.Slot = Slot6; 36743 var plugin_post_publish_panel_default = PluginPostPublishPanel; 36744 36745 // packages/editor/build-module/components/plugin-post-status-info/index.js 36746 var import_components119 = __toESM(require_components()); 36747 var import_jsx_runtime222 = __toESM(require_jsx_runtime()); 36748 var { Fill: Fill7, Slot: Slot7 } = (0, import_components119.createSlotFill)("PluginPostStatusInfo"); 36749 var PluginPostStatusInfo = ({ children, className }) => /* @__PURE__ */ (0, import_jsx_runtime222.jsx)(Fill7, { children: /* @__PURE__ */ (0, import_jsx_runtime222.jsx)(import_components119.PanelRow, { className, children }) }); 36750 PluginPostStatusInfo.Slot = Slot7; 36751 var plugin_post_status_info_default = PluginPostStatusInfo; 36752 36753 // packages/editor/build-module/components/plugin-pre-publish-panel/index.js 36754 var import_components120 = __toESM(require_components()); 36755 var import_plugins6 = __toESM(require_plugins()); 36756 var import_jsx_runtime223 = __toESM(require_jsx_runtime()); 36757 var { Fill: Fill8, Slot: Slot8 } = (0, import_components120.createSlotFill)("PluginPrePublishPanel"); 36758 var PluginPrePublishPanel = ({ 36759 children, 36760 className, 36761 title, 36762 initialOpen = false, 36763 icon 36764 }) => { 36765 const { icon: pluginIcon } = (0, import_plugins6.usePluginContext)(); 36766 return /* @__PURE__ */ (0, import_jsx_runtime223.jsx)(Fill8, { children: /* @__PURE__ */ (0, import_jsx_runtime223.jsx)( 36767 import_components120.PanelBody, 36768 { 36769 className, 36770 initialOpen: initialOpen || !title, 36771 title, 36772 icon: icon ?? pluginIcon, 36773 children 36774 } 36775 ) }); 36776 }; 36777 PluginPrePublishPanel.Slot = Slot8; 36778 var plugin_pre_publish_panel_default = PluginPrePublishPanel; 36779 36780 // packages/editor/build-module/components/plugin-preview-menu-item/index.js 36781 var import_components121 = __toESM(require_components()); 36782 var import_plugins7 = __toESM(require_plugins()); 36783 var import_jsx_runtime224 = __toESM(require_jsx_runtime()); 36784 function PluginPreviewMenuItem(props) { 36785 const context = (0, import_plugins7.usePluginContext)(); 36786 return /* @__PURE__ */ (0, import_jsx_runtime224.jsx)( 36787 action_item_default, 36788 { 36789 name: "core/plugin-preview-menu", 36790 as: props.as ?? import_components121.MenuItem, 36791 icon: props.icon || context.icon, 36792 ...props 36793 } 36794 ); 36795 } 36796 36797 // packages/editor/build-module/components/plugin-sidebar/index.js 36798 var import_jsx_runtime225 = __toESM(require_jsx_runtime()); 36799 function PluginSidebar({ className, ...props }) { 36800 return /* @__PURE__ */ (0, import_jsx_runtime225.jsx)( 36801 complementary_area_default, 36802 { 36803 panelClassName: className, 36804 className: "editor-sidebar", 36805 scope: "core", 36806 ...props 36807 } 36808 ); 36809 } 36810 36811 // packages/editor/build-module/components/plugin-sidebar-more-menu-item/index.js 36812 var import_jsx_runtime226 = __toESM(require_jsx_runtime()); 36813 function PluginSidebarMoreMenuItem(props) { 36814 return /* @__PURE__ */ (0, import_jsx_runtime226.jsx)( 36815 ComplementaryAreaMoreMenuItem, 36816 { 36817 __unstableExplicitMenuItem: true, 36818 scope: "core", 36819 ...props 36820 } 36821 ); 36822 } 36823 36824 // packages/editor/build-module/components/post-template/panel.js 36825 var import_data106 = __toESM(require_data()); 36826 var import_core_data69 = __toESM(require_core_data()); 36827 36828 // packages/editor/build-module/components/post-template/block-theme.js 36829 var import_data105 = __toESM(require_data()); 36830 var import_html_entities16 = __toESM(require_html_entities()); 36831 var import_components125 = __toESM(require_components()); 36832 var import_element99 = __toESM(require_element()); 36833 var import_i18n133 = __toESM(require_i18n()); 36834 var import_core_data68 = __toESM(require_core_data()); 36835 var import_notices21 = __toESM(require_notices()); 36836 var import_preferences13 = __toESM(require_preferences()); 36837 36838 // packages/editor/build-module/components/post-template/swap-template-button.js 36839 var import_element97 = __toESM(require_element()); 36840 var import_html_entities15 = __toESM(require_html_entities()); 36841 var import_block_editor49 = __toESM(require_block_editor()); 36842 var import_components122 = __toESM(require_components()); 36843 var import_i18n130 = __toESM(require_i18n()); 36844 var import_data102 = __toESM(require_data()); 36845 var import_core_data65 = __toESM(require_core_data()); 36846 var import_blocks25 = __toESM(require_blocks()); 36847 36848 // packages/editor/build-module/utils/search-templates.js 36849 var import_remove_accents3 = __toESM(require_remove_accents()); 36850 function normalizeSearchInput(input = "") { 36851 input = (0, import_remove_accents3.default)(input); 36852 input = input.trim().toLowerCase(); 36853 return input; 36854 } 36855 function getTemplateSearchRank(template2, searchValue) { 36856 const normalizedSearchValue = normalizeSearchInput(searchValue); 36857 const normalizedTitle = normalizeSearchInput(template2.title); 36858 let rank = 0; 36859 if (normalizedSearchValue === normalizedTitle) { 36860 rank += 30; 36861 } else if (normalizedTitle.startsWith(normalizedSearchValue)) { 36862 rank += 20; 36863 } else { 36864 const searchTerms = normalizedSearchValue.split(" "); 36865 const hasMatchedTerms = searchTerms.every( 36866 (searchTerm) => normalizedTitle.includes(searchTerm) 36867 ); 36868 if (hasMatchedTerms) { 36869 rank += 10; 36870 } 36871 } 36872 return rank; 36873 } 36874 function searchTemplates(templates = [], searchValue = "") { 36875 if (!searchValue) { 36876 return templates; 36877 } 36878 const rankedTemplates = templates.map((template2) => { 36879 return [template2, getTemplateSearchRank(template2, searchValue)]; 36880 }).filter(([, rank]) => rank > 0); 36881 rankedTemplates.sort(([, rank1], [, rank2]) => rank2 - rank1); 36882 return rankedTemplates.map(([template2]) => template2); 36883 } 36884 36885 // packages/editor/build-module/components/post-template/swap-template-button.js 36886 var import_jsx_runtime227 = __toESM(require_jsx_runtime()); 36887 function SwapTemplateButton({ onClick }) { 36888 const [showModal, setShowModal] = (0, import_element97.useState)(false); 36889 const { postType: postType2, postId: postId2 } = useEditedPostContext(); 36890 const availableTemplates = useAvailableTemplates(postType2); 36891 const { editEntityRecord } = (0, import_data102.useDispatch)(import_core_data65.store); 36892 const onTemplateSelect = async (template2) => { 36893 editEntityRecord( 36894 "postType", 36895 postType2, 36896 postId2, 36897 { template: template2.name }, 36898 { undoIgnore: true } 36899 ); 36900 setShowModal(false); 36901 onClick(); 36902 }; 36903 return /* @__PURE__ */ (0, import_jsx_runtime227.jsxs)(import_jsx_runtime227.Fragment, { children: [ 36904 /* @__PURE__ */ (0, import_jsx_runtime227.jsx)( 36905 import_components122.MenuItem, 36906 { 36907 disabled: !availableTemplates?.length, 36908 accessibleWhenDisabled: true, 36909 onClick: () => setShowModal(true), 36910 children: (0, import_i18n130.__)("Change template") 36911 } 36912 ), 36913 showModal && /* @__PURE__ */ (0, import_jsx_runtime227.jsx)( 36914 import_components122.Modal, 36915 { 36916 title: (0, import_i18n130.__)("Choose a template"), 36917 onRequestClose: () => setShowModal(false), 36918 overlayClassName: "editor-post-template__swap-template-modal", 36919 isFullScreen: true, 36920 children: /* @__PURE__ */ (0, import_jsx_runtime227.jsx)("div", { className: "editor-post-template__swap-template-modal-content", children: /* @__PURE__ */ (0, import_jsx_runtime227.jsx)( 36921 TemplatesList, 36922 { 36923 postType: postType2, 36924 onSelect: onTemplateSelect 36925 } 36926 ) }) 36927 } 36928 ) 36929 ] }); 36930 } 36931 function TemplatesList({ postType: postType2, onSelect }) { 36932 const [searchValue, setSearchValue] = (0, import_element97.useState)(""); 36933 const availableTemplates = useAvailableTemplates(postType2); 36934 const templatesAsPatterns = (0, import_element97.useMemo)( 36935 () => availableTemplates.map((template2) => ({ 36936 name: template2.slug, 36937 blocks: (0, import_blocks25.parse)(template2.content.raw), 36938 title: (0, import_html_entities15.decodeEntities)(template2.title.rendered), 36939 id: template2.id 36940 })), 36941 [availableTemplates] 36942 ); 36943 const filteredBlockTemplates = (0, import_element97.useMemo)(() => { 36944 return searchTemplates(templatesAsPatterns, searchValue); 36945 }, [templatesAsPatterns, searchValue]); 36946 return /* @__PURE__ */ (0, import_jsx_runtime227.jsxs)(import_jsx_runtime227.Fragment, { children: [ 36947 /* @__PURE__ */ (0, import_jsx_runtime227.jsx)( 36948 import_components122.SearchControl, 36949 { 36950 onChange: setSearchValue, 36951 value: searchValue, 36952 label: (0, import_i18n130.__)("Search"), 36953 placeholder: (0, import_i18n130.__)("Search"), 36954 className: "editor-post-template__swap-template-search" 36955 } 36956 ), 36957 /* @__PURE__ */ (0, import_jsx_runtime227.jsx)( 36958 import_block_editor49.__experimentalBlockPatternsList, 36959 { 36960 label: (0, import_i18n130.__)("Templates"), 36961 blockPatterns: filteredBlockTemplates, 36962 onClickPattern: onSelect 36963 } 36964 ) 36965 ] }); 36966 } 36967 36968 // packages/editor/build-module/components/post-template/reset-default-template.js 36969 var import_components123 = __toESM(require_components()); 36970 var import_i18n131 = __toESM(require_i18n()); 36971 var import_data103 = __toESM(require_data()); 36972 var import_core_data66 = __toESM(require_core_data()); 36973 var import_jsx_runtime228 = __toESM(require_jsx_runtime()); 36974 function ResetDefaultTemplate({ onClick }) { 36975 const currentTemplateSlug = useCurrentTemplateSlug(); 36976 const allowSwitchingTemplate = useAllowSwitchingTemplates(); 36977 const { postType: postType2, postId: postId2 } = useEditedPostContext(); 36978 const { editEntityRecord } = (0, import_data103.useDispatch)(import_core_data66.store); 36979 if (!currentTemplateSlug || !allowSwitchingTemplate) { 36980 return null; 36981 } 36982 return /* @__PURE__ */ (0, import_jsx_runtime228.jsx)( 36983 import_components123.MenuItem, 36984 { 36985 onClick: () => { 36986 editEntityRecord( 36987 "postType", 36988 postType2, 36989 postId2, 36990 { template: "" }, 36991 { undoIgnore: true } 36992 ); 36993 onClick(); 36994 }, 36995 children: (0, import_i18n131.__)("Use default template") 36996 } 36997 ); 36998 } 36999 37000 // packages/editor/build-module/components/post-template/create-new-template.js 37001 var import_components124 = __toESM(require_components()); 37002 var import_i18n132 = __toESM(require_i18n()); 37003 var import_data104 = __toESM(require_data()); 37004 var import_core_data67 = __toESM(require_core_data()); 37005 var import_element98 = __toESM(require_element()); 37006 var import_jsx_runtime229 = __toESM(require_jsx_runtime()); 37007 function CreateNewTemplate() { 37008 const { canCreateTemplates } = (0, import_data104.useSelect)((select5) => { 37009 const { canUser } = select5(import_core_data67.store); 37010 return { 37011 canCreateTemplates: canUser("create", { 37012 kind: "postType", 37013 name: "wp_template" 37014 }) 37015 }; 37016 }, []); 37017 const [isCreateModalOpen, setIsCreateModalOpen] = (0, import_element98.useState)(false); 37018 const allowSwitchingTemplate = useAllowSwitchingTemplates(); 37019 if (!canCreateTemplates || !allowSwitchingTemplate) { 37020 return null; 37021 } 37022 return /* @__PURE__ */ (0, import_jsx_runtime229.jsxs)(import_jsx_runtime229.Fragment, { children: [ 37023 /* @__PURE__ */ (0, import_jsx_runtime229.jsx)( 37024 import_components124.MenuItem, 37025 { 37026 onClick: () => { 37027 setIsCreateModalOpen(true); 37028 }, 37029 children: (0, import_i18n132.__)("Create new template") 37030 } 37031 ), 37032 isCreateModalOpen && /* @__PURE__ */ (0, import_jsx_runtime229.jsx)( 37033 CreateNewTemplateModal, 37034 { 37035 onClose: () => { 37036 setIsCreateModalOpen(false); 37037 } 37038 } 37039 ) 37040 ] }); 37041 } 37042 37043 // packages/editor/build-module/components/post-template/block-theme.js 37044 var import_jsx_runtime230 = __toESM(require_jsx_runtime()); 37045 function BlockThemeControl({ id }) { 37046 const { 37047 isTemplateHidden, 37048 onNavigateToEntityRecord, 37049 getEditorSettings: getEditorSettings2, 37050 hasGoBack, 37051 hasSpecificTemplate 37052 } = (0, import_data105.useSelect)((select5) => { 37053 const { 37054 getRenderingMode: getRenderingMode2, 37055 getEditorSettings: _getEditorSettings, 37056 getCurrentPost: getCurrentPost2 37057 } = unlock(select5(store)); 37058 const editorSettings2 = _getEditorSettings(); 37059 const currentPost = getCurrentPost2(); 37060 return { 37061 isTemplateHidden: getRenderingMode2() === "post-only", 37062 onNavigateToEntityRecord: editorSettings2.onNavigateToEntityRecord, 37063 getEditorSettings: _getEditorSettings, 37064 hasGoBack: editorSettings2.hasOwnProperty( 37065 "onNavigateToPreviousEntityRecord" 37066 ), 37067 hasSpecificTemplate: !!currentPost.template 37068 }; 37069 }, []); 37070 const { get: getPreference } = (0, import_data105.useSelect)(import_preferences13.store); 37071 const { editedRecord: template2, hasResolved } = (0, import_core_data68.useEntityRecord)( 37072 "postType", 37073 "wp_template", 37074 id 37075 ); 37076 const { getEntityRecord } = (0, import_data105.useSelect)(import_core_data68.store); 37077 const { editEntityRecord } = (0, import_data105.useDispatch)(import_core_data68.store); 37078 const { createSuccessNotice } = (0, import_data105.useDispatch)(import_notices21.store); 37079 const { setRenderingMode: setRenderingMode2, setDefaultRenderingMode: setDefaultRenderingMode2 } = unlock( 37080 (0, import_data105.useDispatch)(store) 37081 ); 37082 const canCreateTemplate = (0, import_data105.useSelect)( 37083 (select5) => !!select5(import_core_data68.store).canUser("create", { 37084 kind: "postType", 37085 name: "wp_template" 37086 }), 37087 [] 37088 ); 37089 const [popoverAnchor, setPopoverAnchor] = (0, import_element99.useState)(null); 37090 const popoverProps = (0, import_element99.useMemo)( 37091 () => ({ 37092 // Anchor the popover to the middle of the entire row so that it doesn't 37093 // move around when the label changes. 37094 anchor: popoverAnchor, 37095 className: "editor-post-template__dropdown", 37096 placement: "left-start", 37097 offset: 36, 37098 shift: true 37099 }), 37100 [popoverAnchor] 37101 ); 37102 if (!hasResolved) { 37103 return null; 37104 } 37105 const notificationAction = hasGoBack ? [ 37106 { 37107 label: (0, import_i18n133.__)("Go back"), 37108 onClick: () => getEditorSettings2().onNavigateToPreviousEntityRecord() 37109 } 37110 ] : void 0; 37111 const mayShowTemplateEditNotice = () => { 37112 if (!getPreference("core/edit-site", "welcomeGuideTemplate")) { 37113 createSuccessNotice( 37114 (0, import_i18n133.__)( 37115 "Editing template. Changes made here affect all posts and pages that use the template." 37116 ), 37117 { type: "snackbar", actions: notificationAction } 37118 ); 37119 } 37120 }; 37121 return /* @__PURE__ */ (0, import_jsx_runtime230.jsx)(post_panel_row_default, { label: (0, import_i18n133.__)("Template"), ref: setPopoverAnchor, children: /* @__PURE__ */ (0, import_jsx_runtime230.jsx)( 37122 import_components125.DropdownMenu, 37123 { 37124 popoverProps, 37125 focusOnMount: true, 37126 toggleProps: { 37127 size: "compact", 37128 variant: "tertiary", 37129 tooltipPosition: "middle left" 37130 }, 37131 label: (0, import_i18n133.__)("Template options"), 37132 text: (0, import_html_entities16.decodeEntities)(template2.title), 37133 icon: null, 37134 children: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime230.jsxs)(import_jsx_runtime230.Fragment, { children: [ 37135 /* @__PURE__ */ (0, import_jsx_runtime230.jsxs)(import_components125.MenuGroup, { children: [ 37136 canCreateTemplate && /* @__PURE__ */ (0, import_jsx_runtime230.jsx)( 37137 import_components125.MenuItem, 37138 { 37139 onClick: async () => { 37140 onNavigateToEntityRecord({ 37141 postId: template2.id, 37142 postType: "wp_template" 37143 }); 37144 if (!hasSpecificTemplate && window?.__experimentalTemplateActivate) { 37145 const activeTemplates = await getEntityRecord( 37146 "root", 37147 "site" 37148 ).active_templates; 37149 if (activeTemplates[template2.slug] !== template2.id) { 37150 editEntityRecord( 37151 "root", 37152 "site", 37153 void 0, 37154 { 37155 active_templates: { 37156 ...activeTemplates, 37157 [template2.slug]: template2.id 37158 } 37159 } 37160 ); 37161 } 37162 } 37163 onClose(); 37164 mayShowTemplateEditNotice(); 37165 }, 37166 children: (0, import_i18n133.__)("Edit template") 37167 } 37168 ), 37169 /* @__PURE__ */ (0, import_jsx_runtime230.jsx)(SwapTemplateButton, { onClick: onClose }), 37170 /* @__PURE__ */ (0, import_jsx_runtime230.jsx)(ResetDefaultTemplate, { onClick: onClose }), 37171 canCreateTemplate && /* @__PURE__ */ (0, import_jsx_runtime230.jsx)(CreateNewTemplate, {}) 37172 ] }), 37173 /* @__PURE__ */ (0, import_jsx_runtime230.jsx)(import_components125.MenuGroup, { children: /* @__PURE__ */ (0, import_jsx_runtime230.jsx)( 37174 import_components125.MenuItem, 37175 { 37176 icon: !isTemplateHidden ? check_default : void 0, 37177 isSelected: !isTemplateHidden, 37178 role: "menuitemcheckbox", 37179 onClick: () => { 37180 const newRenderingMode = isTemplateHidden ? "template-locked" : "post-only"; 37181 setRenderingMode2(newRenderingMode); 37182 setDefaultRenderingMode2(newRenderingMode); 37183 }, 37184 children: (0, import_i18n133.__)("Show template") 37185 } 37186 ) }) 37187 ] }) 37188 } 37189 ) }); 37190 } 37191 37192 // packages/editor/build-module/components/post-template/panel.js 37193 var import_jsx_runtime231 = __toESM(require_jsx_runtime()); 37194 function PostTemplatePanel() { 37195 const { templateId: templateId2, isBlockTheme } = (0, import_data106.useSelect)((select5) => { 37196 const { getCurrentTemplateId: getCurrentTemplateId2, getEditorSettings: getEditorSettings2 } = select5(store); 37197 return { 37198 templateId: getCurrentTemplateId2(), 37199 isBlockTheme: getEditorSettings2().__unstableIsBlockBasedTheme 37200 }; 37201 }, []); 37202 const isVisible = (0, import_data106.useSelect)((select5) => { 37203 const postTypeSlug = select5(store).getCurrentPostType(); 37204 const postType2 = select5(import_core_data69.store).getPostType(postTypeSlug); 37205 if (!postType2?.viewable) { 37206 return false; 37207 } 37208 const settings = select5(store).getEditorSettings(); 37209 const hasTemplates = !!settings.availableTemplates && Object.keys(settings.availableTemplates).length > 0; 37210 if (hasTemplates) { 37211 return true; 37212 } 37213 if (!settings.supportsTemplateMode) { 37214 return false; 37215 } 37216 const canCreateTemplates = select5(import_core_data69.store).canUser("create", { 37217 kind: "postType", 37218 name: "wp_template" 37219 }) ?? false; 37220 return canCreateTemplates; 37221 }, []); 37222 const canViewTemplates = (0, import_data106.useSelect)( 37223 (select5) => { 37224 return isVisible ? select5(import_core_data69.store).canUser("read", { 37225 kind: "postType", 37226 name: "wp_template" 37227 }) : false; 37228 }, 37229 [isVisible] 37230 ); 37231 if ((!isBlockTheme || !canViewTemplates) && isVisible) { 37232 return /* @__PURE__ */ (0, import_jsx_runtime231.jsx)(classic_theme_default, {}); 37233 } 37234 if (isBlockTheme && !!templateId2) { 37235 return /* @__PURE__ */ (0, import_jsx_runtime231.jsx)(BlockThemeControl, { id: templateId2 }); 37236 } 37237 return null; 37238 } 37239 37240 // packages/editor/build-module/components/post-author/index.js 37241 var import_data110 = __toESM(require_data()); 37242 var import_core_data71 = __toESM(require_core_data()); 37243 37244 // packages/editor/build-module/components/post-author/combobox.js 37245 var import_compose25 = __toESM(require_compose()); 37246 var import_element101 = __toESM(require_element()); 37247 var import_data108 = __toESM(require_data()); 37248 var import_i18n135 = __toESM(require_i18n()); 37249 var import_components126 = __toESM(require_components()); 37250 37251 // packages/editor/build-module/components/post-author/hook.js 37252 var import_i18n134 = __toESM(require_i18n()); 37253 var import_element100 = __toESM(require_element()); 37254 var import_data107 = __toESM(require_data()); 37255 var import_html_entities17 = __toESM(require_html_entities()); 37256 var import_core_data70 = __toESM(require_core_data()); 37257 37258 // packages/editor/build-module/components/post-author/constants.js 37259 var BASE_QUERY = { 37260 _fields: "id,name", 37261 context: "view" 37262 // Allows non-admins to perform requests. 37263 }; 37264 var AUTHORS_QUERY = { 37265 who: "authors", 37266 per_page: 100, 37267 ...BASE_QUERY 37268 }; 37269 37270 // packages/editor/build-module/components/post-author/hook.js 37271 function useAuthorsQuery(search) { 37272 const { authorId, authors, postAuthor, isLoading } = (0, import_data107.useSelect)( 37273 (select5) => { 37274 const { getUser, getUsers, isResolving } = select5(import_core_data70.store); 37275 const { getEditedPostAttribute: getEditedPostAttribute2 } = select5(store); 37276 const _authorId = getEditedPostAttribute2("author"); 37277 const query = { ...AUTHORS_QUERY }; 37278 if (search) { 37279 query.search = search; 37280 query.search_columns = ["name"]; 37281 } 37282 return { 37283 authorId: _authorId, 37284 authors: getUsers(query), 37285 postAuthor: getUser(_authorId, BASE_QUERY), 37286 isLoading: isResolving("getUsers", [query]) 37287 }; 37288 }, 37289 [search] 37290 ); 37291 const authorOptions = (0, import_element100.useMemo)(() => { 37292 const fetchedAuthors = (authors ?? []).map((author) => { 37293 return { 37294 value: author.id, 37295 label: (0, import_html_entities17.decodeEntities)(author.name) 37296 }; 37297 }); 37298 const foundAuthor = fetchedAuthors.findIndex( 37299 ({ value }) => postAuthor?.id === value 37300 ); 37301 let currentAuthor = []; 37302 if (foundAuthor < 0 && postAuthor) { 37303 currentAuthor = [ 37304 { 37305 value: postAuthor.id, 37306 label: (0, import_html_entities17.decodeEntities)(postAuthor.name) 37307 } 37308 ]; 37309 } else if (foundAuthor < 0 && !postAuthor) { 37310 currentAuthor = [ 37311 { 37312 value: 0, 37313 label: (0, import_i18n134.__)("(No author)") 37314 } 37315 ]; 37316 } 37317 return [...currentAuthor, ...fetchedAuthors]; 37318 }, [authors, postAuthor]); 37319 return { authorId, authorOptions, postAuthor, isLoading }; 37320 } 37321 37322 // packages/editor/build-module/components/post-author/combobox.js 37323 var import_jsx_runtime232 = __toESM(require_jsx_runtime()); 37324 function PostAuthorCombobox() { 37325 const [fieldValue, setFieldValue] = (0, import_element101.useState)(); 37326 const { editPost: editPost2 } = (0, import_data108.useDispatch)(store); 37327 const { authorId, authorOptions, isLoading } = useAuthorsQuery(fieldValue); 37328 const handleSelect = (postAuthorId) => { 37329 if (!postAuthorId) { 37330 return; 37331 } 37332 editPost2({ author: postAuthorId }); 37333 }; 37334 return /* @__PURE__ */ (0, import_jsx_runtime232.jsx)( 37335 import_components126.ComboboxControl, 37336 { 37337 __next40pxDefaultSize: true, 37338 label: (0, import_i18n135.__)("Author"), 37339 options: authorOptions, 37340 value: authorId, 37341 onFilterValueChange: (0, import_compose25.debounce)(setFieldValue, 300), 37342 onChange: handleSelect, 37343 allowReset: false, 37344 hideLabelFromVision: true, 37345 isLoading 37346 } 37347 ); 37348 } 37349 37350 // packages/editor/build-module/components/post-author/select.js 37351 var import_i18n136 = __toESM(require_i18n()); 37352 var import_data109 = __toESM(require_data()); 37353 var import_components127 = __toESM(require_components()); 37354 var import_jsx_runtime233 = __toESM(require_jsx_runtime()); 37355 function PostAuthorSelect() { 37356 const { editPost: editPost2 } = (0, import_data109.useDispatch)(store); 37357 const { authorId, authorOptions } = useAuthorsQuery(); 37358 const setAuthorId = (value) => { 37359 const author = Number(value); 37360 editPost2({ author }); 37361 }; 37362 return /* @__PURE__ */ (0, import_jsx_runtime233.jsx)( 37363 import_components127.SelectControl, 37364 { 37365 __next40pxDefaultSize: true, 37366 className: "post-author-selector", 37367 label: (0, import_i18n136.__)("Author"), 37368 options: authorOptions, 37369 onChange: setAuthorId, 37370 value: authorId, 37371 hideLabelFromVision: true 37372 } 37373 ); 37374 } 37375 37376 // packages/editor/build-module/components/post-author/index.js 37377 var import_jsx_runtime234 = __toESM(require_jsx_runtime()); 37378 var minimumUsersForCombobox = 25; 37379 function PostAuthor() { 37380 const showCombobox = (0, import_data110.useSelect)((select5) => { 37381 const authors = select5(import_core_data71.store).getUsers(AUTHORS_QUERY); 37382 return authors?.length >= minimumUsersForCombobox; 37383 }, []); 37384 if (showCombobox) { 37385 return /* @__PURE__ */ (0, import_jsx_runtime234.jsx)(PostAuthorCombobox, {}); 37386 } 37387 return /* @__PURE__ */ (0, import_jsx_runtime234.jsx)(PostAuthorSelect, {}); 37388 } 37389 var post_author_default = PostAuthor; 37390 37391 // packages/editor/build-module/components/post-author/check.js 37392 var import_data111 = __toESM(require_data()); 37393 var import_jsx_runtime235 = __toESM(require_jsx_runtime()); 37394 function PostAuthorCheck({ children }) { 37395 const { hasAssignAuthorAction } = (0, import_data111.useSelect)((select5) => { 37396 const post2 = select5(store).getCurrentPost(); 37397 const canAssignAuthor = post2?._links?.["wp:action-assign-author"] ? true : false; 37398 return { 37399 hasAssignAuthorAction: canAssignAuthor 37400 }; 37401 }, []); 37402 if (!hasAssignAuthorAction) { 37403 return null; 37404 } 37405 return /* @__PURE__ */ (0, import_jsx_runtime235.jsx)(post_type_support_check_default, { supportKeys: "author", children }); 37406 } 37407 37408 // packages/editor/build-module/components/post-author/panel.js 37409 var import_i18n137 = __toESM(require_i18n()); 37410 var import_components128 = __toESM(require_components()); 37411 var import_element102 = __toESM(require_element()); 37412 var import_html_entities18 = __toESM(require_html_entities()); 37413 var import_block_editor50 = __toESM(require_block_editor()); 37414 var import_data112 = __toESM(require_data()); 37415 var import_core_data72 = __toESM(require_core_data()); 37416 var import_jsx_runtime236 = __toESM(require_jsx_runtime()); 37417 function PostAuthorToggle({ isOpen, onClick }) { 37418 const { postAuthor } = (0, import_data112.useSelect)((select5) => { 37419 const id = select5(store).getEditedPostAttribute("author"); 37420 return { 37421 postAuthor: select5(import_core_data72.store).getUser(id, BASE_QUERY) 37422 }; 37423 }, []); 37424 const authorName = (0, import_html_entities18.decodeEntities)(postAuthor?.name) || (0, import_i18n137.__)("(No author)"); 37425 return /* @__PURE__ */ (0, import_jsx_runtime236.jsx)( 37426 import_components128.Button, 37427 { 37428 size: "compact", 37429 className: "editor-post-author__panel-toggle", 37430 variant: "tertiary", 37431 "aria-expanded": isOpen, 37432 "aria-label": ( 37433 // translators: %s: Author name. 37434 (0, import_i18n137.sprintf)((0, import_i18n137.__)("Change author: %s"), authorName) 37435 ), 37436 onClick, 37437 children: authorName 37438 } 37439 ); 37440 } 37441 function PostAuthor2() { 37442 const [popoverAnchor, setPopoverAnchor] = (0, import_element102.useState)(null); 37443 const popoverProps = (0, import_element102.useMemo)( 37444 () => ({ 37445 // Anchor the popover to the middle of the entire row so that it doesn't 37446 // move around when the label changes. 37447 anchor: popoverAnchor, 37448 placement: "left-start", 37449 offset: 36, 37450 shift: true 37451 }), 37452 [popoverAnchor] 37453 ); 37454 return /* @__PURE__ */ (0, import_jsx_runtime236.jsx)(PostAuthorCheck, { children: /* @__PURE__ */ (0, import_jsx_runtime236.jsx)(post_panel_row_default, { label: (0, import_i18n137.__)("Author"), ref: setPopoverAnchor, children: /* @__PURE__ */ (0, import_jsx_runtime236.jsx)( 37455 import_components128.Dropdown, 37456 { 37457 popoverProps, 37458 contentClassName: "editor-post-author__panel-dialog", 37459 focusOnMount: true, 37460 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime236.jsx)( 37461 PostAuthorToggle, 37462 { 37463 isOpen, 37464 onClick: onToggle 37465 } 37466 ), 37467 renderContent: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime236.jsxs)("div", { className: "editor-post-author", children: [ 37468 /* @__PURE__ */ (0, import_jsx_runtime236.jsx)( 37469 import_block_editor50.__experimentalInspectorPopoverHeader, 37470 { 37471 title: (0, import_i18n137.__)("Author"), 37472 onClose 37473 } 37474 ), 37475 /* @__PURE__ */ (0, import_jsx_runtime236.jsx)(post_author_default, { onClose }) 37476 ] }) 37477 } 37478 ) }) }); 37479 } 37480 var panel_default = PostAuthor2; 37481 37482 // packages/editor/build-module/components/post-comments/index.js 37483 var import_i18n138 = __toESM(require_i18n()); 37484 var import_components129 = __toESM(require_components()); 37485 var import_data113 = __toESM(require_data()); 37486 var import_jsx_runtime237 = __toESM(require_jsx_runtime()); 37487 var COMMENT_OPTIONS = [ 37488 { 37489 label: (0, import_i18n138._x)("Open", 'Adjective: e.g. "Comments are open"'), 37490 value: "open", 37491 description: (0, import_i18n138.__)("Visitors can add new comments and replies.") 37492 }, 37493 { 37494 label: (0, import_i18n138.__)("Closed"), 37495 value: "closed", 37496 description: [ 37497 (0, import_i18n138.__)("Visitors cannot add new comments or replies."), 37498 (0, import_i18n138.__)("Existing comments remain visible.") 37499 ].join(" ") 37500 } 37501 ]; 37502 function PostComments() { 37503 const commentStatus = (0, import_data113.useSelect)( 37504 (select5) => select5(store).getEditedPostAttribute("comment_status") ?? "open", 37505 [] 37506 ); 37507 const { editPost: editPost2 } = (0, import_data113.useDispatch)(store); 37508 const handleStatus = (newCommentStatus) => editPost2({ 37509 comment_status: newCommentStatus 37510 }); 37511 return /* @__PURE__ */ (0, import_jsx_runtime237.jsx)("form", { children: /* @__PURE__ */ (0, import_jsx_runtime237.jsx)(import_components129.__experimentalVStack, { spacing: 4, children: /* @__PURE__ */ (0, import_jsx_runtime237.jsx)( 37512 import_components129.RadioControl, 37513 { 37514 className: "editor-change-status__options", 37515 hideLabelFromVision: true, 37516 label: (0, import_i18n138.__)("Comment status"), 37517 options: COMMENT_OPTIONS, 37518 onChange: handleStatus, 37519 selected: commentStatus 37520 } 37521 ) }) }); 37522 } 37523 var post_comments_default = PostComments; 37524 37525 // packages/editor/build-module/components/post-discussion/panel.js 37526 var import_i18n140 = __toESM(require_i18n()); 37527 var import_components131 = __toESM(require_components()); 37528 var import_data115 = __toESM(require_data()); 37529 var import_element103 = __toESM(require_element()); 37530 var import_block_editor51 = __toESM(require_block_editor()); 37531 var import_core_data73 = __toESM(require_core_data()); 37532 37533 // packages/editor/build-module/components/post-pingbacks/index.js 37534 var import_i18n139 = __toESM(require_i18n()); 37535 var import_components130 = __toESM(require_components()); 37536 var import_data114 = __toESM(require_data()); 37537 var import_jsx_runtime238 = __toESM(require_jsx_runtime()); 37538 function PostPingbacks() { 37539 const pingStatus = (0, import_data114.useSelect)( 37540 (select5) => select5(store).getEditedPostAttribute("ping_status") ?? "open", 37541 [] 37542 ); 37543 const { editPost: editPost2 } = (0, import_data114.useDispatch)(store); 37544 const onTogglePingback = () => editPost2({ 37545 ping_status: pingStatus === "open" ? "closed" : "open" 37546 }); 37547 return /* @__PURE__ */ (0, import_jsx_runtime238.jsx)( 37548 import_components130.CheckboxControl, 37549 { 37550 label: (0, import_i18n139.__)("Enable pingbacks & trackbacks"), 37551 checked: pingStatus === "open", 37552 onChange: onTogglePingback, 37553 help: /* @__PURE__ */ (0, import_jsx_runtime238.jsx)( 37554 import_components130.ExternalLink, 37555 { 37556 href: (0, import_i18n139.__)( 37557 "https://wordpress.org/documentation/article/trackbacks-and-pingbacks/" 37558 ), 37559 children: (0, import_i18n139.__)("Learn more about pingbacks & trackbacks") 37560 } 37561 ) 37562 } 37563 ); 37564 } 37565 var post_pingbacks_default = PostPingbacks; 37566 37567 // packages/editor/build-module/components/post-discussion/panel.js 37568 var import_jsx_runtime239 = __toESM(require_jsx_runtime()); 37569 var PANEL_NAME2 = "discussion-panel"; 37570 function ModalContents({ onClose }) { 37571 return /* @__PURE__ */ (0, import_jsx_runtime239.jsxs)("div", { className: "editor-post-discussion", children: [ 37572 /* @__PURE__ */ (0, import_jsx_runtime239.jsx)( 37573 import_block_editor51.__experimentalInspectorPopoverHeader, 37574 { 37575 title: (0, import_i18n140.__)("Discussion"), 37576 onClose 37577 } 37578 ), 37579 /* @__PURE__ */ (0, import_jsx_runtime239.jsxs)(import_components131.__experimentalVStack, { spacing: 4, children: [ 37580 /* @__PURE__ */ (0, import_jsx_runtime239.jsx)(post_type_support_check_default, { supportKeys: "comments", children: /* @__PURE__ */ (0, import_jsx_runtime239.jsx)(post_comments_default, {}) }), 37581 /* @__PURE__ */ (0, import_jsx_runtime239.jsx)(post_type_support_check_default, { supportKeys: "trackbacks", children: /* @__PURE__ */ (0, import_jsx_runtime239.jsx)(post_pingbacks_default, {}) }) 37582 ] }) 37583 ] }); 37584 } 37585 function PostDiscussionToggle({ isOpen, onClick }) { 37586 const { 37587 commentStatus, 37588 pingStatus, 37589 commentsSupported, 37590 trackbacksSupported 37591 } = (0, import_data115.useSelect)((select5) => { 37592 const { getEditedPostAttribute: getEditedPostAttribute2 } = select5(store); 37593 const { getPostType } = select5(import_core_data73.store); 37594 const postType2 = getPostType(getEditedPostAttribute2("type")); 37595 return { 37596 commentStatus: getEditedPostAttribute2("comment_status") ?? "open", 37597 pingStatus: getEditedPostAttribute2("ping_status") ?? "open", 37598 commentsSupported: !!postType2.supports.comments, 37599 trackbacksSupported: !!postType2.supports.trackbacks 37600 }; 37601 }, []); 37602 let label; 37603 if (commentStatus === "open") { 37604 if (pingStatus === "open") { 37605 label = (0, import_i18n140._x)("Open", 'Adjective: e.g. "Comments are open"'); 37606 } else { 37607 label = trackbacksSupported ? (0, import_i18n140.__)("Comments only") : (0, import_i18n140._x)("Open", 'Adjective: e.g. "Comments are open"'); 37608 } 37609 } else if (pingStatus === "open") { 37610 label = commentsSupported ? (0, import_i18n140.__)("Pings only") : (0, import_i18n140.__)("Pings enabled"); 37611 } else { 37612 label = (0, import_i18n140.__)("Closed"); 37613 } 37614 return /* @__PURE__ */ (0, import_jsx_runtime239.jsx)( 37615 import_components131.Button, 37616 { 37617 size: "compact", 37618 className: "editor-post-discussion__panel-toggle", 37619 variant: "tertiary", 37620 "aria-label": (0, import_i18n140.__)("Change discussion options"), 37621 "aria-expanded": isOpen, 37622 onClick, 37623 children: label 37624 } 37625 ); 37626 } 37627 function PostDiscussionPanel() { 37628 const { isEnabled } = (0, import_data115.useSelect)((select5) => { 37629 const { isEditorPanelEnabled: isEditorPanelEnabled2 } = select5(store); 37630 return { 37631 isEnabled: isEditorPanelEnabled2(PANEL_NAME2) 37632 }; 37633 }, []); 37634 const [popoverAnchor, setPopoverAnchor] = (0, import_element103.useState)(null); 37635 const popoverProps = (0, import_element103.useMemo)( 37636 () => ({ 37637 // Anchor the popover to the middle of the entire row so that it doesn't 37638 // move around when the label changes. 37639 anchor: popoverAnchor, 37640 placement: "left-start", 37641 offset: 36, 37642 shift: true 37643 }), 37644 [popoverAnchor] 37645 ); 37646 if (!isEnabled) { 37647 return null; 37648 } 37649 return /* @__PURE__ */ (0, import_jsx_runtime239.jsx)(post_type_support_check_default, { supportKeys: ["comments", "trackbacks"], children: /* @__PURE__ */ (0, import_jsx_runtime239.jsx)(post_panel_row_default, { label: (0, import_i18n140.__)("Discussion"), ref: setPopoverAnchor, children: /* @__PURE__ */ (0, import_jsx_runtime239.jsx)( 37650 import_components131.Dropdown, 37651 { 37652 popoverProps, 37653 className: "editor-post-discussion__panel-dropdown", 37654 contentClassName: "editor-post-discussion__panel-dialog", 37655 focusOnMount: true, 37656 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime239.jsx)( 37657 PostDiscussionToggle, 37658 { 37659 isOpen, 37660 onClick: onToggle 37661 } 37662 ), 37663 renderContent: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime239.jsx)(ModalContents, { onClose }) 37664 } 37665 ) }) }); 37666 } 37667 37668 // packages/editor/build-module/components/post-excerpt/index.js 37669 var import_i18n141 = __toESM(require_i18n()); 37670 var import_components132 = __toESM(require_components()); 37671 var import_data116 = __toESM(require_data()); 37672 var import_element104 = __toESM(require_element()); 37673 var import_html_entities19 = __toESM(require_html_entities()); 37674 var import_jsx_runtime240 = __toESM(require_jsx_runtime()); 37675 function PostExcerpt({ 37676 hideLabelFromVision = false, 37677 updateOnBlur = false 37678 }) { 37679 const { excerpt, shouldUseDescriptionLabel, usedAttribute } = (0, import_data116.useSelect)( 37680 (select5) => { 37681 const { getCurrentPostType: getCurrentPostType2, getEditedPostAttribute: getEditedPostAttribute2 } = select5(store); 37682 const postType2 = getCurrentPostType2(); 37683 const _usedAttribute = [ 37684 "wp_template", 37685 "wp_template_part" 37686 ].includes(postType2) ? "description" : "excerpt"; 37687 return { 37688 excerpt: getEditedPostAttribute2(_usedAttribute), 37689 // There are special cases where we want to label the excerpt as a description. 37690 shouldUseDescriptionLabel: [ 37691 "wp_template", 37692 "wp_template_part", 37693 "wp_block" 37694 ].includes(postType2), 37695 usedAttribute: _usedAttribute 37696 }; 37697 }, 37698 [] 37699 ); 37700 const { editPost: editPost2 } = (0, import_data116.useDispatch)(store); 37701 const [localExcerpt, setLocalExcerpt] = (0, import_element104.useState)( 37702 (0, import_html_entities19.decodeEntities)(excerpt) 37703 ); 37704 const updatePost2 = (value) => { 37705 editPost2({ [usedAttribute]: value }); 37706 }; 37707 const label = shouldUseDescriptionLabel ? (0, import_i18n141.__)("Write a description (optional)") : (0, import_i18n141.__)("Write an excerpt (optional)"); 37708 return /* @__PURE__ */ (0, import_jsx_runtime240.jsx)("div", { className: "editor-post-excerpt", children: /* @__PURE__ */ (0, import_jsx_runtime240.jsx)( 37709 import_components132.TextareaControl, 37710 { 37711 label, 37712 hideLabelFromVision, 37713 className: "editor-post-excerpt__textarea", 37714 onChange: updateOnBlur ? setLocalExcerpt : updatePost2, 37715 onBlur: updateOnBlur ? () => updatePost2(localExcerpt) : void 0, 37716 value: updateOnBlur ? localExcerpt : excerpt, 37717 help: !shouldUseDescriptionLabel ? /* @__PURE__ */ (0, import_jsx_runtime240.jsx)( 37718 import_components132.ExternalLink, 37719 { 37720 href: (0, import_i18n141.__)( 37721 "https://wordpress.org/documentation/article/page-post-settings-sidebar/#excerpt" 37722 ), 37723 children: (0, import_i18n141.__)("Learn more about manual excerpts") 37724 } 37725 ) : (0, import_i18n141.__)("Write a description") 37726 } 37727 ) }); 37728 } 37729 37730 // packages/editor/build-module/components/post-excerpt/check.js 37731 var import_jsx_runtime241 = __toESM(require_jsx_runtime()); 37732 function PostExcerptCheck({ children }) { 37733 return /* @__PURE__ */ (0, import_jsx_runtime241.jsx)(post_type_support_check_default, { supportKeys: "excerpt", children }); 37734 } 37735 var check_default3 = PostExcerptCheck; 37736 37737 // packages/editor/build-module/components/post-excerpt/panel.js 37738 var import_i18n142 = __toESM(require_i18n()); 37739 var import_components134 = __toESM(require_components()); 37740 var import_data117 = __toESM(require_data()); 37741 var import_element105 = __toESM(require_element()); 37742 var import_block_editor52 = __toESM(require_block_editor()); 37743 var import_core_data74 = __toESM(require_core_data()); 37744 var import_html_entities20 = __toESM(require_html_entities()); 37745 37746 // packages/editor/build-module/components/post-excerpt/plugin.js 37747 var import_components133 = __toESM(require_components()); 37748 var import_jsx_runtime242 = __toESM(require_jsx_runtime()); 37749 var { Fill: Fill9, Slot: Slot9 } = (0, import_components133.createSlotFill)("PluginPostExcerpt"); 37750 var PluginPostExcerpt = ({ children, className }) => { 37751 return /* @__PURE__ */ (0, import_jsx_runtime242.jsx)(Fill9, { children: /* @__PURE__ */ (0, import_jsx_runtime242.jsx)(import_components133.PanelRow, { className, children }) }); 37752 }; 37753 PluginPostExcerpt.Slot = Slot9; 37754 var plugin_default = PluginPostExcerpt; 37755 37756 // packages/editor/build-module/components/post-excerpt/panel.js 37757 var import_jsx_runtime243 = __toESM(require_jsx_runtime()); 37758 var PANEL_NAME3 = "post-excerpt"; 37759 function ExcerptPanel() { 37760 const { isOpened, isEnabled, postType: postType2 } = (0, import_data117.useSelect)((select5) => { 37761 const { 37762 isEditorPanelOpened: isEditorPanelOpened2, 37763 isEditorPanelEnabled: isEditorPanelEnabled2, 37764 getCurrentPostType: getCurrentPostType2 37765 } = select5(store); 37766 return { 37767 isOpened: isEditorPanelOpened2(PANEL_NAME3), 37768 isEnabled: isEditorPanelEnabled2(PANEL_NAME3), 37769 postType: getCurrentPostType2() 37770 }; 37771 }, []); 37772 const { toggleEditorPanelOpened: toggleEditorPanelOpened2 } = (0, import_data117.useDispatch)(store); 37773 const toggleExcerptPanel = () => toggleEditorPanelOpened2(PANEL_NAME3); 37774 if (!isEnabled) { 37775 return null; 37776 } 37777 const shouldUseDescriptionLabel = [ 37778 "wp_template", 37779 "wp_template_part", 37780 "wp_block" 37781 ].includes(postType2); 37782 return /* @__PURE__ */ (0, import_jsx_runtime243.jsx)( 37783 import_components134.PanelBody, 37784 { 37785 title: shouldUseDescriptionLabel ? (0, import_i18n142.__)("Description") : (0, import_i18n142.__)("Excerpt"), 37786 opened: isOpened, 37787 onToggle: toggleExcerptPanel, 37788 children: /* @__PURE__ */ (0, import_jsx_runtime243.jsx)(plugin_default.Slot, { children: (fills) => /* @__PURE__ */ (0, import_jsx_runtime243.jsxs)(import_jsx_runtime243.Fragment, { children: [ 37789 /* @__PURE__ */ (0, import_jsx_runtime243.jsx)(PostExcerpt, {}), 37790 fills 37791 ] }) }) 37792 } 37793 ); 37794 } 37795 function PostExcerptPanel() { 37796 return /* @__PURE__ */ (0, import_jsx_runtime243.jsx)(check_default3, { children: /* @__PURE__ */ (0, import_jsx_runtime243.jsx)(ExcerptPanel, {}) }); 37797 } 37798 function PrivatePostExcerptPanel() { 37799 return /* @__PURE__ */ (0, import_jsx_runtime243.jsx)(check_default3, { children: /* @__PURE__ */ (0, import_jsx_runtime243.jsx)(PrivateExcerpt, {}) }); 37800 } 37801 function PrivateExcerpt() { 37802 const { shouldRender, excerpt, shouldBeUsedAsDescription, allowEditing } = (0, import_data117.useSelect)((select5) => { 37803 const { 37804 getCurrentPostType: getCurrentPostType2, 37805 getCurrentPostId: getCurrentPostId2, 37806 getEditedPostAttribute: getEditedPostAttribute2, 37807 isEditorPanelEnabled: isEditorPanelEnabled2 37808 } = select5(store); 37809 const postType2 = getCurrentPostType2(); 37810 const isTemplateOrTemplatePart2 = [ 37811 "wp_template", 37812 "wp_template_part" 37813 ].includes(postType2); 37814 const isPattern = postType2 === "wp_block"; 37815 const _shouldBeUsedAsDescription = isTemplateOrTemplatePart2 || isPattern; 37816 const _usedAttribute = isTemplateOrTemplatePart2 ? "description" : "excerpt"; 37817 const _excerpt = getEditedPostAttribute2(_usedAttribute); 37818 const template2 = isTemplateOrTemplatePart2 && select5(import_core_data74.store).getEntityRecord( 37819 "postType", 37820 postType2, 37821 getCurrentPostId2() 37822 ); 37823 const fallback = !_excerpt && isTemplateOrTemplatePart2 ? getTemplateInfo({ 37824 template: template2, 37825 templateTypes: select5(import_core_data74.store).getCurrentTheme()?.default_template_types 37826 })?.description : void 0; 37827 const _shouldRender = isEditorPanelEnabled2(PANEL_NAME3) || _shouldBeUsedAsDescription; 37828 return { 37829 excerpt: _excerpt ?? fallback, 37830 shouldRender: _shouldRender, 37831 shouldBeUsedAsDescription: _shouldBeUsedAsDescription, 37832 // If we should render, allow editing for all post types that are not used as description. 37833 // For the rest allow editing only for user generated entities. 37834 allowEditing: _shouldRender && (!_shouldBeUsedAsDescription || isPattern || template2 && template2.source === TEMPLATE_ORIGINS.custom && !template2.has_theme_file && template2.is_custom) 37835 }; 37836 }, []); 37837 const [popoverAnchor, setPopoverAnchor] = (0, import_element105.useState)(null); 37838 const label = shouldBeUsedAsDescription ? (0, import_i18n142.__)("Description") : (0, import_i18n142.__)("Excerpt"); 37839 const popoverProps = (0, import_element105.useMemo)( 37840 () => ({ 37841 // Anchor the popover to the middle of the entire row so that it doesn't 37842 // move around when the label changes. 37843 anchor: popoverAnchor, 37844 "aria-label": label, 37845 headerTitle: label, 37846 placement: "left-start", 37847 offset: 36, 37848 shift: true 37849 }), 37850 [popoverAnchor, label] 37851 ); 37852 if (!shouldRender) { 37853 return false; 37854 } 37855 const excerptText = !!excerpt && /* @__PURE__ */ (0, import_jsx_runtime243.jsx)(import_components134.__experimentalText, { align: "left", numberOfLines: 4, truncate: allowEditing, children: (0, import_html_entities20.decodeEntities)(excerpt) }); 37856 if (!allowEditing) { 37857 return excerptText; 37858 } 37859 const excerptPlaceholder = shouldBeUsedAsDescription ? (0, import_i18n142.__)("Add a description\u2026") : (0, import_i18n142.__)("Add an excerpt\u2026"); 37860 const triggerEditLabel = shouldBeUsedAsDescription ? (0, import_i18n142.__)("Edit description") : (0, import_i18n142.__)("Edit excerpt"); 37861 return /* @__PURE__ */ (0, import_jsx_runtime243.jsxs)(import_components134.__experimentalVStack, { children: [ 37862 excerptText, 37863 /* @__PURE__ */ (0, import_jsx_runtime243.jsx)( 37864 import_components134.Dropdown, 37865 { 37866 className: "editor-post-excerpt__dropdown", 37867 contentClassName: "editor-post-excerpt__dropdown__content", 37868 popoverProps, 37869 focusOnMount: true, 37870 ref: setPopoverAnchor, 37871 renderToggle: ({ onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime243.jsx)( 37872 import_components134.Button, 37873 { 37874 __next40pxDefaultSize: true, 37875 onClick: onToggle, 37876 variant: "link", 37877 children: excerptText ? triggerEditLabel : excerptPlaceholder 37878 } 37879 ), 37880 renderContent: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime243.jsxs)(import_jsx_runtime243.Fragment, { children: [ 37881 /* @__PURE__ */ (0, import_jsx_runtime243.jsx)( 37882 import_block_editor52.__experimentalInspectorPopoverHeader, 37883 { 37884 title: label, 37885 onClose 37886 } 37887 ), 37888 /* @__PURE__ */ (0, import_jsx_runtime243.jsx)(import_components134.__experimentalVStack, { spacing: 4, children: /* @__PURE__ */ (0, import_jsx_runtime243.jsx)(plugin_default.Slot, { children: (fills) => /* @__PURE__ */ (0, import_jsx_runtime243.jsxs)(import_jsx_runtime243.Fragment, { children: [ 37889 /* @__PURE__ */ (0, import_jsx_runtime243.jsx)( 37890 PostExcerpt, 37891 { 37892 hideLabelFromVision: true, 37893 updateOnBlur: true 37894 } 37895 ), 37896 fills 37897 ] }) }) }) 37898 ] }) 37899 } 37900 ) 37901 ] }); 37902 } 37903 37904 // packages/editor/build-module/components/post-featured-image/index.js 37905 var import_i18n143 = __toESM(require_i18n()); 37906 var import_hooks44 = __toESM(require_hooks()); 37907 var import_components135 = __toESM(require_components()); 37908 var import_blob2 = __toESM(require_blob()); 37909 var import_element106 = __toESM(require_element()); 37910 var import_compose26 = __toESM(require_compose()); 37911 var import_data119 = __toESM(require_data()); 37912 var import_block_editor53 = __toESM(require_block_editor()); 37913 var import_core_data76 = __toESM(require_core_data()); 37914 37915 // packages/editor/build-module/components/theme-support-check/index.js 37916 var import_data118 = __toESM(require_data()); 37917 var import_core_data75 = __toESM(require_core_data()); 37918 function ThemeSupportCheck({ children, supportKeys }) { 37919 const { postType: postType2, themeSupports } = (0, import_data118.useSelect)((select5) => { 37920 return { 37921 postType: select5(store).getEditedPostAttribute("type"), 37922 themeSupports: select5(import_core_data75.store).getThemeSupports() 37923 }; 37924 }, []); 37925 const isSupported = (Array.isArray(supportKeys) ? supportKeys : [supportKeys]).some((key) => { 37926 const supported = themeSupports?.[key] ?? false; 37927 if ("post-thumbnails" === key && Array.isArray(supported)) { 37928 return supported.includes(postType2); 37929 } 37930 return supported; 37931 }); 37932 if (!isSupported) { 37933 return null; 37934 } 37935 return children; 37936 } 37937 37938 // packages/editor/build-module/components/post-featured-image/check.js 37939 var import_jsx_runtime244 = __toESM(require_jsx_runtime()); 37940 function PostFeaturedImageCheck({ children }) { 37941 return /* @__PURE__ */ (0, import_jsx_runtime244.jsx)(ThemeSupportCheck, { supportKeys: "post-thumbnails", children: /* @__PURE__ */ (0, import_jsx_runtime244.jsx)(post_type_support_check_default, { supportKeys: "thumbnail", children }) }); 37942 } 37943 var check_default4 = PostFeaturedImageCheck; 37944 37945 // packages/editor/build-module/components/post-featured-image/index.js 37946 var import_jsx_runtime245 = __toESM(require_jsx_runtime()); 37947 var ALLOWED_MEDIA_TYPES = ["image"]; 37948 var DEFAULT_FEATURE_IMAGE_LABEL = (0, import_i18n143.__)("Featured image"); 37949 var DEFAULT_SET_FEATURE_IMAGE_LABEL = (0, import_i18n143.__)("Add a featured image"); 37950 var instructions = /* @__PURE__ */ (0, import_jsx_runtime245.jsx)("p", { children: (0, import_i18n143.__)( 37951 "To edit the featured image, you need permission to upload media." 37952 ) }); 37953 function getMediaDetails(media, postId2) { 37954 if (!media) { 37955 return {}; 37956 } 37957 const defaultSize = (0, import_hooks44.applyFilters)( 37958 "editor.PostFeaturedImage.imageSize", 37959 "large", 37960 media.id, 37961 postId2 37962 ); 37963 if (defaultSize in (media?.media_details?.sizes ?? {})) { 37964 return { 37965 mediaWidth: media.media_details.sizes[defaultSize].width, 37966 mediaHeight: media.media_details.sizes[defaultSize].height, 37967 mediaSourceUrl: media.media_details.sizes[defaultSize].source_url 37968 }; 37969 } 37970 const fallbackSize = (0, import_hooks44.applyFilters)( 37971 "editor.PostFeaturedImage.imageSize", 37972 "thumbnail", 37973 media.id, 37974 postId2 37975 ); 37976 if (fallbackSize in (media?.media_details?.sizes ?? {})) { 37977 return { 37978 mediaWidth: media.media_details.sizes[fallbackSize].width, 37979 mediaHeight: media.media_details.sizes[fallbackSize].height, 37980 mediaSourceUrl: media.media_details.sizes[fallbackSize].source_url 37981 }; 37982 } 37983 return { 37984 mediaWidth: media.media_details.width, 37985 mediaHeight: media.media_details.height, 37986 mediaSourceUrl: media.source_url 37987 }; 37988 } 37989 function PostFeaturedImage({ 37990 currentPostId, 37991 featuredImageId, 37992 onUpdateImage, 37993 onRemoveImage, 37994 media, 37995 postType: postType2, 37996 noticeUI, 37997 noticeOperations, 37998 isRequestingFeaturedImageMedia 37999 }) { 38000 const returnsFocusRef = (0, import_element106.useRef)(false); 38001 const [isLoading, setIsLoading] = (0, import_element106.useState)(false); 38002 const { getSettings: getSettings5 } = (0, import_data119.useSelect)(import_block_editor53.store); 38003 const { mediaSourceUrl } = getMediaDetails(media, currentPostId); 38004 function onDropFiles(filesList) { 38005 getSettings5().mediaUpload({ 38006 allowedTypes: ALLOWED_MEDIA_TYPES, 38007 filesList, 38008 onFileChange([image]) { 38009 if ((0, import_blob2.isBlobURL)(image?.url)) { 38010 setIsLoading(true); 38011 return; 38012 } 38013 if (image) { 38014 onUpdateImage(image); 38015 } 38016 setIsLoading(false); 38017 }, 38018 onError(message) { 38019 noticeOperations.removeAllNotices(); 38020 noticeOperations.createErrorNotice(message); 38021 }, 38022 multiple: false 38023 }); 38024 } 38025 function getImageDescription(imageMedia) { 38026 if (imageMedia.alt_text) { 38027 return (0, import_i18n143.sprintf)( 38028 // Translators: %s: The selected image alt text. 38029 (0, import_i18n143.__)("Current image: %s"), 38030 imageMedia.alt_text 38031 ); 38032 } 38033 return (0, import_i18n143.sprintf)( 38034 // Translators: %s: The selected image filename. 38035 (0, import_i18n143.__)( 38036 "The current image has no alternative text. The file name is: %s" 38037 ), 38038 imageMedia.media_details.sizes?.full?.file || imageMedia.slug 38039 ); 38040 } 38041 function returnFocus(node) { 38042 if (returnsFocusRef.current && node) { 38043 node.focus(); 38044 returnsFocusRef.current = false; 38045 } 38046 } 38047 const isMissingMedia = !isRequestingFeaturedImageMedia && !!featuredImageId && !media; 38048 return /* @__PURE__ */ (0, import_jsx_runtime245.jsxs)(check_default4, { children: [ 38049 noticeUI, 38050 /* @__PURE__ */ (0, import_jsx_runtime245.jsxs)("div", { className: "editor-post-featured-image", children: [ 38051 media && /* @__PURE__ */ (0, import_jsx_runtime245.jsx)( 38052 "div", 38053 { 38054 id: `editor-post-featured-image-$featuredImageId}-describedby`, 38055 className: "hidden", 38056 children: getImageDescription(media) 38057 } 38058 ), 38059 /* @__PURE__ */ (0, import_jsx_runtime245.jsx)(import_block_editor53.MediaUploadCheck, { fallback: instructions, children: /* @__PURE__ */ (0, import_jsx_runtime245.jsx)( 38060 import_block_editor53.MediaUpload, 38061 { 38062 title: postType2?.labels?.featured_image || DEFAULT_FEATURE_IMAGE_LABEL, 38063 onSelect: onUpdateImage, 38064 unstableFeaturedImageFlow: true, 38065 allowedTypes: ALLOWED_MEDIA_TYPES, 38066 modalClass: "editor-post-featured-image__media-modal", 38067 render: ({ open }) => /* @__PURE__ */ (0, import_jsx_runtime245.jsxs)("div", { className: "editor-post-featured-image__container", children: [ 38068 isMissingMedia ? /* @__PURE__ */ (0, import_jsx_runtime245.jsx)( 38069 import_components135.Notice, 38070 { 38071 status: "warning", 38072 isDismissible: false, 38073 children: (0, import_i18n143.__)( 38074 "Could not retrieve the featured image data." 38075 ) 38076 } 38077 ) : /* @__PURE__ */ (0, import_jsx_runtime245.jsxs)( 38078 import_components135.Button, 38079 { 38080 __next40pxDefaultSize: true, 38081 ref: returnFocus, 38082 className: !featuredImageId ? "editor-post-featured-image__toggle" : "editor-post-featured-image__preview", 38083 onClick: open, 38084 "aria-label": !featuredImageId ? null : (0, import_i18n143.__)( 38085 "Edit or replace the featured image" 38086 ), 38087 "aria-describedby": !featuredImageId ? null : `editor-post-featured-image-$featuredImageId}-describedby`, 38088 "aria-haspopup": "dialog", 38089 disabled: isLoading, 38090 accessibleWhenDisabled: true, 38091 children: [ 38092 !!featuredImageId && media && /* @__PURE__ */ (0, import_jsx_runtime245.jsx)( 38093 "img", 38094 { 38095 className: "editor-post-featured-image__preview-image", 38096 src: mediaSourceUrl, 38097 alt: getImageDescription( 38098 media 38099 ) 38100 } 38101 ), 38102 (isLoading || isRequestingFeaturedImageMedia) && /* @__PURE__ */ (0, import_jsx_runtime245.jsx)(import_components135.Spinner, {}), 38103 !featuredImageId && !isLoading && (postType2?.labels?.set_featured_image || DEFAULT_SET_FEATURE_IMAGE_LABEL) 38104 ] 38105 } 38106 ), 38107 !!featuredImageId && /* @__PURE__ */ (0, import_jsx_runtime245.jsxs)( 38108 import_components135.__experimentalHStack, 38109 { 38110 className: clsx_default( 38111 "editor-post-featured-image__actions", 38112 { 38113 "editor-post-featured-image__actions-missing-image": isMissingMedia, 38114 "editor-post-featured-image__actions-is-requesting-image": isRequestingFeaturedImageMedia 38115 } 38116 ), 38117 children: [ 38118 /* @__PURE__ */ (0, import_jsx_runtime245.jsx)( 38119 import_components135.Button, 38120 { 38121 __next40pxDefaultSize: true, 38122 className: "editor-post-featured-image__action", 38123 onClick: open, 38124 "aria-haspopup": "dialog", 38125 variant: isMissingMedia ? "secondary" : void 0, 38126 children: (0, import_i18n143.__)("Replace") 38127 } 38128 ), 38129 /* @__PURE__ */ (0, import_jsx_runtime245.jsx)( 38130 import_components135.Button, 38131 { 38132 __next40pxDefaultSize: true, 38133 className: "editor-post-featured-image__action", 38134 onClick: () => { 38135 onRemoveImage(); 38136 returnsFocusRef.current = true; 38137 }, 38138 variant: isMissingMedia ? "secondary" : void 0, 38139 isDestructive: isMissingMedia, 38140 children: (0, import_i18n143.__)("Remove") 38141 } 38142 ) 38143 ] 38144 } 38145 ), 38146 /* @__PURE__ */ (0, import_jsx_runtime245.jsx)(import_components135.DropZone, { onFilesDrop: onDropFiles }) 38147 ] }), 38148 value: featuredImageId 38149 } 38150 ) }) 38151 ] }) 38152 ] }); 38153 } 38154 var applyWithSelect = (0, import_data119.withSelect)((select5) => { 38155 const { getEntityRecord, getPostType, hasFinishedResolution } = select5(import_core_data76.store); 38156 const { getCurrentPostId: getCurrentPostId2, getEditedPostAttribute: getEditedPostAttribute2 } = select5(store); 38157 const featuredImageId = getEditedPostAttribute2("featured_media"); 38158 return { 38159 media: featuredImageId ? getEntityRecord("postType", "attachment", featuredImageId, { 38160 context: "view" 38161 }) : null, 38162 currentPostId: getCurrentPostId2(), 38163 postType: getPostType(getEditedPostAttribute2("type")), 38164 featuredImageId, 38165 isRequestingFeaturedImageMedia: !!featuredImageId && !hasFinishedResolution("getEntityRecord", [ 38166 "postType", 38167 "attachment", 38168 featuredImageId, 38169 { context: "view" } 38170 ]) 38171 }; 38172 }); 38173 var applyWithDispatch = (0, import_data119.withDispatch)( 38174 (dispatch6, { noticeOperations }, { select: select5 }) => { 38175 const { editPost: editPost2 } = dispatch6(store); 38176 return { 38177 onUpdateImage(image) { 38178 editPost2({ featured_media: image.id }); 38179 }, 38180 onDropImage(filesList) { 38181 select5(import_block_editor53.store).getSettings().mediaUpload({ 38182 allowedTypes: ["image"], 38183 filesList, 38184 onFileChange([image]) { 38185 editPost2({ featured_media: image.id }); 38186 }, 38187 onError(message) { 38188 noticeOperations.removeAllNotices(); 38189 noticeOperations.createErrorNotice(message); 38190 }, 38191 multiple: false 38192 }); 38193 }, 38194 onRemoveImage() { 38195 editPost2({ featured_media: 0 }); 38196 } 38197 }; 38198 } 38199 ); 38200 var post_featured_image_default = (0, import_compose26.compose)( 38201 import_components135.withNotices, 38202 applyWithSelect, 38203 applyWithDispatch, 38204 (0, import_components135.withFilters)("editor.PostFeaturedImage") 38205 )(PostFeaturedImage); 38206 38207 // packages/editor/build-module/components/post-featured-image/panel.js 38208 var import_i18n144 = __toESM(require_i18n()); 38209 var import_components136 = __toESM(require_components()); 38210 var import_data120 = __toESM(require_data()); 38211 var import_core_data77 = __toESM(require_core_data()); 38212 var import_jsx_runtime246 = __toESM(require_jsx_runtime()); 38213 var PANEL_NAME4 = "featured-image"; 38214 function PostFeaturedImagePanel({ withPanelBody = true }) { 38215 const { postType: postType2, isEnabled, isOpened } = (0, import_data120.useSelect)((select5) => { 38216 const { 38217 getEditedPostAttribute: getEditedPostAttribute2, 38218 isEditorPanelEnabled: isEditorPanelEnabled2, 38219 isEditorPanelOpened: isEditorPanelOpened2 38220 } = select5(store); 38221 const { getPostType } = select5(import_core_data77.store); 38222 return { 38223 postType: getPostType(getEditedPostAttribute2("type")), 38224 isEnabled: isEditorPanelEnabled2(PANEL_NAME4), 38225 isOpened: isEditorPanelOpened2(PANEL_NAME4) 38226 }; 38227 }, []); 38228 const { toggleEditorPanelOpened: toggleEditorPanelOpened2 } = (0, import_data120.useDispatch)(store); 38229 if (!isEnabled) { 38230 return null; 38231 } 38232 if (!withPanelBody) { 38233 return /* @__PURE__ */ (0, import_jsx_runtime246.jsx)(check_default4, { children: /* @__PURE__ */ (0, import_jsx_runtime246.jsx)(post_featured_image_default, {}) }); 38234 } 38235 return /* @__PURE__ */ (0, import_jsx_runtime246.jsx)(check_default4, { children: /* @__PURE__ */ (0, import_jsx_runtime246.jsx)( 38236 import_components136.PanelBody, 38237 { 38238 title: postType2?.labels?.featured_image ?? (0, import_i18n144.__)("Featured image"), 38239 opened: isOpened, 38240 onToggle: () => toggleEditorPanelOpened2(PANEL_NAME4), 38241 children: /* @__PURE__ */ (0, import_jsx_runtime246.jsx)(post_featured_image_default, {}) 38242 } 38243 ) }); 38244 } 38245 38246 // packages/editor/build-module/components/post-format/index.js 38247 var import_i18n145 = __toESM(require_i18n()); 38248 var import_components137 = __toESM(require_components()); 38249 var import_data122 = __toESM(require_data()); 38250 var import_compose27 = __toESM(require_compose()); 38251 var import_core_data78 = __toESM(require_core_data()); 38252 38253 // packages/editor/build-module/components/post-format/check.js 38254 var import_data121 = __toESM(require_data()); 38255 var import_jsx_runtime247 = __toESM(require_jsx_runtime()); 38256 function PostFormatCheck({ children }) { 38257 const disablePostFormats = (0, import_data121.useSelect)( 38258 (select5) => select5(store).getEditorSettings().disablePostFormats, 38259 [] 38260 ); 38261 if (disablePostFormats) { 38262 return null; 38263 } 38264 return /* @__PURE__ */ (0, import_jsx_runtime247.jsx)(post_type_support_check_default, { supportKeys: "post-formats", children }); 38265 } 38266 38267 // packages/editor/build-module/components/post-format/index.js 38268 var import_jsx_runtime248 = __toESM(require_jsx_runtime()); 38269 var POST_FORMATS = [ 38270 { id: "aside", caption: (0, import_i18n145.__)("Aside") }, 38271 { id: "audio", caption: (0, import_i18n145.__)("Audio") }, 38272 { id: "chat", caption: (0, import_i18n145.__)("Chat") }, 38273 { id: "gallery", caption: (0, import_i18n145.__)("Gallery") }, 38274 { id: "image", caption: (0, import_i18n145.__)("Image") }, 38275 { id: "link", caption: (0, import_i18n145.__)("Link") }, 38276 { id: "quote", caption: (0, import_i18n145.__)("Quote") }, 38277 { id: "standard", caption: (0, import_i18n145.__)("Standard") }, 38278 { id: "status", caption: (0, import_i18n145.__)("Status") }, 38279 { id: "video", caption: (0, import_i18n145.__)("Video") } 38280 ].sort((a3, b3) => { 38281 const normalizedA = a3.caption.toUpperCase(); 38282 const normalizedB = b3.caption.toUpperCase(); 38283 if (normalizedA < normalizedB) { 38284 return -1; 38285 } 38286 if (normalizedA > normalizedB) { 38287 return 1; 38288 } 38289 return 0; 38290 }); 38291 function PostFormat() { 38292 const instanceId = (0, import_compose27.useInstanceId)(PostFormat); 38293 const postFormatSelectorId = `post-format-selector-$instanceId}`; 38294 const { postFormat, suggestedFormat, supportedFormats } = (0, import_data122.useSelect)( 38295 (select5) => { 38296 const { getEditedPostAttribute: getEditedPostAttribute2, getSuggestedPostFormat: getSuggestedPostFormat2 } = select5(store); 38297 const _postFormat = getEditedPostAttribute2("format"); 38298 const themeSupports = select5(import_core_data78.store).getThemeSupports(); 38299 return { 38300 postFormat: _postFormat ?? "standard", 38301 suggestedFormat: getSuggestedPostFormat2(), 38302 supportedFormats: themeSupports.formats 38303 }; 38304 }, 38305 [] 38306 ); 38307 const formats = POST_FORMATS.filter((format) => { 38308 return supportedFormats?.includes(format.id) || postFormat === format.id; 38309 }); 38310 const suggestion = formats.find( 38311 (format) => format.id === suggestedFormat 38312 ); 38313 const { editPost: editPost2 } = (0, import_data122.useDispatch)(store); 38314 const onUpdatePostFormat = (format) => editPost2({ format }); 38315 return /* @__PURE__ */ (0, import_jsx_runtime248.jsx)(PostFormatCheck, { children: /* @__PURE__ */ (0, import_jsx_runtime248.jsxs)("div", { className: "editor-post-format", children: [ 38316 /* @__PURE__ */ (0, import_jsx_runtime248.jsx)( 38317 import_components137.RadioControl, 38318 { 38319 className: "editor-post-format__options", 38320 label: (0, import_i18n145.__)("Post Format"), 38321 selected: postFormat, 38322 onChange: (format) => onUpdatePostFormat(format), 38323 id: postFormatSelectorId, 38324 options: formats.map((format) => ({ 38325 label: format.caption, 38326 value: format.id 38327 })), 38328 hideLabelFromVision: true 38329 } 38330 ), 38331 suggestion && suggestion.id !== postFormat && /* @__PURE__ */ (0, import_jsx_runtime248.jsx)("p", { className: "editor-post-format__suggestion", children: /* @__PURE__ */ (0, import_jsx_runtime248.jsx)( 38332 import_components137.Button, 38333 { 38334 __next40pxDefaultSize: true, 38335 variant: "link", 38336 onClick: () => onUpdatePostFormat(suggestion.id), 38337 children: (0, import_i18n145.sprintf)( 38338 /* translators: %s: post format */ 38339 (0, import_i18n145.__)("Apply suggested format: %s"), 38340 suggestion.caption 38341 ) 38342 } 38343 ) }) 38344 ] }) }); 38345 } 38346 38347 // packages/editor/build-module/components/post-last-revision/index.js 38348 var import_i18n146 = __toESM(require_i18n()); 38349 var import_components138 = __toESM(require_components()); 38350 var import_data124 = __toESM(require_data()); 38351 var import_url11 = __toESM(require_url()); 38352 38353 // packages/editor/build-module/components/post-last-revision/check.js 38354 var import_data123 = __toESM(require_data()); 38355 var import_jsx_runtime249 = __toESM(require_jsx_runtime()); 38356 function PostLastRevisionCheck({ children }) { 38357 const { lastRevisionId, revisionsCount } = (0, import_data123.useSelect)((select5) => { 38358 const { getCurrentPostLastRevisionId: getCurrentPostLastRevisionId2, getCurrentPostRevisionsCount: getCurrentPostRevisionsCount2 } = select5(store); 38359 return { 38360 lastRevisionId: getCurrentPostLastRevisionId2(), 38361 revisionsCount: getCurrentPostRevisionsCount2() 38362 }; 38363 }, []); 38364 if (!lastRevisionId || revisionsCount < 2) { 38365 return null; 38366 } 38367 return /* @__PURE__ */ (0, import_jsx_runtime249.jsx)(post_type_support_check_default, { supportKeys: "revisions", children }); 38368 } 38369 var check_default5 = PostLastRevisionCheck; 38370 38371 // packages/editor/build-module/components/post-last-revision/index.js 38372 var import_jsx_runtime250 = __toESM(require_jsx_runtime()); 38373 function usePostLastRevisionInfo() { 38374 return (0, import_data124.useSelect)((select5) => { 38375 const { getCurrentPostLastRevisionId: getCurrentPostLastRevisionId2, getCurrentPostRevisionsCount: getCurrentPostRevisionsCount2 } = select5(store); 38376 return { 38377 lastRevisionId: getCurrentPostLastRevisionId2(), 38378 revisionsCount: getCurrentPostRevisionsCount2() 38379 }; 38380 }, []); 38381 } 38382 function PostLastRevision() { 38383 const { lastRevisionId, revisionsCount } = usePostLastRevisionInfo(); 38384 return /* @__PURE__ */ (0, import_jsx_runtime250.jsx)(check_default5, { children: /* @__PURE__ */ (0, import_jsx_runtime250.jsx)( 38385 import_components138.Button, 38386 { 38387 __next40pxDefaultSize: true, 38388 href: (0, import_url11.addQueryArgs)("revision.php", { 38389 revision: lastRevisionId 38390 }), 38391 className: "editor-post-last-revision__title", 38392 icon: backup_default, 38393 iconPosition: "right", 38394 text: (0, import_i18n146.sprintf)( 38395 /* translators: %s: number of revisions. */ 38396 (0, import_i18n146.__)("Revisions (%s)"), 38397 revisionsCount 38398 ) 38399 } 38400 ) }); 38401 } 38402 function PrivatePostLastRevision() { 38403 const { lastRevisionId, revisionsCount } = usePostLastRevisionInfo(); 38404 return /* @__PURE__ */ (0, import_jsx_runtime250.jsx)(check_default5, { children: /* @__PURE__ */ (0, import_jsx_runtime250.jsx)(post_panel_row_default, { label: (0, import_i18n146.__)("Revisions"), children: /* @__PURE__ */ (0, import_jsx_runtime250.jsx)( 38405 import_components138.Button, 38406 { 38407 href: (0, import_url11.addQueryArgs)("revision.php", { 38408 revision: lastRevisionId 38409 }), 38410 className: "editor-private-post-last-revision__button", 38411 text: revisionsCount, 38412 variant: "tertiary", 38413 size: "compact" 38414 } 38415 ) }) }); 38416 } 38417 var post_last_revision_default = PostLastRevision; 38418 38419 // packages/editor/build-module/components/post-last-revision/panel.js 38420 var import_components139 = __toESM(require_components()); 38421 var import_jsx_runtime251 = __toESM(require_jsx_runtime()); 38422 function PostLastRevisionPanel() { 38423 return /* @__PURE__ */ (0, import_jsx_runtime251.jsx)(check_default5, { children: /* @__PURE__ */ (0, import_jsx_runtime251.jsx)(import_components139.PanelBody, { className: "editor-post-last-revision__panel", children: /* @__PURE__ */ (0, import_jsx_runtime251.jsx)(post_last_revision_default, {}) }) }); 38424 } 38425 var panel_default2 = PostLastRevisionPanel; 38426 38427 // packages/editor/build-module/components/post-locked-modal/index.js 38428 var import_i18n147 = __toESM(require_i18n()); 38429 var import_components140 = __toESM(require_components()); 38430 var import_data125 = __toESM(require_data()); 38431 var import_url12 = __toESM(require_url()); 38432 var import_element107 = __toESM(require_element()); 38433 var import_hooks45 = __toESM(require_hooks()); 38434 var import_compose28 = __toESM(require_compose()); 38435 var import_core_data79 = __toESM(require_core_data()); 38436 var import_jsx_runtime252 = __toESM(require_jsx_runtime()); 38437 function PostLockedModal() { 38438 const instanceId = (0, import_compose28.useInstanceId)(PostLockedModal); 38439 const hookName = "core/editor/post-locked-modal-" + instanceId; 38440 const { autosave: autosave2, updatePostLock: updatePostLock2 } = (0, import_data125.useDispatch)(store); 38441 const { 38442 isLocked, 38443 isTakeover, 38444 user, 38445 postId: postId2, 38446 postLockUtils, 38447 activePostLock, 38448 postType: postType2, 38449 previewLink 38450 } = (0, import_data125.useSelect)((select5) => { 38451 const { 38452 isPostLocked: isPostLocked2, 38453 isPostLockTakeover: isPostLockTakeover2, 38454 getPostLockUser: getPostLockUser2, 38455 getCurrentPostId: getCurrentPostId2, 38456 getActivePostLock: getActivePostLock2, 38457 getEditedPostAttribute: getEditedPostAttribute2, 38458 getEditedPostPreviewLink: getEditedPostPreviewLink2, 38459 getEditorSettings: getEditorSettings2 38460 } = select5(store); 38461 const { getPostType } = select5(import_core_data79.store); 38462 return { 38463 isLocked: isPostLocked2(), 38464 isTakeover: isPostLockTakeover2(), 38465 user: getPostLockUser2(), 38466 postId: getCurrentPostId2(), 38467 postLockUtils: getEditorSettings2().postLockUtils, 38468 activePostLock: getActivePostLock2(), 38469 postType: getPostType(getEditedPostAttribute2("type")), 38470 previewLink: getEditedPostPreviewLink2() 38471 }; 38472 }, []); 38473 (0, import_element107.useEffect)(() => { 38474 function sendPostLock(data) { 38475 if (isLocked) { 38476 return; 38477 } 38478 data["wp-refresh-post-lock"] = { 38479 lock: activePostLock, 38480 post_id: postId2 38481 }; 38482 } 38483 function receivePostLock(data) { 38484 if (!data["wp-refresh-post-lock"]) { 38485 return; 38486 } 38487 const received = data["wp-refresh-post-lock"]; 38488 if (received.lock_error) { 38489 autosave2(); 38490 updatePostLock2({ 38491 isLocked: true, 38492 isTakeover: true, 38493 user: { 38494 name: received.lock_error.name, 38495 avatar: received.lock_error.avatar_src_2x 38496 } 38497 }); 38498 } else if (received.new_lock) { 38499 updatePostLock2({ 38500 isLocked: false, 38501 activePostLock: received.new_lock 38502 }); 38503 } 38504 } 38505 function releasePostLock() { 38506 if (isLocked || !activePostLock) { 38507 return; 38508 } 38509 const data = new window.FormData(); 38510 data.append("action", "wp-remove-post-lock"); 38511 data.append("_wpnonce", postLockUtils.unlockNonce); 38512 data.append("post_ID", postId2); 38513 data.append("active_post_lock", activePostLock); 38514 if (window.navigator.sendBeacon) { 38515 window.navigator.sendBeacon(postLockUtils.ajaxUrl, data); 38516 } else { 38517 const xhr = new window.XMLHttpRequest(); 38518 xhr.open("POST", postLockUtils.ajaxUrl, false); 38519 xhr.send(data); 38520 } 38521 } 38522 (0, import_hooks45.addAction)("heartbeat.send", hookName, sendPostLock); 38523 (0, import_hooks45.addAction)("heartbeat.tick", hookName, receivePostLock); 38524 window.addEventListener("beforeunload", releasePostLock); 38525 return () => { 38526 (0, import_hooks45.removeAction)("heartbeat.send", hookName); 38527 (0, import_hooks45.removeAction)("heartbeat.tick", hookName); 38528 window.removeEventListener("beforeunload", releasePostLock); 38529 }; 38530 }, []); 38531 if (!isLocked) { 38532 return null; 38533 } 38534 const userDisplayName = user.name; 38535 const userAvatar = user.avatar; 38536 const unlockUrl = (0, import_url12.addQueryArgs)("post.php", { 38537 "get-post-lock": "1", 38538 lockKey: true, 38539 post: postId2, 38540 action: "edit", 38541 _wpnonce: postLockUtils.nonce 38542 }); 38543 const allPostsUrl = (0, import_url12.addQueryArgs)("edit.php", { 38544 post_type: postType2?.slug 38545 }); 38546 const allPostsLabel = (0, import_i18n147.__)("Exit editor"); 38547 return /* @__PURE__ */ (0, import_jsx_runtime252.jsx)( 38548 import_components140.Modal, 38549 { 38550 title: isTakeover ? (0, import_i18n147.__)("Someone else has taken over this post") : (0, import_i18n147.__)("This post is already being edited"), 38551 focusOnMount: true, 38552 shouldCloseOnClickOutside: false, 38553 shouldCloseOnEsc: false, 38554 isDismissible: false, 38555 className: "editor-post-locked-modal", 38556 size: "medium", 38557 children: /* @__PURE__ */ (0, import_jsx_runtime252.jsxs)(import_components140.__experimentalHStack, { alignment: "top", spacing: 6, children: [ 38558 !!userAvatar && /* @__PURE__ */ (0, import_jsx_runtime252.jsx)( 38559 "img", 38560 { 38561 src: userAvatar, 38562 alt: (0, import_i18n147.__)("Avatar"), 38563 className: "editor-post-locked-modal__avatar", 38564 width: 64, 38565 height: 64 38566 } 38567 ), 38568 /* @__PURE__ */ (0, import_jsx_runtime252.jsxs)("div", { children: [ 38569 !!isTakeover && /* @__PURE__ */ (0, import_jsx_runtime252.jsx)("p", { children: (0, import_element107.createInterpolateElement)( 38570 userDisplayName ? (0, import_i18n147.sprintf)( 38571 /* translators: %s: user's display name */ 38572 (0, import_i18n147.__)( 38573 "<strong>%s</strong> now has editing control of this post (<PreviewLink />). Don\u2019t worry, your changes up to this moment have been saved." 38574 ), 38575 userDisplayName 38576 ) : (0, import_i18n147.__)( 38577 "Another user now has editing control of this post (<PreviewLink />). Don\u2019t worry, your changes up to this moment have been saved." 38578 ), 38579 { 38580 strong: /* @__PURE__ */ (0, import_jsx_runtime252.jsx)("strong", {}), 38581 PreviewLink: /* @__PURE__ */ (0, import_jsx_runtime252.jsx)(import_components140.ExternalLink, { href: previewLink, children: (0, import_i18n147.__)("preview") }) 38582 } 38583 ) }), 38584 !isTakeover && /* @__PURE__ */ (0, import_jsx_runtime252.jsxs)(import_jsx_runtime252.Fragment, { children: [ 38585 /* @__PURE__ */ (0, import_jsx_runtime252.jsx)("p", { children: (0, import_element107.createInterpolateElement)( 38586 userDisplayName ? (0, import_i18n147.sprintf)( 38587 /* translators: %s: user's display name */ 38588 (0, import_i18n147.__)( 38589 "<strong>%s</strong> is currently working on this post (<PreviewLink />), which means you cannot make changes, unless you take over." 38590 ), 38591 userDisplayName 38592 ) : (0, import_i18n147.__)( 38593 "Another user is currently working on this post (<PreviewLink />), which means you cannot make changes, unless you take over." 38594 ), 38595 { 38596 strong: /* @__PURE__ */ (0, import_jsx_runtime252.jsx)("strong", {}), 38597 PreviewLink: /* @__PURE__ */ (0, import_jsx_runtime252.jsx)(import_components140.ExternalLink, { href: previewLink, children: (0, import_i18n147.__)("preview") }) 38598 } 38599 ) }), 38600 /* @__PURE__ */ (0, import_jsx_runtime252.jsx)("p", { children: (0, import_i18n147.__)( 38601 "If you take over, the other user will lose editing control to the post, but their changes will be saved." 38602 ) }) 38603 ] }), 38604 /* @__PURE__ */ (0, import_jsx_runtime252.jsxs)( 38605 import_components140.__experimentalHStack, 38606 { 38607 className: "editor-post-locked-modal__buttons", 38608 justify: "flex-end", 38609 children: [ 38610 !isTakeover && /* @__PURE__ */ (0, import_jsx_runtime252.jsx)( 38611 import_components140.Button, 38612 { 38613 __next40pxDefaultSize: true, 38614 variant: "tertiary", 38615 href: unlockUrl, 38616 children: (0, import_i18n147.__)("Take over") 38617 } 38618 ), 38619 /* @__PURE__ */ (0, import_jsx_runtime252.jsx)( 38620 import_components140.Button, 38621 { 38622 __next40pxDefaultSize: true, 38623 variant: "primary", 38624 href: allPostsUrl, 38625 children: allPostsLabel 38626 } 38627 ) 38628 ] 38629 } 38630 ) 38631 ] }) 38632 ] }) 38633 } 38634 ); 38635 } 38636 var post_locked_modal_default = false ? (0, import_components140.withFilters)("editor.PostLockedModal")(PostLockedModal) : PostLockedModal; 38637 38638 // packages/editor/build-module/components/post-pending-status/index.js 38639 var import_i18n148 = __toESM(require_i18n()); 38640 var import_components141 = __toESM(require_components()); 38641 var import_data127 = __toESM(require_data()); 38642 38643 // packages/editor/build-module/components/post-pending-status/check.js 38644 var import_data126 = __toESM(require_data()); 38645 function PostPendingStatusCheck({ children }) { 38646 const { hasPublishAction, isPublished } = (0, import_data126.useSelect)((select5) => { 38647 const { isCurrentPostPublished: isCurrentPostPublished2, getCurrentPost: getCurrentPost2 } = select5(store); 38648 return { 38649 hasPublishAction: getCurrentPost2()._links?.["wp:action-publish"] ?? false, 38650 isPublished: isCurrentPostPublished2() 38651 }; 38652 }, []); 38653 if (isPublished || !hasPublishAction) { 38654 return null; 38655 } 38656 return children; 38657 } 38658 var check_default6 = PostPendingStatusCheck; 38659 38660 // packages/editor/build-module/components/post-pending-status/index.js 38661 var import_jsx_runtime253 = __toESM(require_jsx_runtime()); 38662 function PostPendingStatus() { 38663 const status = (0, import_data127.useSelect)( 38664 (select5) => select5(store).getEditedPostAttribute("status"), 38665 [] 38666 ); 38667 const { editPost: editPost2 } = (0, import_data127.useDispatch)(store); 38668 const togglePendingStatus = () => { 38669 const updatedStatus = status === "pending" ? "draft" : "pending"; 38670 editPost2({ status: updatedStatus }); 38671 }; 38672 return /* @__PURE__ */ (0, import_jsx_runtime253.jsx)(check_default6, { children: /* @__PURE__ */ (0, import_jsx_runtime253.jsx)( 38673 import_components141.CheckboxControl, 38674 { 38675 label: (0, import_i18n148.__)("Pending review"), 38676 checked: status === "pending", 38677 onChange: togglePendingStatus 38678 } 38679 ) }); 38680 } 38681 var post_pending_status_default = PostPendingStatus; 38682 38683 // packages/editor/build-module/components/post-preview-button/index.js 38684 var import_element108 = __toESM(require_element()); 38685 var import_components142 = __toESM(require_components()); 38686 var import_i18n149 = __toESM(require_i18n()); 38687 var import_data128 = __toESM(require_data()); 38688 var import_hooks46 = __toESM(require_hooks()); 38689 var import_core_data80 = __toESM(require_core_data()); 38690 var import_jsx_runtime254 = __toESM(require_jsx_runtime()); 38691 function writeInterstitialMessage(targetDocument) { 38692 let markup = (0, import_element108.renderToString)( 38693 /* @__PURE__ */ (0, import_jsx_runtime254.jsxs)("div", { className: "editor-post-preview-button__interstitial-message", children: [ 38694 /* @__PURE__ */ (0, import_jsx_runtime254.jsxs)(import_components142.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 96 96", children: [ 38695 /* @__PURE__ */ (0, import_jsx_runtime254.jsx)( 38696 import_components142.Path, 38697 { 38698 className: "outer", 38699 d: "M48 12c19.9 0 36 16.1 36 36S67.9 84 48 84 12 67.9 12 48s16.1-36 36-36", 38700 fill: "none" 38701 } 38702 ), 38703 /* @__PURE__ */ (0, import_jsx_runtime254.jsx)( 38704 import_components142.Path, 38705 { 38706 className: "inner", 38707 d: "M69.5 46.4c0-3.9-1.4-6.7-2.6-8.8-1.6-2.6-3.1-4.9-3.1-7.5 0-2.9 2.2-5.7 5.4-5.7h.4C63.9 19.2 56.4 16 48 16c-11.2 0-21 5.7-26.7 14.4h2.1c3.3 0 8.5-.4 8.5-.4 1.7-.1 1.9 2.4.2 2.6 0 0-1.7.2-3.7.3L40 67.5l7-20.9L42 33c-1.7-.1-3.3-.3-3.3-.3-1.7-.1-1.5-2.7.2-2.6 0 0 5.3.4 8.4.4 3.3 0 8.5-.4 8.5-.4 1.7-.1 1.9 2.4.2 2.6 0 0-1.7.2-3.7.3l11.5 34.3 3.3-10.4c1.6-4.5 2.4-7.8 2.4-10.5zM16.1 48c0 12.6 7.3 23.5 18 28.7L18.8 35c-1.7 4-2.7 8.4-2.7 13zm32.5 2.8L39 78.6c2.9.8 5.9 1.3 9 1.3 3.7 0 7.3-.6 10.6-1.8-.1-.1-.2-.3-.2-.4l-9.8-26.9zM76.2 36c0 3.2-.6 6.9-2.4 11.4L64 75.6c9.5-5.5 15.9-15.8 15.9-27.6 0-5.5-1.4-10.8-3.9-15.3.1 1 .2 2.1.2 3.3z", 38708 fill: "none" 38709 } 38710 ) 38711 ] }), 38712 /* @__PURE__ */ (0, import_jsx_runtime254.jsx)("p", { children: (0, import_i18n149.__)("Generating preview\u2026") }) 38713 ] }) 38714 ); 38715 markup += ` 38716 <style> 38717 body { 38718 margin: 0; 38719 } 38720 .editor-post-preview-button__interstitial-message { 38721 display: flex; 38722 flex-direction: column; 38723 align-items: center; 38724 justify-content: center; 38725 height: 100vh; 38726 width: 100vw; 38727 } 38728 @-webkit-keyframes paint { 38729 0% { 38730 stroke-dashoffset: 0; 38731 } 38732 } 38733 @-moz-keyframes paint { 38734 0% { 38735 stroke-dashoffset: 0; 38736 } 38737 } 38738 @-o-keyframes paint { 38739 0% { 38740 stroke-dashoffset: 0; 38741 } 38742 } 38743 @keyframes paint { 38744 0% { 38745 stroke-dashoffset: 0; 38746 } 38747 } 38748 .editor-post-preview-button__interstitial-message svg { 38749 width: 192px; 38750 height: 192px; 38751 stroke: #555d66; 38752 stroke-width: 0.75; 38753 } 38754 .editor-post-preview-button__interstitial-message svg .outer, 38755 .editor-post-preview-button__interstitial-message svg .inner { 38756 stroke-dasharray: 280; 38757 stroke-dashoffset: 280; 38758 -webkit-animation: paint 1.5s ease infinite alternate; 38759 -moz-animation: paint 1.5s ease infinite alternate; 38760 -o-animation: paint 1.5s ease infinite alternate; 38761 animation: paint 1.5s ease infinite alternate; 38762 } 38763 p { 38764 text-align: center; 38765 font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; 38766 } 38767 </style> 38768 `; 38769 markup = (0, import_hooks46.applyFilters)("editor.PostPreview.interstitialMarkup", markup); 38770 targetDocument.write(markup); 38771 targetDocument.title = (0, import_i18n149.__)("Generating preview\u2026"); 38772 targetDocument.close(); 38773 } 38774 function PostPreviewButton({ 38775 className, 38776 textContent, 38777 forceIsAutosaveable, 38778 role, 38779 onPreview 38780 }) { 38781 const { postId: postId2, currentPostLink, previewLink, isSaveable, isViewable } = (0, import_data128.useSelect)((select5) => { 38782 const editor = select5(store); 38783 const core = select5(import_core_data80.store); 38784 const postType2 = core.getPostType( 38785 editor.getCurrentPostType("type") 38786 ); 38787 const canView = postType2?.viewable ?? false; 38788 if (!canView) { 38789 return { isViewable: canView }; 38790 } 38791 return { 38792 postId: editor.getCurrentPostId(), 38793 currentPostLink: editor.getCurrentPostAttribute("link"), 38794 previewLink: editor.getEditedPostPreviewLink(), 38795 isSaveable: editor.isEditedPostSaveable(), 38796 isViewable: canView 38797 }; 38798 }, []); 38799 const { __unstableSaveForPreview: __unstableSaveForPreview2 } = (0, import_data128.useDispatch)(store); 38800 if (!isViewable) { 38801 return null; 38802 } 38803 const targetId = `wp-preview-$postId2}`; 38804 const openPreviewWindow = async (event) => { 38805 event.preventDefault(); 38806 const previewWindow = window.open("", targetId); 38807 previewWindow.focus(); 38808 writeInterstitialMessage(previewWindow.document); 38809 const link = await __unstableSaveForPreview2({ forceIsAutosaveable }); 38810 previewWindow.location = link; 38811 onPreview?.(); 38812 }; 38813 const href = previewLink || currentPostLink; 38814 return /* @__PURE__ */ (0, import_jsx_runtime254.jsx)( 38815 import_components142.Button, 38816 { 38817 variant: !className ? "tertiary" : void 0, 38818 className: className || "editor-post-preview", 38819 href, 38820 target: targetId, 38821 accessibleWhenDisabled: true, 38822 disabled: !isSaveable, 38823 onClick: openPreviewWindow, 38824 role, 38825 size: "compact", 38826 children: textContent || /* @__PURE__ */ (0, import_jsx_runtime254.jsxs)(import_jsx_runtime254.Fragment, { children: [ 38827 (0, import_i18n149._x)("Preview", "imperative verb"), 38828 /* @__PURE__ */ (0, import_jsx_runtime254.jsx)(import_components142.VisuallyHidden, { 38829 as: "span", 38830 /* translators: accessibility text */ 38831 children: (0, import_i18n149.__)("(opens in a new tab)") 38832 }) 38833 ] }) 38834 } 38835 ); 38836 } 38837 38838 // packages/editor/build-module/components/post-publish-button/index.js 38839 var import_components143 = __toESM(require_components()); 38840 var import_element109 = __toESM(require_element()); 38841 var import_data130 = __toESM(require_data()); 38842 var import_compose30 = __toESM(require_compose()); 38843 38844 // packages/editor/build-module/components/post-publish-button/label.js 38845 var import_i18n150 = __toESM(require_i18n()); 38846 var import_data129 = __toESM(require_data()); 38847 var import_compose29 = __toESM(require_compose()); 38848 function PublishButtonLabel() { 38849 const isSmallerThanMediumViewport = (0, import_compose29.useViewportMatch)("medium", "<"); 38850 const { 38851 isPublished, 38852 isBeingScheduled, 38853 isSaving, 38854 isPublishing, 38855 hasPublishAction, 38856 isAutosaving, 38857 hasNonPostEntityChanges: hasNonPostEntityChanges2, 38858 postStatusHasChanged, 38859 postStatus 38860 } = (0, import_data129.useSelect)((select5) => { 38861 const { 38862 isCurrentPostPublished: isCurrentPostPublished2, 38863 isEditedPostBeingScheduled: isEditedPostBeingScheduled2, 38864 isSavingPost: isSavingPost2, 38865 isPublishingPost: isPublishingPost2, 38866 getCurrentPost: getCurrentPost2, 38867 getCurrentPostType: getCurrentPostType2, 38868 isAutosavingPost: isAutosavingPost2, 38869 getPostEdits: getPostEdits2, 38870 getEditedPostAttribute: getEditedPostAttribute2 38871 } = select5(store); 38872 return { 38873 isPublished: isCurrentPostPublished2(), 38874 isBeingScheduled: isEditedPostBeingScheduled2(), 38875 isSaving: isSavingPost2(), 38876 isPublishing: isPublishingPost2(), 38877 hasPublishAction: getCurrentPost2()._links?.["wp:action-publish"] ?? false, 38878 postType: getCurrentPostType2(), 38879 isAutosaving: isAutosavingPost2(), 38880 hasNonPostEntityChanges: select5(store).hasNonPostEntityChanges(), 38881 postStatusHasChanged: !!getPostEdits2()?.status, 38882 postStatus: getEditedPostAttribute2("status") 38883 }; 38884 }, []); 38885 if (isPublishing) { 38886 return (0, import_i18n150.__)("Publishing\u2026"); 38887 } else if ((isPublished || isBeingScheduled) && isSaving && !isAutosaving) { 38888 return (0, import_i18n150.__)("Saving\u2026"); 38889 } 38890 if (!hasPublishAction) { 38891 return isSmallerThanMediumViewport ? (0, import_i18n150.__)("Publish") : (0, import_i18n150.__)("Submit for Review"); 38892 } 38893 if (hasNonPostEntityChanges2 || isPublished || postStatusHasChanged && !["future", "publish"].includes(postStatus) || !postStatusHasChanged && postStatus === "future") { 38894 return (0, import_i18n150.__)("Save"); 38895 } 38896 if (isBeingScheduled) { 38897 return (0, import_i18n150.__)("Schedule"); 38898 } 38899 return (0, import_i18n150.__)("Publish"); 38900 } 38901 38902 // packages/editor/build-module/components/post-publish-button/index.js 38903 var import_jsx_runtime255 = __toESM(require_jsx_runtime()); 38904 var noop5 = () => { 38905 }; 38906 var PostPublishButton = class extends import_element109.Component { 38907 constructor(props) { 38908 super(props); 38909 this.createOnClick = this.createOnClick.bind(this); 38910 this.closeEntitiesSavedStates = this.closeEntitiesSavedStates.bind(this); 38911 this.state = { 38912 entitiesSavedStatesCallback: false 38913 }; 38914 } 38915 createOnClick(callback) { 38916 return (...args) => { 38917 const { hasNonPostEntityChanges: hasNonPostEntityChanges2, setEntitiesSavedStatesCallback } = this.props; 38918 if (hasNonPostEntityChanges2 && setEntitiesSavedStatesCallback) { 38919 this.setState({ 38920 entitiesSavedStatesCallback: () => callback(...args) 38921 }); 38922 setEntitiesSavedStatesCallback( 38923 () => this.closeEntitiesSavedStates 38924 ); 38925 return noop5; 38926 } 38927 return callback(...args); 38928 }; 38929 } 38930 closeEntitiesSavedStates(savedEntities) { 38931 const { postType: postType2, postId: postId2 } = this.props; 38932 const { entitiesSavedStatesCallback } = this.state; 38933 this.setState({ entitiesSavedStatesCallback: false }, () => { 38934 if (savedEntities && savedEntities.some( 38935 (elt) => elt.kind === "postType" && elt.name === postType2 && elt.key === postId2 38936 )) { 38937 entitiesSavedStatesCallback(); 38938 } 38939 }); 38940 } 38941 render() { 38942 const { 38943 forceIsDirty, 38944 hasPublishAction, 38945 isBeingScheduled, 38946 isOpen, 38947 isPostSavingLocked: isPostSavingLocked2, 38948 isPublishable, 38949 isPublished, 38950 isSaveable, 38951 isSaving, 38952 isAutoSaving, 38953 isToggle, 38954 savePostStatus, 38955 onSubmit = noop5, 38956 onToggle, 38957 visibility, 38958 hasNonPostEntityChanges: hasNonPostEntityChanges2, 38959 isSavingNonPostEntityChanges: isSavingNonPostEntityChanges2, 38960 postStatus, 38961 postStatusHasChanged 38962 } = this.props; 38963 const isButtonDisabled = (isSaving || !isSaveable || isPostSavingLocked2 || !isPublishable && !forceIsDirty) && (!hasNonPostEntityChanges2 || isSavingNonPostEntityChanges2); 38964 const isToggleDisabled = (isPublished || isSaving || !isSaveable || !isPublishable && !forceIsDirty) && (!hasNonPostEntityChanges2 || isSavingNonPostEntityChanges2); 38965 let publishStatus = "publish"; 38966 if (postStatusHasChanged) { 38967 publishStatus = postStatus; 38968 } else if (!hasPublishAction) { 38969 publishStatus = "pending"; 38970 } else if (visibility === "private") { 38971 publishStatus = "private"; 38972 } else if (isBeingScheduled) { 38973 publishStatus = "future"; 38974 } 38975 const onClickButton = () => { 38976 if (isButtonDisabled) { 38977 return; 38978 } 38979 onSubmit(); 38980 savePostStatus(publishStatus); 38981 }; 38982 const onClickToggle = () => { 38983 if (isToggleDisabled) { 38984 return; 38985 } 38986 onToggle(); 38987 }; 38988 const buttonProps = { 38989 "aria-disabled": isButtonDisabled, 38990 className: "editor-post-publish-button", 38991 isBusy: !isAutoSaving && isSaving, 38992 variant: "primary", 38993 onClick: this.createOnClick(onClickButton), 38994 "aria-haspopup": hasNonPostEntityChanges2 ? "dialog" : void 0 38995 }; 38996 const toggleProps = { 38997 "aria-disabled": isToggleDisabled, 38998 "aria-expanded": isOpen, 38999 className: "editor-post-publish-panel__toggle", 39000 isBusy: isSaving && isPublished, 39001 variant: "primary", 39002 size: "compact", 39003 onClick: this.createOnClick(onClickToggle), 39004 "aria-haspopup": hasNonPostEntityChanges2 ? "dialog" : void 0 39005 }; 39006 const componentProps = isToggle ? toggleProps : buttonProps; 39007 return /* @__PURE__ */ (0, import_jsx_runtime255.jsx)(import_jsx_runtime255.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime255.jsx)( 39008 import_components143.Button, 39009 { 39010 ...componentProps, 39011 className: `$componentProps.className} editor-post-publish-button__button`, 39012 size: "compact", 39013 children: /* @__PURE__ */ (0, import_jsx_runtime255.jsx)(PublishButtonLabel, {}) 39014 } 39015 ) }); 39016 } 39017 }; 39018 var post_publish_button_default = (0, import_compose30.compose)([ 39019 (0, import_data130.withSelect)((select5) => { 39020 const { 39021 isSavingPost: isSavingPost2, 39022 isAutosavingPost: isAutosavingPost2, 39023 isEditedPostBeingScheduled: isEditedPostBeingScheduled2, 39024 getEditedPostVisibility: getEditedPostVisibility2, 39025 isCurrentPostPublished: isCurrentPostPublished2, 39026 isEditedPostSaveable: isEditedPostSaveable2, 39027 isEditedPostPublishable: isEditedPostPublishable2, 39028 isPostSavingLocked: isPostSavingLocked2, 39029 getCurrentPost: getCurrentPost2, 39030 getCurrentPostType: getCurrentPostType2, 39031 getCurrentPostId: getCurrentPostId2, 39032 hasNonPostEntityChanges: hasNonPostEntityChanges2, 39033 isSavingNonPostEntityChanges: isSavingNonPostEntityChanges2, 39034 getEditedPostAttribute: getEditedPostAttribute2, 39035 getPostEdits: getPostEdits2 39036 } = select5(store); 39037 return { 39038 isSaving: isSavingPost2(), 39039 isAutoSaving: isAutosavingPost2(), 39040 isBeingScheduled: isEditedPostBeingScheduled2(), 39041 visibility: getEditedPostVisibility2(), 39042 isSaveable: isEditedPostSaveable2(), 39043 isPostSavingLocked: isPostSavingLocked2(), 39044 isPublishable: isEditedPostPublishable2(), 39045 isPublished: isCurrentPostPublished2(), 39046 hasPublishAction: getCurrentPost2()._links?.["wp:action-publish"] ?? false, 39047 postType: getCurrentPostType2(), 39048 postId: getCurrentPostId2(), 39049 postStatus: getEditedPostAttribute2("status"), 39050 postStatusHasChanged: getPostEdits2()?.status, 39051 hasNonPostEntityChanges: hasNonPostEntityChanges2(), 39052 isSavingNonPostEntityChanges: isSavingNonPostEntityChanges2() 39053 }; 39054 }), 39055 (0, import_data130.withDispatch)((dispatch6) => { 39056 const { editPost: editPost2, savePost: savePost2 } = dispatch6(store); 39057 return { 39058 savePostStatus: (status) => { 39059 editPost2({ status }, { undoIgnore: true }); 39060 savePost2(); 39061 } 39062 }; 39063 }) 39064 ])(PostPublishButton); 39065 39066 // packages/editor/build-module/components/post-publish-panel/index.js 39067 var import_i18n163 = __toESM(require_i18n()); 39068 var import_element118 = __toESM(require_element()); 39069 var import_components154 = __toESM(require_components()); 39070 var import_data144 = __toESM(require_data()); 39071 var import_compose35 = __toESM(require_compose()); 39072 var import_core_data90 = __toESM(require_core_data()); 39073 39074 // packages/editor/build-module/components/post-publish-panel/prepublish.js 39075 var import_i18n161 = __toESM(require_i18n()); 39076 var import_components152 = __toESM(require_components()); 39077 var import_data142 = __toESM(require_data()); 39078 var import_url14 = __toESM(require_url()); 39079 var import_core_data88 = __toESM(require_core_data()); 39080 var import_html_entities22 = __toESM(require_html_entities()); 39081 39082 // packages/editor/build-module/components/post-visibility/index.js 39083 var import_i18n152 = __toESM(require_i18n()); 39084 var import_element110 = __toESM(require_element()); 39085 var import_components144 = __toESM(require_components()); 39086 var import_compose31 = __toESM(require_compose()); 39087 var import_data131 = __toESM(require_data()); 39088 var import_block_editor54 = __toESM(require_block_editor()); 39089 39090 // packages/editor/build-module/components/post-visibility/utils.js 39091 var import_i18n151 = __toESM(require_i18n()); 39092 var VISIBILITY_OPTIONS = [ 39093 { 39094 label: (0, import_i18n151.__)("Public"), 39095 value: "public", 39096 description: (0, import_i18n151.__)("Visible to everyone.") 39097 }, 39098 { 39099 label: (0, import_i18n151.__)("Private"), 39100 value: "private", 39101 description: (0, import_i18n151.__)("Only visible to site admins and editors.") 39102 }, 39103 { 39104 label: (0, import_i18n151.__)("Password protected"), 39105 value: "password", 39106 description: (0, import_i18n151.__)("Only visible to those who know the password.") 39107 } 39108 ]; 39109 39110 // packages/editor/build-module/components/post-visibility/index.js 39111 var import_jsx_runtime256 = __toESM(require_jsx_runtime()); 39112 function PostVisibility({ onClose }) { 39113 const instanceId = (0, import_compose31.useInstanceId)(PostVisibility); 39114 const { status, visibility, password } = (0, import_data131.useSelect)((select5) => ({ 39115 status: select5(store).getEditedPostAttribute("status"), 39116 visibility: select5(store).getEditedPostVisibility(), 39117 password: select5(store).getEditedPostAttribute("password") 39118 })); 39119 const { editPost: editPost2 } = (0, import_data131.useDispatch)(store); 39120 const [hasPassword, setHasPassword] = (0, import_element110.useState)(!!password); 39121 function updateVisibility(value) { 39122 const nextValues = { 39123 public: { 39124 status: visibility === "private" ? "draft" : status, 39125 password: "" 39126 }, 39127 private: { status: "private", password: "" }, 39128 password: { 39129 status: visibility === "private" ? "draft" : status, 39130 password: password || "" 39131 } 39132 }; 39133 editPost2(nextValues[value]); 39134 setHasPassword(value === "password"); 39135 } 39136 const updatePassword = (value) => { 39137 editPost2({ password: value }); 39138 }; 39139 return /* @__PURE__ */ (0, import_jsx_runtime256.jsxs)("div", { className: "editor-post-visibility", children: [ 39140 /* @__PURE__ */ (0, import_jsx_runtime256.jsx)( 39141 import_block_editor54.__experimentalInspectorPopoverHeader, 39142 { 39143 title: (0, import_i18n152.__)("Visibility"), 39144 help: (0, import_i18n152.__)("Control how this post is viewed."), 39145 onClose 39146 } 39147 ), 39148 /* @__PURE__ */ (0, import_jsx_runtime256.jsxs)(import_components144.__experimentalVStack, { spacing: 4, children: [ 39149 /* @__PURE__ */ (0, import_jsx_runtime256.jsx)( 39150 import_components144.RadioControl, 39151 { 39152 label: (0, import_i18n152.__)("Visibility"), 39153 hideLabelFromVision: true, 39154 options: VISIBILITY_OPTIONS, 39155 selected: hasPassword ? "password" : visibility, 39156 onChange: updateVisibility 39157 } 39158 ), 39159 hasPassword && /* @__PURE__ */ (0, import_jsx_runtime256.jsx)( 39160 import_components144.TextControl, 39161 { 39162 label: (0, import_i18n152.__)("Password"), 39163 onChange: updatePassword, 39164 value: password, 39165 placeholder: (0, import_i18n152.__)("Use a secure password"), 39166 type: "text", 39167 id: `editor-post-visibility__password-input-$instanceId}`, 39168 __next40pxDefaultSize: true, 39169 maxLength: 255 39170 } 39171 ) 39172 ] }) 39173 ] }); 39174 } 39175 39176 // packages/editor/build-module/components/post-visibility/label.js 39177 var import_data132 = __toESM(require_data()); 39178 function PostVisibilityLabel() { 39179 return usePostVisibilityLabel(); 39180 } 39181 function usePostVisibilityLabel() { 39182 const visibility = (0, import_data132.useSelect)( 39183 (select5) => select5(store).getEditedPostVisibility(), 39184 [] 39185 ); 39186 return VISIBILITY_OPTIONS.find((option) => option.value === visibility)?.label; 39187 } 39188 39189 // node_modules/date-fns/toDate.mjs 39190 function toDate(argument) { 39191 const argStr = Object.prototype.toString.call(argument); 39192 if (argument instanceof Date || typeof argument === "object" && argStr === "[object Date]") { 39193 return new argument.constructor(+argument); 39194 } else if (typeof argument === "number" || argStr === "[object Number]" || typeof argument === "string" || argStr === "[object String]") { 39195 return new Date(argument); 39196 } else { 39197 return /* @__PURE__ */ new Date(NaN); 39198 } 39199 } 39200 39201 // node_modules/date-fns/constants.mjs 39202 var daysInYear = 365.2425; 39203 var maxTime = Math.pow(10, 8) * 24 * 60 * 60 * 1e3; 39204 var minTime = -maxTime; 39205 var millisecondsInMinute = 6e4; 39206 var millisecondsInHour = 36e5; 39207 var secondsInHour = 3600; 39208 var secondsInDay = secondsInHour * 24; 39209 var secondsInWeek = secondsInDay * 7; 39210 var secondsInYear = secondsInDay * daysInYear; 39211 var secondsInMonth = secondsInYear / 12; 39212 var secondsInQuarter = secondsInMonth * 3; 39213 39214 // node_modules/date-fns/endOfMonth.mjs 39215 function endOfMonth(date) { 39216 const _date = toDate(date); 39217 const month = _date.getMonth(); 39218 _date.setFullYear(_date.getFullYear(), month + 1, 0); 39219 _date.setHours(23, 59, 59, 999); 39220 return _date; 39221 } 39222 39223 // node_modules/date-fns/startOfMonth.mjs 39224 function startOfMonth(date) { 39225 const _date = toDate(date); 39226 _date.setDate(1); 39227 _date.setHours(0, 0, 0, 0); 39228 return _date; 39229 } 39230 39231 // node_modules/date-fns/parseISO.mjs 39232 function parseISO(argument, options) { 39233 const additionalDigits = options?.additionalDigits ?? 2; 39234 const dateStrings = splitDateString(argument); 39235 let date; 39236 if (dateStrings.date) { 39237 const parseYearResult = parseYear(dateStrings.date, additionalDigits); 39238 date = parseDate(parseYearResult.restDateString, parseYearResult.year); 39239 } 39240 if (!date || isNaN(date.getTime())) { 39241 return /* @__PURE__ */ new Date(NaN); 39242 } 39243 const timestamp = date.getTime(); 39244 let time = 0; 39245 let offset3; 39246 if (dateStrings.time) { 39247 time = parseTime(dateStrings.time); 39248 if (isNaN(time)) { 39249 return /* @__PURE__ */ new Date(NaN); 39250 } 39251 } 39252 if (dateStrings.timezone) { 39253 offset3 = parseTimezone(dateStrings.timezone); 39254 if (isNaN(offset3)) { 39255 return /* @__PURE__ */ new Date(NaN); 39256 } 39257 } else { 39258 const dirtyDate = new Date(timestamp + time); 39259 const result = /* @__PURE__ */ new Date(0); 39260 result.setFullYear( 39261 dirtyDate.getUTCFullYear(), 39262 dirtyDate.getUTCMonth(), 39263 dirtyDate.getUTCDate() 39264 ); 39265 result.setHours( 39266 dirtyDate.getUTCHours(), 39267 dirtyDate.getUTCMinutes(), 39268 dirtyDate.getUTCSeconds(), 39269 dirtyDate.getUTCMilliseconds() 39270 ); 39271 return result; 39272 } 39273 return new Date(timestamp + time + offset3); 39274 } 39275 var patterns = { 39276 dateTimeDelimiter: /[T ]/, 39277 timeZoneDelimiter: /[Z ]/i, 39278 timezone: /([Z+-].*)$/ 39279 }; 39280 var dateRegex = /^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/; 39281 var timeRegex = /^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/; 39282 var timezoneRegex = /^([+-])(\d{2})(?::?(\d{2}))?$/; 39283 function splitDateString(dateString) { 39284 const dateStrings = {}; 39285 const array = dateString.split(patterns.dateTimeDelimiter); 39286 let timeString; 39287 if (array.length > 2) { 39288 return dateStrings; 39289 } 39290 if (/:/.test(array[0])) { 39291 timeString = array[0]; 39292 } else { 39293 dateStrings.date = array[0]; 39294 timeString = array[1]; 39295 if (patterns.timeZoneDelimiter.test(dateStrings.date)) { 39296 dateStrings.date = dateString.split(patterns.timeZoneDelimiter)[0]; 39297 timeString = dateString.substr( 39298 dateStrings.date.length, 39299 dateString.length 39300 ); 39301 } 39302 } 39303 if (timeString) { 39304 const token = patterns.timezone.exec(timeString); 39305 if (token) { 39306 dateStrings.time = timeString.replace(token[1], ""); 39307 dateStrings.timezone = token[1]; 39308 } else { 39309 dateStrings.time = timeString; 39310 } 39311 } 39312 return dateStrings; 39313 } 39314 function parseYear(dateString, additionalDigits) { 39315 const regex = new RegExp( 39316 "^(?:(\\d{4}|[+-]\\d{" + (4 + additionalDigits) + "})|(\\d{2}|[+-]\\d{" + (2 + additionalDigits) + "})$)" 39317 ); 39318 const captures = dateString.match(regex); 39319 if (!captures) return { year: NaN, restDateString: "" }; 39320 const year = captures[1] ? parseInt(captures[1]) : null; 39321 const century = captures[2] ? parseInt(captures[2]) : null; 39322 return { 39323 year: century === null ? year : century * 100, 39324 restDateString: dateString.slice((captures[1] || captures[2]).length) 39325 }; 39326 } 39327 function parseDate(dateString, year) { 39328 if (year === null) return /* @__PURE__ */ new Date(NaN); 39329 const captures = dateString.match(dateRegex); 39330 if (!captures) return /* @__PURE__ */ new Date(NaN); 39331 const isWeekDate = !!captures[4]; 39332 const dayOfYear = parseDateUnit(captures[1]); 39333 const month = parseDateUnit(captures[2]) - 1; 39334 const day = parseDateUnit(captures[3]); 39335 const week = parseDateUnit(captures[4]); 39336 const dayOfWeek = parseDateUnit(captures[5]) - 1; 39337 if (isWeekDate) { 39338 if (!validateWeekDate(year, week, dayOfWeek)) { 39339 return /* @__PURE__ */ new Date(NaN); 39340 } 39341 return dayOfISOWeekYear(year, week, dayOfWeek); 39342 } else { 39343 const date = /* @__PURE__ */ new Date(0); 39344 if (!validateDate(year, month, day) || !validateDayOfYearDate(year, dayOfYear)) { 39345 return /* @__PURE__ */ new Date(NaN); 39346 } 39347 date.setUTCFullYear(year, month, Math.max(dayOfYear, day)); 39348 return date; 39349 } 39350 } 39351 function parseDateUnit(value) { 39352 return value ? parseInt(value) : 1; 39353 } 39354 function parseTime(timeString) { 39355 const captures = timeString.match(timeRegex); 39356 if (!captures) return NaN; 39357 const hours = parseTimeUnit(captures[1]); 39358 const minutes = parseTimeUnit(captures[2]); 39359 const seconds = parseTimeUnit(captures[3]); 39360 if (!validateTime(hours, minutes, seconds)) { 39361 return NaN; 39362 } 39363 return hours * millisecondsInHour + minutes * millisecondsInMinute + seconds * 1e3; 39364 } 39365 function parseTimeUnit(value) { 39366 return value && parseFloat(value.replace(",", ".")) || 0; 39367 } 39368 function parseTimezone(timezoneString) { 39369 if (timezoneString === "Z") return 0; 39370 const captures = timezoneString.match(timezoneRegex); 39371 if (!captures) return 0; 39372 const sign = captures[1] === "+" ? -1 : 1; 39373 const hours = parseInt(captures[2]); 39374 const minutes = captures[3] && parseInt(captures[3]) || 0; 39375 if (!validateTimezone(hours, minutes)) { 39376 return NaN; 39377 } 39378 return sign * (hours * millisecondsInHour + minutes * millisecondsInMinute); 39379 } 39380 function dayOfISOWeekYear(isoWeekYear, week, day) { 39381 const date = /* @__PURE__ */ new Date(0); 39382 date.setUTCFullYear(isoWeekYear, 0, 4); 39383 const fourthOfJanuaryDay = date.getUTCDay() || 7; 39384 const diff = (week - 1) * 7 + day + 1 - fourthOfJanuaryDay; 39385 date.setUTCDate(date.getUTCDate() + diff); 39386 return date; 39387 } 39388 var daysInMonths = [31, null, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; 39389 function isLeapYearIndex(year) { 39390 return year % 400 === 0 || year % 4 === 0 && year % 100 !== 0; 39391 } 39392 function validateDate(year, month, date) { 39393 return month >= 0 && month <= 11 && date >= 1 && date <= (daysInMonths[month] || (isLeapYearIndex(year) ? 29 : 28)); 39394 } 39395 function validateDayOfYearDate(year, dayOfYear) { 39396 return dayOfYear >= 1 && dayOfYear <= (isLeapYearIndex(year) ? 366 : 365); 39397 } 39398 function validateWeekDate(_year, week, day) { 39399 return week >= 1 && week <= 53 && day >= 0 && day <= 6; 39400 } 39401 function validateTime(hours, minutes, seconds) { 39402 if (hours === 24) { 39403 return minutes === 0 && seconds === 0; 39404 } 39405 return seconds >= 0 && seconds < 60 && minutes >= 0 && minutes < 60 && hours >= 0 && hours < 25; 39406 } 39407 function validateTimezone(_hours, minutes) { 39408 return minutes >= 0 && minutes <= 59; 39409 } 39410 39411 // packages/editor/build-module/components/post-schedule/index.js 39412 var import_date5 = __toESM(require_date()); 39413 var import_i18n153 = __toESM(require_i18n()); 39414 var import_data133 = __toESM(require_data()); 39415 var import_block_editor55 = __toESM(require_block_editor()); 39416 var import_element111 = __toESM(require_element()); 39417 var import_core_data81 = __toESM(require_core_data()); 39418 var import_jsx_runtime257 = __toESM(require_jsx_runtime()); 39419 var { PrivatePublishDateTimePicker } = unlock(import_block_editor55.privateApis); 39420 function PostSchedule(props) { 39421 return /* @__PURE__ */ (0, import_jsx_runtime257.jsx)( 39422 PrivatePostSchedule, 39423 { 39424 ...props, 39425 showPopoverHeaderActions: true, 39426 isCompact: false 39427 } 39428 ); 39429 } 39430 function PrivatePostSchedule({ 39431 onClose, 39432 showPopoverHeaderActions, 39433 isCompact 39434 }) { 39435 const { postDate, postType: postType2 } = (0, import_data133.useSelect)( 39436 (select5) => ({ 39437 postDate: select5(store).getEditedPostAttribute("date"), 39438 postType: select5(store).getCurrentPostType() 39439 }), 39440 [] 39441 ); 39442 const { editPost: editPost2 } = (0, import_data133.useDispatch)(store); 39443 const onUpdateDate = (date) => editPost2({ date }); 39444 const [previewedMonth, setPreviewedMonth] = (0, import_element111.useState)( 39445 startOfMonth(new Date(postDate)) 39446 ); 39447 const eventsByPostType = (0, import_data133.useSelect)( 39448 (select5) => select5(import_core_data81.store).getEntityRecords("postType", postType2, { 39449 status: "publish,future", 39450 after: startOfMonth(previewedMonth).toISOString(), 39451 before: endOfMonth(previewedMonth).toISOString(), 39452 exclude: [select5(store).getCurrentPostId()], 39453 per_page: 100, 39454 _fields: "id,date" 39455 }), 39456 [previewedMonth, postType2] 39457 ); 39458 const events = (0, import_element111.useMemo)( 39459 () => (eventsByPostType || []).map(({ date: eventDate }) => ({ 39460 date: new Date(eventDate) 39461 })), 39462 [eventsByPostType] 39463 ); 39464 const settings = (0, import_date5.getSettings)(); 39465 const is12HourTime = /a(?!\\)/i.test( 39466 settings.formats.time.toLowerCase().replace(/\\\\/g, "").split("").reverse().join("") 39467 // Reverse the string and test for "a" not followed by a slash. 39468 ); 39469 return /* @__PURE__ */ (0, import_jsx_runtime257.jsx)( 39470 PrivatePublishDateTimePicker, 39471 { 39472 currentDate: postDate, 39473 onChange: onUpdateDate, 39474 is12Hour: is12HourTime, 39475 dateOrder: ( 39476 /* translators: Order of day, month, and year. Available formats are 'dmy', 'mdy', and 'ymd'. */ 39477 (0, import_i18n153._x)("dmy", "date order") 39478 ), 39479 events, 39480 onMonthPreviewed: (date) => setPreviewedMonth(parseISO(date)), 39481 onClose, 39482 isCompact, 39483 showPopoverHeaderActions 39484 } 39485 ); 39486 } 39487 39488 // packages/editor/build-module/components/post-schedule/label.js 39489 var import_i18n154 = __toESM(require_i18n()); 39490 var import_date6 = __toESM(require_date()); 39491 var import_data134 = __toESM(require_data()); 39492 function PostScheduleLabel(props) { 39493 return usePostScheduleLabel(props); 39494 } 39495 function usePostScheduleLabel({ full = false } = {}) { 39496 const { date, isFloating } = (0, import_data134.useSelect)( 39497 (select5) => ({ 39498 date: select5(store).getEditedPostAttribute("date"), 39499 isFloating: select5(store).isEditedPostDateFloating() 39500 }), 39501 [] 39502 ); 39503 return full ? getFullPostScheduleLabel(date) : getPostScheduleLabel(date, { isFloating }); 39504 } 39505 function getFullPostScheduleLabel(dateAttribute) { 39506 const date = (0, import_date6.getDate)(dateAttribute); 39507 const timezoneAbbreviation = getTimezoneAbbreviation(); 39508 const formattedDate = (0, import_date6.dateI18n)( 39509 // translators: Use a non-breaking space between 'g:i' and 'a' if appropriate. 39510 (0, import_i18n154._x)("F j, Y g:i\xA0a", "post schedule full date format"), 39511 date 39512 ); 39513 return (0, import_i18n154.isRTL)() ? `$timezoneAbbreviation} $formattedDate}` : `$formattedDate} $timezoneAbbreviation}`; 39514 } 39515 function getPostScheduleLabel(dateAttribute, { isFloating = false, now = /* @__PURE__ */ new Date() } = {}) { 39516 if (!dateAttribute || isFloating) { 39517 return (0, import_i18n154.__)("Immediately"); 39518 } 39519 if (!isTimezoneSameAsSiteTimezone(now)) { 39520 return getFullPostScheduleLabel(dateAttribute); 39521 } 39522 const date = (0, import_date6.getDate)(dateAttribute); 39523 if (isSameDay(date, now)) { 39524 return (0, import_i18n154.sprintf)( 39525 // translators: %s: Time of day the post is scheduled for. 39526 (0, import_i18n154.__)("Today at %s"), 39527 // translators: If using a space between 'g:i' and 'a', use a non-breaking space. 39528 (0, import_date6.dateI18n)((0, import_i18n154._x)("g:i\xA0a", "post schedule time format"), date) 39529 ); 39530 } 39531 const tomorrow = new Date(now); 39532 tomorrow.setDate(tomorrow.getDate() + 1); 39533 if (isSameDay(date, tomorrow)) { 39534 return (0, import_i18n154.sprintf)( 39535 // translators: %s: Time of day the post is scheduled for. 39536 (0, import_i18n154.__)("Tomorrow at %s"), 39537 // translators: If using a space between 'g:i' and 'a', use a non-breaking space. 39538 (0, import_date6.dateI18n)((0, import_i18n154._x)("g:i\xA0a", "post schedule time format"), date) 39539 ); 39540 } 39541 if (date.getFullYear() === now.getFullYear()) { 39542 return (0, import_date6.dateI18n)( 39543 // translators: If using a space between 'g:i' and 'a', use a non-breaking space. 39544 (0, import_i18n154._x)("F j g:i\xA0a", "post schedule date format without year"), 39545 date 39546 ); 39547 } 39548 return (0, import_date6.dateI18n)( 39549 // translators: Use a non-breaking space between 'g:i' and 'a' if appropriate. 39550 (0, import_i18n154._x)("F j, Y g:i\xA0a", "post schedule full date format"), 39551 date 39552 ); 39553 } 39554 function getTimezoneAbbreviation() { 39555 const { timezone } = (0, import_date6.getSettings)(); 39556 if (timezone.abbr && isNaN(Number(timezone.abbr))) { 39557 return timezone.abbr; 39558 } 39559 const symbol = timezone.offset < 0 ? "" : "+"; 39560 return `UTC$symbol}$timezone.offsetFormatted}`; 39561 } 39562 function isTimezoneSameAsSiteTimezone(date) { 39563 const { timezone } = (0, import_date6.getSettings)(); 39564 const siteOffset = Number(timezone.offset); 39565 const dateOffset = -1 * (date.getTimezoneOffset() / 60); 39566 return siteOffset === dateOffset; 39567 } 39568 function isSameDay(left, right) { 39569 return left.getDate() === right.getDate() && left.getMonth() === right.getMonth() && left.getFullYear() === right.getFullYear(); 39570 } 39571 39572 // packages/editor/build-module/components/post-publish-panel/maybe-tags-panel.js 39573 var import_i18n156 = __toESM(require_i18n()); 39574 var import_element113 = __toESM(require_element()); 39575 var import_data137 = __toESM(require_data()); 39576 var import_components147 = __toESM(require_components()); 39577 var import_core_data84 = __toESM(require_core_data()); 39578 39579 // packages/editor/build-module/components/post-taxonomies/flat-term-selector.js 39580 var import_i18n155 = __toESM(require_i18n()); 39581 var import_element112 = __toESM(require_element()); 39582 var import_components146 = __toESM(require_components()); 39583 var import_data136 = __toESM(require_data()); 39584 var import_core_data83 = __toESM(require_core_data()); 39585 var import_compose32 = __toESM(require_compose()); 39586 var import_a11y4 = __toESM(require_a11y()); 39587 var import_notices22 = __toESM(require_notices()); 39588 39589 // packages/editor/build-module/components/post-taxonomies/most-used-terms.js 39590 var import_components145 = __toESM(require_components()); 39591 var import_data135 = __toESM(require_data()); 39592 var import_core_data82 = __toESM(require_core_data()); 39593 var import_jsx_runtime258 = __toESM(require_jsx_runtime()); 39594 var MIN_MOST_USED_TERMS = 3; 39595 var DEFAULT_QUERY2 = { 39596 per_page: 10, 39597 orderby: "count", 39598 order: "desc", 39599 hide_empty: true, 39600 _fields: "id,name,count", 39601 context: "view" 39602 }; 39603 function MostUsedTerms({ onSelect, taxonomy }) { 39604 const { _terms, showTerms } = (0, import_data135.useSelect)( 39605 (select5) => { 39606 const mostUsedTerms = select5(import_core_data82.store).getEntityRecords( 39607 "taxonomy", 39608 taxonomy.slug, 39609 DEFAULT_QUERY2 39610 ); 39611 return { 39612 _terms: mostUsedTerms, 39613 showTerms: mostUsedTerms?.length >= MIN_MOST_USED_TERMS 39614 }; 39615 }, 39616 [taxonomy.slug] 39617 ); 39618 if (!showTerms) { 39619 return null; 39620 } 39621 const terms = unescapeTerms(_terms); 39622 return /* @__PURE__ */ (0, import_jsx_runtime258.jsxs)("div", { className: "editor-post-taxonomies__flat-term-most-used", children: [ 39623 /* @__PURE__ */ (0, import_jsx_runtime258.jsx)( 39624 import_components145.BaseControl.VisualLabel, 39625 { 39626 as: "h3", 39627 className: "editor-post-taxonomies__flat-term-most-used-label", 39628 children: taxonomy.labels.most_used 39629 } 39630 ), 39631 /* @__PURE__ */ (0, import_jsx_runtime258.jsx)( 39632 "ul", 39633 { 39634 role: "list", 39635 className: "editor-post-taxonomies__flat-term-most-used-list", 39636 children: terms.map((term) => /* @__PURE__ */ (0, import_jsx_runtime258.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime258.jsx)( 39637 import_components145.Button, 39638 { 39639 __next40pxDefaultSize: true, 39640 variant: "link", 39641 onClick: () => onSelect(term), 39642 children: term.name 39643 } 39644 ) }, term.id)) 39645 } 39646 ) 39647 ] }); 39648 } 39649 39650 // packages/editor/build-module/components/post-taxonomies/flat-term-selector.js 39651 var import_jsx_runtime259 = __toESM(require_jsx_runtime()); 39652 var EMPTY_ARRAY6 = []; 39653 var MAX_TERMS_SUGGESTIONS = 100; 39654 var DEFAULT_QUERY3 = { 39655 per_page: MAX_TERMS_SUGGESTIONS, 39656 _fields: "id,name", 39657 context: "view" 39658 }; 39659 var isSameTermName = (termA, termB) => unescapeString(termA).toLowerCase() === unescapeString(termB).toLowerCase(); 39660 var termNamesToIds = (names, terms) => { 39661 return names.map( 39662 (termName) => terms.find((term) => isSameTermName(term.name, termName))?.id 39663 ).filter((id) => id !== void 0); 39664 }; 39665 function FlatTermSelector({ slug }) { 39666 const [values, setValues] = (0, import_element112.useState)([]); 39667 const [search, setSearch] = (0, import_element112.useState)(""); 39668 const debouncedSearch = (0, import_compose32.useDebounce)(setSearch, 500); 39669 const { 39670 terms, 39671 termIds, 39672 taxonomy, 39673 hasAssignAction, 39674 hasCreateAction, 39675 hasResolvedTerms 39676 } = (0, import_data136.useSelect)( 39677 (select5) => { 39678 const { getCurrentPost: getCurrentPost2, getEditedPostAttribute: getEditedPostAttribute2 } = select5(store); 39679 const { getEntityRecords, getEntityRecord, hasFinishedResolution } = select5(import_core_data83.store); 39680 const post2 = getCurrentPost2(); 39681 const _taxonomy = getEntityRecord("root", "taxonomy", slug); 39682 const _termIds = _taxonomy ? getEditedPostAttribute2(_taxonomy.rest_base) : EMPTY_ARRAY6; 39683 const query = { 39684 ...DEFAULT_QUERY3, 39685 include: _termIds?.join(","), 39686 per_page: -1 39687 }; 39688 return { 39689 hasCreateAction: _taxonomy ? post2._links?.["wp:action-create-" + _taxonomy.rest_base] ?? false : false, 39690 hasAssignAction: _taxonomy ? post2._links?.["wp:action-assign-" + _taxonomy.rest_base] ?? false : false, 39691 taxonomy: _taxonomy, 39692 termIds: _termIds, 39693 terms: _termIds?.length ? getEntityRecords("taxonomy", slug, query) : EMPTY_ARRAY6, 39694 hasResolvedTerms: hasFinishedResolution("getEntityRecords", [ 39695 "taxonomy", 39696 slug, 39697 query 39698 ]) 39699 }; 39700 }, 39701 [slug] 39702 ); 39703 const { searchResults } = (0, import_data136.useSelect)( 39704 (select5) => { 39705 const { getEntityRecords } = select5(import_core_data83.store); 39706 return { 39707 searchResults: !!search ? getEntityRecords("taxonomy", slug, { 39708 ...DEFAULT_QUERY3, 39709 search 39710 }) : EMPTY_ARRAY6 39711 }; 39712 }, 39713 [search, slug] 39714 ); 39715 (0, import_element112.useEffect)(() => { 39716 if (hasResolvedTerms) { 39717 const newValues = (terms ?? []).map( 39718 (term) => unescapeString(term.name) 39719 ); 39720 setValues(newValues); 39721 } 39722 }, [terms, hasResolvedTerms]); 39723 const suggestions = (0, import_element112.useMemo)(() => { 39724 return (searchResults ?? []).map( 39725 (term) => unescapeString(term.name) 39726 ); 39727 }, [searchResults]); 39728 const { editPost: editPost2 } = (0, import_data136.useDispatch)(store); 39729 const { saveEntityRecord } = (0, import_data136.useDispatch)(import_core_data83.store); 39730 const { createErrorNotice } = (0, import_data136.useDispatch)(import_notices22.store); 39731 if (!hasAssignAction) { 39732 return null; 39733 } 39734 async function findOrCreateTerm(term) { 39735 try { 39736 const newTerm = await saveEntityRecord("taxonomy", slug, term, { 39737 throwOnError: true 39738 }); 39739 return unescapeTerm(newTerm); 39740 } catch (error) { 39741 if (error.code !== "term_exists") { 39742 throw error; 39743 } 39744 return { 39745 id: error.data.term_id, 39746 name: term.name 39747 }; 39748 } 39749 } 39750 function onUpdateTerms(newTermIds) { 39751 editPost2({ [taxonomy.rest_base]: newTermIds }); 39752 } 39753 function onChange(termNames) { 39754 const availableTerms = [ 39755 ...terms ?? [], 39756 ...searchResults ?? [] 39757 ]; 39758 const uniqueTerms = termNames.reduce((acc, name2) => { 39759 if (!acc.some((n3) => n3.toLowerCase() === name2.toLowerCase())) { 39760 acc.push(name2); 39761 } 39762 return acc; 39763 }, []); 39764 const newTermNames = uniqueTerms.filter( 39765 (termName) => !availableTerms.find( 39766 (term) => isSameTermName(term.name, termName) 39767 ) 39768 ); 39769 setValues(uniqueTerms); 39770 if (newTermNames.length === 0) { 39771 onUpdateTerms(termNamesToIds(uniqueTerms, availableTerms)); 39772 return; 39773 } 39774 if (!hasCreateAction) { 39775 return; 39776 } 39777 Promise.all( 39778 newTermNames.map( 39779 (termName) => findOrCreateTerm({ name: termName }) 39780 ) 39781 ).then((newTerms) => { 39782 const newAvailableTerms = availableTerms.concat(newTerms); 39783 onUpdateTerms( 39784 termNamesToIds(uniqueTerms, newAvailableTerms) 39785 ); 39786 }).catch((error) => { 39787 createErrorNotice(error.message, { 39788 type: "snackbar" 39789 }); 39790 onUpdateTerms(termNamesToIds(uniqueTerms, availableTerms)); 39791 }); 39792 } 39793 function appendTerm(newTerm) { 39794 if (termIds.includes(newTerm.id)) { 39795 return; 39796 } 39797 const newTermIds = [...termIds, newTerm.id]; 39798 const defaultName = slug === "post_tag" ? (0, import_i18n155.__)("Tag") : (0, import_i18n155.__)("Term"); 39799 const termAddedMessage = (0, import_i18n155.sprintf)( 39800 /* translators: %s: term name. */ 39801 (0, import_i18n155._x)("%s added", "term"), 39802 taxonomy?.labels?.singular_name ?? defaultName 39803 ); 39804 (0, import_a11y4.speak)(termAddedMessage, "assertive"); 39805 onUpdateTerms(newTermIds); 39806 } 39807 const newTermLabel = taxonomy?.labels?.add_new_item ?? (slug === "post_tag" ? (0, import_i18n155.__)("Add Tag") : (0, import_i18n155.__)("Add Term")); 39808 const singularName = taxonomy?.labels?.singular_name ?? (slug === "post_tag" ? (0, import_i18n155.__)("Tag") : (0, import_i18n155.__)("Term")); 39809 const termAddedLabel = (0, import_i18n155.sprintf)( 39810 /* translators: %s: term name. */ 39811 (0, import_i18n155._x)("%s added", "term"), 39812 singularName 39813 ); 39814 const termRemovedLabel = (0, import_i18n155.sprintf)( 39815 /* translators: %s: term name. */ 39816 (0, import_i18n155._x)("%s removed", "term"), 39817 singularName 39818 ); 39819 const removeTermLabel = (0, import_i18n155.sprintf)( 39820 /* translators: %s: term name. */ 39821 (0, import_i18n155._x)("Remove %s", "term"), 39822 singularName 39823 ); 39824 return /* @__PURE__ */ (0, import_jsx_runtime259.jsxs)(import_components146.__experimentalVStack, { spacing: 4, children: [ 39825 /* @__PURE__ */ (0, import_jsx_runtime259.jsx)( 39826 import_components146.FormTokenField, 39827 { 39828 __next40pxDefaultSize: true, 39829 value: values, 39830 suggestions, 39831 onChange, 39832 onInputChange: debouncedSearch, 39833 maxSuggestions: MAX_TERMS_SUGGESTIONS, 39834 label: newTermLabel, 39835 messages: { 39836 added: termAddedLabel, 39837 removed: termRemovedLabel, 39838 remove: removeTermLabel 39839 } 39840 } 39841 ), 39842 /* @__PURE__ */ (0, import_jsx_runtime259.jsx)(MostUsedTerms, { taxonomy, onSelect: appendTerm }) 39843 ] }); 39844 } 39845 var flat_term_selector_default = (0, import_components146.withFilters)("editor.PostTaxonomyType")(FlatTermSelector); 39846 39847 // packages/editor/build-module/components/post-publish-panel/maybe-tags-panel.js 39848 var import_jsx_runtime260 = __toESM(require_jsx_runtime()); 39849 var TagsPanel = () => { 39850 const tagLabels = (0, import_data137.useSelect)((select5) => { 39851 const taxonomy = select5(import_core_data84.store).getTaxonomy("post_tag"); 39852 return taxonomy?.labels; 39853 }, []); 39854 const addNewItem = tagLabels?.add_new_item ?? (0, import_i18n156.__)("Add tag"); 39855 const tagLabel = tagLabels?.name ?? (0, import_i18n156.__)("Tags"); 39856 const panelBodyTitle = [ 39857 (0, import_i18n156.__)("Suggestion:"), 39858 /* @__PURE__ */ (0, import_jsx_runtime260.jsx)("span", { className: "editor-post-publish-panel__link", children: addNewItem }, "label") 39859 ]; 39860 return /* @__PURE__ */ (0, import_jsx_runtime260.jsxs)(import_components147.PanelBody, { initialOpen: false, title: panelBodyTitle, children: [ 39861 /* @__PURE__ */ (0, import_jsx_runtime260.jsx)("p", { children: (0, import_i18n156.sprintf)( 39862 // translators: %s is the taxonomy name (e.g., "Tags"). 39863 (0, import_i18n156.__)( 39864 "%s help users and search engines navigate your site and find your content. Add a few keywords to describe your post." 39865 ), 39866 tagLabel 39867 ) }), 39868 /* @__PURE__ */ (0, import_jsx_runtime260.jsx)(flat_term_selector_default, { slug: "post_tag" }) 39869 ] }); 39870 }; 39871 var MaybeTagsPanel = () => { 39872 const { postHasTags, siteHasTags, isPostTypeSupported } = (0, import_data137.useSelect)( 39873 (select5) => { 39874 const postType2 = select5(store).getCurrentPostType(); 39875 const tagsTaxonomy = select5(import_core_data84.store).getEntityRecord( 39876 "root", 39877 "taxonomy", 39878 "post_tag" 39879 ); 39880 const _isPostTypeSupported = tagsTaxonomy?.types?.includes(postType2); 39881 const areTagsFetched = tagsTaxonomy !== void 0; 39882 const tags = tagsTaxonomy && select5(store).getEditedPostAttribute( 39883 tagsTaxonomy.rest_base 39884 ); 39885 const siteTags = _isPostTypeSupported ? !!select5(import_core_data84.store).getEntityRecords( 39886 "taxonomy", 39887 "post_tag", 39888 { per_page: 1 } 39889 )?.length : false; 39890 return { 39891 postHasTags: !!tags?.length, 39892 siteHasTags: siteTags, 39893 isPostTypeSupported: areTagsFetched && _isPostTypeSupported 39894 }; 39895 }, 39896 [] 39897 ); 39898 const [hadTagsWhenOpeningThePanel] = (0, import_element113.useState)(postHasTags); 39899 if (!isPostTypeSupported || !siteHasTags) { 39900 return null; 39901 } 39902 if (!hadTagsWhenOpeningThePanel) { 39903 return /* @__PURE__ */ (0, import_jsx_runtime260.jsx)(TagsPanel, {}); 39904 } 39905 return null; 39906 }; 39907 var maybe_tags_panel_default = MaybeTagsPanel; 39908 39909 // packages/editor/build-module/components/post-publish-panel/maybe-post-format-panel.js 39910 var import_components148 = __toESM(require_components()); 39911 var import_data138 = __toESM(require_data()); 39912 var import_i18n157 = __toESM(require_i18n()); 39913 var import_core_data85 = __toESM(require_core_data()); 39914 var import_jsx_runtime261 = __toESM(require_jsx_runtime()); 39915 var getSuggestion = (supportedFormats, suggestedPostFormat) => { 39916 const formats = POST_FORMATS.filter( 39917 (format) => supportedFormats?.includes(format.id) 39918 ); 39919 return formats.find((format) => format.id === suggestedPostFormat); 39920 }; 39921 var PostFormatSuggestion = ({ 39922 suggestedPostFormat, 39923 suggestionText, 39924 onUpdatePostFormat 39925 }) => /* @__PURE__ */ (0, import_jsx_runtime261.jsx)( 39926 import_components148.Button, 39927 { 39928 __next40pxDefaultSize: true, 39929 variant: "link", 39930 onClick: () => onUpdatePostFormat(suggestedPostFormat), 39931 children: suggestionText 39932 } 39933 ); 39934 function PostFormatPanel() { 39935 const { currentPostFormat, suggestion } = (0, import_data138.useSelect)((select5) => { 39936 const { getEditedPostAttribute: getEditedPostAttribute2, getSuggestedPostFormat: getSuggestedPostFormat2 } = select5(store); 39937 const supportedFormats = select5(import_core_data85.store).getThemeSupports().formats ?? []; 39938 return { 39939 currentPostFormat: getEditedPostAttribute2("format"), 39940 suggestion: getSuggestion( 39941 supportedFormats, 39942 getSuggestedPostFormat2() 39943 ) 39944 }; 39945 }, []); 39946 const { editPost: editPost2 } = (0, import_data138.useDispatch)(store); 39947 const onUpdatePostFormat = (format) => editPost2({ format }); 39948 const panelBodyTitle = [ 39949 (0, import_i18n157.__)("Suggestion:"), 39950 /* @__PURE__ */ (0, import_jsx_runtime261.jsx)("span", { className: "editor-post-publish-panel__link", children: (0, import_i18n157.__)("Use a post format") }, "label") 39951 ]; 39952 if (!suggestion || suggestion.id === currentPostFormat) { 39953 return null; 39954 } 39955 return /* @__PURE__ */ (0, import_jsx_runtime261.jsxs)(import_components148.PanelBody, { initialOpen: false, title: panelBodyTitle, children: [ 39956 /* @__PURE__ */ (0, import_jsx_runtime261.jsx)("p", { children: (0, import_i18n157.__)( 39957 "Your theme uses post formats to highlight different kinds of content, like images or videos. Apply a post format to see this special styling." 39958 ) }), 39959 /* @__PURE__ */ (0, import_jsx_runtime261.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime261.jsx)( 39960 PostFormatSuggestion, 39961 { 39962 onUpdatePostFormat, 39963 suggestedPostFormat: suggestion.id, 39964 suggestionText: (0, import_i18n157.sprintf)( 39965 /* translators: %1s: post format */ 39966 (0, import_i18n157.__)('Apply the "%1$s" format.'), 39967 suggestion.caption 39968 ) 39969 } 39970 ) }) 39971 ] }); 39972 } 39973 39974 // packages/editor/build-module/components/post-publish-panel/maybe-category-panel.js 39975 var import_i18n159 = __toESM(require_i18n()); 39976 var import_data140 = __toESM(require_data()); 39977 var import_components150 = __toESM(require_components()); 39978 var import_core_data87 = __toESM(require_core_data()); 39979 var import_element115 = __toESM(require_element()); 39980 39981 // packages/editor/build-module/components/post-taxonomies/hierarchical-term-selector.js 39982 var import_i18n158 = __toESM(require_i18n()); 39983 var import_element114 = __toESM(require_element()); 39984 var import_notices23 = __toESM(require_notices()); 39985 var import_components149 = __toESM(require_components()); 39986 var import_data139 = __toESM(require_data()); 39987 var import_compose33 = __toESM(require_compose()); 39988 var import_core_data86 = __toESM(require_core_data()); 39989 var import_a11y5 = __toESM(require_a11y()); 39990 var import_html_entities21 = __toESM(require_html_entities()); 39991 var import_jsx_runtime262 = __toESM(require_jsx_runtime()); 39992 var { normalizeTextString } = unlock(import_components149.privateApis); 39993 var { RECEIVE_INTERMEDIATE_RESULTS } = unlock(import_core_data86.privateApis); 39994 var DEFAULT_QUERY4 = { 39995 per_page: -1, 39996 orderby: "name", 39997 order: "asc", 39998 _fields: "id,name,parent", 39999 context: "view", 40000 [RECEIVE_INTERMEDIATE_RESULTS]: true 40001 }; 40002 var MIN_TERMS_COUNT_FOR_FILTER = 8; 40003 var EMPTY_ARRAY7 = []; 40004 function sortBySelected(termsTree, terms) { 40005 const treeHasSelection = (termTree) => { 40006 if (terms.indexOf(termTree.id) !== -1) { 40007 return true; 40008 } 40009 if (void 0 === termTree.children) { 40010 return false; 40011 } 40012 return termTree.children.map(treeHasSelection).filter((child) => child).length > 0; 40013 }; 40014 const termOrChildIsSelected = (termA, termB) => { 40015 const termASelected = treeHasSelection(termA); 40016 const termBSelected = treeHasSelection(termB); 40017 if (termASelected === termBSelected) { 40018 return 0; 40019 } 40020 if (termASelected && !termBSelected) { 40021 return -1; 40022 } 40023 if (!termASelected && termBSelected) { 40024 return 1; 40025 } 40026 return 0; 40027 }; 40028 const newTermTree = [...termsTree]; 40029 newTermTree.sort(termOrChildIsSelected); 40030 return newTermTree; 40031 } 40032 function findTerm(terms, parent, name2) { 40033 return terms.find((term) => { 40034 return (!term.parent && !parent || parseInt(term.parent) === parseInt(parent)) && term.name.toLowerCase() === name2.toLowerCase(); 40035 }); 40036 } 40037 function getFilterMatcher(filterValue) { 40038 const matchTermsForFilter = (originalTerm) => { 40039 if ("" === filterValue) { 40040 return originalTerm; 40041 } 40042 const term = { ...originalTerm }; 40043 if (term.children.length > 0) { 40044 term.children = term.children.map(matchTermsForFilter).filter((child) => child); 40045 } 40046 if (-1 !== normalizeTextString(term.name).indexOf( 40047 normalizeTextString(filterValue) 40048 ) || term.children.length > 0) { 40049 return term; 40050 } 40051 return false; 40052 }; 40053 return matchTermsForFilter; 40054 } 40055 function HierarchicalTermSelector({ slug }) { 40056 const [adding, setAdding] = (0, import_element114.useState)(false); 40057 const [formName, setFormName] = (0, import_element114.useState)(""); 40058 const [formParent, setFormParent] = (0, import_element114.useState)(""); 40059 const [showForm, setShowForm] = (0, import_element114.useState)(false); 40060 const [filterValue, setFilterValue] = (0, import_element114.useState)(""); 40061 const [filteredTermsTree, setFilteredTermsTree] = (0, import_element114.useState)([]); 40062 const debouncedSpeak = (0, import_compose33.useDebounce)(import_a11y5.speak, 500); 40063 const { 40064 hasCreateAction, 40065 hasAssignAction, 40066 terms, 40067 loading, 40068 availableTerms, 40069 taxonomy 40070 } = (0, import_data139.useSelect)( 40071 (select5) => { 40072 const { getCurrentPost: getCurrentPost2, getEditedPostAttribute: getEditedPostAttribute2 } = select5(store); 40073 const { getEntityRecord, getEntityRecords, isResolving } = select5(import_core_data86.store); 40074 const _taxonomy = getEntityRecord("root", "taxonomy", slug); 40075 const post2 = getCurrentPost2(); 40076 return { 40077 hasCreateAction: _taxonomy ? !!post2._links?.["wp:action-create-" + _taxonomy.rest_base] : false, 40078 hasAssignAction: _taxonomy ? !!post2._links?.["wp:action-assign-" + _taxonomy.rest_base] : false, 40079 terms: _taxonomy ? getEditedPostAttribute2(_taxonomy.rest_base) : EMPTY_ARRAY7, 40080 loading: isResolving("getEntityRecords", [ 40081 "taxonomy", 40082 slug, 40083 DEFAULT_QUERY4 40084 ]), 40085 availableTerms: getEntityRecords("taxonomy", slug, DEFAULT_QUERY4) || EMPTY_ARRAY7, 40086 taxonomy: _taxonomy 40087 }; 40088 }, 40089 [slug] 40090 ); 40091 const { editPost: editPost2 } = (0, import_data139.useDispatch)(store); 40092 const { saveEntityRecord } = (0, import_data139.useDispatch)(import_core_data86.store); 40093 const availableTermsTree = (0, import_element114.useMemo)( 40094 () => sortBySelected(buildTermsTree2(availableTerms), terms), 40095 // Remove `terms` from the dependency list to avoid reordering every time 40096 // checking or unchecking a term. 40097 [availableTerms] 40098 ); 40099 const { createErrorNotice } = (0, import_data139.useDispatch)(import_notices23.store); 40100 if (!hasAssignAction) { 40101 return null; 40102 } 40103 const addTerm = (term) => { 40104 return saveEntityRecord("taxonomy", slug, term, { 40105 throwOnError: true 40106 }); 40107 }; 40108 const onUpdateTerms = (termIds) => { 40109 editPost2({ [taxonomy.rest_base]: termIds }); 40110 }; 40111 const onChange = (termId) => { 40112 const hasTerm = terms.includes(termId); 40113 const newTerms = hasTerm ? terms.filter((id) => id !== termId) : [...terms, termId]; 40114 onUpdateTerms(newTerms); 40115 }; 40116 const onChangeFormName = (value) => { 40117 setFormName(value); 40118 }; 40119 const onChangeFormParent = (parentId) => { 40120 setFormParent(parentId); 40121 }; 40122 const onToggleForm = () => { 40123 setShowForm(!showForm); 40124 }; 40125 const onAddTerm = async (event) => { 40126 event.preventDefault(); 40127 if (formName === "" || adding) { 40128 return; 40129 } 40130 const existingTerm = findTerm(availableTerms, formParent, formName); 40131 if (existingTerm) { 40132 if (!terms.some((term) => term === existingTerm.id)) { 40133 onUpdateTerms([...terms, existingTerm.id]); 40134 } 40135 setFormName(""); 40136 setFormParent(""); 40137 return; 40138 } 40139 setAdding(true); 40140 let newTerm; 40141 try { 40142 newTerm = await addTerm({ 40143 name: formName, 40144 parent: formParent ? formParent : void 0 40145 }); 40146 } catch (error) { 40147 createErrorNotice(error.message, { 40148 type: "snackbar" 40149 }); 40150 return; 40151 } 40152 const defaultName = slug === "category" ? (0, import_i18n158.__)("Category") : (0, import_i18n158.__)("Term"); 40153 const termAddedMessage = (0, import_i18n158.sprintf)( 40154 /* translators: %s: term name. */ 40155 (0, import_i18n158._x)("%s added", "term"), 40156 taxonomy?.labels?.singular_name ?? defaultName 40157 ); 40158 (0, import_a11y5.speak)(termAddedMessage, "assertive"); 40159 setAdding(false); 40160 setFormName(""); 40161 setFormParent(""); 40162 onUpdateTerms([...terms, newTerm.id]); 40163 }; 40164 const setFilter = (value) => { 40165 const newFilteredTermsTree = availableTermsTree.map(getFilterMatcher(value)).filter((term) => term); 40166 const getResultCount = (termsTree) => { 40167 let count = 0; 40168 for (let i3 = 0; i3 < termsTree.length; i3++) { 40169 count++; 40170 if (void 0 !== termsTree[i3].children) { 40171 count += getResultCount(termsTree[i3].children); 40172 } 40173 } 40174 return count; 40175 }; 40176 setFilterValue(value); 40177 setFilteredTermsTree(newFilteredTermsTree); 40178 const resultCount = getResultCount(newFilteredTermsTree); 40179 const resultsFoundMessage = (0, import_i18n158.sprintf)( 40180 /* translators: %d: number of results. */ 40181 (0, import_i18n158._n)("%d result found.", "%d results found.", resultCount), 40182 resultCount 40183 ); 40184 debouncedSpeak(resultsFoundMessage, "assertive"); 40185 }; 40186 const renderTerms = (renderedTerms) => { 40187 return renderedTerms.map((term) => { 40188 return /* @__PURE__ */ (0, import_jsx_runtime262.jsxs)( 40189 "div", 40190 { 40191 className: "editor-post-taxonomies__hierarchical-terms-choice", 40192 children: [ 40193 /* @__PURE__ */ (0, import_jsx_runtime262.jsx)( 40194 import_components149.CheckboxControl, 40195 { 40196 checked: terms.indexOf(term.id) !== -1, 40197 onChange: () => { 40198 const termId = parseInt(term.id, 10); 40199 onChange(termId); 40200 }, 40201 label: (0, import_html_entities21.decodeEntities)(term.name) 40202 } 40203 ), 40204 !!term.children.length && /* @__PURE__ */ (0, import_jsx_runtime262.jsx)("div", { className: "editor-post-taxonomies__hierarchical-terms-subchoices", children: renderTerms(term.children) }) 40205 ] 40206 }, 40207 term.id 40208 ); 40209 }); 40210 }; 40211 const labelWithFallback = (labelProperty, fallbackIsCategory, fallbackIsNotCategory) => taxonomy?.labels?.[labelProperty] ?? (slug === "category" ? fallbackIsCategory : fallbackIsNotCategory); 40212 const newTermButtonLabel = labelWithFallback( 40213 "add_new_item", 40214 (0, import_i18n158.__)("Add Category"), 40215 (0, import_i18n158.__)("Add Term") 40216 ); 40217 const newTermLabel = labelWithFallback( 40218 "new_item_name", 40219 (0, import_i18n158.__)("Add Category"), 40220 (0, import_i18n158.__)("Add Term") 40221 ); 40222 const parentSelectLabel = labelWithFallback( 40223 "parent_item", 40224 (0, import_i18n158.__)("Parent Category"), 40225 (0, import_i18n158.__)("Parent Term") 40226 ); 40227 const noParentOption = `\u2014 $parentSelectLabel} \u2014`; 40228 const newTermSubmitLabel = newTermButtonLabel; 40229 const filterLabel = taxonomy?.labels?.search_items ?? (0, import_i18n158.__)("Search Terms"); 40230 const groupLabel = taxonomy?.name ?? (0, import_i18n158.__)("Terms"); 40231 const showFilter = availableTerms.length >= MIN_TERMS_COUNT_FOR_FILTER; 40232 return /* @__PURE__ */ (0, import_jsx_runtime262.jsxs)(import_components149.Flex, { direction: "column", gap: "4", children: [ 40233 showFilter && !loading && /* @__PURE__ */ (0, import_jsx_runtime262.jsx)( 40234 import_components149.SearchControl, 40235 { 40236 __next40pxDefaultSize: true, 40237 label: filterLabel, 40238 placeholder: filterLabel, 40239 value: filterValue, 40240 onChange: setFilter 40241 } 40242 ), 40243 loading && /* @__PURE__ */ (0, import_jsx_runtime262.jsx)( 40244 import_components149.Flex, 40245 { 40246 justify: "center", 40247 style: { 40248 // Match SearchControl height to prevent layout shift. 40249 height: "40px" 40250 }, 40251 children: /* @__PURE__ */ (0, import_jsx_runtime262.jsx)(import_components149.Spinner, {}) 40252 } 40253 ), 40254 /* @__PURE__ */ (0, import_jsx_runtime262.jsx)( 40255 "div", 40256 { 40257 className: "editor-post-taxonomies__hierarchical-terms-list", 40258 tabIndex: "0", 40259 role: "group", 40260 "aria-label": groupLabel, 40261 children: renderTerms( 40262 "" !== filterValue ? filteredTermsTree : availableTermsTree 40263 ) 40264 } 40265 ), 40266 !loading && hasCreateAction && /* @__PURE__ */ (0, import_jsx_runtime262.jsx)(import_components149.FlexItem, { children: /* @__PURE__ */ (0, import_jsx_runtime262.jsx)( 40267 import_components149.Button, 40268 { 40269 __next40pxDefaultSize: true, 40270 onClick: onToggleForm, 40271 className: "editor-post-taxonomies__hierarchical-terms-add", 40272 "aria-expanded": showForm, 40273 variant: "link", 40274 children: newTermButtonLabel 40275 } 40276 ) }), 40277 showForm && /* @__PURE__ */ (0, import_jsx_runtime262.jsx)("form", { onSubmit: onAddTerm, children: /* @__PURE__ */ (0, import_jsx_runtime262.jsxs)(import_components149.Flex, { direction: "column", gap: "4", children: [ 40278 /* @__PURE__ */ (0, import_jsx_runtime262.jsx)( 40279 import_components149.TextControl, 40280 { 40281 __next40pxDefaultSize: true, 40282 className: "editor-post-taxonomies__hierarchical-terms-input", 40283 label: newTermLabel, 40284 value: formName, 40285 onChange: onChangeFormName, 40286 required: true 40287 } 40288 ), 40289 !!availableTerms.length && /* @__PURE__ */ (0, import_jsx_runtime262.jsx)( 40290 import_components149.TreeSelect, 40291 { 40292 __next40pxDefaultSize: true, 40293 label: parentSelectLabel, 40294 noOptionLabel: noParentOption, 40295 onChange: onChangeFormParent, 40296 selectedId: formParent, 40297 tree: availableTermsTree 40298 } 40299 ), 40300 /* @__PURE__ */ (0, import_jsx_runtime262.jsx)(import_components149.FlexItem, { children: /* @__PURE__ */ (0, import_jsx_runtime262.jsx)( 40301 import_components149.Button, 40302 { 40303 __next40pxDefaultSize: true, 40304 variant: "secondary", 40305 type: "submit", 40306 className: "editor-post-taxonomies__hierarchical-terms-submit", 40307 children: newTermSubmitLabel 40308 } 40309 ) }) 40310 ] }) }) 40311 ] }); 40312 } 40313 var hierarchical_term_selector_default = (0, import_components149.withFilters)("editor.PostTaxonomyType")( 40314 HierarchicalTermSelector 40315 ); 40316 40317 // packages/editor/build-module/components/post-publish-panel/maybe-category-panel.js 40318 var import_jsx_runtime263 = __toESM(require_jsx_runtime()); 40319 function MaybeCategoryPanel() { 40320 const { hasNoCategory, hasSiteCategories } = (0, import_data140.useSelect)((select5) => { 40321 const postType2 = select5(store).getCurrentPostType(); 40322 const { canUser, getEntityRecord } = select5(import_core_data87.store); 40323 const categoriesTaxonomy = getEntityRecord( 40324 "root", 40325 "taxonomy", 40326 "category" 40327 ); 40328 const defaultCategoryId = canUser("read", { 40329 kind: "root", 40330 name: "site" 40331 }) ? getEntityRecord("root", "site")?.default_category : void 0; 40332 const defaultCategory = defaultCategoryId ? getEntityRecord("taxonomy", "category", defaultCategoryId) : void 0; 40333 const postTypeSupportsCategories = categoriesTaxonomy && categoriesTaxonomy.types.some((type) => type === postType2); 40334 const categories = categoriesTaxonomy && select5(store).getEditedPostAttribute( 40335 categoriesTaxonomy.rest_base 40336 ); 40337 const siteCategories = postTypeSupportsCategories ? !!select5(import_core_data87.store).getEntityRecords("taxonomy", "category", { 40338 exclude: [defaultCategoryId], 40339 per_page: 1 40340 })?.length : false; 40341 const noCategory = !!categoriesTaxonomy && !!defaultCategory && postTypeSupportsCategories && (categories?.length === 0 || categories?.length === 1 && defaultCategory?.id === categories[0]); 40342 return { 40343 hasNoCategory: noCategory, 40344 hasSiteCategories: siteCategories 40345 }; 40346 }, []); 40347 const [shouldShowPanel, setShouldShowPanel] = (0, import_element115.useState)(false); 40348 (0, import_element115.useEffect)(() => { 40349 if (hasNoCategory) { 40350 setShouldShowPanel(true); 40351 } 40352 }, [hasNoCategory]); 40353 if (!shouldShowPanel || !hasSiteCategories) { 40354 return null; 40355 } 40356 const panelBodyTitle = [ 40357 (0, import_i18n159.__)("Suggestion:"), 40358 /* @__PURE__ */ (0, import_jsx_runtime263.jsx)("span", { className: "editor-post-publish-panel__link", children: (0, import_i18n159.__)("Assign a category") }, "label") 40359 ]; 40360 return /* @__PURE__ */ (0, import_jsx_runtime263.jsxs)(import_components150.PanelBody, { initialOpen: false, title: panelBodyTitle, children: [ 40361 /* @__PURE__ */ (0, import_jsx_runtime263.jsx)("p", { children: (0, import_i18n159.__)( 40362 "Categories provide a helpful way to group related posts together and to quickly tell readers what a post is about." 40363 ) }), 40364 /* @__PURE__ */ (0, import_jsx_runtime263.jsx)(hierarchical_term_selector_default, { slug: "category" }) 40365 ] }); 40366 } 40367 var maybe_category_panel_default = MaybeCategoryPanel; 40368 40369 // packages/editor/build-module/components/post-publish-panel/maybe-upload-media.js 40370 var import_components151 = __toESM(require_components()); 40371 var import_data141 = __toESM(require_data()); 40372 var import_i18n160 = __toESM(require_i18n()); 40373 var import_block_editor56 = __toESM(require_block_editor()); 40374 var import_element116 = __toESM(require_element()); 40375 var import_blob3 = __toESM(require_blob()); 40376 40377 // packages/editor/build-module/components/post-publish-panel/media-util.js 40378 var import_url13 = __toESM(require_url()); 40379 function generateUniqueBasenames(urls) { 40380 const basenames = /* @__PURE__ */ new Set(); 40381 return Object.fromEntries( 40382 urls.map((url) => { 40383 const filename = (0, import_url13.getFilename)(url); 40384 let basename = ""; 40385 if (filename) { 40386 const parts = filename.split("."); 40387 if (parts.length > 1) { 40388 parts.pop(); 40389 } 40390 basename = parts.join("."); 40391 } 40392 if (!basename) { 40393 basename = v4_default(); 40394 } 40395 if (basenames.has(basename)) { 40396 basename = `$basename}-$v4_default()}`; 40397 } 40398 basenames.add(basename); 40399 return [url, basename]; 40400 }) 40401 ); 40402 } 40403 function fetchMedia(urls) { 40404 return Object.fromEntries( 40405 Object.entries(generateUniqueBasenames(urls)).map( 40406 ([url, basename]) => { 40407 const filePromise = window.fetch(url.includes("?") ? url : url + "?").then((response) => response.blob()).then((blob) => { 40408 return new File([blob], `$basename}.png`, { 40409 type: blob.type 40410 }); 40411 }); 40412 return [url, filePromise]; 40413 } 40414 ) 40415 ); 40416 } 40417 40418 // packages/editor/build-module/components/post-publish-panel/maybe-upload-media.js 40419 var import_jsx_runtime264 = __toESM(require_jsx_runtime()); 40420 function flattenBlocks(blocks) { 40421 const result = []; 40422 blocks.forEach((block) => { 40423 result.push(block); 40424 result.push(...flattenBlocks(block.innerBlocks)); 40425 }); 40426 return result; 40427 } 40428 function hasExternalMedia(block) { 40429 if (block.name === "core/image" || block.name === "core/cover") { 40430 return block.attributes.url && !block.attributes.id; 40431 } 40432 if (block.name === "core/media-text") { 40433 return block.attributes.mediaUrl && !block.attributes.mediaId; 40434 } 40435 return void 0; 40436 } 40437 function getMediaInfo(block) { 40438 if (block.name === "core/image" || block.name === "core/cover") { 40439 const { url, alt, id } = block.attributes; 40440 return { url, alt, id }; 40441 } 40442 if (block.name === "core/media-text") { 40443 const { mediaUrl: url, mediaAlt: alt, mediaId: id } = block.attributes; 40444 return { url, alt, id }; 40445 } 40446 return {}; 40447 } 40448 function Image({ clientId, alt, url }) { 40449 const { selectBlock: selectBlock2 } = (0, import_data141.useDispatch)(import_block_editor56.store); 40450 return /* @__PURE__ */ (0, import_jsx_runtime264.jsx)( 40451 import_components151.__unstableMotion.img, 40452 { 40453 tabIndex: 0, 40454 role: "button", 40455 "aria-label": (0, import_i18n160.__)("Select image block."), 40456 onClick: () => { 40457 selectBlock2(clientId); 40458 }, 40459 onKeyDown: (event) => { 40460 if (event.key === "Enter" || event.key === " ") { 40461 selectBlock2(clientId); 40462 event.preventDefault(); 40463 } 40464 }, 40465 alt, 40466 src: url, 40467 animate: { opacity: 1 }, 40468 exit: { opacity: 0, scale: 0 }, 40469 style: { 40470 width: "32px", 40471 height: "32px", 40472 objectFit: "cover", 40473 borderRadius: "2px", 40474 cursor: "pointer" 40475 }, 40476 whileHover: { scale: 1.08 } 40477 }, 40478 clientId 40479 ); 40480 } 40481 function MaybeUploadMediaPanel() { 40482 const [isUploading, setIsUploading] = (0, import_element116.useState)(false); 40483 const [isAnimating, setIsAnimating] = (0, import_element116.useState)(false); 40484 const [hadUploadError, setHadUploadError] = (0, import_element116.useState)(false); 40485 const { editorBlocks, mediaUpload: mediaUpload2 } = (0, import_data141.useSelect)( 40486 (select5) => ({ 40487 editorBlocks: select5(import_block_editor56.store).getBlocks(), 40488 mediaUpload: select5(import_block_editor56.store).getSettings().mediaUpload 40489 }), 40490 [] 40491 ); 40492 const blocksWithExternalMedia = flattenBlocks(editorBlocks).filter( 40493 (block) => hasExternalMedia(block) 40494 ); 40495 const { updateBlockAttributes: updateBlockAttributes2 } = (0, import_data141.useDispatch)(import_block_editor56.store); 40496 if (!mediaUpload2 || !blocksWithExternalMedia.length) { 40497 return null; 40498 } 40499 const panelBodyTitle = [ 40500 (0, import_i18n160.__)("Suggestion:"), 40501 /* @__PURE__ */ (0, import_jsx_runtime264.jsx)("span", { className: "editor-post-publish-panel__link", children: (0, import_i18n160.__)("External media") }, "label") 40502 ]; 40503 function updateBlockWithUploadedMedia(block, media) { 40504 if (block.name === "core/image" || block.name === "core/cover") { 40505 updateBlockAttributes2(block.clientId, { 40506 id: media.id, 40507 url: media.url 40508 }); 40509 } 40510 if (block.name === "core/media-text") { 40511 updateBlockAttributes2(block.clientId, { 40512 mediaId: media.id, 40513 mediaUrl: media.url 40514 }); 40515 } 40516 } 40517 function uploadImages() { 40518 setIsUploading(true); 40519 setHadUploadError(false); 40520 const mediaUrls = new Set( 40521 blocksWithExternalMedia.map((block) => { 40522 const { url } = getMediaInfo(block); 40523 return url; 40524 }) 40525 ); 40526 const uploadPromises = Object.fromEntries( 40527 Object.entries(fetchMedia([...mediaUrls])).map( 40528 ([url, filePromise]) => { 40529 const uploadPromise = filePromise.then( 40530 (blob) => new Promise((resolve, reject) => { 40531 mediaUpload2({ 40532 filesList: [blob], 40533 onFileChange: ([media]) => { 40534 if ((0, import_blob3.isBlobURL)(media.url)) { 40535 return; 40536 } 40537 resolve(media); 40538 }, 40539 onError() { 40540 reject(); 40541 } 40542 }); 40543 }) 40544 ); 40545 return [url, uploadPromise]; 40546 } 40547 ) 40548 ); 40549 Promise.allSettled( 40550 blocksWithExternalMedia.map((block) => { 40551 const { url } = getMediaInfo(block); 40552 return uploadPromises[url].then( 40553 (media) => updateBlockWithUploadedMedia(block, media) 40554 ).then(() => setIsAnimating(true)).catch(() => setHadUploadError(true)); 40555 }) 40556 ).finally(() => { 40557 setIsUploading(false); 40558 }); 40559 } 40560 return /* @__PURE__ */ (0, import_jsx_runtime264.jsxs)(import_components151.PanelBody, { initialOpen: true, title: panelBodyTitle, children: [ 40561 /* @__PURE__ */ (0, import_jsx_runtime264.jsx)("p", { children: (0, import_i18n160.__)( 40562 "Upload external images to the Media Library. Images from different domains may load slowly, display incorrectly, or be removed unexpectedly." 40563 ) }), 40564 /* @__PURE__ */ (0, import_jsx_runtime264.jsxs)( 40565 "div", 40566 { 40567 style: { 40568 display: "inline-flex", 40569 flexWrap: "wrap", 40570 gap: "8px" 40571 }, 40572 children: [ 40573 /* @__PURE__ */ (0, import_jsx_runtime264.jsx)( 40574 import_components151.__unstableAnimatePresence, 40575 { 40576 onExitComplete: () => setIsAnimating(false), 40577 children: blocksWithExternalMedia.map((block) => { 40578 const { url, alt } = getMediaInfo(block); 40579 return /* @__PURE__ */ (0, import_jsx_runtime264.jsx)( 40580 Image, 40581 { 40582 clientId: block.clientId, 40583 url, 40584 alt 40585 }, 40586 block.clientId 40587 ); 40588 }) 40589 } 40590 ), 40591 isUploading || isAnimating ? /* @__PURE__ */ (0, import_jsx_runtime264.jsx)(import_components151.Spinner, {}) : /* @__PURE__ */ (0, import_jsx_runtime264.jsx)( 40592 import_components151.Button, 40593 { 40594 size: "compact", 40595 variant: "primary", 40596 onClick: uploadImages, 40597 children: (0, import_i18n160._x)("Upload", "verb") 40598 } 40599 ) 40600 ] 40601 } 40602 ), 40603 hadUploadError && /* @__PURE__ */ (0, import_jsx_runtime264.jsx)("p", { children: (0, import_i18n160.__)("Upload failed, try again.") }) 40604 ] }); 40605 } 40606 40607 // packages/editor/build-module/components/post-publish-panel/prepublish.js 40608 var import_jsx_runtime265 = __toESM(require_jsx_runtime()); 40609 function PostPublishPanelPrepublish({ children }) { 40610 const { 40611 isBeingScheduled, 40612 isRequestingSiteIcon, 40613 hasPublishAction, 40614 siteIconUrl, 40615 siteTitle, 40616 siteHome 40617 } = (0, import_data142.useSelect)((select5) => { 40618 const { getCurrentPost: getCurrentPost2, isEditedPostBeingScheduled: isEditedPostBeingScheduled2 } = select5(store); 40619 const { getEntityRecord, isResolving } = select5(import_core_data88.store); 40620 const siteData = getEntityRecord("root", "__unstableBase", void 0) || {}; 40621 return { 40622 hasPublishAction: getCurrentPost2()._links?.["wp:action-publish"] ?? false, 40623 isBeingScheduled: isEditedPostBeingScheduled2(), 40624 isRequestingSiteIcon: isResolving("getEntityRecord", [ 40625 "root", 40626 "__unstableBase", 40627 void 0 40628 ]), 40629 siteIconUrl: siteData.site_icon_url, 40630 siteTitle: siteData.name, 40631 siteHome: siteData.home && (0, import_url14.filterURLForDisplay)(siteData.home) 40632 }; 40633 }, []); 40634 let siteIcon = /* @__PURE__ */ (0, import_jsx_runtime265.jsx)(import_components152.Icon, { className: "components-site-icon", size: "36px", icon: wordpress_default }); 40635 if (siteIconUrl) { 40636 siteIcon = /* @__PURE__ */ (0, import_jsx_runtime265.jsx)( 40637 "img", 40638 { 40639 alt: (0, import_i18n161.__)("Site Icon"), 40640 className: "components-site-icon", 40641 src: siteIconUrl 40642 } 40643 ); 40644 } 40645 if (isRequestingSiteIcon) { 40646 siteIcon = null; 40647 } 40648 let prePublishTitle, prePublishBodyText; 40649 if (!hasPublishAction) { 40650 prePublishTitle = (0, import_i18n161.__)("Are you ready to submit for review?"); 40651 prePublishBodyText = (0, import_i18n161.__)( 40652 "Your work will be reviewed and then approved." 40653 ); 40654 } else if (isBeingScheduled) { 40655 prePublishTitle = (0, import_i18n161.__)("Are you ready to schedule?"); 40656 prePublishBodyText = (0, import_i18n161.__)( 40657 "Your work will be published at the specified date and time." 40658 ); 40659 } else { 40660 prePublishTitle = (0, import_i18n161.__)("Are you ready to publish?"); 40661 prePublishBodyText = (0, import_i18n161.__)( 40662 "Double-check your settings before publishing." 40663 ); 40664 } 40665 return /* @__PURE__ */ (0, import_jsx_runtime265.jsxs)("div", { className: "editor-post-publish-panel__prepublish", children: [ 40666 /* @__PURE__ */ (0, import_jsx_runtime265.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime265.jsx)("strong", { children: prePublishTitle }) }), 40667 /* @__PURE__ */ (0, import_jsx_runtime265.jsx)("p", { children: prePublishBodyText }), 40668 /* @__PURE__ */ (0, import_jsx_runtime265.jsxs)("div", { className: "components-site-card", children: [ 40669 siteIcon, 40670 /* @__PURE__ */ (0, import_jsx_runtime265.jsxs)("div", { className: "components-site-info", children: [ 40671 /* @__PURE__ */ (0, import_jsx_runtime265.jsx)("span", { className: "components-site-name", children: (0, import_html_entities22.decodeEntities)(siteTitle) || (0, import_i18n161.__)("(Untitled)") }), 40672 /* @__PURE__ */ (0, import_jsx_runtime265.jsx)("span", { className: "components-site-home", children: siteHome }) 40673 ] }) 40674 ] }), 40675 /* @__PURE__ */ (0, import_jsx_runtime265.jsx)(MaybeUploadMediaPanel, {}), 40676 hasPublishAction && /* @__PURE__ */ (0, import_jsx_runtime265.jsxs)(import_jsx_runtime265.Fragment, { children: [ 40677 /* @__PURE__ */ (0, import_jsx_runtime265.jsx)( 40678 import_components152.PanelBody, 40679 { 40680 initialOpen: false, 40681 title: [ 40682 (0, import_i18n161.__)("Visibility:"), 40683 /* @__PURE__ */ (0, import_jsx_runtime265.jsx)( 40684 "span", 40685 { 40686 className: "editor-post-publish-panel__link", 40687 children: /* @__PURE__ */ (0, import_jsx_runtime265.jsx)(PostVisibilityLabel, {}) 40688 }, 40689 "label" 40690 ) 40691 ], 40692 children: /* @__PURE__ */ (0, import_jsx_runtime265.jsx)(PostVisibility, {}) 40693 } 40694 ), 40695 /* @__PURE__ */ (0, import_jsx_runtime265.jsx)( 40696 import_components152.PanelBody, 40697 { 40698 initialOpen: false, 40699 title: [ 40700 (0, import_i18n161.__)("Publish:"), 40701 /* @__PURE__ */ (0, import_jsx_runtime265.jsx)( 40702 "span", 40703 { 40704 className: "editor-post-publish-panel__link", 40705 children: /* @__PURE__ */ (0, import_jsx_runtime265.jsx)(PostScheduleLabel, {}) 40706 }, 40707 "label" 40708 ) 40709 ], 40710 children: /* @__PURE__ */ (0, import_jsx_runtime265.jsx)(PostSchedule, {}) 40711 } 40712 ) 40713 ] }), 40714 /* @__PURE__ */ (0, import_jsx_runtime265.jsx)(PostFormatPanel, {}), 40715 /* @__PURE__ */ (0, import_jsx_runtime265.jsx)(maybe_tags_panel_default, {}), 40716 /* @__PURE__ */ (0, import_jsx_runtime265.jsx)(maybe_category_panel_default, {}), 40717 children 40718 ] }); 40719 } 40720 var prepublish_default = PostPublishPanelPrepublish; 40721 40722 // packages/editor/build-module/components/post-publish-panel/postpublish.js 40723 var import_components153 = __toESM(require_components()); 40724 var import_i18n162 = __toESM(require_i18n()); 40725 var import_element117 = __toESM(require_element()); 40726 var import_data143 = __toESM(require_data()); 40727 var import_url15 = __toESM(require_url()); 40728 var import_html_entities23 = __toESM(require_html_entities()); 40729 var import_compose34 = __toESM(require_compose()); 40730 var import_core_data89 = __toESM(require_core_data()); 40731 var import_jsx_runtime266 = __toESM(require_jsx_runtime()); 40732 var POSTNAME = "%postname%"; 40733 var PAGENAME = "%pagename%"; 40734 var getFuturePostUrl = (post2) => { 40735 const { slug } = post2; 40736 if (post2.permalink_template.includes(POSTNAME)) { 40737 return post2.permalink_template.replace(POSTNAME, slug); 40738 } 40739 if (post2.permalink_template.includes(PAGENAME)) { 40740 return post2.permalink_template.replace(PAGENAME, slug); 40741 } 40742 return post2.permalink_template; 40743 }; 40744 function CopyButton2({ text }) { 40745 const [showCopyConfirmation, setShowCopyConfirmation] = (0, import_element117.useState)(false); 40746 const timeoutIdRef = (0, import_element117.useRef)(); 40747 const ref = (0, import_compose34.useCopyToClipboard)(text, () => { 40748 setShowCopyConfirmation(true); 40749 if (timeoutIdRef.current) { 40750 clearTimeout(timeoutIdRef.current); 40751 } 40752 timeoutIdRef.current = setTimeout(() => { 40753 setShowCopyConfirmation(false); 40754 }, 4e3); 40755 }); 40756 (0, import_element117.useEffect)(() => { 40757 return () => { 40758 if (timeoutIdRef.current) { 40759 clearTimeout(timeoutIdRef.current); 40760 } 40761 }; 40762 }, []); 40763 return /* @__PURE__ */ (0, import_jsx_runtime266.jsx)(import_components153.Button, { __next40pxDefaultSize: true, variant: "secondary", ref, children: showCopyConfirmation ? (0, import_i18n162.__)("Copied!") : (0, import_i18n162.__)("Copy") }); 40764 } 40765 function PostPublishPanelPostpublish({ 40766 focusOnMount, 40767 children 40768 }) { 40769 const { post: post2, postType: postType2, isScheduled } = (0, import_data143.useSelect)((select5) => { 40770 const { 40771 getEditedPostAttribute: getEditedPostAttribute2, 40772 getCurrentPost: getCurrentPost2, 40773 isCurrentPostScheduled: isCurrentPostScheduled2 40774 } = select5(store); 40775 const { getPostType } = select5(import_core_data89.store); 40776 return { 40777 post: getCurrentPost2(), 40778 postType: getPostType(getEditedPostAttribute2("type")), 40779 isScheduled: isCurrentPostScheduled2() 40780 }; 40781 }, []); 40782 const postLabel = postType2?.labels?.singular_name; 40783 const viewPostLabel = postType2?.labels?.view_item; 40784 const addNewPostLabel = postType2?.labels?.add_new_item; 40785 const link = post2.status === "future" ? getFuturePostUrl(post2) : post2.link; 40786 const addLink = (0, import_url15.addQueryArgs)("post-new.php", { 40787 post_type: post2.type 40788 }); 40789 const postLinkRef = (0, import_element117.useCallback)( 40790 (node) => { 40791 if (focusOnMount && node) { 40792 node.focus(); 40793 } 40794 }, 40795 [focusOnMount] 40796 ); 40797 const postPublishNonLinkHeader = isScheduled ? /* @__PURE__ */ (0, import_jsx_runtime266.jsxs)(import_jsx_runtime266.Fragment, { children: [ 40798 (0, import_i18n162.__)("is now scheduled. It will go live on"), 40799 " ", 40800 /* @__PURE__ */ (0, import_jsx_runtime266.jsx)(PostScheduleLabel, {}), 40801 "." 40802 ] }) : (0, import_i18n162.__)("is now live."); 40803 return /* @__PURE__ */ (0, import_jsx_runtime266.jsxs)("div", { className: "post-publish-panel__postpublish", children: [ 40804 /* @__PURE__ */ (0, import_jsx_runtime266.jsxs)(import_components153.PanelBody, { className: "post-publish-panel__postpublish-header", children: [ 40805 /* @__PURE__ */ (0, import_jsx_runtime266.jsx)(import_components153.ExternalLink, { ref: postLinkRef, href: link, children: (0, import_html_entities23.decodeEntities)(post2.title) || (0, import_i18n162.__)("(no title)") }), 40806 " ", 40807 postPublishNonLinkHeader 40808 ] }), 40809 /* @__PURE__ */ (0, import_jsx_runtime266.jsxs)(import_components153.PanelBody, { children: [ 40810 /* @__PURE__ */ (0, import_jsx_runtime266.jsx)("p", { className: "post-publish-panel__postpublish-subheader", children: /* @__PURE__ */ (0, import_jsx_runtime266.jsx)("strong", { children: (0, import_i18n162.__)("What\u2019s next?") }) }), 40811 /* @__PURE__ */ (0, import_jsx_runtime266.jsxs)("div", { className: "post-publish-panel__postpublish-post-address-container", children: [ 40812 /* @__PURE__ */ (0, import_jsx_runtime266.jsx)( 40813 import_components153.TextControl, 40814 { 40815 __next40pxDefaultSize: true, 40816 className: "post-publish-panel__postpublish-post-address", 40817 readOnly: true, 40818 label: (0, import_i18n162.sprintf)( 40819 /* translators: %s: post type singular name */ 40820 (0, import_i18n162.__)("%s address"), 40821 postLabel 40822 ), 40823 value: (0, import_url15.safeDecodeURIComponent)(link), 40824 onFocus: (event) => event.target.select() 40825 } 40826 ), 40827 /* @__PURE__ */ (0, import_jsx_runtime266.jsx)("div", { className: "post-publish-panel__postpublish-post-address__copy-button-wrap", children: /* @__PURE__ */ (0, import_jsx_runtime266.jsx)(CopyButton2, { text: link }) }) 40828 ] }), 40829 /* @__PURE__ */ (0, import_jsx_runtime266.jsxs)("div", { className: "post-publish-panel__postpublish-buttons", children: [ 40830 !isScheduled && /* @__PURE__ */ (0, import_jsx_runtime266.jsxs)( 40831 import_components153.Button, 40832 { 40833 variant: "primary", 40834 href: link, 40835 __next40pxDefaultSize: true, 40836 icon: external_default, 40837 iconPosition: "right", 40838 target: "_blank", 40839 children: [ 40840 viewPostLabel, 40841 /* @__PURE__ */ (0, import_jsx_runtime266.jsx)(import_components153.VisuallyHidden, { 40842 as: "span", 40843 /* translators: accessibility text */ 40844 children: (0, import_i18n162.__)("(opens in a new tab)") 40845 }) 40846 ] 40847 } 40848 ), 40849 /* @__PURE__ */ (0, import_jsx_runtime266.jsx)( 40850 import_components153.Button, 40851 { 40852 variant: isScheduled ? "primary" : "secondary", 40853 __next40pxDefaultSize: true, 40854 href: addLink, 40855 children: addNewPostLabel 40856 } 40857 ) 40858 ] }) 40859 ] }), 40860 children 40861 ] }); 40862 } 40863 40864 // packages/editor/build-module/components/post-publish-panel/index.js 40865 var import_jsx_runtime267 = __toESM(require_jsx_runtime()); 40866 var PostPublishPanel = class extends import_element118.Component { 40867 constructor() { 40868 super(...arguments); 40869 this.onSubmit = this.onSubmit.bind(this); 40870 this.cancelButtonNode = (0, import_element118.createRef)(); 40871 } 40872 componentDidMount() { 40873 this.timeoutID = setTimeout(() => { 40874 this.cancelButtonNode.current.focus(); 40875 }, 0); 40876 } 40877 componentWillUnmount() { 40878 clearTimeout(this.timeoutID); 40879 } 40880 componentDidUpdate(prevProps) { 40881 if (prevProps.isPublished && !this.props.isSaving && this.props.isDirty || this.props.currentPostId !== prevProps.currentPostId) { 40882 this.props.onClose(); 40883 } 40884 } 40885 onSubmit() { 40886 const { onClose, hasPublishAction, isPostTypeViewable } = this.props; 40887 if (!hasPublishAction || !isPostTypeViewable) { 40888 onClose(); 40889 } 40890 } 40891 render() { 40892 const { 40893 forceIsDirty, 40894 isBeingScheduled, 40895 isPublished, 40896 isPublishSidebarEnabled: isPublishSidebarEnabled2, 40897 isScheduled, 40898 isSaving, 40899 isSavingNonPostEntityChanges: isSavingNonPostEntityChanges2, 40900 onClose, 40901 onTogglePublishSidebar, 40902 PostPublishExtension, 40903 PrePublishExtension, 40904 currentPostId, 40905 ...additionalProps 40906 } = this.props; 40907 const { 40908 hasPublishAction, 40909 isDirty, 40910 isPostTypeViewable, 40911 ...propsForPanel 40912 } = additionalProps; 40913 const isPublishedOrScheduled = isPublished || isScheduled && isBeingScheduled; 40914 const isPrePublish = !isPublishedOrScheduled && !isSaving; 40915 const isPostPublish = isPublishedOrScheduled && !isSaving; 40916 return /* @__PURE__ */ (0, import_jsx_runtime267.jsxs)("div", { className: "editor-post-publish-panel", ...propsForPanel, children: [ 40917 /* @__PURE__ */ (0, import_jsx_runtime267.jsx)("div", { className: "editor-post-publish-panel__header", children: isPostPublish ? /* @__PURE__ */ (0, import_jsx_runtime267.jsx)( 40918 import_components154.Button, 40919 { 40920 size: "compact", 40921 onClick: onClose, 40922 icon: close_small_default, 40923 label: (0, import_i18n163.__)("Close panel") 40924 } 40925 ) : /* @__PURE__ */ (0, import_jsx_runtime267.jsxs)(import_jsx_runtime267.Fragment, { children: [ 40926 /* @__PURE__ */ (0, import_jsx_runtime267.jsx)("div", { className: "editor-post-publish-panel__header-cancel-button", children: /* @__PURE__ */ (0, import_jsx_runtime267.jsx)( 40927 import_components154.Button, 40928 { 40929 ref: this.cancelButtonNode, 40930 accessibleWhenDisabled: true, 40931 disabled: isSavingNonPostEntityChanges2, 40932 onClick: onClose, 40933 variant: "secondary", 40934 size: "compact", 40935 children: (0, import_i18n163.__)("Cancel") 40936 } 40937 ) }), 40938 /* @__PURE__ */ (0, import_jsx_runtime267.jsx)("div", { className: "editor-post-publish-panel__header-publish-button", children: /* @__PURE__ */ (0, import_jsx_runtime267.jsx)( 40939 post_publish_button_default, 40940 { 40941 onSubmit: this.onSubmit, 40942 forceIsDirty 40943 } 40944 ) }) 40945 ] }) }), 40946 /* @__PURE__ */ (0, import_jsx_runtime267.jsxs)("div", { className: "editor-post-publish-panel__content", children: [ 40947 isPrePublish && /* @__PURE__ */ (0, import_jsx_runtime267.jsx)(prepublish_default, { children: PrePublishExtension && /* @__PURE__ */ (0, import_jsx_runtime267.jsx)(PrePublishExtension, {}) }), 40948 isPostPublish && /* @__PURE__ */ (0, import_jsx_runtime267.jsx)(PostPublishPanelPostpublish, { focusOnMount: true, children: PostPublishExtension && /* @__PURE__ */ (0, import_jsx_runtime267.jsx)(PostPublishExtension, {}) }), 40949 isSaving && /* @__PURE__ */ (0, import_jsx_runtime267.jsx)(import_components154.Spinner, {}) 40950 ] }), 40951 /* @__PURE__ */ (0, import_jsx_runtime267.jsx)("div", { className: "editor-post-publish-panel__footer", children: /* @__PURE__ */ (0, import_jsx_runtime267.jsx)( 40952 import_components154.CheckboxControl, 40953 { 40954 label: (0, import_i18n163.__)("Always show pre-publish checks."), 40955 checked: isPublishSidebarEnabled2, 40956 onChange: onTogglePublishSidebar 40957 } 40958 ) }) 40959 ] }); 40960 } 40961 }; 40962 var post_publish_panel_default = (0, import_compose35.compose)([ 40963 (0, import_data144.withSelect)((select5) => { 40964 const { getPostType } = select5(import_core_data90.store); 40965 const { 40966 getCurrentPost: getCurrentPost2, 40967 getCurrentPostId: getCurrentPostId2, 40968 getEditedPostAttribute: getEditedPostAttribute2, 40969 isCurrentPostPublished: isCurrentPostPublished2, 40970 isCurrentPostScheduled: isCurrentPostScheduled2, 40971 isEditedPostBeingScheduled: isEditedPostBeingScheduled2, 40972 isEditedPostDirty: isEditedPostDirty2, 40973 isAutosavingPost: isAutosavingPost2, 40974 isSavingPost: isSavingPost2, 40975 isSavingNonPostEntityChanges: isSavingNonPostEntityChanges2 40976 } = select5(store); 40977 const { isPublishSidebarEnabled: isPublishSidebarEnabled2 } = select5(store); 40978 const postType2 = getPostType(getEditedPostAttribute2("type")); 40979 return { 40980 hasPublishAction: getCurrentPost2()._links?.["wp:action-publish"] ?? false, 40981 isPostTypeViewable: postType2?.viewable, 40982 isBeingScheduled: isEditedPostBeingScheduled2(), 40983 isDirty: isEditedPostDirty2(), 40984 isPublished: isCurrentPostPublished2(), 40985 isPublishSidebarEnabled: isPublishSidebarEnabled2(), 40986 isSaving: isSavingPost2() && !isAutosavingPost2(), 40987 isSavingNonPostEntityChanges: isSavingNonPostEntityChanges2(), 40988 isScheduled: isCurrentPostScheduled2(), 40989 currentPostId: getCurrentPostId2() 40990 }; 40991 }), 40992 (0, import_data144.withDispatch)((dispatch6, { isPublishSidebarEnabled: isPublishSidebarEnabled2 }) => { 40993 const { disablePublishSidebar: disablePublishSidebar2, enablePublishSidebar: enablePublishSidebar2 } = dispatch6(store); 40994 return { 40995 onTogglePublishSidebar: () => { 40996 if (isPublishSidebarEnabled2) { 40997 disablePublishSidebar2(); 40998 } else { 40999 enablePublishSidebar2(); 41000 } 41001 } 41002 }; 41003 }), 41004 import_components154.withFocusReturn, 41005 import_components154.withConstrainedTabbing 41006 ])(PostPublishPanel); 41007 41008 // packages/editor/build-module/components/post-saved-state/index.js 41009 var import_components157 = __toESM(require_components()); 41010 var import_compose37 = __toESM(require_compose()); 41011 var import_data148 = __toESM(require_data()); 41012 var import_element120 = __toESM(require_element()); 41013 var import_i18n166 = __toESM(require_i18n()); 41014 var import_keycodes11 = __toESM(require_keycodes()); 41015 var import_preferences14 = __toESM(require_preferences()); 41016 41017 // packages/editor/build-module/components/post-status/index.js 41018 var import_components156 = __toESM(require_components()); 41019 var import_i18n165 = __toESM(require_i18n()); 41020 var import_data147 = __toESM(require_data()); 41021 var import_element119 = __toESM(require_element()); 41022 var import_core_data91 = __toESM(require_core_data()); 41023 var import_block_editor57 = __toESM(require_block_editor()); 41024 var import_compose36 = __toESM(require_compose()); 41025 41026 // packages/editor/build-module/components/post-sticky/index.js 41027 var import_i18n164 = __toESM(require_i18n()); 41028 var import_components155 = __toESM(require_components()); 41029 var import_data146 = __toESM(require_data()); 41030 41031 // packages/editor/build-module/components/post-sticky/check.js 41032 var import_data145 = __toESM(require_data()); 41033 function PostStickyCheck({ children }) { 41034 const { hasStickyAction, postType: postType2 } = (0, import_data145.useSelect)((select5) => { 41035 const post2 = select5(store).getCurrentPost(); 41036 return { 41037 hasStickyAction: post2._links?.["wp:action-sticky"] ?? false, 41038 postType: select5(store).getCurrentPostType() 41039 }; 41040 }, []); 41041 if (postType2 !== "post" || !hasStickyAction) { 41042 return null; 41043 } 41044 return children; 41045 } 41046 41047 // packages/editor/build-module/components/post-sticky/index.js 41048 var import_jsx_runtime268 = __toESM(require_jsx_runtime()); 41049 function PostSticky() { 41050 const postSticky = (0, import_data146.useSelect)((select5) => { 41051 return select5(store).getEditedPostAttribute("sticky") ?? false; 41052 }, []); 41053 const { editPost: editPost2 } = (0, import_data146.useDispatch)(store); 41054 return /* @__PURE__ */ (0, import_jsx_runtime268.jsx)(PostStickyCheck, { children: /* @__PURE__ */ (0, import_jsx_runtime268.jsx)( 41055 import_components155.CheckboxControl, 41056 { 41057 className: "editor-post-sticky__checkbox-control", 41058 label: (0, import_i18n164.__)("Sticky"), 41059 help: (0, import_i18n164.__)("Pin this post to the top of the blog."), 41060 checked: postSticky, 41061 onChange: () => editPost2({ sticky: !postSticky }) 41062 } 41063 ) }); 41064 } 41065 41066 // packages/editor/build-module/components/post-status/index.js 41067 var import_jsx_runtime269 = __toESM(require_jsx_runtime()); 41068 var postStatusesInfo = { 41069 "auto-draft": { label: (0, import_i18n165.__)("Draft"), icon: drafts_default }, 41070 draft: { label: (0, import_i18n165.__)("Draft"), icon: drafts_default }, 41071 pending: { label: (0, import_i18n165.__)("Pending"), icon: pending_default }, 41072 private: { label: (0, import_i18n165.__)("Private"), icon: not_allowed_default }, 41073 future: { label: (0, import_i18n165.__)("Scheduled"), icon: scheduled_default }, 41074 publish: { label: (0, import_i18n165.__)("Published"), icon: published_default } 41075 }; 41076 var STATUS_OPTIONS = [ 41077 { 41078 label: (0, import_i18n165.__)("Draft"), 41079 value: "draft", 41080 description: (0, import_i18n165.__)("Not ready to publish.") 41081 }, 41082 { 41083 label: (0, import_i18n165.__)("Pending"), 41084 value: "pending", 41085 description: (0, import_i18n165.__)("Waiting for review before publishing.") 41086 }, 41087 { 41088 label: (0, import_i18n165.__)("Private"), 41089 value: "private", 41090 description: (0, import_i18n165.__)("Only visible to site admins and editors.") 41091 }, 41092 { 41093 label: (0, import_i18n165.__)("Scheduled"), 41094 value: "future", 41095 description: (0, import_i18n165.__)("Publish automatically on a chosen date.") 41096 }, 41097 { 41098 label: (0, import_i18n165.__)("Published"), 41099 value: "publish", 41100 description: (0, import_i18n165.__)("Visible to everyone.") 41101 } 41102 ]; 41103 function PostStatus() { 41104 const { status, date, password, postId: postId2, postType: postType2, canEdit } = (0, import_data147.useSelect)( 41105 (select5) => { 41106 const { 41107 getEditedPostAttribute: getEditedPostAttribute2, 41108 getCurrentPostId: getCurrentPostId2, 41109 getCurrentPostType: getCurrentPostType2, 41110 getCurrentPost: getCurrentPost2 41111 } = select5(store); 41112 return { 41113 status: getEditedPostAttribute2("status"), 41114 date: getEditedPostAttribute2("date"), 41115 password: getEditedPostAttribute2("password"), 41116 postId: getCurrentPostId2(), 41117 postType: getCurrentPostType2(), 41118 canEdit: getCurrentPost2()._links?.["wp:action-publish"] ?? false 41119 }; 41120 }, 41121 [] 41122 ); 41123 const [showPassword, setShowPassword] = (0, import_element119.useState)(!!password); 41124 const passwordInputId = (0, import_compose36.useInstanceId)( 41125 PostStatus, 41126 "editor-change-status__password-input" 41127 ); 41128 const { editEntityRecord } = (0, import_data147.useDispatch)(import_core_data91.store); 41129 const [popoverAnchor, setPopoverAnchor] = (0, import_element119.useState)(null); 41130 const popoverProps = (0, import_element119.useMemo)( 41131 () => ({ 41132 // Anchor the popover to the middle of the entire row so that it doesn't 41133 // move around when the label changes. 41134 anchor: popoverAnchor, 41135 "aria-label": (0, import_i18n165.__)("Status & visibility"), 41136 headerTitle: (0, import_i18n165.__)("Status & visibility"), 41137 placement: "left-start", 41138 offset: 36, 41139 shift: true 41140 }), 41141 [popoverAnchor] 41142 ); 41143 if (DESIGN_POST_TYPES.includes(postType2)) { 41144 return null; 41145 } 41146 const updatePost2 = ({ 41147 status: newStatus = status, 41148 password: newPassword = password, 41149 date: newDate = date 41150 }) => { 41151 editEntityRecord("postType", postType2, postId2, { 41152 status: newStatus, 41153 date: newDate, 41154 password: newPassword 41155 }); 41156 }; 41157 const handleTogglePassword = (value) => { 41158 setShowPassword(value); 41159 if (!value) { 41160 updatePost2({ password: "" }); 41161 } 41162 }; 41163 const handleStatus = (value) => { 41164 let newDate = date; 41165 let newPassword = password; 41166 if (status === "future" && new Date(date) > /* @__PURE__ */ new Date()) { 41167 newDate = null; 41168 } 41169 if (value === "private" && password) { 41170 newPassword = ""; 41171 } 41172 updatePost2({ 41173 status: value, 41174 date: newDate, 41175 password: newPassword 41176 }); 41177 }; 41178 return /* @__PURE__ */ (0, import_jsx_runtime269.jsx)(post_panel_row_default, { label: (0, import_i18n165.__)("Status"), ref: setPopoverAnchor, children: canEdit ? /* @__PURE__ */ (0, import_jsx_runtime269.jsx)( 41179 import_components156.Dropdown, 41180 { 41181 className: "editor-post-status", 41182 contentClassName: "editor-change-status__content", 41183 popoverProps, 41184 focusOnMount: true, 41185 renderToggle: ({ onToggle, isOpen }) => /* @__PURE__ */ (0, import_jsx_runtime269.jsx)( 41186 import_components156.Button, 41187 { 41188 className: "editor-post-status__toggle", 41189 variant: "tertiary", 41190 size: "compact", 41191 onClick: onToggle, 41192 icon: postStatusesInfo[status]?.icon, 41193 "aria-label": (0, import_i18n165.sprintf)( 41194 // translators: %s: Current post status. 41195 (0, import_i18n165.__)("Change status: %s"), 41196 postStatusesInfo[status]?.label 41197 ), 41198 "aria-expanded": isOpen, 41199 children: postStatusesInfo[status]?.label 41200 } 41201 ), 41202 renderContent: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime269.jsxs)(import_jsx_runtime269.Fragment, { children: [ 41203 /* @__PURE__ */ (0, import_jsx_runtime269.jsx)( 41204 import_block_editor57.__experimentalInspectorPopoverHeader, 41205 { 41206 title: (0, import_i18n165.__)("Status & visibility"), 41207 onClose 41208 } 41209 ), 41210 /* @__PURE__ */ (0, import_jsx_runtime269.jsx)( 41211 "form", 41212 { 41213 onSubmit: (event) => { 41214 event.preventDefault(); 41215 onClose(); 41216 }, 41217 children: /* @__PURE__ */ (0, import_jsx_runtime269.jsxs)(import_components156.__experimentalVStack, { spacing: 4, children: [ 41218 /* @__PURE__ */ (0, import_jsx_runtime269.jsx)( 41219 import_components156.RadioControl, 41220 { 41221 className: "editor-change-status__options", 41222 hideLabelFromVision: true, 41223 label: (0, import_i18n165.__)("Status"), 41224 options: STATUS_OPTIONS, 41225 onChange: handleStatus, 41226 selected: status === "auto-draft" ? "draft" : status 41227 } 41228 ), 41229 status === "future" && /* @__PURE__ */ (0, import_jsx_runtime269.jsx)("div", { className: "editor-change-status__publish-date-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime269.jsx)( 41230 PrivatePostSchedule, 41231 { 41232 showPopoverHeaderActions: false, 41233 isCompact: true 41234 } 41235 ) }), 41236 status !== "private" && /* @__PURE__ */ (0, import_jsx_runtime269.jsxs)( 41237 import_components156.__experimentalVStack, 41238 { 41239 as: "fieldset", 41240 spacing: 4, 41241 className: "editor-change-status__password-fieldset", 41242 children: [ 41243 /* @__PURE__ */ (0, import_jsx_runtime269.jsx)( 41244 import_components156.CheckboxControl, 41245 { 41246 label: (0, import_i18n165.__)( 41247 "Password protected" 41248 ), 41249 help: (0, import_i18n165.__)( 41250 "Only visible to those who know the password." 41251 ), 41252 checked: showPassword, 41253 onChange: handleTogglePassword 41254 } 41255 ), 41256 showPassword && /* @__PURE__ */ (0, import_jsx_runtime269.jsx)("div", { className: "editor-change-status__password-input", children: /* @__PURE__ */ (0, import_jsx_runtime269.jsx)( 41257 import_components156.TextControl, 41258 { 41259 label: (0, import_i18n165.__)( 41260 "Password" 41261 ), 41262 onChange: (value) => updatePost2({ 41263 password: value 41264 }), 41265 value: password, 41266 placeholder: (0, import_i18n165.__)( 41267 "Use a secure password" 41268 ), 41269 type: "text", 41270 id: passwordInputId, 41271 __next40pxDefaultSize: true, 41272 maxLength: 255 41273 } 41274 ) }) 41275 ] 41276 } 41277 ), 41278 /* @__PURE__ */ (0, import_jsx_runtime269.jsx)(PostSticky, {}) 41279 ] }) 41280 } 41281 ) 41282 ] }) 41283 } 41284 ) : /* @__PURE__ */ (0, import_jsx_runtime269.jsx)("div", { className: "editor-post-status is-read-only", children: postStatusesInfo[status]?.label }) }); 41285 } 41286 41287 // packages/editor/build-module/components/post-saved-state/index.js 41288 var import_jsx_runtime270 = __toESM(require_jsx_runtime()); 41289 function PostSavedState({ forceIsDirty }) { 41290 const [forceSavedMessage, setForceSavedMessage] = (0, import_element120.useState)(false); 41291 const isLargeViewport = (0, import_compose37.useViewportMatch)("small"); 41292 const { 41293 isAutosaving, 41294 isDirty, 41295 isNew, 41296 isPublished, 41297 isSaveable, 41298 isSaving, 41299 isScheduled, 41300 hasPublishAction, 41301 showIconLabels, 41302 postStatus, 41303 postStatusHasChanged 41304 } = (0, import_data148.useSelect)( 41305 (select5) => { 41306 const { 41307 isEditedPostNew: isEditedPostNew2, 41308 isCurrentPostPublished: isCurrentPostPublished2, 41309 isCurrentPostScheduled: isCurrentPostScheduled2, 41310 isEditedPostDirty: isEditedPostDirty2, 41311 isSavingPost: isSavingPost2, 41312 isEditedPostSaveable: isEditedPostSaveable2, 41313 getCurrentPost: getCurrentPost2, 41314 isAutosavingPost: isAutosavingPost2, 41315 getEditedPostAttribute: getEditedPostAttribute2, 41316 getPostEdits: getPostEdits2 41317 } = select5(store); 41318 const { get } = select5(import_preferences14.store); 41319 return { 41320 isAutosaving: isAutosavingPost2(), 41321 isDirty: forceIsDirty || isEditedPostDirty2(), 41322 isNew: isEditedPostNew2(), 41323 isPublished: isCurrentPostPublished2(), 41324 isSaving: isSavingPost2(), 41325 isSaveable: isEditedPostSaveable2(), 41326 isScheduled: isCurrentPostScheduled2(), 41327 hasPublishAction: getCurrentPost2()?._links?.["wp:action-publish"] ?? false, 41328 showIconLabels: get("core", "showIconLabels"), 41329 postStatus: getEditedPostAttribute2("status"), 41330 postStatusHasChanged: !!getPostEdits2()?.status 41331 }; 41332 }, 41333 [forceIsDirty] 41334 ); 41335 const isPending = postStatus === "pending"; 41336 const { savePost: savePost2 } = (0, import_data148.useDispatch)(store); 41337 const wasSaving = (0, import_compose37.usePrevious)(isSaving); 41338 (0, import_element120.useEffect)(() => { 41339 let timeoutId; 41340 if (wasSaving && !isSaving) { 41341 setForceSavedMessage(true); 41342 timeoutId = setTimeout(() => { 41343 setForceSavedMessage(false); 41344 }, 1e3); 41345 } 41346 return () => clearTimeout(timeoutId); 41347 }, [isSaving]); 41348 if (!hasPublishAction && isPending) { 41349 return null; 41350 } 41351 const isIneligibleStatus = !["pending", "draft", "auto-draft"].includes(postStatus) && STATUS_OPTIONS.map(({ value }) => value).includes(postStatus); 41352 if (isPublished || isScheduled || isIneligibleStatus || postStatusHasChanged && ["pending", "draft"].includes(postStatus)) { 41353 return null; 41354 } 41355 const label = isPending ? (0, import_i18n166.__)("Save as pending") : (0, import_i18n166.__)("Save draft"); 41356 const shortLabel = (0, import_i18n166.__)("Save"); 41357 const isSaved = forceSavedMessage || !isNew && !isDirty; 41358 const isSavedState = isSaving || isSaved; 41359 const isDisabled = isSaving || isSaved || !isSaveable; 41360 let text; 41361 if (isSaving) { 41362 text = isAutosaving ? (0, import_i18n166.__)("Autosaving") : (0, import_i18n166.__)("Saving"); 41363 } else if (isSaved) { 41364 text = (0, import_i18n166.__)("Saved"); 41365 } else if (isLargeViewport) { 41366 text = label; 41367 } else if (showIconLabels) { 41368 text = shortLabel; 41369 } 41370 return /* @__PURE__ */ (0, import_jsx_runtime270.jsxs)( 41371 import_components157.Button, 41372 { 41373 className: isSaveable || isSaving ? clsx_default({ 41374 "editor-post-save-draft": !isSavedState, 41375 "editor-post-saved-state": isSavedState, 41376 "is-saving": isSaving, 41377 "is-autosaving": isAutosaving, 41378 "is-saved": isSaved, 41379 [(0, import_components157.__unstableGetAnimateClassName)({ 41380 type: "loading" 41381 })]: isSaving 41382 }) : void 0, 41383 onClick: isDisabled ? void 0 : () => savePost2(), 41384 shortcut: isDisabled ? void 0 : import_keycodes11.displayShortcut.primary("s"), 41385 variant: "tertiary", 41386 size: "compact", 41387 icon: isLargeViewport ? void 0 : cloud_upload_default, 41388 label: text || label, 41389 "aria-disabled": isDisabled, 41390 children: [ 41391 isSavedState && /* @__PURE__ */ (0, import_jsx_runtime270.jsx)(icon_default, { icon: isSaved ? check_default : cloud_default }), 41392 text 41393 ] 41394 } 41395 ); 41396 } 41397 41398 // packages/editor/build-module/components/post-schedule/check.js 41399 var import_data149 = __toESM(require_data()); 41400 function PostScheduleCheck({ children }) { 41401 const hasPublishAction = (0, import_data149.useSelect)((select5) => { 41402 return select5(store).getCurrentPost()._links?.["wp:action-publish"] ?? false; 41403 }, []); 41404 if (!hasPublishAction) { 41405 return null; 41406 } 41407 return children; 41408 } 41409 41410 // packages/editor/build-module/components/post-schedule/panel.js 41411 var import_components158 = __toESM(require_components()); 41412 var import_i18n167 = __toESM(require_i18n()); 41413 var import_element121 = __toESM(require_element()); 41414 var import_data150 = __toESM(require_data()); 41415 var import_jsx_runtime271 = __toESM(require_jsx_runtime()); 41416 function PostSchedulePanel() { 41417 const [popoverAnchor, setPopoverAnchor] = (0, import_element121.useState)(null); 41418 const postType2 = (0, import_data150.useSelect)( 41419 (select5) => select5(store).getCurrentPostType(), 41420 [] 41421 ); 41422 const popoverProps = (0, import_element121.useMemo)( 41423 () => ({ 41424 // Anchor the popover to the middle of the entire row so that it doesn't 41425 // move around when the label changes. 41426 anchor: popoverAnchor, 41427 "aria-label": (0, import_i18n167.__)("Change publish date"), 41428 placement: "left-start", 41429 offset: 36, 41430 shift: true 41431 }), 41432 [popoverAnchor] 41433 ); 41434 const label = usePostScheduleLabel(); 41435 const fullLabel = usePostScheduleLabel({ full: true }); 41436 if (DESIGN_POST_TYPES.includes(postType2)) { 41437 return null; 41438 } 41439 return /* @__PURE__ */ (0, import_jsx_runtime271.jsx)(PostScheduleCheck, { children: /* @__PURE__ */ (0, import_jsx_runtime271.jsx)(post_panel_row_default, { label: (0, import_i18n167.__)("Publish"), ref: setPopoverAnchor, children: /* @__PURE__ */ (0, import_jsx_runtime271.jsx)( 41440 import_components158.Dropdown, 41441 { 41442 popoverProps, 41443 focusOnMount: true, 41444 className: "editor-post-schedule__panel-dropdown", 41445 contentClassName: "editor-post-schedule__dialog", 41446 renderToggle: ({ onToggle, isOpen }) => /* @__PURE__ */ (0, import_jsx_runtime271.jsx)( 41447 import_components158.Button, 41448 { 41449 size: "compact", 41450 className: "editor-post-schedule__dialog-toggle", 41451 variant: "tertiary", 41452 tooltipPosition: "middle left", 41453 onClick: onToggle, 41454 "aria-label": (0, import_i18n167.sprintf)( 41455 // translators: %s: Current post date. 41456 (0, import_i18n167.__)("Change date: %s"), 41457 label 41458 ), 41459 label: fullLabel, 41460 showTooltip: label !== fullLabel, 41461 "aria-expanded": isOpen, 41462 children: label 41463 } 41464 ), 41465 renderContent: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime271.jsx)(PostSchedule, { onClose }) 41466 } 41467 ) }) }); 41468 } 41469 41470 // packages/editor/build-module/components/post-switch-to-draft-button/index.js 41471 var import_components159 = __toESM(require_components()); 41472 var import_i18n168 = __toESM(require_i18n()); 41473 var import_data151 = __toESM(require_data()); 41474 var import_element122 = __toESM(require_element()); 41475 var import_deprecated9 = __toESM(require_deprecated()); 41476 var import_jsx_runtime272 = __toESM(require_jsx_runtime()); 41477 function PostSwitchToDraftButton() { 41478 (0, import_deprecated9.default)("wp.editor.PostSwitchToDraftButton", { 41479 since: "6.7", 41480 version: "6.9" 41481 }); 41482 const [showConfirmDialog, setShowConfirmDialog] = (0, import_element122.useState)(false); 41483 const { editPost: editPost2, savePost: savePost2 } = (0, import_data151.useDispatch)(store); 41484 const { isSaving, isPublished, isScheduled } = (0, import_data151.useSelect)((select5) => { 41485 const { isSavingPost: isSavingPost2, isCurrentPostPublished: isCurrentPostPublished2, isCurrentPostScheduled: isCurrentPostScheduled2 } = select5(store); 41486 return { 41487 isSaving: isSavingPost2(), 41488 isPublished: isCurrentPostPublished2(), 41489 isScheduled: isCurrentPostScheduled2() 41490 }; 41491 }, []); 41492 const isDisabled = isSaving || !isPublished && !isScheduled; 41493 let alertMessage; 41494 let confirmButtonText; 41495 if (isPublished) { 41496 alertMessage = (0, import_i18n168.__)("Are you sure you want to unpublish this post?"); 41497 confirmButtonText = (0, import_i18n168.__)("Unpublish"); 41498 } else if (isScheduled) { 41499 alertMessage = (0, import_i18n168.__)("Are you sure you want to unschedule this post?"); 41500 confirmButtonText = (0, import_i18n168.__)("Unschedule"); 41501 } 41502 const handleConfirm = () => { 41503 setShowConfirmDialog(false); 41504 editPost2({ status: "draft" }); 41505 savePost2(); 41506 }; 41507 return /* @__PURE__ */ (0, import_jsx_runtime272.jsxs)(import_jsx_runtime272.Fragment, { children: [ 41508 /* @__PURE__ */ (0, import_jsx_runtime272.jsx)( 41509 import_components159.Button, 41510 { 41511 __next40pxDefaultSize: true, 41512 className: "editor-post-switch-to-draft", 41513 onClick: () => { 41514 if (!isDisabled) { 41515 setShowConfirmDialog(true); 41516 } 41517 }, 41518 "aria-disabled": isDisabled, 41519 variant: "secondary", 41520 style: { flexGrow: "1", justifyContent: "center" }, 41521 children: (0, import_i18n168.__)("Switch to draft") 41522 } 41523 ), 41524 /* @__PURE__ */ (0, import_jsx_runtime272.jsx)( 41525 import_components159.__experimentalConfirmDialog, 41526 { 41527 isOpen: showConfirmDialog, 41528 onConfirm: handleConfirm, 41529 onCancel: () => setShowConfirmDialog(false), 41530 confirmButtonText, 41531 children: alertMessage 41532 } 41533 ) 41534 ] }); 41535 } 41536 41537 // packages/editor/build-module/components/post-sync-status/index.js 41538 var import_data152 = __toESM(require_data()); 41539 var import_i18n169 = __toESM(require_i18n()); 41540 var import_jsx_runtime273 = __toESM(require_jsx_runtime()); 41541 function PostSyncStatus() { 41542 const { syncStatus, postType: postType2 } = (0, import_data152.useSelect)((select5) => { 41543 const { getEditedPostAttribute: getEditedPostAttribute2 } = select5(store); 41544 const meta2 = getEditedPostAttribute2("meta"); 41545 const currentSyncStatus = meta2?.wp_pattern_sync_status === "unsynced" ? "unsynced" : getEditedPostAttribute2("wp_pattern_sync_status"); 41546 return { 41547 syncStatus: currentSyncStatus, 41548 postType: getEditedPostAttribute2("type") 41549 }; 41550 }); 41551 if (postType2 !== "wp_block") { 41552 return null; 41553 } 41554 return /* @__PURE__ */ (0, import_jsx_runtime273.jsx)(post_panel_row_default, { label: (0, import_i18n169.__)("Sync status"), children: /* @__PURE__ */ (0, import_jsx_runtime273.jsx)("div", { className: "editor-post-sync-status__value", children: syncStatus === "unsynced" ? (0, import_i18n169._x)("Not synced", "pattern (singular)") : (0, import_i18n169._x)("Synced", "pattern (singular)") }) }); 41555 } 41556 41557 // packages/editor/build-module/components/post-taxonomies/index.js 41558 var import_element123 = __toESM(require_element()); 41559 var import_data153 = __toESM(require_data()); 41560 var import_core_data92 = __toESM(require_core_data()); 41561 var import_jsx_runtime274 = __toESM(require_jsx_runtime()); 41562 var identity2 = (x2) => x2; 41563 function PostTaxonomies({ taxonomyWrapper = identity2 }) { 41564 const { postType: postType2, taxonomies } = (0, import_data153.useSelect)((select5) => { 41565 return { 41566 postType: select5(store).getCurrentPostType(), 41567 taxonomies: select5(import_core_data92.store).getEntityRecords( 41568 "root", 41569 "taxonomy", 41570 { per_page: -1 } 41571 ) 41572 }; 41573 }, []); 41574 const visibleTaxonomies = (taxonomies ?? []).filter( 41575 (taxonomy) => ( 41576 // In some circumstances .visibility can end up as undefined so optional chaining operator required. 41577 // https://github.com/WordPress/gutenberg/issues/40326 41578 taxonomy.types.includes(postType2) && taxonomy.visibility?.show_ui 41579 ) 41580 ); 41581 return visibleTaxonomies.map((taxonomy) => { 41582 const TaxonomyComponent = taxonomy.hierarchical ? hierarchical_term_selector_default : flat_term_selector_default; 41583 return /* @__PURE__ */ (0, import_jsx_runtime274.jsx)(import_element123.Fragment, { children: taxonomyWrapper( 41584 /* @__PURE__ */ (0, import_jsx_runtime274.jsx)(TaxonomyComponent, { slug: taxonomy.slug }), 41585 taxonomy 41586 ) }, `taxonomy-$taxonomy.slug}`); 41587 }); 41588 } 41589 var post_taxonomies_default = PostTaxonomies; 41590 41591 // packages/editor/build-module/components/post-taxonomies/check.js 41592 var import_data154 = __toESM(require_data()); 41593 var import_core_data93 = __toESM(require_core_data()); 41594 function PostTaxonomiesCheck({ children }) { 41595 const hasTaxonomies = (0, import_data154.useSelect)((select5) => { 41596 const postType2 = select5(store).getCurrentPostType(); 41597 const taxonomies = select5(import_core_data93.store).getEntityRecords( 41598 "root", 41599 "taxonomy", 41600 { per_page: -1 } 41601 ); 41602 return taxonomies?.some( 41603 (taxonomy) => taxonomy.types.includes(postType2) 41604 ); 41605 }, []); 41606 if (!hasTaxonomies) { 41607 return null; 41608 } 41609 return children; 41610 } 41611 41612 // packages/editor/build-module/components/post-taxonomies/panel.js 41613 var import_components160 = __toESM(require_components()); 41614 var import_data155 = __toESM(require_data()); 41615 var import_jsx_runtime275 = __toESM(require_jsx_runtime()); 41616 function TaxonomyPanel({ taxonomy, children }) { 41617 const slug = taxonomy?.slug; 41618 const panelName = slug ? `taxonomy-panel-$slug}` : ""; 41619 const { isEnabled, isOpened } = (0, import_data155.useSelect)( 41620 (select5) => { 41621 const { isEditorPanelEnabled: isEditorPanelEnabled2, isEditorPanelOpened: isEditorPanelOpened2 } = select5(store); 41622 return { 41623 isEnabled: slug ? isEditorPanelEnabled2(panelName) : false, 41624 isOpened: slug ? isEditorPanelOpened2(panelName) : false 41625 }; 41626 }, 41627 [panelName, slug] 41628 ); 41629 const { toggleEditorPanelOpened: toggleEditorPanelOpened2 } = (0, import_data155.useDispatch)(store); 41630 if (!isEnabled) { 41631 return null; 41632 } 41633 const taxonomyMenuName = taxonomy?.labels?.menu_name; 41634 if (!taxonomyMenuName) { 41635 return null; 41636 } 41637 return /* @__PURE__ */ (0, import_jsx_runtime275.jsx)( 41638 import_components160.PanelBody, 41639 { 41640 title: taxonomyMenuName, 41641 opened: isOpened, 41642 onToggle: () => toggleEditorPanelOpened2(panelName), 41643 children 41644 } 41645 ); 41646 } 41647 function PostTaxonomies2() { 41648 return /* @__PURE__ */ (0, import_jsx_runtime275.jsx)(PostTaxonomiesCheck, { children: /* @__PURE__ */ (0, import_jsx_runtime275.jsx)( 41649 post_taxonomies_default, 41650 { 41651 taxonomyWrapper: (content, taxonomy) => { 41652 return /* @__PURE__ */ (0, import_jsx_runtime275.jsx)(TaxonomyPanel, { taxonomy, children: content }); 41653 } 41654 } 41655 ) }); 41656 } 41657 41658 // packages/editor/build-module/components/post-text-editor/index.js 41659 var import_react_autosize_textarea = __toESM(require_lib()); 41660 var import_i18n170 = __toESM(require_i18n()); 41661 var import_core_data94 = __toESM(require_core_data()); 41662 var import_element124 = __toESM(require_element()); 41663 var import_blocks26 = __toESM(require_blocks()); 41664 var import_data156 = __toESM(require_data()); 41665 var import_compose38 = __toESM(require_compose()); 41666 var import_components161 = __toESM(require_components()); 41667 var import_jsx_runtime276 = __toESM(require_jsx_runtime()); 41668 function PostTextEditor() { 41669 const instanceId = (0, import_compose38.useInstanceId)(PostTextEditor); 41670 const { content, blocks, type, id } = (0, import_data156.useSelect)((select5) => { 41671 const { getEditedEntityRecord } = select5(import_core_data94.store); 41672 const { getCurrentPostType: getCurrentPostType2, getCurrentPostId: getCurrentPostId2 } = select5(store); 41673 const _type = getCurrentPostType2(); 41674 const _id = getCurrentPostId2(); 41675 const editedRecord = getEditedEntityRecord("postType", _type, _id); 41676 return { 41677 content: editedRecord?.content, 41678 blocks: editedRecord?.blocks, 41679 type: _type, 41680 id: _id 41681 }; 41682 }, []); 41683 const { editEntityRecord } = (0, import_data156.useDispatch)(import_core_data94.store); 41684 const value = (0, import_element124.useMemo)(() => { 41685 if (content instanceof Function) { 41686 return content({ blocks }); 41687 } else if (blocks) { 41688 return (0, import_blocks26.__unstableSerializeAndClean)(blocks); 41689 } 41690 return content; 41691 }, [content, blocks]); 41692 return /* @__PURE__ */ (0, import_jsx_runtime276.jsxs)(import_jsx_runtime276.Fragment, { children: [ 41693 /* @__PURE__ */ (0, import_jsx_runtime276.jsx)( 41694 import_components161.VisuallyHidden, 41695 { 41696 as: "label", 41697 htmlFor: `post-content-$instanceId}`, 41698 children: (0, import_i18n170.__)("Type text or HTML") 41699 } 41700 ), 41701 /* @__PURE__ */ (0, import_jsx_runtime276.jsx)( 41702 import_react_autosize_textarea.default, 41703 { 41704 autoComplete: "off", 41705 dir: "auto", 41706 value, 41707 onChange: (event) => { 41708 editEntityRecord("postType", type, id, { 41709 content: event.target.value, 41710 blocks: void 0, 41711 selection: void 0 41712 }); 41713 }, 41714 className: "editor-post-text-editor", 41715 id: `post-content-$instanceId}`, 41716 placeholder: (0, import_i18n170.__)("Start writing with text or HTML") 41717 } 41718 ) 41719 ] }); 41720 } 41721 41722 // packages/editor/build-module/components/post-title/index.js 41723 var import_i18n171 = __toESM(require_i18n()); 41724 var import_element126 = __toESM(require_element()); 41725 var import_html_entities24 = __toESM(require_html_entities()); 41726 var import_data159 = __toESM(require_data()); 41727 var import_block_editor58 = __toESM(require_block_editor()); 41728 var import_keycodes12 = __toESM(require_keycodes()); 41729 var import_blocks27 = __toESM(require_blocks()); 41730 var import_rich_text2 = __toESM(require_rich_text()); 41731 var import_compose39 = __toESM(require_compose()); 41732 var import_dom2 = __toESM(require_dom()); 41733 41734 // packages/editor/build-module/components/post-title/constants.js 41735 var DEFAULT_CLASSNAMES = "wp-block wp-block-post-title block-editor-block-list__block editor-post-title editor-post-title__input rich-text"; 41736 var REGEXP_NEWLINES = /[\r\n]+/g; 41737 41738 // packages/editor/build-module/components/post-title/use-post-title-focus.js 41739 var import_element125 = __toESM(require_element()); 41740 var import_data157 = __toESM(require_data()); 41741 function usePostTitleFocus(forwardedRef) { 41742 const ref = (0, import_element125.useRef)(); 41743 const { isCleanNewPost: isCleanNewPost2 } = (0, import_data157.useSelect)((select5) => { 41744 const { isCleanNewPost: _isCleanNewPost } = select5(store); 41745 return { 41746 isCleanNewPost: _isCleanNewPost() 41747 }; 41748 }, []); 41749 (0, import_element125.useImperativeHandle)(forwardedRef, () => ({ 41750 focus: () => { 41751 ref?.current?.focus(); 41752 } 41753 })); 41754 (0, import_element125.useEffect)(() => { 41755 if (!ref.current) { 41756 return; 41757 } 41758 const { defaultView } = ref.current.ownerDocument; 41759 const { name: name2, parent } = defaultView; 41760 const ownerDocument = name2 === "editor-canvas" ? parent.document : defaultView.document; 41761 const { activeElement, body } = ownerDocument; 41762 if (isCleanNewPost2 && (!activeElement || body === activeElement)) { 41763 ref.current.focus(); 41764 } 41765 }, [isCleanNewPost2]); 41766 return { ref }; 41767 } 41768 41769 // packages/editor/build-module/components/post-title/use-post-title.js 41770 var import_data158 = __toESM(require_data()); 41771 function usePostTitle() { 41772 const { editPost: editPost2 } = (0, import_data158.useDispatch)(store); 41773 const { title } = (0, import_data158.useSelect)((select5) => { 41774 const { getEditedPostAttribute: getEditedPostAttribute2 } = select5(store); 41775 return { 41776 title: getEditedPostAttribute2("title") 41777 }; 41778 }, []); 41779 function updateTitle(newTitle) { 41780 editPost2({ title: newTitle }); 41781 } 41782 return { title, setTitle: updateTitle }; 41783 } 41784 41785 // packages/editor/build-module/components/post-title/index.js 41786 var import_jsx_runtime277 = __toESM(require_jsx_runtime()); 41787 var PostTitle = (0, import_element126.forwardRef)((_, forwardedRef) => { 41788 const { placeholder, isEditingContentOnlySection } = (0, import_data159.useSelect)( 41789 (select5) => { 41790 const { getSettings: getSettings5, getEditedContentOnlySection } = unlock( 41791 select5(import_block_editor58.store) 41792 ); 41793 const { titlePlaceholder } = getSettings5(); 41794 return { 41795 placeholder: titlePlaceholder, 41796 isEditingContentOnlySection: !!getEditedContentOnlySection() 41797 }; 41798 }, 41799 [] 41800 ); 41801 const [isSelected, setIsSelected] = (0, import_element126.useState)(false); 41802 const { ref: focusRef } = usePostTitleFocus(forwardedRef); 41803 const { title, setTitle: onUpdate } = usePostTitle(); 41804 const [selection, setSelection] = (0, import_element126.useState)({}); 41805 const { clearSelectedBlock: clearSelectedBlock2, insertBlocks: insertBlocks2, insertDefaultBlock: insertDefaultBlock2 } = (0, import_data159.useDispatch)(import_block_editor58.store); 41806 const decodedPlaceholder = (0, import_html_entities24.decodeEntities)(placeholder) || (0, import_i18n171.__)("Add title"); 41807 const { 41808 value, 41809 onChange, 41810 ref: richTextRef 41811 } = (0, import_rich_text2.__unstableUseRichText)({ 41812 value: title, 41813 onChange(newValue) { 41814 onUpdate(newValue.replace(REGEXP_NEWLINES, " ")); 41815 }, 41816 placeholder: decodedPlaceholder, 41817 selectionStart: selection.start, 41818 selectionEnd: selection.end, 41819 onSelectionChange(newStart, newEnd) { 41820 setSelection((sel) => { 41821 const { start, end } = sel; 41822 if (start === newStart && end === newEnd) { 41823 return sel; 41824 } 41825 return { 41826 start: newStart, 41827 end: newEnd 41828 }; 41829 }); 41830 }, 41831 __unstableDisableFormats: false 41832 }); 41833 function onInsertBlockAfter(blocks) { 41834 insertBlocks2(blocks, 0); 41835 } 41836 function onSelect() { 41837 setIsSelected(true); 41838 clearSelectedBlock2(); 41839 } 41840 function onUnselect() { 41841 setIsSelected(false); 41842 setSelection({}); 41843 } 41844 function onEnterPress() { 41845 insertDefaultBlock2(void 0, void 0, 0); 41846 } 41847 function onKeyDown(event) { 41848 if (event.keyCode === import_keycodes12.ENTER) { 41849 event.preventDefault(); 41850 onEnterPress(); 41851 } 41852 } 41853 function onPaste(event) { 41854 const clipboardData = event.clipboardData; 41855 let plainText = ""; 41856 let html = ""; 41857 try { 41858 plainText = clipboardData.getData("text/plain"); 41859 html = clipboardData.getData("text/html"); 41860 } catch (error) { 41861 return; 41862 } 41863 window.console.log("Received HTML:\n\n", html); 41864 window.console.log("Received plain text:\n\n", plainText); 41865 const content = (0, import_blocks27.pasteHandler)({ 41866 HTML: html, 41867 plainText 41868 }); 41869 event.preventDefault(); 41870 if (!content.length) { 41871 return; 41872 } 41873 if (typeof content !== "string") { 41874 const [firstBlock] = content; 41875 if (!title && (firstBlock.name === "core/heading" || firstBlock.name === "core/paragraph")) { 41876 const contentNoHTML = (0, import_dom2.__unstableStripHTML)( 41877 firstBlock.attributes.content 41878 ); 41879 onUpdate(contentNoHTML); 41880 onInsertBlockAfter(content.slice(1)); 41881 } else { 41882 onInsertBlockAfter(content); 41883 } 41884 } else { 41885 const contentNoHTML = (0, import_dom2.__unstableStripHTML)(content); 41886 onChange((0, import_rich_text2.insert)(value, (0, import_rich_text2.create)({ html: contentNoHTML }))); 41887 } 41888 } 41889 const className = clsx_default(DEFAULT_CLASSNAMES, { 41890 "is-selected": isSelected 41891 }); 41892 const style = isEditingContentOnlySection ? { opacity: 0.2 } : void 0; 41893 return ( 41894 /* eslint-disable jsx-a11y/heading-has-content, jsx-a11y/no-noninteractive-element-to-interactive-role */ 41895 /* @__PURE__ */ (0, import_jsx_runtime277.jsx)( 41896 "h1", 41897 { 41898 ref: (0, import_compose39.useMergeRefs)([richTextRef, focusRef]), 41899 contentEditable: !isEditingContentOnlySection, 41900 className, 41901 "aria-label": decodedPlaceholder, 41902 role: "textbox", 41903 "aria-multiline": "true", 41904 onFocus: onSelect, 41905 onBlur: onUnselect, 41906 onKeyDown, 41907 onPaste, 41908 style 41909 } 41910 ) 41911 ); 41912 }); 41913 var post_title_default = (0, import_element126.forwardRef)((_, forwardedRef) => /* @__PURE__ */ (0, import_jsx_runtime277.jsx)(post_type_support_check_default, { supportKeys: "title", children: /* @__PURE__ */ (0, import_jsx_runtime277.jsx)(PostTitle, { ref: forwardedRef }) })); 41914 41915 // packages/editor/build-module/components/post-title/post-title-raw.js 41916 var import_components162 = __toESM(require_components()); 41917 var import_i18n172 = __toESM(require_i18n()); 41918 var import_html_entities25 = __toESM(require_html_entities()); 41919 var import_data160 = __toESM(require_data()); 41920 var import_block_editor59 = __toESM(require_block_editor()); 41921 var import_element127 = __toESM(require_element()); 41922 var import_jsx_runtime278 = __toESM(require_jsx_runtime()); 41923 function PostTitleRaw(_, forwardedRef) { 41924 const { placeholder } = (0, import_data160.useSelect)((select5) => { 41925 const { getSettings: getSettings5 } = select5(import_block_editor59.store); 41926 const { titlePlaceholder } = getSettings5(); 41927 return { 41928 placeholder: titlePlaceholder 41929 }; 41930 }, []); 41931 const [isSelected, setIsSelected] = (0, import_element127.useState)(false); 41932 const { title, setTitle: onUpdate } = usePostTitle(); 41933 const { ref: focusRef } = usePostTitleFocus(forwardedRef); 41934 function onChange(value) { 41935 onUpdate(value.replace(REGEXP_NEWLINES, " ")); 41936 } 41937 function onSelect() { 41938 setIsSelected(true); 41939 } 41940 function onUnselect() { 41941 setIsSelected(false); 41942 } 41943 const className = clsx_default(DEFAULT_CLASSNAMES, { 41944 "is-selected": isSelected, 41945 "is-raw-text": true 41946 }); 41947 const decodedPlaceholder = (0, import_html_entities25.decodeEntities)(placeholder) || (0, import_i18n172.__)("Add title"); 41948 return /* @__PURE__ */ (0, import_jsx_runtime278.jsx)( 41949 import_components162.TextareaControl, 41950 { 41951 ref: focusRef, 41952 value: title, 41953 onChange, 41954 onFocus: onSelect, 41955 onBlur: onUnselect, 41956 label: placeholder, 41957 className, 41958 placeholder: decodedPlaceholder, 41959 hideLabelFromVision: true, 41960 autoComplete: "off", 41961 dir: "auto", 41962 rows: 1 41963 } 41964 ); 41965 } 41966 var post_title_raw_default = (0, import_element127.forwardRef)(PostTitleRaw); 41967 41968 // packages/editor/build-module/components/post-trash/index.js 41969 var import_i18n173 = __toESM(require_i18n()); 41970 var import_components163 = __toESM(require_components()); 41971 var import_data162 = __toESM(require_data()); 41972 var import_element128 = __toESM(require_element()); 41973 41974 // packages/editor/build-module/components/post-trash/check.js 41975 var import_data161 = __toESM(require_data()); 41976 var import_core_data95 = __toESM(require_core_data()); 41977 function PostTrashCheck({ children }) { 41978 const { canTrashPost } = (0, import_data161.useSelect)((select5) => { 41979 const { isEditedPostNew: isEditedPostNew2, getCurrentPostId: getCurrentPostId2, getCurrentPostType: getCurrentPostType2 } = select5(store); 41980 const { canUser } = select5(import_core_data95.store); 41981 const postType2 = getCurrentPostType2(); 41982 const postId2 = getCurrentPostId2(); 41983 const isNew = isEditedPostNew2(); 41984 const canUserDelete = !!postId2 ? canUser("delete", { 41985 kind: "postType", 41986 name: postType2, 41987 id: postId2 41988 }) : false; 41989 return { 41990 canTrashPost: (!isNew || postId2) && canUserDelete && !GLOBAL_POST_TYPES.includes(postType2) 41991 }; 41992 }, []); 41993 if (!canTrashPost) { 41994 return null; 41995 } 41996 return children; 41997 } 41998 41999 // packages/editor/build-module/components/post-trash/index.js 42000 var import_jsx_runtime279 = __toESM(require_jsx_runtime()); 42001 function PostTrash({ onActionPerformed }) { 42002 const registry = (0, import_data162.useRegistry)(); 42003 const { isNew, isDeleting, postId: postId2, title } = (0, import_data162.useSelect)((select5) => { 42004 const store3 = select5(store); 42005 return { 42006 isNew: store3.isEditedPostNew(), 42007 isDeleting: store3.isDeletingPost(), 42008 postId: store3.getCurrentPostId(), 42009 title: store3.getCurrentPostAttribute("title") 42010 }; 42011 }, []); 42012 const { trashPost: trashPost3 } = (0, import_data162.useDispatch)(store); 42013 const [showConfirmDialog, setShowConfirmDialog] = (0, import_element128.useState)(false); 42014 if (isNew || !postId2) { 42015 return null; 42016 } 42017 const handleConfirm = async () => { 42018 setShowConfirmDialog(false); 42019 await trashPost3(); 42020 const item = await registry.resolveSelect(store).getCurrentPost(); 42021 onActionPerformed?.("move-to-trash", [item]); 42022 }; 42023 return /* @__PURE__ */ (0, import_jsx_runtime279.jsxs)(PostTrashCheck, { children: [ 42024 /* @__PURE__ */ (0, import_jsx_runtime279.jsx)( 42025 import_components163.Button, 42026 { 42027 __next40pxDefaultSize: true, 42028 className: "editor-post-trash", 42029 isDestructive: true, 42030 variant: "secondary", 42031 isBusy: isDeleting, 42032 "aria-disabled": isDeleting, 42033 onClick: isDeleting ? void 0 : () => setShowConfirmDialog(true), 42034 children: (0, import_i18n173.__)("Move to trash") 42035 } 42036 ), 42037 /* @__PURE__ */ (0, import_jsx_runtime279.jsx)( 42038 import_components163.__experimentalConfirmDialog, 42039 { 42040 isOpen: showConfirmDialog, 42041 onConfirm: handleConfirm, 42042 onCancel: () => setShowConfirmDialog(false), 42043 confirmButtonText: (0, import_i18n173.__)("Move to trash"), 42044 size: "small", 42045 children: (0, import_i18n173.sprintf)( 42046 // translators: %s: The item's title. 42047 (0, import_i18n173.__)('Are you sure you want to move "%s" to the trash?'), 42048 title 42049 ) 42050 } 42051 ) 42052 ] }); 42053 } 42054 42055 // packages/editor/build-module/components/post-url/index.js 42056 var import_data163 = __toESM(require_data()); 42057 var import_url16 = __toESM(require_url()); 42058 var import_element129 = __toESM(require_element()); 42059 var import_block_editor60 = __toESM(require_block_editor()); 42060 var import_i18n174 = __toESM(require_i18n()); 42061 var import_components164 = __toESM(require_components()); 42062 var import_notices24 = __toESM(require_notices()); 42063 var import_core_data96 = __toESM(require_core_data()); 42064 var import_compose40 = __toESM(require_compose()); 42065 var import_jsx_runtime280 = __toESM(require_jsx_runtime()); 42066 function PostURL({ onClose }) { 42067 const { 42068 isEditable, 42069 postSlug, 42070 postLink, 42071 permalinkPrefix, 42072 permalinkSuffix, 42073 permalink 42074 } = (0, import_data163.useSelect)((select5) => { 42075 const post2 = select5(store).getCurrentPost(); 42076 const postTypeSlug = select5(store).getCurrentPostType(); 42077 const postType2 = select5(import_core_data96.store).getPostType(postTypeSlug); 42078 const permalinkParts = select5(store).getPermalinkParts(); 42079 const hasPublishAction = post2?._links?.["wp:action-publish"] ?? false; 42080 return { 42081 isEditable: select5(store).isPermalinkEditable() && hasPublishAction, 42082 postSlug: (0, import_url16.safeDecodeURIComponent)( 42083 select5(store).getEditedPostSlug() 42084 ), 42085 viewPostLabel: postType2?.labels.view_item, 42086 postLink: post2.link, 42087 permalinkPrefix: permalinkParts?.prefix, 42088 permalinkSuffix: permalinkParts?.suffix, 42089 permalink: (0, import_url16.safeDecodeURIComponent)( 42090 select5(store).getPermalink() 42091 ) 42092 }; 42093 }, []); 42094 const { editPost: editPost2 } = (0, import_data163.useDispatch)(store); 42095 const { createNotice } = (0, import_data163.useDispatch)(import_notices24.store); 42096 const [forceEmptyField, setForceEmptyField] = (0, import_element129.useState)(false); 42097 const copyButtonRef = (0, import_compose40.useCopyToClipboard)(permalink, () => { 42098 createNotice("info", (0, import_i18n174.__)("Copied Permalink to clipboard."), { 42099 isDismissible: true, 42100 type: "snackbar" 42101 }); 42102 }); 42103 const postUrlSlugDescriptionId = "editor-post-url__slug-description-" + (0, import_compose40.useInstanceId)(PostURL); 42104 return /* @__PURE__ */ (0, import_jsx_runtime280.jsxs)("div", { className: "editor-post-url", children: [ 42105 /* @__PURE__ */ (0, import_jsx_runtime280.jsx)( 42106 import_block_editor60.__experimentalInspectorPopoverHeader, 42107 { 42108 title: (0, import_i18n174.__)("Slug"), 42109 onClose 42110 } 42111 ), 42112 /* @__PURE__ */ (0, import_jsx_runtime280.jsxs)(import_components164.__experimentalVStack, { spacing: 3, children: [ 42113 isEditable && /* @__PURE__ */ (0, import_jsx_runtime280.jsx)("p", { className: "editor-post-url__intro", children: (0, import_element129.createInterpolateElement)( 42114 (0, import_i18n174.__)( 42115 "<span>Customize the last part of the Permalink.</span> <a>Learn more.</a>" 42116 ), 42117 { 42118 span: /* @__PURE__ */ (0, import_jsx_runtime280.jsx)("span", { id: postUrlSlugDescriptionId }), 42119 a: /* @__PURE__ */ (0, import_jsx_runtime280.jsx)( 42120 import_components164.ExternalLink, 42121 { 42122 href: (0, import_i18n174.__)( 42123 "https://wordpress.org/documentation/article/page-post-settings-sidebar/#permalink" 42124 ) 42125 } 42126 ) 42127 } 42128 ) }), 42129 /* @__PURE__ */ (0, import_jsx_runtime280.jsxs)("div", { children: [ 42130 isEditable && /* @__PURE__ */ (0, import_jsx_runtime280.jsxs)(import_jsx_runtime280.Fragment, { children: [ 42131 /* @__PURE__ */ (0, import_jsx_runtime280.jsx)( 42132 import_components164.__experimentalInputControl, 42133 { 42134 __next40pxDefaultSize: true, 42135 prefix: /* @__PURE__ */ (0, import_jsx_runtime280.jsx)(import_components164.__experimentalInputControlPrefixWrapper, { children: "/" }), 42136 suffix: /* @__PURE__ */ (0, import_jsx_runtime280.jsx)(import_components164.__experimentalInputControlSuffixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime280.jsx)( 42137 import_components164.Button, 42138 { 42139 icon: copy_small_default, 42140 ref: copyButtonRef, 42141 size: "small", 42142 label: "Copy" 42143 } 42144 ) }), 42145 label: (0, import_i18n174.__)("Slug"), 42146 hideLabelFromVision: true, 42147 value: forceEmptyField ? "" : postSlug, 42148 autoComplete: "off", 42149 spellCheck: "false", 42150 type: "text", 42151 className: "editor-post-url__input", 42152 onChange: (newValue) => { 42153 editPost2({ slug: newValue }); 42154 if (!newValue) { 42155 if (!forceEmptyField) { 42156 setForceEmptyField(true); 42157 } 42158 return; 42159 } 42160 if (forceEmptyField) { 42161 setForceEmptyField(false); 42162 } 42163 }, 42164 onBlur: (event) => { 42165 editPost2({ 42166 slug: (0, import_url16.cleanForSlug)( 42167 event.target.value 42168 ) 42169 }); 42170 if (forceEmptyField) { 42171 setForceEmptyField(false); 42172 } 42173 }, 42174 "aria-describedby": postUrlSlugDescriptionId 42175 } 42176 ), 42177 /* @__PURE__ */ (0, import_jsx_runtime280.jsxs)("p", { className: "editor-post-url__permalink", children: [ 42178 /* @__PURE__ */ (0, import_jsx_runtime280.jsx)("span", { className: "editor-post-url__permalink-visual-label", children: (0, import_i18n174.__)("Permalink:") }), 42179 /* @__PURE__ */ (0, import_jsx_runtime280.jsxs)( 42180 import_components164.ExternalLink, 42181 { 42182 className: "editor-post-url__link", 42183 href: postLink, 42184 target: "_blank", 42185 children: [ 42186 /* @__PURE__ */ (0, import_jsx_runtime280.jsx)("span", { className: "editor-post-url__link-prefix", children: permalinkPrefix }), 42187 /* @__PURE__ */ (0, import_jsx_runtime280.jsx)("span", { className: "editor-post-url__link-slug", children: postSlug }), 42188 /* @__PURE__ */ (0, import_jsx_runtime280.jsx)("span", { className: "editor-post-url__link-suffix", children: permalinkSuffix }) 42189 ] 42190 } 42191 ) 42192 ] }) 42193 ] }), 42194 !isEditable && /* @__PURE__ */ (0, import_jsx_runtime280.jsx)( 42195 import_components164.ExternalLink, 42196 { 42197 className: "editor-post-url__link", 42198 href: postLink, 42199 target: "_blank", 42200 children: postLink 42201 } 42202 ) 42203 ] }) 42204 ] }) 42205 ] }); 42206 } 42207 42208 // packages/editor/build-module/components/post-url/check.js 42209 var import_data164 = __toESM(require_data()); 42210 var import_core_data97 = __toESM(require_core_data()); 42211 function PostURLCheck({ children }) { 42212 const isVisible = (0, import_data164.useSelect)((select5) => { 42213 const postTypeSlug = select5(store).getCurrentPostType(); 42214 const postType2 = select5(import_core_data97.store).getPostType(postTypeSlug); 42215 if (!postType2?.viewable) { 42216 return false; 42217 } 42218 const post2 = select5(store).getCurrentPost(); 42219 if (!post2.link) { 42220 return false; 42221 } 42222 const permalinkParts = select5(store).getPermalinkParts(); 42223 if (!permalinkParts) { 42224 return false; 42225 } 42226 return true; 42227 }, []); 42228 if (!isVisible) { 42229 return null; 42230 } 42231 return children; 42232 } 42233 42234 // packages/editor/build-module/components/post-url/label.js 42235 var import_data165 = __toESM(require_data()); 42236 var import_url17 = __toESM(require_url()); 42237 function PostURLLabel() { 42238 return usePostURLLabel(); 42239 } 42240 function usePostURLLabel() { 42241 const postLink = (0, import_data165.useSelect)( 42242 (select5) => select5(store).getPermalink(), 42243 [] 42244 ); 42245 return (0, import_url17.filterURLForDisplay)((0, import_url17.safeDecodeURIComponent)(postLink)); 42246 } 42247 42248 // packages/editor/build-module/components/post-url/panel.js 42249 var import_element130 = __toESM(require_element()); 42250 var import_data166 = __toESM(require_data()); 42251 var import_components165 = __toESM(require_components()); 42252 var import_i18n175 = __toESM(require_i18n()); 42253 var import_url18 = __toESM(require_url()); 42254 var import_core_data98 = __toESM(require_core_data()); 42255 var import_jsx_runtime281 = __toESM(require_jsx_runtime()); 42256 function PostURLPanel() { 42257 const { isFrontPage } = (0, import_data166.useSelect)((select5) => { 42258 const { getCurrentPostId: getCurrentPostId2 } = select5(store); 42259 const { getEditedEntityRecord, canUser } = select5(import_core_data98.store); 42260 const siteSettings = canUser("read", { 42261 kind: "root", 42262 name: "site" 42263 }) ? getEditedEntityRecord("root", "site") : void 0; 42264 const _id = getCurrentPostId2(); 42265 return { 42266 isFrontPage: siteSettings?.page_on_front === _id 42267 }; 42268 }, []); 42269 const [popoverAnchor, setPopoverAnchor] = (0, import_element130.useState)(null); 42270 const popoverProps = (0, import_element130.useMemo)( 42271 () => ({ 42272 // Anchor the popover to the middle of the entire row so that it doesn't 42273 // move around when the label changes. 42274 anchor: popoverAnchor, 42275 placement: "left-start", 42276 offset: 36, 42277 shift: true 42278 }), 42279 [popoverAnchor] 42280 ); 42281 const label = isFrontPage ? (0, import_i18n175.__)("Link") : (0, import_i18n175.__)("Slug"); 42282 return /* @__PURE__ */ (0, import_jsx_runtime281.jsx)(PostURLCheck, { children: /* @__PURE__ */ (0, import_jsx_runtime281.jsxs)(post_panel_row_default, { label, ref: setPopoverAnchor, children: [ 42283 !isFrontPage && /* @__PURE__ */ (0, import_jsx_runtime281.jsx)( 42284 import_components165.Dropdown, 42285 { 42286 popoverProps, 42287 className: "editor-post-url__panel-dropdown", 42288 contentClassName: "editor-post-url__panel-dialog", 42289 focusOnMount: true, 42290 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime281.jsx)( 42291 PostURLToggle, 42292 { 42293 isOpen, 42294 onClick: onToggle 42295 } 42296 ), 42297 renderContent: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime281.jsx)(PostURL, { onClose }) 42298 } 42299 ), 42300 isFrontPage && /* @__PURE__ */ (0, import_jsx_runtime281.jsx)(FrontPageLink, {}) 42301 ] }) }); 42302 } 42303 function PostURLToggle({ isOpen, onClick }) { 42304 const { slug } = (0, import_data166.useSelect)((select5) => { 42305 return { 42306 slug: select5(store).getEditedPostSlug() 42307 }; 42308 }, []); 42309 const decodedSlug = (0, import_url18.safeDecodeURIComponent)(slug); 42310 return /* @__PURE__ */ (0, import_jsx_runtime281.jsx)( 42311 import_components165.Button, 42312 { 42313 size: "compact", 42314 className: "editor-post-url__panel-toggle", 42315 variant: "tertiary", 42316 "aria-expanded": isOpen, 42317 "aria-label": ( 42318 // translators: %s: Current post link. 42319 (0, import_i18n175.sprintf)((0, import_i18n175.__)("Change link: %s"), decodedSlug) 42320 ), 42321 onClick, 42322 children: /* @__PURE__ */ (0, import_jsx_runtime281.jsx)(import_jsx_runtime281.Fragment, { children: decodedSlug }) 42323 } 42324 ); 42325 } 42326 function FrontPageLink() { 42327 const { postLink } = (0, import_data166.useSelect)((select5) => { 42328 const { getCurrentPost: getCurrentPost2 } = select5(store); 42329 return { 42330 postLink: getCurrentPost2()?.link 42331 }; 42332 }, []); 42333 return /* @__PURE__ */ (0, import_jsx_runtime281.jsx)( 42334 import_components165.ExternalLink, 42335 { 42336 className: "editor-post-url__front-page-link", 42337 href: postLink, 42338 target: "_blank", 42339 children: postLink 42340 } 42341 ); 42342 } 42343 42344 // packages/editor/build-module/components/post-visibility/check.js 42345 var import_data167 = __toESM(require_data()); 42346 function PostVisibilityCheck({ render }) { 42347 const canEdit = (0, import_data167.useSelect)((select5) => { 42348 return select5(store).getCurrentPost()._links?.["wp:action-publish"] ?? false; 42349 }); 42350 return render({ canEdit }); 42351 } 42352 42353 // packages/editor/build-module/components/table-of-contents/index.js 42354 var import_i18n179 = __toESM(require_i18n()); 42355 var import_components166 = __toESM(require_components()); 42356 var import_data172 = __toESM(require_data()); 42357 var import_element132 = __toESM(require_element()); 42358 var import_block_editor62 = __toESM(require_block_editor()); 42359 42360 // packages/editor/build-module/components/table-of-contents/panel.js 42361 var import_i18n178 = __toESM(require_i18n()); 42362 var import_data171 = __toESM(require_data()); 42363 var import_block_editor61 = __toESM(require_block_editor()); 42364 42365 // packages/editor/build-module/components/word-count/index.js 42366 var import_data168 = __toESM(require_data()); 42367 var import_i18n176 = __toESM(require_i18n()); 42368 var import_wordcount = __toESM(require_wordcount()); 42369 var import_jsx_runtime282 = __toESM(require_jsx_runtime()); 42370 function WordCount() { 42371 const content = (0, import_data168.useSelect)( 42372 (select5) => select5(store).getEditedPostAttribute("content"), 42373 [] 42374 ); 42375 const wordCountType = (0, import_i18n176._x)("words", "Word count type. Do not translate!"); 42376 return /* @__PURE__ */ (0, import_jsx_runtime282.jsx)("span", { className: "word-count", children: (0, import_wordcount.count)(content, wordCountType) }); 42377 } 42378 42379 // packages/editor/build-module/components/time-to-read/index.js 42380 var import_data169 = __toESM(require_data()); 42381 var import_i18n177 = __toESM(require_i18n()); 42382 var import_wordcount2 = __toESM(require_wordcount()); 42383 var import_element131 = __toESM(require_element()); 42384 var import_jsx_runtime283 = __toESM(require_jsx_runtime()); 42385 var AVERAGE_READING_RATE = 189; 42386 function TimeToRead() { 42387 const content = (0, import_data169.useSelect)( 42388 (select5) => select5(store).getEditedPostAttribute("content"), 42389 [] 42390 ); 42391 const wordCountType = (0, import_i18n177._x)("words", "Word count type. Do not translate!"); 42392 const minutesToRead = Math.round( 42393 (0, import_wordcount2.count)(content, wordCountType) / AVERAGE_READING_RATE 42394 ); 42395 const minutesToReadString = minutesToRead === 0 ? (0, import_element131.createInterpolateElement)((0, import_i18n177.__)("<span>< 1</span> minute"), { 42396 span: /* @__PURE__ */ (0, import_jsx_runtime283.jsx)("span", {}) 42397 }) : (0, import_element131.createInterpolateElement)( 42398 (0, import_i18n177.sprintf)( 42399 /* translators: %s: the number of minutes to read the post. */ 42400 (0, import_i18n177._n)( 42401 "<span>%s</span> minute", 42402 "<span>%s</span> minutes", 42403 minutesToRead 42404 ), 42405 minutesToRead 42406 ), 42407 { 42408 span: /* @__PURE__ */ (0, import_jsx_runtime283.jsx)("span", {}) 42409 } 42410 ); 42411 return /* @__PURE__ */ (0, import_jsx_runtime283.jsx)("span", { className: "time-to-read", children: minutesToReadString }); 42412 } 42413 42414 // packages/editor/build-module/components/character-count/index.js 42415 var import_data170 = __toESM(require_data()); 42416 var import_wordcount3 = __toESM(require_wordcount()); 42417 function CharacterCount() { 42418 const content = (0, import_data170.useSelect)( 42419 (select5) => select5(store).getEditedPostAttribute("content"), 42420 [] 42421 ); 42422 return (0, import_wordcount3.count)(content, "characters_including_spaces"); 42423 } 42424 42425 // packages/editor/build-module/components/table-of-contents/panel.js 42426 var import_jsx_runtime284 = __toESM(require_jsx_runtime()); 42427 function TableOfContentsPanel({ hasOutlineItemsDisabled, onRequestClose }) { 42428 const { headingCount, paragraphCount, numberOfBlocks } = (0, import_data171.useSelect)( 42429 (select5) => { 42430 const { getGlobalBlockCount: getGlobalBlockCount2 } = select5(import_block_editor61.store); 42431 return { 42432 headingCount: getGlobalBlockCount2("core/heading"), 42433 paragraphCount: getGlobalBlockCount2("core/paragraph"), 42434 numberOfBlocks: getGlobalBlockCount2() 42435 }; 42436 }, 42437 [] 42438 ); 42439 return ( 42440 /* 42441 * Disable reason: The `list` ARIA role is redundant but 42442 * Safari+VoiceOver won't announce the list otherwise. 42443 */ 42444 /* eslint-disable jsx-a11y/no-redundant-roles */ 42445 /* @__PURE__ */ (0, import_jsx_runtime284.jsxs)(import_jsx_runtime284.Fragment, { children: [ 42446 /* @__PURE__ */ (0, import_jsx_runtime284.jsx)( 42447 "div", 42448 { 42449 className: "table-of-contents__wrapper", 42450 role: "note", 42451 "aria-label": (0, import_i18n178.__)("Document Statistics"), 42452 tabIndex: "0", 42453 children: /* @__PURE__ */ (0, import_jsx_runtime284.jsxs)("ul", { role: "list", className: "table-of-contents__counts", children: [ 42454 /* @__PURE__ */ (0, import_jsx_runtime284.jsxs)("li", { className: "table-of-contents__count", children: [ 42455 (0, import_i18n178.__)("Words"), 42456 /* @__PURE__ */ (0, import_jsx_runtime284.jsx)(WordCount, {}) 42457 ] }), 42458 /* @__PURE__ */ (0, import_jsx_runtime284.jsxs)("li", { className: "table-of-contents__count", children: [ 42459 (0, import_i18n178.__)("Characters"), 42460 /* @__PURE__ */ (0, import_jsx_runtime284.jsx)("span", { className: "table-of-contents__number", children: /* @__PURE__ */ (0, import_jsx_runtime284.jsx)(CharacterCount, {}) }) 42461 ] }), 42462 /* @__PURE__ */ (0, import_jsx_runtime284.jsxs)("li", { className: "table-of-contents__count", children: [ 42463 (0, import_i18n178.__)("Time to read"), 42464 /* @__PURE__ */ (0, import_jsx_runtime284.jsx)(TimeToRead, {}) 42465 ] }), 42466 /* @__PURE__ */ (0, import_jsx_runtime284.jsxs)("li", { className: "table-of-contents__count", children: [ 42467 (0, import_i18n178.__)("Headings"), 42468 /* @__PURE__ */ (0, import_jsx_runtime284.jsx)("span", { className: "table-of-contents__number", children: headingCount }) 42469 ] }), 42470 /* @__PURE__ */ (0, import_jsx_runtime284.jsxs)("li", { className: "table-of-contents__count", children: [ 42471 (0, import_i18n178.__)("Paragraphs"), 42472 /* @__PURE__ */ (0, import_jsx_runtime284.jsx)("span", { className: "table-of-contents__number", children: paragraphCount }) 42473 ] }), 42474 /* @__PURE__ */ (0, import_jsx_runtime284.jsxs)("li", { className: "table-of-contents__count", children: [ 42475 (0, import_i18n178.__)("Blocks"), 42476 /* @__PURE__ */ (0, import_jsx_runtime284.jsx)("span", { className: "table-of-contents__number", children: numberOfBlocks }) 42477 ] }) 42478 ] }) 42479 } 42480 ), 42481 headingCount > 0 && /* @__PURE__ */ (0, import_jsx_runtime284.jsxs)(import_jsx_runtime284.Fragment, { children: [ 42482 /* @__PURE__ */ (0, import_jsx_runtime284.jsx)("hr", {}), 42483 /* @__PURE__ */ (0, import_jsx_runtime284.jsx)("h2", { className: "table-of-contents__title", children: (0, import_i18n178.__)("Document Outline") }), 42484 /* @__PURE__ */ (0, import_jsx_runtime284.jsx)( 42485 DocumentOutline, 42486 { 42487 onSelect: onRequestClose, 42488 hasOutlineItemsDisabled 42489 } 42490 ) 42491 ] }) 42492 ] }) 42493 ); 42494 } 42495 var panel_default3 = TableOfContentsPanel; 42496 42497 // packages/editor/build-module/components/table-of-contents/index.js 42498 var import_jsx_runtime285 = __toESM(require_jsx_runtime()); 42499 function TableOfContents({ hasOutlineItemsDisabled, repositionDropdown, ...props }, ref) { 42500 const hasBlocks = (0, import_data172.useSelect)( 42501 (select5) => !!select5(import_block_editor62.store).getBlockCount(), 42502 [] 42503 ); 42504 return /* @__PURE__ */ (0, import_jsx_runtime285.jsx)( 42505 import_components166.Dropdown, 42506 { 42507 popoverProps: { 42508 placement: repositionDropdown ? "right" : "bottom" 42509 }, 42510 className: "table-of-contents", 42511 contentClassName: "table-of-contents__popover", 42512 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime285.jsx)( 42513 import_components166.Button, 42514 { 42515 __next40pxDefaultSize: true, 42516 ...props, 42517 ref, 42518 onClick: hasBlocks ? onToggle : void 0, 42519 icon: info_default, 42520 "aria-expanded": isOpen, 42521 "aria-haspopup": "true", 42522 label: (0, import_i18n179.__)("Details"), 42523 tooltipPosition: "bottom", 42524 "aria-disabled": !hasBlocks 42525 } 42526 ), 42527 renderContent: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime285.jsx)( 42528 panel_default3, 42529 { 42530 onRequestClose: onClose, 42531 hasOutlineItemsDisabled 42532 } 42533 ) 42534 } 42535 ); 42536 } 42537 var table_of_contents_default = (0, import_element132.forwardRef)(TableOfContents); 42538 42539 // packages/editor/build-module/components/unsaved-changes-warning/index.js 42540 var import_i18n180 = __toESM(require_i18n()); 42541 var import_element133 = __toESM(require_element()); 42542 var import_data173 = __toESM(require_data()); 42543 var import_core_data99 = __toESM(require_core_data()); 42544 function UnsavedChangesWarning() { 42545 const { __experimentalGetDirtyEntityRecords } = (0, import_data173.useSelect)(import_core_data99.store); 42546 (0, import_element133.useEffect)(() => { 42547 const warnIfUnsavedChanges = (event) => { 42548 const dirtyEntityRecords = __experimentalGetDirtyEntityRecords(); 42549 if (dirtyEntityRecords.length > 0) { 42550 event.returnValue = (0, import_i18n180.__)( 42551 "You have unsaved changes. If you proceed, they will be lost." 42552 ); 42553 return event.returnValue; 42554 } 42555 }; 42556 window.addEventListener("beforeunload", warnIfUnsavedChanges); 42557 return () => { 42558 window.removeEventListener("beforeunload", warnIfUnsavedChanges); 42559 }; 42560 }, [__experimentalGetDirtyEntityRecords]); 42561 return null; 42562 } 42563 42564 // packages/editor/build-module/components/deprecated.js 42565 var import_deprecated10 = __toESM(require_deprecated()); 42566 var import_element134 = __toESM(require_element()); 42567 var import_block_editor63 = __toESM(require_block_editor()); 42568 var import_server_side_render = __toESM(require_server_side_render()); 42569 var import_jsx_runtime286 = __toESM(require_jsx_runtime()); 42570 function deprecateComponent(name2, Wrapped, staticsToHoist = []) { 42571 const Component6 = (0, import_element134.forwardRef)((props, ref) => { 42572 (0, import_deprecated10.default)("wp.editor." + name2, { 42573 since: "5.3", 42574 alternative: "wp.blockEditor." + name2, 42575 version: "6.2" 42576 }); 42577 return /* @__PURE__ */ (0, import_jsx_runtime286.jsx)(Wrapped, { ref, ...props }); 42578 }); 42579 staticsToHoist.forEach((staticName) => { 42580 Component6[staticName] = deprecateComponent( 42581 name2 + "." + staticName, 42582 Wrapped[staticName] 42583 ); 42584 }); 42585 return Component6; 42586 } 42587 function deprecateFunction(name2, func) { 42588 return (...args) => { 42589 (0, import_deprecated10.default)("wp.editor." + name2, { 42590 since: "5.3", 42591 alternative: "wp.blockEditor." + name2, 42592 version: "6.2" 42593 }); 42594 return func(...args); 42595 }; 42596 } 42597 var RichText = deprecateComponent("RichText", import_block_editor63.RichText, ["Content"]); 42598 RichText.isEmpty = deprecateFunction( 42599 "RichText.isEmpty", 42600 import_block_editor63.RichText.isEmpty 42601 ); 42602 var Autocomplete = deprecateComponent( 42603 "Autocomplete", 42604 import_block_editor63.Autocomplete 42605 ); 42606 var AlignmentToolbar = deprecateComponent( 42607 "AlignmentToolbar", 42608 import_block_editor63.AlignmentToolbar 42609 ); 42610 var BlockAlignmentToolbar = deprecateComponent( 42611 "BlockAlignmentToolbar", 42612 import_block_editor63.BlockAlignmentToolbar 42613 ); 42614 var BlockControls = deprecateComponent( 42615 "BlockControls", 42616 import_block_editor63.BlockControls, 42617 ["Slot"] 42618 ); 42619 var BlockEdit = deprecateComponent("BlockEdit", import_block_editor63.BlockEdit); 42620 var BlockEditorKeyboardShortcuts2 = deprecateComponent( 42621 "BlockEditorKeyboardShortcuts", 42622 import_block_editor63.BlockEditorKeyboardShortcuts 42623 ); 42624 var BlockFormatControls = deprecateComponent( 42625 "BlockFormatControls", 42626 import_block_editor63.BlockFormatControls, 42627 ["Slot"] 42628 ); 42629 var BlockIcon3 = deprecateComponent("BlockIcon", import_block_editor63.BlockIcon); 42630 var BlockInspector = deprecateComponent( 42631 "BlockInspector", 42632 import_block_editor63.BlockInspector 42633 ); 42634 var BlockList4 = deprecateComponent("BlockList", import_block_editor63.BlockList); 42635 var BlockMover = deprecateComponent("BlockMover", import_block_editor63.BlockMover); 42636 var BlockNavigationDropdown = deprecateComponent( 42637 "BlockNavigationDropdown", 42638 import_block_editor63.BlockNavigationDropdown 42639 ); 42640 var BlockSelectionClearer = deprecateComponent( 42641 "BlockSelectionClearer", 42642 import_block_editor63.BlockSelectionClearer 42643 ); 42644 var BlockSettingsMenu = deprecateComponent( 42645 "BlockSettingsMenu", 42646 import_block_editor63.BlockSettingsMenu 42647 ); 42648 var BlockTitle = deprecateComponent("BlockTitle", import_block_editor63.BlockTitle); 42649 var BlockToolbar = deprecateComponent( 42650 "BlockToolbar", 42651 import_block_editor63.BlockToolbar 42652 ); 42653 var ColorPalette2 = deprecateComponent( 42654 "ColorPalette", 42655 import_block_editor63.ColorPalette 42656 ); 42657 var ContrastChecker = deprecateComponent( 42658 "ContrastChecker", 42659 import_block_editor63.ContrastChecker 42660 ); 42661 var CopyHandler = deprecateComponent("CopyHandler", import_block_editor63.CopyHandler); 42662 var DefaultBlockAppender = deprecateComponent( 42663 "DefaultBlockAppender", 42664 import_block_editor63.DefaultBlockAppender 42665 ); 42666 var FontSizePicker = deprecateComponent( 42667 "FontSizePicker", 42668 import_block_editor63.FontSizePicker 42669 ); 42670 var Inserter = deprecateComponent("Inserter", import_block_editor63.Inserter); 42671 var InnerBlocks = deprecateComponent("InnerBlocks", import_block_editor63.InnerBlocks, [ 42672 "ButtonBlockAppender", 42673 "DefaultBlockAppender", 42674 "Content" 42675 ]); 42676 var InspectorAdvancedControls = deprecateComponent( 42677 "InspectorAdvancedControls", 42678 import_block_editor63.InspectorAdvancedControls, 42679 ["Slot"] 42680 ); 42681 var InspectorControls = deprecateComponent( 42682 "InspectorControls", 42683 import_block_editor63.InspectorControls, 42684 ["Slot"] 42685 ); 42686 var PanelColorSettings = deprecateComponent( 42687 "PanelColorSettings", 42688 import_block_editor63.PanelColorSettings 42689 ); 42690 var PlainText = deprecateComponent("PlainText", import_block_editor63.PlainText); 42691 var RichTextShortcut = deprecateComponent( 42692 "RichTextShortcut", 42693 import_block_editor63.RichTextShortcut 42694 ); 42695 var RichTextToolbarButton = deprecateComponent( 42696 "RichTextToolbarButton", 42697 import_block_editor63.RichTextToolbarButton 42698 ); 42699 var __unstableRichTextInputEvent = deprecateComponent( 42700 "__unstableRichTextInputEvent", 42701 import_block_editor63.__unstableRichTextInputEvent 42702 ); 42703 var MediaPlaceholder = deprecateComponent( 42704 "MediaPlaceholder", 42705 import_block_editor63.MediaPlaceholder 42706 ); 42707 var MediaUpload3 = deprecateComponent("MediaUpload", import_block_editor63.MediaUpload); 42708 var MediaUploadCheck2 = deprecateComponent( 42709 "MediaUploadCheck", 42710 import_block_editor63.MediaUploadCheck 42711 ); 42712 var MultiSelectScrollIntoView = deprecateComponent( 42713 "MultiSelectScrollIntoView", 42714 import_block_editor63.MultiSelectScrollIntoView 42715 ); 42716 var NavigableToolbar = deprecateComponent( 42717 "NavigableToolbar", 42718 import_block_editor63.NavigableToolbar 42719 ); 42720 var ObserveTyping = deprecateComponent( 42721 "ObserveTyping", 42722 import_block_editor63.ObserveTyping 42723 ); 42724 var SkipToSelectedBlock = deprecateComponent( 42725 "SkipToSelectedBlock", 42726 import_block_editor63.SkipToSelectedBlock 42727 ); 42728 var URLInput = deprecateComponent("URLInput", import_block_editor63.URLInput); 42729 var URLInputButton = deprecateComponent( 42730 "URLInputButton", 42731 import_block_editor63.URLInputButton 42732 ); 42733 var URLPopover = deprecateComponent("URLPopover", import_block_editor63.URLPopover); 42734 var Warning = deprecateComponent("Warning", import_block_editor63.Warning); 42735 var WritingFlow = deprecateComponent("WritingFlow", import_block_editor63.WritingFlow); 42736 var createCustomColorsHOC = deprecateFunction( 42737 "createCustomColorsHOC", 42738 import_block_editor63.createCustomColorsHOC 42739 ); 42740 var getColorClassName2 = deprecateFunction( 42741 "getColorClassName", 42742 import_block_editor63.getColorClassName 42743 ); 42744 var getColorObjectByAttributeValues = deprecateFunction( 42745 "getColorObjectByAttributeValues", 42746 import_block_editor63.getColorObjectByAttributeValues 42747 ); 42748 var getColorObjectByColorValue = deprecateFunction( 42749 "getColorObjectByColorValue", 42750 import_block_editor63.getColorObjectByColorValue 42751 ); 42752 var getFontSize = deprecateFunction("getFontSize", import_block_editor63.getFontSize); 42753 var getFontSizeClass = deprecateFunction( 42754 "getFontSizeClass", 42755 import_block_editor63.getFontSizeClass 42756 ); 42757 var withColorContext = deprecateFunction( 42758 "withColorContext", 42759 import_block_editor63.withColorContext 42760 ); 42761 var withColors = deprecateFunction("withColors", import_block_editor63.withColors); 42762 var withFontSizes = deprecateFunction( 42763 "withFontSizes", 42764 import_block_editor63.withFontSizes 42765 ); 42766 42767 // packages/editor/build-module/components/index.js 42768 var VisualEditorGlobalKeyboardShortcuts = EditorKeyboardShortcuts; 42769 var TextEditorGlobalKeyboardShortcuts = EditorKeyboardShortcuts; 42770 42771 // packages/editor/build-module/hooks/default-autocompleters.js 42772 function setDefaultCompleters(completers = []) { 42773 completers.push({ ...user_default }); 42774 return completers; 42775 } 42776 (0, import_hooks47.addFilter)( 42777 "editor.Autocomplete.completers", 42778 "editor/autocompleters/set-default-completers", 42779 setDefaultCompleters 42780 ); 42781 42782 // packages/editor/build-module/hooks/media-upload.js 42783 var import_element135 = __toESM(require_element()); 42784 var import_hooks48 = __toESM(require_hooks()); 42785 var import_deprecated11 = __toESM(require_deprecated()); 42786 var import_media_utils6 = __toESM(require_media_utils()); 42787 var import_jsx_runtime287 = __toESM(require_jsx_runtime()); 42788 var { MediaUploadModal: MediaUploadModalComponent } = unlock( 42789 import_media_utils6.privateApis 42790 ); 42791 var MediaUploadModalWrapper = class extends import_element135.Component { 42792 constructor(props) { 42793 super(props); 42794 this.state = { 42795 isOpen: false 42796 }; 42797 this.openModal = this.openModal.bind(this); 42798 this.closeModal = this.closeModal.bind(this); 42799 } 42800 openModal() { 42801 this.setState({ isOpen: true }); 42802 } 42803 closeModal() { 42804 this.setState({ isOpen: false }); 42805 this.props.onClose?.(); 42806 } 42807 render() { 42808 const { 42809 allowedTypes, 42810 multiple, 42811 value, 42812 onSelect, 42813 title, 42814 modalClass, 42815 render 42816 } = this.props; 42817 const { isOpen } = this.state; 42818 return /* @__PURE__ */ (0, import_jsx_runtime287.jsxs)(import_jsx_runtime287.Fragment, { children: [ 42819 render({ open: this.openModal }), 42820 /* @__PURE__ */ (0, import_jsx_runtime287.jsx)( 42821 MediaUploadModalComponent, 42822 { 42823 allowedTypes, 42824 multiple, 42825 value, 42826 onSelect: (media) => { 42827 onSelect(media); 42828 this.closeModal(); 42829 }, 42830 onClose: this.closeModal, 42831 title, 42832 isOpen, 42833 modalClass 42834 } 42835 ) 42836 ] }); 42837 } 42838 }; 42839 if (window.__experimentalDataViewsMediaModal) { 42840 (0, import_hooks48.addFilter)( 42841 "editor.MediaUpload", 42842 "core/editor/components/media-upload", 42843 () => { 42844 (0, import_deprecated11.default)("Extending MediaUpload as a class component", { 42845 since: "7.0", 42846 version: "7.2", 42847 hint: "MediaUpload will become a function component in WordPress 7.2 Please update any custom implementations to use function components instead." 42848 }); 42849 return MediaUploadModalWrapper; 42850 } 42851 ); 42852 } else { 42853 (0, import_hooks48.addFilter)( 42854 "editor.MediaUpload", 42855 "core/editor/components/media-upload", 42856 () => { 42857 return import_media_utils6.MediaUpload; 42858 } 42859 ); 42860 } 42861 42862 // packages/editor/build-module/hooks/pattern-overrides.js 42863 var import_hooks49 = __toESM(require_hooks()); 42864 var import_patterns8 = __toESM(require_patterns()); 42865 var import_compose41 = __toESM(require_compose()); 42866 var import_block_editor64 = __toESM(require_block_editor()); 42867 var import_data174 = __toESM(require_data()); 42868 var import_blocks28 = __toESM(require_blocks()); 42869 var import_jsx_runtime288 = __toESM(require_jsx_runtime()); 42870 var { 42871 PatternOverridesControls, 42872 ResetOverridesControl, 42873 PATTERN_TYPES: PATTERN_TYPES4, 42874 PARTIAL_SYNCING_SUPPORTED_BLOCKS, 42875 PATTERN_SYNC_TYPES 42876 } = unlock(import_patterns8.privateApis); 42877 var withPatternOverrideControls = (0, import_compose41.createHigherOrderComponent)( 42878 (BlockEdit2) => (props) => { 42879 const isSupportedBlock = !!PARTIAL_SYNCING_SUPPORTED_BLOCKS[props.name]; 42880 return /* @__PURE__ */ (0, import_jsx_runtime288.jsxs)(import_jsx_runtime288.Fragment, { children: [ 42881 /* @__PURE__ */ (0, import_jsx_runtime288.jsx)(BlockEdit2, { ...props }, "edit"), 42882 props.isSelected && isSupportedBlock && /* @__PURE__ */ (0, import_jsx_runtime288.jsx)(ControlsWithStoreSubscription, { ...props }) 42883 ] }); 42884 }, 42885 "withPatternOverrideControls" 42886 ); 42887 function ControlsWithStoreSubscription(props) { 42888 const blockEditingMode = (0, import_block_editor64.useBlockEditingMode)(); 42889 const { hasPatternOverridesSource, isEditingSyncedPattern } = (0, import_data174.useSelect)( 42890 (select5) => { 42891 const { getCurrentPostType: getCurrentPostType2, getEditedPostAttribute: getEditedPostAttribute2 } = select5(store); 42892 return { 42893 // For editing link to the site editor if the theme and user permissions support it. 42894 hasPatternOverridesSource: !!(0, import_blocks28.getBlockBindingsSource)( 42895 "core/pattern-overrides" 42896 ), 42897 isEditingSyncedPattern: getCurrentPostType2() === PATTERN_TYPES4.user && getEditedPostAttribute2("meta")?.wp_pattern_sync_status !== PATTERN_SYNC_TYPES.unsynced && getEditedPostAttribute2("wp_pattern_sync_status") !== PATTERN_SYNC_TYPES.unsynced 42898 }; 42899 }, 42900 [] 42901 ); 42902 const bindings = props.attributes.metadata?.bindings; 42903 const hasPatternBindings = !!bindings && Object.values(bindings).some( 42904 (binding) => binding.source === "core/pattern-overrides" 42905 ); 42906 const shouldShowPatternOverridesControls = isEditingSyncedPattern && blockEditingMode === "default"; 42907 const shouldShowResetOverridesControl = !isEditingSyncedPattern && !!props.attributes.metadata?.name && blockEditingMode !== "disabled" && hasPatternBindings; 42908 if (!hasPatternOverridesSource) { 42909 return null; 42910 } 42911 return /* @__PURE__ */ (0, import_jsx_runtime288.jsxs)(import_jsx_runtime288.Fragment, { children: [ 42912 shouldShowPatternOverridesControls && /* @__PURE__ */ (0, import_jsx_runtime288.jsx)(PatternOverridesControls, { ...props }), 42913 shouldShowResetOverridesControl && /* @__PURE__ */ (0, import_jsx_runtime288.jsx)(ResetOverridesControl, { ...props }) 42914 ] }); 42915 } 42916 (0, import_hooks49.addFilter)( 42917 "editor.BlockEdit", 42918 "core/editor/with-pattern-override-controls", 42919 withPatternOverrideControls 42920 ); 42921 42922 // packages/editor/build-module/hooks/navigation-link-view-button.js 42923 var import_hooks50 = __toESM(require_hooks()); 42924 var import_compose42 = __toESM(require_compose()); 42925 var import_element136 = __toESM(require_element()); 42926 var import_i18n181 = __toESM(require_i18n()); 42927 var import_block_editor65 = __toESM(require_block_editor()); 42928 var import_components168 = __toESM(require_components()); 42929 var import_data175 = __toESM(require_data()); 42930 var import_jsx_runtime289 = __toESM(require_jsx_runtime()); 42931 var SUPPORTED_BLOCKS = ["core/navigation-link", "core/navigation-submenu"]; 42932 function NavigationViewButton({ attributes }) { 42933 const { kind, id, type } = attributes; 42934 const blockEditingMode = (0, import_block_editor65.useBlockEditingMode)(); 42935 const onNavigateToEntityRecord = (0, import_data175.useSelect)( 42936 (select5) => select5(import_block_editor65.store).getSettings().onNavigateToEntityRecord, 42937 [] 42938 ); 42939 const onViewPage = (0, import_element136.useCallback)(() => { 42940 if (kind === "post-type" && type === "page" && id && onNavigateToEntityRecord) { 42941 onNavigateToEntityRecord({ 42942 postId: id, 42943 postType: type 42944 }); 42945 } 42946 }, [kind, id, type, onNavigateToEntityRecord]); 42947 if (kind !== "post-type" || type !== "page" || !id || !onNavigateToEntityRecord || blockEditingMode !== "contentOnly") { 42948 return null; 42949 } 42950 return /* @__PURE__ */ (0, import_jsx_runtime289.jsx)(import_block_editor65.__unstableBlockToolbarLastItem, { children: /* @__PURE__ */ (0, import_jsx_runtime289.jsx)(import_components168.ToolbarGroup, { children: /* @__PURE__ */ (0, import_jsx_runtime289.jsx)( 42951 import_components168.ToolbarButton, 42952 { 42953 name: "view", 42954 title: (0, import_i18n181.__)("View"), 42955 onClick: onViewPage, 42956 children: (0, import_i18n181.__)("View") 42957 } 42958 ) }) }); 42959 } 42960 var withNavigationViewButton = (0, import_compose42.createHigherOrderComponent)( 42961 (BlockEdit2) => (props) => { 42962 const isSupportedBlock = SUPPORTED_BLOCKS.includes(props.name); 42963 return /* @__PURE__ */ (0, import_jsx_runtime289.jsxs)(import_jsx_runtime289.Fragment, { children: [ 42964 /* @__PURE__ */ (0, import_jsx_runtime289.jsx)(BlockEdit2, { ...props }, "edit"), 42965 props.isSelected && isSupportedBlock && /* @__PURE__ */ (0, import_jsx_runtime289.jsx)(NavigationViewButton, { ...props }) 42966 ] }); 42967 }, 42968 "withNavigationViewButton" 42969 ); 42970 (0, import_hooks50.addFilter)( 42971 "editor.BlockEdit", 42972 "core/editor/with-navigation-view-button", 42973 withNavigationViewButton 42974 ); 42975 42976 // packages/editor/build-module/hooks/template-part-navigation-edit-button.js 42977 var import_hooks51 = __toESM(require_hooks()); 42978 var import_compose43 = __toESM(require_compose()); 42979 var import_element137 = __toESM(require_element()); 42980 var import_i18n182 = __toESM(require_i18n()); 42981 var import_block_editor66 = __toESM(require_block_editor()); 42982 var import_components169 = __toESM(require_components()); 42983 var import_data176 = __toESM(require_data()); 42984 var import_jsx_runtime290 = __toESM(require_jsx_runtime()); 42985 var NAVIGATION_BLOCK_NAME = "core/navigation"; 42986 var TEMPLATE_PART_BLOCK_NAME = "core/template-part"; 42987 var BLOCK_INSPECTOR_AREA = "edit-post/block"; 42988 function TemplatePartNavigationEditButton({ clientId }) { 42989 const { selectBlock: selectBlock2, flashBlock } = (0, import_data176.useDispatch)(import_block_editor66.store); 42990 const { enableComplementaryArea: enableComplementaryArea2 } = (0, import_data176.useDispatch)(store2); 42991 const { 42992 hasNavigationBlocks, 42993 firstNavigationBlockId, 42994 isNavigationEditable 42995 } = (0, import_data176.useSelect)( 42996 (select5) => { 42997 const { 42998 getClientIdsOfDescendants: getClientIdsOfDescendants2, 42999 getBlockName: getBlockName2, 43000 getBlockEditingMode 43001 } = select5(import_block_editor66.store); 43002 const descendants = getClientIdsOfDescendants2(clientId); 43003 const navigationBlocksInTemplatePart = descendants.filter( 43004 (blockId) => getBlockName2(blockId) === NAVIGATION_BLOCK_NAME 43005 ); 43006 const _hasNavigationBlocks = navigationBlocksInTemplatePart.length > 0; 43007 const _firstNavigationBlockId = _hasNavigationBlocks ? navigationBlocksInTemplatePart[0] : null; 43008 return { 43009 hasNavigationBlocks: _hasNavigationBlocks, 43010 firstNavigationBlockId: _firstNavigationBlockId, 43011 // We can't use the useBlockEditingMode hook here because the current 43012 // context is the template part, not the navigation block. 43013 isNavigationEditable: getBlockEditingMode(_firstNavigationBlockId) !== "disabled" 43014 }; 43015 }, 43016 [clientId] 43017 ); 43018 const onEditNavigation = (0, import_element137.useCallback)(() => { 43019 if (firstNavigationBlockId) { 43020 selectBlock2(firstNavigationBlockId); 43021 flashBlock(firstNavigationBlockId, 500); 43022 enableComplementaryArea2("core", BLOCK_INSPECTOR_AREA); 43023 } 43024 }, [ 43025 firstNavigationBlockId, 43026 selectBlock2, 43027 flashBlock, 43028 enableComplementaryArea2 43029 ]); 43030 if (!hasNavigationBlocks || !isNavigationEditable) { 43031 return null; 43032 } 43033 return /* @__PURE__ */ (0, import_jsx_runtime290.jsx)(import_block_editor66.__unstableBlockToolbarLastItem, { children: /* @__PURE__ */ (0, import_jsx_runtime290.jsx)(import_components169.ToolbarGroup, { children: /* @__PURE__ */ (0, import_jsx_runtime290.jsx)( 43034 import_components169.ToolbarButton, 43035 { 43036 label: (0, import_i18n182.__)("Edit navigation"), 43037 onClick: onEditNavigation, 43038 children: (0, import_i18n182.__)("Edit navigation") 43039 } 43040 ) }) }); 43041 } 43042 var withTemplatePartNavigationEditButton = (0, import_compose43.createHigherOrderComponent)( 43043 (BlockEdit2) => (props) => { 43044 const isTemplatePart2 = props.name === TEMPLATE_PART_BLOCK_NAME; 43045 return /* @__PURE__ */ (0, import_jsx_runtime290.jsxs)(import_jsx_runtime290.Fragment, { children: [ 43046 /* @__PURE__ */ (0, import_jsx_runtime290.jsx)(BlockEdit2, { ...props }, "edit"), 43047 props.isSelected && isTemplatePart2 && /* @__PURE__ */ (0, import_jsx_runtime290.jsx)( 43048 TemplatePartNavigationEditButton, 43049 { 43050 clientId: props.clientId 43051 } 43052 ) 43053 ] }); 43054 }, 43055 "withTemplatePartNavigationEditButton" 43056 ); 43057 (0, import_hooks51.addFilter)( 43058 "editor.BlockEdit", 43059 "core/editor/with-template-part-navigation-edit-button", 43060 withTemplatePartNavigationEditButton 43061 ); 43062 43063 // packages/editor/build-module/hooks/push-changes-to-global-styles/index.js 43064 var import_hooks52 = __toESM(require_hooks()); 43065 var import_compose44 = __toESM(require_compose()); 43066 var import_block_editor67 = __toESM(require_block_editor()); 43067 var import_components170 = __toESM(require_components()); 43068 var import_i18n183 = __toESM(require_i18n()); 43069 var import_blocks29 = __toESM(require_blocks()); 43070 var import_element138 = __toESM(require_element()); 43071 var import_data177 = __toESM(require_data()); 43072 var import_notices25 = __toESM(require_notices()); 43073 var import_core_data100 = __toESM(require_core_data()); 43074 43075 // packages/editor/build-module/utils/set-nested-value.js 43076 function setNestedValue(object, path, value) { 43077 if (!object || typeof object !== "object") { 43078 return object; 43079 } 43080 path.reduce((acc, key, idx) => { 43081 if (acc[key] === void 0) { 43082 if (Number.isInteger(path[idx + 1])) { 43083 acc[key] = []; 43084 } else { 43085 acc[key] = {}; 43086 } 43087 } 43088 if (idx === path.length - 1) { 43089 acc[key] = value; 43090 } 43091 return acc[key]; 43092 }, object); 43093 return object; 43094 } 43095 43096 // packages/editor/build-module/hooks/push-changes-to-global-styles/index.js 43097 var import_jsx_runtime291 = __toESM(require_jsx_runtime()); 43098 var { cleanEmptyObject: cleanEmptyObject3 } = unlock(import_block_editor67.privateApis); 43099 var STYLE_PROPERTY2 = { 43100 ...import_blocks29.__EXPERIMENTAL_STYLE_PROPERTY, 43101 blockGap: { value: ["spacing", "blockGap"] } 43102 }; 43103 var STYLE_PATH_TO_CSS_VAR_INFIX = { 43104 "border.color": "color", 43105 "color.background": "color", 43106 "color.text": "color", 43107 "elements.link.color.text": "color", 43108 "elements.link.:hover.color.text": "color", 43109 "elements.link.typography.fontFamily": "font-family", 43110 "elements.link.typography.fontSize": "font-size", 43111 "elements.button.color.text": "color", 43112 "elements.button.color.background": "color", 43113 "elements.button.typography.fontFamily": "font-family", 43114 "elements.button.typography.fontSize": "font-size", 43115 "elements.caption.color.text": "color", 43116 "elements.heading.color": "color", 43117 "elements.heading.color.background": "color", 43118 "elements.heading.typography.fontFamily": "font-family", 43119 "elements.heading.gradient": "gradient", 43120 "elements.heading.color.gradient": "gradient", 43121 "elements.h1.color": "color", 43122 "elements.h1.color.background": "color", 43123 "elements.h1.typography.fontFamily": "font-family", 43124 "elements.h1.color.gradient": "gradient", 43125 "elements.h2.color": "color", 43126 "elements.h2.color.background": "color", 43127 "elements.h2.typography.fontFamily": "font-family", 43128 "elements.h2.color.gradient": "gradient", 43129 "elements.h3.color": "color", 43130 "elements.h3.color.background": "color", 43131 "elements.h3.typography.fontFamily": "font-family", 43132 "elements.h3.color.gradient": "gradient", 43133 "elements.h4.color": "color", 43134 "elements.h4.color.background": "color", 43135 "elements.h4.typography.fontFamily": "font-family", 43136 "elements.h4.color.gradient": "gradient", 43137 "elements.h5.color": "color", 43138 "elements.h5.color.background": "color", 43139 "elements.h5.typography.fontFamily": "font-family", 43140 "elements.h5.color.gradient": "gradient", 43141 "elements.h6.color": "color", 43142 "elements.h6.color.background": "color", 43143 "elements.h6.typography.fontFamily": "font-family", 43144 "elements.h6.color.gradient": "gradient", 43145 "color.gradient": "gradient", 43146 blockGap: "spacing", 43147 "typography.fontSize": "font-size", 43148 "typography.fontFamily": "font-family" 43149 }; 43150 var STYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE = { 43151 "border.color": "borderColor", 43152 "color.background": "backgroundColor", 43153 "color.text": "textColor", 43154 "color.gradient": "gradient", 43155 "typography.fontSize": "fontSize", 43156 "typography.fontFamily": "fontFamily" 43157 }; 43158 var SUPPORTED_STYLES = ["border", "color", "spacing", "typography"]; 43159 var getValueFromObjectPath2 = (object, path) => { 43160 let value = object; 43161 path.forEach((fieldName) => { 43162 value = value?.[fieldName]; 43163 }); 43164 return value; 43165 }; 43166 var flatBorderProperties = ["borderColor", "borderWidth", "borderStyle"]; 43167 var sides = ["top", "right", "bottom", "left"]; 43168 function getBorderStyleChanges(border, presetColor, userStyle) { 43169 if (!border && !presetColor) { 43170 return []; 43171 } 43172 const changes = [ 43173 ...getFallbackBorderStyleChange("top", border, userStyle), 43174 ...getFallbackBorderStyleChange("right", border, userStyle), 43175 ...getFallbackBorderStyleChange("bottom", border, userStyle), 43176 ...getFallbackBorderStyleChange("left", border, userStyle) 43177 ]; 43178 const { color: customColor, style, width } = border || {}; 43179 const hasColorOrWidth = presetColor || customColor || width; 43180 if (hasColorOrWidth && !style) { 43181 sides.forEach((side) => { 43182 if (!userStyle?.[side]?.style) { 43183 changes.push({ 43184 path: ["border", side, "style"], 43185 value: "solid" 43186 }); 43187 } 43188 }); 43189 } 43190 return changes; 43191 } 43192 function getFallbackBorderStyleChange(side, border, globalBorderStyle) { 43193 if (!border?.[side] || globalBorderStyle?.[side]?.style) { 43194 return []; 43195 } 43196 const { color, style, width } = border[side]; 43197 const hasColorOrWidth = color || width; 43198 if (!hasColorOrWidth || style) { 43199 return []; 43200 } 43201 return [{ path: ["border", side, "style"], value: "solid" }]; 43202 } 43203 function useChangesToPush(name2, attributes, userConfig) { 43204 const supports = (0, import_data177.useSelect)( 43205 (select5) => { 43206 return unlock(select5(import_blocks29.store)).getSupportedStyles(name2); 43207 }, 43208 [name2] 43209 ); 43210 const blockUserConfig = userConfig?.styles?.blocks?.[name2]; 43211 return (0, import_element138.useMemo)(() => { 43212 const changes = supports.flatMap((key) => { 43213 if (!STYLE_PROPERTY2[key]) { 43214 return []; 43215 } 43216 const { value: path } = STYLE_PROPERTY2[key]; 43217 const presetAttributeKey = path.join("."); 43218 const presetAttributeValue = attributes[STYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE[presetAttributeKey]]; 43219 const value = presetAttributeValue ? `var:preset|$STYLE_PATH_TO_CSS_VAR_INFIX[presetAttributeKey]}|$presetAttributeValue}` : getValueFromObjectPath2(attributes.style, path); 43220 if (key === "linkColor") { 43221 const linkChanges = value ? [{ path, value }] : []; 43222 const hoverPath = [ 43223 "elements", 43224 "link", 43225 ":hover", 43226 "color", 43227 "text" 43228 ]; 43229 const hoverValue = getValueFromObjectPath2( 43230 attributes.style, 43231 hoverPath 43232 ); 43233 if (hoverValue) { 43234 linkChanges.push({ path: hoverPath, value: hoverValue }); 43235 } 43236 return linkChanges; 43237 } 43238 if (flatBorderProperties.includes(key) && value) { 43239 const borderChanges = [{ path, value }]; 43240 sides.forEach((side) => { 43241 const currentPath = [...path]; 43242 currentPath.splice(-1, 0, side); 43243 borderChanges.push({ path: currentPath, value }); 43244 }); 43245 return borderChanges; 43246 } 43247 return value ? [{ path, value }] : []; 43248 }); 43249 getBorderStyleChanges( 43250 attributes.style?.border, 43251 attributes.borderColor, 43252 blockUserConfig?.border 43253 ).forEach((change) => changes.push(change)); 43254 return changes; 43255 }, [supports, attributes, blockUserConfig]); 43256 } 43257 function PushChangesToGlobalStylesControl({ 43258 name: name2, 43259 attributes, 43260 setAttributes 43261 }) { 43262 const { user: userConfig, setUser: setUserConfig } = useGlobalStyles(); 43263 const changes = useChangesToPush(name2, attributes, userConfig); 43264 const { __unstableMarkNextChangeAsNotPersistent } = (0, import_data177.useDispatch)(import_block_editor67.store); 43265 const { createSuccessNotice } = (0, import_data177.useDispatch)(import_notices25.store); 43266 const pushChanges = (0, import_element138.useCallback)(() => { 43267 if (changes.length === 0) { 43268 return; 43269 } 43270 if (changes.length > 0) { 43271 const { style: blockStyles } = attributes; 43272 const newBlockStyles = structuredClone(blockStyles); 43273 const newUserConfig = structuredClone(userConfig); 43274 for (const { path, value } of changes) { 43275 setNestedValue(newBlockStyles, path, void 0); 43276 setNestedValue( 43277 newUserConfig, 43278 ["styles", "blocks", name2, ...path], 43279 value 43280 ); 43281 } 43282 const newBlockAttributes = { 43283 borderColor: void 0, 43284 backgroundColor: void 0, 43285 textColor: void 0, 43286 gradient: void 0, 43287 fontSize: void 0, 43288 fontFamily: void 0, 43289 style: cleanEmptyObject3(newBlockStyles) 43290 }; 43291 __unstableMarkNextChangeAsNotPersistent(); 43292 setAttributes(newBlockAttributes); 43293 setUserConfig(newUserConfig, { undoIgnore: true }); 43294 createSuccessNotice( 43295 (0, import_i18n183.sprintf)( 43296 // translators: %s: Title of the block e.g. 'Heading'. 43297 (0, import_i18n183.__)("%s styles applied."), 43298 (0, import_blocks29.getBlockType)(name2).title 43299 ), 43300 { 43301 type: "snackbar", 43302 actions: [ 43303 { 43304 label: (0, import_i18n183.__)("Undo"), 43305 onClick() { 43306 __unstableMarkNextChangeAsNotPersistent(); 43307 setAttributes(attributes); 43308 setUserConfig(userConfig, { 43309 undoIgnore: true 43310 }); 43311 } 43312 } 43313 ] 43314 } 43315 ); 43316 } 43317 }, [ 43318 __unstableMarkNextChangeAsNotPersistent, 43319 attributes, 43320 changes, 43321 createSuccessNotice, 43322 name2, 43323 setAttributes, 43324 setUserConfig, 43325 userConfig 43326 ]); 43327 return /* @__PURE__ */ (0, import_jsx_runtime291.jsxs)( 43328 import_components170.BaseControl, 43329 { 43330 className: "editor-push-changes-to-global-styles-control", 43331 help: (0, import_i18n183.sprintf)( 43332 // translators: %s: Title of the block e.g. 'Heading'. 43333 (0, import_i18n183.__)( 43334 "Apply this block\u2019s typography, spacing, dimensions, and color styles to all %s blocks." 43335 ), 43336 (0, import_blocks29.getBlockType)(name2).title 43337 ), 43338 children: [ 43339 /* @__PURE__ */ (0, import_jsx_runtime291.jsx)(import_components170.BaseControl.VisualLabel, { children: (0, import_i18n183.__)("Styles") }), 43340 /* @__PURE__ */ (0, import_jsx_runtime291.jsx)( 43341 import_components170.Button, 43342 { 43343 __next40pxDefaultSize: true, 43344 variant: "secondary", 43345 accessibleWhenDisabled: true, 43346 disabled: changes.length === 0, 43347 onClick: pushChanges, 43348 children: (0, import_i18n183.__)("Apply globally") 43349 } 43350 ) 43351 ] 43352 } 43353 ); 43354 } 43355 function PushChangesToGlobalStyles(props) { 43356 const blockEditingMode = (0, import_block_editor67.useBlockEditingMode)(); 43357 const isBlockBasedTheme = (0, import_data177.useSelect)( 43358 (select5) => select5(import_core_data100.store).getCurrentTheme()?.is_block_theme, 43359 [] 43360 ); 43361 const supportsStyles = SUPPORTED_STYLES.some( 43362 (feature) => (0, import_blocks29.hasBlockSupport)(props.name, feature) 43363 ); 43364 const isDisplayed = blockEditingMode === "default" && supportsStyles && isBlockBasedTheme; 43365 if (!isDisplayed) { 43366 return null; 43367 } 43368 return /* @__PURE__ */ (0, import_jsx_runtime291.jsx)(import_block_editor67.InspectorAdvancedControls, { children: /* @__PURE__ */ (0, import_jsx_runtime291.jsx)(PushChangesToGlobalStylesControl, { ...props }) }); 43369 } 43370 var withPushChangesToGlobalStyles = (0, import_compose44.createHigherOrderComponent)( 43371 (BlockEdit2) => (props) => /* @__PURE__ */ (0, import_jsx_runtime291.jsxs)(import_jsx_runtime291.Fragment, { children: [ 43372 /* @__PURE__ */ (0, import_jsx_runtime291.jsx)(BlockEdit2, { ...props }, "edit"), 43373 props.isSelected && /* @__PURE__ */ (0, import_jsx_runtime291.jsx)(PushChangesToGlobalStyles, { ...props }) 43374 ] }) 43375 ); 43376 (0, import_hooks52.addFilter)( 43377 "editor.BlockEdit", 43378 "core/editor/push-changes-to-global-styles", 43379 withPushChangesToGlobalStyles 43380 ); 43381 43382 // packages/editor/build-module/components/header/back-button.js 43383 var import_components171 = __toESM(require_components()); 43384 var import_jsx_runtime292 = __toESM(require_jsx_runtime()); 43385 var slotName = "__experimentalMainDashboardButton"; 43386 var useHasBackButton = () => { 43387 const fills = (0, import_components171.__experimentalUseSlotFills)(slotName); 43388 return Boolean(fills && fills.length); 43389 }; 43390 var { Fill: Fill10, Slot: Slot10 } = (0, import_components171.createSlotFill)(slotName); 43391 var BackButton = Fill10; 43392 var BackButtonSlot = () => { 43393 const fills = (0, import_components171.__experimentalUseSlotFills)(slotName); 43394 return /* @__PURE__ */ (0, import_jsx_runtime292.jsx)( 43395 Slot10, 43396 { 43397 bubblesVirtually: true, 43398 fillProps: { length: !fills ? 0 : fills.length } 43399 } 43400 ); 43401 }; 43402 BackButton.Slot = BackButtonSlot; 43403 var back_button_default = BackButton; 43404 43405 // packages/editor/build-module/components/editor/index.js 43406 var import_data229 = __toESM(require_data()); 43407 var import_core_data121 = __toESM(require_core_data()); 43408 var import_components214 = __toESM(require_components()); 43409 var import_i18n225 = __toESM(require_i18n()); 43410 var import_element174 = __toESM(require_element()); 43411 var import_block_editor98 = __toESM(require_block_editor()); 43412 43413 // packages/editor/build-module/utils/block-selection-path.js 43414 var import_data178 = __toESM(require_data()); 43415 var import_element139 = __toESM(require_element()); 43416 var import_block_editor68 = __toESM(require_block_editor()); 43417 function useGenerateBlockPath() { 43418 const registry = (0, import_data178.useRegistry)(); 43419 return (0, import_element139.useCallback)( 43420 (clientId) => { 43421 const { getBlock: getBlock2, getBlockParents, getBlockOrder: getBlockOrder2 } = registry.select(import_block_editor68.store); 43422 const block = getBlock2(clientId); 43423 if (!block) { 43424 return null; 43425 } 43426 const parents = getBlockParents(clientId); 43427 const path = []; 43428 const hierarchy = [...parents, clientId]; 43429 for (let i3 = 0; i3 < hierarchy.length; i3++) { 43430 const currentClientId = hierarchy[i3]; 43431 const currentBlock = getBlock2(currentClientId); 43432 if (!currentBlock) { 43433 return null; 43434 } 43435 const parentClientId = i3 > 0 ? hierarchy[i3 - 1] : ""; 43436 const siblings = getBlockOrder2(parentClientId); 43437 const index2 = siblings.indexOf(currentClientId); 43438 if (index2 === -1) { 43439 return null; 43440 } 43441 path.push({ 43442 blockName: currentBlock.name, 43443 index: index2, 43444 // Store a simple content hash for verification (first 100 chars of serialized content) 43445 contentHash: JSON.stringify( 43446 currentBlock.attributes 43447 ).slice(0, 100) 43448 }); 43449 } 43450 return path; 43451 }, 43452 [registry] 43453 ); 43454 } 43455 function useRestoreBlockFromPath() { 43456 const registry = (0, import_data178.useRegistry)(); 43457 return (0, import_element139.useCallback)( 43458 (path) => { 43459 if (!path || !Array.isArray(path) || path.length === 0) { 43460 return null; 43461 } 43462 const { getBlock: getBlock2, getBlockOrder: getBlockOrder2 } = registry.select(import_block_editor68.store); 43463 let currentParentId = ""; 43464 for (let i3 = 0; i3 < path.length; i3++) { 43465 const step = path[i3]; 43466 const siblings = getBlockOrder2(currentParentId); 43467 if (step.index >= siblings.length) { 43468 return null; 43469 } 43470 const candidateClientId = siblings[step.index]; 43471 const candidateBlock = getBlock2(candidateClientId); 43472 if (!candidateBlock) { 43473 return null; 43474 } 43475 if (candidateBlock.name !== step.blockName) { 43476 return null; 43477 } 43478 if (i3 === path.length - 1) { 43479 return candidateClientId; 43480 } 43481 currentParentId = candidateClientId; 43482 } 43483 return null; 43484 }, 43485 [registry] 43486 ); 43487 } 43488 43489 // packages/editor/build-module/components/editor-interface/index.js 43490 var import_data199 = __toESM(require_data()); 43491 var import_i18n197 = __toESM(require_i18n()); 43492 var import_preferences22 = __toESM(require_preferences()); 43493 var import_block_editor81 = __toESM(require_block_editor()); 43494 var import_compose57 = __toESM(require_compose()); 43495 var import_element151 = __toESM(require_element()); 43496 var import_html_entities26 = __toESM(require_html_entities()); 43497 43498 // packages/editor/build-module/components/header/index.js 43499 var import_block_editor73 = __toESM(require_block_editor()); 43500 var import_data188 = __toESM(require_data()); 43501 var import_compose49 = __toESM(require_compose()); 43502 var import_components182 = __toESM(require_components()); 43503 var import_preferences20 = __toESM(require_preferences()); 43504 var import_element144 = __toESM(require_element()); 43505 43506 // packages/editor/build-module/components/collapsible-block-toolbar/index.js 43507 var import_block_editor69 = __toESM(require_block_editor()); 43508 var import_element140 = __toESM(require_element()); 43509 var import_components172 = __toESM(require_components()); 43510 var import_i18n184 = __toESM(require_i18n()); 43511 var import_data179 = __toESM(require_data()); 43512 var import_jsx_runtime293 = __toESM(require_jsx_runtime()); 43513 var { useHasBlockToolbar } = unlock(import_block_editor69.privateApis); 43514 function CollapsibleBlockToolbar({ isCollapsed, onToggle }) { 43515 const { blockSelectionStart } = (0, import_data179.useSelect)((select5) => { 43516 return { 43517 blockSelectionStart: select5(import_block_editor69.store).getBlockSelectionStart() 43518 }; 43519 }, []); 43520 const hasBlockToolbar = useHasBlockToolbar(); 43521 const hasBlockSelection = !!blockSelectionStart; 43522 (0, import_element140.useEffect)(() => { 43523 if (blockSelectionStart) { 43524 onToggle(false); 43525 } 43526 }, [blockSelectionStart, onToggle]); 43527 if (!hasBlockToolbar) { 43528 return null; 43529 } 43530 return /* @__PURE__ */ (0, import_jsx_runtime293.jsxs)(import_jsx_runtime293.Fragment, { children: [ 43531 /* @__PURE__ */ (0, import_jsx_runtime293.jsx)( 43532 "div", 43533 { 43534 className: clsx_default("editor-collapsible-block-toolbar", { 43535 "is-collapsed": isCollapsed || !hasBlockSelection 43536 }), 43537 children: /* @__PURE__ */ (0, import_jsx_runtime293.jsx)(import_block_editor69.BlockToolbar, { hideDragHandle: true }) 43538 } 43539 ), 43540 /* @__PURE__ */ (0, import_jsx_runtime293.jsx)(import_components172.Popover.Slot, { name: "block-toolbar" }), 43541 /* @__PURE__ */ (0, import_jsx_runtime293.jsx)( 43542 import_components172.Button, 43543 { 43544 className: "editor-collapsible-block-toolbar__toggle", 43545 icon: isCollapsed ? next_default : previous_default, 43546 onClick: () => { 43547 onToggle(!isCollapsed); 43548 }, 43549 label: isCollapsed ? (0, import_i18n184.__)("Show block tools") : (0, import_i18n184.__)("Hide block tools"), 43550 size: "compact" 43551 } 43552 ) 43553 ] }); 43554 } 43555 43556 // packages/editor/build-module/components/document-tools/index.js 43557 var import_compose45 = __toESM(require_compose()); 43558 var import_data180 = __toESM(require_data()); 43559 var import_i18n185 = __toESM(require_i18n()); 43560 var import_block_editor70 = __toESM(require_block_editor()); 43561 var import_components173 = __toESM(require_components()); 43562 var import_element141 = __toESM(require_element()); 43563 var import_keyboard_shortcuts5 = __toESM(require_keyboard_shortcuts()); 43564 var import_preferences15 = __toESM(require_preferences()); 43565 var import_jsx_runtime294 = __toESM(require_jsx_runtime()); 43566 function DocumentTools({ className, disableBlockTools = false }) { 43567 const { setIsInserterOpened: setIsInserterOpened2, setIsListViewOpened: setIsListViewOpened2 } = (0, import_data180.useDispatch)(store); 43568 const { 43569 isDistractionFree, 43570 isInserterOpened: isInserterOpened2, 43571 isListViewOpen, 43572 listViewShortcut, 43573 inserterSidebarToggleRef: inserterSidebarToggleRef2, 43574 listViewToggleRef: listViewToggleRef2, 43575 showIconLabels 43576 } = (0, import_data180.useSelect)((select5) => { 43577 const { get } = select5(import_preferences15.store); 43578 const { 43579 isListViewOpened: isListViewOpened2, 43580 getEditorMode: getEditorMode2, 43581 getInserterSidebarToggleRef: getInserterSidebarToggleRef2, 43582 getListViewToggleRef: getListViewToggleRef2 43583 } = unlock(select5(store)); 43584 const { getShortcutRepresentation } = select5(import_keyboard_shortcuts5.store); 43585 return { 43586 isInserterOpened: select5(store).isInserterOpened(), 43587 isListViewOpen: isListViewOpened2(), 43588 listViewShortcut: getShortcutRepresentation( 43589 "core/editor/toggle-list-view" 43590 ), 43591 inserterSidebarToggleRef: getInserterSidebarToggleRef2(), 43592 listViewToggleRef: getListViewToggleRef2(), 43593 showIconLabels: get("core", "showIconLabels"), 43594 isDistractionFree: get("core", "distractionFree"), 43595 isVisualMode: getEditorMode2() === "visual" 43596 }; 43597 }, []); 43598 const preventDefault = (event) => { 43599 if (isInserterOpened2) { 43600 event.preventDefault(); 43601 } 43602 }; 43603 const isWideViewport = (0, import_compose45.useViewportMatch)("wide"); 43604 const toolbarAriaLabel = (0, import_i18n185.__)("Document tools"); 43605 const toggleListView = (0, import_element141.useCallback)( 43606 () => setIsListViewOpened2(!isListViewOpen), 43607 [setIsListViewOpened2, isListViewOpen] 43608 ); 43609 const toggleInserter = (0, import_element141.useCallback)( 43610 () => setIsInserterOpened2(!isInserterOpened2), 43611 [isInserterOpened2, setIsInserterOpened2] 43612 ); 43613 const longLabel = (0, import_i18n185._x)( 43614 "Block Inserter", 43615 "Generic label for block inserter button" 43616 ); 43617 const shortLabel = !isInserterOpened2 ? (0, import_i18n185.__)("Add") : (0, import_i18n185.__)("Close"); 43618 return ( 43619 // Some plugins expect and use the `edit-post-header-toolbar` CSS class to 43620 // find the toolbar and inject UI elements into it. This is not officially 43621 // supported, but we're keeping it in the list of class names for backwards 43622 // compatibility. 43623 /* @__PURE__ */ (0, import_jsx_runtime294.jsx)( 43624 import_block_editor70.NavigableToolbar, 43625 { 43626 className: clsx_default( 43627 "editor-document-tools", 43628 "edit-post-header-toolbar", 43629 className 43630 ), 43631 "aria-label": toolbarAriaLabel, 43632 variant: "unstyled", 43633 children: /* @__PURE__ */ (0, import_jsx_runtime294.jsxs)("div", { className: "editor-document-tools__left", children: [ 43634 !isDistractionFree && /* @__PURE__ */ (0, import_jsx_runtime294.jsx)( 43635 import_components173.ToolbarButton, 43636 { 43637 ref: inserterSidebarToggleRef2, 43638 className: "editor-document-tools__inserter-toggle", 43639 variant: "primary", 43640 isPressed: isInserterOpened2, 43641 onMouseDown: preventDefault, 43642 onClick: toggleInserter, 43643 disabled: disableBlockTools, 43644 icon: plus_default, 43645 label: showIconLabels ? shortLabel : longLabel, 43646 showTooltip: !showIconLabels, 43647 "aria-expanded": isInserterOpened2 43648 } 43649 ), 43650 (isWideViewport || !showIconLabels) && /* @__PURE__ */ (0, import_jsx_runtime294.jsxs)(import_jsx_runtime294.Fragment, { children: [ 43651 /* @__PURE__ */ (0, import_jsx_runtime294.jsx)( 43652 import_components173.ToolbarItem, 43653 { 43654 as: undo_default2, 43655 showTooltip: !showIconLabels, 43656 variant: showIconLabels ? "tertiary" : void 0, 43657 size: "compact" 43658 } 43659 ), 43660 /* @__PURE__ */ (0, import_jsx_runtime294.jsx)( 43661 import_components173.ToolbarItem, 43662 { 43663 as: redo_default2, 43664 showTooltip: !showIconLabels, 43665 variant: showIconLabels ? "tertiary" : void 0, 43666 size: "compact" 43667 } 43668 ), 43669 !isDistractionFree && /* @__PURE__ */ (0, import_jsx_runtime294.jsx)( 43670 import_components173.ToolbarButton, 43671 { 43672 className: "editor-document-tools__document-overview-toggle", 43673 icon: list_view_default, 43674 disabled: disableBlockTools, 43675 isPressed: isListViewOpen, 43676 label: (0, import_i18n185.__)("Document Overview"), 43677 onClick: toggleListView, 43678 shortcut: listViewShortcut, 43679 showTooltip: !showIconLabels, 43680 variant: showIconLabels ? "tertiary" : void 0, 43681 "aria-expanded": isListViewOpen, 43682 ref: listViewToggleRef2 43683 } 43684 ) 43685 ] }) 43686 ] }) 43687 } 43688 ) 43689 ); 43690 } 43691 var document_tools_default = DocumentTools; 43692 43693 // packages/editor/build-module/components/more-menu/index.js 43694 var import_i18n188 = __toESM(require_i18n()); 43695 var import_data183 = __toESM(require_data()); 43696 var import_keycodes13 = __toESM(require_keycodes()); 43697 var import_components178 = __toESM(require_components()); 43698 var import_preferences16 = __toESM(require_preferences()); 43699 43700 // packages/editor/build-module/components/more-menu/copy-content-menu-item.js 43701 var import_components174 = __toESM(require_components()); 43702 var import_data181 = __toESM(require_data()); 43703 var import_i18n186 = __toESM(require_i18n()); 43704 var import_compose46 = __toESM(require_compose()); 43705 var import_notices26 = __toESM(require_notices()); 43706 var import_core_data101 = __toESM(require_core_data()); 43707 var import_blocks30 = __toESM(require_blocks()); 43708 var import_jsx_runtime295 = __toESM(require_jsx_runtime()); 43709 function CopyContentMenuItem() { 43710 const { createNotice } = (0, import_data181.useDispatch)(import_notices26.store); 43711 const { getCurrentPostId: getCurrentPostId2, getCurrentPostType: getCurrentPostType2 } = (0, import_data181.useSelect)(store); 43712 const { getEditedEntityRecord } = (0, import_data181.useSelect)(import_core_data101.store); 43713 function getText() { 43714 const record = getEditedEntityRecord( 43715 "postType", 43716 getCurrentPostType2(), 43717 getCurrentPostId2() 43718 ); 43719 if (!record) { 43720 return ""; 43721 } 43722 if (typeof record.content === "function") { 43723 return record.content(record); 43724 } else if (record.blocks) { 43725 return (0, import_blocks30.__unstableSerializeAndClean)(record.blocks); 43726 } else if (record.content) { 43727 return record.content; 43728 } 43729 } 43730 function onSuccess() { 43731 createNotice("info", (0, import_i18n186.__)("All content copied."), { 43732 isDismissible: true, 43733 type: "snackbar" 43734 }); 43735 } 43736 const ref = (0, import_compose46.useCopyToClipboard)(getText, onSuccess); 43737 return /* @__PURE__ */ (0, import_jsx_runtime295.jsx)(import_components174.MenuItem, { ref, children: (0, import_i18n186.__)("Copy all blocks") }); 43738 } 43739 43740 // packages/editor/build-module/components/mode-switcher/index.js 43741 var import_i18n187 = __toESM(require_i18n()); 43742 var import_components175 = __toESM(require_components()); 43743 var import_data182 = __toESM(require_data()); 43744 var import_keyboard_shortcuts6 = __toESM(require_keyboard_shortcuts()); 43745 var import_jsx_runtime296 = __toESM(require_jsx_runtime()); 43746 var MODES = [ 43747 { 43748 value: "visual", 43749 label: (0, import_i18n187.__)("Visual editor") 43750 }, 43751 { 43752 value: "text", 43753 label: (0, import_i18n187.__)("Code editor") 43754 } 43755 ]; 43756 function ModeSwitcher() { 43757 const { shortcut, isRichEditingEnabled, isCodeEditingEnabled, mode } = (0, import_data182.useSelect)( 43758 (select5) => ({ 43759 shortcut: select5( 43760 import_keyboard_shortcuts6.store 43761 ).getShortcutRepresentation("core/editor/toggle-mode"), 43762 isRichEditingEnabled: select5(store).getEditorSettings().richEditingEnabled, 43763 isCodeEditingEnabled: select5(store).getEditorSettings().codeEditingEnabled, 43764 mode: select5(store).getEditorMode() 43765 }), 43766 [] 43767 ); 43768 const { switchEditorMode: switchEditorMode2 } = (0, import_data182.useDispatch)(store); 43769 let selectedMode = mode; 43770 if (!isRichEditingEnabled && mode === "visual") { 43771 selectedMode = "text"; 43772 } 43773 if (!isCodeEditingEnabled && mode === "text") { 43774 selectedMode = "visual"; 43775 } 43776 const choices = MODES.map((choice) => { 43777 if (!isCodeEditingEnabled && choice.value === "text") { 43778 choice = { 43779 ...choice, 43780 disabled: true 43781 }; 43782 } 43783 if (!isRichEditingEnabled && choice.value === "visual") { 43784 choice = { 43785 ...choice, 43786 disabled: true, 43787 info: (0, import_i18n187.__)( 43788 "You can enable the visual editor in your profile settings." 43789 ) 43790 }; 43791 } 43792 if (choice.value !== selectedMode && !choice.disabled) { 43793 return { ...choice, shortcut }; 43794 } 43795 return choice; 43796 }); 43797 return /* @__PURE__ */ (0, import_jsx_runtime296.jsx)(import_components175.MenuGroup, { label: (0, import_i18n187.__)("Editor"), children: /* @__PURE__ */ (0, import_jsx_runtime296.jsx)( 43798 import_components175.MenuItemsChoice, 43799 { 43800 choices, 43801 value: selectedMode, 43802 onSelect: switchEditorMode2 43803 } 43804 ) }); 43805 } 43806 var mode_switcher_default = ModeSwitcher; 43807 43808 // packages/editor/build-module/components/more-menu/tools-more-menu-group.js 43809 var import_components176 = __toESM(require_components()); 43810 var import_jsx_runtime297 = __toESM(require_jsx_runtime()); 43811 var { Fill: ToolsMoreMenuGroup, Slot: Slot11 } = (0, import_components176.createSlotFill)("ToolsMoreMenuGroup"); 43812 ToolsMoreMenuGroup.Slot = ({ fillProps }) => /* @__PURE__ */ (0, import_jsx_runtime297.jsx)(Slot11, { fillProps }); 43813 var tools_more_menu_group_default = ToolsMoreMenuGroup; 43814 43815 // packages/editor/build-module/components/more-menu/view-more-menu-group.js 43816 var import_components177 = __toESM(require_components()); 43817 var import_element142 = __toESM(require_element()); 43818 var import_jsx_runtime298 = __toESM(require_jsx_runtime()); 43819 var { Fill: ViewMoreMenuGroup, Slot: Slot12 } = (0, import_components177.createSlotFill)( 43820 import_element142.Platform.OS === "web" ? Symbol("ViewMoreMenuGroup") : "ViewMoreMenuGroup" 43821 ); 43822 ViewMoreMenuGroup.Slot = ({ fillProps }) => /* @__PURE__ */ (0, import_jsx_runtime298.jsx)(Slot12, { fillProps }); 43823 var view_more_menu_group_default = ViewMoreMenuGroup; 43824 43825 // packages/editor/build-module/components/more-menu/index.js 43826 var import_jsx_runtime299 = __toESM(require_jsx_runtime()); 43827 function MoreMenu() { 43828 const { openModal: openModal2 } = (0, import_data183.useDispatch)(store2); 43829 const { set: setPreference } = (0, import_data183.useDispatch)(import_preferences16.store); 43830 const { toggleDistractionFree: toggleDistractionFree2 } = (0, import_data183.useDispatch)(store); 43831 const showIconLabels = (0, import_data183.useSelect)( 43832 (select5) => select5(import_preferences16.store).get("core", "showIconLabels"), 43833 [] 43834 ); 43835 const turnOffDistractionFree = () => { 43836 setPreference("core", "distractionFree", false); 43837 }; 43838 return /* @__PURE__ */ (0, import_jsx_runtime299.jsx)(import_jsx_runtime299.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime299.jsx)( 43839 import_components178.DropdownMenu, 43840 { 43841 icon: more_vertical_default, 43842 label: (0, import_i18n188.__)("Options"), 43843 popoverProps: { 43844 placement: "bottom-end", 43845 className: "more-menu-dropdown__content" 43846 }, 43847 toggleProps: { 43848 showTooltip: !showIconLabels, 43849 ...showIconLabels && { variant: "tertiary" }, 43850 tooltipPosition: "bottom", 43851 size: "compact" 43852 }, 43853 children: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime299.jsxs)(import_jsx_runtime299.Fragment, { children: [ 43854 /* @__PURE__ */ (0, import_jsx_runtime299.jsxs)(import_components178.MenuGroup, { label: (0, import_i18n188._x)("View", "noun"), children: [ 43855 /* @__PURE__ */ (0, import_jsx_runtime299.jsx)( 43856 import_preferences16.PreferenceToggleMenuItem, 43857 { 43858 scope: "core", 43859 name: "fixedToolbar", 43860 onToggle: turnOffDistractionFree, 43861 label: (0, import_i18n188.__)("Top toolbar"), 43862 info: (0, import_i18n188.__)( 43863 "Access all block and document tools in a single place" 43864 ), 43865 messageActivated: (0, import_i18n188.__)( 43866 "Top toolbar activated." 43867 ), 43868 messageDeactivated: (0, import_i18n188.__)( 43869 "Top toolbar deactivated." 43870 ) 43871 } 43872 ), 43873 /* @__PURE__ */ (0, import_jsx_runtime299.jsx)( 43874 import_preferences16.PreferenceToggleMenuItem, 43875 { 43876 scope: "core", 43877 name: "distractionFree", 43878 label: (0, import_i18n188.__)("Distraction free"), 43879 info: (0, import_i18n188.__)("Write with calmness"), 43880 handleToggling: false, 43881 onToggle: () => toggleDistractionFree2({ 43882 createNotice: false 43883 }), 43884 messageActivated: (0, import_i18n188.__)( 43885 "Distraction free mode activated." 43886 ), 43887 messageDeactivated: (0, import_i18n188.__)( 43888 "Distraction free mode deactivated." 43889 ), 43890 shortcut: import_keycodes13.displayShortcut.primaryShift( 43891 "\\" 43892 ) 43893 } 43894 ), 43895 /* @__PURE__ */ (0, import_jsx_runtime299.jsx)( 43896 import_preferences16.PreferenceToggleMenuItem, 43897 { 43898 scope: "core", 43899 name: "focusMode", 43900 label: (0, import_i18n188.__)("Spotlight mode"), 43901 info: (0, import_i18n188.__)("Focus on one block at a time"), 43902 messageActivated: (0, import_i18n188.__)( 43903 "Spotlight mode activated." 43904 ), 43905 messageDeactivated: (0, import_i18n188.__)( 43906 "Spotlight mode deactivated." 43907 ) 43908 } 43909 ), 43910 /* @__PURE__ */ (0, import_jsx_runtime299.jsx)(view_more_menu_group_default.Slot, { fillProps: { onClose } }) 43911 ] }), 43912 /* @__PURE__ */ (0, import_jsx_runtime299.jsx)(mode_switcher_default, {}), 43913 /* @__PURE__ */ (0, import_jsx_runtime299.jsx)( 43914 action_item_default.Slot, 43915 { 43916 name: "core/plugin-more-menu", 43917 label: (0, import_i18n188.__)("Panels"), 43918 fillProps: { onClick: onClose } 43919 } 43920 ), 43921 /* @__PURE__ */ (0, import_jsx_runtime299.jsxs)(import_components178.MenuGroup, { label: (0, import_i18n188.__)("Tools"), children: [ 43922 /* @__PURE__ */ (0, import_jsx_runtime299.jsx)( 43923 import_components178.MenuItem, 43924 { 43925 onClick: () => openModal2("editor/keyboard-shortcut-help"), 43926 shortcut: import_keycodes13.displayShortcut.access("h"), 43927 children: (0, import_i18n188.__)("Keyboard shortcuts") 43928 } 43929 ), 43930 /* @__PURE__ */ (0, import_jsx_runtime299.jsx)(CopyContentMenuItem, {}), 43931 /* @__PURE__ */ (0, import_jsx_runtime299.jsxs)( 43932 import_components178.MenuItem, 43933 { 43934 icon: external_default, 43935 href: (0, import_i18n188.__)( 43936 "https://wordpress.org/documentation/article/wordpress-block-editor/" 43937 ), 43938 target: "_blank", 43939 rel: "noopener noreferrer", 43940 children: [ 43941 (0, import_i18n188.__)("Help"), 43942 /* @__PURE__ */ (0, import_jsx_runtime299.jsx)(import_components178.VisuallyHidden, { 43943 as: "span", 43944 /* translators: accessibility text */ 43945 children: (0, import_i18n188.__)("(opens in a new tab)") 43946 }) 43947 ] 43948 } 43949 ), 43950 /* @__PURE__ */ (0, import_jsx_runtime299.jsx)( 43951 tools_more_menu_group_default.Slot, 43952 { 43953 fillProps: { onClose } 43954 } 43955 ) 43956 ] }), 43957 /* @__PURE__ */ (0, import_jsx_runtime299.jsx)(import_components178.MenuGroup, { children: /* @__PURE__ */ (0, import_jsx_runtime299.jsx)( 43958 import_components178.MenuItem, 43959 { 43960 onClick: () => openModal2("editor/preferences"), 43961 children: (0, import_i18n188.__)("Preferences") 43962 } 43963 ) }) 43964 ] }) 43965 } 43966 ) }); 43967 } 43968 43969 // packages/editor/build-module/components/post-publish-button/post-publish-button-or-toggle.js 43970 var import_compose47 = __toESM(require_compose()); 43971 var import_data184 = __toESM(require_data()); 43972 var import_jsx_runtime300 = __toESM(require_jsx_runtime()); 43973 var IS_TOGGLE = "toggle"; 43974 var IS_BUTTON = "button"; 43975 function PostPublishButtonOrToggle({ 43976 forceIsDirty, 43977 setEntitiesSavedStatesCallback 43978 }) { 43979 let component; 43980 const isSmallerThanMediumViewport = (0, import_compose47.useViewportMatch)("medium", "<"); 43981 const { togglePublishSidebar: togglePublishSidebar2 } = (0, import_data184.useDispatch)(store); 43982 const { 43983 hasPublishAction, 43984 isBeingScheduled, 43985 isPending, 43986 isPublished, 43987 isPublishSidebarEnabled: isPublishSidebarEnabled2, 43988 isPublishSidebarOpened: isPublishSidebarOpened2, 43989 isScheduled, 43990 postStatus, 43991 postStatusHasChanged 43992 } = (0, import_data184.useSelect)((select5) => { 43993 return { 43994 hasPublishAction: !!select5(store).getCurrentPost()?._links?.["wp:action-publish"], 43995 isBeingScheduled: select5(store).isEditedPostBeingScheduled(), 43996 isPending: select5(store).isCurrentPostPending(), 43997 isPublished: select5(store).isCurrentPostPublished(), 43998 isPublishSidebarEnabled: select5(store).isPublishSidebarEnabled(), 43999 isPublishSidebarOpened: select5(store).isPublishSidebarOpened(), 44000 isScheduled: select5(store).isCurrentPostScheduled(), 44001 postStatus: select5(store).getEditedPostAttribute("status"), 44002 postStatusHasChanged: select5(store).getPostEdits()?.status 44003 }; 44004 }, []); 44005 if (isPublished || postStatusHasChanged && !["future", "publish"].includes(postStatus) || isScheduled && isBeingScheduled || isPending && !hasPublishAction && !isSmallerThanMediumViewport) { 44006 component = IS_BUTTON; 44007 } else if (isSmallerThanMediumViewport || isPublishSidebarEnabled2) { 44008 component = IS_TOGGLE; 44009 } else { 44010 component = IS_BUTTON; 44011 } 44012 return /* @__PURE__ */ (0, import_jsx_runtime300.jsx)( 44013 post_publish_button_default, 44014 { 44015 forceIsDirty, 44016 isOpen: isPublishSidebarOpened2, 44017 isToggle: component === IS_TOGGLE, 44018 onToggle: togglePublishSidebar2, 44019 setEntitiesSavedStatesCallback 44020 } 44021 ); 44022 } 44023 44024 // packages/editor/build-module/components/post-view-link/index.js 44025 var import_i18n189 = __toESM(require_i18n()); 44026 var import_components179 = __toESM(require_components()); 44027 var import_core_data102 = __toESM(require_core_data()); 44028 var import_data185 = __toESM(require_data()); 44029 var import_preferences17 = __toESM(require_preferences()); 44030 var import_jsx_runtime301 = __toESM(require_jsx_runtime()); 44031 function PostViewLink() { 44032 const { hasLoaded, permalink, isPublished, label, showIconLabels } = (0, import_data185.useSelect)((select5) => { 44033 const postTypeSlug = select5(store).getCurrentPostType(); 44034 const postType2 = select5(import_core_data102.store).getPostType(postTypeSlug); 44035 const { get } = select5(import_preferences17.store); 44036 return { 44037 permalink: select5(store).getPermalink(), 44038 isPublished: select5(store).isCurrentPostPublished(), 44039 label: postType2?.labels.view_item, 44040 hasLoaded: !!postType2, 44041 showIconLabels: get("core", "showIconLabels") 44042 }; 44043 }, []); 44044 if (!isPublished || !permalink || !hasLoaded) { 44045 return null; 44046 } 44047 return /* @__PURE__ */ (0, import_jsx_runtime301.jsx)( 44048 import_components179.Button, 44049 { 44050 icon: external_default, 44051 label: label || (0, import_i18n189.__)("View post"), 44052 href: permalink, 44053 target: "_blank", 44054 showTooltip: !showIconLabels, 44055 size: "compact" 44056 } 44057 ); 44058 } 44059 44060 // packages/editor/build-module/components/preview-dropdown/index.js 44061 var import_compose48 = __toESM(require_compose()); 44062 var import_components180 = __toESM(require_components()); 44063 var import_i18n190 = __toESM(require_i18n()); 44064 var import_data186 = __toESM(require_data()); 44065 var import_core_data103 = __toESM(require_core_data()); 44066 var import_preferences18 = __toESM(require_preferences()); 44067 var import_block_editor71 = __toESM(require_block_editor()); 44068 var import_jsx_runtime302 = __toESM(require_jsx_runtime()); 44069 function PreviewDropdown({ forceIsAutosaveable, disabled }) { 44070 const { 44071 deviceType: deviceType2, 44072 homeUrl, 44073 isTemplate: isTemplate2, 44074 isViewable, 44075 showIconLabels, 44076 isTemplateHidden, 44077 templateId: templateId2 44078 } = (0, import_data186.useSelect)((select5) => { 44079 const { 44080 getDeviceType: getDeviceType2, 44081 getCurrentPostType: getCurrentPostType2, 44082 getCurrentTemplateId: getCurrentTemplateId2, 44083 getRenderingMode: getRenderingMode2 44084 } = select5(store); 44085 const { getEntityRecord, getPostType } = select5(import_core_data103.store); 44086 const { get } = select5(import_preferences18.store); 44087 const _currentPostType = getCurrentPostType2(); 44088 return { 44089 deviceType: getDeviceType2(), 44090 homeUrl: getEntityRecord("root", "__unstableBase")?.home, 44091 isTemplate: _currentPostType === "wp_template", 44092 isViewable: getPostType(_currentPostType)?.viewable ?? false, 44093 showIconLabels: get("core", "showIconLabels"), 44094 isTemplateHidden: getRenderingMode2() === "post-only", 44095 templateId: getCurrentTemplateId2() 44096 }; 44097 }, []); 44098 const { setDeviceType: setDeviceType2, setRenderingMode: setRenderingMode2, setDefaultRenderingMode: setDefaultRenderingMode2 } = unlock( 44099 (0, import_data186.useDispatch)(store) 44100 ); 44101 const { resetZoomLevel } = unlock((0, import_data186.useDispatch)(import_block_editor71.store)); 44102 const handleDevicePreviewChange = (newDeviceType) => { 44103 setDeviceType2(newDeviceType); 44104 resetZoomLevel(); 44105 }; 44106 const isMobile = (0, import_compose48.useViewportMatch)("medium", "<"); 44107 if (isMobile) { 44108 return null; 44109 } 44110 const popoverProps = { 44111 placement: "bottom-end" 44112 }; 44113 const toggleProps = { 44114 className: "editor-preview-dropdown__toggle", 44115 iconPosition: "right", 44116 size: "compact", 44117 showTooltip: !showIconLabels, 44118 disabled, 44119 accessibleWhenDisabled: disabled 44120 }; 44121 const menuProps = { 44122 "aria-label": (0, import_i18n190.__)("View options") 44123 }; 44124 const deviceIcons = { 44125 desktop: desktop_default, 44126 mobile: mobile_default, 44127 tablet: tablet_default 44128 }; 44129 const choices = [ 44130 { 44131 value: "Desktop", 44132 label: (0, import_i18n190.__)("Desktop"), 44133 icon: desktop_default 44134 }, 44135 { 44136 value: "Tablet", 44137 label: (0, import_i18n190.__)("Tablet"), 44138 icon: tablet_default 44139 }, 44140 { 44141 value: "Mobile", 44142 label: (0, import_i18n190.__)("Mobile"), 44143 icon: mobile_default 44144 } 44145 ]; 44146 return /* @__PURE__ */ (0, import_jsx_runtime302.jsx)( 44147 import_components180.DropdownMenu, 44148 { 44149 className: clsx_default( 44150 "editor-preview-dropdown", 44151 `editor-preview-dropdown--$deviceType2.toLowerCase()}` 44152 ), 44153 popoverProps, 44154 toggleProps, 44155 menuProps, 44156 icon: deviceIcons[deviceType2.toLowerCase()], 44157 label: (0, import_i18n190.__)("View"), 44158 disableOpenOnArrowDown: disabled, 44159 children: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime302.jsxs)(import_jsx_runtime302.Fragment, { children: [ 44160 /* @__PURE__ */ (0, import_jsx_runtime302.jsx)(import_components180.MenuGroup, { children: /* @__PURE__ */ (0, import_jsx_runtime302.jsx)( 44161 import_components180.MenuItemsChoice, 44162 { 44163 choices, 44164 value: deviceType2, 44165 onSelect: handleDevicePreviewChange 44166 } 44167 ) }), 44168 isTemplate2 && /* @__PURE__ */ (0, import_jsx_runtime302.jsx)(import_components180.MenuGroup, { children: /* @__PURE__ */ (0, import_jsx_runtime302.jsxs)( 44169 import_components180.MenuItem, 44170 { 44171 href: homeUrl, 44172 target: "_blank", 44173 icon: external_default, 44174 onClick: onClose, 44175 children: [ 44176 (0, import_i18n190.__)("View site"), 44177 /* @__PURE__ */ (0, import_jsx_runtime302.jsx)(import_components180.VisuallyHidden, { 44178 as: "span", 44179 /* translators: accessibility text */ 44180 children: (0, import_i18n190.__)("(opens in a new tab)") 44181 }) 44182 ] 44183 } 44184 ) }), 44185 !isTemplate2 && !!templateId2 && /* @__PURE__ */ (0, import_jsx_runtime302.jsx)(import_components180.MenuGroup, { children: /* @__PURE__ */ (0, import_jsx_runtime302.jsx)( 44186 import_components180.MenuItem, 44187 { 44188 icon: !isTemplateHidden ? check_default : void 0, 44189 isSelected: !isTemplateHidden, 44190 role: "menuitemcheckbox", 44191 onClick: () => { 44192 const newRenderingMode = isTemplateHidden ? "template-locked" : "post-only"; 44193 setRenderingMode2(newRenderingMode); 44194 setDefaultRenderingMode2(newRenderingMode); 44195 resetZoomLevel(); 44196 }, 44197 children: (0, import_i18n190.__)("Show template") 44198 } 44199 ) }), 44200 isViewable && /* @__PURE__ */ (0, import_jsx_runtime302.jsx)(import_components180.MenuGroup, { children: /* @__PURE__ */ (0, import_jsx_runtime302.jsx)( 44201 PostPreviewButton, 44202 { 44203 className: "editor-preview-dropdown__button-external", 44204 role: "menuitem", 44205 forceIsAutosaveable, 44206 "aria-label": (0, import_i18n190.__)("Preview in new tab"), 44207 textContent: /* @__PURE__ */ (0, import_jsx_runtime302.jsxs)(import_jsx_runtime302.Fragment, { children: [ 44208 (0, import_i18n190.__)("Preview in new tab"), 44209 /* @__PURE__ */ (0, import_jsx_runtime302.jsx)(import_components180.Icon, { icon: external_default }) 44210 ] }), 44211 onPreview: onClose 44212 } 44213 ) }), 44214 /* @__PURE__ */ (0, import_jsx_runtime302.jsx)( 44215 action_item_default.Slot, 44216 { 44217 name: "core/plugin-preview-menu", 44218 fillProps: { onClick: onClose } 44219 } 44220 ) 44221 ] }) 44222 } 44223 ); 44224 } 44225 44226 // packages/editor/build-module/components/zoom-out-toggle/index.js 44227 var import_components181 = __toESM(require_components()); 44228 var import_i18n191 = __toESM(require_i18n()); 44229 var import_element143 = __toESM(require_element()); 44230 var import_data187 = __toESM(require_data()); 44231 var import_block_editor72 = __toESM(require_block_editor()); 44232 var import_preferences19 = __toESM(require_preferences()); 44233 var import_keyboard_shortcuts7 = __toESM(require_keyboard_shortcuts()); 44234 var import_keycodes14 = __toESM(require_keycodes()); 44235 var import_jsx_runtime303 = __toESM(require_jsx_runtime()); 44236 var ZoomOutToggle = ({ disabled }) => { 44237 const { isZoomOut, showIconLabels, isDistractionFree } = (0, import_data187.useSelect)( 44238 (select5) => ({ 44239 isZoomOut: unlock(select5(import_block_editor72.store)).isZoomOut(), 44240 showIconLabels: select5(import_preferences19.store).get( 44241 "core", 44242 "showIconLabels" 44243 ), 44244 isDistractionFree: select5(import_preferences19.store).get( 44245 "core", 44246 "distractionFree" 44247 ) 44248 }) 44249 ); 44250 const { resetZoomLevel, setZoomLevel } = unlock( 44251 (0, import_data187.useDispatch)(import_block_editor72.store) 44252 ); 44253 const { registerShortcut, unregisterShortcut } = (0, import_data187.useDispatch)( 44254 import_keyboard_shortcuts7.store 44255 ); 44256 (0, import_element143.useEffect)(() => { 44257 registerShortcut({ 44258 name: "core/editor/zoom", 44259 category: "global", 44260 description: (0, import_i18n191.__)("Enter or exit zoom out."), 44261 keyCombination: { 44262 // `primaryShift+0` (`ctrl+shift+0`) is the shortcut for switching 44263 // to input mode in Windows, so apply a different key combination. 44264 modifier: (0, import_keycodes14.isAppleOS)() ? "primaryShift" : "secondary", 44265 character: "0" 44266 } 44267 }); 44268 return () => { 44269 unregisterShortcut("core/editor/zoom"); 44270 }; 44271 }, [registerShortcut, unregisterShortcut]); 44272 (0, import_keyboard_shortcuts7.useShortcut)( 44273 "core/editor/zoom", 44274 () => { 44275 if (isZoomOut) { 44276 resetZoomLevel(); 44277 } else { 44278 setZoomLevel("auto-scaled"); 44279 } 44280 }, 44281 { 44282 isDisabled: isDistractionFree 44283 } 44284 ); 44285 const handleZoomOut = () => { 44286 if (isZoomOut) { 44287 resetZoomLevel(); 44288 } else { 44289 setZoomLevel("auto-scaled"); 44290 } 44291 }; 44292 return /* @__PURE__ */ (0, import_jsx_runtime303.jsx)( 44293 import_components181.Button, 44294 { 44295 accessibleWhenDisabled: true, 44296 disabled, 44297 onClick: handleZoomOut, 44298 icon: square_default, 44299 label: (0, import_i18n191.__)("Zoom Out"), 44300 isPressed: isZoomOut, 44301 size: "compact", 44302 showTooltip: !showIconLabels, 44303 className: "editor-zoom-out-toggle" 44304 } 44305 ); 44306 }; 44307 var zoom_out_toggle_default = ZoomOutToggle; 44308 44309 // packages/editor/build-module/components/header/index.js 44310 var import_jsx_runtime304 = __toESM(require_jsx_runtime()); 44311 var toolbarVariations = { 44312 distractionFreeDisabled: { y: "-50px" }, 44313 distractionFreeHover: { y: 0 }, 44314 distractionFreeHidden: { y: "-50px" }, 44315 visible: { y: 0 }, 44316 hidden: { y: 0 } 44317 }; 44318 var backButtonVariations = { 44319 distractionFreeDisabled: { x: "-100%" }, 44320 distractionFreeHover: { x: 0 }, 44321 distractionFreeHidden: { x: "-100%" }, 44322 visible: { x: 0 }, 44323 hidden: { x: 0 } 44324 }; 44325 function Header({ 44326 customSaveButton, 44327 forceIsDirty, 44328 setEntitiesSavedStatesCallback 44329 }) { 44330 const isWideViewport = (0, import_compose49.useViewportMatch)("large"); 44331 const isLargeViewport = (0, import_compose49.useViewportMatch)("medium"); 44332 const isTooNarrowForDocumentBar = (0, import_compose49.useMediaQuery)("(max-width: 403px)"); 44333 const { 44334 postType: postType2, 44335 isTextEditor, 44336 isPublishSidebarOpened: isPublishSidebarOpened2, 44337 showIconLabels, 44338 hasFixedToolbar, 44339 hasBlockSelection, 44340 hasSectionRootClientId, 44341 isStylesCanvasActive 44342 } = (0, import_data188.useSelect)((select5) => { 44343 const { get: getPreference } = select5(import_preferences20.store); 44344 const { 44345 getEditorMode: getEditorMode2, 44346 getCurrentPostType: getCurrentPostType2, 44347 isPublishSidebarOpened: _isPublishSidebarOpened 44348 } = select5(store); 44349 const { getStylesPath: getStylesPath2, getShowStylebook: getShowStylebook2 } = unlock( 44350 select5(store) 44351 ); 44352 const { getBlockSelectionStart: getBlockSelectionStart2, getSectionRootClientId } = unlock( 44353 select5(import_block_editor73.store) 44354 ); 44355 return { 44356 postType: getCurrentPostType2(), 44357 isTextEditor: getEditorMode2() === "text", 44358 isPublishSidebarOpened: _isPublishSidebarOpened(), 44359 showIconLabels: getPreference("core", "showIconLabels"), 44360 hasFixedToolbar: getPreference("core", "fixedToolbar"), 44361 hasBlockSelection: !!getBlockSelectionStart2(), 44362 hasSectionRootClientId: !!getSectionRootClientId(), 44363 isStylesCanvasActive: !!getStylesPath2()?.startsWith("/revisions") || getShowStylebook2() 44364 }; 44365 }, []); 44366 const canBeZoomedOut = ["post", "page", "wp_template"].includes(postType2) && hasSectionRootClientId; 44367 const disablePreviewOption = [ 44368 NAVIGATION_POST_TYPE, 44369 TEMPLATE_PART_POST_TYPE, 44370 PATTERN_POST_TYPE 44371 ].includes(postType2) || isStylesCanvasActive; 44372 const [isBlockToolsCollapsed, setIsBlockToolsCollapsed] = (0, import_element144.useState)(true); 44373 const hasCenter = !isTooNarrowForDocumentBar && (!hasFixedToolbar || hasFixedToolbar && (!hasBlockSelection || isBlockToolsCollapsed)); 44374 const hasBackButton = useHasBackButton(); 44375 return /* @__PURE__ */ (0, import_jsx_runtime304.jsxs)("div", { className: "editor-header edit-post-header", children: [ 44376 hasBackButton && /* @__PURE__ */ (0, import_jsx_runtime304.jsx)( 44377 import_components182.__unstableMotion.div, 44378 { 44379 className: "editor-header__back-button", 44380 variants: backButtonVariations, 44381 transition: { type: "tween" }, 44382 children: /* @__PURE__ */ (0, import_jsx_runtime304.jsx)(back_button_default.Slot, {}) 44383 } 44384 ), 44385 /* @__PURE__ */ (0, import_jsx_runtime304.jsxs)( 44386 import_components182.__unstableMotion.div, 44387 { 44388 variants: toolbarVariations, 44389 className: "editor-header__toolbar", 44390 transition: { type: "tween" }, 44391 children: [ 44392 /* @__PURE__ */ (0, import_jsx_runtime304.jsx)( 44393 document_tools_default, 44394 { 44395 disableBlockTools: isStylesCanvasActive || isTextEditor 44396 } 44397 ), 44398 hasFixedToolbar && isLargeViewport && /* @__PURE__ */ (0, import_jsx_runtime304.jsx)( 44399 CollapsibleBlockToolbar, 44400 { 44401 isCollapsed: isBlockToolsCollapsed, 44402 onToggle: setIsBlockToolsCollapsed 44403 } 44404 ) 44405 ] 44406 } 44407 ), 44408 hasCenter && /* @__PURE__ */ (0, import_jsx_runtime304.jsx)( 44409 import_components182.__unstableMotion.div, 44410 { 44411 className: "editor-header__center", 44412 variants: toolbarVariations, 44413 transition: { type: "tween" }, 44414 children: /* @__PURE__ */ (0, import_jsx_runtime304.jsx)(DocumentBar, {}) 44415 } 44416 ), 44417 /* @__PURE__ */ (0, import_jsx_runtime304.jsxs)( 44418 import_components182.__unstableMotion.div, 44419 { 44420 variants: toolbarVariations, 44421 transition: { type: "tween" }, 44422 className: "editor-header__settings", 44423 children: [ 44424 !customSaveButton && !isPublishSidebarOpened2 && /* 44425 * This button isn't completely hidden by the publish sidebar. 44426 * We can't hide the whole toolbar when the publish sidebar is open because 44427 * we want to prevent mounting/unmounting the PostPublishButtonOrToggle DOM node. 44428 * We track that DOM node to return focus to the PostPublishButtonOrToggle 44429 * when the publish sidebar has been closed. 44430 */ 44431 /* @__PURE__ */ (0, import_jsx_runtime304.jsx)(PostSavedState, { forceIsDirty }), 44432 /* @__PURE__ */ (0, import_jsx_runtime304.jsx)(PostViewLink, {}), 44433 /* @__PURE__ */ (0, import_jsx_runtime304.jsx)( 44434 PreviewDropdown, 44435 { 44436 forceIsAutosaveable: forceIsDirty, 44437 disabled: disablePreviewOption 44438 } 44439 ), 44440 /* @__PURE__ */ (0, import_jsx_runtime304.jsx)( 44441 PostPreviewButton, 44442 { 44443 className: "editor-header__post-preview-button", 44444 forceIsAutosaveable: forceIsDirty 44445 } 44446 ), 44447 isWideViewport && canBeZoomedOut && /* @__PURE__ */ (0, import_jsx_runtime304.jsx)(zoom_out_toggle_default, { disabled: isStylesCanvasActive }), 44448 (isWideViewport || !showIconLabels) && /* @__PURE__ */ (0, import_jsx_runtime304.jsx)(pinned_items_default.Slot, { scope: "core" }), 44449 !customSaveButton && /* @__PURE__ */ (0, import_jsx_runtime304.jsx)( 44450 PostPublishButtonOrToggle, 44451 { 44452 forceIsDirty, 44453 setEntitiesSavedStatesCallback 44454 } 44455 ), 44456 customSaveButton, 44457 /* @__PURE__ */ (0, import_jsx_runtime304.jsx)(MoreMenu, {}) 44458 ] 44459 } 44460 ) 44461 ] }); 44462 } 44463 var header_default2 = Header; 44464 44465 // packages/editor/build-module/components/inserter-sidebar/index.js 44466 var import_data189 = __toESM(require_data()); 44467 var import_block_editor74 = __toESM(require_block_editor()); 44468 var import_compose50 = __toESM(require_compose()); 44469 var import_element145 = __toESM(require_element()); 44470 var import_preferences21 = __toESM(require_preferences()); 44471 var import_keycodes15 = __toESM(require_keycodes()); 44472 var import_jsx_runtime305 = __toESM(require_jsx_runtime()); 44473 var { PrivateInserterLibrary } = unlock(import_block_editor74.privateApis); 44474 function InserterSidebar() { 44475 const { 44476 blockSectionRootClientId, 44477 inserterSidebarToggleRef: inserterSidebarToggleRef2, 44478 inserter, 44479 showMostUsedBlocks, 44480 sidebarIsOpened 44481 } = (0, import_data189.useSelect)((select5) => { 44482 const { 44483 getInserterSidebarToggleRef: getInserterSidebarToggleRef2, 44484 getInserter: getInserter2, 44485 isPublishSidebarOpened: isPublishSidebarOpened2 44486 } = unlock(select5(store)); 44487 const { getBlockRootClientId: getBlockRootClientId2, isZoomOut, getSectionRootClientId } = unlock(select5(import_block_editor74.store)); 44488 const { get } = select5(import_preferences21.store); 44489 const { getActiveComplementaryArea: getActiveComplementaryArea2 } = select5(store2); 44490 const getBlockSectionRootClientId = () => { 44491 if (isZoomOut()) { 44492 const sectionRootClientId = getSectionRootClientId(); 44493 if (sectionRootClientId) { 44494 return sectionRootClientId; 44495 } 44496 } 44497 return getBlockRootClientId2(); 44498 }; 44499 return { 44500 inserterSidebarToggleRef: getInserterSidebarToggleRef2(), 44501 inserter: getInserter2(), 44502 showMostUsedBlocks: get("core", "mostUsedBlocks"), 44503 blockSectionRootClientId: getBlockSectionRootClientId(), 44504 sidebarIsOpened: !!(getActiveComplementaryArea2("core") || isPublishSidebarOpened2()) 44505 }; 44506 }, []); 44507 const { setIsInserterOpened: setIsInserterOpened2 } = (0, import_data189.useDispatch)(store); 44508 const { disableComplementaryArea: disableComplementaryArea2 } = (0, import_data189.useDispatch)(store2); 44509 const isMobileViewport = (0, import_compose50.useViewportMatch)("medium", "<"); 44510 const libraryRef = (0, import_element145.useRef)(); 44511 const closeInserterSidebar = (0, import_element145.useCallback)(() => { 44512 setIsInserterOpened2(false); 44513 inserterSidebarToggleRef2.current?.focus(); 44514 }, [inserterSidebarToggleRef2, setIsInserterOpened2]); 44515 const closeOnEscape = (0, import_element145.useCallback)( 44516 (event) => { 44517 if (event.keyCode === import_keycodes15.ESCAPE && !event.defaultPrevented) { 44518 event.preventDefault(); 44519 closeInserterSidebar(); 44520 } 44521 }, 44522 [closeInserterSidebar] 44523 ); 44524 const inserterContents = /* @__PURE__ */ (0, import_jsx_runtime305.jsx)("div", { className: "editor-inserter-sidebar__content", children: /* @__PURE__ */ (0, import_jsx_runtime305.jsx)( 44525 PrivateInserterLibrary, 44526 { 44527 showMostUsedBlocks, 44528 showInserterHelpPanel: true, 44529 shouldFocusBlock: isMobileViewport, 44530 rootClientId: blockSectionRootClientId, 44531 onSelect: inserter.onSelect, 44532 __experimentalInitialTab: inserter.tab, 44533 __experimentalInitialCategory: inserter.category, 44534 __experimentalFilterValue: inserter.filterValue, 44535 onPatternCategorySelection: sidebarIsOpened ? () => disableComplementaryArea2("core") : void 0, 44536 ref: libraryRef, 44537 onClose: closeInserterSidebar 44538 } 44539 ) }); 44540 return ( 44541 // eslint-disable-next-line jsx-a11y/no-static-element-interactions 44542 /* @__PURE__ */ (0, import_jsx_runtime305.jsx)("div", { onKeyDown: closeOnEscape, className: "editor-inserter-sidebar", children: inserterContents }) 44543 ); 44544 } 44545 44546 // packages/editor/build-module/components/list-view-sidebar/index.js 44547 var import_block_editor75 = __toESM(require_block_editor()); 44548 var import_compose51 = __toESM(require_compose()); 44549 var import_data190 = __toESM(require_data()); 44550 var import_dom3 = __toESM(require_dom()); 44551 var import_element146 = __toESM(require_element()); 44552 var import_i18n193 = __toESM(require_i18n()); 44553 var import_keyboard_shortcuts8 = __toESM(require_keyboard_shortcuts()); 44554 var import_keycodes16 = __toESM(require_keycodes()); 44555 44556 // packages/editor/build-module/components/list-view-sidebar/list-view-outline.js 44557 var import_components183 = __toESM(require_components()); 44558 var import_i18n192 = __toESM(require_i18n()); 44559 var import_jsx_runtime306 = __toESM(require_jsx_runtime()); 44560 function ListViewOutline() { 44561 return /* @__PURE__ */ (0, import_jsx_runtime306.jsxs)(import_jsx_runtime306.Fragment, { children: [ 44562 /* @__PURE__ */ (0, import_jsx_runtime306.jsxs)("div", { className: "editor-list-view-sidebar__outline", children: [ 44563 /* @__PURE__ */ (0, import_jsx_runtime306.jsxs)("div", { children: [ 44564 /* @__PURE__ */ (0, import_jsx_runtime306.jsx)(import_components183.__experimentalText, { children: (0, import_i18n192.__)("Characters:") }), 44565 /* @__PURE__ */ (0, import_jsx_runtime306.jsx)(import_components183.__experimentalText, { children: /* @__PURE__ */ (0, import_jsx_runtime306.jsx)(CharacterCount, {}) }) 44566 ] }), 44567 /* @__PURE__ */ (0, import_jsx_runtime306.jsxs)("div", { children: [ 44568 /* @__PURE__ */ (0, import_jsx_runtime306.jsx)(import_components183.__experimentalText, { children: (0, import_i18n192.__)("Words:") }), 44569 /* @__PURE__ */ (0, import_jsx_runtime306.jsx)(WordCount, {}) 44570 ] }), 44571 /* @__PURE__ */ (0, import_jsx_runtime306.jsxs)("div", { children: [ 44572 /* @__PURE__ */ (0, import_jsx_runtime306.jsx)(import_components183.__experimentalText, { children: (0, import_i18n192.__)("Time to read:") }), 44573 /* @__PURE__ */ (0, import_jsx_runtime306.jsx)(TimeToRead, {}) 44574 ] }) 44575 ] }), 44576 /* @__PURE__ */ (0, import_jsx_runtime306.jsx)(DocumentOutline, {}) 44577 ] }); 44578 } 44579 44580 // packages/editor/build-module/components/list-view-sidebar/index.js 44581 var import_jsx_runtime307 = __toESM(require_jsx_runtime()); 44582 var { TabbedSidebar } = unlock(import_block_editor75.privateApis); 44583 function ListViewSidebar() { 44584 const { setIsListViewOpened: setIsListViewOpened2 } = (0, import_data190.useDispatch)(store); 44585 const { getListViewToggleRef: getListViewToggleRef2 } = unlock((0, import_data190.useSelect)(store)); 44586 const focusOnMountRef = (0, import_compose51.useFocusOnMount)("firstElement"); 44587 const closeListView = (0, import_element146.useCallback)(() => { 44588 setIsListViewOpened2(false); 44589 getListViewToggleRef2().current?.focus(); 44590 }, [getListViewToggleRef2, setIsListViewOpened2]); 44591 const closeOnEscape = (0, import_element146.useCallback)( 44592 (event) => { 44593 if (event.keyCode === import_keycodes16.ESCAPE && !event.defaultPrevented) { 44594 event.preventDefault(); 44595 closeListView(); 44596 } 44597 }, 44598 [closeListView] 44599 ); 44600 const [dropZoneElement, setDropZoneElement] = (0, import_element146.useState)(null); 44601 const [tab, setTab] = (0, import_element146.useState)("list-view"); 44602 const sidebarRef = (0, import_element146.useRef)(); 44603 const tabsRef = (0, import_element146.useRef)(); 44604 const listViewRef = (0, import_element146.useRef)(); 44605 const listViewContainerRef = (0, import_compose51.useMergeRefs)([ 44606 focusOnMountRef, 44607 listViewRef, 44608 setDropZoneElement 44609 ]); 44610 function handleSidebarFocus(currentTab) { 44611 const tabPanelFocus = import_dom3.focus.tabbable.find(tabsRef.current)[0]; 44612 if (currentTab === "list-view") { 44613 const listViewApplicationFocus = import_dom3.focus.tabbable.find( 44614 listViewRef.current 44615 )[0]; 44616 const listViewFocusArea = sidebarRef.current.contains( 44617 listViewApplicationFocus 44618 ) ? listViewApplicationFocus : tabPanelFocus; 44619 listViewFocusArea.focus(); 44620 } else { 44621 tabPanelFocus.focus(); 44622 } 44623 } 44624 const handleToggleListViewShortcut = (0, import_element146.useCallback)(() => { 44625 if (sidebarRef.current.contains( 44626 sidebarRef.current.ownerDocument.activeElement 44627 )) { 44628 closeListView(); 44629 } else { 44630 handleSidebarFocus(tab); 44631 } 44632 }, [closeListView, tab]); 44633 (0, import_keyboard_shortcuts8.useShortcut)("core/editor/toggle-list-view", handleToggleListViewShortcut); 44634 return ( 44635 // eslint-disable-next-line jsx-a11y/no-static-element-interactions 44636 /* @__PURE__ */ (0, import_jsx_runtime307.jsx)( 44637 "div", 44638 { 44639 className: "editor-list-view-sidebar", 44640 onKeyDown: closeOnEscape, 44641 ref: sidebarRef, 44642 children: /* @__PURE__ */ (0, import_jsx_runtime307.jsx)( 44643 TabbedSidebar, 44644 { 44645 tabs: [ 44646 { 44647 name: "list-view", 44648 title: (0, import_i18n193._x)("List View", "Post overview"), 44649 panel: /* @__PURE__ */ (0, import_jsx_runtime307.jsx)("div", { className: "editor-list-view-sidebar__list-view-container", children: /* @__PURE__ */ (0, import_jsx_runtime307.jsx)("div", { className: "editor-list-view-sidebar__list-view-panel-content", children: /* @__PURE__ */ (0, import_jsx_runtime307.jsx)( 44650 import_block_editor75.__experimentalListView, 44651 { 44652 dropZoneElement 44653 } 44654 ) }) }), 44655 panelRef: listViewContainerRef 44656 }, 44657 { 44658 name: "outline", 44659 title: (0, import_i18n193._x)("Outline", "Post overview"), 44660 panel: /* @__PURE__ */ (0, import_jsx_runtime307.jsx)("div", { className: "editor-list-view-sidebar__list-view-container", children: /* @__PURE__ */ (0, import_jsx_runtime307.jsx)(ListViewOutline, {}) }) 44661 } 44662 ], 44663 onClose: closeListView, 44664 onSelect: (tabName) => setTab(tabName), 44665 defaultTabId: "list-view", 44666 ref: tabsRef, 44667 closeButtonLabel: (0, import_i18n193.__)("Close") 44668 } 44669 ) 44670 } 44671 ) 44672 ); 44673 } 44674 44675 // packages/editor/build-module/components/save-publish-panels/index.js 44676 var import_data191 = __toESM(require_data()); 44677 var import_components184 = __toESM(require_components()); 44678 var import_i18n194 = __toESM(require_i18n()); 44679 var import_element147 = __toESM(require_element()); 44680 var import_jsx_runtime308 = __toESM(require_jsx_runtime()); 44681 var { Fill: Fill11, Slot: Slot13 } = (0, import_components184.createSlotFill)("ActionsPanel"); 44682 function SavePublishPanels({ 44683 setEntitiesSavedStatesCallback, 44684 closeEntitiesSavedStates, 44685 isEntitiesSavedStatesOpen, 44686 forceIsDirtyPublishPanel 44687 }) { 44688 const { closePublishSidebar: closePublishSidebar2, togglePublishSidebar: togglePublishSidebar2 } = (0, import_data191.useDispatch)(store); 44689 const { 44690 publishSidebarOpened, 44691 isPublishable, 44692 isDirty, 44693 hasOtherEntitiesChanges 44694 } = (0, import_data191.useSelect)((select5) => { 44695 const { 44696 isPublishSidebarOpened: isPublishSidebarOpened2, 44697 isEditedPostPublishable: isEditedPostPublishable2, 44698 isCurrentPostPublished: isCurrentPostPublished2, 44699 isEditedPostDirty: isEditedPostDirty2, 44700 hasNonPostEntityChanges: hasNonPostEntityChanges2 44701 } = select5(store); 44702 const _hasOtherEntitiesChanges = hasNonPostEntityChanges2(); 44703 return { 44704 publishSidebarOpened: isPublishSidebarOpened2(), 44705 isPublishable: !isCurrentPostPublished2() && isEditedPostPublishable2(), 44706 isDirty: _hasOtherEntitiesChanges || isEditedPostDirty2(), 44707 hasOtherEntitiesChanges: _hasOtherEntitiesChanges 44708 }; 44709 }, []); 44710 const openEntitiesSavedStates = (0, import_element147.useCallback)( 44711 () => setEntitiesSavedStatesCallback(true), 44712 [] 44713 ); 44714 let unmountableContent; 44715 if (publishSidebarOpened) { 44716 unmountableContent = /* @__PURE__ */ (0, import_jsx_runtime308.jsx)( 44717 post_publish_panel_default, 44718 { 44719 onClose: closePublishSidebar2, 44720 forceIsDirty: forceIsDirtyPublishPanel, 44721 PrePublishExtension: plugin_pre_publish_panel_default.Slot, 44722 PostPublishExtension: plugin_post_publish_panel_default.Slot 44723 } 44724 ); 44725 } else if (isPublishable && !hasOtherEntitiesChanges) { 44726 unmountableContent = /* @__PURE__ */ (0, import_jsx_runtime308.jsx)("div", { className: "editor-layout__toggle-publish-panel", children: /* @__PURE__ */ (0, import_jsx_runtime308.jsx)( 44727 import_components184.Button, 44728 { 44729 __next40pxDefaultSize: true, 44730 variant: "secondary", 44731 onClick: togglePublishSidebar2, 44732 "aria-expanded": false, 44733 children: (0, import_i18n194.__)("Open publish panel") 44734 } 44735 ) }); 44736 } else { 44737 unmountableContent = /* @__PURE__ */ (0, import_jsx_runtime308.jsx)("div", { className: "editor-layout__toggle-entities-saved-states-panel", children: /* @__PURE__ */ (0, import_jsx_runtime308.jsx)( 44738 import_components184.Button, 44739 { 44740 __next40pxDefaultSize: true, 44741 variant: "secondary", 44742 onClick: openEntitiesSavedStates, 44743 "aria-expanded": false, 44744 "aria-haspopup": "dialog", 44745 disabled: !isDirty, 44746 accessibleWhenDisabled: true, 44747 children: (0, import_i18n194.__)("Open save panel") 44748 } 44749 ) }); 44750 } 44751 return /* @__PURE__ */ (0, import_jsx_runtime308.jsxs)(import_jsx_runtime308.Fragment, { children: [ 44752 isEntitiesSavedStatesOpen && /* @__PURE__ */ (0, import_jsx_runtime308.jsx)( 44753 EntitiesSavedStates, 44754 { 44755 close: closeEntitiesSavedStates, 44756 renderDialog: true 44757 } 44758 ), 44759 /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(Slot13, { bubblesVirtually: true }), 44760 !isEntitiesSavedStatesOpen && unmountableContent 44761 ] }); 44762 } 44763 44764 // packages/editor/build-module/components/text-editor/index.js 44765 var import_components185 = __toESM(require_components()); 44766 var import_data192 = __toESM(require_data()); 44767 var import_i18n195 = __toESM(require_i18n()); 44768 var import_keyboard_shortcuts9 = __toESM(require_keyboard_shortcuts()); 44769 var import_element148 = __toESM(require_element()); 44770 var import_jsx_runtime309 = __toESM(require_jsx_runtime()); 44771 function TextEditor({ autoFocus = false }) { 44772 const { switchEditorMode: switchEditorMode2 } = (0, import_data192.useDispatch)(store); 44773 const { shortcut, isRichEditingEnabled } = (0, import_data192.useSelect)((select5) => { 44774 const { getEditorSettings: getEditorSettings2 } = select5(store); 44775 const { getShortcutRepresentation } = select5(import_keyboard_shortcuts9.store); 44776 return { 44777 shortcut: getShortcutRepresentation("core/editor/toggle-mode"), 44778 isRichEditingEnabled: getEditorSettings2().richEditingEnabled 44779 }; 44780 }, []); 44781 const titleRef = (0, import_element148.useRef)(); 44782 (0, import_element148.useEffect)(() => { 44783 if (autoFocus) { 44784 return; 44785 } 44786 titleRef?.current?.focus(); 44787 }, [autoFocus]); 44788 return /* @__PURE__ */ (0, import_jsx_runtime309.jsxs)("div", { className: "editor-text-editor", children: [ 44789 isRichEditingEnabled && /* @__PURE__ */ (0, import_jsx_runtime309.jsxs)("div", { className: "editor-text-editor__toolbar", children: [ 44790 /* @__PURE__ */ (0, import_jsx_runtime309.jsx)("h2", { children: (0, import_i18n195.__)("Editing code") }), 44791 /* @__PURE__ */ (0, import_jsx_runtime309.jsx)( 44792 import_components185.Button, 44793 { 44794 __next40pxDefaultSize: true, 44795 variant: "tertiary", 44796 onClick: () => switchEditorMode2("visual"), 44797 shortcut, 44798 children: (0, import_i18n195.__)("Exit code editor") 44799 } 44800 ) 44801 ] }), 44802 /* @__PURE__ */ (0, import_jsx_runtime309.jsxs)("div", { className: "editor-text-editor__body", children: [ 44803 /* @__PURE__ */ (0, import_jsx_runtime309.jsx)(post_title_raw_default, { ref: titleRef }), 44804 /* @__PURE__ */ (0, import_jsx_runtime309.jsx)(PostTextEditor, {}) 44805 ] }) 44806 ] }); 44807 } 44808 44809 // packages/editor/build-module/components/visual-editor/index.js 44810 var import_block_editor80 = __toESM(require_block_editor()); 44811 var import_element150 = __toESM(require_element()); 44812 var import_data198 = __toESM(require_data()); 44813 var import_blocks32 = __toESM(require_blocks()); 44814 var import_core_data105 = __toESM(require_core_data()); 44815 var import_compose56 = __toESM(require_compose()); 44816 44817 // packages/editor/build-module/components/visual-editor/edit-template-blocks-notification.js 44818 var import_data193 = __toESM(require_data()); 44819 var import_core_data104 = __toESM(require_core_data()); 44820 var import_element149 = __toESM(require_element()); 44821 var import_i18n196 = __toESM(require_i18n()); 44822 var import_components186 = __toESM(require_components()); 44823 var import_jsx_runtime310 = __toESM(require_jsx_runtime()); 44824 function EditTemplateBlocksNotification({ contentRef }) { 44825 const { onNavigateToEntityRecord, templateId: templateId2 } = (0, import_data193.useSelect)((select5) => { 44826 const { getEditorSettings: getEditorSettings2, getCurrentTemplateId: getCurrentTemplateId2 } = select5(store); 44827 return { 44828 onNavigateToEntityRecord: getEditorSettings2().onNavigateToEntityRecord, 44829 templateId: getCurrentTemplateId2() 44830 }; 44831 }, []); 44832 const canEditTemplate = (0, import_data193.useSelect)( 44833 (select5) => !!select5(import_core_data104.store).canUser("create", { 44834 kind: "postType", 44835 name: "wp_template" 44836 }), 44837 [] 44838 ); 44839 const [isDialogOpen, setIsDialogOpen] = (0, import_element149.useState)(false); 44840 (0, import_element149.useEffect)(() => { 44841 const handleDblClick = (event) => { 44842 if (!canEditTemplate) { 44843 return; 44844 } 44845 if (!event.target.classList.contains("is-root-container") || event.target.dataset?.type === "core/template-part") { 44846 return; 44847 } 44848 if (!event.defaultPrevented) { 44849 event.preventDefault(); 44850 setIsDialogOpen(true); 44851 } 44852 }; 44853 const canvas = contentRef.current; 44854 canvas?.addEventListener("dblclick", handleDblClick); 44855 return () => { 44856 canvas?.removeEventListener("dblclick", handleDblClick); 44857 }; 44858 }, [contentRef, canEditTemplate]); 44859 if (!canEditTemplate) { 44860 return null; 44861 } 44862 return /* @__PURE__ */ (0, import_jsx_runtime310.jsx)( 44863 import_components186.__experimentalConfirmDialog, 44864 { 44865 isOpen: isDialogOpen, 44866 confirmButtonText: (0, import_i18n196.__)("Edit template"), 44867 onConfirm: () => { 44868 setIsDialogOpen(false); 44869 onNavigateToEntityRecord({ 44870 postId: templateId2, 44871 postType: "wp_template" 44872 }); 44873 }, 44874 onCancel: () => setIsDialogOpen(false), 44875 size: "medium", 44876 children: (0, import_i18n196.__)( 44877 "You\u2019ve tried to select a block that is part of a template that may be used elsewhere on your site. Would you like to edit the template?" 44878 ) 44879 } 44880 ); 44881 } 44882 44883 // packages/editor/build-module/components/visual-editor/use-select-nearest-editable-block.js 44884 var import_compose52 = __toESM(require_compose()); 44885 var import_data194 = __toESM(require_data()); 44886 var import_block_editor76 = __toESM(require_block_editor()); 44887 var DISTANCE_THRESHOLD = 500; 44888 function clamp(value, min2, max2) { 44889 return Math.min(Math.max(value, min2), max2); 44890 } 44891 function distanceFromRect(x2, y3, rect) { 44892 const dx = x2 - clamp(x2, rect.left, rect.right); 44893 const dy = y3 - clamp(y3, rect.top, rect.bottom); 44894 return Math.sqrt(dx * dx + dy * dy); 44895 } 44896 function useSelectNearestEditableBlock({ 44897 isEnabled = true 44898 } = {}) { 44899 const { getEnabledClientIdsTree, getBlockName: getBlockName2, getBlockOrder: getBlockOrder2 } = unlock( 44900 (0, import_data194.useSelect)(import_block_editor76.store) 44901 ); 44902 const { selectBlock: selectBlock2 } = (0, import_data194.useDispatch)(import_block_editor76.store); 44903 return (0, import_compose52.useRefEffect)( 44904 (element) => { 44905 if (!isEnabled) { 44906 return; 44907 } 44908 const selectNearestEditableBlock = (x2, y3) => { 44909 const editableBlockClientIds = getEnabledClientIdsTree().flatMap(({ clientId }) => { 44910 const blockName = getBlockName2(clientId); 44911 if (blockName === "core/template-part") { 44912 return []; 44913 } 44914 if (blockName === "core/post-content") { 44915 const innerBlocks = getBlockOrder2(clientId); 44916 if (innerBlocks.length) { 44917 return innerBlocks; 44918 } 44919 } 44920 return [clientId]; 44921 }); 44922 let nearestDistance = Infinity, nearestClientId = null; 44923 for (const clientId of editableBlockClientIds) { 44924 const block = element.querySelector( 44925 `[data-block="$clientId}"]` 44926 ); 44927 if (!block) { 44928 continue; 44929 } 44930 const rect = block.getBoundingClientRect(); 44931 const distance = distanceFromRect(x2, y3, rect); 44932 if (distance < nearestDistance && distance < DISTANCE_THRESHOLD) { 44933 nearestDistance = distance; 44934 nearestClientId = clientId; 44935 } 44936 } 44937 if (nearestClientId) { 44938 selectBlock2(nearestClientId); 44939 } 44940 }; 44941 const handleClick = (event) => { 44942 const shouldSelect = event.target === element || event.target.classList.contains("is-root-container"); 44943 if (shouldSelect) { 44944 selectNearestEditableBlock(event.clientX, event.clientY); 44945 } 44946 }; 44947 element.addEventListener("click", handleClick); 44948 return () => element.removeEventListener("click", handleClick); 44949 }, 44950 [isEnabled] 44951 ); 44952 } 44953 44954 // packages/editor/build-module/components/visual-editor/use-zoom-out-mode-exit.js 44955 var import_data195 = __toESM(require_data()); 44956 var import_compose53 = __toESM(require_compose()); 44957 var import_block_editor77 = __toESM(require_block_editor()); 44958 function useZoomOutModeExit() { 44959 const { getSettings: getSettings5, isZoomOut } = unlock((0, import_data195.useSelect)(import_block_editor77.store)); 44960 const { resetZoomLevel } = unlock((0, import_data195.useDispatch)(import_block_editor77.store)); 44961 return (0, import_compose53.useRefEffect)( 44962 (node) => { 44963 function onDoubleClick(event) { 44964 if (!isZoomOut()) { 44965 return; 44966 } 44967 if (!event.defaultPrevented) { 44968 event.preventDefault(); 44969 const { __experimentalSetIsInserterOpened } = getSettings5(); 44970 if (typeof __experimentalSetIsInserterOpened === "function") { 44971 __experimentalSetIsInserterOpened(false); 44972 } 44973 resetZoomLevel(); 44974 } 44975 } 44976 node.addEventListener("dblclick", onDoubleClick); 44977 return () => { 44978 node.removeEventListener("dblclick", onDoubleClick); 44979 }; 44980 }, 44981 [getSettings5, isZoomOut, resetZoomLevel] 44982 ); 44983 } 44984 44985 // packages/editor/build-module/components/visual-editor/use-padding-appender.js 44986 var import_data196 = __toESM(require_data()); 44987 var import_compose54 = __toESM(require_compose()); 44988 var import_block_editor78 = __toESM(require_block_editor()); 44989 var import_blocks31 = __toESM(require_blocks()); 44990 var CSS2 = ':root :where(.editor-styles-wrapper)::after {content: ""; display: block; height: 40vh;}'; 44991 function usePaddingAppender(enabled) { 44992 const registry = (0, import_data196.useRegistry)(); 44993 const effect = (0, import_compose54.useRefEffect)( 44994 (node) => { 44995 function onMouseDown(event) { 44996 if (event.target !== node && // Tests for the parent element because in the iframed editor if the click is 44997 // below the padding the target will be the parent element (html) and should 44998 // still be treated as intent to append. 44999 event.target !== node.parentElement) { 45000 return; 45001 } 45002 const lastChild = node.lastElementChild; 45003 if (!lastChild) { 45004 return; 45005 } 45006 const lastChildRect = lastChild.getBoundingClientRect(); 45007 if (event.clientY < lastChildRect.bottom) { 45008 return; 45009 } 45010 event.preventDefault(); 45011 const blockOrder = registry.select(import_block_editor78.store).getBlockOrder(""); 45012 const lastBlockClientId = blockOrder[blockOrder.length - 1]; 45013 const lastBlock = registry.select(import_block_editor78.store).getBlock(lastBlockClientId); 45014 const { selectBlock: selectBlock2, insertDefaultBlock: insertDefaultBlock2 } = registry.dispatch(import_block_editor78.store); 45015 if (lastBlock && (0, import_blocks31.isUnmodifiedDefaultBlock)(lastBlock)) { 45016 selectBlock2(lastBlockClientId); 45017 } else { 45018 insertDefaultBlock2(); 45019 } 45020 } 45021 const { ownerDocument } = node; 45022 ownerDocument.addEventListener("pointerdown", onMouseDown); 45023 return () => { 45024 ownerDocument.removeEventListener("pointerdown", onMouseDown); 45025 }; 45026 }, 45027 [registry] 45028 ); 45029 return enabled ? [effect, CSS2] : []; 45030 } 45031 45032 // packages/editor/build-module/components/visual-editor/use-edit-content-only-section-exit.js 45033 var import_data197 = __toESM(require_data()); 45034 var import_compose55 = __toESM(require_compose()); 45035 var import_block_editor79 = __toESM(require_block_editor()); 45036 function useEditContentOnlySectionExit() { 45037 const { getEditedContentOnlySection } = unlock( 45038 (0, import_data197.useSelect)(import_block_editor79.store) 45039 ); 45040 const { stopEditingContentOnlySection } = unlock( 45041 (0, import_data197.useDispatch)(import_block_editor79.store) 45042 ); 45043 return (0, import_compose55.useRefEffect)( 45044 (node) => { 45045 function onClick(event) { 45046 const editedContentOnlySection = getEditedContentOnlySection(); 45047 if (!editedContentOnlySection) { 45048 return; 45049 } 45050 const isClickOutside = !event.target.closest( 45051 `[data-block="$editedContentOnlySection}"]` 45052 ); 45053 if (isClickOutside && !event.defaultPrevented) { 45054 event.preventDefault(); 45055 stopEditingContentOnlySection(); 45056 } 45057 } 45058 node.addEventListener("click", onClick); 45059 return () => { 45060 node.removeEventListener("click", onClick); 45061 }; 45062 }, 45063 [getEditedContentOnlySection, stopEditingContentOnlySection] 45064 ); 45065 } 45066 45067 // packages/editor/build-module/components/visual-editor/index.js 45068 var import_jsx_runtime311 = __toESM(require_jsx_runtime()); 45069 var { 45070 LayoutStyle, 45071 useLayoutClasses, 45072 useLayoutStyles, 45073 ExperimentalBlockCanvas: BlockCanvas, 45074 useFlashEditableBlocks 45075 } = unlock(import_block_editor80.privateApis); 45076 function getPostContentAttributes(blocks) { 45077 for (let i3 = 0; i3 < blocks.length; i3++) { 45078 if (blocks[i3].name === "core/post-content") { 45079 return blocks[i3].attributes; 45080 } 45081 if (blocks[i3].innerBlocks.length) { 45082 const nestedPostContent = getPostContentAttributes( 45083 blocks[i3].innerBlocks 45084 ); 45085 if (nestedPostContent) { 45086 return nestedPostContent; 45087 } 45088 } 45089 } 45090 } 45091 function checkForPostContentAtRootLevel(blocks) { 45092 for (let i3 = 0; i3 < blocks.length; i3++) { 45093 if (blocks[i3].name === "core/post-content") { 45094 return true; 45095 } 45096 } 45097 return false; 45098 } 45099 function VisualEditor({ 45100 // Ideally as we unify post and site editors, we won't need these props. 45101 autoFocus, 45102 disableIframe = false, 45103 iframeProps, 45104 contentRef, 45105 className 45106 }) { 45107 const isMobileViewport = (0, import_compose56.useViewportMatch)("small", "<"); 45108 const { 45109 renderingMode: renderingMode2, 45110 postContentAttributes, 45111 editedPostTemplate = {}, 45112 wrapperBlockName, 45113 wrapperUniqueId, 45114 deviceType: deviceType2, 45115 isFocusedEntity, 45116 isDesignPostType, 45117 postType: postType2, 45118 isPreview, 45119 styles, 45120 canvasMinHeight: canvasMinHeight2 45121 } = (0, import_data198.useSelect)((select5) => { 45122 const { 45123 getCurrentPostId: getCurrentPostId2, 45124 getCurrentPostType: getCurrentPostType2, 45125 getCurrentTemplateId: getCurrentTemplateId2, 45126 getEditorSettings: getEditorSettings2, 45127 getRenderingMode: getRenderingMode2, 45128 getDeviceType: getDeviceType2, 45129 getCanvasMinHeight: getCanvasMinHeight2 45130 } = unlock(select5(store)); 45131 const { getPostType, getEditedEntityRecord } = select5(import_core_data105.store); 45132 const postTypeSlug = getCurrentPostType2(); 45133 const _renderingMode = getRenderingMode2(); 45134 let _wrapperBlockName; 45135 if (postTypeSlug === PATTERN_POST_TYPE) { 45136 _wrapperBlockName = "core/block"; 45137 } else if (_renderingMode === "post-only") { 45138 _wrapperBlockName = "core/post-content"; 45139 } 45140 const editorSettings2 = getEditorSettings2(); 45141 const supportsTemplateMode = editorSettings2.supportsTemplateMode; 45142 const postTypeObject = getPostType(postTypeSlug); 45143 const currentTemplateId = getCurrentTemplateId2(); 45144 const template2 = currentTemplateId ? getEditedEntityRecord( 45145 "postType", 45146 TEMPLATE_POST_TYPE, 45147 currentTemplateId 45148 ) : void 0; 45149 return { 45150 renderingMode: _renderingMode, 45151 postContentAttributes: editorSettings2.postContentAttributes, 45152 isDesignPostType: DESIGN_POST_TYPES.includes(postTypeSlug), 45153 // Post template fetch returns a 404 on classic themes, which 45154 // messes with e2e tests, so check it's a block theme first. 45155 editedPostTemplate: postTypeObject?.viewable && supportsTemplateMode ? template2 : void 0, 45156 wrapperBlockName: _wrapperBlockName, 45157 wrapperUniqueId: getCurrentPostId2(), 45158 deviceType: getDeviceType2(), 45159 isFocusedEntity: !!editorSettings2.onNavigateToPreviousEntityRecord, 45160 postType: postTypeSlug, 45161 isPreview: editorSettings2.isPreviewMode, 45162 styles: editorSettings2.styles, 45163 canvasMinHeight: getCanvasMinHeight2() 45164 }; 45165 }, []); 45166 const { isCleanNewPost: isCleanNewPost2 } = (0, import_data198.useSelect)(store); 45167 const { 45168 hasRootPaddingAwareAlignments, 45169 themeHasDisabledLayoutStyles, 45170 themeSupportsLayout, 45171 isZoomedOut 45172 } = (0, import_data198.useSelect)((select5) => { 45173 const { getSettings: getSettings5, isZoomOut: _isZoomOut } = unlock( 45174 select5(import_block_editor80.store) 45175 ); 45176 const _settings = getSettings5(); 45177 return { 45178 themeHasDisabledLayoutStyles: _settings.disableLayoutStyles, 45179 themeSupportsLayout: _settings.supportsLayout, 45180 hasRootPaddingAwareAlignments: _settings.__experimentalFeatures?.useRootPaddingAwareAlignments, 45181 isZoomedOut: _isZoomOut() 45182 }; 45183 }, []); 45184 const localRef = (0, import_element150.useRef)(); 45185 const deviceStyles = (0, import_block_editor80.__experimentalUseResizeCanvas)(deviceType2); 45186 const [globalLayoutSettings] = (0, import_block_editor80.useSettings)("layout"); 45187 const fallbackLayout = (0, import_element150.useMemo)(() => { 45188 if (renderingMode2 !== "post-only" || isDesignPostType) { 45189 return { type: "default" }; 45190 } 45191 if (themeSupportsLayout) { 45192 return { ...globalLayoutSettings, type: "constrained" }; 45193 } 45194 return { type: "default" }; 45195 }, [ 45196 renderingMode2, 45197 themeSupportsLayout, 45198 globalLayoutSettings, 45199 isDesignPostType 45200 ]); 45201 const newestPostContentAttributes = (0, import_element150.useMemo)(() => { 45202 if (!editedPostTemplate?.content && !editedPostTemplate?.blocks && postContentAttributes) { 45203 return postContentAttributes; 45204 } 45205 if (editedPostTemplate?.blocks) { 45206 return getPostContentAttributes(editedPostTemplate?.blocks); 45207 } 45208 const parseableContent = typeof editedPostTemplate?.content === "string" ? editedPostTemplate?.content : ""; 45209 return getPostContentAttributes((0, import_blocks32.parse)(parseableContent)) || {}; 45210 }, [ 45211 editedPostTemplate?.content, 45212 editedPostTemplate?.blocks, 45213 postContentAttributes 45214 ]); 45215 const hasPostContentAtRootLevel = (0, import_element150.useMemo)(() => { 45216 if (!editedPostTemplate?.content && !editedPostTemplate?.blocks) { 45217 return false; 45218 } 45219 if (editedPostTemplate?.blocks) { 45220 return checkForPostContentAtRootLevel(editedPostTemplate?.blocks); 45221 } 45222 const parseableContent = typeof editedPostTemplate?.content === "string" ? editedPostTemplate?.content : ""; 45223 return checkForPostContentAtRootLevel((0, import_blocks32.parse)(parseableContent)) || false; 45224 }, [editedPostTemplate?.content, editedPostTemplate?.blocks]); 45225 const { layout = {}, align = "" } = newestPostContentAttributes || {}; 45226 const postContentLayoutClasses = useLayoutClasses( 45227 newestPostContentAttributes, 45228 "core/post-content" 45229 ); 45230 const blockListLayoutClass = clsx_default( 45231 { 45232 "is-layout-flow": !themeSupportsLayout 45233 }, 45234 themeSupportsLayout && postContentLayoutClasses, 45235 align && `align$align}` 45236 ); 45237 const postContentLayoutStyles = useLayoutStyles( 45238 newestPostContentAttributes, 45239 "core/post-content", 45240 ".block-editor-block-list__layout.is-root-container" 45241 ); 45242 const postContentLayout = (0, import_element150.useMemo)(() => { 45243 return layout && (layout?.type === "constrained" || layout?.inherit || layout?.contentSize || layout?.wideSize) ? { ...globalLayoutSettings, ...layout, type: "constrained" } : { ...globalLayoutSettings, ...layout, type: "default" }; 45244 }, [ 45245 layout?.type, 45246 layout?.inherit, 45247 layout?.contentSize, 45248 layout?.wideSize, 45249 globalLayoutSettings 45250 ]); 45251 const blockListLayout = postContentAttributes ? postContentLayout : fallbackLayout; 45252 const postEditorLayout = blockListLayout?.type === "default" && !hasPostContentAtRootLevel ? fallbackLayout : blockListLayout; 45253 const observeTypingRef = (0, import_block_editor80.__unstableUseTypingObserver)(); 45254 const titleRef = (0, import_element150.useRef)(); 45255 (0, import_element150.useEffect)(() => { 45256 if (!autoFocus || !isCleanNewPost2()) { 45257 return; 45258 } 45259 titleRef?.current?.focus(); 45260 }, [autoFocus, isCleanNewPost2]); 45261 const alignCSS = `.is-root-container.alignwide { max-width: var(--wp--style--global--wide-size); margin-left: auto; margin-right: auto;} 45262 .is-root-container.alignwide:where(.is-layout-flow) > :not(.alignleft):not(.alignright) { max-width: var(--wp--style--global--wide-size);} 45263 .is-root-container.alignfull { max-width: none; margin-left: auto; margin-right: auto;} 45264 .is-root-container.alignfull:where(.is-layout-flow) > :not(.alignleft):not(.alignright) { max-width: none;}`; 45265 const enableResizing = [ 45266 NAVIGATION_POST_TYPE, 45267 TEMPLATE_PART_POST_TYPE, 45268 PATTERN_POST_TYPE 45269 ].includes(postType2) && // Disable in previews / view mode. 45270 !isPreview && // Disable resizing in mobile viewport. 45271 !isMobileViewport && // Disable resizing in zoomed-out mode. 45272 !isZoomedOut; 45273 const calculatedMinHeight = (0, import_element150.useMemo)(() => { 45274 if (!localRef.current) { 45275 return canvasMinHeight2; 45276 } 45277 const { ownerDocument } = localRef.current; 45278 const scrollTop = ownerDocument.documentElement.scrollTop || ownerDocument.body.scrollTop; 45279 return canvasMinHeight2 + scrollTop; 45280 }, [canvasMinHeight2]); 45281 const [paddingAppenderRef, paddingStyle] = usePaddingAppender( 45282 !isPreview && renderingMode2 === "post-only" && !isDesignPostType 45283 ); 45284 const iframeStyles = (0, import_element150.useMemo)(() => { 45285 return [ 45286 ...styles ?? [], 45287 { 45288 // Ensures margins of children are contained so that the body background paints behind them. 45289 // Otherwise, the background of html (when zoomed out) would show there and appear broken. It's 45290 // important mostly for post-only views yet conceivably an issue in templated views too. 45291 css: `:where(.block-editor-iframe__body){display:flow-root;$calculatedMinHeight ? `min-height:$calculatedMinHeight}px;` : ""}}.is-root-container{display:flow-root;${// Some themes will have `min-height: 100vh` for the root container, 45292 // which isn't a requirement in auto resize mode. 45293 enableResizing ? "min-height:0!important;" : ""}} 45294 $paddingStyle ? paddingStyle : ""} 45295 $enableResizing ? `.block-editor-iframe__html{background:var(--wp-editor-canvas-background);display:flex;align-items:center;justify-content:center;min-height:100vh;}.block-editor-iframe__body{width:100%;}` : ""}` 45296 // The CSS above centers the body content vertically when resizing is enabled and applies a background 45297 // color to the iframe HTML element to match the background color of the editor canvas. 45298 } 45299 ]; 45300 }, [styles, enableResizing, calculatedMinHeight, paddingStyle]); 45301 const typewriterRef = (0, import_block_editor80.__unstableUseTypewriter)(); 45302 contentRef = (0, import_compose56.useMergeRefs)([ 45303 localRef, 45304 contentRef, 45305 renderingMode2 === "post-only" ? typewriterRef : null, 45306 useFlashEditableBlocks({ 45307 isEnabled: renderingMode2 === "template-locked" 45308 }), 45309 useSelectNearestEditableBlock({ 45310 isEnabled: renderingMode2 === "template-locked" 45311 }), 45312 useZoomOutModeExit(), 45313 paddingAppenderRef, 45314 useEditContentOnlySectionExit() 45315 ]); 45316 return /* @__PURE__ */ (0, import_jsx_runtime311.jsx)( 45317 "div", 45318 { 45319 className: clsx_default( 45320 "editor-visual-editor", 45321 // this class is here for backward compatibility reasons. 45322 "edit-post-visual-editor", 45323 className, 45324 { 45325 "has-padding": isFocusedEntity || enableResizing, 45326 "is-resizable": enableResizing, 45327 "is-iframed": !disableIframe 45328 } 45329 ), 45330 children: /* @__PURE__ */ (0, import_jsx_runtime311.jsx)(resizable_editor_default, { enableResizing, height: "100%", children: /* @__PURE__ */ (0, import_jsx_runtime311.jsxs)( 45331 BlockCanvas, 45332 { 45333 shouldIframe: !disableIframe, 45334 contentRef, 45335 styles: iframeStyles, 45336 height: "100%", 45337 iframeProps: { 45338 ...iframeProps, 45339 style: { 45340 ...iframeProps?.style, 45341 ...deviceStyles 45342 } 45343 }, 45344 children: [ 45345 themeSupportsLayout && !themeHasDisabledLayoutStyles && renderingMode2 === "post-only" && !isDesignPostType && /* @__PURE__ */ (0, import_jsx_runtime311.jsxs)(import_jsx_runtime311.Fragment, { children: [ 45346 /* @__PURE__ */ (0, import_jsx_runtime311.jsx)( 45347 LayoutStyle, 45348 { 45349 selector: ".editor-visual-editor__post-title-wrapper", 45350 layout: fallbackLayout 45351 } 45352 ), 45353 /* @__PURE__ */ (0, import_jsx_runtime311.jsx)( 45354 LayoutStyle, 45355 { 45356 selector: ".block-editor-block-list__layout.is-root-container", 45357 layout: postEditorLayout 45358 } 45359 ), 45360 align && /* @__PURE__ */ (0, import_jsx_runtime311.jsx)(LayoutStyle, { css: alignCSS }), 45361 postContentLayoutStyles && /* @__PURE__ */ (0, import_jsx_runtime311.jsx)( 45362 LayoutStyle, 45363 { 45364 layout: postContentLayout, 45365 css: postContentLayoutStyles 45366 } 45367 ) 45368 ] }), 45369 renderingMode2 === "post-only" && !isDesignPostType && /* @__PURE__ */ (0, import_jsx_runtime311.jsx)( 45370 "div", 45371 { 45372 className: clsx_default( 45373 "editor-visual-editor__post-title-wrapper", 45374 // The following class is only here for backward compatibility 45375 // some themes might be using it to style the post title. 45376 "edit-post-visual-editor__post-title-wrapper", 45377 { 45378 "has-global-padding": hasRootPaddingAwareAlignments 45379 } 45380 ), 45381 contentEditable: false, 45382 ref: observeTypingRef, 45383 style: { 45384 // This is using inline styles 45385 // so it's applied for both iframed and non iframed editors. 45386 marginTop: "4rem" 45387 }, 45388 children: /* @__PURE__ */ (0, import_jsx_runtime311.jsx)(post_title_default, { ref: titleRef }) 45389 } 45390 ), 45391 /* @__PURE__ */ (0, import_jsx_runtime311.jsxs)( 45392 import_block_editor80.RecursionProvider, 45393 { 45394 blockName: wrapperBlockName, 45395 uniqueId: wrapperUniqueId, 45396 children: [ 45397 /* @__PURE__ */ (0, import_jsx_runtime311.jsx)( 45398 import_block_editor80.BlockList, 45399 { 45400 className: clsx_default( 45401 "is-" + deviceType2.toLowerCase() + "-preview", 45402 renderingMode2 !== "post-only" || isDesignPostType ? "wp-site-blocks" : `$blockListLayoutClass} wp-block-post-content`, 45403 // Ensure root level blocks receive default/flow blockGap styling rules. 45404 { 45405 "has-global-padding": renderingMode2 === "post-only" && !isDesignPostType && hasRootPaddingAwareAlignments 45406 } 45407 ), 45408 layout: blockListLayout, 45409 dropZoneElement: ( 45410 // When iframed, pass in the html element of the iframe to 45411 // ensure the drop zone extends to the edges of the iframe. 45412 disableIframe ? localRef.current : localRef.current?.parentNode 45413 ), 45414 __unstableDisableDropZone: ( 45415 // In template preview mode, disable drop zones at the root of the template. 45416 renderingMode2 === "template-locked" ? true : false 45417 ) 45418 } 45419 ), 45420 renderingMode2 === "template-locked" && /* @__PURE__ */ (0, import_jsx_runtime311.jsx)( 45421 EditTemplateBlocksNotification, 45422 { 45423 contentRef: localRef 45424 } 45425 ) 45426 ] 45427 } 45428 ) 45429 ] 45430 } 45431 ) }) 45432 } 45433 ); 45434 } 45435 var visual_editor_default = VisualEditor; 45436 45437 // packages/editor/build-module/components/editor-interface/index.js 45438 var import_jsx_runtime312 = __toESM(require_jsx_runtime()); 45439 var interfaceLabels = { 45440 /* translators: accessibility text for the editor top bar landmark region. */ 45441 header: (0, import_i18n197.__)("Editor top bar"), 45442 /* translators: accessibility text for the editor content landmark region. */ 45443 body: (0, import_i18n197.__)("Editor content"), 45444 /* translators: accessibility text for the editor settings landmark region. */ 45445 sidebar: (0, import_i18n197.__)("Editor settings"), 45446 /* translators: accessibility text for the editor publish landmark region. */ 45447 actions: (0, import_i18n197.__)("Editor publish"), 45448 /* translators: accessibility text for the editor footer landmark region. */ 45449 footer: (0, import_i18n197.__)("Editor footer") 45450 }; 45451 function EditorInterface({ 45452 className, 45453 children, 45454 forceIsDirty, 45455 contentRef, 45456 disableIframe, 45457 autoFocus, 45458 customSaveButton, 45459 customSavePanel, 45460 forceDisableBlockTools, 45461 iframeProps 45462 }) { 45463 const { 45464 mode, 45465 isInserterOpened: isInserterOpened2, 45466 isListViewOpened: isListViewOpened2, 45467 isDistractionFree, 45468 isPreviewMode, 45469 showBlockBreadcrumbs, 45470 postTypeLabel, 45471 stylesPath: stylesPath2, 45472 showStylebook: showStylebook2 45473 } = (0, import_data199.useSelect)((select5) => { 45474 const { get } = select5(import_preferences22.store); 45475 const { getEditorSettings: getEditorSettings2, getPostTypeLabel: getPostTypeLabel2 } = select5(store); 45476 const { getStylesPath: getStylesPath2, getShowStylebook: getShowStylebook2 } = unlock( 45477 select5(store) 45478 ); 45479 const editorSettings2 = getEditorSettings2(); 45480 let _mode = select5(store).getEditorMode(); 45481 if (!editorSettings2.richEditingEnabled && _mode === "visual") { 45482 _mode = "text"; 45483 } 45484 if (!editorSettings2.codeEditingEnabled && _mode === "text") { 45485 _mode = "visual"; 45486 } 45487 return { 45488 mode: _mode, 45489 isInserterOpened: select5(store).isInserterOpened(), 45490 isListViewOpened: select5(store).isListViewOpened(), 45491 isDistractionFree: get("core", "distractionFree"), 45492 isPreviewMode: editorSettings2.isPreviewMode, 45493 showBlockBreadcrumbs: get("core", "showBlockBreadcrumbs"), 45494 postTypeLabel: getPostTypeLabel2(), 45495 stylesPath: getStylesPath2(), 45496 showStylebook: getShowStylebook2() 45497 }; 45498 }, []); 45499 const isLargeViewport = (0, import_compose57.useViewportMatch)("medium"); 45500 const secondarySidebarLabel = isListViewOpened2 ? (0, import_i18n197.__)("Document Overview") : (0, import_i18n197.__)("Block Library"); 45501 const shouldShowStylesCanvas = showStylebook2 || stylesPath2?.startsWith("/revisions"); 45502 const [entitiesSavedStatesCallback, setEntitiesSavedStatesCallback] = (0, import_element151.useState)(false); 45503 const closeEntitiesSavedStates = (0, import_element151.useCallback)( 45504 (arg) => { 45505 if (typeof entitiesSavedStatesCallback === "function") { 45506 entitiesSavedStatesCallback(arg); 45507 } 45508 setEntitiesSavedStatesCallback(false); 45509 }, 45510 [entitiesSavedStatesCallback] 45511 ); 45512 return /* @__PURE__ */ (0, import_jsx_runtime312.jsx)( 45513 interface_skeleton_default, 45514 { 45515 isDistractionFree, 45516 className: clsx_default("editor-editor-interface", className, { 45517 "is-entity-save-view-open": !!entitiesSavedStatesCallback, 45518 "is-distraction-free": isDistractionFree && !isPreviewMode 45519 }), 45520 labels: { 45521 ...interfaceLabels, 45522 secondarySidebar: secondarySidebarLabel 45523 }, 45524 header: !isPreviewMode && /* @__PURE__ */ (0, import_jsx_runtime312.jsx)( 45525 header_default2, 45526 { 45527 forceIsDirty, 45528 setEntitiesSavedStatesCallback, 45529 customSaveButton, 45530 forceDisableBlockTools 45531 } 45532 ), 45533 editorNotices: /* @__PURE__ */ (0, import_jsx_runtime312.jsx)(editor_notices_default, {}), 45534 secondarySidebar: !isPreviewMode && mode === "visual" && (isInserterOpened2 && /* @__PURE__ */ (0, import_jsx_runtime312.jsx)(InserterSidebar, {}) || isListViewOpened2 && /* @__PURE__ */ (0, import_jsx_runtime312.jsx)(ListViewSidebar, {})), 45535 sidebar: !isPreviewMode && !isDistractionFree && /* @__PURE__ */ (0, import_jsx_runtime312.jsx)(complementary_area_default.Slot, { scope: "core" }), 45536 content: /* @__PURE__ */ (0, import_jsx_runtime312.jsxs)(import_jsx_runtime312.Fragment, { children: [ 45537 !isDistractionFree && !isPreviewMode && /* @__PURE__ */ (0, import_jsx_runtime312.jsx)(editor_notices_default, {}), 45538 shouldShowStylesCanvas ? /* @__PURE__ */ (0, import_jsx_runtime312.jsx)(StylesCanvas, {}) : /* @__PURE__ */ (0, import_jsx_runtime312.jsxs)(import_jsx_runtime312.Fragment, { children: [ 45539 !isPreviewMode && mode === "text" && /* @__PURE__ */ (0, import_jsx_runtime312.jsx)( 45540 TextEditor, 45541 { 45542 autoFocus 45543 } 45544 ), 45545 !isPreviewMode && !isLargeViewport && mode === "visual" && /* @__PURE__ */ (0, import_jsx_runtime312.jsx)(import_block_editor81.BlockToolbar, { hideDragHandle: true }), 45546 (isPreviewMode || mode === "visual") && /* @__PURE__ */ (0, import_jsx_runtime312.jsx)( 45547 visual_editor_default, 45548 { 45549 contentRef, 45550 disableIframe, 45551 autoFocus, 45552 iframeProps 45553 } 45554 ), 45555 children 45556 ] }) 45557 ] }), 45558 footer: !isPreviewMode && !isDistractionFree && isLargeViewport && showBlockBreadcrumbs && mode === "visual" && /* @__PURE__ */ (0, import_jsx_runtime312.jsx)( 45559 import_block_editor81.BlockBreadcrumb, 45560 { 45561 rootLabelText: postTypeLabel ? (0, import_html_entities26.decodeEntities)(postTypeLabel) : void 0 45562 } 45563 ), 45564 actions: !isPreviewMode ? customSavePanel || /* @__PURE__ */ (0, import_jsx_runtime312.jsx)( 45565 SavePublishPanels, 45566 { 45567 closeEntitiesSavedStates, 45568 isEntitiesSavedStatesOpen: entitiesSavedStatesCallback, 45569 setEntitiesSavedStatesCallback, 45570 forceIsDirtyPublishPanel: forceIsDirty 45571 } 45572 ) : void 0 45573 } 45574 ); 45575 } 45576 45577 // packages/editor/build-module/components/sidebar/index.js 45578 var import_block_editor90 = __toESM(require_block_editor()); 45579 var import_data219 = __toESM(require_data()); 45580 var import_element167 = __toESM(require_element()); 45581 var import_i18n212 = __toESM(require_i18n()); 45582 var import_keyboard_shortcuts10 = __toESM(require_keyboard_shortcuts()); 45583 var import_components203 = __toESM(require_components()); 45584 45585 // packages/editor/build-module/components/pattern-overrides-panel/index.js 45586 var import_data200 = __toESM(require_data()); 45587 var import_patterns9 = __toESM(require_patterns()); 45588 var import_jsx_runtime313 = __toESM(require_jsx_runtime()); 45589 var { OverridesPanel } = unlock(import_patterns9.privateApis); 45590 function PatternOverridesPanel() { 45591 const supportsPatternOverridesPanel = (0, import_data200.useSelect)( 45592 (select5) => select5(store).getCurrentPostType() === "wp_block", 45593 [] 45594 ); 45595 if (!supportsPatternOverridesPanel) { 45596 return null; 45597 } 45598 return /* @__PURE__ */ (0, import_jsx_runtime313.jsx)(OverridesPanel, {}); 45599 } 45600 45601 // packages/editor/build-module/components/sidebar/post-summary.js 45602 var import_components198 = __toESM(require_components()); 45603 var import_data212 = __toESM(require_data()); 45604 45605 // packages/editor/build-module/components/post-card-panel/index.js 45606 var import_components190 = __toESM(require_components()); 45607 var import_core_data110 = __toESM(require_core_data()); 45608 var import_data205 = __toESM(require_data()); 45609 var import_element156 = __toESM(require_element()); 45610 var import_i18n201 = __toESM(require_i18n()); 45611 var import_dom4 = __toESM(require_dom()); 45612 45613 // packages/editor/build-module/components/post-actions/index.js 45614 var import_data204 = __toESM(require_data()); 45615 var import_element155 = __toESM(require_element()); 45616 var import_i18n200 = __toESM(require_i18n()); 45617 var import_components189 = __toESM(require_components()); 45618 var import_core_data109 = __toESM(require_core_data()); 45619 45620 // packages/editor/build-module/components/post-actions/actions.js 45621 var import_data203 = __toESM(require_data()); 45622 var import_element154 = __toESM(require_element()); 45623 var import_core_data108 = __toESM(require_core_data()); 45624 45625 // packages/editor/build-module/components/post-actions/set-as-homepage.js 45626 var import_i18n198 = __toESM(require_i18n()); 45627 var import_element152 = __toESM(require_element()); 45628 var import_components187 = __toESM(require_components()); 45629 var import_data201 = __toESM(require_data()); 45630 var import_core_data106 = __toESM(require_core_data()); 45631 var import_notices27 = __toESM(require_notices()); 45632 45633 // packages/editor/build-module/utils/get-item-title.js 45634 var import_html_entities27 = __toESM(require_html_entities()); 45635 function getItemTitle2(item) { 45636 if (typeof item.title === "string") { 45637 return (0, import_html_entities27.decodeEntities)(item.title); 45638 } 45639 if (item.title && "rendered" in item.title) { 45640 return (0, import_html_entities27.decodeEntities)(item.title.rendered); 45641 } 45642 if (item.title && "raw" in item.title) { 45643 return (0, import_html_entities27.decodeEntities)(item.title.raw); 45644 } 45645 return ""; 45646 } 45647 45648 // packages/editor/build-module/components/post-actions/set-as-homepage.js 45649 var import_jsx_runtime314 = __toESM(require_jsx_runtime()); 45650 var SetAsHomepageModal = ({ items, closeModal: closeModal2 }) => { 45651 const [item] = items; 45652 const pageTitle = getItemTitle2(item); 45653 const { showOnFront, currentHomePage, isSaving } = (0, import_data201.useSelect)( 45654 (select5) => { 45655 const { getEntityRecord, isSavingEntityRecord } = select5(import_core_data106.store); 45656 const siteSettings = getEntityRecord("root", "site"); 45657 const currentHomePageItem = getEntityRecord( 45658 "postType", 45659 "page", 45660 siteSettings?.page_on_front 45661 ); 45662 return { 45663 showOnFront: siteSettings?.show_on_front, 45664 currentHomePage: currentHomePageItem, 45665 isSaving: isSavingEntityRecord("root", "site") 45666 }; 45667 } 45668 ); 45669 const { saveEntityRecord } = (0, import_data201.useDispatch)(import_core_data106.store); 45670 const { createSuccessNotice, createErrorNotice } = (0, import_data201.useDispatch)(import_notices27.store); 45671 async function onSetPageAsHomepage(event) { 45672 event.preventDefault(); 45673 try { 45674 await saveEntityRecord("root", "site", { 45675 page_on_front: item.id, 45676 show_on_front: "page" 45677 }); 45678 createSuccessNotice((0, import_i18n198.__)("Homepage updated."), { 45679 type: "snackbar" 45680 }); 45681 } catch (error) { 45682 const errorMessage = error.message && error.code !== "unknown_error" ? error.message : (0, import_i18n198.__)("An error occurred while setting the homepage."); 45683 createErrorNotice(errorMessage, { type: "snackbar" }); 45684 } finally { 45685 closeModal2?.(); 45686 } 45687 } 45688 let modalWarning = ""; 45689 if ("posts" === showOnFront) { 45690 modalWarning = (0, import_i18n198.__)( 45691 "This will replace the current homepage which is set to display latest posts." 45692 ); 45693 } else if (currentHomePage) { 45694 modalWarning = (0, import_i18n198.sprintf)( 45695 // translators: %s: title of the current home page. 45696 (0, import_i18n198.__)('This will replace the current homepage: "%s"'), 45697 getItemTitle2(currentHomePage) 45698 ); 45699 } 45700 const modalText = (0, import_i18n198.sprintf)( 45701 // translators: %1$s: title of the page to be set as the homepage, %2$s: homepage replacement warning message. 45702 (0, import_i18n198.__)('Set "%1$s" as the site homepage? %2$s'), 45703 pageTitle, 45704 modalWarning 45705 ).trim(); 45706 const modalButtonLabel = (0, import_i18n198.__)("Set homepage"); 45707 return /* @__PURE__ */ (0, import_jsx_runtime314.jsx)("form", { onSubmit: onSetPageAsHomepage, children: /* @__PURE__ */ (0, import_jsx_runtime314.jsxs)(import_components187.__experimentalVStack, { spacing: "5", children: [ 45708 /* @__PURE__ */ (0, import_jsx_runtime314.jsx)(import_components187.__experimentalText, { children: modalText }), 45709 /* @__PURE__ */ (0, import_jsx_runtime314.jsxs)(import_components187.__experimentalHStack, { justify: "right", children: [ 45710 /* @__PURE__ */ (0, import_jsx_runtime314.jsx)( 45711 import_components187.Button, 45712 { 45713 __next40pxDefaultSize: true, 45714 variant: "tertiary", 45715 onClick: () => { 45716 closeModal2?.(); 45717 }, 45718 disabled: isSaving, 45719 accessibleWhenDisabled: true, 45720 children: (0, import_i18n198.__)("Cancel") 45721 } 45722 ), 45723 /* @__PURE__ */ (0, import_jsx_runtime314.jsx)( 45724 import_components187.Button, 45725 { 45726 __next40pxDefaultSize: true, 45727 variant: "primary", 45728 type: "submit", 45729 disabled: isSaving, 45730 accessibleWhenDisabled: true, 45731 children: modalButtonLabel 45732 } 45733 ) 45734 ] }) 45735 ] }) }); 45736 }; 45737 var useSetAsHomepageAction = () => { 45738 const { pageOnFront, pageForPosts } = (0, import_data201.useSelect)((select5) => { 45739 const { getEntityRecord, canUser } = select5(import_core_data106.store); 45740 const siteSettings = canUser("read", { 45741 kind: "root", 45742 name: "site" 45743 }) ? getEntityRecord("root", "site") : void 0; 45744 return { 45745 pageOnFront: siteSettings?.page_on_front, 45746 pageForPosts: siteSettings?.page_for_posts 45747 }; 45748 }); 45749 return (0, import_element152.useMemo)( 45750 () => ({ 45751 id: "set-as-homepage", 45752 label: (0, import_i18n198.__)("Set as homepage"), 45753 isEligible(post2) { 45754 if (post2.status !== "publish") { 45755 return false; 45756 } 45757 if (post2.type !== "page") { 45758 return false; 45759 } 45760 if (pageOnFront === post2.id) { 45761 return false; 45762 } 45763 if (pageForPosts === post2.id) { 45764 return false; 45765 } 45766 return true; 45767 }, 45768 modalFocusOnMount: "firstContentElement", 45769 RenderModal: SetAsHomepageModal 45770 }), 45771 [pageForPosts, pageOnFront] 45772 ); 45773 }; 45774 45775 // packages/editor/build-module/components/post-actions/set-as-posts-page.js 45776 var import_i18n199 = __toESM(require_i18n()); 45777 var import_element153 = __toESM(require_element()); 45778 var import_components188 = __toESM(require_components()); 45779 var import_data202 = __toESM(require_data()); 45780 var import_core_data107 = __toESM(require_core_data()); 45781 var import_notices28 = __toESM(require_notices()); 45782 var import_jsx_runtime315 = __toESM(require_jsx_runtime()); 45783 var SetAsPostsPageModal = ({ items, closeModal: closeModal2 }) => { 45784 const [item] = items; 45785 const pageTitle = getItemTitle2(item); 45786 const { currentPostsPage, isPageForPostsSet, isSaving } = (0, import_data202.useSelect)( 45787 (select5) => { 45788 const { getEntityRecord, isSavingEntityRecord } = select5(import_core_data107.store); 45789 const siteSettings = getEntityRecord("root", "site"); 45790 const currentPostsPageItem = getEntityRecord( 45791 "postType", 45792 "page", 45793 siteSettings?.page_for_posts 45794 ); 45795 return { 45796 currentPostsPage: currentPostsPageItem, 45797 isPageForPostsSet: siteSettings?.page_for_posts !== 0, 45798 isSaving: isSavingEntityRecord("root", "site") 45799 }; 45800 } 45801 ); 45802 const { saveEntityRecord } = (0, import_data202.useDispatch)(import_core_data107.store); 45803 const { createSuccessNotice, createErrorNotice } = (0, import_data202.useDispatch)(import_notices28.store); 45804 async function onSetPageAsPostsPage(event) { 45805 event.preventDefault(); 45806 try { 45807 await saveEntityRecord("root", "site", { 45808 page_for_posts: item.id, 45809 show_on_front: "page" 45810 }); 45811 createSuccessNotice((0, import_i18n199.__)("Posts page updated."), { 45812 type: "snackbar" 45813 }); 45814 } catch (error) { 45815 const errorMessage = error.message && error.code !== "unknown_error" ? error.message : (0, import_i18n199.__)("An error occurred while setting the posts page."); 45816 createErrorNotice(errorMessage, { type: "snackbar" }); 45817 } finally { 45818 closeModal2?.(); 45819 } 45820 } 45821 const modalWarning = isPageForPostsSet && currentPostsPage ? (0, import_i18n199.sprintf)( 45822 // translators: %s: title of the current posts page. 45823 (0, import_i18n199.__)('This will replace the current posts page: "%s"'), 45824 getItemTitle2(currentPostsPage) 45825 ) : (0, import_i18n199.__)("This page will show the latest posts."); 45826 const modalText = (0, import_i18n199.sprintf)( 45827 // translators: %1$s: title of the page to be set as the posts page, %2$s: posts page replacement warning message. 45828 (0, import_i18n199.__)('Set "%1$s" as the posts page? %2$s'), 45829 pageTitle, 45830 modalWarning 45831 ); 45832 const modalButtonLabel = (0, import_i18n199.__)("Set posts page"); 45833 return /* @__PURE__ */ (0, import_jsx_runtime315.jsx)("form", { onSubmit: onSetPageAsPostsPage, children: /* @__PURE__ */ (0, import_jsx_runtime315.jsxs)(import_components188.__experimentalVStack, { spacing: "5", children: [ 45834 /* @__PURE__ */ (0, import_jsx_runtime315.jsx)(import_components188.__experimentalText, { children: modalText }), 45835 /* @__PURE__ */ (0, import_jsx_runtime315.jsxs)(import_components188.__experimentalHStack, { justify: "right", children: [ 45836 /* @__PURE__ */ (0, import_jsx_runtime315.jsx)( 45837 import_components188.Button, 45838 { 45839 __next40pxDefaultSize: true, 45840 variant: "tertiary", 45841 onClick: () => { 45842 closeModal2?.(); 45843 }, 45844 disabled: isSaving, 45845 accessibleWhenDisabled: true, 45846 children: (0, import_i18n199.__)("Cancel") 45847 } 45848 ), 45849 /* @__PURE__ */ (0, import_jsx_runtime315.jsx)( 45850 import_components188.Button, 45851 { 45852 __next40pxDefaultSize: true, 45853 variant: "primary", 45854 type: "submit", 45855 disabled: isSaving, 45856 accessibleWhenDisabled: true, 45857 children: modalButtonLabel 45858 } 45859 ) 45860 ] }) 45861 ] }) }); 45862 }; 45863 var useSetAsPostsPageAction = () => { 45864 const { pageOnFront, pageForPosts } = (0, import_data202.useSelect)((select5) => { 45865 const { getEntityRecord, canUser } = select5(import_core_data107.store); 45866 const siteSettings = canUser("read", { 45867 kind: "root", 45868 name: "site" 45869 }) ? getEntityRecord("root", "site") : void 0; 45870 return { 45871 pageOnFront: siteSettings?.page_on_front, 45872 pageForPosts: siteSettings?.page_for_posts 45873 }; 45874 }); 45875 return (0, import_element153.useMemo)( 45876 () => ({ 45877 id: "set-as-posts-page", 45878 label: (0, import_i18n199.__)("Set as posts page"), 45879 isEligible(post2) { 45880 if (post2.status !== "publish") { 45881 return false; 45882 } 45883 if (post2.type !== "page") { 45884 return false; 45885 } 45886 if (pageOnFront === post2.id) { 45887 return false; 45888 } 45889 if (pageForPosts === post2.id) { 45890 return false; 45891 } 45892 return true; 45893 }, 45894 modalFocusOnMount: "firstContentElement", 45895 RenderModal: SetAsPostsPageModal 45896 }), 45897 [pageForPosts, pageOnFront] 45898 ); 45899 }; 45900 45901 // packages/editor/build-module/components/post-actions/actions.js 45902 var import_jsx_runtime316 = __toESM(require_jsx_runtime()); 45903 function usePostActions({ postType: postType2, onActionPerformed, context }) { 45904 const { defaultActions } = (0, import_data203.useSelect)( 45905 (select5) => { 45906 const { getEntityActions: getEntityActions3 } = unlock(select5(store)); 45907 return { 45908 defaultActions: getEntityActions3("postType", postType2) 45909 }; 45910 }, 45911 [postType2] 45912 ); 45913 const shouldShowHomepageActions = (0, import_data203.useSelect)( 45914 (select5) => { 45915 if (postType2 !== "page") { 45916 return false; 45917 } 45918 const { getDefaultTemplateId, getEntityRecord, canUser } = select5(import_core_data108.store); 45919 const canUpdateSettings = canUser("update", { 45920 kind: "root", 45921 name: "site" 45922 }); 45923 if (!canUpdateSettings) { 45924 return false; 45925 } 45926 const frontPageTemplateId = getDefaultTemplateId({ 45927 slug: "front-page" 45928 }); 45929 if (!frontPageTemplateId) { 45930 return true; 45931 } 45932 const frontPageTemplate = getEntityRecord( 45933 "postType", 45934 "wp_template", 45935 frontPageTemplateId 45936 ); 45937 if (!frontPageTemplate) { 45938 return true; 45939 } 45940 return frontPageTemplate.slug !== "front-page"; 45941 }, 45942 [postType2] 45943 ); 45944 const setAsHomepageAction = useSetAsHomepageAction(); 45945 const setAsPostsPageAction = useSetAsPostsPageAction(); 45946 const { registerPostTypeSchema: registerPostTypeSchema2 } = unlock((0, import_data203.useDispatch)(store)); 45947 (0, import_element154.useEffect)(() => { 45948 registerPostTypeSchema2(postType2); 45949 }, [registerPostTypeSchema2, postType2]); 45950 return (0, import_element154.useMemo)(() => { 45951 let actions2 = [...defaultActions]; 45952 if (shouldShowHomepageActions) { 45953 actions2.push(setAsHomepageAction, setAsPostsPageAction); 45954 } 45955 actions2 = actions2.sort( 45956 (a3, b3) => b3.id === "move-to-trash" ? -1 : 0 45957 ); 45958 actions2 = actions2.filter((action) => { 45959 if (!action.context) { 45960 return true; 45961 } 45962 return action.context === context; 45963 }); 45964 if (onActionPerformed) { 45965 for (let i3 = 0; i3 < actions2.length; ++i3) { 45966 if (actions2[i3].callback) { 45967 const existingCallback = actions2[i3].callback; 45968 actions2[i3] = { 45969 ...actions2[i3], 45970 callback: (items, argsObject) => { 45971 existingCallback(items, { 45972 ...argsObject, 45973 onActionPerformed: (_items) => { 45974 if (argsObject?.onActionPerformed) { 45975 argsObject.onActionPerformed(_items); 45976 } 45977 onActionPerformed( 45978 actions2[i3].id, 45979 _items 45980 ); 45981 } 45982 }); 45983 } 45984 }; 45985 } 45986 if (actions2[i3].RenderModal) { 45987 const ExistingRenderModal = actions2[i3].RenderModal; 45988 actions2[i3] = { 45989 ...actions2[i3], 45990 RenderModal: (props) => { 45991 return /* @__PURE__ */ (0, import_jsx_runtime316.jsx)( 45992 ExistingRenderModal, 45993 { 45994 ...props, 45995 onActionPerformed: (_items) => { 45996 if (props.onActionPerformed) { 45997 props.onActionPerformed(_items); 45998 } 45999 onActionPerformed( 46000 actions2[i3].id, 46001 _items 46002 ); 46003 } 46004 } 46005 ); 46006 } 46007 }; 46008 } 46009 } 46010 } 46011 return actions2; 46012 }, [ 46013 context, 46014 defaultActions, 46015 onActionPerformed, 46016 setAsHomepageAction, 46017 setAsPostsPageAction, 46018 shouldShowHomepageActions 46019 ]); 46020 } 46021 46022 // packages/editor/build-module/components/post-actions/index.js 46023 var import_jsx_runtime317 = __toESM(require_jsx_runtime()); 46024 var { Menu: Menu5, kebabCase: kebabCase4 } = unlock(import_components189.privateApis); 46025 function PostActions({ postType: postType2, postId: postId2, onActionPerformed }) { 46026 const [activeModalAction, setActiveModalAction] = (0, import_element155.useState)(null); 46027 const { item, permissions } = (0, import_data204.useSelect)( 46028 (select5) => { 46029 const { getEditedEntityRecord, getEntityRecordPermissions } = unlock(select5(import_core_data109.store)); 46030 return { 46031 item: getEditedEntityRecord("postType", postType2, postId2), 46032 permissions: getEntityRecordPermissions( 46033 "postType", 46034 postType2, 46035 postId2 46036 ) 46037 }; 46038 }, 46039 [postId2, postType2] 46040 ); 46041 const itemWithPermissions = (0, import_element155.useMemo)(() => { 46042 return { 46043 ...item, 46044 permissions 46045 }; 46046 }, [item, permissions]); 46047 const allActions = usePostActions({ postType: postType2, onActionPerformed }); 46048 const actions2 = (0, import_element155.useMemo)(() => { 46049 return allActions.filter((action) => { 46050 return !action.isEligible || action.isEligible(itemWithPermissions); 46051 }); 46052 }, [allActions, itemWithPermissions]); 46053 return /* @__PURE__ */ (0, import_jsx_runtime317.jsxs)(import_jsx_runtime317.Fragment, { children: [ 46054 /* @__PURE__ */ (0, import_jsx_runtime317.jsxs)(Menu5, { placement: "bottom-end", children: [ 46055 /* @__PURE__ */ (0, import_jsx_runtime317.jsx)( 46056 Menu5.TriggerButton, 46057 { 46058 render: /* @__PURE__ */ (0, import_jsx_runtime317.jsx)( 46059 import_components189.Button, 46060 { 46061 size: "small", 46062 icon: more_vertical_default, 46063 label: (0, import_i18n200.__)("Actions"), 46064 disabled: !actions2.length, 46065 accessibleWhenDisabled: true, 46066 className: "editor-all-actions-button" 46067 } 46068 ) 46069 } 46070 ), 46071 /* @__PURE__ */ (0, import_jsx_runtime317.jsx)(Menu5.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime317.jsx)( 46072 ActionsDropdownMenuGroup, 46073 { 46074 actions: actions2, 46075 items: [itemWithPermissions], 46076 setActiveModalAction 46077 } 46078 ) }) 46079 ] }), 46080 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime317.jsx)( 46081 ActionModal, 46082 { 46083 action: activeModalAction, 46084 items: [itemWithPermissions], 46085 closeModal: () => setActiveModalAction(null) 46086 } 46087 ) 46088 ] }); 46089 } 46090 function DropdownMenuItemTrigger({ action, onClick, items }) { 46091 const label = typeof action.label === "string" ? action.label : action.label(items); 46092 return /* @__PURE__ */ (0, import_jsx_runtime317.jsx)(Menu5.Item, { onClick, children: /* @__PURE__ */ (0, import_jsx_runtime317.jsx)(Menu5.ItemLabel, { children: label }) }); 46093 } 46094 function ActionModal({ action, items, closeModal: closeModal2 }) { 46095 const label = typeof action.label === "string" ? action.label : action.label(items); 46096 return /* @__PURE__ */ (0, import_jsx_runtime317.jsx)( 46097 import_components189.Modal, 46098 { 46099 title: action.modalHeader || label, 46100 __experimentalHideHeader: !!action.hideModalHeader, 46101 onRequestClose: closeModal2 ?? (() => { 46102 }), 46103 focusOnMount: "firstContentElement", 46104 size: "medium", 46105 overlayClassName: `editor-action-modal editor-action-modal__$kebabCase4( 46106 action.id 46107 )}`, 46108 children: /* @__PURE__ */ (0, import_jsx_runtime317.jsx)(action.RenderModal, { items, closeModal: closeModal2 }) 46109 } 46110 ); 46111 } 46112 function ActionsDropdownMenuGroup({ actions: actions2, items, setActiveModalAction }) { 46113 const registry = (0, import_data204.useRegistry)(); 46114 return /* @__PURE__ */ (0, import_jsx_runtime317.jsx)(Menu5.Group, { children: actions2.map((action) => { 46115 return /* @__PURE__ */ (0, import_jsx_runtime317.jsx)( 46116 DropdownMenuItemTrigger, 46117 { 46118 action, 46119 onClick: () => { 46120 if ("RenderModal" in action) { 46121 setActiveModalAction(action); 46122 return; 46123 } 46124 action.callback(items, { registry }); 46125 }, 46126 items 46127 }, 46128 action.id 46129 ); 46130 }) }); 46131 } 46132 46133 // packages/editor/build-module/components/post-card-panel/index.js 46134 var import_jsx_runtime318 = __toESM(require_jsx_runtime()); 46135 var { Badge: Badge2 } = unlock(import_components190.privateApis); 46136 function PostCardPanel({ 46137 postType: postType2, 46138 postId: postId2, 46139 onActionPerformed 46140 }) { 46141 const postIds = (0, import_element156.useMemo)( 46142 () => Array.isArray(postId2) ? postId2 : [postId2], 46143 [postId2] 46144 ); 46145 const { postTitle, icon, labels } = (0, import_data205.useSelect)( 46146 (select5) => { 46147 const { getEditedEntityRecord, getCurrentTheme, getPostType } = select5(import_core_data110.store); 46148 const { getPostIcon: getPostIcon2 } = unlock(select5(store)); 46149 let _title = ""; 46150 const _record = getEditedEntityRecord( 46151 "postType", 46152 postType2, 46153 postIds[0] 46154 ); 46155 if (postIds.length === 1) { 46156 const { default_template_types: templateTypes = [] } = getCurrentTheme() ?? {}; 46157 const _templateInfo = [ 46158 TEMPLATE_POST_TYPE, 46159 TEMPLATE_PART_POST_TYPE 46160 ].includes(postType2) ? getTemplateInfo({ 46161 template: _record, 46162 templateTypes 46163 }) : {}; 46164 _title = _templateInfo?.title || _record?.title; 46165 } 46166 return { 46167 postTitle: _title, 46168 icon: getPostIcon2(postType2, { 46169 area: _record?.area 46170 }), 46171 labels: getPostType(postType2)?.labels 46172 }; 46173 }, 46174 [postIds, postType2] 46175 ); 46176 const pageTypeBadge = usePageTypeBadge(postId2); 46177 let title = (0, import_i18n201.__)("No title"); 46178 if (labels?.name && postIds.length > 1) { 46179 title = (0, import_i18n201.sprintf)( 46180 // translators: %1$d number of selected items %2$s: Name of the plural post type e.g: "Posts". 46181 (0, import_i18n201.__)("%1$d %2$s"), 46182 postIds.length, 46183 labels?.name 46184 ); 46185 } else if (postTitle) { 46186 title = (0, import_dom4.__unstableStripHTML)(postTitle); 46187 } 46188 return /* @__PURE__ */ (0, import_jsx_runtime318.jsxs)(import_components190.__experimentalVStack, { spacing: 1, className: "editor-post-card-panel", children: [ 46189 /* @__PURE__ */ (0, import_jsx_runtime318.jsxs)( 46190 import_components190.__experimentalHStack, 46191 { 46192 spacing: 2, 46193 className: "editor-post-card-panel__header", 46194 alignment: "flex-start", 46195 children: [ 46196 /* @__PURE__ */ (0, import_jsx_runtime318.jsx)(import_components190.Icon, { className: "editor-post-card-panel__icon", icon }), 46197 /* @__PURE__ */ (0, import_jsx_runtime318.jsxs)( 46198 import_components190.__experimentalText, 46199 { 46200 numberOfLines: 2, 46201 truncate: true, 46202 className: "editor-post-card-panel__title", 46203 as: "h2", 46204 children: [ 46205 /* @__PURE__ */ (0, import_jsx_runtime318.jsx)("span", { className: "editor-post-card-panel__title-name", children: title }), 46206 pageTypeBadge && postIds.length === 1 && /* @__PURE__ */ (0, import_jsx_runtime318.jsx)(Badge2, { children: pageTypeBadge }) 46207 ] 46208 } 46209 ), 46210 postIds.length === 1 && /* @__PURE__ */ (0, import_jsx_runtime318.jsx)( 46211 PostActions, 46212 { 46213 postType: postType2, 46214 postId: postIds[0], 46215 onActionPerformed 46216 } 46217 ) 46218 ] 46219 } 46220 ), 46221 postIds.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime318.jsx)(import_components190.__experimentalText, { className: "editor-post-card-panel__description", children: (0, import_i18n201.sprintf)( 46222 // translators: %s: Name of the plural post type e.g: "Posts". 46223 (0, import_i18n201.__)("Changes will be applied to all selected %s."), 46224 labels?.name.toLowerCase() 46225 ) }) 46226 ] }); 46227 } 46228 46229 // packages/editor/build-module/components/post-content-information/index.js 46230 var import_components191 = __toESM(require_components()); 46231 var import_data206 = __toESM(require_data()); 46232 var import_i18n202 = __toESM(require_i18n()); 46233 var import_wordcount4 = __toESM(require_wordcount()); 46234 var import_element157 = __toESM(require_element()); 46235 var import_core_data111 = __toESM(require_core_data()); 46236 var import_jsx_runtime319 = __toESM(require_jsx_runtime()); 46237 var AVERAGE_READING_RATE2 = 189; 46238 function PostContentInformation() { 46239 const { postContent } = (0, import_data206.useSelect)((select5) => { 46240 const { getEditedPostAttribute: getEditedPostAttribute2, getCurrentPostType: getCurrentPostType2, getCurrentPostId: getCurrentPostId2 } = select5(store); 46241 const { canUser } = select5(import_core_data111.store); 46242 const { getEntityRecord } = select5(import_core_data111.store); 46243 const siteSettings = canUser("read", { 46244 kind: "root", 46245 name: "site" 46246 }) ? getEntityRecord("root", "site") : void 0; 46247 const postType2 = getCurrentPostType2(); 46248 const _id = getCurrentPostId2(); 46249 const isPostsPage = +_id === siteSettings?.page_for_posts; 46250 const showPostContentInfo = !isPostsPage && ![TEMPLATE_POST_TYPE, TEMPLATE_PART_POST_TYPE].includes( 46251 postType2 46252 ); 46253 return { 46254 postContent: showPostContentInfo && getEditedPostAttribute2("content") 46255 }; 46256 }, []); 46257 const wordCountType = (0, import_i18n202._x)("words", "Word count type. Do not translate!"); 46258 const wordsCounted = (0, import_element157.useMemo)( 46259 () => postContent ? (0, import_wordcount4.count)(postContent, wordCountType) : 0, 46260 [postContent, wordCountType] 46261 ); 46262 if (!wordsCounted) { 46263 return null; 46264 } 46265 const readingTime = Math.round(wordsCounted / AVERAGE_READING_RATE2); 46266 const wordsCountText = (0, import_i18n202.sprintf)( 46267 // translators: %s: the number of words in the post. 46268 (0, import_i18n202._n)("%s word", "%s words", wordsCounted), 46269 wordsCounted.toLocaleString() 46270 ); 46271 const minutesText = readingTime <= 1 ? (0, import_i18n202.__)("1 minute") : (0, import_i18n202.sprintf)( 46272 /* translators: %s: the number of minutes to read the post. */ 46273 (0, import_i18n202._n)("%s minute", "%s minutes", readingTime), 46274 readingTime.toLocaleString() 46275 ); 46276 return /* @__PURE__ */ (0, import_jsx_runtime319.jsx)("div", { className: "editor-post-content-information", children: /* @__PURE__ */ (0, import_jsx_runtime319.jsx)(import_components191.__experimentalText, { children: (0, import_i18n202.sprintf)( 46277 /* translators: 1: How many words a post has. 2: the number of minutes to read the post (e.g. 130 words, 2 minutes read time.) */ 46278 (0, import_i18n202.__)("%1$s, %2$s read time."), 46279 wordsCountText, 46280 minutesText 46281 ) }) }); 46282 } 46283 46284 // packages/editor/build-module/components/post-format/panel.js 46285 var import_components192 = __toESM(require_components()); 46286 var import_i18n203 = __toESM(require_i18n()); 46287 var import_data207 = __toESM(require_data()); 46288 var import_element158 = __toESM(require_element()); 46289 var import_block_editor82 = __toESM(require_block_editor()); 46290 var import_jsx_runtime320 = __toESM(require_jsx_runtime()); 46291 function PostFormat2() { 46292 const { postFormat } = (0, import_data207.useSelect)((select5) => { 46293 const { getEditedPostAttribute: getEditedPostAttribute2 } = select5(store); 46294 const _postFormat = getEditedPostAttribute2("format"); 46295 return { 46296 postFormat: _postFormat ?? "standard" 46297 }; 46298 }, []); 46299 const activeFormat = POST_FORMATS.find( 46300 (format) => format.id === postFormat 46301 ); 46302 const [popoverAnchor, setPopoverAnchor] = (0, import_element158.useState)(null); 46303 const popoverProps = (0, import_element158.useMemo)( 46304 () => ({ 46305 // Anchor the popover to the middle of the entire row so that it doesn't 46306 // move around when the label changes. 46307 anchor: popoverAnchor, 46308 placement: "left-start", 46309 offset: 36, 46310 shift: true 46311 }), 46312 [popoverAnchor] 46313 ); 46314 return /* @__PURE__ */ (0, import_jsx_runtime320.jsx)(PostFormatCheck, { children: /* @__PURE__ */ (0, import_jsx_runtime320.jsx)(post_panel_row_default, { label: (0, import_i18n203.__)("Format"), ref: setPopoverAnchor, children: /* @__PURE__ */ (0, import_jsx_runtime320.jsx)( 46315 import_components192.Dropdown, 46316 { 46317 popoverProps, 46318 contentClassName: "editor-post-format__dialog", 46319 focusOnMount: true, 46320 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime320.jsx)( 46321 import_components192.Button, 46322 { 46323 size: "compact", 46324 variant: "tertiary", 46325 "aria-expanded": isOpen, 46326 "aria-label": (0, import_i18n203.sprintf)( 46327 // translators: %s: Current post format. 46328 (0, import_i18n203.__)("Change format: %s"), 46329 activeFormat?.caption 46330 ), 46331 onClick: onToggle, 46332 children: activeFormat?.caption 46333 } 46334 ), 46335 renderContent: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime320.jsxs)("div", { className: "editor-post-format__dialog-content", children: [ 46336 /* @__PURE__ */ (0, import_jsx_runtime320.jsx)( 46337 import_block_editor82.__experimentalInspectorPopoverHeader, 46338 { 46339 title: (0, import_i18n203.__)("Format"), 46340 onClose 46341 } 46342 ), 46343 /* @__PURE__ */ (0, import_jsx_runtime320.jsx)(PostFormat, {}) 46344 ] }) 46345 } 46346 ) }) }); 46347 } 46348 var panel_default4 = PostFormat2; 46349 46350 // packages/editor/build-module/components/post-last-edited-panel/index.js 46351 var import_components193 = __toESM(require_components()); 46352 var import_data208 = __toESM(require_data()); 46353 var import_i18n204 = __toESM(require_i18n()); 46354 var import_date7 = __toESM(require_date()); 46355 var import_jsx_runtime321 = __toESM(require_jsx_runtime()); 46356 function PostLastEditedPanel() { 46357 const modified = (0, import_data208.useSelect)( 46358 (select5) => select5(store).getEditedPostAttribute("modified"), 46359 [] 46360 ); 46361 const lastEditedText = modified && (0, import_i18n204.sprintf)( 46362 // translators: %s: Human-readable time difference, e.g. "2 days ago". 46363 (0, import_i18n204.__)("Last edited %s."), 46364 (0, import_date7.humanTimeDiff)(modified) 46365 ); 46366 if (!lastEditedText) { 46367 return null; 46368 } 46369 return /* @__PURE__ */ (0, import_jsx_runtime321.jsx)("div", { className: "editor-post-last-edited-panel", children: /* @__PURE__ */ (0, import_jsx_runtime321.jsx)(import_components193.__experimentalText, { children: lastEditedText }) }); 46370 } 46371 46372 // packages/editor/build-module/components/post-panel-section/index.js 46373 var import_components194 = __toESM(require_components()); 46374 var import_jsx_runtime322 = __toESM(require_jsx_runtime()); 46375 function PostPanelSection({ className, children }) { 46376 return /* @__PURE__ */ (0, import_jsx_runtime322.jsx)(import_components194.__experimentalVStack, { className: clsx_default("editor-post-panel__section", className), children }); 46377 } 46378 var post_panel_section_default = PostPanelSection; 46379 46380 // packages/editor/build-module/components/blog-title/index.js 46381 var import_i18n205 = __toESM(require_i18n()); 46382 var import_compose58 = __toESM(require_compose()); 46383 var import_data209 = __toESM(require_data()); 46384 var import_core_data112 = __toESM(require_core_data()); 46385 var import_html_entities28 = __toESM(require_html_entities()); 46386 var import_components195 = __toESM(require_components()); 46387 var import_element159 = __toESM(require_element()); 46388 var import_block_editor83 = __toESM(require_block_editor()); 46389 var import_jsx_runtime323 = __toESM(require_jsx_runtime()); 46390 var EMPTY_OBJECT4 = {}; 46391 function BlogTitle() { 46392 const { editEntityRecord } = (0, import_data209.useDispatch)(import_core_data112.store); 46393 const { postsPageTitle, postsPageId, isTemplate: isTemplate2, postSlug } = (0, import_data209.useSelect)( 46394 (select5) => { 46395 const { getEntityRecord, getEditedEntityRecord, canUser } = select5(import_core_data112.store); 46396 const siteSettings = canUser("read", { 46397 kind: "root", 46398 name: "site" 46399 }) ? getEntityRecord("root", "site") : void 0; 46400 const _postsPageRecord = siteSettings?.page_for_posts ? getEditedEntityRecord( 46401 "postType", 46402 "page", 46403 siteSettings?.page_for_posts 46404 ) : EMPTY_OBJECT4; 46405 const { getEditedPostAttribute: getEditedPostAttribute2, getCurrentPostType: getCurrentPostType2 } = select5(store); 46406 return { 46407 postsPageId: _postsPageRecord?.id, 46408 postsPageTitle: _postsPageRecord?.title, 46409 isTemplate: getCurrentPostType2() === TEMPLATE_POST_TYPE, 46410 postSlug: getEditedPostAttribute2("slug") 46411 }; 46412 }, 46413 [] 46414 ); 46415 const [popoverAnchor, setPopoverAnchor] = (0, import_element159.useState)(null); 46416 const popoverProps = (0, import_element159.useMemo)( 46417 () => ({ 46418 // Anchor the popover to the middle of the entire row so that it doesn't 46419 // move around when the label changes. 46420 anchor: popoverAnchor, 46421 placement: "left-start", 46422 offset: 36, 46423 shift: true 46424 }), 46425 [popoverAnchor] 46426 ); 46427 if (!isTemplate2 || !["home", "index"].includes(postSlug) || !postsPageId) { 46428 return null; 46429 } 46430 const setPostsPageTitle = (newValue) => { 46431 editEntityRecord("postType", "page", postsPageId, { 46432 title: newValue 46433 }); 46434 }; 46435 const decodedTitle = (0, import_html_entities28.decodeEntities)(postsPageTitle); 46436 return /* @__PURE__ */ (0, import_jsx_runtime323.jsx)(post_panel_row_default, { label: (0, import_i18n205.__)("Blog title"), ref: setPopoverAnchor, children: /* @__PURE__ */ (0, import_jsx_runtime323.jsx)( 46437 import_components195.Dropdown, 46438 { 46439 popoverProps, 46440 contentClassName: "editor-blog-title-dropdown__content", 46441 focusOnMount: true, 46442 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime323.jsx)( 46443 import_components195.Button, 46444 { 46445 size: "compact", 46446 variant: "tertiary", 46447 "aria-expanded": isOpen, 46448 "aria-label": (0, import_i18n205.sprintf)( 46449 // translators: %s: Current post link. 46450 (0, import_i18n205.__)("Change blog title: %s"), 46451 decodedTitle 46452 ), 46453 onClick: onToggle, 46454 children: decodedTitle 46455 } 46456 ), 46457 renderContent: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime323.jsxs)(import_jsx_runtime323.Fragment, { children: [ 46458 /* @__PURE__ */ (0, import_jsx_runtime323.jsx)( 46459 import_block_editor83.__experimentalInspectorPopoverHeader, 46460 { 46461 title: (0, import_i18n205.__)("Blog title"), 46462 onClose 46463 } 46464 ), 46465 /* @__PURE__ */ (0, import_jsx_runtime323.jsx)( 46466 import_components195.__experimentalInputControl, 46467 { 46468 placeholder: (0, import_i18n205.__)("No title"), 46469 size: "__unstable-large", 46470 value: postsPageTitle, 46471 onChange: (0, import_compose58.debounce)(setPostsPageTitle, 300), 46472 label: (0, import_i18n205.__)("Blog title"), 46473 help: (0, import_i18n205.__)( 46474 "Set the Posts Page title. Appears in search results, and when the page is shared on social media." 46475 ), 46476 hideLabelFromVision: true 46477 } 46478 ) 46479 ] }) 46480 } 46481 ) }); 46482 } 46483 46484 // packages/editor/build-module/components/posts-per-page/index.js 46485 var import_i18n206 = __toESM(require_i18n()); 46486 var import_data210 = __toESM(require_data()); 46487 var import_core_data113 = __toESM(require_core_data()); 46488 var import_components196 = __toESM(require_components()); 46489 var import_element160 = __toESM(require_element()); 46490 var import_block_editor84 = __toESM(require_block_editor()); 46491 var import_jsx_runtime324 = __toESM(require_jsx_runtime()); 46492 function PostsPerPage() { 46493 const { editEntityRecord } = (0, import_data210.useDispatch)(import_core_data113.store); 46494 const { postsPerPage, isTemplate: isTemplate2, postSlug } = (0, import_data210.useSelect)((select5) => { 46495 const { getEditedPostAttribute: getEditedPostAttribute2, getCurrentPostType: getCurrentPostType2 } = select5(store); 46496 const { getEditedEntityRecord, canUser } = select5(import_core_data113.store); 46497 const siteSettings = canUser("read", { 46498 kind: "root", 46499 name: "site" 46500 }) ? getEditedEntityRecord("root", "site") : void 0; 46501 return { 46502 isTemplate: getCurrentPostType2() === TEMPLATE_POST_TYPE, 46503 postSlug: getEditedPostAttribute2("slug"), 46504 postsPerPage: siteSettings?.posts_per_page || 1 46505 }; 46506 }, []); 46507 const [popoverAnchor, setPopoverAnchor] = (0, import_element160.useState)(null); 46508 const popoverProps = (0, import_element160.useMemo)( 46509 () => ({ 46510 // Anchor the popover to the middle of the entire row so that it doesn't 46511 // move around when the label changes. 46512 anchor: popoverAnchor, 46513 placement: "left-start", 46514 offset: 36, 46515 shift: true 46516 }), 46517 [popoverAnchor] 46518 ); 46519 if (!isTemplate2 || !["home", "index"].includes(postSlug)) { 46520 return null; 46521 } 46522 const setPostsPerPage = (newValue) => { 46523 editEntityRecord("root", "site", void 0, { 46524 posts_per_page: newValue 46525 }); 46526 }; 46527 return /* @__PURE__ */ (0, import_jsx_runtime324.jsx)(post_panel_row_default, { label: (0, import_i18n206.__)("Posts per page"), ref: setPopoverAnchor, children: /* @__PURE__ */ (0, import_jsx_runtime324.jsx)( 46528 import_components196.Dropdown, 46529 { 46530 popoverProps, 46531 contentClassName: "editor-posts-per-page-dropdown__content", 46532 focusOnMount: true, 46533 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime324.jsx)( 46534 import_components196.Button, 46535 { 46536 size: "compact", 46537 variant: "tertiary", 46538 "aria-expanded": isOpen, 46539 "aria-label": (0, import_i18n206.__)("Change posts per page"), 46540 onClick: onToggle, 46541 children: postsPerPage 46542 } 46543 ), 46544 renderContent: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime324.jsxs)(import_jsx_runtime324.Fragment, { children: [ 46545 /* @__PURE__ */ (0, import_jsx_runtime324.jsx)( 46546 import_block_editor84.__experimentalInspectorPopoverHeader, 46547 { 46548 title: (0, import_i18n206.__)("Posts per page"), 46549 onClose 46550 } 46551 ), 46552 /* @__PURE__ */ (0, import_jsx_runtime324.jsx)( 46553 import_components196.__experimentalNumberControl, 46554 { 46555 placeholder: 0, 46556 value: postsPerPage, 46557 size: "__unstable-large", 46558 spinControls: "custom", 46559 step: "1", 46560 min: "1", 46561 onChange: setPostsPerPage, 46562 label: (0, import_i18n206.__)("Posts per page"), 46563 help: (0, import_i18n206.__)( 46564 "Set the default number of posts to display on blog pages, including categories and tags. Some templates may override this setting." 46565 ), 46566 hideLabelFromVision: true 46567 } 46568 ) 46569 ] }) 46570 } 46571 ) }); 46572 } 46573 46574 // packages/editor/build-module/components/site-discussion/index.js 46575 var import_i18n207 = __toESM(require_i18n()); 46576 var import_data211 = __toESM(require_data()); 46577 var import_core_data114 = __toESM(require_core_data()); 46578 var import_components197 = __toESM(require_components()); 46579 var import_element161 = __toESM(require_element()); 46580 var import_block_editor85 = __toESM(require_block_editor()); 46581 var import_jsx_runtime325 = __toESM(require_jsx_runtime()); 46582 var COMMENT_OPTIONS2 = [ 46583 { 46584 label: (0, import_i18n207._x)("Open", 'Adjective: e.g. "Comments are open"'), 46585 value: "open", 46586 description: (0, import_i18n207.__)("Visitors can add new comments and replies.") 46587 }, 46588 { 46589 label: (0, import_i18n207.__)("Closed"), 46590 value: "", 46591 description: [ 46592 (0, import_i18n207.__)("Visitors cannot add new comments or replies."), 46593 (0, import_i18n207.__)("Existing comments remain visible.") 46594 ].join(" ") 46595 } 46596 ]; 46597 function SiteDiscussion() { 46598 const { editEntityRecord } = (0, import_data211.useDispatch)(import_core_data114.store); 46599 const { allowCommentsOnNewPosts, isTemplate: isTemplate2, postSlug } = (0, import_data211.useSelect)( 46600 (select5) => { 46601 const { getEditedPostAttribute: getEditedPostAttribute2, getCurrentPostType: getCurrentPostType2 } = select5(store); 46602 const { getEditedEntityRecord, canUser } = select5(import_core_data114.store); 46603 const siteSettings = canUser("read", { 46604 kind: "root", 46605 name: "site" 46606 }) ? getEditedEntityRecord("root", "site") : void 0; 46607 return { 46608 isTemplate: getCurrentPostType2() === TEMPLATE_POST_TYPE, 46609 postSlug: getEditedPostAttribute2("slug"), 46610 allowCommentsOnNewPosts: siteSettings?.default_comment_status || "" 46611 }; 46612 }, 46613 [] 46614 ); 46615 const [popoverAnchor, setPopoverAnchor] = (0, import_element161.useState)(null); 46616 const popoverProps = (0, import_element161.useMemo)( 46617 () => ({ 46618 // Anchor the popover to the middle of the entire row so that it doesn't 46619 // move around when the label changes. 46620 anchor: popoverAnchor, 46621 placement: "left-start", 46622 offset: 36, 46623 shift: true 46624 }), 46625 [popoverAnchor] 46626 ); 46627 if (!isTemplate2 || !["home", "index"].includes(postSlug)) { 46628 return null; 46629 } 46630 const setAllowCommentsOnNewPosts = (newValue) => { 46631 editEntityRecord("root", "site", void 0, { 46632 default_comment_status: newValue ? "open" : null 46633 }); 46634 }; 46635 return /* @__PURE__ */ (0, import_jsx_runtime325.jsx)(post_panel_row_default, { label: (0, import_i18n207.__)("Discussion"), ref: setPopoverAnchor, children: /* @__PURE__ */ (0, import_jsx_runtime325.jsx)( 46636 import_components197.Dropdown, 46637 { 46638 popoverProps, 46639 contentClassName: "editor-site-discussion-dropdown__content", 46640 focusOnMount: true, 46641 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime325.jsx)( 46642 import_components197.Button, 46643 { 46644 size: "compact", 46645 variant: "tertiary", 46646 "aria-expanded": isOpen, 46647 "aria-label": (0, import_i18n207.__)("Change discussion settings"), 46648 onClick: onToggle, 46649 children: allowCommentsOnNewPosts ? (0, import_i18n207.__)("Comments open") : (0, import_i18n207.__)("Comments closed") 46650 } 46651 ), 46652 renderContent: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime325.jsxs)(import_jsx_runtime325.Fragment, { children: [ 46653 /* @__PURE__ */ (0, import_jsx_runtime325.jsx)( 46654 import_block_editor85.__experimentalInspectorPopoverHeader, 46655 { 46656 title: (0, import_i18n207.__)("Discussion"), 46657 onClose 46658 } 46659 ), 46660 /* @__PURE__ */ (0, import_jsx_runtime325.jsxs)(import_components197.__experimentalVStack, { spacing: 3, children: [ 46661 /* @__PURE__ */ (0, import_jsx_runtime325.jsx)(import_components197.__experimentalText, { children: (0, import_i18n207.__)( 46662 "Changes will apply to new posts only. Individual posts may override these settings." 46663 ) }), 46664 /* @__PURE__ */ (0, import_jsx_runtime325.jsx)( 46665 import_components197.RadioControl, 46666 { 46667 className: "editor-site-discussion__options", 46668 hideLabelFromVision: true, 46669 label: (0, import_i18n207.__)("Comment status"), 46670 options: COMMENT_OPTIONS2, 46671 onChange: setAllowCommentsOnNewPosts, 46672 selected: allowCommentsOnNewPosts 46673 } 46674 ) 46675 ] }) 46676 ] }) 46677 } 46678 ) }); 46679 } 46680 46681 // packages/editor/build-module/components/sidebar/post-summary.js 46682 var import_jsx_runtime326 = __toESM(require_jsx_runtime()); 46683 var PANEL_NAME5 = "post-status"; 46684 function PostSummary({ onActionPerformed }) { 46685 const { isRemovedPostStatusPanel, postType: postType2, postId: postId2 } = (0, import_data212.useSelect)( 46686 (select5) => { 46687 const { 46688 isEditorPanelRemoved: isEditorPanelRemoved2, 46689 getCurrentPostType: getCurrentPostType2, 46690 getCurrentPostId: getCurrentPostId2 46691 } = select5(store); 46692 return { 46693 isRemovedPostStatusPanel: isEditorPanelRemoved2(PANEL_NAME5), 46694 postType: getCurrentPostType2(), 46695 postId: getCurrentPostId2() 46696 }; 46697 }, 46698 [] 46699 ); 46700 return /* @__PURE__ */ (0, import_jsx_runtime326.jsx)(post_panel_section_default, { className: "editor-post-summary", children: /* @__PURE__ */ (0, import_jsx_runtime326.jsx)(plugin_post_status_info_default.Slot, { children: (fills) => /* @__PURE__ */ (0, import_jsx_runtime326.jsx)(import_jsx_runtime326.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime326.jsxs)(import_components198.__experimentalVStack, { spacing: 4, children: [ 46701 /* @__PURE__ */ (0, import_jsx_runtime326.jsx)( 46702 PostCardPanel, 46703 { 46704 postType: postType2, 46705 postId: postId2, 46706 onActionPerformed 46707 } 46708 ), 46709 /* @__PURE__ */ (0, import_jsx_runtime326.jsx)(PostFeaturedImagePanel, { withPanelBody: false }), 46710 /* @__PURE__ */ (0, import_jsx_runtime326.jsx)(PrivatePostExcerptPanel, {}), 46711 /* @__PURE__ */ (0, import_jsx_runtime326.jsxs)(import_components198.__experimentalVStack, { spacing: 1, children: [ 46712 /* @__PURE__ */ (0, import_jsx_runtime326.jsx)(PostContentInformation, {}), 46713 /* @__PURE__ */ (0, import_jsx_runtime326.jsx)(PostLastEditedPanel, {}) 46714 ] }), 46715 !isRemovedPostStatusPanel && /* @__PURE__ */ (0, import_jsx_runtime326.jsxs)(import_components198.__experimentalVStack, { spacing: 4, children: [ 46716 /* @__PURE__ */ (0, import_jsx_runtime326.jsxs)(import_components198.__experimentalVStack, { spacing: 1, children: [ 46717 /* @__PURE__ */ (0, import_jsx_runtime326.jsx)(PostStatus, {}), 46718 /* @__PURE__ */ (0, import_jsx_runtime326.jsx)(PostSchedulePanel, {}), 46719 /* @__PURE__ */ (0, import_jsx_runtime326.jsx)(PostURLPanel, {}), 46720 /* @__PURE__ */ (0, import_jsx_runtime326.jsx)(panel_default, {}), 46721 /* @__PURE__ */ (0, import_jsx_runtime326.jsx)(PostTemplatePanel, {}), 46722 /* @__PURE__ */ (0, import_jsx_runtime326.jsx)(PostDiscussionPanel, {}), 46723 /* @__PURE__ */ (0, import_jsx_runtime326.jsx)(PrivatePostLastRevision, {}), 46724 /* @__PURE__ */ (0, import_jsx_runtime326.jsx)(PageAttributesPanel, {}), 46725 /* @__PURE__ */ (0, import_jsx_runtime326.jsx)(PostSyncStatus, {}), 46726 /* @__PURE__ */ (0, import_jsx_runtime326.jsx)(BlogTitle, {}), 46727 /* @__PURE__ */ (0, import_jsx_runtime326.jsx)(PostsPerPage, {}), 46728 /* @__PURE__ */ (0, import_jsx_runtime326.jsx)(SiteDiscussion, {}), 46729 /* @__PURE__ */ (0, import_jsx_runtime326.jsx)(panel_default4, {}), 46730 fills 46731 ] }), 46732 /* @__PURE__ */ (0, import_jsx_runtime326.jsx)( 46733 PostTrash, 46734 { 46735 onActionPerformed 46736 } 46737 ) 46738 ] }) 46739 ] }) }) }) }); 46740 } 46741 46742 // packages/editor/build-module/components/post-transform-panel/index.js 46743 var import_data214 = __toESM(require_data()); 46744 var import_core_data116 = __toESM(require_core_data()); 46745 var import_components199 = __toESM(require_components()); 46746 var import_i18n208 = __toESM(require_i18n()); 46747 var import_block_editor86 = __toESM(require_block_editor()); 46748 var import_blocks34 = __toESM(require_blocks()); 46749 46750 // packages/editor/build-module/components/post-transform-panel/hooks.js 46751 var import_data213 = __toESM(require_data()); 46752 var import_element162 = __toESM(require_element()); 46753 var import_core_data115 = __toESM(require_core_data()); 46754 var import_blocks33 = __toESM(require_blocks()); 46755 var import_patterns10 = __toESM(require_patterns()); 46756 var { EXCLUDED_PATTERN_SOURCES, PATTERN_TYPES: PATTERN_TYPES5 } = unlock(import_patterns10.privateApis); 46757 function injectThemeAttributeInBlockTemplateContent(block, currentThemeStylesheet) { 46758 block.innerBlocks = block.innerBlocks.map((innerBlock) => { 46759 return injectThemeAttributeInBlockTemplateContent( 46760 innerBlock, 46761 currentThemeStylesheet 46762 ); 46763 }); 46764 if (block.name === "core/template-part" && block.attributes.theme === void 0) { 46765 block.attributes.theme = currentThemeStylesheet; 46766 } 46767 return block; 46768 } 46769 function filterPatterns(patterns2, template2) { 46770 const filterOutDuplicatesByName = (currentItem, index2, items) => index2 === items.findIndex((item) => currentItem.name === item.name); 46771 const filterOutExcludedPatternSources = (pattern) => !EXCLUDED_PATTERN_SOURCES.includes(pattern.source); 46772 const filterCompatiblePatterns = (pattern) => pattern.templateTypes?.includes(template2.slug) || pattern.blockTypes?.includes("core/template-part/" + template2.area); 46773 return patterns2.filter((pattern, index2, items) => { 46774 return filterOutDuplicatesByName(pattern, index2, items) && filterOutExcludedPatternSources(pattern) && filterCompatiblePatterns(pattern); 46775 }); 46776 } 46777 function preparePatterns(patterns2, currentThemeStylesheet) { 46778 return patterns2.map((pattern) => ({ 46779 ...pattern, 46780 keywords: pattern.keywords || [], 46781 type: PATTERN_TYPES5.theme, 46782 blocks: (0, import_blocks33.parse)(pattern.content, { 46783 __unstableSkipMigrationLogs: true 46784 }).map( 46785 (block) => injectThemeAttributeInBlockTemplateContent( 46786 block, 46787 currentThemeStylesheet 46788 ) 46789 ) 46790 })); 46791 } 46792 function useAvailablePatterns({ area, name: name2, slug }) { 46793 const { blockPatterns, restBlockPatterns, currentThemeStylesheet } = (0, import_data213.useSelect)((select5) => { 46794 const { getEditorSettings: getEditorSettings2 } = select5(store); 46795 const settings = getEditorSettings2(); 46796 return { 46797 blockPatterns: settings.__experimentalAdditionalBlockPatterns ?? settings.__experimentalBlockPatterns, 46798 restBlockPatterns: select5(import_core_data115.store).getBlockPatterns(), 46799 currentThemeStylesheet: select5(import_core_data115.store).getCurrentTheme().stylesheet 46800 }; 46801 }, []); 46802 return (0, import_element162.useMemo)(() => { 46803 const mergedPatterns = [ 46804 ...blockPatterns || [], 46805 ...restBlockPatterns || [] 46806 ]; 46807 const filteredPatterns = filterPatterns(mergedPatterns, { 46808 area, 46809 name: name2, 46810 slug 46811 }); 46812 return preparePatterns(filteredPatterns, currentThemeStylesheet); 46813 }, [ 46814 area, 46815 name2, 46816 slug, 46817 blockPatterns, 46818 restBlockPatterns, 46819 currentThemeStylesheet 46820 ]); 46821 } 46822 46823 // packages/editor/build-module/components/post-transform-panel/index.js 46824 var import_jsx_runtime327 = __toESM(require_jsx_runtime()); 46825 function TemplatesList2({ availableTemplates, onSelect }) { 46826 if (!availableTemplates || availableTemplates?.length === 0) { 46827 return null; 46828 } 46829 return /* @__PURE__ */ (0, import_jsx_runtime327.jsx)( 46830 import_block_editor86.__experimentalBlockPatternsList, 46831 { 46832 label: (0, import_i18n208.__)("Templates"), 46833 blockPatterns: availableTemplates, 46834 onClickPattern: onSelect, 46835 showTitlesAsTooltip: true 46836 } 46837 ); 46838 } 46839 function PostTransform() { 46840 const { area, name: name2, slug, postType: postType2, postId: postId2 } = (0, import_data214.useSelect)((select5) => { 46841 const { getCurrentPostType: getCurrentPostType2, getCurrentPostId: getCurrentPostId2 } = select5(store); 46842 const { getEditedEntityRecord } = select5(import_core_data116.store); 46843 const type = getCurrentPostType2(); 46844 const id = getCurrentPostId2(); 46845 const record = getEditedEntityRecord("postType", type, id); 46846 return { 46847 area: record?.area, 46848 name: record?.name, 46849 slug: record?.slug, 46850 postType: type, 46851 postId: id 46852 }; 46853 }, []); 46854 const { editEntityRecord } = (0, import_data214.useDispatch)(import_core_data116.store); 46855 const availablePatterns = useAvailablePatterns({ area, name: name2, slug }); 46856 const onTemplateSelect = async (selectedTemplate) => { 46857 await editEntityRecord("postType", postType2, postId2, { 46858 blocks: selectedTemplate.blocks, 46859 content: (0, import_blocks34.serialize)(selectedTemplate.blocks) 46860 }); 46861 }; 46862 if (!availablePatterns?.length) { 46863 return null; 46864 } 46865 return /* @__PURE__ */ (0, import_jsx_runtime327.jsx)( 46866 import_components199.PanelBody, 46867 { 46868 title: (0, import_i18n208.__)("Design"), 46869 initialOpen: postType2 === TEMPLATE_PART_POST_TYPE, 46870 children: /* @__PURE__ */ (0, import_jsx_runtime327.jsx)( 46871 TemplatesList2, 46872 { 46873 availableTemplates: availablePatterns, 46874 onSelect: onTemplateSelect 46875 } 46876 ) 46877 } 46878 ); 46879 } 46880 function PostTransformPanel() { 46881 const { postType: postType2 } = (0, import_data214.useSelect)((select5) => { 46882 const { getCurrentPostType: getCurrentPostType2 } = select5(store); 46883 return { 46884 postType: getCurrentPostType2() 46885 }; 46886 }, []); 46887 if (![TEMPLATE_PART_POST_TYPE, TEMPLATE_POST_TYPE].includes(postType2)) { 46888 return null; 46889 } 46890 return /* @__PURE__ */ (0, import_jsx_runtime327.jsx)(PostTransform, {}); 46891 } 46892 46893 // packages/editor/build-module/components/sidebar/header.js 46894 var import_components200 = __toESM(require_components()); 46895 var import_i18n209 = __toESM(require_i18n()); 46896 var import_data215 = __toESM(require_data()); 46897 var import_element163 = __toESM(require_element()); 46898 var import_html_entities29 = __toESM(require_html_entities()); 46899 46900 // packages/editor/build-module/components/sidebar/constants.js 46901 var sidebars = { 46902 document: "edit-post/document", 46903 block: "edit-post/block" 46904 }; 46905 46906 // packages/editor/build-module/components/sidebar/header.js 46907 var import_jsx_runtime328 = __toESM(require_jsx_runtime()); 46908 var { Tabs: Tabs4 } = unlock(import_components200.privateApis); 46909 var SidebarHeader = (_, ref) => { 46910 const postTypeLabel = (0, import_data215.useSelect)( 46911 (select5) => select5(store).getPostTypeLabel(), 46912 [] 46913 ); 46914 const documentLabel = postTypeLabel ? (0, import_html_entities29.decodeEntities)(postTypeLabel) : ( 46915 // translators: Default label for the Document sidebar tab, not selected. 46916 (0, import_i18n209._x)("Document", "noun, panel") 46917 ); 46918 return /* @__PURE__ */ (0, import_jsx_runtime328.jsxs)(Tabs4.TabList, { ref, children: [ 46919 /* @__PURE__ */ (0, import_jsx_runtime328.jsx)( 46920 Tabs4.Tab, 46921 { 46922 tabId: sidebars.document, 46923 "data-tab-id": sidebars.document, 46924 children: documentLabel 46925 } 46926 ), 46927 /* @__PURE__ */ (0, import_jsx_runtime328.jsx)( 46928 Tabs4.Tab, 46929 { 46930 tabId: sidebars.block, 46931 "data-tab-id": sidebars.block, 46932 children: (0, import_i18n209.__)("Block") 46933 } 46934 ) 46935 ] }); 46936 }; 46937 var header_default3 = (0, import_element163.forwardRef)(SidebarHeader); 46938 46939 // packages/editor/build-module/components/template-content-panel/index.js 46940 var import_data216 = __toESM(require_data()); 46941 var import_block_editor87 = __toESM(require_block_editor()); 46942 var import_components201 = __toESM(require_components()); 46943 var import_i18n210 = __toESM(require_i18n()); 46944 var import_hooks55 = __toESM(require_hooks()); 46945 var import_element164 = __toESM(require_element()); 46946 var import_jsx_runtime329 = __toESM(require_jsx_runtime()); 46947 var { BlockQuickNavigation } = unlock(import_block_editor87.privateApis); 46948 var POST_CONTENT_BLOCK_TYPES2 = [ 46949 "core/post-title", 46950 "core/post-featured-image", 46951 "core/post-content" 46952 ]; 46953 var TEMPLATE_PART_BLOCK = "core/template-part"; 46954 function TemplateContentPanel() { 46955 const postContentBlockTypes = (0, import_element164.useMemo)( 46956 () => (0, import_hooks55.applyFilters)( 46957 "editor.postContentBlockTypes", 46958 POST_CONTENT_BLOCK_TYPES2 46959 ), 46960 [] 46961 ); 46962 const { clientIds, postType: postType2, renderingMode: renderingMode2 } = (0, import_data216.useSelect)( 46963 (select5) => { 46964 const { 46965 getCurrentPostType: getCurrentPostType2, 46966 getPostBlocksByName: getPostBlocksByName2, 46967 getRenderingMode: getRenderingMode2 46968 } = unlock(select5(store)); 46969 const _postType = getCurrentPostType2(); 46970 return { 46971 postType: _postType, 46972 clientIds: getPostBlocksByName2( 46973 TEMPLATE_POST_TYPE === _postType ? TEMPLATE_PART_BLOCK : postContentBlockTypes 46974 ), 46975 renderingMode: getRenderingMode2() 46976 }; 46977 }, 46978 [postContentBlockTypes] 46979 ); 46980 const { enableComplementaryArea: enableComplementaryArea2 } = (0, import_data216.useDispatch)(store2); 46981 if (renderingMode2 === "post-only" && postType2 !== TEMPLATE_POST_TYPE || clientIds.length === 0) { 46982 return null; 46983 } 46984 return /* @__PURE__ */ (0, import_jsx_runtime329.jsx)(import_components201.PanelBody, { title: (0, import_i18n210.__)("Content"), children: /* @__PURE__ */ (0, import_jsx_runtime329.jsx)( 46985 BlockQuickNavigation, 46986 { 46987 clientIds, 46988 onSelect: () => { 46989 enableComplementaryArea2("core", "edit-post/document"); 46990 } 46991 } 46992 ) }); 46993 } 46994 46995 // packages/editor/build-module/components/template-part-content-panel/index.js 46996 var import_data217 = __toESM(require_data()); 46997 var import_element165 = __toESM(require_element()); 46998 var import_blocks35 = __toESM(require_blocks()); 46999 var import_block_editor88 = __toESM(require_block_editor()); 47000 var import_components202 = __toESM(require_components()); 47001 var import_i18n211 = __toESM(require_i18n()); 47002 var import_jsx_runtime330 = __toESM(require_jsx_runtime()); 47003 var { BlockQuickNavigation: BlockQuickNavigation2 } = unlock(import_block_editor88.privateApis); 47004 function TemplatePartContentPanelInner() { 47005 const blockTypes = (0, import_data217.useSelect)((select5) => { 47006 const { getBlockTypes: getBlockTypes6 } = select5(import_blocks35.store); 47007 return getBlockTypes6(); 47008 }, []); 47009 const themeBlockNames = (0, import_element165.useMemo)(() => { 47010 return blockTypes.filter((blockType) => { 47011 return blockType.category === "theme"; 47012 }).map(({ name: name2 }) => name2); 47013 }, [blockTypes]); 47014 const themeBlocks = (0, import_data217.useSelect)( 47015 (select5) => { 47016 const { getBlocksByName } = select5(import_block_editor88.store); 47017 return getBlocksByName(themeBlockNames); 47018 }, 47019 [themeBlockNames] 47020 ); 47021 if (themeBlocks.length === 0) { 47022 return null; 47023 } 47024 return /* @__PURE__ */ (0, import_jsx_runtime330.jsx)(import_components202.PanelBody, { title: (0, import_i18n211.__)("Content"), children: /* @__PURE__ */ (0, import_jsx_runtime330.jsx)(BlockQuickNavigation2, { clientIds: themeBlocks }) }); 47025 } 47026 function TemplatePartContentPanel() { 47027 const postType2 = (0, import_data217.useSelect)((select5) => { 47028 const { getCurrentPostType: getCurrentPostType2 } = select5(store); 47029 return getCurrentPostType2(); 47030 }, []); 47031 if (postType2 !== TEMPLATE_PART_POST_TYPE) { 47032 return null; 47033 } 47034 return /* @__PURE__ */ (0, import_jsx_runtime330.jsx)(TemplatePartContentPanelInner, {}); 47035 } 47036 47037 // packages/editor/build-module/components/provider/use-auto-switch-editor-sidebars.js 47038 var import_data218 = __toESM(require_data()); 47039 var import_element166 = __toESM(require_element()); 47040 var import_block_editor89 = __toESM(require_block_editor()); 47041 var import_preferences23 = __toESM(require_preferences()); 47042 function useAutoSwitchEditorSidebars() { 47043 const { hasBlockSelection } = (0, import_data218.useSelect)((select5) => { 47044 return { 47045 hasBlockSelection: !!select5(import_block_editor89.store).getBlockSelectionStart() 47046 }; 47047 }, []); 47048 const { getActiveComplementaryArea: getActiveComplementaryArea2 } = (0, import_data218.useSelect)(store2); 47049 const { enableComplementaryArea: enableComplementaryArea2 } = (0, import_data218.useDispatch)(store2); 47050 const { get: getPreference } = (0, import_data218.useSelect)(import_preferences23.store); 47051 (0, import_element166.useEffect)(() => { 47052 const activeGeneralSidebar = getActiveComplementaryArea2("core"); 47053 const isEditorSidebarOpened = [ 47054 "edit-post/document", 47055 "edit-post/block" 47056 ].includes(activeGeneralSidebar); 47057 const isDistractionFree = getPreference("core", "distractionFree"); 47058 if (!isEditorSidebarOpened || isDistractionFree) { 47059 return; 47060 } 47061 if (hasBlockSelection) { 47062 enableComplementaryArea2("core", "edit-post/block"); 47063 } else { 47064 enableComplementaryArea2("core", "edit-post/document"); 47065 } 47066 }, [ 47067 hasBlockSelection, 47068 getActiveComplementaryArea2, 47069 enableComplementaryArea2, 47070 getPreference 47071 ]); 47072 } 47073 var use_auto_switch_editor_sidebars_default = useAutoSwitchEditorSidebars; 47074 47075 // packages/editor/build-module/components/sidebar/index.js 47076 var import_jsx_runtime331 = __toESM(require_jsx_runtime()); 47077 var { Tabs: Tabs5 } = unlock(import_components203.privateApis); 47078 var SIDEBAR_ACTIVE_BY_DEFAULT = import_element167.Platform.select({ 47079 web: true, 47080 native: false 47081 }); 47082 var SidebarContent = ({ 47083 tabName, 47084 keyboardShortcut, 47085 onActionPerformed, 47086 extraPanels 47087 }) => { 47088 const tabListRef = (0, import_element167.useRef)(null); 47089 const tabsContextValue = (0, import_element167.useContext)(Tabs5.Context); 47090 (0, import_element167.useEffect)(() => { 47091 const tabsElements = Array.from( 47092 tabListRef.current?.querySelectorAll('[role="tab"]') || [] 47093 ); 47094 const selectedTabElement = tabsElements.find( 47095 // We are purposefully using a custom `data-tab-id` attribute here 47096 // because we don't want rely on any assumptions about `Tabs` 47097 // component internals. 47098 (element) => element.getAttribute("data-tab-id") === tabName 47099 ); 47100 const activeElement = selectedTabElement?.ownerDocument.activeElement; 47101 const tabsHasFocus = tabsElements.some((element) => { 47102 return activeElement && activeElement.id === element.id; 47103 }); 47104 if (tabsHasFocus && selectedTabElement && selectedTabElement.id !== activeElement?.id) { 47105 selectedTabElement?.focus(); 47106 } 47107 }, [tabName]); 47108 return /* @__PURE__ */ (0, import_jsx_runtime331.jsx)( 47109 PluginSidebar, 47110 { 47111 identifier: tabName, 47112 header: /* @__PURE__ */ (0, import_jsx_runtime331.jsx)(Tabs5.Context.Provider, { value: tabsContextValue, children: /* @__PURE__ */ (0, import_jsx_runtime331.jsx)(header_default3, { ref: tabListRef }) }), 47113 closeLabel: (0, import_i18n212.__)("Close Settings"), 47114 className: "editor-sidebar__panel", 47115 headerClassName: "editor-sidebar__panel-tabs", 47116 title: ( 47117 /* translators: button label text should, if possible, be under 16 characters. */ 47118 (0, import_i18n212._x)("Settings", "panel button label") 47119 ), 47120 toggleShortcut: keyboardShortcut, 47121 icon: (0, import_i18n212.isRTL)() ? drawer_left_default : drawer_right_default, 47122 isActiveByDefault: SIDEBAR_ACTIVE_BY_DEFAULT, 47123 children: /* @__PURE__ */ (0, import_jsx_runtime331.jsxs)(Tabs5.Context.Provider, { value: tabsContextValue, children: [ 47124 /* @__PURE__ */ (0, import_jsx_runtime331.jsxs)(Tabs5.TabPanel, { tabId: sidebars.document, focusable: false, children: [ 47125 /* @__PURE__ */ (0, import_jsx_runtime331.jsx)(PostSummary, { onActionPerformed }), 47126 /* @__PURE__ */ (0, import_jsx_runtime331.jsx)(plugin_document_setting_panel_default.Slot, {}), 47127 /* @__PURE__ */ (0, import_jsx_runtime331.jsx)(TemplateContentPanel, {}), 47128 /* @__PURE__ */ (0, import_jsx_runtime331.jsx)(TemplatePartContentPanel, {}), 47129 /* @__PURE__ */ (0, import_jsx_runtime331.jsx)(PostTransformPanel, {}), 47130 /* @__PURE__ */ (0, import_jsx_runtime331.jsx)(PostTaxonomies2, {}), 47131 /* @__PURE__ */ (0, import_jsx_runtime331.jsx)(PatternOverridesPanel, {}), 47132 extraPanels 47133 ] }), 47134 /* @__PURE__ */ (0, import_jsx_runtime331.jsx)(Tabs5.TabPanel, { tabId: sidebars.block, focusable: false, children: /* @__PURE__ */ (0, import_jsx_runtime331.jsx)(import_block_editor90.BlockInspector, {}) }) 47135 ] }) 47136 } 47137 ); 47138 }; 47139 var Sidebar = ({ extraPanels, onActionPerformed }) => { 47140 use_auto_switch_editor_sidebars_default(); 47141 const { tabName, keyboardShortcut, showSummary } = (0, import_data219.useSelect)( 47142 (select5) => { 47143 const shortcut = select5( 47144 import_keyboard_shortcuts10.store 47145 ).getShortcutRepresentation("core/editor/toggle-sidebar"); 47146 const sidebar = select5(store2).getActiveComplementaryArea("core"); 47147 const _isEditorSidebarOpened = [ 47148 sidebars.block, 47149 sidebars.document 47150 ].includes(sidebar); 47151 let _tabName = sidebar; 47152 if (!_isEditorSidebarOpened) { 47153 _tabName = !!select5( 47154 import_block_editor90.store 47155 ).getBlockSelectionStart() ? sidebars.block : sidebars.document; 47156 } 47157 return { 47158 tabName: _tabName, 47159 keyboardShortcut: shortcut, 47160 showSummary: ![ 47161 TEMPLATE_POST_TYPE, 47162 TEMPLATE_PART_POST_TYPE, 47163 NAVIGATION_POST_TYPE 47164 ].includes(select5(store).getCurrentPostType()) 47165 }; 47166 }, 47167 [] 47168 ); 47169 const { enableComplementaryArea: enableComplementaryArea2 } = (0, import_data219.useDispatch)(store2); 47170 const onTabSelect = (0, import_element167.useCallback)( 47171 (newSelectedTabId) => { 47172 if (!!newSelectedTabId) { 47173 enableComplementaryArea2("core", newSelectedTabId); 47174 } 47175 }, 47176 [enableComplementaryArea2] 47177 ); 47178 return /* @__PURE__ */ (0, import_jsx_runtime331.jsx)( 47179 Tabs5, 47180 { 47181 selectedTabId: tabName, 47182 onSelect: onTabSelect, 47183 selectOnMove: false, 47184 children: /* @__PURE__ */ (0, import_jsx_runtime331.jsx)( 47185 SidebarContent, 47186 { 47187 tabName, 47188 keyboardShortcut, 47189 showSummary, 47190 onActionPerformed, 47191 extraPanels 47192 } 47193 ) 47194 } 47195 ); 47196 }; 47197 var sidebar_default2 = Sidebar; 47198 47199 // packages/editor/build-module/components/collab-sidebar/index.js 47200 var import_i18n221 = __toESM(require_i18n()); 47201 var import_data225 = __toESM(require_data()); 47202 var import_components210 = __toESM(require_components()); 47203 var import_element172 = __toESM(require_element()); 47204 var import_compose61 = __toESM(require_compose()); 47205 var import_block_editor97 = __toESM(require_block_editor()); 47206 47207 // packages/editor/build-module/components/collab-sidebar/constants.js 47208 var collabHistorySidebarName = "edit-post/collab-history-sidebar"; 47209 var collabSidebarName = "edit-post/collab-sidebar"; 47210 var SIDEBARS = [collabHistorySidebarName, collabSidebarName]; 47211 47212 // packages/editor/build-module/components/collab-sidebar/comments.js 47213 var import_element170 = __toESM(require_element()); 47214 var import_components207 = __toESM(require_components()); 47215 var import_compose60 = __toESM(require_compose()); 47216 var import_i18n218 = __toESM(require_i18n()); 47217 var import_data223 = __toESM(require_data()); 47218 var import_dom8 = __toESM(require_dom()); 47219 var import_block_editor94 = __toESM(require_block_editor()); 47220 47221 // packages/editor/build-module/components/collab-sidebar/comment-author-info.js 47222 var import_components204 = __toESM(require_components()); 47223 var import_i18n214 = __toESM(require_i18n()); 47224 var import_date8 = __toESM(require_date()); 47225 var import_core_data117 = __toESM(require_core_data()); 47226 var import_data220 = __toESM(require_data()); 47227 var import_block_editor91 = __toESM(require_block_editor()); 47228 47229 // packages/editor/build-module/components/collab-sidebar/utils.js 47230 var import_i18n213 = __toESM(require_i18n()); 47231 function sanitizeCommentString(str) { 47232 return str.trim(); 47233 } 47234 function noop6() { 47235 } 47236 var AVATAR_BORDER_COLORS = [ 47237 "#3858E9", 47238 // Blueberry 47239 "#9fB1FF", 47240 // Blueberry 2 47241 "#1D35B4", 47242 // Dark Blueberry 47243 "#1A1919", 47244 // Charcoal 0 47245 "#E26F56", 47246 // Pomegranate 47247 "#33F078", 47248 // Acid Green 47249 "#FFF972", 47250 // Lemon 47251 "#7A00DF" 47252 // Purple 47253 ]; 47254 function getAvatarBorderColor(userId) { 47255 return AVATAR_BORDER_COLORS[userId % AVATAR_BORDER_COLORS.length]; 47256 } 47257 function getCommentExcerpt(text, excerptLength = 10) { 47258 if (!text) { 47259 return ""; 47260 } 47261 const wordCountType = (0, import_i18n213._x)("words", "Word count type. Do not translate!"); 47262 const rawText = text.trim(); 47263 let trimmedExcerpt = ""; 47264 if (wordCountType === "words") { 47265 trimmedExcerpt = rawText.split(" ", excerptLength).join(" "); 47266 } else if (wordCountType === "characters_excluding_spaces") { 47267 const textWithSpaces = rawText.split("", excerptLength).join(""); 47268 const numberOfSpaces = textWithSpaces.length - textWithSpaces.replaceAll(" ", "").length; 47269 trimmedExcerpt = rawText.split("", excerptLength + numberOfSpaces).join(""); 47270 } else if (wordCountType === "characters_including_spaces") { 47271 trimmedExcerpt = rawText.split("", excerptLength).join(""); 47272 } 47273 const isTrimmed = trimmedExcerpt !== rawText; 47274 return isTrimmed ? trimmedExcerpt + "\u2026" : trimmedExcerpt; 47275 } 47276 function focusCommentThread(commentId, container, additionalSelector) { 47277 if (!container) { 47278 return; 47279 } 47280 const threadSelector = commentId ? `[role=treeitem][id="comment-thread-$commentId}"]` : "[role=treeitem]:not([id])"; 47281 const selector = additionalSelector ? `$threadSelector} $additionalSelector}` : threadSelector; 47282 return new Promise((resolve) => { 47283 if (container.querySelector(selector)) { 47284 return resolve(container.querySelector(selector)); 47285 } 47286 let timer = null; 47287 const observer = new window.MutationObserver(() => { 47288 if (container.querySelector(selector)) { 47289 clearTimeout(timer); 47290 observer.disconnect(); 47291 resolve(container.querySelector(selector)); 47292 } 47293 }); 47294 observer.observe(container, { 47295 childList: true, 47296 subtree: true 47297 }); 47298 timer = setTimeout(() => { 47299 observer.disconnect(); 47300 resolve(null); 47301 }, 3e3); 47302 }).then((element) => element?.focus()); 47303 } 47304 47305 // packages/editor/build-module/components/collab-sidebar/comment-author-info.js 47306 var import_jsx_runtime332 = __toESM(require_jsx_runtime()); 47307 function CommentAuthorInfo({ avatar, name: name2, date, userId }) { 47308 const hasAvatar = !!avatar; 47309 const dateSettings = (0, import_date8.getSettings)(); 47310 const { 47311 currentUserAvatar, 47312 currentUserName, 47313 currentUserId, 47314 dateFormat = dateSettings.formats.date 47315 } = (0, import_data220.useSelect)( 47316 (select5) => { 47317 const { canUser, getCurrentUser, getEntityRecord } = select5(import_core_data117.store); 47318 const siteSettings = canUser("read", { 47319 kind: "root", 47320 name: "site" 47321 }) ? getEntityRecord("root", "site") : void 0; 47322 if (hasAvatar) { 47323 return { 47324 dateFormat: siteSettings?.date_format 47325 }; 47326 } 47327 const { getSettings: getSettings5 } = select5(import_block_editor91.store); 47328 const { __experimentalDiscussionSettings } = getSettings5(); 47329 const defaultAvatar = __experimentalDiscussionSettings?.avatarURL; 47330 const userData = getCurrentUser(); 47331 return { 47332 currentUserAvatar: userData?.avatar_urls?.[48] ?? defaultAvatar, 47333 currentUserName: userData?.name, 47334 currentUserId: userData?.id, 47335 dateFormat: siteSettings?.date_format 47336 }; 47337 }, 47338 [hasAvatar] 47339 ); 47340 const commentDate = (0, import_date8.getDate)(date); 47341 const commentDateTime = (0, import_date8.dateI18n)("c", commentDate); 47342 const shouldShowHumanTimeDiff = Math.floor((/* @__PURE__ */ new Date() - commentDate) / (1e3 * 60 * 60 * 24)) < 30; 47343 const commentDateText = shouldShowHumanTimeDiff ? (0, import_date8.humanTimeDiff)(commentDate) : (0, import_date8.dateI18n)(dateFormat, commentDate); 47344 const tooltipText = (0, import_date8.dateI18n)( 47345 // translators: Use a non-breaking space between 'g:i' and 'a' if appropriate. 47346 (0, import_i18n214._x)("F j, Y g:i\xA0a", "Note date full date format"), 47347 date 47348 ); 47349 return /* @__PURE__ */ (0, import_jsx_runtime332.jsxs)(import_jsx_runtime332.Fragment, { children: [ 47350 /* @__PURE__ */ (0, import_jsx_runtime332.jsx)( 47351 "img", 47352 { 47353 src: avatar || currentUserAvatar, 47354 className: "editor-collab-sidebar-panel__user-avatar", 47355 alt: (0, import_i18n214.__)("User avatar"), 47356 width: 32, 47357 height: 32, 47358 style: { 47359 borderColor: getAvatarBorderColor( 47360 userId ?? currentUserId 47361 ) 47362 } 47363 } 47364 ), 47365 /* @__PURE__ */ (0, import_jsx_runtime332.jsxs)(import_components204.__experimentalVStack, { spacing: "0", children: [ 47366 /* @__PURE__ */ (0, import_jsx_runtime332.jsx)("span", { className: "editor-collab-sidebar-panel__user-name", children: name2 ?? currentUserName }), 47367 date && /* @__PURE__ */ (0, import_jsx_runtime332.jsx)(import_components204.Tooltip, { text: tooltipText, children: /* @__PURE__ */ (0, import_jsx_runtime332.jsx)( 47368 "time", 47369 { 47370 dateTime: commentDateTime, 47371 className: "editor-collab-sidebar-panel__user-time", 47372 children: commentDateText 47373 } 47374 ) }) 47375 ] }) 47376 ] }); 47377 } 47378 var comment_author_info_default = CommentAuthorInfo; 47379 47380 // packages/editor/build-module/components/collab-sidebar/comment-form.js 47381 var import_react_autosize_textarea2 = __toESM(require_lib()); 47382 var import_element168 = __toESM(require_element()); 47383 var import_components205 = __toESM(require_components()); 47384 var import_i18n215 = __toESM(require_i18n()); 47385 var import_compose59 = __toESM(require_compose()); 47386 var import_keycodes17 = __toESM(require_keycodes()); 47387 var import_jsx_runtime333 = __toESM(require_jsx_runtime()); 47388 function CommentForm({ 47389 onSubmit, 47390 onCancel, 47391 thread, 47392 submitButtonText, 47393 labelText, 47394 reflowComments = noop6 47395 }) { 47396 const [inputComment, setInputComment] = (0, import_element168.useState)( 47397 thread?.content?.raw ?? "" 47398 ); 47399 const debouncedCommentUpdated = (0, import_compose59.useDebounce)(reflowComments, 100); 47400 const updateComment = (value) => { 47401 setInputComment(value); 47402 }; 47403 const inputId = (0, import_compose59.useInstanceId)(CommentForm, "comment-input"); 47404 const isDisabled = inputComment === thread?.content?.raw || !sanitizeCommentString(inputComment).length; 47405 return /* @__PURE__ */ (0, import_jsx_runtime333.jsxs)( 47406 import_components205.__experimentalVStack, 47407 { 47408 className: "editor-collab-sidebar-panel__comment-form", 47409 spacing: "4", 47410 as: "form", 47411 onSubmit: (event) => { 47412 event.preventDefault(); 47413 onSubmit(inputComment); 47414 setInputComment(""); 47415 }, 47416 children: [ 47417 /* @__PURE__ */ (0, import_jsx_runtime333.jsx)(import_components205.VisuallyHidden, { as: "label", htmlFor: inputId, children: labelText ?? (0, import_i18n215.__)("Note") }), 47418 /* @__PURE__ */ (0, import_jsx_runtime333.jsx)( 47419 import_react_autosize_textarea2.default, 47420 { 47421 id: inputId, 47422 value: inputComment ?? "", 47423 onChange: (comment) => { 47424 updateComment(comment.target.value); 47425 debouncedCommentUpdated(); 47426 }, 47427 rows: 1, 47428 maxRows: 20, 47429 onKeyDown: (event) => { 47430 if (import_keycodes17.isKeyboardEvent.primary(event, "Enter") && !isDisabled) { 47431 event.target.parentNode.requestSubmit(); 47432 } 47433 } 47434 } 47435 ), 47436 /* @__PURE__ */ (0, import_jsx_runtime333.jsxs)(import_components205.__experimentalHStack, { spacing: "2", justify: "flex-end", wrap: true, children: [ 47437 /* @__PURE__ */ (0, import_jsx_runtime333.jsx)(import_components205.Button, { size: "compact", variant: "tertiary", onClick: onCancel, children: /* @__PURE__ */ (0, import_jsx_runtime333.jsx)(import_components205.__experimentalTruncate, { children: (0, import_i18n215.__)("Cancel") }) }), 47438 /* @__PURE__ */ (0, import_jsx_runtime333.jsx)( 47439 import_components205.Button, 47440 { 47441 size: "compact", 47442 accessibleWhenDisabled: true, 47443 variant: "primary", 47444 type: "submit", 47445 disabled: isDisabled, 47446 children: /* @__PURE__ */ (0, import_jsx_runtime333.jsx)(import_components205.__experimentalTruncate, { children: submitButtonText }) 47447 } 47448 ) 47449 ] }) 47450 ] 47451 } 47452 ); 47453 } 47454 var comment_form_default = CommentForm; 47455 47456 // node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs 47457 var min = Math.min; 47458 var max = Math.max; 47459 var round = Math.round; 47460 var floor = Math.floor; 47461 var createCoords = (v3) => ({ 47462 x: v3, 47463 y: v3 47464 }); 47465 function evaluate(value, param) { 47466 return typeof value === "function" ? value(param) : value; 47467 } 47468 function getSide(placement) { 47469 return placement.split("-")[0]; 47470 } 47471 function getAlignment(placement) { 47472 return placement.split("-")[1]; 47473 } 47474 function getOppositeAxis(axis) { 47475 return axis === "x" ? "y" : "x"; 47476 } 47477 function getAxisLength(axis) { 47478 return axis === "y" ? "height" : "width"; 47479 } 47480 var yAxisSides = /* @__PURE__ */ new Set(["top", "bottom"]); 47481 function getSideAxis(placement) { 47482 return yAxisSides.has(getSide(placement)) ? "y" : "x"; 47483 } 47484 function getAlignmentAxis(placement) { 47485 return getOppositeAxis(getSideAxis(placement)); 47486 } 47487 function rectToClientRect(rect) { 47488 const { 47489 x: x2, 47490 y: y3, 47491 width, 47492 height 47493 } = rect; 47494 return { 47495 width, 47496 height, 47497 top: y3, 47498 left: x2, 47499 right: x2 + width, 47500 bottom: y3 + height, 47501 x: x2, 47502 y: y3 47503 }; 47504 } 47505 47506 // node_modules/@floating-ui/core/dist/floating-ui.core.mjs 47507 function computeCoordsFromPlacement(_ref, placement, rtl) { 47508 let { 47509 reference, 47510 floating 47511 } = _ref; 47512 const sideAxis = getSideAxis(placement); 47513 const alignmentAxis = getAlignmentAxis(placement); 47514 const alignLength = getAxisLength(alignmentAxis); 47515 const side = getSide(placement); 47516 const isVertical = sideAxis === "y"; 47517 const commonX = reference.x + reference.width / 2 - floating.width / 2; 47518 const commonY = reference.y + reference.height / 2 - floating.height / 2; 47519 const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2; 47520 let coords; 47521 switch (side) { 47522 case "top": 47523 coords = { 47524 x: commonX, 47525 y: reference.y - floating.height 47526 }; 47527 break; 47528 case "bottom": 47529 coords = { 47530 x: commonX, 47531 y: reference.y + reference.height 47532 }; 47533 break; 47534 case "right": 47535 coords = { 47536 x: reference.x + reference.width, 47537 y: commonY 47538 }; 47539 break; 47540 case "left": 47541 coords = { 47542 x: reference.x - floating.width, 47543 y: commonY 47544 }; 47545 break; 47546 default: 47547 coords = { 47548 x: reference.x, 47549 y: reference.y 47550 }; 47551 } 47552 switch (getAlignment(placement)) { 47553 case "start": 47554 coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1); 47555 break; 47556 case "end": 47557 coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1); 47558 break; 47559 } 47560 return coords; 47561 } 47562 var computePosition = async (reference, floating, config) => { 47563 const { 47564 placement = "bottom", 47565 strategy = "absolute", 47566 middleware = [], 47567 platform: platform2 47568 } = config; 47569 const validMiddleware = middleware.filter(Boolean); 47570 const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(floating)); 47571 let rects = await platform2.getElementRects({ 47572 reference, 47573 floating, 47574 strategy 47575 }); 47576 let { 47577 x: x2, 47578 y: y3 47579 } = computeCoordsFromPlacement(rects, placement, rtl); 47580 let statefulPlacement = placement; 47581 let middlewareData = {}; 47582 let resetCount = 0; 47583 for (let i3 = 0; i3 < validMiddleware.length; i3++) { 47584 const { 47585 name: name2, 47586 fn 47587 } = validMiddleware[i3]; 47588 const { 47589 x: nextX, 47590 y: nextY, 47591 data, 47592 reset 47593 } = await fn({ 47594 x: x2, 47595 y: y3, 47596 initialPlacement: placement, 47597 placement: statefulPlacement, 47598 strategy, 47599 middlewareData, 47600 rects, 47601 platform: platform2, 47602 elements: { 47603 reference, 47604 floating 47605 } 47606 }); 47607 x2 = nextX != null ? nextX : x2; 47608 y3 = nextY != null ? nextY : y3; 47609 middlewareData = { 47610 ...middlewareData, 47611 [name2]: { 47612 ...middlewareData[name2], 47613 ...data 47614 } 47615 }; 47616 if (reset && resetCount <= 50) { 47617 resetCount++; 47618 if (typeof reset === "object") { 47619 if (reset.placement) { 47620 statefulPlacement = reset.placement; 47621 } 47622 if (reset.rects) { 47623 rects = reset.rects === true ? await platform2.getElementRects({ 47624 reference, 47625 floating, 47626 strategy 47627 }) : reset.rects; 47628 } 47629 ({ 47630 x: x2, 47631 y: y3 47632 } = computeCoordsFromPlacement(rects, statefulPlacement, rtl)); 47633 } 47634 i3 = -1; 47635 } 47636 } 47637 return { 47638 x: x2, 47639 y: y3, 47640 placement: statefulPlacement, 47641 strategy, 47642 middlewareData 47643 }; 47644 }; 47645 var originSides = /* @__PURE__ */ new Set(["left", "top"]); 47646 async function convertValueToCoords(state, options) { 47647 const { 47648 placement, 47649 platform: platform2, 47650 elements: elements2 47651 } = state; 47652 const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements2.floating)); 47653 const side = getSide(placement); 47654 const alignment = getAlignment(placement); 47655 const isVertical = getSideAxis(placement) === "y"; 47656 const mainAxisMulti = originSides.has(side) ? -1 : 1; 47657 const crossAxisMulti = rtl && isVertical ? -1 : 1; 47658 const rawValue = evaluate(options, state); 47659 let { 47660 mainAxis, 47661 crossAxis, 47662 alignmentAxis 47663 } = typeof rawValue === "number" ? { 47664 mainAxis: rawValue, 47665 crossAxis: 0, 47666 alignmentAxis: null 47667 } : { 47668 mainAxis: rawValue.mainAxis || 0, 47669 crossAxis: rawValue.crossAxis || 0, 47670 alignmentAxis: rawValue.alignmentAxis 47671 }; 47672 if (alignment && typeof alignmentAxis === "number") { 47673 crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis; 47674 } 47675 return isVertical ? { 47676 x: crossAxis * crossAxisMulti, 47677 y: mainAxis * mainAxisMulti 47678 } : { 47679 x: mainAxis * mainAxisMulti, 47680 y: crossAxis * crossAxisMulti 47681 }; 47682 } 47683 var offset = function(options) { 47684 if (options === void 0) { 47685 options = 0; 47686 } 47687 return { 47688 name: "offset", 47689 options, 47690 async fn(state) { 47691 var _middlewareData$offse, _middlewareData$arrow; 47692 const { 47693 x: x2, 47694 y: y3, 47695 placement, 47696 middlewareData 47697 } = state; 47698 const diffCoords = await convertValueToCoords(state, options); 47699 if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) { 47700 return {}; 47701 } 47702 return { 47703 x: x2 + diffCoords.x, 47704 y: y3 + diffCoords.y, 47705 data: { 47706 ...diffCoords, 47707 placement 47708 } 47709 }; 47710 } 47711 }; 47712 }; 47713 47714 // node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs 47715 function hasWindow() { 47716 return typeof window !== "undefined"; 47717 } 47718 function getNodeName(node) { 47719 if (isNode(node)) { 47720 return (node.nodeName || "").toLowerCase(); 47721 } 47722 return "#document"; 47723 } 47724 function getWindow(node) { 47725 var _node$ownerDocument; 47726 return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window; 47727 } 47728 function getDocumentElement(node) { 47729 var _ref; 47730 return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement; 47731 } 47732 function isNode(value) { 47733 if (!hasWindow()) { 47734 return false; 47735 } 47736 return value instanceof Node || value instanceof getWindow(value).Node; 47737 } 47738 function isElement(value) { 47739 if (!hasWindow()) { 47740 return false; 47741 } 47742 return value instanceof Element || value instanceof getWindow(value).Element; 47743 } 47744 function isHTMLElement(value) { 47745 if (!hasWindow()) { 47746 return false; 47747 } 47748 return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement; 47749 } 47750 function isShadowRoot(value) { 47751 if (!hasWindow() || typeof ShadowRoot === "undefined") { 47752 return false; 47753 } 47754 return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot; 47755 } 47756 var invalidOverflowDisplayValues = /* @__PURE__ */ new Set(["inline", "contents"]); 47757 function isOverflowElement(element) { 47758 const { 47759 overflow, 47760 overflowX, 47761 overflowY, 47762 display 47763 } = getComputedStyle(element); 47764 return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !invalidOverflowDisplayValues.has(display); 47765 } 47766 var tableElements = /* @__PURE__ */ new Set(["table", "td", "th"]); 47767 function isTableElement(element) { 47768 return tableElements.has(getNodeName(element)); 47769 } 47770 var topLayerSelectors = [":popover-open", ":modal"]; 47771 function isTopLayer(element) { 47772 return topLayerSelectors.some((selector) => { 47773 try { 47774 return element.matches(selector); 47775 } catch (_e) { 47776 return false; 47777 } 47778 }); 47779 } 47780 var transformProperties = ["transform", "translate", "scale", "rotate", "perspective"]; 47781 var willChangeValues = ["transform", "translate", "scale", "rotate", "perspective", "filter"]; 47782 var containValues = ["paint", "layout", "strict", "content"]; 47783 function isContainingBlock(elementOrCss) { 47784 const webkit = isWebKit(); 47785 const css = isElement(elementOrCss) ? getComputedStyle(elementOrCss) : elementOrCss; 47786 return transformProperties.some((value) => css[value] ? css[value] !== "none" : false) || (css.containerType ? css.containerType !== "normal" : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== "none" : false) || !webkit && (css.filter ? css.filter !== "none" : false) || willChangeValues.some((value) => (css.willChange || "").includes(value)) || containValues.some((value) => (css.contain || "").includes(value)); 47787 } 47788 function getContainingBlock(element) { 47789 let currentNode = getParentNode(element); 47790 while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) { 47791 if (isContainingBlock(currentNode)) { 47792 return currentNode; 47793 } else if (isTopLayer(currentNode)) { 47794 return null; 47795 } 47796 currentNode = getParentNode(currentNode); 47797 } 47798 return null; 47799 } 47800 function isWebKit() { 47801 if (typeof CSS === "undefined" || !CSS.supports) return false; 47802 return CSS.supports("-webkit-backdrop-filter", "none"); 47803 } 47804 var lastTraversableNodeNames = /* @__PURE__ */ new Set(["html", "body", "#document"]); 47805 function isLastTraversableNode(node) { 47806 return lastTraversableNodeNames.has(getNodeName(node)); 47807 } 47808 function getComputedStyle(element) { 47809 return getWindow(element).getComputedStyle(element); 47810 } 47811 function getNodeScroll(element) { 47812 if (isElement(element)) { 47813 return { 47814 scrollLeft: element.scrollLeft, 47815 scrollTop: element.scrollTop 47816 }; 47817 } 47818 return { 47819 scrollLeft: element.scrollX, 47820 scrollTop: element.scrollY 47821 }; 47822 } 47823 function getParentNode(node) { 47824 if (getNodeName(node) === "html") { 47825 return node; 47826 } 47827 const result = ( 47828 // Step into the shadow DOM of the parent of a slotted node. 47829 node.assignedSlot || // DOM Element detected. 47830 node.parentNode || // ShadowRoot detected. 47831 isShadowRoot(node) && node.host || // Fallback. 47832 getDocumentElement(node) 47833 ); 47834 return isShadowRoot(result) ? result.host : result; 47835 } 47836 function getNearestOverflowAncestor(node) { 47837 const parentNode = getParentNode(node); 47838 if (isLastTraversableNode(parentNode)) { 47839 return node.ownerDocument ? node.ownerDocument.body : node.body; 47840 } 47841 if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) { 47842 return parentNode; 47843 } 47844 return getNearestOverflowAncestor(parentNode); 47845 } 47846 function getOverflowAncestors(node, list, traverseIframes) { 47847 var _node$ownerDocument2; 47848 if (list === void 0) { 47849 list = []; 47850 } 47851 if (traverseIframes === void 0) { 47852 traverseIframes = true; 47853 } 47854 const scrollableAncestor = getNearestOverflowAncestor(node); 47855 const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body); 47856 const win = getWindow(scrollableAncestor); 47857 if (isBody) { 47858 const frameElement = getFrameElement(win); 47859 return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []); 47860 } 47861 return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes)); 47862 } 47863 function getFrameElement(win) { 47864 return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null; 47865 } 47866 47867 // node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs 47868 function getCssDimensions(element) { 47869 const css = getComputedStyle(element); 47870 let width = parseFloat(css.width) || 0; 47871 let height = parseFloat(css.height) || 0; 47872 const hasOffset = isHTMLElement(element); 47873 const offsetWidth = hasOffset ? element.offsetWidth : width; 47874 const offsetHeight = hasOffset ? element.offsetHeight : height; 47875 const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight; 47876 if (shouldFallback) { 47877 width = offsetWidth; 47878 height = offsetHeight; 47879 } 47880 return { 47881 width, 47882 height, 47883 $: shouldFallback 47884 }; 47885 } 47886 function unwrapElement(element) { 47887 return !isElement(element) ? element.contextElement : element; 47888 } 47889 function getScale(element) { 47890 const domElement = unwrapElement(element); 47891 if (!isHTMLElement(domElement)) { 47892 return createCoords(1); 47893 } 47894 const rect = domElement.getBoundingClientRect(); 47895 const { 47896 width, 47897 height, 47898 $: $2 47899 } = getCssDimensions(domElement); 47900 let x2 = ($2 ? round(rect.width) : rect.width) / width; 47901 let y3 = ($2 ? round(rect.height) : rect.height) / height; 47902 if (!x2 || !Number.isFinite(x2)) { 47903 x2 = 1; 47904 } 47905 if (!y3 || !Number.isFinite(y3)) { 47906 y3 = 1; 47907 } 47908 return { 47909 x: x2, 47910 y: y3 47911 }; 47912 } 47913 var noOffsets = /* @__PURE__ */ createCoords(0); 47914 function getVisualOffsets(element) { 47915 const win = getWindow(element); 47916 if (!isWebKit() || !win.visualViewport) { 47917 return noOffsets; 47918 } 47919 return { 47920 x: win.visualViewport.offsetLeft, 47921 y: win.visualViewport.offsetTop 47922 }; 47923 } 47924 function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) { 47925 if (isFixed === void 0) { 47926 isFixed = false; 47927 } 47928 if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) { 47929 return false; 47930 } 47931 return isFixed; 47932 } 47933 function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) { 47934 if (includeScale === void 0) { 47935 includeScale = false; 47936 } 47937 if (isFixedStrategy === void 0) { 47938 isFixedStrategy = false; 47939 } 47940 const clientRect = element.getBoundingClientRect(); 47941 const domElement = unwrapElement(element); 47942 let scale = createCoords(1); 47943 if (includeScale) { 47944 if (offsetParent) { 47945 if (isElement(offsetParent)) { 47946 scale = getScale(offsetParent); 47947 } 47948 } else { 47949 scale = getScale(element); 47950 } 47951 } 47952 const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0); 47953 let x2 = (clientRect.left + visualOffsets.x) / scale.x; 47954 let y3 = (clientRect.top + visualOffsets.y) / scale.y; 47955 let width = clientRect.width / scale.x; 47956 let height = clientRect.height / scale.y; 47957 if (domElement) { 47958 const win = getWindow(domElement); 47959 const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent; 47960 let currentWin = win; 47961 let currentIFrame = getFrameElement(currentWin); 47962 while (currentIFrame && offsetParent && offsetWin !== currentWin) { 47963 const iframeScale = getScale(currentIFrame); 47964 const iframeRect = currentIFrame.getBoundingClientRect(); 47965 const css = getComputedStyle(currentIFrame); 47966 const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x; 47967 const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y; 47968 x2 *= iframeScale.x; 47969 y3 *= iframeScale.y; 47970 width *= iframeScale.x; 47971 height *= iframeScale.y; 47972 x2 += left; 47973 y3 += top; 47974 currentWin = getWindow(currentIFrame); 47975 currentIFrame = getFrameElement(currentWin); 47976 } 47977 } 47978 return rectToClientRect({ 47979 width, 47980 height, 47981 x: x2, 47982 y: y3 47983 }); 47984 } 47985 function getWindowScrollBarX(element, rect) { 47986 const leftScroll = getNodeScroll(element).scrollLeft; 47987 if (!rect) { 47988 return getBoundingClientRect(getDocumentElement(element)).left + leftScroll; 47989 } 47990 return rect.left + leftScroll; 47991 } 47992 function getHTMLOffset(documentElement, scroll, ignoreScrollbarX) { 47993 if (ignoreScrollbarX === void 0) { 47994 ignoreScrollbarX = false; 47995 } 47996 const htmlRect = documentElement.getBoundingClientRect(); 47997 const x2 = htmlRect.left + scroll.scrollLeft - (ignoreScrollbarX ? 0 : ( 47998 // RTL <body> scrollbar. 47999 getWindowScrollBarX(documentElement, htmlRect) 48000 )); 48001 const y3 = htmlRect.top + scroll.scrollTop; 48002 return { 48003 x: x2, 48004 y: y3 48005 }; 48006 } 48007 function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) { 48008 let { 48009 elements: elements2, 48010 rect, 48011 offsetParent, 48012 strategy 48013 } = _ref; 48014 const isFixed = strategy === "fixed"; 48015 const documentElement = getDocumentElement(offsetParent); 48016 const topLayer = elements2 ? isTopLayer(elements2.floating) : false; 48017 if (offsetParent === documentElement || topLayer && isFixed) { 48018 return rect; 48019 } 48020 let scroll = { 48021 scrollLeft: 0, 48022 scrollTop: 0 48023 }; 48024 let scale = createCoords(1); 48025 const offsets = createCoords(0); 48026 const isOffsetParentAnElement = isHTMLElement(offsetParent); 48027 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) { 48028 if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) { 48029 scroll = getNodeScroll(offsetParent); 48030 } 48031 if (isHTMLElement(offsetParent)) { 48032 const offsetRect = getBoundingClientRect(offsetParent); 48033 scale = getScale(offsetParent); 48034 offsets.x = offsetRect.x + offsetParent.clientLeft; 48035 offsets.y = offsetRect.y + offsetParent.clientTop; 48036 } 48037 } 48038 const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll, true) : createCoords(0); 48039 return { 48040 width: rect.width * scale.x, 48041 height: rect.height * scale.y, 48042 x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x, 48043 y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y 48044 }; 48045 } 48046 function getClientRects(element) { 48047 return Array.from(element.getClientRects()); 48048 } 48049 function getDocumentRect(element) { 48050 const html = getDocumentElement(element); 48051 const scroll = getNodeScroll(element); 48052 const body = element.ownerDocument.body; 48053 const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth); 48054 const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight); 48055 let x2 = -scroll.scrollLeft + getWindowScrollBarX(element); 48056 const y3 = -scroll.scrollTop; 48057 if (getComputedStyle(body).direction === "rtl") { 48058 x2 += max(html.clientWidth, body.clientWidth) - width; 48059 } 48060 return { 48061 width, 48062 height, 48063 x: x2, 48064 y: y3 48065 }; 48066 } 48067 function getViewportRect(element, strategy) { 48068 const win = getWindow(element); 48069 const html = getDocumentElement(element); 48070 const visualViewport = win.visualViewport; 48071 let width = html.clientWidth; 48072 let height = html.clientHeight; 48073 let x2 = 0; 48074 let y3 = 0; 48075 if (visualViewport) { 48076 width = visualViewport.width; 48077 height = visualViewport.height; 48078 const visualViewportBased = isWebKit(); 48079 if (!visualViewportBased || visualViewportBased && strategy === "fixed") { 48080 x2 = visualViewport.offsetLeft; 48081 y3 = visualViewport.offsetTop; 48082 } 48083 } 48084 return { 48085 width, 48086 height, 48087 x: x2, 48088 y: y3 48089 }; 48090 } 48091 var absoluteOrFixed = /* @__PURE__ */ new Set(["absolute", "fixed"]); 48092 function getInnerBoundingClientRect(element, strategy) { 48093 const clientRect = getBoundingClientRect(element, true, strategy === "fixed"); 48094 const top = clientRect.top + element.clientTop; 48095 const left = clientRect.left + element.clientLeft; 48096 const scale = isHTMLElement(element) ? getScale(element) : createCoords(1); 48097 const width = element.clientWidth * scale.x; 48098 const height = element.clientHeight * scale.y; 48099 const x2 = left * scale.x; 48100 const y3 = top * scale.y; 48101 return { 48102 width, 48103 height, 48104 x: x2, 48105 y: y3 48106 }; 48107 } 48108 function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) { 48109 let rect; 48110 if (clippingAncestor === "viewport") { 48111 rect = getViewportRect(element, strategy); 48112 } else if (clippingAncestor === "document") { 48113 rect = getDocumentRect(getDocumentElement(element)); 48114 } else if (isElement(clippingAncestor)) { 48115 rect = getInnerBoundingClientRect(clippingAncestor, strategy); 48116 } else { 48117 const visualOffsets = getVisualOffsets(element); 48118 rect = { 48119 x: clippingAncestor.x - visualOffsets.x, 48120 y: clippingAncestor.y - visualOffsets.y, 48121 width: clippingAncestor.width, 48122 height: clippingAncestor.height 48123 }; 48124 } 48125 return rectToClientRect(rect); 48126 } 48127 function hasFixedPositionAncestor(element, stopNode) { 48128 const parentNode = getParentNode(element); 48129 if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) { 48130 return false; 48131 } 48132 return getComputedStyle(parentNode).position === "fixed" || hasFixedPositionAncestor(parentNode, stopNode); 48133 } 48134 function getClippingElementAncestors(element, cache) { 48135 const cachedResult = cache.get(element); 48136 if (cachedResult) { 48137 return cachedResult; 48138 } 48139 let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body"); 48140 let currentContainingBlockComputedStyle = null; 48141 const elementIsFixed = getComputedStyle(element).position === "fixed"; 48142 let currentNode = elementIsFixed ? getParentNode(element) : element; 48143 while (isElement(currentNode) && !isLastTraversableNode(currentNode)) { 48144 const computedStyle = getComputedStyle(currentNode); 48145 const currentNodeIsContaining = isContainingBlock(currentNode); 48146 if (!currentNodeIsContaining && computedStyle.position === "fixed") { 48147 currentContainingBlockComputedStyle = null; 48148 } 48149 const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && absoluteOrFixed.has(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode); 48150 if (shouldDropCurrentNode) { 48151 result = result.filter((ancestor) => ancestor !== currentNode); 48152 } else { 48153 currentContainingBlockComputedStyle = computedStyle; 48154 } 48155 currentNode = getParentNode(currentNode); 48156 } 48157 cache.set(element, result); 48158 return result; 48159 } 48160 function getClippingRect(_ref) { 48161 let { 48162 element, 48163 boundary, 48164 rootBoundary, 48165 strategy 48166 } = _ref; 48167 const elementClippingAncestors = boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary); 48168 const clippingAncestors = [...elementClippingAncestors, rootBoundary]; 48169 const firstClippingAncestor = clippingAncestors[0]; 48170 const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => { 48171 const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy); 48172 accRect.top = max(rect.top, accRect.top); 48173 accRect.right = min(rect.right, accRect.right); 48174 accRect.bottom = min(rect.bottom, accRect.bottom); 48175 accRect.left = max(rect.left, accRect.left); 48176 return accRect; 48177 }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy)); 48178 return { 48179 width: clippingRect.right - clippingRect.left, 48180 height: clippingRect.bottom - clippingRect.top, 48181 x: clippingRect.left, 48182 y: clippingRect.top 48183 }; 48184 } 48185 function getDimensions(element) { 48186 const { 48187 width, 48188 height 48189 } = getCssDimensions(element); 48190 return { 48191 width, 48192 height 48193 }; 48194 } 48195 function getRectRelativeToOffsetParent(element, offsetParent, strategy) { 48196 const isOffsetParentAnElement = isHTMLElement(offsetParent); 48197 const documentElement = getDocumentElement(offsetParent); 48198 const isFixed = strategy === "fixed"; 48199 const rect = getBoundingClientRect(element, true, isFixed, offsetParent); 48200 let scroll = { 48201 scrollLeft: 0, 48202 scrollTop: 0 48203 }; 48204 const offsets = createCoords(0); 48205 function setLeftRTLScrollbarOffset() { 48206 offsets.x = getWindowScrollBarX(documentElement); 48207 } 48208 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) { 48209 if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) { 48210 scroll = getNodeScroll(offsetParent); 48211 } 48212 if (isOffsetParentAnElement) { 48213 const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent); 48214 offsets.x = offsetRect.x + offsetParent.clientLeft; 48215 offsets.y = offsetRect.y + offsetParent.clientTop; 48216 } else if (documentElement) { 48217 setLeftRTLScrollbarOffset(); 48218 } 48219 } 48220 if (isFixed && !isOffsetParentAnElement && documentElement) { 48221 setLeftRTLScrollbarOffset(); 48222 } 48223 const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0); 48224 const x2 = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x; 48225 const y3 = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y; 48226 return { 48227 x: x2, 48228 y: y3, 48229 width: rect.width, 48230 height: rect.height 48231 }; 48232 } 48233 function isStaticPositioned(element) { 48234 return getComputedStyle(element).position === "static"; 48235 } 48236 function getTrueOffsetParent(element, polyfill) { 48237 if (!isHTMLElement(element) || getComputedStyle(element).position === "fixed") { 48238 return null; 48239 } 48240 if (polyfill) { 48241 return polyfill(element); 48242 } 48243 let rawOffsetParent = element.offsetParent; 48244 if (getDocumentElement(element) === rawOffsetParent) { 48245 rawOffsetParent = rawOffsetParent.ownerDocument.body; 48246 } 48247 return rawOffsetParent; 48248 } 48249 function getOffsetParent(element, polyfill) { 48250 const win = getWindow(element); 48251 if (isTopLayer(element)) { 48252 return win; 48253 } 48254 if (!isHTMLElement(element)) { 48255 let svgOffsetParent = getParentNode(element); 48256 while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) { 48257 if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) { 48258 return svgOffsetParent; 48259 } 48260 svgOffsetParent = getParentNode(svgOffsetParent); 48261 } 48262 return win; 48263 } 48264 let offsetParent = getTrueOffsetParent(element, polyfill); 48265 while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) { 48266 offsetParent = getTrueOffsetParent(offsetParent, polyfill); 48267 } 48268 if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) { 48269 return win; 48270 } 48271 return offsetParent || getContainingBlock(element) || win; 48272 } 48273 var getElementRects = async function(data) { 48274 const getOffsetParentFn = this.getOffsetParent || getOffsetParent; 48275 const getDimensionsFn = this.getDimensions; 48276 const floatingDimensions = await getDimensionsFn(data.floating); 48277 return { 48278 reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy), 48279 floating: { 48280 x: 0, 48281 y: 0, 48282 width: floatingDimensions.width, 48283 height: floatingDimensions.height 48284 } 48285 }; 48286 }; 48287 function isRTL17(element) { 48288 return getComputedStyle(element).direction === "rtl"; 48289 } 48290 var platform = { 48291 convertOffsetParentRelativeRectToViewportRelativeRect, 48292 getDocumentElement, 48293 getClippingRect, 48294 getOffsetParent, 48295 getElementRects, 48296 getClientRects, 48297 getDimensions, 48298 getScale, 48299 isElement, 48300 isRTL: isRTL17 48301 }; 48302 function rectsAreEqual(a3, b3) { 48303 return a3.x === b3.x && a3.y === b3.y && a3.width === b3.width && a3.height === b3.height; 48304 } 48305 function observeMove(element, onMove) { 48306 let io = null; 48307 let timeoutId; 48308 const root = getDocumentElement(element); 48309 function cleanup() { 48310 var _io; 48311 clearTimeout(timeoutId); 48312 (_io = io) == null || _io.disconnect(); 48313 io = null; 48314 } 48315 function refresh(skip, threshold) { 48316 if (skip === void 0) { 48317 skip = false; 48318 } 48319 if (threshold === void 0) { 48320 threshold = 1; 48321 } 48322 cleanup(); 48323 const elementRectForRootMargin = element.getBoundingClientRect(); 48324 const { 48325 left, 48326 top, 48327 width, 48328 height 48329 } = elementRectForRootMargin; 48330 if (!skip) { 48331 onMove(); 48332 } 48333 if (!width || !height) { 48334 return; 48335 } 48336 const insetTop = floor(top); 48337 const insetRight = floor(root.clientWidth - (left + width)); 48338 const insetBottom = floor(root.clientHeight - (top + height)); 48339 const insetLeft = floor(left); 48340 const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px"; 48341 const options = { 48342 rootMargin, 48343 threshold: max(0, min(1, threshold)) || 1 48344 }; 48345 let isFirstUpdate = true; 48346 function handleObserve(entries) { 48347 const ratio = entries[0].intersectionRatio; 48348 if (ratio !== threshold) { 48349 if (!isFirstUpdate) { 48350 return refresh(); 48351 } 48352 if (!ratio) { 48353 timeoutId = setTimeout(() => { 48354 refresh(false, 1e-7); 48355 }, 1e3); 48356 } else { 48357 refresh(false, ratio); 48358 } 48359 } 48360 if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) { 48361 refresh(); 48362 } 48363 isFirstUpdate = false; 48364 } 48365 try { 48366 io = new IntersectionObserver(handleObserve, { 48367 ...options, 48368 // Handle <iframe>s 48369 root: root.ownerDocument 48370 }); 48371 } catch (_e) { 48372 io = new IntersectionObserver(handleObserve, options); 48373 } 48374 io.observe(element); 48375 } 48376 refresh(true); 48377 return cleanup; 48378 } 48379 function autoUpdate(reference, floating, update, options) { 48380 if (options === void 0) { 48381 options = {}; 48382 } 48383 const { 48384 ancestorScroll = true, 48385 ancestorResize = true, 48386 elementResize = typeof ResizeObserver === "function", 48387 layoutShift = typeof IntersectionObserver === "function", 48388 animationFrame = false 48389 } = options; 48390 const referenceEl = unwrapElement(reference); 48391 const ancestors = ancestorScroll || ancestorResize ? [...referenceEl ? getOverflowAncestors(referenceEl) : [], ...getOverflowAncestors(floating)] : []; 48392 ancestors.forEach((ancestor) => { 48393 ancestorScroll && ancestor.addEventListener("scroll", update, { 48394 passive: true 48395 }); 48396 ancestorResize && ancestor.addEventListener("resize", update); 48397 }); 48398 const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null; 48399 let reobserveFrame = -1; 48400 let resizeObserver = null; 48401 if (elementResize) { 48402 resizeObserver = new ResizeObserver((_ref) => { 48403 let [firstEntry] = _ref; 48404 if (firstEntry && firstEntry.target === referenceEl && resizeObserver) { 48405 resizeObserver.unobserve(floating); 48406 cancelAnimationFrame(reobserveFrame); 48407 reobserveFrame = requestAnimationFrame(() => { 48408 var _resizeObserver; 48409 (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating); 48410 }); 48411 } 48412 update(); 48413 }); 48414 if (referenceEl && !animationFrame) { 48415 resizeObserver.observe(referenceEl); 48416 } 48417 resizeObserver.observe(floating); 48418 } 48419 let frameId; 48420 let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null; 48421 if (animationFrame) { 48422 frameLoop(); 48423 } 48424 function frameLoop() { 48425 const nextRefRect = getBoundingClientRect(reference); 48426 if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) { 48427 update(); 48428 } 48429 prevRefRect = nextRefRect; 48430 frameId = requestAnimationFrame(frameLoop); 48431 } 48432 update(); 48433 return () => { 48434 var _resizeObserver2; 48435 ancestors.forEach((ancestor) => { 48436 ancestorScroll && ancestor.removeEventListener("scroll", update); 48437 ancestorResize && ancestor.removeEventListener("resize", update); 48438 }); 48439 cleanupIo == null || cleanupIo(); 48440 (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect(); 48441 resizeObserver = null; 48442 if (animationFrame) { 48443 cancelAnimationFrame(frameId); 48444 } 48445 }; 48446 } 48447 var offset2 = offset; 48448 var computePosition2 = (reference, floating, options) => { 48449 const cache = /* @__PURE__ */ new Map(); 48450 const mergedOptions = { 48451 platform, 48452 ...options 48453 }; 48454 const platformWithCache = { 48455 ...mergedOptions.platform, 48456 _c: cache 48457 }; 48458 return computePosition(reference, floating, { 48459 ...mergedOptions, 48460 platform: platformWithCache 48461 }); 48462 }; 48463 48464 // node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.mjs 48465 var React = __toESM(require_react(), 1); 48466 var import_react = __toESM(require_react(), 1); 48467 var ReactDOM = __toESM(require_react_dom(), 1); 48468 var index = typeof document !== "undefined" ? import_react.useLayoutEffect : import_react.useEffect; 48469 function deepEqual(a3, b3) { 48470 if (a3 === b3) { 48471 return true; 48472 } 48473 if (typeof a3 !== typeof b3) { 48474 return false; 48475 } 48476 if (typeof a3 === "function" && a3.toString() === b3.toString()) { 48477 return true; 48478 } 48479 let length; 48480 let i3; 48481 let keys; 48482 if (a3 && b3 && typeof a3 === "object") { 48483 if (Array.isArray(a3)) { 48484 length = a3.length; 48485 if (length !== b3.length) return false; 48486 for (i3 = length; i3-- !== 0; ) { 48487 if (!deepEqual(a3[i3], b3[i3])) { 48488 return false; 48489 } 48490 } 48491 return true; 48492 } 48493 keys = Object.keys(a3); 48494 length = keys.length; 48495 if (length !== Object.keys(b3).length) { 48496 return false; 48497 } 48498 for (i3 = length; i3-- !== 0; ) { 48499 if (!{}.hasOwnProperty.call(b3, keys[i3])) { 48500 return false; 48501 } 48502 } 48503 for (i3 = length; i3-- !== 0; ) { 48504 const key = keys[i3]; 48505 if (key === "_owner" && a3.$$typeof) { 48506 continue; 48507 } 48508 if (!deepEqual(a3[key], b3[key])) { 48509 return false; 48510 } 48511 } 48512 return true; 48513 } 48514 return a3 !== a3 && b3 !== b3; 48515 } 48516 function getDPR(element) { 48517 if (typeof window === "undefined") { 48518 return 1; 48519 } 48520 const win = element.ownerDocument.defaultView || window; 48521 return win.devicePixelRatio || 1; 48522 } 48523 function roundByDPR(element, value) { 48524 const dpr = getDPR(element); 48525 return Math.round(value * dpr) / dpr; 48526 } 48527 function useLatestRef(value) { 48528 const ref = React.useRef(value); 48529 index(() => { 48530 ref.current = value; 48531 }); 48532 return ref; 48533 } 48534 function useFloating(options) { 48535 if (options === void 0) { 48536 options = {}; 48537 } 48538 const { 48539 placement = "bottom", 48540 strategy = "absolute", 48541 middleware = [], 48542 platform: platform2, 48543 elements: { 48544 reference: externalReference, 48545 floating: externalFloating 48546 } = {}, 48547 transform = true, 48548 whileElementsMounted, 48549 open 48550 } = options; 48551 const [data, setData] = React.useState({ 48552 x: 0, 48553 y: 0, 48554 strategy, 48555 placement, 48556 middlewareData: {}, 48557 isPositioned: false 48558 }); 48559 const [latestMiddleware, setLatestMiddleware] = React.useState(middleware); 48560 if (!deepEqual(latestMiddleware, middleware)) { 48561 setLatestMiddleware(middleware); 48562 } 48563 const [_reference, _setReference] = React.useState(null); 48564 const [_floating, _setFloating] = React.useState(null); 48565 const setReference = React.useCallback((node) => { 48566 if (node !== referenceRef.current) { 48567 referenceRef.current = node; 48568 _setReference(node); 48569 } 48570 }, []); 48571 const setFloating = React.useCallback((node) => { 48572 if (node !== floatingRef.current) { 48573 floatingRef.current = node; 48574 _setFloating(node); 48575 } 48576 }, []); 48577 const referenceEl = externalReference || _reference; 48578 const floatingEl = externalFloating || _floating; 48579 const referenceRef = React.useRef(null); 48580 const floatingRef = React.useRef(null); 48581 const dataRef = React.useRef(data); 48582 const hasWhileElementsMounted = whileElementsMounted != null; 48583 const whileElementsMountedRef = useLatestRef(whileElementsMounted); 48584 const platformRef = useLatestRef(platform2); 48585 const update = React.useCallback(() => { 48586 if (!referenceRef.current || !floatingRef.current) { 48587 return; 48588 } 48589 const config = { 48590 placement, 48591 strategy, 48592 middleware: latestMiddleware 48593 }; 48594 if (platformRef.current) { 48595 config.platform = platformRef.current; 48596 } 48597 computePosition2(referenceRef.current, floatingRef.current, config).then((data2) => { 48598 const fullData = { 48599 ...data2, 48600 isPositioned: true 48601 }; 48602 if (isMountedRef.current && !deepEqual(dataRef.current, fullData)) { 48603 dataRef.current = fullData; 48604 ReactDOM.flushSync(() => { 48605 setData(fullData); 48606 }); 48607 } 48608 }); 48609 }, [latestMiddleware, placement, strategy, platformRef]); 48610 index(() => { 48611 if (open === false && dataRef.current.isPositioned) { 48612 dataRef.current.isPositioned = false; 48613 setData((data2) => ({ 48614 ...data2, 48615 isPositioned: false 48616 })); 48617 } 48618 }, [open]); 48619 const isMountedRef = React.useRef(false); 48620 index(() => { 48621 isMountedRef.current = true; 48622 return () => { 48623 isMountedRef.current = false; 48624 }; 48625 }, []); 48626 index(() => { 48627 if (referenceEl) referenceRef.current = referenceEl; 48628 if (floatingEl) floatingRef.current = floatingEl; 48629 if (referenceEl && floatingEl) { 48630 if (whileElementsMountedRef.current) { 48631 return whileElementsMountedRef.current(referenceEl, floatingEl, update); 48632 } 48633 update(); 48634 } 48635 }, [referenceEl, floatingEl, update, whileElementsMountedRef, hasWhileElementsMounted]); 48636 const refs = React.useMemo(() => ({ 48637 reference: referenceRef, 48638 floating: floatingRef, 48639 setReference, 48640 setFloating 48641 }), [setReference, setFloating]); 48642 const elements2 = React.useMemo(() => ({ 48643 reference: referenceEl, 48644 floating: floatingEl 48645 }), [referenceEl, floatingEl]); 48646 const floatingStyles = React.useMemo(() => { 48647 const initialStyles = { 48648 position: strategy, 48649 left: 0, 48650 top: 0 48651 }; 48652 if (!elements2.floating) { 48653 return initialStyles; 48654 } 48655 const x2 = roundByDPR(elements2.floating, data.x); 48656 const y3 = roundByDPR(elements2.floating, data.y); 48657 if (transform) { 48658 return { 48659 ...initialStyles, 48660 transform: "translate(" + x2 + "px, " + y3 + "px)", 48661 ...getDPR(elements2.floating) >= 1.5 && { 48662 willChange: "transform" 48663 } 48664 }; 48665 } 48666 return { 48667 position: strategy, 48668 left: x2, 48669 top: y3 48670 }; 48671 }, [strategy, transform, elements2.floating, data.x, data.y]); 48672 return React.useMemo(() => ({ 48673 ...data, 48674 update, 48675 refs, 48676 elements: elements2, 48677 floatingStyles 48678 }), [data, update, refs, elements2, floatingStyles]); 48679 } 48680 48681 // packages/editor/build-module/components/collab-sidebar/hooks.js 48682 var import_i18n216 = __toESM(require_i18n()); 48683 var import_element169 = __toESM(require_element()); 48684 var import_core_data118 = __toESM(require_core_data()); 48685 var import_data221 = __toESM(require_data()); 48686 var import_block_editor92 = __toESM(require_block_editor()); 48687 var import_notices29 = __toESM(require_notices()); 48688 var import_html_entities30 = __toESM(require_html_entities()); 48689 var { useBlockElement, cleanEmptyObject: cleanEmptyObject4 } = unlock(import_block_editor92.privateApis); 48690 function useBlockComments(postId2) { 48691 const [commentLastUpdated, reflowComments] = (0, import_element169.useReducer)( 48692 () => Date.now(), 48693 0 48694 ); 48695 const queryArgs = { 48696 post: postId2, 48697 type: "note", 48698 status: "all", 48699 per_page: -1 48700 }; 48701 const { records: threads } = (0, import_core_data118.useEntityRecords)( 48702 "root", 48703 "comment", 48704 queryArgs, 48705 { enabled: !!postId2 && typeof postId2 === "number" } 48706 ); 48707 const { getBlockAttributes: getBlockAttributes2 } = (0, import_data221.useSelect)(import_block_editor92.store); 48708 const { clientIds } = (0, import_data221.useSelect)((select5) => { 48709 const { getClientIdsWithDescendants: getClientIdsWithDescendants2 } = select5(import_block_editor92.store); 48710 return { 48711 clientIds: getClientIdsWithDescendants2() 48712 }; 48713 }, []); 48714 const { resultComments, unresolvedSortedThreads } = (0, import_element169.useMemo)(() => { 48715 if (!threads || threads.length === 0) { 48716 return { resultComments: [], unresolvedSortedThreads: [] }; 48717 } 48718 const blocksWithComments = clientIds.reduce((results, clientId) => { 48719 const commentId = getBlockAttributes2(clientId)?.metadata?.noteId; 48720 if (commentId) { 48721 results[clientId] = commentId; 48722 } 48723 return results; 48724 }, {}); 48725 const compare = {}; 48726 const result = []; 48727 const commentIdToBlockClientId = Object.keys( 48728 blocksWithComments 48729 ).reduce((mapping, clientId) => { 48730 mapping[blocksWithComments[clientId]] = clientId; 48731 return mapping; 48732 }, {}); 48733 threads.forEach((item) => { 48734 const itemBlock = commentIdToBlockClientId[item.id]; 48735 compare[item.id] = { 48736 ...item, 48737 reply: [], 48738 blockClientId: item.parent === 0 ? itemBlock : null 48739 }; 48740 }); 48741 threads.forEach((item) => { 48742 if (item.parent === 0) { 48743 result.push(compare[item.id]); 48744 } else if (compare[item.parent]) { 48745 compare[item.parent].reply.push(compare[item.id]); 48746 } 48747 }); 48748 if (0 === result?.length) { 48749 return { resultComments: [], unresolvedSortedThreads: [] }; 48750 } 48751 const updatedResult = result.map((item) => ({ 48752 ...item, 48753 reply: [...item.reply].reverse() 48754 })); 48755 const threadIdMap = new Map( 48756 updatedResult.map((thread) => [String(thread.id), thread]) 48757 ); 48758 const mappedIds = new Set( 48759 Object.values(blocksWithComments).map((id) => String(id)) 48760 ); 48761 const unresolvedSortedComments = Object.values(blocksWithComments).map((commentId) => threadIdMap.get(String(commentId))).filter( 48762 (thread) => thread !== void 0 && thread.status === "hold" 48763 ); 48764 const resolvedSortedComments = Object.values(blocksWithComments).map((commentId) => threadIdMap.get(String(commentId))).filter( 48765 (thread) => thread !== void 0 && thread.status === "approved" 48766 ); 48767 const orphanedComments = updatedResult.filter( 48768 (thread) => !mappedIds.has(String(thread.id)) 48769 ); 48770 const allSortedComments = [ 48771 ...unresolvedSortedComments, 48772 ...resolvedSortedComments, 48773 ...orphanedComments 48774 ]; 48775 return { 48776 resultComments: allSortedComments, 48777 unresolvedSortedThreads: unresolvedSortedComments 48778 }; 48779 }, [clientIds, threads, getBlockAttributes2]); 48780 return { 48781 resultComments, 48782 unresolvedSortedThreads, 48783 reflowComments, 48784 commentLastUpdated 48785 }; 48786 } 48787 function useBlockCommentsActions(reflowComments = noop6) { 48788 const { createNotice } = (0, import_data221.useDispatch)(import_notices29.store); 48789 const { saveEntityRecord, deleteEntityRecord } = (0, import_data221.useDispatch)(import_core_data118.store); 48790 const { getCurrentPostId: getCurrentPostId2 } = (0, import_data221.useSelect)(store); 48791 const { getBlockAttributes: getBlockAttributes2, getSelectedBlockClientId: getSelectedBlockClientId2 } = (0, import_data221.useSelect)(import_block_editor92.store); 48792 const { updateBlockAttributes: updateBlockAttributes2 } = (0, import_data221.useDispatch)(import_block_editor92.store); 48793 const onError = (error) => { 48794 const errorMessage = error.message && error.code !== "unknown_error" ? (0, import_html_entities30.decodeEntities)(error.message) : (0, import_i18n216.__)("An error occurred while performing an update."); 48795 createNotice("error", errorMessage, { 48796 type: "snackbar", 48797 isDismissible: true 48798 }); 48799 }; 48800 const onCreate = async ({ content, parent }) => { 48801 try { 48802 const savedRecord = await saveEntityRecord( 48803 "root", 48804 "comment", 48805 { 48806 post: getCurrentPostId2(), 48807 content, 48808 status: "hold", 48809 type: "note", 48810 parent: parent || 0 48811 }, 48812 { throwOnError: true } 48813 ); 48814 if (!parent && savedRecord?.id) { 48815 const clientId = getSelectedBlockClientId2(); 48816 const metadata = getBlockAttributes2(clientId)?.metadata; 48817 updateBlockAttributes2(clientId, { 48818 metadata: { 48819 ...metadata, 48820 noteId: savedRecord.id 48821 } 48822 }); 48823 } 48824 createNotice( 48825 "snackbar", 48826 parent ? (0, import_i18n216.__)("Reply added.") : (0, import_i18n216.__)("Note added."), 48827 { 48828 type: "snackbar", 48829 isDismissible: true 48830 } 48831 ); 48832 setTimeout(reflowComments, 300); 48833 return savedRecord; 48834 } catch (error) { 48835 reflowComments(); 48836 onError(error); 48837 } 48838 }; 48839 const onEdit = async ({ id, content, status }) => { 48840 const messageType = status ? status : "updated"; 48841 const messages = { 48842 approved: (0, import_i18n216.__)("Note marked as resolved."), 48843 hold: (0, import_i18n216.__)("Note reopened."), 48844 updated: (0, import_i18n216.__)("Note updated.") 48845 }; 48846 try { 48847 if (status === "approved" || status === "hold") { 48848 await saveEntityRecord( 48849 "root", 48850 "comment", 48851 { 48852 id, 48853 status 48854 }, 48855 { 48856 throwOnError: true 48857 } 48858 ); 48859 const newCommentData = { 48860 post: getCurrentPostId2(), 48861 content: content || "", 48862 // Empty content for resolve, content for reopen. 48863 type: "note", 48864 status, 48865 parent: id, 48866 meta: { 48867 _wp_note_status: status === "approved" ? "resolved" : "reopen" 48868 } 48869 }; 48870 await saveEntityRecord("root", "comment", newCommentData, { 48871 throwOnError: true 48872 }); 48873 } else { 48874 const updateData = { 48875 id, 48876 content, 48877 status 48878 }; 48879 await saveEntityRecord("root", "comment", updateData, { 48880 throwOnError: true 48881 }); 48882 } 48883 createNotice( 48884 "snackbar", 48885 messages[messageType] ?? (0, import_i18n216.__)("Note updated."), 48886 { 48887 type: "snackbar", 48888 isDismissible: true 48889 } 48890 ); 48891 reflowComments(); 48892 } catch (error) { 48893 reflowComments(); 48894 onError(error); 48895 } 48896 }; 48897 const onDelete = async (comment) => { 48898 try { 48899 await deleteEntityRecord( 48900 "root", 48901 "comment", 48902 comment.id, 48903 void 0, 48904 { 48905 throwOnError: true 48906 } 48907 ); 48908 if (!comment.parent) { 48909 const clientId = getSelectedBlockClientId2(); 48910 const metadata = getBlockAttributes2(clientId)?.metadata; 48911 updateBlockAttributes2(clientId, { 48912 metadata: cleanEmptyObject4({ 48913 ...metadata, 48914 noteId: void 0 48915 }) 48916 }); 48917 } 48918 createNotice("snackbar", (0, import_i18n216.__)("Note deleted."), { 48919 type: "snackbar", 48920 isDismissible: true 48921 }); 48922 reflowComments(); 48923 } catch (error) { 48924 reflowComments(); 48925 onError(error); 48926 } 48927 }; 48928 return { onCreate, onEdit, onDelete }; 48929 } 48930 function useEnableFloatingSidebar(enabled = false) { 48931 const registry = (0, import_data221.useRegistry)(); 48932 (0, import_element169.useEffect)(() => { 48933 if (!enabled) { 48934 return; 48935 } 48936 const { getActiveComplementaryArea: getActiveComplementaryArea2 } = registry.select(store2); 48937 const { disableComplementaryArea: disableComplementaryArea2, enableComplementaryArea: enableComplementaryArea2 } = registry.dispatch(store2); 48938 const unsubscribe = registry.subscribe(() => { 48939 if (getActiveComplementaryArea2("core") === null) { 48940 enableComplementaryArea2("core", collabSidebarName); 48941 } 48942 }); 48943 return () => { 48944 unsubscribe(); 48945 if (getActiveComplementaryArea2("core") === collabSidebarName) { 48946 disableComplementaryArea2("core", collabSidebarName); 48947 } 48948 }; 48949 }, [enabled, registry]); 48950 } 48951 function useFloatingThread({ 48952 thread, 48953 calculatedOffset, 48954 setHeights, 48955 selectedThread, 48956 setBlockRef, 48957 commentLastUpdated 48958 }) { 48959 const blockElement = useBlockElement(thread.blockClientId); 48960 const updateHeight = (0, import_element169.useCallback)( 48961 (id, newHeight) => { 48962 setHeights((prev) => { 48963 if (prev[id] !== newHeight) { 48964 return { ...prev, [id]: newHeight }; 48965 } 48966 return prev; 48967 }); 48968 }, 48969 [setHeights] 48970 ); 48971 const { y: y3, refs } = useFloating({ 48972 placement: "right-start", 48973 middleware: [ 48974 offset2({ 48975 crossAxis: calculatedOffset || -16 48976 }) 48977 ], 48978 whileElementsMounted: autoUpdate 48979 }); 48980 (0, import_element169.useEffect)(() => { 48981 if (blockElement) { 48982 refs.setReference(blockElement); 48983 } 48984 }, [blockElement, refs, commentLastUpdated]); 48985 (0, import_element169.useEffect)(() => { 48986 if (refs.floating?.current) { 48987 setBlockRef(thread.id, blockElement); 48988 } 48989 }, [blockElement, thread.id, refs.floating, setBlockRef]); 48990 (0, import_element169.useEffect)(() => { 48991 if (refs.floating?.current) { 48992 const newHeight = refs.floating.current.scrollHeight; 48993 updateHeight(thread.id, newHeight); 48994 } 48995 }, [ 48996 thread.id, 48997 updateHeight, 48998 refs.floating, 48999 selectedThread, 49000 commentLastUpdated 49001 ]); 49002 return { 49003 y: y3, 49004 refs 49005 }; 49006 } 49007 49008 // packages/editor/build-module/components/collab-sidebar/add-comment.js 49009 var import_i18n217 = __toESM(require_i18n()); 49010 var import_data222 = __toESM(require_data()); 49011 var import_components206 = __toESM(require_components()); 49012 var import_block_editor93 = __toESM(require_block_editor()); 49013 var import_jsx_runtime334 = __toESM(require_jsx_runtime()); 49014 var { useBlockElement: useBlockElement2 } = unlock(import_block_editor93.privateApis); 49015 function AddComment({ 49016 onSubmit, 49017 newNoteFormState, 49018 setNewNoteFormState, 49019 commentSidebarRef, 49020 reflowComments = noop6, 49021 isFloating = false, 49022 y: y3, 49023 refs 49024 }) { 49025 const { clientId } = (0, import_data222.useSelect)((select5) => { 49026 const { getSelectedBlockClientId: getSelectedBlockClientId2 } = select5(import_block_editor93.store); 49027 return { 49028 clientId: getSelectedBlockClientId2() 49029 }; 49030 }, []); 49031 const blockElement = useBlockElement2(clientId); 49032 const { toggleBlockSpotlight } = unlock((0, import_data222.useDispatch)(import_block_editor93.store)); 49033 const unselectThread = () => { 49034 setNewNoteFormState("closed"); 49035 blockElement?.focus(); 49036 toggleBlockSpotlight(clientId, false); 49037 }; 49038 if (newNoteFormState !== "open" || !clientId) { 49039 return null; 49040 } 49041 return /* @__PURE__ */ (0, import_jsx_runtime334.jsxs)( 49042 import_components206.__experimentalVStack, 49043 { 49044 className: clsx_default( 49045 "editor-collab-sidebar-panel__thread is-selected", 49046 { 49047 "is-floating": isFloating 49048 } 49049 ), 49050 spacing: "3", 49051 tabIndex: 0, 49052 "aria-label": (0, import_i18n217.__)("New note"), 49053 role: "treeitem", 49054 ref: isFloating ? refs.setFloating : void 0, 49055 style: isFloating ? ( 49056 // Delay showing the floating note box until a Y position is known to prevent blink. 49057 { top: y3, opacity: !y3 ? 0 : void 0 } 49058 ) : void 0, 49059 onBlur: (event) => { 49060 if (event.currentTarget.contains(event.relatedTarget)) { 49061 return; 49062 } 49063 toggleBlockSpotlight(clientId, false); 49064 setNewNoteFormState("closed"); 49065 }, 49066 children: [ 49067 /* @__PURE__ */ (0, import_jsx_runtime334.jsx)(import_components206.__experimentalHStack, { alignment: "left", spacing: "3", children: /* @__PURE__ */ (0, import_jsx_runtime334.jsx)(comment_author_info_default, {}) }), 49068 /* @__PURE__ */ (0, import_jsx_runtime334.jsx)( 49069 comment_form_default, 49070 { 49071 onSubmit: async (inputComment) => { 49072 const { id } = await onSubmit({ content: inputComment }); 49073 focusCommentThread(id, commentSidebarRef.current); 49074 setNewNoteFormState("creating"); 49075 }, 49076 onCancel: unselectThread, 49077 reflowComments, 49078 submitButtonText: (0, import_i18n217.__)("Add note"), 49079 labelText: (0, import_i18n217.__)("New note") 49080 } 49081 ) 49082 ] 49083 } 49084 ); 49085 } 49086 49087 // packages/editor/build-module/components/collab-sidebar/comments.js 49088 var import_jsx_runtime335 = __toESM(require_jsx_runtime()); 49089 var { useBlockElement: useBlockElement3 } = unlock(import_block_editor94.privateApis); 49090 var { Menu: Menu6 } = unlock(import_components207.privateApis); 49091 function Comments({ 49092 threads: noteThreads, 49093 onEditComment, 49094 onAddReply, 49095 onCommentDelete, 49096 newNoteFormState, 49097 setNewNoteFormState, 49098 commentSidebarRef, 49099 reflowComments, 49100 isFloating = false, 49101 commentLastUpdated 49102 }) { 49103 const [heights, setHeights] = (0, import_element170.useState)({}); 49104 const [selectedThread, setSelectedThread] = (0, import_element170.useState)(null); 49105 const [boardOffsets, setBoardOffsets] = (0, import_element170.useState)({}); 49106 const [blockRefs, setBlockRefs] = (0, import_element170.useState)({}); 49107 const { setCanvasMinHeight: setCanvasMinHeight2 } = unlock((0, import_data223.useDispatch)(store)); 49108 const { selectBlock: selectBlock2, toggleBlockSpotlight } = unlock( 49109 (0, import_data223.useDispatch)(import_block_editor94.store) 49110 ); 49111 const { blockCommentId, selectedBlockClientId, orderedBlockIds } = (0, import_data223.useSelect)((select5) => { 49112 const { 49113 getBlockAttributes: getBlockAttributes2, 49114 getSelectedBlockClientId: getSelectedBlockClientId2, 49115 getClientIdsWithDescendants: getClientIdsWithDescendants2 49116 } = select5(import_block_editor94.store); 49117 const clientId = getSelectedBlockClientId2(); 49118 return { 49119 blockCommentId: clientId ? getBlockAttributes2(clientId)?.metadata?.noteId : null, 49120 selectedBlockClientId: clientId, 49121 orderedBlockIds: getClientIdsWithDescendants2() 49122 }; 49123 }, []); 49124 const relatedBlockElement = useBlockElement3(selectedBlockClientId); 49125 const threads = (0, import_element170.useMemo)(() => { 49126 const t4 = [...noteThreads]; 49127 const orderedThreads = []; 49128 if (isFloating && newNoteFormState === "open") { 49129 const newNoteThread = { 49130 id: "new-note-thread", 49131 blockClientId: selectedBlockClientId, 49132 content: { rendered: "" } 49133 }; 49134 orderedBlockIds.forEach((blockId) => { 49135 if (blockId === selectedBlockClientId) { 49136 orderedThreads.push(newNoteThread); 49137 } else { 49138 const threadForBlock = t4.find( 49139 (thread) => thread.blockClientId === blockId 49140 ); 49141 if (threadForBlock) { 49142 orderedThreads.push(threadForBlock); 49143 } 49144 } 49145 }); 49146 return orderedThreads; 49147 } 49148 return t4; 49149 }, [ 49150 noteThreads, 49151 isFloating, 49152 newNoteFormState, 49153 selectedBlockClientId, 49154 orderedBlockIds 49155 ]); 49156 const handleDelete = async (comment) => { 49157 const currentIndex = threads.findIndex((t4) => t4.id === comment.id); 49158 const nextThread = threads[currentIndex + 1]; 49159 const prevThread = threads[currentIndex - 1]; 49160 await onCommentDelete(comment); 49161 if (comment.parent !== 0) { 49162 setSelectedThread(comment.parent); 49163 focusCommentThread(comment.parent, commentSidebarRef.current); 49164 return; 49165 } 49166 if (nextThread) { 49167 setSelectedThread(nextThread.id); 49168 focusCommentThread(nextThread.id, commentSidebarRef.current); 49169 } else if (prevThread) { 49170 setSelectedThread(prevThread.id); 49171 focusCommentThread(prevThread.id, commentSidebarRef.current); 49172 } else { 49173 setSelectedThread(null); 49174 setNewNoteFormState("closed"); 49175 relatedBlockElement?.focus(); 49176 } 49177 }; 49178 (0, import_element170.useEffect)(() => { 49179 setSelectedThread( 49180 newNoteFormState === "open" ? "new-note-thread" : blockCommentId 49181 ); 49182 }, [blockCommentId, newNoteFormState]); 49183 const setBlockRef = (0, import_element170.useCallback)((id, blockRef) => { 49184 setBlockRefs((prev) => ({ ...prev, [id]: blockRef })); 49185 }, []); 49186 (0, import_element170.useEffect)(() => { 49187 const calculateAllOffsets = () => { 49188 const offsets = {}; 49189 if (!isFloating) { 49190 return { offsets, minHeight: 0 }; 49191 } 49192 const selectedThreadIndex = threads.findIndex( 49193 (t4) => t4.id === selectedThread 49194 ); 49195 const breakIndex = selectedThreadIndex === -1 ? 0 : selectedThreadIndex; 49196 const selectedThreadData = threads[breakIndex]; 49197 if (!selectedThreadData || !blockRefs[selectedThreadData.id]) { 49198 return { offsets, minHeight: 0 }; 49199 } 49200 let blockElement = blockRefs[selectedThreadData.id]; 49201 let blockRect = blockElement?.getBoundingClientRect(); 49202 const selectedThreadTop = blockRect?.top || 0; 49203 const selectedThreadHeight = heights[selectedThreadData.id] || 0; 49204 offsets[selectedThreadData.id] = -16; 49205 let previousThreadData = { 49206 threadTop: selectedThreadTop - 16, 49207 threadHeight: selectedThreadHeight 49208 }; 49209 for (let i3 = breakIndex + 1; i3 < threads.length; i3++) { 49210 const thread = threads[i3]; 49211 if (!blockRefs[thread.id]) { 49212 continue; 49213 } 49214 blockElement = blockRefs[thread.id]; 49215 blockRect = blockElement?.getBoundingClientRect(); 49216 const threadTop = blockRect?.top || 0; 49217 const threadHeight = heights[thread.id] || 0; 49218 let additionalOffset = -16; 49219 const previousBottom = previousThreadData.threadTop + previousThreadData.threadHeight; 49220 if (threadTop < previousBottom + 16) { 49221 additionalOffset = previousBottom - threadTop + 20; 49222 } 49223 offsets[thread.id] = additionalOffset; 49224 previousThreadData = { 49225 threadTop: threadTop + additionalOffset, 49226 threadHeight 49227 }; 49228 } 49229 let nextThreadData = { 49230 threadTop: selectedThreadTop - 16 49231 }; 49232 for (let i3 = selectedThreadIndex - 1; i3 >= 0; i3--) { 49233 const thread = threads[i3]; 49234 if (!blockRefs[thread.id]) { 49235 continue; 49236 } 49237 blockElement = blockRefs[thread.id]; 49238 blockRect = blockElement?.getBoundingClientRect(); 49239 const threadTop = blockRect?.top || 0; 49240 const threadHeight = heights[thread.id] || 0; 49241 let additionalOffset = -16; 49242 const threadBottom = threadTop + threadHeight; 49243 if (threadBottom > nextThreadData.threadTop) { 49244 additionalOffset = nextThreadData.threadTop - threadTop - threadHeight - 20; 49245 } 49246 offsets[thread.id] = additionalOffset; 49247 nextThreadData = { 49248 threadTop: threadTop + additionalOffset 49249 }; 49250 } 49251 let editorMinHeight = 0; 49252 const lastThread = threads[threads.length - 1]; 49253 if (blockRefs[lastThread.id]) { 49254 const lastBlockElement = blockRefs[lastThread.id]; 49255 const lastBlockRect = lastBlockElement?.getBoundingClientRect(); 49256 const lastThreadTop = lastBlockRect?.top || 0; 49257 const lastThreadHeight = heights[lastThread.id] || 0; 49258 const lastThreadOffset = offsets[lastThread.id] || 0; 49259 editorMinHeight = lastThreadTop + lastThreadHeight + lastThreadOffset + 32; 49260 } 49261 return { offsets, minHeight: editorMinHeight }; 49262 }; 49263 const { offsets: newOffsets, minHeight } = calculateAllOffsets(); 49264 if (Object.keys(newOffsets).length > 0) { 49265 setBoardOffsets(newOffsets); 49266 } 49267 setCanvasMinHeight2(minHeight); 49268 }, [ 49269 heights, 49270 blockRefs, 49271 isFloating, 49272 threads, 49273 selectedThread, 49274 setCanvasMinHeight2 49275 ]); 49276 const handleThreadNavigation = (event, thread, isSelected) => { 49277 if (event.defaultPrevented) { 49278 return; 49279 } 49280 const currentIndex = threads.findIndex((t4) => t4.id === thread.id); 49281 if ((event.key === "Enter" || event.key === "ArrowRight") && event.currentTarget === event.target && !isSelected) { 49282 setNewNoteFormState("closed"); 49283 setSelectedThread(thread.id); 49284 if (!!thread.blockClientId) { 49285 selectBlock2(thread.blockClientId, null); 49286 toggleBlockSpotlight(thread.blockClientId, true); 49287 } 49288 } else if ((event.key === "Enter" || event.key === "ArrowLeft") && event.currentTarget === event.target && isSelected || event.key === "Escape") { 49289 setSelectedThread(null); 49290 setNewNoteFormState("closed"); 49291 if (thread.blockClientId) { 49292 toggleBlockSpotlight(thread.blockClientId, false); 49293 } 49294 focusCommentThread(thread.id, commentSidebarRef.current); 49295 } else if (event.key === "ArrowDown" && currentIndex < threads.length - 1 && event.currentTarget === event.target) { 49296 const nextThread = threads[currentIndex + 1]; 49297 focusCommentThread(nextThread.id, commentSidebarRef.current); 49298 } else if (event.key === "ArrowUp" && currentIndex > 0 && event.currentTarget === event.target) { 49299 const prevThread = threads[currentIndex - 1]; 49300 focusCommentThread(prevThread.id, commentSidebarRef.current); 49301 } else if (event.key === "Home" && event.currentTarget === event.target) { 49302 focusCommentThread(threads[0].id, commentSidebarRef.current); 49303 } else if (event.key === "End" && event.currentTarget === event.target) { 49304 focusCommentThread( 49305 threads[threads.length - 1].id, 49306 commentSidebarRef.current 49307 ); 49308 } 49309 }; 49310 const hasThreads = Array.isArray(threads) && threads.length > 0; 49311 if (!hasThreads && !isFloating) { 49312 return /* @__PURE__ */ (0, import_jsx_runtime335.jsx)( 49313 AddComment, 49314 { 49315 onSubmit: onAddReply, 49316 newNoteFormState, 49317 setNewNoteFormState, 49318 commentSidebarRef 49319 } 49320 ); 49321 } 49322 return /* @__PURE__ */ (0, import_jsx_runtime335.jsxs)(import_jsx_runtime335.Fragment, { children: [ 49323 !isFloating && newNoteFormState === "open" && /* @__PURE__ */ (0, import_jsx_runtime335.jsx)( 49324 AddComment, 49325 { 49326 onSubmit: onAddReply, 49327 newNoteFormState, 49328 setNewNoteFormState, 49329 commentSidebarRef 49330 } 49331 ), 49332 threads.map((thread) => /* @__PURE__ */ (0, import_jsx_runtime335.jsx)( 49333 Thread, 49334 { 49335 thread, 49336 onAddReply, 49337 onCommentDelete: handleDelete, 49338 onEditComment, 49339 isSelected: selectedThread === thread.id, 49340 setSelectedThread, 49341 setNewNoteFormState, 49342 commentSidebarRef, 49343 reflowComments, 49344 isFloating, 49345 calculatedOffset: boardOffsets[thread.id] ?? 0, 49346 setHeights, 49347 setBlockRef, 49348 selectedThread, 49349 commentLastUpdated, 49350 newNoteFormState, 49351 onKeyDown: (event) => handleThreadNavigation( 49352 event, 49353 thread, 49354 selectedThread === thread.id 49355 ) 49356 }, 49357 thread.id 49358 )) 49359 ] }); 49360 } 49361 function Thread({ 49362 thread, 49363 onEditComment, 49364 onAddReply, 49365 onCommentDelete, 49366 isSelected, 49367 setNewNoteFormState, 49368 commentSidebarRef, 49369 reflowComments, 49370 isFloating, 49371 calculatedOffset, 49372 setHeights, 49373 setBlockRef, 49374 setSelectedThread, 49375 selectedThread, 49376 commentLastUpdated, 49377 newNoteFormState, 49378 onKeyDown 49379 }) { 49380 const { toggleBlockHighlight, selectBlock: selectBlock2, toggleBlockSpotlight } = unlock( 49381 (0, import_data223.useDispatch)(import_block_editor94.store) 49382 ); 49383 const relatedBlockElement = useBlockElement3(thread.blockClientId); 49384 const debouncedToggleBlockHighlight = (0, import_compose60.useDebounce)( 49385 toggleBlockHighlight, 49386 50 49387 ); 49388 const { y: y3, refs } = useFloatingThread({ 49389 thread, 49390 calculatedOffset, 49391 setHeights, 49392 setBlockRef, 49393 selectedThread, 49394 commentLastUpdated 49395 }); 49396 const isKeyboardTabbingRef = (0, import_element170.useRef)(false); 49397 const onMouseEnter = () => { 49398 debouncedToggleBlockHighlight(thread.blockClientId, true); 49399 }; 49400 const onMouseLeave = () => { 49401 debouncedToggleBlockHighlight(thread.blockClientId, false); 49402 }; 49403 const onFocus = () => { 49404 toggleBlockHighlight(thread.blockClientId, true); 49405 }; 49406 const onBlur = (event) => { 49407 const isNoteFocused = event.relatedTarget?.closest( 49408 ".editor-collab-sidebar-panel__thread" 49409 ); 49410 const isDialogFocused = event.relatedTarget?.closest('[role="dialog"]'); 49411 const isTabbing = isKeyboardTabbingRef.current; 49412 if (isNoteFocused && !isTabbing) { 49413 return; 49414 } 49415 if (isDialogFocused) { 49416 return; 49417 } 49418 if (isTabbing && event.currentTarget.contains(event.relatedTarget)) { 49419 return; 49420 } 49421 toggleBlockHighlight(thread.blockClientId, false); 49422 unselectThread(); 49423 }; 49424 const handleCommentSelect = () => { 49425 setNewNoteFormState("closed"); 49426 setSelectedThread(thread.id); 49427 toggleBlockSpotlight(thread.blockClientId, true); 49428 if (!!thread.blockClientId) { 49429 selectBlock2(thread.blockClientId, null); 49430 } 49431 }; 49432 const unselectThread = () => { 49433 setSelectedThread(null); 49434 setNewNoteFormState("closed"); 49435 toggleBlockSpotlight(thread.blockClientId, false); 49436 }; 49437 const allReplies = thread?.reply || []; 49438 const lastReply = allReplies.length > 0 ? allReplies[allReplies.length - 1] : void 0; 49439 const restReplies = allReplies.length > 0 ? allReplies.slice(0, -1) : []; 49440 const commentExcerpt = getCommentExcerpt( 49441 (0, import_dom8.__unstableStripHTML)(thread.content?.rendered), 49442 10 49443 ); 49444 const ariaLabel = !!thread.blockClientId ? (0, import_i18n218.sprintf)( 49445 // translators: %s: note excerpt 49446 (0, import_i18n218.__)("Note: %s"), 49447 commentExcerpt 49448 ) : (0, import_i18n218.sprintf)( 49449 // translators: %s: note excerpt 49450 (0, import_i18n218.__)("Original block deleted. Note: %s"), 49451 commentExcerpt 49452 ); 49453 if (thread.id === "new-note-thread" && newNoteFormState === "open" && isFloating) { 49454 return /* @__PURE__ */ (0, import_jsx_runtime335.jsx)( 49455 AddComment, 49456 { 49457 onSubmit: onAddReply, 49458 newNoteFormState, 49459 setNewNoteFormState, 49460 commentSidebarRef, 49461 reflowComments, 49462 isFloating, 49463 y: y3, 49464 refs 49465 } 49466 ); 49467 } 49468 return /* @__PURE__ */ (0, import_jsx_runtime335.jsxs)( 49469 import_components207.__experimentalVStack, 49470 { 49471 className: clsx_default("editor-collab-sidebar-panel__thread", { 49472 "is-selected": isSelected, 49473 "is-floating": isFloating 49474 }), 49475 id: `comment-thread-$thread.id}`, 49476 spacing: "3", 49477 onClick: handleCommentSelect, 49478 onMouseEnter, 49479 onMouseLeave, 49480 onFocus, 49481 onBlur, 49482 onKeyUp: (event) => { 49483 if (event.key === "Tab") { 49484 isKeyboardTabbingRef.current = false; 49485 } 49486 }, 49487 onKeyDown: (event) => { 49488 if (event.key === "Tab") { 49489 isKeyboardTabbingRef.current = true; 49490 } else { 49491 onKeyDown(event); 49492 } 49493 }, 49494 tabIndex: 0, 49495 role: "treeitem", 49496 "aria-label": ariaLabel, 49497 "aria-expanded": isSelected, 49498 ref: isFloating ? refs.setFloating : void 0, 49499 style: isFloating ? { top: y3 } : void 0, 49500 children: [ 49501 /* @__PURE__ */ (0, import_jsx_runtime335.jsx)( 49502 import_components207.Button, 49503 { 49504 className: "editor-collab-sidebar-panel__skip-to-comment", 49505 variant: "secondary", 49506 size: "compact", 49507 onClick: () => { 49508 focusCommentThread( 49509 thread.id, 49510 commentSidebarRef.current, 49511 "textarea" 49512 ); 49513 }, 49514 children: (0, import_i18n218.__)("Add new reply") 49515 } 49516 ), 49517 !thread.blockClientId && /* @__PURE__ */ (0, import_jsx_runtime335.jsx)(import_components207.__experimentalText, { as: "p", weight: 500, variant: "muted", children: (0, import_i18n218.__)("Original block deleted.") }), 49518 /* @__PURE__ */ (0, import_jsx_runtime335.jsx)( 49519 CommentBoard, 49520 { 49521 thread, 49522 isExpanded: isSelected, 49523 onEdit: (params = {}) => { 49524 onEditComment(params); 49525 if (params.status === "approved") { 49526 unselectThread(); 49527 if (isFloating) { 49528 relatedBlockElement?.focus(); 49529 } else { 49530 focusCommentThread( 49531 thread.id, 49532 commentSidebarRef.current 49533 ); 49534 } 49535 } 49536 }, 49537 onDelete: onCommentDelete, 49538 reflowComments 49539 } 49540 ), 49541 isSelected && allReplies.map((reply) => /* @__PURE__ */ (0, import_jsx_runtime335.jsx)( 49542 CommentBoard, 49543 { 49544 thread: reply, 49545 parent: thread, 49546 isExpanded: isSelected, 49547 onEdit: onEditComment, 49548 onDelete: onCommentDelete, 49549 reflowComments 49550 }, 49551 reply.id 49552 )), 49553 !isSelected && restReplies.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime335.jsx)(import_components207.__experimentalHStack, { className: "editor-collab-sidebar-panel__more-reply-separator", children: /* @__PURE__ */ (0, import_jsx_runtime335.jsx)( 49554 import_components207.Button, 49555 { 49556 size: "compact", 49557 variant: "tertiary", 49558 className: "editor-collab-sidebar-panel__more-reply-button", 49559 onClick: () => { 49560 setSelectedThread(thread.id); 49561 focusCommentThread( 49562 thread.id, 49563 commentSidebarRef.current 49564 ); 49565 }, 49566 children: (0, import_i18n218.sprintf)( 49567 // translators: %s: number of replies. 49568 (0, import_i18n218._n)( 49569 "%s more reply", 49570 "%s more replies", 49571 restReplies.length 49572 ), 49573 restReplies.length 49574 ) 49575 } 49576 ) }), 49577 !isSelected && lastReply && /* @__PURE__ */ (0, import_jsx_runtime335.jsx)( 49578 CommentBoard, 49579 { 49580 thread: lastReply, 49581 parent: thread, 49582 isExpanded: isSelected, 49583 onEdit: onEditComment, 49584 onDelete: onCommentDelete, 49585 reflowComments 49586 } 49587 ), 49588 isSelected && /* @__PURE__ */ (0, import_jsx_runtime335.jsxs)(import_components207.__experimentalVStack, { spacing: "2", role: "treeitem", children: [ 49589 /* @__PURE__ */ (0, import_jsx_runtime335.jsx)(import_components207.__experimentalHStack, { alignment: "left", spacing: "3", justify: "flex-start", children: /* @__PURE__ */ (0, import_jsx_runtime335.jsx)(comment_author_info_default, {}) }), 49590 /* @__PURE__ */ (0, import_jsx_runtime335.jsx)(import_components207.__experimentalVStack, { spacing: "2", children: /* @__PURE__ */ (0, import_jsx_runtime335.jsx)( 49591 comment_form_default, 49592 { 49593 onSubmit: (inputComment) => { 49594 if ("approved" === thread.status) { 49595 onEditComment({ 49596 id: thread.id, 49597 status: "hold", 49598 content: inputComment 49599 }); 49600 } else { 49601 onAddReply({ 49602 content: inputComment, 49603 parent: thread.id 49604 }); 49605 } 49606 }, 49607 onCancel: (event) => { 49608 event.stopPropagation(); 49609 unselectThread(); 49610 focusCommentThread( 49611 thread.id, 49612 commentSidebarRef.current 49613 ); 49614 }, 49615 submitButtonText: "approved" === thread.status ? (0, import_i18n218.__)("Reopen & Reply") : (0, import_i18n218.__)("Reply"), 49616 rows: "approved" === thread.status ? 2 : 4, 49617 labelText: (0, import_i18n218.sprintf)( 49618 // translators: %1$s: note identifier, %2$s: author name 49619 (0, import_i18n218.__)("Reply to note %1$s by %2$s"), 49620 thread.id, 49621 thread.author_name 49622 ), 49623 reflowComments 49624 } 49625 ) }) 49626 ] }), 49627 !!thread.blockClientId && /* @__PURE__ */ (0, import_jsx_runtime335.jsx)( 49628 import_components207.Button, 49629 { 49630 className: "editor-collab-sidebar-panel__skip-to-block", 49631 variant: "secondary", 49632 size: "compact", 49633 onClick: (event) => { 49634 event.stopPropagation(); 49635 relatedBlockElement?.focus(); 49636 }, 49637 children: (0, import_i18n218.__)("Back to block") 49638 } 49639 ) 49640 ] 49641 } 49642 ); 49643 } 49644 var CommentBoard = ({ 49645 thread, 49646 parent, 49647 isExpanded, 49648 onEdit, 49649 onDelete, 49650 reflowComments 49651 }) => { 49652 const [actionState, setActionState] = (0, import_element170.useState)(false); 49653 const [showConfirmDialog, setShowConfirmDialog] = (0, import_element170.useState)(false); 49654 const actionButtonRef = (0, import_element170.useRef)(null); 49655 const handleConfirmDelete = () => { 49656 onDelete(thread); 49657 setActionState(false); 49658 setShowConfirmDialog(false); 49659 }; 49660 const handleCancel = () => { 49661 setActionState(false); 49662 setShowConfirmDialog(false); 49663 actionButtonRef.current?.focus(); 49664 }; 49665 const isResolutionComment = thread.type === "note" && thread.meta && (thread.meta._wp_note_status === "resolved" || thread.meta._wp_note_status === "reopen"); 49666 const actions2 = [ 49667 { 49668 id: "edit", 49669 title: (0, import_i18n218.__)("Edit"), 49670 isEligible: ({ status }) => status !== "approved", 49671 onClick: () => { 49672 setActionState("edit"); 49673 } 49674 }, 49675 { 49676 id: "reopen", 49677 title: (0, import_i18n218._x)("Reopen", "Reopen note"), 49678 isEligible: ({ status }) => status === "approved", 49679 onClick: () => { 49680 onEdit({ id: thread.id, status: "hold" }); 49681 } 49682 }, 49683 { 49684 id: "delete", 49685 title: (0, import_i18n218.__)("Delete"), 49686 isEligible: () => true, 49687 onClick: () => { 49688 setActionState("delete"); 49689 setShowConfirmDialog(true); 49690 } 49691 } 49692 ]; 49693 const canResolve = thread.parent === 0; 49694 const moreActions = parent?.status !== "approved" ? actions2.filter((item) => item.isEligible(thread)) : []; 49695 const deleteConfirmMessage = ( 49696 // When deleting a top level note, descendants will also be deleted. 49697 thread.parent === 0 ? (0, import_i18n218.__)( 49698 "Are you sure you want to delete this note? This will also delete all of this note's replies." 49699 ) : (0, import_i18n218.__)("Are you sure you want to delete this reply?") 49700 ); 49701 return /* @__PURE__ */ (0, import_jsx_runtime335.jsxs)( 49702 import_components207.__experimentalVStack, 49703 { 49704 spacing: "2", 49705 role: thread.parent !== 0 ? "treeitem" : void 0, 49706 children: [ 49707 /* @__PURE__ */ (0, import_jsx_runtime335.jsxs)(import_components207.__experimentalHStack, { alignment: "left", spacing: "3", justify: "flex-start", children: [ 49708 /* @__PURE__ */ (0, import_jsx_runtime335.jsx)( 49709 comment_author_info_default, 49710 { 49711 avatar: thread?.author_avatar_urls?.[48], 49712 name: thread?.author_name, 49713 date: thread?.date, 49714 userId: thread?.author 49715 } 49716 ), 49717 isExpanded && /* @__PURE__ */ (0, import_jsx_runtime335.jsx)( 49718 import_components207.FlexItem, 49719 { 49720 className: "editor-collab-sidebar-panel__comment-status", 49721 onClick: (event) => { 49722 event.stopPropagation(); 49723 }, 49724 children: /* @__PURE__ */ (0, import_jsx_runtime335.jsxs)(import_components207.__experimentalHStack, { spacing: "0", children: [ 49725 canResolve && /* @__PURE__ */ (0, import_jsx_runtime335.jsx)( 49726 import_components207.Button, 49727 { 49728 label: (0, import_i18n218._x)( 49729 "Resolve", 49730 "Mark note as resolved" 49731 ), 49732 size: "small", 49733 icon: published_default, 49734 disabled: thread.status === "approved", 49735 accessibleWhenDisabled: thread.status === "approved", 49736 onClick: () => { 49737 onEdit({ 49738 id: thread.id, 49739 status: "approved" 49740 }); 49741 } 49742 } 49743 ), 49744 /* @__PURE__ */ (0, import_jsx_runtime335.jsxs)(Menu6, { placement: "bottom-end", children: [ 49745 /* @__PURE__ */ (0, import_jsx_runtime335.jsx)( 49746 Menu6.TriggerButton, 49747 { 49748 render: /* @__PURE__ */ (0, import_jsx_runtime335.jsx)( 49749 import_components207.Button, 49750 { 49751 ref: actionButtonRef, 49752 size: "small", 49753 icon: more_vertical_default, 49754 label: (0, import_i18n218.__)("Actions"), 49755 disabled: !moreActions.length, 49756 accessibleWhenDisabled: true 49757 } 49758 ) 49759 } 49760 ), 49761 /* @__PURE__ */ (0, import_jsx_runtime335.jsx)( 49762 Menu6.Popover, 49763 { 49764 modal: false, 49765 children: moreActions.map((action) => /* @__PURE__ */ (0, import_jsx_runtime335.jsx)( 49766 Menu6.Item, 49767 { 49768 onClick: () => action.onClick(), 49769 children: /* @__PURE__ */ (0, import_jsx_runtime335.jsx)(Menu6.ItemLabel, { children: action.title }) 49770 }, 49771 action.id 49772 )) 49773 } 49774 ) 49775 ] }) 49776 ] }) 49777 } 49778 ) 49779 ] }), 49780 "edit" === actionState ? /* @__PURE__ */ (0, import_jsx_runtime335.jsx)( 49781 comment_form_default, 49782 { 49783 onSubmit: (value) => { 49784 onEdit({ 49785 id: thread.id, 49786 content: value 49787 }); 49788 setActionState(false); 49789 actionButtonRef.current?.focus(); 49790 }, 49791 onCancel: () => handleCancel(), 49792 thread, 49793 submitButtonText: (0, import_i18n218._x)("Update", "verb"), 49794 labelText: (0, import_i18n218.sprintf)( 49795 // translators: %1$s: note identifier, %2$s: author name. 49796 (0, import_i18n218.__)("Edit note %1$s by %2$s"), 49797 thread.id, 49798 thread.author_name 49799 ), 49800 reflowComments 49801 } 49802 ) : /* @__PURE__ */ (0, import_jsx_runtime335.jsx)( 49803 import_element170.RawHTML, 49804 { 49805 className: clsx_default( 49806 "editor-collab-sidebar-panel__user-comment", 49807 { 49808 "editor-collab-sidebar-panel__resolution-text": isResolutionComment 49809 } 49810 ), 49811 children: isResolutionComment ? (() => { 49812 const actionText = thread.meta._wp_note_status === "resolved" ? (0, import_i18n218.__)("Marked as resolved") : (0, import_i18n218.__)("Reopened"); 49813 const content = thread?.content?.raw; 49814 if (content && typeof content === "string" && content.trim() !== "") { 49815 return (0, import_i18n218.sprintf)( 49816 // translators: %1$s: action label ("Marked as resolved" or "Reopened"); %2$s: note text. 49817 (0, import_i18n218.__)("%1$s: %2$s"), 49818 actionText, 49819 content 49820 ); 49821 } 49822 return actionText; 49823 })() : thread?.content?.rendered 49824 } 49825 ), 49826 "delete" === actionState && /* @__PURE__ */ (0, import_jsx_runtime335.jsx)( 49827 import_components207.__experimentalConfirmDialog, 49828 { 49829 isOpen: showConfirmDialog, 49830 onConfirm: handleConfirmDelete, 49831 onCancel: handleCancel, 49832 confirmButtonText: (0, import_i18n218.__)("Delete"), 49833 children: deleteConfirmMessage 49834 } 49835 ) 49836 ] 49837 } 49838 ); 49839 }; 49840 49841 // packages/editor/build-module/components/collab-sidebar/comment-menu-item.js 49842 var import_components208 = __toESM(require_components()); 49843 var import_i18n219 = __toESM(require_i18n()); 49844 var import_block_editor95 = __toESM(require_block_editor()); 49845 var import_data224 = __toESM(require_data()); 49846 var import_blocks36 = __toESM(require_blocks()); 49847 var import_jsx_runtime336 = __toESM(require_jsx_runtime()); 49848 var { CommentIconSlotFill } = unlock(import_block_editor95.privateApis); 49849 var AddCommentMenuItem = ({ clientId, onClick, isDistractionFree }) => { 49850 const block = (0, import_data224.useSelect)( 49851 (select5) => { 49852 return select5(import_block_editor95.store).getBlock(clientId); 49853 }, 49854 [clientId] 49855 ); 49856 if (!block?.isValid || block?.name === (0, import_blocks36.getUnregisteredTypeHandlerName)()) { 49857 return null; 49858 } 49859 const isDisabled = isDistractionFree || block?.name === "core/freeform"; 49860 let infoText; 49861 if (isDistractionFree) { 49862 infoText = (0, import_i18n219.__)("Notes are disabled in distraction free mode."); 49863 } else if (block?.name === "core/freeform") { 49864 infoText = (0, import_i18n219.__)("Convert to blocks to add notes."); 49865 } 49866 return /* @__PURE__ */ (0, import_jsx_runtime336.jsx)( 49867 import_components208.MenuItem, 49868 { 49869 icon: comment_default, 49870 onClick, 49871 "aria-haspopup": "dialog", 49872 disabled: isDisabled, 49873 info: infoText, 49874 children: (0, import_i18n219.__)("Add note") 49875 } 49876 ); 49877 }; 49878 var AddCommentMenuItemFill = ({ onClick, isDistractionFree }) => { 49879 return /* @__PURE__ */ (0, import_jsx_runtime336.jsx)(CommentIconSlotFill.Fill, { children: ({ clientId, onClose }) => /* @__PURE__ */ (0, import_jsx_runtime336.jsx)( 49880 AddCommentMenuItem, 49881 { 49882 clientId, 49883 isDistractionFree, 49884 onClick: () => { 49885 onClick(); 49886 onClose(); 49887 } 49888 } 49889 ) }); 49890 }; 49891 var comment_menu_item_default = AddCommentMenuItemFill; 49892 49893 // packages/editor/build-module/components/collab-sidebar/comment-indicator-toolbar.js 49894 var import_components209 = __toESM(require_components()); 49895 var import_i18n220 = __toESM(require_i18n()); 49896 var import_element171 = __toESM(require_element()); 49897 var import_block_editor96 = __toESM(require_block_editor()); 49898 var import_jsx_runtime337 = __toESM(require_jsx_runtime()); 49899 var { CommentIconToolbarSlotFill } = unlock(import_block_editor96.privateApis); 49900 var CommentAvatarIndicator = ({ onClick, thread }) => { 49901 const threadParticipants = (0, import_element171.useMemo)(() => { 49902 if (!thread) { 49903 return []; 49904 } 49905 const participantsMap = /* @__PURE__ */ new Map(); 49906 const allComments = [thread, ...thread.reply]; 49907 allComments.sort((a3, b3) => new Date(a3.date) - new Date(b3.date)); 49908 allComments.forEach((comment) => { 49909 if (comment.author_name && comment.author_avatar_urls) { 49910 if (!participantsMap.has(comment.author)) { 49911 participantsMap.set(comment.author, { 49912 name: comment.author_name, 49913 avatar: comment.author_avatar_urls?.["48"] || comment.author_avatar_urls?.["96"], 49914 id: comment.author, 49915 date: comment.date 49916 }); 49917 } 49918 } 49919 }); 49920 return Array.from(participantsMap.values()); 49921 }, [thread]); 49922 if (!threadParticipants.length) { 49923 return null; 49924 } 49925 const maxAvatars = 3; 49926 const isOverflow = threadParticipants.length > maxAvatars; 49927 const visibleParticipants = isOverflow ? threadParticipants.slice(0, maxAvatars - 1) : threadParticipants; 49928 const overflowCount = Math.max( 49929 0, 49930 threadParticipants.length - visibleParticipants.length 49931 ); 49932 const threadHasMoreParticipants = threadParticipants.length > 100; 49933 const overflowText = threadHasMoreParticipants && overflowCount > 0 ? (0, import_i18n220.__)("100+") : (0, import_i18n220.sprintf)( 49934 // translators: %s: Number of participants. 49935 (0, import_i18n220.__)("+%s"), 49936 overflowCount 49937 ); 49938 return /* @__PURE__ */ (0, import_jsx_runtime337.jsx)(CommentIconToolbarSlotFill.Fill, { children: /* @__PURE__ */ (0, import_jsx_runtime337.jsx)( 49939 import_components209.ToolbarButton, 49940 { 49941 className: "comment-avatar-indicator", 49942 label: (0, import_i18n220.__)("View notes"), 49943 onClick, 49944 showTooltip: true, 49945 children: /* @__PURE__ */ (0, import_jsx_runtime337.jsxs)(import_components209.__experimentalHStack, { spacing: "1", children: [ 49946 visibleParticipants.map((participant) => /* @__PURE__ */ (0, import_jsx_runtime337.jsx)( 49947 "img", 49948 { 49949 src: participant.avatar, 49950 alt: participant.name, 49951 className: "comment-avatar", 49952 style: { 49953 borderColor: getAvatarBorderColor( 49954 participant.id 49955 ) 49956 } 49957 }, 49958 participant.id 49959 )), 49960 overflowCount > 0 && /* @__PURE__ */ (0, import_jsx_runtime337.jsx)(import_components209.__experimentalText, { weight: 500, children: overflowText }) 49961 ] }) 49962 } 49963 ) }); 49964 }; 49965 var comment_indicator_toolbar_default = CommentAvatarIndicator; 49966 49967 // packages/editor/build-module/components/collab-sidebar/index.js 49968 var import_jsx_runtime338 = __toESM(require_jsx_runtime()); 49969 function NotesSidebarContent({ 49970 newNoteFormState, 49971 setNewNoteFormState, 49972 styles, 49973 comments, 49974 commentSidebarRef, 49975 reflowComments, 49976 commentLastUpdated, 49977 isFloating = false 49978 }) { 49979 const { onCreate, onEdit, onDelete } = useBlockCommentsActions(reflowComments); 49980 return /* @__PURE__ */ (0, import_jsx_runtime338.jsx)( 49981 import_components210.__experimentalVStack, 49982 { 49983 className: "editor-collab-sidebar-panel", 49984 style: styles, 49985 role: "tree", 49986 spacing: "3", 49987 justify: "flex-start", 49988 ref: (node) => { 49989 if (node) { 49990 commentSidebarRef.current = node; 49991 } 49992 }, 49993 "aria-label": isFloating ? (0, import_i18n221.__)("Unresolved notes") : (0, import_i18n221.__)("All notes"), 49994 children: /* @__PURE__ */ (0, import_jsx_runtime338.jsx)( 49995 Comments, 49996 { 49997 threads: comments, 49998 onEditComment: onEdit, 49999 onAddReply: onCreate, 50000 onCommentDelete: onDelete, 50001 newNoteFormState, 50002 setNewNoteFormState, 50003 commentSidebarRef, 50004 reflowComments, 50005 commentLastUpdated, 50006 isFloating 50007 } 50008 ) 50009 } 50010 ); 50011 } 50012 function NotesSidebar({ postId: postId2, mode }) { 50013 const [newNoteFormState, setNewNoteFormState] = (0, import_element172.useState)("closed"); 50014 const { getActiveComplementaryArea: getActiveComplementaryArea2 } = (0, import_data225.useSelect)(store2); 50015 const { enableComplementaryArea: enableComplementaryArea2 } = (0, import_data225.useDispatch)(store2); 50016 const { toggleBlockSpotlight } = unlock((0, import_data225.useDispatch)(import_block_editor97.store)); 50017 const isLargeViewport = (0, import_compose61.useViewportMatch)("medium"); 50018 const commentSidebarRef = (0, import_element172.useRef)(null); 50019 const showFloatingSidebar = isLargeViewport && mode === "post-only"; 50020 const { clientId, blockCommentId, isDistractionFree } = (0, import_data225.useSelect)( 50021 (select5) => { 50022 const { 50023 getBlockAttributes: getBlockAttributes2, 50024 getSelectedBlockClientId: getSelectedBlockClientId2, 50025 getSettings: getSettings5 50026 } = select5(import_block_editor97.store); 50027 const _clientId = getSelectedBlockClientId2(); 50028 return { 50029 clientId: _clientId, 50030 blockCommentId: _clientId ? getBlockAttributes2(_clientId)?.metadata?.noteId : null, 50031 isDistractionFree: getSettings5().isDistractionFree 50032 }; 50033 }, 50034 [] 50035 ); 50036 const { 50037 resultComments, 50038 unresolvedSortedThreads, 50039 reflowComments, 50040 commentLastUpdated 50041 } = useBlockComments(postId2); 50042 useEnableFloatingSidebar( 50043 showFloatingSidebar && (unresolvedSortedThreads.length > 0 || newNoteFormState !== "closed") 50044 ); 50045 const { merged: GlobalStyles } = useGlobalStylesContext(); 50046 const backgroundColor = GlobalStyles?.styles?.color?.background; 50047 const currentThread = blockCommentId ? resultComments.find((thread) => thread.id === blockCommentId) : null; 50048 const showAllNotesSidebar = resultComments.length > 0 || !showFloatingSidebar; 50049 async function openTheSidebar() { 50050 const prevArea = await getActiveComplementaryArea2("core"); 50051 const activeNotesArea = SIDEBARS.find((name2) => name2 === prevArea); 50052 if (currentThread?.status === "approved") { 50053 enableComplementaryArea2("core", collabHistorySidebarName); 50054 } else if (!activeNotesArea || !showAllNotesSidebar) { 50055 enableComplementaryArea2( 50056 "core", 50057 showFloatingSidebar ? collabSidebarName : collabHistorySidebarName 50058 ); 50059 } 50060 const currentArea = await getActiveComplementaryArea2("core"); 50061 if (!SIDEBARS.includes(currentArea)) { 50062 return; 50063 } 50064 setNewNoteFormState(!currentThread ? "open" : "closed"); 50065 focusCommentThread( 50066 currentThread?.id, 50067 commentSidebarRef.current, 50068 // Focus a comment thread when there's a selected block with a comment. 50069 !currentThread ? "textarea" : void 0 50070 ); 50071 toggleBlockSpotlight(clientId, true); 50072 } 50073 if (isDistractionFree) { 50074 return /* @__PURE__ */ (0, import_jsx_runtime338.jsx)(comment_menu_item_default, { isDistractionFree: true }); 50075 } 50076 return /* @__PURE__ */ (0, import_jsx_runtime338.jsxs)(import_jsx_runtime338.Fragment, { children: [ 50077 !!currentThread && /* @__PURE__ */ (0, import_jsx_runtime338.jsx)( 50078 comment_indicator_toolbar_default, 50079 { 50080 thread: currentThread, 50081 onClick: openTheSidebar 50082 } 50083 ), 50084 /* @__PURE__ */ (0, import_jsx_runtime338.jsx)(comment_menu_item_default, { onClick: openTheSidebar }), 50085 showAllNotesSidebar && /* @__PURE__ */ (0, import_jsx_runtime338.jsx)( 50086 PluginSidebar, 50087 { 50088 identifier: collabHistorySidebarName, 50089 name: collabHistorySidebarName, 50090 title: (0, import_i18n221.__)("All notes"), 50091 header: /* @__PURE__ */ (0, import_jsx_runtime338.jsx)("h2", { className: "interface-complementary-area-header__title", children: (0, import_i18n221.__)("All notes") }), 50092 icon: comment_default, 50093 closeLabel: (0, import_i18n221.__)("Close Notes"), 50094 children: /* @__PURE__ */ (0, import_jsx_runtime338.jsx)( 50095 NotesSidebarContent, 50096 { 50097 comments: resultComments, 50098 newNoteFormState, 50099 setNewNoteFormState, 50100 commentSidebarRef, 50101 reflowComments, 50102 commentLastUpdated 50103 } 50104 ) 50105 } 50106 ), 50107 isLargeViewport && /* @__PURE__ */ (0, import_jsx_runtime338.jsx)( 50108 PluginSidebar, 50109 { 50110 isPinnable: false, 50111 header: false, 50112 identifier: collabSidebarName, 50113 className: "editor-collab-sidebar", 50114 headerClassName: "editor-collab-sidebar__header", 50115 backgroundColor, 50116 children: /* @__PURE__ */ (0, import_jsx_runtime338.jsx)( 50117 NotesSidebarContent, 50118 { 50119 comments: unresolvedSortedThreads, 50120 newNoteFormState, 50121 setNewNoteFormState, 50122 commentSidebarRef, 50123 reflowComments, 50124 commentLastUpdated, 50125 styles: { 50126 backgroundColor 50127 }, 50128 isFloating: true 50129 } 50130 ) 50131 } 50132 ) 50133 ] }); 50134 } 50135 function NotesSidebarContainer() { 50136 const { postId: postId2, mode, editorMode } = (0, import_data225.useSelect)((select5) => { 50137 const { getCurrentPostId: getCurrentPostId2, getRenderingMode: getRenderingMode2, getEditorMode: getEditorMode2 } = select5(store); 50138 return { 50139 postId: getCurrentPostId2(), 50140 mode: getRenderingMode2(), 50141 editorMode: getEditorMode2() 50142 }; 50143 }, []); 50144 if (!postId2 || typeof postId2 !== "number") { 50145 return null; 50146 } 50147 if (editorMode === "text") { 50148 return null; 50149 } 50150 return /* @__PURE__ */ (0, import_jsx_runtime338.jsx)(post_type_support_check_default, { supportKeys: "editor.notes", children: /* @__PURE__ */ (0, import_jsx_runtime338.jsx)(NotesSidebar, { postId: postId2, mode }) }); 50151 } 50152 50153 // packages/editor/build-module/components/global-styles-sidebar/index.js 50154 var import_components213 = __toESM(require_components()); 50155 var import_i18n224 = __toESM(require_i18n()); 50156 var import_data228 = __toESM(require_data()); 50157 var import_element173 = __toESM(require_element()); 50158 var import_preferences26 = __toESM(require_preferences()); 50159 var import_compose62 = __toESM(require_compose()); 50160 var import_core_data120 = __toESM(require_core_data()); 50161 50162 // packages/editor/build-module/components/global-styles/menu.js 50163 var import_components211 = __toESM(require_components()); 50164 var import_data226 = __toESM(require_data()); 50165 var import_i18n222 = __toESM(require_i18n()); 50166 var import_preferences24 = __toESM(require_preferences()); 50167 var import_core_data119 = __toESM(require_core_data()); 50168 var import_jsx_runtime339 = __toESM(require_jsx_runtime()); 50169 function GlobalStylesActionMenu({ 50170 hideWelcomeGuide = false, 50171 onChangePath 50172 }) { 50173 const { user, setUser } = useGlobalStyles(); 50174 const canReset = !!user && (Object.keys(user?.styles ?? {}).length > 0 || Object.keys(user?.settings ?? {}).length > 0); 50175 const onReset = () => { 50176 setUser({ styles: {}, settings: {} }); 50177 }; 50178 const { toggle } = (0, import_data226.useDispatch)(import_preferences24.store); 50179 const { canEditCSS } = (0, import_data226.useSelect)((select5) => { 50180 const { getEntityRecord, __experimentalGetCurrentGlobalStylesId } = select5(import_core_data119.store); 50181 const globalStylesId = __experimentalGetCurrentGlobalStylesId(); 50182 const globalStyles = globalStylesId ? getEntityRecord("root", "globalStyles", globalStylesId) : void 0; 50183 return { 50184 canEditCSS: !!globalStyles?._links?.["wp:action-edit-css"] 50185 }; 50186 }, []); 50187 const loadCustomCSS = () => { 50188 onChangePath("/css"); 50189 }; 50190 return /* @__PURE__ */ (0, import_jsx_runtime339.jsx)( 50191 import_components211.DropdownMenu, 50192 { 50193 icon: more_vertical_default, 50194 label: (0, import_i18n222.__)("More"), 50195 toggleProps: { size: "compact" }, 50196 children: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime339.jsxs)(import_jsx_runtime339.Fragment, { children: [ 50197 /* @__PURE__ */ (0, import_jsx_runtime339.jsxs)(import_components211.MenuGroup, { children: [ 50198 canEditCSS && /* @__PURE__ */ (0, import_jsx_runtime339.jsx)(import_components211.MenuItem, { onClick: loadCustomCSS, children: (0, import_i18n222.__)("Additional CSS") }), 50199 !hideWelcomeGuide && /* @__PURE__ */ (0, import_jsx_runtime339.jsx)( 50200 import_components211.MenuItem, 50201 { 50202 onClick: () => { 50203 toggle( 50204 "core/edit-site", 50205 "welcomeGuideStyles" 50206 ); 50207 onClose(); 50208 }, 50209 children: (0, import_i18n222.__)("Welcome Guide") 50210 } 50211 ) 50212 ] }), 50213 /* @__PURE__ */ (0, import_jsx_runtime339.jsx)(import_components211.MenuGroup, { children: /* @__PURE__ */ (0, import_jsx_runtime339.jsx)( 50214 import_components211.MenuItem, 50215 { 50216 onClick: () => { 50217 onReset(); 50218 onClose(); 50219 }, 50220 disabled: !canReset, 50221 children: (0, import_i18n222.__)("Reset styles") 50222 } 50223 ) }) 50224 ] }) 50225 } 50226 ); 50227 } 50228 50229 // packages/editor/build-module/components/global-styles-sidebar/default-sidebar.js 50230 var import_jsx_runtime340 = __toESM(require_jsx_runtime()); 50231 function DefaultSidebar({ 50232 className, 50233 identifier, 50234 title, 50235 icon, 50236 children, 50237 closeLabel, 50238 header, 50239 headerClassName, 50240 panelClassName, 50241 isActiveByDefault 50242 }) { 50243 return /* @__PURE__ */ (0, import_jsx_runtime340.jsxs)(import_jsx_runtime340.Fragment, { children: [ 50244 /* @__PURE__ */ (0, import_jsx_runtime340.jsx)( 50245 complementary_area_default, 50246 { 50247 className, 50248 scope: "core", 50249 identifier, 50250 title, 50251 icon, 50252 closeLabel, 50253 header, 50254 headerClassName, 50255 panelClassName, 50256 isActiveByDefault, 50257 children 50258 } 50259 ), 50260 /* @__PURE__ */ (0, import_jsx_runtime340.jsx)( 50261 ComplementaryAreaMoreMenuItem, 50262 { 50263 scope: "core", 50264 identifier, 50265 icon, 50266 children: title 50267 } 50268 ) 50269 ] }); 50270 } 50271 50272 // packages/editor/build-module/components/global-styles-sidebar/welcome-guide.js 50273 var import_data227 = __toESM(require_data()); 50274 var import_components212 = __toESM(require_components()); 50275 var import_i18n223 = __toESM(require_i18n()); 50276 var import_preferences25 = __toESM(require_preferences()); 50277 50278 // packages/editor/build-module/components/global-styles-sidebar/welcome-guide-image.js 50279 var import_jsx_runtime341 = __toESM(require_jsx_runtime()); 50280 function WelcomeGuideImage({ nonAnimatedSrc, animatedSrc }) { 50281 return /* @__PURE__ */ (0, import_jsx_runtime341.jsxs)("picture", { className: "editor-welcome-guide__image", children: [ 50282 /* @__PURE__ */ (0, import_jsx_runtime341.jsx)( 50283 "source", 50284 { 50285 srcSet: nonAnimatedSrc, 50286 media: "(prefers-reduced-motion: reduce)" 50287 } 50288 ), 50289 /* @__PURE__ */ (0, import_jsx_runtime341.jsx)("img", { src: animatedSrc, width: "312", height: "240", alt: "" }) 50290 ] }); 50291 } 50292 50293 // packages/editor/build-module/components/global-styles-sidebar/welcome-guide.js 50294 var import_jsx_runtime342 = __toESM(require_jsx_runtime()); 50295 function WelcomeGuideStyles() { 50296 const { toggle } = (0, import_data227.useDispatch)(import_preferences25.store); 50297 const { isActive, isStylesOpen } = (0, import_data227.useSelect)((select5) => { 50298 const sidebar = select5(store2).getActiveComplementaryArea("core"); 50299 return { 50300 isActive: !!select5(import_preferences25.store).get( 50301 "core/edit-site", 50302 "welcomeGuideStyles" 50303 ), 50304 isStylesOpen: sidebar === "edit-site/global-styles" 50305 }; 50306 }, []); 50307 if (!isActive || !isStylesOpen) { 50308 return null; 50309 } 50310 const welcomeLabel = (0, import_i18n223.__)("Welcome to Styles"); 50311 return /* @__PURE__ */ (0, import_jsx_runtime342.jsx)( 50312 import_components212.Guide, 50313 { 50314 className: "editor-welcome-guide guide-styles", 50315 contentLabel: welcomeLabel, 50316 finishButtonText: (0, import_i18n223.__)("Get started"), 50317 onFinish: () => toggle("core/edit-site", "welcomeGuideStyles"), 50318 pages: [ 50319 { 50320 image: /* @__PURE__ */ (0, import_jsx_runtime342.jsx)( 50321 WelcomeGuideImage, 50322 { 50323 nonAnimatedSrc: "https://s.w.org/images/block-editor/welcome-to-styles.svg?1", 50324 animatedSrc: "https://s.w.org/images/block-editor/welcome-to-styles.gif?1" 50325 } 50326 ), 50327 content: /* @__PURE__ */ (0, import_jsx_runtime342.jsxs)(import_jsx_runtime342.Fragment, { children: [ 50328 /* @__PURE__ */ (0, import_jsx_runtime342.jsx)("h1", { className: "editor-welcome-guide__heading", children: welcomeLabel }), 50329 /* @__PURE__ */ (0, import_jsx_runtime342.jsx)("p", { className: "editor-welcome-guide__text", children: (0, import_i18n223.__)( 50330 "Tweak your site, or give it a whole new look! Get creative \u2014 how about a new color palette for your buttons, or choosing a new font? Take a look at what you can do here." 50331 ) }) 50332 ] }) 50333 }, 50334 { 50335 image: /* @__PURE__ */ (0, import_jsx_runtime342.jsx)( 50336 WelcomeGuideImage, 50337 { 50338 nonAnimatedSrc: "https://s.w.org/images/block-editor/set-the-design.svg?1", 50339 animatedSrc: "https://s.w.org/images/block-editor/set-the-design.gif?1" 50340 } 50341 ), 50342 content: /* @__PURE__ */ (0, import_jsx_runtime342.jsxs)(import_jsx_runtime342.Fragment, { children: [ 50343 /* @__PURE__ */ (0, import_jsx_runtime342.jsx)("h1", { className: "editor-welcome-guide__heading", children: (0, import_i18n223.__)("Set the design") }), 50344 /* @__PURE__ */ (0, import_jsx_runtime342.jsx)("p", { className: "editor-welcome-guide__text", children: (0, import_i18n223.__)( 50345 "You can customize your site as much as you like with different colors, typography, and layouts. Or if you prefer, just leave it up to your theme to handle!" 50346 ) }) 50347 ] }) 50348 }, 50349 { 50350 image: /* @__PURE__ */ (0, import_jsx_runtime342.jsx)( 50351 WelcomeGuideImage, 50352 { 50353 nonAnimatedSrc: "https://s.w.org/images/block-editor/personalize-blocks.svg?1", 50354 animatedSrc: "https://s.w.org/images/block-editor/personalize-blocks.gif?1" 50355 } 50356 ), 50357 content: /* @__PURE__ */ (0, import_jsx_runtime342.jsxs)(import_jsx_runtime342.Fragment, { children: [ 50358 /* @__PURE__ */ (0, import_jsx_runtime342.jsx)("h1", { className: "editor-welcome-guide__heading", children: (0, import_i18n223.__)("Personalize blocks") }), 50359 /* @__PURE__ */ (0, import_jsx_runtime342.jsx)("p", { className: "editor-welcome-guide__text", children: (0, import_i18n223.__)( 50360 "You can adjust your blocks to ensure a cohesive experience across your site \u2014 add your unique colors to a branded Button block, or adjust the Heading block to your preferred size." 50361 ) }) 50362 ] }) 50363 }, 50364 { 50365 image: /* @__PURE__ */ (0, import_jsx_runtime342.jsx)( 50366 WelcomeGuideImage, 50367 { 50368 nonAnimatedSrc: "https://s.w.org/images/block-editor/welcome-documentation.svg", 50369 animatedSrc: "https://s.w.org/images/block-editor/welcome-documentation.gif" 50370 } 50371 ), 50372 content: /* @__PURE__ */ (0, import_jsx_runtime342.jsxs)(import_jsx_runtime342.Fragment, { children: [ 50373 /* @__PURE__ */ (0, import_jsx_runtime342.jsx)("h1", { className: "editor-welcome-guide__heading", children: (0, import_i18n223.__)("Learn more") }), 50374 /* @__PURE__ */ (0, import_jsx_runtime342.jsxs)("p", { className: "editor-welcome-guide__text", children: [ 50375 (0, import_i18n223.__)( 50376 "New to block themes and styling your site?" 50377 ), 50378 " ", 50379 /* @__PURE__ */ (0, import_jsx_runtime342.jsx)( 50380 import_components212.ExternalLink, 50381 { 50382 href: (0, import_i18n223.__)( 50383 "https://wordpress.org/documentation/article/styles-overview/" 50384 ), 50385 children: (0, import_i18n223.__)( 50386 "Here\u2019s a detailed guide to learn how to make the most of it." 50387 ) 50388 } 50389 ) 50390 ] }) 50391 ] }) 50392 } 50393 ] 50394 } 50395 ); 50396 } 50397 50398 // packages/editor/build-module/components/global-styles-sidebar/index.js 50399 var import_jsx_runtime343 = __toESM(require_jsx_runtime()); 50400 function GlobalStylesSidebar() { 50401 const { 50402 shouldResetNavigation, 50403 stylesPath: stylesPath2, 50404 showStylebook: showStylebook2, 50405 showListViewByDefault, 50406 hasRevisions, 50407 activeComplementaryArea 50408 } = (0, import_data228.useSelect)((select5) => { 50409 const { getActiveComplementaryArea: getActiveComplementaryArea2 } = select5(store2); 50410 const { getStylesPath: getStylesPath2, getShowStylebook: getShowStylebook2 } = unlock( 50411 select5(store) 50412 ); 50413 const _isVisualEditorMode = "visual" === select5(store).getEditorMode(); 50414 const _showListViewByDefault = select5(import_preferences26.store).get( 50415 "core", 50416 "showListViewByDefault" 50417 ); 50418 const { getEntityRecord, __experimentalGetCurrentGlobalStylesId } = select5(import_core_data120.store); 50419 const globalStylesId = __experimentalGetCurrentGlobalStylesId(); 50420 const globalStyles = globalStylesId ? getEntityRecord("root", "globalStyles", globalStylesId) : void 0; 50421 return { 50422 stylesPath: getStylesPath2(), 50423 showStylebook: getShowStylebook2(), 50424 shouldResetNavigation: "edit-site/global-styles" !== getActiveComplementaryArea2("core") || !_isVisualEditorMode, 50425 showListViewByDefault: _showListViewByDefault, 50426 hasRevisions: !!globalStyles?._links?.["version-history"]?.[0]?.count, 50427 activeComplementaryArea: select5(store2).getActiveComplementaryArea("core") 50428 }; 50429 }, []); 50430 const { setStylesPath: setStylesPath2, setShowStylebook: setShowStylebook2, resetStylesNavigation: resetStylesNavigation2 } = unlock( 50431 (0, import_data228.useDispatch)(store) 50432 ); 50433 const isMobileViewport = (0, import_compose62.useViewportMatch)("medium", "<"); 50434 const isRevisionsOpened = stylesPath2.startsWith("/revisions") && !showStylebook2; 50435 const isRevisionsStyleBookOpened = stylesPath2.startsWith("/revisions") && showStylebook2; 50436 const previousActiveArea = (0, import_compose62.usePrevious)(activeComplementaryArea); 50437 (0, import_element173.useEffect)(() => { 50438 if (activeComplementaryArea === "edit-site/global-styles" && previousActiveArea !== "edit-site/global-styles") { 50439 resetStylesNavigation2(); 50440 } 50441 }, [activeComplementaryArea, previousActiveArea, resetStylesNavigation2]); 50442 (0, import_element173.useEffect)(() => { 50443 if (shouldResetNavigation) { 50444 resetStylesNavigation2(); 50445 } 50446 }, [shouldResetNavigation, resetStylesNavigation2]); 50447 const { setIsListViewOpened: setIsListViewOpened2 } = (0, import_data228.useDispatch)(store); 50448 const toggleRevisions = () => { 50449 setIsListViewOpened2(false); 50450 if (isRevisionsOpened || isRevisionsStyleBookOpened) { 50451 setStylesPath2("/"); 50452 } else { 50453 setStylesPath2("/revisions"); 50454 } 50455 }; 50456 const toggleStyleBook = () => { 50457 setIsListViewOpened2(showStylebook2 && showListViewByDefault); 50458 setShowStylebook2(!showStylebook2); 50459 }; 50460 return /* @__PURE__ */ (0, import_jsx_runtime343.jsxs)(import_jsx_runtime343.Fragment, { children: [ 50461 /* @__PURE__ */ (0, import_jsx_runtime343.jsx)( 50462 DefaultSidebar, 50463 { 50464 className: "editor-global-styles-sidebar", 50465 identifier: "edit-site/global-styles", 50466 title: (0, import_i18n224.__)("Styles"), 50467 icon: styles_default, 50468 closeLabel: (0, import_i18n224.__)("Close Styles"), 50469 panelClassName: "editor-global-styles-sidebar__panel", 50470 header: /* @__PURE__ */ (0, import_jsx_runtime343.jsxs)( 50471 import_components213.Flex, 50472 { 50473 className: "editor-global-styles-sidebar__header", 50474 gap: 1, 50475 children: [ 50476 /* @__PURE__ */ (0, import_jsx_runtime343.jsx)(import_components213.FlexItem, { children: /* @__PURE__ */ (0, import_jsx_runtime343.jsx)("h2", { className: "editor-global-styles-sidebar__header-title", children: (0, import_i18n224.__)("Styles") }) }), 50477 /* @__PURE__ */ (0, import_jsx_runtime343.jsxs)( 50478 import_components213.Flex, 50479 { 50480 justify: "flex-end", 50481 gap: 1, 50482 className: "editor-global-styles-sidebar__header-actions", 50483 children: [ 50484 !isMobileViewport && /* @__PURE__ */ (0, import_jsx_runtime343.jsx)(import_components213.FlexItem, { children: /* @__PURE__ */ (0, import_jsx_runtime343.jsx)( 50485 import_components213.Button, 50486 { 50487 icon: seen_default, 50488 label: (0, import_i18n224.__)("Style Book"), 50489 isPressed: showStylebook2, 50490 accessibleWhenDisabled: true, 50491 disabled: shouldResetNavigation, 50492 onClick: toggleStyleBook, 50493 size: "compact" 50494 } 50495 ) }), 50496 /* @__PURE__ */ (0, import_jsx_runtime343.jsx)(import_components213.FlexItem, { children: /* @__PURE__ */ (0, import_jsx_runtime343.jsx)( 50497 import_components213.Button, 50498 { 50499 label: (0, import_i18n224.__)("Revisions"), 50500 icon: backup_default, 50501 onClick: toggleRevisions, 50502 accessibleWhenDisabled: true, 50503 disabled: !hasRevisions, 50504 isPressed: isRevisionsOpened || isRevisionsStyleBookOpened, 50505 size: "compact" 50506 } 50507 ) }), 50508 /* @__PURE__ */ (0, import_jsx_runtime343.jsx)( 50509 GlobalStylesActionMenu, 50510 { 50511 onChangePath: setStylesPath2 50512 } 50513 ) 50514 ] 50515 } 50516 ) 50517 ] 50518 } 50519 ), 50520 children: /* @__PURE__ */ (0, import_jsx_runtime343.jsx)( 50521 GlobalStylesUIWrapper, 50522 { 50523 path: stylesPath2, 50524 onPathChange: setStylesPath2 50525 } 50526 ) 50527 } 50528 ), 50529 /* @__PURE__ */ (0, import_jsx_runtime343.jsx)(WelcomeGuideStyles, {}) 50530 ] }); 50531 } 50532 50533 // packages/editor/build-module/components/editor/index.js 50534 var import_jsx_runtime344 = __toESM(require_jsx_runtime()); 50535 function Editor({ 50536 postType: postType2, 50537 postId: postId2, 50538 templateId: templateId2, 50539 settings, 50540 children, 50541 initialEdits, 50542 initialSelection, 50543 // This could be part of the settings. 50544 onActionPerformed, 50545 // The following abstractions are not ideal but necessary 50546 // to account for site editor and post editor differences for now. 50547 extraContent, 50548 extraSidebarPanels, 50549 ...props 50550 }) { 50551 const { 50552 post: post2, 50553 template: template2, 50554 hasLoadedPost, 50555 error, 50556 isBlockTheme, 50557 showGlobalStyles 50558 } = (0, import_data229.useSelect)( 50559 (select5) => { 50560 const { 50561 getEntityRecord, 50562 getResolutionError, 50563 hasFinishedResolution, 50564 getCurrentTheme, 50565 __experimentalGetCurrentGlobalStylesId, 50566 canUser 50567 } = select5(import_core_data121.store); 50568 const { getRenderingMode: getRenderingMode2, getCurrentPostType: getCurrentPostType2 } = select5(store); 50569 const postArgs = ["postType", postType2, postId2]; 50570 const renderingMode2 = getRenderingMode2(); 50571 const currentPostType = getCurrentPostType2(); 50572 const _isBlockTheme = getCurrentTheme()?.is_block_theme; 50573 const globalStylesId = __experimentalGetCurrentGlobalStylesId(); 50574 const userCanEditGlobalStyles = globalStylesId ? canUser("update", { 50575 kind: "root", 50576 name: "globalStyles", 50577 id: globalStylesId 50578 }) : false; 50579 return { 50580 post: getEntityRecord(...postArgs), 50581 template: templateId2 ? getEntityRecord( 50582 "postType", 50583 TEMPLATE_POST_TYPE, 50584 templateId2 50585 ) : void 0, 50586 hasLoadedPost: hasFinishedResolution( 50587 "getEntityRecord", 50588 postArgs 50589 ), 50590 error: getResolutionError("getEntityRecord", postArgs)?.message, 50591 isBlockTheme: _isBlockTheme, 50592 showGlobalStyles: _isBlockTheme && userCanEditGlobalStyles && (currentPostType === "wp_template" || renderingMode2 === "template-locked") 50593 }; 50594 }, 50595 [postType2, postId2, templateId2] 50596 ); 50597 const { selectBlock: selectBlock2 } = (0, import_data229.useDispatch)(import_block_editor98.store); 50598 const restoreBlockFromPath = useRestoreBlockFromPath(); 50599 (0, import_element174.useEffect)(() => { 50600 if (!initialSelection || !hasLoadedPost || !post2) { 50601 return; 50602 } 50603 const timeoutId = setTimeout(() => { 50604 const clientId = restoreBlockFromPath(initialSelection); 50605 if (clientId) { 50606 selectBlock2(clientId); 50607 } 50608 }, 0); 50609 return () => clearTimeout(timeoutId); 50610 }, [ 50611 initialSelection, 50612 hasLoadedPost, 50613 post2, 50614 selectBlock2, 50615 restoreBlockFromPath 50616 ]); 50617 return /* @__PURE__ */ (0, import_jsx_runtime344.jsxs)(import_jsx_runtime344.Fragment, { children: [ 50618 hasLoadedPost && !post2 && /* @__PURE__ */ (0, import_jsx_runtime344.jsx)( 50619 import_components214.Notice, 50620 { 50621 status: !!error ? "error" : "warning", 50622 isDismissible: false, 50623 children: !error ? (0, import_i18n225.__)( 50624 "You attempted to edit an item that doesn't exist. Perhaps it was deleted?" 50625 ) : error 50626 } 50627 ), 50628 !!post2 && /* @__PURE__ */ (0, import_jsx_runtime344.jsxs)( 50629 ExperimentalEditorProvider, 50630 { 50631 post: post2, 50632 __unstableTemplate: template2, 50633 settings, 50634 initialEdits, 50635 useSubRegistry: false, 50636 children: [ 50637 /* @__PURE__ */ (0, import_jsx_runtime344.jsx)(EditorInterface, { ...props, children: extraContent }), 50638 children, 50639 /* @__PURE__ */ (0, import_jsx_runtime344.jsx)( 50640 sidebar_default2, 50641 { 50642 onActionPerformed, 50643 extraPanels: extraSidebarPanels 50644 } 50645 ), 50646 /* @__PURE__ */ (0, import_jsx_runtime344.jsx)(NotesSidebarContainer, {}), 50647 isBlockTheme && /* @__PURE__ */ (0, import_jsx_runtime344.jsx)(GlobalStylesRenderer, {}), 50648 showGlobalStyles && /* @__PURE__ */ (0, import_jsx_runtime344.jsx)(GlobalStylesSidebar, {}) 50649 ] 50650 } 50651 ) 50652 ] }); 50653 } 50654 var editor_default = Editor; 50655 50656 // packages/editor/build-module/components/preferences-modal/index.js 50657 var import_i18n227 = __toESM(require_i18n()); 50658 var import_compose63 = __toESM(require_compose()); 50659 var import_data232 = __toESM(require_data()); 50660 var import_element176 = __toESM(require_element()); 50661 var import_preferences29 = __toESM(require_preferences()); 50662 50663 // packages/editor/build-module/components/preferences-modal/enable-publish-sidebar.js 50664 var import_data230 = __toESM(require_data()); 50665 var import_preferences27 = __toESM(require_preferences()); 50666 var import_jsx_runtime345 = __toESM(require_jsx_runtime()); 50667 var { PreferenceBaseOption: PreferenceBaseOption2 } = unlock(import_preferences27.privateApis); 50668 function EnablePublishSidebarOption(props) { 50669 const isChecked = (0, import_data230.useSelect)((select5) => { 50670 return select5(store).isPublishSidebarEnabled(); 50671 }, []); 50672 const { enablePublishSidebar: enablePublishSidebar2, disablePublishSidebar: disablePublishSidebar2 } = (0, import_data230.useDispatch)(store); 50673 return /* @__PURE__ */ (0, import_jsx_runtime345.jsx)( 50674 PreferenceBaseOption2, 50675 { 50676 isChecked, 50677 onChange: (isEnabled) => isEnabled ? enablePublishSidebar2() : disablePublishSidebar2(), 50678 ...props 50679 } 50680 ); 50681 } 50682 50683 // packages/editor/build-module/components/block-visibility/index.js 50684 var import_data231 = __toESM(require_data()); 50685 var import_preferences28 = __toESM(require_preferences()); 50686 var import_blocks37 = __toESM(require_blocks()); 50687 var import_element175 = __toESM(require_element()); 50688 var import_components215 = __toESM(require_components()); 50689 var import_i18n226 = __toESM(require_i18n()); 50690 var import_block_editor99 = __toESM(require_block_editor()); 50691 var import_jsx_runtime346 = __toESM(require_jsx_runtime()); 50692 var { BlockManager } = unlock(import_block_editor99.privateApis); 50693 var EMPTY_ARRAY8 = []; 50694 function BlockVisibility() { 50695 const { showBlockTypes: showBlockTypes2, hideBlockTypes: hideBlockTypes2 } = unlock( 50696 (0, import_data231.useDispatch)(store) 50697 ); 50698 const { 50699 blockTypes, 50700 allowedBlockTypes: _allowedBlockTypes, 50701 hiddenBlockTypes: _hiddenBlockTypes 50702 } = (0, import_data231.useSelect)((select5) => { 50703 return { 50704 blockTypes: select5(import_blocks37.store).getBlockTypes(), 50705 allowedBlockTypes: select5(store).getEditorSettings().allowedBlockTypes, 50706 hiddenBlockTypes: select5(import_preferences28.store).get("core", "hiddenBlockTypes") ?? EMPTY_ARRAY8 50707 }; 50708 }, []); 50709 const allowedBlockTypes = (0, import_element175.useMemo)(() => { 50710 if (_allowedBlockTypes === true) { 50711 return blockTypes; 50712 } 50713 return blockTypes.filter(({ name: name2 }) => { 50714 return _allowedBlockTypes?.includes(name2); 50715 }); 50716 }, [_allowedBlockTypes, blockTypes]); 50717 const filteredBlockTypes = allowedBlockTypes.filter( 50718 (blockType) => (0, import_blocks37.hasBlockSupport)(blockType, "inserter", true) && (!blockType.parent || blockType.parent.includes("core/post-content")) 50719 ); 50720 const hiddenBlockTypes = _hiddenBlockTypes.filter((hiddenBlock) => { 50721 return filteredBlockTypes.some( 50722 (registeredBlock) => registeredBlock.name === hiddenBlock 50723 ); 50724 }); 50725 const selectedBlockTypes = filteredBlockTypes.filter( 50726 (blockType) => !hiddenBlockTypes.includes(blockType.name) 50727 ); 50728 const numberOfHiddenBlocks = filteredBlockTypes.length - selectedBlockTypes.length; 50729 function enableAllBlockTypes() { 50730 onChangeSelectedBlockTypes(filteredBlockTypes); 50731 } 50732 const onChangeSelectedBlockTypes = (newSelectedBlockTypes) => { 50733 if (selectedBlockTypes.length > newSelectedBlockTypes.length) { 50734 const blockTypesToHide = selectedBlockTypes.filter( 50735 (blockType) => !newSelectedBlockTypes.find( 50736 ({ name: name2 }) => name2 === blockType.name 50737 ) 50738 ); 50739 hideBlockTypes2(blockTypesToHide.map(({ name: name2 }) => name2)); 50740 } else if (selectedBlockTypes.length < newSelectedBlockTypes.length) { 50741 const blockTypesToShow = newSelectedBlockTypes.filter( 50742 (blockType) => !selectedBlockTypes.find( 50743 ({ name: name2 }) => name2 === blockType.name 50744 ) 50745 ); 50746 showBlockTypes2(blockTypesToShow.map(({ name: name2 }) => name2)); 50747 } 50748 }; 50749 return /* @__PURE__ */ (0, import_jsx_runtime346.jsxs)("div", { className: "editor-block-visibility", children: [ 50750 !!numberOfHiddenBlocks && /* @__PURE__ */ (0, import_jsx_runtime346.jsxs)("div", { className: "editor-block-visibility__disabled-blocks-count", children: [ 50751 (0, import_i18n226.sprintf)( 50752 /* translators: %d: number of blocks. */ 50753 (0, import_i18n226._n)( 50754 "%d block is hidden.", 50755 "%d blocks are hidden.", 50756 numberOfHiddenBlocks 50757 ), 50758 numberOfHiddenBlocks 50759 ), 50760 /* @__PURE__ */ (0, import_jsx_runtime346.jsx)( 50761 import_components215.Button, 50762 { 50763 __next40pxDefaultSize: true, 50764 variant: "link", 50765 onClick: enableAllBlockTypes, 50766 children: (0, import_i18n226.__)("Reset") 50767 } 50768 ) 50769 ] }), 50770 /* @__PURE__ */ (0, import_jsx_runtime346.jsx)( 50771 BlockManager, 50772 { 50773 blockTypes: filteredBlockTypes, 50774 selectedBlockTypes, 50775 onChange: onChangeSelectedBlockTypes, 50776 showSelectAll: false 50777 } 50778 ) 50779 ] }); 50780 } 50781 50782 // packages/editor/build-module/components/preferences-modal/index.js 50783 var import_jsx_runtime347 = __toESM(require_jsx_runtime()); 50784 var { 50785 PreferencesModal, 50786 PreferencesModalTabs, 50787 PreferencesModalSection, 50788 PreferenceToggleControl 50789 } = unlock(import_preferences29.privateApis); 50790 function EditorPreferencesModal({ extraSections = {} }) { 50791 const isActive = (0, import_data232.useSelect)((select5) => { 50792 return select5(store2).isModalActive("editor/preferences"); 50793 }, []); 50794 const { closeModal: closeModal2 } = (0, import_data232.useDispatch)(store2); 50795 if (!isActive) { 50796 return null; 50797 } 50798 return /* @__PURE__ */ (0, import_jsx_runtime347.jsx)(PreferencesModal, { closeModal: closeModal2, children: /* @__PURE__ */ (0, import_jsx_runtime347.jsx)(PreferencesModalContents, { extraSections }) }); 50799 } 50800 function PreferencesModalContents({ extraSections = {} }) { 50801 const isLargeViewport = (0, import_compose63.useViewportMatch)("medium"); 50802 const showBlockBreadcrumbsOption = (0, import_data232.useSelect)( 50803 (select5) => { 50804 const { getEditorSettings: getEditorSettings2 } = select5(store); 50805 const { get } = select5(import_preferences29.store); 50806 const isRichEditingEnabled = getEditorSettings2().richEditingEnabled; 50807 const isDistractionFreeEnabled = get("core", "distractionFree"); 50808 return !isDistractionFreeEnabled && isLargeViewport && isRichEditingEnabled; 50809 }, 50810 [isLargeViewport] 50811 ); 50812 const { setIsListViewOpened: setIsListViewOpened2, setIsInserterOpened: setIsInserterOpened2 } = (0, import_data232.useDispatch)(store); 50813 const { set: setPreference } = (0, import_data232.useDispatch)(import_preferences29.store); 50814 const sections = (0, import_element176.useMemo)( 50815 () => [ 50816 { 50817 name: "general", 50818 tabLabel: (0, import_i18n227.__)("General"), 50819 content: /* @__PURE__ */ (0, import_jsx_runtime347.jsxs)(import_jsx_runtime347.Fragment, { children: [ 50820 /* @__PURE__ */ (0, import_jsx_runtime347.jsxs)( 50821 PreferencesModalSection, 50822 { 50823 title: (0, import_i18n227.__)("Interface"), 50824 children: [ 50825 /* @__PURE__ */ (0, import_jsx_runtime347.jsx)( 50826 PreferenceToggleControl, 50827 { 50828 scope: "core", 50829 featureName: "showListViewByDefault", 50830 help: (0, import_i18n227.__)( 50831 "Opens the List View panel by default." 50832 ), 50833 label: (0, import_i18n227.__)("Always open List View") 50834 } 50835 ), 50836 showBlockBreadcrumbsOption && /* @__PURE__ */ (0, import_jsx_runtime347.jsx)( 50837 PreferenceToggleControl, 50838 { 50839 scope: "core", 50840 featureName: "showBlockBreadcrumbs", 50841 help: (0, import_i18n227.__)( 50842 "Display the block hierarchy trail at the bottom of the editor." 50843 ), 50844 label: (0, import_i18n227.__)("Show block breadcrumbs") 50845 } 50846 ), 50847 /* @__PURE__ */ (0, import_jsx_runtime347.jsx)( 50848 PreferenceToggleControl, 50849 { 50850 scope: "core", 50851 featureName: "allowRightClickOverrides", 50852 help: (0, import_i18n227.__)( 50853 "Allows contextual List View menus via right-click, overriding browser defaults." 50854 ), 50855 label: (0, import_i18n227.__)( 50856 "Allow right-click contextual menus" 50857 ) 50858 } 50859 ), 50860 /* @__PURE__ */ (0, import_jsx_runtime347.jsx)( 50861 PreferenceToggleControl, 50862 { 50863 scope: "core", 50864 featureName: "enableChoosePatternModal", 50865 help: (0, import_i18n227.__)( 50866 "Pick from starter content when creating a new page." 50867 ), 50868 label: (0, import_i18n227.__)("Show starter patterns") 50869 } 50870 ) 50871 ] 50872 } 50873 ), 50874 /* @__PURE__ */ (0, import_jsx_runtime347.jsxs)( 50875 PreferencesModalSection, 50876 { 50877 title: (0, import_i18n227.__)("Document settings"), 50878 description: (0, import_i18n227.__)( 50879 "Select what settings are shown in the document panel." 50880 ), 50881 children: [ 50882 /* @__PURE__ */ (0, import_jsx_runtime347.jsx)(enable_plugin_document_setting_panel_default.Slot, {}), 50883 /* @__PURE__ */ (0, import_jsx_runtime347.jsx)( 50884 post_taxonomies_default, 50885 { 50886 taxonomyWrapper: (content, taxonomy) => /* @__PURE__ */ (0, import_jsx_runtime347.jsx)( 50887 EnablePanelOption, 50888 { 50889 label: taxonomy.labels.menu_name, 50890 panelName: `taxonomy-panel-$taxonomy.slug}` 50891 } 50892 ) 50893 } 50894 ), 50895 /* @__PURE__ */ (0, import_jsx_runtime347.jsx)(check_default4, { children: /* @__PURE__ */ (0, import_jsx_runtime347.jsx)( 50896 EnablePanelOption, 50897 { 50898 label: (0, import_i18n227.__)("Featured image"), 50899 panelName: "featured-image" 50900 } 50901 ) }), 50902 /* @__PURE__ */ (0, import_jsx_runtime347.jsx)(check_default3, { children: /* @__PURE__ */ (0, import_jsx_runtime347.jsx)( 50903 EnablePanelOption, 50904 { 50905 label: (0, import_i18n227.__)("Excerpt"), 50906 panelName: "post-excerpt" 50907 } 50908 ) }), 50909 /* @__PURE__ */ (0, import_jsx_runtime347.jsx)( 50910 post_type_support_check_default, 50911 { 50912 supportKeys: ["comments", "trackbacks"], 50913 children: /* @__PURE__ */ (0, import_jsx_runtime347.jsx)( 50914 EnablePanelOption, 50915 { 50916 label: (0, import_i18n227.__)("Discussion"), 50917 panelName: "discussion-panel" 50918 } 50919 ) 50920 } 50921 ), 50922 /* @__PURE__ */ (0, import_jsx_runtime347.jsx)(check_default2, { children: /* @__PURE__ */ (0, import_jsx_runtime347.jsx)( 50923 EnablePanelOption, 50924 { 50925 label: (0, import_i18n227.__)("Page attributes"), 50926 panelName: "page-attributes" 50927 } 50928 ) }) 50929 ] 50930 } 50931 ), 50932 isLargeViewport && /* @__PURE__ */ (0, import_jsx_runtime347.jsx)( 50933 PreferencesModalSection, 50934 { 50935 title: (0, import_i18n227.__)("Publishing"), 50936 children: /* @__PURE__ */ (0, import_jsx_runtime347.jsx)( 50937 EnablePublishSidebarOption, 50938 { 50939 help: (0, import_i18n227.__)( 50940 "Review settings, such as visibility and tags." 50941 ), 50942 label: (0, import_i18n227.__)( 50943 "Enable pre-publish checks" 50944 ) 50945 } 50946 ) 50947 } 50948 ), 50949 extraSections?.general 50950 ] }) 50951 }, 50952 { 50953 name: "appearance", 50954 tabLabel: (0, import_i18n227.__)("Appearance"), 50955 content: /* @__PURE__ */ (0, import_jsx_runtime347.jsxs)( 50956 PreferencesModalSection, 50957 { 50958 title: (0, import_i18n227.__)("Appearance"), 50959 description: (0, import_i18n227.__)( 50960 "Customize the editor interface to suit your needs." 50961 ), 50962 children: [ 50963 /* @__PURE__ */ (0, import_jsx_runtime347.jsx)( 50964 PreferenceToggleControl, 50965 { 50966 scope: "core", 50967 featureName: "fixedToolbar", 50968 onToggle: () => setPreference( 50969 "core", 50970 "distractionFree", 50971 false 50972 ), 50973 help: (0, import_i18n227.__)( 50974 "Access all block and document tools in a single place." 50975 ), 50976 label: (0, import_i18n227.__)("Top toolbar") 50977 } 50978 ), 50979 /* @__PURE__ */ (0, import_jsx_runtime347.jsx)( 50980 PreferenceToggleControl, 50981 { 50982 scope: "core", 50983 featureName: "distractionFree", 50984 onToggle: () => { 50985 setPreference( 50986 "core", 50987 "fixedToolbar", 50988 true 50989 ); 50990 setIsInserterOpened2(false); 50991 setIsListViewOpened2(false); 50992 }, 50993 help: (0, import_i18n227.__)( 50994 "Reduce visual distractions by hiding the toolbar and other elements to focus on writing." 50995 ), 50996 label: (0, import_i18n227.__)("Distraction free") 50997 } 50998 ), 50999 /* @__PURE__ */ (0, import_jsx_runtime347.jsx)( 51000 PreferenceToggleControl, 51001 { 51002 scope: "core", 51003 featureName: "focusMode", 51004 help: (0, import_i18n227.__)( 51005 "Highlights the current block and fades other content." 51006 ), 51007 label: (0, import_i18n227.__)("Spotlight mode") 51008 } 51009 ), 51010 extraSections?.appearance 51011 ] 51012 } 51013 ) 51014 }, 51015 { 51016 name: "accessibility", 51017 tabLabel: (0, import_i18n227.__)("Accessibility"), 51018 content: /* @__PURE__ */ (0, import_jsx_runtime347.jsxs)(import_jsx_runtime347.Fragment, { children: [ 51019 /* @__PURE__ */ (0, import_jsx_runtime347.jsx)( 51020 PreferencesModalSection, 51021 { 51022 title: (0, import_i18n227.__)("Navigation"), 51023 description: (0, import_i18n227.__)( 51024 "Optimize the editing experience for enhanced control." 51025 ), 51026 children: /* @__PURE__ */ (0, import_jsx_runtime347.jsx)( 51027 PreferenceToggleControl, 51028 { 51029 scope: "core", 51030 featureName: "keepCaretInsideBlock", 51031 help: (0, import_i18n227.__)( 51032 "Keeps the text cursor within blocks while navigating with arrow keys, preventing it from moving to other blocks and enhancing accessibility for keyboard users." 51033 ), 51034 label: (0, import_i18n227.__)( 51035 "Contain text cursor inside block" 51036 ) 51037 } 51038 ) 51039 } 51040 ), 51041 /* @__PURE__ */ (0, import_jsx_runtime347.jsx)( 51042 PreferencesModalSection, 51043 { 51044 title: (0, import_i18n227.__)("Interface"), 51045 children: /* @__PURE__ */ (0, import_jsx_runtime347.jsx)( 51046 PreferenceToggleControl, 51047 { 51048 scope: "core", 51049 featureName: "showIconLabels", 51050 label: (0, import_i18n227.__)("Show button text labels"), 51051 help: (0, import_i18n227.__)( 51052 "Show text instead of icons on buttons across the interface." 51053 ) 51054 } 51055 ) 51056 } 51057 ) 51058 ] }) 51059 }, 51060 { 51061 name: "blocks", 51062 tabLabel: (0, import_i18n227.__)("Blocks"), 51063 content: /* @__PURE__ */ (0, import_jsx_runtime347.jsxs)(import_jsx_runtime347.Fragment, { children: [ 51064 /* @__PURE__ */ (0, import_jsx_runtime347.jsx)(PreferencesModalSection, { title: (0, import_i18n227.__)("Inserter"), children: /* @__PURE__ */ (0, import_jsx_runtime347.jsx)( 51065 PreferenceToggleControl, 51066 { 51067 scope: "core", 51068 featureName: "mostUsedBlocks", 51069 help: (0, import_i18n227.__)( 51070 "Adds a category with the most frequently used blocks in the inserter." 51071 ), 51072 label: (0, import_i18n227.__)("Show most used blocks") 51073 } 51074 ) }), 51075 /* @__PURE__ */ (0, import_jsx_runtime347.jsx)( 51076 PreferencesModalSection, 51077 { 51078 title: (0, import_i18n227.__)("Manage block visibility"), 51079 description: (0, import_i18n227.__)( 51080 "Disable blocks that you don't want to appear in the inserter. They can always be toggled back on later." 51081 ), 51082 children: /* @__PURE__ */ (0, import_jsx_runtime347.jsx)(BlockVisibility, {}) 51083 } 51084 ) 51085 ] }) 51086 }, 51087 window.__experimentalMediaProcessing && { 51088 name: "media", 51089 tabLabel: (0, import_i18n227.__)("Media"), 51090 content: /* @__PURE__ */ (0, import_jsx_runtime347.jsx)(import_jsx_runtime347.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime347.jsxs)( 51091 PreferencesModalSection, 51092 { 51093 title: (0, import_i18n227.__)("General"), 51094 description: (0, import_i18n227.__)( 51095 "Customize options related to the media upload flow." 51096 ), 51097 children: [ 51098 /* @__PURE__ */ (0, import_jsx_runtime347.jsx)( 51099 PreferenceToggleControl, 51100 { 51101 scope: "core/media", 51102 featureName: "optimizeOnUpload", 51103 help: (0, import_i18n227.__)( 51104 "Compress media items before uploading to the server." 51105 ), 51106 label: (0, import_i18n227.__)("Pre-upload compression") 51107 } 51108 ), 51109 /* @__PURE__ */ (0, import_jsx_runtime347.jsx)( 51110 PreferenceToggleControl, 51111 { 51112 scope: "core/media", 51113 featureName: "requireApproval", 51114 help: (0, import_i18n227.__)( 51115 "Require approval step when optimizing existing media." 51116 ), 51117 label: (0, import_i18n227.__)("Approval step") 51118 } 51119 ) 51120 ] 51121 } 51122 ) }) 51123 } 51124 ].filter(Boolean), 51125 [ 51126 showBlockBreadcrumbsOption, 51127 extraSections, 51128 setIsInserterOpened2, 51129 setIsListViewOpened2, 51130 setPreference, 51131 isLargeViewport 51132 ] 51133 ); 51134 return /* @__PURE__ */ (0, import_jsx_runtime347.jsx)(PreferencesModalTabs, { sections }); 51135 } 51136 51137 // packages/editor/build-module/components/post-fields/index.js 51138 var import_element177 = __toESM(require_element()); 51139 var import_data233 = __toESM(require_data()); 51140 function usePostFields({ 51141 postType: postType2 51142 }) { 51143 const { registerPostTypeSchema: registerPostTypeSchema2 } = unlock((0, import_data233.useDispatch)(store)); 51144 (0, import_element177.useEffect)(() => { 51145 registerPostTypeSchema2(postType2); 51146 }, [registerPostTypeSchema2, postType2]); 51147 const { fields: fields2 } = (0, import_data233.useSelect)( 51148 (select5) => { 51149 const { getEntityFields: getEntityFields3 } = unlock(select5(store)); 51150 return { 51151 fields: getEntityFields3("postType", postType2) 51152 }; 51153 }, 51154 [postType2] 51155 ); 51156 return fields2; 51157 } 51158 var post_fields_default = usePostFields; 51159 51160 // packages/editor/build-module/bindings/api.js 51161 var import_blocks38 = __toESM(require_blocks()); 51162 51163 // packages/editor/build-module/bindings/pattern-overrides.js 51164 var import_block_editor100 = __toESM(require_block_editor()); 51165 var CONTENT = "content"; 51166 var pattern_overrides_default = { 51167 name: "core/pattern-overrides", 51168 getValues({ select: select5, clientId, context, bindings }) { 51169 const patternOverridesContent = context["pattern/overrides"]; 51170 const { getBlockAttributes: getBlockAttributes2 } = select5(import_block_editor100.store); 51171 const currentBlockAttributes = getBlockAttributes2(clientId); 51172 const overridesValues = {}; 51173 for (const attributeName of Object.keys(bindings)) { 51174 const overridableValue = patternOverridesContent?.[currentBlockAttributes?.metadata?.name]?.[attributeName]; 51175 if (overridableValue === void 0) { 51176 overridesValues[attributeName] = currentBlockAttributes[attributeName]; 51177 continue; 51178 } else { 51179 overridesValues[attributeName] = overridableValue === "" ? void 0 : overridableValue; 51180 } 51181 } 51182 return overridesValues; 51183 }, 51184 setValues({ select: select5, dispatch: dispatch6, clientId, bindings }) { 51185 const { getBlockAttributes: getBlockAttributes2, getBlockParentsByBlockName, getBlocks: getBlocks2 } = select5(import_block_editor100.store); 51186 const currentBlockAttributes = getBlockAttributes2(clientId); 51187 const blockName = currentBlockAttributes?.metadata?.name; 51188 if (!blockName) { 51189 return; 51190 } 51191 const [patternClientId] = getBlockParentsByBlockName( 51192 clientId, 51193 "core/block", 51194 true 51195 ); 51196 const attributes = Object.entries(bindings).reduce( 51197 (attrs, [key, { newValue }]) => { 51198 attrs[key] = newValue; 51199 return attrs; 51200 }, 51201 {} 51202 ); 51203 if (!patternClientId) { 51204 const syncBlocksWithSameName = (blocks) => { 51205 for (const block of blocks) { 51206 if (block.attributes?.metadata?.name === blockName) { 51207 dispatch6(import_block_editor100.store).updateBlockAttributes( 51208 block.clientId, 51209 attributes 51210 ); 51211 } 51212 syncBlocksWithSameName(block.innerBlocks); 51213 } 51214 }; 51215 syncBlocksWithSameName(getBlocks2()); 51216 return; 51217 } 51218 const currentBindingValue = getBlockAttributes2(patternClientId)?.[CONTENT]; 51219 dispatch6(import_block_editor100.store).updateBlockAttributes(patternClientId, { 51220 [CONTENT]: { 51221 ...currentBindingValue, 51222 [blockName]: { 51223 ...currentBindingValue?.[blockName], 51224 ...Object.entries(attributes).reduce( 51225 (acc, [key, value]) => { 51226 acc[key] = value === void 0 ? "" : value; 51227 return acc; 51228 }, 51229 {} 51230 ) 51231 } 51232 } 51233 }); 51234 }, 51235 canUserEditValue: () => true 51236 }; 51237 51238 // packages/editor/build-module/bindings/post-data.js 51239 var import_i18n228 = __toESM(require_i18n()); 51240 var import_core_data122 = __toESM(require_core_data()); 51241 var import_block_editor101 = __toESM(require_block_editor()); 51242 var NAVIGATION_BLOCK_TYPES = [ 51243 "core/navigation-link", 51244 "core/navigation-submenu" 51245 ]; 51246 var postDataFields = [ 51247 { 51248 label: (0, import_i18n228.__)("Post Date"), 51249 args: { field: "date" }, 51250 type: "string" 51251 }, 51252 { 51253 label: (0, import_i18n228.__)("Post Modified Date"), 51254 args: { field: "modified" }, 51255 type: "string" 51256 }, 51257 { 51258 label: (0, import_i18n228.__)("Post Link"), 51259 args: { field: "link" }, 51260 type: "string" 51261 } 51262 ]; 51263 var post_data_default = { 51264 name: "core/post-data", 51265 getValues({ select: select5, context, bindings, clientId }) { 51266 const { getBlockAttributes: getBlockAttributes2, getBlockName: getBlockName2 } = select5(import_block_editor101.store); 51267 const blockName = getBlockName2(clientId); 51268 const isNavigationBlock = NAVIGATION_BLOCK_TYPES.includes(blockName); 51269 let postId2, postType2; 51270 if (isNavigationBlock) { 51271 const blockAttributes = getBlockAttributes2(clientId); 51272 postId2 = blockAttributes?.id; 51273 postType2 = blockAttributes?.type; 51274 } else { 51275 postId2 = context?.postId; 51276 postType2 = context?.postType; 51277 } 51278 const { getEditedEntityRecord } = select5(import_core_data122.store); 51279 const entityDataValues = getEditedEntityRecord( 51280 "postType", 51281 postType2, 51282 postId2 51283 ); 51284 const newValues = {}; 51285 for (const [attributeName, binding] of Object.entries(bindings)) { 51286 const postDataField = postDataFields.find( 51287 (field) => field.args.field === binding.args.field 51288 ); 51289 if (!postDataField) { 51290 newValues[attributeName] = binding.args.field; 51291 } else if (!entityDataValues) { 51292 newValues[attributeName] = postDataField.label; 51293 } else { 51294 newValues[attributeName] = entityDataValues[binding.args.field]; 51295 } 51296 } 51297 return newValues; 51298 }, 51299 setValues({ dispatch: dispatch6, context, bindings, clientId, select: select5 }) { 51300 const { getBlockName: getBlockName2 } = select5(import_block_editor101.store); 51301 const blockName = getBlockName2(clientId); 51302 if (NAVIGATION_BLOCK_TYPES.includes(blockName)) { 51303 return false; 51304 } 51305 const newData = {}; 51306 Object.values(bindings).forEach(({ args, newValue }) => { 51307 newData[args.field] = newValue; 51308 }); 51309 dispatch6(import_core_data122.store).editEntityRecord( 51310 "postType", 51311 context?.postType, 51312 context?.postId, 51313 newData 51314 ); 51315 }, 51316 canUserEditValue({ select: select5, context }) { 51317 const { getBlockName: getBlockName2, getSelectedBlockClientId: getSelectedBlockClientId2 } = select5(import_block_editor101.store); 51318 const clientId = getSelectedBlockClientId2(); 51319 const blockName = getBlockName2(clientId); 51320 if (NAVIGATION_BLOCK_TYPES.includes(blockName)) { 51321 return false; 51322 } 51323 if (context?.query || context?.queryId) { 51324 return false; 51325 } 51326 if (!context?.postType) { 51327 return false; 51328 } 51329 const canUserEdit = select5(import_core_data122.store).canUser("update", { 51330 kind: "postType", 51331 name: context?.postType, 51332 id: context?.postId 51333 }); 51334 if (!canUserEdit) { 51335 return false; 51336 } 51337 return true; 51338 }, 51339 getFieldsList({ context, select: select5 }) { 51340 const selectedBlock = select5(import_block_editor101.store).getSelectedBlock(); 51341 if (selectedBlock?.name !== "core/post-date") { 51342 return []; 51343 } 51344 if (!context || !context.postId || !context.postType) { 51345 return []; 51346 } 51347 return postDataFields; 51348 } 51349 }; 51350 51351 // packages/editor/build-module/bindings/post-meta.js 51352 var import_core_data123 = __toESM(require_core_data()); 51353 function getPostMetaFields(select5, context) { 51354 const { getRegisteredPostMeta } = unlock(select5(import_core_data123.store)); 51355 const registeredFields = getRegisteredPostMeta(context?.postType); 51356 const metaFields = []; 51357 Object.entries(registeredFields).forEach(([key, props]) => { 51358 if (key === "footnotes" || key.charAt(0) === "_") { 51359 return; 51360 } 51361 metaFields.push({ 51362 label: props.title || key, 51363 args: { key }, 51364 default: props.default, 51365 type: props.type 51366 }); 51367 }); 51368 return metaFields; 51369 } 51370 function getValue({ select: select5, context, args }) { 51371 const metaFields = getPostMetaFields(select5, context); 51372 const metaField = metaFields.find( 51373 (field) => field.args.key === args.key 51374 ); 51375 if (!metaField) { 51376 return args.key; 51377 } 51378 if (!context?.postId) { 51379 return metaField.default || metaField.label || args.key; 51380 } 51381 const { getEditedEntityRecord } = select5(import_core_data123.store); 51382 const entityMetaValues = getEditedEntityRecord( 51383 "postType", 51384 context?.postType, 51385 context?.postId 51386 ).meta; 51387 return entityMetaValues?.[args.key] ?? metaField?.label ?? args.key; 51388 } 51389 var post_meta_default = { 51390 name: "core/post-meta", 51391 getValues({ select: select5, context, bindings }) { 51392 const newValues = {}; 51393 for (const [attributeName, binding] of Object.entries(bindings)) { 51394 newValues[attributeName] = getValue({ 51395 select: select5, 51396 context, 51397 args: binding.args 51398 }); 51399 } 51400 return newValues; 51401 }, 51402 setValues({ dispatch: dispatch6, context, bindings }) { 51403 const newMeta = {}; 51404 Object.values(bindings).forEach(({ args, newValue }) => { 51405 newMeta[args.key] = newValue; 51406 }); 51407 dispatch6(import_core_data123.store).editEntityRecord( 51408 "postType", 51409 context?.postType, 51410 context?.postId, 51411 { 51412 meta: newMeta 51413 } 51414 ); 51415 }, 51416 canUserEditValue({ select: select5, context, args }) { 51417 if (context?.query || context?.queryId) { 51418 return false; 51419 } 51420 if (!context?.postType) { 51421 return false; 51422 } 51423 const metaFields = getPostMetaFields(select5, context); 51424 const hasMatchingMetaField = metaFields.some( 51425 (field) => field.args.key === args.key 51426 ); 51427 if (!hasMatchingMetaField) { 51428 return false; 51429 } 51430 const areCustomFieldsEnabled = select5(store).getEditorSettings().enableCustomFields; 51431 if (areCustomFieldsEnabled) { 51432 return false; 51433 } 51434 const canUserEdit = select5(import_core_data123.store).canUser("update", { 51435 kind: "postType", 51436 name: context?.postType, 51437 id: context?.postId 51438 }); 51439 if (!canUserEdit) { 51440 return false; 51441 } 51442 return true; 51443 }, 51444 getFieldsList({ select: select5, context }) { 51445 const metaFields = getPostMetaFields(select5, context); 51446 return metaFields.map( 51447 ({ default: defaultProp, ...otherProps }) => ({ 51448 ...otherProps 51449 }) 51450 ); 51451 } 51452 }; 51453 51454 // packages/editor/build-module/bindings/term-data.js 51455 var import_i18n229 = __toESM(require_i18n()); 51456 var import_core_data124 = __toESM(require_core_data()); 51457 var import_block_editor102 = __toESM(require_block_editor()); 51458 var NAVIGATION_BLOCK_TYPES2 = [ 51459 "core/navigation-link", 51460 "core/navigation-submenu" 51461 ]; 51462 var termDataFields = [ 51463 { 51464 label: (0, import_i18n229.__)("Term ID"), 51465 args: { field: "id" }, 51466 type: "string" 51467 }, 51468 { 51469 label: (0, import_i18n229.__)("Name"), 51470 args: { field: "name" }, 51471 type: "string" 51472 }, 51473 { 51474 label: (0, import_i18n229.__)("Slug"), 51475 args: { field: "slug" }, 51476 type: "string" 51477 }, 51478 { 51479 label: (0, import_i18n229.__)("Link"), 51480 args: { field: "link" }, 51481 type: "string" 51482 }, 51483 { 51484 label: (0, import_i18n229.__)("Description"), 51485 args: { field: "description" }, 51486 type: "string" 51487 }, 51488 { 51489 label: (0, import_i18n229.__)("Parent ID"), 51490 args: { field: "parent" }, 51491 type: "string" 51492 }, 51493 { 51494 label: (0, import_i18n229.__)("Count"), 51495 args: { field: "count" }, 51496 type: "string" 51497 } 51498 ]; 51499 var term_data_default = { 51500 name: "core/term-data", 51501 usesContext: ["taxonomy", "termId", "termData"], 51502 getValues({ select: select5, context, bindings, clientId }) { 51503 const { getEntityRecord } = select5(import_core_data124.store); 51504 const { getBlockAttributes: getBlockAttributes2, getBlockName: getBlockName2 } = select5(import_block_editor102.store); 51505 const blockName = getBlockName2(clientId); 51506 const isNavigationBlock = NAVIGATION_BLOCK_TYPES2.includes(blockName); 51507 let termDataValues; 51508 if (isNavigationBlock) { 51509 const blockAttributes = getBlockAttributes2(clientId); 51510 const typeFromAttributes = blockAttributes?.type; 51511 const taxonomy = typeFromAttributes === "tag" ? "post_tag" : typeFromAttributes; 51512 termDataValues = getEntityRecord( 51513 "taxonomy", 51514 taxonomy, 51515 blockAttributes?.id 51516 ); 51517 } else if (context.termId && context.taxonomy) { 51518 termDataValues = getEntityRecord( 51519 "taxonomy", 51520 context.taxonomy, 51521 context.termId 51522 ); 51523 } 51524 if (!termDataValues && context?.termData && !isNavigationBlock) { 51525 termDataValues = context.termData; 51526 } 51527 const newValues = {}; 51528 for (const [attributeName, binding] of Object.entries(bindings)) { 51529 const termDataField = termDataFields.find( 51530 (field) => field.args.field === binding.args.field 51531 ); 51532 if (!termDataField) { 51533 newValues[attributeName] = binding.args.field; 51534 } else if (!termDataValues || termDataValues[binding.args.field] === void 0) { 51535 newValues[attributeName] = termDataField.label; 51536 } else if (binding.args.field === "count") { 51537 newValues[attributeName] = "(" + termDataValues[binding.args.field] + ")"; 51538 } else { 51539 newValues[attributeName] = termDataValues[binding.args.field]; 51540 } 51541 } 51542 return newValues; 51543 }, 51544 // eslint-disable-next-line no-unused-vars 51545 setValues({ dispatch: dispatch6, context, bindings }) { 51546 return false; 51547 }, 51548 canUserEditValue({ select: select5, context }) { 51549 const { getBlockName: getBlockName2, getSelectedBlockClientId: getSelectedBlockClientId2 } = select5(import_block_editor102.store); 51550 const clientId = getSelectedBlockClientId2(); 51551 const blockName = getBlockName2(clientId); 51552 if (NAVIGATION_BLOCK_TYPES2.includes(blockName)) { 51553 return false; 51554 } 51555 if (context?.termQuery) { 51556 return false; 51557 } 51558 if (!context?.taxonomy || !context?.termId) { 51559 return false; 51560 } 51561 return false; 51562 }, 51563 getFieldsList({ context, select: select5 }) { 51564 const { getBlockAttributes: getBlockAttributes2, getBlockName: getBlockName2, getSelectedBlockClientId: getSelectedBlockClientId2 } = select5(import_block_editor102.store); 51565 const clientId = getSelectedBlockClientId2(); 51566 const blockName = getBlockName2(clientId); 51567 if (NAVIGATION_BLOCK_TYPES2.includes(blockName)) { 51568 const blockAttributes = getBlockAttributes2(clientId); 51569 if (!blockAttributes || !blockAttributes.id || !blockAttributes.type) { 51570 return []; 51571 } 51572 return termDataFields; 51573 } 51574 if (!context) { 51575 return []; 51576 } 51577 if (context.taxonomy && context.termId || context.termData) { 51578 return termDataFields; 51579 } 51580 return []; 51581 } 51582 }; 51583 51584 // packages/editor/build-module/bindings/api.js 51585 function registerCoreBlockBindingsSources() { 51586 (0, import_blocks38.registerBlockBindingsSource)(pattern_overrides_default); 51587 (0, import_blocks38.registerBlockBindingsSource)(post_data_default); 51588 (0, import_blocks38.registerBlockBindingsSource)(post_meta_default); 51589 (0, import_blocks38.registerBlockBindingsSource)(term_data_default); 51590 } 51591 51592 // packages/editor/build-module/private-apis.js 51593 var { store: interfaceStore, ...remainingInterfaceApis } = build_module_exports; 51594 var privateApis3 = {}; 51595 lock(privateApis3, { 51596 CreateTemplatePartModal, 51597 patternTitleField: pattern_title_default, 51598 templateTitleField: template_title_default, 51599 BackButton: back_button_default, 51600 EntitiesSavedStatesExtensible, 51601 Editor: editor_default, 51602 PluginPostExcerpt: plugin_default, 51603 PostCardPanel, 51604 PreferencesModal: EditorPreferencesModal, 51605 usePostActions, 51606 usePostFields: post_fields_default, 51607 ToolsMoreMenuGroup: tools_more_menu_group_default, 51608 ViewMoreMenuGroup: view_more_menu_group_default, 51609 ResizableEditor: resizable_editor_default, 51610 registerCoreBlockBindingsSources, 51611 getTemplateInfo, 51612 // Global Styles 51613 GlobalStylesUIWrapper, 51614 GlobalStylesActionMenu, 51615 StyleBookPreview, 51616 useGlobalStyles, 51617 useStyle: useStyle2, 51618 // Block selection 51619 useGenerateBlockPath, 51620 useRestoreBlockFromPath, 51621 // This is a temporary private API while we're updating the site editor to use EditorProvider. 51622 interfaceStore, 51623 ...remainingInterfaceApis 51624 }); 51625 51626 // packages/editor/build-module/dataviews/api.js 51627 var import_data234 = __toESM(require_data()); 51628 function registerEntityAction2(kind, name2, config) { 51629 const { registerEntityAction: _registerEntityAction } = unlock( 51630 (0, import_data234.dispatch)(store) 51631 ); 51632 if (false) { 51633 _registerEntityAction(kind, name2, config); 51634 } 51635 } 51636 function unregisterEntityAction2(kind, name2, actionId) { 51637 const { unregisterEntityAction: _unregisterEntityAction } = unlock( 51638 (0, import_data234.dispatch)(store) 51639 ); 51640 if (false) { 51641 _unregisterEntityAction(kind, name2, actionId); 51642 } 51643 } 51644 function registerEntityField2(kind, name2, config) { 51645 const { registerEntityField: _registerEntityField } = unlock( 51646 (0, import_data234.dispatch)(store) 51647 ); 51648 if (false) { 51649 _registerEntityField(kind, name2, config); 51650 } 51651 } 51652 function unregisterEntityField2(kind, name2, fieldId) { 51653 const { unregisterEntityField: _unregisterEntityField } = unlock( 51654 (0, import_data234.dispatch)(store) 51655 ); 51656 if (false) { 51657 _unregisterEntityField(kind, name2, fieldId); 51658 } 51659 } 51660 51661 // packages/editor/build-module/index.js 51662 var import_block_editor103 = __toESM(require_block_editor()); 51663 return __toCommonJS(index_exports); 51664 })(); 51665 /*! Bundled license information: 51666 51667 react-is/cjs/react-is.development.js: 51668 (** @license React v16.13.1 51669 * react-is.development.js 51670 * 51671 * Copyright (c) Facebook, Inc. and its affiliates. 51672 * 51673 * This source code is licensed under the MIT license found in the 51674 * LICENSE file in the root directory of this source tree. 51675 *) 51676 51677 object-assign/index.js: 51678 (* 51679 object-assign 51680 (c) Sindre Sorhus 51681 @license MIT 51682 *) 51683 51684 autosize/dist/autosize.js: 51685 (*! 51686 autosize 4.0.2 51687 license: MIT 51688 http://www.jacklmoore.com/autosize 51689 *) 51690 51691 is-plain-object/dist/is-plain-object.mjs: 51692 (*! 51693 * is-plain-object <https://github.com/jonschlinkert/is-plain-object> 51694 * 51695 * Copyright (c) 2014-2017, Jon Schlinkert. 51696 * Released under the MIT License. 51697 *) 51698 */
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated : Wed Apr 15 08:20:10 2026 | Cross-referenced by PHPXref |